jsonwebtoken
Advanced tools
Comparing version 5.5.2 to 5.5.3
20
index.js
@@ -41,5 +41,15 @@ var jws = require('jws'); | ||
var payload_options = [ | ||
'expiresIn', | ||
'notBefore', | ||
'expiresInMinutes', | ||
'expiresInSeconds', | ||
'audience', | ||
'issuer', | ||
'subject', | ||
'jwtid' | ||
]; | ||
JWT.sign = function(payload, secretOrPrivateKey, options, callback) { | ||
options = options || {}; | ||
payload = typeof payload === 'object' ? xtend(payload) : payload; | ||
var header = {}; | ||
@@ -49,4 +59,12 @@ | ||
header.typ = 'JWT'; | ||
payload = xtend(payload); | ||
} else { | ||
var invalid_option = payload_options.filter(function (key) { | ||
return typeof options[key] !== 'undefined'; | ||
})[0]; | ||
console.warn('invalid "' + invalid_option + '" option for ' + (typeof payload) + ' payload'); | ||
} | ||
header.alg = options.algorithm || 'HS256'; | ||
@@ -53,0 +71,0 @@ |
{ | ||
"name": "jsonwebtoken", | ||
"version": "5.5.2", | ||
"version": "5.5.3", | ||
"description": "JSON Web Token implementation (symmetric and asymmetric)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,2 +13,9 @@ var jwt = require('../index'); | ||
//v6 version will throw in this case: | ||
it.skip('should throw with expiresIn', function () { | ||
expect(function () { | ||
jwt.sign('hello', '123', { expiresIn: '12h' }); | ||
}).to.throw(/invalid expiresIn option for string payload/); | ||
}); | ||
it('should fail to validate audience when the payload is string', function () { | ||
@@ -15,0 +22,0 @@ var token = jwt.sign('hello', '123'); |
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
63804
1051