Skip to content

Commit da7393a

Browse files
authored
fix(connection-form): remove dependency on Node.js crypto module (#7632)
We can safely use the webcrypto API exposed through the `crypto` global in both Node.js and Electron now. This enables removing a polyfill with a known vulnerability in the VSCode extension.
1 parent 81da846 commit da7393a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

packages/connection-form/src/utils/csfle-handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { randomBytes } from 'crypto';
21
import { cloneDeep } from 'lodash';
32
import type { ConnectionOptions } from 'mongodb-data-service';
43
import type {
@@ -356,7 +355,7 @@ export function adjustCSFLEParams(
356355
}
357356

358357
export function randomLocalKey(): string {
359-
return randomBytes(96).toString('base64');
358+
return crypto.getRandomValues(Buffer.alloc(96)).toString('base64');
360359
}
361360

362361
export function handleAddKmsProvider<T extends KMSProviderType>({

0 commit comments

Comments
 (0)