From fb724eb6441408ad7f93c50d146a12c9b64d8333 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 26 Jun 2024 21:48:01 +0200 Subject: [PATCH] fix(NODE-6241): allow `Binary` as local KMS provider key (#4160) Co-authored-by: Neal Beeken --- src/client-side-encryption/providers/index.ts | 3 ++- test/types/client-side-encryption.test-d.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client-side-encryption/providers/index.ts b/src/client-side-encryption/providers/index.ts index 54f4366f6ff..f254cf69f92 100644 --- a/src/client-side-encryption/providers/index.ts +++ b/src/client-side-encryption/providers/index.ts @@ -1,3 +1,4 @@ +import type { Binary } from '../../bson'; import { loadAWSCredentials } from './aws'; import { loadAzureCredentials } from './azure'; import { loadGCPCredentials } from './gcp'; @@ -39,7 +40,7 @@ export interface LocalKMSProviderConfiguration { * The master key used to encrypt/decrypt data keys. * A 96-byte long Buffer or base64 encoded string. */ - key: Buffer | string; + key: Binary | Uint8Array | string; } /** @public */ diff --git a/test/types/client-side-encryption.test-d.ts b/test/types/client-side-encryption.test-d.ts index 53e4060aa29..87c9d46a347 100644 --- a/test/types/client-side-encryption.test-d.ts +++ b/test/types/client-side-encryption.test-d.ts @@ -9,7 +9,7 @@ import type { KMSProviders, RangeOptions } from '../..'; -import type { ClientEncryptionDataKeyProvider } from '../mongodb'; +import { Binary, type ClientEncryptionDataKeyProvider } from '../mongodb'; type RequiredCreateEncryptedCollectionSettings = Parameters< ClientEncryption['createEncryptedCollection'] @@ -51,6 +51,10 @@ expectAssignable({ { // KMSProviders + // local + expectAssignable({ key: '' }); + expectAssignable({ key: Buffer.alloc(0) }); + expectAssignable({ key: Binary.createFromBase64('') }); // aws expectAssignable({ accessKeyId: '', secretAccessKey: '' }); expectAssignable({