Skip to content

Commit

Permalink
feat!: Fastify 5 and Node 20 support. Backwards incompatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvzen committed Oct 9, 2024
1 parent 062d43c commit 38ca503
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,6 @@ function fastifyJwtJwks(instance, options, done) {
}
}

module.exports = fastifyPlugin(fastifyJwtJwks, { name: 'fastify-jwt-jwks', fastify: '4.x' })
module.exports = fastifyPlugin(fastifyJwtJwks, { name: 'fastify-jwt-jwks', fastify: '5.x' })
module.exports.default = fastifyJwtJwks
module.exports.fastifyJwtJwks = fastifyJwtJwks
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"lint": "eslint index.js test test-integration"
},
"dependencies": {
"@fastify/cookie": "^8.0.0",
"@fastify/jwt": "^7.2.3",
"fastify-plugin": "^4.0.0",
"@fastify/cookie": "^10.0.1",
"@fastify/jwt": "^9.0.1",
"fastify-plugin": "^5.0.1",
"http-errors": "^2.0.0",
"node-cache": "^5.0.1",
"node-fetch": "^2.6.1"
Expand All @@ -62,15 +62,15 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.1",
"fast-jwt": "^3.3.2",
"fastify": "^4.0.2",
"fastify": "^5.0.0",
"jest": "^29.0.0",
"nock": "^13.0.2",
"oauth2-mock-server": "^5.0.2",
"oauth2-mock-server": "^7.1.2",
"prettier": "^2.0.5",
"tsd": "^0.28.0",
"typescript": "^5.0.2"
},
"engines": {
"node": ">= 14.0.0"
"node": ">= 20"
}
}
13 changes: 6 additions & 7 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ describe('JWT token decoding', function () {
it('should complain if the HTTP Authorization header is in the wrong format', async function () {
const response = await server.inject({ method: 'GET', url: '/decode', headers: { Authorization: 'FOO' } })

expect(response.statusCode).toEqual(400)
expect(response.statusCode).toEqual(401)
expect(response.json()).toEqual({
code: 'FST_JWT_BAD_REQUEST',
statusCode: 400,
error: 'Bad Request',
message: 'Format is Authorization: Bearer [token]'
code: 'FST_JWT_NO_AUTHORIZATION_IN_HEADER',
statusCode: 401,
error: 'Unauthorized',
message: 'No Authorization was found in request.headers'
})
})
})
Expand Down Expand Up @@ -992,7 +992,6 @@ describe('General error handling', function () {

it('should complain if the HTTP Authorization header is missing', async function () {
const response = await server.inject({ method: 'GET', url: '/verify' })

expect(response.statusCode).toEqual(401)
expect(response.json()).toEqual({
statusCode: 401,
Expand All @@ -1008,7 +1007,7 @@ describe('General error handling', function () {
expect(response.json()).toEqual({
statusCode: 401,
error: 'Unauthorized',
message: 'Authorization header should be in format: Bearer [token].'
message: 'Missing Authorization HTTP header.'
})
})

Expand Down

0 comments on commit 38ca503

Please sign in to comment.