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

crypto: synchronise with doc #14805

Closed
wants to merge 4 commits into from
Closed

Conversation

refack
Copy link
Contributor

@refack refack commented Aug 13, 2017

Fixes: #14800

  • Improve description of formal args in doc
  • Rename formal arguments to match doc
  • Merge rsa binding factories
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

crypto,doc

@nodejs-github-bot nodejs-github-bot added the crypto Issues and PRs related to the crypto subsystem. label Aug 13, 2017
@refack
Copy link
Contributor Author

refack commented Aug 13, 2017

@refack
Copy link
Contributor Author

refack commented Aug 13, 2017

/cc @nodejs/documentation @nodejs/crypto

@refack
Copy link
Contributor Author

refack commented Aug 13, 2017

lib/crypto.js Outdated
// Explicit conversion for backward compatibility.
return this._handle.digest(`${outputEncoding}`);
return this._handle.digest(`${encoding}`);
Copy link
Contributor

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?

Copy link
Contributor Author

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

### hash.digest([encoding])

Changing the docs causes the hrefs to change

@mscdex
Copy link
Contributor

mscdex commented Aug 13, 2017

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;
Copy link
Member

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) {
Copy link
Member

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');
Copy link
Member

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.

Copy link
Contributor Author

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.

@refack refack added the doc Issues and PRs related to the documentations. label Aug 13, 2017
@refack
Copy link
Contributor Author

refack commented Aug 13, 2017

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.

The reasoning to synchronize is to help with debugging, where you are exposed the "internal" arguments' names.
In order not to break the docs linking I synchronized in one direction doc -> js.

@addaleax
Copy link
Member

@refack It’s okay to break links in the documentation so long as it’s updated throughout our docs.

@refack
Copy link
Contributor Author

refack commented Aug 13, 2017

@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 semver-major.

@@ -1102,8 +1106,11 @@ changes:
description: Support for RSASSA-PSS and additional options was added.
-->
- `object` {string | Object}
- `key` {string | Buffer | TypedArray | DataView}
Copy link
Contributor

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.

@BridgeAR
Copy link
Member

Ping @refack

@@ -978,9 +980,7 @@ changes:
description: Support for RSASSA-PSS and additional options was added.
-->
- `privateKey` {string | Object}
- `key` {string}
Copy link
Contributor Author

@refack refack Sep 13, 2017

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

@refack
Copy link
Contributor Author

refack commented Sep 13, 2017

@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
Copy link
Contributor

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
Copy link
Contributor

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`).
Copy link
Contributor

@mscdex mscdex Sep 14, 2017

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.

@mscdex
Copy link
Contributor

mscdex commented Sep 14, 2017

My comment about changing the code still stands.

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

@refack Thank you!

@addaleax
Copy link
Member

@refack Re: the code changes, it might be better to contribute that into #15231 than to do it in this PR

Copy link
Member

@BridgeAR BridgeAR left a 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).

@BridgeAR
Copy link
Member

This needs a rebase. I think the doc changes could land soon otherwise.

@refack refack self-assigned this Sep 23, 2017
@BridgeAR
Copy link
Member

Ping @refack

@BridgeAR
Copy link
Member

Closing due to long inactivity. @refack please feel free to reopen if you want to further pursue this!

@BridgeAR BridgeAR closed this Nov 22, 2017
@refack refack deleted the crypo-doc-buf branch September 5, 2018 22:30
@refack refack removed their assignment Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

password and salt parameter allows both string and buffer, but the doc only says string
6 participants