Changelog
All notable changes to this project will be documented in this file.
[Unreleased]
Changed
- Docs tooling: VitePress now runs on a patched Vite 6 (npm
overrides), which clears the dev-only Vite and esbuild advisories. The published package is unaffected. repository.urlinpackage.jsonuses thegit+httpsform npm expects.
[2.1.0] - Oct 16, 2026
Security
sameSiteonly acceptsLax,StrictorNone. Other strings could inject attributes such aspathormax-age.- Glob patterns are matched with a linear-time matcher. The previous RegExp conversion could freeze the page on long cookie names (ReDoS).
pathanddomainsare validated. Unsafe paths are refused, and invalid domains are skipped instead of falling back to a host-only cookie.getJSONCookiedrops__proto__keys to prevent prototype changes when the result is merged.
Fixed
createCookieUtils: a per-call option set toundefinedno longer overrides the default.unitvalues likeconstructorand non-finite or hugetimeToLivevalues no longer produce invalidmax-agevalues (which browsers turned into session cookies). Lifetimes are capped at 400 days.deleteCookiesalso tries paths with a trailing slash.deleteCookiewithoutdomainsalso removes the host-only cookie.partitioned: truedefaultssameSitetoNone, which cross-site embeds need.- CommonJS builds are now emitted as
.cjsfiles. Previouslyrequire('browser-cookie-utils')returned an empty object in Node because the package is"type": "module". getCookieno longer throws when a cookie value isn't valid URI encoding; the raw value is returned.setCookie/deleteCookieno longer set an invaliddomainattribute onlocalhostor IP addresses, which made browsers drop the cookie.SameSite=Nonenow always addsSecure, as browsers require.- An unknown
unitnow falls back tohour(the documented default) instead of creating a session cookie. deleteCookiealso sets anexpiresdate in the past for older browsers.- Removed the duplicate
'use strict'from the CJS build.
Added
- Real-browser tests (Playwright: Chromium, Firefox, WebKit) run in CI with
npm run test:browser. They check what browsers actually store: domains, paths,Secure,SameSite, prefixes, partitioned cookies, size and expiry limits. createCookieUtils(defaults)returns the helpers with default options and an optionalnamePrefix.setCookieandsetJSONCookiereturntrueif the cookie can be read back afterwards;deleteCookiereturnstrueif the cookie is gone.partitionedoption onsetCookie,deleteCookieanddeleteCookiesadds thePartitioned(CHIPS) attribute and forcesSecure.- Cookie prefix rules:
__Secure-cookies always getSecure;__Host-cookies always getSecure,path=/and nodomain. - New
unitvalues:second,minute,weekandyear(365 days). expiresoption for an exact expiryDate, andsessionoption for session cookies.setJSONCookie(name, value, options)andgetJSONCookie(name)store and read JSON values.hasCookie(name)checks whether a cookie exists, even if its value is empty.getAllCookies()returns every cookie as an object of name → decoded value.getCookies(pattern)returns the cookies whose name matches a glob (*,?), RegExp or predicate.deleteCookies(pattern, options)deletes every cookie whose name matches a glob (*,?), RegExp or predicate, and returns the names it couldn't delete.- TypeScript declarations (
.d.ts/.d.cts). exportsentries for./umdand./package.json, plusunpkg/jsdelivrfields.- Helpers are no-ops (instead of throwing) when
documentisn't available, e.g. during SSR. - Cookie names are validated; invalid names are ignored.
- Unit tests (
npm test) and aprepublishOnlycheck.
Changed
Behavior changes to check when upgrading from 2.0.x:
- CommonJS files were renamed to
browser-cookie-utils.cjs/.min.cjs. Imports through the package name are unaffected; only directdist/*.cjs.jspaths need updating. - Invalid cookie names (spaces,
;,=, …) are ignored instead of written. - An unknown
unitnow falls back tohourinstead of creating a session cookie. - Unsafe
pathvalues and invaliddomainsare no longer written;setCookiereturnsfalse. deleteCookiewithoutdomainsalso removes the host-only cookie (two writes instead of one).setCookieanddeleteCookiereturn abooleaninstead ofundefined.
Project:
- Documentation site: https://samiahmedsiddiqui.github.io/browser-cookie-utils/
- Real-browser tests (Chromium, Firefox, WebKit) and coverage thresholds in CI.
- CI uses
npm ci, checks formatting instead of rewriting it, runs tests and verifiesdistis up to date. - README corrections (CDN version pinning, build table, deletion notes).
[2.0.1] - Jan 21, 2026
Fixed
- ESM exports (
getCookie,setCookie,deleteCookie) now work correctly for modern bundlers. - UMD build now properly exposes
browserCookieUtilsglobally in the browser and supports CommonJS. - Fixed build errors caused by Terser parsing
exportstatements inside wrapped code. - Updated README usage examples to reflect the correct import syntax for ESM and CommonJS.
[2.0.0] - Jan 5, 2026
⚠️ Breaking Changes
setCookieanddeleteCookienow use options object instead of positional arguments (see migration guide in README)
Added
- Dual-publish minified builds: ESM + CJS
- UMD build for legacy browsers / script tag & CommonJS
- Non-minified ESM and CJS builds for easier debugging
- Source maps for minified ESM
- Updated package.json
exportsfield for proper module resolution
Changed
- Build system updated for professional dual-publish workflow
- README updated with examples for ESM, CJS, and UMD usage
Improved
- Robust Terser minification with banners and error handling
- Clearer migration guidance
[1.0.0] - Dec 19, 2025
- Initial release of browser-cookie-utils
getCookie,setCookie,deleteCookiehelpers- Time-based expiration (
hour,day,month) - Multi-domain cookie support
- Secure cookies on HTTPS