@fastify/cookie 11.0.2 → 11.1.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/dependabot.yml +41 -1
- package/.github/workflows/ci.yml +12 -2
- package/.github/workflows/lock-threads.yml +19 -0
- package/LICENSE +1 -1
- package/README.md +10 -10
- package/package.json +11 -19
- package/types/{plugin.test-d.ts → index.tst.ts} +102 -61
- package/.github/stale.yml +0 -21
- /package/{plugin.js → index.js} +0 -0
- /package/types/{plugin.d.ts → index.d.ts} +0 -0
package/.github/dependabot.yml
CHANGED
|
@@ -2,12 +2,52 @@ version: 2
|
|
|
2
2
|
updates:
|
|
3
3
|
- package-ecosystem: "github-actions"
|
|
4
4
|
directory: "/"
|
|
5
|
+
commit-message:
|
|
6
|
+
# Prefix all commit messages with "chore: "
|
|
7
|
+
prefix: "chore"
|
|
5
8
|
schedule:
|
|
6
|
-
interval: "
|
|
9
|
+
interval: "weekly"
|
|
10
|
+
cooldown:
|
|
11
|
+
default-days: 7
|
|
12
|
+
allow:
|
|
13
|
+
- dependency-name: "*"
|
|
14
|
+
update-types:
|
|
15
|
+
- "version-update:semver-major"
|
|
7
16
|
open-pull-requests-limit: 10
|
|
8
17
|
|
|
9
18
|
- package-ecosystem: "npm"
|
|
10
19
|
directory: "/"
|
|
20
|
+
commit-message:
|
|
21
|
+
# Prefix all commit messages with "chore: "
|
|
22
|
+
prefix: "chore"
|
|
11
23
|
schedule:
|
|
12
24
|
interval: "weekly"
|
|
25
|
+
cooldown:
|
|
26
|
+
default-days: 7
|
|
27
|
+
versioning-strategy: "increase-if-necessary"
|
|
28
|
+
allow:
|
|
29
|
+
- dependency-name: "*"
|
|
30
|
+
update-types:
|
|
31
|
+
- "version-update:semver-major"
|
|
32
|
+
ignore:
|
|
33
|
+
# TODO: remove ignore until neostandard support ESLint 10
|
|
34
|
+
- dependency-name: "eslint"
|
|
35
|
+
- dependency-name: "neostandard"
|
|
36
|
+
- dependency-name: "@stylistic/*"
|
|
13
37
|
open-pull-requests-limit: 10
|
|
38
|
+
groups:
|
|
39
|
+
# Production dependencies with breaking changes
|
|
40
|
+
dependencies:
|
|
41
|
+
dependency-type: "production"
|
|
42
|
+
# ESLint related dependencies
|
|
43
|
+
dev-dependencies-eslint:
|
|
44
|
+
patterns:
|
|
45
|
+
- "eslint"
|
|
46
|
+
- "neostandard"
|
|
47
|
+
- "@stylistic/*"
|
|
48
|
+
# TypeScript related dependencies
|
|
49
|
+
dev-dependencies-typescript:
|
|
50
|
+
patterns:
|
|
51
|
+
- "@types/*"
|
|
52
|
+
- "tstyche"
|
|
53
|
+
- "typescript"
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -4,7 +4,6 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
6
|
- main
|
|
7
|
-
- master
|
|
8
7
|
- next
|
|
9
8
|
- 'v*'
|
|
10
9
|
paths-ignore:
|
|
@@ -15,9 +14,20 @@ on:
|
|
|
15
14
|
- 'docs/**'
|
|
16
15
|
- '*.md'
|
|
17
16
|
|
|
17
|
+
# This allows a subsequently queued workflow run to interrupt previous runs
|
|
18
|
+
concurrency:
|
|
19
|
+
group: "${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
|
|
18
25
|
jobs:
|
|
19
26
|
test:
|
|
20
|
-
|
|
27
|
+
permissions:
|
|
28
|
+
contents: write
|
|
29
|
+
pull-requests: write
|
|
30
|
+
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v6
|
|
21
31
|
with:
|
|
22
32
|
license-check: true
|
|
23
33
|
lint: true
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Lock Threads
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
- cron: '0 0 1 * *'
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: lock
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
lock-threads:
|
|
16
|
+
permissions:
|
|
17
|
+
issues: write
|
|
18
|
+
pull-requests: write
|
|
19
|
+
uses: fastify/workflows/.github/workflows/lock-threads.yml@v6
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Fastify
|
|
3
|
+
Copyright (c) 2017-present The Fastify team <https://github.com/fastify/fastify#team>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @fastify/cookie
|
|
2
2
|
|
|
3
|
-
[](https://github.com/fastify/fastify-cookie/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@fastify/cookie)
|
|
5
5
|
[](https://github.com/neostandard/neostandard)
|
|
6
6
|
|
|
7
|
-
A plugin for [Fastify](
|
|
7
|
+
A plugin for [Fastify](https://fastify.dev/) that adds support for reading and
|
|
8
8
|
setting cookies.
|
|
9
9
|
|
|
10
10
|
This plugin's cookie parsing works via Fastify's `onRequest` hook. Therefore,
|
|
@@ -21,10 +21,10 @@ npm i @fastify/cookie
|
|
|
21
21
|
### Compatibility
|
|
22
22
|
| Plugin version | Fastify version |
|
|
23
23
|
| ---------------|-----------------|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
24
|
+
| `>=10.x` | `^5.x` |
|
|
25
|
+
| `>=7.x <10.x` | `^4.x` |
|
|
26
|
+
| `>=4.x <7.x` | `^3.x` |
|
|
27
|
+
| `>=2.x <4.x` | `^2.x` |
|
|
28
28
|
| `^1.x` | `^1.x` |
|
|
29
29
|
|
|
30
30
|
Please note that if a Fastify version is out of support, then so are the corresponding versions of this plugin
|
|
@@ -95,7 +95,7 @@ fastify.get('/', (req, reply) => {
|
|
|
95
95
|
## Options
|
|
96
96
|
|
|
97
97
|
- `secret` (`String` | `Array` | `Buffer` | `Object`):
|
|
98
|
-
- A `String` or `Buffer` can be passed to use as secret to sign the cookie using [`cookie-signature`](
|
|
98
|
+
- A `String` or `Buffer` can be passed to use as secret to sign the cookie using [`cookie-signature`](https://www.npmjs.com/package/cookie-signature).
|
|
99
99
|
- An `Array` can be passed if key rotation is desired. Read more about it in [Rotating signing secret](#rotating-secret).
|
|
100
100
|
- More sophisticated cookie signing mechanisms can be implemented by supplying an `Object`. Read more about it in [Custom cookie signer](#custom-cookie-signer).
|
|
101
101
|
|
|
@@ -165,14 +165,14 @@ More information about this can be found in [the proposal](https://github.com/pr
|
|
|
165
165
|
|
|
166
166
|
##### priority
|
|
167
167
|
|
|
168
|
-
Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute](https://
|
|
168
|
+
Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/draft-west-cookie-priority-00#section-4.1).
|
|
169
169
|
|
|
170
170
|
- `'low'` will set the `Priority` attribute to `Low`.
|
|
171
171
|
- `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
|
172
172
|
- `'high'` will set the `Priority` attribute to `High`.
|
|
173
173
|
|
|
174
174
|
More information about the different priority levels can be found in
|
|
175
|
-
[the specification](https://
|
|
175
|
+
[the specification](https://datatracker.ietf.org/doc/html/draft-west-cookie-priority-00#section-4.1).
|
|
176
176
|
|
|
177
177
|
⚠️ **Warning:** This is an attribute that has not yet been fully standardized, and may change in the future without reflecting the semver versioning. This also means many clients may ignore the attribute until they understand it.
|
|
178
178
|
|
|
@@ -235,7 +235,7 @@ Following are _some_ of the precautions that should be taken to ensure the integ
|
|
|
235
235
|
|
|
236
236
|
- It's important to use `options.httpOnly` cookies to prevent attacks like XSS.
|
|
237
237
|
- Use signed cookies (`options.signed`) to ensure they are not getting tampered wit client-side by an attacker.
|
|
238
|
-
- Use `__Host-` [Cookie Prefix](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#
|
|
238
|
+
- Use `__Host-` [Cookie Prefix](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#attributes) to avoid Cookie Tossing attacks.
|
|
239
239
|
- It is important to [use HTTPS for your website/app](https://letsencrypt.org/) to avoid a bunch of other potential security issues like [MITM](https://en.wikipedia.org/wiki/Man-in-the-middle_attack) etc.
|
|
240
240
|
|
|
241
241
|
### Clearing
|
package/package.json
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastify/cookie",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "Plugin for fastify to add support for cookies",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
|
-
"types": "types/
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"coverage": "npm run test:unit -- --coverage-report=html",
|
|
10
10
|
"lint": "eslint",
|
|
11
11
|
"lint:fix": "eslint --fix",
|
|
12
12
|
"test": "npm run test:unit && npm run test:typescript",
|
|
13
|
-
"test:typescript": "
|
|
13
|
+
"test:typescript": "tstyche",
|
|
14
14
|
"test:unit": "c8 --100 node --test",
|
|
15
15
|
"test:unit:verbose": "npm run test:unit -- -Rspec"
|
|
16
16
|
},
|
|
17
|
-
"precommit": [
|
|
18
|
-
"lint",
|
|
19
|
-
"test"
|
|
20
|
-
],
|
|
21
17
|
"repository": {
|
|
22
18
|
"type": "git",
|
|
23
|
-
"url": "git+
|
|
19
|
+
"url": "git+https://github.com/fastify/fastify-cookie.git"
|
|
24
20
|
},
|
|
25
21
|
"keywords": [
|
|
26
22
|
"fastify",
|
|
@@ -62,22 +58,18 @@
|
|
|
62
58
|
}
|
|
63
59
|
],
|
|
64
60
|
"devDependencies": {
|
|
65
|
-
"@
|
|
66
|
-
"@types/node": "^22.0.0",
|
|
61
|
+
"@types/node": "^26.0.1",
|
|
67
62
|
"benchmark": "^2.1.4",
|
|
68
|
-
"c8": "^
|
|
63
|
+
"c8": "^11.0.0",
|
|
69
64
|
"eslint": "^9.17.0",
|
|
70
65
|
"fastify": "^5.0.0",
|
|
71
|
-
"neostandard": "^0.
|
|
72
|
-
"sinon": "^
|
|
73
|
-
"
|
|
66
|
+
"neostandard": "^0.13.0",
|
|
67
|
+
"sinon": "^22.0.0",
|
|
68
|
+
"tstyche": "^7.0.0"
|
|
74
69
|
},
|
|
75
70
|
"dependencies": {
|
|
76
71
|
"cookie": "^1.0.0",
|
|
77
|
-
"fastify-plugin": "^
|
|
78
|
-
},
|
|
79
|
-
"tsd": {
|
|
80
|
-
"directory": "test"
|
|
72
|
+
"fastify-plugin": "^6.0.0"
|
|
81
73
|
},
|
|
82
74
|
"publishConfig": {
|
|
83
75
|
"access": "public"
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expect } from 'tstyche'
|
|
2
2
|
import * as fastifyCookieStar from '..'
|
|
3
3
|
import fastifyCookieCjsImport = require('..')
|
|
4
4
|
import cookie, { fastifyCookie as fastifyCookieNamed, Signer } from '..'
|
|
5
|
-
import fastify, {
|
|
5
|
+
import fastify, {
|
|
6
|
+
type FastifyInstance,
|
|
7
|
+
type FastifyReply,
|
|
8
|
+
type setCookieWrapper
|
|
9
|
+
} from 'fastify'
|
|
6
10
|
|
|
7
11
|
const fastifyCookieCjs = require('..')
|
|
8
12
|
|
|
@@ -15,61 +19,72 @@ app.register(fastifyCookieCjsImport.fastifyCookie)
|
|
|
15
19
|
app.register(fastifyCookieStar.default)
|
|
16
20
|
app.register(fastifyCookieStar.fastifyCookie)
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
expect(fastifyCookieNamed).type.toBe<fastifyCookieStar.FastifyCookie>()
|
|
23
|
+
expect(cookie).type.toBe<fastifyCookieStar.FastifyCookie>()
|
|
24
|
+
expect(
|
|
25
|
+
fastifyCookieCjsImport.default
|
|
26
|
+
).type.toBe<fastifyCookieStar.FastifyCookie>()
|
|
27
|
+
expect(
|
|
28
|
+
fastifyCookieCjsImport.fastifyCookie
|
|
29
|
+
).type.toBe<fastifyCookieStar.FastifyCookie>()
|
|
30
|
+
expect(fastifyCookieStar.default).type.toBe<fastifyCookieStar.FastifyCookie>()
|
|
31
|
+
expect(
|
|
24
32
|
fastifyCookieStar.fastifyCookie
|
|
25
|
-
)
|
|
26
|
-
|
|
33
|
+
).type.toBe<fastifyCookieStar.FastifyCookie>()
|
|
34
|
+
expect(fastifyCookieCjs).type.toBe<any>()
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
expect(cookie.sign).type.toBe<fastifyCookieStar.Sign>()
|
|
37
|
+
expect(cookie.unsign).type.toBe<fastifyCookieStar.Unsign>()
|
|
38
|
+
expect(cookie.signerFactory).type.toBe<fastifyCookieStar.SignerFactory>()
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
expect(fastifyCookieNamed.sign).type.toBe<fastifyCookieStar.Sign>()
|
|
41
|
+
expect(fastifyCookieNamed.unsign).type.toBe<fastifyCookieStar.Unsign>()
|
|
42
|
+
expect(
|
|
43
|
+
fastifyCookieNamed.signerFactory
|
|
44
|
+
).type.toBe<fastifyCookieStar.SignerFactory>()
|
|
35
45
|
|
|
36
46
|
const server = fastify()
|
|
37
47
|
|
|
38
48
|
server.register(cookie)
|
|
39
49
|
|
|
40
50
|
server.after((_err) => {
|
|
41
|
-
|
|
51
|
+
expect(
|
|
42
52
|
server.serializeCookie('sessionId', 'aYb4uTIhdBXC')
|
|
43
|
-
)
|
|
53
|
+
).type.toBe<string>()
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
55
|
+
expect(server.parseCookie('sessionId=aYb4uTIhdBXC')).type.toBe<{
|
|
56
|
+
[key: string]: string;
|
|
57
|
+
}>()
|
|
49
58
|
|
|
50
59
|
server.get('/', (request, reply) => {
|
|
51
60
|
const test = request.cookies.test
|
|
52
|
-
|
|
61
|
+
expect(test).type.toBe<string | undefined>()
|
|
53
62
|
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
expect(reply.cookie).type.toBe<setCookieWrapper>()
|
|
64
|
+
expect(reply.setCookie).type.toBe<setCookieWrapper>()
|
|
56
65
|
|
|
57
|
-
|
|
66
|
+
expect(
|
|
58
67
|
reply
|
|
59
68
|
.setCookie('test', test!, { domain: 'example.com', path: '/' })
|
|
60
69
|
.clearCookie('foo')
|
|
61
70
|
.send({ hello: 'world' })
|
|
62
|
-
)
|
|
71
|
+
).type.toBe<FastifyReply>()
|
|
63
72
|
})
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
expect(server.signCookie).type.toBe<(value: string) => string>()
|
|
75
|
+
expect(server.unsignCookie).type.toBe<
|
|
76
|
+
(value: string) => fastifyCookieStar.UnsignResult
|
|
77
|
+
>()
|
|
67
78
|
|
|
68
79
|
server.get('/', (request, reply) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
expect(request.signCookie).type.toBe<(value: string) => string>()
|
|
81
|
+
expect(reply.signCookie).type.toBe<(value: string) => string>()
|
|
82
|
+
expect(request.unsignCookie).type.toBe<
|
|
83
|
+
(value: string) => fastifyCookieStar.UnsignResult
|
|
84
|
+
>()
|
|
85
|
+
expect(reply.unsignCookie).type.toBe<
|
|
86
|
+
(value: string) => fastifyCookieStar.UnsignResult
|
|
87
|
+
>()
|
|
73
88
|
})
|
|
74
89
|
})
|
|
75
90
|
|
|
@@ -97,11 +112,15 @@ testSamesiteOptionsApp.after(() => {
|
|
|
97
112
|
})
|
|
98
113
|
server.get('/test-samesite-option-false', (request, reply) => {
|
|
99
114
|
const test = request.cookies.test
|
|
100
|
-
reply
|
|
115
|
+
reply
|
|
116
|
+
.setCookie('test', test!, { sameSite: false })
|
|
117
|
+
.send({ hello: 'world' })
|
|
101
118
|
})
|
|
102
119
|
server.get('/test-samesite-option-lax', (request, reply) => {
|
|
103
120
|
const test = request.cookies.test
|
|
104
|
-
reply
|
|
121
|
+
reply
|
|
122
|
+
.setCookie('test', test!, { sameSite: 'lax' })
|
|
123
|
+
.send({ hello: 'world' })
|
|
105
124
|
})
|
|
106
125
|
server.get('/test-samesite-option-strict', (request, reply) => {
|
|
107
126
|
const test = request.cookies.test
|
|
@@ -120,7 +139,7 @@ testSamesiteOptionsApp.after(() => {
|
|
|
120
139
|
const appWithImplicitHttpSigned = fastify()
|
|
121
140
|
|
|
122
141
|
appWithImplicitHttpSigned.register(cookie, {
|
|
123
|
-
secret: 'testsecret'
|
|
142
|
+
secret: 'testsecret'
|
|
124
143
|
})
|
|
125
144
|
appWithImplicitHttpSigned.register(cookie, {
|
|
126
145
|
secret: 'testsecret',
|
|
@@ -144,20 +163,20 @@ appWithImplicitHttpSigned.after(() => {
|
|
|
144
163
|
const appWithRotationSecret = fastify()
|
|
145
164
|
|
|
146
165
|
appWithRotationSecret.register(cookie, {
|
|
147
|
-
secret: ['testsecret']
|
|
166
|
+
secret: ['testsecret']
|
|
148
167
|
})
|
|
149
168
|
appWithRotationSecret.after(() => {
|
|
150
169
|
server.get('/', (request, reply) => {
|
|
151
170
|
reply.unsignCookie(request.cookies.test!)
|
|
152
171
|
const unsigned = reply.unsignCookie('test')
|
|
153
172
|
|
|
154
|
-
|
|
173
|
+
expect(unsigned.valid).type.toBe<boolean>()
|
|
155
174
|
if (unsigned.valid) {
|
|
156
|
-
|
|
175
|
+
expect(unsigned.value).type.toBe<string>()
|
|
157
176
|
} else {
|
|
158
|
-
|
|
177
|
+
expect(unsigned.value).type.toBe<null>()
|
|
159
178
|
}
|
|
160
|
-
|
|
179
|
+
expect(unsigned.renew).type.toBe<boolean>()
|
|
161
180
|
|
|
162
181
|
reply.send({ hello: 'world' })
|
|
163
182
|
})
|
|
@@ -175,25 +194,25 @@ const parseOptions: fastifyCookieStar.CookieSerializeOptions = {
|
|
|
175
194
|
sameSite: 'lax',
|
|
176
195
|
secure: true,
|
|
177
196
|
signed: true,
|
|
178
|
-
partitioned: false
|
|
197
|
+
partitioned: false
|
|
179
198
|
}
|
|
180
|
-
|
|
199
|
+
expect(parseOptions).type.toBe<fastifyCookieStar.CookieSerializeOptions>()
|
|
181
200
|
|
|
182
201
|
appWithParseOptions.register(cookie, {
|
|
183
202
|
secret: 'testsecret',
|
|
184
|
-
parseOptions
|
|
203
|
+
parseOptions
|
|
185
204
|
})
|
|
186
205
|
appWithParseOptions.after(() => {
|
|
187
206
|
server.get('/', (request, reply) => {
|
|
188
207
|
const unsigned = reply.unsignCookie(request.cookies.test!)
|
|
189
208
|
|
|
190
|
-
|
|
209
|
+
expect(unsigned.valid).type.toBe<boolean>()
|
|
191
210
|
if (unsigned.valid) {
|
|
192
|
-
|
|
211
|
+
expect(unsigned.value).type.toBe<string>()
|
|
193
212
|
} else {
|
|
194
|
-
|
|
213
|
+
expect(unsigned.value).type.toBe<null>()
|
|
195
214
|
}
|
|
196
|
-
|
|
215
|
+
expect(unsigned.renew).type.toBe<boolean>()
|
|
197
216
|
})
|
|
198
217
|
})
|
|
199
218
|
|
|
@@ -203,7 +222,9 @@ appWithCustomSigner.register(cookie, {
|
|
|
203
222
|
secret: {
|
|
204
223
|
sign: (x) => x + '.signed',
|
|
205
224
|
unsign: (x) => {
|
|
206
|
-
if (x.endsWith('.signed')) {
|
|
225
|
+
if (x.endsWith('.signed')) {
|
|
226
|
+
return { renew: false, valid: true, value: x.slice(0, -7) }
|
|
227
|
+
}
|
|
207
228
|
return { renew: false, valid: false, value: null }
|
|
208
229
|
}
|
|
209
230
|
}
|
|
@@ -213,22 +234,28 @@ appWithCustomSigner.after(() => {
|
|
|
213
234
|
reply.unsignCookie(request.cookies.test!)
|
|
214
235
|
const unsigned = reply.unsignCookie('test')
|
|
215
236
|
|
|
216
|
-
|
|
237
|
+
expect(unsigned.valid).type.toBe<boolean>()
|
|
217
238
|
if (unsigned.valid) {
|
|
218
|
-
|
|
239
|
+
expect(unsigned.value).type.toBe<string>()
|
|
219
240
|
} else {
|
|
220
|
-
|
|
241
|
+
expect(unsigned.value).type.toBe<null>()
|
|
221
242
|
}
|
|
222
|
-
|
|
243
|
+
expect(unsigned.renew).type.toBe<boolean>()
|
|
223
244
|
|
|
224
245
|
reply.send({ hello: 'world' })
|
|
225
246
|
})
|
|
226
247
|
})
|
|
227
248
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
249
|
+
expect(new fastifyCookieStar.Signer('secretString')).type.toBe<Signer>()
|
|
250
|
+
expect(
|
|
251
|
+
new fastifyCookieStar.Signer(['secretStringInArray'])
|
|
252
|
+
).type.toBe<Signer>()
|
|
253
|
+
expect(
|
|
254
|
+
new fastifyCookieStar.Signer(Buffer.from('secretString'))
|
|
255
|
+
).type.toBe<Signer>()
|
|
256
|
+
expect(
|
|
257
|
+
new fastifyCookieStar.Signer([Buffer.from('secretStringInArray')])
|
|
258
|
+
).type.toBe<Signer>()
|
|
232
259
|
|
|
233
260
|
const signer = new fastifyCookieStar.Signer(['secretStringInArray'], 'sha256')
|
|
234
261
|
signer.sign('Lorem Ipsum')
|
|
@@ -242,8 +269,22 @@ appWithHook.register(cookie, { hook: 'preHandler' })
|
|
|
242
269
|
appWithHook.register(cookie, { hook: 'preParsing' })
|
|
243
270
|
appWithHook.register(cookie, { hook: 'preSerialization' })
|
|
244
271
|
appWithHook.register(cookie, { hook: 'preValidation' })
|
|
245
|
-
expectError(appWithHook.register(cookie, { hook: true }))
|
|
246
|
-
expectError(appWithHook.register(cookie, { hook: 'false' }))
|
|
247
272
|
|
|
248
|
-
|
|
249
|
-
|
|
273
|
+
expect(appWithHook.register)
|
|
274
|
+
.type.not.toBeCallableWith(cookie, { hook: true })
|
|
275
|
+
expect(appWithHook.register)
|
|
276
|
+
.type.not.toBeCallableWith(cookie, { hook: 'false' })
|
|
277
|
+
|
|
278
|
+
expect(cookie.parse).type.toBe<
|
|
279
|
+
(
|
|
280
|
+
cookieHeader: string,
|
|
281
|
+
opts?: fastifyCookieStar.ParseOptions
|
|
282
|
+
) => { [key: string]: string }
|
|
283
|
+
>()
|
|
284
|
+
expect(cookie.serialize).type.toBe<
|
|
285
|
+
(
|
|
286
|
+
name: string,
|
|
287
|
+
value: string,
|
|
288
|
+
opts?: fastifyCookieStar.SerializeOptions
|
|
289
|
+
) => string
|
|
290
|
+
>()
|
package/.github/stale.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Number of days of inactivity before an issue becomes stale
|
|
2
|
-
daysUntilStale: 15
|
|
3
|
-
# Number of days of inactivity before a stale issue is closed
|
|
4
|
-
daysUntilClose: 7
|
|
5
|
-
# Issues with these labels will never be considered stale
|
|
6
|
-
exemptLabels:
|
|
7
|
-
- "discussion"
|
|
8
|
-
- "feature request"
|
|
9
|
-
- "bug"
|
|
10
|
-
- "help wanted"
|
|
11
|
-
- "plugin suggestion"
|
|
12
|
-
- "good first issue"
|
|
13
|
-
# Label to use when marking an issue as stale
|
|
14
|
-
staleLabel: stale
|
|
15
|
-
# Comment to post when marking an issue as stale. Set to `false` to disable
|
|
16
|
-
markComment: >
|
|
17
|
-
This issue has been automatically marked as stale because it has not had
|
|
18
|
-
recent activity. It will be closed if no further activity occurs. Thank you
|
|
19
|
-
for your contributions.
|
|
20
|
-
# Comment to post when closing a stale issue. Set to `false` to disable
|
|
21
|
-
closeComment: false
|
/package/{plugin.js → index.js}
RENAMED
|
File without changes
|
|
File without changes
|