This client provides a convenient way to interact with various endpoints in Vault, such as secrets, engines, and more. Vault is a popular open-source tool used for securely storing and accessing sensitive data, such as passwords, API keys, and certificates. The client offers a range of abstractions to simplify interactions with Vault and streamline the development process. Whether you are a seasoned developer or new to the world of secrets management, this API client is a powerful tool to help you get the most out of Vault.
Table of Contents
To read the docs, visit https://hapic.tada5hi.net
npm install @hapic/vault --save
To create a configuration for the VaultClient
, a configuration must be specified,
like described in the following:
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
request: {
credentials: 'include',
},
conenctionOptions: {
host: 'https://example.com/api/v1/',
token: 'xxx',
},
// connectionString: 'xxx@https://example.com/v1/'
});
Create
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.keyValueV1.create(
'engine',
'path',
{
foo: 'bar'
}
);
GetOne
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
const data = await client.keyValueV1.getOne(
'engine',
'path',
);
console.log(data);
// { data: { foo: 'bar' }, lease_duration: 0, ... }
Delete
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.keyValueV1.delete(
'engine',
'path',
);
Create
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.keyValueV2.create(
'engine',
'path',
{
data: {
foo: 'bar'
}
}
);
GetOne
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
const data = await client.keyValueV2.getOne('engine', 'path');
console.log(data);
// { data: { data: { foo: 'bar' }, ... } }
Update
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.keyValueV2.create(
'engine',
'path',
{
data: {
baz: 'boz'
}
}
);
Delete
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.keyValueV2.delete('engine','path');
Save
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.keyValueV2.save(
'engine',
'path',
{
data: {
foo: 'bar'
}
}
);
Create
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.mount.create(
'engine',
{
type: 'kv',
generate_signing_key: true
}
);
GetMany
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
const data = await client.mount.getMany();
console.log(data);
// {
// data: {
// 'engine/': {
// type: 'kv',
// uuid: 'xxx',
// }
// },
// lease_duration: 0,
// ...
// }
GetOne
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
const data = await client.mount.getOne('engine');
console.log(data);
// { data: { type: 'kv', uuid: 'xxx' }, lease_duration: 0, ... }
Delete
import { VaultClient } from '@hapic/vault';
const client = new VaultClient({
// ...
});
await client.mount.delete('engine');
Made with 💚
Published under MIT License.