A client for the HTTP API of HashiCorp's Vault written for Node.js.
make sure to use node.js version >= 6
npm install node-vault
Run tests inside docker to do also nice integration testing:
docker-compose up --force-recreate test
This will create containers for vault, postgres and running the tests inside docker.
init and unseal
var options =apiVersion: 'v1' // defaultendpoint: '' // defaulttoken: '1234' // optional client token; can be fetched after valid initialization of the server;// get new instance of the clientvar vault = options;// init vault servervault;
write, read and delete secrets
Just generate docco docs via
npm run docs.
git clone email@example.com:kr1sp1n/node-vault.gitcd node-vaultdocker-compose up vault
Now you can run the examples from another terminal window.
First of all you should initialize and unseal the vault:
You should see
root_token: followed by a long key in the response.
Please copy that long key and export it as environment variable:
export VAULT_TOKEN=<insert long key here>
Now you are able to run all of the other examples:
Connecting to vault through a bastion host
To connect to a vault server in a private network with a bastion host, you'll need to first open a connection:
ssh -D <socks4Port> bastion.example.com
const SocksProxyAgent = ;const agent = `socks://127.0.0.1:` true;const options =apiVersion: 'v1'rpOptions:agent;const vault = options;