{"_id":"virtual-cookies","_rev":"3550799","name":"virtual-cookies","description":"Virtual cookies store to manage Request/Response associations.","dist-tags":{"latest":"0.1.2"},"maintainers":[{"name":"kettanaito","email":""},{"name":"npm:kettanaito","email":""}],"time":{"modified":"2024-09-19T02:42:03.000Z","created":"2020-11-19T16:23:46.678Z","0.1.2":"2020-12-05T12:59:06.409Z","0.1.1":"2020-11-19T16:23:46.678Z"},"users":{},"author":{"name":"Artem Zakharchenko"},"repository":{"type":"git","url":"git@github.com:mswjs/cookies.git"},"versions":{"0.1.2":{"name":"virtual-cookies","version":"0.1.2","description":"Virtual cookies store to manage Request/Response associations.","main":"lib/index.js","scripts":{"test":"jest","clean":"rimraf lib","build":"tsc","prepublishOnly":"yarn test && yarn clean && yarn build"},"repository":{"type":"git","url":"git@github.com:mswjs/cookies.git"},"author":{"name":"Artem Zakharchenko"},"license":"MIT","devDependencies":{"@types/jest":"^26.0.15","jest":"^26.6.3","rimraf":"^3.0.2","ts-jest":"^26.4.4","ts-node":"^9.0.0","typescript":"^4.0.5","whatwg-fetch":"^3.5.0"},"dependencies":{"@types/set-cookie-parser":"^2.4.0","set-cookie-parser":"^2.4.6"},"_id":"virtual-cookies@0.1.2","dist":{"shasum":"67683d2bba98b9351d9446274ccbfb9c105671cd","size":3159,"noattachment":false,"key":"/virtual-cookies/-/virtual-cookies-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/virtual-cookies/download/virtual-cookies-0.1.2.tgz"},"_npmUser":{"name":"kettanaito","email":"kettanaito@gmail.com"},"directories":{},"maintainers":[{"name":"kettanaito","email":""},{"name":"npm:kettanaito","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/virtual-cookies_0.1.2_1607173146223_0.1295647482387401"},"_hasShrinkwrap":false,"publish_time":1607173146409,"_cnpm_publish_time":1607173146409,"_cnpmcore_publish_time":"2021-12-16T18:59:36.315Z"},"0.1.1":{"name":"virtual-cookies","version":"0.1.1","description":"Virtual cookies store to manage Request/Response associations.","main":"lib/index.js","scripts":{"test":"jest","clean":"rimraf lib","build":"tsc","prepublishOnly":"yarn test && yarn clean && yarn build"},"repository":{"type":"git","url":"git@github.com:mswjs/cookies.git"},"author":{"name":"Artem Zakharchenko"},"license":"MIT","devDependencies":{"@types/jest":"^26.0.15","jest":"^26.6.3","rimraf":"^3.0.2","ts-jest":"^26.4.4","ts-node":"^9.0.0","typescript":"^4.0.5","whatwg-fetch":"^3.5.0"},"dependencies":{"@types/set-cookie-parser":"^2.4.0","set-cookie-parser":"^2.4.6"},"_id":"virtual-cookies@0.1.1","dist":{"shasum":"5fac667e3ec54f07fe4f586c50cae61075ef969d","size":2039,"noattachment":false,"key":"/virtual-cookies/-/virtual-cookies-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/virtual-cookies/download/virtual-cookies-0.1.1.tgz"},"_npmUser":{"name":"kettanaito","email":"kettanaito@gmail.com"},"directories":{},"maintainers":[{"name":"kettanaito","email":""},{"name":"npm:kettanaito","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/virtual-cookies_0.1.1_1605803026562_0.5341636039087481"},"_hasShrinkwrap":false,"publish_time":1605803026678,"_cnpm_publish_time":1605803026678,"_cnpmcore_publish_time":"2021-12-16T18:59:36.503Z"}},"readme":"[![Latest version](https://img.shields.io/npm/v/virtual-cookies.svg)](https://www.npmjs.com/package/virtual-cookies)\n\n# `virtual-cookies`\n\nVirtual cookie store to manage request/response cookies associations in a unique collection.\n\n## API\n\n### `set(req: Request, res: Response)`\n\nSets the response cookies in the store associated with the given request origin.\n\n```js\nstore.set(\n  new Request('https://mswjs.io'),\n  new Response(null, {\n    headers: new Headers({\n      'set-cookie': 'id=abc-123',\n    }),\n  })\n)\n```\n\n### `get(req: Request)`\n\nRetrieves the cookies relevant to the given request's origin.\n\n```js\nstore.get(new Request('https://mswjs.io'))\n```\n\n> `.get()` respects the `req.credentials` policy.\n\nExecuting this command returns a `Map` instance with the request cookies:\n\n```js\nMap {\n  \"id\" => { name: \"id\", value: \"abc-123\" }\n}\n```\n\n### `getAll()`\n\nReturns all the cookies in the store.\n\nExecuting `.getAll()` method returns a `Map` instance with request cookies grouped by request origin.\n\n```js\nMap {\n  \"https://mswjs.io\" => Map {\n    \"id\" => { name: \"id\", value: \"abc-123\" }\n  }\n}\n```\n\n### `deleteAll(req: Request)`\n\nRemoves all the cookies associated with the given request's origin.\n\n### `persist()`\n\nPersists the current store state in the `localStorage`.\n\n### `hydrate()`\n\nHydrates the store values from the previously persisted state in `localStorage`.\n\n### `clear()`\n\nRemoves all the cookies from the store, producing a nice and shiny empty store.\n\n## Credits\n\nOriginal idea by [\nChristoph Guttandin](https://github.com/chrisguttandin).\n","_attachments":{},"license":"MIT"}