mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 10:52:47 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
268
node_modules/express-session/HISTORY.md
generated
vendored
Normal file
268
node_modules/express-session/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
1.11.3 / 2015-05-22
|
||||
===================
|
||||
|
||||
* deps: cookie@0.1.3
|
||||
- Slight optimizations
|
||||
* deps: crc@3.3.0
|
||||
|
||||
1.11.2 / 2015-05-10
|
||||
===================
|
||||
|
||||
* deps: debug@~2.2.0
|
||||
- deps: ms@0.7.1
|
||||
* deps: uid-safe@~2.0.0
|
||||
|
||||
1.11.1 / 2015-04-08
|
||||
===================
|
||||
|
||||
* Fix mutating `options.secret` value
|
||||
|
||||
1.11.0 / 2015-04-07
|
||||
===================
|
||||
|
||||
* Support an array in `secret` option for key rotation
|
||||
* deps: depd@~1.0.1
|
||||
|
||||
1.10.4 / 2015-03-15
|
||||
===================
|
||||
|
||||
* deps: debug@~2.1.3
|
||||
- Fix high intensity foreground color for bold
|
||||
- deps: ms@0.7.0
|
||||
|
||||
1.10.3 / 2015-02-16
|
||||
===================
|
||||
|
||||
* deps: cookie-signature@1.0.6
|
||||
* deps: uid-safe@1.1.0
|
||||
- Use `crypto.randomBytes`, if available
|
||||
- deps: base64-url@1.2.1
|
||||
|
||||
1.10.2 / 2015-01-31
|
||||
===================
|
||||
|
||||
* deps: uid-safe@1.0.3
|
||||
- Fix error branch that would throw
|
||||
- deps: base64-url@1.2.0
|
||||
|
||||
1.10.1 / 2015-01-08
|
||||
===================
|
||||
|
||||
* deps: uid-safe@1.0.2
|
||||
- Remove dependency on `mz`
|
||||
|
||||
1.10.0 / 2015-01-05
|
||||
===================
|
||||
|
||||
* Add `store.touch` interface for session stores
|
||||
* Fix `MemoryStore` expiration with `resave: false`
|
||||
* deps: debug@~2.1.1
|
||||
|
||||
1.9.3 / 2014-12-02
|
||||
==================
|
||||
|
||||
* Fix error when `req.sessionID` contains a non-string value
|
||||
|
||||
1.9.2 / 2014-11-22
|
||||
==================
|
||||
|
||||
* deps: crc@3.2.1
|
||||
- Minor fixes
|
||||
|
||||
1.9.1 / 2014-10-22
|
||||
==================
|
||||
|
||||
* Remove unnecessary empty write call
|
||||
- Fixes Node.js 0.11.14 behavior change
|
||||
- Helps work-around Node.js 0.10.1 zlib bug
|
||||
|
||||
1.9.0 / 2014-09-16
|
||||
==================
|
||||
|
||||
* deps: debug@~2.1.0
|
||||
- Implement `DEBUG_FD` env variable support
|
||||
* deps: depd@~1.0.0
|
||||
|
||||
1.8.2 / 2014-09-15
|
||||
==================
|
||||
|
||||
* Use `crc` instead of `buffer-crc32` for speed
|
||||
* deps: depd@0.4.5
|
||||
|
||||
1.8.1 / 2014-09-08
|
||||
==================
|
||||
|
||||
* Keep `req.session.save` non-enumerable
|
||||
* Prevent session prototype methods from being overwritten
|
||||
|
||||
1.8.0 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Do not resave already-saved session at end of request
|
||||
* deps: cookie-signature@1.0.5
|
||||
* deps: debug@~2.0.0
|
||||
|
||||
1.7.6 / 2014-08-18
|
||||
==================
|
||||
|
||||
* Fix exception on `res.end(null)` calls
|
||||
|
||||
1.7.5 / 2014-08-10
|
||||
==================
|
||||
|
||||
* Fix parsing original URL
|
||||
* deps: on-headers@~1.0.0
|
||||
* deps: parseurl@~1.3.0
|
||||
|
||||
1.7.4 / 2014-08-05
|
||||
==================
|
||||
|
||||
* Fix response end delay for non-chunked responses
|
||||
|
||||
1.7.3 / 2014-08-05
|
||||
==================
|
||||
|
||||
* Fix `res.end` patch to call correct upstream `res.write`
|
||||
|
||||
1.7.2 / 2014-07-27
|
||||
==================
|
||||
|
||||
* deps: depd@0.4.4
|
||||
- Work-around v8 generating empty stack traces
|
||||
|
||||
1.7.1 / 2014-07-26
|
||||
==================
|
||||
|
||||
* deps: depd@0.4.3
|
||||
- Fix exception when global `Error.stackTraceLimit` is too low
|
||||
|
||||
1.7.0 / 2014-07-22
|
||||
==================
|
||||
|
||||
* Improve session-ending error handling
|
||||
- Errors are passed to `next(err)` instead of `console.error`
|
||||
* deps: debug@1.0.4
|
||||
* deps: depd@0.4.2
|
||||
- Add `TRACE_DEPRECATION` environment variable
|
||||
- Remove non-standard grey color from color output
|
||||
- Support `--no-deprecation` argument
|
||||
- Support `--trace-deprecation` argument
|
||||
|
||||
1.6.5 / 2014-07-11
|
||||
==================
|
||||
|
||||
* Do not require `req.originalUrl`
|
||||
* deps: debug@1.0.3
|
||||
- Add support for multiple wildcards in namespaces
|
||||
|
||||
1.6.4 / 2014-07-07
|
||||
==================
|
||||
|
||||
* Fix blank responses for stores with synchronous operations
|
||||
|
||||
1.6.3 / 2014-07-04
|
||||
==================
|
||||
|
||||
* Fix resave deprecation message
|
||||
|
||||
1.6.2 / 2014-07-04
|
||||
==================
|
||||
|
||||
* Fix confusing option deprecation messages
|
||||
|
||||
1.6.1 / 2014-06-28
|
||||
==================
|
||||
|
||||
* Fix saveUninitialized deprecation message
|
||||
|
||||
1.6.0 / 2014-06-28
|
||||
==================
|
||||
|
||||
* Add deprecation message to undefined `resave` option
|
||||
* Add deprecation message to undefined `saveUninitialized` option
|
||||
* Fix `res.end` patch to return correct value
|
||||
* Fix `res.end` patch to handle multiple `res.end` calls
|
||||
* Reject cookies with missing signatures
|
||||
|
||||
1.5.2 / 2014-06-26
|
||||
==================
|
||||
|
||||
* deps: cookie-signature@1.0.4
|
||||
- fix for timing attacks
|
||||
|
||||
1.5.1 / 2014-06-21
|
||||
==================
|
||||
|
||||
* Move hard-to-track-down `req.secret` deprecation message
|
||||
|
||||
1.5.0 / 2014-06-19
|
||||
==================
|
||||
|
||||
* Debug name is now "express-session"
|
||||
* Deprecate integration with `cookie-parser` middleware
|
||||
* Deprecate looking for secret in `req.secret`
|
||||
* Directly read cookies; `cookie-parser` no longer required
|
||||
* Directly set cookies; `res.cookie` no longer required
|
||||
* Generate session IDs with `uid-safe`, faster and even less collisions
|
||||
|
||||
1.4.0 / 2014-06-17
|
||||
==================
|
||||
|
||||
* Add `genid` option to generate custom session IDs
|
||||
* Add `saveUninitialized` option to control saving uninitialized sessions
|
||||
* Add `unset` option to control unsetting `req.session`
|
||||
* Generate session IDs with `rand-token` by default; reduce collisions
|
||||
* deps: buffer-crc32@0.2.3
|
||||
|
||||
1.3.1 / 2014-06-14
|
||||
==================
|
||||
|
||||
* Add description in package for npmjs.org listing
|
||||
|
||||
1.3.0 / 2014-06-14
|
||||
==================
|
||||
|
||||
* Integrate with express "trust proxy" by default
|
||||
* deps: debug@1.0.2
|
||||
|
||||
1.2.1 / 2014-05-27
|
||||
==================
|
||||
|
||||
* Fix `resave` such that `resave: true` works
|
||||
|
||||
1.2.0 / 2014-05-19
|
||||
==================
|
||||
|
||||
* Add `resave` option to control saving unmodified sessions
|
||||
|
||||
1.1.0 / 2014-05-12
|
||||
==================
|
||||
|
||||
* Add `name` option; replacement for `key` option
|
||||
* Use `setImmediate` in MemoryStore for node.js >= 0.10
|
||||
|
||||
1.0.4 / 2014-04-27
|
||||
==================
|
||||
|
||||
* deps: debug@0.8.1
|
||||
|
||||
1.0.3 / 2014-04-19
|
||||
==================
|
||||
|
||||
* Use `res.cookie()` instead of `res.setHeader()`
|
||||
* deps: cookie@0.1.2
|
||||
|
||||
1.0.2 / 2014-02-23
|
||||
==================
|
||||
|
||||
* Add missing dependency to `package.json`
|
||||
|
||||
1.0.1 / 2014-02-15
|
||||
==================
|
||||
|
||||
* Add missing dependencies to `package.json`
|
||||
|
||||
1.0.0 / 2014-02-15
|
||||
==================
|
||||
|
||||
* Genesis from `connect`
|
||||
24
node_modules/express-session/LICENSE
generated
vendored
Normal file
24
node_modules/express-session/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2010 Sencha Inc.
|
||||
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
||||
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
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.
|
||||
414
node_modules/express-session/README.md
generated
vendored
Normal file
414
node_modules/express-session/README.md
generated
vendored
Normal file
@@ -0,0 +1,414 @@
|
||||
# express-session
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
[![Gratipay][gratipay-image]][gratipay-url]
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install express-session
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var session = require('express-session')
|
||||
```
|
||||
|
||||
### session(options)
|
||||
|
||||
Create a session middleware with the given `options`.
|
||||
|
||||
**Note** Session data is _not_ saved in the cookie itself, just the session ID.
|
||||
Session data is stored server-side.
|
||||
|
||||
**Warning** The default server-side session storage, `MemoryStore`, is _purposely_
|
||||
not designed for a production environment. It will leak memory under most
|
||||
conditions, does not scale past a single process, and is meant for debugging and
|
||||
developing.
|
||||
|
||||
For a list of stores, see [compatible session stores](#compatible-session-stores).
|
||||
|
||||
#### Options
|
||||
|
||||
`express-session` accepts these properties in the options object.
|
||||
|
||||
##### cookie
|
||||
|
||||
Settings for the session ID cookie. See the "Cookie options" section below for
|
||||
more information on the different values.
|
||||
|
||||
The default value is `{ path: '/', httpOnly: true, secure: false, maxAge: null }`.
|
||||
|
||||
##### genid
|
||||
|
||||
Function to call to generate a new session ID. Provide a function that returns
|
||||
a string that will be used as a session ID. The function is given `req` as the
|
||||
first argument if you want to use some value attached to `req` when generating
|
||||
the ID.
|
||||
|
||||
The default value is a function which uses the `uid2` library to generate IDs.
|
||||
|
||||
**NOTE** be careful to generate unique IDs so your sessions do not conflict.
|
||||
|
||||
```js
|
||||
app.use(session({
|
||||
genid: function(req) {
|
||||
return genuuid() // use UUIDs for session IDs
|
||||
},
|
||||
secret: 'keyboard cat'
|
||||
}))
|
||||
```
|
||||
|
||||
##### name
|
||||
|
||||
The name of the session ID cookie to set in the response (and read from in the
|
||||
request).
|
||||
|
||||
The default value is `'connect.sid'`.
|
||||
|
||||
**Note** if you have multiple apps running on the same host (hostname + port),
|
||||
then you need to separate the session cookies from each other. The simplest
|
||||
method is to simply set different `name`s per app.
|
||||
|
||||
##### proxy
|
||||
|
||||
Trust the reverse proxy when setting secure cookies (via the "X-Forwarded-Proto"
|
||||
header).
|
||||
|
||||
The default value is `undefined`.
|
||||
|
||||
- `true` The "X-Forwarded-Proto" header will be used.
|
||||
- `false` All headers are ignored and the connection is considered secure only
|
||||
if there is a direct TLS/SSL connection.
|
||||
- `undefined` Uses the "trust proxy" setting from express
|
||||
|
||||
##### resave
|
||||
|
||||
Forces the session to be saved back to the session store, even if the session
|
||||
was never modified during the request. Depending on your store this may be
|
||||
necessary, but it can also create race conditions where a client makes two
|
||||
parallel requests to your server and changes made to the session in one
|
||||
request may get overwritten when the other request ends, even if it made no
|
||||
changes (this behavior also depends on what store you're using).
|
||||
|
||||
The default value is `true`, but using the default has been deprecated,
|
||||
as the default will change in the future. Please research into this setting
|
||||
and choose what is appropriate to your use-case. Typically, you'll want
|
||||
`false`.
|
||||
|
||||
How do I know if this is necessary for my store? The best way to know is to
|
||||
check with your store if it implements the `touch` method. If it does, then
|
||||
you can safely set `resave: false`. If it does not implement the `touch`
|
||||
method and your store sets an expiration date on stored sessions, then you
|
||||
likely need `resave: true`.
|
||||
|
||||
##### rolling
|
||||
|
||||
Force a cookie to be set on every response. This resets the expiration date.
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
##### saveUninitialized
|
||||
|
||||
Forces a session that is "uninitialized" to be saved to the store. A session is
|
||||
uninitialized when it is new but not modified. Choosing `false` is useful for
|
||||
implementing login sessions, reducing server storage usage, or complying with
|
||||
laws that require permission before setting a cookie. Choosing `false` will also
|
||||
help with race conditions where a client makes multiple parallel requests
|
||||
without a session.
|
||||
|
||||
The default value is `true`, but using the default has been deprecated, as the
|
||||
default will change in the future. Please research into this setting and
|
||||
choose what is appropriate to your use-case.
|
||||
|
||||
**Note** if you are using Session in conjunction with PassportJS, Passport
|
||||
will add an empty Passport object to the session for use after a user is
|
||||
authenticated, which will be treated as a modification to the session, causing
|
||||
it to be saved.
|
||||
|
||||
##### secret
|
||||
|
||||
**Required option**
|
||||
|
||||
This is the secret used to sign the session ID cookie. This can be either a string
|
||||
for a single secret, or an array of multiple secrets. If an array of secrets is
|
||||
provided, only the first element will be used to sign the session ID cookie, while
|
||||
all the elements will be considered when verifying the signature in requests.
|
||||
|
||||
##### store
|
||||
|
||||
The session store instance, defaults to a new `MemoryStore` instance.
|
||||
|
||||
##### unset
|
||||
|
||||
Control the result of unsetting `req.session` (through `delete`, setting to `null`,
|
||||
etc.).
|
||||
|
||||
The default value is `'keep'`.
|
||||
|
||||
- `'destroy'` The session will be destroyed (deleted) when the response ends.
|
||||
- `'keep'` The session in the store will be kept, but modifications made during
|
||||
the request are ignored and not saved.
|
||||
|
||||
#### Cookie options
|
||||
|
||||
**Note** Since version 1.5.0, the [`cookie-parser` middleware](https://www.npmjs.com/package/cookie-parser)
|
||||
no longer needs to be used for this module to work. This module now directly reads
|
||||
and writes cookies on `req`/`res`. Using `cookie-parser` may result in issues
|
||||
if the `secret` is not the same between this module and `cookie-parser`.
|
||||
|
||||
Please note that `secure: true` is a **recommended** option. However, it requires an https-enabled website, i.e., HTTPS is necessary for secure cookies.
|
||||
If `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:
|
||||
|
||||
```js
|
||||
var app = express()
|
||||
app.set('trust proxy', 1) // trust first proxy
|
||||
app.use(session({
|
||||
secret: 'keyboard cat',
|
||||
resave: false,
|
||||
saveUninitialized: true,
|
||||
cookie: { secure: true }
|
||||
}))
|
||||
```
|
||||
|
||||
For 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:
|
||||
|
||||
```js
|
||||
var app = express()
|
||||
var sess = {
|
||||
secret: 'keyboard cat',
|
||||
cookie: {}
|
||||
}
|
||||
|
||||
if (app.get('env') === 'production') {
|
||||
app.set('trust proxy', 1) // trust first proxy
|
||||
sess.cookie.secure = true // serve secure cookies
|
||||
}
|
||||
|
||||
app.use(session(sess))
|
||||
```
|
||||
|
||||
By default `cookie.maxAge` is `null`, meaning no "expires" parameter is set
|
||||
so the cookie becomes a browser-session cookie. When the user closes the
|
||||
browser the cookie (and session) will be removed.
|
||||
|
||||
### req.session
|
||||
|
||||
To store or access session data, simply use the request property `req.session`,
|
||||
which is (generally) serialized as JSON by the store, so nested objects
|
||||
are typically fine. For example below is a user-specific view counter:
|
||||
|
||||
```js
|
||||
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
var sess = req.session
|
||||
if (sess.views) {
|
||||
sess.views++
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
res.write('<p>views: ' + sess.views + '</p>')
|
||||
res.write('<p>expires in: ' + (sess.cookie.maxAge / 1000) + 's</p>')
|
||||
res.end()
|
||||
} else {
|
||||
sess.views = 1
|
||||
res.end('welcome to the session demo. refresh!')
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Session.regenerate()
|
||||
|
||||
To regenerate the session simply invoke the method, once complete
|
||||
a new SID and `Session` instance will be initialized at `req.session`.
|
||||
|
||||
```js
|
||||
req.session.regenerate(function(err) {
|
||||
// will have a new session here
|
||||
})
|
||||
```
|
||||
|
||||
#### Session.destroy()
|
||||
|
||||
Destroys the session, removing `req.session`, will be re-generated next request.
|
||||
|
||||
```js
|
||||
req.session.destroy(function(err) {
|
||||
// cannot access session here
|
||||
})
|
||||
```
|
||||
|
||||
#### Session.reload()
|
||||
|
||||
Reloads the session data.
|
||||
|
||||
```js
|
||||
req.session.reload(function(err) {
|
||||
// session updated
|
||||
})
|
||||
```
|
||||
|
||||
#### Session.save()
|
||||
|
||||
```js
|
||||
req.session.save(function(err) {
|
||||
// session saved
|
||||
})
|
||||
```
|
||||
|
||||
#### Session.touch()
|
||||
|
||||
Updates the `.maxAge` property. Typically this is
|
||||
not necessary to call, as the session middleware does this for you.
|
||||
|
||||
### req.session.cookie
|
||||
|
||||
Each session has a unique cookie object accompany it. This allows
|
||||
you to alter the session cookie per visitor. For example we can
|
||||
set `req.session.cookie.expires` to `false` to enable the cookie
|
||||
to remain for only the duration of the user-agent.
|
||||
|
||||
#### Cookie.maxAge
|
||||
|
||||
Alternatively `req.session.cookie.maxAge` will return the time
|
||||
remaining in milliseconds, which we may also re-assign a new value
|
||||
to adjust the `.expires` property appropriately. The following
|
||||
are essentially equivalent
|
||||
|
||||
```js
|
||||
var hour = 3600000
|
||||
req.session.cookie.expires = new Date(Date.now() + hour)
|
||||
req.session.cookie.maxAge = hour
|
||||
```
|
||||
|
||||
For example when `maxAge` is set to `60000` (one minute), and 30 seconds
|
||||
has elapsed it will return `30000` until the current request has completed,
|
||||
at which time `req.session.touch()` is called to reset `req.session.maxAge`
|
||||
to its original value.
|
||||
|
||||
```js
|
||||
req.session.cookie.maxAge // => 30000
|
||||
```
|
||||
|
||||
## Session Store Implementation
|
||||
|
||||
Every session store _must_ be an `EventEmitter` and implement the following
|
||||
methods:
|
||||
|
||||
- `.get(sid, callback)`
|
||||
- `.set(sid, session, callback)`
|
||||
- `.destroy(sid, callback)`
|
||||
|
||||
Recommended methods include, but are not limited to:
|
||||
|
||||
- `.touch(sid, session, callback)`
|
||||
- `.length(callback)`
|
||||
- `.clear(callback)`
|
||||
|
||||
For an example implementation view the [connect-redis](http://github.com/visionmedia/connect-redis) repo.
|
||||
|
||||
## Compatible Session Stores
|
||||
|
||||
The following modules implement a session store that is compatible with this
|
||||
module. Please make a PR to add additional modules :)
|
||||
|
||||
[![Github Stars][cassandra-store-image] cassandra-store][cassandra-store-url] An Apache Cassandra-based session store.
|
||||
[cassandra-store-url]: https://www.npmjs.com/package/cassandra-store
|
||||
[cassandra-store-image]: https://img.shields.io/github/stars/webcc/cassandra-store.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][connect-mssql-image] connect-mssql][connect-mssql-url] A SQL Server-based session store.
|
||||
[connect-mssql-url]: https://www.npmjs.com/package/connect-mssql
|
||||
[connect-mssql-image]: https://img.shields.io/github/stars/patriksimek/connect-mssql.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][connect-mongo-image] connect-mongo][connect-mongo-url] A MongoDB-based session store.
|
||||
[connect-mongo-url]: https://www.npmjs.com/package/connect-mongo
|
||||
[connect-mongo-image]: https://img.shields.io/github/stars/kcbanner/connect-mongo.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][connect-mongodb-session-image] connect-mongodb-session][connect-mongodb-session-url] Lightweight MongoDB-based session store built and maintained by MongoDB.
|
||||
[connect-mongodb-session-url]: https://www.npmjs.com/package/connect-mongodb-session
|
||||
[connect-mongodb-session-image]: https://img.shields.io/github/stars/mongodb-js/connect-mongodb-session.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][connect-redis-image] connect-redis][connect-redis-url] A Redis-based session store.
|
||||
[connect-redis-url]: https://www.npmjs.com/package/connect-redis
|
||||
[connect-redis-image]: https://img.shields.io/github/stars/tj/connect-redis.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][connect-session-knex-image] connect-session-knex][connect-session-knex-url] A session store using
|
||||
[Knex.js](http://knexjs.org/), which is a SQL query builder for PostgreSQL, MySQL, MariaDB, SQLite3, and Oracle.
|
||||
[connect-session-knex-url]: https://www.npmjs.com/package/connect-session-knex
|
||||
[connect-session-knex-image]: https://img.shields.io/github/stars/llambda/connect-session-knex.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][level-session-store-image] level-session-store][level-session-store-url] A LevelDB-based session store.
|
||||
[level-session-store-url]: https://www.npmjs.com/package/level-session-store
|
||||
[level-session-store-image]: https://img.shields.io/github/stars/scriptollc/level-session-store.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][mssql-session-store-image] mssql-session-store][mssql-session-store-url] A SQL Server-based session store.
|
||||
[mssql-session-store-url]: https://www.npmjs.com/package/mssql-session-store
|
||||
[mssql-session-store-image]: https://img.shields.io/github/stars/jwathen/mssql-session-store.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][session-file-store-image] session-file-store][session-file-store-url] A file system-based session store.
|
||||
[session-file-store-url]: https://www.npmjs.com/package/session-file-store
|
||||
[session-file-store-image]: https://img.shields.io/github/stars/valery-barysok/session-file-store.svg?label=%E2%98%85
|
||||
|
||||
[![Github Stars][session-rethinkdb-image] session-rethinkdb][session-rethinkdb-url] A [RethinkDB](http://rethinkdb.com/)-based session store.
|
||||
[session-rethinkdb-url]: https://www.npmjs.com/package/session-rethinkdb
|
||||
[session-rethinkdb-image]: https://img.shields.io/github/stars/llambda/session-rethinkdb.svg?label=%E2%98%85
|
||||
|
||||
## Example
|
||||
|
||||
A simple example using `express-session` to store page views for a user.
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var parseurl = require('parseurl')
|
||||
var session = require('express-session')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(session({
|
||||
secret: 'keyboard cat',
|
||||
resave: false,
|
||||
saveUninitialized: true
|
||||
}))
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
var views = req.session.views
|
||||
|
||||
if (!views) {
|
||||
views = req.session.views = {}
|
||||
}
|
||||
|
||||
// get the url pathname
|
||||
var pathname = parseurl(req).pathname
|
||||
|
||||
// count the views
|
||||
views[pathname] = (views[pathname] || 0) + 1
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
app.get('/foo', function (req, res, next) {
|
||||
res.send('you viewed this page ' + req.session.views['/foo'] + ' times')
|
||||
})
|
||||
|
||||
app.get('/bar', function (req, res, next) {
|
||||
res.send('you viewed this page ' + req.session.views['/bar'] + ' times')
|
||||
})
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/express-session.svg
|
||||
[npm-url]: https://npmjs.org/package/express-session
|
||||
[travis-image]: https://img.shields.io/travis/expressjs/session/master.svg
|
||||
[travis-url]: https://travis-ci.org/expressjs/session
|
||||
[coveralls-image]: https://img.shields.io/coveralls/expressjs/session/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/session?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/express-session.svg
|
||||
[downloads-url]: https://npmjs.org/package/express-session
|
||||
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
|
||||
[gratipay-url]: https://gratipay.com/dougwilson/
|
||||
607
node_modules/express-session/index.js
generated
vendored
Normal file
607
node_modules/express-session/index.js
generated
vendored
Normal file
@@ -0,0 +1,607 @@
|
||||
/*!
|
||||
* express-session
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var cookie = require('cookie');
|
||||
var crc = require('crc').crc32;
|
||||
var debug = require('debug')('express-session');
|
||||
var deprecate = require('depd')('express-session');
|
||||
var parseUrl = require('parseurl');
|
||||
var uid = require('uid-safe').sync
|
||||
, onHeaders = require('on-headers')
|
||||
, signature = require('cookie-signature')
|
||||
|
||||
var Session = require('./session/session')
|
||||
, MemoryStore = require('./session/memory')
|
||||
, Cookie = require('./session/cookie')
|
||||
, Store = require('./session/store')
|
||||
|
||||
// environment
|
||||
|
||||
var env = process.env.NODE_ENV;
|
||||
|
||||
/**
|
||||
* Expose the middleware.
|
||||
*/
|
||||
|
||||
exports = module.exports = session;
|
||||
|
||||
/**
|
||||
* Expose constructors.
|
||||
*/
|
||||
|
||||
exports.Store = Store;
|
||||
exports.Cookie = Cookie;
|
||||
exports.Session = Session;
|
||||
exports.MemoryStore = MemoryStore;
|
||||
|
||||
/**
|
||||
* Warning message for `MemoryStore` usage in production.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var warning = 'Warning: connect.session() MemoryStore is not\n'
|
||||
+ 'designed for a production environment, as it will leak\n'
|
||||
+ 'memory, and will not scale past a single process.';
|
||||
|
||||
/**
|
||||
* Node.js 0.8+ async implementation.
|
||||
* @private
|
||||
*/
|
||||
|
||||
/* istanbul ignore next */
|
||||
var defer = typeof setImmediate === 'function'
|
||||
? setImmediate
|
||||
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) }
|
||||
|
||||
/**
|
||||
* Setup session store with the given `options`.
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* @param {Object} [options.cookie] Options for cookie
|
||||
* @param {Function} [options.genid]
|
||||
* @param {String} [options.name=connect.sid] Session ID cookie name
|
||||
* @param {Boolean} [options.proxy]
|
||||
* @param {Boolean} [options.resave] Resave unmodified sessions back to the store
|
||||
* @param {Boolean} [options.rolling] Enable/disable rolling session expiration
|
||||
* @param {Boolean} [options.saveUninitialized] Save uninitialized sessions to the store
|
||||
* @param {String|Array} [options.secret] Secret for signing session ID
|
||||
* @param {Object} [options.store=MemoryStore] Session store
|
||||
* @param {String} [options.unset]
|
||||
* @return {Function} middleware
|
||||
* @public
|
||||
*/
|
||||
|
||||
function session(options){
|
||||
var options = options || {}
|
||||
// name - previously "options.key"
|
||||
, name = options.name || options.key || 'connect.sid'
|
||||
, store = options.store || new MemoryStore
|
||||
, cookie = options.cookie || {}
|
||||
, trustProxy = options.proxy
|
||||
, storeReady = true
|
||||
, rollingSessions = options.rolling || false;
|
||||
var resaveSession = options.resave;
|
||||
var saveUninitializedSession = options.saveUninitialized;
|
||||
var secret = options.secret;
|
||||
|
||||
var generateId = options.genid || generateSessionId;
|
||||
|
||||
if (typeof generateId !== 'function') {
|
||||
throw new TypeError('genid option must be a function');
|
||||
}
|
||||
|
||||
if (resaveSession === undefined) {
|
||||
deprecate('undefined resave option; provide resave option');
|
||||
resaveSession = true;
|
||||
}
|
||||
|
||||
if (saveUninitializedSession === undefined) {
|
||||
deprecate('undefined saveUninitialized option; provide saveUninitialized option');
|
||||
saveUninitializedSession = true;
|
||||
}
|
||||
|
||||
if (options.unset && options.unset !== 'destroy' && options.unset !== 'keep') {
|
||||
throw new TypeError('unset option must be "destroy" or "keep"');
|
||||
}
|
||||
|
||||
// TODO: switch to "destroy" on next major
|
||||
var unsetDestroy = options.unset === 'destroy';
|
||||
|
||||
if (Array.isArray(secret) && secret.length === 0) {
|
||||
throw new TypeError('secret option array must contain one or more strings');
|
||||
}
|
||||
|
||||
if (secret && !Array.isArray(secret)) {
|
||||
secret = [secret];
|
||||
}
|
||||
|
||||
if (!secret) {
|
||||
deprecate('req.secret; provide secret option');
|
||||
}
|
||||
|
||||
// notify user that this store is not
|
||||
// meant for a production environment
|
||||
if ('production' == env && store instanceof MemoryStore) {
|
||||
console.warn(warning);
|
||||
}
|
||||
|
||||
// generates the new session
|
||||
store.generate = function(req){
|
||||
req.sessionID = generateId(req);
|
||||
req.session = new Session(req);
|
||||
req.session.cookie = new Cookie(cookie);
|
||||
};
|
||||
|
||||
var storeImplementsTouch = typeof store.touch === 'function';
|
||||
store.on('disconnect', function(){ storeReady = false; });
|
||||
store.on('connect', function(){ storeReady = true; });
|
||||
|
||||
return function session(req, res, next) {
|
||||
// self-awareness
|
||||
if (req.session) return next();
|
||||
|
||||
// Handle connection as if there is no session if
|
||||
// the store has temporarily disconnected etc
|
||||
if (!storeReady) return debug('store is disconnected'), next();
|
||||
|
||||
// pathname mismatch
|
||||
var originalPath = parseUrl.original(req).pathname;
|
||||
if (0 != originalPath.indexOf(cookie.path || '/')) return next();
|
||||
|
||||
// ensure a secret is available or bail
|
||||
if (!secret && !req.secret) {
|
||||
next(new Error('secret option required for sessions'));
|
||||
return;
|
||||
}
|
||||
|
||||
// backwards compatibility for signed cookies
|
||||
// req.secret is passed from the cookie parser middleware
|
||||
var secrets = secret || [req.secret];
|
||||
|
||||
var originalHash;
|
||||
var originalId;
|
||||
var savedHash;
|
||||
|
||||
// expose store
|
||||
req.sessionStore = store;
|
||||
|
||||
// get the session ID from the cookie
|
||||
var cookieId = req.sessionID = getcookie(req, name, secrets);
|
||||
|
||||
// set-cookie
|
||||
onHeaders(res, function(){
|
||||
if (!req.session) {
|
||||
debug('no session');
|
||||
return;
|
||||
}
|
||||
|
||||
var cookie = req.session.cookie;
|
||||
|
||||
// only send secure cookies via https
|
||||
if (cookie.secure && !issecure(req, trustProxy)) {
|
||||
debug('not secured');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!shouldSetCookie(req)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setcookie(res, name, req.sessionID, secrets[0], cookie.data);
|
||||
});
|
||||
|
||||
// proxy end() to commit the session
|
||||
var _end = res.end;
|
||||
var _write = res.write;
|
||||
var ended = false;
|
||||
res.end = function end(chunk, encoding) {
|
||||
if (ended) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ended = true;
|
||||
|
||||
var ret;
|
||||
var sync = true;
|
||||
|
||||
function writeend() {
|
||||
if (sync) {
|
||||
ret = _end.call(res, chunk, encoding);
|
||||
sync = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_end.call(res);
|
||||
}
|
||||
|
||||
function writetop() {
|
||||
if (!sync) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (chunk == null) {
|
||||
ret = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
var contentLength = Number(res.getHeader('Content-Length'));
|
||||
|
||||
if (!isNaN(contentLength) && contentLength > 0) {
|
||||
// measure chunk
|
||||
chunk = !Buffer.isBuffer(chunk)
|
||||
? new Buffer(chunk, encoding)
|
||||
: chunk;
|
||||
encoding = undefined;
|
||||
|
||||
if (chunk.length !== 0) {
|
||||
debug('split response');
|
||||
ret = _write.call(res, chunk.slice(0, chunk.length - 1));
|
||||
chunk = chunk.slice(chunk.length - 1, chunk.length);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = _write.call(res, chunk, encoding);
|
||||
sync = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (shouldDestroy(req)) {
|
||||
// destroy session
|
||||
debug('destroying');
|
||||
store.destroy(req.sessionID, function ondestroy(err) {
|
||||
if (err) {
|
||||
defer(next, err);
|
||||
}
|
||||
|
||||
debug('destroyed');
|
||||
writeend();
|
||||
});
|
||||
|
||||
return writetop();
|
||||
}
|
||||
|
||||
// no session to save
|
||||
if (!req.session) {
|
||||
debug('no session');
|
||||
return _end.call(res, chunk, encoding);
|
||||
}
|
||||
|
||||
// touch session
|
||||
req.session.touch();
|
||||
|
||||
if (shouldSave(req)) {
|
||||
req.session.save(function onsave(err) {
|
||||
if (err) {
|
||||
defer(next, err);
|
||||
}
|
||||
|
||||
writeend();
|
||||
});
|
||||
|
||||
return writetop();
|
||||
} else if (storeImplementsTouch && shouldTouch(req)) {
|
||||
// store implements touch method
|
||||
debug('touching');
|
||||
store.touch(req.sessionID, req.session, function ontouch(err) {
|
||||
if (err) {
|
||||
defer(next, err);
|
||||
}
|
||||
|
||||
debug('touched');
|
||||
writeend();
|
||||
});
|
||||
|
||||
return writetop();
|
||||
}
|
||||
|
||||
return _end.call(res, chunk, encoding);
|
||||
};
|
||||
|
||||
// generate the session
|
||||
function generate() {
|
||||
store.generate(req);
|
||||
originalId = req.sessionID;
|
||||
originalHash = hash(req.session);
|
||||
wrapmethods(req.session);
|
||||
}
|
||||
|
||||
// wrap session methods
|
||||
function wrapmethods(sess) {
|
||||
var _save = sess.save;
|
||||
|
||||
function save() {
|
||||
debug('saving %s', this.id);
|
||||
savedHash = hash(this);
|
||||
_save.apply(this, arguments);
|
||||
}
|
||||
|
||||
Object.defineProperty(sess, 'save', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: save,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
|
||||
// check if session has been modified
|
||||
function isModified(sess) {
|
||||
return originalId !== sess.id || originalHash !== hash(sess);
|
||||
}
|
||||
|
||||
// check if session has been saved
|
||||
function isSaved(sess) {
|
||||
return originalId === sess.id && savedHash === hash(sess);
|
||||
}
|
||||
|
||||
// determine if session should be destroyed
|
||||
function shouldDestroy(req) {
|
||||
return req.sessionID && unsetDestroy && req.session == null;
|
||||
}
|
||||
|
||||
// determine if session should be saved to store
|
||||
function shouldSave(req) {
|
||||
// cannot set cookie without a session ID
|
||||
if (typeof req.sessionID !== 'string') {
|
||||
debug('session ignored because of bogus req.sessionID %o', req.sessionID);
|
||||
return false;
|
||||
}
|
||||
|
||||
return !saveUninitializedSession && cookieId !== req.sessionID
|
||||
? isModified(req.session)
|
||||
: !isSaved(req.session)
|
||||
}
|
||||
|
||||
// determine if session should be touched
|
||||
function shouldTouch(req) {
|
||||
// cannot set cookie without a session ID
|
||||
if (typeof req.sessionID !== 'string') {
|
||||
debug('session ignored because of bogus req.sessionID %o', req.sessionID);
|
||||
return false;
|
||||
}
|
||||
|
||||
return cookieId === req.sessionID && !shouldSave(req);
|
||||
}
|
||||
|
||||
// determine if cookie should be set on response
|
||||
function shouldSetCookie(req) {
|
||||
// cannot set cookie without a session ID
|
||||
if (typeof req.sessionID !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// in case of rolling session, always reset the cookie
|
||||
if (rollingSessions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return cookieId != req.sessionID
|
||||
? saveUninitializedSession || isModified(req.session)
|
||||
: req.session.cookie.expires != null && isModified(req.session);
|
||||
}
|
||||
|
||||
// generate a session if the browser doesn't send a sessionID
|
||||
if (!req.sessionID) {
|
||||
debug('no SID sent, generating session');
|
||||
generate();
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
// generate the session object
|
||||
debug('fetching %s', req.sessionID);
|
||||
store.get(req.sessionID, function(err, sess){
|
||||
// error handling
|
||||
if (err) {
|
||||
debug('error %j', err);
|
||||
|
||||
if (err.code !== 'ENOENT') {
|
||||
next(err);
|
||||
return;
|
||||
}
|
||||
|
||||
generate();
|
||||
// no session
|
||||
} else if (!sess) {
|
||||
debug('no session found');
|
||||
generate();
|
||||
// populate req.session
|
||||
} else {
|
||||
debug('session found');
|
||||
store.createSession(req, sess);
|
||||
originalId = req.sessionID;
|
||||
originalHash = hash(sess);
|
||||
|
||||
if (!resaveSession) {
|
||||
savedHash = originalHash
|
||||
}
|
||||
|
||||
wrapmethods(req.session);
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a session ID for a new session.
|
||||
*
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function generateSessionId(sess) {
|
||||
return uid(24);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session ID cookie from request.
|
||||
*
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getcookie(req, name, secrets) {
|
||||
var header = req.headers.cookie;
|
||||
var raw;
|
||||
var val;
|
||||
|
||||
// read from cookie header
|
||||
if (header) {
|
||||
var cookies = cookie.parse(header);
|
||||
|
||||
raw = cookies[name];
|
||||
|
||||
if (raw) {
|
||||
if (raw.substr(0, 2) === 's:') {
|
||||
val = unsigncookie(raw.slice(2), secrets);
|
||||
|
||||
if (val === false) {
|
||||
debug('cookie signature invalid');
|
||||
val = undefined;
|
||||
}
|
||||
} else {
|
||||
debug('cookie unsigned')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// back-compat read from cookieParser() signedCookies data
|
||||
if (!val && req.signedCookies) {
|
||||
val = req.signedCookies[name];
|
||||
|
||||
if (val) {
|
||||
deprecate('cookie should be available in req.headers.cookie');
|
||||
}
|
||||
}
|
||||
|
||||
// back-compat read from cookieParser() cookies data
|
||||
if (!val && req.cookies) {
|
||||
raw = req.cookies[name];
|
||||
|
||||
if (raw) {
|
||||
if (raw.substr(0, 2) === 's:') {
|
||||
val = unsigncookie(raw.slice(2), secrets);
|
||||
|
||||
if (val) {
|
||||
deprecate('cookie should be available in req.headers.cookie');
|
||||
}
|
||||
|
||||
if (val === false) {
|
||||
debug('cookie signature invalid');
|
||||
val = undefined;
|
||||
}
|
||||
} else {
|
||||
debug('cookie unsigned')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash the given `sess` object omitting changes to `.cookie`.
|
||||
*
|
||||
* @param {Object} sess
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function hash(sess) {
|
||||
return crc(JSON.stringify(sess, function (key, val) {
|
||||
if (key !== 'cookie') {
|
||||
return val;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if request is secure.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Boolean} [trustProxy]
|
||||
* @return {Boolean}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function issecure(req, trustProxy) {
|
||||
// socket is https server
|
||||
if (req.connection && req.connection.encrypted) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// do not trust proxy
|
||||
if (trustProxy === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// no explicit trust; try req.secure from express
|
||||
if (trustProxy !== true) {
|
||||
var secure = req.secure;
|
||||
return typeof secure === 'boolean'
|
||||
? secure
|
||||
: false;
|
||||
}
|
||||
|
||||
// read the proto from x-forwarded-proto header
|
||||
var header = req.headers['x-forwarded-proto'] || '';
|
||||
var index = header.indexOf(',');
|
||||
var proto = index !== -1
|
||||
? header.substr(0, index).toLowerCase().trim()
|
||||
: header.toLowerCase().trim()
|
||||
|
||||
return proto === 'https';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cookie on response.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function setcookie(res, name, val, secret, options) {
|
||||
var signed = 's:' + signature.sign(val, secret);
|
||||
var data = cookie.serialize(name, signed, options);
|
||||
|
||||
debug('set-cookie %s', data);
|
||||
|
||||
var prev = res.getHeader('set-cookie') || [];
|
||||
var header = Array.isArray(prev) ? prev.concat(data)
|
||||
: Array.isArray(data) ? [prev].concat(data)
|
||||
: [prev, data];
|
||||
|
||||
res.setHeader('set-cookie', header)
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify and decode the given `val` with `secrets`.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {Array} secrets
|
||||
* @returns {String|Boolean}
|
||||
* @private
|
||||
*/
|
||||
function unsigncookie(val, secrets) {
|
||||
for (var i = 0; i < secrets.length; i++) {
|
||||
var result = signature.unsign(val, secrets[i]);
|
||||
|
||||
if (result !== false) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
23
node_modules/express-session/node_modules/cookie/LICENSE
generated
vendored
Normal file
23
node_modules/express-session/node_modules/cookie/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com>
|
||||
|
||||
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.
|
||||
|
||||
64
node_modules/express-session/node_modules/cookie/README.md
generated
vendored
Normal file
64
node_modules/express-session/node_modules/cookie/README.md
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# cookie
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
cookie is a basic cookie parser and serializer. It doesn't make assumptions about how you are going to deal with your cookies. It basically just provides a way to read and write the HTTP cookie headers.
|
||||
|
||||
See [RFC6265](http://tools.ietf.org/html/rfc6265) for details about the http header for cookies.
|
||||
|
||||
## how?
|
||||
|
||||
```
|
||||
npm install cookie
|
||||
```
|
||||
|
||||
```javascript
|
||||
var cookie = require('cookie');
|
||||
|
||||
var hdr = cookie.serialize('foo', 'bar');
|
||||
// hdr = 'foo=bar';
|
||||
|
||||
var cookies = cookie.parse('foo=bar; cat=meow; dog=ruff');
|
||||
// cookies = { foo: 'bar', cat: 'meow', dog: 'ruff' };
|
||||
```
|
||||
|
||||
## more
|
||||
|
||||
The serialize function takes a third parameter, an object, to set cookie options. See the RFC for valid values.
|
||||
|
||||
### path
|
||||
> cookie path
|
||||
|
||||
### expires
|
||||
> absolute expiration date for the cookie (Date object)
|
||||
|
||||
### maxAge
|
||||
> relative max age of the cookie from when the client receives it (seconds)
|
||||
|
||||
### domain
|
||||
> domain for the cookie
|
||||
|
||||
### secure
|
||||
> true or false
|
||||
|
||||
### httpOnly
|
||||
> true or false
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/cookie.svg
|
||||
[npm-url]: https://npmjs.org/package/cookie
|
||||
[node-version-image]: https://img.shields.io/node/v/cookie.svg
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/cookie/master.svg
|
||||
[travis-url]: https://travis-ci.org/jshttp/cookie
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/cookie/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/cookie.svg
|
||||
[downloads-url]: https://npmjs.org/package/cookie
|
||||
116
node_modules/express-session/node_modules/cookie/index.js
generated
vendored
Normal file
116
node_modules/express-session/node_modules/cookie/index.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*!
|
||||
* cookie
|
||||
* Copyright(c) 2012-2014 Roman Shtylman
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports.parse = parse;
|
||||
exports.serialize = serialize;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var decode = decodeURIComponent;
|
||||
var encode = encodeURIComponent;
|
||||
|
||||
/**
|
||||
* Parse a cookie header.
|
||||
*
|
||||
* Parse the given cookie header string into an object
|
||||
* The object has the various cookies as keys(names) => values
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {object} [options]
|
||||
* @return {string}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function parse(str, options) {
|
||||
var obj = {}
|
||||
var opt = options || {};
|
||||
var pairs = str.split(/; */);
|
||||
var dec = opt.decode || decode;
|
||||
|
||||
pairs.forEach(function(pair) {
|
||||
var eq_idx = pair.indexOf('=')
|
||||
|
||||
// skip things that don't look like key=value
|
||||
if (eq_idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var key = pair.substr(0, eq_idx).trim()
|
||||
var val = pair.substr(++eq_idx, pair.length).trim();
|
||||
|
||||
// quoted values
|
||||
if ('"' == val[0]) {
|
||||
val = val.slice(1, -1);
|
||||
}
|
||||
|
||||
// only assign once
|
||||
if (undefined == obj[key]) {
|
||||
obj[key] = tryDecode(val, dec);
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize data into a cookie header.
|
||||
*
|
||||
* Serialize the a name value pair into a cookie string suitable for
|
||||
* http headers. An optional options object specified cookie parameters.
|
||||
*
|
||||
* serialize('foo', 'bar', { httpOnly: true })
|
||||
* => "foo=bar; httpOnly"
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {string} val
|
||||
* @param {object} [options]
|
||||
* @return {string}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function serialize(name, val, options) {
|
||||
var opt = options || {};
|
||||
var enc = opt.encode || encode;
|
||||
var pairs = [name + '=' + enc(val)];
|
||||
|
||||
if (null != opt.maxAge) {
|
||||
var maxAge = opt.maxAge - 0;
|
||||
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
||||
pairs.push('Max-Age=' + maxAge);
|
||||
}
|
||||
|
||||
if (opt.domain) pairs.push('Domain=' + opt.domain);
|
||||
if (opt.path) pairs.push('Path=' + opt.path);
|
||||
if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString());
|
||||
if (opt.httpOnly) pairs.push('HttpOnly');
|
||||
if (opt.secure) pairs.push('Secure');
|
||||
|
||||
return pairs.join('; ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Try decoding a string using a decoding function.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {function} decode
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryDecode(str, decode) {
|
||||
try {
|
||||
return decode(str);
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
95
node_modules/express-session/node_modules/cookie/package.json
generated
vendored
Normal file
95
node_modules/express-session/node_modules/cookie/package.json
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"cookie@0.1.3",
|
||||
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/express-session"
|
||||
]
|
||||
],
|
||||
"_from": "cookie@0.1.3",
|
||||
"_id": "cookie@0.1.3",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/express-session/cookie",
|
||||
"_npmUser": {
|
||||
"email": "doug@somethingdoug.com",
|
||||
"name": "dougwilson"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "cookie",
|
||||
"raw": "cookie@0.1.3",
|
||||
"rawSpec": "0.1.3",
|
||||
"scope": null,
|
||||
"spec": "0.1.3",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express-session"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.1.3.tgz",
|
||||
"_shasum": "e734a5c1417fce472d5aef82c381cabb64d1a435",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "cookie@0.1.3",
|
||||
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/express-session",
|
||||
"author": {
|
||||
"email": "shtylman@gmail.com",
|
||||
"name": "Roman Shtylman"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/cookie/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "cookie parsing and serialization",
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.9",
|
||||
"mocha": "1.x.x"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "e734a5c1417fce472d5aef82c381cabb64d1a435",
|
||||
"tarball": "http://registry.npmjs.org/cookie/-/cookie-0.1.3.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "f46097723c16f920a7b9759e154c34792e1d1a3b",
|
||||
"homepage": "https://github.com/jshttp/cookie",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"cookies"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "defunctzombie",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "cookie",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jshttp/cookie.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --bail --check-leaks test/",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
|
||||
},
|
||||
"version": "0.1.3"
|
||||
}
|
||||
75
node_modules/express-session/node_modules/depd/History.md
generated
vendored
Normal file
75
node_modules/express-session/node_modules/depd/History.md
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
1.0.1 / 2015-04-07
|
||||
==================
|
||||
|
||||
* Fix `TypeError`s when under `'use strict'` code
|
||||
* Fix useless type name on auto-generated messages
|
||||
* Support io.js 1.x
|
||||
* Support Node.js 0.12
|
||||
|
||||
1.0.0 / 2014-09-17
|
||||
==================
|
||||
|
||||
* No changes
|
||||
|
||||
0.4.5 / 2014-09-09
|
||||
==================
|
||||
|
||||
* Improve call speed to functions using the function wrapper
|
||||
* Support Node.js 0.6
|
||||
|
||||
0.4.4 / 2014-07-27
|
||||
==================
|
||||
|
||||
* Work-around v8 generating empty stack traces
|
||||
|
||||
0.4.3 / 2014-07-26
|
||||
==================
|
||||
|
||||
* Fix exception when global `Error.stackTraceLimit` is too low
|
||||
|
||||
0.4.2 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Correct call site for wrapped functions and properties
|
||||
|
||||
0.4.1 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Improve automatic message generation for function properties
|
||||
|
||||
0.4.0 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Add `TRACE_DEPRECATION` environment variable
|
||||
* Remove non-standard grey color from color output
|
||||
* Support `--no-deprecation` argument
|
||||
* Support `--trace-deprecation` argument
|
||||
* Support `deprecate.property(fn, prop, message)`
|
||||
|
||||
0.3.0 / 2014-06-16
|
||||
==================
|
||||
|
||||
* Add `NO_DEPRECATION` environment variable
|
||||
|
||||
0.2.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Add `deprecate.property(obj, prop, message)`
|
||||
* Remove `supports-color` dependency for node.js 0.8
|
||||
|
||||
0.1.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Add `deprecate.function(fn, message)`
|
||||
* Add `process.on('deprecation', fn)` emitter
|
||||
* Automatically generate message when omitted from `deprecate()`
|
||||
|
||||
0.0.1 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Fix warning for dynamic calls at singe call site
|
||||
|
||||
0.0.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Initial implementation
|
||||
22
node_modules/express-session/node_modules/depd/LICENSE
generated
vendored
Normal file
22
node_modules/express-session/node_modules/depd/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 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.
|
||||
274
node_modules/express-session/node_modules/depd/Readme.md
generated
vendored
Normal file
274
node_modules/express-session/node_modules/depd/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
# depd
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Linux Build][travis-image]][travis-url]
|
||||
[![Windows Build][appveyor-image]][appveyor-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
[![Gratipay][gratipay-image]][gratipay-url]
|
||||
|
||||
Deprecate all the things
|
||||
|
||||
> With great modules comes great responsibility; mark things deprecated!
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install depd
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-module')
|
||||
```
|
||||
|
||||
This library allows you to display deprecation messages to your users.
|
||||
This library goes above and beyond with deprecation warnings by
|
||||
introspection of the call stack (but only the bits that it is interested
|
||||
in).
|
||||
|
||||
Instead of just warning on the first invocation of a deprecated
|
||||
function and never again, this module will warn on the first invocation
|
||||
of a deprecated function per unique call site, making it ideal to alert
|
||||
users of all deprecated uses across the code base, rather than just
|
||||
whatever happens to execute first.
|
||||
|
||||
The deprecation warnings from this module also include the file and line
|
||||
information for the call into the module that the deprecated function was
|
||||
in.
|
||||
|
||||
**NOTE** this library has a similar interface to the `debug` module, and
|
||||
this module uses the calling file to get the boundary for the call stacks,
|
||||
so you should always create a new `deprecate` object in each file and not
|
||||
within some central file.
|
||||
|
||||
### depd(namespace)
|
||||
|
||||
Create a new deprecate function that uses the given namespace name in the
|
||||
messages and will display the call site prior to the stack entering the
|
||||
file this function was called from. It is highly suggested you use the
|
||||
name of your module as the namespace.
|
||||
|
||||
### deprecate(message)
|
||||
|
||||
Call this function from deprecated code to display a deprecation message.
|
||||
This message will appear once per unique caller site. Caller site is the
|
||||
first call site in the stack in a different file from the caller of this
|
||||
function.
|
||||
|
||||
If the message is omitted, a message is generated for you based on the site
|
||||
of the `deprecate()` call and will display the name of the function called,
|
||||
similar to the name displayed in a stack trace.
|
||||
|
||||
### deprecate.function(fn, message)
|
||||
|
||||
Call this function to wrap a given function in a deprecation message on any
|
||||
call to the function. An optional message can be supplied to provide a custom
|
||||
message.
|
||||
|
||||
### deprecate.property(obj, prop, message)
|
||||
|
||||
Call this function to wrap a given property on object in a deprecation message
|
||||
on any accessing or setting of the property. An optional message can be supplied
|
||||
to provide a custom message.
|
||||
|
||||
The method must be called on the object where the property belongs (not
|
||||
inherited from the prototype).
|
||||
|
||||
If the property is a data descriptor, it will be converted to an accessor
|
||||
descriptor in order to display the deprecation message.
|
||||
|
||||
### process.on('deprecation', fn)
|
||||
|
||||
This module will allow easy capturing of deprecation errors by emitting the
|
||||
errors as the type "deprecation" on the global `process`. If there are no
|
||||
listeners for this type, the errors are written to STDERR as normal, but if
|
||||
there are any listeners, nothing will be written to STDERR and instead only
|
||||
emitted. From there, you can write the errors in a different format or to a
|
||||
logging source.
|
||||
|
||||
The error represents the deprecation and is emitted only once with the same
|
||||
rules as writing to STDERR. The error has the following properties:
|
||||
|
||||
- `message` - This is the message given by the library
|
||||
- `name` - This is always `'DeprecationError'`
|
||||
- `namespace` - This is the namespace the deprecation came from
|
||||
- `stack` - This is the stack of the call to the deprecated thing
|
||||
|
||||
Example `error.stack` output:
|
||||
|
||||
```
|
||||
DeprecationError: my-cool-module deprecated oldfunction
|
||||
at Object.<anonymous> ([eval]-wrapper:6:22)
|
||||
at Module._compile (module.js:456:26)
|
||||
at evalScript (node.js:532:25)
|
||||
at startup (node.js:80:7)
|
||||
at node.js:902:3
|
||||
```
|
||||
|
||||
### process.env.NO_DEPRECATION
|
||||
|
||||
As a user of modules that are deprecated, the environment variable `NO_DEPRECATION`
|
||||
is provided as a quick solution to silencing deprecation warnings from being
|
||||
output. The format of this is similar to that of `DEBUG`:
|
||||
|
||||
```sh
|
||||
$ NO_DEPRECATION=my-module,othermod node app.js
|
||||
```
|
||||
|
||||
This will suppress deprecations from being output for "my-module" and "othermod".
|
||||
The value is a list of comma-separated namespaces. To suppress every warning
|
||||
across all namespaces, use the value `*` for a namespace.
|
||||
|
||||
Providing the argument `--no-deprecation` to the `node` executable will suppress
|
||||
all deprecations (only available in Node.js 0.8 or higher).
|
||||
|
||||
**NOTE** This will not suppress the deperecations given to any "deprecation"
|
||||
event listeners, just the output to STDERR.
|
||||
|
||||
### process.env.TRACE_DEPRECATION
|
||||
|
||||
As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
|
||||
is provided as a solution to getting more detailed location information in deprecation
|
||||
warnings by including the entire stack trace. The format of this is the same as
|
||||
`NO_DEPRECATION`:
|
||||
|
||||
```sh
|
||||
$ TRACE_DEPRECATION=my-module,othermod node app.js
|
||||
```
|
||||
|
||||
This will include stack traces for deprecations being output for "my-module" and
|
||||
"othermod". The value is a list of comma-separated namespaces. To trace every
|
||||
warning across all namespaces, use the value `*` for a namespace.
|
||||
|
||||
Providing the argument `--trace-deprecation` to the `node` executable will trace
|
||||
all deprecations (only available in Node.js 0.8 or higher).
|
||||
|
||||
**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
|
||||
|
||||
## Display
|
||||
|
||||

|
||||
|
||||
When a user calls a function in your library that you mark deprecated, they
|
||||
will see the following written to STDERR (in the given colors, similar colors
|
||||
and layout to the `debug` module):
|
||||
|
||||
```
|
||||
bright cyan bright yellow
|
||||
| | reset cyan
|
||||
| | | |
|
||||
▼ ▼ ▼ ▼
|
||||
my-cool-module deprecated oldfunction [eval]-wrapper:6:22
|
||||
▲ ▲ ▲ ▲
|
||||
| | | |
|
||||
namespace | | location of mycoolmod.oldfunction() call
|
||||
| deprecation message
|
||||
the word "deprecated"
|
||||
```
|
||||
|
||||
If the user redirects their STDERR to a file or somewhere that does not support
|
||||
colors, they see (similar layout to the `debug` module):
|
||||
|
||||
```
|
||||
Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
|
||||
▲ ▲ ▲ ▲ ▲
|
||||
| | | | |
|
||||
timestamp of message namespace | | location of mycoolmod.oldfunction() call
|
||||
| deprecation message
|
||||
the word "deprecated"
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Deprecating all calls to a function
|
||||
|
||||
This will display a deprecated message about "oldfunction" being deprecated
|
||||
from "my-module" on STDERR.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
// message automatically derived from function name
|
||||
// Object.oldfunction
|
||||
exports.oldfunction = deprecate.function(function oldfunction() {
|
||||
// all calls to function are deprecated
|
||||
})
|
||||
|
||||
// specific message
|
||||
exports.oldfunction = deprecate.function(function () {
|
||||
// all calls to function are deprecated
|
||||
}, 'oldfunction')
|
||||
```
|
||||
|
||||
### Conditionally deprecating a function call
|
||||
|
||||
This will display a deprecated message about "weirdfunction" being deprecated
|
||||
from "my-module" on STDERR when called with less than 2 arguments.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.weirdfunction = function () {
|
||||
if (arguments.length < 2) {
|
||||
// calls with 0 or 1 args are deprecated
|
||||
deprecate('weirdfunction args < 2')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When calling `deprecate` as a function, the warning is counted per call site
|
||||
within your own module, so you can display different deprecations depending
|
||||
on different situations and the users will still get all the warnings:
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.weirdfunction = function () {
|
||||
if (arguments.length < 2) {
|
||||
// calls with 0 or 1 args are deprecated
|
||||
deprecate('weirdfunction args < 2')
|
||||
} else if (typeof arguments[0] !== 'string') {
|
||||
// calls with non-string first argument are deprecated
|
||||
deprecate('weirdfunction non-string first arg')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Deprecating property access
|
||||
|
||||
This will display a deprecated message about "oldprop" being deprecated
|
||||
from "my-module" on STDERR when accessed. A deprecation will be displayed
|
||||
when setting the value and when getting the value.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.oldprop = 'something'
|
||||
|
||||
// message automatically derives from property name
|
||||
deprecate.property(exports, 'oldprop')
|
||||
|
||||
// explicit message
|
||||
deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-version-image]: https://img.shields.io/npm/v/depd.svg
|
||||
[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg
|
||||
[npm-url]: https://npmjs.org/package/depd
|
||||
[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd/master.svg?label=linux
|
||||
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/nodejs-depd/master.svg?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd
|
||||
[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
|
||||
[node-image]: https://img.shields.io/node/v/depd.svg
|
||||
[node-url]: http://nodejs.org/download/
|
||||
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
|
||||
[gratipay-url]: https://www.gratipay.com/dougwilson/
|
||||
529
node_modules/express-session/node_modules/depd/index.js
generated
vendored
Normal file
529
node_modules/express-session/node_modules/depd/index.js
generated
vendored
Normal file
@@ -0,0 +1,529 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var callSiteToString = require('./lib/compat').callSiteToString
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var relative = require('path').relative
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = depd
|
||||
|
||||
/**
|
||||
* Get the path to base files on.
|
||||
*/
|
||||
|
||||
var basePath = process.cwd()
|
||||
|
||||
/**
|
||||
* Get listener count on event emitter.
|
||||
*/
|
||||
|
||||
/*istanbul ignore next*/
|
||||
var eventListenerCount = EventEmitter.listenerCount
|
||||
|| function (emitter, type) { return emitter.listeners(type).length }
|
||||
|
||||
/**
|
||||
* Determine if namespace is contained in the string.
|
||||
*/
|
||||
|
||||
function containsNamespace(str, namespace) {
|
||||
var val = str.split(/[ ,]+/)
|
||||
|
||||
namespace = String(namespace).toLowerCase()
|
||||
|
||||
for (var i = 0 ; i < val.length; i++) {
|
||||
if (!(str = val[i])) continue;
|
||||
|
||||
// namespace contained
|
||||
if (str === '*' || str.toLowerCase() === namespace) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data descriptor to accessor descriptor.
|
||||
*/
|
||||
|
||||
function convertDataDescriptorToAccessor(obj, prop, message) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||
var value = descriptor.value
|
||||
|
||||
descriptor.get = function getter() { return value }
|
||||
|
||||
if (descriptor.writable) {
|
||||
descriptor.set = function setter(val) { return value = val }
|
||||
}
|
||||
|
||||
delete descriptor.value
|
||||
delete descriptor.writable
|
||||
|
||||
Object.defineProperty(obj, prop, descriptor)
|
||||
|
||||
return descriptor
|
||||
}
|
||||
|
||||
/**
|
||||
* Create arguments string to keep arity.
|
||||
*/
|
||||
|
||||
function createArgumentsString(arity) {
|
||||
var str = ''
|
||||
|
||||
for (var i = 0; i < arity; i++) {
|
||||
str += ', arg' + i
|
||||
}
|
||||
|
||||
return str.substr(2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stack string from stack.
|
||||
*/
|
||||
|
||||
function createStackString(stack) {
|
||||
var str = this.name + ': ' + this.namespace
|
||||
|
||||
if (this.message) {
|
||||
str += ' deprecated ' + this.message
|
||||
}
|
||||
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
str += '\n at ' + callSiteToString(stack[i])
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
/**
|
||||
* Create deprecate for namespace in caller.
|
||||
*/
|
||||
|
||||
function depd(namespace) {
|
||||
if (!namespace) {
|
||||
throw new TypeError('argument namespace is required')
|
||||
}
|
||||
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
var file = site[0]
|
||||
|
||||
function deprecate(message) {
|
||||
// call to self as log
|
||||
log.call(deprecate, message)
|
||||
}
|
||||
|
||||
deprecate._file = file
|
||||
deprecate._ignored = isignored(namespace)
|
||||
deprecate._namespace = namespace
|
||||
deprecate._traced = istraced(namespace)
|
||||
deprecate._warned = Object.create(null)
|
||||
|
||||
deprecate.function = wrapfunction
|
||||
deprecate.property = wrapproperty
|
||||
|
||||
return deprecate
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if namespace is ignored.
|
||||
*/
|
||||
|
||||
function isignored(namespace) {
|
||||
/* istanbul ignore next: tested in a child processs */
|
||||
if (process.noDeprecation) {
|
||||
// --no-deprecation support
|
||||
return true
|
||||
}
|
||||
|
||||
var str = process.env.NO_DEPRECATION || ''
|
||||
|
||||
// namespace ignored
|
||||
return containsNamespace(str, namespace)
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if namespace is traced.
|
||||
*/
|
||||
|
||||
function istraced(namespace) {
|
||||
/* istanbul ignore next: tested in a child processs */
|
||||
if (process.traceDeprecation) {
|
||||
// --trace-deprecation support
|
||||
return true
|
||||
}
|
||||
|
||||
var str = process.env.TRACE_DEPRECATION || ''
|
||||
|
||||
// namespace traced
|
||||
return containsNamespace(str, namespace)
|
||||
}
|
||||
|
||||
/**
|
||||
* Display deprecation message.
|
||||
*/
|
||||
|
||||
function log(message, site) {
|
||||
var haslisteners = eventListenerCount(process, 'deprecation') !== 0
|
||||
|
||||
// abort early if no destination
|
||||
if (!haslisteners && this._ignored) {
|
||||
return
|
||||
}
|
||||
|
||||
var caller
|
||||
var callFile
|
||||
var callSite
|
||||
var i = 0
|
||||
var seen = false
|
||||
var stack = getStack()
|
||||
var file = this._file
|
||||
|
||||
if (site) {
|
||||
// provided site
|
||||
callSite = callSiteLocation(stack[1])
|
||||
callSite.name = site.name
|
||||
file = callSite[0]
|
||||
} else {
|
||||
// get call site
|
||||
i = 2
|
||||
site = callSiteLocation(stack[i])
|
||||
callSite = site
|
||||
}
|
||||
|
||||
// get caller of deprecated thing in relation to file
|
||||
for (; i < stack.length; i++) {
|
||||
caller = callSiteLocation(stack[i])
|
||||
callFile = caller[0]
|
||||
|
||||
if (callFile === file) {
|
||||
seen = true
|
||||
} else if (callFile === this._file) {
|
||||
file = this._file
|
||||
} else if (seen) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var key = caller
|
||||
? site.join(':') + '__' + caller.join(':')
|
||||
: undefined
|
||||
|
||||
if (key !== undefined && key in this._warned) {
|
||||
// already warned
|
||||
return
|
||||
}
|
||||
|
||||
this._warned[key] = true
|
||||
|
||||
// generate automatic message from call site
|
||||
if (!message) {
|
||||
message = callSite === site || !callSite.name
|
||||
? defaultMessage(site)
|
||||
: defaultMessage(callSite)
|
||||
}
|
||||
|
||||
// emit deprecation if listeners exist
|
||||
if (haslisteners) {
|
||||
var err = DeprecationError(this._namespace, message, stack.slice(i))
|
||||
process.emit('deprecation', err)
|
||||
return
|
||||
}
|
||||
|
||||
// format and write message
|
||||
var format = process.stderr.isTTY
|
||||
? formatColor
|
||||
: formatPlain
|
||||
var msg = format.call(this, message, caller, stack.slice(i))
|
||||
process.stderr.write(msg + '\n', 'utf8')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* Get call site location as array.
|
||||
*/
|
||||
|
||||
function callSiteLocation(callSite) {
|
||||
var file = callSite.getFileName() || '<anonymous>'
|
||||
var line = callSite.getLineNumber()
|
||||
var colm = callSite.getColumnNumber()
|
||||
|
||||
if (callSite.isEval()) {
|
||||
file = callSite.getEvalOrigin() + ', ' + file
|
||||
}
|
||||
|
||||
var site = [file, line, colm]
|
||||
|
||||
site.callSite = callSite
|
||||
site.name = callSite.getFunctionName()
|
||||
|
||||
return site
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a default message from the site.
|
||||
*/
|
||||
|
||||
function defaultMessage(site) {
|
||||
var callSite = site.callSite
|
||||
var funcName = site.name
|
||||
|
||||
// make useful anonymous name
|
||||
if (!funcName) {
|
||||
funcName = '<anonymous@' + formatLocation(site) + '>'
|
||||
}
|
||||
|
||||
var context = callSite.getThis()
|
||||
var typeName = context && callSite.getTypeName()
|
||||
|
||||
// ignore useless type name
|
||||
if (typeName === 'Object') {
|
||||
typeName = undefined
|
||||
}
|
||||
|
||||
// make useful type name
|
||||
if (typeName === 'Function') {
|
||||
typeName = context.name || typeName
|
||||
}
|
||||
|
||||
return typeName && callSite.getMethodName()
|
||||
? typeName + '.' + funcName
|
||||
: funcName
|
||||
}
|
||||
|
||||
/**
|
||||
* Format deprecation message without color.
|
||||
*/
|
||||
|
||||
function formatPlain(msg, caller, stack) {
|
||||
var timestamp = new Date().toUTCString()
|
||||
|
||||
var formatted = timestamp
|
||||
+ ' ' + this._namespace
|
||||
+ ' deprecated ' + msg
|
||||
|
||||
// add stack trace
|
||||
if (this._traced) {
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
formatted += '\n at ' + callSiteToString(stack[i])
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
if (caller) {
|
||||
formatted += ' at ' + formatLocation(caller)
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
/**
|
||||
* Format deprecation message with color.
|
||||
*/
|
||||
|
||||
function formatColor(msg, caller, stack) {
|
||||
var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' // bold cyan
|
||||
+ ' \x1b[33;1mdeprecated\x1b[22;39m' // bold yellow
|
||||
+ ' \x1b[0m' + msg + '\x1b[39m' // reset
|
||||
|
||||
// add stack trace
|
||||
if (this._traced) {
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
formatted += '\n \x1b[36mat ' + callSiteToString(stack[i]) + '\x1b[39m' // cyan
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
if (caller) {
|
||||
formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
/**
|
||||
* Format call site location.
|
||||
*/
|
||||
|
||||
function formatLocation(callSite) {
|
||||
return relative(basePath, callSite[0])
|
||||
+ ':' + callSite[1]
|
||||
+ ':' + callSite[2]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stack as array of call sites.
|
||||
*/
|
||||
|
||||
function getStack() {
|
||||
var limit = Error.stackTraceLimit
|
||||
var obj = {}
|
||||
var prep = Error.prepareStackTrace
|
||||
|
||||
Error.prepareStackTrace = prepareObjectStackTrace
|
||||
Error.stackTraceLimit = Math.max(10, limit)
|
||||
|
||||
// capture the stack
|
||||
Error.captureStackTrace(obj)
|
||||
|
||||
// slice this function off the top
|
||||
var stack = obj.stack.slice(1)
|
||||
|
||||
Error.prepareStackTrace = prep
|
||||
Error.stackTraceLimit = limit
|
||||
|
||||
return stack
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture call site stack from v8.
|
||||
*/
|
||||
|
||||
function prepareObjectStackTrace(obj, stack) {
|
||||
return stack
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a wrapped function in a deprecation message.
|
||||
*/
|
||||
|
||||
function wrapfunction(fn, message) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument fn must be a function')
|
||||
}
|
||||
|
||||
var args = createArgumentsString(fn.length)
|
||||
var deprecate = this
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
site.name = fn.name
|
||||
|
||||
var deprecatedfn = eval('(function (' + args + ') {\n'
|
||||
+ '"use strict"\n'
|
||||
+ 'log.call(deprecate, message, site)\n'
|
||||
+ 'return fn.apply(this, arguments)\n'
|
||||
+ '})')
|
||||
|
||||
return deprecatedfn
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap property in a deprecation message.
|
||||
*/
|
||||
|
||||
function wrapproperty(obj, prop, message) {
|
||||
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
throw new TypeError('argument obj must be object')
|
||||
}
|
||||
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||
|
||||
if (!descriptor) {
|
||||
throw new TypeError('must call property on owner object')
|
||||
}
|
||||
|
||||
if (!descriptor.configurable) {
|
||||
throw new TypeError('property must be configurable')
|
||||
}
|
||||
|
||||
var deprecate = this
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
// set site name
|
||||
site.name = prop
|
||||
|
||||
// convert data descriptor
|
||||
if ('value' in descriptor) {
|
||||
descriptor = convertDataDescriptorToAccessor(obj, prop, message)
|
||||
}
|
||||
|
||||
var get = descriptor.get
|
||||
var set = descriptor.set
|
||||
|
||||
// wrap getter
|
||||
if (typeof get === 'function') {
|
||||
descriptor.get = function getter() {
|
||||
log.call(deprecate, message, site)
|
||||
return get.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
// wrap setter
|
||||
if (typeof set === 'function') {
|
||||
descriptor.set = function setter() {
|
||||
log.call(deprecate, message, site)
|
||||
return set.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, prop, descriptor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DeprecationError for deprecation
|
||||
*/
|
||||
|
||||
function DeprecationError(namespace, message, stack) {
|
||||
var error = new Error()
|
||||
var stackString
|
||||
|
||||
Object.defineProperty(error, 'constructor', {
|
||||
value: DeprecationError
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'message', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: message,
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'name', {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: 'DeprecationError',
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'namespace', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: namespace,
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'stack', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
if (stackString !== undefined) {
|
||||
return stackString
|
||||
}
|
||||
|
||||
// prepare stack trace
|
||||
return stackString = createStackString.call(this, stack)
|
||||
},
|
||||
set: function setter(val) {
|
||||
stackString = val
|
||||
}
|
||||
})
|
||||
|
||||
return error
|
||||
}
|
||||
33
node_modules/express-session/node_modules/depd/lib/compat/buffer-concat.js
generated
vendored
Normal file
33
node_modules/express-session/node_modules/depd/lib/compat/buffer-concat.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = bufferConcat
|
||||
|
||||
/**
|
||||
* Concatenate an array of Buffers.
|
||||
*/
|
||||
|
||||
function bufferConcat(bufs) {
|
||||
var length = 0
|
||||
|
||||
for (var i = 0, len = bufs.length; i < len; i++) {
|
||||
length += bufs[i].length
|
||||
}
|
||||
|
||||
var buf = new Buffer(length)
|
||||
var pos = 0
|
||||
|
||||
for (var i = 0, len = bufs.length; i < len; i++) {
|
||||
bufs[i].copy(buf, pos)
|
||||
pos += bufs[i].length
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
101
node_modules/express-session/node_modules/depd/lib/compat/callsite-tostring.js
generated
vendored
Normal file
101
node_modules/express-session/node_modules/depd/lib/compat/callsite-tostring.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = callSiteToString
|
||||
|
||||
/**
|
||||
* Format a CallSite file location to a string.
|
||||
*/
|
||||
|
||||
function callSiteFileLocation(callSite) {
|
||||
var fileName
|
||||
var fileLocation = ''
|
||||
|
||||
if (callSite.isNative()) {
|
||||
fileLocation = 'native'
|
||||
} else if (callSite.isEval()) {
|
||||
fileName = callSite.getScriptNameOrSourceURL()
|
||||
if (!fileName) {
|
||||
fileLocation = callSite.getEvalOrigin()
|
||||
}
|
||||
} else {
|
||||
fileName = callSite.getFileName()
|
||||
}
|
||||
|
||||
if (fileName) {
|
||||
fileLocation += fileName
|
||||
|
||||
var lineNumber = callSite.getLineNumber()
|
||||
if (lineNumber != null) {
|
||||
fileLocation += ':' + lineNumber
|
||||
|
||||
var columnNumber = callSite.getColumnNumber()
|
||||
if (columnNumber) {
|
||||
fileLocation += ':' + columnNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fileLocation || 'unknown source'
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a CallSite to a string.
|
||||
*/
|
||||
|
||||
function callSiteToString(callSite) {
|
||||
var addSuffix = true
|
||||
var fileLocation = callSiteFileLocation(callSite)
|
||||
var functionName = callSite.getFunctionName()
|
||||
var isConstructor = callSite.isConstructor()
|
||||
var isMethodCall = !(callSite.isToplevel() || isConstructor)
|
||||
var line = ''
|
||||
|
||||
if (isMethodCall) {
|
||||
var methodName = callSite.getMethodName()
|
||||
var typeName = getConstructorName(callSite)
|
||||
|
||||
if (functionName) {
|
||||
if (typeName && functionName.indexOf(typeName) !== 0) {
|
||||
line += typeName + '.'
|
||||
}
|
||||
|
||||
line += functionName
|
||||
|
||||
if (methodName && functionName.lastIndexOf('.' + methodName) !== functionName.length - methodName.length - 1) {
|
||||
line += ' [as ' + methodName + ']'
|
||||
}
|
||||
} else {
|
||||
line += typeName + '.' + (methodName || '<anonymous>')
|
||||
}
|
||||
} else if (isConstructor) {
|
||||
line += 'new ' + (functionName || '<anonymous>')
|
||||
} else if (functionName) {
|
||||
line += functionName
|
||||
} else {
|
||||
addSuffix = false
|
||||
line += fileLocation
|
||||
}
|
||||
|
||||
if (addSuffix) {
|
||||
line += ' (' + fileLocation + ')'
|
||||
}
|
||||
|
||||
return line
|
||||
}
|
||||
|
||||
/**
|
||||
* Get constructor name of reviver.
|
||||
*/
|
||||
|
||||
function getConstructorName(obj) {
|
||||
var receiver = obj.receiver
|
||||
return (receiver.constructor && receiver.constructor.name) || null
|
||||
}
|
||||
69
node_modules/express-session/node_modules/depd/lib/compat/index.js
generated
vendored
Normal file
69
node_modules/express-session/node_modules/depd/lib/compat/index.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
lazyProperty(module.exports, 'bufferConcat', function bufferConcat() {
|
||||
return Buffer.concat || require('./buffer-concat')
|
||||
})
|
||||
|
||||
lazyProperty(module.exports, 'callSiteToString', function callSiteToString() {
|
||||
var limit = Error.stackTraceLimit
|
||||
var obj = {}
|
||||
var prep = Error.prepareStackTrace
|
||||
|
||||
function prepareObjectStackTrace(obj, stack) {
|
||||
return stack
|
||||
}
|
||||
|
||||
Error.prepareStackTrace = prepareObjectStackTrace
|
||||
Error.stackTraceLimit = 2
|
||||
|
||||
// capture the stack
|
||||
Error.captureStackTrace(obj)
|
||||
|
||||
// slice the stack
|
||||
var stack = obj.stack.slice()
|
||||
|
||||
Error.prepareStackTrace = prep
|
||||
Error.stackTraceLimit = limit
|
||||
|
||||
return stack[0].toString ? toString : require('./callsite-tostring')
|
||||
})
|
||||
|
||||
/**
|
||||
* Define a lazy property.
|
||||
*/
|
||||
|
||||
function lazyProperty(obj, prop, getter) {
|
||||
function get() {
|
||||
var val = getter()
|
||||
|
||||
Object.defineProperty(obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: val
|
||||
})
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: get
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Call toString() on the obj
|
||||
*/
|
||||
|
||||
function toString(obj) {
|
||||
return obj.toString()
|
||||
}
|
||||
92
node_modules/express-session/node_modules/depd/package.json
generated
vendored
Normal file
92
node_modules/express-session/node_modules/depd/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"depd@~1.0.1",
|
||||
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/express-session"
|
||||
]
|
||||
],
|
||||
"_from": "depd@>=1.0.1 <1.1.0",
|
||||
"_id": "depd@1.0.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/express-session/depd",
|
||||
"_npmUser": {
|
||||
"email": "doug@somethingdoug.com",
|
||||
"name": "dougwilson"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "depd",
|
||||
"raw": "depd@~1.0.1",
|
||||
"rawSpec": "~1.0.1",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.1 <1.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express-session"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/depd/-/depd-1.0.1.tgz",
|
||||
"_shasum": "80aec64c9d6d97e65cc2a9caa93c0aa6abf73aaa",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "depd@~1.0.1",
|
||||
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/express-session",
|
||||
"author": {
|
||||
"email": "doug@somethingdoug.com",
|
||||
"name": "Douglas Christopher Wilson"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/dougwilson/nodejs-depd/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Deprecate all the things",
|
||||
"devDependencies": {
|
||||
"beautify-benchmark": "0.2.4",
|
||||
"benchmark": "1.0.0",
|
||||
"istanbul": "0.3.5",
|
||||
"mocha": "~1.21.5"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "80aec64c9d6d97e65cc2a9caa93c0aa6abf73aaa",
|
||||
"tarball": "http://registry.npmjs.org/depd/-/depd-1.0.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"History.md",
|
||||
"LICENSE",
|
||||
"Readme.md",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"gitHead": "769e0f8108463c35a6937a9d634ab19fee45100a",
|
||||
"homepage": "https://github.com/dougwilson/nodejs-depd",
|
||||
"keywords": [
|
||||
"deprecate",
|
||||
"deprecated"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"name": "depd",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dougwilson/nodejs-depd.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/index.js",
|
||||
"test": "mocha --reporter spec --bail test/",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/"
|
||||
},
|
||||
"version": "1.0.1"
|
||||
}
|
||||
117
node_modules/express-session/package.json
generated
vendored
Normal file
117
node_modules/express-session/package.json
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"express-session@1.11.3",
|
||||
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/mongo-express"
|
||||
]
|
||||
],
|
||||
"_from": "express-session@1.11.3",
|
||||
"_id": "express-session@1.11.3",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/express-session",
|
||||
"_npmUser": {
|
||||
"email": "doug@somethingdoug.com",
|
||||
"name": "dougwilson"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "express-session",
|
||||
"raw": "express-session@1.11.3",
|
||||
"rawSpec": "1.11.3",
|
||||
"scope": null,
|
||||
"spec": "1.11.3",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mongo-express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/express-session/-/express-session-1.11.3.tgz",
|
||||
"_shasum": "5cc98f3f5ff84ed835f91cbf0aabd0c7107400af",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "express-session@1.11.3",
|
||||
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/mongo-express",
|
||||
"author": {
|
||||
"email": "tj@vision-media.ca",
|
||||
"name": "TJ Holowaychuk",
|
||||
"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": "http://registry.npmjs.org/express-session/-/express-session-1.11.3.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"session/"
|
||||
],
|
||||
"gitHead": "64e2e7a2d21da881ea53ab984f9eff4be58d7caf",
|
||||
"homepage": "https://github.com/expressjs/session",
|
||||
"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": "ERROR: No README data found!",
|
||||
"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"
|
||||
}
|
||||
128
node_modules/express-session/session/cookie.js
generated
vendored
Normal file
128
node_modules/express-session/session/cookie.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
|
||||
/*!
|
||||
* Connect - session - Cookie
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var merge = require('utils-merge')
|
||||
, cookie = require('cookie');
|
||||
|
||||
/**
|
||||
* Initialize a new `Cookie` with the given `options`.
|
||||
*
|
||||
* @param {IncomingMessage} req
|
||||
* @param {Object} options
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var Cookie = module.exports = function Cookie(options) {
|
||||
this.path = '/';
|
||||
this.maxAge = null;
|
||||
this.httpOnly = true;
|
||||
if (options) merge(this, options);
|
||||
this.originalMaxAge = undefined == this.originalMaxAge
|
||||
? this.maxAge
|
||||
: this.originalMaxAge;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Prototype.
|
||||
*/
|
||||
|
||||
Cookie.prototype = {
|
||||
|
||||
/**
|
||||
* Set expires `date`.
|
||||
*
|
||||
* @param {Date} date
|
||||
* @api public
|
||||
*/
|
||||
|
||||
set expires(date) {
|
||||
this._expires = date;
|
||||
this.originalMaxAge = this.maxAge;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get expires `date`.
|
||||
*
|
||||
* @return {Date}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
get expires() {
|
||||
return this._expires;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set expires via max-age in `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @api public
|
||||
*/
|
||||
|
||||
set maxAge(ms) {
|
||||
this.expires = 'number' == typeof ms
|
||||
? new Date(Date.now() + ms)
|
||||
: ms;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get expires max-age in `ms`.
|
||||
*
|
||||
* @return {Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
get maxAge() {
|
||||
return this.expires instanceof Date
|
||||
? this.expires.valueOf() - Date.now()
|
||||
: this.expires;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return cookie data object.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
get data() {
|
||||
return {
|
||||
originalMaxAge: this.originalMaxAge
|
||||
, expires: this._expires
|
||||
, secure: this.secure
|
||||
, httpOnly: this.httpOnly
|
||||
, domain: this.domain
|
||||
, path: this.path
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a serialized cookie string.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
serialize: function(name, val){
|
||||
return cookie.serialize(name, val, this.data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return JSON representation of this cookie.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
toJSON: function(){
|
||||
return this.data;
|
||||
}
|
||||
};
|
||||
183
node_modules/express-session/session/memory.js
generated
vendored
Normal file
183
node_modules/express-session/session/memory.js
generated
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
/*!
|
||||
* express-session
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var Store = require('./store')
|
||||
var util = require('util')
|
||||
|
||||
/**
|
||||
* Shim setImmediate for node.js < 0.10
|
||||
* @private
|
||||
*/
|
||||
|
||||
/* istanbul ignore next */
|
||||
var defer = typeof setImmediate === 'function'
|
||||
? setImmediate
|
||||
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) }
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = MemoryStore
|
||||
|
||||
/**
|
||||
* A session store in memory.
|
||||
* @public
|
||||
*/
|
||||
|
||||
function MemoryStore() {
|
||||
Store.call(this)
|
||||
this.sessions = Object.create(null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from Store.
|
||||
*/
|
||||
|
||||
util.inherits(MemoryStore, Store)
|
||||
|
||||
/**
|
||||
* Get all active sessions.
|
||||
*
|
||||
* @param {function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
MemoryStore.prototype.all = function all(callback) {
|
||||
var sessionIds = Object.keys(this.sessions)
|
||||
var sessions = Object.create(null)
|
||||
|
||||
for (var i = 0; i < sessionIds.length; i++) {
|
||||
var sessionId = sessionIds[i]
|
||||
var session = getSession.call(this, sessionId)
|
||||
|
||||
if (session) {
|
||||
sessions[sessionId] = session;
|
||||
}
|
||||
}
|
||||
|
||||
callback && defer(callback, null, sessions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all sessions.
|
||||
*
|
||||
* @param {function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
MemoryStore.prototype.clear = function clear(callback) {
|
||||
this.sessions = Object.create(null)
|
||||
callback && defer(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the session associated with the given session ID.
|
||||
*
|
||||
* @param {string} sessionId
|
||||
* @public
|
||||
*/
|
||||
|
||||
MemoryStore.prototype.destroy = function destroy(sessionId, callback) {
|
||||
delete this.sessions[sessionId]
|
||||
callback && defer(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch session by the given session ID.
|
||||
*
|
||||
* @param {string} sessionId
|
||||
* @param {function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
MemoryStore.prototype.get = function get(sessionId, callback) {
|
||||
defer(callback, null, getSession.call(this, sessionId))
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit the given session associated with the given sessionId to the store.
|
||||
*
|
||||
* @param {string} sessionId
|
||||
* @param {object} session
|
||||
* @param {function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get number of active sessions.
|
||||
*
|
||||
* @param {function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
MemoryStore.prototype.length = function length(callback) {
|
||||
this.all(function (err, sessions) {
|
||||
if (err) return callback(err)
|
||||
callback(null, Object.keys(sessions).length)
|
||||
})
|
||||
}
|
||||
|
||||
MemoryStore.prototype.set = function set(sessionId, session, callback) {
|
||||
this.sessions[sessionId] = JSON.stringify(session)
|
||||
callback && defer(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* Touch the given session object associated with the given session ID.
|
||||
*
|
||||
* @param {string} sessionId
|
||||
* @param {object} session
|
||||
* @param {function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
MemoryStore.prototype.touch = function touch(sessionId, session, callback) {
|
||||
var currentSession = getSession.call(this, sessionId)
|
||||
|
||||
if (currentSession) {
|
||||
// update expiration
|
||||
currentSession.cookie = session.cookie
|
||||
this.sessions[sessionId] = JSON.stringify(currentSession)
|
||||
}
|
||||
|
||||
callback && defer(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session from the store.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getSession(sessionId) {
|
||||
var sess = this.sessions[sessionId]
|
||||
|
||||
if (!sess) {
|
||||
return
|
||||
}
|
||||
|
||||
// parse
|
||||
sess = JSON.parse(sess)
|
||||
|
||||
var expires = typeof sess.cookie.expires === 'string'
|
||||
? new Date(sess.cookie.expires)
|
||||
: sess.cookie.expires
|
||||
|
||||
// destroy expired session
|
||||
if (expires && expires <= Date.now()) {
|
||||
delete this.sessions[sessionId]
|
||||
return
|
||||
}
|
||||
|
||||
return sess
|
||||
}
|
||||
124
node_modules/express-session/session/session.js
generated
vendored
Normal file
124
node_modules/express-session/session/session.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
/*!
|
||||
* Connect - session - Session
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Expose Session.
|
||||
*/
|
||||
|
||||
module.exports = Session;
|
||||
|
||||
/**
|
||||
* Create a new `Session` with the given request and `data`.
|
||||
*
|
||||
* @param {IncomingRequest} req
|
||||
* @param {Object} data
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function Session(req, data) {
|
||||
Object.defineProperty(this, 'req', { value: req });
|
||||
Object.defineProperty(this, 'id', { value: req.sessionID });
|
||||
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
// merge data into this, ignoring prototype properties
|
||||
for (var prop in data) {
|
||||
if (!(prop in this)) {
|
||||
this[prop] = data[prop]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update reset `.cookie.maxAge` to prevent
|
||||
* the cookie from expiring when the
|
||||
* session is still active.
|
||||
*
|
||||
* @return {Session} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Session.prototype.touch = function(){
|
||||
return this.resetMaxAge();
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset `.maxAge` to `.originalMaxAge`.
|
||||
*
|
||||
* @return {Session} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Session.prototype.resetMaxAge = function(){
|
||||
this.cookie.maxAge = this.cookie.originalMaxAge;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Save the session data with optional callback `fn(err)`.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @return {Session} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Session.prototype.save = function(fn){
|
||||
this.req.sessionStore.set(this.id, this, fn || function(){});
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Re-loads the session data _without_ altering
|
||||
* the maxAge properties. Invokes the callback `fn(err)`,
|
||||
* after which time if no exception has occurred the
|
||||
* `req.session` property will be a new `Session` object,
|
||||
* although representing the same session.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @return {Session} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Session.prototype.reload = function(fn){
|
||||
var req = this.req
|
||||
, store = this.req.sessionStore;
|
||||
store.get(this.id, function(err, sess){
|
||||
if (err) return fn(err);
|
||||
if (!sess) return fn(new Error('failed to load session'));
|
||||
store.createSession(req, sess);
|
||||
fn();
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy `this` session.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @return {Session} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Session.prototype.destroy = function(fn){
|
||||
delete this.req.session;
|
||||
this.req.sessionStore.destroy(this.id, fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Regenerate this request's session.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @return {Session} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Session.prototype.regenerate = function(fn){
|
||||
this.req.sessionStore.regenerate(this.req, fn);
|
||||
return this;
|
||||
};
|
||||
84
node_modules/express-session/session/store.js
generated
vendored
Normal file
84
node_modules/express-session/session/store.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
/*!
|
||||
* Connect - session - Store
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
, Session = require('./session')
|
||||
, Cookie = require('./cookie');
|
||||
|
||||
/**
|
||||
* Initialize abstract `Store`.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var Store = module.exports = function Store(options){};
|
||||
|
||||
/**
|
||||
* Inherit from `EventEmitter.prototype`.
|
||||
*/
|
||||
|
||||
Store.prototype.__proto__ = EventEmitter.prototype;
|
||||
|
||||
/**
|
||||
* Re-generate the given requests's session.
|
||||
*
|
||||
* @param {IncomingRequest} req
|
||||
* @return {Function} fn
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Store.prototype.regenerate = function(req, fn){
|
||||
var self = this;
|
||||
this.destroy(req.sessionID, function(err){
|
||||
self.generate(req);
|
||||
fn(err);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Load a `Session` instance via the given `sid`
|
||||
* and invoke the callback `fn(err, sess)`.
|
||||
*
|
||||
* @param {String} sid
|
||||
* @param {Function} fn
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Store.prototype.load = function(sid, fn){
|
||||
var self = this;
|
||||
this.get(sid, function(err, sess){
|
||||
if (err) return fn(err);
|
||||
if (!sess) return fn();
|
||||
var req = { sessionID: sid, sessionStore: self };
|
||||
sess = self.createSession(req, sess);
|
||||
fn(null, sess);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create session from JSON `sess` data.
|
||||
*
|
||||
* @param {IncomingRequest} req
|
||||
* @param {Object} sess
|
||||
* @return {Session}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Store.prototype.createSession = function(req, sess){
|
||||
var expires = sess.cookie.expires
|
||||
, orig = sess.cookie.originalMaxAge;
|
||||
sess.cookie = new Cookie(sess.cookie);
|
||||
if ('string' == typeof expires) sess.cookie.expires = new Date(expires);
|
||||
sess.cookie.originalMaxAge = orig;
|
||||
req.session = new Session(req, sess);
|
||||
return req.session;
|
||||
};
|
||||
Reference in New Issue
Block a user