Skip to content

Commit 87c23f8

Browse files
authored
breaking(deps): cookie v1.0.2 (#11862)
1 parent 7b65fc2 commit 87c23f8

File tree

8 files changed

+49
-45
lines changed

8 files changed

+49
-45
lines changed

.changesets/11862.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- breaking(deps): cookie v1.0.2 (#11862) by @Tobbe
2+
3+
See https://github.com/jshttp/cookie/releases/tag/v1.0.0 for what's breaking in
4+
this release.
5+
6+
We expose the `SerializeOptions` type (that used to be named
7+
`CookieSerializeOptions`), and it has changed.
8+
It's very unlikely that you're affected by this change. But if you are it'd
9+
probably be becase you're accessing our cookie jar, and used its `set` method
10+
you might be affected by this change.

packages/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"dependencies": {
5353
"@prisma/client": "5.20.0",
5454
"@whatwg-node/fetch": "0.9.21",
55-
"cookie": "0.7.2",
55+
"cookie": "1.0.2",
5656
"humanize-string": "2.1.0",
5757
"jsonwebtoken": "9.0.2",
5858
"pascalcase": "1.0.0",

packages/cookie-jar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"test": "vitest run"
2424
},
2525
"dependencies": {
26-
"cookie": "0.7.2",
26+
"cookie": "1.0.2",
2727
"esbuild": "0.24.2",
2828
"fast-glob": "3.3.2",
2929
"fs-extra": "11.2.0"

packages/cookie-jar/src/CookieJar.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
1-
import cookie from 'cookie'
1+
import * as cookie from 'cookie'
2+
import type { SerializeOptions } from 'cookie'
23

34
export type CookieParams = {
45
value: string
5-
options?: cookie.CookieSerializeOptions
6+
options?: SerializeOptions
67
}
78

89
/** Specialized cookie map, that lets you set cookies with options */
910
export class CookieJar {
1011
private map = new Map<string, CookieParams>()
1112

12-
// This allows CookieJar to be used in MWRequest.cookie also
13-
// note that options are not available when constructed this way
13+
// This allows CookieJar to be used in MiddlewareRequest.cookie
14+
// Also note that options are not available when constructed this way
1415
constructor(cookieString?: string | null) {
15-
if (cookieString) {
16-
const parsedCookies = cookie.parse(cookieString)
17-
18-
this.map = new Map(
19-
Object.entries(parsedCookies).map(([key, value]) => {
20-
return [key, { value }]
21-
}),
22-
)
16+
if (cookieString === null || typeof cookieString === 'undefined') {
17+
return
2318
}
19+
20+
const parsedCookies = cookie.parse(cookieString)
21+
22+
this.map = new Map(
23+
Object.entries(parsedCookies).map(([key, value]) => {
24+
// Since we're not passing any options to cookie.parse above we will
25+
// always use their internal `decode` function to decode the cookie
26+
// value, and that function will always return a string. So the
27+
// `typeof` check here will always be false.
28+
if (typeof value === 'undefined') {
29+
// This cannot happen. See comment above.
30+
throw new Error('Cookie value is undefined')
31+
}
32+
33+
return [key, { value }]
34+
}),
35+
)
2436
}
2537

26-
public set(
27-
name: string,
28-
value: string,
29-
options?: cookie.CookieSerializeOptions,
30-
) {
31-
this.map.set(name, {
32-
value,
33-
options,
34-
})
38+
public set(name: string, value: string, options?: SerializeOptions) {
39+
this.map.set(name, { value, options })
3540

3641
return this
3742
}

packages/vite/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"acorn-loose": "8.4.0",
7474
"buffer": "6.0.3",
7575
"busboy": "^1.6.0",
76-
"cookie": "0.7.2",
76+
"cookie": "1.0.2",
7777
"core-js": "3.38.1",
7878
"dotenv-defaults": "5.0.2",
7979
"execa": "5.1.1",
@@ -95,7 +95,6 @@
9595
"@arethetypeswrong/cli": "0.16.4",
9696
"@hyrious/esbuild-plugin-commonjs": "0.2.4",
9797
"@types/busboy": "^1",
98-
"@types/cookie": "^0",
9998
"@types/express": "4",
10099
"@types/fs-extra": "11.0.4",
101100
"@types/react": "^18.2.55",

packages/web/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
"@redwoodjs/server-store": "workspace:*",
148148
"@whatwg-node/fetch": "0.9.21",
149149
"apollo-upload-client": "18.0.1",
150-
"cookie": "0.7.2",
150+
"cookie": "1.0.2",
151151
"core-js": "3.38.1",
152152
"graphql": "16.9.0",
153153
"graphql-sse": "2.5.3",
@@ -170,7 +170,6 @@
170170
"@testing-library/jest-dom": "6.5.0",
171171
"@testing-library/react": "14.3.1",
172172
"@types/apollo-upload-client": "^18",
173-
"@types/cookie": "^0",
174173
"@types/react": "^18.2.55",
175174
"@types/react-dom": "^18.2.19",
176175
"concurrently": "8.2.2",

packages/web/src/server/MiddlewareResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Response as PonyResponse } from '@whatwg-node/fetch'
2-
import cookie from 'cookie'
2+
import * as cookie from 'cookie'
33

44
import { CookieJar } from '@redwoodjs/cookie-jar'
55

yarn.lock

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7544,7 +7544,7 @@ __metadata:
75447544
"@types/split2": "npm:4.2.3"
75457545
"@whatwg-node/fetch": "npm:0.9.21"
75467546
concurrently: "npm:8.2.2"
7547-
cookie: "npm:0.7.2"
7547+
cookie: "npm:1.0.2"
75487548
humanize-string: "npm:2.1.0"
75497549
jsonwebtoken: "npm:9.0.2"
75507550
memjs: "npm:1.3.2"
@@ -8339,7 +8339,7 @@ __metadata:
83398339
dependencies:
83408340
"@redwoodjs/framework-tools": "workspace:*"
83418341
"@types/fs-extra": "npm:11.0.4"
8342-
cookie: "npm:0.7.2"
8342+
cookie: "npm:1.0.2"
83438343
esbuild: "npm:0.24.2"
83448344
fast-glob: "npm:3.3.2"
83458345
fs-extra: "npm:11.2.0"
@@ -9020,7 +9020,6 @@ __metadata:
90209020
"@redwoodjs/web": "workspace:*"
90219021
"@swc/core": "npm:1.7.28"
90229022
"@types/busboy": "npm:^1"
9023-
"@types/cookie": "npm:^0"
90249023
"@types/express": "npm:4"
90259024
"@types/fs-extra": "npm:11.0.4"
90269025
"@types/react": "npm:^18.2.55"
@@ -9033,7 +9032,7 @@ __metadata:
90339032
buffer: "npm:6.0.3"
90349033
busboy: "npm:^1.6.0"
90359034
concurrently: "npm:8.2.2"
9036-
cookie: "npm:0.7.2"
9035+
cookie: "npm:1.0.2"
90379036
core-js: "npm:3.38.1"
90389037
dotenv-defaults: "npm:5.0.2"
90399038
execa: "npm:5.1.1"
@@ -9105,13 +9104,12 @@ __metadata:
91059104
"@testing-library/jest-dom": "npm:6.5.0"
91069105
"@testing-library/react": "npm:14.3.1"
91079106
"@types/apollo-upload-client": "npm:^18"
9108-
"@types/cookie": "npm:^0"
91099107
"@types/react": "npm:^18.2.55"
91109108
"@types/react-dom": "npm:^18.2.19"
91119109
"@whatwg-node/fetch": "npm:0.9.21"
91129110
apollo-upload-client: "npm:18.0.1"
91139111
concurrently: "npm:8.2.2"
9114-
cookie: "npm:0.7.2"
9112+
cookie: "npm:1.0.2"
91159113
core-js: "npm:3.38.1"
91169114
graphql: "npm:16.9.0"
91179115
graphql-sse: "npm:2.5.3"
@@ -10860,13 +10858,6 @@ __metadata:
1086010858
languageName: node
1086110859
linkType: hard
1086210860

10863-
"@types/cookie@npm:^0":
10864-
version: 0.6.0
10865-
resolution: "@types/cookie@npm:0.6.0"
10866-
checksum: 10c0/5b326bd0188120fb32c0be086b141b1481fec9941b76ad537f9110e10d61ee2636beac145463319c71e4be67a17e85b81ca9e13ceb6e3bb63b93d16824d6c149
10867-
languageName: node
10868-
linkType: hard
10869-
1087010861
"@types/cookie@npm:^0.4.1":
1087110862
version: 0.4.1
1087210863
resolution: "@types/cookie@npm:0.4.1"
@@ -14806,10 +14797,10 @@ __metadata:
1480614797
languageName: node
1480714798
linkType: hard
1480814799

14809-
"cookie@npm:0.7.2":
14810-
version: 0.7.2
14811-
resolution: "cookie@npm:0.7.2"
14812-
checksum: 10c0/9596e8ccdbf1a3a88ae02cf5ee80c1c50959423e1022e4e60b91dd87c622af1da309253d8abdb258fb5e3eacb4f08e579dc58b4897b8087574eee0fd35dfa5d2
14800+
"cookie@npm:1.0.2":
14801+
version: 1.0.2
14802+
resolution: "cookie@npm:1.0.2"
14803+
checksum: 10c0/fd25fe79e8fbcfcaf6aa61cd081c55d144eeeba755206c058682257cb38c4bd6795c6620de3f064c740695bb65b7949ebb1db7a95e4636efb8357a335ad3f54b
1481314804
languageName: node
1481414805
linkType: hard
1481514806

0 commit comments

Comments
 (0)