前端代码
This commit is contained in:
308
node_modules/raw-body/HISTORY.md
generated
vendored
Normal file
308
node_modules/raw-body/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,308 @@
|
||||
2.5.2 / 2023-02-21
|
||||
==================
|
||||
|
||||
* Fix error message for non-stream argument
|
||||
|
||||
2.5.1 / 2022-02-28
|
||||
==================
|
||||
|
||||
* Fix error on early async hooks implementations
|
||||
|
||||
2.5.0 / 2022-02-21
|
||||
==================
|
||||
|
||||
* Prevent loss of async hooks context
|
||||
* Prevent hanging when stream is not readable
|
||||
* deps: http-errors@2.0.0
|
||||
- deps: depd@2.0.0
|
||||
- deps: statuses@2.0.1
|
||||
|
||||
2.4.3 / 2022-02-14
|
||||
==================
|
||||
|
||||
* deps: bytes@3.1.2
|
||||
|
||||
2.4.2 / 2021-11-16
|
||||
==================
|
||||
|
||||
* deps: bytes@3.1.1
|
||||
* deps: http-errors@1.8.1
|
||||
- deps: setprototypeof@1.2.0
|
||||
- deps: toidentifier@1.0.1
|
||||
|
||||
2.4.1 / 2019-06-25
|
||||
==================
|
||||
|
||||
* deps: http-errors@1.7.3
|
||||
- deps: inherits@2.0.4
|
||||
|
||||
2.4.0 / 2019-04-17
|
||||
==================
|
||||
|
||||
* deps: bytes@3.1.0
|
||||
- Add petabyte (`pb`) support
|
||||
* deps: http-errors@1.7.2
|
||||
- Set constructor name when possible
|
||||
- deps: setprototypeof@1.1.1
|
||||
- deps: statuses@'>= 1.5.0 < 2'
|
||||
* deps: iconv-lite@0.4.24
|
||||
- Added encoding MIK
|
||||
|
||||
2.3.3 / 2018-05-08
|
||||
==================
|
||||
|
||||
* deps: http-errors@1.6.3
|
||||
- deps: depd@~1.1.2
|
||||
- deps: setprototypeof@1.1.0
|
||||
- deps: statuses@'>= 1.3.1 < 2'
|
||||
* deps: iconv-lite@0.4.23
|
||||
- Fix loading encoding with year appended
|
||||
- Fix deprecation warnings on Node.js 10+
|
||||
|
||||
2.3.2 / 2017-09-09
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.19
|
||||
- Fix ISO-8859-1 regression
|
||||
- Update Windows-1255
|
||||
|
||||
2.3.1 / 2017-09-07
|
||||
==================
|
||||
|
||||
* deps: bytes@3.0.0
|
||||
* deps: http-errors@1.6.2
|
||||
- deps: depd@1.1.1
|
||||
* perf: skip buffer decoding on overage chunk
|
||||
|
||||
2.3.0 / 2017-08-04
|
||||
==================
|
||||
|
||||
* Add TypeScript definitions
|
||||
* Use `http-errors` for standard emitted errors
|
||||
* deps: bytes@2.5.0
|
||||
* deps: iconv-lite@0.4.18
|
||||
- Add support for React Native
|
||||
- Add a warning if not loaded as utf-8
|
||||
- Fix CESU-8 decoding in Node.js 8
|
||||
- Improve speed of ISO-8859-1 encoding
|
||||
|
||||
2.2.0 / 2017-01-02
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.15
|
||||
- Added encoding MS-31J
|
||||
- Added encoding MS-932
|
||||
- Added encoding MS-936
|
||||
- Added encoding MS-949
|
||||
- Added encoding MS-950
|
||||
- Fix GBK/GB18030 handling of Euro character
|
||||
|
||||
2.1.7 / 2016-06-19
|
||||
==================
|
||||
|
||||
* deps: bytes@2.4.0
|
||||
* perf: remove double-cleanup on happy path
|
||||
|
||||
2.1.6 / 2016-03-07
|
||||
==================
|
||||
|
||||
* deps: bytes@2.3.0
|
||||
- Drop partial bytes on all parsed units
|
||||
- Fix parsing byte string that looks like hex
|
||||
|
||||
2.1.5 / 2015-11-30
|
||||
==================
|
||||
|
||||
* deps: bytes@2.2.0
|
||||
* deps: iconv-lite@0.4.13
|
||||
|
||||
2.1.4 / 2015-09-27
|
||||
==================
|
||||
|
||||
* Fix masking critical errors from `iconv-lite`
|
||||
* deps: iconv-lite@0.4.12
|
||||
- Fix CESU-8 decoding in Node.js 4.x
|
||||
|
||||
2.1.3 / 2015-09-12
|
||||
==================
|
||||
|
||||
* Fix sync callback when attaching data listener causes sync read
|
||||
- Node.js 0.10 compatibility issue
|
||||
|
||||
2.1.2 / 2015-07-05
|
||||
==================
|
||||
|
||||
* Fix error stack traces to skip `makeError`
|
||||
* deps: iconv-lite@0.4.11
|
||||
- Add encoding CESU-8
|
||||
|
||||
2.1.1 / 2015-06-14
|
||||
==================
|
||||
|
||||
* Use `unpipe` module for unpiping requests
|
||||
|
||||
2.1.0 / 2015-05-28
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.10
|
||||
- Improved UTF-16 endianness detection
|
||||
- Leading BOM is now removed when decoding
|
||||
- The encoding UTF-16 without BOM now defaults to UTF-16LE when detection fails
|
||||
|
||||
2.0.2 / 2015-05-21
|
||||
==================
|
||||
|
||||
* deps: bytes@2.1.0
|
||||
- Slight optimizations
|
||||
|
||||
2.0.1 / 2015-05-10
|
||||
==================
|
||||
|
||||
* Fix a false-positive when unpiping in Node.js 0.8
|
||||
|
||||
2.0.0 / 2015-05-08
|
||||
==================
|
||||
|
||||
* Return a promise without callback instead of thunk
|
||||
* deps: bytes@2.0.1
|
||||
- units no longer case sensitive when parsing
|
||||
|
||||
1.3.4 / 2015-04-15
|
||||
==================
|
||||
|
||||
* Fix hanging callback if request aborts during read
|
||||
* deps: iconv-lite@0.4.8
|
||||
- Add encoding alias UNICODE-1-1-UTF-7
|
||||
|
||||
1.3.3 / 2015-02-08
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.7
|
||||
- Gracefully support enumerables on `Object.prototype`
|
||||
|
||||
1.3.2 / 2015-01-20
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.6
|
||||
- Fix rare aliases of single-byte encodings
|
||||
|
||||
1.3.1 / 2014-11-21
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.5
|
||||
- Fix Windows-31J and X-SJIS encoding support
|
||||
|
||||
1.3.0 / 2014-07-20
|
||||
==================
|
||||
|
||||
* Fully unpipe the stream on error
|
||||
- Fixes `Cannot switch to old mode now` error on Node.js 0.10+
|
||||
|
||||
1.2.3 / 2014-07-20
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.4
|
||||
- Added encoding UTF-7
|
||||
|
||||
1.2.2 / 2014-06-19
|
||||
==================
|
||||
|
||||
* Send invalid encoding error to callback
|
||||
|
||||
1.2.1 / 2014-06-15
|
||||
==================
|
||||
|
||||
* deps: iconv-lite@0.4.3
|
||||
- Added encodings UTF-16BE and UTF-16 with BOM
|
||||
|
||||
1.2.0 / 2014-06-13
|
||||
==================
|
||||
|
||||
* Passing string as `options` interpreted as encoding
|
||||
* Support all encodings from `iconv-lite`
|
||||
|
||||
1.1.7 / 2014-06-12
|
||||
==================
|
||||
|
||||
* use `string_decoder` module from npm
|
||||
|
||||
1.1.6 / 2014-05-27
|
||||
==================
|
||||
|
||||
* check encoding for old streams1
|
||||
* support node.js < 0.10.6
|
||||
|
||||
1.1.5 / 2014-05-14
|
||||
==================
|
||||
|
||||
* bump bytes
|
||||
|
||||
1.1.4 / 2014-04-19
|
||||
==================
|
||||
|
||||
* allow true as an option
|
||||
* bump bytes
|
||||
|
||||
1.1.3 / 2014-03-02
|
||||
==================
|
||||
|
||||
* fix case when length=null
|
||||
|
||||
1.1.2 / 2013-12-01
|
||||
==================
|
||||
|
||||
* be less strict on state.encoding check
|
||||
|
||||
1.1.1 / 2013-11-27
|
||||
==================
|
||||
|
||||
* add engines
|
||||
|
||||
1.1.0 / 2013-11-27
|
||||
==================
|
||||
|
||||
* add err.statusCode and err.type
|
||||
* allow for encoding option to be true
|
||||
* pause the stream instead of dumping on error
|
||||
* throw if the stream's encoding is set
|
||||
|
||||
1.0.1 / 2013-11-19
|
||||
==================
|
||||
|
||||
* dont support streams1, throw if dev set encoding
|
||||
|
||||
1.0.0 / 2013-11-17
|
||||
==================
|
||||
|
||||
* rename `expected` option to `length`
|
||||
|
||||
0.2.0 / 2013-11-15
|
||||
==================
|
||||
|
||||
* republish
|
||||
|
||||
0.1.1 / 2013-11-15
|
||||
==================
|
||||
|
||||
* use bytes
|
||||
|
||||
0.1.0 / 2013-11-11
|
||||
==================
|
||||
|
||||
* generator support
|
||||
|
||||
0.0.3 / 2013-10-10
|
||||
==================
|
||||
|
||||
* update repo
|
||||
|
||||
0.0.2 / 2013-09-14
|
||||
==================
|
||||
|
||||
* dump stream on bad headers
|
||||
* listen to events after defining received and buffers
|
||||
|
||||
0.0.1 / 2013-09-14
|
||||
==================
|
||||
|
||||
* Initial release
|
22
node_modules/raw-body/LICENSE
generated
vendored
Normal file
22
node_modules/raw-body/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2014-2022 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.
|
223
node_modules/raw-body/README.md
generated
vendored
Normal file
223
node_modules/raw-body/README.md
generated
vendored
Normal file
@ -0,0 +1,223 @@
|
||||
# raw-body
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build status][github-actions-ci-image]][github-actions-ci-url]
|
||||
[![Test coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Gets the entire buffer of a stream either as a `Buffer` or a string.
|
||||
Validates the stream's length against an expected length and maximum limit.
|
||||
Ideal for parsing request bodies.
|
||||
|
||||
## 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):
|
||||
|
||||
```sh
|
||||
$ npm install raw-body
|
||||
```
|
||||
|
||||
### TypeScript
|
||||
|
||||
This module includes a [TypeScript](https://www.typescriptlang.org/)
|
||||
declaration file to enable auto complete in compatible editors and type
|
||||
information for TypeScript projects. This module depends on the Node.js
|
||||
types, so install `@types/node`:
|
||||
|
||||
```sh
|
||||
$ npm install @types/node
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var getRawBody = require('raw-body')
|
||||
```
|
||||
|
||||
### getRawBody(stream, [options], [callback])
|
||||
|
||||
**Returns a promise if no callback specified and global `Promise` exists.**
|
||||
|
||||
Options:
|
||||
|
||||
- `length` - The length of the stream.
|
||||
If the contents of the stream do not add up to this length,
|
||||
an `400` error code is returned.
|
||||
- `limit` - The byte limit of the body.
|
||||
This is the number of bytes or any string format supported by
|
||||
[bytes](https://www.npmjs.com/package/bytes),
|
||||
for example `1000`, `'500kb'` or `'3mb'`.
|
||||
If the body ends up being larger than this limit,
|
||||
a `413` error code is returned.
|
||||
- `encoding` - The encoding to use to decode the body into a string.
|
||||
By default, a `Buffer` instance will be returned when no encoding is specified.
|
||||
Most likely, you want `utf-8`, so setting `encoding` to `true` will decode as `utf-8`.
|
||||
You can use any type of encoding supported by [iconv-lite](https://www.npmjs.org/package/iconv-lite#readme).
|
||||
|
||||
You can also pass a string in place of options to just specify the encoding.
|
||||
|
||||
If an error occurs, the stream will be paused, everything unpiped,
|
||||
and you are responsible for correctly disposing the stream.
|
||||
For HTTP requests, you may need to finish consuming the stream if
|
||||
you want to keep the socket open for future requests. For streams
|
||||
that use file descriptors, you should `stream.destroy()` or
|
||||
`stream.close()` to prevent leaks.
|
||||
|
||||
## Errors
|
||||
|
||||
This module creates errors depending on the error condition during reading.
|
||||
The error may be an error from the underlying Node.js implementation, but is
|
||||
otherwise an error created by this module, which has the following attributes:
|
||||
|
||||
* `limit` - the limit in bytes
|
||||
* `length` and `expected` - the expected length of the stream
|
||||
* `received` - the received bytes
|
||||
* `encoding` - the invalid encoding
|
||||
* `status` and `statusCode` - the corresponding status code for the error
|
||||
* `type` - the error type
|
||||
|
||||
### Types
|
||||
|
||||
The errors from this module have a `type` property which allows for the programmatic
|
||||
determination of the type of error returned.
|
||||
|
||||
#### encoding.unsupported
|
||||
|
||||
This error will occur when the `encoding` option is specified, but the value does
|
||||
not map to an encoding supported by the [iconv-lite](https://www.npmjs.org/package/iconv-lite#readme)
|
||||
module.
|
||||
|
||||
#### entity.too.large
|
||||
|
||||
This error will occur when the `limit` option is specified, but the stream has
|
||||
an entity that is larger.
|
||||
|
||||
#### request.aborted
|
||||
|
||||
This error will occur when the request stream is aborted by the client before
|
||||
reading the body has finished.
|
||||
|
||||
#### request.size.invalid
|
||||
|
||||
This error will occur when the `length` option is specified, but the stream has
|
||||
emitted more bytes.
|
||||
|
||||
#### stream.encoding.set
|
||||
|
||||
This error will occur when the given stream has an encoding set on it, making it
|
||||
a decoded stream. The stream should not have an encoding set and is expected to
|
||||
emit `Buffer` objects.
|
||||
|
||||
#### stream.not.readable
|
||||
|
||||
This error will occur when the given stream is not readable.
|
||||
|
||||
## Examples
|
||||
|
||||
### Simple Express example
|
||||
|
||||
```js
|
||||
var contentType = require('content-type')
|
||||
var express = require('express')
|
||||
var getRawBody = require('raw-body')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
getRawBody(req, {
|
||||
length: req.headers['content-length'],
|
||||
limit: '1mb',
|
||||
encoding: contentType.parse(req).parameters.charset
|
||||
}, function (err, string) {
|
||||
if (err) return next(err)
|
||||
req.text = string
|
||||
next()
|
||||
})
|
||||
})
|
||||
|
||||
// now access req.text
|
||||
```
|
||||
|
||||
### Simple Koa example
|
||||
|
||||
```js
|
||||
var contentType = require('content-type')
|
||||
var getRawBody = require('raw-body')
|
||||
var koa = require('koa')
|
||||
|
||||
var app = koa()
|
||||
|
||||
app.use(function * (next) {
|
||||
this.text = yield getRawBody(this.req, {
|
||||
length: this.req.headers['content-length'],
|
||||
limit: '1mb',
|
||||
encoding: contentType.parse(this.req).parameters.charset
|
||||
})
|
||||
yield next
|
||||
})
|
||||
|
||||
// now access this.text
|
||||
```
|
||||
|
||||
### Using as a promise
|
||||
|
||||
To use this library as a promise, simply omit the `callback` and a promise is
|
||||
returned, provided that a global `Promise` is defined.
|
||||
|
||||
```js
|
||||
var getRawBody = require('raw-body')
|
||||
var http = require('http')
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
getRawBody(req)
|
||||
.then(function (buf) {
|
||||
res.statusCode = 200
|
||||
res.end(buf.length + ' bytes submitted')
|
||||
})
|
||||
.catch(function (err) {
|
||||
res.statusCode = 500
|
||||
res.end(err.message)
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(3000)
|
||||
```
|
||||
|
||||
### Using with TypeScript
|
||||
|
||||
```ts
|
||||
import * as getRawBody from 'raw-body';
|
||||
import * as http from 'http';
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
getRawBody(req)
|
||||
.then((buf) => {
|
||||
res.statusCode = 200;
|
||||
res.end(buf.length + ' bytes submitted');
|
||||
})
|
||||
.catch((err) => {
|
||||
res.statusCode = err.statusCode;
|
||||
res.end(err.message);
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(3000);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/raw-body.svg
|
||||
[npm-url]: https://npmjs.org/package/raw-body
|
||||
[node-version-image]: https://img.shields.io/node/v/raw-body.svg
|
||||
[node-version-url]: https://nodejs.org/en/download/
|
||||
[coveralls-image]: https://img.shields.io/coveralls/stream-utils/raw-body/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/stream-utils/raw-body?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/raw-body.svg
|
||||
[downloads-url]: https://npmjs.org/package/raw-body
|
||||
[github-actions-ci-image]: https://img.shields.io/github/actions/workflow/status/stream-utils/raw-body/ci.yml?branch=master&label=ci
|
||||
[github-actions-ci-url]: https://github.com/jshttp/stream-utils/raw-body?query=workflow%3Aci
|
24
node_modules/raw-body/SECURITY.md
generated
vendored
Normal file
24
node_modules/raw-body/SECURITY.md
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Security Policies and Procedures
|
||||
|
||||
## Reporting a Bug
|
||||
|
||||
The `raw-body` team and community take all security bugs seriously. Thank you
|
||||
for improving the security of Express. We appreciate your efforts and
|
||||
responsible disclosure and will make every effort to acknowledge your
|
||||
contributions.
|
||||
|
||||
Report security bugs by emailing the current owners of `raw-body`. This information
|
||||
can be found in the npm registry using the command `npm owner ls raw-body`.
|
||||
If unsure or unable to get the information from the above, open an issue
|
||||
in the [project issue tracker](https://github.com/stream-utils/raw-body/issues)
|
||||
asking for the current contact information.
|
||||
|
||||
To ensure the timely response to your report, please ensure that the entirety
|
||||
of the report is contained within the email body and not solely behind a web
|
||||
link or an attachment.
|
||||
|
||||
At least one owner will acknowledge your email within 48 hours, and will send a
|
||||
more detailed response within 48 hours indicating the next steps in handling
|
||||
your report. After the initial reply to your report, the owners will
|
||||
endeavor to keep you informed of the progress towards a fix and full
|
||||
announcement, and may ask for additional information or guidance.
|
87
node_modules/raw-body/index.d.ts
generated
vendored
Normal file
87
node_modules/raw-body/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
import { Readable } from 'stream';
|
||||
|
||||
declare namespace getRawBody {
|
||||
export type Encoding = string | true;
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* The expected length of the stream.
|
||||
*/
|
||||
length?: number | string | null;
|
||||
/**
|
||||
* The byte limit of the body. This is the number of bytes or any string
|
||||
* format supported by `bytes`, for example `1000`, `'500kb'` or `'3mb'`.
|
||||
*/
|
||||
limit?: number | string | null;
|
||||
/**
|
||||
* The encoding to use to decode the body into a string. By default, a
|
||||
* `Buffer` instance will be returned when no encoding is specified. Most
|
||||
* likely, you want `utf-8`, so setting encoding to `true` will decode as
|
||||
* `utf-8`. You can use any type of encoding supported by `iconv-lite`.
|
||||
*/
|
||||
encoding?: Encoding | null;
|
||||
}
|
||||
|
||||
export interface RawBodyError extends Error {
|
||||
/**
|
||||
* The limit in bytes.
|
||||
*/
|
||||
limit?: number;
|
||||
/**
|
||||
* The expected length of the stream.
|
||||
*/
|
||||
length?: number;
|
||||
expected?: number;
|
||||
/**
|
||||
* The received bytes.
|
||||
*/
|
||||
received?: number;
|
||||
/**
|
||||
* The encoding.
|
||||
*/
|
||||
encoding?: string;
|
||||
/**
|
||||
* The corresponding status code for the error.
|
||||
*/
|
||||
status: number;
|
||||
statusCode: number;
|
||||
/**
|
||||
* The error type.
|
||||
*/
|
||||
type: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire buffer of a stream either as a `Buffer` or a string.
|
||||
* Validates the stream's length against an expected length and maximum
|
||||
* limit. Ideal for parsing request bodies.
|
||||
*/
|
||||
declare function getRawBody(
|
||||
stream: Readable,
|
||||
callback: (err: getRawBody.RawBodyError, body: Buffer) => void
|
||||
): void;
|
||||
|
||||
declare function getRawBody(
|
||||
stream: Readable,
|
||||
options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding,
|
||||
callback: (err: getRawBody.RawBodyError, body: string) => void
|
||||
): void;
|
||||
|
||||
declare function getRawBody(
|
||||
stream: Readable,
|
||||
options: getRawBody.Options,
|
||||
callback: (err: getRawBody.RawBodyError, body: Buffer) => void
|
||||
): void;
|
||||
|
||||
declare function getRawBody(
|
||||
stream: Readable,
|
||||
options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding
|
||||
): Promise<string>;
|
||||
|
||||
declare function getRawBody(
|
||||
stream: Readable,
|
||||
options?: getRawBody.Options
|
||||
): Promise<Buffer>;
|
||||
|
||||
export = getRawBody;
|
336
node_modules/raw-body/index.js
generated
vendored
Normal file
336
node_modules/raw-body/index.js
generated
vendored
Normal file
@ -0,0 +1,336 @@
|
||||
/*!
|
||||
* raw-body
|
||||
* Copyright(c) 2013-2014 Jonathan Ong
|
||||
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var asyncHooks = tryRequireAsyncHooks()
|
||||
var bytes = require('bytes')
|
||||
var createError = require('http-errors')
|
||||
var iconv = require('iconv-lite')
|
||||
var unpipe = require('unpipe')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = getRawBody
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: /
|
||||
|
||||
/**
|
||||
* Get the decoder for a given encoding.
|
||||
*
|
||||
* @param {string} encoding
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getDecoder (encoding) {
|
||||
if (!encoding) return null
|
||||
|
||||
try {
|
||||
return iconv.getDecoder(encoding)
|
||||
} catch (e) {
|
||||
// error getting decoder
|
||||
if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e
|
||||
|
||||
// the encoding was not found
|
||||
throw createError(415, 'specified encoding unsupported', {
|
||||
encoding: encoding,
|
||||
type: 'encoding.unsupported'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw body of a stream (typically HTTP).
|
||||
*
|
||||
* @param {object} stream
|
||||
* @param {object|string|function} [options]
|
||||
* @param {function} [callback]
|
||||
* @public
|
||||
*/
|
||||
|
||||
function getRawBody (stream, options, callback) {
|
||||
var done = callback
|
||||
var opts = options || {}
|
||||
|
||||
// light validation
|
||||
if (stream === undefined) {
|
||||
throw new TypeError('argument stream is required')
|
||||
} else if (typeof stream !== 'object' || stream === null || typeof stream.on !== 'function') {
|
||||
throw new TypeError('argument stream must be a stream')
|
||||
}
|
||||
|
||||
if (options === true || typeof options === 'string') {
|
||||
// short cut for encoding
|
||||
opts = {
|
||||
encoding: options
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof options === 'function') {
|
||||
done = options
|
||||
opts = {}
|
||||
}
|
||||
|
||||
// validate callback is a function, if provided
|
||||
if (done !== undefined && typeof done !== 'function') {
|
||||
throw new TypeError('argument callback must be a function')
|
||||
}
|
||||
|
||||
// require the callback without promises
|
||||
if (!done && !global.Promise) {
|
||||
throw new TypeError('argument callback is required')
|
||||
}
|
||||
|
||||
// get encoding
|
||||
var encoding = opts.encoding !== true
|
||||
? opts.encoding
|
||||
: 'utf-8'
|
||||
|
||||
// convert the limit to an integer
|
||||
var limit = bytes.parse(opts.limit)
|
||||
|
||||
// convert the expected length to an integer
|
||||
var length = opts.length != null && !isNaN(opts.length)
|
||||
? parseInt(opts.length, 10)
|
||||
: null
|
||||
|
||||
if (done) {
|
||||
// classic callback style
|
||||
return readStream(stream, encoding, length, limit, wrap(done))
|
||||
}
|
||||
|
||||
return new Promise(function executor (resolve, reject) {
|
||||
readStream(stream, encoding, length, limit, function onRead (err, buf) {
|
||||
if (err) return reject(err)
|
||||
resolve(buf)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Halt a stream.
|
||||
*
|
||||
* @param {Object} stream
|
||||
* @private
|
||||
*/
|
||||
|
||||
function halt (stream) {
|
||||
// unpipe everything from the stream
|
||||
unpipe(stream)
|
||||
|
||||
// pause stream
|
||||
if (typeof stream.pause === 'function') {
|
||||
stream.pause()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data from the stream.
|
||||
*
|
||||
* @param {object} stream
|
||||
* @param {string} encoding
|
||||
* @param {number} length
|
||||
* @param {number} limit
|
||||
* @param {function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
function readStream (stream, encoding, length, limit, callback) {
|
||||
var complete = false
|
||||
var sync = true
|
||||
|
||||
// check the length and limit options.
|
||||
// note: we intentionally leave the stream paused,
|
||||
// so users should handle the stream themselves.
|
||||
if (limit !== null && length !== null && length > limit) {
|
||||
return done(createError(413, 'request entity too large', {
|
||||
expected: length,
|
||||
length: length,
|
||||
limit: limit,
|
||||
type: 'entity.too.large'
|
||||
}))
|
||||
}
|
||||
|
||||
// streams1: assert request encoding is buffer.
|
||||
// streams2+: assert the stream encoding is buffer.
|
||||
// stream._decoder: streams1
|
||||
// state.encoding: streams2
|
||||
// state.decoder: streams2, specifically < 0.10.6
|
||||
var state = stream._readableState
|
||||
if (stream._decoder || (state && (state.encoding || state.decoder))) {
|
||||
// developer error
|
||||
return done(createError(500, 'stream encoding should not be set', {
|
||||
type: 'stream.encoding.set'
|
||||
}))
|
||||
}
|
||||
|
||||
if (typeof stream.readable !== 'undefined' && !stream.readable) {
|
||||
return done(createError(500, 'stream is not readable', {
|
||||
type: 'stream.not.readable'
|
||||
}))
|
||||
}
|
||||
|
||||
var received = 0
|
||||
var decoder
|
||||
|
||||
try {
|
||||
decoder = getDecoder(encoding)
|
||||
} catch (err) {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
var buffer = decoder
|
||||
? ''
|
||||
: []
|
||||
|
||||
// attach listeners
|
||||
stream.on('aborted', onAborted)
|
||||
stream.on('close', cleanup)
|
||||
stream.on('data', onData)
|
||||
stream.on('end', onEnd)
|
||||
stream.on('error', onEnd)
|
||||
|
||||
// mark sync section complete
|
||||
sync = false
|
||||
|
||||
function done () {
|
||||
var args = new Array(arguments.length)
|
||||
|
||||
// copy arguments
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
args[i] = arguments[i]
|
||||
}
|
||||
|
||||
// mark complete
|
||||
complete = true
|
||||
|
||||
if (sync) {
|
||||
process.nextTick(invokeCallback)
|
||||
} else {
|
||||
invokeCallback()
|
||||
}
|
||||
|
||||
function invokeCallback () {
|
||||
cleanup()
|
||||
|
||||
if (args[0]) {
|
||||
// halt the stream on error
|
||||
halt(stream)
|
||||
}
|
||||
|
||||
callback.apply(null, args)
|
||||
}
|
||||
}
|
||||
|
||||
function onAborted () {
|
||||
if (complete) return
|
||||
|
||||
done(createError(400, 'request aborted', {
|
||||
code: 'ECONNABORTED',
|
||||
expected: length,
|
||||
length: length,
|
||||
received: received,
|
||||
type: 'request.aborted'
|
||||
}))
|
||||
}
|
||||
|
||||
function onData (chunk) {
|
||||
if (complete) return
|
||||
|
||||
received += chunk.length
|
||||
|
||||
if (limit !== null && received > limit) {
|
||||
done(createError(413, 'request entity too large', {
|
||||
limit: limit,
|
||||
received: received,
|
||||
type: 'entity.too.large'
|
||||
}))
|
||||
} else if (decoder) {
|
||||
buffer += decoder.write(chunk)
|
||||
} else {
|
||||
buffer.push(chunk)
|
||||
}
|
||||
}
|
||||
|
||||
function onEnd (err) {
|
||||
if (complete) return
|
||||
if (err) return done(err)
|
||||
|
||||
if (length !== null && received !== length) {
|
||||
done(createError(400, 'request size did not match content length', {
|
||||
expected: length,
|
||||
length: length,
|
||||
received: received,
|
||||
type: 'request.size.invalid'
|
||||
}))
|
||||
} else {
|
||||
var string = decoder
|
||||
? buffer + (decoder.end() || '')
|
||||
: Buffer.concat(buffer)
|
||||
done(null, string)
|
||||
}
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
buffer = null
|
||||
|
||||
stream.removeListener('aborted', onAborted)
|
||||
stream.removeListener('data', onData)
|
||||
stream.removeListener('end', onEnd)
|
||||
stream.removeListener('error', onEnd)
|
||||
stream.removeListener('close', cleanup)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to require async_hooks
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryRequireAsyncHooks () {
|
||||
try {
|
||||
return require('async_hooks')
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap function with async resource, if possible.
|
||||
* AsyncResource.bind static method backported.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function wrap (fn) {
|
||||
var res
|
||||
|
||||
// create anonymous resource
|
||||
if (asyncHooks.AsyncResource) {
|
||||
res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')
|
||||
}
|
||||
|
||||
// incompatible node.js
|
||||
if (!res || !res.runInAsyncScope) {
|
||||
return fn
|
||||
}
|
||||
|
||||
// return bound function
|
||||
return res.runInAsyncScope.bind(res, fn, null)
|
||||
}
|
103
node_modules/raw-body/node_modules/depd/History.md
generated
vendored
Normal file
103
node_modules/raw-body/node_modules/depd/History.md
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
2.0.0 / 2018-10-26
|
||||
==================
|
||||
|
||||
* Drop support for Node.js 0.6
|
||||
* Replace internal `eval` usage with `Function` constructor
|
||||
* Use instance methods on `process` to check for listeners
|
||||
|
||||
1.1.2 / 2018-01-11
|
||||
==================
|
||||
|
||||
* perf: remove argument reassignment
|
||||
* Support Node.js 0.6 to 9.x
|
||||
|
||||
1.1.1 / 2017-07-27
|
||||
==================
|
||||
|
||||
* Remove unnecessary `Buffer` loading
|
||||
* Support Node.js 0.6 to 8.x
|
||||
|
||||
1.1.0 / 2015-09-14
|
||||
==================
|
||||
|
||||
* Enable strict mode in more places
|
||||
* Support io.js 3.x
|
||||
* Support io.js 2.x
|
||||
* Support web browser loading
|
||||
- Requires bundler like Browserify or webpack
|
||||
|
||||
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/raw-body/node_modules/depd/LICENSE
generated
vendored
Normal file
22
node_modules/raw-body/node_modules/depd/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2018 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.
|
280
node_modules/raw-body/node_modules/depd/Readme.md
generated
vendored
Normal file
280
node_modules/raw-body/node_modules/depd/Readme.md
generated
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
# 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]
|
||||
|
||||
Deprecate all the things
|
||||
|
||||
> With great modules comes great responsibility; mark things deprecated!
|
||||
|
||||
## Install
|
||||
|
||||
This module is installed directly using `npm`:
|
||||
|
||||
```sh
|
||||
$ npm install depd
|
||||
```
|
||||
|
||||
This module can also be bundled with systems like
|
||||
[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/),
|
||||
though by default this module will alter it's API to no longer display or
|
||||
track deprecations.
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```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)
|
||||
|
||||
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/nodejs-depd/master?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/dougwilson/nodejs-depd/master
|
||||
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
|
||||
[node-image]: https://badgen.net/npm/node/depd
|
||||
[node-url]: https://nodejs.org/en/download/
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/depd
|
||||
[npm-url]: https://npmjs.org/package/depd
|
||||
[npm-version-image]: https://badgen.net/npm/v/depd
|
||||
[travis-image]: https://badgen.net/travis/dougwilson/nodejs-depd/master?label=linux
|
||||
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
|
538
node_modules/raw-body/node_modules/depd/index.js
generated
vendored
Normal file
538
node_modules/raw-body/node_modules/depd/index.js
generated
vendored
Normal file
@ -0,0 +1,538 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014-2018 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var relative = require('path').relative
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = depd
|
||||
|
||||
/**
|
||||
* Get the path to base files on.
|
||||
*/
|
||||
|
||||
var basePath = process.cwd()
|
||||
|
||||
/**
|
||||
* Determine if namespace is contained in the string.
|
||||
*/
|
||||
|
||||
function containsNamespace (str, namespace) {
|
||||
var vals = str.split(/[ ,]+/)
|
||||
var ns = String(namespace).toLowerCase()
|
||||
|
||||
for (var i = 0; i < vals.length; i++) {
|
||||
var val = vals[i]
|
||||
|
||||
// namespace contained
|
||||
if (val && (val === '*' || val.toLowerCase() === ns)) {
|
||||
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 ' + stack[i].toString()
|
||||
}
|
||||
|
||||
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 event emitter has listeners of a given type.
|
||||
*
|
||||
* The way to do this check is done three different ways in Node.js >= 0.8
|
||||
* so this consolidates them into a minimal set using instance methods.
|
||||
*
|
||||
* @param {EventEmitter} emitter
|
||||
* @param {string} type
|
||||
* @returns {boolean}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function eehaslisteners (emitter, type) {
|
||||
var count = typeof emitter.listenerCount !== 'function'
|
||||
? emitter.listeners(type).length
|
||||
: emitter.listenerCount(type)
|
||||
|
||||
return count > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if namespace is ignored.
|
||||
*/
|
||||
|
||||
function isignored (namespace) {
|
||||
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) {
|
||||
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 = eehaslisteners(process, 'deprecation')
|
||||
|
||||
// abort early if no destination
|
||||
if (!haslisteners && this._ignored) {
|
||||
return
|
||||
}
|
||||
|
||||
var caller
|
||||
var callFile
|
||||
var callSite
|
||||
var depSite
|
||||
var i = 0
|
||||
var seen = false
|
||||
var stack = getStack()
|
||||
var file = this._file
|
||||
|
||||
if (site) {
|
||||
// provided site
|
||||
depSite = site
|
||||
callSite = callSiteLocation(stack[1])
|
||||
callSite.name = depSite.name
|
||||
file = callSite[0]
|
||||
} else {
|
||||
// get call site
|
||||
i = 2
|
||||
depSite = callSiteLocation(stack[i])
|
||||
callSite = depSite
|
||||
}
|
||||
|
||||
// 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
|
||||
? depSite.join(':') + '__' + caller.join(':')
|
||||
: undefined
|
||||
|
||||
if (key !== undefined && key in this._warned) {
|
||||
// already warned
|
||||
return
|
||||
}
|
||||
|
||||
this._warned[key] = true
|
||||
|
||||
// generate automatic message from call site
|
||||
var msg = message
|
||||
if (!msg) {
|
||||
msg = callSite === depSite || !callSite.name
|
||||
? defaultMessage(depSite)
|
||||
: defaultMessage(callSite)
|
||||
}
|
||||
|
||||
// emit deprecation if listeners exist
|
||||
if (haslisteners) {
|
||||
var err = DeprecationError(this._namespace, msg, stack.slice(i))
|
||||
process.emit('deprecation', err)
|
||||
return
|
||||
}
|
||||
|
||||
// format and write message
|
||||
var format = process.stderr.isTTY
|
||||
? formatColor
|
||||
: formatPlain
|
||||
var output = format.call(this, msg, caller, stack.slice(i))
|
||||
process.stderr.write(output + '\n', 'utf8')
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ' + stack[i].toString()
|
||||
}
|
||||
|
||||
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 ' + stack[i].toString() + '\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 stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
site.name = fn.name
|
||||
|
||||
// eslint-disable-next-line no-new-func
|
||||
var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
|
||||
'"use strict"\n' +
|
||||
'return function (' + args + ') {' +
|
||||
'log.call(deprecate, message, site)\n' +
|
||||
'return fn.apply(this, arguments)\n' +
|
||||
'}')(fn, log, this, message, site)
|
||||
|
||||
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
|
||||
}
|
77
node_modules/raw-body/node_modules/depd/lib/browser/index.js
generated
vendored
Normal file
77
node_modules/raw-body/node_modules/depd/lib/browser/index.js
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = depd
|
||||
|
||||
/**
|
||||
* Create deprecate for namespace in caller.
|
||||
*/
|
||||
|
||||
function depd (namespace) {
|
||||
if (!namespace) {
|
||||
throw new TypeError('argument namespace is required')
|
||||
}
|
||||
|
||||
function deprecate (message) {
|
||||
// no-op in browser
|
||||
}
|
||||
|
||||
deprecate._file = undefined
|
||||
deprecate._ignored = true
|
||||
deprecate._namespace = namespace
|
||||
deprecate._traced = false
|
||||
deprecate._warned = Object.create(null)
|
||||
|
||||
deprecate.function = wrapfunction
|
||||
deprecate.property = wrapproperty
|
||||
|
||||
return deprecate
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a wrapped function in a deprecation message.
|
||||
*
|
||||
* This is a no-op version of the wrapper, which does nothing but call
|
||||
* validation.
|
||||
*/
|
||||
|
||||
function wrapfunction (fn, message) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument fn must be a function')
|
||||
}
|
||||
|
||||
return fn
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap property in a deprecation message.
|
||||
*
|
||||
* This is a no-op version of the wrapper, which does nothing but call
|
||||
* validation.
|
||||
*/
|
||||
|
||||
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')
|
||||
}
|
||||
}
|
45
node_modules/raw-body/node_modules/depd/package.json
generated
vendored
Normal file
45
node_modules/raw-body/node_modules/depd/package.json
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "depd",
|
||||
"description": "Deprecate all the things",
|
||||
"version": "2.0.0",
|
||||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"deprecate",
|
||||
"deprecated"
|
||||
],
|
||||
"repository": "dougwilson/nodejs-depd",
|
||||
"browser": "lib/browser/index.js",
|
||||
"devDependencies": {
|
||||
"benchmark": "2.1.4",
|
||||
"beautify-benchmark": "0.2.4",
|
||||
"eslint": "5.7.0",
|
||||
"eslint-config-standard": "12.0.0",
|
||||
"eslint-plugin-import": "2.14.0",
|
||||
"eslint-plugin-markdown": "1.0.0-beta.7",
|
||||
"eslint-plugin-node": "7.0.1",
|
||||
"eslint-plugin-promise": "4.0.1",
|
||||
"eslint-plugin-standard": "4.0.0",
|
||||
"istanbul": "0.4.5",
|
||||
"mocha": "5.2.0",
|
||||
"safe-buffer": "5.1.2",
|
||||
"uid-safe": "2.1.5"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"History.md",
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"Readme.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/index.js",
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"test": "mocha --reporter spec --bail test/",
|
||||
"test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
|
||||
"test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
|
||||
}
|
||||
}
|
180
node_modules/raw-body/node_modules/http-errors/HISTORY.md
generated
vendored
Normal file
180
node_modules/raw-body/node_modules/http-errors/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
2.0.0 / 2021-12-17
|
||||
==================
|
||||
|
||||
* Drop support for Node.js 0.6
|
||||
* Remove `I'mateapot` export; use `ImATeapot` instead
|
||||
* Remove support for status being non-first argument
|
||||
* Rename `UnorderedCollection` constructor to `TooEarly`
|
||||
* deps: depd@2.0.0
|
||||
- Replace internal `eval` usage with `Function` constructor
|
||||
- Use instance methods on `process` to check for listeners
|
||||
* deps: statuses@2.0.1
|
||||
- Fix messaging casing of `418 I'm a Teapot`
|
||||
- Remove code 306
|
||||
- Rename `425 Unordered Collection` to standard `425 Too Early`
|
||||
|
||||
2021-11-14 / 1.8.1
|
||||
==================
|
||||
|
||||
* deps: toidentifier@1.0.1
|
||||
|
||||
2020-06-29 / 1.8.0
|
||||
==================
|
||||
|
||||
* Add `isHttpError` export to determine if value is an HTTP error
|
||||
* deps: setprototypeof@1.2.0
|
||||
|
||||
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/raw-body/node_modules/http-errors/LICENSE
generated
vendored
Normal file
23
node_modules/raw-body/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.
|
169
node_modules/raw-body/node_modules/http-errors/README.md
generated
vendored
Normal file
169
node_modules/raw-body/node_modules/http-errors/README.md
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
# 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][ci-image]][ci-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):
|
||||
|
||||
```console
|
||||
$ 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`.
|
||||
|
||||
```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 -->
|
||||
|
||||
```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
|
||||
|
||||
### createError.isHttpError(val)
|
||||
|
||||
Determine if the provided `val` is an `HttpError`. This will return `true`
|
||||
if the error inherits from the `HttpError` constructor of this module or
|
||||
matches the "duck type" for an error this module creates. All outputs from
|
||||
the `createError` factory will return `true` for this function, including
|
||||
if an non-`HttpError` was passed into the factory.
|
||||
|
||||
### new createError\[code || name\](\[msg]\))
|
||||
|
||||
Create a new error object with the given message `msg`.
|
||||
The error object inherits from `createError.HttpError`.
|
||||
|
||||
```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 |TooEarly |
|
||||
|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)
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/jshttp/http-errors/master?label=ci
|
||||
[ci-url]: https://github.com/jshttp/http-errors/actions?query=workflow%3Aci
|
||||
[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
|
289
node_modules/raw-body/node_modules/http-errors/index.js
generated
vendored
Normal file
289
node_modules/raw-body/node_modules/http-errors/index.js
generated
vendored
Normal file
@ -0,0 +1,289 @@
|
||||
/*!
|
||||
* 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()
|
||||
module.exports.isHttpError = createIsHttpErrorFunction(module.exports.HttpError)
|
||||
|
||||
// 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]
|
||||
var type = typeof arg
|
||||
if (type === 'object' && arg instanceof Error) {
|
||||
err = arg
|
||||
status = err.status || err.statusCode || status
|
||||
} else if (type === 'number' && i === 0) {
|
||||
status = arg
|
||||
} else if (type === 'string') {
|
||||
msg = arg
|
||||
} else if (type === 'object') {
|
||||
props = arg
|
||||
} else {
|
||||
throw new TypeError('argument #' + (i + 1) + ' unsupported type ' + type)
|
||||
}
|
||||
}
|
||||
|
||||
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.message[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.message[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 = toClassName(name)
|
||||
|
||||
function ClientError (message) {
|
||||
// create the error object
|
||||
var msg = message != null ? message : statuses.message[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 function to test is a value is a HttpError.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createIsHttpErrorFunction (HttpError) {
|
||||
return function isHttpError (val) {
|
||||
if (!val || typeof val !== 'object') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (val instanceof HttpError) {
|
||||
return true
|
||||
}
|
||||
|
||||
return val instanceof Error &&
|
||||
typeof val.expose === 'boolean' &&
|
||||
typeof val.statusCode === 'number' && val.status === val.statusCode
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a constructor for a server error.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createServerErrorConstructor (HttpError, name, code) {
|
||||
var className = toClassName(name)
|
||||
|
||||
function ServerError (message) {
|
||||
// create the error object
|
||||
var msg = message != null ? message : statuses.message[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.message[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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a class name from a name identifier.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function toClassName (name) {
|
||||
return name.substr(-5) !== 'Error'
|
||||
? name + 'Error'
|
||||
: name
|
||||
}
|
50
node_modules/raw-body/node_modules/http-errors/package.json
generated
vendored
Normal file
50
node_modules/raw-body/node_modules/http-errors/package.json
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "http-errors",
|
||||
"description": "Create HTTP error objects",
|
||||
"version": "2.0.0",
|
||||
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
|
||||
"contributors": [
|
||||
"Alan Plum <me@pluma.io>",
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "jshttp/http-errors",
|
||||
"dependencies": {
|
||||
"depd": "2.0.0",
|
||||
"inherits": "2.0.4",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "2.0.1",
|
||||
"toidentifier": "1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.25.3",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "5.2.0",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "9.1.3",
|
||||
"nyc": "15.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint . && node ./scripts/lint-readme-list.js",
|
||||
"test": "mocha --reporter spec --bail",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"version": "node scripts/version-history.js && git add HISTORY.md"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"error"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
]
|
||||
}
|
16
node_modules/raw-body/node_modules/inherits/LICENSE
generated
vendored
Normal file
16
node_modules/raw-body/node_modules/inherits/LICENSE
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
42
node_modules/raw-body/node_modules/inherits/README.md
generated
vendored
Normal file
42
node_modules/raw-body/node_modules/inherits/README.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
Browser-friendly inheritance fully compatible with standard node.js
|
||||
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
|
||||
|
||||
This package exports standard `inherits` from node.js `util` module in
|
||||
node environment, but also provides alternative browser-friendly
|
||||
implementation through [browser
|
||||
field](https://gist.github.com/shtylman/4339901). Alternative
|
||||
implementation is a literal copy of standard one located in standalone
|
||||
module to avoid requiring of `util`. It also has a shim for old
|
||||
browsers with no `Object.create` support.
|
||||
|
||||
While keeping you sure you are using standard `inherits`
|
||||
implementation in node.js environment, it allows bundlers such as
|
||||
[browserify](https://github.com/substack/node-browserify) to not
|
||||
include full `util` package to your client code if all you need is
|
||||
just `inherits` function. It worth, because browser shim for `util`
|
||||
package is large and `inherits` is often the single function you need
|
||||
from it.
|
||||
|
||||
It's recommended to use this package instead of
|
||||
`require('util').inherits` for any code that has chances to be used
|
||||
not only in node.js but in browser too.
|
||||
|
||||
## usage
|
||||
|
||||
```js
|
||||
var inherits = require('inherits');
|
||||
// then use exactly as the standard one
|
||||
```
|
||||
|
||||
## note on version ~1.0
|
||||
|
||||
Version ~1.0 had completely different motivation and is not compatible
|
||||
neither with 2.0 nor with standard node.js `inherits`.
|
||||
|
||||
If you are using version ~1.0 and planning to switch to ~2.0, be
|
||||
careful:
|
||||
|
||||
* new version uses `super_` instead of `super` for referencing
|
||||
superclass
|
||||
* new version overwrites current prototype while old one preserves any
|
||||
existing fields on it
|
9
node_modules/raw-body/node_modules/inherits/inherits.js
generated
vendored
Normal file
9
node_modules/raw-body/node_modules/inherits/inherits.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
try {
|
||||
var util = require('util');
|
||||
/* istanbul ignore next */
|
||||
if (typeof util.inherits !== 'function') throw '';
|
||||
module.exports = util.inherits;
|
||||
} catch (e) {
|
||||
/* istanbul ignore next */
|
||||
module.exports = require('./inherits_browser.js');
|
||||
}
|
27
node_modules/raw-body/node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
27
node_modules/raw-body/node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
if (typeof Object.create === 'function') {
|
||||
// implementation from standard node.js 'util' module
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
if (superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// old school shim for old browsers
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
if (superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
var TempCtor = function () {}
|
||||
TempCtor.prototype = superCtor.prototype
|
||||
ctor.prototype = new TempCtor()
|
||||
ctor.prototype.constructor = ctor
|
||||
}
|
||||
}
|
||||
}
|
29
node_modules/raw-body/node_modules/inherits/package.json
generated
vendored
Normal file
29
node_modules/raw-body/node_modules/inherits/package.json
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "inherits",
|
||||
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
|
||||
"version": "2.0.4",
|
||||
"keywords": [
|
||||
"inheritance",
|
||||
"class",
|
||||
"klass",
|
||||
"oop",
|
||||
"object-oriented",
|
||||
"inherits",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"main": "./inherits.js",
|
||||
"browser": "./inherits_browser.js",
|
||||
"repository": "git://github.com/isaacs/inherits",
|
||||
"license": "ISC",
|
||||
"scripts": {
|
||||
"test": "tap"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^14.2.4"
|
||||
},
|
||||
"files": [
|
||||
"inherits.js",
|
||||
"inherits_browser.js"
|
||||
]
|
||||
}
|
13
node_modules/raw-body/node_modules/setprototypeof/LICENSE
generated
vendored
Normal file
13
node_modules/raw-body/node_modules/setprototypeof/LICENSE
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright (c) 2015, Wes Todd
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
31
node_modules/raw-body/node_modules/setprototypeof/README.md
generated
vendored
Normal file
31
node_modules/raw-body/node_modules/setprototypeof/README.md
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
# Polyfill for `Object.setPrototypeOf`
|
||||
|
||||
[](https://npmjs.org/package/setprototypeof)
|
||||
[](https://npmjs.org/package/setprototypeof)
|
||||
[](https://github.com/standard/standard)
|
||||
|
||||
A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
|
||||
|
||||
## Usage:
|
||||
|
||||
```
|
||||
$ npm install --save setprototypeof
|
||||
```
|
||||
|
||||
```javascript
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
|
||||
var obj = {}
|
||||
setPrototypeOf(obj, {
|
||||
foo: function () {
|
||||
return 'bar'
|
||||
}
|
||||
})
|
||||
obj.foo() // bar
|
||||
```
|
||||
|
||||
TypeScript is also supported:
|
||||
|
||||
```typescript
|
||||
import setPrototypeOf from 'setprototypeof'
|
||||
```
|
2
node_modules/raw-body/node_modules/setprototypeof/index.d.ts
generated
vendored
Normal file
2
node_modules/raw-body/node_modules/setprototypeof/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare function setPrototypeOf(o: any, proto: object | null): any;
|
||||
export = setPrototypeOf;
|
17
node_modules/raw-body/node_modules/setprototypeof/index.js
generated
vendored
Normal file
17
node_modules/raw-body/node_modules/setprototypeof/index.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
'use strict'
|
||||
/* eslint no-proto: 0 */
|
||||
module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties)
|
||||
|
||||
function setProtoOf (obj, proto) {
|
||||
obj.__proto__ = proto
|
||||
return obj
|
||||
}
|
||||
|
||||
function mixinProperties (obj, proto) {
|
||||
for (var prop in proto) {
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
|
||||
obj[prop] = proto[prop]
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
38
node_modules/raw-body/node_modules/setprototypeof/package.json
generated
vendored
Normal file
38
node_modules/raw-body/node_modules/setprototypeof/package.json
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "setprototypeof",
|
||||
"version": "1.2.0",
|
||||
"description": "A small polyfill for Object.setprototypeof",
|
||||
"main": "index.js",
|
||||
"typings": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "standard && mocha",
|
||||
"testallversions": "npm run node010 && npm run node4 && npm run node6 && npm run node9 && npm run node11",
|
||||
"testversion": "docker run -it --rm -v $(PWD):/usr/src/app -w /usr/src/app node:${NODE_VER} npm install mocha@${MOCHA_VER:-latest} && npm t",
|
||||
"node010": "NODE_VER=0.10 MOCHA_VER=3 npm run testversion",
|
||||
"node4": "NODE_VER=4 npm run testversion",
|
||||
"node6": "NODE_VER=6 npm run testversion",
|
||||
"node9": "NODE_VER=9 npm run testversion",
|
||||
"node11": "NODE_VER=11 npm run testversion",
|
||||
"prepublishOnly": "npm t",
|
||||
"postpublish": "git push origin && git push origin --tags"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/wesleytodd/setprototypeof.git"
|
||||
},
|
||||
"keywords": [
|
||||
"polyfill",
|
||||
"object",
|
||||
"setprototypeof"
|
||||
],
|
||||
"author": "Wes Todd",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/wesleytodd/setprototypeof/issues"
|
||||
},
|
||||
"homepage": "https://github.com/wesleytodd/setprototypeof",
|
||||
"devDependencies": {
|
||||
"mocha": "^6.1.4",
|
||||
"standard": "^13.0.2"
|
||||
}
|
||||
}
|
24
node_modules/raw-body/node_modules/setprototypeof/test/index.js
generated
vendored
Normal file
24
node_modules/raw-body/node_modules/setprototypeof/test/index.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
/* eslint-env mocha */
|
||||
/* eslint no-proto: 0 */
|
||||
var assert = require('assert')
|
||||
var setPrototypeOf = require('..')
|
||||
|
||||
describe('setProtoOf(obj, proto)', function () {
|
||||
it('should merge objects', function () {
|
||||
var obj = { a: 1, b: 2 }
|
||||
var proto = { b: 3, c: 4 }
|
||||
var mergeObj = setPrototypeOf(obj, proto)
|
||||
|
||||
if (Object.getPrototypeOf) {
|
||||
assert.strictEqual(Object.getPrototypeOf(obj), proto)
|
||||
} else if ({ __proto__: [] } instanceof Array) {
|
||||
assert.strictEqual(obj.__proto__, proto)
|
||||
} else {
|
||||
assert.strictEqual(obj.a, 1)
|
||||
assert.strictEqual(obj.b, 2)
|
||||
assert.strictEqual(obj.c, 4)
|
||||
}
|
||||
assert.strictEqual(mergeObj, obj)
|
||||
})
|
||||
})
|
82
node_modules/raw-body/node_modules/statuses/HISTORY.md
generated
vendored
Normal file
82
node_modules/raw-body/node_modules/statuses/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
2.0.1 / 2021-01-03
|
||||
==================
|
||||
|
||||
* Fix returning values from `Object.prototype`
|
||||
|
||||
2.0.0 / 2020-04-19
|
||||
==================
|
||||
|
||||
* Drop support for Node.js 0.6
|
||||
* Fix messaging casing of `418 I'm a Teapot`
|
||||
* Remove code 306
|
||||
* Remove `status[code]` exports; use `status.message[code]`
|
||||
* Remove `status[msg]` exports; use `status.code[msg]`
|
||||
* Rename `425 Unordered Collection` to standard `425 Too Early`
|
||||
* Rename `STATUS_CODES` export to `message`
|
||||
* Return status message for `statuses(code)` when given code
|
||||
|
||||
1.5.0 / 2018-03-27
|
||||
==================
|
||||
|
||||
* Add `103 Early Hints`
|
||||
|
||||
1.4.0 / 2017-10-20
|
||||
==================
|
||||
|
||||
* Add `STATUS_CODES` export
|
||||
|
||||
1.3.1 / 2016-11-11
|
||||
==================
|
||||
|
||||
* Fix return type in JSDoc
|
||||
|
||||
1.3.0 / 2016-05-17
|
||||
==================
|
||||
|
||||
* Add `421 Misdirected Request`
|
||||
* perf: enable strict mode
|
||||
|
||||
1.2.1 / 2015-02-01
|
||||
==================
|
||||
|
||||
* Fix message for status 451
|
||||
- `451 Unavailable For Legal Reasons`
|
||||
|
||||
1.2.0 / 2014-09-28
|
||||
==================
|
||||
|
||||
* Add `208 Already Repored`
|
||||
* Add `226 IM Used`
|
||||
* Add `306 (Unused)`
|
||||
* Add `415 Unable For Legal Reasons`
|
||||
* Add `508 Loop Detected`
|
||||
|
||||
1.1.1 / 2014-09-24
|
||||
==================
|
||||
|
||||
* Add missing 308 to `codes.json`
|
||||
|
||||
1.1.0 / 2014-09-21
|
||||
==================
|
||||
|
||||
* Add `codes.json` for universal support
|
||||
|
||||
1.0.4 / 2014-08-20
|
||||
==================
|
||||
|
||||
* Package cleanup
|
||||
|
||||
1.0.3 / 2014-06-08
|
||||
==================
|
||||
|
||||
* Add 308 to `.redirect` category
|
||||
|
||||
1.0.2 / 2014-03-13
|
||||
==================
|
||||
|
||||
* Add `.retry` category
|
||||
|
||||
1.0.1 / 2014-03-12
|
||||
==================
|
||||
|
||||
* Initial release
|
23
node_modules/raw-body/node_modules/statuses/LICENSE
generated
vendored
Normal file
23
node_modules/raw-body/node_modules/statuses/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.
|
136
node_modules/raw-body/node_modules/statuses/README.md
generated
vendored
Normal file
136
node_modules/raw-body/node_modules/statuses/README.md
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
# statuses
|
||||
|
||||
[![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][ci-image]][ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
HTTP status utility for node.
|
||||
|
||||
This module provides a list of status codes and messages sourced from
|
||||
a few different projects:
|
||||
|
||||
* The [IANA Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
|
||||
* The [Node.js project](https://nodejs.org/)
|
||||
* The [NGINX project](https://www.nginx.com/)
|
||||
* The [Apache HTTP Server project](https://httpd.apache.org/)
|
||||
|
||||
## 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 statuses
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```js
|
||||
var status = require('statuses')
|
||||
```
|
||||
|
||||
### status(code)
|
||||
|
||||
Returns the status message string for a known HTTP status code. The code
|
||||
may be a number or a string. An error is thrown for an unknown status code.
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
status(403) // => 'Forbidden'
|
||||
status('403') // => 'Forbidden'
|
||||
status(306) // throws
|
||||
```
|
||||
|
||||
### status(msg)
|
||||
|
||||
Returns the numeric status code for a known HTTP status message. The message
|
||||
is case-insensitive. An error is thrown for an unknown status message.
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
status('forbidden') // => 403
|
||||
status('Forbidden') // => 403
|
||||
status('foo') // throws
|
||||
```
|
||||
|
||||
### status.codes
|
||||
|
||||
Returns an array of all the status codes as `Integer`s.
|
||||
|
||||
### status.code[msg]
|
||||
|
||||
Returns the numeric status code for a known status message (in lower-case),
|
||||
otherwise `undefined`.
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-expressions -->
|
||||
|
||||
```js
|
||||
status['not found'] // => 404
|
||||
```
|
||||
|
||||
### status.empty[code]
|
||||
|
||||
Returns `true` if a status code expects an empty body.
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-expressions -->
|
||||
|
||||
```js
|
||||
status.empty[200] // => undefined
|
||||
status.empty[204] // => true
|
||||
status.empty[304] // => true
|
||||
```
|
||||
|
||||
### status.message[code]
|
||||
|
||||
Returns the string message for a known numeric status code, otherwise
|
||||
`undefined`. This object is the same format as the
|
||||
[Node.js http module `http.STATUS_CODES`](https://nodejs.org/dist/latest/docs/api/http.html#http_http_status_codes).
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-expressions -->
|
||||
|
||||
```js
|
||||
status.message[404] // => 'Not Found'
|
||||
```
|
||||
|
||||
### status.redirect[code]
|
||||
|
||||
Returns `true` if a status code is a valid redirect status.
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-expressions -->
|
||||
|
||||
```js
|
||||
status.redirect[200] // => undefined
|
||||
status.redirect[301] // => true
|
||||
```
|
||||
|
||||
### status.retry[code]
|
||||
|
||||
Returns `true` if you should retry the rest.
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-expressions -->
|
||||
|
||||
```js
|
||||
status.retry[501] // => undefined
|
||||
status.retry[503] // => true
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/jshttp/statuses/master?label=ci
|
||||
[ci-url]: https://github.com/jshttp/statuses/actions?query=workflow%3Aci
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/statuses/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master
|
||||
[node-version-image]: https://badgen.net/npm/node/statuses
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/statuses
|
||||
[npm-url]: https://npmjs.org/package/statuses
|
||||
[npm-version-image]: https://badgen.net/npm/v/statuses
|
65
node_modules/raw-body/node_modules/statuses/codes.json
generated
vendored
Normal file
65
node_modules/raw-body/node_modules/statuses/codes.json
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"100": "Continue",
|
||||
"101": "Switching Protocols",
|
||||
"102": "Processing",
|
||||
"103": "Early Hints",
|
||||
"200": "OK",
|
||||
"201": "Created",
|
||||
"202": "Accepted",
|
||||
"203": "Non-Authoritative Information",
|
||||
"204": "No Content",
|
||||
"205": "Reset Content",
|
||||
"206": "Partial Content",
|
||||
"207": "Multi-Status",
|
||||
"208": "Already Reported",
|
||||
"226": "IM Used",
|
||||
"300": "Multiple Choices",
|
||||
"301": "Moved Permanently",
|
||||
"302": "Found",
|
||||
"303": "See Other",
|
||||
"304": "Not Modified",
|
||||
"305": "Use Proxy",
|
||||
"307": "Temporary Redirect",
|
||||
"308": "Permanent Redirect",
|
||||
"400": "Bad Request",
|
||||
"401": "Unauthorized",
|
||||
"402": "Payment Required",
|
||||
"403": "Forbidden",
|
||||
"404": "Not Found",
|
||||
"405": "Method Not Allowed",
|
||||
"406": "Not Acceptable",
|
||||
"407": "Proxy Authentication Required",
|
||||
"408": "Request Timeout",
|
||||
"409": "Conflict",
|
||||
"410": "Gone",
|
||||
"411": "Length Required",
|
||||
"412": "Precondition Failed",
|
||||
"413": "Payload Too Large",
|
||||
"414": "URI Too Long",
|
||||
"415": "Unsupported Media Type",
|
||||
"416": "Range Not Satisfiable",
|
||||
"417": "Expectation Failed",
|
||||
"418": "I'm a Teapot",
|
||||
"421": "Misdirected Request",
|
||||
"422": "Unprocessable Entity",
|
||||
"423": "Locked",
|
||||
"424": "Failed Dependency",
|
||||
"425": "Too Early",
|
||||
"426": "Upgrade Required",
|
||||
"428": "Precondition Required",
|
||||
"429": "Too Many Requests",
|
||||
"431": "Request Header Fields Too Large",
|
||||
"451": "Unavailable For Legal Reasons",
|
||||
"500": "Internal Server Error",
|
||||
"501": "Not Implemented",
|
||||
"502": "Bad Gateway",
|
||||
"503": "Service Unavailable",
|
||||
"504": "Gateway Timeout",
|
||||
"505": "HTTP Version Not Supported",
|
||||
"506": "Variant Also Negotiates",
|
||||
"507": "Insufficient Storage",
|
||||
"508": "Loop Detected",
|
||||
"509": "Bandwidth Limit Exceeded",
|
||||
"510": "Not Extended",
|
||||
"511": "Network Authentication Required"
|
||||
}
|
146
node_modules/raw-body/node_modules/statuses/index.js
generated
vendored
Normal file
146
node_modules/raw-body/node_modules/statuses/index.js
generated
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
/*!
|
||||
* statuses
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2016 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var codes = require('./codes.json')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = status
|
||||
|
||||
// status code to message map
|
||||
status.message = codes
|
||||
|
||||
// status message (lower-case) to code map
|
||||
status.code = createMessageToStatusCodeMap(codes)
|
||||
|
||||
// array of status codes
|
||||
status.codes = createStatusCodeList(codes)
|
||||
|
||||
// status codes for redirects
|
||||
status.redirect = {
|
||||
300: true,
|
||||
301: true,
|
||||
302: true,
|
||||
303: true,
|
||||
305: true,
|
||||
307: true,
|
||||
308: true
|
||||
}
|
||||
|
||||
// status codes for empty bodies
|
||||
status.empty = {
|
||||
204: true,
|
||||
205: true,
|
||||
304: true
|
||||
}
|
||||
|
||||
// status codes for when you should retry the request
|
||||
status.retry = {
|
||||
502: true,
|
||||
503: true,
|
||||
504: true
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a map of message to status code.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createMessageToStatusCodeMap (codes) {
|
||||
var map = {}
|
||||
|
||||
Object.keys(codes).forEach(function forEachCode (code) {
|
||||
var message = codes[code]
|
||||
var status = Number(code)
|
||||
|
||||
// populate map
|
||||
map[message.toLowerCase()] = status
|
||||
})
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a list of all status codes.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createStatusCodeList (codes) {
|
||||
return Object.keys(codes).map(function mapCode (code) {
|
||||
return Number(code)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status code for given message.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getStatusCode (message) {
|
||||
var msg = message.toLowerCase()
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(status.code, msg)) {
|
||||
throw new Error('invalid status message: "' + message + '"')
|
||||
}
|
||||
|
||||
return status.code[msg]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status message for given code.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getStatusMessage (code) {
|
||||
if (!Object.prototype.hasOwnProperty.call(status.message, code)) {
|
||||
throw new Error('invalid status code: ' + code)
|
||||
}
|
||||
|
||||
return status.message[code]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status code.
|
||||
*
|
||||
* Given a number, this will throw if it is not a known status
|
||||
* code, otherwise the code will be returned. Given a string,
|
||||
* the string will be parsed for a number and return the code
|
||||
* if valid, otherwise will lookup the code assuming this is
|
||||
* the status message.
|
||||
*
|
||||
* @param {string|number} code
|
||||
* @returns {number}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function status (code) {
|
||||
if (typeof code === 'number') {
|
||||
return getStatusMessage(code)
|
||||
}
|
||||
|
||||
if (typeof code !== 'string') {
|
||||
throw new TypeError('code must be a number or string')
|
||||
}
|
||||
|
||||
// '403'
|
||||
var n = parseInt(code, 10)
|
||||
if (!isNaN(n)) {
|
||||
return getStatusMessage(n)
|
||||
}
|
||||
|
||||
return getStatusCode(code)
|
||||
}
|
49
node_modules/raw-body/node_modules/statuses/package.json
generated
vendored
Normal file
49
node_modules/raw-body/node_modules/statuses/package.json
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "statuses",
|
||||
"description": "HTTP status utility",
|
||||
"version": "2.0.1",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
],
|
||||
"repository": "jshttp/statuses",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"http",
|
||||
"status",
|
||||
"code"
|
||||
],
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"index.js",
|
||||
"codes.json",
|
||||
"LICENSE"
|
||||
],
|
||||
"devDependencies": {
|
||||
"csv-parse": "4.14.2",
|
||||
"eslint": "7.17.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"eslint-plugin-markdown": "1.0.2",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "4.2.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "8.2.1",
|
||||
"nyc": "15.1.0",
|
||||
"raw-body": "2.4.1",
|
||||
"stream-to-array": "2.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js",
|
||||
"fetch": "node scripts/fetch-apache.js && node scripts/fetch-iana.js && node scripts/fetch-nginx.js && node scripts/fetch-node.js",
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"update": "npm run fetch && npm run build",
|
||||
"version": "node scripts/version-history.js && git add HISTORY.md"
|
||||
}
|
||||
}
|
49
node_modules/raw-body/package.json
generated
vendored
Normal file
49
node_modules/raw-body/package.json
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "raw-body",
|
||||
"description": "Get and validate the raw body of a readable stream.",
|
||||
"version": "2.5.2",
|
||||
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Raynos <raynos2@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "stream-utils/raw-body",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"http-errors": "2.0.0",
|
||||
"iconv-lite": "0.4.24",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bluebird": "3.7.2",
|
||||
"eslint": "8.34.0",
|
||||
"eslint-config-standard": "15.0.1",
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"eslint-plugin-markdown": "3.0.0",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "6.1.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "10.2.0",
|
||||
"nyc": "15.1.0",
|
||||
"readable-stream": "2.3.7",
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"SECURITY.md",
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --trace-deprecation --reporter spec --bail --check-leaks test/",
|
||||
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user