Skip to content

Commit

Permalink
Merge next into master (#291)
Browse files Browse the repository at this point in the history
* set sameSite: lax by default (#277)

* update for Fastify v5 (#276)

* update for v5

* Update .github/workflows/ci.yml

Co-authored-by: Frazer Smith <frazer.dev@outlook.com>
Signed-off-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>

* Revert "Update .github/workflows/ci.yml"

This reverts commit b7a3800.

* use replaceAll

* Revert "use replaceAll"

This reverts commit c691788.

---------

Signed-off-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>
Co-authored-by: Frazer Smith <frazer.dev@outlook.com>

* set sameSite: lax by default (#277)

* update for Fastify v5 (#276)

* update for v5

* Update .github/workflows/ci.yml

Co-authored-by: Frazer Smith <frazer.dev@outlook.com>
Signed-off-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>

* Revert "Update .github/workflows/ci.yml"

This reverts commit b7a3800.

* use replaceAll

* Revert "use replaceAll"

This reverts commit c691788.

---------

Signed-off-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>
Co-authored-by: Frazer Smith <frazer.dev@outlook.com>

* update fastify deps

* Update .github/workflows/ci.yml

Co-authored-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>
Signed-off-by: Matteo Collina <matteo.collina@gmail.com>

---------

Signed-off-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>
Signed-off-by: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>
Co-authored-by: Frazer Smith <frazer.dev@outlook.com>
Co-authored-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
4 people authored Jul 3, 2024
1 parent 4e816af commit 1608401
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.2.1
with:
license-check: true
lint: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ lib-cov
coverage
*.lcov

# tap test output
.tap

# nyc test coverage
.nyc_output

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
},
"homepage": "https://github.com/fastify/fastify-cookie#readme",
"devDependencies": {
"@fastify/pre-commit": "^2.0.2",
"@types/node": "^20.1.0",
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^20.11.6",
"benchmark": "^2.1.4",
"fastify": "^4.0.0",
"fastify": "^5.0.0-alpha.3",
"sinon": "^18.0.0",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.31.0"
"standard": "^17.1.0",
"tap": "^18.6.1",
"tsd": "^0.30.4"
},
"dependencies": {
"fastify-plugin": "^4.0.0",
"cookie-signature": "^1.1.0"
"fastify-plugin": "^5.0.0-pre.fv5.1",
"cookie-signature": "^1.2.1"
},
"tsd": {
"directory": "test"
Expand Down
4 changes: 2 additions & 2 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const kReplySetCookiesHookRan = Symbol('fastify.reply.setCookiesHookRan')
function fastifyCookieSetCookie (reply, name, value, options) {
parseCookies(reply.server, reply.request, reply)

const opts = Object.assign({}, options)
const opts = Object.assign({ sameSite: 'lax' }, options)

if (opts.expires && Number.isInteger(opts.expires)) {
opts.expires = new Date(opts.expires)
Expand All @@ -25,7 +25,6 @@ function fastifyCookieSetCookie (reply, name, value, options) {
if (reply.request.protocol === 'https') {
opts.secure = true
} else {
opts.sameSite = 'lax'
opts.secure = false
}
}
Expand All @@ -45,6 +44,7 @@ function fastifyCookieClearCookie (reply, name, options) {
signed: undefined,
maxAge: undefined
})

return fastifyCookieSetCookie(reply, name, '', opts)
}

Expand Down
6 changes: 3 additions & 3 deletions test/cookie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ test('should set multiple cookies', (t) => {
t.equal(cookies[2].name, 'wee')
t.equal(cookies[2].value, 'woo')

t.equal(res.headers['set-cookie'][1], 'bar=test; Partitioned')
t.equal(res.headers['set-cookie'][2], 'wee=woo; Secure; Partitioned')
t.equal(res.headers['set-cookie'][1], 'bar=test; Partitioned; SameSite=Lax')
t.equal(res.headers['set-cookie'][2], 'wee=woo; Secure; Partitioned; SameSite=Lax')
})
})

Expand Down Expand Up @@ -957,7 +957,7 @@ test('result in an error if hook-option is set to an invalid value', (t) => {
const fastify = Fastify()

t.rejects(
() => fastify.register(plugin, { hook: true }),
async () => fastify.register(plugin, { hook: true }),
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'")
)
})
Expand Down

0 comments on commit 1608401

Please sign in to comment.