diff --git a/lib/index.js b/lib/index.js index 575875b..fce7444 100644 --- a/lib/index.js +++ b/lib/index.js @@ -243,13 +243,18 @@ function getSecret (request, secret, token, callback) { return callback({ code: 'invalid_token', message: 'jwt signature is required' }); } - let decodedToken = jwt.decode(token); + let decodedToken = jwt.decode(token, { complete: true }); if (!decodedToken) { return callback({ code: 'invalid_token', message: 'jwt malformed' }); } - secret(request, decodedToken, callback); + const arity = secret.length; + if (arity == 4) { + secret(request, decodedToken.header, decodedToken.payload, callback); + } else { // arity == 3 + secret(request, decodedToken.payload, callback); + } } else { callback(null, secret); }