-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add documentation to functions #1008
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,6 +83,29 @@ const options_for_objects = [ | |||||||||||||||||||||||||||||
| 'jwtid', | ||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * (Asynchronous) If a callback is supplied, the callback is called with the err or the JWT. | ||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||
| * (Synchronous) Returns the JsonWebToken as string | ||||||||||||||||||||||||||||||
| * @param {object | Buffer | string} payload Represents valid JSON. | ||||||||||||||||||||||||||||||
| * @param {string | Buffer | object | KeyObject} secretOrPrivateKey Contains either the secret for HMAC algorithms or the PEM encoded private key for RSA and ECDSA. In case of a private key with passphrase an object `{ key, passphrase }` can be used (based on [crypto documentation](https://nodejs.org/api/crypto.html#crypto_sign_sign_private_key_output_format)), in this case be sure you pass the `algorithm` option. When signing with RSA algorithms the minimum modulus length is 2048 except when the allowInsecureKeySizes option is set to true. Private keys below this size will be rejected with an error. | ||||||||||||||||||||||||||||||
| * @param {object?} options Options | ||||||||||||||||||||||||||||||
| * @param {string} options.algorithm (default: `HS256`) | ||||||||||||||||||||||||||||||
| * @param {string | number} options.expiresIn Expressed in seconds or a string describing a time span vercel/ms. | ||||||||||||||||||||||||||||||
| * @param {string | number} options.notBefore Expressed in seconds or a string describing a time span vercel/ms. | ||||||||||||||||||||||||||||||
| * @param options.audience | ||||||||||||||||||||||||||||||
| * @param options.issuer | ||||||||||||||||||||||||||||||
| * @param options.jwtid | ||||||||||||||||||||||||||||||
| * @param options.subject | ||||||||||||||||||||||||||||||
| * @param options.noTimestamp | ||||||||||||||||||||||||||||||
| * @param options.header | ||||||||||||||||||||||||||||||
| * @param options.keyid | ||||||||||||||||||||||||||||||
|
Comment on lines
+96
to
+102
|
||||||||||||||||||||||||||||||
| * @param options.audience | |
| * @param options.issuer | |
| * @param options.jwtid | |
| * @param options.subject | |
| * @param options.noTimestamp | |
| * @param options.header | |
| * @param options.keyid | |
| * @param {string | string[]} options.audience Identifies the recipients that the JWT is intended for (`aud` claim). | |
| * @param {string} options.issuer Identifies the principal that issued the JWT (`iss` claim). | |
| * @param {string} options.jwtid Unique identifier for the JWT (`jti` claim). | |
| * @param {string} options.subject Identifies the principal that is the subject of the JWT (`sub` claim). | |
| * @param {boolean} options.noTimestamp If `true`, do not automatically include the `iat` (issued at) claim. | |
| * @param {object} options.header Additional JWT header fields to include in the token header. | |
| * @param {string} options.keyid Key identifier to set as the `kid` field in the token header. |
Copilot
AI
Dec 18, 2025
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.
Spelling error: "compatability" should be "compatibility".
| * @param {boolean} options.allowInvalidAsymmetricKeyTypes If `true`, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatability and should be avoided. | |
| * @param {boolean} options.allowInvalidAsymmetricKeyTypes If `true`, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatibility and should be avoided. |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,31 @@ if (PS_SUPPORTED) { | |||||||||
| RSA_KEY_ALGS.splice(RSA_KEY_ALGS.length, 0, 'PS256', 'PS384', 'PS512'); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * (Asynchronous) If a callback is supplied, function acts asynchronously. The callback is called with the decoded payload if the signature is valid and optional expiration, audience, or issuer are valid. If not, it will be called with the error. | ||||||||||
| * | ||||||||||
| * (Synchronous) If a callback is not supplied, function acts synchronously. Returns the payload decoded if the signature is valid and optional expiration, audience, or issuer are valid. If not, it will throw the error. | ||||||||||
| * | ||||||||||
| * > Warning: When the token comes from an untrusted source (e.g. user input or external requests), the returned decoded payload should be treated like any other user input; please make sure to sanitize and only work with properties that are expected. | ||||||||||
| * @param {string} jwtString The JsonWebToken string | ||||||||||
| * @param {string | Buffer | KeyObject} secretOrPublicKey Contains either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA. If `jwt.verify` is called asynchronous, `secretOrPublicKey` can be a function that should fetch the secret or public key. | ||||||||||
| * @param {object?} options Options | ||||||||||
| * @param {string[]} options.algorithms List of string with the names of the allowed algorithms. | ||||||||||
|
||||||||||
| * @param {string[]} options.algorithms List of string with the names of the allowed algorithms. | |
| * @param {string[]} options.algorithms List of strings with the names of the allowed algorithms. |
Copilot
AI
Dec 18, 2025
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 documentation for the options.ignoreNotBefore parameter is incomplete and contains a placeholder ("..."). This should be replaced with a proper description of what this option does. Based on the parameter name, it should likely describe that if true, it does not validate the nbf (not before) claim of the token.
| * @param options.ignoreNotBefore ... | |
| * @param {boolean} options.ignoreNotBefore If `true` do not validate the not before (`nbf`) claim of the token. |
Copilot
AI
Dec 18, 2025
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 options.subject parameter is missing a type annotation. To maintain consistency with other documented parameters, it should include a type (likely {string} based on the validation code that checks payload.sub !== options.subject).
| * @param options.subject If you want to check subject (`sub`), provide a value here. | |
| * @param {string} options.subject If you want to check subject (`sub`), provide a value here. |
Copilot
AI
Dec 18, 2025
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 options.allowInvalidAsymmetricKeyTypes parameter is missing a type annotation. To maintain consistency with other documented parameters like options.ignoreExpiration and options.complete, it should include {boolean} as its type.
| * @param options.allowInvalidAsymmetricKeyTypes If true, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatability and should be avoided. | |
| * @param {boolean} options.allowInvalidAsymmetricKeyTypes If true, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatability and should be avoided. |
Copilot
AI
Dec 18, 2025
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.
Spelling error: "compatability" should be "compatibility".
| * @param options.allowInvalidAsymmetricKeyTypes If true, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatability and should be avoided. | |
| * @param options.allowInvalidAsymmetricKeyTypes If true, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatibility and should be avoided. |
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 type annotation for
options.jsonshould be{boolean}instead of{object}. The description indicates this is a boolean flag to force JSON.parse, and examining the JSDoc conventions, boolean options use the{boolean}type annotation.