Skip to content

lib: enable global WebCrypto by default

Enables --experimental-global-webcrypto by default, and ensures that the classic node:crypto core module is still available in --eval or --print contexts.

Currently this PR takes the route of breaking how the REPL can access the node:crypto module – currently the global crypto in REPL refers to node:crypto, with this PR it now refers to the Web Crypto API. This PR takes the route of keeping node:crypto available when evaluating a string from a CLI flag (e.g. node -p 'crypto.randomBytes(16).toString("hex")') to avoid breaking the ecosystem (see https://github.com/nodejs/node/pull/41779#issuecomment-1041547561).

IMO it makes sense to keep the REPL global crypto same as when parsing files, but I don't have a strong opinion and it's easy to change if the consensus disagrees with me.

Merge request reports

Loading