-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
crypto: use globalThis.crypto over require('crypto').webcrypto #45817
crypto: use globalThis.crypto over require('crypto').webcrypto #45817
Conversation
Review requested:
|
9c778e5
to
bdc2204
Compare
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.
I disagree with the changes in the test, we want to keep the test as is to ensure there's no regressions. The doc-changes LGTM.
What test change do you disagree with? |
Changing the tests to test |
We have other existing tests that ensure the two are equal. So I don't see why these changes would be a cause for concern. |
That seems like another reason not to make this change. Unless we decide to deprecate |
I'm unforunately not following your argumentation @aduh95. I don't see the need for having to have a deprecation on it to recognize the global is the likely way of accessing a Web API, it is the way we already have in most doc examples, and it should therefore be the one tested. |
I guess we would have to agree to disagree, and wait to see if someone else wants to chime in. If someone else thinks we should merge it, I'm ready to dismiss my review. Count me as -.5 on this because:
I disagree, the fact that one API is used less often than another doesn't mean it deserves less test coverage (but anyway it's a bit off-topic, since both APIs are equivalent in this case). |
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.
I agree with @aduh95 regarding the usage of require('node:crypto').webcrypto
instead of globalThis.crypto
internally.
I'm in favor of blocking this because, if we are going to use globalThis.crypto
instead of require('node:crypto').webcrypto
we need a lint rule to protect this change in the upcoming pull requests.
And I've requested assistance with such in the very description of this PR myself. |
I totally missed that part, my bad! |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
bdc2204
to
3e0b149
Compare
I see. I found the corresponding bug report for this: eslint/eslint#16412 |
I've added a working, albeit rudimentary, lint rule. |
This comment was marked as resolved.
This comment was marked as resolved.
3e0b149
to
cac299a
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Lines 150 to 155 in 587367d
|
Still -1 on this, I don't think this lint rule is a great addition, but won't block it.
This comment was marked as outdated.
This comment was marked as outdated.
Landed in 7ad069c |
PR-URL: #45817 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Updates tests and some remaining documentation to use
globalThis.crypto
instead ofrequire('crypto').webcrypto
.@aduh95 it would be great if we could make this into a lint rule but unfortunately the existing options I tried to do this with fall short:
no-restricted-modules
cannot restrict an exported property from the crypto module.no-restricted-properties
does not catch use ofconst { webcrypto } = require('crypto')
.