Crypto KMS
    Preparing search index...

    Class AwsKmsProvider

    AWS KMS adapter.

    Wraps the @aws-sdk/client-kms SDK to provide the unified KmsProvider interface. Install @aws-sdk/client-kms as a peer dependency.

    const provider = new AwsKmsProvider({ region: "us-east-1" });
    const key = await provider.createKey("aes-256-gcm", "encrypt");
    const encrypted = await provider.encrypt(key.keyId, plaintext);

    Implements

    Index
    name: "aws"

    Provider identifier.

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

      Parameters

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

      Returns Promise<KmsKeyMetadata>

    • Disable a KMS key so it cannot be used for operations.

      Parameters

      • keyId: string

      Returns Promise<void>

    • Schedule a KMS key for deletion after a pending window.

      Parameters

      • keyId: string
      • pendingWindowDays: number = 30

      Returns Promise<void>

    • Encrypt plaintext using a KMS key, with optional encryption context.

      Parameters

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

      Returns Promise<KmsEncryptResult>

    • Decrypt ciphertext using a KMS key, with optional encryption context.

      Parameters

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

      Returns Promise<KmsDecryptResult>

    • Sign data using a KMS signing key.

      Parameters

      • keyId: string
      • data: Uint8Array
      • Optionalalgorithm: string

      Returns Promise<KmsSignResult>

    • Verify a signature. AWS KMS reports a signature that does not match by throwing KMSInvalidSignatureException; that is returned as false. Other errors are thrown.

      Parameters

      • keyId: string
      • data: Uint8Array
      • signature: string
      • Optionalalgorithm: string

      Returns Promise<boolean>

    • Rotate a key now with RotateKeyOnDemand: AWS creates new key material and keeps earlier material for decryption. (EnableKeyRotation would only schedule automatic yearly rotation.) AWS supports on-demand rotation for symmetric keys only.

      Parameters

      • keyId: string

      Returns Promise<KmsKeyMetadata>

    • 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 }>