pax_global_header00006660000000000000000000000064146775576420014541gustar00rootroot0000000000000052 comment=cf4658f492c5bd96aeaf5693c3500f8495031014 cookie-0.7.1/000077500000000000000000000000001467755764200130175ustar00rootroot00000000000000cookie-0.7.1/.editorconfig000066400000000000000000000002631467755764200154750ustar00rootroot00000000000000# http://editorconfig.org root = true [*] charset = utf-8 insert_final_newline = true trim_trailing_whitespace = true [{*.js,*.json,*.yml}] indent_size = 2 indent_style = space cookie-0.7.1/.eslintignore000066400000000000000000000000261467755764200155200ustar00rootroot00000000000000coverage node_modules cookie-0.7.1/.eslintrc.yml000066400000000000000000000003431467755764200154430ustar00rootroot00000000000000extends: - plugin:markdown/recommended plugins: - markdown overrides: - files: '**/*.md' processor: 'markdown/markdown' rules: eol-last: error indent: ["error", 2, { "SwitchCase": 1 }] no-trailing-spaces: error cookie-0.7.1/.github/000077500000000000000000000000001467755764200143575ustar00rootroot00000000000000cookie-0.7.1/.github/workflows/000077500000000000000000000000001467755764200164145ustar00rootroot00000000000000cookie-0.7.1/.github/workflows/ci.yml000066400000000000000000000165721467755764200175450ustar00rootroot00000000000000name: ci on: - pull_request - push jobs: test: runs-on: ubuntu-20.04 strategy: matrix: name: - Node.js 0.6 - Node.js 0.8 - Node.js 0.10 - Node.js 0.12 - io.js 1.x - io.js 2.x - io.js 3.x - Node.js 4.x - Node.js 5.x - Node.js 6.x - Node.js 7.x - Node.js 8.x - Node.js 9.x - Node.js 10.x - Node.js 11.x - Node.js 12.x - Node.js 13.x - Node.js 14.x - Node.js 15.x - Node.js 16.x - Node.js 17.x - Node.js 18.x - Node.js 19.x - Node.js 20.x - Node.js 21.x include: - name: Node.js 0.6 node-version: "0.6" npm-i: mocha@1.21.5 npm-rm: beautify-benchmark benchmark nyc top-sites - name: Node.js 0.8 node-version: "0.8" npm-i: mocha@2.5.3 npm-rm: beautify-benchmark benchmark nyc top-sites - name: Node.js 0.10 node-version: "0.10" npm-i: mocha@3.5.3 nyc@10.3.2 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 0.12 node-version: "0.12" npm-i: mocha@3.5.3 nyc@10.3.2 npm-rm: beautify-benchmark benchmark top-sites - name: io.js 1.x node-version: "1.8" npm-i: mocha@3.5.3 nyc@10.3.2 npm-rm: beautify-benchmark benchmark top-sites - name: io.js 2.x node-version: "2.5" npm-i: mocha@3.5.3 nyc@10.3.2 npm-rm: beautify-benchmark benchmark top-sites - name: io.js 3.x node-version: "3.3" npm-i: mocha@3.5.3 nyc@10.3.2 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 4.x node-version: "4.9" npm-i: mocha@5.2.0 nyc@11.9.0 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 5.x node-version: "5.12" npm-i: mocha@5.2.0 nyc@11.9.0 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 6.x node-version: "6.17" npm-i: mocha@6.2.2 nyc@14.1.1 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 7.x node-version: "7.10" npm-i: mocha@6.2.2 nyc@14.1.1 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 8.x node-version: "8.17" npm-i: mocha@7.1.2 nyc@14.1.1 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 9.x node-version: "9.11" npm-i: mocha@7.1.2 nyc@14.1.1 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 10.x node-version: "10.24" npm-i: mocha@8.4.0 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 11.x node-version: "11.15" npm-i: mocha@8.4.0 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 12.x node-version: "12.22" npm-i: mocha@9.2.2 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 13.x node-version: "13.14" npm-i: mocha@9.2.2 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 14.x node-version: "14.21" npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 15.x node-version: "15.14" npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 16.x node-version: "16.20" npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 17.x node-version: "17.9" npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 18.x node-version: "18.18" npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 19.x node-version: "19.9" npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 20.x node-version: "20.9" npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 21.x node-version: "21.1" steps: - uses: actions/checkout@v3 - name: Install Node.js ${{ matrix.node-version }} shell: bash -eo pipefail -l {0} run: | if [[ "${{ matrix.node-version }}" == 0.6* ]]; then sudo sh -c 'echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic universe" >> /etc/apt/sources.list' sudo sh -c 'echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list' sudo apt-get update sudo apt-get install g++-4.8 gcc-4.8 libssl1.0-dev python2 python-is-python2 export CC=/usr/bin/gcc-4.8 export CXX=/usr/bin/g++-4.8 fi nvm install --default ${{ matrix.node-version }} if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then nvm install --alias=npm 0.10 nvm use ${{ matrix.node-version }} if [[ "$(npm -v)" == 1.1.* ]]; then nvm exec npm npm install -g npm@1.1 ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" else sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" fi npm config set strict-ssl false fi dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" - name: Configure npm run: | if [[ "$(npm config get package-lock)" == "true" ]]; then npm config set package-lock false else npm config set shrinkwrap false fi - name: Remove npm module(s) ${{ matrix.npm-rm }} run: npm rm --silent --save-dev ${{ matrix.npm-rm }} if: matrix.npm-rm != '' - name: Install npm module(s) ${{ matrix.npm-i }} run: npm install --save-dev ${{ matrix.npm-i }} if: matrix.npm-i != '' - name: Setup Node.js version-specific dependencies shell: bash run: | # eslint for linting # - remove on Node.js < 12 if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ grep -E '^eslint(-|$)' | \ sort -r | \ xargs -n1 npm rm --silent --save-dev fi - name: Install Node.js dependencies run: npm install - name: List environment id: list_env shell: bash run: | echo "node@$(node -v)" echo "npm@$(npm -v)" npm -s ls ||: (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" - name: Run tests shell: bash run: | if npm -ps ls nyc | grep -q nyc; then npm run test-ci else npm test fi - name: Lint code if: steps.list_env.outputs.eslint != '' run: npm run lint - name: Collect code coverage uses: coverallsapp/github-action@master if: steps.list_env.outputs.nyc != '' with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.test_number }} parallel: true coverage: needs: test runs-on: ubuntu-latest steps: - name: Upload code coverage uses: coverallsapp/github-action@master with: github-token: ${{ secrets.github_token }} parallel-finished: true cookie-0.7.1/.gitignore000066400000000000000000000001051467755764200150030ustar00rootroot00000000000000.nyc_output/ coverage/ node_modules/ npm-debug.log package-lock.json cookie-0.7.1/LICENSE000066400000000000000000000022271467755764200140270ustar00rootroot00000000000000(The MIT License) Copyright (c) 2012-2014 Roman Shtylman Copyright (c) 2015 Douglas Christopher Wilson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cookie-0.7.1/README.md000066400000000000000000000267711467755764200143130ustar00rootroot00000000000000# cookie [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Node.js Version][node-image]][node-url] [![Build Status][ci-image]][ci-url] [![Coverage Status][coveralls-image]][coveralls-url] Basic HTTP cookie parser and serializer for HTTP servers. ## Installation This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/). Installation is done using the [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): ```sh $ npm install cookie ``` ## API ```js var cookie = require('cookie'); ``` ### cookie.parse(str, options) Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs. The `str` argument is the string representing a `Cookie` header value and `options` is an optional object containing additional parsing options. ```js var cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2'); // { foo: 'bar', equation: 'E=mc^2' } ``` #### Options `cookie.parse` accepts these properties in the options object. ##### decode Specifies a function that will be used to decode a cookie's value. Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode a previously-encoded cookie value into a JavaScript string or other object. The default function is the global `decodeURIComponent`, which will decode any URL-encoded sequences into their byte representations. **note** if an error is thrown from this function, the original, non-decoded cookie value will be returned as the cookie's value. ### cookie.serialize(name, value, options) Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the name for the cookie, the `value` argument is the value to set the cookie to, and the `options` argument is an optional object containing additional serialization options. ```js var setCookie = cookie.serialize('foo', 'bar'); // foo=bar ``` #### Options `cookie.serialize` accepts these properties in the options object. ##### domain Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6265-5.2.3]. By default, no domain is set, and most clients will consider the cookie to apply to only the current domain. ##### encode Specifies a function that will be used to encode a cookie's value. Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode a value into a string suited for a cookie's value. The default function is the global `encodeURIComponent`, which will encode a JavaScript string into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range. ##### expires Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6265-5.2.1]. By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting a web browser application. **note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this, so if both are set, they should point to the same date and time. ##### httpOnly Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6265-5.2.6]. When truthy, the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set. **note** be careful when setting this to `true`, as compliant clients will not allow client-side JavaScript to see the cookie in `document.cookie`. ##### maxAge Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6265-5.2.2]. The given number will be converted to an integer by rounding down. By default, no maximum age is set. **note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this, so if both are set, they should point to the same date and time. ##### partitioned Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](rfc-cutler-httpbis-partitioned-cookies) attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the `Partitioned` attribute is not set. **note** This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it. More information about can be found in [the proposal](https://github.com/privacycg/CHIPS). ##### path Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path is considered the ["default path"][rfc-6265-5.1.4]. ##### priority Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1]. - `'low'` will set the `Priority` attribute to `Low`. - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set. - `'high'` will set the `Priority` attribute to `High`. More information about the different priority levels can be found in [the specification][rfc-west-cookie-priority-00-4.1]. **note** This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it. ##### sameSite Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-09-5.4.7]. - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement. - `false` will not set the `SameSite` attribute. - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement. - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie. - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement. More information about the different enforcement levels can be found in [the specification][rfc-6265bis-09-5.4.7]. **note** This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it. ##### secure Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6265-5.2.5]. When truthy, the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set. **note** be careful when setting this to `true`, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection. ## Example The following example uses this module in conjunction with the Node.js core HTTP server to prompt a user for their name and display it back on future visits. ```js var cookie = require('cookie'); var escapeHtml = require('escape-html'); var http = require('http'); var url = require('url'); function onRequest(req, res) { // Parse the query string var query = url.parse(req.url, true, true).query; if (query && query.name) { // Set a new cookie with the name res.setHeader('Set-Cookie', cookie.serialize('name', String(query.name), { httpOnly: true, maxAge: 60 * 60 * 24 * 7 // 1 week })); // Redirect back after setting cookie res.statusCode = 302; res.setHeader('Location', req.headers.referer || '/'); res.end(); return; } // Parse the cookies on the request var cookies = cookie.parse(req.headers.cookie || ''); // Get the visitor name set in the cookie var name = cookies.name; res.setHeader('Content-Type', 'text/html; charset=UTF-8'); if (name) { res.write('

