README
sb-sdk
An SDK for all your ServisBOT Needs
Goal
- Lightweight SDK to interact with ServisBOTs AWS4 signed APIs across many clients including ** portal ** servisbot cli
Install
npm install --save @servisbot/sb-sdk
BREAKING CHANGES
From version 6.6.0 onwards - SB.Auth now requires two new parameters for working with lithium resources - lithiumHttpApiUrl and cognitoJwtToken 8.0.0 - Changes to AuthProfile contracts to move towards consistency with lithium
Getting Started
Auth
The Auth class requires Organization, Drawbridge Url, Bullseye Url, Virtual Assistant URL, lithiumHttpApiUrl and Credentials for aws4 signed requests.
- A function that returns the credentials
- An object containing the credentials
To work with Lithium a cognito cognitoJwtToken is required, this is the token passed to cognito to get user pool details.
SDK clients also take a client name, to help identify where SDK requests are originating from - e.g. @servisbot/myClient@1.0.0
.
As an object
const fetch = require('node-fetch') || window.fetch;
const SB = require('@servisbot/sb-sdk')(fetch, "@servisbot/myClient@1.0.0");
const auth = new SB.Auth({
organization: '<Your Organization>',
drawbridgeUrl:'<ServisBOT drawbridge url>',
bullseyeUrl:'<ServisBOT bullseye url>',
virtualAssistantUrl:'<ServisBOT virtual assistant url>',
brocaUrl:'<ServisBOT broca url>',
metrickyUrl:'<ServisBOT metricky url>',
credentials:{
accessKeyId: '<Access Key Id>',
secretAccessKey: '<Secret Access Key>',
sessionToken: '<Session Token>'
},
cognitoJwtToken: '<JWT Token>'
});
As a function, async supported
const fetch = require('node-fetch') || window.fetch;
const SB = require('@servisbot/sb-sdk')(fetch, "@servisbot/myClient@1.0.0");
const auth = new SB.Auth({
organization: '<Your Organization>',
drawbridgeUrl:'<ServisBOT drawbridge url>',
bullseyeUrl:'<ServisBOT bullseye url>',
credentials: () => async getYourCredentials(),
cognitoJwtToken: '<JWT Token>'
});