{"name":"@mswjs/cookies","version":"0.1.4","author":{"name":"Artem Zakharchenko"},"license":"MIT","_id":"@mswjs/cookies@0.1.4","maintainers":[{"name":"kettanaito","email":"kettanaito@gmail.com"}],"dist":{"shasum":"85ef872997eea2acd888f21af0b2067224dac244","tarball":"http://registry-npm.ywwl.com/@mswjs/cookies/download/@mswjs/cookies-0.1.4.tgz","fileCount":8,"integrity":"sha512-gdtmSv21D4wHTnqF4rrZVX6ye7mQ4nRCTIHYnHBr4SkgoXaiqe3sMvUzXm43+H4PnL0EAKvUTxRVSSXz2xebeg==","signatures":[{"sig":"MEYCIQDsHDWnaT6ri9TVmBIRUNMyJL64vkB6Lx0DBTvCh24ckwIhAOuIrr5MpHF0dVbEp2CGZDND3fqgkRJWC6Kh7ogpPawD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10034,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOuCLCRA9TVsSAnZWagAAMmQP/1R4dC1eG/3GGnYh40V8\nWHqq+6foorx1HvuuuoLO190rajXiHCZeD79NQgI0vrUbBM0V+xuGZAMSQiqP\nS+7hlgg6mzGW9QIu2fX6Ke6TNk8ZtbWD15y/BJ9aM693TJgCwKMw2+Ga/fAX\n2lFTlEuapqvzvZ4PaIqPNCNROVKiOPv/ZYVYXMtApZkWDX6WWKEj/zUhaqRV\n1rAv9F3eaG2eZ2PnL17fwELBpXO4do3siKXYx/L0CLSiLxCEC78UvyZJWn4Q\nXAsNEZzbOKy1GaUU1RS4f6NB+5fFr6mXZn+IhgJyPQwQDDdWuEqJ8TFah7q5\nblxjIwihX1aNL6lQoLDcMKkTXpx+dwE5cOsBMENL0b7RQ9lD98YJtZJa8hrq\nKN7xoSaw6PpM7q7/TAGyDTmOQHTKk4WinjGhahGi8AW3Kc5gaSj2I6zIQxVk\nmi/2rpBbVcPvfEHcqXhrnMZ7jrmZRz0vbgoLpvlK2vIl93w0hJ550E2ljK7d\nq3SwOZ/+tkdqBusTBh9uywasAA+4OrUCMD5Dgl8S7E8vv1M9tARCMXFChE4a\n6Y2LFHSwKo3ScyCSPg8+InK3/QkUtXnfw5hOVlyW0XQGqW1sL5/Wkqp0LoH8\nvn8umN1+dPX5MFG6NEYvjfKS+PblvT1M5wv20rWoEkrTcfif4pEmFqkVWFe1\ngr58\r\n=IabR\r\n-----END PGP SIGNATURE-----\r\n","size":3253,"noattachment":false,"key":"/@mswjs/cookies/-/@mswjs/cookies-0.1.4.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.4_1614471305900_0.17217138743314253","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":1614471306028,"_cnpm_publish_time":1614471306028,"dist-tags":{"latest":"1.1.1"}}