npm / tough-cookie
tough-cookie
What changed in tough-cookie 4 to 6, from its official release notes, upgrade guides and advisories. Also covers @types/tough-cookie. Sources checked 2026-11-30.
7 breaking9 new APIs and options1 performance3 behavior and defaults1 tooling7 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli inittough-cookie 613 changes
Breaking changes 3
Cookie.validate() now returns false for names outside the HTTP token grammar, including empty, separator-containing, control-character, and non-ASCII names; parsing and storage are unchanged.
A __Host- cookie now requires an explicit Path=/ attribute; a default path that resolves to / no longer satisfies the requirement.
CookieJar refuses to store a Secure cookie set from an untrustworthy origin; setCookie() rejects with an error or silently drops it when ignoreError: true is passed.
New APIs and options 2
Now accepts a URL as well as a string, matching its async counterpart; the other listed synchronous methods also accept URL inputs.
Added the exported PrefixSecurityMode string literal union type for the prefixSecurity option.
Behavior and default changes 2
Localhost connections over http are considered secure by default, so secure cookies work on localhost; the feature can be configured.
The check on the Secure attribute when setting a cookie was reverted.
Tooling 1
The package supports publishing both ESM and CJS.
Fixes and other changes 5
Serialization now preserves an explicitly specified SameSite=None instead of dropping it.
An IPv4 address in the Domain attribute is accepted instead of being treated as a public suffix.
An infinite max-age is now treated as never expiring.
Request paths from URL object inputs are decoded to match string inputs.
Avoids decoding the URL authority part.
tough-cookie 510 changes
Breaking changes 3
The inspect function was removed in favor of Node.js's util.inspect.custom symbol.
The minimum supported Node.js version is now v18.
Official support for non-node environments is no longer provided.
New APIs and options 3
First-party TypeScript types are now available.
Now accepts a string or URL as a parameter.
Now accepts a URL parameter.
Performance 1
Performance improvements.
Behavior and default changes 1
Most exposed interfaces accept both null and undefined and return only undefined.
Fixes and other changes 2
Fixed the expiry time not updating when a cookie is updated.
Fixed validation errors not getting called in some callbacks.
tough-cookie 45 changes
Breaking changes 1
The callback function must be the last parameter.
New APIs and options 4
Cookie prefix support was added.
Support for
.localwas added.Support for promises was added.
SameSite cookie support was added.