| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
|
@jasnell could you help us here? It seems there is a confusion on what is the plan for exposing a crypto object on the global scope. Is the plan:
If it's the latter, then I guess we should land this PR, as well as #41760, but this would need your input to move forward. |
Sorry, something went wrong.
|
My preference is exposing require('crypto') as the global. |
Sorry, something went wrong.
This is going to create all sort of compatibility problems (I've been myself affected by #41760), I'm -1 on this idea. Adding it to the TSC agenda so we can discuss this further. |
Sorry, something went wrong.
I suggested this when talking to @jasnell earlier, except that I'd maybe add the aliases to crypto only in the REPL. (Not sure if it's a good idea after all.) |
Sorry, something went wrong.
|
One possible approach we can take here is to modify Node.js' crypto to extend from Web Crypto crypto. Specifically, something like: class NodeCrypto extends Crypto {
// ... add the Node.js stuff...
};
module.exports = new NodeCrypto();
|
Sorry, something went wrong.
It wouldn't help folks doing import { getRandomValues } from 'node:crypto', right? In that case, that'd be fine with me, as long as we explicitly say that it's not a use-case we want to support. Could you maybe explain why we wouldn't expose require('crypto').webcrypto as global.crypto? I'm uncomfortable at the idea of introducing another Node.js specific global, especially if it's competing with one already in browsers and Deno. Is it because REPL (and node --eval) already expose a global-like named crypto and you are concerned it would be too breaking to change that? Sorry if you already discussed that somewhere else, but I feel like I'm missing some context here. |
Sorry, something went wrong.
Yes, I think that was the motivation behind #41266 (see #41266 (comment)). |
Sorry, something went wrong.
|
FYI, I've opened #41938 to suggest exposing the Web Crypto on the global scope instead of the Node.js one. |
Sorry, something went wrong.
PR-URL: #41938 Refs: https://developer.mozilla.org/en-US/docs/Web/API/crypto_property Refs: #41782 Refs: https://w3c.github.io/webcrypto Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
I don't think we get much value from having require('crypto').getRandomValues if it's already available (in a web-compatible way) through globalThis.crypto.getRandomValues. I still think we should remove it, or make it web compatible.
Whatever we decide to do we the alias, I think we should land this ASAP: all this PR is doing is documenting that the shortcut is not exactly the same as the web version, and it unblocks #41760. Currently our docs for Web crypto are "broken", for example here we tell the user to use object destructuring to get a reference to getRandomValues: Lines 128 to 159 in b8de7aa If the user tries to use this code in a browser or Deno, it will throw an arguably quite surprising error (e.g. Chromium throws TypeError: Illegal invocation). |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
|
@jasnell have you got any concerns in landing this as-is? |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
…Node.js specific
Sorry, something went wrong.
Sorry, something went wrong.
PR-URL: nodejs#41938 Refs: https://developer.mozilla.org/en-US/docs/Web/API/crypto_property Refs: nodejs#41782 Refs: https://w3c.github.io/webcrypto Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
PR-URL: #41938 Refs: https://developer.mozilla.org/en-US/docs/Web/API/crypto_property Refs: #41782 Refs: https://w3c.github.io/webcrypto Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
PR-URL: #41938 Refs: https://developer.mozilla.org/en-US/docs/Web/API/crypto_property Refs: #41782 Refs: https://w3c.github.io/webcrypto Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Refs: nodejs#41779 Refs: nodejs#41760 PR-URL: nodejs#41782 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
|
@aduh95 this doesn't land cleanly on v16.x-staging. Can you make a backport for this? Thank you |
Sorry, something went wrong.
PR-URL: nodejs#41938 Refs: https://developer.mozilla.org/en-US/docs/Web/API/crypto_property Refs: nodejs#41782 Refs: https://w3c.github.io/webcrypto Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
PR-URL: #41938 Refs: https://developer.mozilla.org/en-US/docs/Web/API/crypto_property Refs: #41782 Refs: https://w3c.github.io/webcrypto Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
| Back | FazBrowse Home | New Git URL |
Refs: #41779
Refs: #41760