fastify-jwt
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -212,3 +212,8 @@ 'use strict' | ||
function verify (secretOrPublicKey, callback) { | ||
jwt.verify(token, secretOrPublicKey, options, callback) | ||
jwt.verify(token, secretOrPublicKey, options, (err, result) => { | ||
if (err instanceof jwt.TokenExpiredError) { | ||
return callback(new Unauthorized('Authorization token expired')) | ||
} | ||
callback(err, result) | ||
}) | ||
} | ||
@@ -215,0 +220,0 @@ ], function (err, result) { |
{ | ||
"name": "fastify-jwt", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "JWT utils for Fastify", | ||
@@ -5,0 +5,0 @@ "main": "jwt.js", |
22
test.js
@@ -1291,3 +1291,3 @@ 'use strict' | ||
test('errors', function (t) { | ||
t.plan(5) | ||
t.plan(6) | ||
@@ -1390,2 +1390,22 @@ const fastify = Fastify() | ||
t.test('Expired token error', function (t) { | ||
t.plan(2) | ||
const expiredToken = fastify.jwt.sign({ | ||
exp: Math.floor(Date.now() / 1000) - 60, | ||
foo: 'bar' | ||
}) | ||
fastify.inject({ | ||
method: 'get', | ||
url: '/verify', | ||
headers: { | ||
authorization: `Bearer ${expiredToken}` | ||
} | ||
}).then(function (response) { | ||
const error = JSON.parse(response.payload) | ||
t.is(error.message, 'Authorization token expired') | ||
t.is(response.statusCode, 401) | ||
}) | ||
}) | ||
t.test('requestVerify function: steed.waterfall error function loop test', function (t) { | ||
@@ -1392,0 +1412,0 @@ t.plan(3) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68137
1429