node-vault
A modern JavaScript client for HashiCorp's Vault with a focus on ease-of-use.
Notable features
- Mostly type-safe
- Highly extendable and configurable
Installation
npm install @litehex/node-vault
Usage
Init and unseal vault
import { Client } from '@litehex/node-vault';
const vc = new Client({
apiVersion: 'v1',
endpoint: 'http://127.0.0.1:8200',
token: 'hv.xxxxxxxxxxxxxxxxxxxxx'
});
const init = await vc.init({ secret_shares: 1, secret_threshold: 1 });
console.log(init);
const { keys, root_token } = init;
vc.token = root_token;
const unsealed = await vc.unseal({ key: keys[0] });
console.log(unsealed);
Create KV2 engine
const success = await vc.mount({
mountPath: 'my-secret',
type: 'kv-v2'
});
console.log(success);
const info = await vc.mountInfo({ mountPath: 'my-secret' });
console.log(info);
Write, read and delete secrets
const write = await vc.write({
path: 'my-secret/data/hello',
data: { foo: 'bar' }
});
console.log(write);
const read = await vc.read({ path: 'my-secret/data/hello' });
console.log(read);
const deleted = await vc.delete({ path: 'my-secret/data/hello' });
console.log(deleted);
Check out the examples and tests directory for more examples.
Documentation
For all configuration options, please see the API docs.
Contributing
You can contribute to this project by opening an issue or a pull request
on GitHub. Feel free to contribute, we care about your ideas and
suggestions.
Relevant
License
GPL-3.0 © Shahrad Elahi