{"author":{"name":"Jeremy Stashewsky","email":"jstash@gmail.com"},"contributors":[{"name":"Alexander Savin"},{"name":"Ian Livingstone"},{"name":"Ivan Nikulin"},{"name":"Lalit Kapoor"},{"name":"Sam Thompson"},{"name":"Sebastian Mayr"}],"license":"BSD-3-Clause","name":"tough-cookie","description":"RFC6265 Cookies and Cookie Jar for node.js","keywords":["HTTP","cookie","cookies","set-cookie","cookiejar","jar","RFC6265","RFC2965"],"version":"2.4.3","homepage":"https://github.com/salesforce/tough-cookie","repository":{"type":"git","url":"git://github.com/salesforce/tough-cookie.git"},"bugs":{"url":"https://github.com/salesforce/tough-cookie/issues"},"main":"./lib/cookie","files":["lib"],"scripts":{"test":"vows test/*_test.js","cover":"nyc --reporter=lcov --reporter=html vows test/*_test.js"},"engines":{"node":">=0.8"},"devDependencies":{"async":"^1.4.2","nyc":"^11.6.0","string.prototype.repeat":"^0.2.0","vows":"^0.8.1"},"dependencies":{"psl":"^1.1.24","punycode":"^1.4.1"},"gitHead":"671ad413b38d7464352886772f57a7ec417d4760","_id":"tough-cookie@2.4.3","_npmVersion":"6.1.0","_nodeVersion":"10.5.0","_npmUser":{"name":"jstash","email":"jstash@gmail.com"},"dist":{"integrity":"sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==","shasum":"53f36da3f47783b0925afa06ff9f3b165280f781","tarball":"http://registry-npm.ywwl.com/tough-cookie/download/tough-cookie-2.4.3.tgz","fileCount":9,"unpackedSize":83959,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbMVcQCRA9TVsSAnZWagAAzX0P/2COkbzb3dOX/FTOYIVL\n7oHge7BvGODNkEHTjBtNsR0jO/AA/gVcUOq6CSmFH+UC14LrmCyNDemQvD15\njnYuJXUIiZsSZO7BGGbOFYrQF+DKLiwgf0LokrIM8KasZ5nxc5xS1jYHG5o+\nwCqutfhlRTqlPbZsexB+eRlIuYNvpsbRAdSDYXrhLJNMZgx49g/SZ7IwunGN\nJ/5Fe041MZqqdi7MAavM3T7vX9IvVRJJ3f4xAEVxY1vh4s0dN+h4fG2eMQzL\nOiaulRUIahs4xmJUYHZgZESc9eTIrI8K+YT7i3r35TGc0Du7ueB2KYxBqy7q\n6AUFbdX9Ep308kTVsTf/h4wE0RvdxKLfZ0ww7T1ivADX9xMi2oIvVtyhCQHo\nSIpyBhaav/fTufF0/Fu4Lcr7PMJxyvF0UcNRqrPmEQTw4UZkFKfT8HN2P5cH\nBvJsFwpeEjt84tt5pJ/bmD0j0EUCLUXLGH6fbA84fHpZGifO239zSf262Qdv\nSXeygU7YxnK8wOCnvlauZx/gp+/WTMfMdODxiX0QnqwS5BctiPCgGG1cKJcC\nqvTECaAEmxMVf/gEW73oxVXJgUO7f6jJaWoawV7ka+wR91W9Bp0pKGOOAxAG\nU72rmnwQKid9U7ly5833sb3D+lbzKJXGNIqohegP4daKZfNNTaLWZXmKE+Iy\n7Vml\r\n=8KpS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICetFbo9YKADTmuQ0ii1aDWfGQbdb3yGQDhVX+XGEWqvAiBoGt2+lr51EM0MG4heI5fLinoJivS5ikY7p7lBpbiiFA=="}],"size":23806,"noattachment":false,"key":"/tough-cookie/-/tough-cookie-2.4.3.tgz"},"maintainers":[{"email":"awaterma@awaterma.net","name":"awaterma"},{"email":"jstash@gmail.com","name":"jstash"},{"email":"marat+npm@salesforce.com","name":"maratto"},{"email":"clint@ruoho.org","name":"ruoho"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tough-cookie_2.4.3_1529960207843_0.4882910670728131"},"_hasShrinkwrap":false,"readme":"# Tough Cookie &middot; [![RFC6265][rfc6265-badge]][rfc6265-tracker] [![RFC6265bis][rfc6265bis-badge]][rfc6265bis-tracker] [![npm version][npm-badge]][npm-repo] [![CI on Github Actions: salesforce/tough-cookie][ci-badge]][ci-url] ![PRs Welcome][prs-welcome-badge]\n\nA Node.js implementation of [RFC6265][rfc6265-tracker] for cookie parsing, storage, and retrieval.\n\n## Getting Started\n\nInstall Tough Cookie using [`npm`][npm-repo]:\n\n```shell\nnpm install tough-cookie\n```\n\nor [`yarn`][yarn-repo]:\n\n```shell\nyarn add tough-cookie\n```\n\n## Usage\n\n```typescript\nimport { Cookie, CookieJar } from 'tough-cookie'\n\n// parse a `Cookie` request header\nconst reqCookies = 'ID=298zf09hf012fh2; csrf=u32t4o3tb3gg43; _gat=1'.split(';').map(Cookie.parse)\n// generate a `Cookie` request header\nconst cookieHeader = reqCookies.map(cookie => cookie.cookieString()).join(';')\n\n// parse a Set-Cookie response header\nconst resCookie = Cookie.parse('foo=bar; Domain=example.com; Path=/; Expires=Tue, 21 Oct 2025 00:00:00 GMT')\n// generate a Set-Cookie response header\nconst setCookieHeader = cookie.toString()\n\n// store and retrieve cookies\nconst cookieJar = new CookieJar() // uses the in-memory store by default\nawait cookieJar.setCookie(resCookie, 'https://example.com/')\nconst matchingCookies = await cookieJar.getCookies('https://example.com/')\n```\n\n> [!IMPORTANT]\n> For more detailed usage information, refer to the [API docs](./api/docs/tough-cookie.md).\n\n## RFC6265bis\n\nSupport for [RFC6265bis][rfc6265bis-tracker] is being developed. As these revisions to [RFC6252][rfc6265-tracker] are\nstill in `Active Internet-Draft` state, the areas of support that follow are subject to change.\n\n### SameSite Cookies\n\nThis change makes it possible for servers, and supporting clients, to mitigate certain types of CSRF\nattacks by disallowing `SameSite` cookies from being sent cross-origin.\n\n#### Example\n\n```typescript\nimport { CookieJar } from 'tough-cookie'\n\nconst cookieJar = new CookieJar() // uses the in-memory store by default\n\n// storing cookies with various SameSite attributes\nawait cookieJar.setCookie('strict=authorized; SameSite=strict', 'http://example.com/index.html')\nawait cookieJar.setCookie('lax=okay; SameSite=lax', 'http://example.com/index.html')\nawait cookieJar.setCookie('normal=whatever', 'http://example.com/index.html')\n\n// retrieving cookies using a SameSite context\nconst laxCookies = await cookieJar.getCookies('http://example.com/index.html', {\n  // the first cookie (strict=authorized) will not be returned if the context is 'lax'\n  // but the other two cookies will be returned\n  sameSiteContext: 'lax',\n})\n```\n\n> [!NOTE]\n> It is highly recommended that you read [RFC6265bis - Section 8.8][samesite-implementation] for more details on SameSite cookies, security considerations, and defense in depth.\n\n### Cookie Prefixes\n\nCookie prefixes are a way to indicate that a given cookie was set with a set of attributes simply by\ninspecting the first few characters of the cookie's name.\n\nTwo prefixes are defined:\n\n- `\"__Secure-\"`\n\n  If a cookie's name begins with a case-sensitive match for the string `__Secure-`, then the cookie was set with a \"Secure\" attribute.\n\n- `\"__Host-\"`\n\n  If a cookie's name begins with a case-sensitive match for the string `__Host-`, then the cookie was set with a \"Secure\" attribute, a \"Path\" attribute with a value of \"/\", and no \"Domain\" attribute.\n\nIf `prefixSecurity` is enabled for `CookieJar`, then cookies that match the prefixes defined above but do\nnot obey the attribute restrictions are not added.\n\nYou can define this functionality by passing in the `prefixSecurity` option to `CookieJar`. It can be one of 3 values:\n\n1. `silent`: (**default**) Enable cookie prefix checking but silently fail to add the cookie if conditions are not met.\n2. `strict`: Enable cookie prefix checking and error out if conditions are not met.\n3. `unsafe-disabled`: Disable cookie prefix checking.\n\n> If `ignoreError` is passed in as `true` when setting a cookie then the error is silent regardless of the `prefixSecurity` option (assuming it's enabled).\n\n#### Example\n\n```typescript\nimport { CookieJar, MemoryCookieStore } from 'tough-cookie'\n\nconst cookieJar = new CookieJar(new MemoryCookieStore(), {\n  prefixSecurity: 'silent'\n})\n\n// this cookie will be silently ignored since the url is insecure (http)\nawait cookieJar.setCookie(\n  '__Secure-SID=12345; Domain=example.com; Secure;',\n  'http://example.com',\n)\n\n// this cookie will be stored since the url is secure (https)\nawait cookieJar.setCookie(\n  '__Secure-SID=12345; Domain=example.com; Secure;',\n  'https://example.com',\n)\n```\n\n> [!NOTE]\n> It is highly recommended that you read [RFC6265bis - Section 4.1.3][cookie-prefixes-implementation] for more details on Cookie Prefixes.\n\n## Node.js Version Support\n\nWe follow the [Node.js release schedule](https://github.com/nodejs/Release#release-schedule) and support\nall versions that are in Active LTS or Maintenance. We will always do a major release when dropping support\nfor older versions of node, and we will do so in consultation with our community.\n\n[npm-badge]: https://img.shields.io/npm/v/tough-cookie.svg?style=flat\n[npm-repo]: https://www.npmjs.com/package/tough-cookie\n[ci-badge]: https://github.com/salesforce/tough-cookie/actions/workflows/integration.yaml/badge.svg\n[ci-url]: https://github.com/salesforce/tough-cookie/actions/workflows/integration.yaml\n[rfc6265-badge]: https://img.shields.io/badge/RFC-6265-flat?labelColor=000000&color=666666\n[rfc6265-tracker]: https://datatracker.ietf.org/doc/rfc6265/\n[rfc6265bis-badge]: https://img.shields.io/badge/RFC-6265bis-flat?labelColor=000000&color=666666\n[rfc6265bis-tracker]: https://datatracker.ietf.org/doc/draft-ietf-httpbis-rfc6265bis/\n[samesite-implementation]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-8.8\n[cookie-prefixes-implementation]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-4.1.3\n[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg\n[yarn-repo]: https://yarnpkg.com/package?name=tough-cookie\n","publish_time":1529960208465,"_cnpm_publish_time":1529960208465,"dist-tags":{"latest":"6.1.0","next":"6.0.0-rc.2"}}