chore(deps,middleware): bump cookie to 2.0.1 and migrate to parseCookie - #659
Merged
Conversation
Supersedes #652, which does not compile as raised. Split out of the consolidated batch #658 because this needs a source change and sits in the session-verification path. cookie v2.0.0 dropped the deprecated `parse`/`serialize` aliases (renamed to `parseCookie`/`stringifySetCookie` back in v1.1.0) and moved the package to ESM-only. We import exactly the removed `parse` symbol in src/auth/operatorAuthAccessor.ts, so the bump requires the rename. The ESM half is a non-issue: middleware is already "type": "module" and the stack is pinned to Node 22 throughout (engines ">=22.13.0 <23", .nvmrc 22.22.3, CI node 22, Dockerfiles node:22.23.2). parseCookie returns Cookies = Record<string, string | undefined>, exactly the type the call site already declares, so the function body is unchanged. Also drops @types/cookie: cookie v2 ships its own dist/index.d.ts next to its export target, so TypeScript never consults the stub, and nothing else in the lockfile depends on it. express and cookie-parser are unaffected — they declare cookie@^0.7.1 and cookie@0.7.2, so npm nests their own 0.7.2 copies; only our direct import resolves to 2.0.1. Verified on Node 22.22.3 in CI job order: build, lint (0 errors), typecheck and 6094 pass / 0 fail / 4 skipped, including the suites that exercise this accessor (adminKeysRouter operator-session auth with real verification, publicPathsExemption, publicMcpKeyBindingsAdmin).
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of the consolidated batch #658, because this is not a version bump — it needs a source change, and it touches the session-verification path.
Supersedes #652.
Why it could not ride along in the batch
cookiev2.0.0 made two breaking changes:parse/serializeexports. They were renamed inv1.1.0 (
parse→parseCookie,serialize→stringifySetCookie) with the oldnames kept as aliases, and v2.0.0 dropped the aliases.
require(esm); older Node is unsupported.We import exactly the removed symbol:
So #652 as raised does not compile.
The ESM half is a non-issue here:
middlewareis already"type": "module", andthe whole stack is pinned to Node 22 (
engines">=22.13.0 <23",.nvmrc22.22.3, CInode-version: '22', Dockerfiles onnode:22.23.2).The change
cookie^0.7.2→^2.0.1, plus the one-line rename at the single call site:parseCookiereturnsCookies = Record<string, string | undefined>, which isexactly the type the call site already declares for the result, so nothing else
in the function changes.
@types/cookieis dropped. cookie v2 ships its owndist/index.d.tsalongside its export target, so TypeScript resolves types from the package itself
and the
@types/cookiestub is never consulted. Nothing else in the tree dependson it (verified against the lockfile) — leaving it would keep a types package
describing an API we no longer use.
Blast radius
One import, one function, in the operator-session path —
createOperatorAuthAccessoris the thin adapter from a raw
Cookieheader toevaluateSessionToken, which isthe single code path deciding session validity for gated
/api/v1/*routes and forplugins using
ctx.operatorAuth.expressandcookie-parserare unaffected: they declarecookie@^0.7.1andcookie@0.7.2respectively, so npm nests their own 0.7.2 copies. Only our directimport resolves to 2.0.1. The lockfile diff shows exactly that — 27 added / 5
removed lines, with
node_modules/cookieat 2.0.1 andnode_modules/express/node_modules/cookieplusnode_modules/cookie-parser/node_modules/cookieat 0.7.2.Verification
Run locally on Node 22.22.3 in CI job order (
npm ci→ build → lint → typecheck→ test). Results are in the PR checks; the suites that exercise this accessor are
test/channelApi/adminKeysRouter.test.ts,test/channelApi/publicPathsExemption.test.tsandtest/publicMcp/publicMcpKeyBindingsAdmin.test.ts.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.