Uh oh!
There was an error while loading. Please reload this page.
crypto: deprecate aliases for randomBytes - #22519
Conversation
tniessen
commented
Aug 25, 2018
cc @nodejs/crypto @nodejs/security-wg Deprecation was suggested back in #557 by the way. |
There was a problem hiding this comment.
Nit: has been -> is for consistency with the rest of the deprecation messages (with one exception that should also be changed but not in this PR).
This comment has been minimized.
This comment has been minimized.
mcollina
commented
Aug 25, 2018
@dougwilson which module is that? why is it doing that check? |
This comment has been minimized.
This comment has been minimized.
mcollina
commented
Aug 25, 2018
@dougwilson I would release a new major version of that module, and drop support for Node < 4 (even Node < 6). However, you could still detect this without version checking via Note that when this land any user of |
This comment has been minimized.
This comment has been minimized.
mcollina
commented
Aug 25, 2018
My bad. |
mcollina
commented
Aug 25, 2018
I would say go for it. |
There was a problem hiding this comment.
Can you please add a comment:
// The ecosystem needs those to exists for backwards compatibility with// ancient Node.js runtimes (0.10, 0.12).There was a problem hiding this comment.
Added it. IMO this kind of makes it sound as if we couldn't remove these functions in the future though.
There was a problem hiding this comment.
Exactly, this is the sound of #22519 (comment) comment.
tniessen
commented
Aug 26, 2018
@dougwilson Thanks for weighing in! Are you sure that people are still using that package for backcompatibility? The only Node.js releases which require this kind of check are from 2015 or even older and have long been EOL. Maybe people just want to use promises? |
This comment has been minimized.
This comment has been minimized.
tniessen
commented
Aug 26, 2018
@dougwilson I don't know. Your previous comment suggested that backcompatibility was the primary intention of people using the package, but I'd be surprised if that was true. There are barely any packages depending on random-bytes, so maybe the majority of downloads is caused by people using uid-safe? It is cool that packages such as yours try to support "ancient" versions as @mcollina called them, but that shouldn't stand in the way of improving Node.js. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
tniessen
commented
Aug 26, 2018
@dougwilson I am sorry for the misunderstanding, this was in no way directed at you! This was entirely based on #22519 (comment), which suggests that we cannot remove these functions. |
8a304fe to
86b7efdComparetniessen
commented
Aug 27, 2018
Rebased, old HEAD was 8a304fe59a87cf8be7e0a804c860d017b91375ab. |
tniessen
commented
Aug 30, 2018
Landed in 221df22. |
PR-URL: #22519 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
targos
commented
Sep 1, 2018
This affects a module used by |
tniessen
commented
Sep 1, 2018
@targos I opened npm/unique-slug#6. |
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: nodejs#24108 Refs: nodejs#22519 Refs: nodejs#23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: #24108 Refs: #22519 Refs: #23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: #24108 Refs: #22519 Refs: #23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Trott
commented
Dec 29, 2018
The deprecation warning causes an npm test to fail, at least when run via our # Subtest: tarball paths should update port if updating protocol not ok 1 - no error output --- found: > (node:51947) [DEP0115] DeprecationWarning: crypto.pseudoRandomBytes is deprecated. wanted: '' compare: === at: line: 75 column: 9 file: test/tap/add-named-update-protocol-port.js type: globalHopefully npm/unique-slug#6 can land soon, but if not, I wonder if we should document We could also consider the Buffer constructor route and only produce a runtime warning on use outside of node_modules. Updating the npm test somehow may also be an option, I suppose, although it's not obvious to me how in this case, as the whole point of this test is probably to check that there isn't stderr output on success. |
tniessen
commented
Dec 29, 2018
@Trott I think npm/unique-slug#6 should land even if we un-deprecate I am +0.5 on the deprecation itself. I suggested documentation as an alternative, but I still prefer the deprecation. |
addaleax
commented
Dec 30, 2018
Aliases are very cheap, and if this adds a deprecation warning to npm output in some cases, I’d prefer to undo the deprecation (or make it a |
tniessen
commented
Dec 30, 2018
addaleax
commented
Dec 30, 2018
@tniessen oh, ha 😄 Is there actually anything to do for us then? Does the npm test still fail without |
Oh, right, I have Heh, the test still fails on master but not because of this. It's instead because it gets this warning: npm WARN npm npm does not support Node.js v12.0.0-preThe test in question is making sure that there are no warnings emitted. So as-is, I suppose it will always fail on master. Wonder if we should make it an expected failure in our wrapper or if the test itself should be updated to be tolerant about EDIT: Will be solved by updating core's npm from 6.5.0-next to 6.5.0. So: There's no problem. |
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: nodejs#24108 Refs: nodejs#22519 Refs: nodejs#23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
There are three aliases for
crypto.randomBytesnow, all of them are undocumented. I think we should strive to have as little undocumented API surface as possible, so the next logical step would be to either document or deprecate these aliases.crypto.pseudoRandomBytesused to be a different function but became an alias forcrypto.randomBytesin #557 (three years ago). It has been undocumented ever since and is rarely used within the ecosystem.The other two aliases,
crypto.rngandcrypto.prnghave never been documented as far as I can tell and their names are unintuitive for people who are not familiar with crypto and the concept of CSRNGs / CSPRNGs.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes