Methods
# async authenticateWithAppRole()
Authenticates the Vault client using the AppRole method.
If the Vault client is not initialized, authentication fails, or no token is received.
Error
# close()
Closes the Vault service connections and performs cleanup.
If an error occurs during the cleanup process.
Error
# async deleteSecret(key) → {Promise.<boolean>}
Deletes a secret from HashiCorp Vault.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string
|
The key of the secret to delete. |
If the Vault service is not initialized or if deleting the secret fails.
Error
- Returns
trueif the deletion succeeded.
Promise.<boolean>
# async getSecret(optionalKey) → {Promise.<(Record.<string, any>|null)>}
Retrieves a secret from HashiCorp Vault, optionally using Redis cache.
Parameters:
| Name | Type | Description |
|---|---|---|
optionalKey |
string
|
The key of the secret to retrieve. Defaults to the Vault mount path if not provided. |
If the Vault service is not initialized or if retrieving the secret fails.
Error
- The secret data as a key-value record, or
nullif not found.
Promise.<(Record.<string, any>|null)>
# async hasSecret(key) → {Promise.<boolean>}
Checks if a secret exists in HashiCorp Vault.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string
|
The key of the secret to check. |
If the Vault service is not initialized or if checking the secret fails.
Error
trueif the secret exists,falseotherwise.
Promise.<boolean>
# async healthCheck() → {Promise.<boolean>}
Checks if HashiCorp Vault is healthy and accessible.
- Returns
trueif Vault is healthy and accessible,falseotherwise.
Promise.<boolean>
# async initialize()
Initializes the HashiCorp Vault service.
If the Vault client cannot be initialized or authentication fails.
Error
# async listKeys() → {Promise.<Array.<string>>}
Lists all keys in the HashiCorp Vault.
If the Vault service is not initialized or if listing the keys fails.
Error
- An array of key names in the Vault.
Promise.<Array.<string>>
# async setSecret(key, value) → {Promise.<void>}
Stores a secret in HashiCorp Vault.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string
|
The key under which to store the secret. |
value |
Record.<string, string>
|
The secret data as a record of string key-value pairs. |
If the Vault service is not initialized or if storing the secret fails.
Error
Promise.<void>