diff --git a/README.md b/README.md index 2b4bf1db..047adaa6 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,38 @@ -# fastify-passport +# @fastify/passport ![CI](https://github.com/fastify/fastify-passport/workflows/CI/badge.svg) -[![NPM version](https://img.shields.io/npm/v/fastify-passport.svg?style=flat)](https://www.npmjs.com/package/fastify-passport) +[![NPM version](https://img.shields.io/npm/v/fastify-passport.svg?style=flat)](https://www.npmjs.com/package/@fastify/passport) [![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-passport/badge.svg)](https://snyk.io/test/github/fastify/fastify-passport) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat)](https://github.com/prettier/prettier) -`fastify-passport` is a port of [`passport`](http://www.passportjs.org/) for the Fastify ecosystem. It lets you use Passport strategies to authenticate requests and protect Fastify routes! +`@fastify/passport` is a port of [`passport`](http://www.passportjs.org/) for the Fastify ecosystem. It lets you use Passport strategies to authenticate requests and protect Fastify routes! ## Status -Beta. `fastify-passport` is still a relatively new project. There may be incompatibilities with express-based `passport` deployments, and bugs. Please report any issues so we can correct them! +Beta. `@fastify/passport` is still a relatively new project. There may be incompatibilities with express-based `passport` deployments, and bugs. Please report any issues so we can correct them! ## Installation ```shell -npm install fastify-passport +npm install @fastify/passport ``` ## Google OAuth2 Video tutorial -The community created this fast introduction to `fastify-passport`: +The community created this fast introduction to `@fastify/passport`: [![Google OAuth2 Tutorial Passport](https://img.youtube.com/vi/XRcQQWU0XOM/0.jpg)](https://youtu.be/XRcQQWU0XOM) ## Example ```js -import fastifyPassport from 'fastify-passport' -import fastifySecureSession from 'fastify-secure-session' +import fastifyPassport from '@fastify/passport' +import fastifySecureSession from '@fastify/secure-session' const server = fastify() -// set up secure sessions for fastify-passport to store data in +// set up secure sessions for @fastify/passport to store data in server.register(fastifySecureSession, { key: fs.readFileSync(path.join(__dirname, 'secret-key')) }) -// initialize fastify-passport and connect it to the secure-session storage. Note: both of these plugins are mandatory. +// initialize @fastify/passport and connect it to the secure-session storage. Note: both of these plugins are mandatory. server.register(fastifyPassport.initialize()) server.register(fastifyPassport.secureSession()) @@ -60,8 +60,8 @@ Alternatively, [`@fastify/session`](https://github.com/fastify/session) is also Here's an example: ```js -import { Authenticator } from 'fastify-passport' -import fastifyCookie from 'fastify-cookie' +import { Authenticator } from '@fastify/passport' +import fastifyCookie from '@fastify/cookie' import fastifySession from '@fastify/session' const server = fastify() @@ -72,7 +72,7 @@ const fastifyPassport = new Authenticator() server.register(fastifyCookie) server.register(fastifySession, { secret: 'secret with minimum length of 32 characters' }) -// initialize fastify-passport and connect it to the secure-session storage. Note: both of these plugins are mandatory. +// initialize @fastify/passport and connect it to the secure-session storage. Note: both of these plugins are mandatory. server.register(fastifyPassport.initialize()) server.register(fastifyPassport.secureSession()) @@ -80,12 +80,12 @@ server.register(fastifyPassport.secureSession()) fastifyPassport.use('test', new SomePassportStrategy()) // you'd probably use some passport strategy from npm here ``` -## Difference between `fastify-secure-session` and `@fastify/session` -`fastify-secure-session` and `@fastify/session` are both session plugins for Fastify which are capable of encrypting/decrypting the session. The main difference is that `fastify-secure-session` uses the stateless approach and stores the whole session in an encrypted cookie whereas `@fastify/session` uses the stateful approach for sessions and stores them in a session store. +## Difference between `@fastify/secure-session` and `@fastify/session` +`@fastify/secure-session` and `@fastify/session` are both session plugins for Fastify which are capable of encrypting/decrypting the session. The main difference is that `@fastify/secure-session` uses the stateless approach and stores the whole session in an encrypted cookie whereas `@fastify/session` uses the stateful approach for sessions and stores them in a session store. ## Session Serialization -In a typical web application, the credentials used to authenticate a user will only be transmitted once when a user logs in, and after, they are considered logged in because of some data stored in their session. `fastify-passport` implements this pattern by storing sessions using `fastify-secure-cookie`, and serializing/deserializing user objects to and from the session referenced by the cookie. `fastify-passport` cannot store rich object classes in the session, only JSON objects, so you must register a serializer / deserializer pair if you want to say fetch a User object from your database, and store only a user ID in the session. +In a typical web application, the credentials used to authenticate a user will only be transmitted once when a user logs in, and after, they are considered logged in because of some data stored in their session. `@fastify/passport` implements this pattern by storing sessions using `@fastify/secure-session`, and serializing/deserializing user objects to and from the session referenced by the cookie. `@fastify/passport` cannot store rich object classes in the session, only JSON objects, so you must register a serializer / deserializer pair if you want to say fetch a User object from your database, and store only a user ID in the session. ```js // register a serializer that stores the user object's id in the session ... @@ -101,11 +101,11 @@ fastifyPassport.registerUserDeserializer(async (id, request) => { ### initialize() -A hook that **must be added**. Sets up a `fastify-passport` instance's hooks. +A hook that **must be added**. Sets up a `@fastify/passport` instance's hooks. ### secureSession() -A hook that **must be added**. Sets up `fastify-passport`'s connector with `fastify-secure-session` to store authentication in the session. +A hook that **must be added**. Sets up `@fastify/passport`'s connector with `@fastify/secure-session` to store authentication in the session. ### authenticate(strategy: string | Strategy | (string | Strategy)[], options: AuthenticateOptions, callback?: AuthenticateCallback) @@ -178,7 +178,7 @@ Note that if a callback is supplied, it becomes the application's responsibility #### Multiple Strategies -`fastify-passport` supports authenticating with a list of strategies, and will try each in order until one passes. Pass an array of strategy names to `authenticate` for this: +`@fastify/passport` supports authenticating with a list of strategies, and will try each in order until one passes. Pass an array of strategy names to `authenticate` for this: ```js // somewhere before several strategies are registered @@ -200,7 +200,7 @@ fastify.get( ) ``` -Note that multiple strategies that redirect to start an authentication flow, like OAuth2 strategies from major platforms, shouldn't really be used together in the same `authenticate` call. This is because `fastify-passport` will run the strategies in order, and the first one that redirects will do so, preventing the user from ever using the other strategies. To set up multiple OAuth2 strategies, add several routes that each use a different strategy in their own `authenticate` call, and then direct users to the right route for the strategy they pick. +Note that multiple strategies that redirect to start an authentication flow, like OAuth2 strategies from major platforms, shouldn't really be used together in the same `authenticate` call. This is because `@fastify/passport` will run the strategies in order, and the first one that redirects will do so, preventing the user from ever using the other strategies. To set up multiple OAuth2 strategies, add several routes that each use a different strategy in their own `authenticate` call, and then direct users to the right route for the strategy they pick. Multiple strategies can also be passed as instances if you only intend to use them for that route handler or for that request. @@ -265,7 +265,7 @@ fastifyPassport.unuse('legacy-api') ### registerUserSerializer(serializer: (user, request) => Promise) -Registers an async user serializer function for taking a high level User object from your application and serializing it for storage into the session. `fastify-passport` cannot store rich object classes in the session, only JSON objects, so you must register a serializer / deserializer pair if you want to say fetch a User object from your database, and store only a user ID in the session. +Registers an async user serializer function for taking a high level User object from your application and serializing it for storage into the session. `@fastify/passport` cannot store rich object classes in the session, only JSON objects, so you must register a serializer / deserializer pair if you want to say fetch a User object from your database, and store only a user ID in the session. ```js // register a serializer that stores the user object's id in the session ... @@ -274,7 +274,7 @@ fastifyPassport.registerUserSerializer(async (user, request) => user.id) ### registerUserDeserializer(deserializer: (serializedUser, request) => Promise) -Registers an async user deserializer function for taking a low level serialized user object (often just a user ID) from a session, and deserializing it from storage into the request context. `fastify-passport` cannot store rich object classes in the session, only JSON objects, so you must register a serializer / deserializer pair if you want to say fetch a User object from your database, and store only a user ID in the session. +Registers an async user deserializer function for taking a low level serialized user object (often just a user ID) from a session, and deserializing it from storage into the request context. `@fastify/passport` cannot store rich object classes in the session, only JSON objects, so you must register a serializer / deserializer pair if you want to say fetch a User object from your database, and store only a user ID in the session. ```js fastifyPassport.registerUserDeserializer(async (id, request) => { @@ -282,7 +282,7 @@ fastifyPassport.registerUserDeserializer(async (id, request) => { }); ``` -Deserializers can throw the string `"pass"` if they do not apply to the current session and the next deserializer should be tried. This is useful if you are using `fastify-passport` to store two different kinds of user objects. An example: +Deserializers can throw the string `"pass"` if they do not apply to the current session and the next deserializer should be tried. This is useful if you are using `@fastify/passport` to store two different kinds of user objects. An example: ```js // register a deserializer for database users @@ -304,14 +304,14 @@ fastifyPassport.registerUserDeserializer(async (id, request) => { }); ``` -Sessions may specify serialized users that have since been deleted from the datastore storing them for the application. In that case, deserialization often fails because the user row cannot be found for a given id. Depending on the application, this can either be an error condition, or expected if users are deleted from the database while logged in. `fastify-passport`'s behaviour in this case is configurable. Errors are thrown if a deserializer returns undefined, and the session is logged out if a deserializer returns `null` or `false.` This matches the behaviour of the original `passport` module. +Sessions may specify serialized users that have since been deleted from the datastore storing them for the application. In that case, deserialization often fails because the user row cannot be found for a given id. Depending on the application, this can either be an error condition, or expected if users are deleted from the database while logged in. `@fastify/passport`'s behaviour in this case is configurable. Errors are thrown if a deserializer returns undefined, and the session is logged out if a deserializer returns `null` or `false.` This matches the behaviour of the original `passport` module. Therefore, a deserializer can return several things: - if a deserializer returns an object, that object is assumed to be a successfully deserialized user -- if a deserializer returns `undefined`, `fastify-passport` interprets that as an erroneously missing user, and throws an error because the user could not be deserialized. -- if a deserializer returns `null` or `false`, `fastify-passport` interprets that as a missing but expected user, and resets the session to log the user out -- if a deserializer throws the string `"pass"`, `fastify-passport` will try the next deserializer if it exists, or throw an error because the user could not be deserialized. +- if a deserializer returns `undefined`, `@fastify/passport` interprets that as an erroneously missing user, and throws an error because the user could not be deserialized. +- if a deserializer returns `null` or `false`, `@fastify/passport` interprets that as a missing but expected user, and resets the session to log the user out +- if a deserializer throws the string `"pass"`, `@fastify/passport` will try the next deserializer if it exists, or throw an error because the user could not be deserialized. ### Request#isUnauthenticated() @@ -319,7 +319,7 @@ Test if request is unauthenticated. ## Using with TypeScript -`fastify-passport` is written in TypeScript, so it includes type definitions for all of it's API. You can also strongly type the `FastifyRequest.user` property using TypeScript declaration merging. You must re-declare the `PassportUser` interface in the `fastify` module within your own code to add the properties you expect to be assigned by the strategy when authenticating: +`@fastify/passport` is written in TypeScript, so it includes type definitions for all of it's API. You can also strongly type the `FastifyRequest.user` property using TypeScript declaration merging. You must re-declare the `PassportUser` interface in the `fastify` module within your own code to add the properties you expect to be assigned by the strategy when authenticating: ```typescript declare module 'fastify' { @@ -341,12 +341,12 @@ declare module 'fastify' { ## Using multiple instances -`fastify-passport` supports being registered multiple times in different plugin encapsulation contexts. This is useful to implement two separate authentication stacks. For example, you might have a set of strategies that authenticate users of your application, and a whole other set of strategies for authenticating staff members of your application that access an administration area. Users might be stored at `request.user`, and administrators at `request.admin`, and logging in as one should have no bearing on the other. It is important to register each instance of `fastify-passport` in a different Fastify plugin context so that the decorators `fastify-passport` like `request.logIn` and `request.logOut` do not collide. +`@fastify/passport` supports being registered multiple times in different plugin encapsulation contexts. This is useful to implement two separate authentication stacks. For example, you might have a set of strategies that authenticate users of your application, and a whole other set of strategies for authenticating staff members of your application that access an administration area. Users might be stored at `request.user`, and administrators at `request.admin`, and logging in as one should have no bearing on the other. It is important to register each instance of `@fastify/passport` in a different Fastify plugin context so that the decorators `@fastify/passport` like `request.logIn` and `request.logOut` do not collide. -To register fastify-passport more than once, you must instantiate more copies with different `keys` and `userProperty`s so they do not collide when decorating your fastify instance or storing things in the session. +To register @fastify/passport more than once, you must instantiate more copies with different `keys` and `userProperty`s so they do not collide when decorating your fastify instance or storing things in the session. ```typescript -import { Authenticator } from 'fastify-passport' +import { Authenticator } from '@fastify/passport' const server = fastify() @@ -379,11 +379,11 @@ server.get( **Note**: Each `Authenticator` instance's initialize plugin and session plugin must be registered separately. -It is important to note that using multiple `fastify-passport` instances is not necessary if you want to use multiple strategies to login the same type of user. `fastify-passport` supports multiple strategies by passing an array to any `.authenticate` call. +It is important to note that using multiple `@fastify/passport` instances is not necessary if you want to use multiple strategies to login the same type of user. `@fastify/passport` supports multiple strategies by passing an array to any `.authenticate` call. # Differences from Passport.js -`fastify-passport` is an adapted version of Passport that tries to be as compatible as possible, but is an adapted version that has some incompatabilities. Passport strategies that adhere to the passport strategy API should work fine, but there are some differences in other APIs made to integrate better with Fastify and to stick with Fastify's theme of performance. +`@fastify/passport` is an adapted version of Passport that tries to be as compatible as possible, but is an adapted version that has some incompatabilities. Passport strategies that adhere to the passport strategy API should work fine, but there are some differences in other APIs made to integrate better with Fastify and to stick with Fastify's theme of performance. Differences: diff --git a/package-lock.json b/package-lock.json index c318c3df..2dc0c25e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,20 @@ { - "name": "fastify-passport", - "version": "0.4.3", + "name": "@fastify/passport", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.4.3", + "name": "@fastify/passport", + "version": "1.0.0", "license": "MIT", "dependencies": { - "fastify-flash": "^3.0.0", + "@fastify/flash": "^4.0.0", "fastify-plugin": "^3.0.0" }, "devDependencies": { + "@fastify/cookie": "^6.0.0", + "@fastify/secure-session": "^4.0.0", "@fastify/session": "^8.0.0", "@types/jest": "^27.0.0", "@types/node": "^17.0.0", @@ -24,7 +27,6 @@ "eslint-config-prettier": "^8.1.0", "eslint-plugin-prettier": "^4.0.0", "fastify": "^3.9.2", - "fastify-secure-session": "^3.0.0", "got": "^11.8.1", "jest": "^27.0.6", "passport-facebook": "^3.0.0", @@ -704,6 +706,41 @@ "ajv": "^6.12.6" } }, + "node_modules/@fastify/cookie": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@fastify/cookie/-/cookie-6.0.0.tgz", + "integrity": "sha512-Luy3Po3dOJmqAuPCiPcWsX0tV5+C3AOnULSdlsGjNGOvyE7jqzysp8kT9ICfsUvove+TeUMgTWl1y9XS3ZPPMg==", + "dev": true, + "dependencies": { + "cookie-signature": "^1.1.0", + "fastify-plugin": "^3.0.1" + } + }, + "node_modules/@fastify/flash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@fastify/flash/-/flash-4.0.0.tgz", + "integrity": "sha512-hTxOTzjAcCvkldHU3SyjTiuBLbInMvSxCb1knkuWqS10Fj7MPUlr9KH659RNtZnPawLdm/Z4bvNV5HRHf51hyQ==", + "dependencies": { + "fastify-plugin": "^3.0.1" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "node_modules/@fastify/secure-session": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@fastify/secure-session/-/secure-session-4.0.0.tgz", + "integrity": "sha512-kx2wuocE/EG1mOCxGJHhZLv3oltPvFeZcAlDtfQzAV1vac4XvNNYMhu4xbPwbTTCZFdkZ5E2QNUaMSU3WP5t7g==", + "dev": true, + "dependencies": { + "@fastify/cookie": "^6.0.0", + "fastify-plugin": "^3.0.0", + "sodium-native": "^3.0.0" + }, + "bin": { + "fastify-secure-session": "genkey.js" + } + }, "node_modules/@fastify/session": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/@fastify/session/-/session-8.0.0.tgz", @@ -3008,53 +3045,17 @@ "tiny-lru": "^8.0.1" } }, - "node_modules/fastify-cookie": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/fastify-cookie/-/fastify-cookie-5.1.0.tgz", - "integrity": "sha512-AN5C/p7YVSgnW1D9fcUL10yRIN+9lcOtyps3h4/5ZsxwrHVgdNH5T77CbnIrzfAx6qz7K/8NYQCTE8cxZIJcJg==", - "dev": true, - "dependencies": { - "cookie": "^0.4.0", - "cookie-signature": "^1.1.0", - "fastify-plugin": "^3.0.0" - } - }, "node_modules/fastify-error": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/fastify-error/-/fastify-error-0.3.1.tgz", "integrity": "sha512-oCfpcsDndgnDVgiI7bwFKAun2dO+4h84vBlkWsWnz/OUK9Reff5UFoFl241xTiLeHWX/vU9zkDVXqYUxjOwHcQ==", "dev": true }, - "node_modules/fastify-flash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/fastify-flash/-/fastify-flash-3.0.0.tgz", - "integrity": "sha512-A79hWhck3PI59a+VI0y8aMq21WoVibHE0tSMGyr3AfO6XxHvpHmfS+FqjG6X5fTuLWmmHfuATrvsRKlwIjYvsw==", - "dependencies": { - "fastify-plugin": "^3.0.1" - }, - "engines": { - "node": ">=10.16.0" - } - }, "node_modules/fastify-plugin": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.1.tgz", "integrity": "sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA==" }, - "node_modules/fastify-secure-session": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/fastify-secure-session/-/fastify-secure-session-3.1.0.tgz", - "integrity": "sha512-oqYk4/bC+jwdMoc/GTlzbaxJYp/L7OINrQfb04k5nRyNJMqExe1maPi/Cmg2kUjGf+ElW3kvhCHHJAx7Mn31NQ==", - "dev": true, - "dependencies": { - "fastify-cookie": "^5.0.0", - "fastify-plugin": "^3.0.0", - "sodium-native": "^3.0.0" - }, - "bin": { - "fastify-secure-session": "genkey.js" - } - }, "node_modules/fastify-warning": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/fastify-warning/-/fastify-warning-0.2.0.tgz", @@ -6752,6 +6753,35 @@ "ajv": "^6.12.6" } }, + "@fastify/cookie": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@fastify/cookie/-/cookie-6.0.0.tgz", + "integrity": "sha512-Luy3Po3dOJmqAuPCiPcWsX0tV5+C3AOnULSdlsGjNGOvyE7jqzysp8kT9ICfsUvove+TeUMgTWl1y9XS3ZPPMg==", + "dev": true, + "requires": { + "cookie-signature": "^1.1.0", + "fastify-plugin": "^3.0.1" + } + }, + "@fastify/flash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@fastify/flash/-/flash-4.0.0.tgz", + "integrity": "sha512-hTxOTzjAcCvkldHU3SyjTiuBLbInMvSxCb1knkuWqS10Fj7MPUlr9KH659RNtZnPawLdm/Z4bvNV5HRHf51hyQ==", + "requires": { + "fastify-plugin": "^3.0.1" + } + }, + "@fastify/secure-session": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@fastify/secure-session/-/secure-session-4.0.0.tgz", + "integrity": "sha512-kx2wuocE/EG1mOCxGJHhZLv3oltPvFeZcAlDtfQzAV1vac4XvNNYMhu4xbPwbTTCZFdkZ5E2QNUaMSU3WP5t7g==", + "dev": true, + "requires": { + "@fastify/cookie": "^6.0.0", + "fastify-plugin": "^3.0.0", + "sodium-native": "^3.0.0" + } + }, "@fastify/session": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/@fastify/session/-/session-8.0.0.tgz", @@ -8530,47 +8560,17 @@ "tiny-lru": "^8.0.1" } }, - "fastify-cookie": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/fastify-cookie/-/fastify-cookie-5.1.0.tgz", - "integrity": "sha512-AN5C/p7YVSgnW1D9fcUL10yRIN+9lcOtyps3h4/5ZsxwrHVgdNH5T77CbnIrzfAx6qz7K/8NYQCTE8cxZIJcJg==", - "dev": true, - "requires": { - "cookie": "^0.4.0", - "cookie-signature": "^1.1.0", - "fastify-plugin": "^3.0.0" - } - }, "fastify-error": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/fastify-error/-/fastify-error-0.3.1.tgz", "integrity": "sha512-oCfpcsDndgnDVgiI7bwFKAun2dO+4h84vBlkWsWnz/OUK9Reff5UFoFl241xTiLeHWX/vU9zkDVXqYUxjOwHcQ==", "dev": true }, - "fastify-flash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/fastify-flash/-/fastify-flash-3.0.0.tgz", - "integrity": "sha512-A79hWhck3PI59a+VI0y8aMq21WoVibHE0tSMGyr3AfO6XxHvpHmfS+FqjG6X5fTuLWmmHfuATrvsRKlwIjYvsw==", - "requires": { - "fastify-plugin": "^3.0.1" - } - }, "fastify-plugin": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-3.0.1.tgz", "integrity": "sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA==" }, - "fastify-secure-session": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/fastify-secure-session/-/fastify-secure-session-3.1.0.tgz", - "integrity": "sha512-oqYk4/bC+jwdMoc/GTlzbaxJYp/L7OINrQfb04k5nRyNJMqExe1maPi/Cmg2kUjGf+ElW3kvhCHHJAx7Mn31NQ==", - "dev": true, - "requires": { - "fastify-cookie": "^5.0.0", - "fastify-plugin": "^3.0.0", - "sodium-native": "^3.0.0" - } - }, "fastify-warning": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/fastify-warning/-/fastify-warning-0.2.0.tgz", diff --git a/package.json b/package.json index bae3d29f..c4faa6ad 100644 --- a/package.json +++ b/package.json @@ -40,13 +40,15 @@ "node": ">= 12.0.0" }, "dependencies": { - "fastify-flash": "^3.0.0", + "@fastify/flash": "^4.0.0", "fastify-plugin": "^3.0.0" }, "peerDependencies": { "fastify": "^3.0.3" }, "devDependencies": { + "@fastify/cookie": "^6.0.0", + "@fastify/secure-session": "^4.0.0", "@fastify/session": "^8.0.0", "@types/jest": "^27.0.0", "@types/node": "^17.0.0", @@ -59,7 +61,6 @@ "eslint-config-prettier": "^8.1.0", "eslint-plugin-prettier": "^4.0.0", "fastify": "^3.9.2", - "fastify-secure-session": "^3.0.0", "got": "^11.8.1", "jest": "^27.0.6", "passport-facebook": "^3.0.0", diff --git a/src/AuthenticationRoute.ts b/src/AuthenticationRoute.ts index b835d970..158b16ea 100644 --- a/src/AuthenticationRoute.ts +++ b/src/AuthenticationRoute.ts @@ -1,4 +1,4 @@ -/// +/// import * as http from 'http' import AuthenticationError from './errors' import Authenticator from './Authenticator' diff --git a/src/CreateInitializePlugin.ts b/src/CreateInitializePlugin.ts index ba82f2aa..d963be02 100644 --- a/src/CreateInitializePlugin.ts +++ b/src/CreateInitializePlugin.ts @@ -1,7 +1,7 @@ import fp from 'fastify-plugin' import { logIn, logOut, isAuthenticated, isUnauthenticated } from './decorators' import Authenticator from './Authenticator' -import flash = require('fastify-flash') +import flash = require('@fastify/flash') export function CreateInitializePlugin(passport: Authenticator) { return fp(async (fastify) => { diff --git a/src/session-managers/SecureSessionManager.ts b/src/session-managers/SecureSessionManager.ts index 677066cc..a7a3173e 100644 --- a/src/session-managers/SecureSessionManager.ts +++ b/src/session-managers/SecureSessionManager.ts @@ -1,4 +1,4 @@ -/// +/// import { FastifyRequest } from 'fastify' import { SerializeFunction } from '../Authenticator' diff --git a/src/type-extensions.ts b/src/type-extensions.ts index fd6b276a..5835aca6 100644 --- a/src/type-extensions.ts +++ b/src/type-extensions.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ -import { flashFactory } from 'fastify-flash/lib/flash' +import { flashFactory } from '@fastify/flash/lib/flash' import { logIn, logOut, isAuthenticated, isUnauthenticated } from './decorators' import Authenticator from './Authenticator' diff --git a/test/helpers.ts b/test/helpers.ts index d759b2ea..ae63b8aa 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,7 +1,7 @@ import * as fs from 'fs' import fastify, { FastifyInstance } from 'fastify' -import fastifySecureSession, { SecureSessionPluginOptions } from 'fastify-secure-session' -import fastifyCookie from 'fastify-cookie' +import fastifySecureSession, { SecureSessionPluginOptions } from '@fastify/secure-session' +import fastifyCookie from '@fastify/cookie' import fastifySession from '@fastify/session' import Authenticator from '../src/Authenticator' import { Strategy } from '../src/strategies'