@fastify/cookie 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +1 -2
- package/README.md +21 -10
- package/package.json +3 -3
- package/plugin.js +2 -2
package/.github/workflows/ci.yml
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# fastify
|
|
1
|
+
# @fastify/cookie
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-
[](https://www.npmjs.com/package/@fastify/cookie)
|
|
5
5
|
[](https://snyk.io/test/github/fastify/fastify-cookie)
|
|
6
6
|
[](https://standardjs.com/)
|
|
7
7
|
|
|
@@ -12,16 +12,27 @@ This plugin's cookie parsing works via Fastify's `onRequest` hook. Therefore,
|
|
|
12
12
|
you should register it prior to any other `onRequest` hooks that will depend
|
|
13
13
|
upon this plugin's actions.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
`@fastify/cookie` [v2.x](https://github.com/fastify/fastify-cookie/tree/v2.x)
|
|
16
16
|
supports both Fastify@1 and Fastify@2.
|
|
17
|
-
|
|
17
|
+
`@fastify/cookie` v3 only supports Fastify@2.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
```sh
|
|
21
|
+
npm i @fastify/cookie
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
or
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
yarn add @fastify/cookie
|
|
28
|
+
```
|
|
18
29
|
|
|
19
30
|
## Example
|
|
20
31
|
|
|
21
32
|
```js
|
|
22
33
|
const fastify = require('fastify')()
|
|
23
34
|
|
|
24
|
-
fastify.register(require('fastify
|
|
35
|
+
fastify.register(require('@fastify/cookie'), {
|
|
25
36
|
secret: "my-secret", // for cookies signature
|
|
26
37
|
parseOptions: {} // options for parsing cookies
|
|
27
38
|
})
|
|
@@ -47,8 +58,8 @@ fastify.get('/', (req, reply) => {
|
|
|
47
58
|
## TypeScript Example
|
|
48
59
|
|
|
49
60
|
```ts
|
|
50
|
-
import { FastifyCookieOptions } from 'fastify
|
|
51
|
-
import cookie from 'fastify
|
|
61
|
+
import { FastifyCookieOptions } from '@fastify/cookie'
|
|
62
|
+
import cookie from '@fastify/cookie'
|
|
52
63
|
import fastify from 'fastify'
|
|
53
64
|
|
|
54
65
|
const app = fastify()
|
|
@@ -126,7 +137,7 @@ Key rotation is when an encryption key is retired and replaced by generating a n
|
|
|
126
137
|
|
|
127
138
|
**Example:**
|
|
128
139
|
```js
|
|
129
|
-
fastify.register(require('fastify
|
|
140
|
+
fastify.register(require('@fastify/cookie'), {
|
|
130
141
|
secret: [key1, key2]
|
|
131
142
|
})
|
|
132
143
|
```
|
|
@@ -161,7 +172,7 @@ The `secret` option optionally accepts an object with `sign` and `unsign` functi
|
|
|
161
172
|
|
|
162
173
|
**Example:**
|
|
163
174
|
```js
|
|
164
|
-
fastify.register(require('fastify
|
|
175
|
+
fastify.register(require('@fastify/cookie'), {
|
|
165
176
|
secret: {
|
|
166
177
|
sign: (value) => {
|
|
167
178
|
// sign using custom logic
|
|
@@ -188,7 +199,7 @@ the provided signer's (or the default signer if no custom implementation is prov
|
|
|
188
199
|
**Example:**
|
|
189
200
|
|
|
190
201
|
```js
|
|
191
|
-
fastify.register(require('fastify
|
|
202
|
+
fastify.register(require('@fastify/cookie'), { secret: 'my-secret' })
|
|
192
203
|
|
|
193
204
|
fastify.get('/', (req, rep) => {
|
|
194
205
|
if (fastify.unsign(req.cookie.foo).valid === false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastify/cookie",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Plugin for fastify to add support for cookies",
|
|
5
5
|
"main": "plugin.js",
|
|
6
6
|
"types": "plugin.d.ts",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"homepage": "https://github.com/fastify/fastify-cookie#readme",
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^17.0.16",
|
|
43
|
-
"fastify": "^
|
|
43
|
+
"fastify": "^4.0.0-rc.2",
|
|
44
44
|
"pre-commit": "^1.2.2",
|
|
45
|
-
"sinon": "^
|
|
45
|
+
"sinon": "^14.0.0",
|
|
46
46
|
"snazzy": "^9.0.0",
|
|
47
47
|
"standard": "^17.0.0",
|
|
48
48
|
"tap": "^16.0.0",
|