Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(server-runtime): update cookie to v1 #10104

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-dingos-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/server-runtime": patch
---

update `cookie` to v1
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@
- shairez
- shamsup
- shashankboosi
- shelldandy
- shininglovestar
- shubhaguha
- shumuu
Expand Down
22 changes: 12 additions & 10 deletions packages/remix-server-runtime/cookies.ts
Original file line number Diff line number Diff line change
@@ -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 {
/**
Expand All @@ -18,8 +21,8 @@ export interface CookieSignatureOptions {
secrets?: string[];
}

export type CookieOptions = CookieParseOptions &
CookieSerializeOptions &
export type CookieOptions = ParseOptions &
SerializeOptions &
CookieSignatureOptions;

/**
Expand Down Expand Up @@ -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<any>;
parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;

/**
* Serializes the given value to a string and returns the `Set-Cookie`
* header.
*/
serialize(value: any, options?: CookieSerializeOptions): Promise<string>;
serialize(value: any, options?: SerializeOptions): Promise<string>;
}

export type CreateCookieFunction = (
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions packages/remix-server-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions packages/remix-server-runtime/sessions.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -176,7 +176,7 @@ export interface SessionStorage<Data = SessionData, FlashData = Data> {
*/
getSession: (
cookieHeader?: string | null,
options?: CookieParseOptions
options?: ParseOptions
) => Promise<Session<Data, FlashData>>;

/**
Expand All @@ -185,7 +185,7 @@ export interface SessionStorage<Data = SessionData, FlashData = Data> {
*/
commitSession: (
session: Session<Data, FlashData>,
options?: CookieSerializeOptions
options?: SerializeOptions
) => Promise<string>;

/**
Expand All @@ -194,7 +194,7 @@ export interface SessionStorage<Data = SessionData, FlashData = Data> {
*/
destroySession: (
session: Session<Data, FlashData>,
options?: CookieSerializeOptions
options?: SerializeOptions
) => Promise<string>;
}

Expand Down
21 changes: 7 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.