unstale

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 init

@unstale/cli on npm

tough-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.

    6.1.0release notes

  • A __Host- cookie now requires an explicit Path=/ attribute; a default path that resolves to / no longer satisfies the requirement.

    6.1.0release notes

  • 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.

    6.1.0release notes

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.

    6.1.0release notes

  • Added the exported PrefixSecurityMode string literal union type for the prefixSecurity option.

    6.1.0release notes

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.

    6.0.0release notes

  • The check on the Secure attribute when setting a cookie was reverted.

    6.0.0release notes

Tooling 1

  • The package supports publishing both ESM and CJS.

    6.0.0release notes

Fixes and other changes 5

  • Serialization now preserves an explicitly specified SameSite=None instead of dropping it.

    6.1.0release notes

  • An IPv4 address in the Domain attribute is accepted instead of being treated as a public suffix.

    6.1.0release notes

  • An infinite max-age is now treated as never expiring.

    6.1.0release notes

  • Request paths from URL object inputs are decoded to match string inputs.

    6.1.0release notes

  • Avoids decoding the URL authority part.

    6.0.2release notes

tough-cookie 510 changes

Breaking changes 3

  • The inspect function was removed in favor of Node.js's util.inspect.custom symbol.

    5.0.0release notes

  • The minimum supported Node.js version is now v18.

    5.0.0release notes

  • Official support for non-node environments is no longer provided.

    5.0.0release notes

New APIs and options 3

Performance 1

Behavior and default changes 1

  • Most exposed interfaces accept both null and undefined and return only undefined.

    5.0.0release notes

Fixes and other changes 2

  • Fixed the expiry time not updating when a cookie is updated.

    5.0.0release notes

  • Fixed validation errors not getting called in some callbacks.

    5.0.0release notes

tough-cookie 45 changes

Breaking changes 1

  • The callback function must be the last parameter.

    4.0.0release notes

New APIs and options 4