{"name":"@mswjs/cookies","version":"0.1.3","author":{"name":"Artem Zakharchenko"},"license":"MIT","_id":"@mswjs/cookies@0.1.3","maintainers":[{"name":"kettanaito","email":"kettanaito@gmail.com"}],"dist":{"shasum":"b01f6010b13dcb22ac9af9d10d715f3a398676f9","tarball":"http://registry-npm.ywwl.com/@mswjs/cookies/download/@mswjs/cookies-0.1.3.tgz","fileCount":8,"integrity":"sha512-5Eh0Ogb0UsdrBHlAxVd742r7XILWCa6PlwQh9xyDKzywJ3Xq9b0KMNTdNXHHcZfuyhVCSNsRBdyXkCTpaHEKIg==","signatures":[{"sig":"MEQCIG05JetFAxFy79dV1ZQA3acNyXWm5Q0GPGR8FDCvochBAiA6bDkaspwzSiztSDEL7Qeyw2q6KRdaNoD6HuOjLjuqjw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzj2zCRA9TVsSAnZWagAAKSIP/1NH0kYuU7pyGMC+hj/9\n32xUA4CAxs+iixcAnsXl97HstnVHabfExrtuIju7dwfUgFwmhQFQroe2VKjP\ntQDtsMWZ0EcUGaYBVWR9H0XTZbdvb+xSoWd9l/3Cf5mwk87j+HS8skVU9BKB\nFHVvNqAOvXhnTF5eb631QtvP0lyO4vGk1YA01UVj8NhU4WXl4UJ5hArslSDm\nZIfMc8noLLwPflm0DH5Sl4fowaunp/BhwAeSoaIbfWcC0AA8W+JW5h245Qpk\nKWqN2Nk81+gSzcklwl+4mTf04S2/Ae7fxAt7R71Q+dV655avPMxqs8pZUEf0\n4OJ+4SmuZyPmm4PuBBSYs2HAexcsdnech+qJj5s6/BtoSqDAapsGMW4rmyp1\nSaQXfSpy1//q3KYbNmobtojNS3jSgFbc/qMRozhJDGrYp9uSPIHIB+uZI7og\nYvoRCtE+rLoBy3kuHYJvhvxwgK6wG8cS7BwTiZI8yJpLC6THNLMMMf4/X627\nQhH+ogANiCgRhPBRYEak+S1O99DemTrPyff2X1H603NPmGGESh37q41XOub8\nUbGXrLDlrfyCCJ+D+SRqFBz8Eoz6I0hOo0oCTiAg4CNhghpy6EtMdnsKrrG2\nme7uxlUc735T/lDY6B/ICMH6vW/jHG5B/Kwfgkz8qu5xQkb7z8KCCqirCOQo\noJd7\r\n=/AD4\r\n-----END PGP SIGNATURE-----\r\n","size":3186,"noattachment":false,"key":"/@mswjs/cookies/-/@mswjs/cookies-0.1.3.tgz"},"main":"lib/index.js","scripts":{"test":"jest","build":"tsc","clean":"rimraf lib","prepublishOnly":"yarn test && yarn clean && yarn build"},"_npmUser":{"name":"kettanaito","email":"kettanaito@gmail.com"},"repository":{"url":"git@github.com:mswjs/cookies.git","type":"git"},"description":"Virtual cookies store to manage Request/Response associations.","directories":{},"dependencies":{"set-cookie-parser":"^2.4.6","@types/set-cookie-parser":"^2.4.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","rimraf":"^3.0.2","ts-jest":"^26.4.4","ts-node":"^9.0.0","typescript":"^4.0.5","@types/jest":"^26.0.15","whatwg-fetch":"^3.5.0"},"_npmOperationalInternal":{"tmp":"tmp/cookies_0.1.3_1607351730848_0.19244991270080436","host":"s3://npm-registry-packages"},"readme":"[![Latest version](https://img.shields.io/npm/v/@mswjs/cookies.svg)](https://www.npmjs.com/package/@mswjs/cookies)\n\n# Cookies\n\nManage request/response cookies in the environments where those are not supported.\n\n## Install\n\n```bash\nnpm install @mswjs/cookies\n```\n\n## API\n\n### `set(request: Request, response: 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(request: 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(request: 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 [Christoph Guttandin](https://github.com/chrisguttandin).\n","publish_time":1607351731009,"_cnpm_publish_time":1607351731009,"dist-tags":{"latest":"1.1.1"}}