Skip to content

Commit 4861927

Browse files
committed
polyfill crypto directly not just in test, update rush comment
1 parent 0ec3f3d commit 4861927

7 files changed

Lines changed: 18 additions & 14 deletions

File tree

build-tests/api-extractor-test-05/dist/tsdoc-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"toolPackages": [
66
{
77
"packageName": "@microsoft/api-extractor",
8-
"packageVersion": "7.57.5"
8+
"packageVersion": "7.57.7"
99
}
1010
]
1111
}

common/changes/@rushstack/module-minifier/main_2026-03-06-03-25.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"changes": [
33
{
44
"packageName": "@rushstack/module-minifier",
5-
"comment": "Bump serialize-javascript",
5+
"comment": "Bump `serialize-javascript` to partially mitigate CVE-2020-7660.",
66
"type": "patch"
77
}
88
],

libraries/module-minifier/config/jest-setup.js

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"extends": "local-node-rig/profiles/default/config/jest.config.json",
3-
"setupFiles": ["<rootDir>/config/jest-setup.js"]
2+
"extends": "local-node-rig/profiles/default/config/jest.config.json"
43
}

libraries/module-minifier/src/LocalMinifier.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { createHash } from 'node:crypto';
55

6+
import './cryptoPolyfill';
67
import serialize from 'serialize-javascript';
78
import type { MinifyOptions } from 'terser';
89

libraries/module-minifier/src/WorkerPoolMinifier.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createHash } from 'node:crypto';
55
import os from 'node:os';
66
import type { ResourceLimits } from 'node:worker_threads';
77

8+
import './cryptoPolyfill';
89
import serialize from 'serialize-javascript';
910
import type { MinifyOptions } from 'terser';
1011

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
// Polyfill globalThis.crypto for Node 18, which doesn't expose it as a global.
5+
// serialize-javascript accesses crypto.randomBytes() at module load time,
6+
// which requires globalThis.crypto to be the Node.js crypto module.
7+
// Remove this when deprecating nodev18 support.
8+
import { webcrypto } from 'node:crypto';
9+
10+
if (!globalThis.crypto) {
11+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12+
(globalThis as any).crypto = webcrypto;
13+
}

0 commit comments

Comments
 (0)