Crypto KMS
    Preparing search index...

    Class VaultKmsProvider

    HashiCorp Vault Transit secrets engine adapter.

    Uses the Vault HTTP API to provide the unified KmsProvider interface. No additional SDK dependency is required — uses native fetch.

    const provider = new VaultKmsProvider({
    address: "http://127.0.0.1:8200",
    token: "hvs.XXXXX",
    mountPath: "transit",
    });
    const key = await provider.createKey("aes256-gcm96", "encrypt");

    Implements

    Index
    name: "vault"

    Provider identifier.

    • Build a Vault API URL for the transit engine.

      Parameters

      • path: string

      Returns string

    • Common headers for Vault API requests.

      Returns Record<string, string>

    • Create a new key with the given algorithm and usage.

      Parameters

      • algorithm: string
      • usage: "encrypt" | "sign" | "wrap"
      • Optionalmetadata: Record<string, string>

      Returns Promise<KmsKeyMetadata>

    • Not supported: Vault Transit has no way to disable a key (the minimum encryption version cannot exceed the latest version). Restrict use of the key with a Vault policy instead.

      Parameters

      • keyId: string

      Returns Promise<void>

    • Delete a key. Vault Transit has no deletion window: the key and every version are destroyed at once, and data encrypted under it is lost. Pass pendingWindowDays: 0 to confirm; any other value, including none, is refused so a caller expecting a window cannot lose the key.

      Parameters

      • keyId: string
      • OptionalpendingWindowDays: number

      Returns Promise<void>

    • Encrypt plaintext, binding the encryption context.

      Parameters

      • keyId: string
      • plaintext: Uint8Array
      • Optionalcontext: Record<string, string>

      Returns Promise<KmsEncryptResult>

    • Decrypt ciphertext; the encryption context must match.

      Parameters

      • keyId: string
      • ciphertext: string
      • Optionalcontext: Record<string, string>

      Returns Promise<KmsDecryptResult>

    • Sign data. algorithm is the Transit hash algorithm (default "sha2-256"); RSA keys use Transit's default PSS padding, and Ed25519 ignores the hash.

      Parameters

      • keyId: string
      • data: Uint8Array
      • algorithm: string = "sha2-256"

      Returns Promise<KmsSignResult>

    • Verify a signature. A wrong or malformed signature returns false; lookup, permission and transport errors are thrown.

      Parameters

      • keyId: string
      • data: Uint8Array
      • signature: string
      • algorithm: string = "sha2-256"

      Returns Promise<boolean>

    • Generate a data encryption key (DEK) wrapped by the managed key.

      Parameters

      • keyId: string
      • keySpec: string = "AES_256"

      Returns Promise<{ plaintext: Uint8Array; ciphertext: string }>

    • Wrap an existing key with the managed key.

      Parameters

      • keyId: string
      • unwrappedKey: Uint8Array
      • Optionalcontext: Record<string, string>

      Returns Promise<{ wrappedKey: string; keyId: string }>

    • Unwrap a wrapped key with the managed key.

      Parameters

      • keyId: string
      • wrappedKey: string
      • Optionalcontext: Record<string, string>

      Returns Promise<{ unwrappedKey: Uint8Array; keyId: string }>