Skip to content

Commit b412be9

Browse files
committed
Simpler PR which implements the changes from #249.
1 parent 771e0b5 commit b412be9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

sign.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ var sign_options_schema = Joi.object().keys({
1414
issuer: Joi.string(),
1515
subject: Joi.string(),
1616
jwtid: Joi.string(),
17-
noTimestamp: Joi.boolean()
17+
noTimestamp: Joi.boolean(),
18+
keyid: Joi.string()
1819
});
1920

2021
var registered_claims_schema = Joi.object().keys({
@@ -49,7 +50,8 @@ module.exports = function (payload, secretOrPrivateKey, options, callback) {
4950

5051
var header = xtend({
5152
alg: options.algorithm || 'HS256',
52-
typ: isObjectPayload ? 'JWT' : undefined
53+
typ: isObjectPayload ? 'JWT' : undefined,
54+
kid: options.keyid
5355
}, options.header);
5456

5557
function failure(err) {

test/keyid.tests.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var jwt = require('../index');
2+
3+
var claims = {"name": "doron", "age": 46};
4+
jwt.sign(claims, 'secret', {"keyid": "1234"}, function(err, good) {
5+
console.log(jwt.decode(good, {"complete": true}).header.kid);
6+
jwt.verify(good, 'secret', function(err, result) {
7+
console.log(result);
8+
})
9+
});

0 commit comments

Comments
 (0)