Skip to content

Commit bb3907e

Browse files
committed
cli: remove --no-experimental-global-webcrypto flag
1 parent 128c60d commit bb3907e

File tree

9 files changed

+47
-97
lines changed

9 files changed

+47
-97
lines changed

doc/api/cli.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,14 +1375,6 @@ added: v21.2.0
13751375
13761376
Disable exposition of [Navigator API][] on the global scope.
13771377

1378-
### `--no-experimental-global-webcrypto`
1379-
1380-
<!-- YAML
1381-
added: v19.0.0
1382-
-->
1383-
1384-
Disable exposition of [Web Crypto API][] on the global scope.
1385-
13861378
### `--no-experimental-repl-await`
13871379

13881380
<!-- YAML
@@ -2640,7 +2632,6 @@ one is included in the list below.
26402632
* `--no-experimental-fetch`
26412633
* `--no-experimental-global-customevent`
26422634
* `--no-experimental-global-navigator`
2643-
* `--no-experimental-global-webcrypto`
26442635
* `--no-experimental-repl-await`
26452636
* `--no-experimental-websocket`
26462637
* `--no-extra-info-on-fatal-exception`
@@ -3130,7 +3121,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
31303121
[Source Map]: https://sourcemaps.info/spec.html
31313122
[Subresource Integrity]: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
31323123
[V8 JavaScript code coverage]: https://v8project.blogspot.com/2017/12/javascript-code-coverage.html
3133-
[Web Crypto API]: webcrypto.md
31343124
[`"type"`]: packages.md#type
31353125
[`--allow-child-process`]: #--allow-child-process
31363126
[`--allow-fs-read`]: #--allow-fs-read

doc/api/globals.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,15 @@ added:
361361
- v17.6.0
362362
- v16.15.0
363363
changes:
364+
- version: REPLACEME
365+
pr-url: https://github.com/nodejs/node/pull/52564
366+
description: No longer experimental.
364367
- version: v19.0.0
365368
pr-url: https://github.com/nodejs/node/pull/42083
366369
description: No longer behind `--experimental-global-webcrypto` CLI flag.
367370
-->
368371

369-
> Stability: 1 - Experimental. Disable this API with the
370-
> [`--no-experimental-global-webcrypto`][] CLI flag.
372+
> Stability: 2 - Stable.
371373
372374
A browser-compatible implementation of {Crypto}. This global is available
373375
only if the Node.js binary was compiled with including support for the
@@ -380,13 +382,15 @@ added:
380382
- v17.6.0
381383
- v16.15.0
382384
changes:
385+
- version: REPLACEME
386+
pr-url: https://github.com/nodejs/node/pull/52564
387+
description: No longer experimental.
383388
- version: v19.0.0
384389
pr-url: https://github.com/nodejs/node/pull/42083
385390
description: No longer behind `--experimental-global-webcrypto` CLI flag.
386391
-->
387392

388-
> Stability: 1 - Experimental. Disable this API with the
389-
> [`--no-experimental-global-webcrypto`][] CLI flag.
393+
> Stability: 2 - Stable.
390394
391395
A browser-compatible implementation of the [Web Crypto API][].
392396

@@ -397,13 +401,15 @@ added:
397401
- v17.6.0
398402
- v16.15.0
399403
changes:
404+
- version: REPLACEME
405+
pr-url: https://github.com/nodejs/node/pull/52564
406+
description: No longer experimental.
400407
- version: v19.0.0
401408
pr-url: https://github.com/nodejs/node/pull/42083
402409
description: No longer behind `--experimental-global-webcrypto` CLI flag.
403410
-->
404411

405-
> Stability: 1 - Experimental. Disable this API with the
406-
> [`--no-experimental-global-webcrypto`][] CLI flag.
412+
> Stability: 2 - Stable.
407413
408414
A browser-compatible implementation of {CryptoKey}. This global is available
409415
only if the Node.js binary was compiled with including support for the
@@ -981,8 +987,7 @@ changes:
981987
description: No longer behind `--experimental-global-webcrypto` CLI flag.
982988
-->
983989

