From 56b7ab19ff770e8374781487c706519d2c221977 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 25 Jun 2024 14:22:05 +0200 Subject: [PATCH 1/2] fix(NODE-6241): allow `Binary` as local KMS provider key This aligns the types with actual behavior as well as the shell's expected set of supported types. --- 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 54f4366f6f..469bc104ec 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 | Buffer | string; } /** @public */ diff --git a/test/types/client-side-encryption.test-d.ts b/test/types/client-side-encryption.test-d.ts index 53e4060aa2..87c9d46a34 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({ From 90438771e37ca28440f287b27c6d5ffc6231f53b Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 26 Jun 2024 00:15:57 +0200 Subject: [PATCH 2/2] Update src/client-side-encryption/providers/index.ts Co-authored-by: Neal Beeken --- src/client-side-encryption/providers/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client-side-encryption/providers/index.ts b/src/client-side-encryption/providers/index.ts index 469bc104ec..f254cf69f9 100644 --- a/src/client-side-encryption/providers/index.ts +++ b/src/client-side-encryption/providers/index.ts @@ -40,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: Binary | Buffer | string; + key: Binary | Uint8Array | string; } /** @public */