Skip to content

fix(KNO-13317): Remove js-cookie #1450

Merged
andy-knock merged 2 commits into
mainfrom
upgrade-js-cookie
May 26, 2026
Merged

fix(KNO-13317): Remove js-cookie #1450
andy-knock merged 2 commits into
mainfrom
upgrade-js-cookie

Conversation

@andy-knock
Copy link
Copy Markdown
Contributor

@andy-knock andy-knock commented May 26, 2026

Description

https://linear.app/knock/issue/KNO-13317/control-marketing-site-docs-small-upgrade-for-js-cookie

@kylemcd pointed out our usage is pretty trivial.

I rewrote the code to remove the dependency entirely instead of maintaining it

Test steps:

Open http://localhost:3002?utm_source=test&utm_medium=manual

Verify that cookies are set correctly

Screenshot 2026-05-26 at 12 24 11 PM

Refresh page without utm headers, verify cookies persist

Screenshot 2026-05-26 at 12 24 17 PM Screenshot 2026-05-26 at 12 25 24 PM

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 26, 2026

KNO-13317

@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 26, 2026 5:01pm

Request Review

Copy link
Copy Markdown
Contributor Author

andy-knock commented May 26, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@andy-knock andy-knock requested review from a team, BenaventeX24 and meryldakin and removed request for a team May 26, 2026 15:22
@andy-knock andy-knock changed the title fix(KNO-13317): Upgrade js-cookie to 3.0.7 fix(KNO-13317): Upgrade js-cookie to 3.0.7 (security) May 26, 2026
@andy-knock andy-knock requested a review from kylemcd May 26, 2026 15:23
@andy-knock andy-knock marked this pull request as ready for review May 26, 2026 15:23
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk HIGH: Upgrades js-cookie from 3.0.5 to 3.0.7 to address a security vulnerability.

Reasons

  • package.json is modified, which is an automatic HIGH risk trigger per classification rules
  • yarn.lock is modified with updated dependency resolution
  • The change itself is a minimal semver patch bump (3.0.5 → 3.0.7) for a single dependency
  • The diff is very small (5 additions, 5 deletions across 2 files) with no functional code changes
  • No application code, components, or content files are affected

Notes

  • Despite the HIGH classification (triggered by package.json/yarn.lock modification), the actual risk profile of this change is low — it is a straightforward minor version bump of a single dependency for a security fix
  • Reviewer should verify the js-cookie 3.0.7 changelog to confirm there are no breaking changes
  • Confirm the Vercel preview deployment builds and functions correctly with the updated dependency
  • Consider running a quick smoke test on any cookie-dependent functionality (e.g., analytics or consent tracking)
Open in Web View Automation 

Sent by Cursor Automation: Docs PR classifier

Copy link
Copy Markdown
Member

@kylemcd kylemcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this honestly feels like a complete unnecessary dependency. only used in one place too. might just be better to remove it and refactor the one place it's used.

@andy-knock
Copy link
Copy Markdown
Contributor Author

this honestly feels like a complete unnecessary dependency. only used in one place too. might just be better to remove it and refactor the one place it's used.

Won't merge this quite yet, Let me audit the usages across our codebase

@andy-knock andy-knock force-pushed the upgrade-js-cookie branch from 5539139 to 2ffb8b2 Compare May 26, 2026 16:20
@andy-knock andy-knock marked this pull request as draft May 26, 2026 16:27
@andy-knock andy-knock changed the title fix(KNO-13317): Upgrade js-cookie to 3.0.7 (security) fix(KNO-13317): Remove js-cookie May 26, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1ddbb79. Configure here.

Comment thread yarn.lock Outdated
@andy-knock andy-knock requested a review from cjbell May 26, 2026 16:29
@andy-knock andy-knock marked this pull request as ready for review May 26, 2026 16:30
@andy-knock andy-knock force-pushed the upgrade-js-cookie branch 2 times, most recently from c3bbd44 to efcaa1b Compare May 26, 2026 16:30
@andy-knock andy-knock requested a review from kylemcd May 26, 2026 16:32
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk HIGH: Removes the js-cookie dependency entirely and replaces it with native document.cookie helpers in lib/attribution.ts.

Reasons

  • lib/attribution.ts is modified — a .ts file in lib/ triggers HIGH risk per classification rules
  • package.json is modified (removes js-cookie from dependencies and @types/js-cookie from devDependencies), which is an automatic HIGH risk trigger
  • yarn.lock is modified with dependency removals, and contains unresolved merge conflict markers (<<<<<<< HEAD, =======, >>>>>>>) that will break installs
  • The refactor replaces a well-tested library with custom cookie read/write functions (38 new lines of utility code), which introduces functional risk around cookie encoding, expiry handling, and edge cases
  • Total diff is small (46+/21- across 3 files), limiting blast radius despite the HIGH classification

Notes

  • Critical: The yarn.lock file contains unresolved git merge conflict markers (lines with <<<<<<< HEAD, =======, and >>>>>>>) — this must be resolved before merging or yarn install will fail
  • Reviewer should verify the custom getCookie regex handles all cookie name characters correctly (the regex escapes special chars, but edge cases with encoded values should be considered)
  • The setCookie function accepts expires as either a number (days) or a Date — verify the 864e5 constant (86,400,000 ms = 1 day) produces correct expiry behavior
  • The CookieOptions.sameSite is typed as string rather than a union type ("Strict" | "Lax" | "None") — consider tightening this for type safety
  • Confirm the Vercel preview deployment builds and the UTM cookie attribution flow works end-to-end per the author's test steps
Open in Web View Automation 

Sent by Cursor Automation: Docs PR classifier

Comment thread yarn.lock Outdated
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-3.0.7.tgz#0a53abfc459c8e89c85d7a38eb6cb68714965b8c"
integrity sha512-z/wZZgDrkNV1eA0ULjM/F9/50Ya8fbzgKneSpoPsXSGd0KnpdtHfOZWK+GcwLk+EZbS4F9RBhU+K2RgzuDaItw==

=======
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflict markers detected. This file contains unresolved git conflict markers (<<<<<<< HEAD, =======, >>>>>>>) which will cause yarn install to fail. This needs to be resolved before merging.

Copy link
Copy Markdown
Member

@kylemcd kylemcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just need to remove the merge conflict markers and good to go 👍

@andy-knock andy-knock force-pushed the upgrade-js-cookie branch from efcaa1b to 2031800 Compare May 26, 2026 16:54
@andy-knock andy-knock force-pushed the upgrade-js-cookie branch from 2031800 to b0684e2 Compare May 26, 2026 16:54
@andy-knock andy-knock force-pushed the upgrade-js-cookie branch from b0684e2 to 5ac8b42 Compare May 26, 2026 16:54
@andy-knock andy-knock merged commit 791e6be into main May 26, 2026
6 checks passed
@andy-knock andy-knock deleted the upgrade-js-cookie branch May 26, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants