// by Alexander Ezharjan
// 由艾孜尔江制作,直接复制本JavaScript脚本并使用Node命令在终端内运行即可在本机80端口实现HTTP服务器.
module.exports =
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 5763:
/***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => {
const express = __nccwpck_require__(9455);
const app = express();
const bodyParser = __nccwpck_require__(3241);
app.use(express.static(__dirname));
//console.log(__dirname);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.get(\'/test\', (req, res) => {
console.log(\'axios get handled !\');
res.send(\'Your request handled !\');
});
app.get(\'/\', (req, resp) => { indexPageResponse(req, resp) });
app.get(\'/index.html\', (req, resp) => { indexPageResponse(req, resp) });
app.get(\'/index.htm\', (req, resp) => { indexPageResponse(req, resp) });
app.get(\'/index\', (req, resp) => { indexPageResponse(req, resp) });
app.listen(80, () => {
console.log(\'Server is running...\')
});
const indexPageResponse = (_req, _resp) => {
console.log("Remote IP is %s", _req.connection.remoteAddress, "; Remote port is: ", _req.connection.remotePort, ".");
_resp.send(indexHTML);
}
/*允许跨域 */
app.use(function (req, res, next) {
//console.log(req);
console.log(req.method);
res.header("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Token,Accept,Authorization");
res.header(\'Access-Control-Allow-Methods\', \'OPTIONS,GET,POST,PUT,DELETE\');
res.header("Access-Control-Allow-Headers", "Content-Type,Access-Token");
res.header("content-type", "multipart/form-data");
res.header("content-type", "application/x-www-form-urlencoded");
res.header("content-type", "application/json; charset=utf-8");
res.header("Access-Control-Allow-Credentials", "true");
res.header("Access-Control-Expose-Headers", "*");
res.header("Access-Control-Allow-Methods", "*");
res.header("Access-Control-Allow-Origin", "*");
res.header("cache-control", "no-cache");
res.header("ETag", \'\');
//header头信息设置结束后,结束程序往下执行,返回
if (req.method.toLocaleLowerCase() === \'options\') {
res.status(204);
return res.json({}); //直接返回空数据,结束此次请求
} else {
next();
}
});
let indexHTML = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Serv</title>
</head>
<div align="center">
<h1>Welcome to Serv developed by Alexander Ezharjan</h1>
<h1></h1>
<h3>You can visit any files at the relevant directory with http80server.js file.</h3>
</div>
<body>
</body>
</html>
`;
/***/
}),
/***/ 7370:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* accepts
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var Negotiator = __nccwpck_require__(5664)
var mime = __nccwpck_require__(8398)
/**
* Module exports.
* @public
*/
module.exports = Accepts
/**
* Create a new Accepts object for the given req.
*
* @param {object} req
* @public
*/
function Accepts(req) {
if (!(this instanceof Accepts)) {
return new Accepts(req)
}
this.headers = req.headers
this.negotiator = new Negotiator(req)
}
/**
* Check if the given `type(s)` is acceptable, returning
* the best match when true, otherwise `undefined`, in which
* case you should respond with 406 "Not Acceptable".
*
* The `type` value may be a single mime type string
* such as "application/json", the extension name
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
* or array is given the _best_ match, if any is returned.
*
* Examples:
*
* // Accept: text/html
* this.types(\'html\');
* // => "html"
*
* // Accept: text/*, application/json
* this.types(\'html\');
* // => "html"
* this.types(\'text/html\');
* // => "text/html"
* this.types(\'json\', \'text\');
* // => "json"
* this.types(\'application/json\');
* // => "application/json"
*
* // Accept: text/*, application/json
* this.types(\'image/png\');
* this.types(\'png\');
* // => undefined
*
* // Accept: text/*;q=.5, application/json
* this.types([\'html\', \'json\']);
* this.types(\'html\', \'json\');
* // => "json"
*
* @param {String|Array} types...
* @return {String|Array|Boolean}
* @public
*/
Accepts.prototype.type =
Accepts.prototype.types = function (types_) {
var types = types_
// support flattened arguments
if (types && !Array.isArray(types)) {
types = new Array(arguments.length)
for (var i = 0; i < types.length; i++) {
types[i] = arguments[i]
}
}
// no types, return all requested types
if (!types || types.length === 0) {
return this.negotiator.mediaTypes()
}
// no accept header, return first given type
if (!this.headers.accept) {
return types[0]
}
var mimes = types.map(extToMime)
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
var first = accepts[0]
return first
? types[mimes.indexOf(first)]
: false
}
/**
* Return accepted encodings or best fit based on `encodings`.
*
* Given `Accept-Encoding: gzip, deflate`
* an array sorted by quality is returned:
*
* [\'gzip\', \'deflate\']
*
* @param {String|Array} encodings...
* @return {String|Array}
* @public
*/
Accepts.prototype.encoding =
Accepts.prototype.encodings = function (encodings_) {
var encodings = encodings_
// support flattened arguments
if (encodings && !Array.isArray(encodings)) {
encodings = new Array(arguments.length)
for (var i = 0; i < encodings.length; i++) {
encodings[i] = arguments[i]
}
}
// no encodings, return all requested encodings
if (!encodings || encodings.length === 0) {
return this.negotiator.encodings()
}
return this.negotiator.encodings(encodings)[0] || false
}
/**
* Return accepted charsets or best fit based on `charsets`.
*
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
* an array sorted by quality is returned:
*
* [\'utf-8\', \'utf-7\', \'iso-8859-1\']
*
* @param {String|Array} charsets...
* @return {String|Array}
* @public
*/
Accepts.prototype.charset =
Accepts.prototype.charsets = function (charsets_) {
var charsets = charsets_
// support flattened arguments
if (charsets && !Array.isArray(charsets)) {
charsets = new Array(arguments.length)
for (var i = 0; i < charsets.length; i++) {
charsets[i] = arguments[i]
}
}
// no charsets, return all requested charsets
if (!charsets || charsets.length === 0) {
return this.negotiator.charsets()
}
return this.negotiator.charsets(charsets)[0] || false
}
/**
* Return accepted languages or best fit based on `langs`.
*
* Given `Accept-Language: en;q=0.8, es, pt`
* an array sorted by quality is returned:
*
* [\'es\', \'pt\', \'en\']
*
* @param {String|Array} langs...
* @return {Array|String}
* @public
*/
Accepts.prototype.lang =
Accepts.prototype.langs =
Accepts.prototype.language =
Accepts.prototype.languages = function (languages_) {
var languages = languages_
// support flattened arguments
if (languages && !Array.isArray(languages)) {
languages = new Array(arguments.length)
for (var i = 0; i < languages.length; i++) {
languages[i] = arguments[i]
}
}
// no languages, return all requested languages
if (!languages || languages.length === 0) {
return this.negotiator.languages()
}
return this.negotiator.languages(languages)[0] || false
}
/**
* Convert extnames to mime.
*
* @param {String} type
* @return {String}
* @private
*/
function extToMime(type) {
return type.indexOf(\'/\') === -1
? mime.lookup(type)
: type
}
/**
* Check if mime is valid.
*
* @param {String} type
* @return {String}
* @private
*/
function validMime(type) {
return typeof type === \'string\'
}
/***/
}),
/***/ 6663:
/***/ ((module) => {
"use strict";
/**
* Expose `arrayFlatten`.
*/
module.exports = arrayFlatten
/**
* Recursive flatten function with depth.
*
* @param {Array} array
* @param {Array} result
* @param {Number} depth
* @return {Array}
*/
function flattenWithDepth(array, result, depth) {
for (var i = 0; i < array.length; i++) {
var value = array[i]
if (depth > 0 && Array.isArray(value)) {
flattenWithDepth(value, result, depth - 1)
} else {
result.push(value)
}
}
return result
}
/**
* Recursive flatten function. Omitting depth is slightly faster.
*
* @param {Array} array
* @param {Array} result
* @return {Array}
*/
function flattenForever(array, result) {
for (var i = 0; i < array.length; i++) {
var value = array[i]
if (Array.isArray(value)) {
flattenForever(value, result)
} else {
result.push(value)
}
}
return result
}
/**
* Flatten an array, with the ability to define a depth.
*
* @param {Array} array
* @param {Number} depth
* @return {Array}
*/
function arrayFlatten(array, depth) {
if (depth == null) {
return flattenForever(array, [])
}
return flattenWithDepth(array, [], depth)
}
/***/
}),
/***/ 3241:
/***/ ((module, exports, __nccwpck_require__) => {
"use strict";
/*!
* body-parser
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var deprecate = __nccwpck_require__(2225)(\'body-parser\')
/**
* Cache of loaded parsers.
* @private
*/
var parsers = Object.create(null)
/**
* @typedef Parsers
* @type {function}
* @property {function} json
* @property {function} raw
* @property {function} text
* @property {function} urlencoded
*/
/**
* Module exports.
* @type {Parsers}
*/
exports = module.exports = deprecate.function(bodyParser,
\'bodyParser: use individual json/urlencoded middlewares\')
/**
* JSON parser.
* @public
*/
Object.defineProperty(exports, "json", ({
configurable: true,
enumerable: true,
get: createParserGetter(\'json\')
}))
/**
* Raw parser.
* @public
*/
Object.defineProperty(exports, "raw", ({
configurable: true,
enumerable: true,
get: createParserGetter(\'raw\')
}))
/**
* Text parser.
* @public
*/
Object.defineProperty(exports, "text", ({
configurable: true,
enumerable: true,
get: createParserGetter(\'text\')
}))
/**
* URL-encoded parser.
* @public
*/
Object.defineProperty(exports, "urlencoded", ({
configurable: true,
enumerable: true,
get: createParserGetter(\'urlencoded\')
}))
/**
* Create a middleware to parse json and urlencoded bodies.
*
* @param {object} [options]
* @return {function}
* @deprecated
* @public
*/
function bodyParser(options) {
var opts = {}
// exclude type option
if (options) {
for (var prop in options) {
if (prop !== \'type\') {
opts[prop] = options[prop]
}
}
}
var _urlencoded = exports.urlencoded(opts)
var _json = exports.json(opts)
return function bodyParser(req, res, next) {
_json(req, res, function (err) {
if (err) return next(err)
_urlencoded(req, res, next)
})
}
}
/**
* Create a getter for loading a parser.
* @private
*/
function createParserGetter(name) {
return function get() {
return loadParser(name)
}
}
/**
* Load a parser module.
* @private
*/
function loadParser(parserName) {
var parser = parsers[parserName]
if (parser !== undefined) {
return parser
}
// this uses a switch for static require analysis
switch (parserName) {
case \'json\':
parser = __nccwpck_require__(1172)
break
case \'raw\':
parser = __nccwpck_require__(9515)
break
case \'text\':
parser = __nccwpck_require__(85)
break
case \'urlencoded\':
parser = __nccwpck_require__(758)
break
}
// store to prevent invoking require()
return (parsers[parserName] = parser)
}
/***/
}),
/***/ 3051:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* body-parser
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var createError = __nccwpck_require__(3308)
var getBody = __nccwpck_require__(40)
var iconv = __nccwpck_require__(3655)
var onFinished = __nccwpck_require__(7117)
var zlib = __nccwpck_require__(8761)
/**
* Module exports.
*/
module.exports = read
/**
* Read a request into a buffer and parse.
*
* @param {object} req
* @param {object} res
* @param {function} next
* @param {function} parse
* @param {function} debug
* @param {object} options
* @private
*/
function read(req, res, next, parse, debug, options) {
var length
var opts = options
var stream
// flag as parsed
req._body = true
// read options
var encoding = opts.encoding !== null
? opts.encoding
: null
var verify = opts.verify
try {
// get the content stream
stream = contentstream(req, debug, opts.inflate)
length = stream.length
stream.length = undefined
} catch (err) {
return next(err)
}
// set raw-body options
opts.length = length
opts.encoding = verify
? null
: encoding
// assert charset is supported
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
return next(createError(415, \'unsupported charset "\' + encoding.toUpperCase() + \'"\', {
charset: encoding.toLowerCase(),
type: \'charset.unsupported\'
}))
}
// read body
debug(\'read body\')
getBody(stream, opts, function (error, body) {
if (error) {
var _error
if (error.type === \'encoding.unsupported\') {
// echo back charset
_error = createError(415, \'unsupported charset "\' + encoding.toUpperCase() + \'"\', {
charset: encoding.toLowerCase(),
type: \'charset.unsupported\'
})
} else {
// set status code on error
_error = createError(400, error)
}
// read off entire request
stream.resume()
onFinished(req, function onfinished() {
next(createError(400, _error))
})
return
}
// verify
if (verify) {
try {
debug(\'verify body\')
verify(req, res, body, encoding)
} catch (err) {
next(createError(403, err, {
body: body,
type: err.type || \'entity.verify.failed\'
}))
return
}
}
// parse
var str = body
try {
debug(\'parse body\')
str = typeof body !== \'string\' && encoding !== null
? iconv.decode(body, encoding)
: body
req.body = parse(str)
} catch (err) {
next(createError(400, err, {
body: str,
type: err.type || \'entity.parse.failed\'
}))
return
}
next()
})
}
/**
* Get the content stream of the request.
*
* @param {object} req
* @param {function} debug
* @param {boolean} [inflate=true]
* @return {object}
* @api private
*/
function contentstream(req, debug, inflate) {
var encoding = (req.headers[\'content-encoding\'] || \'identity\').toLowerCase()
var length = req.headers[\'content-length\']
var stream
debug(\'content-encoding "%s"\', encoding)
if (inflate === false && encoding !== \'identity\') {
throw createError(415, \'content encoding unsupported\', {
encoding: encoding,
type: \'encoding.unsupported\'
})
}
switch (encoding) {
case \'deflate\':
stream = zlib.createInflate()
debug(\'inflate body\')
req.pipe(stream)
break
case \'gzip\':
stream = zlib.createGunzip()
debug(\'gunzip body\')
req.pipe(stream)
break
case \'identity\':
stream = req
stream.length = length
break
default:
throw createError(415, \'unsupported content encoding "\' + encoding + \'"\', {
encoding: encoding,
type: \'encoding.unsupported\'
})
}
return stream
}
/***/
}),
/***/ 1172:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* body-parser
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var bytes = __nccwpck_require__(324)
var contentType = __nccwpck_require__(7237)
var createError = __nccwpck_require__(3308)
var debug = __nccwpck_require__(8609)(\'body-parser:json\')
var read = __nccwpck_require__(3051)
var typeis = __nccwpck_require__(6393)
/**
* Module exports.
*/
module.exports = json
/**
* RegExp to match the first non-space in a string.
*
* Allowed whitespace is defined in RFC 7159:
*
* ws = *(
* %x20 / ; Space
* %x09 / ; Horizontal tab
* %x0A / ; Line feed or New line
* %x0D ) ; Carriage return
*/
var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*(.)/ // eslint-disable-line no-control-regex
/**
* Create a middleware to parse JSON bodies.
*
* @param {object} [options]
* @return {function}
* @public
*/
function json(options) {
var opts = options || {}
var limit = typeof opts.limit !== \'number\'
? bytes.parse(opts.limit || \'100kb\')
: opts.limit
var inflate = opts.inflate !== false
var reviver = opts.reviver
var strict = opts.strict !== false
var type = opts.type || \'application/json\'
var verify = opts.verify || false
if (verify !== false && typeof verify !== \'function\') {
throw new TypeError(\'option verify must be function\')
}
// create the appropriate type checking function
var shouldParse = typeof type !== \'function\'
? typeChecker(type)
: type
function parse(body) {
if (body.length === 0) {
// special-case empty json body, as it\'s a common client-side mistake
// TODO: maybe make this configurable or part of "strict" option
return {}
}
if (strict) {
var first = firstchar(body)
if (first !== \'{\' && first !== \'[\') {
debug(\'strict violation\')
throw createStrictSyntaxError(body, first)
}
}
try {
debug(\'parse json\')
return JSON.parse(body, reviver)
} catch (e) {
throw normalizeJsonSyntaxError(e, {
message: e.message,
stack: e.stack
})
}
}
return function jsonParser(req, res, next) {
if (req._body) {
debug(\'body already parsed\')
next()
return
}
req.body = req.body || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {
debug(\'skip empty body\')
next()
return
}
debug(\'content-type %j\', req.headers[\'content-type\'])
// determine if request should be parsed
if (!shouldParse(req)) {
debug(\'skip parsing\')
next()
return
}
// assert charset per RFC 7159 sec 8.1
var charset = getCharset(req) || \'utf-8\'
if (charset.substr(0, 4) !== \'utf-\') {
debug(\'invalid charset\')
next(createError(415, \'unsupported charset "\' + charset.toUpperCase() + \'"\', {
charset: charset,
type: \'charset.unsupported\'
}))
return
}
// read
read(req, res, next, parse, debug, {
encoding: charset,
inflate: inflate,
limit: limit,
verify: verify
})
}
}
/**
* Create strict violation syntax error matching native error.
*
* @param {string} str
* @param {string} char
* @return {Error}
* @private
*/
function createStrictSyntaxError(str, char) {
var index = str.indexOf(char)
var partial = str.substring(0, index) + \'#\'
try {
JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError(\'strict violation\')
} catch (e) {
return normalizeJsonSyntaxError(e, {
message: e.message.replace(\'#\', char),
stack: e.stack
})
}
}
/**
* Get the first non-whitespace character in a string.
*
* @param {string} str
* @return {function}
* @private
*/
function firstchar(str) {
return FIRST_CHAR_REGEXP.exec(str)[1]
}
/**
* Get the charset of a request.
*
* @param {object} req
* @api private
*/
function getCharset(req) {
try {
return (contentType.parse(req).parameters.charset || \'\').toLowerCase()
} catch (e) {
return undefined
}
}
/**
* Normalize a SyntaxError for JSON.parse.
*
* @param {SyntaxError} error
* @param {object} obj
* @return {SyntaxError}
*/
function normalizeJsonSyntaxError(error, obj) {
var keys = Object.getOwnPropertyNames(error)
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
if (key !== \'stack\' && key !== \'message\') {
delete error[key]
}
}
// replace stack before message for Node.js 0.10 and below
error.stack = obj.stack.replace(error.message, obj.message)
error.message = obj.message
return error
}
/**
* Get the simple type checker.
*
* @param {string} type
* @return {function}
*/
function typeChecker(type) {
return function checkType(req) {
return Boolean(typeis(req, type))
}
}
/***/
}),
/***/ 9515:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* body-parser
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
*/
var bytes = __nccwpck_require__(324)
var debug = __nccwpck_require__(8609)(\'body-parser:raw\')
var read = __nccwpck_require__(3051)
var typeis = __nccwpck_require__(6393)
/**
* Module exports.
*/
module.exports = raw
/**
* Create a middleware to parse raw bodies.
*
* @param {object} [options]
* @return {function}
* @api public
*/
function raw(options) {
var opts = options || {}
var inflate = opts.inflate !== false
var limit = typeof opts.limit !== \'number\'
? bytes.parse(opts.limit || \'100kb\')
: opts.limit
var type = opts.type || \'application/octet-stream\'
var verify = opts.verify || false
if (verify !== false && typeof verify !== \'function\') {
throw new TypeError(\'option verify must be function\')
}
// create the appropriate type checking function
var shouldParse = typeof type !== \'function\'
? typeChecker(type)
: type
function parse(buf) {
return buf
}
return function rawParser(req, res, next) {
if (req._body) {
debug(\'body already parsed\')
next()
return
}
req.body = req.body || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {
debug(\'skip empty body\')
next()
return
}
debug(\'content-type %j\', req.headers[\'content-type\'])
// determine if request should be parsed
if (!shouldParse(req)) {
debug(\'skip parsing\')
next()
return
}
// read
read(req, res, next, parse, debug, {
encoding: null,
inflate: inflate,
limit: limit,
verify: verify
})
}
}
/**
* Get the simple type checker.
*
* @param {string} type
* @return {function}
*/
function typeChecker(type) {
return function checkType(req) {
return Boolean(typeis(req, type))
}
}
/***/
}),
/***/ 85:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* body-parser
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
*/
var bytes = __nccwpck_require__(324)
var contentType = __nccwpck_require__(7237)
var debug = __nccwpck_require__(8609)(\'body-parser:text\')
var read = __nccwpck_require__(3051)
var typeis = __nccwpck_require__(6393)
/**
* Module exports.
*/
module.exports = text
/**
* Create a middleware to parse text bodies.
*
* @param {object} [options]
* @return {function}
* @api public
*/
function text(options) {
var opts = options || {}
var defaultCharset = opts.defaultCharset || \'utf-8\'
var inflate = opts.inflate !== false
var limit = typeof opts.limit !== \'number\'
? bytes.parse(opts.limit || \'100kb\')
: opts.limit
var type = opts.type || \'text/plain\'
var verify = opts.verify || false
if (verify !== false && typeof verify !== \'function\') {
throw new TypeError(\'option verify must be function\')
}
// create the appropriate type checking function
var shouldParse = typeof type !== \'function\'
? typeChecker(type)
: type
function parse(buf) {
return buf
}
return function textParser(req, res, next) {
if (req._body) {
debug(\'body already parsed\')
next()
return
}
req.body = req.body || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {
debug(\'skip empty body\')
next()
return
}
debug(\'content-type %j\', req.headers[\'content-type\'])
// determine if request should be parsed
if (!shouldParse(req)) {
debug(\'skip parsing\')
next()
return
}
// get charset
var charset = getCharset(req) || defaultCharset
// read
read(req, res, next, parse, debug, {
encoding: charset,
inflate: inflate,
limit: limit,
verify: verify
})
}
}
/**
* Get the charset of a request.
*
* @param {object} req
* @api private
*/
function getCharset(req) {
try {
return (contentType.parse(req).parameters.charset || \'\').toLowerCase()
} catch (e) {
return undefined
}
}
/**
* Get the simple type checker.
*
* @param {string} type
* @return {function}
*/
function typeChecker(type) {
return function checkType(req) {
return Boolean(typeis(req, type))
}
}
/***/
}),
/***/ 758:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* body-parser
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var bytes = __nccwpck_require__(324)
var contentType = __nccwpck_require__(7237)
var createError = __nccwpck_require__(3308)
var debug = __nccwpck_require__(8609)(\'body-parser:urlencoded\')
var deprecate = __nccwpck_require__(2225)(\'body-parser\')
var read = __nccwpck_require__(3051)
var typeis = __nccwpck_require__(6393)
/**
* Module exports.
*/
module.exports = urlencoded
/**
* Cache of parser modules.
*/
var parsers = Object.create(null)
/**
* Create a middleware to parse urlencoded bodies.
*
* @param {object} [options]
* @return {function}
* @public
*/
function urlencoded(options) {
var opts = options || {}
// notice because option default will flip in next major
if (opts.extended === undefined) {
deprecate(\'undefined extended: provide extended option\')
}
var extended = opts.extended !== false
var inflate = opts.inflate !== false
var limit = typeof opts.limit !== \'number\'
? bytes.parse(opts.limit || \'100kb\')
: opts.limit
var type = opts.type || \'application/x-www-form-urlencoded\'
var verify = opts.verify || false
if (verify !== false && typeof verify !== \'function\') {
throw new TypeError(\'option verify must be function\')
}
// create the appropriate query parser
var queryparse = extended
? extendedparser(opts)
: simpleparser(opts)
// create the appropriate type checking function
var shouldParse = typeof type !== \'function\'
? typeChecker(type)
: type
function parse(body) {
return body.length
? queryparse(body)
: {}
}
return function urlencodedParser(req, res, next) {
if (req._body) {
debug(\'body already parsed\')
next()
return
}
req.body = req.body || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {
debug(\'skip empty body\')
next()
return
}
debug(\'content-type %j\', req.headers[\'content-type\'])
// determine if request should be parsed
if (!shouldParse(req)) {
debug(\'skip parsing\')
next()
return
}
// assert charset
var charset = getCharset(req) || \'utf-8\'
if (charset !== \'utf-8\') {
debug(\'invalid charset\')
next(createError(415, \'unsupported charset "\' + charset.toUpperCase() + \'"\', {
charset: charset,
type: \'charset.unsupported\'
}))
return
}
// read
read(req, res, next, parse, debug, {
debug: debug,
encoding: charset,
inflate: inflate,
limit: limit,
verify: verify
})
}
}
/**
* Get the extended query parser.
*
* @param {object} options
*/
function extendedparser(options) {
var parameterLimit = options.parameterLimit !== undefined
? options.parameterLimit
: 1000
var parse = parser(\'qs\')
if (isNaN(parameterLimit) || parameterLimit < 1) {
throw new TypeError(\'option parameterLimit must be a positive number\')
}
if (isFinite(parameterLimit)) {
parameterLimit = parameterLimit | 0
}
return function queryparse(body) {
var paramCount = parameterCount(body, parameterLimit)
if (paramCount === undefined) {
debug(\'too many parameters\')
throw createError(413, \'too many parameters\', {
type: \'parameters.too.many\'
})
}
var arrayLimit = Math.max(100, paramCount)
debug(\'parse extended urlencoding\')
return parse(body, {
allowPrototypes: true,
arrayLimit: arrayLimit,
depth: Infinity,
parameterLimit: parameterLimit
})
}
}
/**
* Get the charset of a request.
*
* @param {object} req
* @api private
*/
function getCharset(req) {
try {
return (contentType.parse(req).parameters.charset || \'\').toLowerCase()
} catch (e) {
return undefined
}
}
/**
* Count the number of parameters, stopping once limit reached
*
* @param {string} body
* @param {number} limit
* @api private
*/
function parameterCount(body, limit) {
var count = 0
var index = 0
while ((index = body.indexOf(\'&\', index)) !== -1) {
count++
index++
if (count === limit) {
return undefined
}
}
return count
}
/**
* Get parser for module name dynamically.
*
* @param {string} name
* @return {function}
* @api private
*/
function parser(name) {
var mod = parsers[name]
if (mod !== undefined) {
return mod.parse
}
// this uses a switch for static require analysis
switch (name) {
case \'qs\':
mod = __nccwpck_require__(8556)
break
case \'querystring\':
mod = __nccwpck_require__(1191)
break
}
// store to prevent invoking require()
parsers[name] = mod
return mod.parse
}
/**
* Get the simple query parser.
*
* @param {object} options
*/
function simpleparser(options) {
var parameterLimit = options.parameterLimit !== undefined
? options.parameterLimit
: 1000
var parse = parser(\'querystring\')
if (isNaN(parameterLimit) || parameterLimit < 1) {
throw new TypeError(\'option parameterLimit must be a positive number\')
}
if (isFinite(parameterLimit)) {
parameterLimit = parameterLimit | 0
}
return function queryparse(body) {
var paramCount = parameterCount(body, parameterLimit)
if (paramCount === undefined) {
debug(\'too many parameters\')
throw createError(413, \'too many parameters\', {
type: \'parameters.too.many\'
})
}
debug(\'parse urlencoding\')
return parse(body, undefined, undefined, { maxKeys: parameterLimit })
}
}
/**
* Get the simple type checker.
*
* @param {string} type
* @return {function}
*/
function typeChecker(type) {
return function checkType(req) {
return Boolean(typeis(req, type))
}
}
/***/
}),
/***/ 324:
/***/ ((module) => {
"use strict";
/*!
* bytes
* Copyright(c) 2012-2014 TJ Holowaychuk
* Copyright(c) 2015 Jed Watson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = bytes;
module.exports.format = format;
module.exports.parse = parse;
/**
* Module variables.
* @private
*/
var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
var map = {
b: 1,
kb: 1 << 10,
mb: 1 << 20,
gb: 1 << 30,
tb: Math.pow(1024, 4),
pb: Math.pow(1024, 5),
};
var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
/**
* Convert the given value in bytes into a string or parse to string to an integer in bytes.
*
* @param {string|number} value
* @param {{
* case: [string],
* decimalPlaces: [number]
* fixedDecimals: [boolean]
* thousandsSeparator: [string]
* unitSeparator: [string]
* }} [options] bytes options.
*
* @returns {string|number|null}
*/
function bytes(value, options) {
if (typeof value === \'string\') {
return parse(value);
}
if (typeof value === \'number\') {
return format(value, options);
}
return null;
}
/**
* Format the given value in bytes into a string.
*
* If the value is negative, it is kept as such. If it is a float,
* it is rounded.
*
* @param {number} value
* @param {object} [options]
* @param {number} [options.decimalPlaces=2]
* @param {number} [options.fixedDecimals=false]
* @param {string} [options.thousandsSeparator=]
* @param {string} [options.unit=]
* @param {string} [options.unitSeparator=]
*
* @returns {string|null}
* @public
*/
function format(value, options) {
if (!Number.isFinite(value)) {
return null;
}
var mag = Math.abs(value);
var thousandsSeparator = (options && options.thousandsSeparator) || \'\';
var unitSeparator = (options && options.unitSeparator) || \'\';
var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
var fixedDecimals = Boolean(options && options.fixedDecimals);
var unit = (options && options.unit) || \'\';
if (!unit || !map[unit.toLowerCase()]) {
if (mag >= map.pb) {
unit = \'PB\';
} else if (mag >= map.tb) {
unit = \'TB\';
} else if (mag >= map.gb) {
unit = \'GB\';
} else if (mag >= map.mb) {
unit = \'MB\';
} else if (mag >= map.kb) {
unit = \'KB\';
} else {
unit = \'B\';
}
}
var val = value / map[unit.toLowerCase()];
var str = val.toFixed(decimalPlaces);
if (!fixedDecimals) {
str = str.replace(formatDecimalsRegExp, \'$1\');
}
if (thousandsSeparator) {
str = str.replace(formatThousandsRegExp, thousandsSeparator);
}
return str + unitSeparator + unit;
}
/**
* Parse the string value into an integer in bytes.
*
* If no unit is given, it is assumed the value is in bytes.
*
* @param {number|string} val
*
* @returns {number|null}
* @public
*/
function parse(val) {
if (typeof val === \'number\' && !isNaN(val)) {
return val;
}
if (typeof val !== \'string\') {
return null;
}
// Test if the string passed is valid
var results = parseRegExp.exec(val);
var floatValue;
var unit = \'b\';
if (!results) {
// Nothing could be extracted from the given string
floatValue = parseInt(val, 10);
unit = \'b\'
} else {
// Retrieve the value and the unit
floatValue = parseFloat(results[1]);
unit = results[4].toLowerCase();
}
return Math.floor(map[unit] * floatValue);
}
/***/
}),
/***/ 2505:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* content-disposition
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = contentDisposition
module.exports.parse = parse
/**
* Module dependencies.
* @private
*/
var basename = __nccwpck_require__(5622).basename
var Buffer = __nccwpck_require__(7608).Buffer
/**
* RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
* @private
*/
var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"\'()*,/:;<=>?@[\\\]{}\x7f]/g // eslint-disable-line no-control-regex
/**
* RegExp to match percent encoding escape.
* @private
*/
var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/
var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g
/**
* RegExp to match non-latin1 characters.
* @private
*/
var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g
/**
* RegExp to match quoted-pair in RFC 2616
*
* quoted-pair = "\" CHAR
* CHAR = <any US-ASCII character (octets 0 - 127)>
* @private
*/
var QESC_REGEXP = /\\([\u0000-\u007f])/g // eslint-disable-line no-control-regex
/**
* RegExp to match chars that must be quoted-pair in RFC 2616
* @private
*/
var QUOTE_REGEXP = /([\\"])/g
/**
* RegExp for various RFC 2616 grammar
*
* parameter = token "=" ( token | quoted-string )
* token = 1*<any CHAR except CTLs or separators>
* separators = "(" | ")" | "<" | ">" | "@"
* | "," | ";" | ":" | "\" | <">
* | "/" | "[" | "]" | "?" | "="
* | "{" | "}" | SP | HT
* quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
* qdtext = <any TEXT except <">>
* quoted-pair = "\" CHAR
* CHAR = <any US-ASCII character (octets 0 - 127)>
* TEXT = <any OCTET except CTLs, but including LWS>
* LWS = [CRLF] 1*( SP | HT )
* CRLF = CR LF
* CR = <US-ASCII CR, carriage return (13)>
* LF = <US-ASCII LF, linefeed (10)>
* SP = <US-ASCII SP, space (32)>
* HT = <US-ASCII HT, horizontal-tab (9)>
* CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
* OCTET = <any 8-bit sequence of data>
* @private
*/
var PARAM_REGEXP = /;[\x09\x20]*([!#$%&\'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&\'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g // eslint-disable-line no-control-regex
var TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/
var TOKEN_REGEXP = /^[!#$%&\'*+.0-9A-Z^_`a-z|~-]+$/
/**
* RegExp for various RFC 5987 grammar
*
* ext-value = charset "\'" [ language ] "\'" value-chars
* charset = "UTF-8" / "ISO-8859-1" / mime-charset
* mime-charset = 1*mime-charsetc
* mime-charsetc = ALPHA / DIGIT
* / "!" / "#" / "$" / "%" / "&"
* / "+" / "-" / "^" / "_" / "`"
* / "{" / "}" / "~"
* language = ( 2*3ALPHA [ extlang ] )
* / 4ALPHA
* / 5*8ALPHA
* extlang = *3( "-" 3ALPHA )
* value-chars = *( pct-encoded / attr-char )
* pct-encoded = "%" HEXDIG HEXDIG
* attr-char = ALPHA / DIGIT
* / "!" / "#" / "$" / "&" / "+" / "-" / "."
* / "^" / "_" / "`" / "|" / "~"
* @private
*/
var EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)\'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)\'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/
/**
* RegExp for various RFC 6266 grammar
*
* disposition-type = "inline" | "attachment" | disp-ext-type
* disp-ext-type = token
* disposition-parm = filename-parm | disp-ext-parm
* filename-parm = "filename" "=" value
* | "filename*" "=" ext-value
* disp-ext-parm = token "=" value
* | ext-token "=" ext-value
* ext-token = <the characters in token, followed by "*">
* @private
*/
var DISPOSITION_TYPE_REGEXP = /^([!#$%&\'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/ // eslint-disable-line no-control-regex
/**
* Create an attachment Content-Disposition header.
*
* @param {string} [filename]
* @param {object} [options]
* @param {string} [options.type=attachment]
* @param {string|boolean} [options.fallback=true]
* @return {string}
* @public
*/
function contentDisposition(filename, options) {
var opts = options || {}
// get type
var type = opts.type || \'attachment\'
// get parameters
var params = createparams(filename, opts.fallback)
// format into string
return format(new ContentDisposition(type, params))
}
/**
* Create parameters object from filename and fallback.
*
* @param {string} [filename]
* @param {string|boolean} [fallback=true]
* @return {object}
* @private
*/
function createparams(filename, fallback) {
if (filename === undefined) {
return
}
var params = {}
if (typeof filename !== \'string\') {
throw new TypeError(\'filename must be a string\')
}
// fallback defaults to true
if (fallback === undefined) {
fallback = true
}
if (typeof fallback !== \'string\' && typeof fallback !== \'boolean\') {
throw new TypeError(\'fallback must be a string or boolean\')
}
if (typeof fallback === \'string\' && NON_LATIN1_REGEXP.test(fallback)) {
throw new TypeError(\'fallback must be ISO-8859-1 string\')
}
// restrict to file base name
var name = basename(filename)
// determine if name is suitable for quoted string
var isQuotedString = TEXT_REGEXP.test(name)
// generate fallback name
var fallbackName = typeof fallback !== \'string\'
? fallback && getlatin1(name)
: basename(fallback)
var hasFallback = typeof fallbackName === \'string\' && fallbackName !== name
// set extended filename parameter
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
params[\'filename*\'] = name
}
// set filename parameter
if (isQuotedString || hasFallback) {
params.filename = hasFallback
? fallbackName
: name
}
return params
}
/**
* Format object to Content-Disposition header.
*
* @param {object} obj
* @param {string} obj.type
* @param {object} [obj.parameters]
* @return {string}
* @private
*/
function format(obj) {
var parameters = obj.parameters
var type = obj.type
if (!type || typeof type !== \'string\' || !TOKEN_REGEXP.test(type)) {
throw new TypeError(\'invalid type\')
}
// start with normalized type
var string = String(type).toLowerCase()
// append parameters
if (parameters && typeof parameters === \'object\') {
var param
var params = Object.keys(parameters).sort()
for (var i = 0; i < params.length; i++) {
param = params[i]
var val = param.substr(-1) === \'*\'
? ustring(parameters[param])
: qstring(parameters[param])
string += \'; \' + param + \'=\' + val
}
}
return string
}
/**
* Decode a RFC 6987 field value (gracefully).
*
* @param {string} str
* @return {string}
* @private
*/
function decodefield(str) {
var match = EXT_VALUE_REGEXP.exec(str)
if (!match) {
throw new TypeError(\'invalid extended field value\')
}
var charset = match[1].toLowerCase()
var encoded = match[2]
var value
// to binary string
var binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode)
switch (charset) {
case \'iso-8859-1\':
value = getlatin1(binary)
break
case \'utf-8\':
value = Buffer.from(binary, \'binary\').toString(\'utf8\')
break
default:
throw new TypeError(\'unsupported charset in extended field\')
}
return value
}
/**
* Get ISO-8859-1 version of string.
*
* @param {string} val
* @return {string}
* @private
*/
function getlatin1(val) {
// simple Unicode -> ISO-8859-1 transformation
return String(val).replace(NON_LATIN1_REGEXP, \'?\')
}
/**
* Parse Content-Disposition header string.
*
* @param {string} string
* @return {object}
* @public
*/
function parse(string) {
if (!string || typeof string !== \'string\') {
throw new TypeError(\'argument string is required\')
}
var match = DISPOSITION_TYPE_REGEXP.exec(string)
if (!match) {
throw new TypeError(\'invalid type format\')
}
// normalize type
var index = match[0].length
var type = match[1].toLowerCase()
var key
var names = []
var params = {}
var value
// calculate index to start at
index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === \';\'
? index - 1
: index
// match parameters
while ((match = PARAM_REGEXP.exec(string))) {
if (match.index !== index) {
throw new TypeError(\'invalid parameter format\')
}
index += match[0].length
key = match[1].toLowerCase()
value = match[2]
if (names.indexOf(key) !== -1) {
throw new TypeError(\'invalid duplicate parameter\')
}
names.push(key)
if (key.indexOf(\'*\') + 1 === key.length) {
// decode extended value
key = key.slice(0, -1)
value = decodefield(value)
// overwrite existing value
params[key] = value
continue
}
if (typeof params[key] === \'string\') {
continue
}
if (value[0] === \'"\') {
// remove quotes and escapes
value = value
.substr(1, value.length - 2)
.replace(QESC_REGEXP, \'$1\')
}
params[key] = value
}
if (index !== -1 && index !== string.length) {
throw new TypeError(\'invalid parameter format\')
}
return new ContentDisposition(type, params)
}
/**
* Percent decode a single character.
*
* @param {string} str
* @param {string} hex
* @return {string}
* @private
*/
function pdecode(str, hex) {
return String.fromCharCode(parseInt(hex, 16))
}
/**
* Percent encode a single character.
*
* @param {string} char
* @return {string}
* @private
*/
function pencode(char) {
return \'%\' + String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
}
/**
* Quote a string for HTTP.
*
* @param {string} val
* @return {string}
* @private
*/
function qstring(val) {
var str = String(val)
return \'"\' + str.replace(QUOTE_REGEXP, \'\\$1\') + \'"\'
}
/**
* Encode a Unicode string for HTTP (RFC 5987).
*
* @param {string} val
* @return {string}
* @private
*/
function ustring(val) {
var str = String(val)
// percent encode as UTF-8
var encoded = encodeURIComponent(str)
.replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode)
return \'UTF-8\\'\\'\' + encoded
}
/**
* Class for parsed Content-Disposition header for v8 optimization
*
* @public
* @param {string} type
* @param {object} parameters
* @constructor
*/
function ContentDisposition(type, parameters) {
this.type = type
this.parameters = parameters
}
/***/
}),
/***/ 7237:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
/*!
* content-type
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
*
* parameter = token "=" ( token / quoted-string )
* token = 1*tchar
* tchar = "!" / "#" / "$" / "%" / "&" / "\'" / "*"
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
* / DIGIT / ALPHA
* ; any VCHAR, except delimiters
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
* obs-text = %x80-FF
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
*/
var PARAM_REGEXP = /; *([!#$%&\'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&\'*+.^_`|~0-9A-Za-z-]+) */g
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/
var TOKEN_REGEXP = /^[!#$%&\'*+.^_`|~0-9A-Za-z-]+$/
/**
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6
*
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
* obs-text = %x80-FF
*/
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g
/**
* RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
*/
var QUOTE_REGEXP = /([\\"])/g
/**
* RegExp to match type in RFC 7231 sec 3.1.1.1
*
* media-type = type "/" subtype
* type = token
* subtype = token
*/
var TYPE_REGEXP = /^[!#$%&\'*+.^_`|~0-9A-Za-z-]+\/[!#$%&\'*+.^_`|~0-9A-Za-z-]+$/
/**
* Module exports.
* @public
*/
exports.format = format
exports.parse = parse
/**
* Format object to media type.
*
* @param {object} obj
* @return {string}
* @public
*/
function format(obj) {
if (!obj || typeof obj !== \'object\') {
throw new TypeError(\'argument obj is required\')
}
var parameters = obj.parameters
var type = obj.type
if (!type || !TYPE_REGEXP.test(type)) {
throw new TypeError(\'invalid type\')
}
var string = type
// append parameters
if (parameters && typeof parameters === \'object\') {
var param
var params = Object.keys(parameters).sort()
for (var i = 0; i < params.length; i++) {
param = params[i]
if (!TOKEN_REGEXP.test(param)) {
throw new TypeError(\'invalid parameter name\')
}
string += \'; \' + param + \'=\' + qstring(parameters[param])
}
}
return string
}
/**
* Parse media type to object.
*
* @param {string|object} string
* @return {Object}
* @public
*/
function parse(string) {
if (!string) {
throw new TypeError(\'argument string is required\')
}
// support req/res-like objects as argument
var header = typeof string === \'object\'
? getcontenttype(string)
: string
if (typeof header !== \'string\') {
throw new TypeError(\'argument string is required to be a string\')
}
var index = header.indexOf(\';\')
var type = index !== -1
? header.substr(0, index).trim()
: header.trim()
if (!TYPE_REGEXP.test(type)) {
throw new TypeError(\'invalid media type\')
}
var obj = new ContentType(type.toLowerCase())
// parse parameters
if (index !== -1) {
var key
var match
var value
PARAM_REGEXP.lastIndex = index
while ((match = PARAM_REGEXP.exec(header))) {
if (match.index !== index) {
throw new TypeError(\'invalid parameter format\')
}
index += match[0].length
key = match[1].toLowerCase()
value = match[2]
if (value[0] === \'"\') {
// remove quotes and escapes
value = value
.substr(1, value.length - 2)
.replace(QESC_REGEXP, \'$1\')
}
obj.parameters[key] = value
}
if (index !== header.length) {
throw new TypeError(\'invalid parameter format\')
}
}
return obj
}
/**
* Get content-type from req/res objects.
*
* @param {object}
* @return {Object}
* @private
*/
function getcontenttype(obj) {
var header
if (typeof obj.getHeader === \'function\') {
// res-like
header = obj.getHeader(\'content-type\')
} else if (typeof obj.headers === \'object\') {
// req-like
header = obj.headers && obj.headers[\'content-type\']
}
if (typeof header !== \'string\') {
throw new TypeError(\'content-type header is missing from object\')
}
return header
}
/**
* Quote a string if necessary.
*
* @param {string} val
* @return {string}
* @private
*/
function qstring(val) {
var str = String(val)
// no need to quote tokens
if (TOKEN_REGEXP.test(str)) {
return str
}
if (str.length > 0 && !TEXT_REGEXP.test(str)) {
throw new TypeError(\'invalid parameter value\')
}
return \'"\' + str.replace(QUOTE_REGEXP, \'\\$1\') + \'"\'
}
/**
* Class to represent a content type.
* @private
*/
function ContentType(type) {
this.parameters = Object.create(null)
this.type = type
}
/***/
}),
/***/ 3524:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
/**
* Module dependencies.
*/
var crypto = __nccwpck_require__(6417);
/**
* Sign the given `val` with `secret`.
*
* @param {String} val
* @param {String} secret
* @return {String}
* @api private
*/
exports.sign = function (val, secret) {
if (\'string\' != typeof val) throw new TypeError("Cookie value must be provided as a string.");
if (\'string\' != typeof secret) throw new TypeError("Secret string must be provided.");
return val + \'.\' + crypto
.createHmac(\'sha256\', secret)
.update(val)
.digest(\'base64\')
.replace(/\=+$/, \'\');
};
/**
* Unsign and decode the given `val` with `secret`,
* returning `false` if the signature is invalid.
*
* @param {String} val
* @param {String} secret
* @return {String|Boolean}
* @api private
*/
exports.unsign = function (val, secret) {
if (\'string\' != typeof val) throw new TypeError("Signed cookie string must be provided.");
if (\'string\' != typeof secret) throw new TypeError("Secret string must be provided.");
var str = val.slice(0, val.lastIndexOf(\'.\'))
, mac = exports.sign(str, secret);
return sha1(mac) == sha1(val) ? str : false;
};
/**
* Private
*/
function sha1(str) {
return crypto.createHash(\'sha1\').update(str).digest(\'hex\');
}
/***/
}),
/***/ 6810:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
/*!
* cookie
* Copyright(c) 2012-2014 Roman Shtylman
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
exports.parse = parse;
exports.serialize = serialize;
/**
* Module variables.
* @private
*/
var decode = decodeURIComponent;
var encode = encodeURIComponent;
var pairSplitRegExp = /; */;
/**
* RegExp to match field-content in RFC 7230 sec 3.2
*
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
* field-vchar = VCHAR / obs-text
* obs-text = %x80-FF
*/
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
/**
* Parse a cookie header.
*
* Parse the given cookie header string into an object
* The object has the various cookies as keys(names) => values
*
* @param {string} str
* @param {object} [options]
* @return {object}
* @public
*/
function parse(str, options) {
if (typeof str !== \'string\') {
throw new TypeError(\'argument str must be a string\');
}
var obj = {}
var opt = options || {};
var pairs = str.split(pairSplitRegExp);
var dec = opt.decode || decode;
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i];
var eq_idx = pair.indexOf(\'=\');
// skip things that don\'t look like key=value
if (eq_idx < 0) {
continue;
}
var key = pair.substr(0, eq_idx).trim()
var val = pair.substr(++eq_idx, pair.length).trim();
// quoted values
if (\'"\' == val[0]) {
val = val.slice(1, -1);
}
// only assign once
if (undefined == obj[key]) {
obj[key] = tryDecode(val, dec);
}
}
return obj;
}
/**
* Serialize data into a cookie header.
*
* Serialize the a name value pair into a cookie string suitable for
* http headers. An optional options object specified cookie parameters.
*
* serialize(\'foo\', \'bar\', { httpOnly: true })
* => "foo=bar; httpOnly"
*
* @param {string} name
* @param {string} val
* @param {object} [options]
* @return {string}
* @public
*/
function serialize(name, val, options) {
var opt = options || {};
var enc = opt.encode || encode;
if (typeof enc !== \'function\') {
throw new TypeError(\'option encode is invalid\');
}
if (!fieldContentRegExp.test(name)) {
throw new TypeError(\'argument name is invalid\');
}
var value = enc(val);
if (value && !fieldContentRegExp.test(value)) {
throw new TypeError(\'argument val is invalid\');
}
var str = name + \'=\' + value;
if (null != opt.maxAge) {
var maxAge = opt.maxAge - 0;
if (isNaN(maxAge)) throw new Error(\'maxAge should be a Number\');
str += \'; Max-Age=\' + Math.floor(maxAge);
}
if (opt.domain) {
if (!fieldContentRegExp.test(opt.domain)) {
throw new TypeError(\'option domain is invalid\');
}
str += \'; Domain=\' + opt.domain;
}
if (opt.path) {
if (!fieldContentRegExp.test(opt.path)) {
throw new TypeError(\'option path is invalid\');
}
str += \'; Path=\' + opt.path;
}
if (opt.expires) {
if (typeof opt.expires.toUTCString !== \'function\') {
throw new TypeError(\'option expires is invalid\');
}
str += \'; Expires=\' + opt.expires.toUTCString();
}
if (opt.httpOnly) {
str += \'; HttpOnly\';
}
if (opt.secure) {
str += \'; Secure\';
}
if (opt.sameSite) {
var sameSite = typeof opt.sameSite === \'string\'
? opt.sameSite.toLowerCase() : opt.sameSite;
switch (sameSite) {
case true:
str += \'; SameSite=Strict\';
break;
case \'lax\':
str += \'; SameSite=Lax\';
break;
case \'strict\':
str += \'; SameSite=Strict\';
break;
case \'none\':
str += \'; SameSite=None\';
break;
default:
throw new TypeError(\'option sameSite is invalid\');
}
}
return str;
}
/**
* Try decoding a string using a decoding function.
*
* @param {string} str
* @param {function} decode
* @private
*/
function tryDecode(str, decode) {
try {
return decode(str);
} catch (e) {
return str;
}
}
/***/
}),
/***/ 856:
/***/ ((module, exports, __nccwpck_require__) => {
/**
* This is the web browser implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = __nccwpck_require__(2059);
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = \'undefined\' != typeof chrome
&& \'undefined\' != typeof chrome.storage
? chrome.storage.local
: localstorage();
/**
* Colors.
*/
exports.colors = [
\'lightseagreen\',
\'forestgreen\',
\'goldenrod\',
\'dodgerblue\',
\'darkorchid\',
\'crimson\'
];
/**
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
* and the Firebug extension (any Firefox version) are known
* to support "%c" CSS customizations.
*
* TODO: add a `localStorage` variable to explicitly enable/disable colors
*/
function useColors() {
// NB: In an Electron preload script, document will be defined but not fully
// initialized. Since we know we\'re in Chrome, we\'ll just detect this case
// explicitly
if (typeof window !== \'undefined\' && window.process && window.process.type === \'renderer\') {
return true;
}
// is webkit? http://stackoverflow.com/a/16459606/376773
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
return (typeof document !== \'undefined\' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
// is firebug? http://stackoverflow.com/a/398120/376773
(typeof window !== \'undefined\' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
// is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
(typeof navigator !== \'undefined\' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
// double check webkit in userAgent just in case we are in a worker
(typeof navigator !== \'undefined\' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
}
/**
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
*/
exports.formatters.j = function (v) {
try {
return JSON.stringify(v);
} catch (err) {
return \'[UnexpectedJSONParseError]: \' + err.message;
}
};
/**
* Colorize log arguments if enabled.
*
* @api public
*/
function formatArgs(args) {
var useColors = this.useColors;
args[0] = (useColors ? \'%c\' : \'\')
+ this.namespace
+ (useColors ? \' %c\' : \' \')
+ args[0]
+ (useColors ? \'%c \' : \' \')
+ \'+\' + exports.humanize(this.diff);
if (!useColors) return;
var c = \'color: \' + this.color;
args.splice(1, 0, c, \'color: inherit\')
// the final "%c" is somewhat tricky, because there could be other
// arguments passed either before or after the %c, so we need to
// figure out the correct index to insert the CSS into
var index = 0;
var lastC = 0;
args[0].replace(/%[a-zA-Z%]/g, function (match) {
if (\'%%\' === match) return;
index++;
if (\'%c\' === match) {
// we only are interested in the *last* %c
// (the user may have provided their own)
lastC = index;
}
});
args.splice(lastC, 0, c);
}
/**
* Invokes `console.log()` when available.
* No-op when `console.log` is not a "function".
*
* @api public
*/
function log() {
// this hackery is required for IE8/9, where
// the `console.log` function doesn\'t have \'apply\'
return \'object\' === typeof console
&& console.log
&& Function.prototype.apply.call(console.log, console, arguments);
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
try {
if (null == namespaces) {
exports.storage.removeItem(\'debug\');
} else {
exports.storage.debug = namespaces;
}
} catch (e) { }
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
var r;
try {
r = exports.storage.debug;
} catch (e) { }
// If debug isn\'t set in LS, and we\'re in Electron, try to load $DEBUG
if (!r && typeof process !== \'undefined\' && \'env\' in process) {
r = process.env.DEBUG;
}
return r;
}
/**
* Enable namespaces listed in `localStorage.debug` initially.
*/
exports.enable(load());
/**
* Localstorage attempts to return the localstorage.
*
* This is necessary because safari throws
* when a user disables cookies/localstorage
* and you attempt to access it.
*
* @return {LocalStorage}
* @api private
*/
function localstorage() {
try {
return window.localStorage;
} catch (e) { }
}
/***/
}),
/***/ 2059:
/***/ ((module, exports, __nccwpck_require__) => {
/**
* This is the common logic for both the Node.js and web browser
* implementations of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = createDebug.debug = createDebug[\'default\'] = createDebug;
exports.coerce = coerce;
exports.disable = disable;
exports.enable = enable;
exports.enabled = enabled;
exports.humanize = __nccwpck_require__(1607);
/**
* The currently active debug mode names, and names to skip.
*/
exports.names = [];
exports.skips = [];
/**
* Map of special "%n" handling functions, for the debug "format" argument.
*
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
*/
exports.formatters = {};
/**
* Previous log timestamp.
*/
var prevTime;
/**
* Select a color.
* @param {String} namespace
* @return {Number}
* @api private
*/
function selectColor(namespace) {
var hash = 0, i;
for (i in namespace) {
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
hash |= 0; // Convert to 32bit integer
}
return exports.colors[Math.abs(hash) % exports.colors.length];
}
/**
* Create a debugger with the given `namespace`.
*
* @param {String} namespace
* @return {Function}
* @api public
*/
function createDebug(namespace) {
function debug() {
// disabled?
if (!debug.enabled) return;
var self = debug;
// set `diff` timestamp
var curr = +new Date();
var ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
// turn the `arguments` into a proper Array
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
args[0] = exports.coerce(args[0]);
if (\'string\' !== typeof args[0]) {
// anything else let\'s inspect with %O
args.unshift(\'%O\');
}
// apply any `formatters` transformations
var index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
// if we encounter an escaped % then don\'t increase the array index
if (match === \'%%\') return match;
index++;
var formatter = exports.formatters[format];
if (\'function\' === typeof formatter) {
var val = args[index];
match = formatter.call(self, val);
// now we need to remove `args[index]` since it\'s inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
// apply env-specific formatting (colors, etc.)
exports.formatArgs.call(self, args);
var logFn = debug.log || exports.log || console.log.bind(console);
logFn.apply(self, args);
}
debug.namespace = namespace;
debug.enabled = exports.enabled(namespace);
debug.useColors = exports.useColors();
debug.color = selectColor(namespace);
// env-specific initialization logic for debug instances
if (\'function\' === typeof exports.init) {
exports.init(debug);
}
return debug;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*
* @param {String} namespaces
* @api public
*/
function enable(namespaces) {
exports.save(namespaces);
exports.names = [];
exports.skips = [];
var split = (typeof namespaces === \'string\' ? namespaces : \'\').split(/[\s,]+/);
var len = split.length;
for (var i = 0; i < len; i++) {
if (!split[i]) continue; // ignore empty strings
namespaces = split[i].replace(/\*/g, \'.*?\');
if (namespaces[0] === \'-\') {
exports.skips.push(new RegExp(\'^\' + namespaces.substr(1) + \'$\'));
} else {
exports.names.push(new RegExp(\'^\' + namespaces + \'$\'));
}
}
}
/**
* Disable debug output.
*
* @api public
*/
function disable() {
exports.enable(\'\');
}
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
function enabled(name) {
var i, len;
for (i = 0, len = exports.skips.length; i < len; i++) {
if (exports.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = exports.names.length; i < len; i++) {
if (exports.names[i].test(name)) {
return true;
}
}
return false;
}
/**
* Coerce `val`.
*
* @param {Mixed} val
* @return {Mixed}
* @api private
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
/***/
}),
/***/ 8609:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
/**
* Detect Electron renderer process, which is node, but we should
* treat as a browser.
*/
if (typeof process !== \'undefined\' && process.type === \'renderer\') {
module.exports = __nccwpck_require__(856);
} else {
module.exports = __nccwpck_require__(617);
}
/***/
}),
/***/ 617:
/***/ ((module, exports, __nccwpck_require__) => {
/**
* Module dependencies.
*/
var tty = __nccwpck_require__(3867);
var util = __nccwpck_require__(1669);
/**
* This is the Node.js implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = __nccwpck_require__(2059);
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
/**
* Colors.
*/
exports.colors = [6, 2, 3, 4, 5, 1];
/**
* Build up the default `inspectOpts` object from the environment variables.
*
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
*/
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
return /^debug_/i.test(key);
}).reduce(function (obj, key) {
// camel-case
var prop = key
.substring(6)
.toLowerCase()
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
// coerce string value into JS value
var val = process.env[key];
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
else if (val === \'null\') val = null;
else val = Number(val);
obj[prop] = val;
return obj;
}, {});
/**
* The file descriptor to write the `debug()` calls to.
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
*
* $ DEBUG_FD=3 node script.js 3>debug.log
*/
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
if (1 !== fd && 2 !== fd) {
util.deprecate(function () { }, \'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)\')()
}
var stream = 1 === fd ? process.stdout :
2 === fd ? process.stderr :
createWritableStdioStream(fd);
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
return \'colors\' in exports.inspectOpts
? Boolean(exports.inspectOpts.colors)
: tty.isatty(fd);
}
/**
* Map %o to `util.inspect()`, all on a single line.
*/
exports.formatters.o = function (v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts)
.split(\'\n\').map(function (str) {
return str.trim()
}).join(\' \');
};
/**
* Map %o to `util.inspect()`, allowing multiple lines if needed.
*/
exports.formatters.O = function (v) {
this.inspectOpts.colors = this.useColors;
return util.inspect(v, this.inspectOpts);
};
/**
* Adds ANSI color escape codes if enabled.
*
* @api public
*/
function formatArgs(args) {
var name = this.namespace;
var useColors = this.useColors;
if (useColors) {
var c = this.color;
var prefix = \' \u001b[3\' + c + \';1m\' + name + \' \' + \'\u001b[0m\';
args[0] = prefix + args[0].split(\'\n\').join(\'\n\' + prefix);
args.push(\'\u001b[3\' + c + \'m+\' + exports.humanize(this.diff) + \'\u001b[0m\');
} else {
args[0] = new Date().toUTCString()
+ \' \' + name + \' \' + args[0];
}
}
/**
* Invokes `util.format()` with the specified arguments and writes to `stream`.
*/
function log() {
return stream.write(util.format.apply(util, arguments) + \'\n\');
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
if (null == namespaces) {
// If you set a process.env field to null or undefined, it gets cast to the
// string \'null\' or \'undefined\'. Just delete instead.
delete process.env.DEBUG;
} else {
process.env.DEBUG = namespaces;
}
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
return process.env.DEBUG;
}
/**
* Copied from `node/src/node.js`.
*
* XXX: It\'s lame that node doesn\'t expose this API out-of-the-box. It also
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
*/
function createWritableStdioStream(fd) {
var stream;
var tty_wrap = process.binding(\'tty_wrap\');
// Note stream._type is used for test-module-load-list.js
switch (tty_wrap.guessHandleType(fd)) {
case \'TTY\':
stream = new tty.WriteStream(fd);
stream._type = \'tty\';
// Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
case \'FILE\':
var fs = __nccwpck_require__(5747);
stream = new fs.SyncWriteStream(fd, { autoClose: false });
stream._type = \'fs\';
break;
case \'PIPE\':
case \'TCP\':
var net = __nccwpck_require__(1631);
stream = new net.Socket({
fd: fd,
readable: false,
writable: true
});
// FIXME Should probably have an option in net.Socket to create a
// stream from an existing fd which is writable only. But for now
// we\'ll just add this hack and set the `readable` member to false.
// Test: ./node test/fixtures/echo.js < /etc/passwd
stream.readable = false;
stream.read = null;
stream._type = \'pipe\';
// FIXME Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
default:
// Probably an error on in uv_guess_handle()
throw new Error(\'Implement me. Unknown stream file type!\');
}
// For supporting legacy API we put the FD here.
stream.fd = fd;
stream._isStdio = true;
return stream;
}
/**
* Init logic for `debug` instances.
*
* Create a new `inspectOpts` object in case `useColors` is set
* differently for a particular `debug` instance.
*/
function init(debug) {
debug.inspectOpts = {};
var keys = Object.keys(exports.inspectOpts);
for (var i = 0; i < keys.length; i++) {
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
}
}
/**
* Enable namespaces listed in `process.env.DEBUG` initially.
*/
exports.enable(load());
/***/
}),
/***/ 2225:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
/*!
* depd
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
*/
var callSiteToString = __nccwpck_require__(7872).callSiteToString
var eventListenerCount = __nccwpck_require__(7872).eventListenerCount
var relative = __nccwpck_require__(5622).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 \' + callSiteToString(stack[i])
}
return str
}
/**
* Create deprecate for namespace in caller.
*/
function depd(namespace) {
if (!namespace) {
throw new TypeError(\'argument namespace is required\')
}
var stack = getStack()
var site = callSiteLocation(stack[1])
var file = site[0]
function deprecate(message) {
// call to self as log
log.call(deprecate, message)
}
deprecate._file = file
deprecate._ignored = isignored(namespace)
deprecate._namespace = namespace
deprecate._traced = istraced(namespace)
deprecate._warned = Object.create(null)
deprecate.function = wrapfunction
deprecate.property = wrapproperty
return deprecate
}
/**
* Determine if namespace is ignored.
*/
function isignored(namespace) {
/* istanbul ignore next: tested in a child processs */
if (process.noDeprecation) {
// --no-deprecation support
return true
}
var str = process.env.NO_DEPRECATION || \'\'
// namespace ignored
return containsNamespace(str, namespace)
}
/**
* Determine if namespace is traced.
*/
function istraced(namespace) {
/* istanbul ignore next: tested in a child processs */
if (process.traceDeprecation) {
// --trace-deprecation support
return true
}
var str = process.env.TRACE_DEPRECATION || \'\'
// namespace traced
return containsNamespace(str, namespace)
}
/**
* Display deprecation message.
*/
function log(message, site) {
var haslisteners = eventListenerCount(process, \'deprecation\') !== 0
// abort early if no destination
if (!haslisteners && this._ignored) {
return
}
var caller
var callFile
var callSite
var 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 \' + callSiteToString(stack[i])
}
return formatted
}
if (caller) {
formatted += \' at \' + formatLocation(caller)
}
return formatted
}
/**
* Format deprecation message with color.
*/
function formatColor(msg, caller, stack) {
var formatted = \'\x1b[36;1m\' + this._namespace + \'\x1b[22;39m\' + // bold cyan
\' \x1b[33;1mdeprecated\x1b[22;39m\' + // bold yellow
\' \x1b[0m\' + msg + \'\x1b[39m\' // reset
// add stack trace
if (this._traced) {
for (var i = 0; i < stack.length; i++) {
formatted += \'\n \x1b[36mat \' + callSiteToString(stack[i]) + \'\x1b[39m\' // cyan
}
return formatted
}
if (caller) {
formatted += \' \x1b[36m\' + formatLocation(caller) + \'\x1b[39m\' // cyan
}
return formatted
}
/**
* Format call site location.
*/
function formatLocation(callSite) {
return relative(basePath, callSite[0]) +
\':\' + callSite[1] +
\':\' + callSite[2]
}
/**
* Get the stack as array of call sites.
*/
function getStack() {
var limit = Error.stackTraceLimit
var obj = {}
var prep = Error.prepareStackTrace
Error.prepareStackTrace = prepareObjectStackTrace
Error.stackTraceLimit = Math.max(10, limit)
// capture the stack
Error.captureStackTrace(obj)
// slice this function off the top
var stack = obj.stack.slice(1)
Error.prepareStackTrace = prep
Error.stackTraceLimit = limit
return stack
}
/**
* Capture call site stack from v8.
*/
function prepareObjectStackTrace(obj, stack) {
return stack
}
/**
* Return a wrapped function in a deprecation message.
*/
function wrapfunction(fn, message) {
if (typeof fn !== \'function\') {
throw new TypeError(\'argument fn must be a function\')
}
var args = createArgumentsString(fn.length)
var deprecate = this // eslint-disable-line no-unused-vars
var stack = getStack()
var site = callSiteLocation(stack[1])
site.name = fn.name
// eslint-disable-next-line no-eval
var deprecatedfn = eval(\'(function (\' + args + \') {\n\' +
\'"use strict"\n\' +
\'log.call(deprecate, message, site)\n\' +
\'return fn.apply(this, arguments)\n\' +
\'})\')
return deprecatedfn
}
/**
* Wrap property in a deprecation message.
*/
function wrapproperty(obj, prop, message) {
if (!obj || (typeof obj !== \'object\' && typeof obj !== \'function\')) {
throw new TypeError(\'argument obj must be object\')
}
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
if (!descriptor) {
throw new TypeError(\'must call property on owner object\')
}
if (!descriptor.configurable) {
throw new TypeError(\'property must be configurable\')
}
var deprecate = this
var stack = getStack()
var site = callSiteLocation(stack[1])
// set site name
site.name = prop
// convert data descriptor
if (\'value\' in descriptor) {
descriptor = convertDataDescriptorToAccessor(obj, prop, message)
}
var get = descriptor.get
var set = descriptor.set
// wrap getter
if (typeof get === \'function\') {
descriptor.get = function getter() {
log.call(deprecate, message, site)
return get.apply(this, arguments)
}
}
// wrap setter
if (typeof set === \'function\') {
descriptor.set = function setter() {
log.call(deprecate, message, site)
return set.apply(this, arguments)
}
}
Object.defineProperty(obj, prop, descriptor)
}
/**
* Create DeprecationError for deprecation
*/
function DeprecationError(namespace, message, stack) {
var error = new Error()
var stackString
Object.defineProperty(error, \'constructor\', {
value: DeprecationError
})
Object.defineProperty(error, \'message\', {
configurable: true,
enumerable: false,
value: message,
writable: true
})
Object.defineProperty(error, \'name\', {
enumerable: false,
configurable: true,
value: \'DeprecationError\',
writable: true
})
Object.defineProperty(error, \'namespace\', {
configurable: true,
enumerable: false,
value: namespace,
writable: true
})
Object.defineProperty(error, \'stack\', {
configurable: true,
enumerable: false,
get: function () {
if (stackString !== undefined) {
return stackString
}
// prepare stack trace
return (stackString = createStackString.call(this, stack))
},
set: function setter(val) {
stackString = val
}
})
return error
}
/***/
}),
/***/ 765:
/***/ ((module) => {
"use strict";
/*!
* depd
* Copyright(c) 2014 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
*/
module.exports = callSiteToString
/**
* Format a CallSite file location to a string.
*/
function callSiteFileLocation(callSite) {
var fileName
var fileLocation = \'\'
if (callSite.isNative()) {
fileLocation = \'native\'
} else if (callSite.isEval()) {
fileName = callSite.getScriptNameOrSourceURL()
if (!fileName) {
fileLocation = callSite.getEvalOrigin()
}
} else {
fileName = callSite.getFileName()
}
if (fileName) {
fileLocation += fileName
var lineNumber = callSite.getLineNumber()
if (lineNumber != null) {
fileLocation += \':\' + lineNumber
var columnNumber = callSite.getColumnNumber()
if (columnNumber) {
fileLocation += \':\' + columnNumber
}
}
}
return fileLocation || \'unknown source\'
}
/**
* Format a CallSite to a string.
*/
function callSiteToString(callSite) {
var addSuffix = true
var fileLocation = callSiteFileLocation(callSite)
var functionName = callSite.getFunctionName()
var isConstructor = callSite.isConstructor()
var isMethodCall = !(callSite.isToplevel() || isConstructor)
var line = \'\'
if (isMethodCall) {
var methodName = callSite.getMethodName()
var typeName = getConstructorName(callSite)
if (functionName) {
if (typeName && functionName.indexOf(typeName) !== 0) {
line += typeName + \'.\'
}
line += functionName
if (methodName && functionName.lastIndexOf(\'.\' + methodName) !== functionName.length - methodName.length - 1) {
line += \' [as \' + methodName + \']\'
}
} else {
line += typeName + \'.\' + (methodName || \'<anonymous>\')
}
} else if (isConstructor) {
line += \'new \' + (functionName || \'<anonymous>\')
} else if (functionName) {
line += functionName
} else {
addSuffix = false
line += fileLocation
}
if (addSuffix) {
line += \' (\' + fileLocation + \')\'
}
return line
}
/**
* Get constructor name of reviver.
*/
function getConstructorName(obj) {
var receiver = obj.receiver
return (receiver.constructor && receiver.constructor.name) || null
}
/***/
}),
/***/ 3445:
/***/ ((module) => {
"use strict";
/*!
* depd
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = eventListenerCount
/**
* Get the count of listeners on an event emitter of a specific type.
*/
function eventListenerCount(emitter, type) {
return emitter.listeners(type).length
}
/***/
}),
/***/ 7872:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* depd
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var EventEmitter = __nccwpck_require__(8614).EventEmitter
/**
* Module exports.
* @public
*/
lazyProperty(module.exports, \'callSiteToString\', function callSiteToString() {
var limit = Error.stackTraceLimit
var obj = {}
var prep = Error.prepareStackTrace
function prepareObjectStackTrace(obj, stack) {
return stack
}
Error.prepareStackTrace = prepareObjectStackTrace
Error.stackTraceLimit = 2
// capture the stack
Error.captureStackTrace(obj)
// slice the stack
var stack = obj.stack.slice()
Error.prepareStackTrace = prep
Error.stackTraceLimit = limit
return stack[0].toString ? toString : __nccwpck_require__(765)
})
lazyProperty(module.exports, \'eventListenerCount\', function eventListenerCount() {
return EventEmitter.listenerCount || __nccwpck_require__(3445)
})
/**
* Define a lazy property.
*/
function lazyProperty(obj, prop, getter) {
function get() {
var val = getter()
Object.defineProperty(obj, prop, {
configurable: true,
enumerable: true,
value: val
})
return val
}
Object.defineProperty(obj, prop, {
configurable: true,
enumerable: true,
get: get
})
}
/**
* Call toString() on the obj
*/
function toString(obj) {
return obj.toString()
}
/***/
}),
/***/ 6317:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* destroy
* Copyright(c) 2014 Jonathan Ong
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var ReadStream = __nccwpck_require__(5747).ReadStream
var Stream = __nccwpck_require__(2413)
/**
* Module exports.
* @public
*/
module.exports = destroy
/**
* Destroy a stream.
*
* @param {object} stream
* @public
*/
function destroy(stream) {
if (stream instanceof ReadStream) {
return destroyReadStream(stream)
}
if (!(stream instanceof Stream)) {
return stream
}
if (typeof stream.destroy === \'function\') {
stream.destroy()
}
return stream
}
/**
* Destroy a ReadStream.
*
* @param {object} stream
* @private
*/
function destroyReadStream(stream) {
stream.destroy()
if (typeof stream.close === \'function\') {
// node.js core bug work-around
stream.on(\'open\', onOpenClose)
}
return stream
}
/**
* On open handler to close stream.
* @private
*/
function onOpenClose() {
if (typeof this.fd === \'number\') {
// actually close down the fd
this.close()
}
}
/***/
}),
/***/ 2716:
/***/ ((module) => {
"use strict";
/*!
* ee-first
* Copyright(c) 2014 Jonathan Ong
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = first
/**
* Get the first event in a set of event emitters and event pairs.
*
* @param {array} stuff
* @param {function} done
* @public
*/
function first(stuff, done) {
if (!Array.isArray(stuff))
throw new TypeError(\'arg must be an array of [ee, events...] arrays\')
var cleanups = []
for (var i = 0; i < stuff.length; i++) {
var arr = stuff[i]
if (!Array.isArray(arr) || arr.length < 2)
throw new TypeError(\'each array member must be [ee, events...]\')
var ee = arr[0]
for (var j = 1; j < arr.length; j++) {
var event = arr[j]
var fn = listener(event, callback)
// listen to the event
ee.on(event, fn)
// push this listener to the list of cleanups
cleanups.push({
ee: ee,
event: event,
fn: fn,
})
}
}
function callback() {
cleanup()
done.apply(null, arguments)
}
function cleanup() {
var x
for (var i = 0; i < cleanups.length; i++) {
x = cleanups[i]
x.ee.removeListener(x.event, x.fn)
}
}
function thunk(fn) {
done = fn
}
thunk.cancel = cleanup
return thunk
}
/**
* Create the event listener.
* @private
*/
function listener(event, done) {
return function onevent(arg1) {
var args = new Array(arguments.length)
var ee = this
var err = event === \'error\'
? arg1
: null
// copy args to prevent arguments escaping scope
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i]
}
done(err, ee, event, args)
}
}
/***/
}),
/***/ 1979:
/***/ ((module) => {
"use strict";
/*!
* encodeurl
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = encodeUrl
/**
* RegExp to match non-URL code points, *after* encoding (i.e. not including "%")
* and including invalid escape sequences.
* @private
*/
var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g
/**
* RegExp to match unmatched surrogate pair.
* @private
*/
var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g
/**
* String to replace unmatched surrogate pair with.
* @private
*/
var UNMATCHED_SURROGATE_PAIR_REPLACE = \'$1\uFFFD$2\'
/**
* Encode a URL to a percent-encoded form, excluding already-encoded sequences.
*
* This function will take an already-encoded URL and encode all the non-URL
* code points. This function will not encode the "%" character unless it is
* not part of a valid sequence (`%20` will be left as-is, but `%foo` will
* be encoded as `%25foo`).
*
* This encode is meant to be "safe" and does not throw errors. It will try as
* hard as it can to properly encode the given URL, including replacing any raw,
* unpaired surrogate pairs with the Unicode replacement character prior to
* encoding.
*
* @param {string} url
* @return {string}
* @public
*/
function encodeUrl(url) {
return String(url)
.replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)
.replace(ENCODE_CHARS_REGEXP, encodeURI)
}
/***/
}),
/***/ 6591:
/***/ ((module) => {
"use strict";
/*!
* escape-html
* Copyright(c) 2012-2013 TJ Holowaychuk
* Copyright(c) 2015 Andreas Lubbe
* Copyright(c) 2015 Tiancheng "Timothy" Gu
* MIT Licensed
*/
/**
* Module variables.
* @private
*/
var matchHtmlRegExp = /["\'&<>]/;
/**
* Module exports.
* @public
*/
module.exports = escapeHtml;
/**
* Escape special characters in the given string of html.
*
* @param {string} string The string to escape for inserting into HTML
* @return {string}
* @public
*/
function escapeHtml(string) {
var str = \'\' + string;
var match = matchHtmlRegExp.exec(str);
if (!match) {
return str;
}
var escape;
var html = \'\';
var index = 0;
var lastIndex = 0;
for (index = match.index; index < str.length; index++) {
switch (str.charCodeAt(index)) {
case 34: // "
escape = \'"\';
break;
case 38: // &
escape = \'&\';
break;
case 39: // \'
escape = \''\';
break;
case 60: // <
escape = \'<\';
break;
case 62: // >
escape = \'>\';
break;
default:
continue;
}
if (lastIndex !== index) {
html += str.substring(lastIndex, index);
}
lastIndex = index + 1;
html += escape;
}
return lastIndex !== index
? html + str.substring(lastIndex, index)
: html;
}
/***/
}),
/***/ 4091:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* etag
* Copyright(c) 2014-2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = etag
/**
* Module dependencies.
* @private
*/
var crypto = __nccwpck_require__(6417)
var Stats = __nccwpck_require__(5747).Stats
/**
* Module variables.
* @private
*/
var toString = Object.prototype.toString
/**
* Generate an entity tag.
*
* @param {Buffer|string} entity
* @return {string}
* @private
*/
function entitytag(entity) {
if (entity.length === 0) {
// fast-path empty
return \'"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"\'
}
// compute hash of entity
var hash = crypto
.createHash(\'sha1\')
.update(entity, \'utf8\')
.digest(\'base64\')
.substring(0, 27)
// compute length of entity
var len = typeof entity === \'string\'
? Buffer.byteLength(entity, \'utf8\')
: entity.length
return \'"\' + len.toString(16) + \'-\' + hash + \'"\'
}
/**
* Create a simple ETag.
*
* @param {string|Buffer|Stats} entity
* @param {object} [options]
* @param {boolean} [options.weak]
* @return {String}
* @public
*/
function etag(entity, options) {
if (entity == null) {
throw new TypeError(\'argument entity is required\')
}
// support fs.Stats object
var isStats = isstats(entity)
var weak = options && typeof options.weak === \'boolean\'
? options.weak
: isStats
// validate argument
if (!isStats && typeof entity !== \'string\' && !Buffer.isBuffer(entity)) {
throw new TypeError(\'argument entity must be string, Buffer, or fs.Stats\')
}
// generate entity tag
var tag = isStats
? stattag(entity)
: entitytag(entity)
return weak
? \'W/\' + tag
: tag
}
/**
* Determine if object is a Stats object.
*
* @param {object} obj
* @return {boolean}
* @api private
*/
function isstats(obj) {
// genuine fs.Stats
if (typeof Stats === \'function\' && obj instanceof Stats) {
return true
}
// quack quack
return obj && typeof obj === \'object\' &&
\'ctime\' in obj && toString.call(obj.ctime) === \'[object Date]\' &&
\'mtime\' in obj && toString.call(obj.mtime) === \'[object Date]\' &&
\'ino\' in obj && typeof obj.ino === \'number\' &&
\'size\' in obj && typeof obj.size === \'number\'
}
/**
* Generate a tag for a stat.
*
* @param {object} stat
* @return {string}
* @private
*/
function stattag(stat) {
var mtime = stat.mtime.getTime().toString(16)
var size = stat.size.toString(16)
return \'"\' + size + \'-\' + mtime + \'"\'
}
/***/
}),
/***/ 9455:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
module.exports = __nccwpck_require__(7943);
/***/
}),
/***/ 8298:
/***/ ((module, exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var finalhandler = __nccwpck_require__(5278);
var Router = __nccwpck_require__(1061);
var methods = __nccwpck_require__(3454);
var middleware = __nccwpck_require__(7852);
var query = __nccwpck_require__(5192);
var debug = __nccwpck_require__(8609)(\'express:application\');
var View = __nccwpck_require__(1409);
var http = __nccwpck_require__(8605);
var compileETag = __nccwpck_require__(5665).compileETag;
var compileQueryParser = __nccwpck_require__(5665).compileQueryParser;
var compileTrust = __nccwpck_require__(5665).compileTrust;
var deprecate = __nccwpck_require__(2225)(\'express\');
var flatten = __nccwpck_require__(6663);
var merge = __nccwpck_require__(6996);
var resolve = __nccwpck_require__(5622).resolve;
var setPrototypeOf = __nccwpck_require__(2927)
var slice = Array.prototype.slice;
/**
* Application prototype.
*/
var app = exports = module.exports = {};
/**
* Variable for trust proxy inheritance back-compat
* @private
*/
var trustProxyDefaultSymbol = \'@@symbol:trust_proxy_default\';
/**
* Initialize the server.
*
* - setup default configuration
* - setup default middleware
* - setup route reflection methods
*
* @private
*/
app.init = function init() {
this.cache = {};
this.engines = {};
this.settings = {};
this.defaultConfiguration();
};
/**
* Initialize application configuration.
* @private
*/
app.defaultConfiguration = function defaultConfiguration() {
var env = process.env.NODE_ENV || \'development\';
// default settings
this.enable(\'x-powered-by\');
this.set(\'etag\', \'weak\');
this.set(\'env\', env);
this.set(\'query parser\', \'extended\');
this.set(\'subdomain offset\', 2);
this.set(\'trust proxy\', false);
// trust proxy inherit back-compat
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
configurable: true,
value: true
});
debug(\'booting in %s mode\', env);
this.on(\'mount\', function onmount(parent) {
// inherit trust proxy
if (this.settings[trustProxyDefaultSymbol] === true
&& typeof parent.settings[\'trust proxy fn\'] === \'function\') {
delete this.settings[\'trust proxy\'];
delete this.settings[\'trust proxy fn\'];
}
// inherit protos
setPrototypeOf(this.request, parent.request)
setPrototypeOf(this.response, parent.response)
setPrototypeOf(this.engines, parent.engines)
setPrototypeOf(this.settings, parent.settings)
});
// setup locals
this.locals = Object.create(null);
// top-most app is mounted at /
this.mountpath = \'/\';
// default locals
this.locals.settings = this.settings;
// default configuration
this.set(\'view\', View);
this.set(\'views\', resolve(\'views\'));
this.set(\'jsonp callback name\', \'callback\');
if (env === \'production\') {
this.enable(\'view cache\');
}
Object.defineProperty(this, \'router\', {
get: function () {
throw new Error(\'\\'app.router\\' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.\');
}
});
};
/**
* lazily adds the base router if it has not yet been added.
*
* We cannot add the base router in the defaultConfiguration because
* it reads app settings which might be set after that has run.
*
* @private
*/
app.lazyrouter = function lazyrouter() {
if (!this._router) {
this._router = new Router({
caseSensitive: this.enabled(\'case sensitive routing\'),
strict: this.enabled(\'strict routing\')
});
this._router.use(query(this.get(\'query parser fn\')));
this._router.use(middleware.init(this));
}
};
/**
* Dispatch a req, res pair into the application. Starts pipeline processing.
*
* If no callback is provided, then default error handlers will respond
* in the event of an error bubbling through the stack.
*
* @private
*/
app.handle = function handle(req, res, callback) {
var router = this._router;
// final handler
var done = callback || finalhandler(req, res, {
env: this.get(\'env\'),
onerror: logerror.bind(this)
});
// no routes
if (!router) {
debug(\'no routes defined on app\');
done();
return;
}
router.handle(req, res, done);
};
/**
* Proxy `Router#use()` to add middleware to the app router.
* See Router#use() documentation for details.
*
* If the _fn_ parameter is an express app, then it will be
* mounted at the _route_ specified.
*
* @public
*/
app.use = function use(fn) {
var offset = 0;
var path = \'/\';
// default path to \'/\'
// disambiguate app.use([fn])
if (typeof fn !== \'function\') {
var arg = fn;
while (Array.isArray(arg) && arg.length !== 0) {
arg = arg[0];
}
// first arg is the path
if (typeof arg !== \'function\') {
offset = 1;
path = fn;
}
}
var fns = flatten(slice.call(arguments, offset));
if (fns.length === 0) {
throw new TypeError(\'app.use() requires a middleware function\')
}
// setup router
this.lazyrouter();
var router = this._router;
fns.forEach(function (fn) {
// non-express app
if (!fn || !fn.handle || !fn.set) {
return router.use(path, fn);
}
debug(\'.use app under %s\', path);
fn.mountpath = path;
fn.parent = this;
// restore .app property on req and res
router.use(path, function mounted_app(req, res, next) {
var orig = req.app;
fn.handle(req, res, function (err) {
setPrototypeOf(req, orig.request)
setPrototypeOf(res, orig.response)
next(err);
});
});
// mounted an app
fn.emit(\'mount\', this);
}, this);
return this;
};
/**
* Proxy to the app `Router#route()`
* Returns a new `Route` instance for the _path_.
*
* Routes are isolated middleware stacks for specific paths.
* See the Route api docs for details.
*
* @public
*/
app.route = function route(path) {
this.lazyrouter();
return this._router.route(path);
};
/**
* Register the given template engine callback `fn`
* as `ext`.
*
* By default will `require()` the engine based on the
* file extension. For example if you try to render
* a "foo.ejs" file Express will invoke the following internally:
*
* app.engine(\'ejs\', require(\'ejs\').__express);
*
* For engines that do not provide `.__express` out of the box,
* or if you wish to "map" a different extension to the template engine
* you may use this method. For example mapping the EJS template engine to
* ".html" files:
*
* app.engine(\'html\', require(\'ejs\').renderFile);
*
* In this case EJS provides a `.renderFile()` method with
* the same signature that Express expects: `(path, options, callback)`,
* though note that it aliases this method as `ejs.__express` internally
* so if you\'re using ".ejs" extensions you dont need to do anything.
*
* Some template engines do not follow this convention, the
* [Consolidate.js](https://github.com/tj/consolidate.js)
* library was created to map all of node\'s popular template
* engines to follow this convention, thus allowing them to
* work seamlessly within Express.
*
* @param {String} ext
* @param {Function} fn
* @return {app} for chaining
* @public
*/
app.engine = function engine(ext, fn) {
if (typeof fn !== \'function\') {
throw new Error(\'callback function required\');
}
// get file extension
var extension = ext[0] !== \'.\'
? \'.\' + ext
: ext;
// store engine
this.engines[extension] = fn;
return this;
};
/**
* Proxy to `Router#param()` with one added api feature. The _name_ parameter
* can be an array of names.
*
* See the Router#param() docs for more details.
*
* @param {String|Array} name
* @param {Function} fn
* @return {app} for chaining
* @public
*/
app.param = function param(name, fn) {
this.lazyrouter();
if (Array.isArray(name)) {
for (var i = 0; i < name.length; i++) {
this.param(name[i], fn);
}
return this;
}
this._router.param(name, fn);
return this;
};
/**
* Assign `setting` to `val`, or return `setting`\'s value.
*
* app.set(\'foo\', \'bar\');
* app.set(\'foo\');
* // => "bar"
*
* Mounted servers inherit their parent server\'s settings.
*
* @param {String} setting
* @param {*} [val]
* @return {Server} for chaining
* @public
*/
app.set = function set(setting, val) {
if (arguments.length === 1) {
// app.get(setting)
return this.settings[setting];
}
debug(\'set "%s" to %o\', setting, val);
// set value
this.settings[setting] = val;
// trigger matched settings
switch (setting) {
case \'etag\':
this.set(\'etag fn\', compileETag(val));
break;
case \'query parser\':
this.set(\'query parser fn\', compileQueryParser(val));
break;
case \'trust proxy\':
this.set(\'trust proxy fn\', compileTrust(val));
// trust proxy inherit back-compat
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
configurable: true,
value: false
});
break;
}
return this;
};
/**
* Return the app\'s absolute pathname
* based on the parent(s) that have
* mounted it.
*
* For example if the application was
* mounted as "/admin", which itself
* was mounted as "/blog" then the
* return value would be "/blog/admin".
*
* @return {String}
* @private
*/
app.path = function path() {
return this.parent
? this.parent.path() + this.mountpath
: \'\';
};
/**
* Check if `setting` is enabled (truthy).
*
* app.enabled(\'foo\')
* // => false
*
* app.enable(\'foo\')
* app.enabled(\'foo\')
* // => true
*
* @param {String} setting
* @return {Boolean}
* @public
*/
app.enabled = function enabled(setting) {
return Boolean(this.set(setting));
};
/**
* Check if `setting` is disabled.
*
* app.disabled(\'foo\')
* // => true
*
* app.enable(\'foo\')
* app.disabled(\'foo\')
* // => false
*
* @param {String} setting
* @return {Boolean}
* @public
*/
app.disabled = function disabled(setting) {
return !this.set(setting);
};
/**
* Enable `setting`.
*
* @param {String} setting
* @return {app} for chaining
* @public
*/
app.enable = function enable(setting) {
return this.set(setting, true);
};
/**
* Disable `setting`.
*
* @param {String} setting
* @return {app} for chaining
* @public
*/
app.disable = function disable(setting) {
return this.set(setting, false);
};
/**
* Delegate `.VERB(...)` calls to `router.VERB(...)`.
*/
methods.forEach(function (method) {
app[method] = function (path) {
if (method === \'get\' && arguments.length === 1) {
// app.get(setting)
return this.set(path);
}
this.lazyrouter();
var route = this._router.route(path);
route[method].apply(route, slice.call(arguments, 1));
return this;
};
});
/**
* Special-cased "all" method, applying the given route `path`,
* middleware, and callback to _every_ HTTP method.
*
* @param {String} path
* @param {Function} ...
* @return {app} for chaining
* @public
*/
app.all = function all(path) {
this.lazyrouter();
var route = this._router.route(path);
var args = slice.call(arguments, 1);
for (var i = 0; i < methods.length; i++) {
route[methods[i]].apply(route, args);
}
return this;
};
// del -> delete alias
app.del = deprecate.function(app.delete, \'app.del: Use app.delete instead\');
/**
* Render the given view `name` name with `options`
* and a callback accepting an error and the
* rendered template string.
*
* Example:
*
* app.render(\'email\', { name: \'Tobi\' }, function(err, html){
* // ...
* })
*
* @param {String} name
* @param {Object|Function} options or fn
* @param {Function} callback
* @public
*/
app.render = function render(name, options, callback) {
var cache = this.cache;
var done = callback;
var engines = this.engines;
var opts = options;
var renderOptions = {};
var view;
// support callback function as second arg
if (typeof options === \'function\') {
done = options;
opts = {};
}
// merge app.locals
merge(renderOptions, this.locals);
// merge options._locals
if (opts._locals) {
merge(renderOptions, opts._locals);
}
// merge options
merge(renderOptions, opts);
// set .cache unless explicitly provided
if (renderOptions.cache == null) {
renderOptions.cache = this.enabled(\'view cache\');
}
// primed cache
if (renderOptions.cache) {
view = cache[name];
}
// view
if (!view) {
var View = this.get(\'view\');
view = new View(name, {
defaultEngine: this.get(\'view engine\'),
root: this.get(\'views\'),
engines: engines
});
if (!view.path) {
var dirs = Array.isArray(view.root) && view.root.length > 1
? \'directories "\' + view.root.slice(0, -1).join(\'", "\') + \'" or "\' + view.root[view.root.length - 1] + \'"\'
: \'directory "\' + view.root + \'"\'
var err = new Error(\'Failed to lookup view "\' + name + \'" in views \' + dirs);
err.view = view;
return done(err);
}
// prime the cache
if (renderOptions.cache) {
cache[name] = view;
}
}
// render
tryRender(view, renderOptions, done);
};
/**
* Listen for connections.
*
* A node `http.Server` is returned, with this
* application (which is a `Function`) as its
* callback. If you wish to create both an HTTP
* and HTTPS server you may do so with the "http"
* and "https" modules as shown here:
*
* var http = require(\'http\')
* , https = require(\'https\')
* , express = require(\'express\')
* , app = express();
*
* http.createServer(app).listen(80);
* https.createServer({ ... }, app).listen(443);
*
* @return {http.Server}
* @public
*/
app.listen = function listen() {
var server = http.createServer(this);
return server.listen.apply(server, arguments);
};
/**
* Log error using console.error.
*
* @param {Error} err
* @private
*/
function logerror(err) {
/* istanbul ignore next */
if (this.get(\'env\') !== \'test\') console.error(err.stack || err.toString());
}
/**
* Try rendering a view.
* @private
*/
function tryRender(view, options, callback) {
try {
view.render(options, callback);
} catch (err) {
callback(err);
}
}
/***/
}),
/***/ 7943:
/***/ ((module, exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
*/
var bodyParser = __nccwpck_require__(3241)
var EventEmitter = __nccwpck_require__(8614).EventEmitter;
var mixin = __nccwpck_require__(9725);
var proto = __nccwpck_require__(8298);
var Route = __nccwpck_require__(3192);
var Router = __nccwpck_require__(1061);
var req = __nccwpck_require__(903);
var res = __nccwpck_require__(7187);
/**
* Expose `createApplication()`.
*/
exports = module.exports = createApplication;
/**
* Create an express application.
*
* @return {Function}
* @api public
*/
function createApplication() {
var app = function (req, res, next) {
app.handle(req, res, next);
};
mixin(app, EventEmitter.prototype, false);
mixin(app, proto, false);
// expose the prototype that will get set on requests
app.request = Object.create(req, {
app: { configurable: true, enumerable: true, writable: true, value: app }
})
// expose the prototype that will get set on responses
app.response = Object.create(res, {
app: { configurable: true, enumerable: true, writable: true, value: app }
})
app.init();
return app;
}
/**
* Expose the prototypes.
*/
exports.application = proto;
exports.request = req;
exports.response = res;
/**
* Expose constructors.
*/
exports.Route = Route;
exports.Router = Router;
/**
* Expose middleware
*/
exports.json = bodyParser.json
exports.query = __nccwpck_require__(5192);
exports.raw = bodyParser.raw
exports.static = __nccwpck_require__(3921);
exports.text = bodyParser.text
exports.urlencoded = bodyParser.urlencoded
/**
* Replace removed middleware with an appropriate error message.
*/
var removedMiddlewares = [
\'bodyParser\',
\'compress\',
\'cookieSession\',
\'session\',
\'logger\',
\'cookieParser\',
\'favicon\',
\'responseTime\',
\'errorHandler\',
\'timeout\',
\'methodOverride\',
\'vhost\',
\'csrf\',
\'directory\',
\'limit\',
\'multipart\',
\'staticCache\'
]
removedMiddlewares.forEach(function (name) {
Object.defineProperty(exports, name, {
get: function () {
throw new Error(\'Most middleware (like \' + name + \') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.\');
},
configurable: true
});
});
/***/
}),
/***/ 7852:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var setPrototypeOf = __nccwpck_require__(2927)
/**
* Initialization middleware, exposing the
* request and response to each other, as well
* as defaulting the X-Powered-By header field.
*
* @param {Function} app
* @return {Function}
* @api private
*/
exports.init = function (app) {
return function expressInit(req, res, next) {
if (app.enabled(\'x-powered-by\')) res.setHeader(\'X-Powered-By\', \'Express\');
req.res = res;
res.req = req;
req.next = next;
setPrototypeOf(req, app.request)
setPrototypeOf(res, app.response)
res.locals = res.locals || Object.create(null);
next();
};
};
/***/
}),
/***/ 5192:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
*/
var merge = __nccwpck_require__(6996)
var parseUrl = __nccwpck_require__(222);
var qs = __nccwpck_require__(8556);
/**
* @param {Object} options
* @return {Function}
* @api public
*/
module.exports = function query(options) {
var opts = merge({}, options)
var queryparse = qs.parse;
if (typeof options === \'function\') {
queryparse = options;
opts = undefined;
}
if (opts !== undefined && opts.allowPrototypes === undefined) {
// back-compat for qs module
opts.allowPrototypes = true;
}
return function query(req, res, next) {
if (!req.query) {
var val = parseUrl(req).query;
req.query = queryparse(val, opts);
}
next();
};
};
/***/
}),
/***/ 903:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var accepts = __nccwpck_require__(7370);
var deprecate = __nccwpck_require__(2225)(\'express\');
var isIP = __nccwpck_require__(1631).isIP;
var typeis = __nccwpck_require__(6393);
var http = __nccwpck_require__(8605);
var fresh = __nccwpck_require__(8176);
var parseRange = __nccwpck_require__(2800);
var parse = __nccwpck_require__(222);
var proxyaddr = __nccwpck_require__(5293);
/**
* Request prototype.
* @public
*/
var req = Object.create(http.IncomingMessage.prototype)
/**
* Module exports.
* @public
*/
module.exports = req
/**
* Return request header.
*
* The `Referrer` header field is special-cased,
* both `Referrer` and `Referer` are interchangeable.
*
* Examples:
*
* req.get(\'Content-Type\');
* // => "text/plain"
*
* req.get(\'content-type\');
* // => "text/plain"
*
* req.get(\'Something\');
* // => undefined
*
* Aliased as `req.header()`.
*
* @param {String} name
* @return {String}
* @public
*/
req.get =
req.header = function header(name) {
if (!name) {
throw new TypeError(\'name argument is required to req.get\');
}
if (typeof name !== \'string\') {
throw new TypeError(\'name must be a string to req.get\');
}
var lc = name.toLowerCase();
switch (lc) {
case \'referer\':
case \'referrer\':
return this.headers.referrer
|| this.headers.referer;
default:
return this.headers[lc];
}
};
/**
* To do: update docs.
*
* Check if the given `type(s)` is acceptable, returning
* the best match when true, otherwise `undefined`, in which
* case you should respond with 406 "Not Acceptable".
*
* The `type` value may be a single MIME type string
* such as "application/json", an extension name
* such as "json", a comma-delimited list such as "json, html, text/plain",
* an argument list such as `"json", "html", "text/plain"`,
* or an array `["json", "html", "text/plain"]`. When a list
* or array is given, the _best_ match, if any is returned.
*
* Examples:
*
* // Accept: text/html
* req.accepts(\'html\');
* // => "html"
*
* // Accept: text/*, application/json
* req.accepts(\'html\');
* // => "html"
* req.accepts(\'text/html\');
* // => "text/html"
* req.accepts(\'json, text\');
* // => "json"
* req.accepts(\'application/json\');
* // => "application/json"
*
* // Accept: text/*, application/json
* req.accepts(\'image/png\');
* req.accepts(\'png\');
* // => undefined
*
* // Accept: text/*;q=.5, application/json
* req.accepts([\'html\', \'json\']);
* req.accepts(\'html\', \'json\');
* req.accepts(\'html, json\');
* // => "json"
*
* @param {String|Array} type(s)
* @return {String|Array|Boolean}
* @public
*/
req.accepts = function () {
var accept = accepts(this);
return accept.types.apply(accept, arguments);
};
/**
* Check if the given `encoding`s are accepted.
*
* @param {String} ...encoding
* @return {String|Array}
* @public
*/
req.acceptsEncodings = function () {
var accept = accepts(this);
return accept.encodings.apply(accept, arguments);
};
req.acceptsEncoding = deprecate.function(req.acceptsEncodings,
\'req.acceptsEncoding: Use acceptsEncodings instead\');
/**
* Check if the given `charset`s are acceptable,
* otherwise you should respond with 406 "Not Acceptable".
*
* @param {String} ...charset
* @return {String|Array}
* @public
*/
req.acceptsCharsets = function () {
var accept = accepts(this);
return accept.charsets.apply(accept, arguments);
};
req.acceptsCharset = deprecate.function(req.acceptsCharsets,
\'req.acceptsCharset: Use acceptsCharsets instead\');
/**
* Check if the given `lang`s are acceptable,
* otherwise you should respond with 406 "Not Acceptable".
*
* @param {String} ...lang
* @return {String|Array}
* @public
*/
req.acceptsLanguages = function () {
var accept = accepts(this);
return accept.languages.apply(accept, arguments);
};
req.acceptsLanguage = deprecate.function(req.acceptsLanguages,
\'req.acceptsLanguage: Use acceptsLanguages instead\');
/**
* Parse Range header field, capping to the given `size`.
*
* Unspecified ranges such as "0-" require knowledge of your resource length. In
* the case of a byte range this is of course the total number of bytes. If the
* Range header field is not given `undefined` is returned, `-1` when unsatisfiable,
* and `-2` when syntactically invalid.
*
* When ranges are returned, the array has a "type" property which is the type of
* range that is required (most commonly, "bytes"). Each array element is an object
* with a "start" and "end" property for the portion of the range.
*
* The "combine" option can be set to `true` and overlapping & adjacent ranges
* will be combined into a single range.
*
* NOTE: remember that ranges are inclusive, so for example "Range: users=0-3"
* should respond with 4 users when available, not 3.
*
* @param {number} size
* @param {object} [options]
* @param {boolean} [options.combine=false]
* @return {number|array}
* @public
*/
req.range = function range(size, options) {
var range = this.get(\'Range\');
if (!range) return;
return parseRange(size, range, options);
};
/**
* Return the value of param `name` when present or `defaultValue`.
*
* - Checks route placeholders, ex: _/user/:id_
* - Checks body params, ex: id=12, {"id":12}
* - Checks query string params, ex: ?id=12
*
* To utilize request bodies, `req.body`
* should be an object. This can be done by using
* the `bodyParser()` middleware.
*
* @param {String} name
* @param {Mixed} [defaultValue]
* @return {String}
* @public
*/
req.param = function param(name, defaultValue) {
var params = this.params || {};
var body = this.body || {};
var query = this.query || {};
var args = arguments.length === 1
? \'name\'
: \'name, default\';
deprecate(\'req.param(\' + args + \'): Use req.params, req.body, or req.query instead\');
if (null != params[name] && params.hasOwnProperty(name)) return params[name];
if (null != body[name]) return body[name];
if (null != query[name]) return query[name];
return defaultValue;
};
/**
* Check if the incoming request contains the "Content-Type"
* header field, and it contains the give mime `type`.
*
* Examples:
*
* // With Content-Type: text/html; charset=utf-8
* req.is(\'html\');
* req.is(\'text/html\');
* req.is(\'text/*\');
* // => true
*
* // When Content-Type is application/json
* req.is(\'json\');
* req.is(\'application/json\');
* req.is(\'application/*\');
* // => true
*
* req.is(\'html\');
* // => false
*
* @param {String|Array} types...
* @return {String|false|null}
* @public
*/
req.is = function is(types) {
var arr = types;
// support flattened arguments
if (!Array.isArray(types)) {
arr = new Array(arguments.length);
for (var i = 0; i < arr.length; i++) {
arr[i] = arguments[i];
}
}
return typeis(this, arr);
};
/**
* Return the protocol string "http" or "https"
* when requested with TLS. When the "trust proxy"
* setting trusts the socket address, the
* "X-Forwarded-Proto" header field will be trusted
* and used if present.
*
* If you\'re running behind a reverse proxy that
* supplies https for you this may be enabled.
*
* @return {String}
* @public
*/
defineGetter(req, \'protocol\', function protocol() {
var proto = this.connection.encrypted
? \'https\'
: \'http\';
var trust = this.app.get(\'trust proxy fn\');
if (!trust(this.connection.remoteAddress, 0)) {
return proto;
}
// Note: X-Forwarded-Proto is normally only ever a
// single value, but this is to be safe.
var header = this.get(\'X-Forwarded-Proto\') || proto
var index = header.indexOf(\',\')
return index !== -1
? header.substring(0, index).trim()
: header.trim()
});
/**
* Short-hand for:
*
* req.protocol === \'https\'
*
* @return {Boolean}
* @public
*/
defineGetter(req, \'secure\', function secure() {
return this.protocol === \'https\';
});
/**
* Return the remote address from the trusted proxy.
*
* The is the remote address on the socket unless
* "trust proxy" is set.
*
* @return {String}
* @public
*/
defineGetter(req, \'ip\', function ip() {
var trust = this.app.get(\'trust proxy fn\');
return proxyaddr(this, trust);
});
/**
* When "trust proxy" is set, trusted proxy addresses + client.
*
* For example if the value were "client, proxy1, proxy2"
* you would receive the array `["client", "proxy1", "proxy2"]`
* where "proxy2" is the furthest down-stream and "proxy1" and
* "proxy2" were trusted.
*
* @return {Array}
* @public
*/
defineGetter(req, \'ips\', function ips() {
var trust = this.app.get(\'trust proxy fn\');
var addrs = proxyaddr.all(this, trust);
// reverse the order (to farthest -> closest)
// and remove socket address
addrs.reverse().pop()
return addrs
});
/**
* Return subdomains as an array.
*
* Subdomains are the dot-separated parts of the host before the main domain of
* the app. By default, the domain of the app is assumed to be the last two
* parts of the host. This can be changed by setting "subdomain offset".
*
* For example, if the domain is "tobi.ferrets.example.com":
* If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`.
* If "subdomain offset" is 3, req.subdomains is `["tobi"]`.
*
* @return {Array}
* @public
*/
defineGetter(req, \'subdomains\', function subdomains() {
var hostname = this.hostname;
if (!hostname) return [];
var offset = this.app.get(\'subdomain offset\');
var subdomains = !isIP(hostname)
? hostname.split(\'.\').reverse()
: [hostname];
return subdomains.slice(offset);
});
/**
* Short-hand for `url.parse(req.url).pathname`.
*
* @return {String}
* @public
*/
defineGetter(req, \'path\', function path() {
return parse(this).pathname;
});
/**
* Parse the "Host" header field to a hostname.
*
* When the "trust proxy" setting trusts the socket
* address, the "X-Forwarded-Host" header field will
* be trusted.
*
* @return {String}
* @public
*/
defineGetter(req, \'hostname\', function hostname() {
var trust = this.app.get(\'trust proxy fn\');
var host = this.get(\'X-Forwarded-Host\');
if (!host || !trust(this.connection.remoteAddress, 0)) {
host = this.get(\'Host\');
} else if (host.indexOf(\',\') !== -1) {
// Note: X-Forwarded-Host is normally only ever a
// single value, but this is to be safe.
host = host.substring(0, host.indexOf(\',\')).trimRight()
}
if (!host) return;
// IPv6 literal support
var offset = host[0] === \'[\'
? host.indexOf(\']\') + 1
: 0;
var index = host.indexOf(\':\', offset);
return index !== -1
? host.substring(0, index)
: host;
});
// TODO: change req.host to return host in next major
defineGetter(req, \'host\', deprecate.function(function host() {
return this.hostname;
}, \'req.host: Use req.hostname instead\'));
/**
* Check if the request is fresh, aka
* Last-Modified and/or the ETag
* still match.
*
* @return {Boolean}
* @public
*/
defineGetter(req, \'fresh\', function () {
var method = this.method;
var res = this.res
var status = res.statusCode
// GET or HEAD for weak freshness validation only
if (\'GET\' !== method && \'HEAD\' !== method) return false;
// 2xx or 304 as per rfc2616 14.26
if ((status >= 200 && status < 300) || 304 === status) {
return fresh(this.headers, {
\'etag\': res.get(\'ETag\'),
\'last-modified\': res.get(\'Last-Modified\')
})
}
return false;
});
/**
* Check if the request is stale, aka
* "Last-Modified" and / or the "ETag" for the
* resource has changed.
*
* @return {Boolean}
* @public
*/
defineGetter(req, \'stale\', function stale() {
return !this.fresh;
});
/**
* Check if the request was an _XMLHttpRequest_.
*
* @return {Boolean}
* @public
*/
defineGetter(req, \'xhr\', function xhr() {
var val = this.get(\'X-Requested-With\') || \'\';
return val.toLowerCase() === \'xmlhttprequest\';
});
/**
* Helper function for creating a getter on an object.
*
* @param {Object} obj
* @param {String} name
* @param {Function} getter
* @private
*/
function defineGetter(obj, name, getter) {
Object.defineProperty(obj, name, {
configurable: true,
enumerable: true,
get: getter
});
}
/***/
}),
/***/ 7187:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var Buffer = __nccwpck_require__(7608).Buffer
var contentDisposition = __nccwpck_require__(2505);
var deprecate = __nccwpck_require__(2225)(\'express\');
var encodeUrl = __nccwpck_require__(1979);
var escapeHtml = __nccwpck_require__(6591);
var http = __nccwpck_require__(8605);
var isAbsolute = __nccwpck_require__(5665).isAbsolute;
var onFinished = __nccwpck_require__(7117);
var path = __nccwpck_require__(5622);
var statuses = __nccwpck_require__(5755)
var merge = __nccwpck_require__(6996);
var sign = __nccwpck_require__(3524).sign;
var normalizeType = __nccwpck_require__(5665).normalizeType;
var normalizeTypes = __nccwpck_require__(5665).normalizeTypes;
var setCharset = __nccwpck_require__(5665).setCharset;
var cookie = __nccwpck_require__(6810);
var send = __nccwpck_require__(7176);
var extname = path.extname;
var mime = send.mime;
var resolve = path.resolve;
var vary = __nccwpck_require__(4974);
/**
* Response prototype.
* @public
*/
var res = Object.create(http.ServerResponse.prototype)
/**
* Module exports.
* @public
*/
module.exports = res
/**
* Module variables.
* @private
*/
var charsetRegExp = /;\s*charset\s*=/;
/**
* Set status `code`.
*
* @param {Number} code
* @return {ServerResponse}
* @public
*/
res.status = function status(code) {
this.statusCode = code;
return this;
};
/**
* Set Link header field with the given `links`.
*
* Examples:
*
* res.links({
* next: \'http://api.example.com/users?page=2\',
* last: \'http://api.example.com/users?page=5\'
* });
*
* @param {Object} links
* @return {ServerResponse}
* @public
*/
res.links = function (links) {
var link = this.get(\'Link\') || \'\';
if (link) link += \', \';
return this.set(\'Link\', link + Object.keys(links).map(function (rel) {
return \'<\' + links[rel] + \'>; rel="\' + rel + \'"\';
}).join(\', \'));
};
/**
* Send a response.
*
* Examples:
*
* res.send(Buffer.from(\'wahoo\'));
* res.send({ some: \'json\' });
* res.send(\'<p>some html</p>\');
*
* @param {string|number|boolean|object|Buffer} body
* @public
*/
res.send = function send(body) {
var chunk = body;
var encoding;
var req = this.req;
var type;
// settings
var app = this.app;
// allow status / body
if (arguments.length === 2) {
// res.send(body, status) backwards compat
if (typeof arguments[0] !== \'number\' && typeof arguments[1] === \'number\') {
deprecate(\'res.send(body, status): Use res.status(status).send(body) instead\');
this.statusCode = arguments[1];
} else {
deprecate(\'res.send(status, body): Use res.status(status).send(body) instead\');
this.statusCode = arguments[0];
chunk = arguments[1];
}
}
// disambiguate res.send(status) and res.send(status, num)
if (typeof chunk === \'number\' && arguments.length === 1) {
// res.send(status) will set status message as text string
if (!this.get(\'Content-Type\')) {
this.type(\'txt\');
}
deprecate(\'res.send(status): Use res.sendStatus(status) instead\');
this.statusCode = chunk;
chunk = statuses[chunk]
}
switch (typeof chunk) {
// string defaulting to html
case \'string\':
if (!this.get(\'Content-Type\')) {
this.type(\'html\');
}
break;
case \'boolean\':
case \'number\':
case \'object\':
if (chunk === null) {
chunk = \'\';
} else if (Buffer.isBuffer(chunk)) {
if (!this.get(\'Content-Type\')) {
this.type(\'bin\');
}
} else {
return this.json(chunk);
}
break;
}
// write strings in utf-8
if (typeof chunk === \'string\') {
encoding = \'utf8\';
type = this.get(\'Content-Type\');
// reflect this in content-type
if (typeof type === \'string\') {
this.set(\'Content-Type\', setCharset(type, \'utf-8\'));
}
}
// determine if ETag should be generated
var etagFn = app.get(\'etag fn\')
var generateETag = !this.get(\'ETag\') && typeof etagFn === \'function\'
// populate Content-Length
var len
if (chunk !== undefined) {
if (Buffer.isBuffer(chunk)) {
// get length of Buffer
len = chunk.length
} else if (!generateETag && chunk.length < 1000) {
// just calculate length when no ETag + small chunk
len = Buffer.byteLength(chunk, encoding)
} else {
// convert chunk to Buffer and calculate
chunk = Buffer.from(chunk, encoding)
encoding = undefined;
len = chunk.length
}
this.set(\'Content-Length\', len);
}
// populate ETag
var etag;
if (generateETag && len !== undefined) {
if ((etag = etagFn(chunk, encoding))) {
this.set(\'ETag\', etag);
}
}
// freshness
if (req.fresh) this.statusCode = 304;
// strip irrelevant headers
if (204 === this.statusCode || 304 === this.statusCode) {
this.removeHeader(\'Content-Type\');
this.removeHeader(\'Content-Length\');
this.removeHeader(\'Transfer-Encoding\');
chunk = \'\';
}
if (req.method === \'HEAD\') {
// skip body for HEAD
this.end();
} else {
// respond
this.end(chunk, encoding);
}
return this;
};
/**
* Send JSON response.
*
* Examples:
*
* res.json(null);
* res.json({ user: \'tj\' });
*
* @param {string|number|boolean|object} obj
* @public
*/
res.json = function json(obj) {
var val = obj;
// allow status / body
if (arguments.length === 2) {
// res.json(body, status) backwards compat
if (typeof arguments[1] === \'number\') {
deprecate(\'res.json(obj, status): Use res.status(status).json(obj) instead\');
this.statusCode = arguments[1];
} else {
deprecate(\'res.json(status, obj): Use res.status(status).json(obj) instead\');
this.statusCode = arguments[0];
val = arguments[1];
}
}
// settings
var app = this.app;
var escape = app.get(\'json escape\')
var replacer = app.get(\'json replacer\');
var spaces = app.get(\'json spaces\');
var body = stringify(val, replacer, spaces, escape)
// content-type
if (!this.get(\'Content-Type\')) {
this.set(\'Content-Type\', \'application/json\');
}
return this.send(body);
};
/**
* Send JSON response with JSONP callback support.
*
* Examples:
*
* res.jsonp(null);
* res.jsonp({ user: \'tj\' });
*
* @param {string|number|boolean|object} obj
* @public
*/
res.jsonp = function jsonp(obj) {
var val = obj;
// allow status / body
if (arguments.length === 2) {
// res.json(body, status) backwards compat
if (typeof arguments[1] === \'number\') {
deprecate(\'res.jsonp(obj, status): Use res.status(status).json(obj) instead\');
this.statusCode = arguments[1];
} else {
deprecate(\'res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead\');
this.statusCode = arguments[0];
val = arguments[1];
}
}
// settings
var app = this.app;
var escape = app.get(\'json escape\')
var replacer = app.get(\'json replacer\');
var spaces = app.get(\'json spaces\');
var body = stringify(val, replacer, spaces, escape)
var callback = this.req.query[app.get(\'jsonp callback name\')];
// content-type
if (!this.get(\'Content-Type\')) {
this.set(\'X-Content-Type-Options\', \'nosniff\');
this.set(\'Content-Type\', \'application/json\');
}
// fixup callback
if (Array.isArray(callback)) {
callback = callback[0];
}
// jsonp
if (typeof callback === \'string\' && callback.length !== 0) {
this.set(\'X-Content-Type-Options\', \'nosniff\');
this.set(\'Content-Type\', \'text/javascript\');
// restrict callback charset
callback = callback.replace(/[^\[\]\w$.]/g, \'\');
// replace chars not allowed in JavaScript that are in JSON
body = body
.replace(/\u2028/g, \'\\u2028\')
.replace(/\u2029/g, \'\\u2029\');
// the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse"
// the typeof check is just to reduce client error noise
body = \'/**/ typeof \' + callback + \' === \\'function\\' && \' + callback + \'(\' + body + \');\';
}
return this.send(body);
};
/**
* Send given HTTP status code.
*
* Sets the response status to `statusCode` and the body of the
* response to the standard description from node\'s http.STATUS_CODES
* or the statusCode number if no description.
*
* Examples:
*
* res.sendStatus(200);
*
* @param {number} statusCode
* @public
*/
res.sendStatus = function sendStatus(statusCode) {
var body = statuses[statusCode] || String(statusCode)
this.statusCode = statusCode;
this.type(\'txt\');
return this.send(body);
};
/**
* Transfer the file at the given `path`.
*
* Automatically sets the _Content-Type_ response header field.
* The callback `callback(err)` is invoked when the transfer is complete
* or when an error occurs. Be sure to check `res.sentHeader`
* if you wish to attempt responding, as the header and some data
* may have already been transferred.
*
* Options:
*
* - `maxAge` defaulting to 0 (can be string converted by `ms`)
* - `root` root directory for relative filenames
* - `headers` object of headers to serve with file
* - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them
*
* Other options are passed along to `send`.
*
* Examples:
*
* The following example illustrates how `res.sendFile()` may
* be used as an alternative for the `static()` middleware for
* dynamic situations. The code backing `res.sendFile()` is actually
* the same code, so HTTP cache support etc is identical.
*
* app.get(\'/user/:uid/photos/:file\', function(req, res){
* var uid = req.params.uid
* , file = req.params.file;
*
* req.user.mayViewFilesFrom(uid, function(yes){
* if (yes) {
* res.sendFile(\'/uploads/\' + uid + \'/\' + file);
* } else {
* res.send(403, \'Sorry! you cant see that.\');
* }
* });
* });
*
* @public
*/
res.sendFile = function sendFile(path, options, callback) {
var done = callback;
var req = this.req;
var res = this;
var next = req.next;
var opts = options || {};
if (!path) {
throw new TypeError(\'path argument is required to res.sendFile\');
}
if (typeof path !== \'string\') {
throw new TypeError(\'path must be a string to res.sendFile\')
}
// support function as second arg
if (typeof options === \'function\') {
done = options;
opts = {};
}
if (!opts.root && !isAbsolute(path)) {
throw new TypeError(\'path must be absolute or specify root to res.sendFile\');
}
// create file stream
var pathname = encodeURI(path);
var file = send(req, pathname, opts);
// transfer
sendfile(res, file, opts, function (err) {
if (done) return done(err);
if (err && err.code === \'EISDIR\') return next();
// next() all but write errors
if (err && err.code !== \'ECONNABORTED\' && err.syscall !== \'write\') {
next(err);
}
});
};
/**
* Transfer the file at the given `path`.
*
* Automatically sets the _Content-Type_ response header field.
* The callback `callback(err)` is invoked when the transfer is complete
* or when an error occurs. Be sure to check `res.sentHeader`
* if you wish to attempt responding, as the header and some data
* may have already been transferred.
*
* Options:
*
* - `maxAge` defaulting to 0 (can be string converted by `ms`)
* - `root` root directory for relative filenames
* - `headers` object of headers to serve with file
* - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them
*
* Other options are passed along to `send`.
*
* Examples:
*
* The following example illustrates how `res.sendfile()` may
* be used as an alternative for the `static()` middleware for
* dynamic situations. The code backing `res.sendfile()` is actually
* the same code, so HTTP cache support etc is identical.
*
* app.get(\'/user/:uid/photos/:file\', function(req, res){
* var uid = req.params.uid
* , file = req.params.file;
*
* req.user.mayViewFilesFrom(uid, function(yes){
* if (yes) {
* res.sendfile(\'/uploads/\' + uid + \'/\' + file);
* } else {
* res.send(403, \'Sorry! you cant see that.\');
* }
* });
* });
*
* @public
*/
res.sendfile = function (path, options, callback) {
var done = callback;
var req = this.req;
var res = this;
var next = req.next;
var opts = options || {};
// support function as second arg
if (typeof options === \'function\') {
done = options;
opts = {};
}
// create file stream
var file = send(req, path, opts);
// transfer
sendfile(res, file, opts, function (err) {
if (done) return done(err);
if (err && err.code === \'EISDIR\') return next();
// next() all but write errors
if (err && err.code !== \'ECONNABORTED\' && err.syscall !== \'write\') {
next(err);
}
});
};
res.sendfile = deprecate.function(res.sendfile,
\'res.sendfile: Use res.sendFile instead\');
/**
* Transfer the file at the given `path` as an attachment.
*
* Optionally providing an alternate attachment `filename`,
* and optional callback `callback(err)`. The callback is invoked
* when the data transfer is complete, or when an error has
* ocurred. Be sure to check `res.headersSent` if you plan to respond.
*
* Optionally providing an `options` object to use with `res.sendFile()`.
* This function will set the `Content-Disposition` header, overriding
* any `Content-Disposition` header passed as header options in order
* to set the attachment and filename.
*
* This method uses `res.sendFile()`.
*
* @public
*/
res.download = function download(path, filename, options, callback) {
var done = callback;
var name = filename;
var opts = options || null
// support function as second or third arg
if (typeof filename === \'function\') {
done = filename;
name = null;
opts = null
} else if (typeof options === \'function\') {
done = options
opts = null
}
// set Content-Disposition when file is sent
var headers = {
\'Content-Disposition\': contentDisposition(name || path)
};
// merge user-provided headers
if (opts && opts.headers) {
var keys = Object.keys(opts.headers)
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
if (key.toLowerCase() !== \'content-disposition\') {
headers[key] = opts.headers[key]
}
}
}
// merge user-provided options
opts = Object.create(opts)
opts.headers = headers
// Resolve the full path for sendFile
var fullPath = resolve(path);
// send file
return this.sendFile(fullPath, opts, done)
};
/**
* Set _Content-Type_ response header with `type` through `mime.lookup()`
* when it does not contain "/", or set the Content-Type to `type` otherwise.
*
* Examples:
*
* res.type(\'.html\');
* res.type(\'html\');
* res.type(\'json\');
* res.type(\'application/json\');
* res.type(\'png\');
*
* @param {String} type
* @return {ServerResponse} for chaining
* @public
*/
res.contentType =
res.type = function contentType(type) {
var ct = type.indexOf(\'/\') === -1
? mime.lookup(type)
: type;
return this.set(\'Content-Type\', ct);
};
/**
* Respond to the Acceptable formats using an `obj`
* of mime-type callbacks.
*
* This method uses `req.accepted`, an array of
* acceptable types ordered by their quality values.
* When "Accept" is not present the _first_ callback
* is invoked, otherwise the first match is used. When
* no match is performed the server responds with
* 406 "Not Acceptable".
*
* Content-Type is set for you, however if you choose
* you may alter this within the callback using `res.type()`
* or `res.set(\'Content-Type\', ...)`.
*
* res.format({
* \'text/plain\': function(){
* res.send(\'hey\');
* },
*
* \'text/html\': function(){
* res.send(\'<p>hey</p>\');
* },
*
* \'appliation/json\': function(){
* res.send({ message: \'hey\' });
* }
* });
*
* In addition to canonicalized MIME types you may
* also use extnames mapped to these types:
*
* res.format({
* text: function(){
* res.send(\'hey\');
* },
*
* html: function(){
* res.send(\'<p>hey</p>\');
* },
*
* json: function(){
* res.send({ message: \'hey\' });
* }
* });
*
* By default Express passes an `Error`
* with a `.status` of 406 to `next(err)`
* if a match is not made. If you provide
* a `.default` callback it will be invoked
* instead.
*
* @param {Object} obj
* @return {ServerResponse} for chaining
* @public
*/
res.format = function (obj) {
var req = this.req;
var next = req.next;
var fn = obj.default;
if (fn) delete obj.default;
var keys = Object.keys(obj);
var key = keys.length > 0
? req.accepts(keys)
: false;
this.vary("Accept");
if (key) {
this.set(\'Content-Type\', normalizeType(key).value);
obj[key](req, this, next);
} else if (fn) {
fn();
} else {
var err = new Error(\'Not Acceptable\');
err.status = err.statusCode = 406;
err.types = normalizeTypes(keys).map(function (o) { return o.value });
next(err);
}
return this;
};
/**
* Set _Content-Disposition_ header to _attachment_ with optional `filename`.
*
* @param {String} filename
* @return {ServerResponse}
* @public
*/
res.attachment = function attachment(filename) {
if (filename) {
this.type(extname(filename));
}
this.set(\'Content-Disposition\', contentDisposition(filename));
return this;
};
/**
* Append additional header `field` with value `val`.
*
* Example:
*
* res.append(\'Link\', [\'<http://localhost/>\', \'<http://localhost:3000/>\']);
* res.append(\'Set-Cookie\', \'foo=bar; Path=/; HttpOnly\');
* res.append(\'Warning\', \'199 Miscellaneous warning\');
*
* @param {String} field
* @param {String|Array} val
* @return {ServerResponse} for chaining
* @public
*/
res.append = function append(field, val) {
var prev = this.get(field);
var value = val;
if (prev) {
// concat the new and prev vals
value = Array.isArray(prev) ? prev.concat(val)
: Array.isArray(val) ? [prev].concat(val)
: [prev, val];
}
return this.set(field, value);
};
/**
* Set header `field` to `val`, or pass
* an object of header fields.
*
* Examples:
*
* res.set(\'Foo\', [\'bar\', \'baz\']);
* res.set(\'Accept\', \'application/json\');
* res.set({ Accept: \'text/plain\', \'X-API-Key\': \'tobi\' });
*
* Aliased as `res.header()`.
*
* @param {String|Object} field
* @param {String|Array} val
* @return {ServerResponse} for chaining
* @public
*/
res.set =
res.header = function header(field, val) {
if (arguments.length === 2) {
var value = Array.isArray(val)
? val.map(String)
: String(val);
// add charset to content-type
if (field.toLowerCase() === \'content-type\') {
if (Array.isArray(value)) {
throw new TypeError(\'Content-Type cannot be set to an Array\');
}
if (!charsetRegExp.test(value)) {
var charset = mime.charsets.lookup(value.split(\';\')[0]);
if (charset) value += \'; charset=\' + charset.toLowerCase();
}
}
this.setHeader(field, value);
} else {
for (var key in field) {
this.set(key, field[key]);
}
}
return this;
};
/**
* Get value for header `field`.
*
* @param {String} field
* @return {String}
* @public
*/
res.get = function (field) {
return this.getHeader(field);
};
/**
* Clear cookie `name`.
*
* @param {String} name
* @param {Object} [options]
* @return {ServerResponse} for chaining
* @public
*/
res.clearCookie = function clearCookie(name, options) {
var opts = merge({ expires: new Date(1), path: \'/\' }, options);
return this.cookie(name, \'\', opts);
};
/**
* Set cookie `name` to `value`, with the given `options`.
*
* Options:
*
* - `maxAge` max-age in milliseconds, converted to `expires`
* - `signed` sign the cookie
* - `path` defaults to "/"
*
* Examples:
*
* // "Remember Me" for 15 minutes
* res.cookie(\'rememberme\', \'1\', { expires: new Date(Date.now() + 900000), httpOnly: true });
*
* // same as above
* res.cookie(\'rememberme\', \'1\', { maxAge: 900000, httpOnly: true })
*
* @param {String} name
* @param {String|Object} value
* @param {Object} [options]
* @return {ServerResponse} for chaining
* @public
*/
res.cookie = function (name, value, options) {
var opts = merge({}, options);
var secret = this.req.secret;
var signed = opts.signed;
if (signed && !secret) {
throw new Error(\'cookieParser("secret") required for signed cookies\');
}
var val = typeof value === \'object\'
? \'j:\' + JSON.stringify(value)
: String(value);
if (signed) {
val = \'s:\' + sign(val, secret);
}
if (\'maxAge\' in opts) {
opts.expires = new Date(Date.now() + opts.maxAge);
opts.maxAge /= 1000;
}
if (opts.path == null) {
opts.path = \'/\';
}
this.append(\'Set-Cookie\', cookie.serialize(name, String(val), opts));
return this;
};
/**
* Set the location header to `url`.
*
* The given `url` can also be "back", which redirects
* to the _Referrer_ or _Referer_ headers or "/".
*
* Examples:
*
* res.location(\'/foo/bar\').;
* res.location(\'http://example.com\');
* res.location(\'../login\');
*
* @param {String} url
* @return {ServerResponse} for chaining
* @public
*/
res.location = function location(url) {
var loc = url;
// "back" is an alias for the referrer
if (url === \'back\') {
loc = this.req.get(\'Referrer\') || \'/\';
}
// set location
return this.set(\'Location\', encodeUrl(loc));
};
/**
* Redirect to the given `url` with optional response `status`
* defaulting to 302.
*
* The resulting `url` is determined by `res.location()`, so
* it will play nicely with mounted apps, relative paths,
* `"back"` etc.
*
* Examples:
*
* res.redirect(\'/foo/bar\');
* res.redirect(\'http://example.com\');
* res.redirect(301, \'http://example.com\');
* res.redirect(\'../login\'); // /blog/post/1 -> /blog/login
*
* @public
*/
res.redirect = function redirect(url) {
var address = url;
var body;
var status = 302;
// allow status / url
if (arguments.length === 2) {
if (typeof arguments[0] === \'number\') {
status = arguments[0];
address = arguments[1];
} else {
deprecate(\'res.redirect(url, status): Use res.redirect(status, url) instead\');
status = arguments[1];
}
}
// Set location header
address = this.location(address).get(\'Location\');
// Support text/{plain,html} by default
this.format({
text: function () {
body = statuses[status] + \'. Redirecting to \' + address
},
html: function () {
var u = escapeHtml(address);
body = \'<p>\' + statuses[status] + \'. Redirecting to <a href="\' + u + \'">\' + u + \'</a></p>\'
},
default: function () {
body = \'\';
}
});
// Respond
this.statusCode = status;
this.set(\'Content-Length\', Buffer.byteLength(body));
if (this.req.method === \'HEAD\') {
this.end();
} else {
this.end(body);
}
};
/**
* Add `field` to Vary. If already present in the Vary set, then
* this call is simply ignored.
*
* @param {Array|String} field
* @return {ServerResponse} for chaining
* @public
*/
res.vary = function (field) {
// checks for back-compat
if (!field || (Array.isArray(field) && !field.length)) {
deprecate(\'res.vary(): Provide a field name\');
return this;
}
vary(this, field);
return this;
};
/**
* Render `view` with the given `options` and optional callback `fn`.
* When a callback function is given a response will _not_ be made
* automatically, otherwise a response of _200_ and _text/html_ is given.
*
* Options:
*
* - `cache` boolean hinting to the engine it should cache
* - `filename` filename of the view being rendered
*
* @public
*/
res.render = function render(view, options, callback) {
var app = this.req.app;
var done = callback;
var opts = options || {};
var req = this.req;
var self = this;
// support callback function as second arg
if (typeof options === \'function\') {
done = options;
opts = {};
}
// merge res.locals
opts._locals = self.locals;
// default callback to respond
done = done || function (err, str) {
if (err) return req.next(err);
self.send(str);
};
// render
app.render(view, opts, done);
};
// pipe the send file stream
function sendfile(res, file, options, callback) {
var done = false;
var streaming;
// request aborted
function onaborted() {
if (done) return;
done = true;
var err = new Error(\'Request aborted\');
err.code = \'ECONNABORTED\';
callback(err);
}
// directory
function ondirectory() {
if (done) return;
done = true;
var err = new Error(\'EISDIR, read\');
err.code = \'EISDIR\';
callback(err);
}
// errors
function onerror(err) {
if (done) return;
done = true;
callback(err);
}
// ended
function onend() {
if (done) return;
done = true;
callback();
}
// file
function onfile() {
streaming = false;
}
// finished
function onfinish(err) {
if (err && err.code === \'ECONNRESET\') return onaborted();
if (err) return onerror(err);
if (done) return;
setImmediate(function () {
if (streaming !== false && !done) {
onaborted();
return;
}
if (done) return;
done = true;
callback();
});
}
// streaming
function onstream() {
streaming = true;
}
file.on(\'directory\', ondirectory);
file.on(\'end\', onend);
file.on(\'error\', onerror);
file.on(\'file\', onfile);
file.on(\'stream\', onstream);
onFinished(res, onfinish);
if (options.headers) {
// set headers on successful transfer
file.on(\'headers\', function headers(res) {
var obj = options.headers;
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
res.setHeader(k, obj[k]);
}
});
}
// pipe
file.pipe(res);
}
/**
* Stringify JSON, like JSON.stringify, but v8 optimized, with the
* ability to escape characters that can trigger HTML sniffing.
*
* @param {*} value
* @param {function} replaces
* @param {number} spaces
* @param {boolean} escape
* @returns {string}
* @private
*/
function stringify(value, replacer, spaces, escape) {
// v8 checks arguments.length for optimizing simple call
// https://bugs.chromium.org/p/v8/issues/detail?id=4730
var json = replacer || spaces
? JSON.stringify(value, replacer, spaces)
: JSON.stringify(value);
if (escape) {
json = json.replace(/[<>&]/g, function (c) {
switch (c.charCodeAt(0)) {
case 0x3c:
return \'\\u003c\'
case 0x3e:
return \'\\u003e\'
case 0x26:
return \'\\u0026\'
/* istanbul ignore next: unreachable default */
default:
return c
}
})
}
return json
}
/***/
}),
/***/ 1061:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var Route = __nccwpck_require__(3192);
var Layer = __nccwpck_require__(4663);
var methods = __nccwpck_require__(3454);
var mixin = __nccwpck_require__(6996);
var debug = __nccwpck_require__(8609)(\'express:router\');
var deprecate = __nccwpck_require__(2225)(\'express\');
var flatten = __nccwpck_require__(6663);
var parseUrl = __nccwpck_require__(222);
var setPrototypeOf = __nccwpck_require__(2927)
/**
* Module variables.
* @private
*/
var objectRegExp = /^\[object (\S+)\]$/;
var slice = Array.prototype.slice;
var toString = Object.prototype.toString;
/**
* Initialize a new `Router` with the given `options`.
*
* @param {Object} [options]
* @return {Router} which is an callable function
* @public
*/
var proto = module.exports = function (options) {
var opts = options || {};
function router(req, res, next) {
router.handle(req, res, next);
}
// mixin Router class functions
setPrototypeOf(router, proto)
router.params = {};
router._params = [];
router.caseSensitive = opts.caseSensitive;
router.mergeParams = opts.mergeParams;
router.strict = opts.strict;
router.stack = [];
return router;
};
/**
* Map the given param placeholder `name`(s) to the given callback.
*
* Parameter mapping is used to provide pre-conditions to routes
* which use normalized placeholders. For example a _:user_id_ parameter
* could automatically load a user\'s information from the database without
* any additional code,
*
* The callback uses the same signature as middleware, the only difference
* being that the value of the placeholder is passed, in this case the _id_
* of the user. Once the `next()` function is invoked, just like middleware
* it will continue on to execute the route, or subsequent parameter functions.
*
* Just like in middleware, you must either respond to the request or call next
* to avoid stalling the request.
*
* app.param(\'user_id\', function(req, res, next, id){
* User.find(id, function(err, user){
* if (err) {
* return next(err);
* } else if (!user) {
* return next(new Error(\'failed to load user\'));
* }
* req.user = user;
* next();
* });
* });
*
* @param {String} name
* @param {Function} fn
* @return {app} for chaining
* @public
*/
proto.param = function param(name, fn) {
// param logic
if (typeof name === \'function\') {
deprecate(\'router.param(fn): Refactor to use path params\');
this._params.push(name);
return;
}
// apply param functions
var params = this._params;
var len = params.length;
var ret;
if (name[0] === \':\') {
deprecate(\'router.param(\' + JSON.stringify(name) + \', fn): Use router.param(\' + JSON.stringify(name.substr(1)) + \', fn) instead\');
name = name.substr(1);
}
for (var i = 0; i < len; ++i) {
if (ret = params[i](name, fn)) {
fn = ret;
}
}
// ensure we end up with a
// middleware function
if (\'function\' !== typeof fn) {
throw new Error(\'invalid param() call for \' + name + \', got \' + fn);
}
(this.params[name] = this.params[name] || []).push(fn);
return this;
};
/**
* Dispatch a req, res into the router.
* @private
*/
proto.handle = function handle(req, res, out) {
var self = this;
debug(\'dispatching %s %s\', req.method, req.url);
var idx = 0;
var protohost = getProtohost(req.url) || \'\'
var removed = \'\';
var slashAdded = false;
var paramcalled = {};
// store options for OPTIONS request
// only used if OPTIONS request
var options = [];
// middleware and routes
var stack = self.stack;
// manage inter-router variables
var parentParams = req.params;
var parentUrl = req.baseUrl || \'\';
var done = restore(out, req, \'baseUrl\', \'next\', \'params\');
// setup next layer
req.next = next;
// for options requests, respond with a default if nothing else responds
if (req.method === \'OPTIONS\') {
done = wrap(done, function (old, err) {
if (err || options.length === 0) return old(err);
sendOptionsResponse(res, options, old);
});
}
// setup basic req values
req.baseUrl = parentUrl;
req.originalUrl = req.originalUrl || req.url;
next();
function next(err) {
var layerError = err === \'route\'
? null
: err;
// remove added slash
if (slashAdded) {
req.url = req.url.substr(1);
slashAdded = false;
}
// restore altered req.url
if (removed.length !== 0) {
req.baseUrl = parentUrl;
req.url = protohost + removed + req.url.substr(protohost.length);
removed = \'\';
}
// signal to exit router
if (layerError === \'router\') {
setImmediate(done, null)
return
}
// no more matching layers
if (idx >= stack.length) {
setImmediate(done, layerError);
return;
}
// get pathname of request
var path = getPathname(req);
if (path == null) {
return done(layerError);
}
// find next matching layer
var layer;
var match;
var route;
while (match !== true && idx < stack.length) {
layer = stack[idx++];
match = matchLayer(layer, path);
route = layer.route;
if (typeof match !== \'boolean\') {
// hold on to layerError
layerError = layerError || match;
}
if (match !== true) {
continue;
}
if (!route) {
// process non-route handlers normally
continue;
}
if (layerError) {
// routes do not match with a pending error
match = false;
continue;
}
var method = req.method;
var has_method = route._handles_method(method);
// build up automatic options response
if (!has_method && method === \'OPTIONS\') {
appendMethods(options, route._options());
}
// don\'t even bother matching route
if (!has_method && method !== \'HEAD\') {
match = false;
continue;
}
}
// no match
if (match !== true) {
return done(layerError);
}
// store route for dispatch on change
if (route) {
req.route = route;
}
// Capture one-time layer values
req.params = self.mergeParams
? mergeParams(layer.params, parentParams)
: layer.params;
var layerPath = layer.path;
// this should be done for the layer
self.process_params(layer, paramcalled, req, res, function (err) {
if (err) {
return next(layerError || err);
}
if (route) {
return layer.handle_request(req, res, next);
}
trim_prefix(layer, layerError, layerPath, path);
});
}
function trim_prefix(layer, layerError, layerPath, path) {
if (layerPath.length !== 0) {
// Validate path breaks on a path separator
var c = path[layerPath.length]
if (c && c !== \'/\' && c !== \'.\') return next(layerError)
// Trim off the part of the url that matches the route
// middleware (.use stuff) needs to have the path stripped
debug(\'trim prefix (%s) from url %s\', layerPath, req.url);
removed = layerPath;
req.url = protohost + req.url.substr(protohost.length + removed.length);
// Ensure leading slash
if (!protohost && req.url[0] !== \'/\') {
req.url = \'/\' + req.url;
slashAdded = true;
}
// Setup base URL (no trailing slash)
req.baseUrl = parentUrl + (removed[removed.length - 1] === \'/\'
? removed.substring(0, removed.length - 1)
: removed);
}
debug(\'%s %s : %s\', layer.name, layerPath, req.originalUrl);
if (layerError) {
layer.handle_error(layerError, req, res, next);
} else {
layer.handle_request(req, res, next);
}
}
};
/**
* Process any parameters for the layer.
* @private
*/
proto.process_params = function process_params(layer, called, req, res, done) {
var params = this.params;
// captured parameters from the layer, keys and values
var keys = layer.keys;
// fast track
if (!keys || keys.length === 0) {
return done();
}
var i = 0;
var name;
var paramIndex = 0;
var key;
var paramVal;
var paramCallbacks;
var paramCalled;
// process params in order
// param callbacks can be async
function param(err) {
if (err) {
return done(err);
}
if (i >= keys.length) {
return done();
}
paramIndex = 0;
key = keys[i++];
name = key.name;
paramVal = req.params[name];
paramCallbacks = params[name];
paramCalled = called[name];
if (paramVal === undefined || !paramCallbacks) {
return param();
}
// param previously called with same value or error occurred
if (paramCalled && (paramCalled.match === paramVal
|| (paramCalled.error && paramCalled.error !== \'route\'))) {
// restore value
req.params[name] = paramCalled.value;
// next param
return param(paramCalled.error);
}
called[name] = paramCalled = {
error: null,
match: paramVal,
value: paramVal
};
paramCallback();
}
// single param callbacks
function paramCallback(err) {
var fn = paramCallbacks[paramIndex++];
// store updated value
paramCalled.value = req.params[key.name];
if (err) {
// store error
paramCalled.error = err;
param(err);
return;
}
if (!fn) return param();
try {
fn(req, res, paramCallback, paramVal, key.name);
} catch (e) {
paramCallback(e);
}
}
param();
};
/**
* Use the given middleware function, with optional path, defaulting to "/".
*
* Use (like `.all`) will run for any http METHOD, but it will not add
* handlers for those methods so OPTIONS requests will not consider `.use`
* functions even if they could respond.
*
* The other difference is that _route_ path is stripped and not visible
* to the handler function. The main effect of this feature is that mounted
* handlers can operate without any code changes regardless of the "prefix"
* pathname.
*
* @public
*/
proto.use = function use(fn) {
var offset = 0;
var path = \'/\';
// default path to \'/\'
// disambiguate router.use([fn])
if (typeof fn !== \'function\') {
var arg = fn;
while (Array.isArray(arg) && arg.length !== 0) {
arg = arg[0];
}
// first arg is the path
if (typeof arg !== \'function\') {
offset = 1;
path = fn;
}
}
var callbacks = flatten(slice.call(arguments, offset));
if (callbacks.length === 0) {
throw new TypeError(\'Router.use() requires a middleware function\')
}
for (var i = 0; i < callbacks.length; i++) {
var fn = callbacks[i];
if (typeof fn !== \'function\') {
throw new TypeError(\'Router.use() requires a middleware function but got a \' + gettype(fn))
}
// add the middleware
debug(\'use %o %s\', path, fn.name || \'<anonymous>\')
var layer = new Layer(path, {
sensitive: this.caseSensitive,
strict: false,
end: false
}, fn);
layer.route = undefined;
this.stack.push(layer);
}
return this;
};
/**
* Create a new Route for the given path.
*
* Each route contains a separate middleware stack and VERB handlers.
*
* See the Route api documentation for details on adding handlers
* and middleware to routes.
*
* @param {String} path
* @return {Route}
* @public
*/
proto.route = function route(path) {
var route = new Route(path);
var layer = new Layer(path, {
sensitive: this.caseSensitive,
strict: this.strict,
end: true
}, route.dispatch.bind(route));
layer.route = route;
this.stack.push(layer);
return route;
};
// create Router#VERB functions
methods.concat(\'all\').forEach(function (method) {
proto[method] = function (path) {
var route = this.route(path)
route[method].apply(route, slice.call(arguments, 1));
return this;
};
});
// append methods to a list of methods
function appendMethods(list, addition) {
for (var i = 0; i < addition.length; i++) {
var method = addition[i];
if (list.indexOf(method) === -1) {
list.push(method);
}
}
}
// get pathname of request
function getPathname(req) {
try {
return parseUrl(req).pathname;
} catch (err) {
return undefined;
}
}
// Get get protocol + host for a URL
function getProtohost(url) {
if (typeof url !== \'string\' || url.length === 0 || url[0] === \'/\') {
return undefined
}
var searchIndex = url.indexOf(\'?\')
var pathLength = searchIndex !== -1
? searchIndex
: url.length
var fqdnIndex = url.substr(0, pathLength).indexOf(\'://\')
return fqdnIndex !== -1
? url.substr(0, url.indexOf(\'/\', 3 + fqdnIndex))
: undefined
}
// get type for error message
function gettype(obj) {
var type = typeof obj;
if (type !== \'object\') {
return type;
}
// inspect [[Class]] for objects
return toString.call(obj)
.replace(objectRegExp, \'$1\');
}
/**
* Match path to a layer.
*
* @param {Layer} layer
* @param {string} path
* @private
*/
function matchLayer(layer, path) {
try {
return layer.match(path);
} catch (err) {
return err;
}
}
// merge params with parent params
function mergeParams(params, parent) {
if (typeof parent !== \'object\' || !parent) {
return params;
}
// make copy of parent for base
var obj = mixin({}, parent);
// simple non-numeric merging
if (!(0 in params) || !(0 in parent)) {
return mixin(obj, params);
}
var i = 0;
var o = 0;
// determine numeric gaps
while (i in params) {
i++;
}
while (o in parent) {
o++;
}
// offset numeric indices in params before merge
for (i--; i >= 0; i--) {
params[i + o] = params[i];
// create holes for the merge when necessary
if (i < o) {
delete params[i];
}
}
return mixin(obj, params);
}
// restore obj props after function
function restore(fn, obj) {
var props = new Array(arguments.length - 2);
var vals = new Array(arguments.length - 2);
for (var i = 0; i < props.length; i++) {
props[i] = arguments[i + 2];
vals[i] = obj[props[i]];
}
return function () {
// restore vals
for (var i = 0; i < props.length; i++) {
obj[props[i]] = vals[i];
}
return fn.apply(this, arguments);
};
}
// send an OPTIONS response
function sendOptionsResponse(res, options, next) {
try {
var body = options.join(\',\');
res.set(\'Allow\', body);
res.send(body);
} catch (err) {
next(err);
}
}
// wrap a function
function wrap(old, fn) {
return function proxy() {
var args = new Array(arguments.length + 1);
args[0] = old;
for (var i = 0, len = arguments.length; i < len; i++) {
args[i + 1] = arguments[i];
}
fn.apply(this, args);
};
}
/***/
}),
/***/ 4663:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var pathRegexp = __nccwpck_require__(3230);
var debug = __nccwpck_require__(8609)(\'express:router:layer\');
/**
* Module variables.
* @private
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Module exports.
* @public
*/
module.exports = Layer;
function Layer(path, options, fn) {
if (!(this instanceof Layer)) {
return new Layer(path, options, fn);
}
debug(\'new %o\', path)
var opts = options || {};
this.handle = fn;
this.name = fn.name || \'<anonymous>\';
this.params = undefined;
this.path = undefined;
this.regexp = pathRegexp(path, this.keys = [], opts);
// set fast path flags
this.regexp.fast_star = path === \'*\'
this.regexp.fast_slash = path === \'/\' && opts.end === false
}
/**
* Handle the error for the layer.
*
* @param {Error} error
* @param {Request} req
* @param {Response} res
* @param {function} next
* @api private
*/
Layer.prototype.handle_error = function handle_error(error, req, res, next) {
var fn = this.handle;
if (fn.length !== 4) {
// not a standard error handler
return next(error);
}
try {
fn(error, req, res, next);
} catch (err) {
next(err);
}
};
/**
* Handle the request for the layer.
*
* @param {Request} req
* @param {Response} res
* @param {function} next
* @api private
*/
Layer.prototype.handle_request = function handle(req, res, next) {
var fn = this.handle;
if (fn.length > 3) {
// not a standard request handler
return next();
}
try {
fn(req, res, next);
} catch (err) {
next(err);
}
};
/**
* Check if this route matches `path`, if so
* populate `.params`.
*
* @param {String} path
* @return {Boolean}
* @api private
*/
Layer.prototype.match = function match(path) {
var match
if (path != null) {
// fast path non-ending match for / (any path matches)
if (this.regexp.fast_slash) {
this.params = {}
this.path = \'\'
return true
}
// fast path for * (everything matched in a param)
if (this.regexp.fast_star) {
this.params = { \'0\': decode_param(path) }
this.path = path
return true
}
// match the path
match = this.regexp.exec(path)
}
if (!match) {
this.params = undefined;
this.path = undefined;
return false;
}
// store values
this.params = {};
this.path = match[0]
var keys = this.keys;
var params = this.params;
for (var i = 1; i < match.length; i++) {
var key = keys[i - 1];
var prop = key.name;
var val = decode_param(match[i])
if (val !== undefined || !(hasOwnProperty.call(params, prop))) {
params[prop] = val;
}
}
return true;
};
/**
* Decode param value.
*
* @param {string} val
* @return {string}
* @private
*/
function decode_param(val) {
if (typeof val !== \'string\' || val.length === 0) {
return val;
}
try {
return decodeURIComponent(val);
} catch (err) {
if (err instanceof URIError) {
err.message = \'Failed to decode param \\'\' + val + \'\\'\';
err.status = err.statusCode = 400;
}
throw err;
}
}
/***/
}),
/***/ 3192:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var debug = __nccwpck_require__(8609)(\'express:router:route\');
var flatten = __nccwpck_require__(6663);
var Layer = __nccwpck_require__(4663);
var methods = __nccwpck_require__(3454);
/**
* Module variables.
* @private
*/
var slice = Array.prototype.slice;
var toString = Object.prototype.toString;
/**
* Module exports.
* @public
*/
module.exports = Route;
/**
* Initialize `Route` with the given `path`,
*
* @param {String} path
* @public
*/
function Route(path) {
this.path = path;
this.stack = [];
debug(\'new %o\', path)
// route handlers for various http methods
this.methods = {};
}
/**
* Determine if the route handles a given method.
* @private
*/
Route.prototype._handles_method = function _handles_method(method) {
if (this.methods._all) {
return true;
}
var name = method.toLowerCase();
if (name === \'head\' && !this.methods[\'head\']) {
name = \'get\';
}
return Boolean(this.methods[name]);
};
/**
* @return {Array} supported HTTP methods
* @private
*/
Route.prototype._options = function _options() {
var methods = Object.keys(this.methods);
// append automatic head
if (this.methods.get && !this.methods.head) {
methods.push(\'head\');
}
for (var i = 0; i < methods.length; i++) {
// make upper case
methods[i] = methods[i].toUpperCase();
}
return methods;
};
/**
* dispatch req, res into this route
* @private
*/
Route.prototype.dispatch = function dispatch(req, res, done) {
var idx = 0;
var stack = this.stack;
if (stack.length === 0) {
return done();
}
var method = req.method.toLowerCase();
if (method === \'head\' && !this.methods[\'head\']) {
method = \'get\';
}
req.route = this;
next();
function next(err) {
// signal to exit route
if (err && err === \'route\') {
return done();
}
// signal to exit router
if (err && err === \'router\') {
return done(err)
}
var layer = stack[idx++];
if (!layer) {
return done(err);
}
if (layer.method && layer.method !== method) {
return next(err);
}
if (err) {
layer.handle_error(err, req, res, next);
} else {
layer.handle_request(req, res, next);
}
}
};
/**
* Add a handler for all HTTP verbs to this route.
*
* Behaves just like middleware and can respond or call `next`
* to continue processing.
*
* You can use multiple `.all` call to add multiple handlers.
*
* function check_something(req, res, next){
* next();
* };
*
* function validate_user(req, res, next){
* next();
* };
*
* route
* .all(validate_user)
* .all(check_something)
* .get(function(req, res, next){
* res.send(\'hello world\');
* });
*
* @param {function} handler
* @return {Route} for chaining
* @api public
*/
Route.prototype.all = function all() {
var handles = flatten(slice.call(arguments));
for (var i = 0; i < handles.length; i++) {
var handle = handles[i];
if (typeof handle !== \'function\') {
var type = toString.call(handle);
var msg = \'Route.all() requires a callback function but got a \' + type
throw new TypeError(msg);
}
var layer = Layer(\'/\', {}, handle);
layer.method = undefined;
this.methods._all = true;
this.stack.push(layer);
}
return this;
};
methods.forEach(function (method) {
Route.prototype[method] = function () {
var handles = flatten(slice.call(arguments));
for (var i = 0; i < handles.length; i++) {
var handle = handles[i];
if (typeof handle !== \'function\') {
var type = toString.call(handle);
var msg = \'Route.\' + method + \'() requires a callback function but got a \' + type
throw new Error(msg);
}
debug(\'%s %o\', method, this.path)
var layer = Layer(\'/\', {}, handle);
layer.method = method;
this.methods[method] = true;
this.stack.push(layer);
}
return this;
};
});
/***/
}),
/***/ 5665:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @api private
*/
var Buffer = __nccwpck_require__(7608).Buffer
var contentDisposition = __nccwpck_require__(2505);
var contentType = __nccwpck_require__(7237);
var deprecate = __nccwpck_require__(2225)(\'express\');
var flatten = __nccwpck_require__(6663);
var mime = __nccwpck_require__(7176).mime;
var etag = __nccwpck_require__(4091);
var proxyaddr = __nccwpck_require__(5293);
var qs = __nccwpck_require__(8556);
var querystring = __nccwpck_require__(1191);
/**
* Return strong ETag for `body`.
*
* @param {String|Buffer} body
* @param {String} [encoding]
* @return {String}
* @api private
*/
exports.etag = createETagGenerator({ weak: false })
/**
* Return weak ETag for `body`.
*
* @param {String|Buffer} body
* @param {String} [encoding]
* @return {String}
* @api private
*/
exports.wetag = createETagGenerator({ weak: true })
/**
* Check if `path` looks absolute.
*
* @param {String} path
* @return {Boolean}
* @api private
*/
exports.isAbsolute = function (path) {
if (\'/\' === path[0]) return true;
if (\':\' === path[1] && (\'\\\' === path[2] || \'/\' === path[2])) return true; // Windows device path
if (\'\\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path
};
/**
* Flatten the given `arr`.
*
* @param {Array} arr
* @return {Array}
* @api private
*/
exports.flatten = deprecate.function(flatten,
\'utils.flatten: use array-flatten npm module instead\');
/**
* Normalize the given `type`, for example "html" becomes "text/html".
*
* @param {String} type
* @return {Object}
* @api private
*/
exports.normalizeType = function (type) {
return ~type.indexOf(\'/\')
? acceptParams(type)
: { value: mime.lookup(type), params: {} };
};
/**
* Normalize `types`, for example "html" becomes "text/html".
*
* @param {Array} types
* @return {Array}
* @api private
*/
exports.normalizeTypes = function (types) {
var ret = [];
for (var i = 0; i < types.length; ++i) {
ret.push(exports.normalizeType(types[i]));
}
return ret;
};
/**
* Generate Content-Disposition header appropriate for the filename.
* non-ascii filenames are urlencoded and a filename* parameter is added
*
* @param {String} filename
* @return {String}
* @api private
*/
exports.contentDisposition = deprecate.function(contentDisposition,
\'utils.contentDisposition: use content-disposition npm module instead\');
/**
* Parse accept params `str` returning an
* object with `.value`, `.quality` and `.params`.
* also includes `.originalIndex` for stable sorting
*
* @param {String} str
* @return {Object}
* @api private
*/
function acceptParams(str, index) {
var parts = str.split(/ *; */);
var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index };
for (var i = 1; i < parts.length; ++i) {
var pms = parts[i].split(/ *= */);
if (\'q\' === pms[0]) {
ret.quality = parseFloat(pms[1]);
} else {
ret.params[pms[0]] = pms[1];
}
}
return ret;
}
/**
* Compile "etag" value to function.
*
* @param {Boolean|String|Function} val
* @return {Function}
* @api private
*/
exports.compileETag = function (val) {
var fn;
if (typeof val === \'function\') {
return val;
}
switch (val) {
case true:
fn = exports.wetag;
break;
case false:
break;
case \'strong\':
fn = exports.etag;
break;
case \'weak\':
fn = exports.wetag;
break;
default:
throw new TypeError(\'unknown value for etag function: \' + val);
}
return fn;
}
/**
* Compile "query parser" value to function.
*
* @param {String|Function} val
* @return {Function}
* @api private
*/
exports.compileQueryParser = function compileQueryParser(val) {
var fn;
if (typeof val === \'function\') {
return val;
}
switch (val) {
case true:
fn = querystring.parse;
break;
case false:
fn = newObject;
break;
case \'extended\':
fn = parseExtendedQueryString;
break;
case \'simple\':
fn = querystring.parse;
break;
default:
throw new TypeError(\'unknown value for query parser function: \' + val);
}
return fn;
}
/**
* Compile "proxy trust" value to function.
*
* @param {Boolean|String|Number|Array|Function} val
* @return {Function}
* @api private
*/
exports.compileTrust = function (val) {
if (typeof val === \'function\') return val;
if (val === true) {
// Support plain true/false
return function () { return true };
}
if (typeof val === \'number\') {
// Support trusting hop count
return function (a, i) { return i < val };
}
if (typeof val === \'string\') {
// Support comma-separated values
val = val.split(/ *, */);
}
return proxyaddr.compile(val || []);
}
/**
* Set the charset in a given Content-Type string.
*
* @param {String} type
* @param {String} charset
* @return {String}
* @api private
*/
exports.setCharset = function setCharset(type, charset) {
if (!type || !charset) {
return type;
}
// parse type
var parsed = contentType.parse(type);
// set charset
parsed.parameters.charset = charset;
// format type
return contentType.format(parsed);
};
/**
* Create an ETag generator function, generating ETags with
* the given options.
*
* @param {object} options
* @return {function}
* @private
*/
function createETagGenerator(options) {
return function generateETag(body, encoding) {
var buf = !Buffer.isBuffer(body)
? Buffer.from(body, encoding)
: body
return etag(buf, options)
}
}
/**
* Parse an extended query string with qs.
*
* @return {Object}
* @private
*/
function parseExtendedQueryString(str) {
return qs.parse(str, {
allowPrototypes: true
});
}
/**
* Return new empty object.
*
* @return {Object}
* @api private
*/
function newObject() {
return {};
}
/***/
}),
/***/ 1409:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var debug = __nccwpck_require__(8609)(\'express:view\');
var path = __nccwpck_require__(5622);
var fs = __nccwpck_require__(5747);
/**
* Module variables.
* @private
*/
var dirname = path.dirname;
var basename = path.basename;
var extname = path.extname;
var join = path.join;
var resolve = path.resolve;
/**
* Module exports.
* @public
*/
module.exports = View;
/**
* Initialize a new `View` with the given `name`.
*
* Options:
*
* - `defaultEngine` the default template engine name
* - `engines` template engine require() cache
* - `root` root path for view lookup
*
* @param {string} name
* @param {object} options
* @public
*/
function View(name, options) {
var opts = options || {};
this.defaultEngine = opts.defaultEngine;
this.ext = extname(name);
this.name = name;
this.root = opts.root;
if (!this.ext && !this.defaultEngine) {
throw new Error(\'No default engine was specified and no extension was provided.\');
}
var fileName = name;
if (!this.ext) {
// get extension from default engine name
this.ext = this.defaultEngine[0] !== \'.\'
? \'.\' + this.defaultEngine
: this.defaultEngine;
fileName += this.ext;
}
if (!opts.engines[this.ext]) {
// load engine
var mod = this.ext.substr(1)
debug(\'require "%s"\', mod)
// default engine export
var fn = require(mod).__express
if (typeof fn !== \'function\') {
throw new Error(\'Module "\' + mod + \'" does not provide a view engine.\')
}
opts.engines[this.ext] = fn
}
// store loaded engine
this.engine = opts.engines[this.ext];
// lookup path
this.path = this.lookup(fileName);
}
/**
* Lookup view by the given `name`
*
* @param {string} name
* @private
*/
View.prototype.lookup = function lookup(name) {
var path;
var roots = [].concat(this.root);
debug(\'lookup "%s"\', name);
for (var i = 0; i < roots.length && !path; i++) {
var root = roots[i];
// resolve the path
var loc = resolve(root, name);
var dir = dirname(loc);
var file = basename(loc);
// resolve the file
path = this.resolve(dir, file);
}
return path;
};
/**
* Render with the given options.
*
* @param {object} options
* @param {function} callback
* @private
*/
View.prototype.render = function render(options, callback) {
debug(\'render "%s"\', this.path);
this.engine(this.path, options, callback);
};
/**
* Resolve the file within the given directory.
*
* @param {string} dir
* @param {string} file
* @private
*/
View.prototype.resolve = function resolve(dir, file) {
var ext = this.ext;
// <path>.<ext>
var path = join(dir, file);
var stat = tryStat(path);
if (stat && stat.isFile()) {
return path;
}
// <path>/index.<ext>
path = join(dir, basename(file, ext), \'index\' + ext);
stat = tryStat(path);
if (stat && stat.isFile()) {
return path;
}
};
/**
* Return a stat, maybe.
*
* @param {string} path
* @return {fs.Stats}
* @private
*/
function tryStat(path) {
debug(\'stat "%s"\', path);
try {
return fs.statSync(path);
} catch (e) {
return undefined;
}
}
/***/
}),
/***/ 5278:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* finalhandler
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var debug = __nccwpck_require__(8609)(\'finalhandler\')
var encodeUrl = __nccwpck_require__(1979)
var escapeHtml = __nccwpck_require__(6591)
var onFinished = __nccwpck_require__(7117)
var parseUrl = __nccwpck_require__(222)
var statuses = __nccwpck_require__(5755)
var unpipe = __nccwpck_require__(279)
/**
* Module variables.
* @private
*/
var DOUBLE_SPACE_REGEXP = /\x20{2}/g
var NEWLINE_REGEXP = /\n/g
/* istanbul ignore next */
var defer = typeof setImmediate === \'function\'
? setImmediate
: function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) }
var isFinished = onFinished.isFinished
/**
* Create a minimal HTML document.
*
* @param {string} message
* @private
*/
function createHtmlDocument(message) {
var body = escapeHtml(message)
.replace(NEWLINE_REGEXP, \'<br>\')
.replace(DOUBLE_SPACE_REGEXP, \' \')
return \'<!DOCTYPE html>\n\' +
\'<html lang="en">\n\' +
\'<head>\n\' +
\'<meta charset="utf-8">\n\' +
\'<title>Error</title>\n\' +
\'</head>\n\' +
\'<body>\n\' +
\'<pre>\' + body + \'</pre>\n\' +
\'</body>\n\' +
\'</html>\n\'
}
/**
* Module exports.
* @public
*/
module.exports = finalhandler
/**
* Create a function to handle the final response.
*
* @param {Request} req
* @param {Response} res
* @param {Object} [options]
* @return {Function}
* @public
*/
function finalhandler(req, res, options) {
var opts = options || {}
// get environment
var env = opts.env || process.env.NODE_ENV || \'development\'
// get error callback
var onerror = opts.onerror
return function (err) {
var headers
var msg
var status
// ignore 404 on in-flight response
if (!err && headersSent(res)) {
debug(\'cannot 404 after headers sent\')
return
}
// unhandled error
if (err) {
// respect status code from error
status = getErrorStatusCode(err)
if (status === undefined) {
// fallback to status code on response
status = getResponseStatusCode(res)
} else {
// respect headers from error
headers = getErrorHeaders(err)
}
// get error message
msg = getErrorMessage(err, status, env)
} else {
// not found
status = 404
msg = \'Cannot \' + req.method + \' \' + encodeUrl(getResourceName(req))
}
debug(\'default %s\', status)
// schedule onerror callback
if (err && onerror) {
defer(onerror, err, req, res)
}
// cannot actually respond
if (headersSent(res)) {
debug(\'cannot %d after headers sent\', status)
req.socket.destroy()
return
}
// send response
send(req, res, status, headers, msg)
}
}
/**
* Get headers from Error object.
*
* @param {Error} err
* @return {object}
* @private
*/
function getErrorHeaders(err) {
if (!err.headers || typeof err.headers !== \'object\') {
return undefined
}
var headers = Object.create(null)
var keys = Object.keys(err.headers)
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
headers[key] = err.headers[key]
}
return headers
}
/**
* Get message from Error object, fallback to status message.
*
* @param {Error} err
* @param {number} status
* @param {string} env
* @return {string}
* @private
*/
function getErrorMessage(err, status, env) {
var msg
if (env !== \'production\') {
// use err.stack, which typically includes err.message
msg = err.stack
// fallback to err.toString() when possible
if (!msg && typeof err.toString === \'function\') {
msg = err.toString()
}
}
return msg || statuses[status]
}
/**
* Get status code from Error object.
*
* @param {Error} err
* @return {number}
* @private
*/
function getErrorStatusCode(err) {
// check err.status
if (typeof err.status === \'number\' && err.status >= 400 && err.status < 600) {
return err.status
}
// check err.statusCode
if (typeof err.statusCode === \'number\' && err.statusCode >= 400 && err.statusCode < 600) {
return err.statusCode
}
return undefined
}
/**
* Get resource name for the request.
*
* This is typically just the original pathname of the request
* but will fallback to "resource" is that cannot be determined.
*
* @param {IncomingMessage} req
* @return {string}
* @private
*/
function getResourceName(req) {
try {
return parseUrl.original(req).pathname
} catch (e) {
return \'resource\'
}
}
/**
* Get status code from response.
*
* @param {OutgoingMessage} res
* @return {number}
* @private
*/
function getResponseStatusCode(res) {
var status = res.statusCode
// default status code to 500 if outside valid range
if (typeof status !== \'number\' || status < 400 || status > 599) {
status = 500
}
return status
}
/**
* Determine if the response headers have been sent.
*
* @param {object} res
* @returns {boolean}
* @private
*/
function headersSent(res) {
return typeof res.headersSent !== \'boolean\'
? Boolean(res._header)
: res.headersSent
}
/**
* Send response.
*
* @param {IncomingMessage} req
* @param {OutgoingMessage} res
* @param {number} status
* @param {object} headers
* @param {string} message
* @private
*/
function send(req, res, status, headers, message) {
function write() {
// response body
var body = createHtmlDocument(message)
// response status
res.statusCode = status
res.statusMessage = statuses[status]
// response headers
setHeaders(res, headers)
// security headers
res.setHeader(\'Content-Security-Policy\', "default-src \'none\'")
res.setHeader(\'X-Content-Type-Options\', \'nosniff\')
// standard headers
res.setHeader(\'Content-Type\', \'text/html; charset=utf-8\')
res.setHeader(\'Content-Length\', Buffer.byteLength(body, \'utf8\'))
if (req.method === \'HEAD\') {
res.end()
return
}
res.end(body, \'utf8\')
}
if (isFinished(req)) {
write()
return
}
// unpipe everything from the request
unpipe(req)
// flush the request
onFinished(req, write)
req.resume()
}
/**
* Set response headers from an object.
*
* @param {OutgoingMessage} res
* @param {object} headers
* @private
*/
function setHeaders(res, headers) {
if (!headers) {
return
}
var keys = Object.keys(headers)
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
res.setHeader(key, headers[key])
}
}
/***/
}),
/***/ 2207:
/***/ ((module) => {
"use strict";
/*!
* forwarded
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
module.exports = forwarded
/**
* Get all addresses in the request, using the `X-Forwarded-For` header.
*
* @param {object} req
* @return {array}
* @public
*/
function forwarded(req) {
if (!req) {
throw new TypeError(\'argument req is required\')
}
// simple header parsing
var proxyAddrs = parse(req.headers[\'x-forwarded-for\'] || \'\')
var socketAddr = req.connection.remoteAddress
var addrs = [socketAddr].concat(proxyAddrs)
// return all addresses
return addrs
}
/**
* Parse the X-Forwarded-For header.
*
* @param {string} header
* @private
*/
function parse(header) {
var end = header.length
var list = []
var start = header.length
// gather addresses, backwards
for (var i = header.length - 1; i >= 0; i--) {
switch (header.charCodeAt(i)) {
case 0x20: /* */
if (start === end) {
start = end = i
}
break
case 0x2c: /* , */
if (start !== end) {
list.push(header.substring(start, end))
}
start = end = i
break
default:
start = i
break
}
}
// final address
if (start !== end) {
list.push(header.substring(start, end))
}
return list
}
/***/
}),
/***/ 8176:
/***/ ((module) => {
"use strict";
/*!
* fresh
* Copyright(c) 2012 TJ Holowaychuk
* Copyright(c) 2016-2017 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* RegExp to check for no-cache token in Cache-Control.
* @private
*/
var CACHE_CONTROL_NO_CACHE_REGEXP = /(?:^|,)\s*?no-cache\s*?(?:,|$)/
/**
* Module exports.
* @public
*/
module.exports = fresh
/**
* Check freshness of the response using request and response headers.
*
* @param {Object} reqHeaders
* @param {Object} resHeaders
* @return {Boolean}
* @public
*/
function fresh(reqHeaders, resHeaders) {
// fields
var modifiedSince = reqHeaders[\'if-modified-since\']
var noneMatch = reqHeaders[\'if-none-match\']
// unconditional request
if (!modifiedSince && !noneMatch) {
return false
}
// Always return stale when Cache-Control: no-cache
// to support end-to-end reload requests
// https://tools.ietf.org/html/rfc2616#section-14.9.4
var cacheControl = reqHeaders[\'cache-control\']
if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) {
return false
}
// if-none-match
if (noneMatch && noneMatch !== \'*\') {
var etag = resHeaders[\'etag\']
if (!etag) {
return false
}
var etagStale = true
var matches = parseTokenList(noneMatch)
for (var i = 0; i < matches.length; i++) {
var match = matches[i]
if (match === etag || match === \'W/\' + etag || \'W/\' + match === etag) {
etagStale = false
break
}
}
if (etagStale) {
return false
}
}
// if-modified-since
if (modifiedSince) {
var lastModified = resHeaders[\'last-modified\']
var modifiedStale = !lastModified || !(parseHttpDate(lastModified) <= parseHttpDate(modifiedSince))
if (modifiedStale) {
return false
}
}
return true
}
/**
* Parse an HTTP Date into a number.
*
* @param {string} date
* @private
*/
function parseHttpDate(date) {
var timestamp = date && Date.parse(date)
// istanbul ignore next: guard against date.js Date.parse patching
return typeof timestamp === \'number\'
? timestamp
: NaN
}
/**
* Parse a HTTP token list.
*
* @param {string} str
* @private
*/
function parseTokenList(str) {
var end = 0
var list = []
var start = 0
// gather tokens
for (var i = 0, len = str.length; i < len; i++) {
switch (str.charCodeAt(i)) {
case 0x20: /* */
if (start === end) {
start = end = i + 1
}
break
case 0x2c: /* , */
list.push(str.substring(start, end))
start = end = i + 1
break
default:
end = i + 1
break
}
}
// final token
list.push(str.substring(start, end))
return list
}
/***/
}),
/***/ 3308:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
/*!
* http-errors
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @private
*/
var deprecate = __nccwpck_require__(2225)(\'http-errors\')
var setPrototypeOf = __nccwpck_require__(2927)
var statuses = __nccwpck_require__(5755)
var inherits = __nccwpck_require__(8926)
var toIdentifier = __nccwpck_require__(9501)
/**
* Module exports.
* @public
*/
module.exports = createError
module.exports.HttpError = createHttpErrorConstructor()
// Populate exports for all constructors
populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError)
/**
* Get the code class of a status code.
* @private
*/
function codeClass(status) {
return Number(String(status).charAt(0) + \'00\')
}
/**
* Create a new HTTP Error.
*
* @returns {Error}
* @public
*/
function createError() {
// so much arity going on ~_~
var err
var msg
var status = 500
var props = {}
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i]
if (arg instanceof Error) {
err = arg
status = err.status || err.statusCode || status
continue
}
switch (typeof arg) {
case \'string\':
msg = arg
break
case \'number\':
status = arg
if (i !== 0) {
deprecate(\'non-first-argument status code; replace with createError(\' + arg + \', ...)\')
}
break
case \'object\':
props = arg
break
}
}
if (typeof status === \'number\' && (status < 400 || status >= 600)) {
deprecate(\'non-error status code; use only 4xx or 5xx status codes\')
}
if (typeof status !== \'number\' ||
(!statuses[status] && (status < 400 || status >= 600))) {
status = 500
}
// constructor
var HttpError = createError[status] || createError[codeClass(status)]
if (!err) {
// create error
err = HttpError
? new HttpError(msg)
: new Error(msg || statuses[status])
Error.captureStackTrace(err, createError)
}
if (!HttpError || !(err instanceof HttpError) || err.status !== status) {
// add properties to generic error
err.expose = status < 500
err.status = err.statusCode = status
}
for (var key in props) {
if (key !== \'status\' && key !== \'statusCode\') {
err[key] = props[key]
}
}
return err
}
/**
* Create HTTP error abstract base class.
* @private
*/
function createHttpErrorConstructor() {
function HttpError() {
throw new TypeError(\'cannot construct abstract class\')
}
inherits(HttpError, Error)
return HttpError
}
/**
* Create a constructor for a client error.
* @private
*/
function createClientErrorConstructor(HttpError, name, code) {
var className = name.match(/Error$/) ? name : name + \'Error\'
function ClientError(message) {
// create the error object
var msg = message != null ? message : statuses[code]
var err = new Error(msg)
// capture a stack trace to the construction point
Error.captureStackTrace(err, ClientError)
// adjust the [[Prototype]]
setPrototypeOf(err, ClientError.prototype)
// redefine the error message
Object.defineProperty(err, \'message\', {
enumerable: true,
configurable: true,
value: msg,
writable: true
})
// redefine the error name
Object.defineProperty(err, \'name\', {
enumerable: false,
configurable: true,
value: className,
writable: true
})
return err
}
inherits(ClientError, HttpError)
nameFunc(ClientError, className)
ClientError.prototype.status = code
ClientError.prototype.statusCode = code
ClientError.prototype.expose = true
return ClientError
}
/**
* Create a constructor for a server error.
* @private
*/
function createServerErrorConstructor(HttpError, name, code) {
var className = name.match(/Error$/) ? name : name + \'Error\'
function ServerError(message) {
// create the error object
var msg = message != null ? message : statuses[code]
var err = new Error(msg)
// capture a stack trace to the construction point
Error.captureStackTrace(err, ServerError)
// adjust the [[Prototype]]
setPrototypeOf(err, ServerError.prototype)
// redefine the error message
Object.defineProperty(err, \'message\', {
enumerable: true,
configurable: true,
value: msg,
writable: true
})
// redefine the error name
Object.defineProperty(err, \'name\', {
enumerable: false,
configurable: true,
value: className,
writable: true
})
return err
}
inherits(ServerError, HttpError)
nameFunc(ServerError, className)
ServerError.prototype.status = code
ServerError.prototype.statusCode = code
ServerError.prototype.expose = false
return ServerError
}
/**
* Set the name of a function, if possible.
* @private
*/
function nameFunc(func, name) {
var desc = Object.getOwnPropertyDescriptor(func, \'name\')
if (desc && desc.configurable) {
desc.value = name
Object.defineProperty(func, \'name\', desc)
}
}
/**
* Populate the exports object with constructors for every error class.
* @private
*/
function populateConstructorExports(exports, codes, HttpError) {
codes.forEach(function forEachCode(code) {
var CodeError
var name = toIdentifier(statuses[code])
switch (codeClass(code)) {
case 400:
CodeError = createClientErrorConstructor(HttpError, name, code)
break
case 500:
CodeError = createServerErrorConstructor(HttpError, name, code)
break
}
if (CodeError) {
// export the constructor
exports[code] = CodeError
exports[name] = CodeError
}
})
// backwards-compatibility
exports["I\'mateapot"] = deprecate.function(exports.ImATeapot,
\'"I\\'mateapot"; use "ImATeapot" instead\')
}
/***/
}),
/***/ 8735:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
var Buffer = __nccwpck_require__(6160).Buffer;
// Multibyte codec. In this scheme, a character is represented by 1 or more bytes.
// Our codec supports UTF-16 surrogates, extensions for GB18030 and unicode sequences.
// To save memory and loading time, we read table files only when requested.
exports._dbcs = DBCSCodec;
var UNASSIGNED = -1,
GB18030_CODE = -2,
SEQ_START = -10,
NODE_START = -1000,
UNASSIGNED_NODE = new Array(0x100),
DEF_CHAR = -1;
for (var i = 0; i < 0x100; i++)
UNASSIGNED_NODE[i] = UNASSIGNED;
// Class DBCSCodec reads and initializes mapping tables.
function DBCSCodec(codecOptions, iconv) {
this.encodingName = codecOptions.encodingName;
if (!codecOptions)
throw new Error("DBCS codec is called without the data.")
if (!codecOptions.table)
throw new Error("Encoding \'" + this.encodingName + "\' has no data.");
// Load tables.
var mappingTable = codecOptions.table();
// Decode tables: MBCS -> Unicode.
// decodeTables is a trie, encoded as an array of arrays of integers. Internal arrays are trie nodes and all have len = 256.
// Trie root is decodeTables[0].
// Values: >= 0 -> unicode character code. can be > 0xFFFF
// == UNASSIGNED -> unknown/unassigned sequence.
// == GB18030_CODE -> this is the end of a GB18030 4-byte sequence.
// <= NODE_START -> index of the next node in our trie to process next byte.
// <= SEQ_START -> index of the start of a character code sequence, in decodeTableSeq.
this.decodeTables = [];
this.decodeTables[0] = UNASSIGNED_NODE.slice(0); // Create root node.
// Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here.
this.decodeTableSeq = [];
// Actual mapping tables consist of chunks. Use them to fill up decode tables.
for (var i = 0; i < mappingTable.length; i++)
this._addDecodeChunk(mappingTable[i]);
this.defaultCharUnicode = iconv.defaultCharUnicode;
// Encode tables: Unicode -> DBCS.
// `encodeTable` is array mapping from unicode char to encoded char. All its values are integers for performance.
// Because it can be sparse, it is represented as array of buckets by 256 chars each. Bucket can be null.
// Values: >= 0 -> it is a normal char. Write the value (if <=256 then 1 byte, if <=65536 then 2 bytes, etc.).
// == UNASSIGNED -> no conversion found. Output a default char.
// <= SEQ_START -> it\'s an index in encodeTableSeq, see below. The character starts a sequence.
this.encodeTable = [];
// `encodeTableSeq` is used when a sequence of unicode characters is encoded as a single code. We use a tree of
// objects where keys correspond to characters in sequence and leafs are the encoded dbcs values. A special DEF_CHAR key
// means end of sequence (needed when one sequence is a strict subsequence of another).
// Objects are kept separately from encodeTable to increase performance.
this.encodeTableSeq = [];
// Some chars can be decoded, but need not be encoded.
var skipEncodeChars = {};
if (codecOptions.encodeSkipVals)
for (var i = 0; i < codecOptions.encodeSkipVals.length; i++) {
var val = codecOptions.encodeSkipVals[i];
if (typeof val === \'number\')
skipEncodeChars[val] = true;
else
for (var j = val.from; j <= val.to; j++)
skipEncodeChars[j] = true;
}
// Use decode trie to recursively fill out encode tables.
this._fillEncodeTable(0, 0, skipEncodeChars);
// Add more encoding pairs when needed.
if (codecOptions.encodeAdd) {
for (var uChar in codecOptions.encodeAdd)
if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar))
this._setEncodeChar(uChar.charCodeAt(0), codecOptions.encodeAdd[uChar]);
}
this.defCharSB = this.encodeTable[0][iconv.defaultCharSingleByte.charCodeAt(0)];
if (this.defCharSB === UNASSIGNED) this.defCharSB = this.encodeTable[0][\'?\'];
if (this.defCharSB === UNASSIGNED) this.defCharSB = "?".charCodeAt(0);
// Load & create GB18030 tables when needed.
if (typeof codecOptions.gb18030 === \'function\') {
this.gb18030 = codecOptions.gb18030(); // Load GB18030 ranges.
// Add GB18030 decode tables.
var thirdByteNodeIdx = this.decodeTables.length;
var thirdByteNode = this.decodeTables[thirdByteNodeIdx] = UNASSIGNED_NODE.slice(0);
var fourthByteNodeIdx = this.decodeTables.length;
var fourthByteNode = this.decodeTables[fourthByteNodeIdx] = UNASSIGNED_NODE.slice(0);
for (var i = 0x81; i <= 0xFE; i++) {
var secondByteNodeIdx = NODE_START - this.decodeTables[0][i];
var secondByteNode = this.decodeTables[secondByteNodeIdx];
for (var j = 0x30; j <= 0x39; j++)
secondByteNode[j] = NODE_START - thirdByteNodeIdx;
}
for (var i = 0x81; i <= 0xFE; i++)
thirdByteNode[i] = NODE_START - fourthByteNodeIdx;
for (var i = 0x30; i <= 0x39; i++)
fourthByteNode[i] = GB18030_CODE
}
}
DBCSCodec.prototype.encoder = DBCSEncoder;
DBCSCodec.prototype.decoder = DBCSDecoder;
// Decoder helpers
DBCSCodec.prototype._getDecodeTrieNode = function (addr) {
var bytes = [];
for (; addr > 0; addr >>= 8)
bytes.push(addr & 0xFF);
if (bytes.length == 0)
bytes.push(0);
var node = this.decodeTables[0];
for (var i = bytes.length - 1; i > 0; i--) { // Traverse nodes deeper into the trie.
var val = node[bytes[i]];
if (val == UNASSIGNED) { // Create new node.
node[bytes[i]] = NODE_START - this.decodeTables.length;
this.decodeTables.push(node = UNASSIGNED_NODE.slice(0));
}
else if (val <= NODE_START) { // Existing node.
node = this.decodeTables[NODE_START - val];
}
else
throw new Error("Overwrite byte in " + this.encodingName + ", addr: " + addr.toString(16));
}
return node;
}
DBCSCodec.prototype._addDecodeChunk = function (chunk) {
// First element of chunk is the hex mbcs code where we start.
var curAddr = parseInt(chunk[0], 16);
// Choose the decoding node where we\'ll write our chars.
var writeTable = this._getDecodeTrieNode(curAddr);
curAddr = curAddr & 0xFF;
// Write all other elements of the chunk to the table.
for (var k = 1; k < chunk.length; k++) {
var part = chunk[k];
if (typeof part === "string") { // String, write as-is.
for (var l = 0; l < part.length;) {
var code = part.charCodeAt(l++);
if (0xD800 <= code && code < 0xDC00) { // Decode surrogate
var codeTrail = part.charCodeAt(l++);
if (0xDC00 <= codeTrail && codeTrail < 0xE000)
writeTable[curAddr++] = 0x10000 + (code - 0xD800) * 0x400 + (codeTrail - 0xDC00);
else
throw new Error("Incorrect surrogate pair in " + this.encodingName + " at chunk " + chunk[0]);
}
else if (0x0FF0 < code && code <= 0x0FFF) { // Character sequence (our own encoding used)
var len = 0xFFF - code + 2;
var seq = [];
for (var m = 0; m < len; m++)
seq.push(part.charCodeAt(l++)); // Simple variation: don\'t support surrogates or subsequences in seq.
writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;
this.decodeTableSeq.push(seq);
}
else
writeTable[curAddr++] = code; // Basic char
}
}
else if (typeof part === "number") { // Integer, meaning increasing sequence starting with prev character.
var charCode = writeTable[curAddr - 1] + 1;
for (var l = 0; l < part; l++)
writeTable[curAddr++] = charCode++;
}
else
throw new Error("Incorrect type \'" + typeof part + "\' given in " + this.encodingName + " at chunk " + chunk[0]);
}
if (curAddr > 0xFF)
throw new Error("Incorrect chunk in " + this.encodingName + " at addr " + chunk[0] + ": too long" + curAddr);
}
// Encoder helpers
DBCSCodec.prototype._getEncodeBucket = function (uCode) {
var high = uCode >> 8; // This could be > 0xFF because of astral characters.
if (this.encodeTable[high] === undefined)
this.encodeTable[high] = UNASSIGNED_NODE.slice(0); // Create bucket on demand.
return this.encodeTable[high];
}
DBCSCodec.prototype._setEncodeChar = function (uCode, dbcsCode) {
var bucket = this._getEncodeBucket(uCode);
var low = uCode & 0xFF;
if (bucket[low] <= SEQ_START)
this.encodeTableSeq[SEQ_START - bucket[low]][DEF_CHAR] = dbcsCode; // There\'s already a sequence, set a single-char subsequence of it.
else if (bucket[low] == UNASSIGNED)
bucket[low] = dbcsCode;
}
DBCSCodec.prototype._setEncodeSequence = function (seq, dbcsCode) {
// Get the root of character tree according to first character of the sequence.
var uCode = seq[0];
var bucket = this._getEncodeBucket(uCode);
var low = uCode & 0xFF;
var node;
if (bucket[low] <= SEQ_START) {
// There\'s already a sequence with - use it.
node = this.encodeTableSeq[SEQ_START - bucket[low]];
}
else {
// There was no sequence object - allocate a new one.
node = {};
if (bucket[low] !== UNASSIGNED) node[DEF_CHAR] = bucket[low]; // If a char was set before - make it a single-char subsequence.
bucket[low] = SEQ_START - this.encodeTableSeq.length;
this.encodeTableSeq.push(node);
}
// Traverse the character tree, allocating new nodes as needed.
for (var j = 1; j < seq.length - 1; j++) {
var oldVal = node[uCode];
if (typeof oldVal === \'object\')
node = oldVal;
else {
node = node[uCode] = {}
if (oldVal !== undefined)
node[DEF_CHAR] = oldVal
}
}
// Set the leaf to given dbcsCode.
uCode = seq[seq.length - 1];
node[uCode] = dbcsCode;
}
DBCSCodec.prototype._fillEncodeTable = function (nodeIdx, prefix, skipEncodeChars) {
var node = this.decodeTables[nodeIdx];
for (var i = 0; i < 0x100; i++) {
var uCode = node[i];
var mbCode = prefix + i;
if (skipEncodeChars[mbCode])
continue;
if (uCode >= 0)
this._setEncodeChar(uCode, mbCode);
else if (uCode <= NODE_START)
this._fillEncodeTable(NODE_START - uCode, mbCode << 8, skipEncodeChars);
else if (uCode <= SEQ_START)
this._setEncodeSequence(this.decodeTableSeq[SEQ_START - uCode], mbCode);
}
}
// == Encoder ==================================================================
function DBCSEncoder(options, codec) {
// Encoder state
this.leadSurrogate = -1;
this.seqObj = undefined;
// Static data
this.encodeTable = codec.encodeTable;
this.encodeTableSeq = codec.encodeTableSeq;
this.defaultCharSingleByte = codec.defCharSB;
this.gb18030 = codec.gb18030;
}
DBCSEncoder.prototype.write = function (str) {
var newBuf = Buffer.alloc(str.length * (this.gb18030 ? 4 : 3)),
leadSurrogate = this.leadSurrogate,
seqObj = this.seqObj, nextChar = -1,
i = 0, j = 0;
while (true) {
// 0. Get next character.
if (nextChar === -1) {
if (i == str.length) break;
var uCode = str.charCodeAt(i++);
}
else {
var uCode = nextChar;
nextChar = -1;
}
// 1. Handle surrogates.
if (0xD800 <= uCode && uCode < 0xE000) { // Char is one of surrogates.
if (uCode < 0xDC00) { // We\'ve got lead surrogate.
if (leadSurrogate === -1) {
leadSurrogate = uCode;
continue;
} else {
leadSurrogate = uCode;
// Double lead surrogate found.
uCode = UNASSIGNED;
}
} else { // We\'ve got trail surrogate.
if (leadSurrogate !== -1) {
uCode = 0x10000 + (leadSurrogate - 0xD800) * 0x400 + (uCode - 0xDC00);
leadSurrogate = -1;
} else {
// Incomplete surrogate pair - only trail surrogate found.
uCode = UNASSIGNED;
}
}
}
else if (leadSurrogate !== -1) {
// Incomplete surrogate pair - only lead surrogate found.
nextChar = uCode; uCode = UNASSIGNED; // Write an error, then current char.
leadSurrogate = -1;
}
// 2. Convert uCode character.
var dbcsCode = UNASSIGNED;
if (seqObj !== undefined && uCode != UNASSIGNED) { // We are in the middle of the sequence
var resCode = seqObj[uCode];
if (typeof resCode === \'object\') { // Sequence continues.
seqObj = resCode;
continue;
} else if (typeof resCode == \'number\') { // Sequence finished. Write it.
dbcsCode = resCode;
} else if (resCode == undefined) { // Current character is not part of the sequence.
// Try default character for this sequence
resCode = seqObj[DEF_CHAR];
if (resCode !== undefined) {
dbcsCode = resCode; // Found. Write it.
nextChar = uCode; // Current character will be written too in the next iteration.
} else {
// TODO: What if we have no default? (resCode == undefined)
// Then, we should write first char of the sequence as-is and try the rest recursively.
// Didn\'t do it for now because no encoding has this situation yet.
// Currently, just skip the sequence and write current char.
}
}
seqObj = undefined;
}
else if (uCode >= 0) { // Regular character
var subtable = this.encodeTable[uCode >> 8];
if (subtable !== undefined)
dbcsCode = subtable[uCode & 0xFF];
if (dbcsCode <= SEQ_START) { // Sequence start
seqObj = this.encodeTableSeq[SEQ_START - dbcsCode];
continue;
}
if (dbcsCode == UNASSIGNED && this.gb18030) {
// Use GB18030 algorithm to find character(s) to write.
var idx = findIdx(this.gb18030.uChars, uCode);
if (idx != -1) {
var dbcsCode = this.gb18030.gbChars[idx] + (uCode - this.gb18030.uChars[idx]);
newBuf[j++] = 0x81 + Math.floor(dbcsCode / 12600); dbcsCode = dbcsCode % 12600;
newBuf[j++] = 0x30 + Math.floor(dbcsCode / 1260); dbcsCode = dbcsCode % 1260;
newBuf[j++] = 0x81 + Math.floor(dbcsCode / 10); dbcsCode = dbcsCode % 10;
newBuf[j++] = 0x30 + dbcsCode;
continue;
}
}
}
// 3. Write dbcsCode character.
if (dbcsCode === UNASSIGNED)
dbcsCode = this.defaultCharSingleByte;
if (dbcsCode < 0x100) {
newBuf[j++] = dbcsCode;
}
else if (dbcsCode < 0x10000) {
newBuf[j++] = dbcsCode >> 8; // high byte
newBuf[j++] = dbcsCode & 0xFF; // low byte
}
else {
newBuf[j++] = dbcsCode >> 16;
newBuf[j++] = (dbcsCode >> 8) & 0xFF;
newBuf[j++] = dbcsCode & 0xFF;
}
}
this.seqObj = seqObj;
this.leadSurrogate = leadSurrogate;
return newBuf.slice(0, j);
}
DBCSEncoder.prototype.end = function () {
if (this.leadSurrogate === -1 && this.seqObj === undefined)
return; // All clean. Most often case.
var newBuf = Buffer.alloc(10), j = 0;
if (this.seqObj) { // We\'re in the sequence.
var dbcsCode = this.seqObj[DEF_CHAR];
if (dbcsCode !== undefined) { // Write beginning of the sequence.
if (dbcsCode < 0x100) {
newBuf[j++] = dbcsCode;
}
else {
newBuf[j++] = dbcsCode >> 8; // high byte
newBuf[j++] = dbcsCode & 0xFF; // low byte
}
} else {
// See todo above.
}
this.seqObj = undefined;
}
if (this.leadSurrogate !== -1) {
// Incomplete surrogate pair - only lead surrogate found.
newBuf[j++] = this.defaultCharSingleByte;
this.leadSurrogate = -1;
}
return newBuf.slice(0, j);
}
// Export for testing
DBCSEncoder.prototype.findIdx = findIdx;
// == Decoder ==================================================================
function DBCSDecoder(options, codec) {
// Decoder state
this.nodeIdx = 0;
this.prevBuf = Buffer.alloc(0);
// Static data
this.decodeTables = codec.decodeTables;
this.decodeTableSeq = codec.decodeTableSeq;
this.defaultCharUnicode = codec.defaultCharUnicode;
this.gb18030 = codec.gb18030;
}
DBCSDecoder.prototype.write = function (buf) {
var newBuf = Buffer.alloc(buf.length * 2),
nodeIdx = this.nodeIdx,
prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length,
seqStart = -this.prevBuf.length, // idx of the start of current parsed sequence.
uCode;
if (prevBufOffset > 0) // Make prev buf overlap a little to make it easier to slice later.
prevBuf = Buffer.concat([prevBuf, buf.slice(0, 10)]);
for (var i = 0, j = 0; i < buf.length; i++) {
var curByte = (i >= 0) ? buf[i] : prevBuf[i + prevBufOffset];
// Lookup in current trie node.
var uCode = this.decodeTables[nodeIdx][curByte];
if (uCode >= 0) {
// Normal character, just use it.
}
else if (uCode === UNASSIGNED) { // Unknown char.
// TODO: Callback with seq.
//var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i+1) : prevBuf.slice(seqStart + prevBufOffset, i+1 + prevBufOffset);
i = seqStart; // Try to parse again, after skipping first byte of the sequence (\'i\' will be incremented by \'for\' cycle).
uCode = this.defaultCharUnicode.charCodeAt(0);
}
else if (uCode === GB18030_CODE) {
var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i + 1) : prevBuf.slice(seqStart + prevBufOffset, i + 1 + prevBufOffset);
var ptr = (curSeq[0] - 0x81) * 12600 + (curSeq[1] - 0x30) * 1260 + (curSeq[2] - 0x81) * 10 + (curSeq[3] - 0x30);
var idx = findIdx(this.gb18030.gbChars, ptr);
uCode = this.gb18030.uChars[idx] + ptr - this.gb18030.gbChars[idx];
}
else if (uCode <= NODE_START) { // Go to next trie node.
nodeIdx = NODE_START - uCode;
continue;
}
else if (uCode <= SEQ_START) { // Output a sequence of chars.
var seq = this.decodeTableSeq[SEQ_START - uCode];
for (var k = 0; k < seq.length - 1; k++) {
uCode = seq[k];
newBuf[j++] = uCode & 0xFF;
newBuf[j++] = uCode >> 8;
}
uCode = seq[seq.length - 1];
}
else
throw new Error("iconv-lite internal error: invalid decoding table value " + uCode + " at " + nodeIdx + "/" + curByte);
// Write the character to buffer, handling higher planes using surrogate pair.
if (uCode > 0xFFFF) {
uCode -= 0x10000;
var uCodeLead = 0xD800 + Math.floor(uCode / 0x400);
newBuf[j++] = uCodeLead & 0xFF;
newBuf[j++] = uCodeLead >> 8;
uCode = 0xDC00 + uCode % 0x400;
}
newBuf[j++] = uCode & 0xFF;
newBuf[j++] = uCode >> 8;
// Reset trie node.
nodeIdx = 0; seqStart = i + 1;
}
this.nodeIdx = nodeIdx;
this.prevBuf = (seqStart >= 0) ? buf.slice(seqStart) : prevBuf.slice(seqStart + prevBufOffset);
return newBuf.slice(0, j).toString(\'ucs2\');
}
DBCSDecoder.prototype.end = function () {
var ret = \'\';
// Try to parse all remaining chars.
while (this.prevBuf.length > 0) {
// Skip 1 character in the buffer.
ret += this.defaultCharUnicode;
var buf = this.prevBuf.slice(1);
// Parse remaining as usual.
this.prevBuf = Buffer.alloc(0);
this.nodeIdx = 0;
if (buf.length > 0)
ret += this.write(buf);
}
this.nodeIdx = 0;
return ret;
}
// Binary search for GB18030. Returns largest i such that table[i] <= val.
function findIdx(table, val) {
if (table[0] > val)
return -1;
var l = 0, r = table.length;
while (l < r - 1) { // always table[l] <= val < table[r]
var mid = l + Math.floor((r - l + 1) / 2);
if (table[mid] <= val)
l = mid;
else
r = mid;
}
return l;
}
/***/
}),
/***/ 3091:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
// Description of supported double byte encodings and aliases.
// Tables are not require()-d until they are needed to speed up library load.
// require()-s are direct to support Browserify.
module.exports = {
// == Japanese/ShiftJIS ====================================================
// All japanese encodings are based on JIS X set of standards:
// JIS X 0201 - Single-byte encoding of ASCII + ¥ + Kana chars at 0xA1-0xDF.
// JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes.
// Has several variations in 1978, 1983, 1990 and 1997.
// JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead.
// JIS X 0213 - Extension and modern replacement of 0208 and 0212. Total chars: 11233.
// 2 planes, first is superset of 0208, second - revised 0212.
// Introduced in 2000, revised 2004. Some characters are in Unicode Plane 2 (0x2xxxx)
// Byte encodings are:
// * Shift_JIS: Compatible with 0201, uses not defined chars in top half as lead bytes for double-byte
// encoding of 0208. Lead byte ranges: 0x81-0x9F, 0xE0-0xEF; Trail byte ranges: 0x40-0x7E, 0x80-0x9E, 0x9F-0xFC.
// Windows CP932 is a superset of Shift_JIS. Some companies added more chars, notably KDDI.
// * EUC-JP: Up to 3 bytes per character. Used mostly on *nixes.
// 0x00-0x7F - lower part of 0201
// 0x8E, 0xA1-0xDF - upper part of 0201
// (0xA1-0xFE)x2 - 0208 plane (94x94).
// 0x8F, (0xA1-0xFE)x2 - 0212 plane (94x94).
// * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon.
// Used as-is in ISO2022 family.
// * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII,
// 0201-1976 Roman, 0208-1978, 0208-1983.
// * ISO2022-JP-1: Adds esc seq for 0212-1990.
// * ISO2022-JP-2: Adds esc seq for GB2313-1980, KSX1001-1992, ISO8859-1, ISO8859-7.
// * ISO2022-JP-3: Adds esc seq for 0201-1976 Kana set, 0213-2000 Planes 1, 2.
// * ISO2022-JP-2004: Adds 0213-2004 Plane 1.
//
// After JIS X 0213 appeared, Shift_JIS-2004, EUC-JISX0213 and ISO2022-JP-2004 followed, with just changing the planes.
//
// Overall, it seems that it\'s a mess :( http://www8.plala.or.jp/tkubota1/unicode-symbols-map2.html
\'shiftjis\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(4108) },
encodeAdd: { \'\u00a5\': 0x5C, \'\u203E\': 0x7E },
encodeSkipVals: [{ from: 0xED40, to: 0xF940 }],
},
\'csshiftjis\': \'shiftjis\',
\'mskanji\': \'shiftjis\',
\'sjis\': \'shiftjis\',
\'windows31j\': \'shiftjis\',
\'ms31j\': \'shiftjis\',
\'xsjis\': \'shiftjis\',
\'windows932\': \'shiftjis\',
\'ms932\': \'shiftjis\',
\'932\': \'shiftjis\',
\'cp932\': \'shiftjis\',
\'eucjp\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(2417) },
encodeAdd: { \'\u00a5\': 0x5C, \'\u203E\': 0x7E },
},
// TODO: KDDI extension to Shift_JIS
// TODO: IBM CCSID 942 = CP932, but F0-F9 custom chars and other char changes.
// TODO: IBM CCSID 943 = Shift_JIS = CP932 with original Shift_JIS lower 128 chars.
// == Chinese/GBK ==========================================================
// http://en.wikipedia.org/wiki/GBK
// We mostly implement W3C recommendation: https://www.w3.org/TR/encoding/#gbk-encoder
// Oldest GB2312 (1981, ~7600 chars) is a subset of CP936
\'gb2312\': \'cp936\',
\'gb231280\': \'cp936\',
\'gb23121980\': \'cp936\',
\'csgb2312\': \'cp936\',
\'csiso58gb231280\': \'cp936\',
\'euccn\': \'cp936\',
// Microsoft\'s CP936 is a subset and approximation of GBK.
\'windows936\': \'cp936\',
\'ms936\': \'cp936\',
\'936\': \'cp936\',
\'cp936\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(7803) },
},
// GBK (~22000 chars) is an extension of CP936 that added user-mapped chars and some other.
\'gbk\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(7803).concat(__nccwpck_require__(7419)) },
},
\'xgbk\': \'gbk\',
\'isoir58\': \'gbk\',
// GB18030 is an algorithmic extension of GBK.
// Main source: https://www.w3.org/TR/encoding/#gbk-encoder
// http://icu-project.org/docs/papers/gb18030.html
// http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml
// http://www.khngai.com/chinese/charmap/tblgbk.php?page=0
\'gb18030\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(7803).concat(__nccwpck_require__(7419)) },
gb18030: function () { return __nccwpck_require__(6351) },
encodeSkipVals: [0x80],
encodeAdd: { \'€\': 0xA2E3 },
},
\'chinese\': \'gb18030\',
// == Korean ===============================================================
// EUC-KR, KS_C_5601 and KS X 1001 are exactly the same.
\'windows949\': \'cp949\',
\'ms949\': \'cp949\',
\'949\': \'cp949\',
\'cp949\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(7013) },
},
\'cseuckr\': \'cp949\',
\'csksc56011987\': \'cp949\',
\'euckr\': \'cp949\',
\'isoir149\': \'cp949\',
\'korean\': \'cp949\',
\'ksc56011987\': \'cp949\',
\'ksc56011989\': \'cp949\',
\'ksc5601\': \'cp949\',
// == Big5/Taiwan/Hong Kong ================================================
// There are lots of tables for Big5 and cp950. Please see the following links for history:
// http://moztw.org/docs/big5/ http://www.haible.de/bruno/charsets/conversion-tables/Big5.html
// Variations, in roughly number of defined chars:
// * Windows CP 950: Microsoft variant of Big5. Canonical: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT
// * Windows CP 951: Microsoft variant of Big5-HKSCS-2001. Seems to be never public. http://me.abelcheung.org/articles/research/what-is-cp951/
// * Big5-2003 (Taiwan standard) almost superset of cp950.
// * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers.
// * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard.
// many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years.
// Plus, it has 4 combining sequences.
// Seems that Mozilla refused to support it for 10 yrs. https://bugzilla.mozilla.org/show_bug.cgi?id=162431 https://bugzilla.mozilla.org/show_bug.cgi?id=310299
// because big5-hkscs is the only encoding to include astral characters in non-algorithmic way.
// Implementations are not consistent within browsers; sometimes labeled as just big5.
// MS Internet Explorer switches from big5 to big5-hkscs when a patch applied.
// Great discussion & recap of what\'s going on https://bugzilla.mozilla.org/show_bug.cgi?id=912470#c31
// In the encoder, it might make sense to support encoding old PUA mappings to Big5 bytes seq-s.
// Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt
// http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt
//
// Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder
// Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong.
\'windows950\': \'cp950\',
\'ms950\': \'cp950\',
\'950\': \'cp950\',
\'cp950\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(3104) },
},
// Big5 has many variations and is an extension of cp950. We use Encoding Standard\'s as a consensus.
\'big5\': \'big5hkscs\',
\'big5hkscs\': {
type: \'_dbcs\',
table: function () { return __nccwpck_require__(3104).concat(__nccwpck_require__(3612)) },
encodeSkipVals: [0xa2cc],
},
\'cnbig5\': \'big5hkscs\',
\'csbig5\': \'big5hkscs\',
\'xxbig5\': \'big5hkscs\',
};
/***/
}),
/***/ 9964:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
// Update this array if you add/rename/remove files in this directory.
// We support Browserify by skipping automatic module discovery and requiring modules directly.
var modules = [
__nccwpck_require__(4862),
__nccwpck_require__(7483),
__nccwpck_require__(1799),
__nccwpck_require__(9282),
__nccwpck_require__(7954),
__nccwpck_require__(4018),
__nccwpck_require__(8735),
__nccwpck_require__(3091),
];
// Put all encoding/alias/codec definitions to single object and export it.
for (var i = 0; i < modules.length; i++) {
var module = modules[i];
for (var enc in module)
if (Object.prototype.hasOwnProperty.call(module, enc))
exports[enc] = module[enc];
}
/***/
}),
/***/ 4862:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
var Buffer = __nccwpck_require__(6160).Buffer;
// Export Node.js internal encodings.
module.exports = {
// Encodings
utf8: { type: "_internal", bomAware: true },
cesu8: { type: "_internal", bomAware: true },
unicode11utf8: "utf8",
ucs2: { type: "_internal", bomAware: true },
utf16le: "ucs2",
binary: { type: "_internal" },
base64: { type: "_internal" },
hex: { type: "_internal" },
// Codec.
_internal: InternalCodec,
};
//------------------------------------------------------------------------------
function InternalCodec(codecOptions, iconv) {
this.enc = codecOptions.encodingName;
this.bomAware = codecOptions.bomAware;
if (this.enc === "base64")
this.encoder = InternalEncoderBase64;
else if (this.enc === "cesu8") {
this.enc = "utf8"; // Use utf8 for decoding.
this.encoder = InternalEncoderCesu8;
// Add decoder for versions of Node not supporting CESU-8
if (Buffer.from(\'eda0bdedb2a9\', \'hex\').toString() !== \'
相关文章: