-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: synchronise with doc #14805
crypto: synchronise with doc #14805
Conversation
/cc @nodejs/documentation @nodejs/crypto |
Quick recheck: https://ci.nodejs.org/job/node-test-commit-linuxone/7934/ |
lib/crypto.js
Outdated
// Explicit conversion for backward compatibility. | ||
return this._handle.digest(`${outputEncoding}`); | ||
return this._handle.digest(`${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.
Why was this changed to a more generic name?
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.
To sync with the docs - https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding
Line 783 in 2e7ccc2
### hash.digest([encoding]) |
Changing the docs causes the
href
s to change
I'm not sure most of these changes are worth it. It's not necessary to ensure the documentation parameter names exactly match what are used internally. |
lib/crypto.js
Outdated
return function(argOne, buffer) { | ||
var key = argOne.key || argOne; | ||
var passphrase = argOne.passphrase || null; | ||
var padding = argOne.padding || defaultPadding; |
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.
options
seemed like the better name here?
lib/crypto.js
Outdated
var key = options.key || options; | ||
var padding = options.padding || defaultPadding; | ||
var passphrase = options.passphrase || null; | ||
function rsaBinder(method, defaultPadding) { |
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.
Um … “binder”?
Elsewhere in the code we name these things makeFoo
, so you could call it makeRSAMethod
or so if you at set on wanting to change the names.
exports.setEngine = function setEngine(id, flags) { | ||
if (typeof id !== 'string') | ||
exports.setEngine = function setEngine(engine, flags) { | ||
if (typeof engine !== 'string') | ||
throw new TypeError('"id" argument should be a string'); |
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 TypeError gets really weird now.
Also, if anything, engineID
is probably better.
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 know, there is at least another place like this.
I'll do the migration to internal/errors and fix these.
The reasoning to synchronize is to help with debugging, where you are exposed the "internal" arguments' names. |
@refack It’s okay to break links in the documentation so long as it’s updated throughout our docs. |
It's more delicate work. I'll give it another look if there are places where it's obviously better to break the docs. Also it breaks "permalinks" that might be embedded in other sites, so the change should really be worth it and I'd even categorize it |
doc/api/crypto.md
Outdated
@@ -1102,8 +1106,11 @@ changes: | |||
description: Support for RSASSA-PSS and additional options was added. | |||
--> | |||
- `object` {string | Object} | |||
- `key` {string | Buffer | TypedArray | DataView} |
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 has to be done in the list below the paragraph. All the options are explained there.
Ping @refack |
f676054
to
8d8f61c
Compare
8d8f61c
to
4f24fe1
Compare
@@ -978,9 +980,7 @@ changes: | |||
description: Support for RSASSA-PSS and additional options was added. | |||
--> | |||
- `privateKey` {string | Object} | |||
- `key` {string} |
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.
Description of Object
case in second paragraph L988
@mscdex @addaleax @thefourtheye addressed comments PTAL |
<!-- YAML | ||
added: v0.11.8 | ||
--> | ||
- `spkac` {string | Buffer | TypedArray | DataView} | ||
- `encoding` {string} (Default `utf-8`) used to encode the `spkac` into a Buffer |
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.
For string literal values, single quotes should be added inside the backticks: `'utf-8'`
<!-- YAML | ||
added: v0.11.8 | ||
--> | ||
- `spkac` {string | Buffer | TypedArray | DataView} | ||
- `encoding` {string} (Default `utf-8`) used to encode the `spkac` into a Buffer |
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
@@ -378,7 +380,7 @@ The `decipher.setAuthTag()` method must be called before | |||
<!-- YAML | |||
added: v0.7.1 | |||
--> | |||
- `autoPadding` {boolean} Defaults to `true`. | |||
- `autoPadding` {boolean} (Default `true`). |
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.
If we're going to switch these, we should do so consistently. There are other instances in this document.
My comment about changing the code still stands. |
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.
@refack Thank you!
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.
The doc changes LGTM but I would also prefer not to include the changes in crypto (besides the consolidation of the rsaPublic and rsaPrivate functions).
This needs a rebase. I think the doc changes could land soon otherwise. |
Ping @refack |
Closing due to long inactivity. @refack please feel free to reopen if you want to further pursue this! |
Fixes: #14800
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
crypto,doc