Skip to content

Commit

Permalink
fix(NODE-6241): allow Binary as local KMS provider key (#4160)
Browse files Browse the repository at this point in the history
Co-authored-by: Neal Beeken <neal.beeken@mongodb.com>
  • Loading branch information
addaleax and nbbeeken committed Jun 26, 2024
1 parent 4f32dec commit fb724eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/client-side-encryption/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Binary } from '../../bson';
import { loadAWSCredentials } from './aws';
import { loadAzureCredentials } from './azure';
import { loadGCPCredentials } from './gcp';
Expand Down Expand Up @@ -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 */
Expand Down
6 changes: 5 additions & 1 deletion test/types/client-side-encryption.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -51,6 +51,10 @@ expectAssignable<RequiredCreateEncryptedCollectionSettings>({

{
// KMSProviders
// local
expectAssignable<KMSProviders['local']>({ key: '' });
expectAssignable<KMSProviders['local']>({ key: Buffer.alloc(0) });
expectAssignable<KMSProviders['local']>({ key: Binary.createFromBase64('') });
// aws
expectAssignable<KMSProviders['aws']>({ accessKeyId: '', secretAccessKey: '' });
expectAssignable<KMSProviders['aws']>({
Expand Down

0 comments on commit fb724eb

Please sign in to comment.