@fastify/cookie 9.4.0 → 10.0.0-pre.fv5.2
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 -1
- package/package.json +9 -9
- package/plugin.js +3 -3
- package/test/cookie.test.js +3 -3
package/.github/workflows/ci.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastify/cookie",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-pre.fv5.2",
|
|
4
4
|
"description": "Plugin for fastify to add support for cookies",
|
|
5
5
|
"main": "plugin.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://github.com/fastify/fastify-cookie#readme",
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@fastify/pre-commit": "^2.0
|
|
44
|
-
"@types/node": "^
|
|
43
|
+
"@fastify/pre-commit": "^2.1.0",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
45
|
"benchmark": "^2.1.4",
|
|
46
|
-
"fastify": "^
|
|
46
|
+
"fastify": "^5.0.0-alpha.3",
|
|
47
47
|
"sinon": "^18.0.0",
|
|
48
48
|
"snazzy": "^9.0.0",
|
|
49
|
-
"standard": "^17.
|
|
50
|
-
"tap": "^
|
|
51
|
-
"tsd": "^0.31.
|
|
49
|
+
"standard": "^17.1.0",
|
|
50
|
+
"tap": "^18.6.1",
|
|
51
|
+
"tsd": "^0.31.1"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"fastify-plugin": "^
|
|
55
|
-
"cookie-signature": "^1.1
|
|
54
|
+
"fastify-plugin": "^5.0.0-pre.fv5.1",
|
|
55
|
+
"cookie-signature": "^1.2.1"
|
|
56
56
|
},
|
|
57
57
|
"tsd": {
|
|
58
58
|
"directory": "test"
|
package/plugin.js
CHANGED
|
@@ -11,7 +11,7 @@ const kReplySetCookiesHookRan = Symbol('fastify.reply.setCookiesHookRan')
|
|
|
11
11
|
function fastifyCookieSetCookie (reply, name, value, options) {
|
|
12
12
|
parseCookies(reply.server, reply.request, reply)
|
|
13
13
|
|
|
14
|
-
const opts = Object.assign({}, options)
|
|
14
|
+
const opts = Object.assign({ sameSite: 'lax' }, options)
|
|
15
15
|
|
|
16
16
|
if (opts.expires && Number.isInteger(opts.expires)) {
|
|
17
17
|
opts.expires = new Date(opts.expires)
|
|
@@ -25,7 +25,6 @@ function fastifyCookieSetCookie (reply, name, value, options) {
|
|
|
25
25
|
if (reply.request.protocol === 'https') {
|
|
26
26
|
opts.secure = true
|
|
27
27
|
} else {
|
|
28
|
-
opts.sameSite = 'lax'
|
|
29
28
|
opts.secure = false
|
|
30
29
|
}
|
|
31
30
|
}
|
|
@@ -45,6 +44,7 @@ function fastifyCookieClearCookie (reply, name, options) {
|
|
|
45
44
|
signed: undefined,
|
|
46
45
|
maxAge: undefined
|
|
47
46
|
})
|
|
47
|
+
|
|
48
48
|
return fastifyCookieSetCookie(reply, name, '', opts)
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -188,7 +188,7 @@ function getHook (hook = 'onRequest') {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
const fastifyCookie = fp(plugin, {
|
|
191
|
-
fastify: '
|
|
191
|
+
fastify: '5.x',
|
|
192
192
|
name: '@fastify/cookie'
|
|
193
193
|
})
|
|
194
194
|
|
package/test/cookie.test.js
CHANGED
|
@@ -127,8 +127,8 @@ test('should set multiple cookies', (t) => {
|
|
|
127
127
|
t.equal(cookies[2].name, 'wee')
|
|
128
128
|
t.equal(cookies[2].value, 'woo')
|
|
129
129
|
|
|
130
|
-
t.equal(res.headers['set-cookie'][1], 'bar=test; Partitioned')
|
|
131
|
-
t.equal(res.headers['set-cookie'][2], 'wee=woo; Secure; Partitioned')
|
|
130
|
+
t.equal(res.headers['set-cookie'][1], 'bar=test; Partitioned; SameSite=Lax')
|
|
131
|
+
t.equal(res.headers['set-cookie'][2], 'wee=woo; Secure; Partitioned; SameSite=Lax')
|
|
132
132
|
})
|
|
133
133
|
})
|
|
134
134
|
|
|
@@ -957,7 +957,7 @@ test('result in an error if hook-option is set to an invalid value', (t) => {
|
|
|
957
957
|
const fastify = Fastify()
|
|
958
958
|
|
|
959
959
|
t.rejects(
|
|
960
|
-
() => fastify.register(plugin, { hook: true }),
|
|
960
|
+
async () => fastify.register(plugin, { hook: true }),
|
|
961
961
|
new Error("@fastify/cookie: Invalid value provided for the hook-option. You can set the hook-option only to false, 'onRequest' , 'preParsing' , 'preValidation' or 'preHandler'")
|
|
962
962
|
)
|
|
963
963
|
})
|