mirror of
https://git.hmsn.ink/kospo/helptalk/push.git
synced 2026-03-20 01:22:33 +09:00
first
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
6
.idea/jsLibraryMappings.xml
generated
Normal file
6
.idea/jsLibraryMappings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptLibraryMappings">
|
||||||
|
<includedPredefinedLibrary name="Node.js Core" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/../talk_push.iml" filepath="$PROJECT_DIR$/../talk_push.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
11
.idea/runConfigurations/bin_www.xml
generated
Normal file
11
.idea/runConfigurations/bin_www.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="bin\www" type="NodeJSConfigurationType" path-to-js-file="bin/www" working-dir="$PROJECT_DIR$">
|
||||||
|
<envs>
|
||||||
|
<env name="DEBUG" value="talk-push:*" />
|
||||||
|
</envs>
|
||||||
|
<EXTENSION ID="com.intellij.lang.javascript.buildTools.npm.rc.StartBrowserRunConfigurationExtension">
|
||||||
|
<browser url="http://localhost:3000/" />
|
||||||
|
</EXTENSION>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
78
app.js
Normal file
78
app.js
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
// 서버 사이드 (Node.js Express)
|
||||||
|
const express = require('express');
|
||||||
|
const webpush = require('web-push');
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
|
const cors = require('cors');
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
// VAPID 키 생성 (최초 1회 생성 후 저장해서 사용)
|
||||||
|
// const vapidKeys = webpush.generateVAPIDKeys();
|
||||||
|
// const publicVapidKey = vapidKeys.publicKey;
|
||||||
|
// const privateVapidKey = vapidKeys.privateKey;
|
||||||
|
|
||||||
|
const publicVapidKey = 'BLBOCa4S62kYyYn3qwAAwSw-8g9gQ5xK6BU_PYC4f-NAZkihmBRkjYbI9ao5npLEW88H2bsDiCsSznNbtWSSNWA'
|
||||||
|
privateVapidKey = 'KFyzoAfq6jawkfA16iwUd7NhQIBbWJ44XVvyPxb3L1g'
|
||||||
|
|
||||||
|
webpush.setVapidDetails(
|
||||||
|
'mailto:bangae2@gmail.com',
|
||||||
|
publicVapidKey,
|
||||||
|
privateVapidKey
|
||||||
|
);
|
||||||
|
|
||||||
|
// 구독 정보 저장소 (실제 구현시 DB 사용)
|
||||||
|
const subscriptions = new Map();
|
||||||
|
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
app.use(cors({
|
||||||
|
origin: '*'
|
||||||
|
}))
|
||||||
|
|
||||||
|
// 클라이언트 구독 등록 엔드포인트
|
||||||
|
app.post('/api/subscribe', (req, res) => {
|
||||||
|
const subscription = req.body;
|
||||||
|
const userId = req.headers['user-id']; // 사용자 식별자
|
||||||
|
console.log(userId)
|
||||||
|
subscriptions.set(userId, subscription);
|
||||||
|
res.status(201).json({});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 푸시 메시지 전송 엔드포인트
|
||||||
|
app.post('/api/push', async (req, res) => {
|
||||||
|
const notifications = req.body;
|
||||||
|
|
||||||
|
if(!Array.isArray(notifications)) {
|
||||||
|
return res.status(400).json({ error: 'Notifications must be an array' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = JSON.stringify({
|
||||||
|
notifications: notifications.map((notif, index) => ({
|
||||||
|
...notif,
|
||||||
|
title: `${notif.workNm}[${notif.insName}]`,
|
||||||
|
tag: `notification-${Date.now()}-${index}`
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
// const subscription = subscriptions.get(userId);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
const sendPromises = Array.from(subscriptions.keys()).map(key => {
|
||||||
|
if(key === "17131303") {
|
||||||
|
webpush.sendNotification(subscriptions.get(key), payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.all(sendPromises);
|
||||||
|
res.status(200).json({ message: 'Notification sent successfully.' });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('푸시 전송 실패:', error);
|
||||||
|
res.status(500).json({ error: '푸시 전송 실패' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 서버 시작
|
||||||
|
app.listen(3000, () => {
|
||||||
|
console.log('푸시 서버가 3000 포트에서 실행중입니다.');
|
||||||
|
});
|
||||||
90
bin/www
Normal file
90
bin/www
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var app = require('../app');
|
||||||
|
var debug = require('debug')('talk-push:server');
|
||||||
|
var http = require('http');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get port from environment and store in Express.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var port = normalizePort(process.env.PORT || '3000');
|
||||||
|
app.set('port', port);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create HTTP server.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var server = http.createServer(app);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listen on provided port, on all network interfaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
server.listen(port);
|
||||||
|
server.on('error', onError);
|
||||||
|
server.on('listening', onListening);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a port into a number, string, or false.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function normalizePort(val) {
|
||||||
|
var port = parseInt(val, 10);
|
||||||
|
|
||||||
|
if (isNaN(port)) {
|
||||||
|
// named pipe
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port >= 0) {
|
||||||
|
// port number
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener for HTTP server "error" event.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onError(error) {
|
||||||
|
if (error.syscall !== 'listen') {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bind = typeof port === 'string'
|
||||||
|
? 'Pipe ' + port
|
||||||
|
: 'Port ' + port;
|
||||||
|
|
||||||
|
// handle specific listen errors with friendly messages
|
||||||
|
switch (error.code) {
|
||||||
|
case 'EACCES':
|
||||||
|
console.error(bind + ' requires elevated privileges');
|
||||||
|
process.exit(1);
|
||||||
|
break;
|
||||||
|
case 'EADDRINUSE':
|
||||||
|
console.error(bind + ' is already in use');
|
||||||
|
process.exit(1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener for HTTP server "listening" event.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onListening() {
|
||||||
|
var addr = server.address();
|
||||||
|
var bind = typeof addr === 'string'
|
||||||
|
? 'pipe ' + addr
|
||||||
|
: 'port ' + addr.port;
|
||||||
|
debug('Listening on ' + bind);
|
||||||
|
}
|
||||||
16
node_modules/.bin/mime
generated
vendored
Normal file
16
node_modules/.bin/mime
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../mime/cli.js" "$@"
|
||||||
|
fi
|
||||||
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*
|
||||||
28
node_modules/.bin/mime.ps1
generated
vendored
Normal file
28
node_modules/.bin/mime.ps1
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
||||||
16
node_modules/.bin/web-push
generated
vendored
Normal file
16
node_modules/.bin/web-push
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../web-push/src/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../web-push/src/cli.js" "$@"
|
||||||
|
fi
|
||||||
17
node_modules/.bin/web-push.cmd
generated
vendored
Normal file
17
node_modules/.bin/web-push.cmd
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\web-push\src\cli.js" %*
|
||||||
28
node_modules/.bin/web-push.ps1
generated
vendored
Normal file
28
node_modules/.bin/web-push.ps1
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../web-push/src/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../web-push/src/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../web-push/src/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../web-push/src/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
||||||
1013
node_modules/.package-lock.json
generated
vendored
Normal file
1013
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
243
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
243
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
1.3.8 / 2022-02-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.34
|
||||||
|
- deps: mime-db@~1.51.0
|
||||||
|
* deps: negotiator@0.6.3
|
||||||
|
|
||||||
|
1.3.7 / 2019-04-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.6.2
|
||||||
|
- Fix sorting charset, encoding, and language with extra parameters
|
||||||
|
|
||||||
|
1.3.6 / 2019-04-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.24
|
||||||
|
- deps: mime-db@~1.40.0
|
||||||
|
|
||||||
|
1.3.5 / 2018-02-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.18
|
||||||
|
- deps: mime-db@~1.33.0
|
||||||
|
|
||||||
|
1.3.4 / 2017-08-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.16
|
||||||
|
- deps: mime-db@~1.29.0
|
||||||
|
|
||||||
|
1.3.3 / 2016-05-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.11
|
||||||
|
- deps: mime-db@~1.23.0
|
||||||
|
* deps: negotiator@0.6.1
|
||||||
|
- perf: improve `Accept` parsing speed
|
||||||
|
- perf: improve `Accept-Charset` parsing speed
|
||||||
|
- perf: improve `Accept-Encoding` parsing speed
|
||||||
|
- perf: improve `Accept-Language` parsing speed
|
||||||
|
|
||||||
|
1.3.2 / 2016-03-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.10
|
||||||
|
- Fix extension of `application/dash+xml`
|
||||||
|
- Update primary extension for `audio/mp4`
|
||||||
|
- deps: mime-db@~1.22.0
|
||||||
|
|
||||||
|
1.3.1 / 2016-01-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.9
|
||||||
|
- deps: mime-db@~1.21.0
|
||||||
|
|
||||||
|
1.3.0 / 2015-09-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.7
|
||||||
|
- deps: mime-db@~1.19.0
|
||||||
|
* deps: negotiator@0.6.0
|
||||||
|
- Fix including type extensions in parameters in `Accept` parsing
|
||||||
|
- Fix parsing `Accept` parameters with quoted equals
|
||||||
|
- Fix parsing `Accept` parameters with quoted semicolons
|
||||||
|
- Lazy-load modules from main entry point
|
||||||
|
- perf: delay type concatenation until needed
|
||||||
|
- perf: enable strict mode
|
||||||
|
- perf: hoist regular expressions
|
||||||
|
- perf: remove closures getting spec properties
|
||||||
|
- perf: remove a closure from media type parsing
|
||||||
|
- perf: remove property delete from media type parsing
|
||||||
|
|
||||||
|
1.2.13 / 2015-09-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.6
|
||||||
|
- deps: mime-db@~1.18.0
|
||||||
|
|
||||||
|
1.2.12 / 2015-07-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.4
|
||||||
|
- deps: mime-db@~1.16.0
|
||||||
|
|
||||||
|
1.2.11 / 2015-07-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.3
|
||||||
|
- deps: mime-db@~1.15.0
|
||||||
|
|
||||||
|
1.2.10 / 2015-07-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.2
|
||||||
|
- deps: mime-db@~1.14.0
|
||||||
|
|
||||||
|
1.2.9 / 2015-06-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.1
|
||||||
|
- perf: fix deopt during mapping
|
||||||
|
|
||||||
|
1.2.8 / 2015-06-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.0
|
||||||
|
- deps: mime-db@~1.13.0
|
||||||
|
* perf: avoid argument reassignment & argument slice
|
||||||
|
* perf: avoid negotiator recursive construction
|
||||||
|
* perf: enable strict mode
|
||||||
|
* perf: remove unnecessary bitwise operator
|
||||||
|
|
||||||
|
1.2.7 / 2015-05-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.3
|
||||||
|
- Fix media type parameter matching to be case-insensitive
|
||||||
|
|
||||||
|
1.2.6 / 2015-05-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.11
|
||||||
|
- deps: mime-db@~1.9.1
|
||||||
|
* deps: negotiator@0.5.2
|
||||||
|
- Fix comparing media types with quoted values
|
||||||
|
- Fix splitting media types with quoted commas
|
||||||
|
|
||||||
|
1.2.5 / 2015-03-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.10
|
||||||
|
- deps: mime-db@~1.8.0
|
||||||
|
|
||||||
|
1.2.4 / 2015-02-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support Node.js 0.6
|
||||||
|
* deps: mime-types@~2.0.9
|
||||||
|
- deps: mime-db@~1.7.0
|
||||||
|
* deps: negotiator@0.5.1
|
||||||
|
- Fix preference sorting to be stable for long acceptable lists
|
||||||
|
|
||||||
|
1.2.3 / 2015-01-31
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.8
|
||||||
|
- deps: mime-db@~1.6.0
|
||||||
|
|
||||||
|
1.2.2 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.7
|
||||||
|
- deps: mime-db@~1.5.0
|
||||||
|
|
||||||
|
1.2.1 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.5
|
||||||
|
- deps: mime-db@~1.3.1
|
||||||
|
|
||||||
|
1.2.0 / 2014-12-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.0
|
||||||
|
- Fix list return order when large accepted list
|
||||||
|
- Fix missing identity encoding when q=0 exists
|
||||||
|
- Remove dynamic building of Negotiator class
|
||||||
|
|
||||||
|
1.1.4 / 2014-12-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.4
|
||||||
|
- deps: mime-db@~1.3.0
|
||||||
|
|
||||||
|
1.1.3 / 2014-11-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.3
|
||||||
|
- deps: mime-db@~1.2.0
|
||||||
|
|
||||||
|
1.1.2 / 2014-10-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.9
|
||||||
|
- Fix error when media type has invalid parameter
|
||||||
|
|
||||||
|
1.1.1 / 2014-09-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.2
|
||||||
|
- deps: mime-db@~1.1.0
|
||||||
|
* deps: negotiator@0.4.8
|
||||||
|
- Fix all negotiations to be case-insensitive
|
||||||
|
- Stable sort preferences of same quality according to client order
|
||||||
|
|
||||||
|
1.1.0 / 2014-09-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* update `mime-types`
|
||||||
|
|
||||||
|
1.0.7 / 2014-07-04
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix wrong type returned from `type` when match after unknown extension
|
||||||
|
|
||||||
|
1.0.6 / 2014-06-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.7
|
||||||
|
|
||||||
|
1.0.5 / 2014-06-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix crash when unknown extension given
|
||||||
|
|
||||||
|
1.0.4 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* use `mime-types`
|
||||||
|
|
||||||
|
1.0.3 / 2014-06-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.6
|
||||||
|
- Order by specificity when quality is the same
|
||||||
|
|
||||||
|
1.0.2 / 2014-05-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix interpretation when header not in request
|
||||||
|
* deps: pin negotiator@0.4.5
|
||||||
|
|
||||||
|
1.0.1 / 2014-01-18
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Identity encoding isn't always acceptable
|
||||||
|
* deps: negotiator@~0.4.0
|
||||||
|
|
||||||
|
1.0.0 / 2013-12-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Genesis
|
||||||
23
node_modules/accepts/LICENSE
generated
vendored
Normal file
23
node_modules/accepts/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
140
node_modules/accepts/README.md
generated
vendored
Normal file
140
node_modules/accepts/README.md
generated
vendored
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
# accepts
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Node.js Version][node-version-image]][node-version-url]
|
||||||
|
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
|
||||||
|
Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
|
||||||
|
|
||||||
|
In addition to negotiator, it allows:
|
||||||
|
|
||||||
|
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
|
||||||
|
as well as `('text/html', 'application/json')`.
|
||||||
|
- Allows type shorthands such as `json`.
|
||||||
|
- Returns `false` when no types match
|
||||||
|
- Treats non-existent headers as `*`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install accepts
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
```
|
||||||
|
|
||||||
|
### accepts(req)
|
||||||
|
|
||||||
|
Create a new `Accepts` object for the given `req`.
|
||||||
|
|
||||||
|
#### .charset(charsets)
|
||||||
|
|
||||||
|
Return the first accepted charset. If nothing in `charsets` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .charsets()
|
||||||
|
|
||||||
|
Return the charsets that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .encoding(encodings)
|
||||||
|
|
||||||
|
Return the first accepted encoding. If nothing in `encodings` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .encodings()
|
||||||
|
|
||||||
|
Return the encodings that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .language(languages)
|
||||||
|
|
||||||
|
Return the first accepted language. If nothing in `languages` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .languages()
|
||||||
|
|
||||||
|
Return the languages that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .type(types)
|
||||||
|
|
||||||
|
Return the first accepted type (and it is returned as the same text as what
|
||||||
|
appears in the `types` array). If nothing in `types` is accepted, then `false`
|
||||||
|
is returned.
|
||||||
|
|
||||||
|
The `types` array can contain full MIME types or file extensions. Any value
|
||||||
|
that is not a full MIME types is passed to `require('mime-types').lookup`.
|
||||||
|
|
||||||
|
#### .types()
|
||||||
|
|
||||||
|
Return the types that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Simple type negotiation
|
||||||
|
|
||||||
|
This simple example shows how to use `accepts` to return a different typed
|
||||||
|
respond body based on what the client wants to accept. The server lists it's
|
||||||
|
preferences in order and will get back the best match between the client and
|
||||||
|
server.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
var http = require('http')
|
||||||
|
|
||||||
|
function app (req, res) {
|
||||||
|
var accept = accepts(req)
|
||||||
|
|
||||||
|
// the order of this list is significant; should be server preferred order
|
||||||
|
switch (accept.type(['json', 'html'])) {
|
||||||
|
case 'json':
|
||||||
|
res.setHeader('Content-Type', 'application/json')
|
||||||
|
res.write('{"hello":"world!"}')
|
||||||
|
break
|
||||||
|
case 'html':
|
||||||
|
res.setHeader('Content-Type', 'text/html')
|
||||||
|
res.write('<b>hello, world!</b>')
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
// the fallback is text/plain, so no need to specify it above
|
||||||
|
res.setHeader('Content-Type', 'text/plain')
|
||||||
|
res.write('hello, world!')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
res.end()
|
||||||
|
}
|
||||||
|
|
||||||
|
http.createServer(app).listen(3000)
|
||||||
|
```
|
||||||
|
|
||||||
|
You can test this out with the cURL program:
|
||||||
|
```sh
|
||||||
|
curl -I -H'Accept: text/html' http://localhost:3000/
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
|
||||||
|
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
|
||||||
|
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
|
||||||
|
[node-version-image]: https://badgen.net/npm/node/accepts
|
||||||
|
[node-version-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
|
||||||
|
[npm-url]: https://npmjs.org/package/accepts
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/accepts
|
||||||
238
node_modules/accepts/index.js
generated
vendored
Normal file
238
node_modules/accepts/index.js
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
/*!
|
||||||
|
* accepts
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Negotiator = require('negotiator')
|
||||||
|
var mime = require('mime-types')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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'
|
||||||
|
}
|
||||||
47
node_modules/accepts/package.json
generated
vendored
Normal file
47
node_modules/accepts/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "accepts",
|
||||||
|
"description": "Higher-level content negotiation",
|
||||||
|
"version": "1.3.8",
|
||||||
|
"contributors": [
|
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "jshttp/accepts",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-types": "~2.1.34",
|
||||||
|
"negotiator": "0.6.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"deep-equal": "1.0.1",
|
||||||
|
"eslint": "7.32.0",
|
||||||
|
"eslint-config-standard": "14.1.1",
|
||||||
|
"eslint-plugin-import": "2.25.4",
|
||||||
|
"eslint-plugin-markdown": "2.2.1",
|
||||||
|
"eslint-plugin-node": "11.1.0",
|
||||||
|
"eslint-plugin-promise": "4.3.1",
|
||||||
|
"eslint-plugin-standard": "4.1.0",
|
||||||
|
"mocha": "9.2.0",
|
||||||
|
"nyc": "15.1.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"LICENSE",
|
||||||
|
"HISTORY.md",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
|
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"content",
|
||||||
|
"negotiation",
|
||||||
|
"accept",
|
||||||
|
"accepts"
|
||||||
|
]
|
||||||
|
}
|
||||||
22
node_modules/agent-base/LICENSE
generated
vendored
Normal file
22
node_modules/agent-base/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
69
node_modules/agent-base/README.md
generated
vendored
Normal file
69
node_modules/agent-base/README.md
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
agent-base
|
||||||
|
==========
|
||||||
|
### Turn a function into an [`http.Agent`][http.Agent] instance
|
||||||
|
|
||||||
|
This module is a thin wrapper around the base `http.Agent` class.
|
||||||
|
|
||||||
|
It provides an abstract class that must define a `connect()` function,
|
||||||
|
which is responsible for creating the underlying socket that the HTTP
|
||||||
|
client requests will use.
|
||||||
|
|
||||||
|
The `connect()` function may return an arbitrary `Duplex` stream, or
|
||||||
|
another `http.Agent` instance to delegate the request to, and may be
|
||||||
|
asynchronous (by defining an `async` function).
|
||||||
|
|
||||||
|
Instances of this agent can be used with the `http` and `https`
|
||||||
|
modules. To differentiate, the options parameter in the `connect()`
|
||||||
|
function includes a `secureEndpoint` property, which can be checked
|
||||||
|
to determine what type of socket should be returned.
|
||||||
|
|
||||||
|
#### Some subclasses:
|
||||||
|
|
||||||
|
Here are some more interesting uses of `agent-base`.
|
||||||
|
Send a pull request to list yours!
|
||||||
|
|
||||||
|
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
||||||
|
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
||||||
|
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
||||||
|
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
Here's a minimal example that creates a new `net.Socket` or `tls.Socket`
|
||||||
|
based on the `secureEndpoint` property. This agent can be used with both
|
||||||
|
the `http` and `https` modules.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import * as net from 'net';
|
||||||
|
import * as tls from 'tls';
|
||||||
|
import * as http from 'http';
|
||||||
|
import { Agent } from 'agent-base';
|
||||||
|
|
||||||
|
class MyAgent extends Agent {
|
||||||
|
connect(req, opts) {
|
||||||
|
// `secureEndpoint` is true when using the "https" module
|
||||||
|
if (opts.secureEndpoint) {
|
||||||
|
return tls.connect(opts);
|
||||||
|
} else {
|
||||||
|
return net.connect(opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Keep alive enabled means that `connect()` will only be
|
||||||
|
// invoked when a new connection needs to be created
|
||||||
|
const agent = new MyAgent({ keepAlive: true });
|
||||||
|
|
||||||
|
// Pass the `agent` option when creating the HTTP request
|
||||||
|
http.get('http://nodejs.org/api/', { agent }, (res) => {
|
||||||
|
console.log('"response" event!', res.headers);
|
||||||
|
res.pipe(process.stdout);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
[http-proxy-agent]: ../http-proxy-agent
|
||||||
|
[https-proxy-agent]: ../https-proxy-agent
|
||||||
|
[pac-proxy-agent]: ../pac-proxy-agent
|
||||||
|
[socks-proxy-agent]: ../socks-proxy-agent
|
||||||
|
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
||||||
15
node_modules/agent-base/dist/helpers.d.ts
generated
vendored
Normal file
15
node_modules/agent-base/dist/helpers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
import * as http from 'http';
|
||||||
|
import * as https from 'https';
|
||||||
|
import type { Readable } from 'stream';
|
||||||
|
export type ThenableRequest = http.ClientRequest & {
|
||||||
|
then: Promise<http.IncomingMessage>['then'];
|
||||||
|
};
|
||||||
|
export declare function toBuffer(stream: Readable): Promise<Buffer>;
|
||||||
|
export declare function json(stream: Readable): Promise<any>;
|
||||||
|
export declare function req(url: string | URL, opts?: https.RequestOptions): ThenableRequest;
|
||||||
|
//# sourceMappingURL=helpers.d.ts.map
|
||||||
1
node_modules/agent-base/dist/helpers.d.ts.map
generated
vendored
Normal file
1
node_modules/agent-base/dist/helpers.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,GAAG;IAClD,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAQhE;AAGD,wBAAsB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAUzD;AAED,wBAAgB,GAAG,CAClB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,GAAE,KAAK,CAAC,cAAmB,GAC7B,eAAe,CAcjB"}
|
||||||
66
node_modules/agent-base/dist/helpers.js
generated
vendored
Normal file
66
node_modules/agent-base/dist/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.req = exports.json = exports.toBuffer = void 0;
|
||||||
|
const http = __importStar(require("http"));
|
||||||
|
const https = __importStar(require("https"));
|
||||||
|
async function toBuffer(stream) {
|
||||||
|
let length = 0;
|
||||||
|
const chunks = [];
|
||||||
|
for await (const chunk of stream) {
|
||||||
|
length += chunk.length;
|
||||||
|
chunks.push(chunk);
|
||||||
|
}
|
||||||
|
return Buffer.concat(chunks, length);
|
||||||
|
}
|
||||||
|
exports.toBuffer = toBuffer;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
async function json(stream) {
|
||||||
|
const buf = await toBuffer(stream);
|
||||||
|
const str = buf.toString('utf8');
|
||||||
|
try {
|
||||||
|
return JSON.parse(str);
|
||||||
|
}
|
||||||
|
catch (_err) {
|
||||||
|
const err = _err;
|
||||||
|
err.message += ` (input: ${str})`;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.json = json;
|
||||||
|
function req(url, opts = {}) {
|
||||||
|
const href = typeof url === 'string' ? url : url.href;
|
||||||
|
const req = (href.startsWith('https:') ? https : http).request(url, opts);
|
||||||
|
const promise = new Promise((resolve, reject) => {
|
||||||
|
req
|
||||||
|
.once('response', resolve)
|
||||||
|
.once('error', reject)
|
||||||
|
.end();
|
||||||
|
});
|
||||||
|
req.then = promise.then.bind(promise);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
exports.req = req;
|
||||||
|
//# sourceMappingURL=helpers.js.map
|
||||||
1
node_modules/agent-base/dist/helpers.js.map
generated
vendored
Normal file
1
node_modules/agent-base/dist/helpers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,6CAA+B;AAOxB,KAAK,UAAU,QAAQ,CAAC,MAAgB;IAC9C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACnB;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AARD,4BAQC;AAED,8DAA8D;AACvD,KAAK,UAAU,IAAI,CAAC,MAAgB;IAC1C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACvB;IAAC,OAAO,IAAa,EAAE;QACvB,MAAM,GAAG,GAAG,IAAa,CAAC;QAC1B,GAAG,CAAC,OAAO,IAAI,YAAY,GAAG,GAAG,CAAC;QAClC,MAAM,GAAG,CAAC;KACV;AACF,CAAC;AAVD,oBAUC;AAED,SAAgB,GAAG,CAClB,GAAiB,EACjB,OAA6B,EAAE;IAE/B,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACtD,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAC7D,GAAG,EACH,IAAI,CACe,CAAC;IACrB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrE,GAAG;aACD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC;aACzB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;aACrB,GAAG,EAAqB,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACZ,CAAC;AAjBD,kBAiBC"}
|
||||||
41
node_modules/agent-base/dist/index.d.ts
generated
vendored
Normal file
41
node_modules/agent-base/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="node" />
|
||||||
|
import * as net from 'net';
|
||||||
|
import * as tls from 'tls';
|
||||||
|
import * as http from 'http';
|
||||||
|
import type { Duplex } from 'stream';
|
||||||
|
export * from './helpers';
|
||||||
|
interface HttpConnectOpts extends net.TcpNetConnectOpts {
|
||||||
|
secureEndpoint: false;
|
||||||
|
protocol?: string;
|
||||||
|
}
|
||||||
|
interface HttpsConnectOpts extends tls.ConnectionOptions {
|
||||||
|
secureEndpoint: true;
|
||||||
|
protocol?: string;
|
||||||
|
port: number;
|
||||||
|
}
|
||||||
|
export type AgentConnectOpts = HttpConnectOpts | HttpsConnectOpts;
|
||||||
|
declare const INTERNAL: unique symbol;
|
||||||
|
export declare abstract class Agent extends http.Agent {
|
||||||
|
private [INTERNAL];
|
||||||
|
options: Partial<net.TcpNetConnectOpts & tls.ConnectionOptions>;
|
||||||
|
keepAlive: boolean;
|
||||||
|
constructor(opts?: http.AgentOptions);
|
||||||
|
abstract connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<Duplex | http.Agent> | Duplex | http.Agent;
|
||||||
|
/**
|
||||||
|
* Determine whether this is an `http` or `https` request.
|
||||||
|
*/
|
||||||
|
isSecureEndpoint(options?: AgentConnectOpts): boolean;
|
||||||
|
private incrementSockets;
|
||||||
|
private decrementSockets;
|
||||||
|
getName(options: AgentConnectOpts): string;
|
||||||
|
createSocket(req: http.ClientRequest, options: AgentConnectOpts, cb: (err: Error | null, s?: Duplex) => void): void;
|
||||||
|
createConnection(): Duplex;
|
||||||
|
get defaultPort(): number;
|
||||||
|
set defaultPort(v: number);
|
||||||
|
get protocol(): string;
|
||||||
|
set protocol(v: string);
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
node_modules/agent-base/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/agent-base/dist/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,cAAc,WAAW,CAAC;AAE1B,UAAU,eAAgB,SAAQ,GAAG,CAAC,iBAAiB;IACtD,cAAc,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IACvD,cAAc,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAElE,QAAA,MAAM,QAAQ,eAAmC,CAAC;AAQlD,8BAAsB,KAAM,SAAQ,IAAI,CAAC,KAAK;IAC7C,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAgB;IAGlC,OAAO,EAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACjE,SAAS,EAAG,OAAO,CAAC;gBAER,IAAI,CAAC,EAAE,IAAI,CAAC,YAAY;IAKpC,QAAQ,CAAC,OAAO,CACf,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK;IAErD;;OAEG;IACH,gBAAgB,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO;IAqCrD,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;IAa1C,YAAY,CACX,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,OAAO,EAAE,gBAAgB,EACzB,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI;IA4B5C,gBAAgB,IAAI,MAAM;IAW1B,IAAI,WAAW,IAAI,MAAM,CAKxB;IAED,IAAI,WAAW,CAAC,CAAC,EAAE,MAAM,EAIxB;IAED,IAAI,QAAQ,IAAI,MAAM,CAKrB;IAED,IAAI,QAAQ,CAAC,CAAC,EAAE,MAAM,EAIrB;CACD"}
|
||||||
175
node_modules/agent-base/dist/index.js
generated
vendored
Normal file
175
node_modules/agent-base/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||||
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Agent = void 0;
|
||||||
|
const net = __importStar(require("net"));
|
||||||
|
const http = __importStar(require("http"));
|
||||||
|
const https_1 = require("https");
|
||||||
|
__exportStar(require("./helpers"), exports);
|
||||||
|
const INTERNAL = Symbol('AgentBaseInternalState');
|
||||||
|
class Agent extends http.Agent {
|
||||||
|
constructor(opts) {
|
||||||
|
super(opts);
|
||||||
|
this[INTERNAL] = {};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Determine whether this is an `http` or `https` request.
|
||||||
|
*/
|
||||||
|
isSecureEndpoint(options) {
|
||||||
|
if (options) {
|
||||||
|
// First check the `secureEndpoint` property explicitly, since this
|
||||||
|
// means that a parent `Agent` is "passing through" to this instance.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
if (typeof options.secureEndpoint === 'boolean') {
|
||||||
|
return options.secureEndpoint;
|
||||||
|
}
|
||||||
|
// If no explicit `secure` endpoint, check if `protocol` property is
|
||||||
|
// set. This will usually be the case since using a full string URL
|
||||||
|
// or `URL` instance should be the most common usage.
|
||||||
|
if (typeof options.protocol === 'string') {
|
||||||
|
return options.protocol === 'https:';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Finally, if no `protocol` property was set, then fall back to
|
||||||
|
// checking the stack trace of the current call stack, and try to
|
||||||
|
// detect the "https" module.
|
||||||
|
const { stack } = new Error();
|
||||||
|
if (typeof stack !== 'string')
|
||||||
|
return false;
|
||||||
|
return stack
|
||||||
|
.split('\n')
|
||||||
|
.some((l) => l.indexOf('(https.js:') !== -1 ||
|
||||||
|
l.indexOf('node:https:') !== -1);
|
||||||
|
}
|
||||||
|
// In order to support async signatures in `connect()` and Node's native
|
||||||
|
// connection pooling in `http.Agent`, the array of sockets for each origin
|
||||||
|
// has to be updated synchronously. This is so the length of the array is
|
||||||
|
// accurate when `addRequest()` is next called. We achieve this by creating a
|
||||||
|
// fake socket and adding it to `sockets[origin]` and incrementing
|
||||||
|
// `totalSocketCount`.
|
||||||
|
incrementSockets(name) {
|
||||||
|
// If `maxSockets` and `maxTotalSockets` are both Infinity then there is no
|
||||||
|
// need to create a fake socket because Node.js native connection pooling
|
||||||
|
// will never be invoked.
|
||||||
|
if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// All instances of `sockets` are expected TypeScript errors. The
|
||||||
|
// alternative is to add it as a private property of this class but that
|
||||||
|
// will break TypeScript subclassing.
|
||||||
|
if (!this.sockets[name]) {
|
||||||
|
// @ts-expect-error `sockets` is readonly in `@types/node`
|
||||||
|
this.sockets[name] = [];
|
||||||
|
}
|
||||||
|
const fakeSocket = new net.Socket({ writable: false });
|
||||||
|
this.sockets[name].push(fakeSocket);
|
||||||
|
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
||||||
|
this.totalSocketCount++;
|
||||||
|
return fakeSocket;
|
||||||
|
}
|
||||||
|
decrementSockets(name, socket) {
|
||||||
|
if (!this.sockets[name] || socket === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const sockets = this.sockets[name];
|
||||||
|
const index = sockets.indexOf(socket);
|
||||||
|
if (index !== -1) {
|
||||||
|
sockets.splice(index, 1);
|
||||||
|
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
||||||
|
this.totalSocketCount--;
|
||||||
|
if (sockets.length === 0) {
|
||||||
|
// @ts-expect-error `sockets` is readonly in `@types/node`
|
||||||
|
delete this.sockets[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// In order to properly update the socket pool, we need to call `getName()` on
|
||||||
|
// the core `https.Agent` if it is a secureEndpoint.
|
||||||
|
getName(options) {
|
||||||
|
const secureEndpoint = typeof options.secureEndpoint === 'boolean'
|
||||||
|
? options.secureEndpoint
|
||||||
|
: this.isSecureEndpoint(options);
|
||||||
|
if (secureEndpoint) {
|
||||||
|
// @ts-expect-error `getName()` isn't defined in `@types/node`
|
||||||
|
return https_1.Agent.prototype.getName.call(this, options);
|
||||||
|
}
|
||||||
|
// @ts-expect-error `getName()` isn't defined in `@types/node`
|
||||||
|
return super.getName(options);
|
||||||
|
}
|
||||||
|
createSocket(req, options, cb) {
|
||||||
|
const connectOpts = {
|
||||||
|
...options,
|
||||||
|
secureEndpoint: this.isSecureEndpoint(options),
|
||||||
|
};
|
||||||
|
const name = this.getName(connectOpts);
|
||||||
|
const fakeSocket = this.incrementSockets(name);
|
||||||
|
Promise.resolve()
|
||||||
|
.then(() => this.connect(req, connectOpts))
|
||||||
|
.then((socket) => {
|
||||||
|
this.decrementSockets(name, fakeSocket);
|
||||||
|
if (socket instanceof http.Agent) {
|
||||||
|
// @ts-expect-error `addRequest()` isn't defined in `@types/node`
|
||||||
|
return socket.addRequest(req, connectOpts);
|
||||||
|
}
|
||||||
|
this[INTERNAL].currentSocket = socket;
|
||||||
|
// @ts-expect-error `createSocket()` isn't defined in `@types/node`
|
||||||
|
super.createSocket(req, options, cb);
|
||||||
|
}, (err) => {
|
||||||
|
this.decrementSockets(name, fakeSocket);
|
||||||
|
cb(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
createConnection() {
|
||||||
|
const socket = this[INTERNAL].currentSocket;
|
||||||
|
this[INTERNAL].currentSocket = undefined;
|
||||||
|
if (!socket) {
|
||||||
|
throw new Error('No socket was returned in the `connect()` function');
|
||||||
|
}
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
get defaultPort() {
|
||||||
|
return (this[INTERNAL].defaultPort ??
|
||||||
|
(this.protocol === 'https:' ? 443 : 80));
|
||||||
|
}
|
||||||
|
set defaultPort(v) {
|
||||||
|
if (this[INTERNAL]) {
|
||||||
|
this[INTERNAL].defaultPort = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get protocol() {
|
||||||
|
return (this[INTERNAL].protocol ??
|
||||||
|
(this.isSecureEndpoint() ? 'https:' : 'http:'));
|
||||||
|
}
|
||||||
|
set protocol(v) {
|
||||||
|
if (this[INTERNAL]) {
|
||||||
|
this[INTERNAL].protocol = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Agent = Agent;
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
1
node_modules/agent-base/dist/index.js.map
generated
vendored
Normal file
1
node_modules/agent-base/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAE3B,2CAA6B;AAC7B,iCAA4C;AAG5C,4CAA0B;AAe1B,MAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAQlD,MAAsB,KAAM,SAAQ,IAAI,CAAC,KAAK;IAO7C,YAAY,IAAwB;QACnC,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;IAOD;;OAEG;IACH,gBAAgB,CAAC,OAA0B;QAC1C,IAAI,OAAO,EAAE;YACZ,mEAAmE;YACnE,qEAAqE;YACrE,8DAA8D;YAC9D,IAAI,OAAQ,OAAe,CAAC,cAAc,KAAK,SAAS,EAAE;gBACzD,OAAO,OAAO,CAAC,cAAc,CAAC;aAC9B;YAED,oEAAoE;YACpE,mEAAmE;YACnE,qDAAqD;YACrD,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBACzC,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;aACrC;SACD;QAED,gEAAgE;QAChE,iEAAiE;QACjE,6BAA6B;QAC7B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,OAAO,KAAK;aACV,KAAK,CAAC,IAAI,CAAC;aACX,IAAI,CACJ,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAChC,CAAC;IACJ,CAAC;IAED,wEAAwE;IACxE,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,kEAAkE;IAClE,sBAAsB;IACd,gBAAgB,CAAC,IAAY;QACpC,2EAA2E;QAC3E,yEAAyE;QACzE,yBAAyB;QACzB,IAAI,IAAI,CAAC,UAAU,KAAK,QAAQ,IAAI,IAAI,CAAC,eAAe,KAAK,QAAQ,EAAE;YACtE,OAAO,IAAI,CAAC;SACZ;QACD,iEAAiE;QACjE,wEAAwE;QACxE,qCAAqC;QACrC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,0DAA0D;YAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SACxB;QACD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtD,qEAAqE;QACrE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC;IACnB,CAAC;IAEO,gBAAgB,CAAC,IAAY,EAAE,MAAyB;QAC/D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,MAAM,KAAK,IAAI,EAAE;YAC3C,OAAO;SACP;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAiB,CAAC;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACjB,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACzB,sEAAsE;YACtE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACzB,0DAA0D;gBAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC1B;SACD;IACF,CAAC;IAED,8EAA8E;IAC9E,oDAAoD;IACpD,OAAO,CAAC,OAAyB;QAChC,MAAM,cAAc,GACnB,OAAO,OAAO,CAAC,cAAc,KAAK,SAAS;YAC1C,CAAC,CAAC,OAAO,CAAC,cAAc;YACxB,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,cAAc,EAAE;YACnB,8DAA8D;YAC9D,OAAO,aAAU,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SACxD;QACD,8DAA8D;QAC9D,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,YAAY,CACX,GAAuB,EACvB,OAAyB,EACzB,EAA2C;QAE3C,MAAM,WAAW,GAAG;YACnB,GAAG,OAAO;YACV,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;SAC9C,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,CAAC,OAAO,EAAE;aACf,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;aAC1C,IAAI,CACJ,CAAC,MAAM,EAAE,EAAE;YACV,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YACxC,IAAI,MAAM,YAAY,IAAI,CAAC,KAAK,EAAE;gBACjC,iEAAiE;gBACjE,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;aAC3C;YACD,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,GAAG,MAAM,CAAC;YACtC,mEAAmE;YACnE,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QACtC,CAAC,EACD,CAAC,GAAG,EAAE,EAAE;YACP,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YACxC,EAAE,CAAC,GAAG,CAAC,CAAC;QACT,CAAC,CACD,CAAC;IACJ,CAAC;IAED,gBAAgB;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC;QAC5C,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,MAAM,EAAE;YACZ,MAAM,IAAI,KAAK,CACd,oDAAoD,CACpD,CAAC;SACF;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED,IAAI,WAAW;QACd,OAAO,CACN,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW;YAC1B,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACvC,CAAC;IACH,CAAC;IAED,IAAI,WAAW,CAAC,CAAS;QACxB,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;YACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC;SAC/B;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,CACN,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ;YACvB,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAC9C,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,CAAC,CAAS;QACrB,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;YACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC;SAC5B;IACF,CAAC;CACD;AAjLD,sBAiLC"}
|
||||||
20
node_modules/agent-base/node_modules/debug/LICENSE
generated
vendored
Normal file
20
node_modules/agent-base/node_modules/debug/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
Copyright (c) 2018-2021 Josh Junon
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||||
|
and associated documentation files (the 'Software'), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||||
|
portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
481
node_modules/agent-base/node_modules/debug/README.md
generated
vendored
Normal file
481
node_modules/agent-base/node_modules/debug/README.md
generated
vendored
Normal file
@@ -0,0 +1,481 @@
|
|||||||
|
# debug
|
||||||
|
[](#backers)
|
||||||
|
[](#sponsors)
|
||||||
|
|
||||||
|
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||||
|
|
||||||
|
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
||||||
|
technique. Works in Node.js and web browsers.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install debug
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
||||||
|
|
||||||
|
Example [_app.js_](./examples/node/app.js):
|
||||||
|
|
||||||
|
```js
|
||||||
|
var debug = require('debug')('http')
|
||||||
|
, http = require('http')
|
||||||
|
, name = 'My App';
|
||||||
|
|
||||||
|
// fake app
|
||||||
|
|
||||||
|
debug('booting %o', name);
|
||||||
|
|
||||||
|
http.createServer(function(req, res){
|
||||||
|
debug(req.method + ' ' + req.url);
|
||||||
|
res.end('hello\n');
|
||||||
|
}).listen(3000, function(){
|
||||||
|
debug('listening');
|
||||||
|
});
|
||||||
|
|
||||||
|
// fake worker of some kind
|
||||||
|
|
||||||
|
require('./worker');
|
||||||
|
```
|
||||||
|
|
||||||
|
Example [_worker.js_](./examples/node/worker.js):
|
||||||
|
|
||||||
|
```js
|
||||||
|
var a = require('debug')('worker:a')
|
||||||
|
, b = require('debug')('worker:b');
|
||||||
|
|
||||||
|
function work() {
|
||||||
|
a('doing lots of uninteresting work');
|
||||||
|
setTimeout(work, Math.random() * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
work();
|
||||||
|
|
||||||
|
function workb() {
|
||||||
|
b('doing some work');
|
||||||
|
setTimeout(workb, Math.random() * 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
workb();
|
||||||
|
```
|
||||||
|
|
||||||
|
The `DEBUG` environment variable is then used to enable these based on space or
|
||||||
|
comma-delimited names.
|
||||||
|
|
||||||
|
Here are some examples:
|
||||||
|
|
||||||
|
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
||||||
|
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
||||||
|
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
||||||
|
|
||||||
|
#### Windows command prompt notes
|
||||||
|
|
||||||
|
##### CMD
|
||||||
|
|
||||||
|
On Windows the environment variable is set using the `set` command.
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
set DEBUG=*,-not_this
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
set DEBUG=* & node app.js
|
||||||
|
```
|
||||||
|
|
||||||
|
##### PowerShell (VS Code default)
|
||||||
|
|
||||||
|
PowerShell uses different syntax to set environment variables.
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
$env:DEBUG = "*,-not_this"
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
$env:DEBUG='app';node app.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, run the program to be debugged as usual.
|
||||||
|
|
||||||
|
npm script example:
|
||||||
|
```js
|
||||||
|
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
||||||
|
```
|
||||||
|
|
||||||
|
## Namespace Colors
|
||||||
|
|
||||||
|
Every debug instance has a color generated for it based on its namespace name.
|
||||||
|
This helps when visually parsing the debug output to identify which debug instance
|
||||||
|
a debug line belongs to.
|
||||||
|
|
||||||
|
#### Node.js
|
||||||
|
|
||||||
|
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
||||||
|
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
||||||
|
otherwise debug will only use a small handful of basic colors.
|
||||||
|
|
||||||
|
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
||||||
|
|
||||||
|
#### Web Browser
|
||||||
|
|
||||||
|
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||||
|
option. These are WebKit web inspectors, Firefox ([since version
|
||||||
|
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||||
|
and the Firebug plugin for Firefox (any version).
|
||||||
|
|
||||||
|
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
||||||
|
|
||||||
|
|
||||||
|
## Millisecond diff
|
||||||
|
|
||||||
|
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||||
|
|
||||||
|
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||||
|
|
||||||
|
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
||||||
|
|
||||||
|
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
||||||
|
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
||||||
|
|
||||||
|
## Wildcards
|
||||||
|
|
||||||
|
The `*` character may be used as a wildcard. Suppose for example your library has
|
||||||
|
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
||||||
|
instead of listing all three with
|
||||||
|
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
||||||
|
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||||
|
|
||||||
|
You can also exclude specific debuggers by prefixing them with a "-" character.
|
||||||
|
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
||||||
|
starting with "connect:".
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
When running through Node.js, you can set a few environment variables that will
|
||||||
|
change the behavior of the debug logging:
|
||||||
|
|
||||||
|
| Name | Purpose |
|
||||||
|
|-----------|-------------------------------------------------|
|
||||||
|
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||||
|
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||||
|
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
||||||
|
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||||
|
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||||
|
|
||||||
|
|
||||||
|
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
||||||
|
converted into an Options object that gets used with `%o`/`%O` formatters.
|
||||||
|
See the Node.js documentation for
|
||||||
|
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
||||||
|
for the complete list.
|
||||||
|
|
||||||
|
## Formatters
|
||||||
|
|
||||||
|
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
||||||
|
Below are the officially supported formatters:
|
||||||
|
|
||||||
|
| Formatter | Representation |
|
||||||
|
|-----------|----------------|
|
||||||
|
| `%O` | Pretty-print an Object on multiple lines. |
|
||||||
|
| `%o` | Pretty-print an Object all on a single line. |
|
||||||
|
| `%s` | String. |
|
||||||
|
| `%d` | Number (both integer and float). |
|
||||||
|
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
||||||
|
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
||||||
|
|
||||||
|
|
||||||
|
### Custom formatters
|
||||||
|
|
||||||
|
You can add custom formatters by extending the `debug.formatters` object.
|
||||||
|
For example, if you wanted to add support for rendering a Buffer as hex with
|
||||||
|
`%h`, you could do something like:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const createDebug = require('debug')
|
||||||
|
createDebug.formatters.h = (v) => {
|
||||||
|
return v.toString('hex')
|
||||||
|
}
|
||||||
|
|
||||||
|
// …elsewhere
|
||||||
|
const debug = createDebug('foo')
|
||||||
|
debug('this is hex: %h', new Buffer('hello world'))
|
||||||
|
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Browser Support
|
||||||
|
|
||||||
|
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
||||||
|
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
||||||
|
if you don't want to build it yourself.
|
||||||
|
|
||||||
|
Debug's enable state is currently persisted by `localStorage`.
|
||||||
|
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
||||||
|
and wish to debug both. You can enable this using `localStorage.debug`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
localStorage.debug = 'worker:*'
|
||||||
|
```
|
||||||
|
|
||||||
|
And then refresh the page.
|
||||||
|
|
||||||
|
```js
|
||||||
|
a = debug('worker:a');
|
||||||
|
b = debug('worker:b');
|
||||||
|
|
||||||
|
setInterval(function(){
|
||||||
|
a('doing some work');
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
setInterval(function(){
|
||||||
|
b('doing some work');
|
||||||
|
}, 1200);
|
||||||
|
```
|
||||||
|
|
||||||
|
In Chromium-based web browsers (e.g. Brave, Chrome, and Electron), the JavaScript console will—by default—only show messages logged by `debug` if the "Verbose" log level is _enabled_.
|
||||||
|
|
||||||
|
<img width="647" src="https://user-images.githubusercontent.com/7143133/152083257-29034707-c42c-4959-8add-3cee850e6fcf.png">
|
||||||
|
|
||||||
|
## Output streams
|
||||||
|
|
||||||
|
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
||||||
|
|
||||||
|
Example [_stdout.js_](./examples/node/stdout.js):
|
||||||
|
|
||||||
|
```js
|
||||||
|
var debug = require('debug');
|
||||||
|
var error = debug('app:error');
|
||||||
|
|
||||||
|
// by default stderr is used
|
||||||
|
error('goes to stderr!');
|
||||||
|
|
||||||
|
var log = debug('app:log');
|
||||||
|
// set this namespace to log via console.log
|
||||||
|
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||||
|
log('goes to stdout');
|
||||||
|
error('still goes to stderr!');
|
||||||
|
|
||||||
|
// set all output to go via console.info
|
||||||
|
// overrides all per-namespace log settings
|
||||||
|
debug.log = console.info.bind(console);
|
||||||
|
error('now goes to stdout via console.info');
|
||||||
|
log('still goes to stdout, but via console.info now');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Extend
|
||||||
|
You can simply extend debugger
|
||||||
|
```js
|
||||||
|
const log = require('debug')('auth');
|
||||||
|
|
||||||
|
//creates new debug instance with extended namespace
|
||||||
|
const logSign = log.extend('sign');
|
||||||
|
const logLogin = log.extend('login');
|
||||||
|
|
||||||
|
log('hello'); // auth hello
|
||||||
|
logSign('hello'); //auth:sign hello
|
||||||
|
logLogin('hello'); //auth:login hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set dynamically
|
||||||
|
|
||||||
|
You can also enable debug dynamically by calling the `enable()` method :
|
||||||
|
|
||||||
|
```js
|
||||||
|
let debug = require('debug');
|
||||||
|
|
||||||
|
console.log(1, debug.enabled('test'));
|
||||||
|
|
||||||
|
debug.enable('test');
|
||||||
|
console.log(2, debug.enabled('test'));
|
||||||
|
|
||||||
|
debug.disable();
|
||||||
|
console.log(3, debug.enabled('test'));
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
print :
|
||||||
|
```
|
||||||
|
1 false
|
||||||
|
2 true
|
||||||
|
3 false
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage :
|
||||||
|
`enable(namespaces)`
|
||||||
|
`namespaces` can include modes separated by a colon and wildcards.
|
||||||
|
|
||||||
|
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
||||||
|
|
||||||
|
```
|
||||||
|
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
||||||
|
=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
`disable()`
|
||||||
|
|
||||||
|
Will disable all namespaces. The functions returns the namespaces currently
|
||||||
|
enabled (and skipped). This can be useful if you want to disable debugging
|
||||||
|
temporarily without knowing what was enabled to begin with.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
let debug = require('debug');
|
||||||
|
debug.enable('foo:*,-foo:bar');
|
||||||
|
let namespaces = debug.disable();
|
||||||
|
debug.enable(namespaces);
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: There is no guarantee that the string will be identical to the initial
|
||||||
|
enable string, but semantically they will be identical.
|
||||||
|
|
||||||
|
## Checking whether a debug target is enabled
|
||||||
|
|
||||||
|
After you've created a debug instance, you can determine whether or not it is
|
||||||
|
enabled by checking the `enabled` property:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const debug = require('debug')('http');
|
||||||
|
|
||||||
|
if (debug.enabled) {
|
||||||
|
// do stuff...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also manually toggle this property to force the debug instance to be
|
||||||
|
enabled or disabled.
|
||||||
|
|
||||||
|
## Usage in child processes
|
||||||
|
|
||||||
|
Due to the way `debug` detects if the output is a TTY or not, colors are not shown in child processes when `stderr` is piped. A solution is to pass the `DEBUG_COLORS=1` environment variable to the child process.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
worker = fork(WORKER_WRAP_PATH, [workerPath], {
|
||||||
|
stdio: [
|
||||||
|
/* stdin: */ 0,
|
||||||
|
/* stdout: */ 'pipe',
|
||||||
|
/* stderr: */ 'pipe',
|
||||||
|
'ipc',
|
||||||
|
],
|
||||||
|
env: Object.assign({}, process.env, {
|
||||||
|
DEBUG_COLORS: 1 // without this settings, colors won't be shown
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
worker.stderr.pipe(process.stderr, { end: false });
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
- TJ Holowaychuk
|
||||||
|
- Nathan Rajlich
|
||||||
|
- Andrew Rhyne
|
||||||
|
- Josh Junon
|
||||||
|
|
||||||
|
## Backers
|
||||||
|
|
||||||
|
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
||||||
|
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
Copyright (c) 2018-2021 Josh Junon
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
60
node_modules/agent-base/node_modules/debug/package.json
generated
vendored
Normal file
60
node_modules/agent-base/node_modules/debug/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"name": "debug",
|
||||||
|
"version": "4.3.7",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/debug-js/debug.git"
|
||||||
|
},
|
||||||
|
"description": "Lightweight debugging utility for Node.js and the browser",
|
||||||
|
"keywords": [
|
||||||
|
"debug",
|
||||||
|
"log",
|
||||||
|
"debugger"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"LICENSE",
|
||||||
|
"README.md"
|
||||||
|
],
|
||||||
|
"author": "Josh Junon (https://github.com/qix-)",
|
||||||
|
"contributors": [
|
||||||
|
"TJ Holowaychuk <tj@vision-media.ca>",
|
||||||
|
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)",
|
||||||
|
"Andrew Rhyne <rhyneandrew@gmail.com>"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"lint": "xo",
|
||||||
|
"test": "npm run test:node && npm run test:browser && npm run lint",
|
||||||
|
"test:node": "istanbul cover _mocha -- test.js test.node.js",
|
||||||
|
"test:browser": "karma start --single-run",
|
||||||
|
"test:coverage": "cat ./coverage/lcov.info | coveralls"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "^2.1.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"brfs": "^2.0.1",
|
||||||
|
"browserify": "^16.2.3",
|
||||||
|
"coveralls": "^3.0.2",
|
||||||
|
"istanbul": "^0.4.5",
|
||||||
|
"karma": "^3.1.4",
|
||||||
|
"karma-browserify": "^6.0.0",
|
||||||
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
|
"karma-mocha": "^1.3.0",
|
||||||
|
"mocha": "^5.2.0",
|
||||||
|
"mocha-lcov-reporter": "^1.2.0",
|
||||||
|
"sinon": "^14.0.0",
|
||||||
|
"xo": "^0.23.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"supports-color": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"main": "./src/index.js",
|
||||||
|
"browser": "./src/browser.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
271
node_modules/agent-base/node_modules/debug/src/browser.js
generated
vendored
Normal file
271
node_modules/agent-base/node_modules/debug/src/browser.js
generated
vendored
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
/* eslint-env browser */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the web browser implementation of `debug()`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.formatArgs = formatArgs;
|
||||||
|
exports.save = save;
|
||||||
|
exports.load = load;
|
||||||
|
exports.useColors = useColors;
|
||||||
|
exports.storage = localstorage();
|
||||||
|
exports.destroy = (() => {
|
||||||
|
let warned = false;
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (!warned) {
|
||||||
|
warned = true;
|
||||||
|
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.colors = [
|
||||||
|
'#0000CC',
|
||||||
|
'#0000FF',
|
||||||
|
'#0033CC',
|
||||||
|
'#0033FF',
|
||||||
|
'#0066CC',
|
||||||
|
'#0066FF',
|
||||||
|
'#0099CC',
|
||||||
|
'#0099FF',
|
||||||
|
'#00CC00',
|
||||||
|
'#00CC33',
|
||||||
|
'#00CC66',
|
||||||
|
'#00CC99',
|
||||||
|
'#00CCCC',
|
||||||
|
'#00CCFF',
|
||||||
|
'#3300CC',
|
||||||
|
'#3300FF',
|
||||||
|
'#3333CC',
|
||||||
|
'#3333FF',
|
||||||
|
'#3366CC',
|
||||||
|
'#3366FF',
|
||||||
|
'#3399CC',
|
||||||
|
'#3399FF',
|
||||||
|
'#33CC00',
|
||||||
|
'#33CC33',
|
||||||
|
'#33CC66',
|
||||||
|
'#33CC99',
|
||||||
|
'#33CCCC',
|
||||||
|
'#33CCFF',
|
||||||
|
'#6600CC',
|
||||||
|
'#6600FF',
|
||||||
|
'#6633CC',
|
||||||
|
'#6633FF',
|
||||||
|
'#66CC00',
|
||||||
|
'#66CC33',
|
||||||
|
'#9900CC',
|
||||||
|
'#9900FF',
|
||||||
|
'#9933CC',
|
||||||
|
'#9933FF',
|
||||||
|
'#99CC00',
|
||||||
|
'#99CC33',
|
||||||
|
'#CC0000',
|
||||||
|
'#CC0033',
|
||||||
|
'#CC0066',
|
||||||
|
'#CC0099',
|
||||||
|
'#CC00CC',
|
||||||
|
'#CC00FF',
|
||||||
|
'#CC3300',
|
||||||
|
'#CC3333',
|
||||||
|
'#CC3366',
|
||||||
|
'#CC3399',
|
||||||
|
'#CC33CC',
|
||||||
|
'#CC33FF',
|
||||||
|
'#CC6600',
|
||||||
|
'#CC6633',
|
||||||
|
'#CC9900',
|
||||||
|
'#CC9933',
|
||||||
|
'#CCCC00',
|
||||||
|
'#CCCC33',
|
||||||
|
'#FF0000',
|
||||||
|
'#FF0033',
|
||||||
|
'#FF0066',
|
||||||
|
'#FF0099',
|
||||||
|
'#FF00CC',
|
||||||
|
'#FF00FF',
|
||||||
|
'#FF3300',
|
||||||
|
'#FF3333',
|
||||||
|
'#FF3366',
|
||||||
|
'#FF3399',
|
||||||
|
'#FF33CC',
|
||||||
|
'#FF33FF',
|
||||||
|
'#FF6600',
|
||||||
|
'#FF6633',
|
||||||
|
'#FF9900',
|
||||||
|
'#FF9933',
|
||||||
|
'#FFCC00',
|
||||||
|
'#FFCC33'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line complexity
|
||||||
|
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' || window.process.__nwjs)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Internet Explorer and Edge do not support colors.
|
||||||
|
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let m;
|
||||||
|
|
||||||
|
// 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 && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[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+)/));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colorize log arguments if enabled.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formatArgs(args) {
|
||||||
|
args[0] = (this.useColors ? '%c' : '') +
|
||||||
|
this.namespace +
|
||||||
|
(this.useColors ? ' %c' : ' ') +
|
||||||
|
args[0] +
|
||||||
|
(this.useColors ? '%c ' : ' ') +
|
||||||
|
'+' + module.exports.humanize(this.diff);
|
||||||
|
|
||||||
|
if (!this.useColors) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const 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
|
||||||
|
let index = 0;
|
||||||
|
let lastC = 0;
|
||||||
|
args[0].replace(/%[a-zA-Z%]/g, match => {
|
||||||
|
if (match === '%%') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
if (match === '%c') {
|
||||||
|
// We only are interested in the *last* %c
|
||||||
|
// (the user may have provided their own)
|
||||||
|
lastC = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
args.splice(lastC, 0, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes `console.debug()` when available.
|
||||||
|
* No-op when `console.debug` is not a "function".
|
||||||
|
* If `console.debug` is not available, falls back
|
||||||
|
* to `console.log`.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
exports.log = console.debug || console.log || (() => {});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save `namespaces`.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function save(namespaces) {
|
||||||
|
try {
|
||||||
|
if (namespaces) {
|
||||||
|
exports.storage.setItem('debug', namespaces);
|
||||||
|
} else {
|
||||||
|
exports.storage.removeItem('debug');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load `namespaces`.
|
||||||
|
*
|
||||||
|
* @return {String} returns the previously persisted debug modes
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function load() {
|
||||||
|
let r;
|
||||||
|
try {
|
||||||
|
r = exports.storage.getItem('debug');
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
||||||
|
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||||
|
// The Browser also has localStorage in the global context.
|
||||||
|
return localStorage;
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = require('./common')(exports);
|
||||||
|
|
||||||
|
const {formatters} = module.exports;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||||
|
*/
|
||||||
|
|
||||||
|
formatters.j = function (v) {
|
||||||
|
try {
|
||||||
|
return JSON.stringify(v);
|
||||||
|
} catch (error) {
|
||||||
|
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
274
node_modules/agent-base/node_modules/debug/src/common.js
generated
vendored
Normal file
274
node_modules/agent-base/node_modules/debug/src/common.js
generated
vendored
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* This is the common logic for both the Node.js and web browser
|
||||||
|
* implementations of `debug()`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function setup(env) {
|
||||||
|
createDebug.debug = createDebug;
|
||||||
|
createDebug.default = createDebug;
|
||||||
|
createDebug.coerce = coerce;
|
||||||
|
createDebug.disable = disable;
|
||||||
|
createDebug.enable = enable;
|
||||||
|
createDebug.enabled = enabled;
|
||||||
|
createDebug.humanize = require('ms');
|
||||||
|
createDebug.destroy = destroy;
|
||||||
|
|
||||||
|
Object.keys(env).forEach(key => {
|
||||||
|
createDebug[key] = env[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The currently active debug mode names, and names to skip.
|
||||||
|
*/
|
||||||
|
|
||||||
|
createDebug.names = [];
|
||||||
|
createDebug.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".
|
||||||
|
*/
|
||||||
|
createDebug.formatters = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects a color for a debug namespace
|
||||||
|
* @param {String} namespace The namespace string for the debug instance to be colored
|
||||||
|
* @return {Number|String} An ANSI color code for the given namespace
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function selectColor(namespace) {
|
||||||
|
let hash = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < namespace.length; i++) {
|
||||||
|
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
||||||
|
hash |= 0; // Convert to 32bit integer
|
||||||
|
}
|
||||||
|
|
||||||
|
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||||
|
}
|
||||||
|
createDebug.selectColor = selectColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a debugger with the given `namespace`.
|
||||||
|
*
|
||||||
|
* @param {String} namespace
|
||||||
|
* @return {Function}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function createDebug(namespace) {
|
||||||
|
let prevTime;
|
||||||
|
let enableOverride = null;
|
||||||
|
let namespacesCache;
|
||||||
|
let enabledCache;
|
||||||
|
|
||||||
|
function debug(...args) {
|
||||||
|
// Disabled?
|
||||||
|
if (!debug.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const self = debug;
|
||||||
|
|
||||||
|
// Set `diff` timestamp
|
||||||
|
const curr = Number(new Date());
|
||||||
|
const ms = curr - (prevTime || curr);
|
||||||
|
self.diff = ms;
|
||||||
|
self.prev = prevTime;
|
||||||
|
self.curr = curr;
|
||||||
|
prevTime = curr;
|
||||||
|
|
||||||
|
args[0] = createDebug.coerce(args[0]);
|
||||||
|
|
||||||
|
if (typeof args[0] !== 'string') {
|
||||||
|
// Anything else let's inspect with %O
|
||||||
|
args.unshift('%O');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply any `formatters` transformations
|
||||||
|
let index = 0;
|
||||||
|
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||||||
|
// If we encounter an escaped % then don't increase the array index
|
||||||
|
if (match === '%%') {
|
||||||
|
return '%';
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
const formatter = createDebug.formatters[format];
|
||||||
|
if (typeof formatter === 'function') {
|
||||||
|
const 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.)
|
||||||
|
createDebug.formatArgs.call(self, args);
|
||||||
|
|
||||||
|
const logFn = self.log || createDebug.log;
|
||||||
|
logFn.apply(self, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug.namespace = namespace;
|
||||||
|
debug.useColors = createDebug.useColors();
|
||||||
|
debug.color = createDebug.selectColor(namespace);
|
||||||
|
debug.extend = extend;
|
||||||
|
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
||||||
|
|
||||||
|
Object.defineProperty(debug, 'enabled', {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: false,
|
||||||
|
get: () => {
|
||||||
|
if (enableOverride !== null) {
|
||||||
|
return enableOverride;
|
||||||
|
}
|
||||||
|
if (namespacesCache !== createDebug.namespaces) {
|
||||||
|
namespacesCache = createDebug.namespaces;
|
||||||
|
enabledCache = createDebug.enabled(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return enabledCache;
|
||||||
|
},
|
||||||
|
set: v => {
|
||||||
|
enableOverride = v;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Env-specific initialization logic for debug instances
|
||||||
|
if (typeof createDebug.init === 'function') {
|
||||||
|
createDebug.init(debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extend(namespace, delimiter) {
|
||||||
|
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||||
|
newDebug.log = this.log;
|
||||||
|
return newDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables a debug mode by namespaces. This can include modes
|
||||||
|
* separated by a colon and wildcards.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function enable(namespaces) {
|
||||||
|
createDebug.save(namespaces);
|
||||||
|
createDebug.namespaces = namespaces;
|
||||||
|
|
||||||
|
createDebug.names = [];
|
||||||
|
createDebug.skips = [];
|
||||||
|
|
||||||
|
let i;
|
||||||
|
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||||
|
const len = split.length;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (!split[i]) {
|
||||||
|
// ignore empty strings
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespaces = split[i].replace(/\*/g, '.*?');
|
||||||
|
|
||||||
|
if (namespaces[0] === '-') {
|
||||||
|
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
||||||
|
} else {
|
||||||
|
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable debug output.
|
||||||
|
*
|
||||||
|
* @return {String} namespaces
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function disable() {
|
||||||
|
const namespaces = [
|
||||||
|
...createDebug.names.map(toNamespace),
|
||||||
|
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||||
|
].join(',');
|
||||||
|
createDebug.enable('');
|
||||||
|
return namespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given mode name is enabled, false otherwise.
|
||||||
|
*
|
||||||
|
* @param {String} name
|
||||||
|
* @return {Boolean}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function enabled(name) {
|
||||||
|
if (name[name.length - 1] === '*') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let i;
|
||||||
|
let len;
|
||||||
|
|
||||||
|
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||||
|
if (createDebug.skips[i].test(name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||||
|
if (createDebug.names[i].test(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert regexp to namespace
|
||||||
|
*
|
||||||
|
* @param {RegExp} regxep
|
||||||
|
* @return {String} namespace
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function toNamespace(regexp) {
|
||||||
|
return regexp.toString()
|
||||||
|
.substring(2, regexp.toString().length - 2)
|
||||||
|
.replace(/\.\*\?$/, '*');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coerce `val`.
|
||||||
|
*
|
||||||
|
* @param {Mixed} val
|
||||||
|
* @return {Mixed}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function coerce(val) {
|
||||||
|
if (val instanceof Error) {
|
||||||
|
return val.stack || val.message;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XXX DO NOT USE. This is a temporary stub function.
|
||||||
|
* XXX It WILL be removed in the next major release.
|
||||||
|
*/
|
||||||
|
function destroy() {
|
||||||
|
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||||
|
}
|
||||||
|
|
||||||
|
createDebug.enable(createDebug.load());
|
||||||
|
|
||||||
|
return createDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = setup;
|
||||||
10
node_modules/agent-base/node_modules/debug/src/index.js
generated
vendored
Normal file
10
node_modules/agent-base/node_modules/debug/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Detect Electron renderer / nwjs process, which is node, but we should
|
||||||
|
* treat as a browser.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||||
|
module.exports = require('./browser.js');
|
||||||
|
} else {
|
||||||
|
module.exports = require('./node.js');
|
||||||
|
}
|
||||||
263
node_modules/agent-base/node_modules/debug/src/node.js
generated
vendored
Normal file
263
node_modules/agent-base/node_modules/debug/src/node.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const tty = require('tty');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Node.js implementation of `debug()`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.init = init;
|
||||||
|
exports.log = log;
|
||||||
|
exports.formatArgs = formatArgs;
|
||||||
|
exports.save = save;
|
||||||
|
exports.load = load;
|
||||||
|
exports.useColors = useColors;
|
||||||
|
exports.destroy = util.deprecate(
|
||||||
|
() => {},
|
||||||
|
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
const supportsColor = require('supports-color');
|
||||||
|
|
||||||
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||||||
|
exports.colors = [
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40,
|
||||||
|
41,
|
||||||
|
42,
|
||||||
|
43,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
56,
|
||||||
|
57,
|
||||||
|
62,
|
||||||
|
63,
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
74,
|
||||||
|
75,
|
||||||
|
76,
|
||||||
|
77,
|
||||||
|
78,
|
||||||
|
79,
|
||||||
|
80,
|
||||||
|
81,
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
98,
|
||||||
|
99,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
128,
|
||||||
|
129,
|
||||||
|
134,
|
||||||
|
135,
|
||||||
|
148,
|
||||||
|
149,
|
||||||
|
160,
|
||||||
|
161,
|
||||||
|
162,
|
||||||
|
163,
|
||||||
|
164,
|
||||||
|
165,
|
||||||
|
166,
|
||||||
|
167,
|
||||||
|
168,
|
||||||
|
169,
|
||||||
|
170,
|
||||||
|
171,
|
||||||
|
172,
|
||||||
|
173,
|
||||||
|
178,
|
||||||
|
179,
|
||||||
|
184,
|
||||||
|
185,
|
||||||
|
196,
|
||||||
|
197,
|
||||||
|
198,
|
||||||
|
199,
|
||||||
|
200,
|
||||||
|
201,
|
||||||
|
202,
|
||||||
|
203,
|
||||||
|
204,
|
||||||
|
205,
|
||||||
|
206,
|
||||||
|
207,
|
||||||
|
208,
|
||||||
|
209,
|
||||||
|
214,
|
||||||
|
215,
|
||||||
|
220,
|
||||||
|
221
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(key => {
|
||||||
|
return /^debug_/i.test(key);
|
||||||
|
}).reduce((obj, key) => {
|
||||||
|
// Camel-case
|
||||||
|
const prop = key
|
||||||
|
.substring(6)
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/_([a-z])/g, (_, k) => {
|
||||||
|
return k.toUpperCase();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Coerce string value into JS value
|
||||||
|
let 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;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function useColors() {
|
||||||
|
return 'colors' in exports.inspectOpts ?
|
||||||
|
Boolean(exports.inspectOpts.colors) :
|
||||||
|
tty.isatty(process.stderr.fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds ANSI color escape codes if enabled.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formatArgs(args) {
|
||||||
|
const {namespace: name, useColors} = this;
|
||||||
|
|
||||||
|
if (useColors) {
|
||||||
|
const c = this.color;
|
||||||
|
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
||||||
|
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
||||||
|
|
||||||
|
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||||||
|
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
||||||
|
} else {
|
||||||
|
args[0] = getDate() + name + ' ' + args[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDate() {
|
||||||
|
if (exports.inspectOpts.hideDate) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return new Date().toISOString() + ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function log(...args) {
|
||||||
|
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save `namespaces`.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function save(namespaces) {
|
||||||
|
if (namespaces) {
|
||||||
|
process.env.DEBUG = namespaces;
|
||||||
|
} else {
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load `namespaces`.
|
||||||
|
*
|
||||||
|
* @return {String} returns the previously persisted debug modes
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
return process.env.DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = {};
|
||||||
|
|
||||||
|
const keys = Object.keys(exports.inspectOpts);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = require('./common')(exports);
|
||||||
|
|
||||||
|
const {formatters} = module.exports;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map %o to `util.inspect()`, all on a single line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
formatters.o = function (v) {
|
||||||
|
this.inspectOpts.colors = this.useColors;
|
||||||
|
return util.inspect(v, this.inspectOpts)
|
||||||
|
.split('\n')
|
||||||
|
.map(str => str.trim())
|
||||||
|
.join(' ');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
formatters.O = function (v) {
|
||||||
|
this.inspectOpts.colors = this.useColors;
|
||||||
|
return util.inspect(v, this.inspectOpts);
|
||||||
|
};
|
||||||
162
node_modules/agent-base/node_modules/ms/index.js
generated
vendored
Normal file
162
node_modules/agent-base/node_modules/ms/index.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/**
|
||||||
|
* Helpers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var s = 1000;
|
||||||
|
var m = s * 60;
|
||||||
|
var h = m * 60;
|
||||||
|
var d = h * 24;
|
||||||
|
var w = d * 7;
|
||||||
|
var y = d * 365.25;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse or format the given `val`.
|
||||||
|
*
|
||||||
|
* Options:
|
||||||
|
*
|
||||||
|
* - `long` verbose formatting [false]
|
||||||
|
*
|
||||||
|
* @param {String|Number} val
|
||||||
|
* @param {Object} [options]
|
||||||
|
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||||
|
* @return {String|Number}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = function (val, options) {
|
||||||
|
options = options || {};
|
||||||
|
var type = typeof val;
|
||||||
|
if (type === 'string' && val.length > 0) {
|
||||||
|
return parse(val);
|
||||||
|
} else if (type === 'number' && isFinite(val)) {
|
||||||
|
return options.long ? fmtLong(val) : fmtShort(val);
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
'val is not a non-empty string or a valid number. val=' +
|
||||||
|
JSON.stringify(val)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the given `str` and return milliseconds.
|
||||||
|
*
|
||||||
|
* @param {String} str
|
||||||
|
* @return {Number}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function parse(str) {
|
||||||
|
str = String(str);
|
||||||
|
if (str.length > 100) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||||
|
str
|
||||||
|
);
|
||||||
|
if (!match) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var n = parseFloat(match[1]);
|
||||||
|
var type = (match[2] || 'ms').toLowerCase();
|
||||||
|
switch (type) {
|
||||||
|
case 'years':
|
||||||
|
case 'year':
|
||||||
|
case 'yrs':
|
||||||
|
case 'yr':
|
||||||
|
case 'y':
|
||||||
|
return n * y;
|
||||||
|
case 'weeks':
|
||||||
|
case 'week':
|
||||||
|
case 'w':
|
||||||
|
return n * w;
|
||||||
|
case 'days':
|
||||||
|
case 'day':
|
||||||
|
case 'd':
|
||||||
|
return n * d;
|
||||||
|
case 'hours':
|
||||||
|
case 'hour':
|
||||||
|
case 'hrs':
|
||||||
|
case 'hr':
|
||||||
|
case 'h':
|
||||||
|
return n * h;
|
||||||
|
case 'minutes':
|
||||||
|
case 'minute':
|
||||||
|
case 'mins':
|
||||||
|
case 'min':
|
||||||
|
case 'm':
|
||||||
|
return n * m;
|
||||||
|
case 'seconds':
|
||||||
|
case 'second':
|
||||||
|
case 'secs':
|
||||||
|
case 'sec':
|
||||||
|
case 's':
|
||||||
|
return n * s;
|
||||||
|
case 'milliseconds':
|
||||||
|
case 'millisecond':
|
||||||
|
case 'msecs':
|
||||||
|
case 'msec':
|
||||||
|
case 'ms':
|
||||||
|
return n;
|
||||||
|
default:
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Short format for `ms`.
|
||||||
|
*
|
||||||
|
* @param {Number} ms
|
||||||
|
* @return {String}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function fmtShort(ms) {
|
||||||
|
var msAbs = Math.abs(ms);
|
||||||
|
if (msAbs >= d) {
|
||||||
|
return Math.round(ms / d) + 'd';
|
||||||
|
}
|
||||||
|
if (msAbs >= h) {
|
||||||
|
return Math.round(ms / h) + 'h';
|
||||||
|
}
|
||||||
|
if (msAbs >= m) {
|
||||||
|
return Math.round(ms / m) + 'm';
|
||||||
|
}
|
||||||
|
if (msAbs >= s) {
|
||||||
|
return Math.round(ms / s) + 's';
|
||||||
|
}
|
||||||
|
return ms + 'ms';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Long format for `ms`.
|
||||||
|
*
|
||||||
|
* @param {Number} ms
|
||||||
|
* @return {String}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function fmtLong(ms) {
|
||||||
|
var msAbs = Math.abs(ms);
|
||||||
|
if (msAbs >= d) {
|
||||||
|
return plural(ms, msAbs, d, 'day');
|
||||||
|
}
|
||||||
|
if (msAbs >= h) {
|
||||||
|
return plural(ms, msAbs, h, 'hour');
|
||||||
|
}
|
||||||
|
if (msAbs >= m) {
|
||||||
|
return plural(ms, msAbs, m, 'minute');
|
||||||
|
}
|
||||||
|
if (msAbs >= s) {
|
||||||
|
return plural(ms, msAbs, s, 'second');
|
||||||
|
}
|
||||||
|
return ms + ' ms';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pluralization helper.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function plural(ms, msAbs, n, name) {
|
||||||
|
var isPlural = msAbs >= n * 1.5;
|
||||||
|
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||||
|
}
|
||||||
21
node_modules/agent-base/node_modules/ms/license.md
generated
vendored
Normal file
21
node_modules/agent-base/node_modules/ms/license.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2020 Vercel, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
38
node_modules/agent-base/node_modules/ms/package.json
generated
vendored
Normal file
38
node_modules/agent-base/node_modules/ms/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"name": "ms",
|
||||||
|
"version": "2.1.3",
|
||||||
|
"description": "Tiny millisecond conversion utility",
|
||||||
|
"repository": "vercel/ms",
|
||||||
|
"main": "./index",
|
||||||
|
"files": [
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"precommit": "lint-staged",
|
||||||
|
"lint": "eslint lib/* bin/*",
|
||||||
|
"test": "mocha tests.js"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es6": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.js": [
|
||||||
|
"npm run lint",
|
||||||
|
"prettier --single-quote --write",
|
||||||
|
"git add"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "4.18.2",
|
||||||
|
"expect.js": "0.3.1",
|
||||||
|
"husky": "0.14.3",
|
||||||
|
"lint-staged": "5.0.0",
|
||||||
|
"mocha": "4.0.1",
|
||||||
|
"prettier": "2.0.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
59
node_modules/agent-base/node_modules/ms/readme.md
generated
vendored
Normal file
59
node_modules/agent-base/node_modules/ms/readme.md
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# ms
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Use this package to easily convert various time formats to milliseconds.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```js
|
||||||
|
ms('2 days') // 172800000
|
||||||
|
ms('1d') // 86400000
|
||||||
|
ms('10h') // 36000000
|
||||||
|
ms('2.5 hrs') // 9000000
|
||||||
|
ms('2h') // 7200000
|
||||||
|
ms('1m') // 60000
|
||||||
|
ms('5s') // 5000
|
||||||
|
ms('1y') // 31557600000
|
||||||
|
ms('100') // 100
|
||||||
|
ms('-3 days') // -259200000
|
||||||
|
ms('-1h') // -3600000
|
||||||
|
ms('-200') // -200
|
||||||
|
```
|
||||||
|
|
||||||
|
### Convert from Milliseconds
|
||||||
|
|
||||||
|
```js
|
||||||
|
ms(60000) // "1m"
|
||||||
|
ms(2 * 60000) // "2m"
|
||||||
|
ms(-3 * 60000) // "-3m"
|
||||||
|
ms(ms('10 hours')) // "10h"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Time Format Written-Out
|
||||||
|
|
||||||
|
```js
|
||||||
|
ms(60000, { long: true }) // "1 minute"
|
||||||
|
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||||
|
ms(-3 * 60000, { long: true }) // "-3 minutes"
|
||||||
|
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Works both in [Node.js](https://nodejs.org) and in the browser
|
||||||
|
- If a number is supplied to `ms`, a string with a unit is returned
|
||||||
|
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
|
||||||
|
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
|
||||||
|
|
||||||
|
## Related Packages
|
||||||
|
|
||||||
|
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
|
||||||
|
|
||||||
|
## Caught a Bug?
|
||||||
|
|
||||||
|
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||||
|
2. Link the package to the global module directory: `npm link`
|
||||||
|
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
|
||||||
|
|
||||||
|
As always, you can run the tests using: `npm test`
|
||||||
49
node_modules/agent-base/package.json
generated
vendored
Normal file
49
node_modules/agent-base/package.json
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"name": "agent-base",
|
||||||
|
"version": "7.1.1",
|
||||||
|
"description": "Turn a function into an `http.Agent` instance",
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/TooTallNate/proxy-agents.git",
|
||||||
|
"directory": "packages/agent-base"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"agent",
|
||||||
|
"base",
|
||||||
|
"barebones",
|
||||||
|
"https"
|
||||||
|
],
|
||||||
|
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "^4.3.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/debug": "^4.1.7",
|
||||||
|
"@types/jest": "^29.5.1",
|
||||||
|
"@types/node": "^14.18.45",
|
||||||
|
"@types/semver": "^7.3.13",
|
||||||
|
"@types/ws": "^6.0.4",
|
||||||
|
"async-listen": "^3.0.0",
|
||||||
|
"jest": "^29.5.0",
|
||||||
|
"ts-jest": "^29.1.0",
|
||||||
|
"typescript": "^5.0.4",
|
||||||
|
"ws": "^3.3.3",
|
||||||
|
"tsconfig": "0.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 14"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"test": "jest --env node --verbose --bail",
|
||||||
|
"lint": "eslint . --ext .ts",
|
||||||
|
"pack": "node ../../scripts/pack.mjs"
|
||||||
|
}
|
||||||
|
}
|
||||||
21
node_modules/array-flatten/LICENSE
generated
vendored
Normal file
21
node_modules/array-flatten/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
43
node_modules/array-flatten/README.md
generated
vendored
Normal file
43
node_modules/array-flatten/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Array Flatten
|
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url]
|
||||||
|
[![NPM downloads][downloads-image]][downloads-url]
|
||||||
|
[![Build status][travis-image]][travis-url]
|
||||||
|
[![Test coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install array-flatten --save
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var flatten = require('array-flatten')
|
||||||
|
|
||||||
|
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
|
||||||
|
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
|
||||||
|
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
|
||||||
|
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
flatten(arguments) //=> [1, 2, 3]
|
||||||
|
})(1, [2, 3])
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
|
||||||
|
[npm-url]: https://npmjs.org/package/array-flatten
|
||||||
|
[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
|
||||||
|
[downloads-url]: https://npmjs.org/package/array-flatten
|
||||||
|
[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
|
||||||
|
[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
|
||||||
|
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
|
||||||
|
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
|
||||||
64
node_modules/array-flatten/array-flatten.js
generated
vendored
Normal file
64
node_modules/array-flatten/array-flatten.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
'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)
|
||||||
|
}
|
||||||
39
node_modules/array-flatten/package.json
generated
vendored
Normal file
39
node_modules/array-flatten/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "array-flatten",
|
||||||
|
"version": "1.1.1",
|
||||||
|
"description": "Flatten an array of nested arrays into a single flat array",
|
||||||
|
"main": "array-flatten.js",
|
||||||
|
"files": [
|
||||||
|
"array-flatten.js",
|
||||||
|
"LICENSE"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "istanbul cover _mocha -- -R spec"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/blakeembrey/array-flatten.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"array",
|
||||||
|
"flatten",
|
||||||
|
"arguments",
|
||||||
|
"depth"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Blake Embrey",
|
||||||
|
"email": "hello@blakeembrey.com",
|
||||||
|
"url": "http://blakeembrey.me"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/blakeembrey/array-flatten/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/blakeembrey/array-flatten",
|
||||||
|
"devDependencies": {
|
||||||
|
"istanbul": "^0.3.13",
|
||||||
|
"mocha": "^2.2.4",
|
||||||
|
"pre-commit": "^1.0.7",
|
||||||
|
"standard": "^3.7.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
27
node_modules/asn1.js/.eslintrc.js
generated
vendored
Normal file
27
node_modules/asn1.js/.eslintrc.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
module.exports = {
|
||||||
|
'env': {
|
||||||
|
'browser': false,
|
||||||
|
'commonjs': true,
|
||||||
|
'es6': true,
|
||||||
|
'node': true
|
||||||
|
},
|
||||||
|
'extends': 'eslint:recommended',
|
||||||
|
'rules': {
|
||||||
|
'indent': [
|
||||||
|
'error',
|
||||||
|
2
|
||||||
|
],
|
||||||
|
'linebreak-style': [
|
||||||
|
'error',
|
||||||
|
'unix'
|
||||||
|
],
|
||||||
|
'quotes': [
|
||||||
|
'error',
|
||||||
|
'single'
|
||||||
|
],
|
||||||
|
'semi': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
21
node_modules/asn1.js/LICENSE
generated
vendored
Normal file
21
node_modules/asn1.js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 Fedor Indutny
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
100
node_modules/asn1.js/README.md
generated
vendored
Normal file
100
node_modules/asn1.js/README.md
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
# ASN1.js
|
||||||
|
|
||||||
|
ASN.1 DER Encoder/Decoder and DSL.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Define model:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var asn = require('asn1.js');
|
||||||
|
|
||||||
|
var Human = asn.define('Human', function() {
|
||||||
|
this.seq().obj(
|
||||||
|
this.key('firstName').octstr(),
|
||||||
|
this.key('lastName').octstr(),
|
||||||
|
this.key('age').int(),
|
||||||
|
this.key('gender').enum({ 0: 'male', 1: 'female' }),
|
||||||
|
this.key('bio').seqof(Bio)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
var Bio = asn.define('Bio', function() {
|
||||||
|
this.seq().obj(
|
||||||
|
this.key('time').gentime(),
|
||||||
|
this.key('description').octstr()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Encode data:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var output = Human.encode({
|
||||||
|
firstName: 'Thomas',
|
||||||
|
lastName: 'Anderson',
|
||||||
|
age: 28,
|
||||||
|
gender: 'male',
|
||||||
|
bio: [
|
||||||
|
{
|
||||||
|
time: +new Date('31 March 1999'),
|
||||||
|
description: 'freedom of mind'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, 'der');
|
||||||
|
```
|
||||||
|
|
||||||
|
Decode data:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var human = Human.decode(output, 'der');
|
||||||
|
console.log(human);
|
||||||
|
/*
|
||||||
|
{ firstName: <Buffer 54 68 6f 6d 61 73>,
|
||||||
|
lastName: <Buffer 41 6e 64 65 72 73 6f 6e>,
|
||||||
|
age: 28,
|
||||||
|
gender: 'male',
|
||||||
|
bio:
|
||||||
|
[ { time: 922820400000,
|
||||||
|
description: <Buffer 66 72 65 65 64 6f 6d 20 6f 66 20 6d 69 6e 64> } ] }
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Partial decode
|
||||||
|
|
||||||
|
Its possible to parse data without stopping on first error. In order to do it,
|
||||||
|
you should call:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var human = Human.decode(output, 'der', { partial: true });
|
||||||
|
console.log(human);
|
||||||
|
/*
|
||||||
|
{ result: { ... },
|
||||||
|
errors: [ ... ] }
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
#### LICENSE
|
||||||
|
|
||||||
|
This software is licensed under the MIT License.
|
||||||
|
|
||||||
|
Copyright Fedor Indutny, 2017.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
11
node_modules/asn1.js/lib/asn1.js
generated
vendored
Normal file
11
node_modules/asn1.js/lib/asn1.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const asn1 = exports;
|
||||||
|
|
||||||
|
asn1.bignum = require('bn.js');
|
||||||
|
|
||||||
|
asn1.define = require('./asn1/api').define;
|
||||||
|
asn1.base = require('./asn1/base');
|
||||||
|
asn1.constants = require('./asn1/constants');
|
||||||
|
asn1.decoders = require('./asn1/decoders');
|
||||||
|
asn1.encoders = require('./asn1/encoders');
|
||||||
57
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
57
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const encoders = require('./encoders');
|
||||||
|
const decoders = require('./decoders');
|
||||||
|
const inherits = require('inherits');
|
||||||
|
|
||||||
|
const api = exports;
|
||||||
|
|
||||||
|
api.define = function define(name, body) {
|
||||||
|
return new Entity(name, body);
|
||||||
|
};
|
||||||
|
|
||||||
|
function Entity(name, body) {
|
||||||
|
this.name = name;
|
||||||
|
this.body = body;
|
||||||
|
|
||||||
|
this.decoders = {};
|
||||||
|
this.encoders = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity.prototype._createNamed = function createNamed(Base) {
|
||||||
|
const name = this.name;
|
||||||
|
|
||||||
|
function Generated(entity) {
|
||||||
|
this._initNamed(entity, name);
|
||||||
|
}
|
||||||
|
inherits(Generated, Base);
|
||||||
|
Generated.prototype._initNamed = function _initNamed(entity, name) {
|
||||||
|
Base.call(this, entity, name);
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Generated(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
Entity.prototype._getDecoder = function _getDecoder(enc) {
|
||||||
|
enc = enc || 'der';
|
||||||
|
// Lazily create decoder
|
||||||
|
if (!this.decoders.hasOwnProperty(enc))
|
||||||
|
this.decoders[enc] = this._createNamed(decoders[enc]);
|
||||||
|
return this.decoders[enc];
|
||||||
|
};
|
||||||
|
|
||||||
|
Entity.prototype.decode = function decode(data, enc, options) {
|
||||||
|
return this._getDecoder(enc).decode(data, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
Entity.prototype._getEncoder = function _getEncoder(enc) {
|
||||||
|
enc = enc || 'der';
|
||||||
|
// Lazily create encoder
|
||||||
|
if (!this.encoders.hasOwnProperty(enc))
|
||||||
|
this.encoders[enc] = this._createNamed(encoders[enc]);
|
||||||
|
return this.encoders[enc];
|
||||||
|
};
|
||||||
|
|
||||||
|
Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
|
||||||
|
return this._getEncoder(enc).encode(data, reporter);
|
||||||
|
};
|
||||||
153
node_modules/asn1.js/lib/asn1/base/buffer.js
generated
vendored
Normal file
153
node_modules/asn1.js/lib/asn1/base/buffer.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const inherits = require('inherits');
|
||||||
|
const Reporter = require('../base/reporter').Reporter;
|
||||||
|
const Buffer = require('safer-buffer').Buffer;
|
||||||
|
|
||||||
|
function DecoderBuffer(base, options) {
|
||||||
|
Reporter.call(this, options);
|
||||||
|
if (!Buffer.isBuffer(base)) {
|
||||||
|
this.error('Input not Buffer');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.base = base;
|
||||||
|
this.offset = 0;
|
||||||
|
this.length = base.length;
|
||||||
|
}
|
||||||
|
inherits(DecoderBuffer, Reporter);
|
||||||
|
exports.DecoderBuffer = DecoderBuffer;
|
||||||
|
|
||||||
|
DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {
|
||||||
|
if (data instanceof DecoderBuffer) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or accept compatible API
|
||||||
|
const isCompatible = typeof data === 'object' &&
|
||||||
|
Buffer.isBuffer(data.base) &&
|
||||||
|
data.constructor.name === 'DecoderBuffer' &&
|
||||||
|
typeof data.offset === 'number' &&
|
||||||
|
typeof data.length === 'number' &&
|
||||||
|
typeof data.save === 'function' &&
|
||||||
|
typeof data.restore === 'function' &&
|
||||||
|
typeof data.isEmpty === 'function' &&
|
||||||
|
typeof data.readUInt8 === 'function' &&
|
||||||
|
typeof data.skip === 'function' &&
|
||||||
|
typeof data.raw === 'function';
|
||||||
|
|
||||||
|
return isCompatible;
|
||||||
|
};
|
||||||
|
|
||||||
|
DecoderBuffer.prototype.save = function save() {
|
||||||
|
return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
|
||||||
|
};
|
||||||
|
|
||||||
|
DecoderBuffer.prototype.restore = function restore(save) {
|
||||||
|
// Return skipped data
|
||||||
|
const res = new DecoderBuffer(this.base);
|
||||||
|
res.offset = save.offset;
|
||||||
|
res.length = this.offset;
|
||||||
|
|
||||||
|
this.offset = save.offset;
|
||||||
|
Reporter.prototype.restore.call(this, save.reporter);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
DecoderBuffer.prototype.isEmpty = function isEmpty() {
|
||||||
|
return this.offset === this.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
|
||||||
|
if (this.offset + 1 <= this.length)
|
||||||
|
return this.base.readUInt8(this.offset++, true);
|
||||||
|
else
|
||||||
|
return this.error(fail || 'DecoderBuffer overrun');
|
||||||
|
};
|
||||||
|
|
||||||
|
DecoderBuffer.prototype.skip = function skip(bytes, fail) {
|
||||||
|
if (!(this.offset + bytes <= this.length))
|
||||||
|
return this.error(fail || 'DecoderBuffer overrun');
|
||||||
|
|
||||||
|
const res = new DecoderBuffer(this.base);
|
||||||
|
|
||||||
|
// Share reporter state
|
||||||
|
res._reporterState = this._reporterState;
|
||||||
|
|
||||||
|
res.offset = this.offset;
|
||||||
|
res.length = this.offset + bytes;
|
||||||
|
this.offset += bytes;
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
DecoderBuffer.prototype.raw = function raw(save) {
|
||||||
|
return this.base.slice(save ? save.offset : this.offset, this.length);
|
||||||
|
};
|
||||||
|
|
||||||
|
function EncoderBuffer(value, reporter) {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
this.length = 0;
|
||||||
|
this.value = value.map(function(item) {
|
||||||
|
if (!EncoderBuffer.isEncoderBuffer(item))
|
||||||
|
item = new EncoderBuffer(item, reporter);
|
||||||
|
this.length += item.length;
|
||||||
|
return item;
|
||||||
|
}, this);
|
||||||
|
} else if (typeof value === 'number') {
|
||||||
|
if (!(0 <= value && value <= 0xff))
|
||||||
|
return reporter.error('non-byte EncoderBuffer value');
|
||||||
|
this.value = value;
|
||||||
|
this.length = 1;
|
||||||
|
} else if (typeof value === 'string') {
|
||||||
|
this.value = value;
|
||||||
|
this.length = Buffer.byteLength(value);
|
||||||
|
} else if (Buffer.isBuffer(value)) {
|
||||||
|
this.value = value;
|
||||||
|
this.length = value.length;
|
||||||
|
} else {
|
||||||
|
return reporter.error('Unsupported type: ' + typeof value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.EncoderBuffer = EncoderBuffer;
|
||||||
|
|
||||||
|
EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {
|
||||||
|
if (data instanceof EncoderBuffer) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or accept compatible API
|
||||||
|
const isCompatible = typeof data === 'object' &&
|
||||||
|
data.constructor.name === 'EncoderBuffer' &&
|
||||||
|
typeof data.length === 'number' &&
|
||||||
|
typeof data.join === 'function';
|
||||||
|
|
||||||
|
return isCompatible;
|
||||||
|
};
|
||||||
|
|
||||||
|
EncoderBuffer.prototype.join = function join(out, offset) {
|
||||||
|
if (!out)
|
||||||
|
out = Buffer.alloc(this.length);
|
||||||
|
if (!offset)
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
if (this.length === 0)
|
||||||
|
return out;
|
||||||
|
|
||||||
|
if (Array.isArray(this.value)) {
|
||||||
|
this.value.forEach(function(item) {
|
||||||
|
item.join(out, offset);
|
||||||
|
offset += item.length;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (typeof this.value === 'number')
|
||||||
|
out[offset] = this.value;
|
||||||
|
else if (typeof this.value === 'string')
|
||||||
|
out.write(this.value, offset);
|
||||||
|
else if (Buffer.isBuffer(this.value))
|
||||||
|
this.value.copy(out, offset);
|
||||||
|
offset += this.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
};
|
||||||
8
node_modules/asn1.js/lib/asn1/base/index.js
generated
vendored
Normal file
8
node_modules/asn1.js/lib/asn1/base/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const base = exports;
|
||||||
|
|
||||||
|
base.Reporter = require('./reporter').Reporter;
|
||||||
|
base.DecoderBuffer = require('./buffer').DecoderBuffer;
|
||||||
|
base.EncoderBuffer = require('./buffer').EncoderBuffer;
|
||||||
|
base.Node = require('./node');
|
||||||
638
node_modules/asn1.js/lib/asn1/base/node.js
generated
vendored
Normal file
638
node_modules/asn1.js/lib/asn1/base/node.js
generated
vendored
Normal file
@@ -0,0 +1,638 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const Reporter = require('../base/reporter').Reporter;
|
||||||
|
const EncoderBuffer = require('../base/buffer').EncoderBuffer;
|
||||||
|
const DecoderBuffer = require('../base/buffer').DecoderBuffer;
|
||||||
|
const assert = require('minimalistic-assert');
|
||||||
|
|
||||||
|
// Supported tags
|
||||||
|
const tags = [
|
||||||
|
'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
|
||||||
|
'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
|
||||||
|
'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
|
||||||
|
'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Public methods list
|
||||||
|
const methods = [
|
||||||
|
'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
|
||||||
|
'any', 'contains'
|
||||||
|
].concat(tags);
|
||||||
|
|
||||||
|
// Overrided methods list
|
||||||
|
const overrided = [
|
||||||
|
'_peekTag', '_decodeTag', '_use',
|
||||||
|
'_decodeStr', '_decodeObjid', '_decodeTime',
|
||||||
|
'_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
|
||||||
|
|
||||||
|
'_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
|
||||||
|
'_encodeNull', '_encodeInt', '_encodeBool'
|
||||||
|
];
|
||||||
|
|
||||||
|
function Node(enc, parent, name) {
|
||||||
|
const state = {};
|
||||||
|
this._baseState = state;
|
||||||
|
|
||||||
|
state.name = name;
|
||||||
|
state.enc = enc;
|
||||||
|
|
||||||
|
state.parent = parent || null;
|
||||||
|
state.children = null;
|
||||||
|
|
||||||
|
// State
|
||||||
|
state.tag = null;
|
||||||
|
state.args = null;
|
||||||
|
state.reverseArgs = null;
|
||||||
|
state.choice = null;
|
||||||
|
state.optional = false;
|
||||||
|
state.any = false;
|
||||||
|
state.obj = false;
|
||||||
|
state.use = null;
|
||||||
|
state.useDecoder = null;
|
||||||
|
state.key = null;
|
||||||
|
state['default'] = null;
|
||||||
|
state.explicit = null;
|
||||||
|
state.implicit = null;
|
||||||
|
state.contains = null;
|
||||||
|
|
||||||
|
// Should create new instance on each method
|
||||||
|
if (!state.parent) {
|
||||||
|
state.children = [];
|
||||||
|
this._wrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = Node;
|
||||||
|
|
||||||
|
const stateProps = [
|
||||||
|
'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
|
||||||
|
'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
|
||||||
|
'implicit', 'contains'
|
||||||
|
];
|
||||||
|
|
||||||
|
Node.prototype.clone = function clone() {
|
||||||
|
const state = this._baseState;
|
||||||
|
const cstate = {};
|
||||||
|
stateProps.forEach(function(prop) {
|
||||||
|
cstate[prop] = state[prop];
|
||||||
|
});
|
||||||
|
const res = new this.constructor(cstate.parent);
|
||||||
|
res._baseState = cstate;
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._wrap = function wrap() {
|
||||||
|
const state = this._baseState;
|
||||||
|
methods.forEach(function(method) {
|
||||||
|
this[method] = function _wrappedMethod() {
|
||||||
|
const clone = new this.constructor(this);
|
||||||
|
state.children.push(clone);
|
||||||
|
return clone[method].apply(clone, arguments);
|
||||||
|
};
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._init = function init(body) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state.parent === null);
|
||||||
|
body.call(this);
|
||||||
|
|
||||||
|
// Filter children
|
||||||
|
state.children = state.children.filter(function(child) {
|
||||||
|
return child._baseState.parent === this;
|
||||||
|
}, this);
|
||||||
|
assert.equal(state.children.length, 1, 'Root node can have only one child');
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._useArgs = function useArgs(args) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
// Filter children and args
|
||||||
|
const children = args.filter(function(arg) {
|
||||||
|
return arg instanceof this.constructor;
|
||||||
|
}, this);
|
||||||
|
args = args.filter(function(arg) {
|
||||||
|
return !(arg instanceof this.constructor);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
if (children.length !== 0) {
|
||||||
|
assert(state.children === null);
|
||||||
|
state.children = children;
|
||||||
|
|
||||||
|
// Replace parent to maintain backward link
|
||||||
|
children.forEach(function(child) {
|
||||||
|
child._baseState.parent = this;
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
if (args.length !== 0) {
|
||||||
|
assert(state.args === null);
|
||||||
|
state.args = args;
|
||||||
|
state.reverseArgs = args.map(function(arg) {
|
||||||
|
if (typeof arg !== 'object' || arg.constructor !== Object)
|
||||||
|
return arg;
|
||||||
|
|
||||||
|
const res = {};
|
||||||
|
Object.keys(arg).forEach(function(key) {
|
||||||
|
if (key == (key | 0))
|
||||||
|
key |= 0;
|
||||||
|
const value = arg[key];
|
||||||
|
res[value] = key;
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Overrided methods
|
||||||
|
//
|
||||||
|
|
||||||
|
overrided.forEach(function(method) {
|
||||||
|
Node.prototype[method] = function _overrided() {
|
||||||
|
const state = this._baseState;
|
||||||
|
throw new Error(method + ' not implemented for encoding: ' + state.enc);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Public methods
|
||||||
|
//
|
||||||
|
|
||||||
|
tags.forEach(function(tag) {
|
||||||
|
Node.prototype[tag] = function _tagMethod() {
|
||||||
|
const state = this._baseState;
|
||||||
|
const args = Array.prototype.slice.call(arguments);
|
||||||
|
|
||||||
|
assert(state.tag === null);
|
||||||
|
state.tag = tag;
|
||||||
|
|
||||||
|
this._useArgs(args);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
Node.prototype.use = function use(item) {
|
||||||
|
assert(item);
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state.use === null);
|
||||||
|
state.use = item;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.optional = function optional() {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
state.optional = true;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.def = function def(val) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state['default'] === null);
|
||||||
|
state['default'] = val;
|
||||||
|
state.optional = true;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.explicit = function explicit(num) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state.explicit === null && state.implicit === null);
|
||||||
|
state.explicit = num;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.implicit = function implicit(num) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state.explicit === null && state.implicit === null);
|
||||||
|
state.implicit = num;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.obj = function obj() {
|
||||||
|
const state = this._baseState;
|
||||||
|
const args = Array.prototype.slice.call(arguments);
|
||||||
|
|
||||||
|
state.obj = true;
|
||||||
|
|
||||||
|
if (args.length !== 0)
|
||||||
|
this._useArgs(args);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.key = function key(newKey) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state.key === null);
|
||||||
|
state.key = newKey;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.any = function any() {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
state.any = true;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.choice = function choice(obj) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state.choice === null);
|
||||||
|
state.choice = obj;
|
||||||
|
this._useArgs(Object.keys(obj).map(function(key) {
|
||||||
|
return obj[key];
|
||||||
|
}));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.contains = function contains(item) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
assert(state.use === null);
|
||||||
|
state.contains = item;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decoding
|
||||||
|
//
|
||||||
|
|
||||||
|
Node.prototype._decode = function decode(input, options) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
// Decode root node
|
||||||
|
if (state.parent === null)
|
||||||
|
return input.wrapResult(state.children[0]._decode(input, options));
|
||||||
|
|
||||||
|
let result = state['default'];
|
||||||
|
let present = true;
|
||||||
|
|
||||||
|
let prevKey = null;
|
||||||
|
if (state.key !== null)
|
||||||
|
prevKey = input.enterKey(state.key);
|
||||||
|
|
||||||
|
// Check if tag is there
|
||||||
|
if (state.optional) {
|
||||||
|
let tag = null;
|
||||||
|
if (state.explicit !== null)
|
||||||
|
tag = state.explicit;
|
||||||
|
else if (state.implicit !== null)
|
||||||
|
tag = state.implicit;
|
||||||
|
else if (state.tag !== null)
|
||||||
|
tag = state.tag;
|
||||||
|
|
||||||
|
if (tag === null && !state.any) {
|
||||||
|
// Trial and Error
|
||||||
|
const save = input.save();
|
||||||
|
try {
|
||||||
|
if (state.choice === null)
|
||||||
|
this._decodeGeneric(state.tag, input, options);
|
||||||
|
else
|
||||||
|
this._decodeChoice(input, options);
|
||||||
|
present = true;
|
||||||
|
} catch (e) {
|
||||||
|
present = false;
|
||||||
|
}
|
||||||
|
input.restore(save);
|
||||||
|
} else {
|
||||||
|
present = this._peekTag(input, tag, state.any);
|
||||||
|
|
||||||
|
if (input.isError(present))
|
||||||
|
return present;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push object on stack
|
||||||
|
let prevObj;
|
||||||
|
if (state.obj && present)
|
||||||
|
prevObj = input.enterObject();
|
||||||
|
|
||||||
|
if (present) {
|
||||||
|
// Unwrap explicit values
|
||||||
|
if (state.explicit !== null) {
|
||||||
|
const explicit = this._decodeTag(input, state.explicit);
|
||||||
|
if (input.isError(explicit))
|
||||||
|
return explicit;
|
||||||
|
input = explicit;
|
||||||
|
}
|
||||||
|
|
||||||
|
const start = input.offset;
|
||||||
|
|
||||||
|
// Unwrap implicit and normal values
|
||||||
|
if (state.use === null && state.choice === null) {
|
||||||
|
let save;
|
||||||
|
if (state.any)
|
||||||
|
save = input.save();
|
||||||
|
const body = this._decodeTag(
|
||||||
|
input,
|
||||||
|
state.implicit !== null ? state.implicit : state.tag,
|
||||||
|
state.any
|
||||||
|
);
|
||||||
|
if (input.isError(body))
|
||||||
|
return body;
|
||||||
|
|
||||||
|
if (state.any)
|
||||||
|
result = input.raw(save);
|
||||||
|
else
|
||||||
|
input = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options && options.track && state.tag !== null)
|
||||||
|
options.track(input.path(), start, input.length, 'tagged');
|
||||||
|
|
||||||
|
if (options && options.track && state.tag !== null)
|
||||||
|
options.track(input.path(), input.offset, input.length, 'content');
|
||||||
|
|
||||||
|
// Select proper method for tag
|
||||||
|
if (state.any) {
|
||||||
|
// no-op
|
||||||
|
} else if (state.choice === null) {
|
||||||
|
result = this._decodeGeneric(state.tag, input, options);
|
||||||
|
} else {
|
||||||
|
result = this._decodeChoice(input, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.isError(result))
|
||||||
|
return result;
|
||||||
|
|
||||||
|
// Decode children
|
||||||
|
if (!state.any && state.choice === null && state.children !== null) {
|
||||||
|
state.children.forEach(function decodeChildren(child) {
|
||||||
|
// NOTE: We are ignoring errors here, to let parser continue with other
|
||||||
|
// parts of encoded data
|
||||||
|
child._decode(input, options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode contained/encoded by schema, only in bit or octet strings
|
||||||
|
if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
|
||||||
|
const data = new DecoderBuffer(result);
|
||||||
|
result = this._getUse(state.contains, input._reporterState.obj)
|
||||||
|
._decode(data, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pop object
|
||||||
|
if (state.obj && present)
|
||||||
|
result = input.leaveObject(prevObj);
|
||||||
|
|
||||||
|
// Set key
|
||||||
|
if (state.key !== null && (result !== null || present === true))
|
||||||
|
input.leaveKey(prevKey, state.key, result);
|
||||||
|
else if (prevKey !== null)
|
||||||
|
input.exitKey(prevKey);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
if (tag === 'seq' || tag === 'set')
|
||||||
|
return null;
|
||||||
|
if (tag === 'seqof' || tag === 'setof')
|
||||||
|
return this._decodeList(input, tag, state.args[0], options);
|
||||||
|
else if (/str$/.test(tag))
|
||||||
|
return this._decodeStr(input, tag, options);
|
||||||
|
else if (tag === 'objid' && state.args)
|
||||||
|
return this._decodeObjid(input, state.args[0], state.args[1], options);
|
||||||
|
else if (tag === 'objid')
|
||||||
|
return this._decodeObjid(input, null, null, options);
|
||||||
|
else if (tag === 'gentime' || tag === 'utctime')
|
||||||
|
return this._decodeTime(input, tag, options);
|
||||||
|
else if (tag === 'null_')
|
||||||
|
return this._decodeNull(input, options);
|
||||||
|
else if (tag === 'bool')
|
||||||
|
return this._decodeBool(input, options);
|
||||||
|
else if (tag === 'objDesc')
|
||||||
|
return this._decodeStr(input, tag, options);
|
||||||
|
else if (tag === 'int' || tag === 'enum')
|
||||||
|
return this._decodeInt(input, state.args && state.args[0], options);
|
||||||
|
|
||||||
|
if (state.use !== null) {
|
||||||
|
return this._getUse(state.use, input._reporterState.obj)
|
||||||
|
._decode(input, options);
|
||||||
|
} else {
|
||||||
|
return input.error('unknown tag: ' + tag);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._getUse = function _getUse(entity, obj) {
|
||||||
|
|
||||||
|
const state = this._baseState;
|
||||||
|
// Create altered use decoder if implicit is set
|
||||||
|
state.useDecoder = this._use(entity, obj);
|
||||||
|
assert(state.useDecoder._baseState.parent === null);
|
||||||
|
state.useDecoder = state.useDecoder._baseState.children[0];
|
||||||
|
if (state.implicit !== state.useDecoder._baseState.implicit) {
|
||||||
|
state.useDecoder = state.useDecoder.clone();
|
||||||
|
state.useDecoder._baseState.implicit = state.implicit;
|
||||||
|
}
|
||||||
|
return state.useDecoder;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._decodeChoice = function decodeChoice(input, options) {
|
||||||
|
const state = this._baseState;
|
||||||
|
let result = null;
|
||||||
|
let match = false;
|
||||||
|
|
||||||
|
Object.keys(state.choice).some(function(key) {
|
||||||
|
const save = input.save();
|
||||||
|
const node = state.choice[key];
|
||||||
|
try {
|
||||||
|
const value = node._decode(input, options);
|
||||||
|
if (input.isError(value))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
result = { type: key, value: value };
|
||||||
|
match = true;
|
||||||
|
} catch (e) {
|
||||||
|
input.restore(save);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
if (!match)
|
||||||
|
return input.error('Choice not matched');
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Encoding
|
||||||
|
//
|
||||||
|
|
||||||
|
Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
|
||||||
|
return new EncoderBuffer(data, this.reporter);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._encode = function encode(data, reporter, parent) {
|
||||||
|
const state = this._baseState;
|
||||||
|
if (state['default'] !== null && state['default'] === data)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const result = this._encodeValue(data, reporter, parent);
|
||||||
|
if (result === undefined)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this._skipDefault(result, reporter, parent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._encodeValue = function encode(data, reporter, parent) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
// Decode root node
|
||||||
|
if (state.parent === null)
|
||||||
|
return state.children[0]._encode(data, reporter || new Reporter());
|
||||||
|
|
||||||
|
let result = null;
|
||||||
|
|
||||||
|
// Set reporter to share it with a child class
|
||||||
|
this.reporter = reporter;
|
||||||
|
|
||||||
|
// Check if data is there
|
||||||
|
if (state.optional && data === undefined) {
|
||||||
|
if (state['default'] !== null)
|
||||||
|
data = state['default'];
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode children first
|
||||||
|
let content = null;
|
||||||
|
let primitive = false;
|
||||||
|
if (state.any) {
|
||||||
|
// Anything that was given is translated to buffer
|
||||||
|
result = this._createEncoderBuffer(data);
|
||||||
|
} else if (state.choice) {
|
||||||
|
result = this._encodeChoice(data, reporter);
|
||||||
|
} else if (state.contains) {
|
||||||
|
content = this._getUse(state.contains, parent)._encode(data, reporter);
|
||||||
|
primitive = true;
|
||||||
|
} else if (state.children) {
|
||||||
|
content = state.children.map(function(child) {
|
||||||
|
if (child._baseState.tag === 'null_')
|
||||||
|
return child._encode(null, reporter, data);
|
||||||
|
|
||||||
|
if (child._baseState.key === null)
|
||||||
|
return reporter.error('Child should have a key');
|
||||||
|
const prevKey = reporter.enterKey(child._baseState.key);
|
||||||
|
|
||||||
|
if (typeof data !== 'object')
|
||||||
|
return reporter.error('Child expected, but input is not object');
|
||||||
|
|
||||||
|
const res = child._encode(data[child._baseState.key], reporter, data);
|
||||||
|
reporter.leaveKey(prevKey);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}, this).filter(function(child) {
|
||||||
|
return child;
|
||||||
|
});
|
||||||
|
content = this._createEncoderBuffer(content);
|
||||||
|
} else {
|
||||||
|
if (state.tag === 'seqof' || state.tag === 'setof') {
|
||||||
|
// TODO(indutny): this should be thrown on DSL level
|
||||||
|
if (!(state.args && state.args.length === 1))
|
||||||
|
return reporter.error('Too many args for : ' + state.tag);
|
||||||
|
|
||||||
|
if (!Array.isArray(data))
|
||||||
|
return reporter.error('seqof/setof, but data is not Array');
|
||||||
|
|
||||||
|
const child = this.clone();
|
||||||
|
child._baseState.implicit = null;
|
||||||
|
content = this._createEncoderBuffer(data.map(function(item) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
return this._getUse(state.args[0], data)._encode(item, reporter);
|
||||||
|
}, child));
|
||||||
|
} else if (state.use !== null) {
|
||||||
|
result = this._getUse(state.use, parent)._encode(data, reporter);
|
||||||
|
} else {
|
||||||
|
content = this._encodePrimitive(state.tag, data);
|
||||||
|
primitive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode data itself
|
||||||
|
if (!state.any && state.choice === null) {
|
||||||
|
const tag = state.implicit !== null ? state.implicit : state.tag;
|
||||||
|
const cls = state.implicit === null ? 'universal' : 'context';
|
||||||
|
|
||||||
|
if (tag === null) {
|
||||||
|
if (state.use === null)
|
||||||
|
reporter.error('Tag could be omitted only for .use()');
|
||||||
|
} else {
|
||||||
|
if (state.use === null)
|
||||||
|
result = this._encodeComposite(tag, primitive, cls, content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap in explicit
|
||||||
|
if (state.explicit !== null)
|
||||||
|
result = this._encodeComposite(state.explicit, false, 'context', result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
const node = state.choice[data.type];
|
||||||
|
if (!node) {
|
||||||
|
assert(
|
||||||
|
false,
|
||||||
|
data.type + ' not found in ' +
|
||||||
|
JSON.stringify(Object.keys(state.choice)));
|
||||||
|
}
|
||||||
|
return node._encode(data.value, reporter);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
|
||||||
|
const state = this._baseState;
|
||||||
|
|
||||||
|
if (/str$/.test(tag))
|
||||||
|
return this._encodeStr(data, tag);
|
||||||
|
else if (tag === 'objid' && state.args)
|
||||||
|
return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
|
||||||
|
else if (tag === 'objid')
|
||||||
|
return this._encodeObjid(data, null, null);
|
||||||
|
else if (tag === 'gentime' || tag === 'utctime')
|
||||||
|
return this._encodeTime(data, tag);
|
||||||
|
else if (tag === 'null_')
|
||||||
|
return this._encodeNull();
|
||||||
|
else if (tag === 'int' || tag === 'enum')
|
||||||
|
return this._encodeInt(data, state.args && state.reverseArgs[0]);
|
||||||
|
else if (tag === 'bool')
|
||||||
|
return this._encodeBool(data);
|
||||||
|
else if (tag === 'objDesc')
|
||||||
|
return this._encodeStr(data, tag);
|
||||||
|
else
|
||||||
|
throw new Error('Unsupported tag: ' + tag);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._isNumstr = function isNumstr(str) {
|
||||||
|
return /^[0-9 ]*$/.test(str);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype._isPrintstr = function isPrintstr(str) {
|
||||||
|
return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str);
|
||||||
|
};
|
||||||
123
node_modules/asn1.js/lib/asn1/base/reporter.js
generated
vendored
Normal file
123
node_modules/asn1.js/lib/asn1/base/reporter.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const inherits = require('inherits');
|
||||||
|
|
||||||
|
function Reporter(options) {
|
||||||
|
this._reporterState = {
|
||||||
|
obj: null,
|
||||||
|
path: [],
|
||||||
|
options: options || {},
|
||||||
|
errors: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.Reporter = Reporter;
|
||||||
|
|
||||||
|
Reporter.prototype.isError = function isError(obj) {
|
||||||
|
return obj instanceof ReporterError;
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.save = function save() {
|
||||||
|
const state = this._reporterState;
|
||||||
|
|
||||||
|
return { obj: state.obj, pathLen: state.path.length };
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.restore = function restore(data) {
|
||||||
|
const state = this._reporterState;
|
||||||
|
|
||||||
|
state.obj = data.obj;
|
||||||
|
state.path = state.path.slice(0, data.pathLen);
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.enterKey = function enterKey(key) {
|
||||||
|
return this._reporterState.path.push(key);
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.exitKey = function exitKey(index) {
|
||||||
|
const state = this._reporterState;
|
||||||
|
|
||||||
|
state.path = state.path.slice(0, index - 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
|
||||||
|
const state = this._reporterState;
|
||||||
|
|
||||||
|
this.exitKey(index);
|
||||||
|
if (state.obj !== null)
|
||||||
|
state.obj[key] = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.path = function path() {
|
||||||
|
return this._reporterState.path.join('/');
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.enterObject = function enterObject() {
|
||||||
|
const state = this._reporterState;
|
||||||
|
|
||||||
|
const prev = state.obj;
|
||||||
|
state.obj = {};
|
||||||
|
return prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.leaveObject = function leaveObject(prev) {
|
||||||
|
const state = this._reporterState;
|
||||||
|
|
||||||
|
const now = state.obj;
|
||||||
|
state.obj = prev;
|
||||||
|
return now;
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.error = function error(msg) {
|
||||||
|
let err;
|
||||||
|
const state = this._reporterState;
|
||||||
|
|
||||||
|
const inherited = msg instanceof ReporterError;
|
||||||
|
if (inherited) {
|
||||||
|
err = msg;
|
||||||
|
} else {
|
||||||
|
err = new ReporterError(state.path.map(function(elem) {
|
||||||
|
return '[' + JSON.stringify(elem) + ']';
|
||||||
|
}).join(''), msg.message || msg, msg.stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state.options.partial)
|
||||||
|
throw err;
|
||||||
|
|
||||||
|
if (!inherited)
|
||||||
|
state.errors.push(err);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
};
|
||||||
|
|
||||||
|
Reporter.prototype.wrapResult = function wrapResult(result) {
|
||||||
|
const state = this._reporterState;
|
||||||
|
if (!state.options.partial)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
return {
|
||||||
|
result: this.isError(result) ? null : result,
|
||||||
|
errors: state.errors
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function ReporterError(path, msg) {
|
||||||
|
this.path = path;
|
||||||
|
this.rethrow(msg);
|
||||||
|
}
|
||||||
|
inherits(ReporterError, Error);
|
||||||
|
|
||||||
|
ReporterError.prototype.rethrow = function rethrow(msg) {
|
||||||
|
this.message = msg + ' at: ' + (this.path || '(shallow)');
|
||||||
|
if (Error.captureStackTrace)
|
||||||
|
Error.captureStackTrace(this, ReporterError);
|
||||||
|
|
||||||
|
if (!this.stack) {
|
||||||
|
try {
|
||||||
|
// IE only adds stack when thrown
|
||||||
|
throw new Error(this.message);
|
||||||
|
} catch (e) {
|
||||||
|
this.stack = e.stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
58
node_modules/asn1.js/lib/asn1/constants/der.js
generated
vendored
Normal file
58
node_modules/asn1.js/lib/asn1/constants/der.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Helper
|
||||||
|
function reverse(map) {
|
||||||
|
const res = {};
|
||||||
|
|
||||||
|
Object.keys(map).forEach(function(key) {
|
||||||
|
// Convert key to integer if it is stringified
|
||||||
|
if ((key | 0) == key)
|
||||||
|
key = key | 0;
|
||||||
|
|
||||||
|
const value = map[key];
|
||||||
|
res[value] = key;
|
||||||
|
});
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.tagClass = {
|
||||||
|
0: 'universal',
|
||||||
|
1: 'application',
|
||||||
|
2: 'context',
|
||||||
|
3: 'private'
|
||||||
|
};
|
||||||
|
exports.tagClassByName = reverse(exports.tagClass);
|
||||||
|
|
||||||
|
exports.tag = {
|
||||||
|
0x00: 'end',
|
||||||
|
0x01: 'bool',
|
||||||
|
0x02: 'int',
|
||||||
|
0x03: 'bitstr',
|
||||||
|
0x04: 'octstr',
|
||||||
|
0x05: 'null_',
|
||||||
|
0x06: 'objid',
|
||||||
|
0x07: 'objDesc',
|
||||||
|
0x08: 'external',
|
||||||
|
0x09: 'real',
|
||||||
|
0x0a: 'enum',
|
||||||
|
0x0b: 'embed',
|
||||||
|
0x0c: 'utf8str',
|
||||||
|
0x0d: 'relativeOid',
|
||||||
|
0x10: 'seq',
|
||||||
|
0x11: 'set',
|
||||||
|
0x12: 'numstr',
|
||||||
|
0x13: 'printstr',
|
||||||
|
0x14: 't61str',
|
||||||
|
0x15: 'videostr',
|
||||||
|
0x16: 'ia5str',
|
||||||
|
0x17: 'utctime',
|
||||||
|
0x18: 'gentime',
|
||||||
|
0x19: 'graphstr',
|
||||||
|
0x1a: 'iso646str',
|
||||||
|
0x1b: 'genstr',
|
||||||
|
0x1c: 'unistr',
|
||||||
|
0x1d: 'charstr',
|
||||||
|
0x1e: 'bmpstr'
|
||||||
|
};
|
||||||
|
exports.tagByName = reverse(exports.tag);
|
||||||
21
node_modules/asn1.js/lib/asn1/constants/index.js
generated
vendored
Normal file
21
node_modules/asn1.js/lib/asn1/constants/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const constants = exports;
|
||||||
|
|
||||||
|
// Helper
|
||||||
|
constants._reverse = function reverse(map) {
|
||||||
|
const res = {};
|
||||||
|
|
||||||
|
Object.keys(map).forEach(function(key) {
|
||||||
|
// Convert key to integer if it is stringified
|
||||||
|
if ((key | 0) == key)
|
||||||
|
key = key | 0;
|
||||||
|
|
||||||
|
const value = map[key];
|
||||||
|
res[value] = key;
|
||||||
|
});
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
constants.der = require('./der');
|
||||||
335
node_modules/asn1.js/lib/asn1/decoders/der.js
generated
vendored
Normal file
335
node_modules/asn1.js/lib/asn1/decoders/der.js
generated
vendored
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const inherits = require('inherits');
|
||||||
|
|
||||||
|
const bignum = require('bn.js');
|
||||||
|
const DecoderBuffer = require('../base/buffer').DecoderBuffer;
|
||||||
|
const Node = require('../base/node');
|
||||||
|
|
||||||
|
// Import DER constants
|
||||||
|
const der = require('../constants/der');
|
||||||
|
|
||||||
|
function DERDecoder(entity) {
|
||||||
|
this.enc = 'der';
|
||||||
|
this.name = entity.name;
|
||||||
|
this.entity = entity;
|
||||||
|
|
||||||
|
// Construct base tree
|
||||||
|
this.tree = new DERNode();
|
||||||
|
this.tree._init(entity.body);
|
||||||
|
}
|
||||||
|
module.exports = DERDecoder;
|
||||||
|
|
||||||
|
DERDecoder.prototype.decode = function decode(data, options) {
|
||||||
|
if (!DecoderBuffer.isDecoderBuffer(data)) {
|
||||||
|
data = new DecoderBuffer(data, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.tree._decode(data, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Tree methods
|
||||||
|
|
||||||
|
function DERNode(parent) {
|
||||||
|
Node.call(this, 'der', parent);
|
||||||
|
}
|
||||||
|
inherits(DERNode, Node);
|
||||||
|
|
||||||
|
DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
|
||||||
|
if (buffer.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const state = buffer.save();
|
||||||
|
const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
|
||||||
|
if (buffer.isError(decodedTag))
|
||||||
|
return decodedTag;
|
||||||
|
|
||||||
|
buffer.restore(state);
|
||||||
|
|
||||||
|
return decodedTag.tag === tag || decodedTag.tagStr === tag ||
|
||||||
|
(decodedTag.tagStr + 'of') === tag || any;
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
|
||||||
|
const decodedTag = derDecodeTag(buffer,
|
||||||
|
'Failed to decode tag of "' + tag + '"');
|
||||||
|
if (buffer.isError(decodedTag))
|
||||||
|
return decodedTag;
|
||||||
|
|
||||||
|
let len = derDecodeLen(buffer,
|
||||||
|
decodedTag.primitive,
|
||||||
|
'Failed to get length of "' + tag + '"');
|
||||||
|
|
||||||
|
// Failure
|
||||||
|
if (buffer.isError(len))
|
||||||
|
return len;
|
||||||
|
|
||||||
|
if (!any &&
|
||||||
|
decodedTag.tag !== tag &&
|
||||||
|
decodedTag.tagStr !== tag &&
|
||||||
|
decodedTag.tagStr + 'of' !== tag) {
|
||||||
|
return buffer.error('Failed to match tag: "' + tag + '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decodedTag.primitive || len !== null)
|
||||||
|
return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
|
||||||
|
|
||||||
|
// Indefinite length... find END tag
|
||||||
|
const state = buffer.save();
|
||||||
|
const res = this._skipUntilEnd(
|
||||||
|
buffer,
|
||||||
|
'Failed to skip indefinite length body: "' + this.tag + '"');
|
||||||
|
if (buffer.isError(res))
|
||||||
|
return res;
|
||||||
|
|
||||||
|
len = buffer.offset - state.offset;
|
||||||
|
buffer.restore(state);
|
||||||
|
return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
|
||||||
|
for (;;) {
|
||||||
|
const tag = derDecodeTag(buffer, fail);
|
||||||
|
if (buffer.isError(tag))
|
||||||
|
return tag;
|
||||||
|
const len = derDecodeLen(buffer, tag.primitive, fail);
|
||||||
|
if (buffer.isError(len))
|
||||||
|
return len;
|
||||||
|
|
||||||
|
let res;
|
||||||
|
if (tag.primitive || len !== null)
|
||||||
|
res = buffer.skip(len);
|
||||||
|
else
|
||||||
|
res = this._skipUntilEnd(buffer, fail);
|
||||||
|
|
||||||
|
// Failure
|
||||||
|
if (buffer.isError(res))
|
||||||
|
return res;
|
||||||
|
|
||||||
|
if (tag.tagStr === 'end')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
|
||||||
|
options) {
|
||||||
|
const result = [];
|
||||||
|
while (!buffer.isEmpty()) {
|
||||||
|
const possibleEnd = this._peekTag(buffer, 'end');
|
||||||
|
if (buffer.isError(possibleEnd))
|
||||||
|
return possibleEnd;
|
||||||
|
|
||||||
|
const res = decoder.decode(buffer, 'der', options);
|
||||||
|
if (buffer.isError(res) && possibleEnd)
|
||||||
|
break;
|
||||||
|
result.push(res);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
|
||||||
|
if (tag === 'bitstr') {
|
||||||
|
const unused = buffer.readUInt8();
|
||||||
|
if (buffer.isError(unused))
|
||||||
|
return unused;
|
||||||
|
return { unused: unused, data: buffer.raw() };
|
||||||
|
} else if (tag === 'bmpstr') {
|
||||||
|
const raw = buffer.raw();
|
||||||
|
if (raw.length % 2 === 1)
|
||||||
|
return buffer.error('Decoding of string type: bmpstr length mismatch');
|
||||||
|
|
||||||
|
let str = '';
|
||||||
|
for (let i = 0; i < raw.length / 2; i++) {
|
||||||
|
str += String.fromCharCode(raw.readUInt16BE(i * 2));
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
} else if (tag === 'numstr') {
|
||||||
|
const numstr = buffer.raw().toString('ascii');
|
||||||
|
if (!this._isNumstr(numstr)) {
|
||||||
|
return buffer.error('Decoding of string type: ' +
|
||||||
|
'numstr unsupported characters');
|
||||||
|
}
|
||||||
|
return numstr;
|
||||||
|
} else if (tag === 'octstr') {
|
||||||
|
return buffer.raw();
|
||||||
|
} else if (tag === 'objDesc') {
|
||||||
|
return buffer.raw();
|
||||||
|
} else if (tag === 'printstr') {
|
||||||
|
const printstr = buffer.raw().toString('ascii');
|
||||||
|
if (!this._isPrintstr(printstr)) {
|
||||||
|
return buffer.error('Decoding of string type: ' +
|
||||||
|
'printstr unsupported characters');
|
||||||
|
}
|
||||||
|
return printstr;
|
||||||
|
} else if (/str$/.test(tag)) {
|
||||||
|
return buffer.raw().toString();
|
||||||
|
} else {
|
||||||
|
return buffer.error('Decoding of string type: ' + tag + ' unsupported');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
|
||||||
|
let result;
|
||||||
|
const identifiers = [];
|
||||||
|
let ident = 0;
|
||||||
|
let subident = 0;
|
||||||
|
while (!buffer.isEmpty()) {
|
||||||
|
subident = buffer.readUInt8();
|
||||||
|
ident <<= 7;
|
||||||
|
ident |= subident & 0x7f;
|
||||||
|
if ((subident & 0x80) === 0) {
|
||||||
|
identifiers.push(ident);
|
||||||
|
ident = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subident & 0x80)
|
||||||
|
identifiers.push(ident);
|
||||||
|
|
||||||
|
const first = (identifiers[0] / 40) | 0;
|
||||||
|
const second = identifiers[0] % 40;
|
||||||
|
|
||||||
|
if (relative)
|
||||||
|
result = identifiers;
|
||||||
|
else
|
||||||
|
result = [first, second].concat(identifiers.slice(1));
|
||||||
|
|
||||||
|
if (values) {
|
||||||
|
let tmp = values[result.join(' ')];
|
||||||
|
if (tmp === undefined)
|
||||||
|
tmp = values[result.join('.')];
|
||||||
|
if (tmp !== undefined)
|
||||||
|
result = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
|
||||||
|
const str = buffer.raw().toString();
|
||||||
|
|
||||||
|
let year;
|
||||||
|
let mon;
|
||||||
|
let day;
|
||||||
|
let hour;
|
||||||
|
let min;
|
||||||
|
let sec;
|
||||||
|
if (tag === 'gentime') {
|
||||||
|
year = str.slice(0, 4) | 0;
|
||||||
|
mon = str.slice(4, 6) | 0;
|
||||||
|
day = str.slice(6, 8) | 0;
|
||||||
|
hour = str.slice(8, 10) | 0;
|
||||||
|
min = str.slice(10, 12) | 0;
|
||||||
|
sec = str.slice(12, 14) | 0;
|
||||||
|
} else if (tag === 'utctime') {
|
||||||
|
year = str.slice(0, 2) | 0;
|
||||||
|
mon = str.slice(2, 4) | 0;
|
||||||
|
day = str.slice(4, 6) | 0;
|
||||||
|
hour = str.slice(6, 8) | 0;
|
||||||
|
min = str.slice(8, 10) | 0;
|
||||||
|
sec = str.slice(10, 12) | 0;
|
||||||
|
if (year < 70)
|
||||||
|
year = 2000 + year;
|
||||||
|
else
|
||||||
|
year = 1900 + year;
|
||||||
|
} else {
|
||||||
|
return buffer.error('Decoding ' + tag + ' time is not supported yet');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeNull = function decodeNull() {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeBool = function decodeBool(buffer) {
|
||||||
|
const res = buffer.readUInt8();
|
||||||
|
if (buffer.isError(res))
|
||||||
|
return res;
|
||||||
|
else
|
||||||
|
return res !== 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
|
||||||
|
// Bigint, return as it is (assume big endian)
|
||||||
|
const raw = buffer.raw();
|
||||||
|
let res = new bignum(raw);
|
||||||
|
|
||||||
|
if (values)
|
||||||
|
res = values[res.toString(10)] || res;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._use = function use(entity, obj) {
|
||||||
|
if (typeof entity === 'function')
|
||||||
|
entity = entity(obj);
|
||||||
|
return entity._getDecoder('der').tree;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Utility methods
|
||||||
|
|
||||||
|
function derDecodeTag(buf, fail) {
|
||||||
|
let tag = buf.readUInt8(fail);
|
||||||
|
if (buf.isError(tag))
|
||||||
|
return tag;
|
||||||
|
|
||||||
|
const cls = der.tagClass[tag >> 6];
|
||||||
|
const primitive = (tag & 0x20) === 0;
|
||||||
|
|
||||||
|
// Multi-octet tag - load
|
||||||
|
if ((tag & 0x1f) === 0x1f) {
|
||||||
|
let oct = tag;
|
||||||
|
tag = 0;
|
||||||
|
while ((oct & 0x80) === 0x80) {
|
||||||
|
oct = buf.readUInt8(fail);
|
||||||
|
if (buf.isError(oct))
|
||||||
|
return oct;
|
||||||
|
|
||||||
|
tag <<= 7;
|
||||||
|
tag |= oct & 0x7f;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tag &= 0x1f;
|
||||||
|
}
|
||||||
|
const tagStr = der.tag[tag];
|
||||||
|
|
||||||
|
return {
|
||||||
|
cls: cls,
|
||||||
|
primitive: primitive,
|
||||||
|
tag: tag,
|
||||||
|
tagStr: tagStr
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function derDecodeLen(buf, primitive, fail) {
|
||||||
|
let len = buf.readUInt8(fail);
|
||||||
|
if (buf.isError(len))
|
||||||
|
return len;
|
||||||
|
|
||||||
|
// Indefinite form
|
||||||
|
if (!primitive && len === 0x80)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Definite form
|
||||||
|
if ((len & 0x80) === 0) {
|
||||||
|
// Short form
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Long form
|
||||||
|
const num = len & 0x7f;
|
||||||
|
if (num > 4)
|
||||||
|
return buf.error('length octect is too long');
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
for (let i = 0; i < num; i++) {
|
||||||
|
len <<= 8;
|
||||||
|
const j = buf.readUInt8(fail);
|
||||||
|
if (buf.isError(j))
|
||||||
|
return j;
|
||||||
|
len |= j;
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
6
node_modules/asn1.js/lib/asn1/decoders/index.js
generated
vendored
Normal file
6
node_modules/asn1.js/lib/asn1/decoders/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const decoders = exports;
|
||||||
|
|
||||||
|
decoders.der = require('./der');
|
||||||
|
decoders.pem = require('./pem');
|
||||||
51
node_modules/asn1.js/lib/asn1/decoders/pem.js
generated
vendored
Normal file
51
node_modules/asn1.js/lib/asn1/decoders/pem.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const inherits = require('inherits');
|
||||||
|
const Buffer = require('safer-buffer').Buffer;
|
||||||
|
|
||||||
|
const DERDecoder = require('./der');
|
||||||
|
|
||||||
|
function PEMDecoder(entity) {
|
||||||
|
DERDecoder.call(this, entity);
|
||||||
|
this.enc = 'pem';
|
||||||
|
}
|
||||||
|
inherits(PEMDecoder, DERDecoder);
|
||||||
|
module.exports = PEMDecoder;
|
||||||
|
|
||||||
|
PEMDecoder.prototype.decode = function decode(data, options) {
|
||||||
|
const lines = data.toString().split(/[\r\n]+/g);
|
||||||
|
|
||||||
|
const label = options.label.toUpperCase();
|
||||||
|
|
||||||
|
const re = /^-----(BEGIN|END) ([^-]+)-----$/;
|
||||||
|
let start = -1;
|
||||||
|
let end = -1;
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
const match = lines[i].match(re);
|
||||||
|
if (match === null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (match[2] !== label)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (start === -1) {
|
||||||
|
if (match[1] !== 'BEGIN')
|
||||||
|
break;
|
||||||
|
start = i;
|
||||||
|
} else {
|
||||||
|
if (match[1] !== 'END')
|
||||||
|
break;
|
||||||
|
end = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (start === -1 || end === -1)
|
||||||
|
throw new Error('PEM section not found for: ' + label);
|
||||||
|
|
||||||
|
const base64 = lines.slice(start + 1, end).join('');
|
||||||
|
// Remove excessive symbols
|
||||||
|
base64.replace(/[^a-z0-9+/=]+/gi, '');
|
||||||
|
|
||||||
|
const input = Buffer.from(base64, 'base64');
|
||||||
|
return DERDecoder.prototype.decode.call(this, input, options);
|
||||||
|
};
|
||||||
295
node_modules/asn1.js/lib/asn1/encoders/der.js
generated
vendored
Normal file
295
node_modules/asn1.js/lib/asn1/encoders/der.js
generated
vendored
Normal file
@@ -0,0 +1,295 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const inherits = require('inherits');
|
||||||
|
const Buffer = require('safer-buffer').Buffer;
|
||||||
|
const Node = require('../base/node');
|
||||||
|
|
||||||
|
// Import DER constants
|
||||||
|
const der = require('../constants/der');
|
||||||
|
|
||||||
|
function DEREncoder(entity) {
|
||||||
|
this.enc = 'der';
|
||||||
|
this.name = entity.name;
|
||||||
|
this.entity = entity;
|
||||||
|
|
||||||
|
// Construct base tree
|
||||||
|
this.tree = new DERNode();
|
||||||
|
this.tree._init(entity.body);
|
||||||
|
}
|
||||||
|
module.exports = DEREncoder;
|
||||||
|
|
||||||
|
DEREncoder.prototype.encode = function encode(data, reporter) {
|
||||||
|
return this.tree._encode(data, reporter).join();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Tree methods
|
||||||
|
|
||||||
|
function DERNode(parent) {
|
||||||
|
Node.call(this, 'der', parent);
|
||||||
|
}
|
||||||
|
inherits(DERNode, Node);
|
||||||
|
|
||||||
|
DERNode.prototype._encodeComposite = function encodeComposite(tag,
|
||||||
|
primitive,
|
||||||
|
cls,
|
||||||
|
content) {
|
||||||
|
const encodedTag = encodeTag(tag, primitive, cls, this.reporter);
|
||||||
|
|
||||||
|
// Short form
|
||||||
|
if (content.length < 0x80) {
|
||||||
|
const header = Buffer.alloc(2);
|
||||||
|
header[0] = encodedTag;
|
||||||
|
header[1] = content.length;
|
||||||
|
return this._createEncoderBuffer([ header, content ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Long form
|
||||||
|
// Count octets required to store length
|
||||||
|
let lenOctets = 1;
|
||||||
|
for (let i = content.length; i >= 0x100; i >>= 8)
|
||||||
|
lenOctets++;
|
||||||
|
|
||||||
|
const header = Buffer.alloc(1 + 1 + lenOctets);
|
||||||
|
header[0] = encodedTag;
|
||||||
|
header[1] = 0x80 | lenOctets;
|
||||||
|
|
||||||
|
for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
|
||||||
|
header[i] = j & 0xff;
|
||||||
|
|
||||||
|
return this._createEncoderBuffer([ header, content ]);
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._encodeStr = function encodeStr(str, tag) {
|
||||||
|
if (tag === 'bitstr') {
|
||||||
|
return this._createEncoderBuffer([ str.unused | 0, str.data ]);
|
||||||
|
} else if (tag === 'bmpstr') {
|
||||||
|
const buf = Buffer.alloc(str.length * 2);
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
buf.writeUInt16BE(str.charCodeAt(i), i * 2);
|
||||||
|
}
|
||||||
|
return this._createEncoderBuffer(buf);
|
||||||
|
} else if (tag === 'numstr') {
|
||||||
|
if (!this._isNumstr(str)) {
|
||||||
|
return this.reporter.error('Encoding of string type: numstr supports ' +
|
||||||
|
'only digits and space');
|
||||||
|
}
|
||||||
|
return this._createEncoderBuffer(str);
|
||||||
|
} else if (tag === 'printstr') {
|
||||||
|
if (!this._isPrintstr(str)) {
|
||||||
|
return this.reporter.error('Encoding of string type: printstr supports ' +
|
||||||
|
'only latin upper and lower case letters, ' +
|
||||||
|
'digits, space, apostrophe, left and rigth ' +
|
||||||
|
'parenthesis, plus sign, comma, hyphen, ' +
|
||||||
|
'dot, slash, colon, equal sign, ' +
|
||||||
|
'question mark');
|
||||||
|
}
|
||||||
|
return this._createEncoderBuffer(str);
|
||||||
|
} else if (/str$/.test(tag)) {
|
||||||
|
return this._createEncoderBuffer(str);
|
||||||
|
} else if (tag === 'objDesc') {
|
||||||
|
return this._createEncoderBuffer(str);
|
||||||
|
} else {
|
||||||
|
return this.reporter.error('Encoding of string type: ' + tag +
|
||||||
|
' unsupported');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
|
||||||
|
if (typeof id === 'string') {
|
||||||
|
if (!values)
|
||||||
|
return this.reporter.error('string objid given, but no values map found');
|
||||||
|
if (!values.hasOwnProperty(id))
|
||||||
|
return this.reporter.error('objid not found in values map');
|
||||||
|
id = values[id].split(/[\s.]+/g);
|
||||||
|
for (let i = 0; i < id.length; i++)
|
||||||
|
id[i] |= 0;
|
||||||
|
} else if (Array.isArray(id)) {
|
||||||
|
id = id.slice();
|
||||||
|
for (let i = 0; i < id.length; i++)
|
||||||
|
id[i] |= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(id)) {
|
||||||
|
return this.reporter.error('objid() should be either array or string, ' +
|
||||||
|
'got: ' + JSON.stringify(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!relative) {
|
||||||
|
if (id[1] >= 40)
|
||||||
|
return this.reporter.error('Second objid identifier OOB');
|
||||||
|
id.splice(0, 2, id[0] * 40 + id[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count number of octets
|
||||||
|
let size = 0;
|
||||||
|
for (let i = 0; i < id.length; i++) {
|
||||||
|
let ident = id[i];
|
||||||
|
for (size++; ident >= 0x80; ident >>= 7)
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
|
||||||
|
const objid = Buffer.alloc(size);
|
||||||
|
let offset = objid.length - 1;
|
||||||
|
for (let i = id.length - 1; i >= 0; i--) {
|
||||||
|
let ident = id[i];
|
||||||
|
objid[offset--] = ident & 0x7f;
|
||||||
|
while ((ident >>= 7) > 0)
|
||||||
|
objid[offset--] = 0x80 | (ident & 0x7f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._createEncoderBuffer(objid);
|
||||||
|
};
|
||||||
|
|
||||||
|
function two(num) {
|
||||||
|
if (num < 10)
|
||||||
|
return '0' + num;
|
||||||
|
else
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
DERNode.prototype._encodeTime = function encodeTime(time, tag) {
|
||||||
|
let str;
|
||||||
|
const date = new Date(time);
|
||||||
|
|
||||||
|
if (tag === 'gentime') {
|
||||||
|
str = [
|
||||||
|
two(date.getUTCFullYear()),
|
||||||
|
two(date.getUTCMonth() + 1),
|
||||||
|
two(date.getUTCDate()),
|
||||||
|
two(date.getUTCHours()),
|
||||||
|
two(date.getUTCMinutes()),
|
||||||
|
two(date.getUTCSeconds()),
|
||||||
|
'Z'
|
||||||
|
].join('');
|
||||||
|
} else if (tag === 'utctime') {
|
||||||
|
str = [
|
||||||
|
two(date.getUTCFullYear() % 100),
|
||||||
|
two(date.getUTCMonth() + 1),
|
||||||
|
two(date.getUTCDate()),
|
||||||
|
two(date.getUTCHours()),
|
||||||
|
two(date.getUTCMinutes()),
|
||||||
|
two(date.getUTCSeconds()),
|
||||||
|
'Z'
|
||||||
|
].join('');
|
||||||
|
} else {
|
||||||
|
this.reporter.error('Encoding ' + tag + ' time is not supported yet');
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._encodeStr(str, 'octstr');
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._encodeNull = function encodeNull() {
|
||||||
|
return this._createEncoderBuffer('');
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._encodeInt = function encodeInt(num, values) {
|
||||||
|
if (typeof num === 'string') {
|
||||||
|
if (!values)
|
||||||
|
return this.reporter.error('String int or enum given, but no values map');
|
||||||
|
if (!values.hasOwnProperty(num)) {
|
||||||
|
return this.reporter.error('Values map doesn\'t contain: ' +
|
||||||
|
JSON.stringify(num));
|
||||||
|
}
|
||||||
|
num = values[num];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bignum, assume big endian
|
||||||
|
if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
|
||||||
|
const numArray = num.toArray();
|
||||||
|
if (!num.sign && numArray[0] & 0x80) {
|
||||||
|
numArray.unshift(0);
|
||||||
|
}
|
||||||
|
num = Buffer.from(numArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Buffer.isBuffer(num)) {
|
||||||
|
let size = num.length;
|
||||||
|
if (num.length === 0)
|
||||||
|
size++;
|
||||||
|
|
||||||
|
const out = Buffer.alloc(size);
|
||||||
|
num.copy(out);
|
||||||
|
if (num.length === 0)
|
||||||
|
out[0] = 0;
|
||||||
|
return this._createEncoderBuffer(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num < 0x80)
|
||||||
|
return this._createEncoderBuffer(num);
|
||||||
|
|
||||||
|
if (num < 0x100)
|
||||||
|
return this._createEncoderBuffer([0, num]);
|
||||||
|
|
||||||
|
let size = 1;
|
||||||
|
for (let i = num; i >= 0x100; i >>= 8)
|
||||||
|
size++;
|
||||||
|
|
||||||
|
const out = new Array(size);
|
||||||
|
for (let i = out.length - 1; i >= 0; i--) {
|
||||||
|
out[i] = num & 0xff;
|
||||||
|
num >>= 8;
|
||||||
|
}
|
||||||
|
if(out[0] & 0x80) {
|
||||||
|
out.unshift(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._createEncoderBuffer(Buffer.from(out));
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._encodeBool = function encodeBool(value) {
|
||||||
|
return this._createEncoderBuffer(value ? 0xff : 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._use = function use(entity, obj) {
|
||||||
|
if (typeof entity === 'function')
|
||||||
|
entity = entity(obj);
|
||||||
|
return entity._getEncoder('der').tree;
|
||||||
|
};
|
||||||
|
|
||||||
|
DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
|
||||||
|
const state = this._baseState;
|
||||||
|
let i;
|
||||||
|
if (state['default'] === null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const data = dataBuffer.join();
|
||||||
|
if (state.defaultBuffer === undefined)
|
||||||
|
state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
|
||||||
|
|
||||||
|
if (data.length !== state.defaultBuffer.length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (i=0; i < data.length; i++)
|
||||||
|
if (data[i] !== state.defaultBuffer[i])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Utility methods
|
||||||
|
|
||||||
|
function encodeTag(tag, primitive, cls, reporter) {
|
||||||
|
let res;
|
||||||
|
|
||||||
|
if (tag === 'seqof')
|
||||||
|
tag = 'seq';
|
||||||
|
else if (tag === 'setof')
|
||||||
|
tag = 'set';
|
||||||
|
|
||||||
|
if (der.tagByName.hasOwnProperty(tag))
|
||||||
|
res = der.tagByName[tag];
|
||||||
|
else if (typeof tag === 'number' && (tag | 0) === tag)
|
||||||
|
res = tag;
|
||||||
|
else
|
||||||
|
return reporter.error('Unknown tag: ' + tag);
|
||||||
|
|
||||||
|
if (res >= 0x1f)
|
||||||
|
return reporter.error('Multi-octet tag encoding unsupported');
|
||||||
|
|
||||||
|
if (!primitive)
|
||||||
|
res |= 0x20;
|
||||||
|
|
||||||
|
res |= (der.tagClassByName[cls || 'universal'] << 6);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
6
node_modules/asn1.js/lib/asn1/encoders/index.js
generated
vendored
Normal file
6
node_modules/asn1.js/lib/asn1/encoders/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const encoders = exports;
|
||||||
|
|
||||||
|
encoders.der = require('./der');
|
||||||
|
encoders.pem = require('./pem');
|
||||||
23
node_modules/asn1.js/lib/asn1/encoders/pem.js
generated
vendored
Normal file
23
node_modules/asn1.js/lib/asn1/encoders/pem.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const inherits = require('inherits');
|
||||||
|
|
||||||
|
const DEREncoder = require('./der');
|
||||||
|
|
||||||
|
function PEMEncoder(entity) {
|
||||||
|
DEREncoder.call(this, entity);
|
||||||
|
this.enc = 'pem';
|
||||||
|
}
|
||||||
|
inherits(PEMEncoder, DEREncoder);
|
||||||
|
module.exports = PEMEncoder;
|
||||||
|
|
||||||
|
PEMEncoder.prototype.encode = function encode(data, options) {
|
||||||
|
const buf = DEREncoder.prototype.encode.call(this, data);
|
||||||
|
|
||||||
|
const p = buf.toString('base64');
|
||||||
|
const out = [ '-----BEGIN ' + options.label + '-----' ];
|
||||||
|
for (let i = 0; i < p.length; i += 64)
|
||||||
|
out.push(p.slice(i, i + 64));
|
||||||
|
out.push('-----END ' + options.label + '-----');
|
||||||
|
return out.join('\n');
|
||||||
|
};
|
||||||
36
node_modules/asn1.js/package.json
generated
vendored
Normal file
36
node_modules/asn1.js/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "asn1.js",
|
||||||
|
"version": "5.4.1",
|
||||||
|
"description": "ASN.1 encoder and decoder",
|
||||||
|
"main": "lib/asn1.js",
|
||||||
|
"scripts": {
|
||||||
|
"lint-2560": "eslint --fix rfc/2560/*.js rfc/2560/test/*.js",
|
||||||
|
"lint-5280": "eslint --fix rfc/5280/*.js rfc/5280/test/*.js",
|
||||||
|
"lint": "eslint --fix lib/*.js lib/**/*.js lib/**/**/*.js && npm run lint-2560 && npm run lint-5280",
|
||||||
|
"test": "mocha --reporter spec test/*-test.js && cd rfc/2560 && npm i && npm test && cd ../../rfc/5280 && npm i && npm test && cd ../../ && npm run lint"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@github.com:indutny/asn1.js"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"asn.1",
|
||||||
|
"der"
|
||||||
|
],
|
||||||
|
"author": "Fedor Indutny",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/indutny/asn1.js/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/indutny/asn1.js",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^4.10.0",
|
||||||
|
"mocha": "^7.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"bn.js": "^4.0.0",
|
||||||
|
"inherits": "^2.0.1",
|
||||||
|
"minimalistic-assert": "^1.0.0",
|
||||||
|
"safer-buffer": "^2.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
19
node_modules/bn.js/LICENSE
generated
vendored
Normal file
19
node_modules/bn.js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright Fedor Indutny, 2015.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
200
node_modules/bn.js/README.md
generated
vendored
Normal file
200
node_modules/bn.js/README.md
generated
vendored
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
# <img src="./logo.png" alt="bn.js" width="160" height="160" />
|
||||||
|
|
||||||
|
> BigNum in pure javascript
|
||||||
|
|
||||||
|
[](http://travis-ci.org/indutny/bn.js)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
`npm install --save bn.js`
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const BN = require('bn.js');
|
||||||
|
|
||||||
|
var a = new BN('dead', 16);
|
||||||
|
var b = new BN('101010', 2);
|
||||||
|
|
||||||
|
var res = a.add(b);
|
||||||
|
console.log(res.toString(10)); // 57047
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note**: decimals are not supported in this library.
|
||||||
|
|
||||||
|
## Notation
|
||||||
|
|
||||||
|
### Prefixes
|
||||||
|
|
||||||
|
There are several prefixes to instructions that affect the way the work. Here
|
||||||
|
is the list of them in the order of appearance in the function name:
|
||||||
|
|
||||||
|
* `i` - perform operation in-place, storing the result in the host object (on
|
||||||
|
which the method was invoked). Might be used to avoid number allocation costs
|
||||||
|
* `u` - unsigned, ignore the sign of operands when performing operation, or
|
||||||
|
always return positive value. Second case applies to reduction operations
|
||||||
|
like `mod()`. In such cases if the result will be negative - modulo will be
|
||||||
|
added to the result to make it positive
|
||||||
|
|
||||||
|
### Postfixes
|
||||||
|
|
||||||
|
The only available postfix at the moment is:
|
||||||
|
|
||||||
|
* `n` - which means that the argument of the function must be a plain JavaScript
|
||||||
|
Number. Decimals are not supported.
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
|
||||||
|
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
|
||||||
|
* `a.iushln(13)` - shift bits of `a` left by 13
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
Prefixes/postfixes are put in parens at the of the line. `endian` - could be
|
||||||
|
either `le` (little-endian) or `be` (big-endian).
|
||||||
|
|
||||||
|
### Utilities
|
||||||
|
|
||||||
|
* `a.clone()` - clone number
|
||||||
|
* `a.toString(base, length)` - convert to base-string and pad with zeroes
|
||||||
|
* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
|
||||||
|
* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
|
||||||
|
* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
|
||||||
|
pad to length, throwing if already exceeding
|
||||||
|
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
|
||||||
|
which must behave like an `Array`
|
||||||
|
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
|
||||||
|
compatibility with browserify and similar tools, use this instead:
|
||||||
|
`a.toArrayLike(Buffer, endian, length)`
|
||||||
|
* `a.bitLength()` - get number of bits occupied
|
||||||
|
* `a.zeroBits()` - return number of less-significant consequent zero bits
|
||||||
|
(example: `1010000` has 4 zero bits)
|
||||||
|
* `a.byteLength()` - return number of bytes occupied
|
||||||
|
* `a.isNeg()` - true if the number is negative
|
||||||
|
* `a.isEven()` - no comments
|
||||||
|
* `a.isOdd()` - no comments
|
||||||
|
* `a.isZero()` - no comments
|
||||||
|
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
|
||||||
|
depending on the comparison result (`ucmp`, `cmpn`)
|
||||||
|
* `a.lt(b)` - `a` less than `b` (`n`)
|
||||||
|
* `a.lte(b)` - `a` less than or equals `b` (`n`)
|
||||||
|
* `a.gt(b)` - `a` greater than `b` (`n`)
|
||||||
|
* `a.gte(b)` - `a` greater than or equals `b` (`n`)
|
||||||
|
* `a.eq(b)` - `a` equals `b` (`n`)
|
||||||
|
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
|
||||||
|
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
|
||||||
|
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
|
||||||
|
|
||||||
|
### Arithmetics
|
||||||
|
|
||||||
|
* `a.neg()` - negate sign (`i`)
|
||||||
|
* `a.abs()` - absolute value (`i`)
|
||||||
|
* `a.add(b)` - addition (`i`, `n`, `in`)
|
||||||
|
* `a.sub(b)` - subtraction (`i`, `n`, `in`)
|
||||||
|
* `a.mul(b)` - multiply (`i`, `n`, `in`)
|
||||||
|
* `a.sqr()` - square (`i`)
|
||||||
|
* `a.pow(b)` - raise `a` to the power of `b`
|
||||||
|
* `a.div(b)` - divide (`divn`, `idivn`)
|
||||||
|
* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
|
||||||
|
* `a.divRound(b)` - rounded division
|
||||||
|
|
||||||
|
### Bit operations
|
||||||
|
|
||||||
|
* `a.or(b)` - or (`i`, `u`, `iu`)
|
||||||
|
* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
|
||||||
|
with `andn` in future)
|
||||||
|
* `a.xor(b)` - xor (`i`, `u`, `iu`)
|
||||||
|
* `a.setn(b)` - set specified bit to `1`
|
||||||
|
* `a.shln(b)` - shift left (`i`, `u`, `iu`)
|
||||||
|
* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
|
||||||
|
* `a.testn(b)` - test if specified bit is set
|
||||||
|
* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
|
||||||
|
* `a.bincn(b)` - add `1 << b` to the number
|
||||||
|
* `a.notn(w)` - not (for the width specified by `w`) (`i`)
|
||||||
|
|
||||||
|
### Reduction
|
||||||
|
|
||||||
|
* `a.gcd(b)` - GCD
|
||||||
|
* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
|
||||||
|
* `a.invm(b)` - inverse `a` modulo `b`
|
||||||
|
|
||||||
|
## Fast reduction
|
||||||
|
|
||||||
|
When doing lots of reductions using the same modulo, it might be beneficial to
|
||||||
|
use some tricks: like [Montgomery multiplication][0], or using special algorithm
|
||||||
|
for [Mersenne Prime][1].
|
||||||
|
|
||||||
|
### Reduction context
|
||||||
|
|
||||||
|
To enable this tricks one should create a reduction context:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var red = BN.red(num);
|
||||||
|
```
|
||||||
|
where `num` is just a BN instance.
|
||||||
|
|
||||||
|
Or:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var red = BN.red(primeName);
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `primeName` is either of these [Mersenne Primes][1]:
|
||||||
|
|
||||||
|
* `'k256'`
|
||||||
|
* `'p224'`
|
||||||
|
* `'p192'`
|
||||||
|
* `'p25519'`
|
||||||
|
|
||||||
|
Or:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var red = BN.mont(num);
|
||||||
|
```
|
||||||
|
|
||||||
|
To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
|
||||||
|
`.red(num)`, but slower than `BN.red(primeName)`.
|
||||||
|
|
||||||
|
### Converting numbers
|
||||||
|
|
||||||
|
Before performing anything in reduction context - numbers should be converted
|
||||||
|
to it. Usually, this means that one should:
|
||||||
|
|
||||||
|
* Convert inputs to reducted ones
|
||||||
|
* Operate on them in reduction context
|
||||||
|
* Convert outputs back from the reduction context
|
||||||
|
|
||||||
|
Here is how one may convert numbers to `red`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var redA = a.toRed(red);
|
||||||
|
```
|
||||||
|
Where `red` is a reduction context created using instructions above
|
||||||
|
|
||||||
|
Here is how to convert them back:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var a = redA.fromRed();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Red instructions
|
||||||
|
|
||||||
|
Most of the instructions from the very start of this readme have their
|
||||||
|
counterparts in red context:
|
||||||
|
|
||||||
|
* `a.redAdd(b)`, `a.redIAdd(b)`
|
||||||
|
* `a.redSub(b)`, `a.redISub(b)`
|
||||||
|
* `a.redShl(num)`
|
||||||
|
* `a.redMul(b)`, `a.redIMul(b)`
|
||||||
|
* `a.redSqr()`, `a.redISqr()`
|
||||||
|
* `a.redSqrt()` - square root modulo reduction context's prime
|
||||||
|
* `a.redInvm()` - modular inverse of the number
|
||||||
|
* `a.redNeg()`
|
||||||
|
* `a.redPow(b)` - modular exponentiation
|
||||||
|
|
||||||
|
## LICENSE
|
||||||
|
|
||||||
|
This software is licensed under the MIT License.
|
||||||
|
|
||||||
|
[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
|
||||||
|
[1]: https://en.wikipedia.org/wiki/Mersenne_prime
|
||||||
3446
node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
3446
node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
36
node_modules/bn.js/package.json
generated
vendored
Normal file
36
node_modules/bn.js/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "bn.js",
|
||||||
|
"version": "4.12.0",
|
||||||
|
"description": "Big number implementation in pure javascript",
|
||||||
|
"main": "lib/bn.js",
|
||||||
|
"scripts": {
|
||||||
|
"lint": "semistandard",
|
||||||
|
"unit": "mocha --reporter=spec test/*-test.js",
|
||||||
|
"test": "npm run lint && npm run unit"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@github.com:indutny/bn.js"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"BN",
|
||||||
|
"BigNum",
|
||||||
|
"Big number",
|
||||||
|
"Modulo",
|
||||||
|
"Montgomery"
|
||||||
|
],
|
||||||
|
"author": "Fedor Indutny <fedor@indutny.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/indutny/bn.js/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/indutny/bn.js",
|
||||||
|
"browser": {
|
||||||
|
"buffer": false
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"istanbul": "^0.3.5",
|
||||||
|
"mocha": "^2.1.0",
|
||||||
|
"semistandard": "^7.0.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
672
node_modules/body-parser/HISTORY.md
generated
vendored
Normal file
672
node_modules/body-parser/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,672 @@
|
|||||||
|
1.20.3 / 2024-09-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@6.13.0
|
||||||
|
* add `depth` option to customize the depth level in the parser
|
||||||
|
* IMPORTANT: The default `depth` level for parsing URL-encoded data is now `32` (previously was `Infinity`)
|
||||||
|
|
||||||
|
1.20.2 / 2023-02-21
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix strict json error message on Node.js 19+
|
||||||
|
* deps: content-type@~1.0.5
|
||||||
|
- perf: skip value escaping when unnecessary
|
||||||
|
* deps: raw-body@2.5.2
|
||||||
|
|
||||||
|
1.20.1 / 2022-10-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@6.11.0
|
||||||
|
* perf: remove unnecessary object clone
|
||||||
|
|
||||||
|
1.20.0 / 2022-04-02
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix error message for json parse whitespace in `strict`
|
||||||
|
* Fix internal error when inflated body exceeds limit
|
||||||
|
* Prevent loss of async hooks context
|
||||||
|
* Prevent hanging when request already read
|
||||||
|
* deps: depd@2.0.0
|
||||||
|
- Replace internal `eval` usage with `Function` constructor
|
||||||
|
- Use instance methods on `process` to check for listeners
|
||||||
|
* deps: http-errors@2.0.0
|
||||||
|
- deps: depd@2.0.0
|
||||||
|
- deps: statuses@2.0.1
|
||||||
|
* deps: on-finished@2.4.1
|
||||||
|
* deps: qs@6.10.3
|
||||||
|
* deps: raw-body@2.5.1
|
||||||
|
- deps: http-errors@2.0.0
|
||||||
|
|
||||||
|
1.19.2 / 2022-02-15
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@3.1.2
|
||||||
|
* deps: qs@6.9.7
|
||||||
|
* Fix handling of `__proto__` keys
|
||||||
|
* deps: raw-body@2.4.3
|
||||||
|
- deps: bytes@3.1.2
|
||||||
|
|
||||||
|
1.19.1 / 2021-12-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@3.1.1
|
||||||
|
* deps: http-errors@1.8.1
|
||||||
|
- deps: inherits@2.0.4
|
||||||
|
- deps: toidentifier@1.0.1
|
||||||
|
- deps: setprototypeof@1.2.0
|
||||||
|
* deps: qs@6.9.6
|
||||||
|
* deps: raw-body@2.4.2
|
||||||
|
- deps: bytes@3.1.1
|
||||||
|
- deps: http-errors@1.8.1
|
||||||
|
* deps: safe-buffer@5.2.1
|
||||||
|
* deps: type-is@~1.6.18
|
||||||
|
|
||||||
|
1.19.0 / 2019-04-25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@3.1.0
|
||||||
|
- Add petabyte (`pb`) support
|
||||||
|
* deps: http-errors@1.7.2
|
||||||
|
- Set constructor name when possible
|
||||||
|
- deps: setprototypeof@1.1.1
|
||||||
|
- deps: statuses@'>= 1.5.0 < 2'
|
||||||
|
* deps: iconv-lite@0.4.24
|
||||||
|
- Added encoding MIK
|
||||||
|
* deps: qs@6.7.0
|
||||||
|
- Fix parsing array brackets after index
|
||||||
|
* deps: raw-body@2.4.0
|
||||||
|
- deps: bytes@3.1.0
|
||||||
|
- deps: http-errors@1.7.2
|
||||||
|
- deps: iconv-lite@0.4.24
|
||||||
|
* deps: type-is@~1.6.17
|
||||||
|
- deps: mime-types@~2.1.24
|
||||||
|
- perf: prevent internal `throw` on invalid type
|
||||||
|
|
||||||
|
1.18.3 / 2018-05-14
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix stack trace for strict json parse error
|
||||||
|
* deps: depd@~1.1.2
|
||||||
|
- perf: remove argument reassignment
|
||||||
|
* deps: http-errors@~1.6.3
|
||||||
|
- deps: depd@~1.1.2
|
||||||
|
- deps: setprototypeof@1.1.0
|
||||||
|
- deps: statuses@'>= 1.3.1 < 2'
|
||||||
|
* deps: iconv-lite@0.4.23
|
||||||
|
- Fix loading encoding with year appended
|
||||||
|
- Fix deprecation warnings on Node.js 10+
|
||||||
|
* deps: qs@6.5.2
|
||||||
|
* deps: raw-body@2.3.3
|
||||||
|
- deps: http-errors@1.6.3
|
||||||
|
- deps: iconv-lite@0.4.23
|
||||||
|
* deps: type-is@~1.6.16
|
||||||
|
- deps: mime-types@~2.1.18
|
||||||
|
|
||||||
|
1.18.2 / 2017-09-22
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.9
|
||||||
|
* perf: remove argument reassignment
|
||||||
|
|
||||||
|
1.18.1 / 2017-09-12
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: content-type@~1.0.4
|
||||||
|
- perf: remove argument reassignment
|
||||||
|
- perf: skip parameter parsing when no parameters
|
||||||
|
* deps: iconv-lite@0.4.19
|
||||||
|
- Fix ISO-8859-1 regression
|
||||||
|
- Update Windows-1255
|
||||||
|
* deps: qs@6.5.1
|
||||||
|
- Fix parsing & compacting very deep objects
|
||||||
|
* deps: raw-body@2.3.2
|
||||||
|
- deps: iconv-lite@0.4.19
|
||||||
|
|
||||||
|
1.18.0 / 2017-09-08
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix JSON strict violation error to match native parse error
|
||||||
|
* Include the `body` property on verify errors
|
||||||
|
* Include the `type` property on all generated errors
|
||||||
|
* Use `http-errors` to set status code on errors
|
||||||
|
* deps: bytes@3.0.0
|
||||||
|
* deps: debug@2.6.8
|
||||||
|
* deps: depd@~1.1.1
|
||||||
|
- Remove unnecessary `Buffer` loading
|
||||||
|
* deps: http-errors@~1.6.2
|
||||||
|
- deps: depd@1.1.1
|
||||||
|
* deps: iconv-lite@0.4.18
|
||||||
|
- Add support for React Native
|
||||||
|
- Add a warning if not loaded as utf-8
|
||||||
|
- Fix CESU-8 decoding in Node.js 8
|
||||||
|
- Improve speed of ISO-8859-1 encoding
|
||||||
|
* deps: qs@6.5.0
|
||||||
|
* deps: raw-body@2.3.1
|
||||||
|
- Use `http-errors` for standard emitted errors
|
||||||
|
- deps: bytes@3.0.0
|
||||||
|
- deps: iconv-lite@0.4.18
|
||||||
|
- perf: skip buffer decoding on overage chunk
|
||||||
|
* perf: prevent internal `throw` when missing charset
|
||||||
|
|
||||||
|
1.17.2 / 2017-05-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.7
|
||||||
|
- Fix `DEBUG_MAX_ARRAY_LENGTH`
|
||||||
|
- deps: ms@2.0.0
|
||||||
|
* deps: type-is@~1.6.15
|
||||||
|
- deps: mime-types@~2.1.15
|
||||||
|
|
||||||
|
1.17.1 / 2017-03-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@6.4.0
|
||||||
|
- Fix regression parsing keys starting with `[`
|
||||||
|
|
||||||
|
1.17.0 / 2017-03-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: http-errors@~1.6.1
|
||||||
|
- Make `message` property enumerable for `HttpError`s
|
||||||
|
- deps: setprototypeof@1.0.3
|
||||||
|
* deps: qs@6.3.1
|
||||||
|
- Fix compacting nested arrays
|
||||||
|
|
||||||
|
1.16.1 / 2017-02-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.1
|
||||||
|
- Fix deprecation messages in WebStorm and other editors
|
||||||
|
- Undeprecate `DEBUG_FD` set to `1` or `2`
|
||||||
|
|
||||||
|
1.16.0 / 2017-01-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.0
|
||||||
|
- Allow colors in workers
|
||||||
|
- Deprecated `DEBUG_FD` environment variable
|
||||||
|
- Fix error when running under React Native
|
||||||
|
- Use same color for same namespace
|
||||||
|
- deps: ms@0.7.2
|
||||||
|
* deps: http-errors@~1.5.1
|
||||||
|
- deps: inherits@2.0.3
|
||||||
|
- deps: setprototypeof@1.0.2
|
||||||
|
- deps: statuses@'>= 1.3.1 < 2'
|
||||||
|
* deps: iconv-lite@0.4.15
|
||||||
|
- Added encoding MS-31J
|
||||||
|
- Added encoding MS-932
|
||||||
|
- Added encoding MS-936
|
||||||
|
- Added encoding MS-949
|
||||||
|
- Added encoding MS-950
|
||||||
|
- Fix GBK/GB18030 handling of Euro character
|
||||||
|
* deps: qs@6.2.1
|
||||||
|
- Fix array parsing from skipping empty values
|
||||||
|
* deps: raw-body@~2.2.0
|
||||||
|
- deps: iconv-lite@0.4.15
|
||||||
|
* deps: type-is@~1.6.14
|
||||||
|
- deps: mime-types@~2.1.13
|
||||||
|
|
||||||
|
1.15.2 / 2016-06-19
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@2.4.0
|
||||||
|
* deps: content-type@~1.0.2
|
||||||
|
- perf: enable strict mode
|
||||||
|
* deps: http-errors@~1.5.0
|
||||||
|
- Use `setprototypeof` module to replace `__proto__` setting
|
||||||
|
- deps: statuses@'>= 1.3.0 < 2'
|
||||||
|
- perf: enable strict mode
|
||||||
|
* deps: qs@6.2.0
|
||||||
|
* deps: raw-body@~2.1.7
|
||||||
|
- deps: bytes@2.4.0
|
||||||
|
- perf: remove double-cleanup on happy path
|
||||||
|
* deps: type-is@~1.6.13
|
||||||
|
- deps: mime-types@~2.1.11
|
||||||
|
|
||||||
|
1.15.1 / 2016-05-05
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@2.3.0
|
||||||
|
- Drop partial bytes on all parsed units
|
||||||
|
- Fix parsing byte string that looks like hex
|
||||||
|
* deps: raw-body@~2.1.6
|
||||||
|
- deps: bytes@2.3.0
|
||||||
|
* deps: type-is@~1.6.12
|
||||||
|
- deps: mime-types@~2.1.10
|
||||||
|
|
||||||
|
1.15.0 / 2016-02-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: http-errors@~1.4.0
|
||||||
|
- Add `HttpError` export, for `err instanceof createError.HttpError`
|
||||||
|
- deps: inherits@2.0.1
|
||||||
|
- deps: statuses@'>= 1.2.1 < 2'
|
||||||
|
* deps: qs@6.1.0
|
||||||
|
* deps: type-is@~1.6.11
|
||||||
|
- deps: mime-types@~2.1.9
|
||||||
|
|
||||||
|
1.14.2 / 2015-12-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@2.2.0
|
||||||
|
* deps: iconv-lite@0.4.13
|
||||||
|
* deps: qs@5.2.0
|
||||||
|
* deps: raw-body@~2.1.5
|
||||||
|
- deps: bytes@2.2.0
|
||||||
|
- deps: iconv-lite@0.4.13
|
||||||
|
* deps: type-is@~1.6.10
|
||||||
|
- deps: mime-types@~2.1.8
|
||||||
|
|
||||||
|
1.14.1 / 2015-09-27
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix issue where invalid charset results in 400 when `verify` used
|
||||||
|
* deps: iconv-lite@0.4.12
|
||||||
|
- Fix CESU-8 decoding in Node.js 4.x
|
||||||
|
* deps: raw-body@~2.1.4
|
||||||
|
- Fix masking critical errors from `iconv-lite`
|
||||||
|
- deps: iconv-lite@0.4.12
|
||||||
|
* deps: type-is@~1.6.9
|
||||||
|
- deps: mime-types@~2.1.7
|
||||||
|
|
||||||
|
1.14.0 / 2015-09-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix JSON strict parse error to match syntax errors
|
||||||
|
* Provide static `require` analysis in `urlencoded` parser
|
||||||
|
* deps: depd@~1.1.0
|
||||||
|
- Support web browser loading
|
||||||
|
* deps: qs@5.1.0
|
||||||
|
* deps: raw-body@~2.1.3
|
||||||
|
- Fix sync callback when attaching data listener causes sync read
|
||||||
|
* deps: type-is@~1.6.8
|
||||||
|
- Fix type error when given invalid type to match against
|
||||||
|
- deps: mime-types@~2.1.6
|
||||||
|
|
||||||
|
1.13.3 / 2015-07-31
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: type-is@~1.6.6
|
||||||
|
- deps: mime-types@~2.1.4
|
||||||
|
|
||||||
|
1.13.2 / 2015-07-05
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.11
|
||||||
|
* deps: qs@4.0.0
|
||||||
|
- Fix dropping parameters like `hasOwnProperty`
|
||||||
|
- Fix user-visible incompatibilities from 3.1.0
|
||||||
|
- Fix various parsing edge cases
|
||||||
|
* deps: raw-body@~2.1.2
|
||||||
|
- Fix error stack traces to skip `makeError`
|
||||||
|
- deps: iconv-lite@0.4.11
|
||||||
|
* deps: type-is@~1.6.4
|
||||||
|
- deps: mime-types@~2.1.2
|
||||||
|
- perf: enable strict mode
|
||||||
|
- perf: remove argument reassignment
|
||||||
|
|
||||||
|
1.13.1 / 2015-06-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@2.4.2
|
||||||
|
- Downgraded from 3.1.0 because of user-visible incompatibilities
|
||||||
|
|
||||||
|
1.13.0 / 2015-06-14
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Add `statusCode` property on `Error`s, in addition to `status`
|
||||||
|
* Change `type` default to `application/json` for JSON parser
|
||||||
|
* Change `type` default to `application/x-www-form-urlencoded` for urlencoded parser
|
||||||
|
* Provide static `require` analysis
|
||||||
|
* Use the `http-errors` module to generate errors
|
||||||
|
* deps: bytes@2.1.0
|
||||||
|
- Slight optimizations
|
||||||
|
* deps: iconv-lite@0.4.10
|
||||||
|
- The encoding UTF-16 without BOM now defaults to UTF-16LE when detection fails
|
||||||
|
- Leading BOM is now removed when decoding
|
||||||
|
* deps: on-finished@~2.3.0
|
||||||
|
- Add defined behavior for HTTP `CONNECT` requests
|
||||||
|
- Add defined behavior for HTTP `Upgrade` requests
|
||||||
|
- deps: ee-first@1.1.1
|
||||||
|
* deps: qs@3.1.0
|
||||||
|
- Fix dropping parameters like `hasOwnProperty`
|
||||||
|
- Fix various parsing edge cases
|
||||||
|
- Parsed object now has `null` prototype
|
||||||
|
* deps: raw-body@~2.1.1
|
||||||
|
- Use `unpipe` module for unpiping requests
|
||||||
|
- deps: iconv-lite@0.4.10
|
||||||
|
* deps: type-is@~1.6.3
|
||||||
|
- deps: mime-types@~2.1.1
|
||||||
|
- perf: reduce try block size
|
||||||
|
- perf: remove bitwise operations
|
||||||
|
* perf: enable strict mode
|
||||||
|
* perf: remove argument reassignment
|
||||||
|
* perf: remove delete call
|
||||||
|
|
||||||
|
1.12.4 / 2015-05-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@~2.2.0
|
||||||
|
* deps: qs@2.4.2
|
||||||
|
- Fix allowing parameters like `constructor`
|
||||||
|
* deps: on-finished@~2.2.1
|
||||||
|
* deps: raw-body@~2.0.1
|
||||||
|
- Fix a false-positive when unpiping in Node.js 0.8
|
||||||
|
- deps: bytes@2.0.1
|
||||||
|
* deps: type-is@~1.6.2
|
||||||
|
- deps: mime-types@~2.0.11
|
||||||
|
|
||||||
|
1.12.3 / 2015-04-15
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Slight efficiency improvement when not debugging
|
||||||
|
* deps: depd@~1.0.1
|
||||||
|
* deps: iconv-lite@0.4.8
|
||||||
|
- Add encoding alias UNICODE-1-1-UTF-7
|
||||||
|
* deps: raw-body@1.3.4
|
||||||
|
- Fix hanging callback if request aborts during read
|
||||||
|
- deps: iconv-lite@0.4.8
|
||||||
|
|
||||||
|
1.12.2 / 2015-03-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@2.4.1
|
||||||
|
- Fix error when parameter `hasOwnProperty` is present
|
||||||
|
|
||||||
|
1.12.1 / 2015-03-15
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@~2.1.3
|
||||||
|
- Fix high intensity foreground color for bold
|
||||||
|
- deps: ms@0.7.0
|
||||||
|
* deps: type-is@~1.6.1
|
||||||
|
- deps: mime-types@~2.0.10
|
||||||
|
|
||||||
|
1.12.0 / 2015-02-13
|
||||||
|
===================
|
||||||
|
|
||||||
|
* add `debug` messages
|
||||||
|
* accept a function for the `type` option
|
||||||
|
* use `content-type` to parse `Content-Type` headers
|
||||||
|
* deps: iconv-lite@0.4.7
|
||||||
|
- Gracefully support enumerables on `Object.prototype`
|
||||||
|
* deps: raw-body@1.3.3
|
||||||
|
- deps: iconv-lite@0.4.7
|
||||||
|
* deps: type-is@~1.6.0
|
||||||
|
- fix argument reassignment
|
||||||
|
- fix false-positives in `hasBody` `Transfer-Encoding` check
|
||||||
|
- support wildcard for both type and subtype (`*/*`)
|
||||||
|
- deps: mime-types@~2.0.9
|
||||||
|
|
||||||
|
1.11.0 / 2015-01-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* make internal `extended: true` depth limit infinity
|
||||||
|
* deps: type-is@~1.5.6
|
||||||
|
- deps: mime-types@~2.0.8
|
||||||
|
|
||||||
|
1.10.2 / 2015-01-20
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.6
|
||||||
|
- Fix rare aliases of single-byte encodings
|
||||||
|
* deps: raw-body@1.3.2
|
||||||
|
- deps: iconv-lite@0.4.6
|
||||||
|
|
||||||
|
1.10.1 / 2015-01-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: on-finished@~2.2.0
|
||||||
|
* deps: type-is@~1.5.5
|
||||||
|
- deps: mime-types@~2.0.7
|
||||||
|
|
||||||
|
1.10.0 / 2014-12-02
|
||||||
|
===================
|
||||||
|
|
||||||
|
* make internal `extended: true` array limit dynamic
|
||||||
|
|
||||||
|
1.9.3 / 2014-11-21
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.5
|
||||||
|
- Fix Windows-31J and X-SJIS encoding support
|
||||||
|
* deps: qs@2.3.3
|
||||||
|
- Fix `arrayLimit` behavior
|
||||||
|
* deps: raw-body@1.3.1
|
||||||
|
- deps: iconv-lite@0.4.5
|
||||||
|
* deps: type-is@~1.5.3
|
||||||
|
- deps: mime-types@~2.0.3
|
||||||
|
|
||||||
|
1.9.2 / 2014-10-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.3.2
|
||||||
|
- Fix parsing of mixed objects and values
|
||||||
|
|
||||||
|
1.9.1 / 2014-10-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: on-finished@~2.1.1
|
||||||
|
- Fix handling of pipelined requests
|
||||||
|
* deps: qs@2.3.0
|
||||||
|
- Fix parsing of mixed implicit and explicit arrays
|
||||||
|
* deps: type-is@~1.5.2
|
||||||
|
- deps: mime-types@~2.0.2
|
||||||
|
|
||||||
|
1.9.0 / 2014-09-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* include the charset in "unsupported charset" error message
|
||||||
|
* include the encoding in "unsupported content encoding" error message
|
||||||
|
* deps: depd@~1.0.0
|
||||||
|
|
||||||
|
1.8.4 / 2014-09-23
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix content encoding to be case-insensitive
|
||||||
|
|
||||||
|
1.8.3 / 2014-09-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.2.4
|
||||||
|
- Fix issue with object keys starting with numbers truncated
|
||||||
|
|
||||||
|
1.8.2 / 2014-09-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.5
|
||||||
|
|
||||||
|
1.8.1 / 2014-09-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: media-typer@0.3.0
|
||||||
|
* deps: type-is@~1.5.1
|
||||||
|
|
||||||
|
1.8.0 / 2014-09-05
|
||||||
|
==================
|
||||||
|
|
||||||
|
* make empty-body-handling consistent between chunked requests
|
||||||
|
- empty `json` produces `{}`
|
||||||
|
- empty `raw` produces `new Buffer(0)`
|
||||||
|
- empty `text` produces `''`
|
||||||
|
- empty `urlencoded` produces `{}`
|
||||||
|
* deps: qs@2.2.3
|
||||||
|
- Fix issue where first empty value in array is discarded
|
||||||
|
* deps: type-is@~1.5.0
|
||||||
|
- fix `hasbody` to be true for `content-length: 0`
|
||||||
|
|
||||||
|
1.7.0 / 2014-09-01
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `parameterLimit` option to `urlencoded` parser
|
||||||
|
* change `urlencoded` extended array limit to 100
|
||||||
|
* respond with 413 when over `parameterLimit` in `urlencoded`
|
||||||
|
|
||||||
|
1.6.7 / 2014-08-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.2.2
|
||||||
|
- Remove unnecessary cloning
|
||||||
|
|
||||||
|
1.6.6 / 2014-08-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.2.0
|
||||||
|
- Array parsing fix
|
||||||
|
- Performance improvements
|
||||||
|
|
||||||
|
1.6.5 / 2014-08-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: on-finished@2.1.0
|
||||||
|
|
||||||
|
1.6.4 / 2014-08-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.2.2
|
||||||
|
|
||||||
|
1.6.3 / 2014-08-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.2.1
|
||||||
|
|
||||||
|
1.6.2 / 2014-08-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.2.0
|
||||||
|
- Fix parsing array of objects
|
||||||
|
|
||||||
|
1.6.1 / 2014-08-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.1.0
|
||||||
|
- Accept urlencoded square brackets
|
||||||
|
- Accept empty values in implicit array notation
|
||||||
|
|
||||||
|
1.6.0 / 2014-08-05
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.0.2
|
||||||
|
- Complete rewrite
|
||||||
|
- Limits array length to 20
|
||||||
|
- Limits object depth to 5
|
||||||
|
- Limits parameters to 1,000
|
||||||
|
|
||||||
|
1.5.2 / 2014-07-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.4
|
||||||
|
- Work-around v8 generating empty stack traces
|
||||||
|
|
||||||
|
1.5.1 / 2014-07-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.3
|
||||||
|
- Fix exception when global `Error.stackTraceLimit` is too low
|
||||||
|
|
||||||
|
1.5.0 / 2014-07-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.2
|
||||||
|
- Add `TRACE_DEPRECATION` environment variable
|
||||||
|
- Remove non-standard grey color from color output
|
||||||
|
- Support `--no-deprecation` argument
|
||||||
|
- Support `--trace-deprecation` argument
|
||||||
|
* deps: iconv-lite@0.4.4
|
||||||
|
- Added encoding UTF-7
|
||||||
|
* deps: raw-body@1.3.0
|
||||||
|
- deps: iconv-lite@0.4.4
|
||||||
|
- Added encoding UTF-7
|
||||||
|
- Fix `Cannot switch to old mode now` error on Node.js 0.10+
|
||||||
|
* deps: type-is@~1.3.2
|
||||||
|
|
||||||
|
1.4.3 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: type-is@1.3.1
|
||||||
|
- fix global variable leak
|
||||||
|
|
||||||
|
1.4.2 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: type-is@1.3.0
|
||||||
|
- improve type parsing
|
||||||
|
|
||||||
|
1.4.1 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix urlencoded extended deprecation message
|
||||||
|
|
||||||
|
1.4.0 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `text` parser
|
||||||
|
* add `raw` parser
|
||||||
|
* check accepted charset in content-type (accepts utf-8)
|
||||||
|
* check accepted encoding in content-encoding (accepts identity)
|
||||||
|
* deprecate `bodyParser()` middleware; use `.json()` and `.urlencoded()` as needed
|
||||||
|
* deprecate `urlencoded()` without provided `extended` option
|
||||||
|
* lazy-load urlencoded parsers
|
||||||
|
* parsers split into files for reduced mem usage
|
||||||
|
* support gzip and deflate bodies
|
||||||
|
- set `inflate: false` to turn off
|
||||||
|
* deps: raw-body@1.2.2
|
||||||
|
- Support all encodings from `iconv-lite`
|
||||||
|
|
||||||
|
1.3.1 / 2014-06-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: type-is@1.2.1
|
||||||
|
- Switch dependency from mime to mime-types@1.0.0
|
||||||
|
|
||||||
|
1.3.0 / 2014-05-31
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `extended` option to urlencoded parser
|
||||||
|
|
||||||
|
1.2.2 / 2014-05-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: raw-body@1.1.6
|
||||||
|
- assert stream encoding on node.js 0.8
|
||||||
|
- assert stream encoding on node.js < 0.10.6
|
||||||
|
- deps: bytes@1
|
||||||
|
|
||||||
|
1.2.1 / 2014-05-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* invoke `next(err)` after request fully read
|
||||||
|
- prevents hung responses and socket hang ups
|
||||||
|
|
||||||
|
1.2.0 / 2014-05-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `verify` option
|
||||||
|
* deps: type-is@1.2.0
|
||||||
|
- support suffix matching
|
||||||
|
|
||||||
|
1.1.2 / 2014-05-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* improve json parser speed
|
||||||
|
|
||||||
|
1.1.1 / 2014-05-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix repeated limit parsing with every request
|
||||||
|
|
||||||
|
1.1.0 / 2014-05-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `type` option
|
||||||
|
* deps: pin for safety and consistency
|
||||||
|
|
||||||
|
1.0.2 / 2014-04-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* use `type-is` module
|
||||||
|
|
||||||
|
1.0.1 / 2014-03-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* lower default limits to 100kb
|
||||||
23
node_modules/body-parser/LICENSE
generated
vendored
Normal file
23
node_modules/body-parser/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
476
node_modules/body-parser/README.md
generated
vendored
Normal file
476
node_modules/body-parser/README.md
generated
vendored
Normal file
@@ -0,0 +1,476 @@
|
|||||||
|
# body-parser
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Build Status][ci-image]][ci-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
|
||||||
|
|
||||||
|
Node.js body parsing middleware.
|
||||||
|
|
||||||
|
Parse incoming request bodies in a middleware before your handlers, available
|
||||||
|
under the `req.body` property.
|
||||||
|
|
||||||
|
**Note** As `req.body`'s shape is based on user-controlled input, all
|
||||||
|
properties and values in this object are untrusted and should be validated
|
||||||
|
before trusting. For example, `req.body.foo.toString()` may fail in multiple
|
||||||
|
ways, for example the `foo` property may not be there or may not be a string,
|
||||||
|
and `toString` may not be a function and instead a string or other user input.
|
||||||
|
|
||||||
|
[Learn about the anatomy of an HTTP transaction in Node.js](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/).
|
||||||
|
|
||||||
|
_This does not handle multipart bodies_, due to their complex and typically
|
||||||
|
large nature. For multipart bodies, you may be interested in the following
|
||||||
|
modules:
|
||||||
|
|
||||||
|
* [busboy](https://www.npmjs.org/package/busboy#readme) and
|
||||||
|
[connect-busboy](https://www.npmjs.org/package/connect-busboy#readme)
|
||||||
|
* [multiparty](https://www.npmjs.org/package/multiparty#readme) and
|
||||||
|
[connect-multiparty](https://www.npmjs.org/package/connect-multiparty#readme)
|
||||||
|
* [formidable](https://www.npmjs.org/package/formidable#readme)
|
||||||
|
* [multer](https://www.npmjs.org/package/multer#readme)
|
||||||
|
|
||||||
|
This module provides the following parsers:
|
||||||
|
|
||||||
|
* [JSON body parser](#bodyparserjsonoptions)
|
||||||
|
* [Raw body parser](#bodyparserrawoptions)
|
||||||
|
* [Text body parser](#bodyparsertextoptions)
|
||||||
|
* [URL-encoded form body parser](#bodyparserurlencodedoptions)
|
||||||
|
|
||||||
|
Other body parsers you might be interested in:
|
||||||
|
|
||||||
|
- [body](https://www.npmjs.org/package/body#readme)
|
||||||
|
- [co-body](https://www.npmjs.org/package/co-body#readme)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install body-parser
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
```
|
||||||
|
|
||||||
|
The `bodyParser` object exposes various factories to create middlewares. All
|
||||||
|
middlewares will populate the `req.body` property with the parsed body when
|
||||||
|
the `Content-Type` request header matches the `type` option, or an empty
|
||||||
|
object (`{}`) if there was no body to parse, the `Content-Type` was not matched,
|
||||||
|
or an error occurred.
|
||||||
|
|
||||||
|
The various errors returned by this module are described in the
|
||||||
|
[errors section](#errors).
|
||||||
|
|
||||||
|
### bodyParser.json([options])
|
||||||
|
|
||||||
|
Returns middleware that only parses `json` and only looks at requests where
|
||||||
|
the `Content-Type` header matches the `type` option. This parser accepts any
|
||||||
|
Unicode encoding of the body and supports automatic inflation of `gzip` and
|
||||||
|
`deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`).
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `json` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### reviver
|
||||||
|
|
||||||
|
The `reviver` option is passed directly to `JSON.parse` as the second
|
||||||
|
argument. You can find more information on this argument
|
||||||
|
[in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter).
|
||||||
|
|
||||||
|
##### strict
|
||||||
|
|
||||||
|
When set to `true`, will only accept arrays and objects; when `false` will
|
||||||
|
accept anything `JSON.parse` accepts. Defaults to `true`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not a
|
||||||
|
function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `json`), a mime type (like `application/json`), or
|
||||||
|
a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type`
|
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a truthy
|
||||||
|
value. Defaults to `application/json`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.raw([options])
|
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a `Buffer` and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser supports automatic inflation of `gzip` and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This will be a `Buffer` object
|
||||||
|
of the body.
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `raw` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function.
|
||||||
|
If not a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this
|
||||||
|
can be an extension name (like `bin`), a mime type (like
|
||||||
|
`application/octet-stream`), or a mime type with a wildcard (like `*/*` or
|
||||||
|
`application/*`). If a function, the `type` option is called as `fn(req)`
|
||||||
|
and the request is parsed if it returns a truthy value. Defaults to
|
||||||
|
`application/octet-stream`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.text([options])
|
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a string and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser supports automatic inflation of `gzip` and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` string containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This will be a string of the
|
||||||
|
body.
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `text` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### defaultCharset
|
||||||
|
|
||||||
|
Specify the default character set for the text content if the charset is not
|
||||||
|
specified in the `Content-Type` header of the request. Defaults to `utf-8`.
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not
|
||||||
|
a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `txt`), a mime type (like `text/plain`), or a mime
|
||||||
|
type with a wildcard (like `*/*` or `text/*`). If a function, the `type`
|
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a
|
||||||
|
truthy value. Defaults to `text/plain`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.urlencoded([options])
|
||||||
|
|
||||||
|
Returns middleware that only parses `urlencoded` bodies and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser accepts only UTF-8 encoding of the body and supports automatic
|
||||||
|
inflation of `gzip` and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This object will contain
|
||||||
|
key-value pairs, where the value can be a string or array (when `extended` is
|
||||||
|
`false`), or any type (when `extended` is `true`).
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `urlencoded` function takes an optional `options` object that may contain
|
||||||
|
any of the following keys:
|
||||||
|
|
||||||
|
##### extended
|
||||||
|
|
||||||
|
The `extended` option allows to choose between parsing the URL-encoded data
|
||||||
|
with the `querystring` library (when `false`) or the `qs` library (when
|
||||||
|
`true`). The "extended" syntax allows for rich objects and arrays to be
|
||||||
|
encoded into the URL-encoded format, allowing for a JSON-like experience
|
||||||
|
with URL-encoded. For more information, please
|
||||||
|
[see the qs library](https://www.npmjs.org/package/qs#readme).
|
||||||
|
|
||||||
|
Defaults to `true`, but using the default has been deprecated. Please
|
||||||
|
research into the difference between `qs` and `querystring` and choose the
|
||||||
|
appropriate setting.
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### parameterLimit
|
||||||
|
|
||||||
|
The `parameterLimit` option controls the maximum number of parameters that
|
||||||
|
are allowed in the URL-encoded data. If a request contains more parameters
|
||||||
|
than this value, a 413 will be returned to the client. Defaults to `1000`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not
|
||||||
|
a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `urlencoded`), a mime type (like
|
||||||
|
`application/x-www-form-urlencoded`), or a mime type with a wildcard (like
|
||||||
|
`*/x-www-form-urlencoded`). If a function, the `type` option is called as
|
||||||
|
`fn(req)` and the request is parsed if it returns a truthy value. Defaults
|
||||||
|
to `application/x-www-form-urlencoded`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
#### depth
|
||||||
|
|
||||||
|
The `depth` option is used to configure the maximum depth of the `qs` library when `extended` is `true`. This allows you to limit the amount of keys that are parsed and can be useful to prevent certain types of abuse. Defaults to `32`. It is recommended to keep this value as low as possible.
|
||||||
|
|
||||||
|
## Errors
|
||||||
|
|
||||||
|
The middlewares provided by this module create errors using the
|
||||||
|
[`http-errors` module](https://www.npmjs.com/package/http-errors). The errors
|
||||||
|
will typically have a `status`/`statusCode` property that contains the suggested
|
||||||
|
HTTP response code, an `expose` property to determine if the `message` property
|
||||||
|
should be displayed to the client, a `type` property to determine the type of
|
||||||
|
error without matching against the `message`, and a `body` property containing
|
||||||
|
the read body, if available.
|
||||||
|
|
||||||
|
The following are the common errors created, though any error can come through
|
||||||
|
for various reasons.
|
||||||
|
|
||||||
|
### content encoding unsupported
|
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that
|
||||||
|
contained an encoding but the "inflation" option was set to `false`. The
|
||||||
|
`status` property is set to `415`, the `type` property is set to
|
||||||
|
`'encoding.unsupported'`, and the `charset` property will be set to the
|
||||||
|
encoding that is unsupported.
|
||||||
|
|
||||||
|
### entity parse failed
|
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be
|
||||||
|
parsed by the middleware. The `status` property is set to `400`, the `type`
|
||||||
|
property is set to `'entity.parse.failed'`, and the `body` property is set to
|
||||||
|
the entity value that failed parsing.
|
||||||
|
|
||||||
|
### entity verify failed
|
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be
|
||||||
|
failed verification by the defined `verify` option. The `status` property is
|
||||||
|
set to `403`, the `type` property is set to `'entity.verify.failed'`, and the
|
||||||
|
`body` property is set to the entity value that failed verification.
|
||||||
|
|
||||||
|
### request aborted
|
||||||
|
|
||||||
|
This error will occur when the request is aborted by the client before reading
|
||||||
|
the body has finished. The `received` property will be set to the number of
|
||||||
|
bytes received before the request was aborted and the `expected` property is
|
||||||
|
set to the number of expected bytes. The `status` property is set to `400`
|
||||||
|
and `type` property is set to `'request.aborted'`.
|
||||||
|
|
||||||
|
### request entity too large
|
||||||
|
|
||||||
|
This error will occur when the request body's size is larger than the "limit"
|
||||||
|
option. The `limit` property will be set to the byte limit and the `length`
|
||||||
|
property will be set to the request body's length. The `status` property is
|
||||||
|
set to `413` and the `type` property is set to `'entity.too.large'`.
|
||||||
|
|
||||||
|
### request size did not match content length
|
||||||
|
|
||||||
|
This error will occur when the request's length did not match the length from
|
||||||
|
the `Content-Length` header. This typically occurs when the request is malformed,
|
||||||
|
typically when the `Content-Length` header was calculated based on characters
|
||||||
|
instead of bytes. The `status` property is set to `400` and the `type` property
|
||||||
|
is set to `'request.size.invalid'`.
|
||||||
|
|
||||||
|
### stream encoding should not be set
|
||||||
|
|
||||||
|
This error will occur when something called the `req.setEncoding` method prior
|
||||||
|
to this middleware. This module operates directly on bytes only and you cannot
|
||||||
|
call `req.setEncoding` when using this module. The `status` property is set to
|
||||||
|
`500` and the `type` property is set to `'stream.encoding.set'`.
|
||||||
|
|
||||||
|
### stream is not readable
|
||||||
|
|
||||||
|
This error will occur when the request is no longer readable when this middleware
|
||||||
|
attempts to read it. This typically means something other than a middleware from
|
||||||
|
this module read the request body already and the middleware was also configured to
|
||||||
|
read the same request. The `status` property is set to `500` and the `type`
|
||||||
|
property is set to `'stream.not.readable'`.
|
||||||
|
|
||||||
|
### too many parameters
|
||||||
|
|
||||||
|
This error will occur when the content of the request exceeds the configured
|
||||||
|
`parameterLimit` for the `urlencoded` parser. The `status` property is set to
|
||||||
|
`413` and the `type` property is set to `'parameters.too.many'`.
|
||||||
|
|
||||||
|
### unsupported charset "BOGUS"
|
||||||
|
|
||||||
|
This error will occur when the request had a charset parameter in the
|
||||||
|
`Content-Type` header, but the `iconv-lite` module does not support it OR the
|
||||||
|
parser does not support it. The charset is contained in the message as well
|
||||||
|
as in the `charset` property. The `status` property is set to `415`, the
|
||||||
|
`type` property is set to `'charset.unsupported'`, and the `charset` property
|
||||||
|
is set to the charset that is unsupported.
|
||||||
|
|
||||||
|
### unsupported content encoding "bogus"
|
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that
|
||||||
|
contained an unsupported encoding. The encoding is contained in the message
|
||||||
|
as well as in the `encoding` property. The `status` property is set to `415`,
|
||||||
|
the `type` property is set to `'encoding.unsupported'`, and the `encoding`
|
||||||
|
property is set to the encoding that is unsupported.
|
||||||
|
|
||||||
|
### The input exceeded the depth
|
||||||
|
|
||||||
|
This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. When the `depth` option is set to `32` (default value), the error will not be thrown.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Express/Connect top-level generic
|
||||||
|
|
||||||
|
This example demonstrates adding a generic JSON and URL-encoded parser as a
|
||||||
|
top-level middleware, which will parse the bodies of all incoming requests.
|
||||||
|
This is the simplest setup.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var express = require('express')
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
// parse application/x-www-form-urlencoded
|
||||||
|
app.use(bodyParser.urlencoded({ extended: false }))
|
||||||
|
|
||||||
|
// parse application/json
|
||||||
|
app.use(bodyParser.json())
|
||||||
|
|
||||||
|
app.use(function (req, res) {
|
||||||
|
res.setHeader('Content-Type', 'text/plain')
|
||||||
|
res.write('you posted:\n')
|
||||||
|
res.end(JSON.stringify(req.body, null, 2))
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Express route-specific
|
||||||
|
|
||||||
|
This example demonstrates adding body parsers specifically to the routes that
|
||||||
|
need them. In general, this is the most recommended way to use body-parser with
|
||||||
|
Express.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var express = require('express')
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
// create application/json parser
|
||||||
|
var jsonParser = bodyParser.json()
|
||||||
|
|
||||||
|
// create application/x-www-form-urlencoded parser
|
||||||
|
var urlencodedParser = bodyParser.urlencoded({ extended: false })
|
||||||
|
|
||||||
|
// POST /login gets urlencoded bodies
|
||||||
|
app.post('/login', urlencodedParser, function (req, res) {
|
||||||
|
res.send('welcome, ' + req.body.username)
|
||||||
|
})
|
||||||
|
|
||||||
|
// POST /api/users gets JSON bodies
|
||||||
|
app.post('/api/users', jsonParser, function (req, res) {
|
||||||
|
// create user in req.body
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Change accepted type for parsers
|
||||||
|
|
||||||
|
All the parsers accept a `type` option which allows you to change the
|
||||||
|
`Content-Type` that the middleware will parse.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var express = require('express')
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
// parse various different custom JSON types as JSON
|
||||||
|
app.use(bodyParser.json({ type: 'application/*+json' }))
|
||||||
|
|
||||||
|
// parse some custom thing into a Buffer
|
||||||
|
app.use(bodyParser.raw({ type: 'application/vnd.custom-type' }))
|
||||||
|
|
||||||
|
// parse an HTML body into a string
|
||||||
|
app.use(bodyParser.text({ type: 'text/html' }))
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[ci-image]: https://badgen.net/github/checks/expressjs/body-parser/master?label=ci
|
||||||
|
[ci-url]: https://github.com/expressjs/body-parser/actions/workflows/ci.yml
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/body-parser/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master
|
||||||
|
[node-version-image]: https://badgen.net/npm/node/body-parser
|
||||||
|
[node-version-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/body-parser
|
||||||
|
[npm-url]: https://npmjs.org/package/body-parser
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/body-parser
|
||||||
|
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/body-parser/badge
|
||||||
|
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/body-parser
|
||||||
25
node_modules/body-parser/SECURITY.md
generated
vendored
Normal file
25
node_modules/body-parser/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Security Policies and Procedures
|
||||||
|
|
||||||
|
## Reporting a Bug
|
||||||
|
|
||||||
|
The Express team and community take all security bugs seriously. Thank you
|
||||||
|
for improving the security of Express. We appreciate your efforts and
|
||||||
|
responsible disclosure and will make every effort to acknowledge your
|
||||||
|
contributions.
|
||||||
|
|
||||||
|
Report security bugs by emailing the current owner(s) of `body-parser`. This
|
||||||
|
information can be found in the npm registry using the command
|
||||||
|
`npm owner ls body-parser`.
|
||||||
|
If unsure or unable to get the information from the above, open an issue
|
||||||
|
in the [project issue tracker](https://github.com/expressjs/body-parser/issues)
|
||||||
|
asking for the current contact information.
|
||||||
|
|
||||||
|
To ensure the timely response to your report, please ensure that the entirety
|
||||||
|
of the report is contained within the email body and not solely behind a web
|
||||||
|
link or an attachment.
|
||||||
|
|
||||||
|
At least one owner will acknowledge your email within 48 hours, and will send a
|
||||||
|
more detailed response within 48 hours indicating the next steps in handling
|
||||||
|
your report. After the initial reply to your report, the owners will
|
||||||
|
endeavor to keep you informed of the progress towards a fix and full
|
||||||
|
announcement, and may ask for additional information or guidance.
|
||||||
156
node_modules/body-parser/index.js
generated
vendored
Normal file
156
node_modules/body-parser/index.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var deprecate = require('depd')('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) {
|
||||||
|
// use default type for parsers
|
||||||
|
var opts = Object.create(options || null, {
|
||||||
|
type: {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
value: undefined,
|
||||||
|
writable: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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 = require('./lib/types/json')
|
||||||
|
break
|
||||||
|
case 'raw':
|
||||||
|
parser = require('./lib/types/raw')
|
||||||
|
break
|
||||||
|
case 'text':
|
||||||
|
parser = require('./lib/types/text')
|
||||||
|
break
|
||||||
|
case 'urlencoded':
|
||||||
|
parser = require('./lib/types/urlencoded')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// store to prevent invoking require()
|
||||||
|
return (parsers[parserName] = parser)
|
||||||
|
}
|
||||||
205
node_modules/body-parser/lib/read.js
generated
vendored
Normal file
205
node_modules/body-parser/lib/read.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var createError = require('http-errors')
|
||||||
|
var destroy = require('destroy')
|
||||||
|
var getBody = require('raw-body')
|
||||||
|
var iconv = require('iconv-lite')
|
||||||
|
var onFinished = require('on-finished')
|
||||||
|
var unpipe = require('unpipe')
|
||||||
|
var zlib = require('zlib')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// unpipe from stream and destroy
|
||||||
|
if (stream !== req) {
|
||||||
|
unpipe(req)
|
||||||
|
destroy(stream, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// read off entire request
|
||||||
|
dump(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
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump the contents of a request.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @param {function} callback
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function dump (req, callback) {
|
||||||
|
if (onFinished.isFinished(req)) {
|
||||||
|
callback(null)
|
||||||
|
} else {
|
||||||
|
onFinished(req, callback)
|
||||||
|
req.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
247
node_modules/body-parser/lib/types/json.js
generated
vendored
Normal file
247
node_modules/body-parser/lib/types/json.js
generated
vendored
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var contentType = require('content-type')
|
||||||
|
var createError = require('http-errors')
|
||||||
|
var debug = require('debug')('body-parser:json')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex
|
||||||
|
|
||||||
|
var JSON_SYNTAX_CHAR = '#'
|
||||||
|
var JSON_SYNTAX_REGEXP = /#+/g
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.slice(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 = ''
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
partial = str.substring(0, index) + JSON_SYNTAX_CHAR
|
||||||
|
|
||||||
|
for (var i = index + 1; i < str.length; i++) {
|
||||||
|
partial += JSON_SYNTAX_CHAR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
|
||||||
|
} catch (e) {
|
||||||
|
return normalizeJsonSyntaxError(e, {
|
||||||
|
message: e.message.replace(JSON_SYNTAX_REGEXP, function (placeholder) {
|
||||||
|
return str.substring(index, index + placeholder.length)
|
||||||
|
}),
|
||||||
|
stack: e.stack
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the first non-whitespace character in a string.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @return {function}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function firstchar (str) {
|
||||||
|
var match = FIRST_CHAR_REGEXP.exec(str)
|
||||||
|
|
||||||
|
return match
|
||||||
|
? match[1]
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
101
node_modules/body-parser/lib/types/raw.js
generated
vendored
Normal file
101
node_modules/body-parser/lib/types/raw.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var debug = require('debug')('body-parser:raw')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
121
node_modules/body-parser/lib/types/text.js
generated
vendored
Normal file
121
node_modules/body-parser/lib/types/text.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var contentType = require('content-type')
|
||||||
|
var debug = require('debug')('body-parser:text')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
307
node_modules/body-parser/lib/types/urlencoded.js
generated
vendored
Normal file
307
node_modules/body-parser/lib/types/urlencoded.js
generated
vendored
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var contentType = require('content-type')
|
||||||
|
var createError = require('http-errors')
|
||||||
|
var debug = require('debug')('body-parser:urlencoded')
|
||||||
|
var deprecate = require('depd')('body-parser')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
var depth = typeof opts.depth !== 'number'
|
||||||
|
? Number(opts.depth || 32)
|
||||||
|
: opts.depth
|
||||||
|
|
||||||
|
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,
|
||||||
|
depth: depth
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the extended query parser.
|
||||||
|
*
|
||||||
|
* @param {object} options
|
||||||
|
*/
|
||||||
|
|
||||||
|
function extendedparser (options) {
|
||||||
|
var parameterLimit = options.parameterLimit !== undefined
|
||||||
|
? options.parameterLimit
|
||||||
|
: 1000
|
||||||
|
|
||||||
|
var depth = typeof options.depth !== 'number'
|
||||||
|
? Number(options.depth || 32)
|
||||||
|
: options.depth
|
||||||
|
var parse = parser('qs')
|
||||||
|
|
||||||
|
if (isNaN(parameterLimit) || parameterLimit < 1) {
|
||||||
|
throw new TypeError('option parameterLimit must be a positive number')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNaN(depth) || depth < 0) {
|
||||||
|
throw new TypeError('option depth must be a zero or 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')
|
||||||
|
try {
|
||||||
|
return parse(body, {
|
||||||
|
allowPrototypes: true,
|
||||||
|
arrayLimit: arrayLimit,
|
||||||
|
depth: depth,
|
||||||
|
strictDepth: true,
|
||||||
|
parameterLimit: parameterLimit
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof RangeError) {
|
||||||
|
throw createError(400, 'The input exceeded the depth', {
|
||||||
|
type: 'querystring.parse.rangeError'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = require('qs')
|
||||||
|
break
|
||||||
|
case 'querystring':
|
||||||
|
mod = require('querystring')
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
103
node_modules/body-parser/node_modules/depd/History.md
generated
vendored
Normal file
103
node_modules/body-parser/node_modules/depd/History.md
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
2.0.0 / 2018-10-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Drop support for Node.js 0.6
|
||||||
|
* Replace internal `eval` usage with `Function` constructor
|
||||||
|
* Use instance methods on `process` to check for listeners
|
||||||
|
|
||||||
|
1.1.2 / 2018-01-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* perf: remove argument reassignment
|
||||||
|
* Support Node.js 0.6 to 9.x
|
||||||
|
|
||||||
|
1.1.1 / 2017-07-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Remove unnecessary `Buffer` loading
|
||||||
|
* Support Node.js 0.6 to 8.x
|
||||||
|
|
||||||
|
1.1.0 / 2015-09-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Enable strict mode in more places
|
||||||
|
* Support io.js 3.x
|
||||||
|
* Support io.js 2.x
|
||||||
|
* Support web browser loading
|
||||||
|
- Requires bundler like Browserify or webpack
|
||||||
|
|
||||||
|
1.0.1 / 2015-04-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix `TypeError`s when under `'use strict'` code
|
||||||
|
* Fix useless type name on auto-generated messages
|
||||||
|
* Support io.js 1.x
|
||||||
|
* Support Node.js 0.12
|
||||||
|
|
||||||
|
1.0.0 / 2014-09-17
|
||||||
|
==================
|
||||||
|
|
||||||
|
* No changes
|
||||||
|
|
||||||
|
0.4.5 / 2014-09-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Improve call speed to functions using the function wrapper
|
||||||
|
* Support Node.js 0.6
|
||||||
|
|
||||||
|
0.4.4 / 2014-07-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Work-around v8 generating empty stack traces
|
||||||
|
|
||||||
|
0.4.3 / 2014-07-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix exception when global `Error.stackTraceLimit` is too low
|
||||||
|
|
||||||
|
0.4.2 / 2014-07-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Correct call site for wrapped functions and properties
|
||||||
|
|
||||||
|
0.4.1 / 2014-07-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Improve automatic message generation for function properties
|
||||||
|
|
||||||
|
0.4.0 / 2014-07-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `TRACE_DEPRECATION` environment variable
|
||||||
|
* Remove non-standard grey color from color output
|
||||||
|
* Support `--no-deprecation` argument
|
||||||
|
* Support `--trace-deprecation` argument
|
||||||
|
* Support `deprecate.property(fn, prop, message)`
|
||||||
|
|
||||||
|
0.3.0 / 2014-06-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `NO_DEPRECATION` environment variable
|
||||||
|
|
||||||
|
0.2.0 / 2014-06-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `deprecate.property(obj, prop, message)`
|
||||||
|
* Remove `supports-color` dependency for node.js 0.8
|
||||||
|
|
||||||
|
0.1.0 / 2014-06-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `deprecate.function(fn, message)`
|
||||||
|
* Add `process.on('deprecation', fn)` emitter
|
||||||
|
* Automatically generate message when omitted from `deprecate()`
|
||||||
|
|
||||||
|
0.0.1 / 2014-06-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix warning for dynamic calls at singe call site
|
||||||
|
|
||||||
|
0.0.0 / 2014-06-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Initial implementation
|
||||||
22
node_modules/body-parser/node_modules/depd/LICENSE
generated
vendored
Normal file
22
node_modules/body-parser/node_modules/depd/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2018 Douglas Christopher Wilson
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
280
node_modules/body-parser/node_modules/depd/Readme.md
generated
vendored
Normal file
280
node_modules/body-parser/node_modules/depd/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
# depd
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Node.js Version][node-image]][node-url]
|
||||||
|
[![Linux Build][travis-image]][travis-url]
|
||||||
|
[![Windows Build][appveyor-image]][appveyor-url]
|
||||||
|
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
Deprecate all the things
|
||||||
|
|
||||||
|
> With great modules comes great responsibility; mark things deprecated!
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
This module is installed directly using `npm`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install depd
|
||||||
|
```
|
||||||
|
|
||||||
|
This module can also be bundled with systems like
|
||||||
|
[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/),
|
||||||
|
though by default this module will alter it's API to no longer display or
|
||||||
|
track deprecations.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
<!-- eslint-disable no-unused-vars -->
|
||||||
|
|
||||||
|
```js
|
||||||
|
var deprecate = require('depd')('my-module')
|
||||||
|
```
|
||||||
|
|
||||||
|
This library allows you to display deprecation messages to your users.
|
||||||
|
This library goes above and beyond with deprecation warnings by
|
||||||
|
introspection of the call stack (but only the bits that it is interested
|
||||||
|
in).
|
||||||
|
|
||||||
|
Instead of just warning on the first invocation of a deprecated
|
||||||
|
function and never again, this module will warn on the first invocation
|
||||||
|
of a deprecated function per unique call site, making it ideal to alert
|
||||||
|
users of all deprecated uses across the code base, rather than just
|
||||||
|
whatever happens to execute first.
|
||||||
|
|
||||||
|
The deprecation warnings from this module also include the file and line
|
||||||
|
information for the call into the module that the deprecated function was
|
||||||
|
in.
|
||||||
|
|
||||||
|
**NOTE** this library has a similar interface to the `debug` module, and
|
||||||
|
this module uses the calling file to get the boundary for the call stacks,
|
||||||
|
so you should always create a new `deprecate` object in each file and not
|
||||||
|
within some central file.
|
||||||
|
|
||||||
|
### depd(namespace)
|
||||||
|
|
||||||
|
Create a new deprecate function that uses the given namespace name in the
|
||||||
|
messages and will display the call site prior to the stack entering the
|
||||||
|
file this function was called from. It is highly suggested you use the
|
||||||
|
name of your module as the namespace.
|
||||||
|
|
||||||
|
### deprecate(message)
|
||||||
|
|
||||||
|
Call this function from deprecated code to display a deprecation message.
|
||||||
|
This message will appear once per unique caller site. Caller site is the
|
||||||
|
first call site in the stack in a different file from the caller of this
|
||||||
|
function.
|
||||||
|
|
||||||
|
If the message is omitted, a message is generated for you based on the site
|
||||||
|
of the `deprecate()` call and will display the name of the function called,
|
||||||
|
similar to the name displayed in a stack trace.
|
||||||
|
|
||||||
|
### deprecate.function(fn, message)
|
||||||
|
|
||||||
|
Call this function to wrap a given function in a deprecation message on any
|
||||||
|
call to the function. An optional message can be supplied to provide a custom
|
||||||
|
message.
|
||||||
|
|
||||||
|
### deprecate.property(obj, prop, message)
|
||||||
|
|
||||||
|
Call this function to wrap a given property on object in a deprecation message
|
||||||
|
on any accessing or setting of the property. An optional message can be supplied
|
||||||
|
to provide a custom message.
|
||||||
|
|
||||||
|
The method must be called on the object where the property belongs (not
|
||||||
|
inherited from the prototype).
|
||||||
|
|
||||||
|
If the property is a data descriptor, it will be converted to an accessor
|
||||||
|
descriptor in order to display the deprecation message.
|
||||||
|
|
||||||
|
### process.on('deprecation', fn)
|
||||||
|
|
||||||
|
This module will allow easy capturing of deprecation errors by emitting the
|
||||||
|
errors as the type "deprecation" on the global `process`. If there are no
|
||||||
|
listeners for this type, the errors are written to STDERR as normal, but if
|
||||||
|
there are any listeners, nothing will be written to STDERR and instead only
|
||||||
|
emitted. From there, you can write the errors in a different format or to a
|
||||||
|
logging source.
|
||||||
|
|
||||||
|
The error represents the deprecation and is emitted only once with the same
|
||||||
|
rules as writing to STDERR. The error has the following properties:
|
||||||
|
|
||||||
|
- `message` - This is the message given by the library
|
||||||
|
- `name` - This is always `'DeprecationError'`
|
||||||
|
- `namespace` - This is the namespace the deprecation came from
|
||||||
|
- `stack` - This is the stack of the call to the deprecated thing
|
||||||
|
|
||||||
|
Example `error.stack` output:
|
||||||
|
|
||||||
|
```
|
||||||
|
DeprecationError: my-cool-module deprecated oldfunction
|
||||||
|
at Object.<anonymous> ([eval]-wrapper:6:22)
|
||||||
|
at Module._compile (module.js:456:26)
|
||||||
|
at evalScript (node.js:532:25)
|
||||||
|
at startup (node.js:80:7)
|
||||||
|
at node.js:902:3
|
||||||
|
```
|
||||||
|
|
||||||
|
### process.env.NO_DEPRECATION
|
||||||
|
|
||||||
|
As a user of modules that are deprecated, the environment variable `NO_DEPRECATION`
|
||||||
|
is provided as a quick solution to silencing deprecation warnings from being
|
||||||
|
output. The format of this is similar to that of `DEBUG`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ NO_DEPRECATION=my-module,othermod node app.js
|
||||||
|
```
|
||||||
|
|
||||||
|
This will suppress deprecations from being output for "my-module" and "othermod".
|
||||||
|
The value is a list of comma-separated namespaces. To suppress every warning
|
||||||
|
across all namespaces, use the value `*` for a namespace.
|
||||||
|
|
||||||
|
Providing the argument `--no-deprecation` to the `node` executable will suppress
|
||||||
|
all deprecations (only available in Node.js 0.8 or higher).
|
||||||
|
|
||||||
|
**NOTE** This will not suppress the deperecations given to any "deprecation"
|
||||||
|
event listeners, just the output to STDERR.
|
||||||
|
|
||||||
|
### process.env.TRACE_DEPRECATION
|
||||||
|
|
||||||
|
As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
|
||||||
|
is provided as a solution to getting more detailed location information in deprecation
|
||||||
|
warnings by including the entire stack trace. The format of this is the same as
|
||||||
|
`NO_DEPRECATION`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ TRACE_DEPRECATION=my-module,othermod node app.js
|
||||||
|
```
|
||||||
|
|
||||||
|
This will include stack traces for deprecations being output for "my-module" and
|
||||||
|
"othermod". The value is a list of comma-separated namespaces. To trace every
|
||||||
|
warning across all namespaces, use the value `*` for a namespace.
|
||||||
|
|
||||||
|
Providing the argument `--trace-deprecation` to the `node` executable will trace
|
||||||
|
all deprecations (only available in Node.js 0.8 or higher).
|
||||||
|
|
||||||
|
**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
|
||||||
|
|
||||||
|
## Display
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
When a user calls a function in your library that you mark deprecated, they
|
||||||
|
will see the following written to STDERR (in the given colors, similar colors
|
||||||
|
and layout to the `debug` module):
|
||||||
|
|
||||||
|
```
|
||||||
|
bright cyan bright yellow
|
||||||
|
| | reset cyan
|
||||||
|
| | | |
|
||||||
|
▼ ▼ ▼ ▼
|
||||||
|
my-cool-module deprecated oldfunction [eval]-wrapper:6:22
|
||||||
|
▲ ▲ ▲ ▲
|
||||||
|
| | | |
|
||||||
|
namespace | | location of mycoolmod.oldfunction() call
|
||||||
|
| deprecation message
|
||||||
|
the word "deprecated"
|
||||||
|
```
|
||||||
|
|
||||||
|
If the user redirects their STDERR to a file or somewhere that does not support
|
||||||
|
colors, they see (similar layout to the `debug` module):
|
||||||
|
|
||||||
|
```
|
||||||
|
Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
|
||||||
|
▲ ▲ ▲ ▲ ▲
|
||||||
|
| | | | |
|
||||||
|
timestamp of message namespace | | location of mycoolmod.oldfunction() call
|
||||||
|
| deprecation message
|
||||||
|
the word "deprecated"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Deprecating all calls to a function
|
||||||
|
|
||||||
|
This will display a deprecated message about "oldfunction" being deprecated
|
||||||
|
from "my-module" on STDERR.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var deprecate = require('depd')('my-cool-module')
|
||||||
|
|
||||||
|
// message automatically derived from function name
|
||||||
|
// Object.oldfunction
|
||||||
|
exports.oldfunction = deprecate.function(function oldfunction () {
|
||||||
|
// all calls to function are deprecated
|
||||||
|
})
|
||||||
|
|
||||||
|
// specific message
|
||||||
|
exports.oldfunction = deprecate.function(function () {
|
||||||
|
// all calls to function are deprecated
|
||||||
|
}, 'oldfunction')
|
||||||
|
```
|
||||||
|
|
||||||
|
### Conditionally deprecating a function call
|
||||||
|
|
||||||
|
This will display a deprecated message about "weirdfunction" being deprecated
|
||||||
|
from "my-module" on STDERR when called with less than 2 arguments.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var deprecate = require('depd')('my-cool-module')
|
||||||
|
|
||||||
|
exports.weirdfunction = function () {
|
||||||
|
if (arguments.length < 2) {
|
||||||
|
// calls with 0 or 1 args are deprecated
|
||||||
|
deprecate('weirdfunction args < 2')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
When calling `deprecate` as a function, the warning is counted per call site
|
||||||
|
within your own module, so you can display different deprecations depending
|
||||||
|
on different situations and the users will still get all the warnings:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var deprecate = require('depd')('my-cool-module')
|
||||||
|
|
||||||
|
exports.weirdfunction = function () {
|
||||||
|
if (arguments.length < 2) {
|
||||||
|
// calls with 0 or 1 args are deprecated
|
||||||
|
deprecate('weirdfunction args < 2')
|
||||||
|
} else if (typeof arguments[0] !== 'string') {
|
||||||
|
// calls with non-string first argument are deprecated
|
||||||
|
deprecate('weirdfunction non-string first arg')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Deprecating property access
|
||||||
|
|
||||||
|
This will display a deprecated message about "oldprop" being deprecated
|
||||||
|
from "my-module" on STDERR when accessed. A deprecation will be displayed
|
||||||
|
when setting the value and when getting the value.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var deprecate = require('depd')('my-cool-module')
|
||||||
|
|
||||||
|
exports.oldprop = 'something'
|
||||||
|
|
||||||
|
// message automatically derives from property name
|
||||||
|
deprecate.property(exports, 'oldprop')
|
||||||
|
|
||||||
|
// explicit message
|
||||||
|
deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/nodejs-depd/master?label=windows
|
||||||
|
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/dougwilson/nodejs-depd/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
|
||||||
|
[node-image]: https://badgen.net/npm/node/depd
|
||||||
|
[node-url]: https://nodejs.org/en/download/
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/depd
|
||||||
|
[npm-url]: https://npmjs.org/package/depd
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/depd
|
||||||
|
[travis-image]: https://badgen.net/travis/dougwilson/nodejs-depd/master?label=linux
|
||||||
|
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
|
||||||
538
node_modules/body-parser/node_modules/depd/index.js
generated
vendored
Normal file
538
node_modules/body-parser/node_modules/depd/index.js
generated
vendored
Normal file
@@ -0,0 +1,538 @@
|
|||||||
|
/*!
|
||||||
|
* depd
|
||||||
|
* Copyright(c) 2014-2018 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var relative = require('path').relative
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = depd
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path to base files on.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var basePath = process.cwd()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if namespace is contained in the string.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function containsNamespace (str, namespace) {
|
||||||
|
var vals = str.split(/[ ,]+/)
|
||||||
|
var ns = String(namespace).toLowerCase()
|
||||||
|
|
||||||
|
for (var i = 0; i < vals.length; i++) {
|
||||||
|
var val = vals[i]
|
||||||
|
|
||||||
|
// namespace contained
|
||||||
|
if (val && (val === '*' || val.toLowerCase() === ns)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a data descriptor to accessor descriptor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function convertDataDescriptorToAccessor (obj, prop, message) {
|
||||||
|
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||||
|
var value = descriptor.value
|
||||||
|
|
||||||
|
descriptor.get = function getter () { return value }
|
||||||
|
|
||||||
|
if (descriptor.writable) {
|
||||||
|
descriptor.set = function setter (val) { return (value = val) }
|
||||||
|
}
|
||||||
|
|
||||||
|
delete descriptor.value
|
||||||
|
delete descriptor.writable
|
||||||
|
|
||||||
|
Object.defineProperty(obj, prop, descriptor)
|
||||||
|
|
||||||
|
return descriptor
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create arguments string to keep arity.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createArgumentsString (arity) {
|
||||||
|
var str = ''
|
||||||
|
|
||||||
|
for (var i = 0; i < arity; i++) {
|
||||||
|
str += ', arg' + i
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.substr(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create stack string from stack.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createStackString (stack) {
|
||||||
|
var str = this.name + ': ' + this.namespace
|
||||||
|
|
||||||
|
if (this.message) {
|
||||||
|
str += ' deprecated ' + this.message
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < stack.length; i++) {
|
||||||
|
str += '\n at ' + stack[i].toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create deprecate for namespace in caller.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function depd (namespace) {
|
||||||
|
if (!namespace) {
|
||||||
|
throw new TypeError('argument namespace is required')
|
||||||
|
}
|
||||||
|
|
||||||
|
var stack = getStack()
|
||||||
|
var site = callSiteLocation(stack[1])
|
||||||
|
var file = site[0]
|
||||||
|
|
||||||
|
function deprecate (message) {
|
||||||
|
// call to self as log
|
||||||
|
log.call(deprecate, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
deprecate._file = file
|
||||||
|
deprecate._ignored = isignored(namespace)
|
||||||
|
deprecate._namespace = namespace
|
||||||
|
deprecate._traced = istraced(namespace)
|
||||||
|
deprecate._warned = Object.create(null)
|
||||||
|
|
||||||
|
deprecate.function = wrapfunction
|
||||||
|
deprecate.property = wrapproperty
|
||||||
|
|
||||||
|
return deprecate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if event emitter has listeners of a given type.
|
||||||
|
*
|
||||||
|
* The way to do this check is done three different ways in Node.js >= 0.8
|
||||||
|
* so this consolidates them into a minimal set using instance methods.
|
||||||
|
*
|
||||||
|
* @param {EventEmitter} emitter
|
||||||
|
* @param {string} type
|
||||||
|
* @returns {boolean}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function eehaslisteners (emitter, type) {
|
||||||
|
var count = typeof emitter.listenerCount !== 'function'
|
||||||
|
? emitter.listeners(type).length
|
||||||
|
: emitter.listenerCount(type)
|
||||||
|
|
||||||
|
return count > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if namespace is ignored.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isignored (namespace) {
|
||||||
|
if (process.noDeprecation) {
|
||||||
|
// --no-deprecation support
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
var str = process.env.NO_DEPRECATION || ''
|
||||||
|
|
||||||
|
// namespace ignored
|
||||||
|
return containsNamespace(str, namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if namespace is traced.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function istraced (namespace) {
|
||||||
|
if (process.traceDeprecation) {
|
||||||
|
// --trace-deprecation support
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
var str = process.env.TRACE_DEPRECATION || ''
|
||||||
|
|
||||||
|
// namespace traced
|
||||||
|
return containsNamespace(str, namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display deprecation message.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function log (message, site) {
|
||||||
|
var haslisteners = eehaslisteners(process, 'deprecation')
|
||||||
|
|
||||||
|
// abort early if no destination
|
||||||
|
if (!haslisteners && this._ignored) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var caller
|
||||||
|
var callFile
|
||||||
|
var callSite
|
||||||
|
var depSite
|
||||||
|
var i = 0
|
||||||
|
var seen = false
|
||||||
|
var stack = getStack()
|
||||||
|
var file = this._file
|
||||||
|
|
||||||
|
if (site) {
|
||||||
|
// provided site
|
||||||
|
depSite = site
|
||||||
|
callSite = callSiteLocation(stack[1])
|
||||||
|
callSite.name = depSite.name
|
||||||
|
file = callSite[0]
|
||||||
|
} else {
|
||||||
|
// get call site
|
||||||
|
i = 2
|
||||||
|
depSite = callSiteLocation(stack[i])
|
||||||
|
callSite = depSite
|
||||||
|
}
|
||||||
|
|
||||||
|
// get caller of deprecated thing in relation to file
|
||||||
|
for (; i < stack.length; i++) {
|
||||||
|
caller = callSiteLocation(stack[i])
|
||||||
|
callFile = caller[0]
|
||||||
|
|
||||||
|
if (callFile === file) {
|
||||||
|
seen = true
|
||||||
|
} else if (callFile === this._file) {
|
||||||
|
file = this._file
|
||||||
|
} else if (seen) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var key = caller
|
||||||
|
? depSite.join(':') + '__' + caller.join(':')
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
if (key !== undefined && key in this._warned) {
|
||||||
|
// already warned
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this._warned[key] = true
|
||||||
|
|
||||||
|
// generate automatic message from call site
|
||||||
|
var msg = message
|
||||||
|
if (!msg) {
|
||||||
|
msg = callSite === depSite || !callSite.name
|
||||||
|
? defaultMessage(depSite)
|
||||||
|
: defaultMessage(callSite)
|
||||||
|
}
|
||||||
|
|
||||||
|
// emit deprecation if listeners exist
|
||||||
|
if (haslisteners) {
|
||||||
|
var err = DeprecationError(this._namespace, msg, stack.slice(i))
|
||||||
|
process.emit('deprecation', err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// format and write message
|
||||||
|
var format = process.stderr.isTTY
|
||||||
|
? formatColor
|
||||||
|
: formatPlain
|
||||||
|
var output = format.call(this, msg, caller, stack.slice(i))
|
||||||
|
process.stderr.write(output + '\n', 'utf8')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get call site location as array.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function callSiteLocation (callSite) {
|
||||||
|
var file = callSite.getFileName() || '<anonymous>'
|
||||||
|
var line = callSite.getLineNumber()
|
||||||
|
var colm = callSite.getColumnNumber()
|
||||||
|
|
||||||
|
if (callSite.isEval()) {
|
||||||
|
file = callSite.getEvalOrigin() + ', ' + file
|
||||||
|
}
|
||||||
|
|
||||||
|
var site = [file, line, colm]
|
||||||
|
|
||||||
|
site.callSite = callSite
|
||||||
|
site.name = callSite.getFunctionName()
|
||||||
|
|
||||||
|
return site
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a default message from the site.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function defaultMessage (site) {
|
||||||
|
var callSite = site.callSite
|
||||||
|
var funcName = site.name
|
||||||
|
|
||||||
|
// make useful anonymous name
|
||||||
|
if (!funcName) {
|
||||||
|
funcName = '<anonymous@' + formatLocation(site) + '>'
|
||||||
|
}
|
||||||
|
|
||||||
|
var context = callSite.getThis()
|
||||||
|
var typeName = context && callSite.getTypeName()
|
||||||
|
|
||||||
|
// ignore useless type name
|
||||||
|
if (typeName === 'Object') {
|
||||||
|
typeName = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
// make useful type name
|
||||||
|
if (typeName === 'Function') {
|
||||||
|
typeName = context.name || typeName
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeName && callSite.getMethodName()
|
||||||
|
? typeName + '.' + funcName
|
||||||
|
: funcName
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format deprecation message without color.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formatPlain (msg, caller, stack) {
|
||||||
|
var timestamp = new Date().toUTCString()
|
||||||
|
|
||||||
|
var formatted = timestamp +
|
||||||
|
' ' + this._namespace +
|
||||||
|
' deprecated ' + msg
|
||||||
|
|
||||||
|
// add stack trace
|
||||||
|
if (this._traced) {
|
||||||
|
for (var i = 0; i < stack.length; i++) {
|
||||||
|
formatted += '\n at ' + stack[i].toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatted
|
||||||
|
}
|
||||||
|
|
||||||
|
if (caller) {
|
||||||
|
formatted += ' at ' + formatLocation(caller)
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatted
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format deprecation message with color.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formatColor (msg, caller, stack) {
|
||||||
|
var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' + // bold cyan
|
||||||
|
' \x1b[33;1mdeprecated\x1b[22;39m' + // bold yellow
|
||||||
|
' \x1b[0m' + msg + '\x1b[39m' // reset
|
||||||
|
|
||||||
|
// add stack trace
|
||||||
|
if (this._traced) {
|
||||||
|
for (var i = 0; i < stack.length; i++) {
|
||||||
|
formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m' // cyan
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatted
|
||||||
|
}
|
||||||
|
|
||||||
|
if (caller) {
|
||||||
|
formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatted
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format call site location.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formatLocation (callSite) {
|
||||||
|
return relative(basePath, callSite[0]) +
|
||||||
|
':' + callSite[1] +
|
||||||
|
':' + callSite[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the stack as array of call sites.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getStack () {
|
||||||
|
var limit = Error.stackTraceLimit
|
||||||
|
var obj = {}
|
||||||
|
var prep = Error.prepareStackTrace
|
||||||
|
|
||||||
|
Error.prepareStackTrace = prepareObjectStackTrace
|
||||||
|
Error.stackTraceLimit = Math.max(10, limit)
|
||||||
|
|
||||||
|
// capture the stack
|
||||||
|
Error.captureStackTrace(obj)
|
||||||
|
|
||||||
|
// slice this function off the top
|
||||||
|
var stack = obj.stack.slice(1)
|
||||||
|
|
||||||
|
Error.prepareStackTrace = prep
|
||||||
|
Error.stackTraceLimit = limit
|
||||||
|
|
||||||
|
return stack
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture call site stack from v8.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function prepareObjectStackTrace (obj, stack) {
|
||||||
|
return stack
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a wrapped function in a deprecation message.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function wrapfunction (fn, message) {
|
||||||
|
if (typeof fn !== 'function') {
|
||||||
|
throw new TypeError('argument fn must be a function')
|
||||||
|
}
|
||||||
|
|
||||||
|
var args = createArgumentsString(fn.length)
|
||||||
|
var stack = getStack()
|
||||||
|
var site = callSiteLocation(stack[1])
|
||||||
|
|
||||||
|
site.name = fn.name
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-new-func
|
||||||
|
var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
|
||||||
|
'"use strict"\n' +
|
||||||
|
'return function (' + args + ') {' +
|
||||||
|
'log.call(deprecate, message, site)\n' +
|
||||||
|
'return fn.apply(this, arguments)\n' +
|
||||||
|
'}')(fn, log, this, message, site)
|
||||||
|
|
||||||
|
return deprecatedfn
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap property in a deprecation message.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function wrapproperty (obj, prop, message) {
|
||||||
|
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||||
|
throw new TypeError('argument obj must be object')
|
||||||
|
}
|
||||||
|
|
||||||
|
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||||
|
|
||||||
|
if (!descriptor) {
|
||||||
|
throw new TypeError('must call property on owner object')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!descriptor.configurable) {
|
||||||
|
throw new TypeError('property must be configurable')
|
||||||
|
}
|
||||||
|
|
||||||
|
var deprecate = this
|
||||||
|
var stack = getStack()
|
||||||
|
var site = callSiteLocation(stack[1])
|
||||||
|
|
||||||
|
// set site name
|
||||||
|
site.name = prop
|
||||||
|
|
||||||
|
// convert data descriptor
|
||||||
|
if ('value' in descriptor) {
|
||||||
|
descriptor = convertDataDescriptorToAccessor(obj, prop, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
var get = descriptor.get
|
||||||
|
var set = descriptor.set
|
||||||
|
|
||||||
|
// wrap getter
|
||||||
|
if (typeof get === 'function') {
|
||||||
|
descriptor.get = function getter () {
|
||||||
|
log.call(deprecate, message, site)
|
||||||
|
return get.apply(this, arguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrap setter
|
||||||
|
if (typeof set === 'function') {
|
||||||
|
descriptor.set = function setter () {
|
||||||
|
log.call(deprecate, message, site)
|
||||||
|
return set.apply(this, arguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(obj, prop, descriptor)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create DeprecationError for deprecation
|
||||||
|
*/
|
||||||
|
|
||||||
|
function DeprecationError (namespace, message, stack) {
|
||||||
|
var error = new Error()
|
||||||
|
var stackString
|
||||||
|
|
||||||
|
Object.defineProperty(error, 'constructor', {
|
||||||
|
value: DeprecationError
|
||||||
|
})
|
||||||
|
|
||||||
|
Object.defineProperty(error, 'message', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: false,
|
||||||
|
value: message,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
Object.defineProperty(error, 'name', {
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
value: 'DeprecationError',
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
Object.defineProperty(error, 'namespace', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: false,
|
||||||
|
value: namespace,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
Object.defineProperty(error, 'stack', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: false,
|
||||||
|
get: function () {
|
||||||
|
if (stackString !== undefined) {
|
||||||
|
return stackString
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare stack trace
|
||||||
|
return (stackString = createStackString.call(this, stack))
|
||||||
|
},
|
||||||
|
set: function setter (val) {
|
||||||
|
stackString = val
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return error
|
||||||
|
}
|
||||||
77
node_modules/body-parser/node_modules/depd/lib/browser/index.js
generated
vendored
Normal file
77
node_modules/body-parser/node_modules/depd/lib/browser/index.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/*!
|
||||||
|
* depd
|
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = depd
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create deprecate for namespace in caller.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function depd (namespace) {
|
||||||
|
if (!namespace) {
|
||||||
|
throw new TypeError('argument namespace is required')
|
||||||
|
}
|
||||||
|
|
||||||
|
function deprecate (message) {
|
||||||
|
// no-op in browser
|
||||||
|
}
|
||||||
|
|
||||||
|
deprecate._file = undefined
|
||||||
|
deprecate._ignored = true
|
||||||
|
deprecate._namespace = namespace
|
||||||
|
deprecate._traced = false
|
||||||
|
deprecate._warned = Object.create(null)
|
||||||
|
|
||||||
|
deprecate.function = wrapfunction
|
||||||
|
deprecate.property = wrapproperty
|
||||||
|
|
||||||
|
return deprecate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a wrapped function in a deprecation message.
|
||||||
|
*
|
||||||
|
* This is a no-op version of the wrapper, which does nothing but call
|
||||||
|
* validation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function wrapfunction (fn, message) {
|
||||||
|
if (typeof fn !== 'function') {
|
||||||
|
throw new TypeError('argument fn must be a function')
|
||||||
|
}
|
||||||
|
|
||||||
|
return fn
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap property in a deprecation message.
|
||||||
|
*
|
||||||
|
* This is a no-op version of the wrapper, which does nothing but call
|
||||||
|
* validation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function wrapproperty (obj, prop, message) {
|
||||||
|
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||||
|
throw new TypeError('argument obj must be object')
|
||||||
|
}
|
||||||
|
|
||||||
|
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||||
|
|
||||||
|
if (!descriptor) {
|
||||||
|
throw new TypeError('must call property on owner object')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!descriptor.configurable) {
|
||||||
|
throw new TypeError('property must be configurable')
|
||||||
|
}
|
||||||
|
}
|
||||||
45
node_modules/body-parser/node_modules/depd/package.json
generated
vendored
Normal file
45
node_modules/body-parser/node_modules/depd/package.json
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"name": "depd",
|
||||||
|
"description": "Deprecate all the things",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"deprecate",
|
||||||
|
"deprecated"
|
||||||
|
],
|
||||||
|
"repository": "dougwilson/nodejs-depd",
|
||||||
|
"browser": "lib/browser/index.js",
|
||||||
|
"devDependencies": {
|
||||||
|
"benchmark": "2.1.4",
|
||||||
|
"beautify-benchmark": "0.2.4",
|
||||||
|
"eslint": "5.7.0",
|
||||||
|
"eslint-config-standard": "12.0.0",
|
||||||
|
"eslint-plugin-import": "2.14.0",
|
||||||
|
"eslint-plugin-markdown": "1.0.0-beta.7",
|
||||||
|
"eslint-plugin-node": "7.0.1",
|
||||||
|
"eslint-plugin-promise": "4.0.1",
|
||||||
|
"eslint-plugin-standard": "4.0.0",
|
||||||
|
"istanbul": "0.4.5",
|
||||||
|
"mocha": "5.2.0",
|
||||||
|
"safe-buffer": "5.1.2",
|
||||||
|
"uid-safe": "2.1.5"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib/",
|
||||||
|
"History.md",
|
||||||
|
"LICENSE",
|
||||||
|
"index.js",
|
||||||
|
"Readme.md"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"bench": "node benchmark/index.js",
|
||||||
|
"lint": "eslint --plugin markdown --ext js,md .",
|
||||||
|
"test": "mocha --reporter spec --bail test/",
|
||||||
|
"test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
|
||||||
|
"test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
|
||||||
|
}
|
||||||
|
}
|
||||||
23
node_modules/body-parser/node_modules/destroy/LICENSE
generated
vendored
Normal file
23
node_modules/body-parser/node_modules/destroy/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
||||||
|
Copyright (c) 2015-2022 Douglas Christopher Wilson doug@somethingdoug.com
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
63
node_modules/body-parser/node_modules/destroy/README.md
generated
vendored
Normal file
63
node_modules/body-parser/node_modules/destroy/README.md
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# destroy
|
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url]
|
||||||
|
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
||||||
|
[![Test coverage][coveralls-image]][coveralls-url]
|
||||||
|
[![License][license-image]][license-url]
|
||||||
|
[![Downloads][downloads-image]][downloads-url]
|
||||||
|
|
||||||
|
Destroy a stream.
|
||||||
|
|
||||||
|
This module is meant to ensure a stream gets destroyed, handling different APIs
|
||||||
|
and Node.js bugs.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var destroy = require('destroy')
|
||||||
|
```
|
||||||
|
|
||||||
|
### destroy(stream [, suppress])
|
||||||
|
|
||||||
|
Destroy the given stream, and optionally suppress any future `error` events.
|
||||||
|
|
||||||
|
In most cases, this is identical to a simple `stream.destroy()` call. The rules
|
||||||
|
are as follows for a given stream:
|
||||||
|
|
||||||
|
1. If the `stream` is an instance of `ReadStream`, then call `stream.destroy()`
|
||||||
|
and add a listener to the `open` event to call `stream.close()` if it is
|
||||||
|
fired. This is for a Node.js bug that will leak a file descriptor if
|
||||||
|
`.destroy()` is called before `open`.
|
||||||
|
2. If the `stream` is an instance of a zlib stream, then call `stream.destroy()`
|
||||||
|
and close the underlying zlib handle if open, otherwise call `stream.close()`.
|
||||||
|
This is for consistency across Node.js versions and a Node.js bug that will
|
||||||
|
leak a native zlib handle.
|
||||||
|
3. If the `stream` is not an instance of `Stream`, then nothing happens.
|
||||||
|
4. If the `stream` has a `.destroy()` method, then call it.
|
||||||
|
|
||||||
|
The function returns the `stream` passed in as the argument.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
var destroy = require('destroy')
|
||||||
|
|
||||||
|
var fs = require('fs')
|
||||||
|
var stream = fs.createReadStream('package.json')
|
||||||
|
|
||||||
|
// ... and later
|
||||||
|
destroy(stream)
|
||||||
|
```
|
||||||
|
|
||||||
|
[npm-image]: https://img.shields.io/npm/v/destroy.svg?style=flat-square
|
||||||
|
[npm-url]: https://npmjs.org/package/destroy
|
||||||
|
[github-tag]: http://img.shields.io/github/tag/stream-utils/destroy.svg?style=flat-square
|
||||||
|
[github-url]: https://github.com/stream-utils/destroy/tags
|
||||||
|
[coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy.svg?style=flat-square
|
||||||
|
[coveralls-url]: https://coveralls.io/r/stream-utils/destroy?branch=master
|
||||||
|
[license-image]: http://img.shields.io/npm/l/destroy.svg?style=flat-square
|
||||||
|
[license-url]: LICENSE.md
|
||||||
|
[downloads-image]: http://img.shields.io/npm/dm/destroy.svg?style=flat-square
|
||||||
|
[downloads-url]: https://npmjs.org/package/destroy
|
||||||
|
[github-actions-ci-image]: https://img.shields.io/github/workflow/status/stream-utils/destroy/ci/master?label=ci&style=flat-square
|
||||||
|
[github-actions-ci-url]: https://github.com/stream-utils/destroy/actions/workflows/ci.yml
|
||||||
209
node_modules/body-parser/node_modules/destroy/index.js
generated
vendored
Normal file
209
node_modules/body-parser/node_modules/destroy/index.js
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
/*!
|
||||||
|
* destroy
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var EventEmitter = require('events').EventEmitter
|
||||||
|
var ReadStream = require('fs').ReadStream
|
||||||
|
var Stream = require('stream')
|
||||||
|
var Zlib = require('zlib')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = destroy
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy the given stream, and optionally suppress any future `error` events.
|
||||||
|
*
|
||||||
|
* @param {object} stream
|
||||||
|
* @param {boolean} suppress
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function destroy (stream, suppress) {
|
||||||
|
if (isFsReadStream(stream)) {
|
||||||
|
destroyReadStream(stream)
|
||||||
|
} else if (isZlibStream(stream)) {
|
||||||
|
destroyZlibStream(stream)
|
||||||
|
} else if (hasDestroy(stream)) {
|
||||||
|
stream.destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEventEmitter(stream) && suppress) {
|
||||||
|
stream.removeAllListeners('error')
|
||||||
|
stream.addListener('error', noop)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close a Zlib stream.
|
||||||
|
*
|
||||||
|
* Zlib streams below Node.js 4.5.5 have a buggy implementation
|
||||||
|
* of .close() when zlib encountered an error.
|
||||||
|
*
|
||||||
|
* @param {object} stream
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function closeZlibStream (stream) {
|
||||||
|
if (stream._hadError === true) {
|
||||||
|
var prop = stream._binding === null
|
||||||
|
? '_binding'
|
||||||
|
: '_handle'
|
||||||
|
|
||||||
|
stream[prop] = {
|
||||||
|
close: function () { this[prop] = null }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy a Zlib stream.
|
||||||
|
*
|
||||||
|
* Zlib streams don't have a destroy function in Node.js 6. On top of that
|
||||||
|
* simply calling destroy on a zlib stream in Node.js 8+ will result in a
|
||||||
|
* memory leak. So until that is fixed, we need to call both close AND destroy.
|
||||||
|
*
|
||||||
|
* PR to fix memory leak: https://github.com/nodejs/node/pull/23734
|
||||||
|
*
|
||||||
|
* In Node.js 6+8, it's important that destroy is called before close as the
|
||||||
|
* stream would otherwise emit the error 'zlib binding closed'.
|
||||||
|
*
|
||||||
|
* @param {object} stream
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function destroyZlibStream (stream) {
|
||||||
|
if (typeof stream.destroy === 'function') {
|
||||||
|
// node.js core bug work-around
|
||||||
|
// istanbul ignore if: node.js 0.8
|
||||||
|
if (stream._binding) {
|
||||||
|
// node.js < 0.10.0
|
||||||
|
stream.destroy()
|
||||||
|
if (stream._processing) {
|
||||||
|
stream._needDrain = true
|
||||||
|
stream.once('drain', onDrainClearBinding)
|
||||||
|
} else {
|
||||||
|
stream._binding.clear()
|
||||||
|
}
|
||||||
|
} else if (stream._destroy && stream._destroy !== Stream.Transform.prototype._destroy) {
|
||||||
|
// node.js >= 12, ^11.1.0, ^10.15.1
|
||||||
|
stream.destroy()
|
||||||
|
} else if (stream._destroy && typeof stream.close === 'function') {
|
||||||
|
// node.js 7, 8
|
||||||
|
stream.destroyed = true
|
||||||
|
stream.close()
|
||||||
|
} else {
|
||||||
|
// fallback
|
||||||
|
// istanbul ignore next
|
||||||
|
stream.destroy()
|
||||||
|
}
|
||||||
|
} else if (typeof stream.close === 'function') {
|
||||||
|
// node.js < 8 fallback
|
||||||
|
closeZlibStream(stream)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if stream has destroy.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function hasDestroy (stream) {
|
||||||
|
return stream instanceof Stream &&
|
||||||
|
typeof stream.destroy === 'function'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if val is EventEmitter.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isEventEmitter (val) {
|
||||||
|
return val instanceof EventEmitter
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if stream is fs.ReadStream stream.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isFsReadStream (stream) {
|
||||||
|
return stream instanceof ReadStream
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if stream is Zlib stream.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isZlibStream (stream) {
|
||||||
|
return stream instanceof Zlib.Gzip ||
|
||||||
|
stream instanceof Zlib.Gunzip ||
|
||||||
|
stream instanceof Zlib.Deflate ||
|
||||||
|
stream instanceof Zlib.DeflateRaw ||
|
||||||
|
stream instanceof Zlib.Inflate ||
|
||||||
|
stream instanceof Zlib.InflateRaw ||
|
||||||
|
stream instanceof Zlib.Unzip
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No-op function.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function noop () {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On drain handler to clear binding.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
// istanbul ignore next: node.js 0.8
|
||||||
|
function onDrainClearBinding () {
|
||||||
|
this._binding.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On open handler to close stream.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onOpenClose () {
|
||||||
|
if (typeof this.fd === 'number') {
|
||||||
|
// actually close down the fd
|
||||||
|
this.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
48
node_modules/body-parser/node_modules/destroy/package.json
generated
vendored
Normal file
48
node_modules/body-parser/node_modules/destroy/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "destroy",
|
||||||
|
"description": "destroy a stream if possible",
|
||||||
|
"version": "1.2.0",
|
||||||
|
"author": {
|
||||||
|
"name": "Jonathan Ong",
|
||||||
|
"email": "me@jongleberry.com",
|
||||||
|
"url": "http://jongleberry.com",
|
||||||
|
"twitter": "https://twitter.com/jongleberry"
|
||||||
|
},
|
||||||
|
"contributors": [
|
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "stream-utils/destroy",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "7.32.0",
|
||||||
|
"eslint-config-standard": "14.1.1",
|
||||||
|
"eslint-plugin-import": "2.25.4",
|
||||||
|
"eslint-plugin-node": "11.1.0",
|
||||||
|
"eslint-plugin-promise": "5.2.0",
|
||||||
|
"eslint-plugin-standard": "4.1.0",
|
||||||
|
"mocha": "9.2.2",
|
||||||
|
"nyc": "15.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.8",
|
||||||
|
"npm": "1.2.8000 || >= 1.4.16"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
|
"test": "mocha --reporter spec",
|
||||||
|
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
|
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"LICENSE"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"stream",
|
||||||
|
"streams",
|
||||||
|
"destroy",
|
||||||
|
"cleanup",
|
||||||
|
"leak",
|
||||||
|
"fd"
|
||||||
|
]
|
||||||
|
}
|
||||||
180
node_modules/body-parser/node_modules/http-errors/HISTORY.md
generated
vendored
Normal file
180
node_modules/body-parser/node_modules/http-errors/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
2.0.0 / 2021-12-17
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Drop support for Node.js 0.6
|
||||||
|
* Remove `I'mateapot` export; use `ImATeapot` instead
|
||||||
|
* Remove support for status being non-first argument
|
||||||
|
* Rename `UnorderedCollection` constructor to `TooEarly`
|
||||||
|
* deps: depd@2.0.0
|
||||||
|
- Replace internal `eval` usage with `Function` constructor
|
||||||
|
- Use instance methods on `process` to check for listeners
|
||||||
|
* deps: statuses@2.0.1
|
||||||
|
- Fix messaging casing of `418 I'm a Teapot`
|
||||||
|
- Remove code 306
|
||||||
|
- Rename `425 Unordered Collection` to standard `425 Too Early`
|
||||||
|
|
||||||
|
2021-11-14 / 1.8.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: toidentifier@1.0.1
|
||||||
|
|
||||||
|
2020-06-29 / 1.8.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `isHttpError` export to determine if value is an HTTP error
|
||||||
|
* deps: setprototypeof@1.2.0
|
||||||
|
|
||||||
|
2019-06-24 / 1.7.3
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: inherits@2.0.4
|
||||||
|
|
||||||
|
2019-02-18 / 1.7.2
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: setprototypeof@1.1.1
|
||||||
|
|
||||||
|
2018-09-08 / 1.7.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix error creating objects in some environments
|
||||||
|
|
||||||
|
2018-07-30 / 1.7.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Set constructor name when possible
|
||||||
|
* Use `toidentifier` module to make class names
|
||||||
|
* deps: statuses@'>= 1.5.0 < 2'
|
||||||
|
|
||||||
|
2018-03-29 / 1.6.3
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@~1.1.2
|
||||||
|
- perf: remove argument reassignment
|
||||||
|
* deps: setprototypeof@1.1.0
|
||||||
|
* deps: statuses@'>= 1.4.0 < 2'
|
||||||
|
|
||||||
|
2017-08-04 / 1.6.2
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@1.1.1
|
||||||
|
- Remove unnecessary `Buffer` loading
|
||||||
|
|
||||||
|
2017-02-20 / 1.6.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: setprototypeof@1.0.3
|
||||||
|
- Fix shim for old browsers
|
||||||
|
|
||||||
|
2017-02-14 / 1.6.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Accept custom 4xx and 5xx status codes in factory
|
||||||
|
* Add deprecation message to `"I'mateapot"` export
|
||||||
|
* Deprecate passing status code as anything except first argument in factory
|
||||||
|
* Deprecate using non-error status codes
|
||||||
|
* Make `message` property enumerable for `HttpError`s
|
||||||
|
|
||||||
|
2016-11-16 / 1.5.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: inherits@2.0.3
|
||||||
|
- Fix issue loading in browser
|
||||||
|
* deps: setprototypeof@1.0.2
|
||||||
|
* deps: statuses@'>= 1.3.1 < 2'
|
||||||
|
|
||||||
|
2016-05-18 / 1.5.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support new code `421 Misdirected Request`
|
||||||
|
* Use `setprototypeof` module to replace `__proto__` setting
|
||||||
|
* deps: statuses@'>= 1.3.0 < 2'
|
||||||
|
- Add `421 Misdirected Request`
|
||||||
|
- perf: enable strict mode
|
||||||
|
* perf: enable strict mode
|
||||||
|
|
||||||
|
2016-01-28 / 1.4.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `HttpError` export, for `err instanceof createError.HttpError`
|
||||||
|
* deps: inherits@2.0.1
|
||||||
|
* deps: statuses@'>= 1.2.1 < 2'
|
||||||
|
- Fix message for status 451
|
||||||
|
- Remove incorrect nginx status code
|
||||||
|
|
||||||
|
2015-02-02 / 1.3.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix regression where status can be overwritten in `createError` `props`
|
||||||
|
|
||||||
|
2015-02-01 / 1.3.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Construct errors using defined constructors from `createError`
|
||||||
|
* Fix error names that are not identifiers
|
||||||
|
- `createError["I'mateapot"]` is now `createError.ImATeapot`
|
||||||
|
* Set a meaningful `name` property on constructed errors
|
||||||
|
|
||||||
|
2014-12-09 / 1.2.8
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix stack trace from exported function
|
||||||
|
* Remove `arguments.callee` usage
|
||||||
|
|
||||||
|
2014-10-14 / 1.2.7
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Remove duplicate line
|
||||||
|
|
||||||
|
2014-10-02 / 1.2.6
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix `expose` to be `true` for `ClientError` constructor
|
||||||
|
|
||||||
|
2014-09-28 / 1.2.5
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: statuses@1
|
||||||
|
|
||||||
|
2014-09-21 / 1.2.4
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix dependency version to work with old `npm`s
|
||||||
|
|
||||||
|
2014-09-21 / 1.2.3
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: statuses@~1.1.0
|
||||||
|
|
||||||
|
2014-09-21 / 1.2.2
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix publish error
|
||||||
|
|
||||||
|
2014-09-21 / 1.2.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support Node.js 0.6
|
||||||
|
* Use `inherits` instead of `util`
|
||||||
|
|
||||||
|
2014-09-09 / 1.2.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix the way inheriting functions
|
||||||
|
* Support `expose` being provided in properties argument
|
||||||
|
|
||||||
|
2014-09-08 / 1.1.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Default status to 500
|
||||||
|
* Support provided `error` to extend
|
||||||
|
|
||||||
|
2014-09-08 / 1.0.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix accepting string message
|
||||||
|
|
||||||
|
2014-09-08 / 1.0.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Initial release
|
||||||
23
node_modules/body-parser/node_modules/http-errors/LICENSE
generated
vendored
Normal file
23
node_modules/body-parser/node_modules/http-errors/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
||||||
|
Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
169
node_modules/body-parser/node_modules/http-errors/README.md
generated
vendored
Normal file
169
node_modules/body-parser/node_modules/http-errors/README.md
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
# http-errors
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][node-url]
|
||||||
|
[![Node.js Version][node-image]][node-url]
|
||||||
|
[![Build Status][ci-image]][ci-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
Create HTTP errors for Express, Koa, Connect, etc. with ease.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ npm install http-errors
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
var createError = require('http-errors')
|
||||||
|
var express = require('express')
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
app.use(function (req, res, next) {
|
||||||
|
if (!req.user) return next(createError(401, 'Please login to view this page.'))
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This is the current API, currently extracted from Koa and subject to change.
|
||||||
|
|
||||||
|
### Error Properties
|
||||||
|
|
||||||
|
- `expose` - can be used to signal if `message` should be sent to the client,
|
||||||
|
defaulting to `false` when `status` >= 500
|
||||||
|
- `headers` - can be an object of header names to values to be sent to the
|
||||||
|
client, defaulting to `undefined`. When defined, the key names should all
|
||||||
|
be lower-cased
|
||||||
|
- `message` - the traditional error message, which should be kept short and all
|
||||||
|
single line
|
||||||
|
- `status` - the status code of the error, mirroring `statusCode` for general
|
||||||
|
compatibility
|
||||||
|
- `statusCode` - the status code of the error, defaulting to `500`
|
||||||
|
|
||||||
|
### createError([status], [message], [properties])
|
||||||
|
|
||||||
|
Create a new error object with the given message `msg`.
|
||||||
|
The error object inherits from `createError.HttpError`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var err = createError(404, 'This video does not exist!')
|
||||||
|
```
|
||||||
|
|
||||||
|
- `status: 500` - the status code as a number
|
||||||
|
- `message` - the message of the error, defaulting to node's text for that status code.
|
||||||
|
- `properties` - custom properties to attach to the object
|
||||||
|
|
||||||
|
### createError([status], [error], [properties])
|
||||||
|
|
||||||
|
Extend the given `error` object with `createError.HttpError`
|
||||||
|
properties. This will not alter the inheritance of the given
|
||||||
|
`error` object, and the modified `error` object is the
|
||||||
|
return value.
|
||||||
|
|
||||||
|
<!-- eslint-disable no-redeclare -->
|
||||||
|
|
||||||
|
```js
|
||||||
|
fs.readFile('foo.txt', function (err, buf) {
|
||||||
|
if (err) {
|
||||||
|
if (err.code === 'ENOENT') {
|
||||||
|
var httpError = createError(404, err, { expose: false })
|
||||||
|
} else {
|
||||||
|
var httpError = createError(500, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
- `status` - the status code as a number
|
||||||
|
- `error` - the error object to extend
|
||||||
|
- `properties` - custom properties to attach to the object
|
||||||
|
|
||||||
|
### createError.isHttpError(val)
|
||||||
|
|
||||||
|
Determine if the provided `val` is an `HttpError`. This will return `true`
|
||||||
|
if the error inherits from the `HttpError` constructor of this module or
|
||||||
|
matches the "duck type" for an error this module creates. All outputs from
|
||||||
|
the `createError` factory will return `true` for this function, including
|
||||||
|
if an non-`HttpError` was passed into the factory.
|
||||||
|
|
||||||
|
### new createError\[code || name\](\[msg]\))
|
||||||
|
|
||||||
|
Create a new error object with the given message `msg`.
|
||||||
|
The error object inherits from `createError.HttpError`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var err = new createError.NotFound()
|
||||||
|
```
|
||||||
|
|
||||||
|
- `code` - the status code as a number
|
||||||
|
- `name` - the name of the error as a "bumpy case", i.e. `NotFound` or `InternalServerError`.
|
||||||
|
|
||||||
|
#### List of all constructors
|
||||||
|
|
||||||
|
|Status Code|Constructor Name |
|
||||||
|
|-----------|-----------------------------|
|
||||||
|
|400 |BadRequest |
|
||||||
|
|401 |Unauthorized |
|
||||||
|
|402 |PaymentRequired |
|
||||||
|
|403 |Forbidden |
|
||||||
|
|404 |NotFound |
|
||||||
|
|405 |MethodNotAllowed |
|
||||||
|
|406 |NotAcceptable |
|
||||||
|
|407 |ProxyAuthenticationRequired |
|
||||||
|
|408 |RequestTimeout |
|
||||||
|
|409 |Conflict |
|
||||||
|
|410 |Gone |
|
||||||
|
|411 |LengthRequired |
|
||||||
|
|412 |PreconditionFailed |
|
||||||
|
|413 |PayloadTooLarge |
|
||||||
|
|414 |URITooLong |
|
||||||
|
|415 |UnsupportedMediaType |
|
||||||
|
|416 |RangeNotSatisfiable |
|
||||||
|
|417 |ExpectationFailed |
|
||||||
|
|418 |ImATeapot |
|
||||||
|
|421 |MisdirectedRequest |
|
||||||
|
|422 |UnprocessableEntity |
|
||||||
|
|423 |Locked |
|
||||||
|
|424 |FailedDependency |
|
||||||
|
|425 |TooEarly |
|
||||||
|
|426 |UpgradeRequired |
|
||||||
|
|428 |PreconditionRequired |
|
||||||
|
|429 |TooManyRequests |
|
||||||
|
|431 |RequestHeaderFieldsTooLarge |
|
||||||
|
|451 |UnavailableForLegalReasons |
|
||||||
|
|500 |InternalServerError |
|
||||||
|
|501 |NotImplemented |
|
||||||
|
|502 |BadGateway |
|
||||||
|
|503 |ServiceUnavailable |
|
||||||
|
|504 |GatewayTimeout |
|
||||||
|
|505 |HTTPVersionNotSupported |
|
||||||
|
|506 |VariantAlsoNegotiates |
|
||||||
|
|507 |InsufficientStorage |
|
||||||
|
|508 |LoopDetected |
|
||||||
|
|509 |BandwidthLimitExceeded |
|
||||||
|
|510 |NotExtended |
|
||||||
|
|511 |NetworkAuthenticationRequired|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[ci-image]: https://badgen.net/github/checks/jshttp/http-errors/master?label=ci
|
||||||
|
[ci-url]: https://github.com/jshttp/http-errors/actions?query=workflow%3Aci
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/http-errors/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/http-errors?branch=master
|
||||||
|
[node-image]: https://badgen.net/npm/node/http-errors
|
||||||
|
[node-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/http-errors
|
||||||
|
[npm-url]: https://npmjs.org/package/http-errors
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/http-errors
|
||||||
|
[travis-image]: https://badgen.net/travis/jshttp/http-errors/master
|
||||||
|
[travis-url]: https://travis-ci.org/jshttp/http-errors
|
||||||
289
node_modules/body-parser/node_modules/http-errors/index.js
generated
vendored
Normal file
289
node_modules/body-parser/node_modules/http-errors/index.js
generated
vendored
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
/*!
|
||||||
|
* http-errors
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2016 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var deprecate = require('depd')('http-errors')
|
||||||
|
var setPrototypeOf = require('setprototypeof')
|
||||||
|
var statuses = require('statuses')
|
||||||
|
var inherits = require('inherits')
|
||||||
|
var toIdentifier = require('toidentifier')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = createError
|
||||||
|
module.exports.HttpError = createHttpErrorConstructor()
|
||||||
|
module.exports.isHttpError = createIsHttpErrorFunction(module.exports.HttpError)
|
||||||
|
|
||||||
|
// Populate exports for all constructors
|
||||||
|
populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the code class of a status code.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function codeClass (status) {
|
||||||
|
return Number(String(status).charAt(0) + '00')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new HTTP Error.
|
||||||
|
*
|
||||||
|
* @returns {Error}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createError () {
|
||||||
|
// so much arity going on ~_~
|
||||||
|
var err
|
||||||
|
var msg
|
||||||
|
var status = 500
|
||||||
|
var props = {}
|
||||||
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
var arg = arguments[i]
|
||||||
|
var type = typeof arg
|
||||||
|
if (type === 'object' && arg instanceof Error) {
|
||||||
|
err = arg
|
||||||
|
status = err.status || err.statusCode || status
|
||||||
|
} else if (type === 'number' && i === 0) {
|
||||||
|
status = arg
|
||||||
|
} else if (type === 'string') {
|
||||||
|
msg = arg
|
||||||
|
} else if (type === 'object') {
|
||||||
|
props = arg
|
||||||
|
} else {
|
||||||
|
throw new TypeError('argument #' + (i + 1) + ' unsupported type ' + type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof status === 'number' && (status < 400 || status >= 600)) {
|
||||||
|
deprecate('non-error status code; use only 4xx or 5xx status codes')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof status !== 'number' ||
|
||||||
|
(!statuses.message[status] && (status < 400 || status >= 600))) {
|
||||||
|
status = 500
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
var HttpError = createError[status] || createError[codeClass(status)]
|
||||||
|
|
||||||
|
if (!err) {
|
||||||
|
// create error
|
||||||
|
err = HttpError
|
||||||
|
? new HttpError(msg)
|
||||||
|
: new Error(msg || statuses.message[status])
|
||||||
|
Error.captureStackTrace(err, createError)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!HttpError || !(err instanceof HttpError) || err.status !== status) {
|
||||||
|
// add properties to generic error
|
||||||
|
err.expose = status < 500
|
||||||
|
err.status = err.statusCode = status
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var key in props) {
|
||||||
|
if (key !== 'status' && key !== 'statusCode') {
|
||||||
|
err[key] = props[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create HTTP error abstract base class.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createHttpErrorConstructor () {
|
||||||
|
function HttpError () {
|
||||||
|
throw new TypeError('cannot construct abstract class')
|
||||||
|
}
|
||||||
|
|
||||||
|
inherits(HttpError, Error)
|
||||||
|
|
||||||
|
return HttpError
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a constructor for a client error.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createClientErrorConstructor (HttpError, name, code) {
|
||||||
|
var className = toClassName(name)
|
||||||
|
|
||||||
|
function ClientError (message) {
|
||||||
|
// create the error object
|
||||||
|
var msg = message != null ? message : statuses.message[code]
|
||||||
|
var err = new Error(msg)
|
||||||
|
|
||||||
|
// capture a stack trace to the construction point
|
||||||
|
Error.captureStackTrace(err, ClientError)
|
||||||
|
|
||||||
|
// adjust the [[Prototype]]
|
||||||
|
setPrototypeOf(err, ClientError.prototype)
|
||||||
|
|
||||||
|
// redefine the error message
|
||||||
|
Object.defineProperty(err, 'message', {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
value: msg,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
// redefine the error name
|
||||||
|
Object.defineProperty(err, 'name', {
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
value: className,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
inherits(ClientError, HttpError)
|
||||||
|
nameFunc(ClientError, className)
|
||||||
|
|
||||||
|
ClientError.prototype.status = code
|
||||||
|
ClientError.prototype.statusCode = code
|
||||||
|
ClientError.prototype.expose = true
|
||||||
|
|
||||||
|
return ClientError
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create function to test is a value is a HttpError.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createIsHttpErrorFunction (HttpError) {
|
||||||
|
return function isHttpError (val) {
|
||||||
|
if (!val || typeof val !== 'object') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val instanceof HttpError) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return val instanceof Error &&
|
||||||
|
typeof val.expose === 'boolean' &&
|
||||||
|
typeof val.statusCode === 'number' && val.status === val.statusCode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a constructor for a server error.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createServerErrorConstructor (HttpError, name, code) {
|
||||||
|
var className = toClassName(name)
|
||||||
|
|
||||||
|
function ServerError (message) {
|
||||||
|
// create the error object
|
||||||
|
var msg = message != null ? message : statuses.message[code]
|
||||||
|
var err = new Error(msg)
|
||||||
|
|
||||||
|
// capture a stack trace to the construction point
|
||||||
|
Error.captureStackTrace(err, ServerError)
|
||||||
|
|
||||||
|
// adjust the [[Prototype]]
|
||||||
|
setPrototypeOf(err, ServerError.prototype)
|
||||||
|
|
||||||
|
// redefine the error message
|
||||||
|
Object.defineProperty(err, 'message', {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
value: msg,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
// redefine the error name
|
||||||
|
Object.defineProperty(err, 'name', {
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true,
|
||||||
|
value: className,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
inherits(ServerError, HttpError)
|
||||||
|
nameFunc(ServerError, className)
|
||||||
|
|
||||||
|
ServerError.prototype.status = code
|
||||||
|
ServerError.prototype.statusCode = code
|
||||||
|
ServerError.prototype.expose = false
|
||||||
|
|
||||||
|
return ServerError
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of a function, if possible.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function nameFunc (func, name) {
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(func, 'name')
|
||||||
|
|
||||||
|
if (desc && desc.configurable) {
|
||||||
|
desc.value = name
|
||||||
|
Object.defineProperty(func, 'name', desc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate the exports object with constructors for every error class.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function populateConstructorExports (exports, codes, HttpError) {
|
||||||
|
codes.forEach(function forEachCode (code) {
|
||||||
|
var CodeError
|
||||||
|
var name = toIdentifier(statuses.message[code])
|
||||||
|
|
||||||
|
switch (codeClass(code)) {
|
||||||
|
case 400:
|
||||||
|
CodeError = createClientErrorConstructor(HttpError, name, code)
|
||||||
|
break
|
||||||
|
case 500:
|
||||||
|
CodeError = createServerErrorConstructor(HttpError, name, code)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CodeError) {
|
||||||
|
// export the constructor
|
||||||
|
exports[code] = CodeError
|
||||||
|
exports[name] = CodeError
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a class name from a name identifier.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function toClassName (name) {
|
||||||
|
return name.substr(-5) !== 'Error'
|
||||||
|
? name + 'Error'
|
||||||
|
: name
|
||||||
|
}
|
||||||
50
node_modules/body-parser/node_modules/http-errors/package.json
generated
vendored
Normal file
50
node_modules/body-parser/node_modules/http-errors/package.json
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"name": "http-errors",
|
||||||
|
"description": "Create HTTP error objects",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
|
||||||
|
"contributors": [
|
||||||
|
"Alan Plum <me@pluma.io>",
|
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "jshttp/http-errors",
|
||||||
|
"dependencies": {
|
||||||
|
"depd": "2.0.0",
|
||||||
|
"inherits": "2.0.4",
|
||||||
|
"setprototypeof": "1.2.0",
|
||||||
|
"statuses": "2.0.1",
|
||||||
|
"toidentifier": "1.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "7.32.0",
|
||||||
|
"eslint-config-standard": "14.1.1",
|
||||||
|
"eslint-plugin-import": "2.25.3",
|
||||||
|
"eslint-plugin-markdown": "2.2.1",
|
||||||
|
"eslint-plugin-node": "11.1.0",
|
||||||
|
"eslint-plugin-promise": "5.2.0",
|
||||||
|
"eslint-plugin-standard": "4.1.0",
|
||||||
|
"mocha": "9.1.3",
|
||||||
|
"nyc": "15.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint . && node ./scripts/lint-readme-list.js",
|
||||||
|
"test": "mocha --reporter spec --bail",
|
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||||
|
"version": "node scripts/version-history.js && git add HISTORY.md"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"error"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"HISTORY.md",
|
||||||
|
"LICENSE",
|
||||||
|
"README.md"
|
||||||
|
]
|
||||||
|
}
|
||||||
16
node_modules/body-parser/node_modules/inherits/LICENSE
generated
vendored
Normal file
16
node_modules/body-parser/node_modules/inherits/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
42
node_modules/body-parser/node_modules/inherits/README.md
generated
vendored
Normal file
42
node_modules/body-parser/node_modules/inherits/README.md
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
Browser-friendly inheritance fully compatible with standard node.js
|
||||||
|
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
|
||||||
|
|
||||||
|
This package exports standard `inherits` from node.js `util` module in
|
||||||
|
node environment, but also provides alternative browser-friendly
|
||||||
|
implementation through [browser
|
||||||
|
field](https://gist.github.com/shtylman/4339901). Alternative
|
||||||
|
implementation is a literal copy of standard one located in standalone
|
||||||
|
module to avoid requiring of `util`. It also has a shim for old
|
||||||
|
browsers with no `Object.create` support.
|
||||||
|
|
||||||
|
While keeping you sure you are using standard `inherits`
|
||||||
|
implementation in node.js environment, it allows bundlers such as
|
||||||
|
[browserify](https://github.com/substack/node-browserify) to not
|
||||||
|
include full `util` package to your client code if all you need is
|
||||||
|
just `inherits` function. It worth, because browser shim for `util`
|
||||||
|
package is large and `inherits` is often the single function you need
|
||||||
|
from it.
|
||||||
|
|
||||||
|
It's recommended to use this package instead of
|
||||||
|
`require('util').inherits` for any code that has chances to be used
|
||||||
|
not only in node.js but in browser too.
|
||||||
|
|
||||||
|
## usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
var inherits = require('inherits');
|
||||||
|
// then use exactly as the standard one
|
||||||
|
```
|
||||||
|
|
||||||
|
## note on version ~1.0
|
||||||
|
|
||||||
|
Version ~1.0 had completely different motivation and is not compatible
|
||||||
|
neither with 2.0 nor with standard node.js `inherits`.
|
||||||
|
|
||||||
|
If you are using version ~1.0 and planning to switch to ~2.0, be
|
||||||
|
careful:
|
||||||
|
|
||||||
|
* new version uses `super_` instead of `super` for referencing
|
||||||
|
superclass
|
||||||
|
* new version overwrites current prototype while old one preserves any
|
||||||
|
existing fields on it
|
||||||
9
node_modules/body-parser/node_modules/inherits/inherits.js
generated
vendored
Normal file
9
node_modules/body-parser/node_modules/inherits/inherits.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
try {
|
||||||
|
var util = require('util');
|
||||||
|
/* istanbul ignore next */
|
||||||
|
if (typeof util.inherits !== 'function') throw '';
|
||||||
|
module.exports = util.inherits;
|
||||||
|
} catch (e) {
|
||||||
|
/* istanbul ignore next */
|
||||||
|
module.exports = require('./inherits_browser.js');
|
||||||
|
}
|
||||||
27
node_modules/body-parser/node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
27
node_modules/body-parser/node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
if (typeof Object.create === 'function') {
|
||||||
|
// implementation from standard node.js 'util' module
|
||||||
|
module.exports = function inherits(ctor, superCtor) {
|
||||||
|
if (superCtor) {
|
||||||
|
ctor.super_ = superCtor
|
||||||
|
ctor.prototype = Object.create(superCtor.prototype, {
|
||||||
|
constructor: {
|
||||||
|
value: ctor,
|
||||||
|
enumerable: false,
|
||||||
|
writable: true,
|
||||||
|
configurable: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// old school shim for old browsers
|
||||||
|
module.exports = function inherits(ctor, superCtor) {
|
||||||
|
if (superCtor) {
|
||||||
|
ctor.super_ = superCtor
|
||||||
|
var TempCtor = function () {}
|
||||||
|
TempCtor.prototype = superCtor.prototype
|
||||||
|
ctor.prototype = new TempCtor()
|
||||||
|
ctor.prototype.constructor = ctor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
node_modules/body-parser/node_modules/inherits/package.json
generated
vendored
Normal file
29
node_modules/body-parser/node_modules/inherits/package.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "inherits",
|
||||||
|
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
|
||||||
|
"version": "2.0.4",
|
||||||
|
"keywords": [
|
||||||
|
"inheritance",
|
||||||
|
"class",
|
||||||
|
"klass",
|
||||||
|
"oop",
|
||||||
|
"object-oriented",
|
||||||
|
"inherits",
|
||||||
|
"browser",
|
||||||
|
"browserify"
|
||||||
|
],
|
||||||
|
"main": "./inherits.js",
|
||||||
|
"browser": "./inherits_browser.js",
|
||||||
|
"repository": "git://github.com/isaacs/inherits",
|
||||||
|
"license": "ISC",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tap"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"tap": "^14.2.4"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"inherits.js",
|
||||||
|
"inherits_browser.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
98
node_modules/body-parser/node_modules/on-finished/HISTORY.md
generated
vendored
Normal file
98
node_modules/body-parser/node_modules/on-finished/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
2.4.1 / 2022-02-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix error on early async hooks implementations
|
||||||
|
|
||||||
|
2.4.0 / 2022-02-21
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Prevent loss of async hooks context
|
||||||
|
|
||||||
|
2.3.0 / 2015-05-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add defined behavior for HTTP `CONNECT` requests
|
||||||
|
* Add defined behavior for HTTP `Upgrade` requests
|
||||||
|
* deps: ee-first@1.1.1
|
||||||
|
|
||||||
|
2.2.1 / 2015-04-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix `isFinished(req)` when data buffered
|
||||||
|
|
||||||
|
2.2.0 / 2014-12-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add message object to callback arguments
|
||||||
|
|
||||||
|
2.1.1 / 2014-10-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix handling of pipelined requests
|
||||||
|
|
||||||
|
2.1.0 / 2014-08-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Check if `socket` is detached
|
||||||
|
* Return `undefined` for `isFinished` if state unknown
|
||||||
|
|
||||||
|
2.0.0 / 2014-08-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `isFinished` function
|
||||||
|
* Move to `jshttp` organization
|
||||||
|
* Remove support for plain socket argument
|
||||||
|
* Rename to `on-finished`
|
||||||
|
* Support both `req` and `res` as arguments
|
||||||
|
* deps: ee-first@1.0.5
|
||||||
|
|
||||||
|
1.2.2 / 2014-06-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Reduce listeners added to emitters
|
||||||
|
- avoids "event emitter leak" warnings when used multiple times on same request
|
||||||
|
|
||||||
|
1.2.1 / 2014-06-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix returned value when already finished
|
||||||
|
|
||||||
|
1.2.0 / 2014-06-05
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Call callback when called on already-finished socket
|
||||||
|
|
||||||
|
1.1.4 / 2014-05-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support node.js 0.8
|
||||||
|
|
||||||
|
1.1.3 / 2014-04-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Make sure errors passed as instanceof `Error`
|
||||||
|
|
||||||
|
1.1.2 / 2014-04-18
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Default the `socket` to passed-in object
|
||||||
|
|
||||||
|
1.1.1 / 2014-01-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Rename module to `finished`
|
||||||
|
|
||||||
|
1.1.0 / 2013-12-25
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Call callback when called on already-errored socket
|
||||||
|
|
||||||
|
1.0.1 / 2013-12-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Actually pass the error to the callback
|
||||||
|
|
||||||
|
1.0.0 / 2013-12-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Initial release
|
||||||
23
node_modules/body-parser/node_modules/on-finished/LICENSE
generated
vendored
Normal file
23
node_modules/body-parser/node_modules/on-finished/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2014 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
162
node_modules/body-parser/node_modules/on-finished/README.md
generated
vendored
Normal file
162
node_modules/body-parser/node_modules/on-finished/README.md
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
# on-finished
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Node.js Version][node-image]][node-url]
|
||||||
|
[![Build Status][ci-image]][ci-url]
|
||||||
|
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
Execute a callback when a HTTP request closes, finishes, or errors.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install on-finished
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var onFinished = require('on-finished')
|
||||||
|
```
|
||||||
|
|
||||||
|
### onFinished(res, listener)
|
||||||
|
|
||||||
|
Attach a listener to listen for the response to finish. The listener will
|
||||||
|
be invoked only once when the response finished. If the response finished
|
||||||
|
to an error, the first argument will contain the error. If the response
|
||||||
|
has already finished, the listener will be invoked.
|
||||||
|
|
||||||
|
Listening to the end of a response would be used to close things associated
|
||||||
|
with the response, like open files.
|
||||||
|
|
||||||
|
Listener is invoked as `listener(err, res)`.
|
||||||
|
|
||||||
|
<!-- eslint-disable handle-callback-err -->
|
||||||
|
|
||||||
|
```js
|
||||||
|
onFinished(res, function (err, res) {
|
||||||
|
// clean up open fds, etc.
|
||||||
|
// err contains the error if request error'd
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### onFinished(req, listener)
|
||||||
|
|
||||||
|
Attach a listener to listen for the request to finish. The listener will
|
||||||
|
be invoked only once when the request finished. If the request finished
|
||||||
|
to an error, the first argument will contain the error. If the request
|
||||||
|
has already finished, the listener will be invoked.
|
||||||
|
|
||||||
|
Listening to the end of a request would be used to know when to continue
|
||||||
|
after reading the data.
|
||||||
|
|
||||||
|
Listener is invoked as `listener(err, req)`.
|
||||||
|
|
||||||
|
<!-- eslint-disable handle-callback-err -->
|
||||||
|
|
||||||
|
```js
|
||||||
|
var data = ''
|
||||||
|
|
||||||
|
req.setEncoding('utf8')
|
||||||
|
req.on('data', function (str) {
|
||||||
|
data += str
|
||||||
|
})
|
||||||
|
|
||||||
|
onFinished(req, function (err, req) {
|
||||||
|
// data is read unless there is err
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### onFinished.isFinished(res)
|
||||||
|
|
||||||
|
Determine if `res` is already finished. This would be useful to check and
|
||||||
|
not even start certain operations if the response has already finished.
|
||||||
|
|
||||||
|
### onFinished.isFinished(req)
|
||||||
|
|
||||||
|
Determine if `req` is already finished. This would be useful to check and
|
||||||
|
not even start certain operations if the request has already finished.
|
||||||
|
|
||||||
|
## Special Node.js requests
|
||||||
|
|
||||||
|
### HTTP CONNECT method
|
||||||
|
|
||||||
|
The meaning of the `CONNECT` method from RFC 7231, section 4.3.6:
|
||||||
|
|
||||||
|
> The CONNECT method requests that the recipient establish a tunnel to
|
||||||
|
> the destination origin server identified by the request-target and,
|
||||||
|
> if successful, thereafter restrict its behavior to blind forwarding
|
||||||
|
> of packets, in both directions, until the tunnel is closed. Tunnels
|
||||||
|
> are commonly used to create an end-to-end virtual connection, through
|
||||||
|
> one or more proxies, which can then be secured using TLS (Transport
|
||||||
|
> Layer Security, [RFC5246]).
|
||||||
|
|
||||||
|
In Node.js, these request objects come from the `'connect'` event on
|
||||||
|
the HTTP server.
|
||||||
|
|
||||||
|
When this module is used on a HTTP `CONNECT` request, the request is
|
||||||
|
considered "finished" immediately, **due to limitations in the Node.js
|
||||||
|
interface**. This means if the `CONNECT` request contains a request entity,
|
||||||
|
the request will be considered "finished" even before it has been read.
|
||||||
|
|
||||||
|
There is no such thing as a response object to a `CONNECT` request in
|
||||||
|
Node.js, so there is no support for one.
|
||||||
|
|
||||||
|
### HTTP Upgrade request
|
||||||
|
|
||||||
|
The meaning of the `Upgrade` header from RFC 7230, section 6.1:
|
||||||
|
|
||||||
|
> The "Upgrade" header field is intended to provide a simple mechanism
|
||||||
|
> for transitioning from HTTP/1.1 to some other protocol on the same
|
||||||
|
> connection.
|
||||||
|
|
||||||
|
In Node.js, these request objects come from the `'upgrade'` event on
|
||||||
|
the HTTP server.
|
||||||
|
|
||||||
|
When this module is used on a HTTP request with an `Upgrade` header, the
|
||||||
|
request is considered "finished" immediately, **due to limitations in the
|
||||||
|
Node.js interface**. This means if the `Upgrade` request contains a request
|
||||||
|
entity, the request will be considered "finished" even before it has been
|
||||||
|
read.
|
||||||
|
|
||||||
|
There is no such thing as a response object to a `Upgrade` request in
|
||||||
|
Node.js, so there is no support for one.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
The following code ensures that file descriptors are always closed
|
||||||
|
once the response finishes.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var destroy = require('destroy')
|
||||||
|
var fs = require('fs')
|
||||||
|
var http = require('http')
|
||||||
|
var onFinished = require('on-finished')
|
||||||
|
|
||||||
|
http.createServer(function onRequest (req, res) {
|
||||||
|
var stream = fs.createReadStream('package.json')
|
||||||
|
stream.pipe(res)
|
||||||
|
onFinished(res, function () {
|
||||||
|
destroy(stream)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[ci-image]: https://badgen.net/github/checks/jshttp/on-finished/master?label=ci
|
||||||
|
[ci-url]: https://github.com/jshttp/on-finished/actions/workflows/ci.yml
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/on-finished/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/on-finished?branch=master
|
||||||
|
[node-image]: https://badgen.net/npm/node/on-finished
|
||||||
|
[node-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/on-finished
|
||||||
|
[npm-url]: https://npmjs.org/package/on-finished
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/on-finished
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user