node-vault
A Javascript client for the HTTP API of HashiCorp's vault with a focus on ease of use.
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'
});
vc.init({ secret_shares: 1, secret_threshold: 1 }).then((res) => {
const { keys, root_token } = res;
vc.token = root_token;
vc.unseal({ secret_shares: 1, key: keys[0] });
});
Write, read and delete secrets
vc.write({ path: 'secret/hello', data: { foo: 'bar' } }).then(() => {
vc.read({ path: 'secret/hello' }).then(({ data }) => {
console.log(data);
});
});
vc.delete({ path: 'secret/hello' });
Docs
Examples
Using a proxy or having the ability to modify the outgoing request.
import { Client } from '@litehex/node-vault';
import { ProxyAgent } from 'undici';
const agent = new ProxyAgent('http://localhost:8080');
const vc = new Client({
request: {
agent: agent,
headers: {
'X-Custom-Header': 'value'
}
}
});
License
This project is licensed under the GPLv3 License - see the LICENSE file for details