{"name":"universal-cookie","version":"7.2.0","keywords":["universal","isomophic","cookie"],"author":{"name":"Benoit Tremblay","email":"me@ben.codes"},"license":"MIT","_id":"universal-cookie@7.2.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":"1f3fa9c575d863ac41b4e42272d240ae2d32c047","tarball":"http://registry-npm.ywwl.com/universal-cookie/download/universal-cookie-7.2.0.tgz","fileCount":19,"integrity":"sha512-PvcyflJAYACJKr28HABxkGemML5vafHmiL4ICe3e+BEKXRMt0GaFLZhAwgv637kFFnnfiSJ8e6jknrKkMrU+PQ==","signatures":[{"sig":"MEUCIQCzKi3i5DjB6i4SZ8AzDzj0xuupB1HaRXaVQFOrtwEviAIgVF/19AY1PKpR4YPZx7DZgMTLqBF4xW/CyOp9ixYo/eY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45425,"size":9488,"noattachment":false,"key":"/universal-cookie/-/universal-cookie-7.2.0.tgz"},"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":"da40af6caf8aa3c8a74d62e789f8107970743ef6","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.7.0","description":"Universal cookies for JavaScript","directories":{},"sideEffects":false,"_nodeVersion":"20.15.1","dependencies":{"cookie":"^0.6.0","@types/cookie":"^0.6.0"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","rollup":"^4.19.0","@babel/cli":"^7.24.8","typescript":"^5.5.3"},"_npmOperationalInternal":{"tmp":"tmp/universal-cookie_7.2.0_1721571269404_0.7058048770643468","host":"s3://npm-registry-packages"},"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":1721571269623,"_cnpm_publish_time":1721571269623,"dist-tags":{"latest":"8.1.2"}}