diff --git a/.changeset/lovely-dingos-exist.md b/.changeset/lovely-dingos-exist.md new file mode 100644 index 00000000000..98e77a15a2f --- /dev/null +++ b/.changeset/lovely-dingos-exist.md @@ -0,0 +1,5 @@ +--- +"@remix-run/server-runtime": patch +--- + +update `cookie` to v1 diff --git a/contributors.yml b/contributors.yml index 38822cfde52..ac75b6f68c7 100644 --- a/contributors.yml +++ b/contributors.yml @@ -609,6 +609,7 @@ - shairez - shamsup - shashankboosi +- shelldandy - shininglovestar - shubhaguha - shumuu diff --git a/packages/remix-server-runtime/cookies.ts b/packages/remix-server-runtime/cookies.ts index 80884fa8fc2..d2241d10b37 100644 --- a/packages/remix-server-runtime/cookies.ts +++ b/packages/remix-server-runtime/cookies.ts @@ -1,10 +1,13 @@ -import type { CookieParseOptions, CookieSerializeOptions } from "cookie"; +import type { ParseOptions, SerializeOptions } from "cookie"; import { parse, serialize } from "cookie"; import type { SignFunction, UnsignFunction } from "./crypto"; import { warnOnce } from "./warnings"; -export type { CookieParseOptions, CookieSerializeOptions }; +export type { + ParseOptions as CookieParseOptions, + SerializeOptions as CookieSerializeOptions, +}; export interface CookieSignatureOptions { /** @@ -18,8 +21,8 @@ export interface CookieSignatureOptions { secrets?: string[]; } -export type CookieOptions = CookieParseOptions & - CookieSerializeOptions & +export type CookieOptions = ParseOptions & + SerializeOptions & CookieSignatureOptions; /** @@ -55,16 +58,13 @@ export interface Cookie { * Parses a raw `Cookie` header and returns the value of this cookie or * `null` if it's not present. */ - parse( - cookieHeader: string | null, - options?: CookieParseOptions - ): Promise; + parse(cookieHeader: string | null, options?: ParseOptions): Promise; /** * Serializes the given value to a string and returns the `Set-Cookie` * header. */ - serialize(value: any, options?: CookieSerializeOptions): Promise; + serialize(value: any, options?: SerializeOptions): Promise; } export type CreateCookieFunction = ( @@ -113,7 +113,9 @@ export const createCookieFactory = return name in cookies ? cookies[name] === "" ? "" - : await decodeCookieValue(unsign, cookies[name], secrets) + : cookies[name] === undefined + ? null + : decodeCookieValue(unsign, cookies[name], secrets) : null; }, async serialize(value, serializeOptions) { diff --git a/packages/remix-server-runtime/package.json b/packages/remix-server-runtime/package.json index c9373fc86e1..704bb1b353f 100644 --- a/packages/remix-server-runtime/package.json +++ b/packages/remix-server-runtime/package.json @@ -20,9 +20,8 @@ }, "dependencies": { "@remix-run/router": "1.21.0", - "@types/cookie": "^0.6.0", "@web3-storage/multipart-parser": "^1.0.0", - "cookie": "^0.6.0", + "cookie": "^1.0.1", "set-cookie-parser": "^2.4.8", "source-map": "^0.7.3", "turbo-stream": "2.4.0" diff --git a/packages/remix-server-runtime/sessions.ts b/packages/remix-server-runtime/sessions.ts index c00eedb2321..a1c54251125 100644 --- a/packages/remix-server-runtime/sessions.ts +++ b/packages/remix-server-runtime/sessions.ts @@ -1,4 +1,4 @@ -import type { CookieParseOptions, CookieSerializeOptions } from "cookie"; +import type { ParseOptions, SerializeOptions } from "cookie"; import type { Cookie, CookieOptions, CreateCookieFunction } from "./cookies"; import { isCookie } from "./cookies"; @@ -176,7 +176,7 @@ export interface SessionStorage { */ getSession: ( cookieHeader?: string | null, - options?: CookieParseOptions + options?: ParseOptions ) => Promise>; /** @@ -185,7 +185,7 @@ export interface SessionStorage { */ commitSession: ( session: Session, - options?: CookieSerializeOptions + options?: SerializeOptions ) => Promise; /** @@ -194,7 +194,7 @@ export interface SessionStorage { */ destroySession: ( session: Session, - options?: CookieSerializeOptions + options?: SerializeOptions ) => Promise; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 00a209a327f..c628e674b04 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1366,15 +1366,12 @@ importers: '@remix-run/router': specifier: 1.21.0 version: 1.21.0 - '@types/cookie': - specifier: ^0.6.0 - version: 0.6.0 '@web3-storage/multipart-parser': specifier: ^1.0.0 version: 1.0.0 cookie: - specifier: ^0.6.0 - version: 0.6.0 + specifier: ^1.0.1 + version: 1.0.1 set-cookie-parser: specifier: ^2.4.8 version: 2.6.0 @@ -4714,10 +4711,6 @@ packages: resolution: {integrity: sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==} dev: true - /@types/cookie@0.6.0: - resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} - dev: false - /@types/cookiejar@2.1.5: resolution: {integrity: sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==} dev: true @@ -6664,15 +6657,15 @@ packages: resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} engines: {node: '>= 0.6'} - /cookie@0.6.0: - resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} - engines: {node: '>= 0.6'} - dev: false - /cookie@0.7.1: resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==} engines: {node: '>= 0.6'} + /cookie@1.0.1: + resolution: {integrity: sha512-Xd8lFX4LM9QEEwxQpF9J9NTUh8pmdJO0cyRJhFiDoLTk2eH8FXlRv2IFGYVadZpqI3j8fhNrSdKCeYPxiAhLXw==} + engines: {node: '>=18'} + dev: false + /cookiejar@2.1.4: resolution: {integrity: sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==} dev: true