-
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
crypto: runtime deprecate DEFAULT_ENCODING #18333
Conversation
I am reluctant to introduce new APIs for a legacy feature; this is really just here to support old applications (pre-2012!). Like, I’m totally 👍 on the deprecation. But if you want to retrieve a string in a specific encoding, you should pass that option explicitly when calling then function anyway. |
So I know, is that -1 reluctant or -0 reluctant? |
@jasnell That is -1 unless there’s a good reason that I don’t see, which is totally possible. |
Ok. Fwiw, these methods already exist as the getter/setter. The only additional cost is the overhead of introducing new public API. Let's see how others feel about it, ok? |
doc/api/deprecations.md
Outdated
@@ -831,6 +840,7 @@ is not included in this list will be considered invalid in compliance with | |||
[`console.error()`]: console.html#console_console_error_data_args | |||
[`console.log()`]: console.html#console_console_log_data_args | |||
[`crypto.createCredentials()`]: crypto.html#crypto_crypto_createcredentials_details | |||
[`crypto.DEFAULT_ENCODING`]: crypto.html#crypto_crypto_defaultencoding |
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_crypto_defaultencoding
-> #crypto_crypto_default_encoding
?
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.
@jasnell This wasn't fixed in the «nits»-fix commit ;-)
https://nodejs.org/api/crypto.html#crypto_crypto_default_encoding is the actual link, so it indeed should be crypto.html#crypto_crypto_default_encoding
.
doc/api/deprecations.md
Outdated
|
||
The [`crypto.DEFAULT_ENCODING`][] property has been deprecated and replaced | ||
with `crypto.setDefaultEncoding()` and `crypto.getDefaultEncoding()` | ||
alternatives. |
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.
Can we keep this wording consistent with other messages by changing it to this?:
The [`crypto.DEFAULT_ENCODING`][] property is deprecated. Please use
`crypto.getDefaultEncoding()` and `crypto.setDefaultEncoding()` instead.
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.
Just marking this with the red X so my objection doesn’t get lost
I would prefer we deprecate this and remove it in 11. Unless this feature is needed by some very popular module, in which case we might have to do what you propose. |
fwiw if its needed by some very popular module we can just ping the author and ask them to refactor the calls |
Ok, so that brings up the next question: instead of docs-deprecation-with-replacement, should we just go with a full runtime deprecation of the property and not worry about replacing it? |
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.
This property was added 5 years ago as a temporary measure, documented for future deprecation in 2015 (in 6.0 release). I'm pretty sure we don't want to introduce a new API around it, unless there is some valid usecase that we would want to support and are missing.
+1 to doc or runtime deprecation.
The usage seems to be really low, I'm for runtime-deprecation. |
1dd37a1
to
dbb4e9b
Compare
dbb4e9b
to
144ab92
Compare
Updated to use a runtime deprecation with no new API exposed. |
doc/api/crypto.md
Outdated
is passed to the callback: | ||
The `crypto.DEFAULT_ENCODING` property can be used to change the way the | ||
`derivedKey` is passed to the callback. This property, however, has been | ||
deprecated and use should be avoideed. |
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.
avoided
doc/api/crypto.md
Outdated
is returned: | ||
The `crypto.DEFAULT_ENCODING` property may be used to change the way the | ||
`derivedKey` is returned. This property, however, has been deprecated and use | ||
should be avoideed. |
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.
ditto
lib/crypto.js
Outdated
@@ -202,11 +202,14 @@ Object.defineProperties(exports, { | |||
set: !fipsMode ? setFipsDisabled : | |||
fipsForced ? setFipsForced : setFipsCrypto | |||
}, | |||
// DEFAULT_ENCODING is documentation-only deprecated: DEP00XX |
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.
remove this line?
lib/internal/crypto/util.js
Outdated
const enc = normalizeEncoding(val); | ||
if (enc === undefined) | ||
throw new errors.TypeError('ERR_UNKNOWN_ENCODING', val); | ||
defaultEncoding = enc; |
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.
this change does not seem to be directly related to the deprecation
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.
This should probably go into a separate PR if still wanted.
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.
Ah, right, yeah. missed this.
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.
LGTM with already mentioned nits and undoing (or explaining) changes in util.js
.
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.
LGTM
4736855
to
909643a
Compare
CI looks good, although there is an issue with the arm build bots |
Runtime deprecate the crypto.DEFAULT_ENCODING property. This is specifically in preparation for eventual ESM support Refs: nodejs#18131
4bf301f
to
79a4683
Compare
New CI, just to be safe: https://ci.nodejs.org/job/node-test-pull-request/12863/ |
Build bot failures on multiple CI bots but otherwise ok. |
Runtime deprecate the crypto.DEFAULT_ENCODING property. This is specifically in preparation for eventual ESM support Refs: #18131 PR-URL: #18333 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
landed in 6035bee |
Missed when landing nodejs#18333
Runtime deprecate the crypto.DEFAULT_ENCODING property. This is specifically in preparation for eventual ESM support Refs: nodejs#18131 PR-URL: nodejs#18333 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Citing 76b0bdf from 2012, "only use this as a temporary measure." Getting or setting DEFAULT_ENCODING has emitted a warning ever since Node.js 10, so it seems appropriate to remove it in Node.js 20 five years later. The last Node.js version that did not emit a warning reached its end-of-life status at the end of 2019. This commit only removes the public API so that the change can land in time for Node.js 20. Refs: nodejs/node-v0.x-archive#4179 Refs: nodejs#18333
Citing 76b0bdf from 2012, "only use this as a temporary measure." Getting or setting DEFAULT_ENCODING has emitted a warning ever since Node.js 10, so it seems appropriate to remove it in Node.js 20 five years later. The last Node.js version that did not emit a warning reached its end-of-life status at the end of 2019. This commit only removes the public API so that the change can land in time for Node.js 20. Refs: nodejs/node-v0.x-archive#4179 Refs: nodejs#18333
Citing 76b0bdf from 2012, "only use this as a temporary measure." Getting or setting DEFAULT_ENCODING has emitted a warning ever since Node.js 10, so it seems appropriate to remove it in Node.js 20 five years later. The last Node.js version that did not emit a warning reached its end-of-life status at the end of 2019. This commit only removes the public API so that the change can land in time for Node.js 20. Refs: nodejs/node-v0.x-archive#4179 Refs: #18333 PR-URL: #47182 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com> Reviewed-By: Erick Wendel <erick.workspace@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Docs-onlyRuntime deprecate the crypto.DEFAULT_ENCODINGand replace by directly exposing the getDefaultEncoding/setDefaultEncoding functions that are used as it's getter and setter.This is specifically in preparation for eventual ESM support
Refs: #18131
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
crypto