Skip to content
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

Update & fix nodejs data for Crypto #24979

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

skyclouds2001
Copy link
Contributor

@skyclouds2001 skyclouds2001 commented Nov 6, 2024

Summary

The support for the Web Crypto API is:

in v15.0.0, the API has been shipped, but can't access globally, access via the crypto module with the alternative name webcrypto via nodejs/node#35093

in v17.6.0, v16.15.0, the API can be available to global context, but need to be enabled with --experimental-global-webcrypto CLI flag via nodejs/node#41938

in v19.0.0, the API is available to global context without flags, but can be disabled with --no-experimental-global-webcrypto CLI flag via nodejs/node#42083

in v23.0.0, the API is marked as not experimental via nodejs/node#52564

See also:

https://nodejs.org/docs/latest/api/globals.html#crypto
https://nodejs.org/docs/latest/api/webcrypto.html#class-crypto
https://nodejs.org/docs/latest/api/crypto.html#cryptorandomuuidoptions
https://nodejs.org/docs/latest/api/crypto.html#cryptogetrandomvaluestypedarray

Also fixes #23784

Also note that the fix in #21414 and the test in #20752 is not correct, as the issue and PR use the link of the getRandomValues() method of crypto module (which says v17.4.0), NOT the getRandomValues() method of Web Crypto API (which says v15.0.0). Also notice that, the getRandomValues() method of crypto module is simply a convenient alias of the getRandomValues() method of Web Crypto API

Test results and supporting details

image
image

Related issues

@github-actions github-actions bot added the data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Nov 6, 2024
@skyclouds2001 skyclouds2001 marked this pull request as ready for review November 6, 2024 21:38
Comment on lines +94 to +95
"version_added": "15.0.0",
"notes": "Since v17.4.0, a similar method is available via the <code>crypto</code> module."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right: Since the parent feature is only available via the crypto module from 15.0.0, and only outside of the crypto module from 19.0.0, isn't this note obsolete, and the current support statement (17.4.0) is correct?

Suggested change
"version_added": "15.0.0",
"notes": "Since v17.4.0, a similar method is available via the <code>crypto</code> module."
"version_added": "17.4.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the v17.4.0 one means require('crypto').getRandomValues(), see https://nodejs.org/docs/latest/api/crypto.html#cryptogetrandomvaluestypedarray
the v15.0.0 one means require('crypto').webcrypto.getRandomValues(), see https://nodejs.org/docs/latest/api/webcrypto.html#cryptogetrandomvaluestypedarray
per documentation, the v17.4.0 one is simply an alias of the v15.0.0 one
also, since here is referring Crypto interface's getRandomValues(), the v15.0.0 should be used instead

api/Crypto.json Outdated Show resolved Hide resolved
"notes": "From version 14.17.0, a similar method is available as <a href='https://nodejs.org/docs/latest-v14.x/api/crypto.html#crypto_crypto'><code>crypto.randomUUID()</code></a>."
}
],
"nodejs": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we keep the "version_added": "19.0.0" entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because there is no difference made to randomUUID() before v19.0.0 and after v19.0.0 (while the Crypto interface is exposed to global scope, so just combine the previous two entries)

@caugner caugner added the nodejs Data about Node.js label Nov 12, 2024
caugner and others added 2 commits November 12, 2024 22:29
Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API nodejs Data about Node.js
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api.Crypto.randomUUID - available in NodeJS 18
2 participants