-
Notifications
You must be signed in to change notification settings - Fork 36
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
The secret can be any CipherKey, not just a String. #44
Conversation
Thanks, looks like this is a necessary comment-based documentation update for the work done on #33. I'm a bit unclear on using (They do mention something called Afaict there's no official type definitions for node.js, but my IDE relies on @types/node as I suspect many others do, and their current definition for |
index.js
Outdated
@@ -8,7 +8,7 @@ var crypto = require('crypto'); | |||
* Sign the given `val` with `secret`. | |||
* | |||
* @param {String} val | |||
* @param {String} secret | |||
* @param {crypto.CipherKey} secret |
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.
see background in the PR comments, but maybe @param {String|BinaryLike|KeyObject} secret
would be most clear here?
[technically "String" is already part of "BinaryLike" in the typescript defs that we're borrowing from, but I'd rather err on the side of people knowing a string is still fine here]
index.js
Outdated
@@ -28,7 +28,7 @@ exports.sign = function(val, secret){ | |||
* returning `false` if the signature is invalid. | |||
* | |||
* @param {String} input | |||
* @param {String} secret | |||
* @param {crypto.CipherKey} secret |
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.
[same here as whatever settled on above]
… match @types/node. NodeJS documentation: https://nodejs.org/api/crypto.html#cryptocreatehmacalgorithm-key-options @types/node: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0039ca2aaa/types/node/crypto.d.ts#L278
Ah, sorry for not explaining that. type CipherKey = BinaryLike | KeyObject; so just a shorthand for the argument type of +1 that including "String" is probably clearer for JS folks trying to refer to the nodejs docs. It might also be clearest to expand out |
Whoops, sorry I missed your updates here! Looks good to me, I'll merge and bump a patch release for this. |
Published as |
No description provided.