@oneboard/node-sdk
v0.0.6
Published
OneBoard Node SDK
Downloads
92
Readme
@oneboard/node-sdk
Example
import OneBoard from '@oneboard/node-sdk';
const oneBoard = new OneBoard({
privateKey: '<PrivateKey>',
appPublicKey: '<AppPublicKey>',
appToken: '<Token>',
});
const result = await oneBoard.getVerificationRequestAccessToken(<UserId>);
Installing
npm install @oneboard/node-sdk
Configuration
Specify configuration options when creating a OneBoard instance
Example
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
await oneBoard.getVerificationRequestAccessToken(userId, {
ttl: 3600,
email: '[email protected]',
});
Options
ttl
: (Optional) Lifetime for access token in seconds. Defaults to3600
.email
: (Optional) Current user's mail.
request(requestOptions) / requestSigned(requestOptions)
Send http request to OneBoard API
request
used for simple requestrequestSigned
used for signed request- Both methods use the same options and return the same response format
Example
await oneBoard.requestSigned({
path: '/api/v1/...',
method: 'POST',
body: {
foo: 1,
},
});
checkWebhookHashSum(hashSum, params)
Check hash sum from webhook. Return boolean
hashSum
string fromX-App-Sig
header from webhook requestparams
data for create test hash
Example
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
await oneBoard.getWebhookHashSum({
url: 'https://test.com/oneboard/webhook',
timestamp: '834007431',
body: '{...}',
});