@bluemax/vault-multitenant
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -23,3 +23,3 @@ export interface IAWSGenerateTokenOptions { | ||
export interface IKVGetSecretOptions { | ||
path: string; | ||
engineName: string; | ||
token: string; | ||
@@ -26,0 +26,0 @@ } |
@@ -6,6 +6,6 @@ import { VaultService } from '../vault.service'; | ||
constructor(vaultService: VaultService); | ||
getSecret<T = IKVGetSecretResponse>(options: IKVGetSecretOptions): Promise<T>; | ||
createSecret(options: IKVGetSecretOptions, data: IKVData): Promise<void>; | ||
deleteSecret(options: IKVGetSecretOptions): Promise<void>; | ||
listSecretKeys(options: IKVGetSecretOptions): Promise<string[]>; | ||
getSecret<T = IKVGetSecretResponse>(options: IKVGetSecretOptions, secretKey: string, version?: number): Promise<T>; | ||
createSecret(options: IKVGetSecretOptions, secretKey: string, data: IKVData, cas?: number): Promise<void>; | ||
deleteSecret(options: IKVGetSecretOptions, secretKey: string): Promise<void>; | ||
listSecretKeys(options: IKVGetSecretOptions, path?: string): Promise<string[]>; | ||
} |
@@ -11,6 +11,7 @@ "use strict"; | ||
} | ||
async getSecret(options) { | ||
async getSecret(options, secretKey, version = 1) { | ||
var _a; | ||
const result = await request_promise_native_1.default({ | ||
method: 'GET', | ||
uri: `${this.vaultService.hostname}/v1/${options.path}`, | ||
uri: `${this.vaultService.hostname}/v1/${options.engineName}/data/${secretKey}?version=${version}`, | ||
headers: { | ||
@@ -21,8 +22,8 @@ 'X-Vault-Token': options.token | ||
}); | ||
return result.data; | ||
return (_a = result.data) === null || _a === void 0 ? void 0 : _a.data; | ||
} | ||
async createSecret(options, data) { | ||
async createSecret(options, secretKey, data, cas = 0) { | ||
await request_promise_native_1.default({ | ||
method: 'POST', | ||
uri: `${this.vaultService.hostname}/v1/${options.path}`, | ||
uri: `${this.vaultService.hostname}/v1/${options.engineName}/data/${secretKey}`, | ||
headers: { | ||
@@ -32,9 +33,9 @@ 'X-Vault-Token': options.token | ||
json: true, | ||
body: data | ||
body: { data, options: { cas } } | ||
}); | ||
} | ||
async deleteSecret(options) { | ||
async deleteSecret(options, secretKey) { | ||
await request_promise_native_1.default({ | ||
method: 'DELETE', | ||
uri: `${this.vaultService.hostname}/v1/${options.path}`, | ||
uri: `${this.vaultService.hostname}/v1/${options.engineName}/metadata/${secretKey}`, | ||
headers: { | ||
@@ -46,7 +47,7 @@ 'X-Vault-Token': options.token | ||
} | ||
async listSecretKeys(options) { | ||
async listSecretKeys(options, path) { | ||
var _a; | ||
const result = await request_promise_native_1.default({ | ||
method: 'LIST', | ||
uri: `${this.vaultService.hostname}/v1/${options.path}`, | ||
uri: `${this.vaultService.hostname}/v1/${options.engineName}/metadata/${path ? path : ''}`, | ||
headers: { | ||
@@ -53,0 +54,0 @@ 'X-Vault-Token': options.token |
{ | ||
"name": "@bluemax/vault-multitenant", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "vault extension for bluemax framework", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
28126
435