Skip to content

Commit

Permalink
Fix typo options.header is not a documented option +
Browse files Browse the repository at this point in the history
Fix - do not modify the options.headers object
  • Loading branch information
simov committed Aug 8, 2015
1 parent 7b9f509 commit 5feaa5b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ JWT.decode = function (jwt, options) {
JWT.sign = function(payload, secretOrPrivateKey, options) {
options = options || {};

var header = ((typeof options.headers === 'object') && options.headers) || {};
var header = {};

if (typeof payload === 'object') {
header.typ = 'JWT';
}

header.alg = options.algorithm || 'HS256';

if (options.header) {
Object.keys(options.header).forEach(function (k) {
header[k] = options.header[k];
if (options.headers) {
Object.keys(options.headers).forEach(function (k) {
header[k] = options.headers[k];
});
}

Expand Down

0 comments on commit 5feaa5b

Please sign in to comment.