aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/raw-body
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--node_modules/raw-body/LICENSE22
-rw-r--r--node_modules/raw-body/README.md223
-rw-r--r--node_modules/raw-body/index.d.ts85
-rw-r--r--node_modules/raw-body/index.js336
-rw-r--r--node_modules/raw-body/package.json46
5 files changed, 0 insertions, 712 deletions
diff --git a/node_modules/raw-body/LICENSE b/node_modules/raw-body/LICENSE
deleted file mode 100644
index 1029a7a..0000000
--- a/node_modules/raw-body/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-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.
diff --git a/node_modules/raw-body/README.md b/node_modules/raw-body/README.md
deleted file mode 100644
index d9b36d6..0000000
--- a/node_modules/raw-body/README.md
+++ /dev/null
@@ -1,223 +0,0 @@
-# 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
diff --git a/node_modules/raw-body/index.d.ts b/node_modules/raw-body/index.d.ts
deleted file mode 100644
index b504611..0000000
--- a/node_modules/raw-body/index.d.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-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: NodeJS.ReadableStream,
- callback: (err: getRawBody.RawBodyError, body: Buffer) => void
-): void;
-
-declare function getRawBody(
- stream: NodeJS.ReadableStream,
- options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding,
- callback: (err: getRawBody.RawBodyError, body: string) => void
-): void;
-
-declare function getRawBody(
- stream: NodeJS.ReadableStream,
- options: getRawBody.Options,
- callback: (err: getRawBody.RawBodyError, body: Buffer) => void
-): void;
-
-declare function getRawBody(
- stream: NodeJS.ReadableStream,
- options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding
-): Promise<string>;
-
-declare function getRawBody(
- stream: NodeJS.ReadableStream,
- options?: getRawBody.Options
-): Promise<Buffer>;
-
-export = getRawBody;
diff --git a/node_modules/raw-body/index.js b/node_modules/raw-body/index.js
deleted file mode 100644
index 9cdcd12..0000000
--- a/node_modules/raw-body/index.js
+++ /dev/null
@@ -1,336 +0,0 @@
-/*!
- * 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)
-}
diff --git a/node_modules/raw-body/package.json b/node_modules/raw-body/package.json
deleted file mode 100644
index eab819f..0000000
--- a/node_modules/raw-body/package.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "name": "raw-body",
- "description": "Get and validate the raw body of a readable stream.",
- "version": "3.0.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.1",
- "iconv-lite": "~0.7.0",
- "unpipe": "~1.0.0"
- },
- "devDependencies": {
- "@stylistic/eslint-plugin": "^5.1.0",
- "@stylistic/eslint-plugin-js": "^4.1.0",
- "bluebird": "3.7.2",
- "eslint": "^9.0.0",
- "mocha": "10.7.0",
- "neostandard": "^0.12.0",
- "nyc": "17.0.0",
- "readable-stream": "2.3.7",
- "safe-buffer": "5.2.1"
- },
- "engines": {
- "node": ">= 0.10"
- },
- "files": [
- "LICENSE",
- "README.md",
- "index.d.ts",
- "index.js"
- ],
- "scripts": {
- "lint": "eslint",
- "lint:fix": "eslint --fix",
- "test": "mocha --trace-deprecation --reporter spec --check-leaks test/",
- "test:ci": "nyc --reporter=lcovonly --reporter=text npm test",
- "test:cov": "nyc --reporter=html --reporter=text npm test",
- "version": "node scripts/version-history.js && git add HISTORY.md"
- }
-}