0.0.4 • Published 2 years ago

@oneboard/node-sdk v0.0.4

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

@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

OptionTypeRequiredDesciption
privateKeyStringYesPrivet key for sign requests
appPublicKeyStringYesPublic key for your OneBoard application
appTokenStringYesOneBoard authorization token
webhookSecretKeyStringNoSecret key for check webhook hash sum
testingBooleanNoFlag for using the test server
apiOriginStringNoYou 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 });

Options

  • ttl: (Optional) Lifetime for access token in seconds. Defaults to 3600.

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
  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
  await oneBoard.checkWebhookHashSum('rAxPRgdw1AYVoKSvoRoVDVOXS7PefCgFYSZMjfmclxE=', {
      url: 'https://test.com/oneboard/webhook',
      timestamp: '834007431',
      body: '{...}',
  });

Params

OptionTypeRequiredDesciption
urlStringYesFull webhook url
timestampStringYesTimestamp from X-App-Timestamp header from webhook request
bodyStringYesWebhook 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: '{...}',
  });
0.0.3

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago