129 lines
18 KiB
JSON
129 lines
18 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "express-session@~1.11.3",
|
|
"scope": null,
|
|
"escapedName": "express-session",
|
|
"name": "express-session",
|
|
"rawSpec": "~1.11.3",
|
|
"spec": ">=1.11.3 <1.12.0",
|
|
"type": "range"
|
|
},
|
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/connect"
|
|
]
|
|
],
|
|
"_from": "express-session@>=1.11.3 <1.12.0",
|
|
"_id": "express-session@1.11.3",
|
|
"_inCache": true,
|
|
"_location": "/express-session",
|
|
"_npmUser": {
|
|
"name": "dougwilson",
|
|
"email": "doug@somethingdoug.com"
|
|
},
|
|
"_npmVersion": "1.4.28",
|
|
"_phantomChildren": {
|
|
"base64-url": "1.2.1"
|
|
},
|
|
"_requested": {
|
|
"raw": "express-session@~1.11.3",
|
|
"scope": null,
|
|
"escapedName": "express-session",
|
|
"name": "express-session",
|
|
"rawSpec": "~1.11.3",
|
|
"spec": ">=1.11.3 <1.12.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/connect"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/express-session/-/express-session-1.11.3.tgz",
|
|
"_shasum": "5cc98f3f5ff84ed835f91cbf0aabd0c7107400af",
|
|
"_shrinkwrap": null,
|
|
"_spec": "express-session@~1.11.3",
|
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/connect",
|
|
"author": {
|
|
"name": "TJ Holowaychuk",
|
|
"email": "tj@vision-media.ca",
|
|
"url": "http://tjholowaychuk.com"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/expressjs/session/issues"
|
|
},
|
|
"contributors": [
|
|
{
|
|
"name": "Douglas Christopher Wilson",
|
|
"email": "doug@somethingdoug.com"
|
|
},
|
|
{
|
|
"name": "Joe Wagner",
|
|
"email": "njwjs722@gmail.com"
|
|
}
|
|
],
|
|
"dependencies": {
|
|
"cookie": "0.1.3",
|
|
"cookie-signature": "1.0.6",
|
|
"crc": "3.3.0",
|
|
"debug": "~2.2.0",
|
|
"depd": "~1.0.1",
|
|
"on-headers": "~1.0.0",
|
|
"parseurl": "~1.3.0",
|
|
"uid-safe": "~2.0.0",
|
|
"utils-merge": "1.0.0"
|
|
},
|
|
"description": "Simple session middleware for Express",
|
|
"devDependencies": {
|
|
"after": "0.8.1",
|
|
"cookie-parser": "~1.3.5",
|
|
"express": "~4.12.4",
|
|
"istanbul": "0.3.15",
|
|
"mocha": "2.2.5",
|
|
"supertest": "1.0.1"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "5cc98f3f5ff84ed835f91cbf0aabd0c7107400af",
|
|
"tarball": "https://registry.npmjs.org/express-session/-/express-session-1.11.3.tgz"
|
|
},
|
|
"engines": {
|
|
"node": ">= 0.8.0"
|
|
},
|
|
"files": [
|
|
"session/",
|
|
"HISTORY.md",
|
|
"LICENSE",
|
|
"index.js"
|
|
],
|
|
"gitHead": "64e2e7a2d21da881ea53ab984f9eff4be58d7caf",
|
|
"homepage": "https://github.com/expressjs/session#readme",
|
|
"license": "MIT",
|
|
"maintainers": [
|
|
{
|
|
"name": "dougwilson",
|
|
"email": "doug@somethingdoug.com"
|
|
},
|
|
{
|
|
"name": "mscdex",
|
|
"email": "mscdex@mscdex.net"
|
|
},
|
|
{
|
|
"name": "defunctzombie",
|
|
"email": "shtylman@gmail.com"
|
|
}
|
|
],
|
|
"name": "express-session",
|
|
"optionalDependencies": {},
|
|
"readme": "# express-session\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![Gratipay][gratipay-image]][gratipay-url]\n\n## Installation\n\n```bash\n$ npm install express-session\n```\n\n## API\n\n```js\nvar session = require('express-session')\n```\n\n### session(options)\n\nCreate a session middleware with the given `options`.\n\n**Note** Session data is _not_ saved in the cookie itself, just the session ID.\nSession data is stored server-side.\n\n**Warning** The default server-side session storage, `MemoryStore`, is _purposely_\nnot designed for a production environment. It will leak memory under most\nconditions, does not scale past a single process, and is meant for debugging and\ndeveloping.\n\nFor a list of stores, see [compatible session stores](#compatible-session-stores).\n\n#### Options\n\n`express-session` accepts these properties in the options object.\n\n##### cookie\n\nSettings for the session ID cookie. See the \"Cookie options\" section below for\nmore information on the different values.\n\nThe default value is `{ path: '/', httpOnly: true, secure: false, maxAge: null }`.\n\n##### genid\n\nFunction to call to generate a new session ID. Provide a function that returns\na string that will be used as a session ID. The function is given `req` as the\nfirst argument if you want to use some value attached to `req` when generating\nthe ID.\n\nThe default value is a function which uses the `uid2` library to generate IDs.\n\n**NOTE** be careful to generate unique IDs so your sessions do not conflict.\n\n```js\napp.use(session({\n genid: function(req) {\n return genuuid() // use UUIDs for session IDs\n },\n secret: 'keyboard cat'\n}))\n```\n\n##### name\n\nThe name of the session ID cookie to set in the response (and read from in the\nrequest).\n\nThe default value is `'connect.sid'`.\n\n**Note** if you have multiple apps running on the same host (hostname + port),\nthen you need to separate the session cookies from each other. The simplest\nmethod is to simply set different `name`s per app.\n\n##### proxy\n\nTrust the reverse proxy when setting secure cookies (via the \"X-Forwarded-Proto\"\nheader).\n\nThe default value is `undefined`.\n\n - `true` The \"X-Forwarded-Proto\" header will be used.\n - `false` All headers are ignored and the connection is considered secure only\n if there is a direct TLS/SSL connection.\n - `undefined` Uses the \"trust proxy\" setting from express\n\n##### resave\n\nForces the session to be saved back to the session store, even if the session\nwas never modified during the request. Depending on your store this may be\nnecessary, but it can also create race conditions where a client makes two\nparallel requests to your server and changes made to the session in one\nrequest may get overwritten when the other request ends, even if it made no\nchanges (this behavior also depends on what store you're using).\n\nThe default value is `true`, but using the default has been deprecated,\nas the default will change in the future. Please research into this setting\nand choose what is appropriate to your use-case. Typically, you'll want\n`false`.\n\nHow do I know if this is necessary for my store? The best way to know is to\ncheck with your store if it implements the `touch` method. If it does, then\nyou can safely set `resave: false`. If it does not implement the `touch`\nmethod and your store sets an expiration date on stored sessions, then you\nlikely need `resave: true`.\n\n##### rolling\n\nForce a cookie to be set on every response. This resets the expiration date.\n\nThe default value is `false`.\n\n##### saveUninitialized\n\nForces a session that is \"uninitialized\" to be saved to the store. A session is\nuninitialized when it is new but not modified. Choosing `false` is useful for\nimplementing login sessions, reducing server storage usage, or complying with\nlaws that require permission before setting a cookie. Choosing `false` will also\nhelp with race conditions where a client makes multiple parallel requests\nwithout a session.\n\nThe default value is `true`, but using the default has been deprecated, as the\ndefault will change in the future. Please research into this setting and\nchoose what is appropriate to your use-case.\n\n**Note** if you are using Session in conjunction with PassportJS, Passport\nwill add an empty Passport object to the session for use after a user is\nauthenticated, which will be treated as a modification to the session, causing\nit to be saved.\n\n##### secret\n\n**Required option**\n\nThis is the secret used to sign the session ID cookie. This can be either a string\nfor a single secret, or an array of multiple secrets. If an array of secrets is\nprovided, only the first element will be used to sign the session ID cookie, while\nall the elements will be considered when verifying the signature in requests.\n\n##### store\n\nThe session store instance, defaults to a new `MemoryStore` instance.\n\n##### unset\n\nControl the result of unsetting `req.session` (through `delete`, setting to `null`,\netc.).\n\nThe default value is `'keep'`.\n\n - `'destroy'` The session will be destroyed (deleted) when the response ends.\n - `'keep'` The session in the store will be kept, but modifications made during\n the request are ignored and not saved.\n\n#### Cookie options\n\n**Note** Since version 1.5.0, the [`cookie-parser` middleware](https://www.npmjs.com/package/cookie-parser)\nno longer needs to be used for this module to work. This module now directly reads\nand writes cookies on `req`/`res`. Using `cookie-parser` may result in issues\nif the `secret` is not the same between this module and `cookie-parser`.\n\nPlease note that `secure: true` is a **recommended** option. However, it requires an https-enabled website, i.e., HTTPS is necessary for secure cookies.\nIf `secure` is set, and you access your site over HTTP, the cookie will not be set. If you have your node.js behind a proxy and are using `secure: true`, you need to set \"trust proxy\" in express:\n\n```js\nvar app = express()\napp.set('trust proxy', 1) // trust first proxy\napp.use(session({\n secret: 'keyboard cat',\n resave: false,\n saveUninitialized: true,\n cookie: { secure: true }\n}))\n```\n\nFor using secure cookies in production, but allowing for testing in development, the following is an example of enabling this setup based on `NODE_ENV` in express:\n\n```js\nvar app = express()\nvar sess = {\n secret: 'keyboard cat',\n cookie: {}\n}\n\nif (app.get('env') === 'production') {\n app.set('trust proxy', 1) // trust first proxy\n sess.cookie.secure = true // serve secure cookies\n}\n\napp.use(session(sess))\n```\n\nBy default `cookie.maxAge` is `null`, meaning no \"expires\" parameter is set\nso the cookie becomes a browser-session cookie. When the user closes the\nbrowser the cookie (and session) will be removed.\n\n### req.session\n\nTo store or access session data, simply use the request property `req.session`,\nwhich is (generally) serialized as JSON by the store, so nested objects\nare typically fine. For example below is a user-specific view counter:\n\n```js\napp.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))\n\napp.use(function(req, res, next) {\n var sess = req.session\n if (sess.views) {\n sess.views++\n res.setHeader('Content-Type', 'text/html')\n res.write('<p>views: ' + sess.views + '</p>')\n res.write('<p>expires in: ' + (sess.cookie.maxAge / 1000) + 's</p>')\n res.end()\n } else {\n sess.views = 1\n res.end('welcome to the session demo. refresh!')\n }\n})\n```\n\n#### Session.regenerate()\n\nTo regenerate the session simply invoke the method, once complete\na new SID and `Session` instance will be initialized at `req.session`.\n\n```js\nreq.session.regenerate(function(err) {\n // will have a new session here\n})\n```\n\n#### Session.destroy()\n\nDestroys the session, removing `req.session`, will be re-generated next request.\n\n```js\nreq.session.destroy(function(err) {\n // cannot access session here\n})\n```\n\n#### Session.reload()\n\nReloads the session data.\n\n```js\nreq.session.reload(function(err) {\n // session updated\n})\n```\n\n#### Session.save()\n\n```js\nreq.session.save(function(err) {\n // session saved\n})\n```\n\n#### Session.touch()\n\nUpdates the `.maxAge` property. Typically this is\nnot necessary to call, as the session middleware does this for you.\n\n### req.session.cookie\n\nEach session has a unique cookie object accompany it. This allows\nyou to alter the session cookie per visitor. For example we can\nset `req.session.cookie.expires` to `false` to enable the cookie\nto remain for only the duration of the user-agent.\n\n#### Cookie.maxAge\n\nAlternatively `req.session.cookie.maxAge` will return the time\nremaining in milliseconds, which we may also re-assign a new value\nto adjust the `.expires` property appropriately. The following\nare essentially equivalent\n\n```js\nvar hour = 3600000\nreq.session.cookie.expires = new Date(Date.now() + hour)\nreq.session.cookie.maxAge = hour\n```\n\nFor example when `maxAge` is set to `60000` (one minute), and 30 seconds\nhas elapsed it will return `30000` until the current request has completed,\nat which time `req.session.touch()` is called to reset `req.session.maxAge`\nto its original value.\n\n```js\nreq.session.cookie.maxAge // => 30000\n```\n\n## Session Store Implementation\n\nEvery session store _must_ be an `EventEmitter` and implement the following\nmethods:\n\n - `.get(sid, callback)`\n - `.set(sid, session, callback)`\n - `.destroy(sid, callback)`\n\nRecommended methods include, but are not limited to:\n\n - `.touch(sid, session, callback)`\n - `.length(callback)`\n - `.clear(callback)`\n\nFor an example implementation view the [connect-redis](http://github.com/visionmedia/connect-redis) repo.\n\n## Compatible Session Stores\n\nThe following modules implement a session store that is compatible with this\nmodule. Please make a PR to add additional modules :)\n\n[![Github Stars][cassandra-store-image] cassandra-store][cassandra-store-url] An Apache Cassandra-based session store.\n[cassandra-store-url]: https://www.npmjs.com/package/cassandra-store\n[cassandra-store-image]: https://img.shields.io/github/stars/webcc/cassandra-store.svg?label=%E2%98%85\n\n[![Github Stars][connect-mssql-image] connect-mssql][connect-mssql-url] A SQL Server-based session store.\n[connect-mssql-url]: https://www.npmjs.com/package/connect-mssql\n[connect-mssql-image]: https://img.shields.io/github/stars/patriksimek/connect-mssql.svg?label=%E2%98%85\n\n[![Github Stars][connect-mongo-image] connect-mongo][connect-mongo-url] A MongoDB-based session store.\n[connect-mongo-url]: https://www.npmjs.com/package/connect-mongo\n[connect-mongo-image]: https://img.shields.io/github/stars/kcbanner/connect-mongo.svg?label=%E2%98%85\n\n[![Github Stars][connect-mongodb-session-image] connect-mongodb-session][connect-mongodb-session-url] Lightweight MongoDB-based session store built and maintained by MongoDB.\n[connect-mongodb-session-url]: https://www.npmjs.com/package/connect-mongodb-session\n[connect-mongodb-session-image]: https://img.shields.io/github/stars/mongodb-js/connect-mongodb-session.svg?label=%E2%98%85\n\n[![Github Stars][connect-redis-image] connect-redis][connect-redis-url] A Redis-based session store.\n[connect-redis-url]: https://www.npmjs.com/package/connect-redis\n[connect-redis-image]: https://img.shields.io/github/stars/tj/connect-redis.svg?label=%E2%98%85\n\n[![Github Stars][connect-session-knex-image] connect-session-knex][connect-session-knex-url] A session store using\n[Knex.js](http://knexjs.org/), which is a SQL query builder for PostgreSQL, MySQL, MariaDB, SQLite3, and Oracle.\n[connect-session-knex-url]: https://www.npmjs.com/package/connect-session-knex\n[connect-session-knex-image]: https://img.shields.io/github/stars/llambda/connect-session-knex.svg?label=%E2%98%85\n\n[![Github Stars][level-session-store-image] level-session-store][level-session-store-url] A LevelDB-based session store.\n[level-session-store-url]: https://www.npmjs.com/package/level-session-store\n[level-session-store-image]: https://img.shields.io/github/stars/scriptollc/level-session-store.svg?label=%E2%98%85\n\n[![Github Stars][mssql-session-store-image] mssql-session-store][mssql-session-store-url] A SQL Server-based session store.\n[mssql-session-store-url]: https://www.npmjs.com/package/mssql-session-store\n[mssql-session-store-image]: https://img.shields.io/github/stars/jwathen/mssql-session-store.svg?label=%E2%98%85\n\n[![Github Stars][session-file-store-image] session-file-store][session-file-store-url] A file system-based session store.\n[session-file-store-url]: https://www.npmjs.com/package/session-file-store\n[session-file-store-image]: https://img.shields.io/github/stars/valery-barysok/session-file-store.svg?label=%E2%98%85\n\n[![Github Stars][session-rethinkdb-image] session-rethinkdb][session-rethinkdb-url] A [RethinkDB](http://rethinkdb.com/)-based session store.\n[session-rethinkdb-url]: https://www.npmjs.com/package/session-rethinkdb\n[session-rethinkdb-image]: https://img.shields.io/github/stars/llambda/session-rethinkdb.svg?label=%E2%98%85\n\n## Example\n\nA simple example using `express-session` to store page views for a user.\n\n```js\nvar express = require('express')\nvar parseurl = require('parseurl')\nvar session = require('express-session')\n\nvar app = express()\n\napp.use(session({\n secret: 'keyboard cat',\n resave: false,\n saveUninitialized: true\n}))\n\napp.use(function (req, res, next) {\n var views = req.session.views\n\n if (!views) {\n views = req.session.views = {}\n }\n\n // get the url pathname\n var pathname = parseurl(req).pathname\n\n // count the views\n views[pathname] = (views[pathname] || 0) + 1\n\n next()\n})\n\napp.get('/foo', function (req, res, next) {\n res.send('you viewed this page ' + req.session.views['/foo'] + ' times')\n})\n\napp.get('/bar', function (req, res, next) {\n res.send('you viewed this page ' + req.session.views['/bar'] + ' times')\n})\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/express-session.svg\n[npm-url]: https://npmjs.org/package/express-session\n[travis-image]: https://img.shields.io/travis/expressjs/session/master.svg\n[travis-url]: https://travis-ci.org/expressjs/session\n[coveralls-image]: https://img.shields.io/coveralls/expressjs/session/master.svg\n[coveralls-url]: https://coveralls.io/r/expressjs/session?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/express-session.svg\n[downloads-url]: https://npmjs.org/package/express-session\n[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg\n[gratipay-url]: https://gratipay.com/dougwilson/\n",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/expressjs/session.git"
|
|
},
|
|
"scripts": {
|
|
"test": "mocha --bail --reporter spec test/",
|
|
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/",
|
|
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/"
|
|
},
|
|
"version": "1.11.3"
|
|
}
|