Crypto KMS
    Preparing search index...

    Class GcpKmsProvider

    Google Cloud KMS adapter.

    Uses the Google Cloud KMS REST API v1 via native fetch with zero SDK dependencies.

    const provider = new GcpKmsProvider({
    projectId: "my-project",
    locationId: "us-east1",
    keyRingId: "my-ring",
    token: "ya29.XXXXX",
    });
    const key = await provider.createKey("aes-256-gcm", "encrypt");

    Implements

    Index
    name: "gcp"

    Provider identifier.

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

      Parameters

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

      Returns Promise<KmsKeyMetadata>

    • Schedule every version that is not already scheduled or destroyed for destruction. Cloud KMS applies the key's own destroyScheduledDuration, set when the key is created, so pendingWindowDays is not used.

      Parameters

      • keyId: string
      • Optional_pendingWindowDays: number

      Returns Promise<void>

    • Encrypt plaintext using a managed key.

      Parameters

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

      Returns Promise<KmsEncryptResult>

    • Decrypt ciphertext using a managed key.

      Parameters

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

      Returns Promise<KmsDecryptResult>

    • Sign data with the newest enabled version of a signing key. Digest algorithms receive the message's digest, Ed25519 the message itself. The result reports the version's actual algorithm.

      Parameters

      • keyId: string
      • data: Uint8Array
      • Optional_algorithm: string

      Returns Promise<KmsSignResult>

    • Verify a signature locally against the public key of every enabled version, so signatures made before a rotation still verify until their version is disabled or destroyed. Cloud KMS has no remote verify for asymmetric keys. A mismatch returns false; transport and lookup errors are thrown.

      Parameters

      • keyId: string
      • data: Uint8Array
      • signature: string
      • Optional_algorithm: string

      Returns Promise<boolean>

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

      Parameters

      • keyId: string
      • OptionalkeySpec: string

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