jsonwebtoken
Advanced tools
Comparing version 1.1.1 to 1.1.2
13
index.js
@@ -39,3 +39,3 @@ var jws = require('jws'); | ||
if (!jwtString) | ||
return callback(new JsonWebTokenError('jwt must be provided')); | ||
return callback(new JsonWebTokenError('jwt must be provided')); | ||
@@ -60,4 +60,10 @@ var parts = jwtString.split('.'); | ||
var payload = this.decode(jwtString); | ||
var payload; | ||
try { | ||
payload = this.decode(jwtString); | ||
} catch(err) { | ||
return callback(err); | ||
} | ||
if (payload.exp) { | ||
@@ -87,3 +93,4 @@ if (Math.floor(Date.now() / 1000) >= payload.exp) | ||
if (error) this.inner = error; | ||
} | ||
}; | ||
JsonWebTokenError.prototype = Object.create(Error.prototype); | ||
@@ -90,0 +97,0 @@ JsonWebTokenError.prototype.constructor = JsonWebTokenError; |
{ | ||
"name": "jsonwebtoken", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "JSON Web Token implementation (symmetric and asymmetric)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,3 +12,3 @@ var jwt = require('../index'); | ||
var token = jwt.sign({ foo: 'bar' }, secret, { algorithm: 'HS256' }); | ||
it('should be syntactically valid', function() { | ||
@@ -53,3 +53,10 @@ expect(token).to.be.a('string'); | ||
it.only('should throw when the payload is not json', function(done) { | ||
var token = jwt.sign('bar', 'secret', { algorithm: 'HS256' }); | ||
jwt.verify(token, 'secret', function() { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21899
298