Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
crypto: alias webcrypto.subtle and webcrypto.getRandomValues on crypto#41266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
The aliases allow code written to assume that `crypto.subtle` and `crypto.getRandomValues()` exist on the `crypto` global to just work. Signed-off-by: James M Snell <[email protected]>
nodejs-github-bot commented Dec 21, 2021
Review requested:
|
panva commented Dec 21, 2021
A code like that will likely expect crypto to be on a globalThis, window, global, or similar in the first place. Nevertheless, I don't mind this change if it means some libraries will work. It's worth pointing out that webcrypto is still experimental and there's no runtime warning about it being so. |
jasnell commented Dec 21, 2021
Yep once this lands, I plan to open a PR to expose |
nodejs-github-bot commented Dec 21, 2021
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Antoine du Hamel <[email protected]>
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tniessen commented Dec 22, 2021
What is the plan for doing that? I am unsure if this change makes sense without exposing Would the global |
aduh95 commented Dec 22, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Not exactly incompatible, thanks to import maps: <scripttype="importmap">{"imports": {"node:crypto": "data:text/javascript,export%20default%20globalThis.crypto"}}</script><scripttype="module">importcryptofrom'node:crypto';console.log(crypto.subtle);</script> |
tniessen commented Dec 22, 2021
@aduh95 I don't see how that helps. In browsers, there is already a |
jasnell commented Dec 23, 2021
It would be |
Co-authored-by: Michaël Zasso <[email protected]>
nodejs-github-bot commented Dec 23, 2021
dnalborczyk commented Dec 23, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
why don't we put |
dnalborczyk commented Dec 23, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@jasnell one thing I'm curious about: letwebcrypto;functionlazyWebCrypto(){webcrypto??=require('internal/crypto/webcrypto');returnwebcrypto;}does |
tniessen commented Dec 23, 2021
My concern is that globalThis.crypto===require('crypto')implies globalThis.crypto!==require('crypto').webcryptounless require('crypto')===require('crypto').webcryptowhich has implications such as globalThis.crypto.constructor.name==='Object'globalThis.crypto.webcrypto.constructor.name==='Crypto'I get that we want to improve compatibility with code that uses web APIs, even if those weren't designed for Node.js, but exposing non-standard features through the standard Conversely, we could expose only Web Crypto as |
jasnell commented Dec 23, 2021
We can't really. That would create an inconsistency with the Node.js REPL where
Yes, there's a small risk there but I think it's manageable and I think the benefits here outweigh the risks. You are right, tho, the risks are non-zero. |
jasnell commented Dec 24, 2021
@tniessen ... I just want to clarify, is your concern here blocking or can this PR go ahead and land? |
tniessen commented Dec 24, 2021
It's not blocking :) I haven't given this enough thought one way or the other to have an opinion here, I'm just wary of convenience changes with potentially significant API implications. |
nodejs-github-bot commented Dec 27, 2021
Commit Queue failed- Loading data for nodejs/node/pull/41266 ✔ Done loading data for nodejs/node/pull/41266 ----------------------------------- PR info ------------------------------------ Title crypto: alias webcrypto.subtle and webcrypto.getRandomValues on crypto (#41266) Author James M Snell (@jasnell) Branch jasnell:webcrypto-aliases -> nodejs:master Labels crypto, semver-minor, author ready, needs-ci, webcrypto, commit-queue-squash Commits 3 - crypto: alias webcrypto.subtle and webcrypto.getRandomValues on crypto - [Squash] nits - [Squash] nit Committers 2 - James M Snell - GitHub PR-URL: https://github.com/nodejs/node/pull/41266 Reviewed-By: Filip Skokan Reviewed-By: Michaël Zasso ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/41266 Reviewed-By: Filip Skokan Reviewed-By: Michaël Zasso -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - [Squash] nit ℹ This PR was created on Tue, 21 Dec 2021 18:40:38 GMT ✔ Approvals: 2 ✔ - Filip Skokan (@panva): https://github.com/nodejs/node/pull/41266#pullrequestreview-837777172 ✔ - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/41266#pullrequestreview-838130176 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2021-12-23T01:16:25Z: https://ci.nodejs.org/job/node-test-pull-request/41621/ - Querying data for job/node-test-pull-request/41621/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/1627255427 |
nodejs-github-bot commented Dec 27, 2021
Landed in 353532b |
The aliases allow code written to assume that `crypto.subtle` and `crypto.getRandomValues()` exist on the `crypto` global to just work. Signed-off-by: James M Snell <[email protected]> PR-URL: #41266 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Notable changes: crypto: * (SEMVER-MINOR) alias webcrypto.subtle and webcrypto.getRandomValues on crypto (James M Snell) #41266 doc: * add Mesteery to collaborators (Mestery) #41543 events: * (SEMVER-MINOR) graduate capturerejections to supported (James M Snell) #41267 * (SEMVER-MINOR) add EventEmitterAsyncResource to core (James M Snell) #41246 loader: * (SEMVER-MINOR) return package format from defaultResolve if known (Gabriel Bota) #40980 perf_hooks: * (SEMVER-MINOR) multiple fixes for Histogram (James M Snell) #41153 stream: * add filter method to readable (Benjamin Gruenbaum) #41354 * add map method to Readable (Benjamin Gruenbaum) #40815 PR-URL: TODO
Notable changes: crypto: * (SEMVER-MINOR) alias webcrypto.subtle and webcrypto.getRandomValues on crypto (James M Snell) #41266 doc: * add Mesteery to collaborators (Mestery) #41543 events: * (SEMVER-MINOR) graduate capturerejections to supported (James M Snell) #41267 * (SEMVER-MINOR) add EventEmitterAsyncResource to core (James M Snell) #41246 loader: * (SEMVER-MINOR) return package format from defaultResolve if known (Gabriel Bota) #40980 perf_hooks: * (SEMVER-MINOR) multiple fixes for Histogram (James M Snell) #41153 stream: * add filter method to readable (Benjamin Gruenbaum) #41354 * add map method to Readable (Benjamin Gruenbaum) #40815 PR-URL: #41557
Notable changes: child_process: * (SEMVER-MINOR) add support for URL to `cp.fork` (Antoine du Hamel) #41225 crypto: * (SEMVER-MINOR) alias webcrypto.subtle and webcrypto.getRandomValues on crypto (James M Snell) #41266 doc: * add Mesteery to collaborators (Mestery) #41543 events: * (SEMVER-MINOR) graduate capturerejections to supported (James M Snell) #41267 * (SEMVER-MINOR) add EventEmitterAsyncResource to core (James M Snell) #41246 loader: * (SEMVER-MINOR) return package format from defaultResolve if known (Gabriel Bota) #40980 perf_hooks: * (SEMVER-MINOR) multiple fixes for Histogram (James M Snell) #41153 stream: * (SEMVER-MINOR) add filter method to readable (Benjamin Gruenbaum, Robert Nagy) #41354 * (SEMVER-MINOR) add isReadable helper (Robert Nagy) #41199 * (SEMVER-MINOR) add map method to Readable (Benjamin Gruenbaum, Robert Nagy) #40815 PR-URL: #41557
Notable changes: child_process: * (SEMVER-MINOR) add support for URL to `cp.fork` (Antoine du Hamel) #41225 crypto: * (SEMVER-MINOR) alias webcrypto.subtle and webcrypto.getRandomValues on crypto (James M Snell) #41266 doc: * add Mesteery to collaborators (Mestery) #41543 events: * (SEMVER-MINOR) graduate capturerejections to supported (James M Snell) #41267 * (SEMVER-MINOR) add EventEmitterAsyncResource to core (James M Snell) #41246 loader: * (SEMVER-MINOR) return package format from defaultResolve if known (Gabriel Bota) #40980 perf_hooks: * (SEMVER-MINOR) multiple fixes for Histogram (James M Snell) #41153 stream: * (SEMVER-MINOR) add filter method to readable (Benjamin Gruenbaum, Robert Nagy) #41354 * (SEMVER-MINOR) add isReadable helper (Robert Nagy) #41199 * (SEMVER-MINOR) add map method to Readable (Benjamin Gruenbaum, Robert Nagy) #40815 PR-URL: #41557
Notable changes: child_process: * (SEMVER-MINOR) add support for URL to `cp.fork` (Antoine du Hamel) #41225 crypto: * (SEMVER-MINOR) alias webcrypto.subtle and webcrypto.getRandomValues on crypto (James M Snell) #41266 doc: * add Mesteery to collaborators (Mestery) #41543 events: * (SEMVER-MINOR) graduate capturerejections to supported (James M Snell) #41267 * (SEMVER-MINOR) add EventEmitterAsyncResource to core (James M Snell) #41246 loader: * (SEMVER-MINOR) return package format from defaultResolve if known (Gabriel Bota) #40980 perf_hooks: * (SEMVER-MINOR) multiple fixes for Histogram (James M Snell) #41153 stream: * (SEMVER-MINOR) add filter method to readable (Benjamin Gruenbaum, Robert Nagy) #41354 * (SEMVER-MINOR) add isReadable helper (Robert Nagy) #41199 * (SEMVER-MINOR) add map method to Readable (Benjamin Gruenbaum, Robert Nagy) #40815 PR-URL: #41557
Notable changes: child_process: * (SEMVER-MINOR) add support for URL to `cp.fork` (Antoine du Hamel) nodejs#41225 crypto: * (SEMVER-MINOR) alias webcrypto.subtle and webcrypto.getRandomValues on crypto (James M Snell) nodejs#41266 doc: * add Mesteery to collaborators (Mestery) nodejs#41543 events: * (SEMVER-MINOR) graduate capturerejections to supported (James M Snell) nodejs#41267 * (SEMVER-MINOR) add EventEmitterAsyncResource to core (James M Snell) nodejs#41246 loader: * (SEMVER-MINOR) return package format from defaultResolve if known (Gabriel Bota) nodejs#40980 perf_hooks: * (SEMVER-MINOR) multiple fixes for Histogram (James M Snell) nodejs#41153 stream: * (SEMVER-MINOR) add filter method to readable (Benjamin Gruenbaum, Robert Nagy) nodejs#41354 * (SEMVER-MINOR) add isReadable helper (Robert Nagy) nodejs#41199 * (SEMVER-MINOR) add map method to Readable (Benjamin Gruenbaum, Robert Nagy) nodejs#40815 PR-URL: nodejs#41557
aduh95 commented Jan 30, 2022
I don't think the |
The aliases allow code written to assume that `crypto.subtle` and `crypto.getRandomValues()` exist on the `crypto` global to just work. Signed-off-by: James M Snell <[email protected]> PR-URL: nodejs#41266 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Notable changes: child_process: * (SEMVER-MINOR) add support for URL to `cp.fork` (Antoine du Hamel) nodejs#41225 crypto: * (SEMVER-MINOR) alias webcrypto.subtle and webcrypto.getRandomValues on crypto (James M Snell) nodejs#41266 doc: * add Mesteery to collaborators (Mestery) nodejs#41543 events: * (SEMVER-MINOR) graduate capturerejections to supported (James M Snell) nodejs#41267 * (SEMVER-MINOR) add EventEmitterAsyncResource to core (James M Snell) nodejs#41246 loader: * (SEMVER-MINOR) return package format from defaultResolve if known (Gabriel Bota) nodejs#40980 perf_hooks: * (SEMVER-MINOR) multiple fixes for Histogram (James M Snell) nodejs#41153 stream: * (SEMVER-MINOR) add filter method to readable (Benjamin Gruenbaum, Robert Nagy) nodejs#41354 * (SEMVER-MINOR) add isReadable helper (Robert Nagy) nodejs#41199 * (SEMVER-MINOR) add map method to Readable (Benjamin Gruenbaum, Robert Nagy) nodejs#40815 PR-URL: nodejs#41557
The aliases allow code written to assume that
crypto.subtleandcrypto.getRandomValues()exist on thecryptoglobal to just work.Signed-off-by: James M Snell [email protected]