Skip to content

Commit

Permalink
fix: honour the JWT.sign jti option
Browse files Browse the repository at this point in the history
fixes #33
  • Loading branch information
panva committed Jul 14, 2019
1 parent 10a1b64 commit 36c9ce2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jwt/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module.exports = (payload, key, options = {}) => {
sub: subject || payload.sub,
aud: audience || payload.aud,
iss: issuer || payload.iss,
jti: jti || payload.jti,
iat: iat ? unix : payload.iat,
nonce: nonce || payload.nonce,
exp: expiresIn ? unix + secs(expiresIn) : payload.exp,
Expand Down
6 changes: 6 additions & 0 deletions test/jwt/sign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ test('options.issuer', t => {
t.is(iss, issuer)
})

test('options.jti', t => {
const jti = 'foo'
const decoded = JWT.decode(JWT.sign({}, key, { jti }))
t.is(decoded.jti, jti)
})

test('options.iat false', t => {
const iat = false
t.deepEqual(JWT.decode(JWT.sign({}, key, { iat })), {})
Expand Down

0 comments on commit 36c9ce2

Please sign in to comment.