984-
> Stability: 1 - Experimental. Disable this API with the
985-
> [`--no-experimental-global-webcrypto`][] CLI flag.
990+
> Stability: 2 - Stable.
986991
987992
A browser-compatible implementation of {SubtleCrypto}. This global is available
988993
only if the Node.js binary was compiled with including support for the
@@ -1147,7 +1152,6 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
11471152
[Web Crypto API]: webcrypto.md
11481153
[`--no-experimental-global-customevent`]: cli.md#--no-experimental-global-customevent
11491154
[`--no-experimental-global-navigator`]: cli.md#--no-experimental-global-navigator
1150-
[`--no-experimental-global-webcrypto`]: cli.md#--no-experimental-global-webcrypto
11511155
[`--no-experimental-websocket`]: cli.md#--no-experimental-websocket
11521156
[`AbortController`]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
11531157
[`ByteLengthQueuingStrategy`]: webstreams.md#class-bytelengthqueuingstrategy

doc/node.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ Disable experimental support for the WebSocket API.
192192
.It Fl -no-experimental-global-customevent
193193
Disable exposition of the CustomEvent on the global scope.
194194
.
195-
.It Fl -no-experimental-global-webcrypto
196-
Disable exposition of the Web Crypto API on the global scope.
197-
.
198195
.It Fl -no-experimental-repl-await
199196
Disable top-level await keyword support in REPL.
200197
.

lib/internal/bootstrap/web/exposed-wildcard.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@
88

99
const {
1010
globalThis,
11+
ObjectDefineProperty,
12+
ObjectGetOwnPropertyDescriptor,
1113
} = primordials;
1214

1315
const {
16+
defineReplaceableLazyAttribute,
1417
exposeInterface,
1518
lazyDOMExceptionClass,
1619
exposeLazyInterfaces,
1720
exposeGetterAndSetter,
1821
exposeNamespace,
1922
} = require('internal/util');
23+
const {
24+
ERR_INVALID_THIS,
25+
ERR_NO_CRYPTO,
26+
} = require('internal/errors').codes;
2027
const config = internalBinding('config');
2128

2229
// https://console.spec.whatwg.org/#console-namespace
@@ -112,3 +119,29 @@ exposeLazyInterfaces(
112119
[
113120
'CompressionStream', 'DecompressionStream',
114121
]);
122+
123+
// WebCryptoAPI
124+
if (internalBinding('config').hasOpenSSL) {
125+
defineReplaceableLazyAttribute(
126+
globalThis,
127+
'internal/crypto/webcrypto',
128+
['crypto'],
129+
false,
130+
function cryptoThisCheck() {
131+
if (this !== globalThis && this != null)
132+
throw new ERR_INVALID_THIS(
133+
'nullish or must be the global object');
134+
},
135+
);
136+
exposeLazyInterfaces(
137+
globalThis, 'internal/crypto/webcrypto',
138+
['Crypto', 'CryptoKey', 'SubtleCrypto'],
139+
);
140+
} else {
141+
ObjectDefineProperty(globalThis, 'crypto',
142+
{ __proto__: null, ...ObjectGetOwnPropertyDescriptor({
143+
get crypto() {
144+
throw new ERR_NO_CRYPTO();
145+
},
146+
}, 'crypto') });
147+
}

lib/internal/crypto/webcrypto.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const {
55
JSONParse,
66
JSONStringify,
77
ObjectDefineProperties,
8-
ObjectDefineProperty,
98
ReflectApply,
109
ReflectConstruct,
1110
SafeSet,
@@ -21,10 +20,6 @@ const {
2120
kWebCryptoCipherDecrypt,
2221
} = internalBinding('crypto');
2322

24-
const {
25-
getOptionValue,
26-
} = require('internal/options');
27-
2823
const { TextDecoder, TextEncoder } = require('internal/encoding');
2924

3025
const {
@@ -1025,18 +1020,6 @@ ObjectDefineProperties(
10251020
},
10261021
});
10271022

