Implement throwError option for .verify().
This commit is contained in:
3
index.d.ts
vendored
3
index.d.ts
vendored
@@ -13,6 +13,7 @@ declare class JWT {
|
||||
* @param {object} payload The payload object. To use `nbf` (Not Before) and/or `exp` (Expiration Time) add `nbf` and/or `exp` to the payload.
|
||||
* @param {string} secret A string which is used to sign the payload.
|
||||
* @param {JWTSignOptions | JWTAlgorithm} options The options object or the algorithm.
|
||||
* @throws {Error} If there's a validation issue.
|
||||
* @returns {Promise<string>} Returns token as a `string`.
|
||||
*/
|
||||
sign(payload: object, secret: string, options?: JWTSignOptions | JWTAlgorithm): Promise<string>
|
||||
@@ -23,6 +24,7 @@ declare class JWT {
|
||||
* @param {string} token The token string generated by `jwt.sign()`.
|
||||
* @param {string} secret The string which was used to sign the payload.
|
||||
* @param {JWTVerifyOptions | JWTAlgorithm} options The options object or the algorithm.
|
||||
* @throws {Error | string} Throws an error `string` if the token is invalid or an `Error-Object` if there's a validation issue.
|
||||
* @returns {Promise<boolean>} Returns `true` if signature, `nbf` (if set) and `exp` (if set) are valid, otherwise returns `false`.
|
||||
*/
|
||||
verify(token: string, secret: string, options?: JWTVerifyOptions | JWTAlgorithm): Promise<boolean>
|
||||
@@ -46,6 +48,7 @@ type JWTSignOptions = {
|
||||
|
||||
type JWTVerifyOptions = {
|
||||
algorithm?: JWTAlgorithm
|
||||
throwError?: boolean
|
||||
}
|
||||
|
||||
export = _exports
|
||||
Reference in New Issue
Block a user