Skip to content

Commit

Permalink
Revert "Merge branch 'venatir-master'"
Browse files Browse the repository at this point in the history
This reverts commit d66d4eb, reversing
changes made to 5117aac.
  • Loading branch information
jfromaniello committed Aug 11, 2016
1 parent 51c4fef commit d06359e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions test/verify.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('verify', function() {
var priv = fs.readFileSync(path.join(__dirname, 'priv.pem'));

it('should first assume JSON claim set', function (done) {
var header = { typ: 'JWT', alg: 'RS256' };
var header = { alg: 'RS256' };
var payload = { iat: Math.floor(Date.now() / 1000 ) };

var signed = jws.sign({
Expand All @@ -21,15 +21,15 @@ describe('verify', function() {
encoding: 'utf8'
});

jwt.verify(signed, pub, function(err, p) {
jwt.verify(signed, pub, {typ: 'JWT'}, function(err, p) {
assert.isNull(err);
assert.deepEqual(p, payload);
done();
});
});

it('should be able to validate unsigned token', function (done) {
var header = { typ: 'JWT', alg: 'none' };
var header = { alg: 'none' };
var payload = { iat: Math.floor(Date.now() / 1000 ) };

var signed = jws.sign({
Expand All @@ -39,7 +39,7 @@ describe('verify', function() {
encoding: 'utf8'
});

jwt.verify(signed, null, function(err, p) {
jwt.verify(signed, null, {typ: 'JWT'}, function(err, p) {
assert.isNull(err);
assert.deepEqual(p, payload);
done();
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('verify', function() {

it('should not error on expired token within clockTolerance interval', function (done) {
clock = sinon.useFakeTimers(1437018584000);
var options = {algorithms: ['HS256'], clockTolerance: 100};
var options = {algorithms: ['HS256'], clockTolerance: 100}

jwt.verify(token, key, options, function (err, p) {
assert.isNull(err);
Expand Down
8 changes: 7 additions & 1 deletion verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ module.exports = function (jwtString, secretOrPublicKey, options, callback) {
if (!valid)
return done(new JsonWebTokenError('invalid signature'));

var payload=decodedToken.payload;
var payload;

try {
payload = decode(jwtString);
} catch(err) {
return done(err);
}

if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
if (typeof payload.nbf !== 'number') {
Expand Down

0 comments on commit d06359e

Please sign in to comment.