mirror of
https://github.com/hanzoai/node-jsonwebtoken.git
synced 2026-09-24 17:00:48 +00:00
Allow passing JOSE headers to sign function
Any properties of options.headers are added to the header passed to jws.
This commit is contained in:
@@ -8,7 +8,9 @@ module.exports.decode = function (jwt) {
|
||||
module.exports.sign = function(payload, secretOrPrivateKey, options) {
|
||||
options = options || {};
|
||||
|
||||
var header = {typ: 'JWT', alg: options.algorithm || 'HS256'};
|
||||
var header = ((typeof options.headers === 'object') && options.headers) || {};
|
||||
header.typ = 'JWT';
|
||||
header.alg = options.algorithm || 'HS256';
|
||||
|
||||
payload.iat = Math.floor(Date.now() / 1000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user