Using External Secret Source With SDK

This guide shows how you can use an external secret source with the Onboardbase JavaScript SDK

Onboardbase lets you use secrets stored anywhere - not just on our servers. If you are using Onboardbase in this way, then you are using it as a Secret injector only and not as a secure store for your secrets.

You use the sourcePath config option in the configuration object you pass to init method call to configure an external source. For example, if you have a .env file with secrets in the form KEY=VALUE and you want Onboardbase SDK to inject secrets from the file into your project, you do:

Secrets.init({
  sourcePath: '.env',
})
  .then(() => console.log(process.env))
  .catch((err) => console.log(err));

The value of source-path can be any of these three:

  • A local .env file with secrets in KEY=VALUE format
  • A JSON file in the format {"KEY": "VALUE", "KEY2": "VALUE2"}
  • A JSON Object

Using JSON File

Suppose you have a env.json file with the following content:

{
    "PORT": 3000,
    "KEY": "VALUE"
}

Then you can pass it to sourcePath as follows:


Secrets.init({
  sourcePath: 'env.json',
})
  .then(() => console.log(process.env))
  .catch((err) => console.log(err));

Using JSON Object

You can also pass in a JSON Object as the value of sourcePath as follows:

Secrets.init({
  sourcePath: [{ KEY: "VALUE" }],
})
  .then(() => console.log(process.env))
  .catch((err) => console.log(err));