mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 05:52:02 +02:00
Initial commit
This commit is contained in:
183
node_modules/csurf/HISTORY.md
generated
vendored
Normal file
183
node_modules/csurf/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
1.11.0 / 2020-01-18
|
||||
===================
|
||||
|
||||
* deps: cookie@0.4.0
|
||||
- Add `SameSite=None` support
|
||||
* deps: http-errors@~1.7.3
|
||||
- deps: inherits@2.0.4
|
||||
|
||||
1.10.0 / 2019-04-22
|
||||
===================
|
||||
|
||||
* deps: csrf@3.1.0
|
||||
- Remove `base64-url` dependency
|
||||
- deps: tsscmp@1.0.6
|
||||
- deps: uid-safe@2.1.5
|
||||
* deps: http-errors@~1.7.2
|
||||
- Make `message` property enumerable for `HttpError`s
|
||||
- Set constructor name when possible
|
||||
- deps: depd@~1.1.2
|
||||
- deps: inherits@2.0.3
|
||||
- deps: setprototypeof@1.1.1
|
||||
- deps: statuses@'>= 1.5.0 < 2'
|
||||
* perf: remove argument reassignment
|
||||
* perf: use plain object for internal cookie options
|
||||
|
||||
1.9.0 / 2016-05-27
|
||||
==================
|
||||
|
||||
* Pass invalid csrf token error to `next()` instead of throwing
|
||||
* Pass misconfigured error to `next()` instead of throwing
|
||||
* Provide misconfigured error when using cookies without cookie-parser
|
||||
* deps: cookie@0.3.1
|
||||
- Add `sameSite` option
|
||||
- Fix cookie `Max-Age` to never be a floating point number
|
||||
- Improve error message when `expires` is not a `Date`
|
||||
- Throw better error for invalid argument to parse
|
||||
- Throw on invalid values provided to `serialize`
|
||||
- perf: enable strict mode
|
||||
- perf: hoist regular expression
|
||||
- perf: use for loop in parse
|
||||
- perf: use string concatination for serialization
|
||||
* deps: csrf@~3.0.3
|
||||
- Use `tsscmp` module for timing-safe token verification
|
||||
- deps: base64-url@1.2.2
|
||||
- deps: rndm@1.2.0
|
||||
- deps: uid-safe@2.1.1
|
||||
* deps: http-errors@~1.5.0
|
||||
- Add `HttpError` export, for `err instanceof createError.HttpError`
|
||||
- Support new code `421 Misdirected Request`
|
||||
- Use `setprototypeof` module to replace `__proto__` setting
|
||||
- deps: inherits@2.0.1
|
||||
- deps: statuses@'>= 1.3.0 < 2'
|
||||
- perf: enable strict mode
|
||||
* perf: enable strict mode
|
||||
* perf: remove argument reassignment
|
||||
|
||||
1.8.3 / 2015-06-10
|
||||
==================
|
||||
|
||||
* deps: cookie@0.1.3
|
||||
- Slight optimizations
|
||||
|
||||
1.8.2 / 2015-05-09
|
||||
==================
|
||||
|
||||
* deps: csrf@~3.0.0
|
||||
- deps: uid-safe@~2.0.0
|
||||
|
||||
1.8.1 / 2015-05-03
|
||||
==================
|
||||
|
||||
* deps: csrf@~2.0.7
|
||||
- Fix compatibility with `crypto.DEFAULT_ENCODING` global changes
|
||||
|
||||
1.8.0 / 2015-04-07
|
||||
==================
|
||||
|
||||
* Add `sessionKey` option
|
||||
|
||||
1.7.0 / 2015-02-15
|
||||
==================
|
||||
|
||||
* Accept `CSRF-Token` and `XSRF-Token` request headers
|
||||
* Default `cookie.path` to `'/'`, if using cookies
|
||||
* deps: cookie-signature@1.0.6
|
||||
* deps: csrf@~2.0.6
|
||||
- deps: base64-url@1.2.1
|
||||
- deps: uid-safe@~1.1.0
|
||||
* deps: http-errors@~1.3.1
|
||||
- Construct errors using defined constructors from `createError`
|
||||
- Fix error names that are not identifiers
|
||||
- Set a meaningful `name` property on constructed errors
|
||||
|
||||
1.6.6 / 2015-01-31
|
||||
==================
|
||||
|
||||
* deps: csrf@~2.0.5
|
||||
- deps: base64-url@1.2.0
|
||||
- deps: uid-safe@~1.0.3
|
||||
|
||||
1.6.5 / 2015-01-08
|
||||
==================
|
||||
|
||||
* deps: csrf@~2.0.4
|
||||
- deps: uid-safe@~1.0.2
|
||||
|
||||
1.6.4 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: csrf@~2.0.3
|
||||
- Slight speed improvement for `verify`
|
||||
- deps: base64-url@1.1.0
|
||||
- deps: rndm@~1.1.0
|
||||
* deps: http-errors@~1.2.8
|
||||
- Fix stack trace from exported function
|
||||
|
||||
1.6.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: csrf@~2.0.2
|
||||
- deps: scmp@1.0.0
|
||||
* deps: http-errors@~1.2.7
|
||||
- Remove duplicate line
|
||||
|
||||
1.6.2 / 2014-10-14
|
||||
==================
|
||||
|
||||
* Fix cookie name when using `cookie: true`
|
||||
* deps: http-errors@~1.2.6
|
||||
- Fix `expose` to be `true` for `ClientError` constructor
|
||||
- Use `inherits` instead of `util`
|
||||
- deps: statuses@1
|
||||
|
||||
1.6.1 / 2014-09-05
|
||||
==================
|
||||
|
||||
* deps: cookie-signature@1.0.5
|
||||
|
||||
1.6.0 / 2014-09-03
|
||||
==================
|
||||
|
||||
* Set `code` property on CSRF token errors
|
||||
|
||||
1.5.0 / 2014-08-24
|
||||
==================
|
||||
|
||||
* Add `ignoreMethods` option
|
||||
|
||||
1.4.1 / 2014-08-22
|
||||
==================
|
||||
|
||||
* Use `csrf-tokens` instead of `csrf`
|
||||
|
||||
1.4.0 / 2014-07-30
|
||||
==================
|
||||
|
||||
* Support changing `req.session` after `csurf` middleware
|
||||
- Calling `res.csrfToken()` after `req.session.destroy()` will now work
|
||||
|
||||
1.3.0 / 2014-07-03
|
||||
==================
|
||||
|
||||
* Add support for environments without `res.cookie` (connect@3)
|
||||
|
||||
1.2.2 / 2014-06-18
|
||||
==================
|
||||
|
||||
* deps: csrf-tokens@~2.0.0
|
||||
|
||||
1.2.1 / 2014-06-09
|
||||
==================
|
||||
|
||||
* Refactor to use `csrf-tokens` module
|
||||
|
||||
1.2.0 / 2014-05-13
|
||||
==================
|
||||
|
||||
* Add support for double-submit cookie
|
||||
|
||||
1.1.0 / 2014-04-06
|
||||
==================
|
||||
|
||||
* Add constant-time string compare
|
23
node_modules/csurf/LICENSE
generated
vendored
Normal file
23
node_modules/csurf/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2014-2016 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.
|
326
node_modules/csurf/README.md
generated
vendored
Normal file
326
node_modules/csurf/README.md
generated
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
# csurf
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][node-url]
|
||||
[![Build status][travis-image]][travis-url]
|
||||
[![Test coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Node.js [CSRF][wikipedia-csrf] protection middleware.
|
||||
|
||||
Requires either a session middleware or [cookie-parser](https://www.npmjs.com/package/cookie-parser) to be initialized first.
|
||||
|
||||
* If you are setting the ["cookie" option](#cookie) to a non-`false` value,
|
||||
then you must use [cookie-parser](https://www.npmjs.com/package/cookie-parser)
|
||||
before this module.
|
||||
* Otherwise, you must use a session middleware before this module. For example:
|
||||
- [express-session](https://www.npmjs.com/package/express-session)
|
||||
- [cookie-session](https://www.npmjs.com/package/cookie-session)
|
||||
|
||||
If you have questions on how this module is implemented, please read
|
||||
[Understanding CSRF](https://github.com/pillarjs/understanding-csrf).
|
||||
|
||||
## Installation
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install csurf
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```js
|
||||
var csurf = require('csurf')
|
||||
```
|
||||
|
||||
### csurf([options])
|
||||
|
||||
Create a middleware for CSRF token creation and validation. This middleware
|
||||
adds a `req.csrfToken()` function to make a token which should be added to
|
||||
requests which mutate state, within a hidden form field, query-string etc.
|
||||
This token is validated against the visitor's session or csrf cookie.
|
||||
|
||||
#### Options
|
||||
|
||||
The `csurf` function takes an optional `options` object that may contain
|
||||
any of the following keys:
|
||||
|
||||
##### cookie
|
||||
|
||||
Determines if the token secret for the user should be stored in a cookie
|
||||
or in `req.session`. Storing the token secret in a cookie implements
|
||||
the [double submit cookie pattern][owsap-csrf-double-submit].
|
||||
Defaults to `false`.
|
||||
|
||||
When set to `true` (or an object of options for the cookie), then the module
|
||||
changes behavior and no longer uses `req.session`. This means you _are no
|
||||
longer required to use a session middleware_. Instead, you do need to use the
|
||||
[cookie-parser](https://www.npmjs.com/package/cookie-parser) middleware in
|
||||
your app before this middleware.
|
||||
|
||||
When set to an object, cookie storage of the secret is enabled and the
|
||||
object contains options for this functionality (when set to `true`, the
|
||||
defaults for the options are used). The options may contain any of the
|
||||
following keys:
|
||||
|
||||
- `key` - the name of the cookie to use to store the token secret
|
||||
(defaults to `'_csrf'`).
|
||||
- `path` - the path of the cookie (defaults to `'/'`).
|
||||
- `signed` - indicates if the cookie should be signed (defaults to `false`).
|
||||
- `secure` - marks the cookie to be used with HTTPS only (defaults to
|
||||
`false`).
|
||||
- `maxAge` - the number of seconds after which the cookie will expire
|
||||
(defaults to session length).
|
||||
- `httpOnly` - flags the cookie to be accessible only by the web server
|
||||
(defaults to `false`).
|
||||
- `sameSite` - sets the same site policy for the cookie(defaults to
|
||||
`false`). This can be set to `'strict'`, `'lax'`, `'none'`, or `true`
|
||||
(which maps to `'strict'`).
|
||||
- `domain` - sets the domain the cookie is valid on(defaults to current
|
||||
domain).
|
||||
|
||||
##### ignoreMethods
|
||||
|
||||
An array of the methods for which CSRF token checking will disabled.
|
||||
Defaults to `['GET', 'HEAD', 'OPTIONS']`.
|
||||
|
||||
##### sessionKey
|
||||
|
||||
Determines what property ("key") on `req` the session object is located.
|
||||
Defaults to `'session'` (i.e. looks at `req.session`). The CSRF secret
|
||||
from this library is stored and read as `req[sessionKey].csrfSecret`.
|
||||
|
||||
If the ["cookie" option](#cookie) is not `false`, then this option does
|
||||
nothing.
|
||||
|
||||
##### value
|
||||
|
||||
Provide a function that the middleware will invoke to read the token from
|
||||
the request for validation. The function is called as `value(req)` and is
|
||||
expected to return the token as a string.
|
||||
|
||||
The default value is a function that reads the token from the following
|
||||
locations, in order:
|
||||
|
||||
- `req.body._csrf` - typically generated by the `body-parser` module.
|
||||
- `req.query._csrf` - a built-in from Express.js to read from the URL
|
||||
query string.
|
||||
- `req.headers['csrf-token']` - the `CSRF-Token` HTTP request header.
|
||||
- `req.headers['xsrf-token']` - the `XSRF-Token` HTTP request header.
|
||||
- `req.headers['x-csrf-token']` - the `X-CSRF-Token` HTTP request header.
|
||||
- `req.headers['x-xsrf-token']` - the `X-XSRF-Token` HTTP request header.
|
||||
|
||||
## Example
|
||||
|
||||
### Simple express example
|
||||
|
||||
The following is an example of some server-side code that generates a form
|
||||
that requires a CSRF token to post back.
|
||||
|
||||
```js
|
||||
var cookieParser = require('cookie-parser')
|
||||
var csrf = require('csurf')
|
||||
var bodyParser = require('body-parser')
|
||||
var express = require('express')
|
||||
|
||||
// setup route middlewares
|
||||
var csrfProtection = csrf({ cookie: true })
|
||||
var parseForm = bodyParser.urlencoded({ extended: false })
|
||||
|
||||
// create express app
|
||||
var app = express()
|
||||
|
||||
// parse cookies
|
||||
// we need this because "cookie" is true in csrfProtection
|
||||
app.use(cookieParser())
|
||||
|
||||
app.get('/form', csrfProtection, function (req, res) {
|
||||
// pass the csrfToken to the view
|
||||
res.render('send', { csrfToken: req.csrfToken() })
|
||||
})
|
||||
|
||||
app.post('/process', parseForm, csrfProtection, function (req, res) {
|
||||
res.send('data is being processed')
|
||||
})
|
||||
```
|
||||
|
||||
Inside the view (depending on your template language; handlebars-style
|
||||
is demonstrated here), set the `csrfToken` value as the value of a hidden
|
||||
input field named `_csrf`:
|
||||
|
||||
```html
|
||||
<form action="/process" method="POST">
|
||||
<input type="hidden" name="_csrf" value="{{csrfToken}}">
|
||||
|
||||
Favorite color: <input type="text" name="favoriteColor">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
```
|
||||
|
||||
#### Using AJAX
|
||||
|
||||
When accessing protected routes via ajax both the csrf token will need to be
|
||||
passed in the request. Typically this is done using a request header, as adding
|
||||
a request header can typically be done at a central location easily without
|
||||
payload modification.
|
||||
|
||||
The CSRF token is obtained from the `req.csrfToken()` call on the server-side.
|
||||
This token needs to be exposed to the client-side, typically by including it in
|
||||
the initial page content. One possibility is to store it in an HTML `<meta>` tag,
|
||||
where value can then be retrieved at the time of the request by JavaScript.
|
||||
|
||||
The following can be included in your view (handlebar example below), where the
|
||||
`csrfToken` value came from `req.csrfToken()`:
|
||||
|
||||
```html
|
||||
<meta name="csrf-token" content="{{csrfToken}}">
|
||||
```
|
||||
|
||||
The following is an example of using the
|
||||
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to post
|
||||
to the `/process` route with the CSRF token from the `<meta>` tag on the page:
|
||||
|
||||
<!-- eslint-env browser -->
|
||||
|
||||
```js
|
||||
// Read the CSRF token from the <meta> tag
|
||||
var token = document.querySelector('meta[name="csrf-token"]').getAttribute('content')
|
||||
|
||||
// Make a request using the Fetch API
|
||||
fetch('/process', {
|
||||
credentials: 'same-origin', // <-- includes cookies in the request
|
||||
headers: {
|
||||
'CSRF-Token': token // <-- is the csrf token as a header
|
||||
},
|
||||
method: 'POST',
|
||||
body: {
|
||||
favoriteColor: 'blue'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Single Page Application (SPA)
|
||||
|
||||
Many SPA frameworks like Angular have CSRF support built in automatically.
|
||||
Typically they will reflect the value from a specific cookie, like
|
||||
`XSRF-TOKEN` (which is the case for Angular).
|
||||
|
||||
To take advantage of this, set the value from `req.csrfToken()` in the cookie
|
||||
used by the SPA framework. This is only necessary to do on the route that
|
||||
renders the page (where `res.render` or `res.sendFile` is called in Express,
|
||||
for example).
|
||||
|
||||
The following is an example for Express of a typical SPA response:
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
app.all('*', function (req, res) {
|
||||
res.cookie('XSRF-TOKEN', req.csrfToken())
|
||||
res.render('index')
|
||||
})
|
||||
```
|
||||
|
||||
### Ignoring Routes
|
||||
|
||||
**Note** CSRF checks should only be disabled for requests that you expect to
|
||||
come from outside of your website. Do not disable CSRF checks for requests
|
||||
that you expect to only come from your website. An existing session, even if
|
||||
it belongs to an authenticated user, is not enough to protect against CSRF
|
||||
attacks.
|
||||
|
||||
The following is an example of how to order your routes so that certain endpoints
|
||||
do not check for a valid CSRF token.
|
||||
|
||||
```js
|
||||
var cookieParser = require('cookie-parser')
|
||||
var csrf = require('csurf')
|
||||
var bodyParser = require('body-parser')
|
||||
var express = require('express')
|
||||
|
||||
// create express app
|
||||
var app = express()
|
||||
|
||||
// create api router
|
||||
var api = createApiRouter()
|
||||
|
||||
// mount api before csrf is appended to the app stack
|
||||
app.use('/api', api)
|
||||
|
||||
// now add csrf and other middlewares, after the "/api" was mounted
|
||||
app.use(bodyParser.urlencoded({ extended: false }))
|
||||
app.use(cookieParser())
|
||||
app.use(csrf({ cookie: true }))
|
||||
|
||||
app.get('/form', function (req, res) {
|
||||
// pass the csrfToken to the view
|
||||
res.render('send', { csrfToken: req.csrfToken() })
|
||||
})
|
||||
|
||||
app.post('/process', function (req, res) {
|
||||
res.send('csrf was required to get here')
|
||||
})
|
||||
|
||||
function createApiRouter () {
|
||||
var router = new express.Router()
|
||||
|
||||
router.post('/getProfile', function (req, res) {
|
||||
res.send('no csrf to get here')
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
||||
```
|
||||
|
||||
### Custom error handling
|
||||
|
||||
When the CSRF token validation fails, an error is thrown that has
|
||||
`err.code === 'EBADCSRFTOKEN'`. This can be used to display custom
|
||||
error messages.
|
||||
|
||||
```js
|
||||
var bodyParser = require('body-parser')
|
||||
var cookieParser = require('cookie-parser')
|
||||
var csrf = require('csurf')
|
||||
var express = require('express')
|
||||
|
||||
var app = express()
|
||||
app.use(bodyParser.urlencoded({ extended: false }))
|
||||
app.use(cookieParser())
|
||||
app.use(csrf({ cookie: true }))
|
||||
|
||||
// error handler
|
||||
app.use(function (err, req, res, next) {
|
||||
if (err.code !== 'EBADCSRFTOKEN') return next(err)
|
||||
|
||||
// handle CSRF token errors here
|
||||
res.status(403)
|
||||
res.send('form tampered with')
|
||||
})
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [Cross-side request forgery on Wikipedia][wikipedia-csrf]
|
||||
- [OWASP Cross-Site Request Forgery Prevention Cheat Sheet][owsap-csrf]
|
||||
|
||||
[owsap-csrf]: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
|
||||
[owsap-csrf-double-submit]: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie
|
||||
[wikipedia-csrf]: https://en.wikipedia.org/wiki/Cross-site_request_forgery
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/csurf/master
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/csurf?branch=master
|
||||
[node-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/csurf
|
||||
[npm-url]: https://npmjs.org/package/csurf
|
||||
[npm-version-image]: https://badgen.net/npm/v/csurf
|
||||
[travis-image]: https://badgen.net/travis/expressjs/csurf/master
|
||||
[travis-url]: https://travis-ci.org/expressjs/csurf
|
297
node_modules/csurf/index.js
generated
vendored
Normal file
297
node_modules/csurf/index.js
generated
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
/*!
|
||||
* csurf
|
||||
* Copyright(c) 2011 Sencha Inc.
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var Cookie = require('cookie')
|
||||
var createError = require('http-errors')
|
||||
var sign = require('cookie-signature').sign
|
||||
var Tokens = require('csrf')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = csurf
|
||||
|
||||
/**
|
||||
* CSRF protection middleware.
|
||||
*
|
||||
* This middleware adds a `req.csrfToken()` function to make a token
|
||||
* which should be added to requests which mutate
|
||||
* state, within a hidden form field, query-string etc. This
|
||||
* token is validated against the visitor's session.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {Function} middleware
|
||||
* @public
|
||||
*/
|
||||
|
||||
function csurf (options) {
|
||||
var opts = options || {}
|
||||
|
||||
// get cookie options
|
||||
var cookie = getCookieOptions(opts.cookie)
|
||||
|
||||
// get session options
|
||||
var sessionKey = opts.sessionKey || 'session'
|
||||
|
||||
// get value getter
|
||||
var value = opts.value || defaultValue
|
||||
|
||||
// token repo
|
||||
var tokens = new Tokens(opts)
|
||||
|
||||
// ignored methods
|
||||
var ignoreMethods = opts.ignoreMethods === undefined
|
||||
? ['GET', 'HEAD', 'OPTIONS']
|
||||
: opts.ignoreMethods
|
||||
|
||||
if (!Array.isArray(ignoreMethods)) {
|
||||
throw new TypeError('option ignoreMethods must be an array')
|
||||
}
|
||||
|
||||
// generate lookup
|
||||
var ignoreMethod = getIgnoredMethods(ignoreMethods)
|
||||
|
||||
return function csrf (req, res, next) {
|
||||
// validate the configuration against request
|
||||
if (!verifyConfiguration(req, sessionKey, cookie)) {
|
||||
return next(new Error('misconfigured csrf'))
|
||||
}
|
||||
|
||||
// get the secret from the request
|
||||
var secret = getSecret(req, sessionKey, cookie)
|
||||
var token
|
||||
|
||||
// lazy-load token getter
|
||||
req.csrfToken = function csrfToken () {
|
||||
var sec = !cookie
|
||||
? getSecret(req, sessionKey, cookie)
|
||||
: secret
|
||||
|
||||
// use cached token if secret has not changed
|
||||
if (token && sec === secret) {
|
||||
return token
|
||||
}
|
||||
|
||||
// generate & set new secret
|
||||
if (sec === undefined) {
|
||||
sec = tokens.secretSync()
|
||||
setSecret(req, res, sessionKey, sec, cookie)
|
||||
}
|
||||
|
||||
// update changed secret
|
||||
secret = sec
|
||||
|
||||
// create new token
|
||||
token = tokens.create(secret)
|
||||
|
||||
return token
|
||||
}
|
||||
|
||||
// generate & set secret
|
||||
if (!secret) {
|
||||
secret = tokens.secretSync()
|
||||
setSecret(req, res, sessionKey, secret, cookie)
|
||||
}
|
||||
|
||||
// verify the incoming token
|
||||
if (!ignoreMethod[req.method] && !tokens.verify(secret, value(req))) {
|
||||
return next(createError(403, 'invalid csrf token', {
|
||||
code: 'EBADCSRFTOKEN'
|
||||
}))
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default value function, checking the `req.body`
|
||||
* and `req.query` for the CSRF token.
|
||||
*
|
||||
* @param {IncomingMessage} req
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function defaultValue (req) {
|
||||
return (req.body && req.body._csrf) ||
|
||||
(req.query && req.query._csrf) ||
|
||||
(req.headers['csrf-token']) ||
|
||||
(req.headers['xsrf-token']) ||
|
||||
(req.headers['x-csrf-token']) ||
|
||||
(req.headers['x-xsrf-token'])
|
||||
}
|
||||
|
||||
/**
|
||||
* Get options for cookie.
|
||||
*
|
||||
* @param {boolean|object} [options]
|
||||
* @returns {object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getCookieOptions (options) {
|
||||
if (options !== true && typeof options !== 'object') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var opts = Object.create(null)
|
||||
|
||||
// defaults
|
||||
opts.key = '_csrf'
|
||||
opts.path = '/'
|
||||
|
||||
if (options && typeof options === 'object') {
|
||||
for (var prop in options) {
|
||||
var val = options[prop]
|
||||
|
||||
if (val !== undefined) {
|
||||
opts[prop] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return opts
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a lookup of ignored methods.
|
||||
*
|
||||
* @param {array} methods
|
||||
* @returns {object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getIgnoredMethods (methods) {
|
||||
var obj = Object.create(null)
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
var method = methods[i].toUpperCase()
|
||||
obj[method] = true
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token secret from the request.
|
||||
*
|
||||
* @param {IncomingMessage} req
|
||||
* @param {String} sessionKey
|
||||
* @param {Object} [cookie]
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getSecret (req, sessionKey, cookie) {
|
||||
// get the bag & key
|
||||
var bag = getSecretBag(req, sessionKey, cookie)
|
||||
var key = cookie ? cookie.key : 'csrfSecret'
|
||||
|
||||
if (!bag) {
|
||||
throw new Error('misconfigured csrf')
|
||||
}
|
||||
|
||||
// return secret from bag
|
||||
return bag[key]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token secret bag from the request.
|
||||
*
|
||||
* @param {IncomingMessage} req
|
||||
* @param {String} sessionKey
|
||||
* @param {Object} [cookie]
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getSecretBag (req, sessionKey, cookie) {
|
||||
if (cookie) {
|
||||
// get secret from cookie
|
||||
var cookieKey = cookie.signed
|
||||
? 'signedCookies'
|
||||
: 'cookies'
|
||||
|
||||
return req[cookieKey]
|
||||
} else {
|
||||
// get secret from session
|
||||
return req[sessionKey]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a cookie on the HTTP response.
|
||||
*
|
||||
* @param {OutgoingMessage} res
|
||||
* @param {string} name
|
||||
* @param {string} val
|
||||
* @param {Object} [options]
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function setCookie (res, name, val, options) {
|
||||
var data = Cookie.serialize(name, val, options)
|
||||
|
||||
var prev = res.getHeader('set-cookie') || []
|
||||
var header = Array.isArray(prev) ? prev.concat(data)
|
||||
: [prev, data]
|
||||
|
||||
res.setHeader('set-cookie', header)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the token secret on the request.
|
||||
*
|
||||
* @param {IncomingMessage} req
|
||||
* @param {OutgoingMessage} res
|
||||
* @param {string} sessionKey
|
||||
* @param {string} val
|
||||
* @param {Object} [cookie]
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function setSecret (req, res, sessionKey, val, cookie) {
|
||||
if (cookie) {
|
||||
// set secret on cookie
|
||||
var value = val
|
||||
|
||||
if (cookie.signed) {
|
||||
value = 's:' + sign(val, req.secret)
|
||||
}
|
||||
|
||||
setCookie(res, cookie.key, value, cookie)
|
||||
} else {
|
||||
// set secret on session
|
||||
req[sessionKey].csrfSecret = val
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the configuration against the request.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function verifyConfiguration (req, sessionKey, cookie) {
|
||||
if (!getSecretBag(req, sessionKey, cookie)) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (cookie && cookie.signed && !req.secret) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
123
node_modules/csurf/node_modules/cookie/HISTORY.md
generated
vendored
Normal file
123
node_modules/csurf/node_modules/cookie/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
0.4.0 / 2019-05-15
|
||||
==================
|
||||
|
||||
* Add `SameSite=None` support
|
||||
|
||||
0.3.1 / 2016-05-26
|
||||
==================
|
||||
|
||||
* Fix `sameSite: true` to work with draft-7 clients
|
||||
- `true` now sends `SameSite=Strict` instead of `SameSite`
|
||||
|
||||
0.3.0 / 2016-05-26
|
||||
==================
|
||||
|
||||
* Add `sameSite` option
|
||||
- Replaces `firstPartyOnly` option, never implemented by browsers
|
||||
* Improve error message when `encode` is not a function
|
||||
* Improve error message when `expires` is not a `Date`
|
||||
|
||||
0.2.4 / 2016-05-20
|
||||
==================
|
||||
|
||||
* perf: enable strict mode
|
||||
* perf: use for loop in parse
|
||||
* perf: use string concatination for serialization
|
||||
|
||||
0.2.3 / 2015-10-25
|
||||
==================
|
||||
|
||||
* Fix cookie `Max-Age` to never be a floating point number
|
||||
|
||||
0.2.2 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Fix regression when setting empty cookie value
|
||||
- Ease the new restriction, which is just basic header-level validation
|
||||
* Fix typo in invalid value errors
|
||||
|
||||
0.2.1 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Throw on invalid values provided to `serialize`
|
||||
- Ensures the resulting string is a valid HTTP header value
|
||||
|
||||
0.2.0 / 2015-08-13
|
||||
==================
|
||||
|
||||
* Add `firstPartyOnly` option
|
||||
* Throw better error for invalid argument to parse
|
||||
* perf: hoist regular expression
|
||||
|
||||
0.1.5 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Fix regression when setting empty cookie value
|
||||
- Ease the new restriction, which is just basic header-level validation
|
||||
* Fix typo in invalid value errors
|
||||
|
||||
0.1.4 / 2015-09-17
|
||||
==================
|
||||
|
||||
* Throw better error for invalid argument to parse
|
||||
* Throw on invalid values provided to `serialize`
|
||||
- Ensures the resulting string is a valid HTTP header value
|
||||
|
||||
0.1.3 / 2015-05-19
|
||||
==================
|
||||
|
||||
* Reduce the scope of try-catch deopt
|
||||
* Remove argument reassignments
|
||||
|
||||
0.1.2 / 2014-04-16
|
||||
==================
|
||||
|
||||
* Remove unnecessary files from npm package
|
||||
|
||||
0.1.1 / 2014-02-23
|
||||
==================
|
||||
|
||||
* Fix bad parse when cookie value contained a comma
|
||||
* Fix support for `maxAge` of `0`
|
||||
|
||||
0.1.0 / 2013-05-01
|
||||
==================
|
||||
|
||||
* Add `decode` option
|
||||
* Add `encode` option
|
||||
|
||||
0.0.6 / 2013-04-08
|
||||
==================
|
||||
|
||||
* Ignore cookie parts missing `=`
|
||||
|
||||
0.0.5 / 2012-10-29
|
||||
==================
|
||||
|
||||
* Return raw cookie value if value unescape errors
|
||||
|
||||
0.0.4 / 2012-06-21
|
||||
==================
|
||||
|
||||
* Use encode/decodeURIComponent for cookie encoding/decoding
|
||||
- Improve server/client interoperability
|
||||
|
||||
0.0.3 / 2012-06-06
|
||||
==================
|
||||
|
||||
* Only escape special characters per the cookie RFC
|
||||
|
||||
0.0.2 / 2012-06-01
|
||||
==================
|
||||
|
||||
* Fix `maxAge` option to not throw error
|
||||
|
||||
0.0.1 / 2012-05-28
|
||||
==================
|
||||
|
||||
* Add more tests
|
||||
|
||||
0.0.0 / 2012-05-28
|
||||
==================
|
||||
|
||||
* Initial release
|
24
node_modules/csurf/node_modules/cookie/LICENSE
generated
vendored
Normal file
24
node_modules/csurf/node_modules/cookie/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com>
|
||||
Copyright (c) 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.
|
||||
|
253
node_modules/csurf/node_modules/cookie/README.md
generated
vendored
Normal file
253
node_modules/csurf/node_modules/cookie/README.md
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
# cookie
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Basic HTTP cookie parser and serializer for HTTP servers.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install cookie
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var cookie = require('cookie');
|
||||
```
|
||||
|
||||
### cookie.parse(str, options)
|
||||
|
||||
Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs.
|
||||
The `str` argument is the string representing a `Cookie` header value and `options` is an
|
||||
optional object containing additional parsing options.
|
||||
|
||||
```js
|
||||
var cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2');
|
||||
// { foo: 'bar', equation: 'E=mc^2' }
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
`cookie.parse` accepts these properties in the options object.
|
||||
|
||||
##### decode
|
||||
|
||||
Specifies a function that will be used to decode a cookie's value. Since the value of a cookie
|
||||
has a limited character set (and must be a simple string), this function can be used to decode
|
||||
a previously-encoded cookie value into a JavaScript string or other object.
|
||||
|
||||
The default function is the global `decodeURIComponent`, which will decode any URL-encoded
|
||||
sequences into their byte representations.
|
||||
|
||||
**note** if an error is thrown from this function, the original, non-decoded cookie value will
|
||||
be returned as the cookie's value.
|
||||
|
||||
### cookie.serialize(name, value, options)
|
||||
|
||||
Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the
|
||||
name for the cookie, the `value` argument is the value to set the cookie to, and the `options`
|
||||
argument is an optional object containing additional serialization options.
|
||||
|
||||
```js
|
||||
var setCookie = cookie.serialize('foo', 'bar');
|
||||
// foo=bar
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
`cookie.serialize` accepts these properties in the options object.
|
||||
|
||||
##### domain
|
||||
|
||||
Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6265-5.2.3]. By default, no
|
||||
domain is set, and most clients will consider the cookie to apply to only the current domain.
|
||||
|
||||
##### encode
|
||||
|
||||
Specifies a function that will be used to encode a cookie's value. Since value of a cookie
|
||||
has a limited character set (and must be a simple string), this function can be used to encode
|
||||
a value into a string suited for a cookie's value.
|
||||
|
||||
The default function is the global `encodeURIComponent`, which will encode a JavaScript string
|
||||
into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
|
||||
|
||||
##### expires
|
||||
|
||||
Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6265-5.2.1].
|
||||
By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and
|
||||
will delete it on a condition like exiting a web browser application.
|
||||
|
||||
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
|
||||
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
##### httpOnly
|
||||
|
||||
Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6265-5.2.6]. When truthy,
|
||||
the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.
|
||||
|
||||
**note** be careful when setting this to `true`, as compliant clients will not allow client-side
|
||||
JavaScript to see the cookie in `document.cookie`.
|
||||
|
||||
##### maxAge
|
||||
|
||||
Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6265-5.2.2].
|
||||
The given number will be converted to an integer by rounding down. By default, no maximum age is set.
|
||||
|
||||
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
|
||||
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
##### path
|
||||
|
||||
Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path
|
||||
is considered the ["default path"][rfc-6265-5.1.4].
|
||||
|
||||
##### sameSite
|
||||
|
||||
Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-03-4.1.2.7].
|
||||
|
||||
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
- `false` will not set the `SameSite` attribute.
|
||||
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
||||
- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
||||
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
|
||||
More information about the different enforcement levels can be found in
|
||||
[the specification][rfc-6265bis-03-4.1.2.7].
|
||||
|
||||
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
|
||||
This also means many clients may ignore this attribute until they understand it.
|
||||
|
||||
##### secure
|
||||
|
||||
Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6265-5.2.5]. When truthy,
|
||||
the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
|
||||
|
||||
**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to
|
||||
the server in the future if the browser does not have an HTTPS connection.
|
||||
|
||||
## Example
|
||||
|
||||
The following example uses this module in conjunction with the Node.js core HTTP server
|
||||
to prompt a user for their name and display it back on future visits.
|
||||
|
||||
```js
|
||||
var cookie = require('cookie');
|
||||
var escapeHtml = require('escape-html');
|
||||
var http = require('http');
|
||||
var url = require('url');
|
||||
|
||||
function onRequest(req, res) {
|
||||
// Parse the query string
|
||||
var query = url.parse(req.url, true, true).query;
|
||||
|
||||
if (query && query.name) {
|
||||
// Set a new cookie with the name
|
||||
res.setHeader('Set-Cookie', cookie.serialize('name', String(query.name), {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7 // 1 week
|
||||
}));
|
||||
|
||||
// Redirect back after setting cookie
|
||||
res.statusCode = 302;
|
||||
res.setHeader('Location', req.headers.referer || '/');
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse the cookies on the request
|
||||
var cookies = cookie.parse(req.headers.cookie || '');
|
||||
|
||||
// Get the visitor name set in the cookie
|
||||
var name = cookies.name;
|
||||
|
||||
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
|
||||
|
||||
if (name) {
|
||||
res.write('<p>Welcome back, <b>' + escapeHtml(name) + '</b>!</p>');
|
||||
} else {
|
||||
res.write('<p>Hello, new visitor!</p>');
|
||||
}
|
||||
|
||||
res.write('<form method="GET">');
|
||||
res.write('<input placeholder="enter your name" name="name"> <input type="submit" value="Set Name">');
|
||||
res.end('</form>');
|
||||
}
|
||||
|
||||
http.createServer(onRequest).listen(3000);
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## Benchmark
|
||||
|
||||
```
|
||||
$ npm run bench
|
||||
|
||||
> cookie@0.3.1 bench cookie
|
||||
> node benchmark/index.js
|
||||
|
||||
http_parser@2.8.0
|
||||
node@6.14.2
|
||||
v8@5.1.281.111
|
||||
uv@1.16.1
|
||||
zlib@1.2.11
|
||||
ares@1.10.1-DEV
|
||||
icu@58.2
|
||||
modules@48
|
||||
napi@3
|
||||
openssl@1.0.2o
|
||||
|
||||
> node benchmark/parse.js
|
||||
|
||||
cookie.parse
|
||||
|
||||
6 tests completed.
|
||||
|
||||
simple x 1,200,691 ops/sec ±1.12% (189 runs sampled)
|
||||
decode x 1,012,994 ops/sec ±0.97% (186 runs sampled)
|
||||
unquote x 1,074,174 ops/sec ±2.43% (186 runs sampled)
|
||||
duplicates x 438,424 ops/sec ±2.17% (184 runs sampled)
|
||||
10 cookies x 147,154 ops/sec ±1.01% (186 runs sampled)
|
||||
100 cookies x 14,274 ops/sec ±1.07% (187 runs sampled)
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [RFC 6265: HTTP State Management Mechanism][rfc-6265]
|
||||
- [Same-site Cookies][rfc-6265bis-03-4.1.2.7]
|
||||
|
||||
[rfc-6265bis-03-4.1.2.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
|
||||
[rfc-6265]: https://tools.ietf.org/html/rfc6265
|
||||
[rfc-6265-5.1.4]: https://tools.ietf.org/html/rfc6265#section-5.1.4
|
||||
[rfc-6265-5.2.1]: https://tools.ietf.org/html/rfc6265#section-5.2.1
|
||||
[rfc-6265-5.2.2]: https://tools.ietf.org/html/rfc6265#section-5.2.2
|
||||
[rfc-6265-5.2.3]: https://tools.ietf.org/html/rfc6265#section-5.2.3
|
||||
[rfc-6265-5.2.4]: https://tools.ietf.org/html/rfc6265#section-5.2.4
|
||||
[rfc-6265-5.2.5]: https://tools.ietf.org/html/rfc6265#section-5.2.5
|
||||
[rfc-6265-5.2.6]: https://tools.ietf.org/html/rfc6265#section-5.2.6
|
||||
[rfc-6265-5.3]: https://tools.ietf.org/html/rfc6265#section-5.3
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/cookie/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master
|
||||
[node-version-image]: https://badgen.net/npm/node/cookie
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/cookie
|
||||
[npm-url]: https://npmjs.org/package/cookie
|
||||
[npm-version-image]: https://badgen.net/npm/v/cookie
|
||||
[travis-image]: https://badgen.net/travis/jshttp/cookie/master
|
||||
[travis-url]: https://travis-ci.org/jshttp/cookie
|
198
node_modules/csurf/node_modules/cookie/index.js
generated
vendored
Normal file
198
node_modules/csurf/node_modules/cookie/index.js
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
/*!
|
||||
* cookie
|
||||
* Copyright(c) 2012-2014 Roman Shtylman
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports.parse = parse;
|
||||
exports.serialize = serialize;
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var decode = decodeURIComponent;
|
||||
var encode = encodeURIComponent;
|
||||
var pairSplitRegExp = /; */;
|
||||
|
||||
/**
|
||||
* RegExp to match field-content in RFC 7230 sec 3.2
|
||||
*
|
||||
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
||||
* field-vchar = VCHAR / obs-text
|
||||
* obs-text = %x80-FF
|
||||
*/
|
||||
|
||||
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
||||
|
||||
/**
|
||||
* 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 {object}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function parse(str, options) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('argument str must be a string');
|
||||
}
|
||||
|
||||
var obj = {}
|
||||
var opt = options || {};
|
||||
var pairs = str.split(pairSplitRegExp);
|
||||
var dec = opt.decode || decode;
|
||||
|
||||
for (var i = 0; i < pairs.length; i++) {
|
||||
var pair = pairs[i];
|
||||
var eq_idx = pair.indexOf('=');
|
||||
|
||||
// skip things that don't look like key=value
|
||||
if (eq_idx < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (typeof enc !== 'function') {
|
||||
throw new TypeError('option encode is invalid');
|
||||
}
|
||||
|
||||
if (!fieldContentRegExp.test(name)) {
|
||||
throw new TypeError('argument name is invalid');
|
||||
}
|
||||
|
||||
var value = enc(val);
|
||||
|
||||
if (value && !fieldContentRegExp.test(value)) {
|
||||
throw new TypeError('argument val is invalid');
|
||||
}
|
||||
|
||||
var str = name + '=' + value;
|
||||
|
||||
if (null != opt.maxAge) {
|
||||
var maxAge = opt.maxAge - 0;
|
||||
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
||||
str += '; Max-Age=' + Math.floor(maxAge);
|
||||
}
|
||||
|
||||
if (opt.domain) {
|
||||
if (!fieldContentRegExp.test(opt.domain)) {
|
||||
throw new TypeError('option domain is invalid');
|
||||
}
|
||||
|
||||
str += '; Domain=' + opt.domain;
|
||||
}
|
||||
|
||||
if (opt.path) {
|
||||
if (!fieldContentRegExp.test(opt.path)) {
|
||||
throw new TypeError('option path is invalid');
|
||||
}
|
||||
|
||||
str += '; Path=' + opt.path;
|
||||
}
|
||||
|
||||
if (opt.expires) {
|
||||
if (typeof opt.expires.toUTCString !== 'function') {
|
||||
throw new TypeError('option expires is invalid');
|
||||
}
|
||||
|
||||
str += '; Expires=' + opt.expires.toUTCString();
|
||||
}
|
||||
|
||||
if (opt.httpOnly) {
|
||||
str += '; HttpOnly';
|
||||
}
|
||||
|
||||
if (opt.secure) {
|
||||
str += '; Secure';
|
||||
}
|
||||
|
||||
if (opt.sameSite) {
|
||||
var sameSite = typeof opt.sameSite === 'string'
|
||||
? opt.sameSite.toLowerCase() : opt.sameSite;
|
||||
|
||||
switch (sameSite) {
|
||||
case true:
|
||||
str += '; SameSite=Strict';
|
||||
break;
|
||||
case 'lax':
|
||||
str += '; SameSite=Lax';
|
||||
break;
|
||||
case 'strict':
|
||||
str += '; SameSite=Strict';
|
||||
break;
|
||||
case 'none':
|
||||
str += '; SameSite=None';
|
||||
break;
|
||||
default:
|
||||
throw new TypeError('option sameSite is invalid');
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
78
node_modules/csurf/node_modules/cookie/package.json
generated
vendored
Normal file
78
node_modules/csurf/node_modules/cookie/package.json
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"_from": "cookie@0.4.0",
|
||||
"_id": "cookie@0.4.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==",
|
||||
"_location": "/csurf/cookie",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "cookie@0.4.0",
|
||||
"name": "cookie",
|
||||
"escapedName": "cookie",
|
||||
"rawSpec": "0.4.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.4.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/csurf"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
|
||||
"_shasum": "beb437e7022b3b6d49019d088665303ebe9c14ba",
|
||||
"_spec": "cookie@0.4.0",
|
||||
"_where": "/home/runner/Socketio-Chat-Template/node_modules/csurf",
|
||||
"author": {
|
||||
"name": "Roman Shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/cookie/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"description": "HTTP server cookie parsing and serialization",
|
||||
"devDependencies": {
|
||||
"beautify-benchmark": "0.2.4",
|
||||
"benchmark": "2.1.4",
|
||||
"eslint": "5.16.0",
|
||||
"eslint-plugin-markdown": "1.0.0",
|
||||
"istanbul": "0.4.5",
|
||||
"mocha": "6.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/jshttp/cookie#readme",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"cookies"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "cookie",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jshttp/cookie.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/index.js",
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"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": "node scripts/version-history.js && git add HISTORY.md"
|
||||
},
|
||||
"version": "0.4.0"
|
||||
}
|
154
node_modules/csurf/node_modules/http-errors/HISTORY.md
generated
vendored
Normal file
154
node_modules/csurf/node_modules/http-errors/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
2019-06-24 / 1.7.3
|
||||
==================
|
||||
|
||||
* deps: inherits@2.0.4
|
||||
|
||||
2019-02-18 / 1.7.2
|
||||
==================
|
||||
|
||||
* deps: setprototypeof@1.1.1
|
||||
|
||||
2018-09-08 / 1.7.1
|
||||
==================
|
||||
|
||||
* Fix error creating objects in some environments
|
||||
|
||||
2018-07-30 / 1.7.0
|
||||
==================
|
||||
|
||||
* Set constructor name when possible
|
||||
* Use `toidentifier` module to make class names
|
||||
* deps: statuses@'>= 1.5.0 < 2'
|
||||
|
||||
2018-03-29 / 1.6.3
|
||||
==================
|
||||
|
||||
* deps: depd@~1.1.2
|
||||
- perf: remove argument reassignment
|
||||
* deps: setprototypeof@1.1.0
|
||||
* deps: statuses@'>= 1.4.0 < 2'
|
||||
|
||||
2017-08-04 / 1.6.2
|
||||
==================
|
||||
|
||||
* deps: depd@1.1.1
|
||||
- Remove unnecessary `Buffer` loading
|
||||
|
||||
2017-02-20 / 1.6.1
|
||||
==================
|
||||
|
||||
* deps: setprototypeof@1.0.3
|
||||
- Fix shim for old browsers
|
||||
|
||||
2017-02-14 / 1.6.0
|
||||
==================
|
||||
|
||||
* Accept custom 4xx and 5xx status codes in factory
|
||||
* Add deprecation message to `"I'mateapot"` export
|
||||
* Deprecate passing status code as anything except first argument in factory
|
||||
* Deprecate using non-error status codes
|
||||
* Make `message` property enumerable for `HttpError`s
|
||||
|
||||
2016-11-16 / 1.5.1
|
||||
==================
|
||||
|
||||
* deps: inherits@2.0.3
|
||||
- Fix issue loading in browser
|
||||
* deps: setprototypeof@1.0.2
|
||||
* deps: statuses@'>= 1.3.1 < 2'
|
||||
|
||||
2016-05-18 / 1.5.0
|
||||
==================
|
||||
|
||||
* Support new code `421 Misdirected Request`
|
||||
* Use `setprototypeof` module to replace `__proto__` setting
|
||||
* deps: statuses@'>= 1.3.0 < 2'
|
||||
- Add `421 Misdirected Request`
|
||||
- perf: enable strict mode
|
||||
* perf: enable strict mode
|
||||
|
||||
2016-01-28 / 1.4.0
|
||||
==================
|
||||
|
||||
* Add `HttpError` export, for `err instanceof createError.HttpError`
|
||||
* deps: inherits@2.0.1
|
||||
* deps: statuses@'>= 1.2.1 < 2'
|
||||
- Fix message for status 451
|
||||
- Remove incorrect nginx status code
|
||||
|
||||
2015-02-02 / 1.3.1
|
||||
==================
|
||||
|
||||
* Fix regression where status can be overwritten in `createError` `props`
|
||||
|
||||
2015-02-01 / 1.3.0
|
||||
==================
|
||||
|
||||
* Construct errors using defined constructors from `createError`
|
||||
* Fix error names that are not identifiers
|
||||
- `createError["I'mateapot"]` is now `createError.ImATeapot`
|
||||
* Set a meaningful `name` property on constructed errors
|
||||
|
||||
2014-12-09 / 1.2.8
|
||||
==================
|
||||
|
||||
* Fix stack trace from exported function
|
||||
* Remove `arguments.callee` usage
|
||||
|
||||
2014-10-14 / 1.2.7
|
||||
==================
|
||||
|
||||
* Remove duplicate line
|
||||
|
||||
2014-10-02 / 1.2.6
|
||||
==================
|
||||
|
||||
* Fix `expose` to be `true` for `ClientError` constructor
|
||||
|
||||
2014-09-28 / 1.2.5
|
||||
==================
|
||||
|
||||
* deps: statuses@1
|
||||
|
||||
2014-09-21 / 1.2.4
|
||||
==================
|
||||
|
||||
* Fix dependency version to work with old `npm`s
|
||||
|
||||
2014-09-21 / 1.2.3
|
||||
==================
|
||||
|
||||
* deps: statuses@~1.1.0
|
||||
|
||||
2014-09-21 / 1.2.2
|
||||
==================
|
||||
|
||||
* Fix publish error
|
||||
|
||||
2014-09-21 / 1.2.1
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
* Use `inherits` instead of `util`
|
||||
|
||||
2014-09-09 / 1.2.0
|
||||
==================
|
||||
|
||||
* Fix the way inheriting functions
|
||||
* Support `expose` being provided in properties argument
|
||||
|
||||
2014-09-08 / 1.1.0
|
||||
==================
|
||||
|
||||
* Default status to 500
|
||||
* Support provided `error` to extend
|
||||
|
||||
2014-09-08 / 1.0.1
|
||||
==================
|
||||
|
||||
* Fix accepting string message
|
||||
|
||||
2014-09-08 / 1.0.0
|
||||
==================
|
||||
|
||||
* Initial release
|
23
node_modules/csurf/node_modules/http-errors/LICENSE
generated
vendored
Normal file
23
node_modules/csurf/node_modules/http-errors/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
||||
Copyright (c) 2016 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.
|
163
node_modules/csurf/node_modules/http-errors/README.md
generated
vendored
Normal file
163
node_modules/csurf/node_modules/http-errors/README.md
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
# http-errors
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][node-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Create HTTP errors for Express, Koa, Connect, etc. with ease.
|
||||
|
||||
## Install
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```bash
|
||||
$ npm install http-errors
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var createError = require('http-errors')
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
if (!req.user) return next(createError(401, 'Please login to view this page.'))
|
||||
next()
|
||||
})
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This is the current API, currently extracted from Koa and subject to change.
|
||||
|
||||
### Error Properties
|
||||
|
||||
- `expose` - can be used to signal if `message` should be sent to the client,
|
||||
defaulting to `false` when `status` >= 500
|
||||
- `headers` - can be an object of header names to values to be sent to the
|
||||
client, defaulting to `undefined`. When defined, the key names should all
|
||||
be lower-cased
|
||||
- `message` - the traditional error message, which should be kept short and all
|
||||
single line
|
||||
- `status` - the status code of the error, mirroring `statusCode` for general
|
||||
compatibility
|
||||
- `statusCode` - the status code of the error, defaulting to `500`
|
||||
|
||||
### createError([status], [message], [properties])
|
||||
|
||||
Create a new error object with the given message `msg`.
|
||||
The error object inherits from `createError.HttpError`.
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-vars -->
|
||||
|
||||
```js
|
||||
var err = createError(404, 'This video does not exist!')
|
||||
```
|
||||
|
||||
- `status: 500` - the status code as a number
|
||||
- `message` - the message of the error, defaulting to node's text for that status code.
|
||||
- `properties` - custom properties to attach to the object
|
||||
|
||||
### createError([status], [error], [properties])
|
||||
|
||||
Extend the given `error` object with `createError.HttpError`
|
||||
properties. This will not alter the inheritance of the given
|
||||
`error` object, and the modified `error` object is the
|
||||
return value.
|
||||
|
||||
<!-- eslint-disable no-redeclare, no-undef, no-unused-vars -->
|
||||
|
||||
```js
|
||||
fs.readFile('foo.txt', function (err, buf) {
|
||||
if (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
var httpError = createError(404, err, { expose: false })
|
||||
} else {
|
||||
var httpError = createError(500, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
- `status` - the status code as a number
|
||||
- `error` - the error object to extend
|
||||
- `properties` - custom properties to attach to the object
|
||||
|
||||
### new createError\[code || name\](\[msg]\))
|
||||
|
||||
Create a new error object with the given message `msg`.
|
||||
The error object inherits from `createError.HttpError`.
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-vars -->
|
||||
|
||||
```js
|
||||
var err = new createError.NotFound()
|
||||
```
|
||||
|
||||
- `code` - the status code as a number
|
||||
- `name` - the name of the error as a "bumpy case", i.e. `NotFound` or `InternalServerError`.
|
||||
|
||||
#### List of all constructors
|
||||
|
||||
|Status Code|Constructor Name |
|
||||
|-----------|-----------------------------|
|
||||
|400 |BadRequest |
|
||||
|401 |Unauthorized |
|
||||
|402 |PaymentRequired |
|
||||
|403 |Forbidden |
|
||||
|404 |NotFound |
|
||||
|405 |MethodNotAllowed |
|
||||
|406 |NotAcceptable |
|
||||
|407 |ProxyAuthenticationRequired |
|
||||
|408 |RequestTimeout |
|
||||
|409 |Conflict |
|
||||
|410 |Gone |
|
||||
|411 |LengthRequired |
|
||||
|412 |PreconditionFailed |
|
||||
|413 |PayloadTooLarge |
|
||||
|414 |URITooLong |
|
||||
|415 |UnsupportedMediaType |
|
||||
|416 |RangeNotSatisfiable |
|
||||
|417 |ExpectationFailed |
|
||||
|418 |ImATeapot |
|
||||
|421 |MisdirectedRequest |
|
||||
|422 |UnprocessableEntity |
|
||||
|423 |Locked |
|
||||
|424 |FailedDependency |
|
||||
|425 |UnorderedCollection |
|
||||
|426 |UpgradeRequired |
|
||||
|428 |PreconditionRequired |
|
||||
|429 |TooManyRequests |
|
||||
|431 |RequestHeaderFieldsTooLarge |
|
||||
|451 |UnavailableForLegalReasons |
|
||||
|500 |InternalServerError |
|
||||
|501 |NotImplemented |
|
||||
|502 |BadGateway |
|
||||
|503 |ServiceUnavailable |
|
||||
|504 |GatewayTimeout |
|
||||
|505 |HTTPVersionNotSupported |
|
||||
|506 |VariantAlsoNegotiates |
|
||||
|507 |InsufficientStorage |
|
||||
|508 |LoopDetected |
|
||||
|509 |BandwidthLimitExceeded |
|
||||
|510 |NotExtended |
|
||||
|511 |NetworkAuthenticationRequired|
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/http-errors/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/http-errors?branch=master
|
||||
[node-image]: https://badgen.net/npm/node/http-errors
|
||||
[node-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/http-errors
|
||||
[npm-url]: https://npmjs.org/package/http-errors
|
||||
[npm-version-image]: https://badgen.net/npm/v/http-errors
|
||||
[travis-image]: https://badgen.net/travis/jshttp/http-errors/master
|
||||
[travis-url]: https://travis-ci.org/jshttp/http-errors
|
266
node_modules/csurf/node_modules/http-errors/index.js
generated
vendored
Normal file
266
node_modules/csurf/node_modules/http-errors/index.js
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
/*!
|
||||
* http-errors
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2016 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var deprecate = require('depd')('http-errors')
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
var statuses = require('statuses')
|
||||
var inherits = require('inherits')
|
||||
var toIdentifier = require('toidentifier')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = createError
|
||||
module.exports.HttpError = createHttpErrorConstructor()
|
||||
|
||||
// Populate exports for all constructors
|
||||
populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError)
|
||||
|
||||
/**
|
||||
* Get the code class of a status code.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function codeClass (status) {
|
||||
return Number(String(status).charAt(0) + '00')
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new HTTP Error.
|
||||
*
|
||||
* @returns {Error}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function createError () {
|
||||
// so much arity going on ~_~
|
||||
var err
|
||||
var msg
|
||||
var status = 500
|
||||
var props = {}
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var arg = arguments[i]
|
||||
if (arg instanceof Error) {
|
||||
err = arg
|
||||
status = err.status || err.statusCode || status
|
||||
continue
|
||||
}
|
||||
switch (typeof arg) {
|
||||
case 'string':
|
||||
msg = arg
|
||||
break
|
||||
case 'number':
|
||||
status = arg
|
||||
if (i !== 0) {
|
||||
deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)')
|
||||
}
|
||||
break
|
||||
case 'object':
|
||||
props = arg
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof status === 'number' && (status < 400 || status >= 600)) {
|
||||
deprecate('non-error status code; use only 4xx or 5xx status codes')
|
||||
}
|
||||
|
||||
if (typeof status !== 'number' ||
|
||||
(!statuses[status] && (status < 400 || status >= 600))) {
|
||||
status = 500
|
||||
}
|
||||
|
||||
// constructor
|
||||
var HttpError = createError[status] || createError[codeClass(status)]
|
||||
|
||||
if (!err) {
|
||||
// create error
|
||||
err = HttpError
|
||||
? new HttpError(msg)
|
||||
: new Error(msg || statuses[status])
|
||||
Error.captureStackTrace(err, createError)
|
||||
}
|
||||
|
||||
if (!HttpError || !(err instanceof HttpError) || err.status !== status) {
|
||||
// add properties to generic error
|
||||
err.expose = status < 500
|
||||
err.status = err.statusCode = status
|
||||
}
|
||||
|
||||
for (var key in props) {
|
||||
if (key !== 'status' && key !== 'statusCode') {
|
||||
err[key] = props[key]
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Create HTTP error abstract base class.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createHttpErrorConstructor () {
|
||||
function HttpError () {
|
||||
throw new TypeError('cannot construct abstract class')
|
||||
}
|
||||
|
||||
inherits(HttpError, Error)
|
||||
|
||||
return HttpError
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a constructor for a client error.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createClientErrorConstructor (HttpError, name, code) {
|
||||
var className = name.match(/Error$/) ? name : name + 'Error'
|
||||
|
||||
function ClientError (message) {
|
||||
// create the error object
|
||||
var msg = message != null ? message : statuses[code]
|
||||
var err = new Error(msg)
|
||||
|
||||
// capture a stack trace to the construction point
|
||||
Error.captureStackTrace(err, ClientError)
|
||||
|
||||
// adjust the [[Prototype]]
|
||||
setPrototypeOf(err, ClientError.prototype)
|
||||
|
||||
// redefine the error message
|
||||
Object.defineProperty(err, 'message', {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: msg,
|
||||
writable: true
|
||||
})
|
||||
|
||||
// redefine the error name
|
||||
Object.defineProperty(err, 'name', {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: className,
|
||||
writable: true
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
inherits(ClientError, HttpError)
|
||||
nameFunc(ClientError, className)
|
||||
|
||||
ClientError.prototype.status = code
|
||||
ClientError.prototype.statusCode = code
|
||||
ClientError.prototype.expose = true
|
||||
|
||||
return ClientError
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a constructor for a server error.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createServerErrorConstructor (HttpError, name, code) {
|
||||
var className = name.match(/Error$/) ? name : name + 'Error'
|
||||
|
||||
function ServerError (message) {
|
||||
// create the error object
|
||||
var msg = message != null ? message : statuses[code]
|
||||
var err = new Error(msg)
|
||||
|
||||
// capture a stack trace to the construction point
|
||||
Error.captureStackTrace(err, ServerError)
|
||||
|
||||
// adjust the [[Prototype]]
|
||||
setPrototypeOf(err, ServerError.prototype)
|
||||
|
||||
// redefine the error message
|
||||
Object.defineProperty(err, 'message', {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: msg,
|
||||
writable: true
|
||||
})
|
||||
|
||||
// redefine the error name
|
||||
Object.defineProperty(err, 'name', {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: className,
|
||||
writable: true
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
inherits(ServerError, HttpError)
|
||||
nameFunc(ServerError, className)
|
||||
|
||||
ServerError.prototype.status = code
|
||||
ServerError.prototype.statusCode = code
|
||||
ServerError.prototype.expose = false
|
||||
|
||||
return ServerError
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of a function, if possible.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function nameFunc (func, name) {
|
||||
var desc = Object.getOwnPropertyDescriptor(func, 'name')
|
||||
|
||||
if (desc && desc.configurable) {
|
||||
desc.value = name
|
||||
Object.defineProperty(func, 'name', desc)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the exports object with constructors for every error class.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function populateConstructorExports (exports, codes, HttpError) {
|
||||
codes.forEach(function forEachCode (code) {
|
||||
var CodeError
|
||||
var name = toIdentifier(statuses[code])
|
||||
|
||||
switch (codeClass(code)) {
|
||||
case 400:
|
||||
CodeError = createClientErrorConstructor(HttpError, name, code)
|
||||
break
|
||||
case 500:
|
||||
CodeError = createServerErrorConstructor(HttpError, name, code)
|
||||
break
|
||||
}
|
||||
|
||||
if (CodeError) {
|
||||
// export the constructor
|
||||
exports[code] = CodeError
|
||||
exports[name] = CodeError
|
||||
}
|
||||
})
|
||||
|
||||
// backwards-compatibility
|
||||
exports["I'mateapot"] = deprecate.function(exports.ImATeapot,
|
||||
'"I\'mateapot"; use "ImATeapot" instead')
|
||||
}
|
91
node_modules/csurf/node_modules/http-errors/package.json
generated
vendored
Normal file
91
node_modules/csurf/node_modules/http-errors/package.json
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"_from": "http-errors@~1.7.3",
|
||||
"_id": "http-errors@1.7.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==",
|
||||
"_location": "/csurf/http-errors",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "http-errors@~1.7.3",
|
||||
"name": "http-errors",
|
||||
"escapedName": "http-errors",
|
||||
"rawSpec": "~1.7.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.7.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/csurf"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz",
|
||||
"_shasum": "6c619e4f9c60308c38519498c14fbb10aacebb06",
|
||||
"_spec": "http-errors@~1.7.3",
|
||||
"_where": "/home/runner/Socketio-Chat-Template/node_modules/csurf",
|
||||
"author": {
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/http-errors/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Alan Plum",
|
||||
"email": "me@pluma.io"
|
||||
},
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"depd": "~1.1.2",
|
||||
"inherits": "2.0.4",
|
||||
"setprototypeof": "1.1.1",
|
||||
"statuses": ">= 1.5.0 < 2",
|
||||
"toidentifier": "1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Create HTTP error objects",
|
||||
"devDependencies": {
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-standard": "12.0.0",
|
||||
"eslint-plugin-import": "2.18.0",
|
||||
"eslint-plugin-markdown": "1.0.0",
|
||||
"eslint-plugin-node": "8.0.1",
|
||||
"eslint-plugin-promise": "4.1.1",
|
||||
"eslint-plugin-standard": "4.0.0",
|
||||
"istanbul": "0.4.5",
|
||||
"mocha": "6.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"homepage": "https://github.com/jshttp/http-errors#readme",
|
||||
"keywords": [
|
||||
"http",
|
||||
"error"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "http-errors",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jshttp/http-errors.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --plugin markdown --ext js,md . && node ./scripts/lint-readme-list.js",
|
||||
"test": "mocha --reporter spec --bail",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
|
||||
},
|
||||
"version": "1.7.3"
|
||||
}
|
98
node_modules/csurf/package.json
generated
vendored
Normal file
98
node_modules/csurf/package.json
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"_from": "csurf@^1.9.0",
|
||||
"_id": "csurf@1.11.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-UCtehyEExKTxgiu8UHdGvHj4tnpE/Qctue03Giq5gPgMQ9cg/ciod5blZQ5a4uCEenNQjxyGuzygLdKUmee/bQ==",
|
||||
"_location": "/csurf",
|
||||
"_phantomChildren": {
|
||||
"depd": "1.1.2",
|
||||
"inherits": "2.0.4",
|
||||
"setprototypeof": "1.1.1",
|
||||
"statuses": "1.5.0",
|
||||
"toidentifier": "1.0.0"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "csurf@^1.9.0",
|
||||
"name": "csurf",
|
||||
"escapedName": "csurf",
|
||||
"rawSpec": "^1.9.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.9.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/server"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/csurf/-/csurf-1.11.0.tgz",
|
||||
"_shasum": "ab0c3c6634634192bd3d6f4b861be20800eeb61a",
|
||||
"_spec": "csurf@^1.9.0",
|
||||
"_where": "/home/runner/Socketio-Chat-Template/node_modules/server",
|
||||
"author": {
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/expressjs/csurf/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"cookie": "0.4.0",
|
||||
"cookie-signature": "1.0.6",
|
||||
"csrf": "3.1.0",
|
||||
"http-errors": "~1.7.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "CSRF token middleware",
|
||||
"devDependencies": {
|
||||
"body-parser": "1.19.0",
|
||||
"connect": "3.7.0",
|
||||
"cookie-parser": "1.4.4",
|
||||
"cookie-session": "1.4.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-standard": "14.1.0",
|
||||
"eslint-plugin-import": "2.20.0",
|
||||
"eslint-plugin-markdown": "1.0.1",
|
||||
"eslint-plugin-node": "11.0.0",
|
||||
"eslint-plugin-promise": "4.2.1",
|
||||
"eslint-plugin-standard": "4.0.1",
|
||||
"mocha": "7.0.0",
|
||||
"nyc": "15.0.0",
|
||||
"supertest": "4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/expressjs/csurf#readme",
|
||||
"keywords": [
|
||||
"csrf",
|
||||
"tokens",
|
||||
"middleware",
|
||||
"express"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "csurf",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/expressjs/csurf.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"test": "mocha --check-leaks --reporter spec --bail test/",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"test-travis": "nyc --reporter=text npm test"
|
||||
},
|
||||
"version": "1.11.0"
|
||||
}
|
Reference in New Issue
Block a user