@fastify/jwt
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -17,3 +17,3 @@ # Certificates generation | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
@@ -47,3 +47,3 @@ fastify.register(jwt, { | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
@@ -79,3 +79,3 @@ fastify.register(jwt, { | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
@@ -109,3 +109,3 @@ fastify.register(jwt, { | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
@@ -112,0 +112,0 @@ fastify.register(jwt, { |
{ | ||
"name": "@fastify/jwt", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "JWT utils for Fastify", | ||
@@ -44,5 +44,5 @@ "main": "jwt.js", | ||
"devDependencies": { | ||
"@fastify/cookie": "^6.0.0", | ||
"@types/node": "^17.0.21", | ||
"fastify": "^3.27.2", | ||
"fastify-cookie": "^5.6.0", | ||
"pre-commit": "^1.2.2", | ||
@@ -49,0 +49,0 @@ "standard": "^17.0.0", |
@@ -1,5 +0,5 @@ | ||
# fastify-jwt | ||
# @fastify/jwt | ||
![CI](https://github.com/fastify/fastify-jwt/workflows/CI/badge.svg) | ||
[![NPM version](https://img.shields.io/npm/v/fastify-jwt.svg?style=flat)](https://www.npmjs.com/package/fastify-jwt) | ||
[![NPM version](https://img.shields.io/npm/v/@fastify/jwt.svg?style=flat)](https://www.npmjs.com/package/@fastify/jwt) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-jwt/badge.svg)](https://snyk.io/test/github/fastify/fastify-jwt) | ||
@@ -12,4 +12,4 @@ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) | ||
`fastify-jwt` supports Fastify@3. | ||
`fastify-jwt` [v1.x](https://github.com/fastify/fastify-jwt/tree/1.x) | ||
`@fastify/jwt` supports Fastify@3. | ||
`@fastify/jwt` [v1.x](https://github.com/fastify/fastify-jwt/tree/1.x) | ||
supports both Fastify@2. | ||
@@ -19,3 +19,3 @@ | ||
``` | ||
npm i fastify-jwt --save | ||
npm i @fastify/jwt --save | ||
``` | ||
@@ -28,3 +28,3 @@ | ||
const fastify = require('fastify')() | ||
fastify.register(require('fastify-jwt'), { | ||
fastify.register(require('@fastify/jwt'), { | ||
secret: 'supersecret' | ||
@@ -48,3 +48,3 @@ }) | ||
const fastify = require('fastify')() | ||
fastify.register(require('fastify-jwt'), { | ||
fastify.register(require('@fastify/jwt'), { | ||
secret: 'supersecret' | ||
@@ -78,3 +78,3 @@ }) | ||
module.exports = fp(async function(fastify, opts) { | ||
fastify.register(require("fastify-jwt"), { | ||
fastify.register(require("@fastify/jwt"), { | ||
secret: "supersecret" | ||
@@ -109,3 +109,3 @@ }) | ||
Make sure that you also check [fastify-auth](https://github.com/fastify/fastify-auth) plugin for composing more complex strategies. | ||
Make sure that you also check [@fastify/auth](https://github.com/fastify/fastify-auth) plugin for composing more complex strategies. | ||
@@ -132,3 +132,3 @@ ### Auth0 tokens verification | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
// secret as a string | ||
@@ -177,3 +177,3 @@ fastify.register(jwt, { secret: 'supersecret' }) | ||
``` | ||
Optionally you can define global default options that will be used by `fastify-jwt` API if you do not override them. | ||
Optionally you can define global default options that will be used by `@fastify/jwt` API if you do not override them. | ||
@@ -187,3 +187,3 @@ Additionally, it is also possible to reject tokens selectively (i.e. blacklisting) by providing the option `trusted` with the following signature: `(request, decodedToken) => boolean|Promise<boolean>|SignPayloadType|Promise<SignPayloadType>` where `request` is a `FastifyRequest` and `decodedToken` is the parsed (and verified) token information. Its result should be `false` or `Promise<false>` if the token should be rejected or, otherwise, be `true` or `Promise<true>` if the token should be accepted and, considering that `request.user` will be used after that, the return should be `decodedToken` itself. | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
fastify.register(jwt, { | ||
@@ -256,5 +256,5 @@ secret: { | ||
In some situations you may want to store a token in a cookie. This allows you to drastically reduce the attack surface of XSS on your web app with the [`httpOnly`](https://wiki.owasp.org/index.php/HttpOnly) and `secure` flags. Cookies can be susceptible to CSRF. You can mitigate this by either setting the [`sameSite`](https://www.owasp.org/index.php/SameSite) flag to `strict`, or by using a CSRF library such as [`fastify-csrf`](https://www.npmjs.com/package/fastify-csrf). | ||
In some situations you may want to store a token in a cookie. This allows you to drastically reduce the attack surface of XSS on your web app with the [`httpOnly`](https://wiki.owasp.org/index.php/HttpOnly) and `secure` flags. Cookies can be susceptible to CSRF. You can mitigate this by either setting the [`sameSite`](https://www.owasp.org/index.php/SameSite) flag to `strict`, or by using a CSRF library such as [`@fastify/csrf`](https://www.npmjs.com/package/@fastify/csrf). | ||
**Note:** This plugin will look for a decorated request with the `cookies` property. [`fastify-cookie`](https://www.npmjs.com/package/fastify-cookie) supports this feature, and therefore you should use it when using the cookie feature. The plugin will fallback to looking for the token in the authorization header if either of the following happens (even if the cookie option is enabled): | ||
**Note:** This plugin will look for a decorated request with the `cookies` property. [`@fastify/cookie`](https://www.npmjs.com/package/@fastify/cookie) supports this feature, and therefore you should use it when using the cookie feature. The plugin will fallback to looking for the token in the authorization header if either of the following happens (even if the cookie option is enabled): | ||
@@ -268,3 +268,3 @@ - The request has both the authorization and cookie header | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
@@ -280,3 +280,3 @@ fastify.register(jwt, { | ||
fastify | ||
.register(require('fastify-cookie')) | ||
.register(require('@fastify/cookie')) | ||
@@ -318,3 +318,3 @@ fastify.get('/cookies', async (request, reply) => { | ||
fastify.register(require('fastify-jwt'), { | ||
fastify.register(require('@fastify/jwt'), { | ||
secret: 'foobar', | ||
@@ -351,3 +351,3 @@ trusted: validateToken | ||
const fastify = require('fastify')(); | ||
fastify.register(require('fastify-jwt'), { | ||
fastify.register(require('@fastify/jwt'), { | ||
formatUser: function (user) { | ||
@@ -422,3 +422,3 @@ return { | ||
fastify.register(require('fastify-jwt'), { | ||
fastify.register(require('@fastify/jwt'), { | ||
secret: 'supersecret', | ||
@@ -497,3 +497,3 @@ messages: myCustomMessages | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
fastify.register(jwt, { | ||
@@ -574,3 +574,3 @@ secret: { | ||
The following algorithms are currently supported by [fast-jwt](https://github.com/nearform/fast-jwt) that is internally used by `fastify-jwt`. | ||
The following algorithms are currently supported by [fast-jwt](https://github.com/nearform/fast-jwt) that is internally used by `@fastify/jwt`. | ||
@@ -605,3 +605,3 @@ **Name** | **Description** | ||
const fastify = require('fastify')() | ||
const jwt = require('fastify-jwt') | ||
const jwt = require('@fastify/jwt') | ||
const request = require('request') | ||
@@ -673,3 +673,3 @@ | ||
const Fastify = require('fastify') | ||
const fjwt = require('fastify-jwt') | ||
const fjwt = require('@fastify/jwt') | ||
const buildGetJwks = require('get-jwks') | ||
@@ -706,3 +706,3 @@ | ||
```ts | ||
import fastifyJwt, { FastifyJWTOptions } from 'fastify-jwt' | ||
import fastifyJwt, { FastifyJWTOptions } from '@fastify/jwt' | ||
``` | ||
@@ -716,5 +716,5 @@ | ||
// fastify-jwt.d.ts | ||
import "fastify-jwt" | ||
import "@fastify/jwt" | ||
declare module "fastify-jwt" { | ||
declare module "@fastify/jwt" { | ||
interface FastifyJWT { | ||
@@ -721,0 +721,0 @@ payload: { id: number } // payload type is used for signing and verifying |
## Upgrading Notes | ||
This document captures breaking changes between versions of `fastify-jwt`. | ||
This document captures breaking changes between versions of `@fastify/jwt`. | ||
@@ -4,0 +4,0 @@ ### Upgrading from 3.x to 4.0 |
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
140490
2