Added options parameters to decode method of jsonwebtoken

Added options parameters to decode method of jsonwebtoken
This commit is contained in:
Chris Pearce 2016-02-12 03:56:28 +00:00
parent 44c9273e1e
commit 8d9e2d7993
2 changed files with 13 additions and 1 deletions

View File

@ -74,3 +74,9 @@ jwt.verify(token, cert, { ignoreExpiration: true }, function(err, decoded) {
* https://github.com/auth0/node-jsonwebtoken#jwtdecodetoken
*/
var decoded = jwt.decode(token);
decoded = jwt.decode(token, { complete: false });
decoded = jwt.decode(token, { json: false });
decoded = jwt.decode(token, { complete: false, json: false });

View File

@ -43,6 +43,11 @@ declare module "jsonwebtoken" {
maxAge?: string;
}
export interface DecodeOptions {
complete?: boolean;
json?: boolean;
}
export interface VerifyCallback {
(err: Error, decoded: any): void;
}
@ -93,7 +98,8 @@ declare module "jsonwebtoken" {
/**
* Returns the decoded payload without verifying if the signature is valid.
* @param {String} token - JWT string to decode
* @param {DecodeOptions} [options] - Options for decoding
* @returns {Object} The decoded Token
*/
function decode(token: string): any;
function decode(token: string, options?: DecodeOptions): any;
}