Initialize and unseal a Vault server
masterUse init() to initialize a new Vault server and unseal() to make it operational.
When initializing, you specify secret_shares and secret_threshold. The init result contains the keys needed for unsealing and a root_token for authentication. After initialization, you should set the client's token to the root_token to perform subsequent operations.
const vault = require('node-vault')({
apiVersion: 'v1',
endpoint: 'http://127.0.0.1:8200',
token: 'MY_TOKEN',
});
// init vault server
vault.init({ secret_shares: 1, secret_threshold: 1 })
.then((result) => {
const keys = result.keys;
// set token for all following requests
vault.token = result.root_token;
// unseal vault server
return vault.unseal({ secret_shares: 1, key: keys[0] });
})
.catch(console.error);