JS SDK
This guide shows how to setup Onboardbase with our JS SDK
Installation
npm install @onboardbase/secrets
or
yarn add @onboardbase/secrets
Create a Service Token
To create a new service token, go to your organization settings page, and you will find the service token sections.
On the service token section, click Create a token, Enter an identifying name, and select a duration, a single project, and a single environment. Then click on generate to get your token.
Once a service token is generated, click on the options dropdown of the key and then click on copy to copy the newly generated key to your clipboard.
Integrate Onboardbase JS SDK
After having a service token, Import Onboardbase SDK into your project
const { Secrets } = require("@onboardbase/secrets");
Initialize the library in an IIFE, which would ensure secrets are available before they are accessed.
(async () => {
//set your onboardbase service token in your env as OBB_CRED = Service....XXXXXXXX
const secrets = await Secrets.init(process.env.OBB_CRED);
// console.log('get secrets', secrets.get()); -> logs all the secrets from onboardbase
})();
And access individual secrets using process.env.SECRET_NAME
console.log(process.env.TEST_SECRET); // -> Secret from onboardbase
Inbuilt SDK Feature
Secure fallback cache
The JavaScript SDK supports caching your secrets to a secured location on the current computer. This cache is helpful in case of an issue with communicating with Onboardbase servers to serve secrets.
Updated 9 days ago