Skip to content

Commit 36c9ce2

Browse files
committed
fix: honour the JWT.sign jti option
fixes #33
1 parent 10a1b64 commit 36c9ce2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/jwt/sign.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module.exports = (payload, key, options = {}) => {
6767
sub: subject || payload.sub,
6868
aud: audience || payload.aud,
6969
iss: issuer || payload.iss,
70+
jti: jti || payload.jti,
7071
iat: iat ? unix : payload.iat,
7172
nonce: nonce || payload.nonce,
7273
exp: expiresIn ? unix + secs(expiresIn) : payload.exp,

test/jwt/sign.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ test('options.issuer', t => {
102102
t.is(iss, issuer)
103103
})
104104

105+
test('options.jti', t => {
106+
const jti = 'foo'
107+
const decoded = JWT.decode(JWT.sign({}, key, { jti }))
108+
t.is(decoded.jti, jti)
109+
})
110+
105111
test('options.iat false', t => {
106112
const iat = false
107113
t.deepEqual(JWT.decode(JWT.sign({}, key, { iat })), {})

0 commit comments

Comments
 (0)