Class

VaultService

VaultService()

Vault Service

Constructor

# new VaultService()

View Source services/vault.service.js, line 8

Methods

# async authenticateWithAppRole()

Authenticates the Vault client using the AppRole method.

View Source services/vault.service.js, line 60

If the Vault client is not initialized, authentication fails, or no token is received.

Error

# close()

Closes the Vault service connections and performs cleanup.

View Source services/vault.service.js, line 251

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.

View Source services/vault.service.js, line 169

If the Vault service is not initialized or if deleting the secret fails.

Error
  • Returns true if 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.

View Source services/vault.service.js, line 132

If the Vault service is not initialized or if retrieving the secret fails.

Error
  • The secret data as a key-value record, or null if 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.

View Source services/vault.service.js, line 198

If the Vault service is not initialized or if checking the secret fails.

Error
  • true if the secret exists, false otherwise.
Promise.<boolean>

# async healthCheck() → {Promise.<boolean>}

Checks if HashiCorp Vault is healthy and accessible.

View Source services/vault.service.js, line 272

  • Returns true if Vault is healthy and accessible, false otherwise.
Promise.<boolean>

# async initialize()

Initializes the HashiCorp Vault service.

View Source services/vault.service.js, line 17

If the Vault client cannot be initialized or authentication fails.

Error

# async listKeys() → {Promise.<Array.<string>>}

Lists all keys in the HashiCorp Vault.

View Source services/vault.service.js, line 221

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.

View Source services/vault.service.js, line 104

If the Vault service is not initialized or if storing the secret fails.

Error
Promise.<void>