-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
webcrypto: graduate from experimental, expose via crypto
#37969
Conversation
In the browser, the `crypto` global exposes `subtle` and `getRandomValues` as properties. In the Node.js impl, those require an additional indirection via `crypto.webcrypto.*`. This commit exposes aliases to promote cross-environment isomorphism. Note: In the browser, the `CryptoKey` object is also exposed as a global. I decided not to do that here because it requires a larger change to the internal `node_crypto` binding because of the need to register external references. That can be done in a separate PR but it's a much lower priority. Signed-off-by: James M Snell <[email protected]>
Signed-off-by: James M Snell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crypto
is not a global, as the added test shows.
I'd be much more comfortable approving this part of the change if we had the WebCryptoAPI WPT in the tree. |
Sorry, I was speaking of it as a global in terms of the repl but wasn't clear. Because it is a global in the repl, making |
I've done interoperability testing on everything defined by Web Cryptography API, but I wouldn't rush calling the Non-standard Node.js extensions as stable just yet, as evidenced by the fact that every time I attempted to use one of them I found a thing to fix. Is there a way for us to call the standard defined algorithms stable but keep the node specific extensions experimental? We should also take this moment to consider whether we really want to keep those extensions around. This might be the last chance for us to ditch or trim those. Not saying we should, but this is the time to reflect.
I'm also not sure this PR achieves such a thing. For one it's not exposed via globalThis, so one has to write runtime specific code to import |
I understand. We need to think about this, because one solution could be to make |
Yes, absolutely.
I believe there's value in keeping them, but I'm a bit biased since I added them ;-) ... we can absolutely keep those extensions experimental for some time.
I could go either way with it. I'm fine with making it a global, but I'm also fine with keeping it behind the |
crypto
globalcrypto
This might lead to problems when Node.js is compiled without OpenSSL and disables lazy loading. |
#38029 has to land first |
I'm torn on this one, aside from the Curve25519/448 raw key import which we could just add to Since these are not portable to other Web Cryptography API implementations if it came down to a decision I'd say remove the Node.js-specific extensions.
Adding it to global would conflict with |
In the browser, the
crypto
global exposessubtle
andgetRandomValues
as properties. In the Node.js impl, thoserequire an additional indirection via
crypto.webcrypto.*
.This commit exposes aliases to promote cross-environment
isomorphism.
Note: In the browser, the
CryptoKey
object is also exposedas a global. I decided not to do that here because it requires
a larger change to the internal
node_crypto
binding becauseof the need to register external references. That can be done
in a separate PR but it's a much lower priority.
This also graduates WebCrypto from experimental status.
Signed-off-by: James M Snell [email protected]