Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = function (jwtString, secretOrPublicKey, options, callback) {
options = {};
}

//clone this object since we are going to mutate it.
options = Object.assign({}, options);

let done;
Expand All @@ -46,6 +45,12 @@ module.exports = function (jwtString, secretOrPublicKey, options, callback) {
return done(new JsonWebTokenError('clockTimestamp must be a number'));
}

if (options.clockTolerance !== undefined && options.clockTolerance > 300) {
return done(new JsonWebTokenError(
'clockTolerance must not exceed 300 seconds to prevent accidental expiry bypass'
));
}

if (options.nonce !== undefined && (typeof options.nonce !== 'string' || options.nonce.trim() === '')) {
return done(new JsonWebTokenError('nonce must be a non-empty string'));
}
Expand Down Expand Up @@ -260,4 +265,4 @@ module.exports = function (jwtString, secretOrPublicKey, options, callback) {

return done(null, payload);
});
};
};