# @oneboard/node-sdk

> OneBoard Node SDK

Latest version **0.0.6** (published 2023-10-20) · 0 weekly downloads

## Install

```sh
npm install @oneboard/node-sdk
pnpm add @oneboard/node-sdk
yarn add @oneboard/node-sdk
bun add @oneboard/node-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2023-10-20 |
| First published | 2023-10-20 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | OneBoard |
| Maintainers | artemzav, grebble |

## Links

- npm: https://www.npmjs.com/package/@oneboard/node-sdk
- npm.io page: https://npm.io/package/@oneboard/node-sdk

## Dependencies (2)

- [node-rsa](https://npm.io/package/node-rsa.md) ^1.1.1
- [node-fetch](https://npm.io/package/node-fetch.md) 2

## Recent versions

- 0.0.6 (latest) — 2023-10-20

## README

# `@oneboard/node-sdk`

## Example

```javascript
import OneBoard from '@oneboard/node-sdk';

const oneBoard = new OneBoard({
    privateKey: '<PrivateKey>',
    appPublicKey: '<AppPublicKey>',
    appToken: '<Token>',
  });

const result = await oneBoard.getVerificationRequestAccessToken(<UserId>);
```

## Installing

```shell
npm install @oneboard/node-sdk
```

## Configuration

Specify configuration options when creating a OneBoard instance

##### Example

```javascript
new OneBoard({ ...options });
```

#### Options

| Option             | Type    | Required | Desciption                                                                   |
| ------------------ | ------- | -------- | ---------------------------------------------------------------------------- |
| `privateKey`       | String  | Yes      | Privet key for sign requests                                                 |
| `appPublicKey`     | String  | Yes      | Public key for your OneBoard application                                     |
| `appToken`         | String  | Yes      | OneBoard authorization token                                                 |
| `webhookSecretKey` | String  | No       | Secret key for check webhook hash sum                                        |
| `testing`          | Boolean | No       | Flag for using the test server                                               |
| `apiOrigin`        | String  | No       | You can provide custom OneBoard API url, if you use custom OneBoard instance |

## API

### getVerificationRequestAccessToken(userId, [options])

Returns an Promise with an access token for the specified `userId` to work with a verification request

- `userId` can be string or number

##### Example

```javascript
await oneBoard.getVerificationRequestAccessToken(userId, {
  ttl: 3600,
  email: 'testmail123@mail.com',
});
```

#### Options

- `ttl`: (Optional) Lifetime for access token in seconds. Defaults to `3600`.
- `email`: (Optional) Current user's mail.

### request(requestOptions) / requestSigned(requestOptions)

Send http request to OneBoard API

- `request` used for simple request
- `requestSigned` used for signed request
- Both methods use the same options and return the same response format

##### Example

```javascript
await oneBoard.requestSigned({
  path: '/api/v1/...',
  method: 'POST',
  body: {
    foo: 1,
  },
});
```

### checkWebhookHashSum(hashSum, params)

Check hash sum from webhook. Return `boolean`

- `hashSum` string from `X-App-Sig` header from webhook request
- `params` data for create test hash

##### Example

```javascript
await oneBoard.checkWebhookHashSum(
  'rAxPRgdw1AYVoKSvoRoVDVOXS7PefCgFYSZMjfmclxE=',
  {
    url: 'https://test.com/oneboard/webhook',
    timestamp: '834007431',
    body: '{...}',
  }
);
```

#### Params

| Option      | Type   | Required | Desciption                                                   |
| ----------- | ------ | -------- | ------------------------------------------------------------ |
| `url`       | String | Yes      | Full webhook url                                             |
| `timestamp` | String | Yes      | Timestamp from `X-App-Timestamp` header from webhook request |
| `body`      | String | Yes      | Webhook body                                                 |

### getWebhookHashSum(params)

Create hash sum from webhook request. Return `string`

- `params` same format as checkWebhookHashSum method

##### Example

```javascript
await oneBoard.getWebhookHashSum({
  url: 'https://test.com/oneboard/webhook',
  timestamp: '834007431',
  body: '{...}',
});
```

---
_Source: https://npm.io/package/@oneboard/node-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
