@secretary/core
v4.2.1
Published
Secrets Manager for NodeJS
Downloads
475
Readme
Secretary - NodeJS Secrets Management
Secretary (etymology: Keeper of secrets) provides an abstract way to manage secrets.
Currently supports the following adapters:
Installation
// If you want to use AWS Secrets Manager
$ npm install @secretary/core @secretary/aws-secrets-manager-adapter
// If you want to use Hashicorp Vault
$ npm install @secretary/core @secretary/hashicorp-vault-adapter
Check the install docs of the adapter you want to use for specific instructions.
Usage
import {Manager} from '@secretary/core';
import {Adapter} from '@secretary/aws-secrets-manager-adapter';
import {SecretsManager} from 'aws-sdk';
const manager = new Manager({
aws: new Adapter({client: new SecretsManager()})
});
Fetch Secrets
const someSecret = await manager.getSecret('some/database/secret', 'aws');
// or, aws as the first (and only) adapter in the manager, `default` is another key that works,
// which is what source getSecret defaults to
const someSecret = await manager.getSecret('some/database/secret');
console.log(someSecret.value.dsn); // redis://localhost:6379
Create Secrets
const secret = new Secret('some/database/secret', {dsn: 'redis://localhost:6379'});
await manager.putSecret(secret, 'aws');
console.log(someSecret.value.dsn); // redis://localhost:6379
Delete Secrets
const secret = await manager.getSecret('some/database/secret');
await manager.deleteSecret(secret, 'aws');
Check the usage docs of the adapter you want to use for specific instructions.