Skip to content

Commit fb724eb

Browse files
addaleaxnbbeeken
andauthored
fix(NODE-6241): allow Binary as local KMS provider key (#4160)
Co-authored-by: Neal Beeken <neal.beeken@mongodb.com>
1 parent 4f32dec commit fb724eb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/client-side-encryption/providers/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Binary } from '../../bson';
12
import { loadAWSCredentials } from './aws';
23
import { loadAzureCredentials } from './azure';
34
import { loadGCPCredentials } from './gcp';
@@ -39,7 +40,7 @@ export interface LocalKMSProviderConfiguration {
3940
* The master key used to encrypt/decrypt data keys.
4041
* A 96-byte long Buffer or base64 encoded string.
4142
*/
42-
key: Buffer | string;
43+
key: Binary | Uint8Array | string;
4344
}
4445

4546
/** @public */

test/types/client-side-encryption.test-d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
KMSProviders,
1010
RangeOptions
1111
} from '../..';
12-
import type { ClientEncryptionDataKeyProvider } from '../mongodb';
12+
import { Binary, type ClientEncryptionDataKeyProvider } from '../mongodb';
1313

1414
type RequiredCreateEncryptedCollectionSettings = Parameters<
1515
ClientEncryption['createEncryptedCollection']
@@ -51,6 +51,10 @@ expectAssignable<RequiredCreateEncryptedCollectionSettings>({
5151

5252
{
5353
// KMSProviders
54+
// local
55+
expectAssignable<KMSProviders['local']>({ key: '' });
56+
expectAssignable<KMSProviders['local']>({ key: Buffer.alloc(0) });
57+
expectAssignable<KMSProviders['local']>({ key: Binary.createFromBase64('') });
5458
// aws
5559
expectAssignable<KMSProviders['aws']>({ accessKeyId: '', secretAccessKey: '' });
5660
expectAssignable<KMSProviders['aws']>({

0 commit comments

Comments
 (0)