1028-
if (getOptionValue('--no-experimental-global-webcrypto')) {
1029-
// For backward compatibility, keep exposing CryptoKey in the Crypto prototype
1030-
// when using the flag.
1031-
ObjectDefineProperty(Crypto.prototype, 'CryptoKey', {
1032-
__proto__: null,
1033-
enumerable: true,
1034-
configurable: true,
1035-
writable: true,
1036-
value: CryptoKey,
1037-
});
1038-
}
1039-
10401023
ObjectDefineProperties(
10411024
SubtleCrypto.prototype, {
10421025
[SymbolToStringTag]: {

lib/internal/main/eval_string.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ if (getOptionValue('--input-type') === 'module' ||
3131
} else {
3232
// For backward compatibility, we want the identifier crypto to be the
3333
// `node:crypto` module rather than WebCrypto.
34-
const isUsingCryptoIdentifier =
35-
getOptionValue('--experimental-global-webcrypto') &&
36-
RegExpPrototypeExec(/\bcrypto\b/, source) !== null;
34+
const isUsingCryptoIdentifier = RegExpPrototypeExec(/\bcrypto\b/, source) !== null;
3735
const shouldDefineCrypto = isUsingCryptoIdentifier && internalBinding('config').hasOpenSSL;
3836

3937
if (isUsingCryptoIdentifier && !shouldDefineCrypto) {

lib/internal/process/pre_execution.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const {
1212
NumberParseInt,
1313
ObjectDefineProperty,
1414
ObjectFreeze,
15-
ObjectGetOwnPropertyDescriptor,
1615
SafeMap,
1716
String,
1817
StringPrototypeStartsWith,
@@ -36,9 +35,7 @@ const {
3635
} = require('internal/util');
3736

3837
const {
39-
ERR_INVALID_THIS,
4038
ERR_MANIFEST_ASSERT_INTEGRITY,
41-
ERR_NO_CRYPTO,
4239
ERR_MISSING_OPTION,
4340
ERR_ACCESS_DENIED,
4441
} = require('internal/errors').codes;
@@ -107,7 +104,6 @@ function prepareExecution(options) {
107104
setupNavigator();
108105
setupWarningHandler();
109106
setupUndici();
110-
setupWebCrypto();
111107
setupCustomEvent();
112108
setupCodeCoverage();
113109
setupDebugEnv();
@@ -341,41 +337,6 @@ function setupNavigator() {
341337
defineReplaceableLazyAttribute(globalThis, 'internal/navigator', ['navigator'], false);
342338
}
343339

344-
// TODO(aduh95): move this to internal/bootstrap/web/* when the CLI flag is
345-
// removed.
346-
function setupWebCrypto() {
347-
if (getEmbedderOptions().noBrowserGlobals ||
348-
getOptionValue('--no-experimental-global-webcrypto')) {
349-
return;
350-
}
351-
352-
if (internalBinding('config').hasOpenSSL) {
353-
defineReplaceableLazyAttribute(
354-
globalThis,
355-
'internal/crypto/webcrypto',
356-
['crypto'],
357-
false,
358-
function cryptoThisCheck() {
359-
if (this !== globalThis && this != null)
360-
throw new ERR_INVALID_THIS(
361-
'nullish or must be the global object');
362-
},
363-
);
364-
exposeLazyInterfaces(
365-
globalThis, 'internal/crypto/webcrypto',
366-
['Crypto', 'CryptoKey', 'SubtleCrypto'],
367-
);
368-
} else {
369-
ObjectDefineProperty(globalThis, 'crypto',
370-
{ __proto__: null, ...ObjectGetOwnPropertyDescriptor({
371-
get crypto() {
372-
throw new ERR_NO_CRYPTO();
373-
},
374-
}, 'crypto') });
375-
376-
}
377-
}
378-
379340
function setupCodeCoverage() {
380341
// Resolve the coverage directory to an absolute path, and
381342
// overwrite process.env so that the original path gets passed

test/parallel/test-cli-eval.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,6 @@ child.exec(
348348
common.mustSucceed((stdout) => {
349349
assert.match(stdout, /^number/);
350350
}));
351-
child.exec(
352-
`${nodejs} --no-experimental-global-webcrypto ` +
353-
'-p "var crypto = {randomBytes:1};typeof crypto.randomBytes"',
354-
common.mustSucceed((stdout) => {
355-
assert.match(stdout, /^number/);
356-
}));
357351

358352
// Regression test for https://github.com/nodejs/node/issues/45336
359353
child.execFile(process.execPath,

test/parallel/test-global-webcrypto-disbled.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)