Welcome back, ' + escapeHtml(name) + '!

'); } else { res.write('

Hello, new visitor!

'); } res.write('
'); res.write(' '); res.end('
'); } http.createServer(onRequest).listen(3000); ``` ## Testing ```sh $ npm test ``` ## Benchmark ``` $ npm run bench > cookie@0.5.0 bench > node benchmark/index.js node@18.18.2 acorn@8.10.0 ada@2.6.0 ares@1.19.1 brotli@1.0.9 cldr@43.1 icu@73.2 llhttp@6.0.11 modules@108 napi@9 nghttp2@1.57.0 nghttp3@0.7.0 ngtcp2@0.8.1 openssl@3.0.10+quic simdutf@3.2.14 tz@2023c undici@5.26.3 unicode@15.0 uv@1.44.2 uvwasi@0.0.18 v8@10.2.154.26-node.26 zlib@1.2.13.1-motley > node benchmark/parse-top.js cookie.parse - top sites 14 tests completed. parse accounts.google.com x 2,588,913 ops/sec ±0.74% (186 runs sampled) parse apple.com x 2,370,002 ops/sec ±0.69% (186 runs sampled) parse cloudflare.com x 2,213,102 ops/sec ±0.88% (188 runs sampled) parse docs.google.com x 2,194,157 ops/sec ±1.03% (184 runs sampled) parse drive.google.com x 2,265,084 ops/sec ±0.79% (187 runs sampled) parse en.wikipedia.org x 457,099 ops/sec ±0.81% (186 runs sampled) parse linkedin.com x 504,407 ops/sec ±0.89% (186 runs sampled) parse maps.google.com x 1,230,959 ops/sec ±0.98% (186 runs sampled) parse microsoft.com x 926,294 ops/sec ±0.88% (184 runs sampled) parse play.google.com x 2,311,338 ops/sec ±0.83% (185 runs sampled) parse support.google.com x 1,508,850 ops/sec ±0.86% (186 runs sampled) parse www.google.com x 1,022,582 ops/sec ±1.32% (182 runs sampled) parse youtu.be x 332,136 ops/sec ±1.02% (185 runs sampled) parse youtube.com x 323,833 ops/sec ±0.77% (183 runs sampled) > node benchmark/parse.js cookie.parse - generic 6 tests completed. simple x 3,214,032 ops/sec ±1.61% (183 runs sampled) decode x 587,237 ops/sec ±1.16% (187 runs sampled) unquote x 2,954,618 ops/sec ±1.35% (183 runs sampled) duplicates x 857,008 ops/sec ±0.89% (187 runs sampled) 10 cookies x 292,133 ops/sec ±0.89% (187 runs sampled) 100 cookies x 22,610 ops/sec ±0.68% (187 runs sampled) ``` ## References - [RFC 6265: HTTP State Management Mechanism][rfc-6265] - [Same-site Cookies][rfc-6265bis-09-5.4.7] [rfc-cutler-httpbis-partitioned-cookies]: https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/ [rfc-west-cookie-priority-00-4.1]: https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1 [rfc-6265bis-09-5.4.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7 [rfc-6265]: https://tools.ietf.org/html/rfc6265 [rfc-6265-5.1.4]: https://tools.ietf.org/html/rfc6265#section-5.1.4 [rfc-6265-5.2.1]: https://tools.ietf.org/html/rfc6265#section-5.2.1 [rfc-6265-5.2.2]: https://tools.ietf.org/html/rfc6265#section-5.2.2 [rfc-6265-5.2.3]: https://tools.ietf.org/html/rfc6265#section-5.2.3 [rfc-6265-5.2.4]: https://tools.ietf.org/html/rfc6265#section-5.2.4 [rfc-6265-5.2.5]: https://tools.ietf.org/html/rfc6265#section-5.2.5 [rfc-6265-5.2.6]: https://tools.ietf.org/html/rfc6265#section-5.2.6 [rfc-6265-5.3]: https://tools.ietf.org/html/rfc6265#section-5.3 ## License [MIT](LICENSE) [ci-image]: https://badgen.net/github/checks/jshttp/cookie/master?label=ci [ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/cookie/master [coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master [node-image]: https://badgen.net/npm/node/cookie [node-url]: https://nodejs.org/en/download [npm-downloads-image]: https://badgen.net/npm/dm/cookie [npm-url]: https://npmjs.org/package/cookie [npm-version-image]: https://badgen.net/npm/v/cookie cookie-0.7.1/SECURITY.md000066400000000000000000000022341467755764200146110ustar00rootroot00000000000000# Security Policies and Procedures ## Reporting a Bug The `cookie` team and community take all security bugs seriously. Thank you for improving the security of the project. We appreciate your efforts and responsible disclosure and will make every effort to acknowledge your contributions. Report security bugs by emailing the current owner(s) of `cookie`. This information can be found in the npm registry using the command `npm owner ls cookie`. If unsure or unable to get the information from the above, open an issue in the [project issue tracker](https://github.com/jshttp/cookie/issues) asking for the current contact information. To ensure the timely response to your report, please ensure that the entirety of the report is contained within the email body and not solely behind a web link or an attachment. At least one owner will acknowledge your email within 48 hours, and will send a more detailed response within 48 hours indicating the next steps in handling your report. After the initial reply to your report, the owners will endeavor to keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance. cookie-0.7.1/benchmark/000077500000000000000000000000001467755764200147515ustar00rootroot00000000000000cookie-0.7.1/benchmark/index.js000066400000000000000000000013751467755764200164240ustar00rootroot00000000000000var fs = require('fs') var path = require('path') var spawn = require('child_process').spawn var exe = process.argv[0] var cwd = process.cwd() for (var dep in process.versions) { console.log(' %s@%s', dep, process.versions[dep]) } console.log('') runScripts(fs.readdirSync(__dirname)) function runScripts (fileNames) { var fileName = fileNames.shift() if (!fileName) return if (!/\.js$/i.test(fileName)) return runScripts(fileNames) if (fileName.toLowerCase() === 'index.js') return runScripts(fileNames) var fullPath = path.join(__dirname, fileName) console.log('> %s %s', exe, path.relative(cwd, fullPath)) var proc = spawn(exe, [fullPath], { 'stdio': 'inherit' }) proc.on('exit', function () { runScripts(fileNames) }) } cookie-0.7.1/benchmark/parse-top.js000066400000000000000000000012741467755764200172250ustar00rootroot00000000000000/** * Module dependencies. */ var benchmark = require('benchmark') var benchmarks = require('beautify-benchmark') var top = require('./parse-top.json') /** * Globals for benchmark.js */ global.cookie = require('..') var suite = new benchmark.Suite() Object.keys(top).forEach(function (domain) { suite.add({ name: 'parse ' + domain, minSamples: 100, fn: 'var val = cookie.parse(' + JSON.stringify(top[domain]) + ')' }) }) suite.on('start', function () { process.stdout.write(' cookie.parse - top sites\n\n') }) suite.on('cycle', function (event) { benchmarks.add(event.target) }) suite.on('complete', function () { benchmarks.log() }) suite.run({ async: false }) cookie-0.7.1/benchmark/parse-top.json000066400000000000000000000047411467755764200175640ustar00rootroot00000000000000{ "accounts.google.com": "__Ulll-UUUU=0:lllllUlUUUlUU_llUU0UUUl0lU0UUl:UUlUlUl0UU0UlUlU", "apple.com": "lll=UU", "cloudflare.com": "__ll_ll=llUUlU0U0UlUlUll.lllUUUUlUUUlUUlUU000UlllUl-0000000000-0-UllU00UUllllUUUllUl0l0llllUUlU0UlUUUlUUl0Ull/l0+lllllUlUlU0l0l00ll+0U0ll/l0UlU00lllllllUUll0lU00lUUUllUUlUUl", "docs.google.com": "__Ulll-UUUU=0:lUlUlU0UUlUllUUlUllUUlUUlU0U:Ul0UllUUllll0UUl", "drive.google.com": "__Ulll-UUUU=0:U0l0lUUllU0lllUlU0UU00UlllUUlU:lUUUllUlUUUllUUl", "en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UUU-UU=lll; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0; UllllllUllllUllll=0.000", "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&0l0ll000-0000-00ll-0000-0l000ll00000\"; llllllll=\"l=0&00000000000000l00l0l0l-l000-00l0-00ll-l0000l000000UUUUlUlUU0llll0UlllUU0UU--UUlUlU\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUU-UUlUlUUl0lUUlUlUllll0lllUUUU\"", "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=lU00_U0UllU-lUlUUUllUl0l0U_lUlUUUl00UUU0llllU_UUlUUU0UllUllll0l-_lUlllUU0llll0UlUUllll_UU0U0lU-llUllll00lUllUllUlUlllU_lUUUl0ll0lUUlUlllUUl0llUUl0UU0llUlllllUllUll0UUUllUU", "microsoft.com": "UUUUU=llllll0; lllll_UllUU=0000000000~ll=00~ll=0000l0l0l0lllll0l000000000l0l00l; lllll_UllUU=0000000000~ll=00~ll=0000l0l0l0lllll0l000000000l0l00l", "play.google.com": "UUU=000=UllU0l0UU0llUlU0UUU0lUUUl0lUlUUllUlUl0ll0UlUlllUlUlUUlUUllUll-UUll0llll0UllUlUU0U0lUUUUU0Ull0l0l0l0lUU0UlUU000lUUUU0lU_UUlUUlUUl0UU-lUlUU0lUlUllUUUllUUllll00lllU0U0UUU0Ull", "support.google.com": "UUU=000=l0llUUlUllU0UlllU0U0U0UlU-Ulll0lUlllU0UUllUUlUUUlllllUUUU-UUllUllU0lUU0U0U00lU0UUlUl0l0lUUlUUUUl0lUU0UUllUlUlUUlUlUUUU0ll0l0UU0lllU0lllUUUU0U0lU0U00l0Ul0UlU-U0UllU00lUUl0U; UUU=000=l0llUUlUllU0UlllU0U0U0UlU-Ulll0lUlllU0UUllUUlUUUlllllUUUU-UUllUllU0lUU0U0U00lU0UUlUl0l0lUUlUUUUl0lUU0UUllUlUlUUlUlUUUU0ll0l0UU0lllU0lllUUUU0U0lU0U00l0Ul0UlU-U0UllU00lUUl0U", "www.google.com": "0U_UUU=0000-00-00-00; UUU=Ullll0Ullll0U0llUllU00U_lllll0lUUlUl0UllUlUUl0lUlUUUl00UUl; UUU=000=lUU0U0U0U0UllUUUlUUlUUU_UlUll_l0U0UU00lUlUlUlllllUUUl00UllllUU_0ll0UllUllUUU-UUUlllU0UlUlUllUlUllUll00UllU0U00llUUl0lU00lUlUUlllUl_U00UUlU0UU0UllUlUU0lUUlUUUl00lUUlUUUU0ll", "youtu.be": "UUU=0; UUU=ll0UU-l0lUl; UUUUUUU_UUUU0_UUUU=0_llUUlUllU; UUUUUUU_UUUUUUU_UUUUUUUU=UlUUUlUUUlU%22", "youtube.com": "UUU=0; UUU=l0_UlUUUlUl; UUUUUUU_UUUU0_UUUU=UUUUlUUUlll; UUUUUUU_UUUUUUU_UUUUUUUU=UlUUUlUUUlU%22", "example.com": "" } cookie-0.7.1/benchmark/parse.js000066400000000000000000000024701467755764200164240ustar00rootroot00000000000000/** * Module dependencies. */ var benchmark = require('benchmark') var benchmarks = require('beautify-benchmark') /** * Globals for benchmark.js */ global.cookie = require('..') var suite = new benchmark.Suite() suite.add({ name: 'simple', minSamples: 100, fn: 'var val = cookie.parse("foo=bar")' }) suite.add({ name: 'decode', minSamples: 100, fn: 'var val = cookie.parse("foo=hello%20there!")' }) suite.add({ name: 'unquote', minSamples: 100, fn: 'var val = cookie.parse("foo=\\"foo bar\\"")' }) suite.add({ name: 'duplicates', minSamples: 100, fn: 'var val = cookie.parse(' + JSON.stringify(gencookies(2) + '; ' + gencookies(2)) + ')' }) suite.add({ name: '10 cookies', minSamples: 100, fn: 'var val = cookie.parse(' + JSON.stringify(gencookies(10)) + ')' }) suite.add({ name: '100 cookies', minSamples: 100, fn: 'var val = cookie.parse(' + JSON.stringify(gencookies(100)) + ')' }) suite.on('start', function () { process.stdout.write(' cookie.parse - generic\n\n') }) suite.on('cycle', function (event) { benchmarks.add(event.target) }) suite.on('complete', function onComplete () { benchmarks.log() }) suite.run({ async: false }) function gencookies (num) { var str = '' for (var i = 0; i < num; i++) { str += '; foo' + i + '=bar' } return str.slice(2) } cookie-0.7.1/index.js000066400000000000000000000176471467755764200145030ustar00rootroot00000000000000/*! * cookie * Copyright(c) 2012-2014 Roman Shtylman * Copyright(c) 2015 Douglas Christopher Wilson * MIT Licensed */ 'use strict'; /** * Module exports. * @public */ exports.parse = parse; exports.serialize = serialize; /** * Module variables. * @private */ var __toString = Object.prototype.toString /** * RegExp to match cookie-name in RFC 6265 sec 4.1.1 * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2 * which has been replaced by the token definition in RFC 7230 appendix B. * * cookie-name = token * token = 1*tchar * tchar = "!" / "#" / "$" / "%" / "&" / "'" / * "*" / "+" / "-" / "." / "^" / "_" / * "`" / "|" / "~" / DIGIT / ALPHA */ var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/; /** * RegExp to match cookie-value in RFC 6265 sec 4.1.1 * * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE ) * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E * ; US-ASCII characters excluding CTLs, * ; whitespace DQUOTE, comma, semicolon, * ; and backslash */ var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/; /** * RegExp to match domain-value in RFC 6265 sec 4.1.1 * * domain-value = * ; defined in [RFC1034], Section 3.5, as * ; enhanced by [RFC1123], Section 2.1 * =