@ambassify/vault-client
v4.0.4
Published
API Client for Vault service
Downloads
360
Readme
vault-client
A client for storing private information.
Installation
npm install --save @ambassify/vault-client
Usage
example
const Vault = require('@ambassify/vault-client');
const vault = new Vault({
baseUrl: 'http://my-vault-instance',
token: 'my super secure access token',
key: 'some-random-generated-key-string'
});
vault.save('my-string')
.then(id => {
console.log('Vault item at id', id);
});
vault.get(someId)
.then(value => {
console.log('Vault item contained', value);
});
API
new Vault()
const vault = new Vault(options);
Creates a new instance of a VaultClient.
- options
- baseUrl The endpoint for the vault service
- token A valid access token to authenticate with the vault service.
- key The password used to encrypt the data.
.save()
vault.save(data, [salt])
Encrypts data
using the specified key
and saves it into the vault instance and returns a promise that resolves to the id
of the vault entry.
- data Any value that can be serialized using
JSON.stringify
. - salt A salt to use in the key generation process, salt is generated if not specified.
.get()
vault.get(id)
Fetches the entry at the specified id
and decrypts it. The returnvalue is a promise that resolves to the original data inserted at id
.