{ "_args": [ [ { "raw": "cookie@0.3.1", "scope": null, "escapedName": "cookie", "name": "cookie", "rawSpec": "0.3.1", "spec": "0.3.1", "type": "version" }, "C:\\Users\\Giuliano\\Desktop\\nasaproject\\node_modules\\express" ] ], "_from": "cookie@0.3.1", "_id": "cookie@0.3.1", "_inCache": true, "_location": "/cookie", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/cookie-0.3.1.tgz_1464323556714_0.6435900838114321" }, "_npmUser": { "name": "dougwilson", "email": "doug@somethingdoug.com" }, "_npmVersion": "1.4.28", "_phantomChildren": {}, "_requested": { "raw": "cookie@0.3.1", "scope": null, "escapedName": "cookie", "name": "cookie", "rawSpec": "0.3.1", "spec": "0.3.1", "type": "version" }, "_requiredBy": [ "/express" ], "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", "_shrinkwrap": null, "_spec": "cookie@0.3.1", "_where": "C:\\Users\\Giuliano\\Desktop\\nasaproject\\node_modules\\express", "author": { "name": "Roman Shtylman", "email": "shtylman@gmail.com" }, "bugs": { "url": "https://github.com/jshttp/cookie/issues" }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], "dependencies": {}, "description": "HTTP server cookie parsing and serialization", "devDependencies": { "istanbul": "0.4.3", "mocha": "1.21.5" }, "directories": {}, "dist": { "shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", "tarball": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz" }, "engines": { "node": ">= 0.6" }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], "gitHead": "e3c77d497d66c8b8d4b677b8954c1b192a09f0b3", "homepage": "https://github.com/jshttp/cookie#readme", "keywords": [ "cookie", "cookies" ], "license": "MIT", "maintainers": [ { "name": "dougwilson", "email": "doug@somethingdoug.com" } ], "name": "cookie", "optionalDependencies": {}, "readme": "# cookie\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Node.js Version][node-version-image]][node-version-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nBasic HTTP cookie parser and serializer for HTTP servers.\n\n## Installation\n\n```sh\n$ npm install cookie\n```\n\n## API\n\n```js\nvar cookie = require('cookie');\n```\n\n### cookie.parse(str, options)\n\nParse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs.\nThe `str` argument is the string representing a `Cookie` header value and `options` is an\noptional object containing additional parsing options.\n\n```js\nvar cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2');\n// { foo: 'bar', equation: 'E=mc^2' }\n```\n\n#### Options\n\n`cookie.parse` accepts these properties in the options object.\n\n##### decode\n\nSpecifies a function that will be used to decode a cookie's value. Since the value of a cookie\nhas a limited character set (and must be a simple string), this function can be used to decode\na previously-encoded cookie value into a JavaScript string or other object.\n\nThe default function is the global `decodeURIComponent`, which will decode any URL-encoded\nsequences into their byte representations.\n\n**note** if an error is thrown from this function, the original, non-decoded cookie value will\nbe returned as the cookie's value.\n\n### cookie.serialize(name, value, options)\n\nSerialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the\nname for the cookie, the `value` argument is the value to set the cookie to, and the `options`\nargument is an optional object containing additional serialization options.\n\n```js\nvar setCookie = cookie.serialize('foo', 'bar');\n// foo=bar\n```\n\n#### Options\n\n`cookie.serialize` accepts these properties in the options object.\n\n##### domain\n\nSpecifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6266-5.2.3]. By default, no\ndomain is set, and most clients will consider the cookie to apply to only the current domain.\n\n##### encode\n\nSpecifies a function that will be used to encode a cookie's value. Since value of a cookie\nhas a limited character set (and must be a simple string), this function can be used to encode\na value into a string suited for a cookie's value.\n\nThe default function is the global `ecodeURIComponent`, which will encode a JavaScript string\ninto UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.\n\n##### expires\n\nSpecifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6266-5.2.1].\nBy default, no expiration is set, and most clients will consider this a \"non-persistent cookie\" and\nwill delete it on a condition like exiting a web browser application.\n\n**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and\n`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,\nso if both are set, they should point to the same date and time.\n\n##### httpOnly\n\nSpecifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6266-5.2.6]. When truthy,\nthe `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.\n\n**note** be careful when setting this to `true`, as compliant clients will not allow client-side\nJavaScript to see the cookie in `document.cookie`.\n\n##### maxAge\n\nSpecifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6266-5.2.2].\nThe given number will be converted to an integer by rounding down. By default, no maximum age is set.\n\n**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and\n`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,\nso if both are set, they should point to the same date and time.\n\n##### path\n\nSpecifies the value for the [`Path` `Set-Cookie` attribute][rfc-6266-5.2.4]. By default, the path\nis considered the [\"default path\"][rfc-6266-5.1.4]. By default, no maximum age is set, and most\nclients will consider this a \"non-persistent cookie\" and will delete it on a condition like exiting\na web browser application.\n\n##### sameSite\n\nSpecifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][draft-west-first-party-cookies-07].\n\n - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.\n - `false` will not set the `SameSite` attribute.\n - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.\n - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.\n\nMore information about the different enforcement levels can be found in the specification\nhttps://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1.1\n\n**note** This is an attribute that has not yet been fully standardized, and may change in the future.\nThis also means many clients may ignore this attribute until they understand it.\n\n##### secure\n\nSpecifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6266-5.2.5]. When truthy,\nthe `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.\n\n**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to\nthe server in the future if the browser does not have an HTTPS connection.\n\n## Example\n\nThe following example uses this module in conjunction with the Node.js core HTTP server\nto prompt a user for their name and display it back on future visits.\n\n```js\nvar cookie = require('cookie');\nvar escapeHtml = require('escape-html');\nvar http = require('http');\nvar url = require('url');\n\nfunction onRequest(req, res) {\n // Parse the query string\n var query = url.parse(req.url, true, true).query;\n\n if (query && query.name) {\n // Set a new cookie with the name\n res.setHeader('Set-Cookie', cookie.serialize('name', String(query.name), {\n httpOnly: true,\n maxAge: 60 * 60 * 24 * 7 // 1 week\n }));\n\n // Redirect back after setting cookie\n res.statusCode = 302;\n res.setHeader('Location', req.headers.referer || '/');\n res.end();\n return;\n }\n\n // Parse the cookies on the request\n var cookies = cookie.parse(req.headers.cookie || '');\n\n // Get the visitor name set in the cookie\n var name = cookies.name;\n\n res.setHeader('Content-Type', 'text/html; charset=UTF-8');\n\n if (name) {\n res.write('

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

');\n } else {\n res.write('

Hello, new visitor!

');\n }\n\n res.write('
');\n res.write(' ');\n res.end('