{"name":"@mswjs/cookies","version":"0.1.6","author":{"name":"Artem Zakharchenko"},"license":"MIT","_id":"@mswjs/cookies@0.1.6","maintainers":[{"name":"kettanaito","email":"kettanaito@gmail.com"}],"dist":{"shasum":"176f77034ab6d7373ae5c94bcbac36fee8869249","tarball":"http://registry-npm.ywwl.com/@mswjs/cookies/download/@mswjs/cookies-0.1.6.tgz","fileCount":8,"integrity":"sha512-A53XD5TOfwhpqAmwKdPtg1dva5wrng2gH5xMvklzbd9WLTSVU953eCRa8rtrrm6G7Cy60BOGsBRN89YQK0mlKA==","signatures":[{"sig":"MEUCIQDdcYz9Pby6E3CEKJLCHOsjxQLVaHHCpCJz6AxERmuh3wIgblmnNvO585KMDCh/PYRjSpr1LgB9ccRkagxvjEpwEX0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9994,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsMStCRA9TVsSAnZWagAAVEoP/1z67YzaFNtjVrPx38wI\npxi6Tv/6HHscRrzbAZkesGRwOahCiav8RpDIU4xggz1BRVlAQR1KPqHufdCC\nb2Q+2gw+buSeiqO5fggEy0TphozC+TLuZuaIFMeS1/Tc+hHsz1lCci4Mc1wG\npS6hL5R8mjDCIG0tHv1cfFThP6kWHqqG8iXcn3GBlPK/RCueYsCFXLt3iq/y\nLEeDztmUxdjE3Gc5mbcYgpNeWV8vr/LPFyzyPsQcbK2jKqkN63ffItnP87Gg\nADorUtIOl4XhUT0MrTv6QGkPhAwrHnfNz0CdJRcPcKRbHG+hneOR1eKnQoGj\nopBa/wAJS9KWBsWPzXSiQ6pwawBd3ObkTG9Q6E+/03vcMa4ScEvzSE6NUiJl\nMpIWXOlOD+FwyR3EiUKzuANdPihB7RIH/dnQrQCBft9KV/nzgOZgNx5zZH+v\nVjX94tfyGMy7gVa9PlcxScsZlrJntqhG4ZjP6A/nvo2Qlj1qfpuIB1iRfruM\nzVOsaAqtAQ0hM6BsFxxoICmcjilwDS1HfPqYw58JiBpWDXdD+KDS73yhy77x\nOLu+6Kr0TWdvHPT+9MvgS8nJj73jt7bVKgJhURk+xCmqyqRVMSl8HIVAGWrZ\nVYxmIboczvnLFFNdkqZD+FDWh/HvBwVkU4AH6ybx5TcrW25wbCBhEUoPZSbv\n38GJ\r\n=rtDY\r\n-----END PGP SIGNATURE-----\r\n","size":3236,"noattachment":false,"key":"/@mswjs/cookies/-/@mswjs/cookies-0.1.6.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.6_1622197421377_0.6494391416234673","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":1622197421477,"_cnpm_publish_time":1622197421477,"dist-tags":{"latest":"1.1.1"}}