{"name":"universal-cookie","version":"8.0.0","keywords":["universal","isomophic","cookie"],"author":{"name":"Benoit Tremblay","email":"me@ben.codes"},"license":"MIT","_id":"universal-cookie@8.0.0","maintainers":[{"name":"exon","email":"trembl.ben@gmail.com"}],"homepage":"https://github.com/bendotcodes/cookies/tree/main/packages/universal-cookie#readme","bugs":{"url":"https://github.com/bendotcodes/cookies/issues"},"dist":{"shasum":"ddaa7cf8d0269501c9812313a169c3ba25c02385","tarball":"http://registry-npm.ywwl.com/universal-cookie/download/universal-cookie-8.0.0.tgz","fileCount":19,"integrity":"sha512-p5D4A9zpJ8Hp798kZJVN5kuzLsXrN/1HKjI5cukRwVNEdOnx0/XXWBgVfWtAvncgnFQwKdlPjyeAp7qdRaqQLQ==","signatures":[{"sig":"MEQCIDvjmLLyu6keq7oTYnDidTmpvMEs8WZpB30uFAA/hmWhAiAbMOTlq7csYSYgrp1zp3/jD4VoptzB99fsrZmLhyDajw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54359,"size":10748,"noattachment":false,"key":"/universal-cookie/-/universal-cookie-8.0.0.tgz"},"main":"cjs/index.js","types":"cjs/index.d.ts","module":"esm/index.mjs","exports":{".":{"import":{"types":"./esm/index.d.mts","default":"./esm/index.mjs"},"default":"./cjs/index.js","require":{"types":"./cjs/index.d.ts","default":"./cjs/index.js"}}},"gitHead":"86315e6a475a7167835a56209a766643da283786","scripts":{"build":"rollup -c","prebuild":"rimraf esm && rimraf cjs && rimraf umd","postbuild":"node ../../tools/fix-typescript-typedef.mjs ./esm"},"_npmUser":{"name":"exon","email":"trembl.ben@gmail.com"},"repository":{"url":"git+https://github.com/bendotcodes/cookies.git","type":"git"},"_npmVersion":"10.9.2","description":"Universal cookies for JavaScript","directories":{},"sideEffects":false,"_nodeVersion":"22.14.0","dependencies":{"cookie":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","rollup":"^4.35.0","@babel/cli":"^7.26.4","typescript":"^5.8.2"},"_npmOperationalInternal":{"tmp":"tmp/universal-cookie_8.0.0_1741917213932_0.9785280999462331","host":"s3://npm-registry-packages-npm-production"},"readme":"<h3 align=\"center\">\n  universal-cookie\n</h3>\n\n<p align=\"center\">\n  Universal cookies for JavaScript<br />\n  <a href=\"https://badge.fury.io/js/universal-cookie\"><img src=\"https://badge.fury.io/js/universal-cookie.svg\" /></a>\n  <img src=\"https://github.com/github/docs/actions/workflows/test.yml/badge.svg\" />\n</p>\n\n## Integrations\n\n- [`react-cookie`](https://www.npmjs.com/package/react-cookie) - Universal cookies for React\n- [`universal-cookie-express`](https://www.npmjs.com/package/universal-cookie-express) - Hook cookies get/set on Express for server-rendering\n\n## Getting started\n\n`npm install universal-cookie`\n\nor in the browser (global variable `UniversalCookie`):\n\n```html\n<script\n  crossorigin\n  src=\"https://unpkg.com/universal-cookie@7/umd/universalCookie.min.js\"\n></script>\n```\n\n## API - Cookies class\n\n### `constructor([cookieHeader], [defaultSetOptions])`\n\nCreate a cookies context\n\n- cookieHeader (string|object): specify the cookie header or object\n- defaultSetOptions (object): specify the default options when setting cookies\n  - path (string): cookie path, use `/` as the path if you want your cookie to be accessible on all pages\n  - expires (Date): absolute expiration date for the cookie\n  - maxAge (number): relative max age of the cookie from when the client receives it in seconds\n  - domain (string): domain for the cookie (sub.domain.com or .allsubdomains.com)\n  - secure (boolean): Is only accessible through HTTPS?\n  - httpOnly (boolean): Is only the server can access the cookie? **Note: You cannot get or set httpOnly cookies from the browser, only the server.**\n  - sameSite (boolean|none|lax|strict): Strict or Lax enforcement\n  - partitioned (boolean): Indicates that the cookie should be stored using partitioned storage\n\n### `get(name, [options])`\n\nGet a cookie value\n\n- name (string): cookie name\n- options (object):\n  - doNotParse (boolean): do not convert the cookie into an object no matter what\n\n### `getAll([options])`\n\nGet all cookies\n\n- options (object):\n  - doNotParse (boolean): do not convert the cookie into an object no matter what\n\n### `set(name, value, [options])`\n\nSet a cookie value\n\n- name (string): cookie name\n- value (string|object): save the value and stringify the object if needed\n- options (object): Support all the cookie options from RFC 6265\n  - path (string): cookie path, use `/` as the path if you want your cookie to be accessible on all pages\n  - expires (Date): absolute expiration date for the cookie\n  - maxAge (number): relative max age of the cookie from when the client receives it in seconds\n  - domain (string): domain for the cookie (sub.domain.com or .allsubdomains.com)\n  - secure (boolean): Is only accessible through HTTPS?\n  - httpOnly (boolean): Is only the server can access the cookie? **Note: You cannot get or set httpOnly cookies from the browser, only the server.**\n  - sameSite (boolean|none|lax|strict): Strict or Lax enforcement\n  - partitioned (boolean): Indicates that the cookie should be stored using partitioned storage\n\n### `remove(name, [options])`\n\nRemove a cookie\n\n- name (string): cookie name\n- options (object): Support all the cookie options from RFC 6265\n  - path (string): cookie path, use `/` as the path if you want your cookie to be accessible on all pages\n  - expires (Date): absolute expiration date for the cookie\n  - maxAge (number): relative max age of the cookie from when the client receives it in seconds\n  - domain (string): domain for the cookie (sub.domain.com or .allsubdomains.com)\n  - secure (boolean): Is only accessible through HTTPS?\n  - httpOnly (boolean): Is only the server can access the cookie? **Note: You cannot get or set httpOnly cookies from the browser, only the server.**\n  - sameSite (boolean|none|lax|strict): Strict or Lax enforcement\n  - partitioned (boolean): Indicates that the cookie should be stored using partitioned storage\n\n### `addChangeListener(callback)`\n\nAdd a listener to when a cookie is set or removed.\n\n- callback (function): Call that will be called with the first argument containing `name`, `value` and `options` of the changed cookie.\n\n### `removeChangeListener(callback)`\n\nRemove a listener from the change callback.\n\n### `removeAllChangeListeners()`\n\nRemove all change listeners that were previously added with `addChangeListener()`.\n\n### `update()`\n\nRead back the cookies from the browser and triggers the change listeners. This should normally not be necessary because this library detects cookie changes automatically.\n\n## Browser Example\n\n```js\nimport Cookies from 'universal-cookie';\n\nconst cookies = new Cookies(null, { path: '/' });\n\ncookies.set('myCat', 'Pacman');\nconsole.log(cookies.get('myCat')); // Pacman\n```\n\n## Server Example\n\n```js\nimport Cookies from 'universal-cookie';\n\nconst cookies = new Cookies(req.headers.cookie, { path: '/' });\n\nconsole.log(cookies.get('myCat')); // Pacman or undefined if not set yet\n```\n","publish_time":1741917214123,"_cnpm_publish_time":1741917214123,"dist-tags":{"latest":"8.1.2"}}