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 documentation update #14846

Closed
wants to merge 4 commits into from
Closed

Conversation

ashanhol
Copy link
Contributor

Updated crypto docs to include options argument.
Fixes: #14804

Checklist
Affected core subsystem(s)

doc

@nodejs-github-bot nodejs-github-bot added crypto Issues and PRs related to the crypto subsystem. doc Issues and PRs related to the documentations. labels Aug 16, 2017
@refack
Copy link
Contributor

refack commented Aug 16, 2017

@ashanhol welcome, and thank you for your contribution 🥇

@refack refack self-assigned this Aug 16, 2017
@refack
Copy link
Contributor

refack commented Aug 16, 2017

/cc @nodejs/documentation @nodejs/crypto @nodejs/streams

@vsemozhetbyt
Copy link
Contributor

Hi, @ashanhol. Thank you for improving the docs.
A nit: if I recall correctly, in type labels we use lower case for primitives only, so {object} should possibly be {Object}.

<!-- YAML
added: v0.1.94
-->
- `algorithm` {string}
- `password` {string | Buffer | TypedArray | DataView}
- `options` {object} combined [OpenSSL options][] and [`stream.transform` options][]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be stream.Transform since we're referencing a constructor.

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

LGTM assuming @vsemozhetbyt's nit and this one is addressed.

@@ -2247,3 +2258,5 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
[initialization vector]: https://en.wikipedia.org/wiki/Initialization_vector
[stream-writable-write]: stream.html#stream_writable_write_chunk_encoding_callback
[stream]: stream.html
[OpenSSL options]: #openssl-options
[`stream.transform` options]: stream.html#stream_new_stream_transform_options
Copy link
Member

Choose a reason for hiding this comment

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

Can you sort the references ASCIIbetically? See the references that are already there.

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

Sorry, but I'm going to have to renege on my LGTM earlier. Noticed some more issues with this...

<!-- YAML
added: v0.1.92
-->
- `algorithm` {string}
- `options` {object} combined [OpenSSL options][] and [`stream.transform` options][]
Copy link
Member

Choose a reason for hiding this comment

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

Actually for Sign it's stream.Writable:

node/lib/crypto.js

Lines 285 to 292 in 0d22858

function Sign(algorithm, options) {
if (!(this instanceof Sign))
return new Sign(algorithm, options);
this._handle = new binding.Sign();
this._handle.init(algorithm);
stream.Writable.call(this, options);
}

<!-- YAML
added: v0.1.92
-->
- `algorithm` {string}
- `options` {object} combined [OpenSSL options][] and [`stream.transform` options][]
Copy link
Member

Choose a reason for hiding this comment

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

It's stream.Writable for Verify too.

<!-- YAML
added: v0.1.94
-->
- `algorithm` {string}
- `password` {string | Buffer | TypedArray | DataView}
- `options` {object} combined [OpenSSL options][] and [`stream.transform` options][]
Copy link
Member

Choose a reason for hiding this comment

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

The options object isn't actually combined, but only used for streams:

node/lib/crypto.js

Lines 136 to 145 in 0d22858

function Cipher(cipher, password, options) {
if (!(this instanceof Cipher))
return new Cipher(cipher, password, options);
this._handle = new binding.CipherBase(true);
this._handle.init(cipher, toBuf(password));
this._decoder = null;
LazyTransform.call(this, options);
}

The first instance of options is used when the function is not called with new (it's passed back into itself).

Same goes for the other classes.

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Aug 16, 2017

It seems, there is one missing step. If we change headings in our docs, this also automatically changes anchors for href hashes. So for each changed heading we should search all the docs for previous hashes and update them.

You can get the old hashes from the TOC in the https://nodejs.org/api/crypto.html

For example the old one for ### crypto.createCipher(algorithm, password) was #crypto_crypto_createcipher_algorithm_password. So the new one for ### crypto.createCipher(algorithm, password[, options]) would be the #crypto_crypto_createcipher_algorithm_password_options if I get this right. There is a reference with the old hash in the crypto.md, but we also possibly should check all the doc files for such cases and update all the cross-links. I think, grepping all the *.md files with some tool for this fragments will do.

@refack
Copy link
Contributor

refack commented Aug 16, 2017

@ashanhol what I forgot to mention before is that documentation changes, while easy to do are more difficult to validate. With code we can write tests and the CI can validate the change. With documentation the only way to validate is with human eyes, so don't be dismayed.

@refack
Copy link
Contributor

refack commented Aug 16, 2017

It seems, there is one missing step. If we change headings in our docs, this also changes anchors and href hashes. So for each changed heading we should search all the docs for previous hashes and update them.

That's a real pain, we need to figure out an automatic way to do this...

@vsemozhetbyt
Copy link
Contributor

@refack If the #12756 makes it, we can at least think about a linting rule for such outdated hashes inside the doc system.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM with all the nits addressed.

@ashanhol
Copy link
Contributor Author

Thank you all for the feedback, I've made the suggested changes and grep'd the docs to make sure the old header links are updated.
@vsemozhetbyt @TimothyGu

@jasnell
Copy link
Member

jasnell commented Aug 23, 2017

Ping @TimothyGu ... have your concerns been addressed?

@BridgeAR
Copy link
Member

BridgeAR commented Sep 1, 2017

Ping @TimothyGu

@BridgeAR
Copy link
Member

BridgeAR commented Sep 3, 2017

I take that as a yes.

@ashanhol please rebase this as we otherwise can not land this cleanly. Currently there is a merge commit in here.

@ashanhol
Copy link
Contributor Author

ashanhol commented Sep 5, 2017

Hi @BridgeAR, seems a couple commits got duplicated somewhere. I did an interactive rebase and removed them so there's no merges. 👍

tniessen pushed a commit that referenced this pull request Sep 7, 2017
PR-URL: #14846
Fixes: #14804
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@tniessen
Copy link
Member

tniessen commented Sep 7, 2017

Landed in 4477155, thank you for your first contribution @ashanhol! 🎉

Some tips for future contributions:

  • If you can, it would be great if you format the commit title and message of the first commit of a PR according to our contribution guidelines.
  • You can use git's whitespace options to automatically check for trailing whitespace, and it is usually a good idea to configure your editor to automatically remove or highlight unnecessary whitespace. Usually, such nits are not a problem, but they can make merging your changes a little more difficult.

@tniessen tniessen closed this Sep 7, 2017
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
PR-URL: #14846
Fixes: #14804
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 11, 2017
PR-URL: #14846
Fixes: #14804
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
PR-URL: #14846
Fixes: #14804
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
addaleax pushed a commit to addaleax/node that referenced this pull request Sep 13, 2017
PR-URL: nodejs#14846
Fixes: nodejs#14804
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
@refack refack removed their assignment Oct 20, 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.

crypto: crypto.create* - argument "options" is undocumented