diff --git a/node_modules/.bin/errno b/node_modules/.bin/errno deleted file mode 100644 index c3be4fc5..00000000 --- a/node_modules/.bin/errno +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") - -case `uname` in - *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; -esac - -if [ -x "$basedir/node" ]; then - exec "$basedir/node" "$basedir/../errno/cli.js" "$@" -else - exec node "$basedir/../errno/cli.js" "$@" -fi diff --git a/node_modules/.bin/errno.cmd b/node_modules/.bin/errno.cmd deleted file mode 100644 index 609af3bf..00000000 --- a/node_modules/.bin/errno.cmd +++ /dev/null @@ -1,17 +0,0 @@ -@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%\..\errno\cli.js" %* diff --git a/node_modules/.bin/errno.ps1 b/node_modules/.bin/errno.ps1 deleted file mode 100644 index 2b2d86fa..00000000 --- a/node_modules/.bin/errno.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#!/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/../errno/cli.js" $args - } else { - & "$basedir/node$exe" "$basedir/../errno/cli.js" $args - } - $ret=$LASTEXITCODE -} else { - # Support pipeline input - if ($MyInvocation.ExpectingInput) { - $input | & "node$exe" "$basedir/../errno/cli.js" $args - } else { - & "node$exe" "$basedir/../errno/cli.js" $args - } - $ret=$LASTEXITCODE -} -exit $ret diff --git a/node_modules/.bin/image-size b/node_modules/.bin/image-size deleted file mode 100644 index ae4ce4c9..00000000 --- a/node_modules/.bin/image-size +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") - -case `uname` in - *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; -esac - -if [ -x "$basedir/node" ]; then - exec "$basedir/node" "$basedir/../image-size/bin/image-size.js" "$@" -else - exec node "$basedir/../image-size/bin/image-size.js" "$@" -fi diff --git a/node_modules/.bin/image-size.cmd b/node_modules/.bin/image-size.cmd deleted file mode 100644 index 5ebeb0ef..00000000 --- a/node_modules/.bin/image-size.cmd +++ /dev/null @@ -1,17 +0,0 @@ -@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%\..\image-size\bin\image-size.js" %* diff --git a/node_modules/.bin/image-size.ps1 b/node_modules/.bin/image-size.ps1 deleted file mode 100644 index 606184aa..00000000 --- a/node_modules/.bin/image-size.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#!/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/../image-size/bin/image-size.js" $args - } else { - & "$basedir/node$exe" "$basedir/../image-size/bin/image-size.js" $args - } - $ret=$LASTEXITCODE -} else { - # Support pipeline input - if ($MyInvocation.ExpectingInput) { - $input | & "node$exe" "$basedir/../image-size/bin/image-size.js" $args - } else { - & "node$exe" "$basedir/../image-size/bin/image-size.js" $args - } - $ret=$LASTEXITCODE -} -exit $ret diff --git a/node_modules/.bin/mime b/node_modules/.bin/mime deleted file mode 100644 index 0a62a1b1..00000000 --- a/node_modules/.bin/mime +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") - -case `uname` in - *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; -esac - -if [ -x "$basedir/node" ]; then - exec "$basedir/node" "$basedir/../mime/cli.js" "$@" -else - exec node "$basedir/../mime/cli.js" "$@" -fi diff --git a/node_modules/.bin/mime.cmd b/node_modules/.bin/mime.cmd deleted file mode 100644 index 54491f12..00000000 --- a/node_modules/.bin/mime.cmd +++ /dev/null @@ -1,17 +0,0 @@ -@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" %* diff --git a/node_modules/.bin/mime.ps1 b/node_modules/.bin/mime.ps1 deleted file mode 100644 index 2222f40b..00000000 --- a/node_modules/.bin/mime.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 diff --git a/node_modules/.bin/needle b/node_modules/.bin/needle deleted file mode 100644 index c7ed0fe6..00000000 --- a/node_modules/.bin/needle +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") - -case `uname` in - *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; -esac - -if [ -x "$basedir/node" ]; then - exec "$basedir/node" "$basedir/../needle/bin/needle" "$@" -else - exec node "$basedir/../needle/bin/needle" "$@" -fi diff --git a/node_modules/.bin/needle.cmd b/node_modules/.bin/needle.cmd deleted file mode 100644 index 7b711f98..00000000 --- a/node_modules/.bin/needle.cmd +++ /dev/null @@ -1,17 +0,0 @@ -@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%\..\needle\bin\needle" %* diff --git a/node_modules/.bin/needle.ps1 b/node_modules/.bin/needle.ps1 deleted file mode 100644 index 39c95acd..00000000 --- a/node_modules/.bin/needle.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#!/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/../needle/bin/needle" $args - } else { - & "$basedir/node$exe" "$basedir/../needle/bin/needle" $args - } - $ret=$LASTEXITCODE -} else { - # Support pipeline input - if ($MyInvocation.ExpectingInput) { - $input | & "node$exe" "$basedir/../needle/bin/needle" $args - } else { - & "node$exe" "$basedir/../needle/bin/needle" $args - } - $ret=$LASTEXITCODE -} -exit $ret diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 09a00735..f582e89b 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1432,18 +1432,6 @@ "once": "^1.4.0" } }, - "node_modules/errno": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", - "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", - "optional": true, - "dependencies": { - "prr": "~1.0.1" - }, - "bin": { - "errno": "cli.js" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -3445,18 +3433,6 @@ "node": ">=0.10.0" } }, - "node_modules/image-size": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", - "integrity": "sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=", - "optional": true, - "bin": { - "image-size": "bin/image-size.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/import-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/import-regex/-/import-regex-1.1.0.tgz", @@ -4288,28 +4264,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", - "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", - "optional": true, - "dependencies": { - "pify": "^4.0.1", - "semver": "^5.6.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/make-dir/node_modules/pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "optional": true, - "engines": { - "node": ">=6" - } - }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -4475,18 +4429,6 @@ "node": ">=0.10.0" } }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "optional": true, - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", @@ -4645,38 +4587,6 @@ "node": ">=0.10.0" } }, - "node_modules/needle": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.9.1.tgz", - "integrity": "sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ==", - "optional": true, - "dependencies": { - "debug": "^3.2.6", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - }, - "bin": { - "needle": "bin/needle" - }, - "engines": { - "node": ">= 4.4.x" - } - }, - "node_modules/needle/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "optional": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/needle/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "optional": true - }, "node_modules/next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -5348,12 +5258,6 @@ "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", "integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=" }, - "node_modules/prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", - "optional": true - }, "node_modules/pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -5880,12 +5784,6 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "node_modules/sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "optional": true - }, "node_modules/semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", diff --git a/node_modules/errno/.jshintrc b/node_modules/errno/.jshintrc deleted file mode 100644 index c8ef3ca4..00000000 --- a/node_modules/errno/.jshintrc +++ /dev/null @@ -1,59 +0,0 @@ -{ - "predef": [ ] - , "bitwise": false - , "camelcase": false - , "curly": false - , "eqeqeq": false - , "forin": false - , "immed": false - , "latedef": false - , "noarg": true - , "noempty": true - , "nonew": true - , "plusplus": false - , "quotmark": true - , "regexp": false - , "undef": true - , "unused": true - , "strict": false - , "trailing": true - , "maxlen": 120 - , "asi": true - , "boss": true - , "debug": true - , "eqnull": true - , "esnext": true - , "evil": true - , "expr": true - , "funcscope": false - , "globalstrict": false - , "iterator": false - , "lastsemic": true - , "laxbreak": true - , "laxcomma": true - , "loopfunc": true - , "multistr": false - , "onecase": false - , "proto": false - , "regexdash": false - , "scripturl": true - , "smarttabs": false - , "shadow": false - , "sub": true - , "supernew": false - , "validthis": true - , "browser": true - , "couch": false - , "devel": false - , "dojo": false - , "mootools": false - , "node": true - , "nonstandard": true - , "prototypejs": false - , "rhino": false - , "worker": true - , "wsh": false - , "nomen": false - , "onevar": false - , "passfail": false -} \ No newline at end of file diff --git a/node_modules/errno/.travis.yml b/node_modules/errno/.travis.yml deleted file mode 100644 index 9c068879..00000000 --- a/node_modules/errno/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -sudo: false - -language: node_js - -node_js: - - 14 - - 12 - - 10 - - 9 - - 8 - - 7 - - 6 - - 5 - - 4 - -arch: - - amd64 - - ppc64le - diff --git a/node_modules/errno/README.md b/node_modules/errno/README.md deleted file mode 100644 index a4d0fb54..00000000 --- a/node_modules/errno/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# node-errno - -> Better [libuv](https://github.com/libuv/libuv)/[Node.js](https://nodejs.org)/[io.js](https://iojs.org) error handling & reporting. Available in npm as *errno*. - -[![npm](https://img.shields.io/npm/v/errno.svg)](https://www.npmjs.com/package/errno) -[![Build Status](https://secure.travis-ci.org/rvagg/node-errno.png)](http://travis-ci.org/rvagg/node-errno) -[![npm](https://img.shields.io/npm/dm/errno.svg)](https://www.npmjs.com/package/errno) - -* [errno exposed](#errnoexposed) -* [Custom errors](#customerrors) - - -## errno exposed - -Ever find yourself needing more details about Node.js errors? Me too, so *node-errno* contains the errno mappings direct from libuv so you can use them in your code. - -**By errno:** - -```js -require('errno').errno[3] -// → { -// "errno": 3, -// "code": "EACCES", -// "description": "permission denied" -// } -``` - -**By code:** - -```js -require('errno').code.ENOTEMPTY -// → { -// "errno": 53, -// "code": "ENOTEMPTY", -// "description": "directory not empty" -// } -``` - -**Make your errors more descriptive:** - -```js -var errno = require('errno') - -function errmsg(err) { - var str = 'Error: ' - // if it's a libuv error then get the description from errno - if (errno.errno[err.errno]) - str += errno.errno[err.errno].description - else - str += err.message - - // if it's a `fs` error then it'll have a 'path' property - if (err.path) - str += ' [' + err.path + ']' - - return str -} - -var fs = require('fs') - -fs.readFile('thisisnotarealfile.txt', function (err, data) { - if (err) - console.log(errmsg(err)) -}) -``` - -**Use as a command line tool:** - -``` -~ $ errno 53 -{ - "errno": 53, - "code": "ENOTEMPTY", - "description": "directory not empty" -} -~ $ errno EROFS -{ - "errno": 56, - "code": "EROFS", - "description": "read-only file system" -} -~ $ errno foo -No such errno/code: "foo" -``` - -Supply no arguments for the full list. Error codes are processed case-insensitive. - -You will need to install with `npm install errno -g` if you want the `errno` command to be available without supplying a full path to the node_modules installation. - - -## Custom errors - -Use `errno.custom.createError()` to create custom `Error` objects to throw around in your Node.js library. Create error hierarchies so `instanceof` becomes a useful tool in tracking errors. Call-stack is correctly captured at the time you create an instance of the error object, plus a `cause` property will make available the original error object if you pass one in to the constructor. - -```js -var create = require('errno').custom.createError -var MyError = create('MyError') // inherits from Error -var SpecificError = create('SpecificError', MyError) // inherits from MyError -var OtherError = create('OtherError', MyError) - -// use them! -if (condition) throw new SpecificError('Eeek! Something bad happened') - -if (err) return callback(new OtherError(err)) -``` - -Also available is a `errno.custom.FilesystemError` with in-built access to errno properties: - -```js -fs.readFile('foo', function (err, data) { - if (err) return callback(new errno.custom.FilesystemError(err)) - // do something else -}) -``` - -The resulting error object passed through the callback will have the following properties: `code`, `errno`, `path` and `message` will contain a descriptive human-readable message. - -## Contributors - -* [bahamas10](https://github.com/bahamas10) (Dave Eddy) - Added CLI -* [ralphtheninja](https://github.com/ralphtheninja) (Lars-Magnus Skog) - -## Copyright & Licence - -*Copyright (c) 2012-2015 [Rod Vagg](https://github.com/rvagg) ([@rvagg](https://twitter.com/rvagg))* - -Made available under the MIT licence: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/errno/build.js b/node_modules/errno/build.js deleted file mode 100644 index fce89260..00000000 --- a/node_modules/errno/build.js +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env node - -var request = require('request') - , fs = require('fs') - - , uvheadloc = 'https://raw.github.com/joyent/libuv/master/include/uv.h' - , defreg = /^\s*XX\(\s*([\-\d]+),\s*([A-Z]+),\s*"([^"]*)"\s*\)\s*\\?$/ - - -request(uvheadloc, function (err, response) { - if (err) - throw err - - var data, out - - data = response.body - .split('\n') - .map(function (line) { return line.match(defreg) }) - .filter(function (match) { return match }) - .map(function (match) { return { - errno: parseInt(match[1], 10) - , code: match[2] - , description: match[3] - }}) - - out = 'var all = module.exports.all = ' + JSON.stringify(data, 0, 1) + '\n\n' - - out += '\nmodule.exports.errno = {\n ' - + data.map(function (e, i) { - return '\'' + e.errno + '\': all[' + i + ']' - }).join('\n , ') - + '\n}\n\n' - - out += '\nmodule.exports.code = {\n ' - + data.map(function (e, i) { - return '\'' + e.code + '\': all[' + i + ']' - }).join('\n , ') - + '\n}\n\n' - - out += '\nmodule.exports.custom = require("./custom")(module.exports)\n' - - fs.writeFile('errno.js', out) -}) \ No newline at end of file diff --git a/node_modules/errno/cli.js b/node_modules/errno/cli.js deleted file mode 100644 index 61d179bb..00000000 --- a/node_modules/errno/cli.js +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env node - -var errno = require('./') - , arg = process.argv[2] - , data, code - -if (arg === undefined) { - console.log(JSON.stringify(errno.code, null, 2)) - process.exit(0) -} - -if ((code = +arg) == arg) - data = errno.errno[code] -else - data = errno.code[arg] || errno.code[arg.toUpperCase()] - -if (data) - console.log(JSON.stringify(data, null, 2)) -else { - console.error('No such errno/code: "' + arg + '"') - process.exit(1) -} diff --git a/node_modules/errno/custom.js b/node_modules/errno/custom.js deleted file mode 100644 index ca8c1d8d..00000000 --- a/node_modules/errno/custom.js +++ /dev/null @@ -1,57 +0,0 @@ -var prr = require('prr') - -function init (type, message, cause) { - if (!!message && typeof message != 'string') { - message = message.message || message.name - } - prr(this, { - type : type - , name : type - // can be passed just a 'cause' - , cause : typeof message != 'string' ? message : cause - , message : message - }, 'ewr') -} - -// generic prototype, not intended to be actually used - helpful for `instanceof` -function CustomError (message, cause) { - Error.call(this) - if (Error.captureStackTrace) - Error.captureStackTrace(this, this.constructor) - init.call(this, 'CustomError', message, cause) -} - -CustomError.prototype = new Error() - -function createError (errno, type, proto) { - var err = function (message, cause) { - init.call(this, type, message, cause) - //TODO: the specificity here is stupid, errno should be available everywhere - if (type == 'FilesystemError') { - this.code = this.cause.code - this.path = this.cause.path - this.errno = this.cause.errno - this.message = - (errno.errno[this.cause.errno] - ? errno.errno[this.cause.errno].description - : this.cause.message) - + (this.cause.path ? ' [' + this.cause.path + ']' : '') - } - Error.call(this) - if (Error.captureStackTrace) - Error.captureStackTrace(this, err) - } - err.prototype = !!proto ? new proto() : new CustomError() - return err -} - -module.exports = function (errno) { - var ce = function (type, proto) { - return createError(errno, type, proto) - } - return { - CustomError : CustomError - , FilesystemError : ce('FilesystemError') - , createError : ce - } -} diff --git a/node_modules/errno/errno.js b/node_modules/errno/errno.js deleted file mode 100644 index efb79d41..00000000 --- a/node_modules/errno/errno.js +++ /dev/null @@ -1,313 +0,0 @@ -var all = module.exports.all = [ - { - errno: -2, - code: 'ENOENT', - description: 'no such file or directory' - }, - { - errno: -1, - code: 'UNKNOWN', - description: 'unknown error' - }, - { - errno: 0, - code: 'OK', - description: 'success' - }, - { - errno: 1, - code: 'EOF', - description: 'end of file' - }, - { - errno: 2, - code: 'EADDRINFO', - description: 'getaddrinfo error' - }, - { - errno: 3, - code: 'EACCES', - description: 'permission denied' - }, - { - errno: 4, - code: 'EAGAIN', - description: 'resource temporarily unavailable' - }, - { - errno: 5, - code: 'EADDRINUSE', - description: 'address already in use' - }, - { - errno: 6, - code: 'EADDRNOTAVAIL', - description: 'address not available' - }, - { - errno: 7, - code: 'EAFNOSUPPORT', - description: 'address family not supported' - }, - { - errno: 8, - code: 'EALREADY', - description: 'connection already in progress' - }, - { - errno: 9, - code: 'EBADF', - description: 'bad file descriptor' - }, - { - errno: 10, - code: 'EBUSY', - description: 'resource busy or locked' - }, - { - errno: 11, - code: 'ECONNABORTED', - description: 'software caused connection abort' - }, - { - errno: 12, - code: 'ECONNREFUSED', - description: 'connection refused' - }, - { - errno: 13, - code: 'ECONNRESET', - description: 'connection reset by peer' - }, - { - errno: 14, - code: 'EDESTADDRREQ', - description: 'destination address required' - }, - { - errno: 15, - code: 'EFAULT', - description: 'bad address in system call argument' - }, - { - errno: 16, - code: 'EHOSTUNREACH', - description: 'host is unreachable' - }, - { - errno: 17, - code: 'EINTR', - description: 'interrupted system call' - }, - { - errno: 18, - code: 'EINVAL', - description: 'invalid argument' - }, - { - errno: 19, - code: 'EISCONN', - description: 'socket is already connected' - }, - { - errno: 20, - code: 'EMFILE', - description: 'too many open files' - }, - { - errno: 21, - code: 'EMSGSIZE', - description: 'message too long' - }, - { - errno: 22, - code: 'ENETDOWN', - description: 'network is down' - }, - { - errno: 23, - code: 'ENETUNREACH', - description: 'network is unreachable' - }, - { - errno: 24, - code: 'ENFILE', - description: 'file table overflow' - }, - { - errno: 25, - code: 'ENOBUFS', - description: 'no buffer space available' - }, - { - errno: 26, - code: 'ENOMEM', - description: 'not enough memory' - }, - { - errno: 27, - code: 'ENOTDIR', - description: 'not a directory' - }, - { - errno: 28, - code: 'EISDIR', - description: 'illegal operation on a directory' - }, - { - errno: 29, - code: 'ENONET', - description: 'machine is not on the network' - }, - { - errno: 31, - code: 'ENOTCONN', - description: 'socket is not connected' - }, - { - errno: 32, - code: 'ENOTSOCK', - description: 'socket operation on non-socket' - }, - { - errno: 33, - code: 'ENOTSUP', - description: 'operation not supported on socket' - }, - { - errno: 34, - code: 'ENOENT', - description: 'no such file or directory' - }, - { - errno: 35, - code: 'ENOSYS', - description: 'function not implemented' - }, - { - errno: 36, - code: 'EPIPE', - description: 'broken pipe' - }, - { - errno: 37, - code: 'EPROTO', - description: 'protocol error' - }, - { - errno: 38, - code: 'EPROTONOSUPPORT', - description: 'protocol not supported' - }, - { - errno: 39, - code: 'EPROTOTYPE', - description: 'protocol wrong type for socket' - }, - { - errno: 40, - code: 'ETIMEDOUT', - description: 'connection timed out' - }, - { - errno: 41, - code: 'ECHARSET', - description: 'invalid Unicode character' - }, - { - errno: 42, - code: 'EAIFAMNOSUPPORT', - description: 'address family for hostname not supported' - }, - { - errno: 44, - code: 'EAISERVICE', - description: 'servname not supported for ai_socktype' - }, - { - errno: 45, - code: 'EAISOCKTYPE', - description: 'ai_socktype not supported' - }, - { - errno: 46, - code: 'ESHUTDOWN', - description: 'cannot send after transport endpoint shutdown' - }, - { - errno: 47, - code: 'EEXIST', - description: 'file already exists' - }, - { - errno: 48, - code: 'ESRCH', - description: 'no such process' - }, - { - errno: 49, - code: 'ENAMETOOLONG', - description: 'name too long' - }, - { - errno: 50, - code: 'EPERM', - description: 'operation not permitted' - }, - { - errno: 51, - code: 'ELOOP', - description: 'too many symbolic links encountered' - }, - { - errno: 52, - code: 'EXDEV', - description: 'cross-device link not permitted' - }, - { - errno: 53, - code: 'ENOTEMPTY', - description: 'directory not empty' - }, - { - errno: 54, - code: 'ENOSPC', - description: 'no space left on device' - }, - { - errno: 55, - code: 'EIO', - description: 'i/o error' - }, - { - errno: 56, - code: 'EROFS', - description: 'read-only file system' - }, - { - errno: 57, - code: 'ENODEV', - description: 'no such device' - }, - { - errno: 58, - code: 'ESPIPE', - description: 'invalid seek' - }, - { - errno: 59, - code: 'ECANCELED', - description: 'operation canceled' - } -] - -module.exports.errno = {} -module.exports.code = {} - -all.forEach(function (error) { - module.exports.errno[error.errno] = error - module.exports.code[error.code] = error -}) - -module.exports.custom = require('./custom')(module.exports) -module.exports.create = module.exports.custom.createError diff --git a/node_modules/errno/package.json b/node_modules/errno/package.json deleted file mode 100644 index eee3e559..00000000 --- a/node_modules/errno/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "errno", - "authors": [ - "Rod Vagg @rvagg (https://github.com/rvagg)" - ], - "description": "libuv errno details exposed", - "keywords": [ - "errors", - "errno", - "libuv" - ], - "version": "0.1.8", - "main": "errno.js", - "dependencies": { - "prr": "~1.0.1" - }, - "bin": { - "errno": "./cli.js" - }, - "devDependencies": { - "error-stack-parser": "^2.0.1", - "inherits": "^2.0.3", - "tape": "~4.8.0" - }, - "repository": { - "type": "git", - "url": "https://github.com/rvagg/node-errno.git" - }, - "license": "MIT", - "scripts": { - "test": "node --use_strict test.js" - } -} diff --git a/node_modules/errno/test.js b/node_modules/errno/test.js deleted file mode 100644 index 1c046357..00000000 --- a/node_modules/errno/test.js +++ /dev/null @@ -1,88 +0,0 @@ -var test = require('tape') - , inherits = require('inherits') - , ErrorStackParser = require('error-stack-parser') - , errno = require('./') - -test('sanity checks', function (t) { - t.ok(errno.all, 'errno.all not found') - t.ok(errno.errno, 'errno.errno not found') - t.ok(errno.code, 'errno.code not found') - - t.equal(errno.all.length, 60, 'found ' + errno.all.length + ', expected 60') - t.equal(errno.errno['-1'], errno.all[1], 'errno -1 not second element') - - t.equal(errno.code['UNKNOWN'], errno.all[1], 'code UNKNOWN not second element') - - t.equal(errno.errno[1], errno.all[3], 'errno 1 not fourth element') - - t.equal(errno.code['EOF'], errno.all[3], 'code EOF not fourth element') - t.end() -}) - -test('custom errors', function (t) { - const Cust = errno.create('FooNotBarError') - const cust = new Cust('foo is not bar') - - t.equal(cust.name, 'FooNotBarError', 'correct custom name') - t.equal(cust.type, 'FooNotBarError', 'correct custom type') - t.equal(cust.message, 'foo is not bar', 'correct custom message') - t.notOk(cust.cause, 'no cause') - t.end() -}) - -test('callstack', function (t) { - const MyError = errno.create('MyError') - - function lastFunction (ErrorType, cb) { - process.nextTick(cb, new ErrorType('oh noes!')) - } - - function secondLastFunction (ErrorType, cb) { - lastFunction(ErrorType, cb) - } - - function testFrames (t) { - return function (err) { - const stack = ErrorStackParser.parse(err) - t.same(stack[0].functionName, 'lastFunction', 'last stack frame ok') - t.same(stack[1].functionName, 'secondLastFunction', 'second last stack frame ok') - t.end() - } - } - - t.test('custom error, default prototype', function (t) { - secondLastFunction(MyError, testFrames(t)) - }) - - t.test('custom error, custom prototype', function (t) { - const MyError2 = errno.create('MyError2', MyError) - secondLastFunction(MyError2, testFrames(t)) - }) - - t.test('custom error, using inheritance', function (t) { - const CustomError = errno.custom.CustomError - - function MyError3 (message, cause) { - CustomError.call(this, message, cause) - } - - inherits(MyError3, CustomError) - - secondLastFunction(MyError3, testFrames(t)) - }) -}) - -test('error without message', function (t) { - const Cust = errno.create('WriteError') - const cust = new Cust({ - code: 22, - message: '', - name: 'QuotaExceededError' - }) - - t.equal(cust.name, 'WriteError', 'correct custom name') - t.equal(cust.type, 'WriteError', 'correct custom type') - t.equal(cust.message, 'QuotaExceededError', 'message is the name') - t.notOk(cust.cause, 'no cause') - t.end() -}) diff --git a/node_modules/image-size/LICENSE b/node_modules/image-size/LICENSE deleted file mode 100644 index 1341a90d..00000000 --- a/node_modules/image-size/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -The MIT License (MIT) - -Copyright © 2017 Aditya Yadav, http://netroy.in - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/image-size/Readme.md b/node_modules/image-size/Readme.md deleted file mode 100644 index 66c6ca2a..00000000 --- a/node_modules/image-size/Readme.md +++ /dev/null @@ -1,88 +0,0 @@ -# image-size - -[![NPM Version](https://img.shields.io/npm/v/image-size.svg)](https://www.npmjs.com/package/image-size) -[![Build Status](https://travis-ci.org/image-size/image-size.svg?branch=master)](https://travis-ci.org/image-size/image-size) -[![NPM Downloads](https://img.shields.io/npm/dm/image-size.svg)](http://npm-stat.com/charts.html?package=image-size&author=&from=&to=) -[![Coverage Status](https://img.shields.io/coveralls/image-size/image-size/master.svg)](https://coveralls.io/github/image-size/image-size?branch=master) -[![devDependency Status](https://david-dm.org/image-size/image-size/dev-status.svg)](https://david-dm.org/image-size/image-size#info=devDependencies) - -A [Node](https://nodejs.org/en/) module to get dimensions of any image file - -## Supported formats - -* BMP -* GIF -* JPEG -* PNG -* PSD -* TIFF -* WebP -* SVG -* DDS - -### Upcoming - -* SWF - -## Programmatic Usage - -``` -npm install image-size --save -``` - -### Synchronous - -```javascript -var sizeOf = require('image-size'); -var dimensions = sizeOf('images/funny-cats.png'); -console.log(dimensions.width, dimensions.height); -``` - -### Asynchronous - -```javascript -var sizeOf = require('image-size'); -sizeOf('images/funny-cats.png', function (err, dimensions) { - console.log(dimensions.width, dimensions.height); -}); -``` -NOTE: The asynchronous version doesn't work if the input is a Buffer. Use synchronous version instead. - -### Using a URL - -```javascript -var url = require('url'); -var http = require('http'); - -var sizeOf = require('image-size'); - -var imgUrl = 'http://my-amazing-website.com/image.jpeg'; -var options = url.parse(imgUrl); - -http.get(options, function (response) { - var chunks = []; - response.on('data', function (chunk) { - chunks.push(chunk); - }).on('end', function() { - var buffer = Buffer.concat(chunks); - console.log(sizeOf(buffer)); - }); -}); -``` - -You can optionally check the buffer lengths & stop downloading the image after a few kilobytes. -**You don't need to download the entire image** - -## Command-Line Usage (CLI) - -``` -npm install image-size --global -image-size image1 [image2] [image3] ... -``` - -## Credits - -not a direct port, but an attempt to have something like -[dabble's imagesize](https://github.com/dabble/imagesize/blob/master/lib/image_size.rb) as a node module. - -## [Contributors](Contributors.md) diff --git a/node_modules/image-size/bin/image-size.js b/node_modules/image-size/bin/image-size.js deleted file mode 100644 index 449b03ce..00000000 --- a/node_modules/image-size/bin/image-size.js +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env node -'use strict'; - -var fs = require('fs'); -var path = require('path'); - -var imageSize = require('..'); - -var files = process.argv.slice(2); - -if (!files.length) { - console.error('Usage: image-size image1 [image2] [image3] ...'); - process.exit(-1); -} - -var red = ['\x1B[31m', '\x1B[39m']; -// var bold = ['\x1B[1m', '\x1B[22m']; -var grey = ['\x1B[90m', '\x1B[39m']; -var green = ['\x1B[32m', '\x1B[39m']; - -files.forEach(function (image) { - try { - if (fs.existsSync(path.resolve(image))) { - var size = imageSize(image); - var label = green[0] + size.width + green[1] + - grey[0] + 'x' + grey[1] + - green[0] + size.height + green[1]; - console.info(label, '-', grey[0] + image + grey[1]); - } else { - console.error('file doesn\'t exist - ', image); - } - } catch (e) { - // console.error(e.stack); - console.error(red[0] + e.message + red[1], '-', image); - } -}); diff --git a/node_modules/image-size/lib/detector.js b/node_modules/image-size/lib/detector.js deleted file mode 100644 index f0e66d3c..00000000 --- a/node_modules/image-size/lib/detector.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var typeMap = {}; -var types = require('./types'); - -// load all available handlers -types.forEach(function (type) { - typeMap[type] = require('./types/' + type).detect; -}); - -module.exports = function (buffer, filepath) { - var type, result; - for (type in typeMap) { - result = typeMap[type](buffer, filepath); - if (result) { - return type; - } - } -}; diff --git a/node_modules/image-size/lib/index.js b/node_modules/image-size/lib/index.js deleted file mode 100644 index fcac144b..00000000 --- a/node_modules/image-size/lib/index.js +++ /dev/null @@ -1,105 +0,0 @@ -'use strict'; - -var fs = require('fs'); -var path = require('path'); - -var detector = require('./detector'); - -var handlers = {}; -var types = require('./types'); - -// load all available handlers -types.forEach(function (type) { - handlers[type] = require('./types/' + type); -}); - -// Maximum buffer size, with a default of 128 kilobytes. -// TO-DO: make this adaptive based on the initial signature of the image -var MaxBufferSize = 128*1024; - -function lookup (buffer, filepath) { - // detect the file type.. don't rely on the extension - var type = detector(buffer, filepath); - - // find an appropriate handler for this file type - if (type in handlers) { - var size = handlers[type].calculate(buffer, filepath); - if (size !== false) { - size.type = type; - return size; - } - } - - // throw up, if we don't understand the file - throw new TypeError('unsupported file type: ' + type + ' (file: ' + filepath + ')'); -} - -function asyncFileToBuffer (filepath, callback) { - // open the file in read only mode - fs.open(filepath, 'r', function (err, descriptor) { - if (err) { return callback(err); } - var size = fs.fstatSync(descriptor).size; - if (size <= 0){return callback(new Error("File size is not greater than 0 —— " + filepath)); } - var bufferSize = Math.min(size, MaxBufferSize); - var buffer = new Buffer(bufferSize); - // read first buffer block from the file, asynchronously - fs.read(descriptor, buffer, 0, bufferSize, 0, function (err) { - if (err) { return callback(err); } - // close the file, we are done - fs.close(descriptor, function (err) { - callback(err, buffer); - }); - }); - }); -} - -function syncFileToBuffer (filepath) { - // read from the file, synchronously - var descriptor = fs.openSync(filepath, 'r'); - var size = fs.fstatSync(descriptor).size; - var bufferSize = Math.min(size, MaxBufferSize); - var buffer = new Buffer(bufferSize); - fs.readSync(descriptor, buffer, 0, bufferSize, 0); - fs.closeSync(descriptor); - return buffer; -} - -/** - * @params input - buffer or relative/absolute path of the image file - * @params callback - optional function for async detection - */ -module.exports = function (input, callback) { - - // Handle buffer input - if (Buffer.isBuffer(input)) { - return lookup(input); - } - - // input should be a string at this point - if (typeof input !== 'string') { - throw new TypeError('invalid invocation'); - } - - // resolve the file path - var filepath = path.resolve(input); - - if (typeof callback === 'function') { - asyncFileToBuffer(filepath, function (err, buffer) { - if (err) { return callback(err); } - - // return the dimensions - var dimensions; - try { - dimensions = lookup(buffer, filepath); - } catch (e) { - err = e; - } - callback(err, dimensions); - }); - } else { - var buffer = syncFileToBuffer(filepath); - return lookup(buffer, filepath); - } -}; - -module.exports.types = types; diff --git a/node_modules/image-size/lib/readUInt.js b/node_modules/image-size/lib/readUInt.js deleted file mode 100644 index 36c6033c..00000000 --- a/node_modules/image-size/lib/readUInt.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -// Abstract reading multi-byte unsigned integers -function readUInt (buffer, bits, offset, isBigEndian) { - offset = offset || 0; - var endian = !!isBigEndian ? 'BE' : 'LE'; - var method = buffer['readUInt' + bits + endian]; - return method.call(buffer, offset); -} - -module.exports = readUInt; diff --git a/node_modules/image-size/lib/types.js b/node_modules/image-size/lib/types.js deleted file mode 100644 index 77fd7b52..00000000 --- a/node_modules/image-size/lib/types.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = [ - 'bmp', - 'gif', - 'jpg', - 'png', - 'psd', - 'svg', - 'tiff', - 'webp', - 'dds' -]; diff --git a/node_modules/image-size/lib/types/bmp.js b/node_modules/image-size/lib/types/bmp.js deleted file mode 100644 index ada01414..00000000 --- a/node_modules/image-size/lib/types/bmp.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -function isBMP (buffer) { - return ('BM' === buffer.toString('ascii', 0, 2)); -} - -function calculate (buffer) { - return { - 'width': buffer.readUInt32LE(18), - 'height': Math.abs(buffer.readInt32LE(22)) - }; -} - -module.exports = { - 'detect': isBMP, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/dds.js b/node_modules/image-size/lib/types/dds.js deleted file mode 100644 index 862c0460..00000000 --- a/node_modules/image-size/lib/types/dds.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -function isDDS(buffer){ - return buffer.readUInt32LE(0) === 0x20534444; -} - -function calculate(buffer){ - // read file resolution metadata - return { - 'height': buffer.readUInt32LE(12), - 'width': buffer.readUInt32LE(16) - }; -} - -module.exports = { - 'detect': isDDS, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/gif.js b/node_modules/image-size/lib/types/gif.js deleted file mode 100644 index b4970792..00000000 --- a/node_modules/image-size/lib/types/gif.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var gifRegexp = /^GIF8[79]a/; -function isGIF (buffer) { - var signature = buffer.toString('ascii', 0, 6); - return (gifRegexp.test(signature)); -} - -function calculate(buffer) { - return { - 'width': buffer.readUInt16LE(6), - 'height': buffer.readUInt16LE(8) - }; -} - -module.exports = { - 'detect': isGIF, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/jpg.js b/node_modules/image-size/lib/types/jpg.js deleted file mode 100644 index e8ed127d..00000000 --- a/node_modules/image-size/lib/types/jpg.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; - -// NOTE: we only support baseline and progressive JPGs here -// due to the structure of the loader class, we only get a buffer -// with a maximum size of 4096 bytes. so if the SOF marker is outside -// if this range we can't detect the file size correctly. - -function isJPG (buffer) { //, filepath - var SOIMarker = buffer.toString('hex', 0, 2); - return ('ffd8' === SOIMarker); -} - -function extractSize (buffer, i) { - return { - 'height' : buffer.readUInt16BE(i), - 'width' : buffer.readUInt16BE(i + 2) - }; -} - -function validateBuffer (buffer, i) { - // index should be within buffer limits - if (i > buffer.length) { - throw new TypeError('Corrupt JPG, exceeded buffer limits'); - } - // Every JPEG block must begin with a 0xFF - if (buffer[i] !== 0xFF) { - throw new TypeError('Invalid JPG, marker table corrupted'); - } -} - -function calculate (buffer) { - - // Skip 4 chars, they are for signature - buffer = buffer.slice(4); - - var i, next; - while (buffer.length) { - // read length of the next block - i = buffer.readUInt16BE(0); - - // ensure correct format - validateBuffer(buffer, i); - - // 0xFFC0 is baseline standard(SOF) - // 0xFFC1 is baseline optimized(SOF) - // 0xFFC2 is progressive(SOF2) - next = buffer[i + 1]; - if (next === 0xC0 || next === 0xC1 || next === 0xC2) { - return extractSize(buffer, i + 5); - } - - // move to the next block - buffer = buffer.slice(i + 2); - } - - throw new TypeError('Invalid JPG, no size found'); -} - -module.exports = { - 'detect': isJPG, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/png.js b/node_modules/image-size/lib/types/png.js deleted file mode 100644 index 9fe1a1e4..00000000 --- a/node_modules/image-size/lib/types/png.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -var pngSignature = 'PNG\r\n\x1a\n'; -var pngImageHeaderChunkName = 'IHDR'; -var pngFriedChunkName = 'CgBI'; // Used to detect "fried" png's: http://www.jongware.com/pngdefry.html - -function isPNG (buffer) { - if (pngSignature === buffer.toString('ascii', 1, 8)) { - var chunkName = buffer.toString('ascii', 12, 16); - if (chunkName === pngFriedChunkName) { - chunkName = buffer.toString('ascii', 28, 32); - } - if (chunkName !== pngImageHeaderChunkName) { - throw new TypeError('invalid png'); - } - return true; - } -} - -function calculate (buffer) { - if (buffer.toString('ascii', 12, 16) === pngFriedChunkName) { - return { - 'width': buffer.readUInt32BE(32), - 'height': buffer.readUInt32BE(36) - }; - } - return { - 'width': buffer.readUInt32BE(16), - 'height': buffer.readUInt32BE(20) - }; -} - -module.exports = { - 'detect': isPNG, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/psd.js b/node_modules/image-size/lib/types/psd.js deleted file mode 100644 index dec43047..00000000 --- a/node_modules/image-size/lib/types/psd.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -function isPSD (buffer) { - return ('8BPS' === buffer.toString('ascii', 0, 4)); -} - -function calculate (buffer) { - return { - 'width': buffer.readUInt32BE(18), - 'height': buffer.readUInt32BE(14) - }; -} - -module.exports = { - 'detect': isPSD, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/svg.js b/node_modules/image-size/lib/types/svg.js deleted file mode 100644 index 73c8d270..00000000 --- a/node_modules/image-size/lib/types/svg.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -var svgReg = /]+[^>]*>/; -function isSVG (buffer) { - return svgReg.test(buffer); -} - -var extractorRegExps = { - 'root': /]+>/, - 'width': /\bwidth=(['"])([^%]+?)\1/, - 'height': /\bheight=(['"])([^%]+?)\1/, - 'viewbox': /\bviewBox=(['"])(.+?)\1/ -}; - -function parseViewbox (viewbox) { - var bounds = viewbox.split(' '); - return { - 'width': parseInt(bounds[2], 10), - 'height': parseInt(bounds[3], 10) - }; -} - -function parseAttributes (root) { - var width = root.match(extractorRegExps.width); - var height = root.match(extractorRegExps.height); - var viewbox = root.match(extractorRegExps.viewbox); - return { - 'width': width && parseInt(width[2], 10), - 'height': height && parseInt(height[2], 10), - 'viewbox': viewbox && parseViewbox(viewbox[2]) - }; -} - -function calculateByDimensions (attrs) { - return { - 'width': attrs.width, - 'height': attrs.height - }; -} - -function calculateByViewbox (attrs) { - var ratio = attrs.viewbox.width / attrs.viewbox.height; - if (attrs.width) { - return { - 'width': attrs.width, - 'height': Math.floor(attrs.width / ratio) - }; - } - if (attrs.height) { - return { - 'width': Math.floor(attrs.height * ratio), - 'height': attrs.height - }; - } - return { - 'width': attrs.viewbox.width, - 'height': attrs.viewbox.height - }; -} - -function calculate (buffer) { - var root = buffer.toString('utf8').match(extractorRegExps.root); - if (root) { - var attrs = parseAttributes(root[0]); - if (attrs.width && attrs.height) { - return calculateByDimensions(attrs); - } - if (attrs.viewbox) { - return calculateByViewbox(attrs); - } - } - throw new TypeError('invalid svg'); -} - -module.exports = { - 'detect': isSVG, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/tiff.js b/node_modules/image-size/lib/types/tiff.js deleted file mode 100644 index 191676dd..00000000 --- a/node_modules/image-size/lib/types/tiff.js +++ /dev/null @@ -1,118 +0,0 @@ -'use strict'; - -// based on http://www.compix.com/fileformattif.htm -// TO-DO: support big-endian as well - -var fs = require('fs'); -var readUInt = require('../readUInt'); - -function isTIFF (buffer) { - var hex4 = buffer.toString('hex', 0, 4); - return ('49492a00' === hex4 || '4d4d002a' === hex4); -} - -// Read IFD (image-file-directory) into a buffer -function readIFD (buffer, filepath, isBigEndian) { - - var ifdOffset = readUInt(buffer, 32, 4, isBigEndian); - - // read only till the end of the file - var bufferSize = 1024; - var fileSize = fs.statSync(filepath).size; - if (ifdOffset + bufferSize > fileSize) { - bufferSize = fileSize - ifdOffset - 10; - } - - // populate the buffer - var endBuffer = new Buffer(bufferSize); - var descriptor = fs.openSync(filepath, 'r'); - fs.readSync(descriptor, endBuffer, 0, bufferSize, ifdOffset); - - // var ifdLength = readUInt(endBuffer, 16, 0, isBigEndian); - var ifdBuffer = endBuffer.slice(2); //, 2 + 12 * ifdLength); - return ifdBuffer; -} - -// TIFF values seem to be messed up on Big-Endian, this helps -function readValue (buffer, isBigEndian) { - var low = readUInt(buffer, 16, 8, isBigEndian); - var high = readUInt(buffer, 16, 10, isBigEndian); - return (high << 16) + low; -} - -// move to the next tag -function nextTag (buffer) { - if (buffer.length > 24) { - return buffer.slice(12); - } -} - -// Extract IFD tags from TIFF metadata -function extractTags (buffer, isBigEndian) { - var tags = {}; - var code, type, length; - - while (buffer && buffer.length) { - code = readUInt(buffer, 16, 0, isBigEndian); - type = readUInt(buffer, 16, 2, isBigEndian); - length = readUInt(buffer, 32, 4, isBigEndian); - - // 0 means end of IFD - if (code === 0) { - break; - } else { - // 256 is width, 257 is height - // if (code === 256 || code === 257) { - if (length === 1 && (type === 3 || type === 4)) { - tags[code] = readValue(buffer, isBigEndian); - } - - // move to the next tag - buffer = nextTag(buffer); - } - } - return tags; -} - -// Test if the TIFF is Big Endian or Little Endian -function determineEndianness (buffer) { - var signature = buffer.toString('ascii', 0, 2); - if ('II' === signature) { - return 'LE'; - } else if ('MM' === signature) { - return 'BE'; - } -} - -function calculate (buffer, filepath) { - - if (!filepath) { - throw new TypeError('Tiff doesn\'t support buffer'); - } - - // Determine BE/LE - var isBigEndian = determineEndianness(buffer) === 'BE'; - - // read the IFD - var ifdBuffer = readIFD(buffer, filepath, isBigEndian); - - // extract the tags from the IFD - var tags = extractTags(ifdBuffer, isBigEndian); - - var width = tags[256]; - var height = tags[257]; - - if (!width || !height) { - throw new TypeError('Invalid Tiff, missing tags'); - } - - return { - 'width': width, - 'height': height - }; -} - -module.exports = { - 'detect': isTIFF, - 'calculate': calculate -}; diff --git a/node_modules/image-size/lib/types/webp.js b/node_modules/image-size/lib/types/webp.js deleted file mode 100644 index 51cba629..00000000 --- a/node_modules/image-size/lib/types/webp.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -// based on https://developers.google.com/speed/webp/docs/riff_container - -function isWebP (buffer) { - var riffHeader = 'RIFF' === buffer.toString('ascii', 0, 4); - var webpHeader = 'WEBP' === buffer.toString('ascii', 8, 12); - var vp8Header = 'VP8' === buffer.toString('ascii', 12, 15); - return (riffHeader && webpHeader && vp8Header); -} - -function calculate (buffer) { - var chunkHeader = buffer.toString('ascii', 12, 16); - buffer = buffer.slice(20, 30); - - // Extended webp stream signature - if (chunkHeader === 'VP8X') { - var extendedHeader = buffer[0]; - var validStart = (extendedHeader & 0xc0) === 0; - var validEnd = (extendedHeader & 0x01) === 0; - if (validStart && validEnd) { - return calculateExtended(buffer); - } else { - return false; - } - } - - // Lossless webp stream signature - if (chunkHeader === 'VP8 ' && buffer[0] !== 0x2f) { - return calculateLossy(buffer); - } - - // Lossy webp stream signature - var signature = buffer.toString('hex', 3, 6); - if (chunkHeader === 'VP8L' && signature !== '9d012a') { - return calculateLossless(buffer); - } - - return false; -} - -function calculateExtended (buffer) { - return { - 'width': 1 + buffer.readUIntLE(4, 3), - 'height': 1 + buffer.readUIntLE(7, 3) - } -} - -function calculateLossless (buffer) { - return { - 'width': 1 + (((buffer[2] & 0x3F) << 8) | buffer[1]), - 'height': 1 + (((buffer[4] & 0xF) << 10) | (buffer[3] << 2) | - ((buffer[2] & 0xC0) >> 6)) - }; -} - -function calculateLossy (buffer) { - // `& 0x3fff` returns the last 14 bits - // TO-DO: include webp scaling in the calculations - return { - 'width': buffer.readInt16LE(6) & 0x3fff, - 'height': buffer.readInt16LE(8) & 0x3fff - }; -} - -module.exports = { - 'detect': isWebP, - 'calculate': calculate -}; diff --git a/node_modules/image-size/package.json b/node_modules/image-size/package.json deleted file mode 100644 index a26130eb..00000000 --- a/node_modules/image-size/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "image-size", - "version": "0.5.5", - "description": "get dimensions of any image file", - "main": "lib/index.js", - "files": [ - "bin", - "lib" - ], - "engines": { - "node": ">=0.10.0" - }, - "bin": { - "image-size": "bin/image-size.js" - }, - "scripts": { - "pretest": "jshint", - "test": "mocha specs", - "coverage": "istanbul cover _mocha specs" - }, - "repository": "image-size/image-size", - "keywords": [ - "image", - "size", - "dimensions", - "resolution", - "width", - "height", - "png", - "jpeg", - "bmp", - "gif", - "psd", - "tiff", - "webp", - "svg" - ], - "author": "netroy (http://netroy.in/)", - "license": "MIT", - "devDependencies": { - "escomplex-js": "^1.2.0", - "expect.js": "^0.3.1", - "glob": "^7.1.1", - "istanbul": "^1.1.0-alpha.1", - "jshint": "^2.9.4", - "mocha": "^3.4.1", - "sinon": "^2.2.0" - } -} diff --git a/node_modules/make-dir/index.d.ts b/node_modules/make-dir/index.d.ts deleted file mode 100644 index 3e1529c6..00000000 --- a/node_modules/make-dir/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// -import * as fs from 'fs'; - -export interface Options { - /** - * Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/). - * - * @default 0o777 & (~process.umask()) - */ - readonly mode?: number; - - /** - * Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs). - * - * Using a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function. - * - * @default require('fs') - */ - readonly fs?: typeof fs; -} - -/** - * Make a directory and its parents if needed - Think `mkdir -p`. - * - * @param path - Directory to create. - * @returns A `Promise` for the path to the created directory. - */ -export default function makeDir( - path: string, - options?: Options -): Promise; - -/** - * Synchronously make a directory and its parents if needed - Think `mkdir -p`. - * - * @param path - Directory to create. - * @returns The path to the created directory. - */ -export function sync(path: string, options?: Options): string; diff --git a/node_modules/make-dir/index.js b/node_modules/make-dir/index.js deleted file mode 100644 index 4d95c916..00000000 --- a/node_modules/make-dir/index.js +++ /dev/null @@ -1,139 +0,0 @@ -'use strict'; -const fs = require('fs'); -const path = require('path'); -const pify = require('pify'); -const semver = require('semver'); - -const defaults = { - mode: 0o777 & (~process.umask()), - fs -}; - -const useNativeRecursiveOption = semver.satisfies(process.version, '>=10.12.0'); - -// https://github.com/nodejs/node/issues/8987 -// https://github.com/libuv/libuv/pull/1088 -const checkPath = pth => { - if (process.platform === 'win32') { - const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, '')); - - if (pathHasInvalidWinCharacters) { - const error = new Error(`Path contains invalid characters: ${pth}`); - error.code = 'EINVAL'; - throw error; - } - } -}; - -const permissionError = pth => { - // This replicates the exception of `fs.mkdir` with native the - // `recusive` option when run on an invalid drive under Windows. - const error = new Error(`operation not permitted, mkdir '${pth}'`); - error.code = 'EPERM'; - error.errno = -4048; - error.path = pth; - error.syscall = 'mkdir'; - return error; -}; - -const makeDir = (input, options) => Promise.resolve().then(() => { - checkPath(input); - options = Object.assign({}, defaults, options); - - // TODO: Use util.promisify when targeting Node.js 8 - const mkdir = pify(options.fs.mkdir); - const stat = pify(options.fs.stat); - - if (useNativeRecursiveOption && options.fs.mkdir === fs.mkdir) { - const pth = path.resolve(input); - - return mkdir(pth, { - mode: options.mode, - recursive: true - }).then(() => pth); - } - - const make = pth => { - return mkdir(pth, options.mode) - .then(() => pth) - .catch(error => { - if (error.code === 'EPERM') { - throw error; - } - - if (error.code === 'ENOENT') { - if (path.dirname(pth) === pth) { - throw permissionError(pth); - } - - if (error.message.includes('null bytes')) { - throw error; - } - - return make(path.dirname(pth)).then(() => make(pth)); - } - - return stat(pth) - .then(stats => stats.isDirectory() ? pth : Promise.reject()) - .catch(() => { - throw error; - }); - }); - }; - - return make(path.resolve(input)); -}); - -module.exports = makeDir; -module.exports.default = makeDir; - -module.exports.sync = (input, options) => { - checkPath(input); - options = Object.assign({}, defaults, options); - - if (useNativeRecursiveOption && options.fs.mkdirSync === fs.mkdirSync) { - const pth = path.resolve(input); - - fs.mkdirSync(pth, { - mode: options.mode, - recursive: true - }); - - return pth; - } - - const make = pth => { - try { - options.fs.mkdirSync(pth, options.mode); - } catch (error) { - if (error.code === 'EPERM') { - throw error; - } - - if (error.code === 'ENOENT') { - if (path.dirname(pth) === pth) { - throw permissionError(pth); - } - - if (error.message.includes('null bytes')) { - throw error; - } - - make(path.dirname(pth)); - return make(pth); - } - - try { - if (!options.fs.statSync(pth).isDirectory()) { - throw new Error('The path is not a directory'); - } - } catch (_) { - throw error; - } - } - - return pth; - }; - - return make(path.resolve(input)); -}; diff --git a/node_modules/make-dir/license b/node_modules/make-dir/license deleted file mode 100644 index e7af2f77..00000000 --- a/node_modules/make-dir/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/make-dir/node_modules/pify/index.js b/node_modules/make-dir/node_modules/pify/index.js deleted file mode 100644 index df56221d..00000000 --- a/node_modules/make-dir/node_modules/pify/index.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; - -const processFn = (fn, options) => function (...args) { - const P = options.promiseModule; - - return new P((resolve, reject) => { - if (options.multiArgs) { - args.push((...result) => { - if (options.errorFirst) { - if (result[0]) { - reject(result); - } else { - result.shift(); - resolve(result); - } - } else { - resolve(result); - } - }); - } else if (options.errorFirst) { - args.push((error, result) => { - if (error) { - reject(error); - } else { - resolve(result); - } - }); - } else { - args.push(resolve); - } - - fn.apply(this, args); - }); -}; - -module.exports = (input, options) => { - options = Object.assign({ - exclude: [/.+(Sync|Stream)$/], - errorFirst: true, - promiseModule: Promise - }, options); - - const objType = typeof input; - if (!(input !== null && (objType === 'object' || objType === 'function'))) { - throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${input === null ? 'null' : objType}\``); - } - - const filter = key => { - const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key); - return options.include ? options.include.some(match) : !options.exclude.some(match); - }; - - let ret; - if (objType === 'function') { - ret = function (...args) { - return options.excludeMain ? input(...args) : processFn(input, options).apply(this, args); - }; - } else { - ret = Object.create(Object.getPrototypeOf(input)); - } - - for (const key in input) { // eslint-disable-line guard-for-in - const property = input[key]; - ret[key] = typeof property === 'function' && filter(key) ? processFn(property, options) : property; - } - - return ret; -}; diff --git a/node_modules/make-dir/node_modules/pify/license b/node_modules/make-dir/node_modules/pify/license deleted file mode 100644 index e7af2f77..00000000 --- a/node_modules/make-dir/node_modules/pify/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/make-dir/node_modules/pify/package.json b/node_modules/make-dir/node_modules/pify/package.json deleted file mode 100644 index a5468cd2..00000000 --- a/node_modules/make-dir/node_modules/pify/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "pify", - "version": "4.0.1", - "description": "Promisify a callback-style function", - "license": "MIT", - "repository": "sindresorhus/pify", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=6" - }, - "scripts": { - "test": "xo && ava", - "optimization-test": "node --allow-natives-syntax optimization-test.js" - }, - "files": [ - "index.js" - ], - "keywords": [ - "promise", - "promises", - "promisify", - "all", - "denodify", - "denodeify", - "callback", - "cb", - "node", - "then", - "thenify", - "convert", - "transform", - "wrap", - "wrapper", - "bind", - "to", - "async", - "await", - "es2015", - "bluebird" - ], - "devDependencies": { - "ava": "^0.25.0", - "pinkie-promise": "^2.0.0", - "v8-natives": "^1.1.0", - "xo": "^0.23.0" - } -} diff --git a/node_modules/make-dir/node_modules/pify/readme.md b/node_modules/make-dir/node_modules/pify/readme.md deleted file mode 100644 index 7ae3f1c5..00000000 --- a/node_modules/make-dir/node_modules/pify/readme.md +++ /dev/null @@ -1,145 +0,0 @@ -# pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify) - -> Promisify a callback-style function - ---- - -
- - Get professional support for 'pify' with a Tidelift subscription - -
- - Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. -
-
- ---- - - -## Install - -``` -$ npm install pify -``` - - -## Usage - -```js -const fs = require('fs'); -const pify = require('pify'); - -// Promisify a single function -pify(fs.readFile)('package.json', 'utf8').then(data => { - console.log(JSON.parse(data).name); - //=> 'pify' -}); - -// Promisify all methods in a module -pify(fs).readFile('package.json', 'utf8').then(data => { - console.log(JSON.parse(data).name); - //=> 'pify' -}); -``` - - -## API - -### pify(input, [options]) - -Returns a `Promise` wrapped version of the supplied function or module. - -#### input - -Type: `Function` `Object` - -Callback-style function or module whose methods you want to promisify. - -#### options - -##### multiArgs - -Type: `boolean`
-Default: `false` - -By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. This also applies to rejections, where it returns an array of all the callback arguments, including the error. - -```js -const request = require('request'); -const pify = require('pify'); - -pify(request, {multiArgs: true})('https://sindresorhus.com').then(result => { - const [httpResponse, body] = result; -}); -``` - -##### include - -Type: `string[]` `RegExp[]` - -Methods in a module to promisify. Remaining methods will be left untouched. - -##### exclude - -Type: `string[]` `RegExp[]`
-Default: `[/.+(Sync|Stream)$/]` - -Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default. - -##### excludeMain - -Type: `boolean`
-Default: `false` - -If given module is a function itself, it will be promisified. Turn this option on if you want to promisify only methods of the module. - -```js -const pify = require('pify'); - -function fn() { - return true; -} - -fn.method = (data, callback) => { - setImmediate(() => { - callback(null, data); - }); -}; - -// Promisify methods but not `fn()` -const promiseFn = pify(fn, {excludeMain: true}); - -if (promiseFn()) { - promiseFn.method('hi').then(data => { - console.log(data); - }); -} -``` - -##### errorFirst - -Type: `boolean`
-Default: `true` - -Whether the callback has an error as the first argument. You'll want to set this to `false` if you're dealing with an API that doesn't have an error as the first argument, like `fs.exists()`, some browser APIs, Chrome Extension APIs, etc. - -##### promiseModule - -Type: `Function` - -Custom promise module to use instead of the native one. - -Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill. - - -## Related - -- [p-event](https://github.com/sindresorhus/p-event) - Promisify an event by waiting for it to be emitted -- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently -- [More…](https://github.com/sindresorhus/promise-fun) - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/make-dir/package.json b/node_modules/make-dir/package.json deleted file mode 100644 index 1b51bf70..00000000 --- a/node_modules/make-dir/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "make-dir", - "version": "2.1.0", - "description": "Make a directory and its parents if needed - Think `mkdir -p`", - "license": "MIT", - "repository": "sindresorhus/make-dir", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=6" - }, - "scripts": { - "test": "xo && nyc ava && tsd-check" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "mkdir", - "mkdirp", - "make", - "directories", - "dir", - "dirs", - "folders", - "directory", - "folder", - "path", - "parent", - "parents", - "intermediate", - "recursively", - "recursive", - "create", - "fs", - "filesystem", - "file-system" - ], - "dependencies": { - "pify": "^4.0.1", - "semver": "^5.6.0" - }, - "devDependencies": { - "@types/graceful-fs": "^4.1.3", - "@types/node": "^11.10.4", - "ava": "^1.2.0", - "codecov": "^3.0.0", - "graceful-fs": "^4.1.11", - "nyc": "^13.1.0", - "path-type": "^3.0.0", - "tempy": "^0.2.1", - "tsd-check": "^0.3.0", - "xo": "^0.24.0" - } -} diff --git a/node_modules/make-dir/readme.md b/node_modules/make-dir/readme.md deleted file mode 100644 index 8c225c1f..00000000 --- a/node_modules/make-dir/readme.md +++ /dev/null @@ -1,123 +0,0 @@ -# make-dir [![Build Status](https://travis-ci.org/sindresorhus/make-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/make-dir) [![codecov](https://codecov.io/gh/sindresorhus/make-dir/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/make-dir) - -> Make a directory and its parents if needed - Think `mkdir -p` - - -## Advantages over [`mkdirp`](https://github.com/substack/node-mkdirp) - -- Promise API *(Async/await ready!)* -- Fixes many `mkdirp` issues: [#96](https://github.com/substack/node-mkdirp/pull/96) [#70](https://github.com/substack/node-mkdirp/issues/70) [#66](https://github.com/substack/node-mkdirp/issues/66) -- 100% test coverage -- CI-tested on macOS, Linux, and Windows -- Actively maintained -- Doesn't bundle a CLI -- Uses native the `fs.mkdir/mkdirSync` [`recursive` option](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_mkdir_path_options_callback) in Node.js >=10.12.0 unless [overridden](#fs) - - -## Install - -``` -$ npm install make-dir -``` - - -## Usage - -``` -$ pwd -/Users/sindresorhus/fun -$ tree -. -``` - -```js -const makeDir = require('make-dir'); - -(async () => { - const path = await makeDir('unicorn/rainbow/cake'); - - console.log(path); - //=> '/Users/sindresorhus/fun/unicorn/rainbow/cake' -})(); -``` - -``` -$ tree -. -└── unicorn - └── rainbow - └── cake -``` - -Multiple directories: - -```js -const makeDir = require('make-dir'); - -(async () => { - const paths = await Promise.all([ - makeDir('unicorn/rainbow'), - makeDir('foo/bar') - ]); - - console.log(paths); - /* - [ - '/Users/sindresorhus/fun/unicorn/rainbow', - '/Users/sindresorhus/fun/foo/bar' - ] - */ -})(); -``` - - -## API - -### makeDir(path, [options]) - -Returns a `Promise` for the path to the created directory. - -### makeDir.sync(path, [options]) - -Returns the path to the created directory. - -#### path - -Type: `string` - -Directory to create. - -#### options - -Type: `Object` - -##### mode - -Type: `integer`
-Default: `0o777 & (~process.umask())` - -Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/). - -##### fs - -Type: `Object`
-Default: `require('fs')` - -Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs). - -Using a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function. - - -## Related - -- [make-dir-cli](https://github.com/sindresorhus/make-dir-cli) - CLI for this module -- [del](https://github.com/sindresorhus/del) - Delete files and directories -- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching -- [cpy](https://github.com/sindresorhus/cpy) - Copy files -- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line -- [move-file](https://github.com/sindresorhus/move-file) - Move a file - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/mime/.npmignore b/node_modules/mime/.npmignore deleted file mode 100644 index e69de29b..00000000 diff --git a/node_modules/mime/CHANGELOG.md b/node_modules/mime/CHANGELOG.md deleted file mode 100644 index f1275350..00000000 --- a/node_modules/mime/CHANGELOG.md +++ /dev/null @@ -1,164 +0,0 @@ -# Changelog - -## v1.6.0 (24/11/2017) -*No changelog for this release.* - ---- - -## v2.0.4 (24/11/2017) -- [**closed**] Switch to mime-score module for resolving extension contention issues. [#182](https://github.com/broofa/node-mime/issues/182) -- [**closed**] Update mime-db to 1.31.0 in v1.x branch [#181](https://github.com/broofa/node-mime/issues/181) - ---- - -## v1.5.0 (22/11/2017) -- [**closed**] need ES5 version ready in npm package [#179](https://github.com/broofa/node-mime/issues/179) -- [**closed**] mime-db no trace of iWork - pages / numbers / etc. [#178](https://github.com/broofa/node-mime/issues/178) -- [**closed**] How it works in brownser ? [#176](https://github.com/broofa/node-mime/issues/176) -- [**closed**] Missing `./Mime` [#175](https://github.com/broofa/node-mime/issues/175) -- [**closed**] Vulnerable Regular Expression [#167](https://github.com/broofa/node-mime/issues/167) - ---- - -## v2.0.3 (25/09/2017) -*No changelog for this release.* - ---- - -## v1.4.1 (25/09/2017) -- [**closed**] Issue when bundling with webpack [#172](https://github.com/broofa/node-mime/issues/172) - ---- - -## v2.0.2 (15/09/2017) -- [**V2**] fs.readFileSync is not a function [#165](https://github.com/broofa/node-mime/issues/165) -- [**closed**] The extension for video/quicktime should map to .mov, not .qt [#164](https://github.com/broofa/node-mime/issues/164) -- [**V2**] [v2 Feedback request] Mime class API [#163](https://github.com/broofa/node-mime/issues/163) -- [**V2**] [v2 Feedback request] Resolving conflicts over extensions [#162](https://github.com/broofa/node-mime/issues/162) -- [**V2**] Allow callers to load module with official, full, or no defined types. [#161](https://github.com/broofa/node-mime/issues/161) -- [**V2**] Use "facets" to resolve extension conflicts [#160](https://github.com/broofa/node-mime/issues/160) -- [**V2**] Remove fs and path dependencies [#152](https://github.com/broofa/node-mime/issues/152) -- [**V2**] Default content-type should not be application/octet-stream [#139](https://github.com/broofa/node-mime/issues/139) -- [**V2**] reset mime-types [#124](https://github.com/broofa/node-mime/issues/124) -- [**V2**] Extensionless paths should return null or false [#113](https://github.com/broofa/node-mime/issues/113) - ---- - -## v2.0.1 (14/09/2017) -- [**closed**] Changelog for v2.0 does not mention breaking changes [#171](https://github.com/broofa/node-mime/issues/171) -- [**closed**] MIME breaking with 'class' declaration as it is without 'use strict mode' [#170](https://github.com/broofa/node-mime/issues/170) - ---- - -## v2.0.0 (12/09/2017) -- [**closed**] woff and woff2 [#168](https://github.com/broofa/node-mime/issues/168) - ---- - -## v1.4.0 (28/08/2017) -- [**closed**] support for ac3 voc files [#159](https://github.com/broofa/node-mime/issues/159) -- [**closed**] Help understanding change from application/xml to text/xml [#158](https://github.com/broofa/node-mime/issues/158) -- [**closed**] no longer able to override mimetype [#157](https://github.com/broofa/node-mime/issues/157) -- [**closed**] application/vnd.adobe.photoshop [#147](https://github.com/broofa/node-mime/issues/147) -- [**closed**] Directories should appear as something other than application/octet-stream [#135](https://github.com/broofa/node-mime/issues/135) -- [**closed**] requested features [#131](https://github.com/broofa/node-mime/issues/131) -- [**closed**] Make types.json loading optional? [#129](https://github.com/broofa/node-mime/issues/129) -- [**closed**] Cannot find module './types.json' [#120](https://github.com/broofa/node-mime/issues/120) -- [**V2**] .wav files show up as "audio/x-wav" instead of "audio/x-wave" [#118](https://github.com/broofa/node-mime/issues/118) -- [**closed**] Don't be a pain in the ass for node community [#108](https://github.com/broofa/node-mime/issues/108) -- [**closed**] don't make default_type global [#78](https://github.com/broofa/node-mime/issues/78) -- [**closed**] mime.extension() fails if the content-type is parameterized [#74](https://github.com/broofa/node-mime/issues/74) - ---- - -## v1.3.6 (11/05/2017) -- [**closed**] .md should be text/markdown as of March 2016 [#154](https://github.com/broofa/node-mime/issues/154) -- [**closed**] Error while installing mime [#153](https://github.com/broofa/node-mime/issues/153) -- [**closed**] application/manifest+json [#149](https://github.com/broofa/node-mime/issues/149) -- [**closed**] Dynamic adaptive streaming over HTTP (DASH) file extension typo [#141](https://github.com/broofa/node-mime/issues/141) -- [**closed**] charsets image/png undefined [#140](https://github.com/broofa/node-mime/issues/140) -- [**closed**] Mime-db dependency out of date [#130](https://github.com/broofa/node-mime/issues/130) -- [**closed**] how to support plist? [#126](https://github.com/broofa/node-mime/issues/126) -- [**closed**] how does .types file format look like? [#123](https://github.com/broofa/node-mime/issues/123) -- [**closed**] Feature: support for expanding MIME patterns [#121](https://github.com/broofa/node-mime/issues/121) -- [**closed**] DEBUG_MIME doesn't work [#117](https://github.com/broofa/node-mime/issues/117) - ---- - -## v1.3.4 (06/02/2015) -*No changelog for this release.* - ---- - -## v1.3.3 (06/02/2015) -*No changelog for this release.* - ---- - -## v1.3.1 (05/02/2015) -- [**closed**] Consider adding support for Handlebars .hbs file ending [#111](https://github.com/broofa/node-mime/issues/111) -- [**closed**] Consider adding support for hjson. [#110](https://github.com/broofa/node-mime/issues/110) -- [**closed**] Add mime type for Opus audio files [#94](https://github.com/broofa/node-mime/issues/94) -- [**closed**] Consider making the `Requesting New Types` information more visible [#77](https://github.com/broofa/node-mime/issues/77) - ---- - -## v1.3.0 (05/02/2015) -- [**closed**] Add common name? [#114](https://github.com/broofa/node-mime/issues/114) -- [**closed**] application/x-yaml [#104](https://github.com/broofa/node-mime/issues/104) -- [**closed**] Add mime type for WOFF file format 2.0 [#102](https://github.com/broofa/node-mime/issues/102) -- [**closed**] application/x-msi for .msi [#99](https://github.com/broofa/node-mime/issues/99) -- [**closed**] Add mimetype for gettext translation files [#98](https://github.com/broofa/node-mime/issues/98) -- [**closed**] collaborators [#88](https://github.com/broofa/node-mime/issues/88) -- [**closed**] getting errot in installation of mime module...any1 can help? [#87](https://github.com/broofa/node-mime/issues/87) -- [**closed**] should application/json's charset be utf8? [#86](https://github.com/broofa/node-mime/issues/86) -- [**closed**] Add "license" and "licenses" to package.json [#81](https://github.com/broofa/node-mime/issues/81) -- [**closed**] lookup with extension-less file on Windows returns wrong type [#68](https://github.com/broofa/node-mime/issues/68) - ---- - -## v1.2.11 (15/08/2013) -- [**closed**] Update mime.types [#65](https://github.com/broofa/node-mime/issues/65) -- [**closed**] Publish a new version [#63](https://github.com/broofa/node-mime/issues/63) -- [**closed**] README should state upfront that "application/octet-stream" is default for unknown extension [#55](https://github.com/broofa/node-mime/issues/55) -- [**closed**] Suggested improvement to the charset API [#52](https://github.com/broofa/node-mime/issues/52) - ---- - -## v1.2.10 (25/07/2013) -- [**closed**] Mime type for woff files should be application/font-woff and not application/x-font-woff [#62](https://github.com/broofa/node-mime/issues/62) -- [**closed**] node.types in conflict with mime.types [#51](https://github.com/broofa/node-mime/issues/51) - ---- - -## v1.2.9 (17/01/2013) -- [**closed**] Please update "mime" NPM [#49](https://github.com/broofa/node-mime/issues/49) -- [**closed**] Please add semicolon [#46](https://github.com/broofa/node-mime/issues/46) -- [**closed**] parse full mime types [#43](https://github.com/broofa/node-mime/issues/43) - ---- - -## v1.2.8 (10/01/2013) -- [**closed**] /js directory mime is application/javascript. Is it correct? [#47](https://github.com/broofa/node-mime/issues/47) -- [**closed**] Add mime types for lua code. [#45](https://github.com/broofa/node-mime/issues/45) - ---- - -## v1.2.7 (19/10/2012) -- [**closed**] cannot install 1.2.7 via npm [#41](https://github.com/broofa/node-mime/issues/41) -- [**closed**] Transfer ownership to @broofa [#36](https://github.com/broofa/node-mime/issues/36) -- [**closed**] it's wrong to set charset to UTF-8 for text [#30](https://github.com/broofa/node-mime/issues/30) -- [**closed**] Allow multiple instances of MIME types container [#27](https://github.com/broofa/node-mime/issues/27) - ---- - -## v1.2.5 (16/02/2012) -- [**closed**] When looking up a types, check hasOwnProperty [#23](https://github.com/broofa/node-mime/issues/23) -- [**closed**] Bump version to 1.2.2 [#18](https://github.com/broofa/node-mime/issues/18) -- [**closed**] No license [#16](https://github.com/broofa/node-mime/issues/16) -- [**closed**] Some types missing that are used by html5/css3 [#13](https://github.com/broofa/node-mime/issues/13) -- [**closed**] npm install fails for 1.2.1 [#12](https://github.com/broofa/node-mime/issues/12) -- [**closed**] image/pjpeg + image/x-png [#10](https://github.com/broofa/node-mime/issues/10) -- [**closed**] symlink [#8](https://github.com/broofa/node-mime/issues/8) -- [**closed**] gzip [#2](https://github.com/broofa/node-mime/issues/2) -- [**closed**] ALL CAPS filenames return incorrect mime type [#1](https://github.com/broofa/node-mime/issues/1) diff --git a/node_modules/mime/LICENSE b/node_modules/mime/LICENSE deleted file mode 100644 index d3f46f7e..00000000 --- a/node_modules/mime/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2010 Benjamin Thomas, Robert Kieffer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/mime/README.md b/node_modules/mime/README.md deleted file mode 100644 index 506fbe55..00000000 --- a/node_modules/mime/README.md +++ /dev/null @@ -1,90 +0,0 @@ -# mime - -Comprehensive MIME type mapping API based on mime-db module. - -## Install - -Install with [npm](http://github.com/isaacs/npm): - - npm install mime - -## Contributing / Testing - - npm run test - -## Command Line - - mime [path_string] - -E.g. - - > mime scripts/jquery.js - application/javascript - -## API - Queries - -### mime.lookup(path) -Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g. - -```js -var mime = require('mime'); - -mime.lookup('/path/to/file.txt'); // => 'text/plain' -mime.lookup('file.txt'); // => 'text/plain' -mime.lookup('.TXT'); // => 'text/plain' -mime.lookup('htm'); // => 'text/html' -``` - -### mime.default_type -Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.) - -### mime.extension(type) -Get the default extension for `type` - -```js -mime.extension('text/html'); // => 'html' -mime.extension('application/octet-stream'); // => 'bin' -``` - -### mime.charsets.lookup() - -Map mime-type to charset - -```js -mime.charsets.lookup('text/plain'); // => 'UTF-8' -``` - -(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.) - -## API - Defining Custom Types - -Custom type mappings can be added on a per-project basis via the following APIs. - -### mime.define() - -Add custom mime/extension mappings - -```js -mime.define({ - 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'], - 'application/x-my-type': ['x-mt', 'x-mtt'], - // etc ... -}); - -mime.lookup('x-sft'); // => 'text/x-some-format' -``` - -The first entry in the extensions array is returned by `mime.extension()`. E.g. - -```js -mime.extension('text/x-some-format'); // => 'x-sf' -``` - -### mime.load(filepath) - -Load mappings from an Apache ".types" format file - -```js -mime.load('./my_project.types'); -``` -The .types file format is simple - See the `types` dir for examples. diff --git a/node_modules/mime/cli.js b/node_modules/mime/cli.js deleted file mode 100644 index 20b1ffeb..00000000 --- a/node_modules/mime/cli.js +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env node - -var mime = require('./mime.js'); -var file = process.argv[2]; -var type = mime.lookup(file); - -process.stdout.write(type + '\n'); - diff --git a/node_modules/mime/mime.js b/node_modules/mime/mime.js deleted file mode 100644 index d7efbde7..00000000 --- a/node_modules/mime/mime.js +++ /dev/null @@ -1,108 +0,0 @@ -var path = require('path'); -var fs = require('fs'); - -function Mime() { - // Map of extension -> mime type - this.types = Object.create(null); - - // Map of mime type -> extension - this.extensions = Object.create(null); -} - -/** - * Define mimetype -> extension mappings. Each key is a mime-type that maps - * to an array of extensions associated with the type. The first extension is - * used as the default extension for the type. - * - * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); - * - * @param map (Object) type definitions - */ -Mime.prototype.define = function (map) { - for (var type in map) { - var exts = map[type]; - for (var i = 0; i < exts.length; i++) { - if (process.env.DEBUG_MIME && this.types[exts[i]]) { - console.warn((this._loading || "define()").replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' + - this.types[exts[i]] + ' to ' + type); - } - - this.types[exts[i]] = type; - } - - // Default extension is the first one we encounter - if (!this.extensions[type]) { - this.extensions[type] = exts[0]; - } - } -}; - -/** - * Load an Apache2-style ".types" file - * - * This may be called multiple times (it's expected). Where files declare - * overlapping types/extensions, the last file wins. - * - * @param file (String) path of file to load. - */ -Mime.prototype.load = function(file) { - this._loading = file; - // Read file and split into lines - var map = {}, - content = fs.readFileSync(file, 'ascii'), - lines = content.split(/[\r\n]+/); - - lines.forEach(function(line) { - // Clean up whitespace/comments, and split into fields - var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/); - map[fields.shift()] = fields; - }); - - this.define(map); - - this._loading = null; -}; - -/** - * Lookup a mime type based on extension - */ -Mime.prototype.lookup = function(path, fallback) { - var ext = path.replace(/^.*[\.\/\\]/, '').toLowerCase(); - - return this.types[ext] || fallback || this.default_type; -}; - -/** - * Return file extension associated with a mime type - */ -Mime.prototype.extension = function(mimeType) { - var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase(); - return this.extensions[type]; -}; - -// Default instance -var mime = new Mime(); - -// Define built-in types -mime.define(require('./types.json')); - -// Default type -mime.default_type = mime.lookup('bin'); - -// -// Additional API specific to the default instance -// - -mime.Mime = Mime; - -/** - * Lookup a charset based on mime type. - */ -mime.charsets = { - lookup: function(mimeType, fallback) { - // Assume text types are utf8 - return (/^text\/|^application\/(javascript|json)/).test(mimeType) ? 'UTF-8' : fallback; - } -}; - -module.exports = mime; diff --git a/node_modules/mime/package.json b/node_modules/mime/package.json deleted file mode 100644 index 6bd24bc5..00000000 --- a/node_modules/mime/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "author": { - "name": "Robert Kieffer", - "url": "http://github.com/broofa", - "email": "robert@broofa.com" - }, - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - }, - "contributors": [ - { - "name": "Benjamin Thomas", - "url": "http://github.com/bentomas", - "email": "benjamin@benjaminthomas.org" - } - ], - "description": "A comprehensive library for mime-type mapping", - "license": "MIT", - "dependencies": {}, - "devDependencies": { - "github-release-notes": "0.13.1", - "mime-db": "1.31.0", - "mime-score": "1.1.0" - }, - "scripts": { - "prepare": "node src/build.js", - "changelog": "gren changelog --tags=all --generate --override", - "test": "node src/test.js" - }, - "keywords": [ - "util", - "mime" - ], - "main": "mime.js", - "name": "mime", - "repository": { - "url": "https://github.com/broofa/node-mime", - "type": "git" - }, - "version": "1.6.0" -} diff --git a/node_modules/mime/src/build.js b/node_modules/mime/src/build.js deleted file mode 100644 index 4928e48b..00000000 --- a/node_modules/mime/src/build.js +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const mimeScore = require('mime-score'); - -let db = require('mime-db'); -let chalk = require('chalk'); - -const STANDARD_FACET_SCORE = 900; - -const byExtension = {}; - -// Clear out any conflict extensions in mime-db -for (let type in db) { - let entry = db[type]; - entry.type = type; - - if (!entry.extensions) continue; - - entry.extensions.forEach(ext => { - if (ext in byExtension) { - const e0 = entry; - const e1 = byExtension[ext]; - e0.pri = mimeScore(e0.type, e0.source); - e1.pri = mimeScore(e1.type, e1.source); - - let drop = e0.pri < e1.pri ? e0 : e1; - let keep = e0.pri >= e1.pri ? e0 : e1; - drop.extensions = drop.extensions.filter(e => e !== ext); - - console.log(`${ext}: Keeping ${chalk.green(keep.type)} (${keep.pri}), dropping ${chalk.red(drop.type)} (${drop.pri})`); - } - byExtension[ext] = entry; - }); -} - -function writeTypesFile(types, path) { - fs.writeFileSync(path, JSON.stringify(types)); -} - -// Segregate into standard and non-standard types based on facet per -// https://tools.ietf.org/html/rfc6838#section-3.1 -const types = {}; - -Object.keys(db).sort().forEach(k => { - const entry = db[k]; - types[entry.type] = entry.extensions; -}); - -writeTypesFile(types, path.join(__dirname, '..', 'types.json')); diff --git a/node_modules/mime/src/test.js b/node_modules/mime/src/test.js deleted file mode 100644 index 42958a20..00000000 --- a/node_modules/mime/src/test.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Usage: node test.js - */ - -var mime = require('../mime'); -var assert = require('assert'); -var path = require('path'); - -// -// Test mime lookups -// - -assert.equal('text/plain', mime.lookup('text.txt')); // normal file -assert.equal('text/plain', mime.lookup('TEXT.TXT')); // uppercase -assert.equal('text/plain', mime.lookup('dir/text.txt')); // dir + file -assert.equal('text/plain', mime.lookup('.text.txt')); // hidden file -assert.equal('text/plain', mime.lookup('.txt')); // nameless -assert.equal('text/plain', mime.lookup('txt')); // extension-only -assert.equal('text/plain', mime.lookup('/txt')); // extension-less () -assert.equal('text/plain', mime.lookup('\\txt')); // Windows, extension-less -assert.equal('application/octet-stream', mime.lookup('text.nope')); // unrecognized -assert.equal('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default - -// -// Test extensions -// - -assert.equal('txt', mime.extension(mime.types.text)); -assert.equal('html', mime.extension(mime.types.htm)); -assert.equal('bin', mime.extension('application/octet-stream')); -assert.equal('bin', mime.extension('application/octet-stream ')); -assert.equal('html', mime.extension(' text/html; charset=UTF-8')); -assert.equal('html', mime.extension('text/html; charset=UTF-8 ')); -assert.equal('html', mime.extension('text/html; charset=UTF-8')); -assert.equal('html', mime.extension('text/html ; charset=UTF-8')); -assert.equal('html', mime.extension('text/html;charset=UTF-8')); -assert.equal('html', mime.extension('text/Html;charset=UTF-8')); -assert.equal(undefined, mime.extension('unrecognized')); - -// -// Test node.types lookups -// - -assert.equal('font/woff', mime.lookup('file.woff')); -assert.equal('application/octet-stream', mime.lookup('file.buffer')); -// TODO: Uncomment once #157 is resolved -// assert.equal('audio/mp4', mime.lookup('file.m4a')); -assert.equal('font/otf', mime.lookup('file.otf')); - -// -// Test charsets -// - -assert.equal('UTF-8', mime.charsets.lookup('text/plain')); -assert.equal('UTF-8', mime.charsets.lookup(mime.types.js)); -assert.equal('UTF-8', mime.charsets.lookup(mime.types.json)); -assert.equal(undefined, mime.charsets.lookup(mime.types.bin)); -assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback')); - -console.log('\nAll tests passed'); diff --git a/node_modules/mime/types.json b/node_modules/mime/types.json deleted file mode 100644 index bec78abd..00000000 --- a/node_modules/mime/types.json +++ /dev/null @@ -1 +0,0 @@ -{"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/bdoc":["bdoc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":[],"application/font-woff2":[],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":[],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":[],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":[],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":[],"application/x-msdownload":["com","bat"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":[],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":[],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp3":[],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/wav":["wav"],"audio/wave":[],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":[],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":[],"audio/x-wav":[],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/apng":["apng"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":[],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":[],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/rtf":[],"text/sgml":["sgml","sgm"],"text/slim":["slim","slm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":[],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/xml":[],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]} \ No newline at end of file diff --git a/node_modules/needle/.github/workflows/nodejs.yml b/node_modules/needle/.github/workflows/nodejs.yml deleted file mode 100644 index 7b255974..00000000 --- a/node_modules/needle/.github/workflows/nodejs.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Node CI -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [4.x, 6.x, 8.x, 10.x, 12.x] - - steps: - - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: npm install, build, and test - run: | - npm install - mkdir -p test/keys - openssl genrsa -out test/keys/ssl.key 2048 - openssl req -new -key test/keys/ssl.key -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -x509 -days 999 -out test/keys/ssl.cert - npm run build --if-present - npm test - env: - CI: true diff --git a/node_modules/needle/README.md b/node_modules/needle/README.md deleted file mode 100644 index b9689f9d..00000000 --- a/node_modules/needle/README.md +++ /dev/null @@ -1,612 +0,0 @@ -Needle -====== - -[![NPM](https://nodei.co/npm/needle.png)](https://nodei.co/npm/needle/) - -The leanest and most handsome HTTP client in the Nodelands. - -```js -var needle = require('needle'); - -needle.get('http://www.google.com', function(error, response) { - if (!error && response.statusCode == 200) - console.log(response.body); -}); -``` - -Callbacks not floating your boat? Needle got your back. - -``` js -var data = { - file: '/home/johnlennon/walrus.png', - content_type: 'image/png' -}; - -// the callback is optional, and needle returns a `readableStream` object -// that triggers a 'done' event when the request/response process is complete. -needle - .post('https://my.server.com/foo', data, { multipart: true }) - .on('readable', function() { /* eat your chunks */ }) - .on('done', function(err) { - console.log('Ready-o!'); - }) -``` - -From version 2.0.x up, Promises are also supported. Just call `needle()` directly and you'll get a native Promise object. - -```js -needle('put', 'https://hacking.the.gibson/login', { password: 'god' }, { json: true }) - .then(function(response) { - return doSomethingWith(response) - }) - .catch(function(err) { - console.log('Call the locksmith!') - }) -``` - -With only two real dependencies, Needle supports: - - - HTTP/HTTPS requests, with the usual verbs you would expect - - All of Node's native TLS options, such as 'rejectUnauthorized' (see below) - - Basic & Digest authentication with auto-detection - - Multipart form-data (e.g. file uploads) - - HTTP Proxy forwarding, optionally with authentication - - Streaming gzip, deflate, and brotli decompression - - Automatic XML & JSON parsing - - 301/302/303 redirect following, with fine-grained tuning, and - - Streaming non-UTF-8 charset decoding, via `iconv-lite` - -And yes, Mr. Wayne, it does come in black. - -This makes Needle an ideal alternative for performing quick HTTP requests in Node, either for API interaction, downloading or uploading streams of data, and so on. If you need OAuth, AWS support or anything fancier, you should check out mikeal's request module. - -Install -------- - -``` -$ npm install needle -``` - -Usage ------ - -```js -// using promises -needle('get', 'https://server.com/posts/123') - .then(function(resp) { - // ... - }) - .catch(function(err) { - // ... - }); - -// with callback -needle.get('ifconfig.me/all.json', function(error, response, body) { - if (error) throw error; - - // body is an alias for `response.body`, - // that in this case holds a JSON-decoded object. - console.log(body.ip_addr); -}); - -// no callback, using streams -needle.get('https://google.com/images/logo.png') - .pipe(fs.createWriteStream('logo.png')) - .on('done', function(err) { - console.log('Pipe finished!'); - }); -``` - -As you can see, you can use Needle with Promises or without them. When using Promises or when a callback is passed, the response's body will be buffered and written to `response.body`, and the callback will be fired when all of the data has been collected and processed (e.g. decompressed, decoded and/or parsed). - -When no callback is passed, however, the buffering logic will be skipped but the response stream will still go through Needle's processing pipeline, so you get all the benefits of post-processing while keeping the streamishness we all love from Node. - -Response pipeline ------------------ - -Depending on the response's Content-Type, Needle will either attempt to parse JSON or XML streams, or, if a text response was received, will ensure that the final encoding you get is UTF-8. - -You can also request a gzip/deflated/brotli response, which, if sent by the server, will be processed before parsing or decoding is performed. (Note: brotli is only supported on Node 10.16.0 or above, and will not be requested or processed on earlier versions.) - -```js -needle.get('http://stackoverflow.com/feeds', { compressed: true }, function(err, resp) { - console.log(resp.body); // this little guy won't be a Gzipped binary blob - // but a nice object containing all the latest entries -}); -``` - -Or in anti-callback mode, using a few other options: - -```js -var options = { - compressed : true, // sets 'Accept-Encoding' to 'gzip, deflate, br' - follow_max : 5, // follow up to five redirects - rejectUnauthorized : true // verify SSL certificate -} - -var stream = needle.get('https://backend.server.com/everything.html', options); - -// read the chunks from the 'readable' event, so the stream gets consumed. -stream.on('readable', function() { - while (data = this.read()) { - console.log(data.toString()); - } -}) - -stream.on('done', function(err) { - // if our request had an error, our 'done' event will tell us. - if (!err) console.log('Great success!'); -}) -``` - -API ---- - -### needle(method, url[, data][, options][, callback]) `(> 2.0.x)` - -Calling `needle()` directly returns a Promise. Besides `method` and `url`, all parameters are optional, although when sending a `post`, `put` or `patch` request you will get an error if `data` is not present. - -```js -needle('get', 'http://some.url.com') - .then(function(resp) { console.log(resp.body) }) - .catch(function(err) { console.error(err) }) -``` - -Except from the above, all of Needle's request methods return a Readable stream, and both `options` and `callback` are optional. If passed, the callback will return three arguments: `error`, `response` and `body`, which is basically an alias for `response.body`. - -### needle.head(url[, options][, callback]) - -```js -needle.head('https://my.backend.server.com', { - open_timeout: 5000 // if we're not able to open a connection in 5 seconds, boom. -}, function(err, resp) { - if (err) - console.log('Shoot! Something is wrong: ' + err.message) - else - console.log('Yup, still alive.') -}) -``` - -### needle.get(url[, options][, callback]) - -```js -needle.get('google.com/search?q=syd+barrett', function(err, resp) { - // if no http:// is found, Needle will automagically prepend it. -}); -``` - -### needle.post(url, data[, options][, callback]) - -```js -var options = { - headers: { 'X-Custom-Header': 'Bumbaway atuna' } -} - -needle.post('https://my.app.com/endpoint', 'foo=bar', options, function(err, resp) { - // you can pass params as a string or as an object. -}); -``` - -### needle.put(url, data[, options][, callback]) - -```js -var nested = { - params: { - are: { - also: 'supported' - } - } -} - -needle.put('https://api.app.com/v2', nested, function(err, resp) { - console.log('Got ' + resp.bytes + ' bytes.') // another nice treat from this handsome fella. -}); -``` - -### needle.patch(url, data[, options][, callback]) - -Same behaviour as PUT. - -### needle.delete(url, data[, options][, callback]) - -```js -var options = { - username: 'fidelio', - password: 'x' -} - -needle.delete('https://api.app.com/messages/123', null, options, function(err, resp) { - // in this case, data may be null, but you need to explicity pass it. -}); -``` - -### needle.request(method, url, data[, options][, callback]) - -Generic request. This not only allows for flexibility, but also lets you perform a GET request with data, in which case will be appended to the request as a query string, unless you pass a `json: true` option (read below). - -```js -var params = { - q : 'a very smart query', - page : 2 -} - -needle.request('get', 'forum.com/search', params, function(err, resp) { - if (!err && resp.statusCode == 200) - console.log(resp.body); // here you go, mister. -}); -``` - -Now, if you set pass `json: true` among the options, Needle won't set your params as a querystring but instead send a JSON representation of your data through the request's body, as well as set the `Content-Type` and `Accept` headers to `application/json`. - -```js -needle.request('get', 'forum.com/search', params, { json: true }, function(err, resp) { - if (resp.statusCode == 200) console.log('It worked!'); -}); -``` - -Events ------- - -The [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) object returned by the above request methods emits the following events, in addition to the regular ones (e.g. `end`, `close`, `data`, `pipe`, `readable`). - -### Event: `'response'` - - - `response ` - -Emitted when the underlying [http.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest) emits a response event. This is after the connection is established and the header received, but before any of it is processed (e.g. authorization required or redirect to be followed). No data has been consumed at this point. - -### Event: `'redirect'` - - - `location ` - -Indicates that the a redirect is being followed. This means that the response code was a redirect (`301`, `302`, `303`, `307`) and the given [redirect options](#redirect-options) allowed following the URL received in the `Location` header. - -### Event: `'header'` - - - `statusCode ` - - `headers ` - -Triggered after the header has been processed, and just before the data is to be consumed. This implies that no redirect was followed and/or authentication header was received. In other words, we got a "valid" response. - -### Event: `'done'` (previously 'end') - - - `exception ` (optional) - -Emitted when the request/response process has finished, either because all data was consumed or an error ocurred somewhere in between. Unlike a regular stream's `end` event, Needle's `done` will be fired either on success or on failure, which is why the first argument may be an Error object. In other words: - -```js -var resp = needle.get('something.worthy/of/being/streamed/by/needle'); -resp.pipe(someWritableStream); - -resp.on('done', function(err) { - if (err) console.log('An error ocurred: ' + err.message); - else console.log('Great success!'); -}) -``` - -### Event: `'err'` - - - `exception ` - -Emitted when an error ocurrs. This should only happen once in the lifecycle of a Needle request. - -### Event: `'timeout'` - - - `type ` - -Emitted when an timeout error occurs. Type can be either 'open', 'response', or 'read'. This will called right before aborting the request, which will also trigger an `err` event, a described above, with an `ECONNRESET` (Socket hang up) exception. - -Request options ---------------- - -For information about options that've changed, there's always [the changelog](https://github.com/tomas/needle/releases). - - - `agent` : Uses an [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) of your choice, instead of the global, default one. Useful for tweaking the behaviour at the connection level, such as when doing tunneling (see below for an example). - - `json` : When `true`, sets content type to `application/json` and sends request body as JSON string, instead of a query string. - - `open_timeout`: (or `timeout`) Returns error if connection takes longer than X milisecs to establish. Defaults to `10000` (10 secs). `0` means no timeout. - - `response_timeout`: Returns error if no response headers are received in X milisecs, counting from when the connection is opened. Defaults to `0` (no response timeout). - - `read_timeout`: Returns error if data transfer takes longer than X milisecs, once response headers are received. Defaults to `0` (no timeout). - - `follow_max` : (or `follow`) Number of redirects to follow. Defaults to `0`. See below for more redirect options. - - `multipart` : Enables multipart/form-data encoding. Defaults to `false`. Use it when uploading files. - - `proxy` : Forwards request through HTTP(s) proxy. Eg. `proxy: 'http://user:pass@proxy.server.com:3128'`. For more advanced proxying/tunneling use a custom `agent`, as described below. - - `headers` : Object containing custom HTTP headers for request. Overrides defaults described below. - - `auth` : Determines what to do with provided username/password. Options are `auto`, `digest` or `basic` (default). `auto` will detect the type of authentication depending on the response headers. - - `stream_length`: When sending streams, this lets you manually set the Content-Length header --if the stream's bytecount is known beforehand--, preventing ECONNRESET (socket hang up) errors on some servers that misbehave when receiving payloads of unknown size. Set it to `0` and Needle will get and set the stream's length for you, or leave unset for the default behaviour, which is no Content-Length header for stream payloads. - - `localAddress`: , IP address. Passed to http/https request. Local interface from which the request should be emitted. - - `uri_modifier`: Anonymous function taking request (or redirect location if following redirects) URI as an argument and modifying it given logic. It has to return a valid URI string for successful request. - -Response options ----------------- - - - `decode_response` : (or `decode`) Whether to decode the text responses to UTF-8, if Content-Type header shows a different charset. Defaults to `true`. - - `parse_response` : (or `parse`) Whether to parse XML or JSON response bodies automagically. Defaults to `true`. You can also set this to 'xml' or 'json' in which case Needle will *only* parse the response if the content type matches. - - `output` : Dump response output to file. This occurs after parsing and charset decoding is done. - - `parse_cookies` : Whether to parse response’s `Set-Cookie` header. Defaults to `true`. If parsed, response cookies will be available at `resp.cookies`. - -HTTP Header options -------------------- - -These are basically shortcuts to the `headers` option described above. - - - `cookies` : Builds and sets a Cookie header from a `{ key: 'value' }` object. - - `compressed`: If `true`, sets 'Accept-Encoding' header to 'gzip,deflate', and inflates content if zipped. Defaults to `false`. - - `username` : For HTTP basic auth. - - `password` : For HTTP basic auth. Requires username to be passed, but is optional. - - `accept` : Sets 'Accept' HTTP header. Defaults to `*/*`. - - `connection`: Sets 'Connection' HTTP header. Not set by default, unless running Node < 0.11.4 in which case it defaults to `close`. More info about this below. - - `user_agent`: Sets the 'User-Agent' HTTP header. Defaults to `Needle/{version} (Node.js {node_version})`. - - `content_type`: Sets the 'Content-Type' header. Unset by default, unless you're sending data in which case it's set accordingly to whatever is being sent (`application/x-www-form-urlencoded`, `application/json` or `multipart/form-data`). That is, of course, unless the option is passed, either here or through `options.headers`. You're the boss. - -Node.js TLS Options -------------------- - -These options are passed directly to `https.request` if present. Taken from the [original documentation](http://nodejs.org/docs/latest/api/https.html): - - - `pfx` : Certificate, Private key and CA certificates to use for SSL. - - `key` : Private key to use for SSL. - - `passphrase` : A string of passphrase for the private key or pfx. - - `cert` : Public x509 certificate to use. - - `ca` : An authority certificate or array of authority certificates to check the remote host against. - - `ciphers` : A string describing the ciphers to use or exclude. - - `rejectUnauthorized` : If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. - - `secureProtocol` : The SSL method to use, e.g. SSLv3_method to force SSL version 3. - - `family` : IP address family to use when resolving host and hostname. Valid values are 4 or 6. When unspecified, both IP v4 and v6 will be used. - -Redirect options ----------------- - -These options only apply if the `follow_max` (or `follow`) option is higher than 0. - - - `follow_set_cookies` : Sends the cookies received in the `set-cookie` header as part of the following request. `false` by default. - - `follow_set_referer` : Sets the 'Referer' header to the requested URI when following a redirect. `false` by default. - - `follow_keep_method` : If enabled, resends the request using the original verb instead of being rewritten to `get` with no data. `false` by default. - - `follow_if_same_host` : When true, Needle will only follow redirects that point to the same host as the original request. `false` by default. - - `follow_if_same_protocol` : When true, Needle will only follow redirects that point to the same protocol as the original request. `false` by default. - - `follow_if_same_location` : Unless true, Needle will not follow redirects that point to same location (as set in the response header) as the original request URL. `false` by default. - -Overriding Defaults -------------------- - -Yes sir, we have it. Needle includes a `defaults()` method, that lets you override some of the defaults for all future requests. Like this: - -```js -needle.defaults({ - open_timeout: 60000, - user_agent: 'MyApp/1.2.3', - parse_response: false }); -``` - -This will override Needle's default user agent and 10-second timeout, and disable response parsing, so you don't need to pass those options in every other request. - -More advanced Proxy support ---------------------------- - -Since you can pass a custom HTTPAgent to Needle you can do all sorts of neat stuff. For example, if you want to use the [`tunnel`](https://github.com/koichik/node-tunnel) module for HTTPS proxying, you can do this: - -```js -var tunnel = require('tunnel'); -var myAgent = tunnel.httpOverHttp({ - proxy: { host: 'localhost' } -}); - -needle.get('foobar.com', { agent: myAgent }); -``` - -Otherwise, you can use the [`hpagent`](https://github.com/delvedor/hpagent) package, which keeps the internal sockets alive to be reused. - -```js -const { HttpsProxyAgent } = require('hpagent'); -needle('get', 'https://localhost:9200', { - agent: new HttpsProxyAgent({ - keepAlive: true, - keepAliveMsecs: 1000, - maxSockets: 256, - maxFreeSockets: 256, - scheduling: 'lifo', - proxy: 'https://localhost:8080' - }) -}); -``` - -Regarding the 'Connection' header ---------------------------------- - -Unless you're running an old version of Node (< 0.11.4), by default Needle won't set the Connection header on requests, yielding Node's default behaviour of keeping the connection alive with the target server. This speeds up immensely the process of sending several requests to the same host. - -On older versions, however, this has the unwanted behaviour of preventing the runtime from exiting, either because of a bug or 'feature' that was changed on 0.11.4. To overcome this Needle does set the 'Connection' header to 'close' on those versions, however this also means that making new requests to the same host doesn't benefit from Keep-Alive. - -So if you're stuck on 0.10 or even lower and want full speed, you can simply set the Connection header to 'Keep-Alive' by using `{ connection: 'Keep-Alive' }`. Please note, though, that an event loop handler will prevent the runtime from exiting so you'll need to manually call `process.exit()` or the universe will collapse. - -Examples Galore ---------------- - -### HTTPS GET with Basic Auth - -```js -needle.get('https://api.server.com', { username: 'you', password: 'secret' }, - function(err, resp) { - // used HTTP auth -}); -``` - -Or use [RFC-1738](http://tools.ietf.org/html/rfc1738#section-3.1) basic auth URL syntax: - -```js -needle.get('https://username:password@api.server.com', function(err, resp) { - // used HTTP auth from URL -}); -``` - -### Digest Auth - -```js -needle.get('other.server.com', { username: 'you', password: 'secret', auth: 'digest' }, - function(err, resp, body) { - // needle prepends 'http://' to your URL, if missing -}); -``` - -### Custom Accept header, deflate - -```js -var options = { - compressed : true, - follow : 10, - accept : 'application/vnd.github.full+json' -} - -needle.get('api.github.com/users/tomas', options, function(err, resp, body) { - // body will contain a JSON.parse(d) object - // if parsing fails, you'll simply get the original body -}); -``` - -### GET XML object - -```js -needle.get('https://news.ycombinator.com/rss', function(err, resp, body) { - // you'll get a nice object containing the nodes in the RSS -}); -``` - -### GET binary, output to file - -```js -needle.get('http://upload.server.com/tux.png', { output: '/tmp/tux.png' }, function(err, resp, body) { - // you can dump any response to a file, not only binaries. -}); -``` - -### GET through proxy - -```js -needle.get('http://search.npmjs.org', { proxy: 'http://localhost:1234' }, function(err, resp, body) { - // request passed through proxy -}); -``` - -### GET a very large document in a stream (from 0.7+) - -```js -var stream = needle.get('http://www.as35662.net/100.log'); - -stream.on('readable', function() { - var chunk; - while (chunk = this.read()) { - console.log('got data: ', chunk); - } -}); -``` - -### GET JSON object in a stream (from 0.7+) - -```js -var stream = needle.get('http://jsonplaceholder.typicode.com/db', { parse: true }); - -stream.on('readable', function() { - var node; - - // our stream will only emit a single JSON root node. - while (node = this.read()) { - console.log('got data: ', node); - } -}); -``` - -### GET JSONStream flexible parser with search query (from 0.7+) - -```js - - // The 'data' element of this stream will be the string representation - // of the titles of all posts. - -needle.get('http://jsonplaceholder.typicode.com/db', { parse: true }) - .pipe(new JSONStream.parse('posts.*.title')); - .on('data', function (obj) { - console.log('got post title: %s', obj); - }); -``` - -### File upload using multipart, passing file path - -```js -var data = { - foo: 'bar', - image: { file: '/home/tomas/linux.png', content_type: 'image/png' } -} - -needle.post('http://my.other.app.com', data, { multipart: true }, function(err, resp, body) { - // needle will read the file and include it in the form-data as binary -}); -``` - -### Stream upload, PUT or POST - -``` js -needle.put('https://api.app.com/v2', fs.createReadStream('myfile.txt'), function(err, resp, body) { - // stream content is uploaded verbatim -}); -``` - -### Multipart POST, passing data buffer - -```js -var buffer = fs.readFileSync('/path/to/package.zip'); - -var data = { - zip_file: { - buffer : buffer, - filename : 'mypackage.zip', - content_type : 'application/octet-stream' - } -} - -needle.post('http://somewhere.com/over/the/rainbow', data, { multipart: true }, function(err, resp, body) { - // if you see, when using buffers we need to pass the filename for the multipart body. - // you can also pass a filename when using the file path method, in case you want to override - // the default filename to be received on the other end. -}); -``` - -### Multipart with custom Content-Type - -```js -var data = { - token: 'verysecret', - payload: { - value: JSON.stringify({ title: 'test', version: 1 }), - content_type: 'application/json' - } -} - -needle.post('http://test.com/', data, { timeout: 5000, multipart: true }, function(err, resp, body) { - // in this case, if the request takes more than 5 seconds - // the callback will return a [Socket closed] error -}); -``` - -For even more examples, check out the examples directory in the repo. - -### Testing - -To run tests, you need to generate a self-signed SSL certificate in the `test` directory. After cloning the repository, run the following commands: - - $ mkdir -p test/keys - $ openssl genrsa -out test/keys/ssl.key 2048 - $ openssl req -new -key test/keys/ssl.key -x509 -days 999 -out test/keys/ssl.cert - -Then you should be able to run `npm test` once you have the dependencies in place. - -> Note: Tests currently only work on linux-based environments that have `/proc/self/fd`. They *do not* work on MacOS environments. -> You can use Docker to run tests by creating a container and mounting the needle project directory on `/app` -> `docker create --name Needle -v /app -w /app -v /app/node_modules -i node:argon` - -Credits -------- - -Written by Tomás Pollak, with the help of contributors. - -Copyright ---------- - -(c) Fork Ltd. Licensed under the MIT license. diff --git a/node_modules/needle/bin/needle b/node_modules/needle/bin/needle deleted file mode 100644 index baaa79b0..00000000 --- a/node_modules/needle/bin/needle +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env node -var needle = require('./../lib/needle'); - -function exit(code, str) { - console.log(str) || process.exit(code); -} - -function usage() { - var out = ['Usage: needle [get|head|post|put|delete] url [query]']; - out.push('Examples: \n needle get google.com\n needle post server.com/api foo=bar'); - exit(1, out.join('\n')) -} - -if (process.argv[2] == '-v' || process.argv[2] == '--version') - exit(0, needle.version); -else if (process.argv[2] == null) - usage(); - -var method = process.argv[2], - url = process.argv[3], - options = { compressed: true, parse_response: true, follow_max: 5, timeout: 10000 }; - -if (!needle[method]) { - url = method; - method = 'get'; -} - -var callback = function(err, resp) { - if (err) return exit(1, "Error: " + err.message); - - if (process.argv.indexOf('-i') != -1) - console.log(resp.headers) || console.log(''); - - console.log(resp.body.toString()); -}; - -if (method == 'post' || method == 'put') - needle[method](url, process.argv[4], options, callback); -else - needle[method](url, options, callback); diff --git a/node_modules/needle/examples/deflated-stream.js b/node_modules/needle/examples/deflated-stream.js deleted file mode 100644 index 4e771b74..00000000 --- a/node_modules/needle/examples/deflated-stream.js +++ /dev/null @@ -1,22 +0,0 @@ -var fs = require('fs'), - stream = require('stream'), - needle = require('./../'); - -var url = 'http://ibl.gamechaser.net/f/tagqfxtteucbuldhezkz/bt_level1.gz'; - -var resp = needle.get(url, { compressed: true, follow_max: 10 }); -console.log('Downloading...'); - -resp.on('readable', function() { - - while (data = this.read()) { - var lines = data.toString().split('\n'); - console.log('Got ' + lines.length + ' items.'); - // console.log(lines); - } - -}) - -resp.on('done', function(data) { - console.log('Done'); -}) diff --git a/node_modules/needle/examples/digest-auth.js b/node_modules/needle/examples/digest-auth.js deleted file mode 100644 index 5b8e5d5e..00000000 --- a/node_modules/needle/examples/digest-auth.js +++ /dev/null @@ -1,16 +0,0 @@ -var needle = require('./..'); - -var opts = { - username: 'user3', - password: 'user3', - auth: 'digest' -} - -needle.get('http://test.webdav.org/auth-digest/', opts, function(err, resp, body) { - console.log(resp.headers); - - if (resp.statusCode == 401) - console.log('\nIt failed.') - else - console.log('\nIt worked!') -}); diff --git a/node_modules/needle/examples/download-to-file.js b/node_modules/needle/examples/download-to-file.js deleted file mode 100644 index 39d5af97..00000000 --- a/node_modules/needle/examples/download-to-file.js +++ /dev/null @@ -1,18 +0,0 @@ -var fs = require('fs'), - needle = require('./..'), - path = require('path'); - -var url = process.argv[2] || 'https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png'; -var file = path.basename(url); - -console.log('Downloading ' + file); - -needle.get(url, { output: file, follow: 3 }, function(err, resp, data){ - console.log('File saved: ' + process.cwd() + '/' + file); - - var size = fs.statSync(file).size; - if (size == resp.bytes) - console.log(resp.bytes + ' bytes written to file.'); - else - throw new Error('File size mismatch: ' + size + ' != ' + resp.bytes); -}); diff --git a/node_modules/needle/examples/multipart-stream.js b/node_modules/needle/examples/multipart-stream.js deleted file mode 100644 index df1ada6e..00000000 --- a/node_modules/needle/examples/multipart-stream.js +++ /dev/null @@ -1,25 +0,0 @@ -var needle = require('./../'); - -var url = 'http://posttestserver.com/post.php?dir=needle'; - -var black_pixel = Buffer.from("R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=", 'base64'); - -var data = { - foo: 'bar', - nested: { - test: 123 - }, - image: { buffer: black_pixel, content_type: 'image/gif' } -} - -var resp = needle.post(url, data, { multipart: true }); - -resp.on('readable', function() { - while (data = this.read()) { - console.log(data.toString()); - } -}) - -resp.on('done', function(data) { - console.log('Done.'); -}) diff --git a/node_modules/needle/examples/parsed-stream.js b/node_modules/needle/examples/parsed-stream.js deleted file mode 100644 index 89c22c66..00000000 --- a/node_modules/needle/examples/parsed-stream.js +++ /dev/null @@ -1,23 +0,0 @@ -////////////////////////////////////////// -// This example demonstrates what happends -// when you use the built-in JSON parser. -////////////////////////////////////////// - -var fs = require('fs'), - stream = require('stream'), - needle = require('./../'); - -var url = 'http://ip.jsontest.com/', - resp = needle.get(url, { parse: true }); - -resp.on('readable', function(obj) { - var chunk; - - while (chunk = this.read()) { - console.log('root = ', chunk); - } -}); - -resp.on('done', function() { - console.log('Done.'); -}); diff --git a/node_modules/needle/examples/parsed-stream2.js b/node_modules/needle/examples/parsed-stream2.js deleted file mode 100644 index f325ec10..00000000 --- a/node_modules/needle/examples/parsed-stream2.js +++ /dev/null @@ -1,21 +0,0 @@ -////////////////////////////////////////// -// This example illustrates a more complex -// example of parsing a JSON stream. -////////////////////////////////////////// - -var needle = require('./../'), - JSONStream = require('JSONStream'); - -var url = 'http://jsonplaceholder.typicode.com/db'; - -// Initialize our GET request with our default (JSON) -// parsers disabled. - -var json = new needle.get(url, {parse: false}) - // And now interpret the stream as JSON, returning only the - // title of all the posts. - .pipe(new JSONStream.parse('posts.*.title')); - -json.on('data', function (obj) { - console.log('got title: \'' + obj + '\''); -}) diff --git a/node_modules/needle/examples/stream-events.js b/node_modules/needle/examples/stream-events.js deleted file mode 100644 index 62309938..00000000 --- a/node_modules/needle/examples/stream-events.js +++ /dev/null @@ -1,23 +0,0 @@ -var needle = require('./..'); - -var resp = needle.get('google.com', { follow_max: 10, timeout: 5000 }); - -resp.on('readable', function() { - var chunk; - while (chunk = this.read()) { - console.log('Got ' + chunk.length + ' bytes'); - } -}) - -resp.on('headers', function(headers) { - console.log('Got headers', headers); -}) - -resp.on('redirect', function(url) { - console.log('Redirected to url ' + url); -}) - -resp.on('done', function(err) { - console.log('Finished. No more data to receive.'); - if (err) console.log('With error', err) -}) diff --git a/node_modules/needle/examples/stream-to-file.js b/node_modules/needle/examples/stream-to-file.js deleted file mode 100644 index d261bee9..00000000 --- a/node_modules/needle/examples/stream-to-file.js +++ /dev/null @@ -1,14 +0,0 @@ -var fs = require('fs'), - needle = require('./..'), - path = require('path'); - -var url = process.argv[2] || 'http://www.google.com/images/errors/robot.png'; -var file = path.basename(url); - -console.log('Downloading ' + file + '...'); -needle - .get(url) - .pipe(fs.createWriteStream(file)) - .on('done', function() { - console.log('Done!') - }) diff --git a/node_modules/needle/examples/upload-image.js b/node_modules/needle/examples/upload-image.js deleted file mode 100644 index 090e3e3f..00000000 --- a/node_modules/needle/examples/upload-image.js +++ /dev/null @@ -1,51 +0,0 @@ -var needle = require('../'), - path = require('path'); - -var image = 'https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png'; - -function upload(obj, cb) { - console.log('Uploading image...'); - - var url = 'http://deviantsart.com'; - - var opts = { - timeout: 10000, - follow: 3, - multipart: true - }; - - var params = { - file: obj - } - - needle.post(url, params, opts, function(err, resp) { - if (err || !resp.body.match('url')) - return cb(err || new Error('No image URL found.')) - - cb(null, JSON.parse(resp.body).url) - }) -} - -function download(url, cb) { - console.log('Getting ' + url); - needle.get(url, function(err, resp) { - if (err) throw err; - - cb(null, resp.body); - }) -} - -//////////////////////////////////////// -// ok, now go. - -download(image, function(err, buffer) { - if (err) throw err; - - var obj = { buffer: buffer, content_type: 'image/png' }; - - upload(obj, function(err, url) { - if (err) throw err; - - console.log('Image uploaded to ' + url); - }) -}) diff --git a/node_modules/needle/lib/auth.js b/node_modules/needle/lib/auth.js deleted file mode 100644 index 66d3f5ce..00000000 --- a/node_modules/needle/lib/auth.js +++ /dev/null @@ -1,112 +0,0 @@ -var createHash = require('crypto').createHash; - -function get_header(header, credentials, opts) { - var type = header.split(' ')[0], - user = credentials[0], - pass = credentials[1]; - - if (type == 'Digest') { - return digest.generate(header, user, pass, opts.method, opts.path); - } else if (type == 'Basic') { - return basic(user, pass); - } -} - -//////////////////// -// basic - -function md5(string) { - return createHash('md5').update(string).digest('hex'); -} - -function basic(user, pass) { - var str = typeof pass == 'undefined' ? user : [user, pass].join(':'); - return 'Basic ' + Buffer.from(str).toString('base64'); -} - -//////////////////// -// digest -// logic inspired from https://github.com/simme/node-http-digest-client - -var digest = {}; - -digest.parse_header = function(header) { - var challenge = {}, - matches = header.match(/([a-z0-9_-]+)="?([a-z0-9_=\/\.@\s-\+)()]+)"?/gi); - - for (var i = 0, l = matches.length; i < l; i++) { - var parts = matches[i].split('='), - key = parts.shift(), - val = parts.join('=').replace(/^"/, '').replace(/"$/, ''); - - challenge[key] = val; - } - - return challenge; -} - -digest.update_nc = function(nc) { - var max = 99999999; - nc++; - - if (nc > max) - nc = 1; - - var padding = new Array(8).join('0') + ''; - nc = nc + ''; - return padding.substr(0, 8 - nc.length) + nc; -} - -digest.generate = function(header, user, pass, method, path) { - - var nc = 1, - cnonce = null, - challenge = digest.parse_header(header); - - var ha1 = md5(user + ':' + challenge.realm + ':' + pass), - ha2 = md5(method.toUpperCase() + ':' + path), - resp = [ha1, challenge.nonce]; - - if (typeof challenge.qop === 'string') { - cnonce = md5(Math.random().toString(36)).substr(0, 8); - nc = digest.update_nc(nc); - resp = resp.concat(nc, cnonce); - resp = resp.concat(challenge.qop, ha2); - } else { - resp = resp.concat(ha2); - } - - - var params = { - uri : path, - realm : challenge.realm, - nonce : challenge.nonce, - username : user, - response : md5(resp.join(':')) - } - - if (challenge.qop) { - params.qop = challenge.qop; - } - - if (challenge.opaque) { - params.opaque = challenge.opaque; - } - - if (cnonce) { - params.nc = nc; - params.cnonce = cnonce; - } - - header = [] - for (var k in params) - header.push(k + '="' + params[k] + '"') - - return 'Digest ' + header.join(', '); -} - -module.exports = { - header : get_header, - basic : basic, - digest : digest.generate -} diff --git a/node_modules/needle/lib/cookies.js b/node_modules/needle/lib/cookies.js deleted file mode 100644 index 0f48afcf..00000000 --- a/node_modules/needle/lib/cookies.js +++ /dev/null @@ -1,79 +0,0 @@ - -// Simple cookie handling implementation based on the standard RFC 6265. -// -// This module just has two functionalities: -// - Parse a set-cookie-header as a key value object -// - Write a cookie-string from a key value object -// -// All cookie attributes are ignored. - -var unescape = require('querystring').unescape; - -var COOKIE_PAIR = /^([^=\s]+)\s*=\s*("?)\s*(.*)\s*\2\s*$/; -var EXCLUDED_CHARS = /[\x00-\x1F\x7F\x3B\x3B\s\"\,\\"%]/g; -var TRAILING_SEMICOLON = /\x3B+$/; -var SEP_SEMICOLON = /\s*\x3B\s*/; - -// i know these should be 'const', but I'd like to keep -// supporting earlier node.js versions as long as I can. :) - -var KEY_INDEX = 1; // index of key from COOKIE_PAIR match -var VALUE_INDEX = 3; // index of value from COOKIE_PAIR match - -// Returns a copy str trimmed and without trainling semicolon. -function cleanCookieString(str) { - return str.trim().replace(/\x3B+$/, ''); -} - -function getFirstPair(str) { - var index = str.indexOf('\x3B'); - return index === -1 ? str : str.substr(0, index); -} - -// Returns a encoded copy of str based on RFC6265 S4.1.1. -function encodeCookieComponent(str) { - return str.toString().replace(EXCLUDED_CHARS, encodeURIComponent); -} - -// Parses a set-cookie-string based on the standard defined in RFC6265 S4.1.1. -function parseSetCookieString(str) { - str = cleanCookieString(str); - str = getFirstPair(str); - - var res = COOKIE_PAIR.exec(str); - if (!res || !res[VALUE_INDEX]) return null; - - return { - name : unescape(res[KEY_INDEX]), - value : unescape(res[VALUE_INDEX]) - }; -} - -// Parses a set-cookie-header and returns a key/value object. -// Each key represents the name of a cookie. -function parseSetCookieHeader(header) { - if (!header) return {}; - header = Array.isArray(header) ? header : [header]; - - return header.reduce(function(res, str) { - var cookie = parseSetCookieString(str); - if (cookie) res[cookie.name] = cookie.value; - return res; - }, {}); -} - -// Writes a set-cookie-string based on the standard definded in RFC6265 S4.1.1. -function writeCookieString(obj) { - return Object.keys(obj).reduce(function(str, name) { - var encodedName = encodeCookieComponent(name); - var encodedValue = encodeCookieComponent(obj[name]); - str += (str ? '; ' : '') + encodedName + '=' + encodedValue; - return str; - }, ''); -} - -// returns a key/val object from an array of cookie strings -exports.read = parseSetCookieHeader; - -// writes a cookie string header -exports.write = writeCookieString; diff --git a/node_modules/needle/lib/decoder.js b/node_modules/needle/lib/decoder.js deleted file mode 100644 index 4ff6198b..00000000 --- a/node_modules/needle/lib/decoder.js +++ /dev/null @@ -1,53 +0,0 @@ -var iconv, - inherits = require('util').inherits, - stream = require('stream'); - -var regex = /(?:charset|encoding)\s*=\s*['"]? *([\w\-]+)/i; - -inherits(StreamDecoder, stream.Transform); - -function StreamDecoder(charset) { - if (!(this instanceof StreamDecoder)) - return new StreamDecoder(charset); - - stream.Transform.call(this, charset); - this.charset = charset; - this.parsed_chunk = false; -} - -StreamDecoder.prototype._transform = function(chunk, encoding, done) { - var res, found; - - // try get charset from chunk, just once - if (this.charset == 'utf8' && !this.parsed_chunk) { - this.parsed_chunk = true; - - var matches = regex.exec(chunk.toString()); - if (matches) { - found = matches[1].toLowerCase(); - this.charset = found == 'utf-8' ? 'utf8' : found; - } - } - - try { - res = iconv.decode(chunk, this.charset); - } catch(e) { // something went wrong, just return original chunk - res = chunk; - } - - this.push(res); - done(); -} - -module.exports = function(charset) { - try { - if (!iconv) iconv = require('iconv-lite'); - } catch(e) { - /* iconv not found */ - } - - if (iconv) - return new StreamDecoder(charset); - else - return new stream.PassThrough; -} diff --git a/node_modules/needle/lib/multipart.js b/node_modules/needle/lib/multipart.js deleted file mode 100644 index d1e6e185..00000000 --- a/node_modules/needle/lib/multipart.js +++ /dev/null @@ -1,98 +0,0 @@ -var readFile = require('fs').readFile, - basename = require('path').basename; - -exports.build = function(data, boundary, callback) { - - if (typeof data != 'object' || typeof data.pipe == 'function') - return callback(new Error('Multipart builder expects data as key/val object.')); - - var body = '', - object = flatten(data), - count = Object.keys(object).length; - - if (count === 0) - return callback(new Error('Empty multipart body. Invalid data.')) - - function done(err, section) { - if (err) return callback(err); - if (section) body += section; - --count || callback(null, body + '--' + boundary + '--'); - }; - - for (var key in object) { - var value = object[key]; - if (value === null || typeof value == 'undefined') { - done(); - } else if (Buffer.isBuffer(value)) { - var part = { buffer: value, content_type: 'application/octet-stream' }; - generate_part(key, part, boundary, done); - } else { - var part = (value.buffer || value.file || value.content_type) ? value : { value: value }; - generate_part(key, part, boundary, done); - } - } - -} - -function generate_part(name, part, boundary, callback) { - - var return_part = '--' + boundary + '\r\n'; - return_part += 'Content-Disposition: form-data; name="' + name + '"'; - - function append(data, filename) { - - if (data) { - var binary = part.content_type.indexOf('text') == -1; - return_part += '; filename="' + encodeURIComponent(filename) + '"\r\n'; - if (binary) return_part += 'Content-Transfer-Encoding: binary\r\n'; - return_part += 'Content-Type: ' + part.content_type + '\r\n\r\n'; - return_part += binary ? data.toString('binary') : data.toString('utf8'); - } - - callback(null, return_part + '\r\n'); - }; - - if ((part.file || part.buffer) && part.content_type) { - - var filename = part.filename ? part.filename : part.file ? basename(part.file) : name; - if (part.buffer) return append(part.buffer, filename); - - readFile(part.file, function(err, data) { - if (err) return callback(err); - append(data, filename); - }); - - } else { - - if (typeof part.value == 'object') - return callback(new Error('Object received for ' + name + ', expected string.')) - - if (part.content_type) { - return_part += '\r\n'; - return_part += 'Content-Type: ' + part.content_type; - } - - return_part += '\r\n\r\n'; - return_part += Buffer.from(String(part.value), 'utf8').toString('binary'); - append(); - - } - -} - -// flattens nested objects for multipart body -function flatten(object, into, prefix) { - into = into || {}; - - for(var key in object) { - var prefix_key = prefix ? prefix + '[' + key + ']' : key; - var prop = object[key]; - - if (prop && typeof prop === 'object' && !(prop.buffer || prop.file || prop.content_type)) - flatten(prop, into, prefix_key) - else - into[prefix_key] = prop; - } - - return into; -} diff --git a/node_modules/needle/lib/needle.js b/node_modules/needle/lib/needle.js deleted file mode 100644 index b56c8f66..00000000 --- a/node_modules/needle/lib/needle.js +++ /dev/null @@ -1,879 +0,0 @@ -////////////////////////////////////////// -// Needle -- HTTP Client for Node.js -// Written by Tomás Pollak -// (c) 2012-2020 - Fork Ltd. -// MIT Licensed -////////////////////////////////////////// - -var fs = require('fs'), - http = require('http'), - https = require('https'), - url = require('url'), - stream = require('stream'), - debug = require('debug')('needle'), - stringify = require('./querystring').build, - multipart = require('./multipart'), - auth = require('./auth'), - cookies = require('./cookies'), - parsers = require('./parsers'), - decoder = require('./decoder'); - -////////////////////////////////////////// -// variabilia - -var version = require('../package.json').version; - -var user_agent = 'Needle/' + version; -user_agent += ' (Node.js ' + process.version + '; ' + process.platform + ' ' + process.arch + ')'; - -var tls_options = 'agent pfx key passphrase cert ca ciphers rejectUnauthorized secureProtocol checkServerIdentity family'; - -// older versions of node (< 0.11.4) prevent the runtime from exiting -// because of connections in keep-alive state. so if this is the case -// we'll default new requests to set a Connection: close header. -var close_by_default = !http.Agent || http.Agent.defaultMaxSockets != Infinity; - -// see if we have Object.assign. otherwise fall back to util._extend -var extend = Object.assign ? Object.assign : require('util')._extend; - -// these are the status codes that Needle interprets as redirects. -var redirect_codes = [301, 302, 303, 307, 308]; - -////////////////////////////////////////// -// decompressors for gzip/deflate/br bodies - -function bind_opts(fn, options) { - return fn.bind(null, options); -} - -var decompressors = {}; - -try { - - var zlib = require('zlib'); - - // Enable Z_SYNC_FLUSH to avoid Z_BUF_ERROR errors (Node PR #2595) - var zlib_options = { - flush: zlib.Z_SYNC_FLUSH, - finishFlush: zlib.Z_SYNC_FLUSH - }; - - var br_options = { - flush: zlib.BROTLI_OPERATION_FLUSH, - finishFlush: zlib.BROTLI_OPERATION_FLUSH - }; - - decompressors['x-deflate'] = bind_opts(zlib.Inflate, zlib_options); - decompressors['deflate'] = bind_opts(zlib.Inflate, zlib_options); - decompressors['x-gzip'] = bind_opts(zlib.Gunzip, zlib_options); - decompressors['gzip'] = bind_opts(zlib.Gunzip, zlib_options); - if (typeof zlib.BrotliDecompress === 'function') { - decompressors['br'] = bind_opts(zlib.BrotliDecompress, br_options); - } - -} catch(e) { /* zlib not available */ } - -////////////////////////////////////////// -// options and aliases - -var defaults = { - // data - boundary : '--------------------NODENEEDLEHTTPCLIENT', - encoding : 'utf8', - parse_response : 'all', // same as true. valid options: 'json', 'xml' or false/null - proxy : null, - - // headers - headers : {}, - accept : '*/*', - user_agent : user_agent, - - // numbers - open_timeout : 10000, - response_timeout : 0, - read_timeout : 0, - follow_max : 0, - stream_length : -1, - - // booleans - compressed : false, - decode_response : true, - parse_cookies : true, - follow_set_cookies : false, - follow_set_referer : false, - follow_keep_method : false, - follow_if_same_host : false, - follow_if_same_protocol : false, - follow_if_same_location : false -} - -var aliased = { - options: { - decode : 'decode_response', - parse : 'parse_response', - timeout : 'open_timeout', - follow : 'follow_max' - }, - inverted: {} -} - -// only once, invert aliased keys so we can get passed options. -Object.keys(aliased.options).map(function(k) { - var value = aliased.options[k]; - aliased.inverted[value] = k; -}); - -////////////////////////////////////////// -// helpers - -function keys_by_type(type) { - return Object.keys(defaults).map(function(el) { - if (defaults[el] !== null && defaults[el].constructor == type) - return el; - }).filter(function(el) { return el }) -} - -function parse_content_type(header) { - if (!header || header === '') return {}; - - var found, charset = 'utf8', arr = header.split(';'); - - if (arr.length > 1 && (found = arr[1].match(/charset=(.+)/))) - charset = found[1]; - - return { type: arr[0], charset: charset }; -} - -function is_stream(obj) { - return typeof obj.pipe === 'function'; -} - -function get_stream_length(stream, given_length, cb) { - if (given_length > 0) - return cb(given_length); - - if (stream.end !== void 0 && stream.end !== Infinity && stream.start !== void 0) - return cb((stream.end + 1) - (stream.start || 0)); - - fs.stat(stream.path, function(err, stat) { - cb(stat ? stat.size - (stream.start || 0) : null); - }); -} - -function resolve_url(href, base) { - if (url.URL) - return new url.URL(href, base); - - // older Node version (< v6.13) - return url.resolve(base, href); -} - -function pump_streams(streams, cb) { - if (stream.pipeline) - return stream.pipeline.apply(null, streams.concat(cb)); - - var tmp = streams.shift(); - while (streams.length) { - tmp = tmp.pipe(streams.shift()); - tmp.once('error', function(e) { - cb && cb(e); - cb = null; - }) - } -} - -////////////////////////////////////////// -// the main act - -function Needle(method, uri, data, options, callback) { - // if (!(this instanceof Needle)) { - // return new Needle(method, uri, data, options, callback); - // } - - if (typeof uri !== 'string') - throw new TypeError('URL must be a string, not ' + uri); - - this.method = method.toLowerCase(); - this.uri = uri; - this.data = data; - - if (typeof options == 'function') { - this.callback = options; - this.options = {}; - } else { - this.callback = callback; - this.options = options; - } - -} - -Needle.prototype.setup = function(uri, options) { - - function get_option(key, fallback) { - // if original is in options, return that value - if (typeof options[key] != 'undefined') return options[key]; - - // otherwise, return value from alias or fallback/undefined - return typeof options[aliased.inverted[key]] != 'undefined' - ? options[aliased.inverted[key]] : fallback; - } - - function check_value(expected, key) { - var value = get_option(key), - type = typeof value; - - if (type != 'undefined' && type != expected) - throw new TypeError(type + ' received for ' + key + ', but expected a ' + expected); - - return (type == expected) ? value : defaults[key]; - } - - ////////////////////////////////////////////////// - // the basics - - var config = { - http_opts : { - localAddress: get_option('localAddress', undefined), - lookup: get_option('lookup', undefined) - }, // passed later to http.request() directly - headers : {}, - output : options.output, - proxy : get_option('proxy', defaults.proxy), - parser : get_option('parse_response', defaults.parse_response), - encoding : options.encoding || (options.multipart ? 'binary' : defaults.encoding) - } - - keys_by_type(Boolean).forEach(function(key) { - config[key] = check_value('boolean', key); - }) - - keys_by_type(Number).forEach(function(key) { - config[key] = check_value('number', key); - }) - - // populate http_opts with given TLS options - tls_options.split(' ').forEach(function(key) { - if (typeof options[key] != 'undefined') { - config.http_opts[key] = options[key]; - if (typeof options.agent == 'undefined') - config.http_opts.agent = false; // otherwise tls options are skipped - } - }); - - ////////////////////////////////////////////////// - // headers, cookies - - for (var key in defaults.headers) - config.headers[key] = defaults.headers[key]; - - config.headers['accept'] = options.accept || defaults.accept; - config.headers['user-agent'] = options.user_agent || defaults.user_agent; - - if (options.content_type) - config.headers['content-type'] = options.content_type; - - // set connection header if opts.connection was passed, or if node < 0.11.4 (close) - if (options.connection || close_by_default) - config.headers['connection'] = options.connection || 'close'; - - if ((options.compressed || defaults.compressed) && typeof zlib != 'undefined') - config.headers['accept-encoding'] = decompressors['br'] ? 'gzip, deflate, br' : 'gzip, deflate'; - - if (options.cookies) - config.headers['cookie'] = cookies.write(options.cookies); - - ////////////////////////////////////////////////// - // basic/digest auth - - if (uri.match(/[^\/]@/)) { // url contains user:pass@host, so parse it. - var parts = (url.parse(uri).auth || '').split(':'); - options.username = parts[0]; - options.password = parts[1]; - } - - if (options.username) { - if (options.auth && (options.auth == 'auto' || options.auth == 'digest')) { - config.credentials = [options.username, options.password]; - } else { - config.headers['authorization'] = auth.basic(options.username, options.password); - } - } - - // if proxy is present, set auth header from either url or proxy_user option. - if (config.proxy) { - if (config.proxy.indexOf('http') === -1) - config.proxy = 'http://' + config.proxy; - - if (config.proxy.indexOf('@') !== -1) { - var proxy = (url.parse(config.proxy).auth || '').split(':'); - options.proxy_user = proxy[0]; - options.proxy_pass = proxy[1]; - } - - if (options.proxy_user) - config.headers['proxy-authorization'] = auth.basic(options.proxy_user, options.proxy_pass); - } - - // now that all our headers are set, overwrite them if instructed. - for (var h in options.headers) - config.headers[h.toLowerCase()] = options.headers[h]; - - config.uri_modifier = get_option('uri_modifier', null); - - return config; -} - -Needle.prototype.start = function() { - - var out = new stream.PassThrough({ objectMode: false }), - uri = this.uri, - data = this.data, - method = this.method, - callback = (typeof this.options == 'function') ? this.options : this.callback, - options = this.options || {}; - - // if no 'http' is found on URL, prepend it. - if (uri.indexOf('http') === -1) - uri = uri.replace(/^(\/\/)?/, 'http://'); - - var self = this, body, waiting = false, config = this.setup(uri, options); - - // unless options.json was set to false, assume boss also wants JSON if content-type matches. - var json = options.json || (options.json !== false && config.headers['content-type'] == 'application/json'); - - if (data) { - - if (options.multipart) { // boss says we do multipart. so we do it. - var boundary = options.boundary || defaults.boundary; - - waiting = true; - multipart.build(data, boundary, function(err, parts) { - if (err) throw(err); - - config.headers['content-type'] = 'multipart/form-data; boundary=' + boundary; - next(parts); - }); - - } else if (is_stream(data)) { - - if (method == 'get') - throw new Error('Refusing to pipe() a stream via GET. Did you mean .post?'); - - if (config.stream_length > 0 || (config.stream_length === 0 && data.path)) { - // ok, let's get the stream's length and set it as the content-length header. - // this prevents some servers from cutting us off before all the data is sent. - waiting = true; - get_stream_length(data, config.stream_length, function(length) { - data.length = length; - next(data); - }) - - } else { - // if the boss doesn't want us to get the stream's length, or if it doesn't - // have a file descriptor for that purpose, then just head on. - body = data; - } - - } else if (Buffer.isBuffer(data)) { - - body = data; // use the raw buffer as request body. - - } else if (method == 'get' && !json) { - - // append the data to the URI as a querystring. - uri = uri.replace(/\?.*|$/, '?' + stringify(data)); - - } else { // string or object data, no multipart. - - // if string, leave it as it is, otherwise, stringify. - body = (typeof(data) === 'string') ? data - : json ? JSON.stringify(data) : stringify(data); - - // ensure we have a buffer so bytecount is correct. - body = Buffer.from(body, config.encoding); - } - - } - - function next(body) { - if (body) { - if (body.length) config.headers['content-length'] = body.length; - - // if no content-type was passed, determine if json or not. - if (!config.headers['content-type']) { - config.headers['content-type'] = json - ? 'application/json; charset=utf-8' - : 'application/x-www-form-urlencoded'; // no charset says W3 spec. - } - } - - // unless a specific accept header was set, assume json: true wants JSON back. - if (options.json && (!options.accept && !(options.headers || {}).accept)) - config.headers['accept'] = 'application/json'; - - self.send_request(1, method, uri, config, body, out, callback); - } - - if (!waiting) next(body); - return out; -} - -Needle.prototype.get_request_opts = function(method, uri, config) { - var opts = config.http_opts, - proxy = config.proxy, - remote = proxy ? url.parse(proxy) : url.parse(uri); - - opts.protocol = remote.protocol; - opts.host = remote.hostname; - opts.port = remote.port || (remote.protocol == 'https:' ? 443 : 80); - opts.path = proxy ? uri : remote.pathname + (remote.search || ''); - opts.method = method; - opts.headers = config.headers; - - if (!opts.headers['host']) { - // if using proxy, make sure the host header shows the final destination - var target = proxy ? url.parse(uri) : remote; - opts.headers['host'] = target.hostname; - - // and if a non standard port was passed, append it to the port header - if (target.port && [80, 443].indexOf(target.port) === -1) { - opts.headers['host'] += ':' + target.port; - } - } - - return opts; -} - -Needle.prototype.should_follow = function(location, config, original) { - if (!location) return false; - - // returns true if location contains matching property (host or protocol) - function matches(property) { - var property = original[property]; - return location.indexOf(property) !== -1; - } - - // first, check whether the requested location is actually different from the original - if (!config.follow_if_same_location && location === original) - return false; - - if (config.follow_if_same_host && !matches('host')) - return false; // host does not match, so not following - - if (config.follow_if_same_protocol && !matches('protocol')) - return false; // procotol does not match, so not following - - return true; -} - -Needle.prototype.send_request = function(count, method, uri, config, post_data, out, callback) { - - if (typeof config.uri_modifier === 'function') { - var modified_uri = config.uri_modifier(uri); - debug('Modifying request URI', uri + ' => ' + modified_uri); - uri = modified_uri; - } - - var request, - timer, - returned = 0, - self = this, - request_opts = this.get_request_opts(method, uri, config), - protocol = request_opts.protocol == 'https:' ? https : http; - - function done(err, resp) { - if (returned++ > 0) - return debug('Already finished, stopping here.'); - - if (timer) clearTimeout(timer); - request.removeListener('error', had_error); - out.done = true; - - if (callback) - return callback(err, resp, resp ? resp.body : undefined); - - // NOTE: this event used to be called 'end', but the behaviour was confusing - // when errors ocurred, because the stream would still emit an 'end' event. - out.emit('done', err); - - // trigger the 'done' event on streams we're being piped to, if any - var pipes = out._readableState.pipes || []; - if (!pipes.forEach) pipes = [pipes]; - pipes.forEach(function(st) { st.emit('done', err); }) - } - - function had_error(err) { - debug('Request error', err); - out.emit('err', err); - done(err || new Error('Unknown error when making request.')); - } - - function set_timeout(type, milisecs) { - if (timer) clearTimeout(timer); - if (milisecs <= 0) return; - - timer = setTimeout(function() { - out.emit('timeout', type); - request.abort(); - // also invoke done() to terminate job on read_timeout - if (type == 'read') done(new Error(type + ' timeout')); - }, milisecs); - } - - // handle errors on the underlying socket, that may be closed while writing - // for an example case, see test/long_string_spec.js. we make sure this - // scenario ocurred by verifying the socket's writable & destroyed states. - function on_socket_end() { - if (returned && !this.writable && this.destroyed === false) { - this.destroy(); - had_error(new Error('Remote end closed socket abruptly.')) - } - } - - debug('Making request #' + count, request_opts); - request = protocol.request(request_opts, function(resp) { - - var headers = resp.headers; - debug('Got response', resp.statusCode, headers); - out.emit('response', resp); - - set_timeout('read', config.read_timeout); - - // if we got cookies, parse them unless we were instructed not to. make sure to include any - // cookies that might have been set on previous redirects. - if (config.parse_cookies && (headers['set-cookie'] || config.previous_resp_cookies)) { - resp.cookies = extend(config.previous_resp_cookies || {}, cookies.read(headers['set-cookie'])); - debug('Got cookies', resp.cookies); - } - - // if redirect code is found, determine if we should follow it according to the given options. - if (redirect_codes.indexOf(resp.statusCode) !== -1 && self.should_follow(headers.location, config, uri)) { - // clear timer before following redirects to prevent unexpected setTimeout consequence - clearTimeout(timer); - - if (count <= config.follow_max) { - out.emit('redirect', headers.location); - - // unless 'follow_keep_method' is true, rewrite the request to GET before continuing. - if (!config.follow_keep_method) { - method = 'GET'; - post_data = null; - delete config.headers['content-length']; // in case the original was a multipart POST request. - } - - // if follow_set_cookies is true, insert cookies in the next request's headers. - // we set both the original request cookies plus any response cookies we might have received. - if (config.follow_set_cookies) { - var request_cookies = cookies.read(config.headers['cookie']); - config.previous_resp_cookies = resp.cookies; - if (Object.keys(request_cookies).length || Object.keys(resp.cookies || {}).length) { - config.headers['cookie'] = cookies.write(extend(request_cookies, resp.cookies)); - } - } else if (config.headers['cookie']) { - debug('Clearing original request cookie', config.headers['cookie']); - delete config.headers['cookie']; - } - - if (config.follow_set_referer) - config.headers['referer'] = encodeURI(uri); // the original, not the destination URL. - - config.headers['host'] = null; // clear previous Host header to avoid conflicts. - - var redirect_url = resolve_url(headers.location, uri); - debug('Redirecting to ' + redirect_url.toString()); - return self.send_request(++count, method, redirect_url.toString(), config, post_data, out, callback); - } else if (config.follow_max > 0) { - return done(new Error('Max redirects reached. Possible loop in: ' + headers.location)); - } - } - - // if auth is requested and credentials were not passed, resend request, provided we have user/pass. - if (resp.statusCode == 401 && headers['www-authenticate'] && config.credentials) { - if (!config.headers['authorization']) { // only if authentication hasn't been sent - var auth_header = auth.header(headers['www-authenticate'], config.credentials, request_opts); - - if (auth_header) { - config.headers['authorization'] = auth_header; - return self.send_request(count, method, uri, config, post_data, out, callback); - } - } - } - - // ok, so we got a valid (non-redirect & authorized) response. let's notify the stream guys. - out.emit('header', resp.statusCode, headers); - out.emit('headers', headers); - - var pipeline = [], - mime = parse_content_type(headers['content-type']), - text_response = mime.type && (mime.type.indexOf('text/') != -1 || !!mime.type.match(/(\/|\+)(xml|json)$/)); - - // To start, if our body is compressed and we're able to inflate it, do it. - if (headers['content-encoding'] && decompressors[headers['content-encoding']]) { - - var decompressor = decompressors[headers['content-encoding']](); - - // make sure we catch errors triggered by the decompressor. - decompressor.on('error', had_error); - pipeline.push(decompressor); - } - - // If parse is enabled and we have a parser for it, then go for it. - if (config.parser && parsers[mime.type]) { - - // If a specific parser was requested, make sure we don't parse other types. - var parser_name = config.parser.toString().toLowerCase(); - if (['xml', 'json'].indexOf(parser_name) == -1 || parsers[mime.type].name == parser_name) { - - // OK, so either we're parsing all content types or the one requested matches. - out.parser = parsers[mime.type].name; - pipeline.push(parsers[mime.type].fn()); - - // Set objectMode on out stream to improve performance. - out._writableState.objectMode = true; - out._readableState.objectMode = true; - } - - // If we're not parsing, and unless decoding was disabled, we'll try - // decoding non UTF-8 bodies to UTF-8, using the iconv-lite library. - } else if (text_response && config.decode_response && mime.charset) { - pipeline.push(decoder(mime.charset)); - } - - // And `out` is the stream we finally push the decoded/parsed output to. - pipeline.push(out); - - // Now, release the kraken! - pump_streams([resp].concat(pipeline), function(err) { - if (err) debug(err) - - // on node v8.x, if an error ocurrs on the receiving end, - // then we want to abort the request to avoid having dangling sockets - if (err && err.message == 'write after end') request.destroy(); - }); - - // If the user has requested and output file, pipe the output stream to it. - // In stream mode, we will still get the response stream to play with. - if (config.output && resp.statusCode == 200) { - - // for some reason, simply piping resp to the writable stream doesn't - // work all the time (stream gets cut in the middle with no warning). - // so we'll manually need to do the readable/write(chunk) trick. - var file = fs.createWriteStream(config.output); - file.on('error', had_error); - - out.on('end', function() { - if (file.writable) file.end(); - }); - - file.on('close', function() { - delete out.file; - }) - - out.on('readable', function() { - var chunk; - while ((chunk = this.read()) !== null) { - if (file.writable) file.write(chunk); - - // if callback was requested, also push it to resp.body - if (resp.body) resp.body.push(chunk); - } - }) - - out.file = file; - } - - // Only aggregate the full body if a callback was requested. - if (callback) { - resp.raw = []; - resp.body = []; - resp.bytes = 0; - - // Gather and count the amount of (raw) bytes using a PassThrough stream. - var clean_pipe = new stream.PassThrough(); - - clean_pipe.on('readable', function() { - var chunk; - while ((chunk = this.read()) != null) { - resp.bytes += chunk.length; - resp.raw.push(chunk); - } - }) - - pump_streams([resp, clean_pipe], function(err) { - if (err) debug(err); - }); - - // Listen on the 'readable' event to aggregate the chunks, but only if - // file output wasn't requested. Otherwise we'd have two stream readers. - if (!config.output || resp.statusCode != 200) { - out.on('readable', function() { - var chunk; - while ((chunk = this.read()) !== null) { - // We're either pushing buffers or objects, never strings. - if (typeof chunk == 'string') chunk = Buffer.from(chunk); - - // Push all chunks to resp.body. We'll bind them in resp.end(). - resp.body.push(chunk); - } - }) - } - } - - // And set the .body property once all data is in. - out.on('end', function() { - if (resp.body) { // callback mode - - // we want to be able to access to the raw data later, so keep a reference. - resp.raw = Buffer.concat(resp.raw); - - // if parse was successful, we should have an array with one object - if (resp.body[0] !== undefined && !Buffer.isBuffer(resp.body[0])) { - - // that's our body right there. - resp.body = resp.body[0]; - - // set the parser property on our response. we may want to check. - if (out.parser) resp.parser = out.parser; - - } else { // we got one or several buffers. string or binary. - resp.body = Buffer.concat(resp.body); - - // if we're here and parsed is true, it means we tried to but it didn't work. - // so given that we got a text response, let's stringify it. - if (text_response || out.parser) { - resp.body = resp.body.toString(); - } - } - } - - // if an output file is being written to, make sure the callback - // is triggered after all data has been written to it. - if (out.file) { - out.file.on('close', function() { - done(null, resp); - }) - } else { // elvis has left the building. - done(null, resp); - } - - }); - - // out.on('error', function(err) { - // had_error(err); - // if (err.code == 'ERR_STREAM_DESTROYED' || err.code == 'ERR_STREAM_PREMATURE_CLOSE') { - // request.abort(); - // } - // }) - - }); // end request call - - // unless open_timeout was disabled, set a timeout to abort the request. - set_timeout('open', config.open_timeout); - - // handle errors on the request object. things might get bumpy. - request.on('error', had_error); - - // make sure timer is cleared if request is aborted (issue #257) - request.once('abort', function() { - if (timer) clearTimeout(timer); - }) - - // handle socket 'end' event to ensure we don't get delayed EPIPE errors. - request.once('socket', function(socket) { - if (socket.connecting) { - socket.once('connect', function() { - set_timeout('response', config.response_timeout); - }) - } else { - set_timeout('response', config.response_timeout); - } - - // socket.once('close', function(e) { - // console.log('socket closed!', e); - // }) - - if (!socket.on_socket_end) { - socket.on_socket_end = on_socket_end; - socket.once('end', function() { process.nextTick(on_socket_end.bind(socket)) }); - } - }) - - if (post_data) { - if (is_stream(post_data)) { - pump_streams([post_data, request], function(err) { - if (err) debug(err); - }); - } else { - request.write(post_data, config.encoding); - request.end(); - } - } else { - request.end(); - } - - out.abort = function() { request.abort() }; // easier access - out.request = request; - return out; -} - -////////////////////////////////////////// -// exports - -if (typeof Promise !== 'undefined') { - module.exports = function() { - var verb, args = [].slice.call(arguments); - - if (args[0].match(/\.|\//)) // first argument looks like a URL - verb = (args.length > 2) ? 'post' : 'get'; - else - verb = args.shift(); - - if (verb.match(/get|head/i) && args.length == 2) - args.splice(1, 0, null); // assume no data if head/get with two args (url, options) - - return new Promise(function(resolve, reject) { - module.exports.request(verb, args[0], args[1], args[2], function(err, resp) { - return err ? reject(err) : resolve(resp); - }); - }) - } -} - -module.exports.version = version; - -module.exports.defaults = function(obj) { - for (var key in obj) { - var target_key = aliased.options[key] || key; - - if (defaults.hasOwnProperty(target_key) && typeof obj[key] != 'undefined') { - if (target_key != 'parse_response' && target_key != 'proxy') { - // ensure type matches the original, except for proxy/parse_response that can be null/bool or string - var valid_type = defaults[target_key].constructor.name; - - if (obj[key].constructor.name != valid_type) - throw new TypeError('Invalid type for ' + key + ', should be ' + valid_type); - } - defaults[target_key] = obj[key]; - } else { - throw new Error('Invalid property for defaults:' + target_key); - } - } - - return defaults; -} - -'head get'.split(' ').forEach(function(method) { - module.exports[method] = function(uri, options, callback) { - return new Needle(method, uri, null, options, callback).start(); - } -}) - -'post put patch delete'.split(' ').forEach(function(method) { - module.exports[method] = function(uri, data, options, callback) { - return new Needle(method, uri, data, options, callback).start(); - } -}) - -module.exports.request = function(method, uri, data, opts, callback) { - return new Needle(method, uri, data, opts, callback).start(); -}; diff --git a/node_modules/needle/lib/parsers.js b/node_modules/needle/lib/parsers.js deleted file mode 100644 index 3da72871..00000000 --- a/node_modules/needle/lib/parsers.js +++ /dev/null @@ -1,121 +0,0 @@ -////////////////////////////////////////// -// Defines mappings between content-type -// and the appropriate parsers. -////////////////////////////////////////// - -var Transform = require('stream').Transform; -var sax = require('sax'); - -function parseXML(str, cb) { - var obj, current, parser = sax.parser(true, { trim: true, lowercase: true }) - parser.onerror = parser.onend = done; - - function done(err) { - parser.onerror = parser.onend = function() { } - cb(err, obj) - } - - function newElement(name, attributes) { - return { - name: name || '', - value: '', - attributes: attributes || {}, - children: [] - } - } - - parser.oncdata = parser.ontext = function(t) { - if (current) current.value += t - } - - parser.onopentag = function(node) { - var element = newElement(node.name, node.attributes) - if (current) { - element.parent = current - current.children.push(element) - } else { // root object - obj = element - } - - current = element - }; - - parser.onclosetag = function() { - if (typeof current.parent !== 'undefined') { - var just_closed = current - current = current.parent - delete just_closed.parent - } - } - - parser.write(str).close() -} - -function parserFactory(name, fn) { - - function parser() { - var chunks = [], - stream = new Transform({ objectMode: true }); - - // Buffer all our data - stream._transform = function(chunk, encoding, done) { - chunks.push(chunk); - done(); - } - - // And call the parser when all is there. - stream._flush = function(done) { - var self = this, - data = Buffer.concat(chunks); - - try { - fn(data, function(err, result) { - if (err) throw err; - self.push(result); - }); - } catch (err) { - self.push(data); // just pass the original data - } finally { - done(); - } - } - - return stream; - } - - return { fn: parser, name: name }; -} - -var parsers = {} - -function buildParser(name, types, fn) { - var parser = parserFactory(name, fn); - types.forEach(function(type) { - parsers[type] = parser; - }) -} - -buildParser('json', [ - 'application/json', - 'text/javascript', - 'application/vnd.api+json' -], function(buffer, cb) { - var err, data; - try { data = JSON.parse(buffer); } catch (e) { err = e; } - cb(err, data); -}); - -buildParser('xml', [ - 'text/xml', - 'application/xml', - 'application/rdf+xml', - 'application/rss+xml', - 'application/atom+xml' -], function(buffer, cb) { - parseXML(buffer.toString(), function(err, obj) { - cb(err, obj) - }) -}); - -module.exports = parsers; -module.exports.use = buildParser; diff --git a/node_modules/needle/lib/querystring.js b/node_modules/needle/lib/querystring.js deleted file mode 100644 index e58cc426..00000000 --- a/node_modules/needle/lib/querystring.js +++ /dev/null @@ -1,49 +0,0 @@ -// based on the qs module, but handles null objects as expected -// fixes by Tomas Pollak. - -var toString = Object.prototype.toString; - -function stringify(obj, prefix) { - if (prefix && (obj === null || typeof obj == 'undefined')) { - return prefix + '='; - } else if (toString.call(obj) == '[object Array]') { - return stringifyArray(obj, prefix); - } else if (toString.call(obj) == '[object Object]') { - return stringifyObject(obj, prefix); - } else if (toString.call(obj) == '[object Date]') { - return obj.toISOString(); - } else if (prefix) { // string inside array or hash - return prefix + '=' + encodeURIComponent(String(obj)); - } else if (String(obj).indexOf('=') !== -1) { // string with equal sign - return String(obj); - } else { - throw new TypeError('Cannot build a querystring out of: ' + obj); - } -}; - -function stringifyArray(arr, prefix) { - var ret = []; - - for (var i = 0, len = arr.length; i < len; i++) { - if (prefix) - ret.push(stringify(arr[i], prefix + '[]')); - else - ret.push(stringify(arr[i])); - } - - return ret.join('&'); -} - -function stringifyObject(obj, prefix) { - var ret = []; - - Object.keys(obj).forEach(function(key) { - ret.push(stringify(obj[key], prefix - ? prefix + '[' + encodeURIComponent(key) + ']' - : encodeURIComponent(key))); - }) - - return ret.join('&'); -} - -exports.build = stringify; diff --git a/node_modules/needle/license.txt b/node_modules/needle/license.txt deleted file mode 100644 index fb245f39..00000000 --- a/node_modules/needle/license.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) Fork, Ltd. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/needle/node_modules/debug/CHANGELOG.md b/node_modules/needle/node_modules/debug/CHANGELOG.md deleted file mode 100644 index 820d21e3..00000000 --- a/node_modules/needle/node_modules/debug/CHANGELOG.md +++ /dev/null @@ -1,395 +0,0 @@ - -3.1.0 / 2017-09-26 -================== - - * Add `DEBUG_HIDE_DATE` env var (#486) - * Remove ReDoS regexp in %o formatter (#504) - * Remove "component" from package.json - * Remove `component.json` - * Ignore package-lock.json - * Examples: fix colors printout - * Fix: browser detection - * Fix: spelling mistake (#496, @EdwardBetts) - -3.0.1 / 2017-08-24 -================== - - * Fix: Disable colors in Edge and Internet Explorer (#489) - -3.0.0 / 2017-08-08 -================== - - * Breaking: Remove DEBUG_FD (#406) - * Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418) - * Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408) - * Addition: document `enabled` flag (#465) - * Addition: add 256 colors mode (#481) - * Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440) - * Update: component: update "ms" to v2.0.0 - * Update: separate the Node and Browser tests in Travis-CI - * Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots - * Update: separate Node.js and web browser examples for organization - * Update: update "browserify" to v14.4.0 - * Fix: fix Readme typo (#473) - -2.6.9 / 2017-09-22 -================== - - * remove ReDoS regexp in %o formatter (#504) - -2.6.8 / 2017-05-18 -================== - - * Fix: Check for undefined on browser globals (#462, @marbemac) - -2.6.7 / 2017-05-16 -================== - - * Fix: Update ms to 2.0.0 to fix regular expression denial of service vulnerability (#458, @hubdotcom) - * Fix: Inline extend function in node implementation (#452, @dougwilson) - * Docs: Fix typo (#455, @msasad) - -2.6.5 / 2017-04-27 -================== - - * Fix: null reference check on window.documentElement.style.WebkitAppearance (#447, @thebigredgeek) - * Misc: clean up browser reference checks (#447, @thebigredgeek) - * Misc: add npm-debug.log to .gitignore (@thebigredgeek) - - -2.6.4 / 2017-04-20 -================== - - * Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) - * Chore: ignore bower.json in npm installations. (#437, @joaovieira) - * Misc: update "ms" to v0.7.3 (@tootallnate) - -2.6.3 / 2017-03-13 -================== - - * Fix: Electron reference to `process.env.DEBUG` (#431, @paulcbetts) - * Docs: Changelog fix (@thebigredgeek) - -2.6.2 / 2017-03-10 -================== - - * Fix: DEBUG_MAX_ARRAY_LENGTH (#420, @slavaGanzin) - * Docs: Add backers and sponsors from Open Collective (#422, @piamancini) - * Docs: Add Slackin invite badge (@tootallnate) - -2.6.1 / 2017-02-10 -================== - - * Fix: Module's `export default` syntax fix for IE8 `Expected identifier` error - * Fix: Whitelist DEBUG_FD for values 1 and 2 only (#415, @pi0) - * Fix: IE8 "Expected identifier" error (#414, @vgoma) - * Fix: Namespaces would not disable once enabled (#409, @musikov) - -2.6.0 / 2016-12-28 -================== - - * Fix: added better null pointer checks for browser useColors (@thebigredgeek) - * Improvement: removed explicit `window.debug` export (#404, @tootallnate) - * Improvement: deprecated `DEBUG_FD` environment variable (#405, @tootallnate) - -2.5.2 / 2016-12-25 -================== - - * Fix: reference error on window within webworkers (#393, @KlausTrainer) - * Docs: fixed README typo (#391, @lurch) - * Docs: added notice about v3 api discussion (@thebigredgeek) - -2.5.1 / 2016-12-20 -================== - - * Fix: babel-core compatibility - -2.5.0 / 2016-12-20 -================== - - * Fix: wrong reference in bower file (@thebigredgeek) - * Fix: webworker compatibility (@thebigredgeek) - * Fix: output formatting issue (#388, @kribblo) - * Fix: babel-loader compatibility (#383, @escwald) - * Misc: removed built asset from repo and publications (@thebigredgeek) - * Misc: moved source files to /src (#378, @yamikuronue) - * Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue) - * Test: coveralls integration (#378, @yamikuronue) - * Docs: simplified language in the opening paragraph (#373, @yamikuronue) - -2.4.5 / 2016-12-17 -================== - - * Fix: `navigator` undefined in Rhino (#376, @jochenberger) - * Fix: custom log function (#379, @hsiliev) - * Improvement: bit of cleanup + linting fixes (@thebigredgeek) - * Improvement: rm non-maintainted `dist/` dir (#375, @freewil) - * Docs: simplified language in the opening paragraph. (#373, @yamikuronue) - -2.4.4 / 2016-12-14 -================== - - * Fix: work around debug being loaded in preload scripts for electron (#368, @paulcbetts) - -2.4.3 / 2016-12-14 -================== - - * Fix: navigation.userAgent error for react native (#364, @escwald) - -2.4.2 / 2016-12-14 -================== - - * Fix: browser colors (#367, @tootallnate) - * Misc: travis ci integration (@thebigredgeek) - * Misc: added linting and testing boilerplate with sanity check (@thebigredgeek) - -2.4.1 / 2016-12-13 -================== - - * Fix: typo that broke the package (#356) - -2.4.0 / 2016-12-13 -================== - - * Fix: bower.json references unbuilt src entry point (#342, @justmatt) - * Fix: revert "handle regex special characters" (@tootallnate) - * Feature: configurable util.inspect()`options for NodeJS (#327, @tootallnate) - * Feature: %O`(big O) pretty-prints objects (#322, @tootallnate) - * Improvement: allow colors in workers (#335, @botverse) - * Improvement: use same color for same namespace. (#338, @lchenay) - -2.3.3 / 2016-11-09 -================== - - * Fix: Catch `JSON.stringify()` errors (#195, Jovan Alleyne) - * Fix: Returning `localStorage` saved values (#331, Levi Thomason) - * Improvement: Don't create an empty object when no `process` (Nathan Rajlich) - -2.3.2 / 2016-11-09 -================== - - * Fix: be super-safe in index.js as well (@TooTallNate) - * Fix: should check whether process exists (Tom Newby) - -2.3.1 / 2016-11-09 -================== - - * Fix: Added electron compatibility (#324, @paulcbetts) - * Improvement: Added performance optimizations (@tootallnate) - * Readme: Corrected PowerShell environment variable example (#252, @gimre) - * Misc: Removed yarn lock file from source control (#321, @fengmk2) - -2.3.0 / 2016-11-07 -================== - - * Fix: Consistent placement of ms diff at end of output (#215, @gorangajic) - * Fix: Escaping of regex special characters in namespace strings (#250, @zacronos) - * Fix: Fixed bug causing crash on react-native (#282, @vkarpov15) - * Feature: Enabled ES6+ compatible import via default export (#212 @bucaran) - * Feature: Added %O formatter to reflect Chrome's console.log capability (#279, @oncletom) - * Package: Update "ms" to 0.7.2 (#315, @DevSide) - * Package: removed superfluous version property from bower.json (#207 @kkirsche) - * Readme: fix USE_COLORS to DEBUG_COLORS - * Readme: Doc fixes for format string sugar (#269, @mlucool) - * Readme: Updated docs for DEBUG_FD and DEBUG_COLORS environment variables (#232, @mattlyons0) - * Readme: doc fixes for PowerShell (#271 #243, @exoticknight @unreadable) - * Readme: better docs for browser support (#224, @matthewmueller) - * Tooling: Added yarn integration for development (#317, @thebigredgeek) - * Misc: Renamed History.md to CHANGELOG.md (@thebigredgeek) - * Misc: Added license file (#226 #274, @CantemoInternal @sdaitzman) - * Misc: Updated contributors (@thebigredgeek) - -2.2.0 / 2015-05-09 -================== - - * package: update "ms" to v0.7.1 (#202, @dougwilson) - * README: add logging to file example (#193, @DanielOchoa) - * README: fixed a typo (#191, @amir-s) - * browser: expose `storage` (#190, @stephenmathieson) - * Makefile: add a `distclean` target (#189, @stephenmathieson) - -2.1.3 / 2015-03-13 -================== - - * Updated stdout/stderr example (#186) - * Updated example/stdout.js to match debug current behaviour - * Renamed example/stderr.js to stdout.js - * Update Readme.md (#184) - * replace high intensity foreground color for bold (#182, #183) - -2.1.2 / 2015-03-01 -================== - - * dist: recompile - * update "ms" to v0.7.0 - * package: update "browserify" to v9.0.3 - * component: fix "ms.js" repo location - * changed bower package name - * updated documentation about using debug in a browser - * fix: security error on safari (#167, #168, @yields) - -2.1.1 / 2014-12-29 -================== - - * browser: use `typeof` to check for `console` existence - * browser: check for `console.log` truthiness (fix IE 8/9) - * browser: add support for Chrome apps - * Readme: added Windows usage remarks - * Add `bower.json` to properly support bower install - -2.1.0 / 2014-10-15 -================== - - * node: implement `DEBUG_FD` env variable support - * package: update "browserify" to v6.1.0 - * package: add "license" field to package.json (#135, @panuhorsmalahti) - -2.0.0 / 2014-09-01 -================== - - * package: update "browserify" to v5.11.0 - * node: use stderr rather than stdout for logging (#29, @stephenmathieson) - -1.0.4 / 2014-07-15 -================== - - * dist: recompile - * example: remove `console.info()` log usage - * example: add "Content-Type" UTF-8 header to browser example - * browser: place %c marker after the space character - * browser: reset the "content" color via `color: inherit` - * browser: add colors support for Firefox >= v31 - * debug: prefer an instance `log()` function over the global one (#119) - * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) - -1.0.3 / 2014-07-09 -================== - - * Add support for multiple wildcards in namespaces (#122, @seegno) - * browser: fix lint - -1.0.2 / 2014-06-10 -================== - - * browser: update color palette (#113, @gscottolson) - * common: make console logging function configurable (#108, @timoxley) - * node: fix %o colors on old node <= 0.8.x - * Makefile: find node path using shell/which (#109, @timoxley) - -1.0.1 / 2014-06-06 -================== - - * browser: use `removeItem()` to clear localStorage - * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) - * package: add "contributors" section - * node: fix comment typo - * README: list authors - -1.0.0 / 2014-06-04 -================== - - * make ms diff be global, not be scope - * debug: ignore empty strings in enable() - * node: make DEBUG_COLORS able to disable coloring - * *: export the `colors` array - * npmignore: don't publish the `dist` dir - * Makefile: refactor to use browserify - * package: add "browserify" as a dev dependency - * Readme: add Web Inspector Colors section - * node: reset terminal color for the debug content - * node: map "%o" to `util.inspect()` - * browser: map "%j" to `JSON.stringify()` - * debug: add custom "formatters" - * debug: use "ms" module for humanizing the diff - * Readme: add "bash" syntax highlighting - * browser: add Firebug color support - * browser: add colors for WebKit browsers - * node: apply log to `console` - * rewrite: abstract common logic for Node & browsers - * add .jshintrc file - -0.8.1 / 2014-04-14 -================== - - * package: re-add the "component" section - -0.8.0 / 2014-03-30 -================== - - * add `enable()` method for nodejs. Closes #27 - * change from stderr to stdout - * remove unnecessary index.js file - -0.7.4 / 2013-11-13 -================== - - * remove "browserify" key from package.json (fixes something in browserify) - -0.7.3 / 2013-10-30 -================== - - * fix: catch localStorage security error when cookies are blocked (Chrome) - * add debug(err) support. Closes #46 - * add .browser prop to package.json. Closes #42 - -0.7.2 / 2013-02-06 -================== - - * fix package.json - * fix: Mobile Safari (private mode) is broken with debug - * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript - -0.7.1 / 2013-02-05 -================== - - * add repository URL to package.json - * add DEBUG_COLORED to force colored output - * add browserify support - * fix component. Closes #24 - -0.7.0 / 2012-05-04 -================== - - * Added .component to package.json - * Added debug.component.js build - -0.6.0 / 2012-03-16 -================== - - * Added support for "-" prefix in DEBUG [Vinay Pulim] - * Added `.enabled` flag to the node version [TooTallNate] - -0.5.0 / 2012-02-02 -================== - - * Added: humanize diffs. Closes #8 - * Added `debug.disable()` to the CS variant - * Removed padding. Closes #10 - * Fixed: persist client-side variant again. Closes #9 - -0.4.0 / 2012-02-01 -================== - - * Added browser variant support for older browsers [TooTallNate] - * Added `debug.enable('project:*')` to browser variant [TooTallNate] - * Added padding to diff (moved it to the right) - -0.3.0 / 2012-01-26 -================== - - * Added millisecond diff when isatty, otherwise UTC string - -0.2.0 / 2012-01-22 -================== - - * Added wildcard support - -0.1.0 / 2011-12-02 -================== - - * Added: remove colors unless stderr isatty [TooTallNate] - -0.0.1 / 2010-01-03 -================== - - * Initial release diff --git a/node_modules/needle/node_modules/debug/LICENSE b/node_modules/needle/node_modules/debug/LICENSE deleted file mode 100644 index 658c933d..00000000 --- a/node_modules/needle/node_modules/debug/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -(The MIT License) - -Copyright (c) 2014 TJ Holowaychuk - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the 'Software'), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/node_modules/needle/node_modules/debug/README.md b/node_modules/needle/node_modules/debug/README.md deleted file mode 100644 index 0ee7634d..00000000 --- a/node_modules/needle/node_modules/debug/README.md +++ /dev/null @@ -1,437 +0,0 @@ -# debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) -[![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) - - - -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: - -screen shot 2017-08-08 at 12 53 04 pm -screen shot 2017-08-08 at 12 53 38 pm -screen shot 2017-08-08 at 12 53 25 pm - -#### 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. - - - -#### 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). - - - - -## 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. - - - -When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: - - - - -## 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); -``` - - -## 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 -``` - -## 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. - - -## Authors - - - TJ Holowaychuk - - Nathan Rajlich - - Andrew Rhyne - -## Backers - -Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -## 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)] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -## License - -(The MIT License) - -Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/needle/node_modules/debug/node.js b/node_modules/needle/node_modules/debug/node.js deleted file mode 100644 index 7fc36fe6..00000000 --- a/node_modules/needle/node_modules/debug/node.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./src/node'); diff --git a/node_modules/needle/node_modules/debug/package.json b/node_modules/needle/node_modules/debug/package.json deleted file mode 100644 index 191c8154..00000000 --- a/node_modules/needle/node_modules/debug/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "debug", - "version": "3.2.7", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" - }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" - ], - "files": [ - "src", - "node.js", - "dist/debug.js", - "LICENSE", - "README.md" - ], - "author": "TJ Holowaychuk ", - "contributors": [ - "Nathan Rajlich (http://n8.io)", - "Andrew Rhyne " - ], - "license": "MIT", - "dependencies": { - "ms": "^2.1.1" - }, - "devDependencies": { - "@babel/cli": "^7.0.0", - "@babel/core": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "browserify": "14.4.0", - "chai": "^3.5.0", - "concurrently": "^3.1.0", - "coveralls": "^3.0.2", - "istanbul": "^0.4.5", - "karma": "^3.0.0", - "karma-chai": "^0.1.0", - "karma-mocha": "^1.3.0", - "karma-phantomjs-launcher": "^1.0.2", - "mocha": "^5.2.0", - "mocha-lcov-reporter": "^1.2.0", - "rimraf": "^2.5.4", - "xo": "^0.23.0" - }, - "main": "./src/index.js", - "browser": "./src/browser.js", - "unpkg": "./dist/debug.js" -} diff --git a/node_modules/needle/node_modules/debug/src/browser.js b/node_modules/needle/node_modules/debug/src/browser.js deleted file mode 100644 index c924b0ac..00000000 --- a/node_modules/needle/node_modules/debug/src/browser.js +++ /dev/null @@ -1,180 +0,0 @@ -"use strict"; - -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - -/* eslint-env browser */ - -/** - * This is the web browser implementation of `debug()`. - */ -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = localstorage(); -/** - * 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; - } // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - - - return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 - typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker - typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); -} -/** - * 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; - } - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function (match) { - if (match === '%%') { - return; - } - - index++; - - if (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.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - - -function log() { - var _console; - - // This hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments); -} -/** - * 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() { - var 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); -var formatters = module.exports.formatters; -/** - * 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; - } -}; - diff --git a/node_modules/needle/node_modules/debug/src/common.js b/node_modules/needle/node_modules/debug/src/common.js deleted file mode 100644 index e0de3fb5..00000000 --- a/node_modules/needle/node_modules/debug/src/common.js +++ /dev/null @@ -1,249 +0,0 @@ -"use strict"; - -/** - * 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'); - Object.keys(env).forEach(function (key) { - createDebug[key] = env[key]; - }); - /** - * Active `debug` instances. - */ - - createDebug.instances = []; - /** - * 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 for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - - function selectColor(namespace) { - var hash = 0; - - for (var 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) { - var prevTime; - - function debug() { - // Disabled? - if (!debug.enabled) { - return; - } - - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var self = debug; // Set `diff` timestamp - - var curr = Number(new Date()); - var 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 - - - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return match; - } - - index++; - var formatter = createDebug.formatters[format]; - - if (typeof formatter === 'function') { - var val = args[index]; - match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format` - - args.splice(index, 1); - index--; - } - - return match; - }); // Apply env-specific formatting (colors, etc.) - - createDebug.formatArgs.call(self, args); - var logFn = self.log || createDebug.log; - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = createDebug.enabled(namespace); - debug.useColors = createDebug.useColors(); - debug.color = selectColor(namespace); - debug.destroy = destroy; - debug.extend = extend; // Debug.formatArgs = formatArgs; - // debug.rawLog = rawLog; - // env-specific initialization logic for debug instances - - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } - - createDebug.instances.push(debug); - return debug; - } - - function destroy() { - var index = createDebug.instances.indexOf(this); - - if (index !== -1) { - createDebug.instances.splice(index, 1); - return true; - } - - return false; - } - - function extend(namespace, delimiter) { - return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - } - /** - * 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.names = []; - createDebug.skips = []; - var i; - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var 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.substr(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - - for (i = 0; i < createDebug.instances.length; i++) { - var instance = createDebug.instances[i]; - instance.enabled = createDebug.enabled(instance.namespace); - } - } - /** - * Disable debug output. - * - * @api public - */ - - - function disable() { - createDebug.enable(''); - } - /** - * 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; - } - - var i; - var 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; - } - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - - - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - - return val; - } - - createDebug.enable(createDebug.load()); - return createDebug; -} - -module.exports = setup; - diff --git a/node_modules/needle/node_modules/debug/src/index.js b/node_modules/needle/node_modules/debug/src/index.js deleted file mode 100644 index 02173159..00000000 --- a/node_modules/needle/node_modules/debug/src/index.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -/** - * 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'); -} - diff --git a/node_modules/needle/node_modules/debug/src/node.js b/node_modules/needle/node_modules/debug/src/node.js deleted file mode 100644 index 1e6a5f16..00000000 --- a/node_modules/needle/node_modules/debug/src/node.js +++ /dev/null @@ -1,177 +0,0 @@ -"use strict"; - -/** - * Module dependencies. - */ -var tty = require('tty'); - -var 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; -/** - * 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 - var 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(function (key) { - return /^debug_/i.test(key); -}).reduce(function (obj, key) { - // Camel-case - var prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, function (_, k) { - return k.toUpperCase(); - }); // Coerce string value into JS value - - var val = process.env[key]; - - if (/^(yes|on|true|enabled)$/i.test(val)) { - val = true; - } else if (/^(no|off|false|disabled)$/i.test(val)) { - val = false; - } else if (val === 'null') { - val = null; - } else { - val = Number(val); - } - - obj[prop] = val; - return obj; -}, {}); -/** - * 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) { - var name = this.namespace, - useColors = this.useColors; - - if (useColors) { - var c = this.color; - var colorCode = "\x1B[3" + (c < 8 ? c : '8;5;' + c); - var prefix = " ".concat(colorCode, ";1m").concat(name, " \x1B[0m"); - args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + "\x1B[0m"); - } else { - args[0] = getDate() + name + ' ' + args[0]; - } -} - -function getDate() { - if (exports.inspectOpts.hideDate) { - return ''; - } - - return new Date().toISOString() + ' '; -} -/** - * Invokes `util.format()` with the specified arguments and writes to stderr. - */ - - -function log() { - return process.stderr.write(util.format.apply(util, arguments) + '\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 = {}; - var keys = Object.keys(exports.inspectOpts); - - for (var i = 0; i < keys.length; i++) { - debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; - } -} - -module.exports = require('./common')(exports); -var formatters = module.exports.formatters; -/** - * 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(function (str) { return 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); -}; - diff --git a/node_modules/needle/node_modules/ms/index.js b/node_modules/needle/node_modules/ms/index.js deleted file mode 100644 index ea734fb7..00000000 --- a/node_modules/needle/node_modules/ms/index.js +++ /dev/null @@ -1,162 +0,0 @@ -/** - * 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' : ''); -} diff --git a/node_modules/needle/node_modules/ms/license.md b/node_modules/needle/node_modules/ms/license.md deleted file mode 100644 index fa5d39b6..00000000 --- a/node_modules/needle/node_modules/ms/license.md +++ /dev/null @@ -1,21 +0,0 @@ -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. diff --git a/node_modules/needle/node_modules/ms/package.json b/node_modules/needle/node_modules/ms/package.json deleted file mode 100644 index 49971890..00000000 --- a/node_modules/needle/node_modules/ms/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "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" - } -} diff --git a/node_modules/needle/node_modules/ms/readme.md b/node_modules/needle/node_modules/ms/readme.md deleted file mode 100644 index 0fc1abb3..00000000 --- a/node_modules/needle/node_modules/ms/readme.md +++ /dev/null @@ -1,59 +0,0 @@ -# ms - -![CI](https://github.com/vercel/ms/workflows/CI/badge.svg) - -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` diff --git a/node_modules/needle/package.json b/node_modules/needle/package.json deleted file mode 100644 index 195f48f8..00000000 --- a/node_modules/needle/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "needle", - "version": "2.9.1", - "description": "The leanest and most handsome HTTP client in the Nodelands.", - "keywords": [ - "http", - "https", - "simple", - "request", - "client", - "multipart", - "upload", - "proxy", - "deflate", - "timeout", - "charset", - "iconv", - "cookie", - "redirect" - ], - "tags": [ - "http", - "https", - "simple", - "request", - "client", - "multipart", - "upload", - "proxy", - "deflate", - "timeout", - "charset", - "iconv", - "cookie", - "redirect" - ], - "author": "Tomás Pollak ", - "repository": { - "type": "git", - "url": "https://github.com/tomas/needle.git" - }, - "dependencies": { - "debug": "^3.2.6", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - }, - "devDependencies": { - "JSONStream": "^1.3.5", - "jschardet": "^1.6.0", - "mocha": "^5.2.0", - "pump": "^3.0.0", - "q": "^1.5.1", - "should": "^13.2.3", - "sinon": "^2.3.0", - "xml2js": "^0.4.19" - }, - "scripts": { - "test": "mocha test" - }, - "directories": { - "lib": "./lib" - }, - "main": "./lib/needle", - "bin": { - "needle": "./bin/needle" - }, - "license": "MIT", - "engines": { - "node": ">= 4.4.x" - } -} diff --git a/node_modules/needle/test/auth_digest_spec.js b/node_modules/needle/test/auth_digest_spec.js deleted file mode 100644 index 58799f21..00000000 --- a/node_modules/needle/test/auth_digest_spec.js +++ /dev/null @@ -1,192 +0,0 @@ -var needle = require('../'), - auth = require('../lib/auth'), - sinon = require('sinon'), - should = require('should'), - http = require('http'), - helpers = require('./helpers'); - -var createHash = require('crypto').createHash; - -function md5(string) { - return createHash('md5').update(string).digest('hex'); -} - -function parse_header(header) { - var challenge = {}, - matches = header.match(/([a-z0-9_-]+)="?([a-z0-9=\/\.@\s-\+]+)"?/gi); - - for (var i = 0, l = matches.length; i < l; i++) { - var parts = matches[i].split('='), - key = parts.shift(), - val = parts.join('=').replace(/^"/, '').replace(/"$/, ''); - - challenge[key] = val; - } - - return challenge; -} - -describe('auth_digest', function() { - describe('With qop (RFC 2617)', function() { - it('should generate a proper header', function() { - // from https://tools.ietf.org/html/rfc2617 - var performDigest = function() { - var header = 'Digest realm="testrealm@host.com", qop="auth,auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"'; - var user = 'Mufasa'; - var pass = 'Circle Of Life'; - var method = 'get'; - var path = '/dir/index.html'; - - var updatedHeader = auth.digest(header, user, pass, method, path); - var parsedUpdatedHeader = parse_header(updatedHeader); - - var ha1 = md5(user + ':' + parsedUpdatedHeader.realm + ':' + pass); - var ha2 = md5(method.toUpperCase() + ':' + path); - var expectedResponse = md5([ - ha1, - parsedUpdatedHeader.nonce, - parsedUpdatedHeader.nc, - parsedUpdatedHeader.cnonce, - parsedUpdatedHeader.qop, - ha2 - ].join(':')); - - return { - header: updatedHeader, - parsed: parsedUpdatedHeader, - expectedResponse: expectedResponse, - } - } - - const result = performDigest(); - - (result.header).should - .match(/qop="auth"/) - .match(/uri="\/dir\/index.html"/) - .match(/opaque="5ccc069c403ebaf9f0171e9517f40e41"/) - .match(/realm="testrealm@host\.com"/) - .match(/response=/) - .match(/nc=/) - .match(/nonce=/) - .match(/cnonce=/); - - (result.parsed.response).should.be.eql(result.expectedResponse); - }); - }); - - describe('With plus character in nonce header', function() { - it('should generate a proper header', function() { - // from https://tools.ietf.org/html/rfc2617 - var performDigest = function() { - var header = 'Digest realm="testrealm@host.com", qop="auth,auth-int", nonce="dcd98b7102dd2f0e8b11d0f6+00bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"'; - var user = 'Mufasa'; - var pass = 'Circle Of Life'; - var method = 'get'; - var path = '/dir/index.html'; - - var updatedHeader = auth.digest(header, user, pass, method, path); - var parsedUpdatedHeader = parse_header(updatedHeader); - - var ha1 = md5(user + ':' + parsedUpdatedHeader.realm + ':' + pass); - var ha2 = md5(method.toUpperCase() + ':' + path); - var expectedResponse = md5([ - ha1, - parsedUpdatedHeader.nonce, - parsedUpdatedHeader.nc, - parsedUpdatedHeader.cnonce, - parsedUpdatedHeader.qop, - ha2 - ].join(':')); - - return { - header: updatedHeader, - parsed: parsedUpdatedHeader, - expectedResponse: expectedResponse, - } - } - - const result = performDigest(); - - (result.header).should - .match(/nonce="dcd98b7102dd2f0e8b11d0f6\+00bfb0c093"/) - }); - }); - - describe('With brackets in realm header', function() { - it('should generate a proper header', function() { - // from https://tools.ietf.org/html/rfc2617 - var performDigest = function() { - var header = 'Digest qop="auth", realm="IP Camera(76475)", nonce="4e4449794d575269597a706b5a575935595441324d673d3d", stale="FALSE", Basic realm="IP Camera(76475)"'; - var user = 'Mufasa'; - var pass = 'Circle Of Life'; - var method = 'get'; - var path = '/dir/index.html'; - - var updatedHeader = auth.digest(header, user, pass, method, path); - var parsedUpdatedHeader = parse_header(updatedHeader); - - var ha1 = md5(user + ':' + parsedUpdatedHeader.realm + ':' + pass); - var ha2 = md5(method.toUpperCase() + ':' + path); - var expectedResponse = md5([ - ha1, - parsedUpdatedHeader.nonce, - parsedUpdatedHeader.nc, - parsedUpdatedHeader.cnonce, - parsedUpdatedHeader.qop, - ha2 - ].join(':')); - - return { - header: updatedHeader, - parsed: parsedUpdatedHeader, - expectedResponse: expectedResponse, - } - } - - const result = performDigest(); - - (result.header).should - .match(/realm="IP Camera\(76475\)"/) - }); - }); - - describe('Without qop (RFC 2617)', function() { - it('should generate a proper header', function() { - // from https://tools.ietf.org/html/rfc2069 - var performDigest = function() { - var header = 'Digest realm="testrealm@host.com", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"'; - var user = 'Mufasa'; - var pass = 'Circle Of Life'; - var method = 'get'; - var path = '/dir/index.html'; - - var updatedHeader = auth.digest(header, user, pass, method, path); - var parsedUpdatedHeader = parse_header(updatedHeader); - - var ha1 = md5(user + ':' + parsedUpdatedHeader.realm + ':' + pass); - var ha2 = md5(method.toUpperCase() + ':' + path); - var expectedResponse = md5([ha1, parsedUpdatedHeader.nonce, ha2].join(':')); - - return { - header: updatedHeader, - parsed: parsedUpdatedHeader, - expectedResponse: expectedResponse, - } - } - - const result = performDigest(); - - (result.header).should - .not.match(/qop=/) - .match(/uri="\/dir\/index.html"/) - .match(/opaque="5ccc069c403ebaf9f0171e9517f40e41"/) - .match(/realm="testrealm@host\.com"/) - .match(/response=/) - .not.match(/nc=/) - .match(/nonce=/) - .not.match(/cnonce=/); - - (result.parsed.response).should.be.eql(result.expectedResponse); - }); - }); -}) \ No newline at end of file diff --git a/node_modules/needle/test/basic_auth_spec.js b/node_modules/needle/test/basic_auth_spec.js deleted file mode 100644 index 343f1db0..00000000 --- a/node_modules/needle/test/basic_auth_spec.js +++ /dev/null @@ -1,196 +0,0 @@ -var helpers = require('./helpers'), - should = require('should'), - needle = require('./../'), - server; - -var port = 7707; - -describe('Basic Auth', function() { - - before(function(done) { - server = helpers.server({ port: port }, done); - }) - - after(function(done) { - server.close(done); - }) - - ///////////////// helpers - - var get_auth = function(header) { - var token = header.split(/\s+/).pop(); - return token && Buffer.from(token, 'base64').toString().split(':'); - } - - describe('when neither username or password are passed', function() { - - it('doesnt send any Authorization headers', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.not.containEql('authorization'); - done(); - }) - }) - - }) - - describe('when username is an empty string, and password is a valid string', function() { - - var opts = { username: '', password: 'foobar', parse: true }; - - it('doesnt send any Authorization headers', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.not.containEql('authorization'); - done(); - }) - }) - - }); - - describe('when username is a valid string, but no username is passed', function() { - - var opts = { username: 'foobar', parse: true }; - - it('sends Authorization header', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.containEql('authorization'); - done(); - }) - }) - - it('Basic Auth only includes username, without colon', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - var auth = get_auth(sent_headers['authorization']); - auth[0].should.equal('foobar'); - auth.should.have.lengthOf(1); - done(); - }) - }) - - }) - - describe('when username is a valid string, and password is null', function() { - - var opts = { username: 'foobar', password: null, parse: true }; - - it('sends Authorization header', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.containEql('authorization'); - done(); - }) - }) - - it('Basic Auth only includes both username and password', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - var auth = get_auth(sent_headers['authorization']); - auth[0].should.equal('foobar'); - auth[1].should.equal(''); - done(); - }) - }) - - }) - - describe('when username is a valid string, and password is an empty string', function() { - - var opts = { username: 'foobar', password: '', parse: true }; - - it('sends Authorization header', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.containEql('authorization'); - done(); - }) - }) - - it('Basic Auth only includes both username and password', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - var auth = get_auth(sent_headers['authorization']); - auth[0].should.equal('foobar'); - auth[1].should.equal(''); - auth.should.have.lengthOf(2); - done(); - }) - }) - - }) - - describe('when username AND password are non empty strings', function() { - - var opts = { username: 'foobar', password: 'jakub', parse: true }; - - it('sends Authorization header', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.containEql('authorization'); - done(); - }) - }) - - it('Basic Auth only includes both user and password', function(done) { - needle.get('localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - var auth = get_auth(sent_headers['authorization']); - auth[0].should.equal('foobar'); - auth[1].should.equal('jakub'); - auth.should.have.lengthOf(2); - done(); - }) - }) - - }) - - describe('URL with @ but not username/pass', function() { - it('doesnt send Authorization header', function(done) { - var url = 'localhost:' + port + '/abc/@def/xyz.zip'; - - needle.get(url, {}, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.not.containEql('authorization'); - done(); - }) - }) - - it('sends user:pass headers if passed via options', function(done) { - var url = 'localhost:' + port + '/abc/@def/xyz.zip'; - - needle.get(url, { username: 'foo' }, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.containEql('authorization'); - sent_headers['authorization'].should.eql('Basic Zm9v') - done(); - }) - }) - }) - - describe('when username/password are included in URL', function() { - var opts = { parse: true }; - - it('sends Authorization header', function(done) { - needle.get('foobar:jakub@localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - Object.keys(sent_headers).should.containEql('authorization'); - done(); - }) - }) - - it('Basic Auth only includes both user and password', function(done) { - needle.get('foobar:jakub@localhost:' + port, opts, function(err, resp) { - var sent_headers = resp.body.headers; - var auth = get_auth(sent_headers['authorization']); - auth[0].should.equal('foobar'); - auth[1].should.equal('jakub'); - auth.should.have.lengthOf(2); - done(); - }) - }) - - }) - -}) diff --git a/node_modules/needle/test/compression_spec.js b/node_modules/needle/test/compression_spec.js deleted file mode 100644 index 80988be3..00000000 --- a/node_modules/needle/test/compression_spec.js +++ /dev/null @@ -1,112 +0,0 @@ -var should = require('should'), - needle = require('./../'), - http = require('http'), - zlib = require('zlib'), - stream = require('stream'), - port = 11123, - server; - -describe('compression', function(){ - - require.bind(null, 'zlib').should.not.throw() - - var jsonData = '{"foo":"bar"}'; - - describe('when server supports compression', function(){ - - before(function(){ - server = http.createServer(function(req, res) { - var raw = new stream.PassThrough(); - - var acceptEncoding = req.headers['accept-encoding']; - if (!acceptEncoding) { - acceptEncoding = ''; - } - - if (acceptEncoding.match(/\bdeflate\b/)) { - res.setHeader('Content-Encoding', 'deflate'); - raw.pipe(zlib.createDeflate()).pipe(res); - } else if (acceptEncoding.match(/\bgzip\b/)) { - res.setHeader('Content-Encoding', 'gzip'); - raw.pipe(zlib.createGzip()).pipe(res); - } else if (acceptEncoding.match(/\bbr\b/)) { - res.setHeader('Content-Encoding', 'br'); - raw.pipe(zlib.createBrotliCompress()).pipe(res); - } else { - raw.pipe(res); - } - - res.setHeader('Content-Type', 'application/json') - if (req.headers['with-bad']) { - res.end('foo'); // end, no deflate data - } else { - raw.end(jsonData) - } - - }) - - server.listen(port); - }); - - after(function(done){ - server.close(done); - }) - - describe('and client requests no compression', function() { - it('should have the body decompressed', function(done){ - needle.get('localhost:' + port, function(err, response, body){ - should.ifError(err); - body.should.have.property('foo', 'bar'); - response.bytes.should.equal(jsonData.length); - done(); - }) - }) - }) - - describe('and client requests gzip compression', function() { - it('should have the body decompressed', function(done){ - needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'gzip'}}, function(err, response, body){ - should.ifError(err); - body.should.have.property('foo', 'bar'); - response.bytes.should.not.equal(jsonData.length); - done(); - }) - }) - }) - - describe('and client requests deflate compression', function() { - it('should have the body decompressed', function(done){ - needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'deflate'}}, function(err, response, body){ - should.ifError(err); - body.should.have.property('foo', 'bar'); - response.bytes.should.not.equal(jsonData.length); - done(); - }) - }) - - it('should rethrow errors from decompressors', function(done){ - needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'deflate', 'With-Bad': 'true'}}, function(err, response, body) { - should.exist(err); - err.message.should.equal("incorrect header check"); - err.code.should.equal("Z_DATA_ERROR") - done(); - }) - }) - }) - - describe('and client requests brotli compression', function() { - it('should have the body decompressed', function(done){ - // Skip this test if Brotli is not supported - if (typeof zlib.BrotliDecompress !== 'function') { - return done(); - } - needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'br'}}, function(err, response, body){ - should.ifError(err); - body.should.have.property('foo', 'bar'); - response.bytes.should.not.equal(jsonData.length); - done(); - }) - }) - }) - }) -}) diff --git a/node_modules/needle/test/cookies_spec.js b/node_modules/needle/test/cookies_spec.js deleted file mode 100644 index 745f4c71..00000000 --- a/node_modules/needle/test/cookies_spec.js +++ /dev/null @@ -1,396 +0,0 @@ -var needle = require('../'), - cookies = require('../lib/cookies'), - sinon = require('sinon'), - http = require('http'), - should = require('should'); - -var WEIRD_COOKIE_NAME = 'wc', - BASE64_COOKIE_NAME = 'bc', - FORBIDDEN_COOKIE_NAME = 'fc', - NUMBER_COOKIE_NAME = 'nc'; - -var WEIRD_COOKIE_VALUE = '!\'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~', - BASE64_COOKIE_VALUE = 'Y29va2llCg==', - FORBIDDEN_COOKIE_VALUE = ' ;"\\,', - NUMBER_COOKIE_VALUE = 12354342; - -var NO_COOKIES_TEST_PORT = 11112, - ALL_COOKIES_TEST_PORT = 11113; - -describe('cookies', function() { - - var setCookieHeader, headers, server, opts; - - function decode(str) { - return decodeURIComponent(str); - } - - function encode(str) { - str = str.toString().replace(/[\x00-\x1F\x7F]/g, encodeURIComponent); - return str.replace(/[\s\"\,;\\%]/g, encodeURIComponent); - } - - before(function() { - setCookieHeader = [ - WEIRD_COOKIE_NAME + '=' + encode(WEIRD_COOKIE_VALUE) + ';', - BASE64_COOKIE_NAME + '=' + encode(BASE64_COOKIE_VALUE) + ';', - FORBIDDEN_COOKIE_NAME + '=' + encode(FORBIDDEN_COOKIE_VALUE) + ';', - NUMBER_COOKIE_NAME + '=' + encode(NUMBER_COOKIE_VALUE) + ';' - ]; - }); - - before(function(done) { - serverAllCookies = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'text/html'); - res.setHeader('Set-Cookie', setCookieHeader); - res.end('200'); - }).listen(ALL_COOKIES_TEST_PORT, done); - }); - - after(function(done) { - serverAllCookies.close(done); - }); - - describe('with default options', function() { - it('no cookie header is set on request', function(done) { - needle.get( - 'localhost:' + ALL_COOKIES_TEST_PORT, function(err, response) { - should.not.exist(response.req._headers.cookie); - done(); - }); - }); - }); - - describe('if response does not contain cookies', function() { - before(function(done) { - serverNoCookies = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'text/html'); - res.end('200'); - }).listen(NO_COOKIES_TEST_PORT, done); - }); - - it('response.cookies is undefined', function(done) { - needle.get( - 'localhost:' + NO_COOKIES_TEST_PORT, function(error, response) { - should.not.exist(response.cookies); - done(); - }); - }); - - after(function(done) { - serverNoCookies.close(done); - }); - }); - - describe('if response contains cookies', function() { - - it('puts them on resp.cookies', function(done) { - needle.get( - 'localhost:' + ALL_COOKIES_TEST_PORT, function(error, response) { - response.should.have.property('cookies'); - done(); - }); - }); - - it('parses them as a object', function(done) { - needle.get( - 'localhost:' + ALL_COOKIES_TEST_PORT, function(error, response) { - response.cookies.should.be.an.instanceOf(Object) - .and.have.property(WEIRD_COOKIE_NAME); - response.cookies.should.have.property(BASE64_COOKIE_NAME); - response.cookies.should.have.property(FORBIDDEN_COOKIE_NAME); - response.cookies.should.have.property(NUMBER_COOKIE_NAME); - done(); - }); - }); - - it('must decode it', function(done) { - needle.get( - 'localhost:' + ALL_COOKIES_TEST_PORT, function(error, response) { - response.cookies.wc.should.be.eql(WEIRD_COOKIE_VALUE); - response.cookies.bc.should.be.eql(BASE64_COOKIE_VALUE); - response.cookies.fc.should.be.eql(FORBIDDEN_COOKIE_VALUE); - response.cookies.nc.should.be.eql(NUMBER_COOKIE_VALUE.toString()); - done(); - }); - }); - - describe('when a cookie value is invalid', function() { - - before(function() { - setCookieHeader = [ - 'geo_city=%D1%E0%ED%EA%F2-%CF%E5%F2%E5%F0%E1%F3%F0%E3' - ]; - }) - - it('doesnt blow up', function(done) { - needle.get('localhost:' + ALL_COOKIES_TEST_PORT, function(error, response) { - should.not.exist(error) - var whatever = 'efbfbdefbfbdefbfbdefbfbdefbfbd2defbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbd'; - Buffer.from(response.cookies.geo_city).toString('hex').should.eql(whatever) - done(); - }); - }) - - }) - - describe('and response is a redirect', function() { - - var redirectServer, testPort = 22222; - var requestCookies = []; - - var responseCookies = [ - [ // first req - WEIRD_COOKIE_NAME + '=' + encode(WEIRD_COOKIE_VALUE) + ';', - BASE64_COOKIE_NAME + '=' + encode(BASE64_COOKIE_VALUE) + ';', - 'FOO=123;' - ], [ // second req - FORBIDDEN_COOKIE_NAME + '=' + encode(FORBIDDEN_COOKIE_VALUE) + ';', - NUMBER_COOKIE_NAME + '=' + encode(NUMBER_COOKIE_VALUE) + ';' - ], [ // third red - 'FOO=BAR;' - ] - ] - - before(function(done) { - redirectServer = http.createServer(function(req, res) { - var number = parseInt(req.url.replace('/', '')); - var nextUrl = 'http://' + 'localhost:' + testPort + '/' + (number + 1); - - if (number == 0) requestCookies = []; // reset - requestCookies.push(req.headers['cookie']); - - if (responseCookies[number]) { // we should send cookies for this request - res.statusCode = 302; - res.setHeader('Set-Cookie', responseCookies[number]); - res.setHeader('Location', nextUrl); - } else if (number == 3) { - res.statusCode = 302; // redirect but without cookies - res.setHeader('Location', nextUrl); - } - - res.end('OK'); - }).listen(22222, done); - }); - - after(function(done) { - redirectServer.close(done); - }) - - describe('and follow_set_cookies is false', function() { - - describe('with original request cookie', function() { - - var opts = { - follow_set_cookies: false, - follow_max: 4, - cookies: { 'xxx': 123 } - }; - - it('request cookie is not passed to redirects', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - requestCookies.should.eql(["xxx=123", undefined, undefined, undefined, undefined]) - done(); - }); - }); - - it('response cookies are not passed either', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - should.not.exist(resp.cookies); - done(); - }); - }); - - }) - - describe('without original request cookie', function() { - - var opts = { - follow_set_cookies: false, - follow_max: 4, - }; - - it('no request cookies are sent', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - requestCookies.should.eql([undefined, undefined, undefined, undefined, undefined]) - done(); - }); - }); - - it('response cookies are not passed either', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - should.not.exist(resp.cookies); - done(); - }); - }); - - }) - - }); - - describe('and follow_set_cookies is true', function() { - - describe('with original request cookie', function() { - - var opts = { - follow_set_cookies: true, - follow_max: 4, - cookies: { 'xxx': 123 } - }; - - it('request cookie is passed passed to redirects, and response cookies are added too', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - requestCookies.should.eql([ - "xxx=123", - "xxx=123; wc=!'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=123", - "xxx=123; wc=!\'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=123; fc=%20%3B%22%5C%2C; nc=12354342", - "xxx=123; wc=!\'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=BAR; fc=%20%3B%22%5C%2C; nc=12354342", - "xxx=123; wc=!\'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=BAR; fc=%20%3B%22%5C%2C; nc=12354342" - ]) - done(); - }); - }); - - it('response cookies are passed as well', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - resp.cookies.should.have.property(WEIRD_COOKIE_NAME); - resp.cookies.should.have.property(BASE64_COOKIE_NAME); - resp.cookies.should.have.property(FORBIDDEN_COOKIE_NAME); - resp.cookies.should.have.property(NUMBER_COOKIE_NAME); - resp.cookies.should.have.property('FOO'); - resp.cookies.FOO.should.eql('BAR'); // should overwrite previous one - done(); - }); - }); - - }) - - describe('without original request cookie', function() { - - var opts = { - follow_set_cookies: true, - follow_max: 4, - }; - - it('response cookies are passed to redirects', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - requestCookies.should.eql([ - undefined, - "wc=!'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=123", - "wc=!\'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=123; fc=%20%3B%22%5C%2C; nc=12354342", - "wc=!\'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=BAR; fc=%20%3B%22%5C%2C; nc=12354342", - "wc=!\'*+#()&-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~; bc=Y29va2llCg==; FOO=BAR; fc=%20%3B%22%5C%2C; nc=12354342" - ]) - done(); - }); - }); - - it('response cookies are passed as well', function(done) { - needle.get('localhost:' + testPort + '/0', opts, function(err, resp) { - // resp.cookies.should.have.property(WEIRD_COOKIE_NAME); - // resp.cookies.should.have.property(BASE64_COOKIE_NAME); - // resp.cookies.should.have.property(FORBIDDEN_COOKIE_NAME); - // resp.cookies.should.have.property(NUMBER_COOKIE_NAME); - // resp.cookies.should.have.property('FOO'); - // resp.cookies.FOO.should.eql('BAR'); // should overwrite previous one - done(); - }); - }); - - }) - - }); - }); - - describe('with parse_cookies = false', function() { - it('does not parse them', function(done) { - needle.get( - 'localhost:' + ALL_COOKIES_TEST_PORT, { parse_cookies: false }, function(error, response) { - should.not.exist(response.cookies); - done(); - }); - }); - }); - }); - - describe('if request contains cookie header', function() { - var opts = { - cookies: {} - }; - - before(function() { - opts.cookies[WEIRD_COOKIE_NAME] = WEIRD_COOKIE_VALUE; - opts.cookies[BASE64_COOKIE_NAME] = BASE64_COOKIE_VALUE; - opts.cookies[FORBIDDEN_COOKIE_NAME] = FORBIDDEN_COOKIE_VALUE; - opts.cookies[NUMBER_COOKIE_NAME] = NUMBER_COOKIE_VALUE; - }); - - it('must be a valid cookie string', function(done) { - var COOKIE_PAIR = /^([^=\s]+)\s*=\s*("?)\s*(.*)\s*\2\s*$/; - - var full_header = [ - WEIRD_COOKIE_NAME + '=' + WEIRD_COOKIE_VALUE, - BASE64_COOKIE_NAME + '=' + BASE64_COOKIE_VALUE, - FORBIDDEN_COOKIE_NAME + '=' + encode(FORBIDDEN_COOKIE_VALUE), - NUMBER_COOKIE_NAME + '=' + NUMBER_COOKIE_VALUE - ].join('; ') - - needle.get('localhost:' + ALL_COOKIES_TEST_PORT, opts, function(error, response) { - var cookieString = response.req._headers.cookie; - cookieString.should.be.type('string'); - - cookieString.split(/\s*;\s*/).forEach(function(pair) { - COOKIE_PAIR.test(pair).should.be.exactly(true); - }); - - cookieString.should.be.exactly(full_header); - done(); - }); - }); - - it('dont have to encode allowed characters', function(done) { - var COOKIE_PAIR = /^([^=\s]+)\s*=\s*("?)\s*(.*)\s*\2\s*$/, - KEY_INDEX = 1, - VALUE_INEX = 3; - - needle.get('localhost:' + ALL_COOKIES_TEST_PORT, opts, function(error, response) { - var cookieObj = {}, - cookieString = response.req._headers.cookie; - - cookieString.split(/\s*;\s*/).forEach(function(str) { - var pair = COOKIE_PAIR.exec(str); - cookieObj[pair[KEY_INDEX]] = pair[VALUE_INEX]; - }); - - cookieObj[WEIRD_COOKIE_NAME].should.be.exactly(WEIRD_COOKIE_VALUE); - cookieObj[BASE64_COOKIE_NAME].should.be.exactly(BASE64_COOKIE_VALUE); - done(); - }); - }); - - it('must encode forbidden characters', function(done) { - var COOKIE_PAIR = /^([^=\s]+)\s*=\s*("?)\s*(.*)\s*\2\s*$/, - KEY_INDEX = 1, - VALUE_INEX = 3; - - needle.get('localhost:' + ALL_COOKIES_TEST_PORT, opts, function(error, response) { - var cookieObj = {}, - cookieString = response.req._headers.cookie; - - cookieString.split(/\s*;\s*/).forEach(function(str) { - var pair = COOKIE_PAIR.exec(str); - cookieObj[pair[KEY_INDEX]] = pair[VALUE_INEX]; - }); - - cookieObj[FORBIDDEN_COOKIE_NAME].should.not.be.eql( - FORBIDDEN_COOKIE_VALUE); - cookieObj[FORBIDDEN_COOKIE_NAME].should.be.exactly( - encode(FORBIDDEN_COOKIE_VALUE)); - cookieObj[FORBIDDEN_COOKIE_NAME].should.be.exactly( - encodeURIComponent(FORBIDDEN_COOKIE_VALUE)); - done(); - }); - }); - }); - -}); diff --git a/node_modules/needle/test/decoder_spec.js b/node_modules/needle/test/decoder_spec.js deleted file mode 100644 index db38821d..00000000 --- a/node_modules/needle/test/decoder_spec.js +++ /dev/null @@ -1,121 +0,0 @@ -var should = require('should'), - needle = require('./../'), - Q = require('q'), - chardet = require('jschardet'), - helpers = require('./helpers'); - -describe('character encoding', function() { - - var url; - this.timeout(5000); - - describe('Given content-type: "text/html; charset=EUC-JP"', function() { - - before(function() { - url = 'http://www.nina.jp/server/slackware/webapp/tomcat_charset.html'; - }) - - describe('with decode = false', function() { - - it('does not decode', function(done) { - - needle.get(url, { decode: false }, function(err, resp) { - resp.body.should.be.a.String; - chardet.detect(resp.body).encoding.should.eql('windows-1252'); - resp.body.indexOf('EUCを使う').should.eql(-1); - done(); - }) - - }) - - }) - - describe('with decode = true', function() { - - it('decodes', function(done) { - - needle.get(url, { decode: true }, function(err, resp) { - resp.body.should.be.a.String; - chardet.detect(resp.body).encoding.should.eql('ascii'); - resp.body.indexOf('EUCを使う').should.not.eql(-1); - done(); - }) - - }) - - }) - - }) - - describe('Given content-type: "text/html but file is charset: gb2312', function() { - - it('encodes to UTF-8', function(done) { - - // Our Needle wrapper that requests a chinese website. - var task = Q.nbind(needle.get, needle, 'http://www.chinesetop100.com/'); - - // Different instantiations of this task - var tasks = [Q.fcall(task, {decode: true}), - Q.fcall(task, {decode: false})]; - - var results = tasks.map(function(task) { - return task.then(function(obj) { - return obj[0].body; - }); - }); - - // Execute all requests concurrently - Q.all(results).done(function(bodies) { - - var charsets = [ - chardet.detect(bodies[0]).encoding, - chardet.detect(bodies[1]).encoding, - ] - - // We wanted to decode our first stream as specified by options - charsets[0].should.equal('ascii'); - bodies[0].indexOf('全球中文网站前二十强').should.not.equal(-1); - - // But not our second stream - charsets[1].should.equal('windows-1252'); - bodies[1].indexOf('全球中文网站前二十强').should.equal(-1); - - done(); - }); - }) - }) - - describe('Given content-type: "text/html"', function () { - - var server, - port = 54321, - text = 'Magyarországi Fióktelepe' - - before(function(done) { - server = helpers.server({ - port: port, - response: text, - headers: { 'Content-Type': 'text/html' } - }, done); - }) - - after(function(done) { - server.close(done) - }) - - describe('with decode = false', function () { - it('decodes by default to utf-8', function (done) { - - needle.get('http://localhost:' + port, { decode: false }, function (err, resp) { - resp.body.should.be.a.String; - chardet.detect(resp.body).encoding.should.eql('ISO-8859-2'); - resp.body.should.eql('Magyarországi Fióktelepe') - done(); - }) - - }) - - }) - - }) -}) diff --git a/node_modules/needle/test/errors_spec.js b/node_modules/needle/test/errors_spec.js deleted file mode 100644 index c1956814..00000000 --- a/node_modules/needle/test/errors_spec.js +++ /dev/null @@ -1,272 +0,0 @@ -var needle = require('../'), - sinon = require('sinon'), - should = require('should'), - http = require('http'), - Emitter = require('events').EventEmitter, - helpers = require('./helpers'); - -var get_catch = function(url, opts) { - var err; - try { - needle.get(url, opts); - } catch(e) { - err = e; - } - return err; -} - -describe('errors', function() { - - after(function(done) { - setTimeout(done, 100) - }) - - describe('when host does not exist', function() { - - var url = 'http://unexistinghost/foo'; - - describe('with callback', function() { - - it('does not throw', function() { - var ex = get_catch(url); - should.not.exist(ex); - }) - - it('callbacks an error', function(done) { - needle.get(url, function(err) { - err.should.be.a.Error; - done(); - }) - }) - - it('error should be ENOTFOUND or EADDRINFO or EAI_AGAIN', function(done) { - needle.get(url, function(err) { - err.code.should.match(/ENOTFOUND|EADDRINFO|EAI_AGAIN/) - done(); - }) - }) - - it('does not callback a response', function(done) { - needle.get(url, function(err, resp) { - should.not.exist(resp); - done(); - }) - }) - - it('does not emit an error event', function(done) { - var emitted = false; - var req = needle.get(url, function(err, resp) { }) - - req.on('error', function() { - emitted = true; - }) - - setTimeout(function() { - emitted.should.eql(false); - done(); - }, 100); - }) - - }) - - describe('without callback', function() { - - it('does not throw', function() { - var ex = get_catch(url); - should.not.exist(ex); - }) - - it('emits end event once, with error', function(done) { - var callcount = 0, - stream = needle.get(url); - - stream.on('done', function(err) { - err.code.should.match(/ENOTFOUND|EADDRINFO|EAI_AGAIN/) - callcount++; - }) - - setTimeout(function() { - callcount.should.equal(1); - done(); - }, 200) - }) - - it('does not emit a readable event', function(done) { - var called = false, - stream = needle.get(url); - - stream.on('readable', function() { - called = true; - }) - - stream.on('done', function(err) { - called.should.be.false; - done(); - }) - }) - - it('does not emit an error event', function(done) { - var emitted = false, - stream = needle.get(url); - - stream.on('error', function() { - emitted = true; - }) - - stream.on('done', function(err) { - emitted.should.eql(false); - done(); - }) - }) - - }) - - }) - - describe('when request times out waiting for response', function() { - - var server, - url = 'http://localhost:3333/foo'; - - var send_request = function(cb) { - return needle.get(url, { response_timeout: 200 }, cb); - } - - before(function() { - server = helpers.server({ port: 3333, wait: 1000 }); - }) - - after(function() { - server.close(); - }) - - describe('with callback', function() { - - it('aborts the request', function(done) { - - var time = new Date(); - - send_request(function(err) { - var timediff = (new Date() - time); - timediff.should.be.within(200, 300); - done(); - }) - - }) - - it('callbacks an error', function(done) { - send_request(function(err) { - err.should.be.a.Error; - done(); - }) - }) - - it('error should be ECONNRESET', function(done) { - send_request(function(err) { - err.code.should.equal('ECONNRESET') - done(); - }) - }) - - it('does not callback a response', function(done) { - send_request(function(err, resp) { - should.not.exist(resp); - done(); - }) - }) - - it('does not emit an error event', function(done) { - var emitted = false; - - var req = send_request(function(err, resp) { - should.not.exist(resp); - }) - - req.on('error', function() { - emitted = true; - }) - - setTimeout(function() { - emitted.should.eql(false); - done(); - }, 350); - }) - - }) - - describe('without callback', function() { - - it('emits done event once, with error', function(done) { - var error, - called = 0, - stream = send_request(); - - stream.on('done', function(err) { - err.code.should.equal('ECONNRESET'); - called++; - }) - - setTimeout(function() { - called.should.equal(1); - done(); - }, 250) - }) - - it('aborts the request', function(done) { - - var time = new Date(); - var stream = send_request(); - - stream.on('done', function(err) { - var timediff = (new Date() - time); - timediff.should.be.within(200, 300); - done(); - }) - - }) - - it('error should be ECONNRESET', function(done) { - var error, - stream = send_request(); - - stream.on('done', function(err) { - err.code.should.equal('ECONNRESET') - done(); - }) - }) - - it('does not emit a readable event', function(done) { - var called = false, - stream = send_request(); - - stream.on('readable', function() { - called = true; - }) - - stream.on('done', function(err) { - called.should.be.false; - done(); - }) - }) - - it('does not emit an error event', function(done) { - var emitted = false; - var stream = send_request(); - - stream.on('error', function() { - emitted = true; - }) - - stream.on('done', function(err) { - err.should.be.a.Error; - err.code.should.equal('ECONNRESET') - emitted.should.eql(false); - done(); - }) - }) - - }) - - }) - -}) diff --git a/node_modules/needle/test/headers_spec.js b/node_modules/needle/test/headers_spec.js deleted file mode 100644 index a5c17e62..00000000 --- a/node_modules/needle/test/headers_spec.js +++ /dev/null @@ -1,203 +0,0 @@ -var http = require('http'), - helpers = require('./helpers'), - should = require('should'); - -var port = 54321; - -describe('request headers', function() { - - var needle, - server, - existing_sockets, - original_defaultMaxSockets; - - before(function(done) { - setTimeout(function() { - existing_sockets = get_active_sockets().length; - server = helpers.server({ port: port }, done); - }, 100); - }) - - after(function(done) { - server.close(done); - }) - - function send_request(opts, cb) { - needle.get('http://localhost:' + port, opts, cb); - } - - function get_active_sockets() { - var handles = process._getActiveHandles(); - - return handles.filter(function(el) { - if (el.constructor.name.toString() == 'Socket') { - return el.destroyed !== true; - } - }) - } - - describe('old node versions (<0.11.4) with persistent keep-alive connections', function() { - - before(function() { - delete require.cache[require.resolve('..')] // in case it was already loaded - original_defaultMaxSockets = http.Agent.defaultMaxSockets; - http.Agent.defaultMaxSockets = 5; - needle = require('..'); - }) - - after(function() { - http.Agent.defaultMaxSockets = original_defaultMaxSockets; - delete require.cache[require.resolve('..')] - }) - - describe('default options', function() { - - it('sends a Connection: close header', function(done) { - send_request({}, function(err, resp) { - resp.body.headers['connection'].should.eql('close'); - done(); - }) - }) - - it('no open sockets remain after request', function(done) { - send_request({}, function(err, resp) { - setTimeout(function() { - get_active_sockets().length.should.eql(existing_sockets); - done(); - }, 10) - }); - }) - - }) - - describe('passing connection: close', function() { - - it('sends a Connection: close header', function(done) { - send_request({ connection: 'close' }, function(err, resp) { - resp.body.headers['connection'].should.eql('close'); - done(); - }) - }) - - it('no open sockets remain after request', function(done) { - send_request({ connection: 'close' }, function(err, resp) { - setTimeout(function() { - get_active_sockets().length.should.eql(existing_sockets); - done(); - }, 10) - }); - }) - - }) - - describe('passing connection: keep-alive', function() { - - it('sends a Connection: keep-alive header (using options.headers.connection)', function(done) { - send_request({ headers: { connection: 'keep-alive' }}, function(err, resp) { - resp.body.headers['connection'].should.eql('keep-alive'); - done(); - }) - }) - - it('sends a Connection: keep-alive header (using options.connection)', function(done) { - send_request({ connection: 'keep-alive' }, function(err, resp) { - resp.body.headers['connection'].should.eql('keep-alive'); - done(); - }) - }) - - it('one open socket remain after request', function(done) { - send_request({ connection: 'keep-alive' }, function(err, resp) { - get_active_sockets().length.should.eql(existing_sockets + 1); - done(); - }); - }) - - }) - - }) - - describe('new node versions with smarter connection disposing', function() { - - before(function() { - delete require.cache[require.resolve('..')] - original_defaultMaxSockets = http.Agent.defaultMaxSockets; - http.Agent.defaultMaxSockets = Infinity; - needle = require('..'); - }) - - after(function() { - http.Agent.defaultMaxSockets = original_defaultMaxSockets; - delete require.cache[require.resolve('..')] - }) - - describe('default options', function() { - - // TODO: - // this is weird. by default, new node versions set a 'close' header - // while older versions set a keep-alive header - - it.skip('sets a Connection header', function(done) { - send_request({}, function(err, resp) { - // should.not.exist(resp.body.headers['connection']); - // done(); - }) - }) - - it.skip('one open sockets remain after request', function(done) { - send_request({}, function(err, resp) { - // get_active_sockets().length.should.eql(1); - // done(); - }); - }) - - }) - - describe('passing connection: close', function() { - - it('sends a Connection: close header', function(done) { - send_request({ connection: 'close' }, function(err, resp) { - resp.body.headers['connection'].should.eql('close'); - done(); - }) - }) - - it('no open sockets remain after request', function(done) { - send_request({ connection: 'close' }, function(err, resp) { - setTimeout(function() { - get_active_sockets().length.should.eql(existing_sockets); - done(); - }, 10); - }); - }) - - }) - - describe('passing connection: keep-alive', function() { - - it('sends a Connection: keep-alive header (using options.headers.connection)', function(done) { - send_request({ headers: { connection: 'keep-alive' }}, function(err, resp) { - resp.body.headers['connection'].should.eql('keep-alive'); - done(); - }) - }) - - it('sends a Connection: keep-alive header (using options.connection)', function(done) { - send_request({ connection: 'keep-alive' }, function(err, resp) { - resp.body.headers['connection'].should.eql('keep-alive'); - done(); - }) - }) - - it('one open socket remain after request', function(done) { - send_request({ connection: 'keep-alive' }, function(err, resp) { - get_active_sockets().length.should.eql(existing_sockets + 1); - done(); - }); - }) - - }) - - }) - -}) diff --git a/node_modules/needle/test/helpers.js b/node_modules/needle/test/helpers.js deleted file mode 100644 index 613ff578..00000000 --- a/node_modules/needle/test/helpers.js +++ /dev/null @@ -1,74 +0,0 @@ -var fs = require('fs'); - -var protocols = { - http : require('http'), - https : require('https') -} - -var keys = { - cert : fs.readFileSync(__dirname + '/keys/ssl.cert'), - key : fs.readFileSync(__dirname + '/keys/ssl.key') -} - -var helpers = {}; - -helpers.server = function(opts, cb) { - - var defaults = { - code : 200, - headers : {'Content-Type': 'application/json'} - } - - var mirror_response = function(req) { - return JSON.stringify({ - headers: req.headers, - body: req.body - }) - } - - var get = function(what) { - if (!opts[what]) - return defaults[what]; - - if (typeof opts[what] == 'function') - return opts[what](); // set them at runtime - else - return opts[what]; - } - - var finish = function(req, res) { - if (opts.handler) return opts.handler(req, res); - - res.writeHead(get('code'), get('headers')); - res.end(opts.response || mirror_response(req)); - } - - var handler = function(req, res) { - - req.setEncoding('utf8'); // get as string - req.body = ''; - req.on('data', function(str) { req.body += str }) - req.socket.on('error', function(e) { - // res.writeHead(500, {'Content-Type': 'text/plain'}); - // res.end('Error: ' + e.message); - }) - - setTimeout(function(){ - finish(req, res); - }, opts.wait || 0); - - }; - - var protocol = opts.protocol || 'http'; - var server; - - if (protocol == 'https') - server = protocols[protocol].createServer(keys, handler); - else - server = protocols[protocol].createServer(handler); - - server.listen(opts.port, cb); - return server; -} - -module.exports = helpers; \ No newline at end of file diff --git a/node_modules/needle/test/long_string_spec.js b/node_modules/needle/test/long_string_spec.js deleted file mode 100644 index 4f2fa736..00000000 --- a/node_modules/needle/test/long_string_spec.js +++ /dev/null @@ -1,43 +0,0 @@ -var needle = require('../'), - should = require('should'); - -describe('when posting a very long string', function() { - - this.timeout(20000); - - function get_string(length) { - var str = ''; - for (var i = 0; i < length; i++) { - str += 'x'; - } - return str; - } - - var major_version = process.version.split('.')[0]; - - it("shouldn't throw an EPIPE error out of nowhere", function(done) { - - // for some reason this test fails in Github Actions with Node v8.x - // although in my Linux box passes without issues - if (process.env.CI && (major_version == 'v8' || major_version == 'v6')) { - return done(); - } - - var error; - - function finished() { - setTimeout(function() { - should.not.exist(error); - done(); - }, 300); - } - - try { - needle.post('https://google.com', { data: get_string(Math.pow(2, 20)) }, finished) - } catch(e) { - error = e; - } - - }) - -}) diff --git a/node_modules/needle/test/mimetype.js b/node_modules/needle/test/mimetype.js deleted file mode 100644 index dbeaf295..00000000 --- a/node_modules/needle/test/mimetype.js +++ /dev/null @@ -1,81 +0,0 @@ -var should = require('should'), - needle = require('./../'), - helpers = require('./helpers'); - -describe('receiving json and xml content as string', function() { - - this.timeout(5000); - - ["text/plain", "application/json", "application/ld+json", "application/xml", "image/svg+xml"].forEach(function(mimetype, offset){ - - describe('Given content-type: "'+mimetype+'"', function () { - - var server, port = 54330+offset; - - before(function(done) { - server = helpers.server({ - port: port, - response: 'content', - headers: { 'Content-Type': mimetype } - }, done); - }) - - after(function(done) { - server.close(done) - }) - - describe('with parse = false', function () { - it('delivers by default as string', function (done) { - - needle.get('http://localhost:' + port, { parse: false }, function (err, resp) { - - resp.body.should.be.a.String; - (typeof resp.body).should.eql('string') - done(); - }) - - }) - - }) - - }) - - }); - - ["application/octet-stream", "image/png"].forEach(function(mimetype, offset){ - - describe('Given content-type: "'+mimetype+'"', function () { - - var server, port = 54340+offset; - - before(function(done) { - server = helpers.server({ - port: port, - response: 'content', - headers: { 'Content-Type': mimetype } - }, done); - }) - - after(function(done) { - server.close(done) - }) - - describe('with parse = false', function () { - it('delivers by default as Buffer', function (done) { - - needle.get('http://localhost:' + port, { parse: false }, function (err, resp) { - - resp.body.should.be.a.Buffer; - (resp.body instanceof Buffer).should.eql(true) - done(); - }) - - }) - - }) - - }) - - }) - -}) diff --git a/node_modules/needle/test/output_spec.js b/node_modules/needle/test/output_spec.js deleted file mode 100644 index 14fc5bb0..00000000 --- a/node_modules/needle/test/output_spec.js +++ /dev/null @@ -1,254 +0,0 @@ -var should = require('should'), - needle = require('./../'), - http = require('http'), - sinon = require('sinon'), - stream = require('stream'), - fs = require('fs'), - port = 11111, - server; - -describe('with output option', function() { - - var server, handler, file = '/tmp/foobar.out'; - - function send_request_cb(where, cb) { - var url = 'http://localhost:' + port + '/whatever.file'; - return needle.get(url, { output: where }, cb); - } - - function send_request_stream(where, cb) { - var url = 'http://localhost:' + port + '/whatever.file'; - var stream = needle.get(url, { output: where }); - stream.on('end', cb); - } - - // this will only work in UNICES - function get_open_file_descriptors() { - var list = fs.readdirSync('/proc/self/fd'); - return list.length; - } - - var send_request = send_request_cb; - - before(function(){ - server = http.createServer(function(req, res) { - handler(req, res); - }).listen(port); - }); - - after(function() { - server.close(); - }) - - beforeEach(function() { - try { fs.unlinkSync(file) } catch(e) { }; - }) - - describe('and a 404 response', function() { - - before(function() { - handler = function(req, res) { - res.writeHead(404, {'Content-Type': 'text/plain' }); - res.end(); - } - }) - - it('doesnt attempt to write a file', function(done) { - var spy = sinon.spy(fs, 'createWriteStream'); - send_request(file, function(err, resp) { - resp.statusCode.should.eql(404); - spy.called.should.eql(false); - spy.restore(); - done(); - }) - }) - - it('doesnt actually write a file', function(done) { - send_request(file, function(err, resp) { - resp.statusCode.should.eql(404); - fs.existsSync(file).should.eql(false); - done(); - }) - }) - - }) - - describe('and a 200 response', function() { - - describe('for an empty response', function() { - - before(function() { - handler = function(req, res) { - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.end(); - } - }) - - it('uses a writableStream', function(done) { - var spy = sinon.spy(fs, 'createWriteStream'); - send_request(file, function(err, resp) { - resp.statusCode.should.eql(200); - spy.called.should.eql(true); - spy.restore(); - done(); - }) - }) - - it('writes a file', function(done) { - fs.existsSync(file).should.eql(false); - send_request(file, function(err, resp) { - fs.existsSync(file).should.eql(true); - done(); - }) - }) - - it('file is zero bytes in length', function(done) { - send_request(file, function(err, resp) { - fs.statSync(file).size.should.equal(0); - done(); - }) - }) - - if (process.platform != 'win32') { - it('closes the file descriptor', function(done) { - var open_descriptors = get_open_file_descriptors(); - send_request(file + Math.random(), function(err, resp) { - var current_descriptors = get_open_file_descriptors(); - open_descriptors.should.eql(current_descriptors); - done() - }) - }) - } - - }) - - describe('for a JSON response', function() { - - before(function() { - handler = function(req, res) { - res.writeHead(200, { 'Content-Type': 'application/javascript' }); - res.end(JSON.stringify({foo: 'bar'})); - } - }) - - it('uses a writableStream', function(done) { - var spy = sinon.spy(fs, 'createWriteStream'); - send_request(file, function(err, resp) { - resp.statusCode.should.eql(200); - spy.called.should.eql(true); - spy.restore(); - done(); - }) - }) - - it('writes a file', function(done) { - fs.existsSync(file).should.eql(false); - send_request(file, function(err, resp) { - fs.existsSync(file).should.eql(true); - done(); - }) - }) - - it('file size equals response length', function(done) { - send_request(file, function(err, resp) { - fs.statSync(file).size.should.equal(resp.bytes); - done(); - }) - }) - - it('response pipeline is honoured (JSON is decoded by default)', function(done) { - send_request_stream(file, function(err, resp) { - // we need to wait a bit since writing to config.output - // happens independently of needle's callback logic. - setTimeout(function() { - fs.readFileSync(file).toString().should.eql('{\"foo\":\"bar\"}'); - done(); - }, 20); - }) - }) - - it('closes the file descriptor', function(done) { - var open_descriptors = get_open_file_descriptors(); - send_request(file + Math.random(), function(err, resp) { - var current_descriptors = get_open_file_descriptors(); - open_descriptors.should.eql(current_descriptors); - done() - }) - }) - - }) - - describe('for a binary file', function() { - - var pixel = Buffer.from("base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs", "base64"); - - before(function() { - handler = function(req, res) { - res.writeHead(200, { 'Content-Type': 'application/octet-stream', 'Transfer-Encoding': 'chunked' }); - res.write(pixel.slice(0, 10)); - res.write(pixel.slice(10, 20)); - res.write(pixel.slice(20, 30)); - res.write(pixel.slice(30)); - res.end(); - } - }) - - it('uses a writableStream', function(done) { - var spy = sinon.spy(fs, 'createWriteStream'); - send_request(file, function(err, resp) { - resp.statusCode.should.eql(200); - spy.called.should.eql(true); - spy.restore(); - done(); - }) - }) - - it('writes a file', function(done) { - fs.existsSync(file).should.eql(false); - send_request(file, function(err, resp) { - fs.existsSync(file).should.eql(true); - done(); - }) - }) - - it('file size equals response length', function(done) { - send_request(file, function(err, resp) { - fs.statSync(file).size.should.equal(resp.bytes); - done(); - }) - }) - - it('file is equal to original buffer', function(done) { - send_request(file, function(err, resp) { - // we need to wait a bit since writing to config.output - // happens independently of needle's callback logic. - setTimeout(function() { - fs.readFileSync(file).should.eql(pixel); - done(); - }, 20); - }) - }) - - it('returns the data in resp.body too', function(done) { - send_request(file, function(err, resp) { - resp.body.should.eql(pixel); - done(); - }) - }) - - if (process.platform != 'win32') { - it('closes the file descriptor', function(done) { - var open_descriptors = get_open_file_descriptors(); - send_request(file + Math.random(), function(err, resp) { - var current_descriptors = get_open_file_descriptors(); - open_descriptors.should.eql(current_descriptors); - done() - }) - }) - } - - }) - - }) - -}) diff --git a/node_modules/needle/test/parsing_spec.js b/node_modules/needle/test/parsing_spec.js deleted file mode 100644 index b32bfb1e..00000000 --- a/node_modules/needle/test/parsing_spec.js +++ /dev/null @@ -1,547 +0,0 @@ -var should = require('should'), - needle = require('./../'), - http = require('http'), - port = 11111, - server; - -describe('parsing', function(){ - - describe('when response is an JSON string', function(){ - - var json_string = '{"foo":"bar"}'; - - before(function(done){ - server = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'application/json'); - res.end(json_string); - }).listen(port, done); - }); - - after(function(done){ - server.close(done); - }) - - describe('and parse option is not passed', function() { - - describe('with default parse_response', function() { - - before(function() { - needle.defaults().parse_response.should.eql('all') - }) - - it('should return object', function(done){ - needle.get('localhost:' + port, function(err, response, body){ - should.ifError(err); - body.should.have.property('foo', 'bar'); - done(); - }) - }) - - }) - - describe('and default parse_response is set to false', function() { - - it('does NOT return object when disabled using .defaults', function(done){ - needle.defaults({ parse_response: false }) - - needle.get('localhost:' + port, function(err, response, body) { - should.not.exist(err); - body.should.be.an.instanceof(String) - body.toString().should.eql('{"foo":"bar"}'); - - needle.defaults({ parse_response: 'all' }); - done(); - }) - }) - - - }) - - }) - - describe('and parse option is true', function() { - - describe('and JSON is valid', function() { - - it('should return object', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, response, body){ - should.not.exist(err); - body.should.have.property('foo', 'bar') - done(); - }) - }) - - it('should have a .parser = json property', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, resp) { - should.not.exist(err); - resp.parser.should.eql('json'); - done(); - }) - }) - - }); - - describe('and response is empty', function() { - - var old_json_string; - - before(function() { - old_json_string = json_string; - json_string = ""; - }); - - after(function() { - json_string = old_json_string; - }); - - it('should return an empty string', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, resp) { - should.not.exist(err); - resp.body.should.equal(''); - done(); - }) - }) - - }) - - describe('and JSON is invalid', function() { - - var old_json_string; - - before(function() { - old_json_string = json_string; - json_string = "this is not going to work"; - }); - - after(function() { - json_string = old_json_string; - }); - - it('does not throw', function(done) { - (function(){ - needle.get('localhost:' + port, { parse: true }, done); - }).should.not.throw(); - }); - - it('does NOT return object', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, response, body) { - should.not.exist(err); - body.should.be.a.String; - body.toString().should.eql('this is not going to work'); - done(); - }) - }) - - }); - - }) - - describe('and parse option is false', function() { - - it('does NOT return object', function(done){ - needle.get('localhost:' + port, { parse: false }, function(err, response, body) { - should.not.exist(err); - body.should.be.an.instanceof(String) - body.toString().should.eql('{"foo":"bar"}'); - done(); - }) - }) - - it('should NOT have a .parser = json property', function(done) { - needle.get('localhost:' + port, { parse: false }, function(err, resp) { - should.not.exist(err); - should.not.exist(resp.parser); - done(); - }) - }) - - }) - - describe('and parse option is "xml"', function() { - - it('does NOT return object', function(done){ - needle.get('localhost:' + port, { parse: 'xml' }, function(err, response, body) { - should.not.exist(err); - body.should.be.an.instanceof(String) - body.toString().should.eql('{"foo":"bar"}'); - done(); - }) - }) - - it('should NOT have a .parser = json property', function(done) { - needle.get('localhost:' + port, { parse: 'xml' }, function(err, resp) { - should.not.exist(err); - should.not.exist(resp.parser); - done(); - }) - }) - - }) - - }); - - describe('when response is JSON \'false\'', function(){ - - var json_string = 'false'; - - before(function(done){ - server = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'application/json'); - res.end(json_string); - }).listen(port, done); - }); - - after(function(done){ - server.close(done); - }) - - describe('and parse option is not passed', function() { - - it('should return object', function(done){ - needle.get('localhost:' + port, function(err, response, body){ - should.ifError(err); - body.should.equal(false); - done(); - }) - }) - - }) - - describe('and parse option is true', function() { - - describe('and JSON is valid', function() { - - it('should return object', function(done){ - needle.get('localhost:' + port, { parse: true }, function(err, response, body){ - should.not.exist(err); - body.should.equal(false) - done(); - }) - }) - - }); - - describe('and response is empty', function() { - - var old_json_string; - - before(function() { - old_json_string = json_string; - json_string = ""; - }); - - after(function() { - json_string = old_json_string; - }); - - it('should return an empty string', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, resp) { - should.not.exist(err); - resp.body.should.equal(''); - done(); - }) - }) - - }) - - describe('and JSON is invalid', function() { - - var old_json_string; - - before(function() { - old_json_string = json_string; - json_string = "this is not going to work"; - }); - - after(function() { - json_string = old_json_string; - }); - - it('does not throw', function(done) { - (function(){ - needle.get('localhost:' + port, { parse: true }, done); - }).should.not.throw(); - }); - - it('does NOT return object', function(done) { - needle.get('localhost:' + port, { parse: true }, function(err, response, body) { - should.not.exist(err); - body.should.be.a.String; - body.toString().should.eql('this is not going to work'); - done(); - }) - }) - - }); - - }) - - describe('and parse option is false', function() { - - it('does NOT return object', function(done){ - needle.get('localhost:' + port, { parse: false }, function(err, response, body) { - should.not.exist(err); - body.should.be.an.instanceof(String) - body.toString().should.eql('false'); - done(); - }) - }) - - }) - - describe('and parse option is "xml"', function() { - - it('does NOT return object', function(done){ - needle.get('localhost:' + port, { parse: 'xml' }, function(err, response, body) { - should.not.exist(err); - body.should.be.an.instanceof(String) - body.toString().should.eql('false'); - done(); - }) - }) - - }) - - - }); - - describe('when response is an invalid XML string', function(){ - - before(function(done){ - server = http.createServer(function(req, res) { - res.writeHeader(200, {'Content-Type': 'application/xml'}) - res.end("") - }).listen(port, done); - }); - - after(function(done){ - server.close(done); - }) - - describe('and parse_response is true', function(){ - - it('should return original string', function(done) { - needle.get('localhost:' + port, { parse_response: true }, function(err, response, body) { - should.not.exist(err); - body.should.eql('') - should.not.exist(body.name); - done(); - }) - }) - - it('should not have a .parser = xml property', function(done) { - needle.get('localhost:' + port, { parse_response: true }, function(err, resp) { - should.not.exist(err); - should.not.exist(resp.parser); - done(); - }) - }) - - }) - - describe('and parse response is false', function(){ - - it('should return valid object', function(done) { - needle.get('localhost:' + port, { parse_response: false }, function(err, response, body){ - should.not.exist(err); - body.toString().should.eql('') - done(); - }) - }) - - it('should not have a .parser property', function(done) { - needle.get('localhost:' + port, { parse_response: false }, function(err, resp) { - should.not.exist(err); - should.not.exist(resp.parser) - done(); - }) - }) - - }) - - }) - - describe('when response is a valid XML string', function(){ - - before(function(done) { - server = http.createServer(function(req, res) { - res.writeHeader(200, {'Content-Type': 'application/xml'}) - res.end("

hello

") - }).listen(port, done); - }); - - after(function(done) { - server.close(done); - }) - - describe('and parse_response is true', function(){ - - it('should return valid object', function(done) { - needle.get('localhost:' + port, { parse_response: true }, function(err, response, body) { - should.not.exist(err); - body.name.should.eql('post') - body.children[0].name.should.eql('p') - body.children[0].value.should.eql('hello') - - body.children[1].name.should.eql('p') - body.children[1].value.should.eql('world') - done(); - }) - }) - - it('should have a .parser = xml property', function(done) { - needle.get('localhost:' + port, { parse_response: true }, function(err, resp) { - should.not.exist(err); - resp.parser.should.eql('xml'); - done(); - }) - }) - - }) - - describe('and parse response is false', function(){ - - it('should return valid object', function(done) { - needle.get('localhost:' + port, { parse_response: false }, function(err, response, body){ - should.not.exist(err); - body.toString().should.eql('

hello

') - done(); - }) - }) - - it('should not have a .parser property', function(done) { - needle.get('localhost:' + port, { parse_response: false }, function(err, resp) { - should.not.exist(err); - should.not.exist(resp.parser) - done(); - }) - }) - - }) - - }) - - describe('valid XML, using xml2js', function() { - - var parsers, origParser; - - before(function(done) { - var xml2js = require('xml2js') - parsers = require('../lib/parsers'); - origParser = parsers['application/xml']; - - var customParser = require('xml2js').parseString; - parsers.use('xml2js', ['application/xml'], function(buff, cb) { - var opts = { explicitRoot: true, explicitArray: false }; - customParser(buff, opts, cb); - }) - - server = http.createServer(function(req, res) { - res.writeHeader(200, {'Content-Type': 'application/xml'}) - res.end("

hello

world

") - }).listen(port, done); - }); - - after(function(done) { - parsers['application/xml'] = origParser; - server.close(done); - }) - - describe('and parse_response is true', function(){ - - it('should return valid object', function(done) { - needle.get('localhost:' + port, { parse_response: true }, function(err, response, body) { - should.not.exist(err); - body.should.eql({ post: { p: ['hello', 'world' ]}}) - done(); - }) - }) - - it('should have a .parser = xml property', function(done) { - needle.get('localhost:' + port, { parse_response: true }, function(err, resp) { - should.not.exist(err); - resp.parser.should.eql('xml2js'); - done(); - }) - }) - - }) - - describe('and parse response is false', function(){ - - it('should return valid object', function(done) { - needle.get('localhost:' + port, { parse_response: false }, function(err, response, body){ - should.not.exist(err); - body.toString().should.eql('

hello

world

') - done(); - }) - }) - - it('should not have a .parser property', function(done) { - needle.get('localhost:' + port, { parse_response: false }, function(err, resp) { - should.not.exist(err); - should.not.exist(resp.parser) - done(); - }) - }) - - }) - - }) - - describe('when response is a JSON API flavored JSON string', function () { - - var json_string = '{"data":[{"type":"articles","id":"1","attributes":{"title":"Needle","body":"The leanest and most handsome HTTP client in the Nodelands."}}],"included":[{"type":"people","id":"42","attributes":{"name":"Tomás"}}]}'; - - before(function(done){ - server = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'application/vnd.api+json'); - res.end(json_string); - }).listen(port, done); - }); - - after(function(done){ - server.close(done); - }); - - describe('and parse option is not passed', function() { - - describe('with default parse_response', function() { - - before(function() { - needle.defaults().parse_response.should.eql('all') - }) - - it('should return object', function(done){ - needle.get('localhost:' + port, function(err, response, body){ - should.ifError(err); - body.should.deepEqual({ - "data": [{ - "type": "articles", - "id": "1", - "attributes": { - "title": "Needle", - "body": "The leanest and most handsome HTTP client in the Nodelands." - } - }], - "included": [ - { - "type": "people", - "id": "42", - "attributes": { - "name": "Tomás" - } - } - ] - }); - done(); - }); - }); - - }); - - }) - - }); - -}) diff --git a/node_modules/needle/test/post_data_spec.js b/node_modules/needle/test/post_data_spec.js deleted file mode 100644 index 5c826d67..00000000 --- a/node_modules/needle/test/post_data_spec.js +++ /dev/null @@ -1,1021 +0,0 @@ -var needle = require('..'), - http = require('http'), - should = require('should'), - sinon = require('sinon'), - stream = require('stream'), - helpers = require('./helpers'); - -var multiparts = ['----------------------NODENEEDLEHTTPCLIENT']; -multiparts.push(['Content-Disposition: form-data; name=\"foo\"']) -multiparts.push(['\r\nbar\r\n----------------------NODENEEDLEHTTPCLIENT--']) -// multiparts.push(['Content-Disposition: form-data; name=\"test\"']) -// multiparts.push(['\r\næµè¯\r\n----------------------NODENEEDLEHTTPCLIENT--']) -// multiparts.push(['\r\n' + Buffer.from('测试').toString() + '\r\n----------------------NODENEEDLEHTTPCLIENT--']) - - -describe('post data (e.g. request body)', function() { - - var stub, spy, server; - - before(function(done) { - server = helpers.server({ port: 4321 }, done); - }) - - after(function(done) { - server.close(done); - }) - - afterEach(function() { - if (stub) stub.restore(); - if (spy) spy.restore(); - }) - - function get(data, opts, cb) { - return needle.request('get', 'http://localhost:' + 4321, data, opts, cb) - } - - function post(data, opts, cb) { - return needle.request('post', 'http://localhost:' + 4321, data, opts, cb) - } - - function spystub_request() { - var http_req = http.request; - stub = sinon.stub(http, 'request').callsFake(function(opts, cb) { - var req = http_req(opts, cb); - spy = sinon.spy(req, 'write'); - return req; - }) - } - - function check_request(method) { - stub.calledOnce.should.be.true; - stub.args[0][0]['headers']['host'].should.equal('localhost:4321'); - stub.args[0][0]['method'].should.equal(method); - } - - describe('with multipart: true', function() { - - describe('when null', function() { - - it('sends request (non multipart)', function(done) { - spystub_request(); - - post(null, { multipart: true }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('doesnt set Content-Type header', function(done) { - post(null, { multipart: true }, function(err, resp) { - should.not.exist(resp.body.headers['content-type']); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - post(null, { multipart: true }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('doesnt write anything', function(done) { - spystub_request(); - - post(null, { multipart: true }, function(err, resp) { - spy.called.should.be.false; - resp.body.body.should.eql(''); - done(); - }) - }) - - }) - - describe('when string', function() { - - it('explodes', function() { - (function() { - post('foobar', { multipart: true }) - }).should.throw() - }) - - }) - - describe('when object', function() { - - describe('get request', function() { - - it('sends request', function(done) { - spystub_request(); - - get({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) { - check_request('get'); - done(); - }) - }) - - it('sets Content-Type header', function(done) { - post({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('multipart/form-data; boundary=--------------------NODENEEDLEHTTPCLIENT'); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - post({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes string as buffer', function(done) { - spystub_request(); - - get({ foo: 'bar' }, { multipart: true }, function(err, resp) { - spy.called.should.be.true; - - spy.args[0][0].should.be.an.instanceof(String); - spy.args[0][0].toString().should.equal(multiparts.join('\r\n')); - resp.body.body.should.eql(multiparts.join('\r\n')); - done(); - }) - }) - - it('writes japanese chars correctly as binary', function(done) { - spystub_request(); - - get({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) { - spy.called.should.be.true; - - spy.args[0][0].should.be.an.instanceof(String); - Buffer.from(spy.args[0][0]).toString('hex').should.eql('2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d22666f6f220d0a0d0a6261720d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2274657374220d0a0d0ac3a6c2b5c28bc3a8c2afc2950d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e542d2d') - done(); - }) - }) - - - }) - - describe('post request', function() { - - it('sends request', function(done) { - spystub_request(); - - post({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('writes string as buffer', function(done) { - spystub_request(); - - post({ foo: 'bar' }, { multipart: true }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(String); - spy.args[0][0].toString().should.equal(multiparts.join('\r\n')); - resp.body.body.should.eql(multiparts.join('\r\n')); - done(); - }) - }) - - it('writes japanese chars correctly as binary', function(done) { - spystub_request(); - - post({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(String); - Buffer.from(spy.args[0][0]).toString('hex').should.eql('2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d22666f6f220d0a0d0a6261720d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2274657374220d0a0d0ac3a6c2b5c28bc3a8c2afc2950d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e542d2d') - done(); - }) - }) - - }) - - }) - - describe('when stream', function() { - - var stream_for_multipart; - - before(function() { - stream_for_multipart = new stream.Readable(); - stream_for_multipart._read = function() { - this.push('foobar'); - this.push(null); - } - }) - - it('explodes', function() { - (function() { - post(stream_for_multipart, { multipart: true }) - }).should.throw() - }) - - }) - - }) - - describe('non multipart', function() { - - describe('when null', function() { - - describe('get request', function() { - - it('sends request', function(done) { - spystub_request(); - - get(null, {}, function(err, resp) { - check_request('get'); - done(); - }) - }) - - it('doesnt write anything', function(done) { - spystub_request(); - - get(null, {}, function(err, resp) { - spy.called.should.be.false; - resp.body.body.should.eql(''); - done(); - }) - }) - - }) - - describe('post request', function() { - - it('sends request', function(done) { - spystub_request(); - - post(null, {}, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('doesnt write anything', function(done) { - spystub_request(); - - post(null, {}, function(err, resp) { - spy.called.should.be.false; - resp.body.body.should.eql(''); - done(); - }) - }) - - }) - - }) - - describe('when string with no equal sign', function() { - - describe('get request', function() { - - it('explodes', function() { - (function() { - get('foobar', {}) - }).should.throw() - }) - - }) - - describe('post request', function() { - - it('sends request', function(done) { - spystub_request(); - - post('foobar', {}, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('writes string as buffer', function(done) { - spystub_request(); - - post('foobar', {}, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(Buffer); - spy.args[0][0].toString().should.equal('foobar'); - resp.body.body.should.eql('foobar'); - done(); - }) - }) - - }) - - }) - - describe('when string WITH equal sign', function() { - - describe('get request', function() { - - describe('with json: false (default)', function() { - - it('sends request, adding data as querystring', function(done) { - spystub_request(); - - get('foo=bar', { json: false }, function(err, resp) { - check_request('get'); - stub.args[0][0]['path'].should.equal('/?foo=bar') - done(); - }) - }) - - it('doesnt set Content-Type header', function(done) { - get('foo=bar', { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - should.not.exist(resp.body.headers['content-type']); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - get('foo=bar', { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('doesnt write anything', function(done) { - get('foo=bar', { json: false }, function(err, resp) { - spy.called.should.be.false; - resp.body.body.should.eql(''); - done(); - }) - }) - - }) - - describe('with json: true', function() { - - it('sends request, without setting a querystring', function(done) { - spystub_request(); - - get('foo=bar', { json: true }, function(err, resp) { - check_request('get'); - stub.args[0][0]['path'].should.equal('/') - done(); - }) - }) - - it('sets Content-Type header', function(done) { - get('foo=bar', { json: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('set Accept header to application/json', function(done) { - get('foo=bar', { json: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('application/json'); - done(); - }) - }) - - it('writes raw string (assuming it already is JSON, so no JSON.stringify)', function(done) { - get('foo=bar', { json: true }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].toString().should.eql('foo=bar') - resp.body.body.should.eql('foo=bar'); - done(); - }) - }) - - }) - - }) - - describe('post request', function() { - - describe('with json: false (default)', function() { - - it('sends request', function(done) { - spystub_request(); - - post('foo=bar', { json: false }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header to www-form-urlencoded', function(done) { - post('foo=bar', { json: false }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/x-www-form-urlencoded'); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - post('foo=bar', { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes as buffer', function(done) { - post('foo=bar', { json: false }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(Buffer); - spy.args[0][0].toString().should.equal('foo=bar'); - resp.body.body.should.eql('foo=bar'); - done(); - }) - }) - - }) - - describe('with json: true', function() { - - it('sends request', function(done) { - spystub_request(); - - post('foo=bar', { json: true }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header', function(done) { - post('foo=bar', { json: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('set Accept header to application/json', function(done) { - post('foo=bar', { json: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('application/json'); - done(); - }) - }) - - it('writes raw string (assuming it already is JSON, so no JSON.stringify)', function(done) { - post('foo=bar', { json: true }, function(err, resp) { - spy.called.should.be.true; - var json = JSON.stringify('foo=bar'); - spy.args[0][0].toString().should.eql('foo=bar') - resp.body.body.should.eql('foo=bar'); - done(); - }) - }) - - }) - - }) - - }) - - describe('when object', function() { - - describe('get request', function() { - - describe('with json: false (default)', function() { - - it('sends request, adding data as querystring', function(done) { - spystub_request(); - - get({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - check_request('get'); - stub.args[0][0]['path'].should.equal('/?foo=bar&test=%E6%B5%8B%E8%AF%95') - done(); - }) - }) - - it('doesnt set Content-Type header', function(done) { - get({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - should.not.exist(resp.body.headers['content-type']); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - get({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('doesnt write anything', function(done) { - get({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - spy.called.should.be.false; - resp.body.body.should.eql(''); - done(); - }) - }) - - }) - - describe('with json: true', function() { - - it('sends request, without setting a querystring', function(done) { - spystub_request(); - - get({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - check_request('get'); - stub.args[0][0]['path'].should.equal('/') - done(); - }) - }) - - it('sets Content-Type header', function(done) { - get({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('set Accept header to application/json', function(done) { - get({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('application/json'); - done(); - }) - }) - - it('writes JSON.stringify version of object', function(done) { - get({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - spy.called.should.be.true; - var json = JSON.stringify({ foo: 'bar', test: '测试' }) - spy.args[0][0].toString().should.eql(json) - resp.body.body.should.eql(json); - done(); - }) - }) - - }) - - }) - - describe('post request', function() { - - describe('with json: false (default)', function() { - - it('sends request', function(done) { - spystub_request(); - - post({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header to www-form-urlencoded', function(done) { - post({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/x-www-form-urlencoded'); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - post({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes as buffer', function(done) { - post({ foo: 'bar', test: '测试' }, { json: false }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(Buffer); - spy.args[0][0].toString().should.equal('foo=bar&test=%E6%B5%8B%E8%AF%95'); - resp.body.body.should.eql('foo=bar&test=%E6%B5%8B%E8%AF%95'); - done(); - }) - }) - - }) - - describe('with json: false and content_type = "application/json"', function() { - - var opts = { json: false, content_type: 'application/json' }; - - it('sends request', function(done) { - spystub_request(); - - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header to application/json', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json'); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes as buffer', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].constructor.name.should.eql('Buffer'); - spy.args[0][0].toString().should.equal('foo=bar&test=%E6%B5%8B%E8%AF%95'); - resp.body.body.should.eql('foo=bar&test=%E6%B5%8B%E8%AF%95'); - done(); - }) - }) - - }) - - describe('with json: undefined but content-type = application/json', function() { - - var opts = { headers: { 'content-type': 'application/json' } }; - - it('sends request', function(done) { - spystub_request(); - - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('doesnt change Content-Type header', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json'); - done(); - }) - }) - - it('leaves default Accept header', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes JSON.stringified object', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - spy.called.should.be.true; - var json = JSON.stringify({ foo: 'bar', test: '测试' }) - spy.args[0][0].toString().should.eql(json) - resp.body.body.should.eql(json); - done(); - }) - }) - }) - - describe('with json: true', function() { - - it('sends request', function(done) { - spystub_request(); - - post({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header', function(done) { - post({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('set Accept header to application/json', function(done) { - post({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('application/json'); - done(); - }) - }) - - it('writes JSON.stringified object', function(done) { - post({ foo: 'bar', test: '测试' }, { json: true }, function(err, resp) { - spy.called.should.be.true; - var json = JSON.stringify({ foo: 'bar', test: '测试' }) - spy.args[0][0].toString().should.eql(json) - resp.body.body.should.eql(json); - done(); - }) - }) - - }) - - - describe('with json: true and content_type: */* (passed, not default)', function() { - - var opts = { json: true, accept: '*/*' }; - - it('sends request', function(done) { - spystub_request(); - - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header to application/json', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('respects Accept header set by user', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes JSON.stringified object', function(done) { - post({ foo: 'bar', test: '测试' }, opts, function(err, resp) { - spy.called.should.be.true; - var json = JSON.stringify({ foo: 'bar', test: '测试' }) - spy.args[0][0].toString().should.eql(json) - resp.body.body.should.eql(json); - done(); - }) - }) - - }) - - }) - - }) - - describe('when buffer', function() { - - describe('get request', function() { - - describe('with json: false (default)', function() { - - it('sends request', function(done) { - spystub_request(); - - get(Buffer.from('foobar'), { json: false }, function(err, resp) { - check_request('get'); - done(); - }) - }) - - it('sets Content-Type header', function(done) { - get(Buffer.from('foobar'), { json: false }, function(err, resp) { - // should.not.exist(resp.body.headers['content-type']); - resp.body.headers['content-type'].should.equal('application/x-www-form-urlencoded'); - - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - get(Buffer.from('foobar'), { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes as buffer', function(done) { - get(Buffer.from('foobar'), { json: false }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(Buffer); - spy.args[0][0].toString().should.equal('foobar'); - resp.body.body.should.eql('foobar'); - done(); - }) - }) - - }) - - describe('with json: true', function() { - - it('sends request, without setting a querystring', function(done) { - spystub_request(); - - get(Buffer.from('foobar'), { json: true }, function(err, resp) { - check_request('get'); - done(); - }) - }) - - it('sets Content-Type header', function(done) { - get(Buffer.from('foobar'), { json: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('set Accept header to application/json', function(done) { - get(Buffer.from('foobar'), { json: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('application/json'); - done(); - }) - }) - - it('writes JSON.stringify version of object', function(done) { - get(Buffer.from('foobar'), { json: true }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].toString().should.eql('foobar') - resp.body.body.should.eql('foobar'); - done(); - }) - }) - - }) - - }) - - describe('post request', function() { - - describe('with json: false (default)', function() { - - it('sends request', function(done) { - spystub_request(); - - post(Buffer.from('foobar'), { json: false }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header to www-form-urlencoded', function(done) { - post(Buffer.from('foobar'), { json: false }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/x-www-form-urlencoded'); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - post(Buffer.from('foobar'), { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes as buffer', function(done) { - post(Buffer.from('foobar'), { json: false }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(Buffer); - spy.args[0][0].toString().should.equal('foobar'); - resp.body.body.should.eql('foobar'); - done(); - }) - }) - - }) - - describe('with json: true', function() { - - it('sends request', function(done) { - spystub_request(); - - post(Buffer.from('foobar'), { json: true }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header', function(done) { - post(Buffer.from('foobar'), { json: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('set Accept header to application/json', function(done) { - post(Buffer.from('foobar'), { json: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('application/json'); - done(); - }) - }) - - it('passes raw buffer (assuming its a JSON string beneath)', function(done) { - post(Buffer.from('foobar'), { json: true }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].toString().should.eql('foobar') - resp.body.body.should.eql('foobar'); - done(); - }) - }) - - }) - - }) - - }) - - describe('when stream', function() { - - var input_stream; - - beforeEach(function() { - input_stream = new stream.Readable(); - input_stream._read = function() { - this.push('foobar'); - this.push(null); - } - }) - - describe('get request', function() { - - it('explodes', function() { - (function() { - get(input_stream, {}) - }).should.throw() - }) - - }); - - describe('post request', function() { - - describe('with json: false (default)', function() { - - it('sends request', function(done) { - spystub_request(); - - post(input_stream, { json: false }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header to www-form-urlencoded', function(done) { - post(input_stream, { json: false }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/x-www-form-urlencoded'); - done(); - }) - }) - - it('doesnt change default Accept header', function(done) { - post(input_stream, { json: false }, function(err, resp) { - // resp.body contains 'header' and 'body', mirroring what we sent - resp.body.headers['accept'].should.equal('*/*'); - done(); - }) - }) - - it('writes as buffer', function(done) { - post(input_stream, { json: false }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].should.be.an.instanceof(Buffer); - spy.args[0][0].toString().should.equal('foobar'); - resp.body.body.should.eql('foobar'); - done(); - }) - }) - - }) - - describe('with json: true', function() { - - it('sends request', function(done) { - spystub_request(); - - post(input_stream, { json: true }, function(err, resp) { - check_request('post'); - done(); - }) - }) - - it('sets Content-Type header', function(done) { - post(input_stream, { json: true }, function(err, resp) { - resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); - done(); - }) - }) - - it('set Accept header to application/json', function(done) { - post(input_stream, { json: true }, function(err, resp) { - resp.body.headers['accept'].should.equal('application/json'); - done(); - }) - }) - - it('writes JSON.stringified object', function(done) { - post(input_stream, { json: true }, function(err, resp) { - spy.called.should.be.true; - spy.args[0][0].toString().should.eql('foobar') - resp.body.body.should.eql('foobar'); - done(); - }) - }) - - }) - - }) - - }) - - }) - -}) diff --git a/node_modules/needle/test/proxy_spec.js b/node_modules/needle/test/proxy_spec.js deleted file mode 100644 index 9526e7f7..00000000 --- a/node_modules/needle/test/proxy_spec.js +++ /dev/null @@ -1,202 +0,0 @@ -var helpers = require('./helpers'), - should = require('should'), - sinon = require('sinon'), - http = require('http'), - needle = require('./../'); - -var port = 7707; -var url = 'localhost:' + port; -var nonexisting_host = 'awepfokawepofawe.com'; - -describe('proxy option', function() { - - var spy, opts; - - function send_request(opts, done) { - if (spy) spy.restore(); - spy = sinon.spy(http, 'request'); - needle.get(url, opts, done); - } - - ////////////////////// - // proxy opts helpers - - function not_proxied(done) { - return function(err, resp) { - var path = spy.args[0][0].path; - path.should.eql('/'); // not the full original URI - spy.restore(); - done(); - } - } - - function proxied(host, port, done) { - return function(err, resp) { - var path = spy.args[0][0].path; - path.should.eql('http://' + url); // the full original URI - - var http_host = spy.args[0][0].host; - if (http_host) http_host.should.eql(host); - - var http_port = spy.args[0][0].port; - if (http_port) http_port.should.eql(port); - - spy.restore(); - done(); - } - } - - ////////////////////// - // auth helpers - - function get_auth(header) { - var token = header.split(/\s+/).pop(); - return token && Buffer.from(token, 'base64').toString().split(':'); - } - - function no_proxy_auth(done) { - return function(err, resp) { - var headers = spy.args[0][0].headers; - Object.keys(headers).should.not.containEql('proxy-authorization'); - done(); - } - } - - function header_set(name, user, pass, done) { - return function(err, resp) { - var headers = spy.args[0][0].headers; - var auth = get_auth(headers[name]); - auth[0].should.eql(user); - auth[1].should.eql(pass); - done(); - } - } - - function proxy_auth_set(user, pass, done) { - return header_set('proxy-authorization', user, pass, done); - } - - function basic_auth_set(user, pass, done) { - return header_set('authorization', user, pass, done); - } - - after(function() { - spy.restore(); - }) - - describe('when null proxy is passed', function() { - - it('does not proxy', function(done) { - send_request({ proxy: null }, not_proxied(done)) - }) - - describe('but defaults has been set', function() { - - before(function() { - needle.defaults({ proxy: 'foobar' }); - }) - - after(function() { - needle.defaults({ proxy: null }); - }) - - it('tries to proxy anyway', function(done) { - send_request({}, proxied('foobar', 80, done)) - }) - - }) - - }) - - describe('when weird string is passed', function() { - - it('tries to proxy anyway', function(done) { - send_request({ proxy: 'alfalfa' }, proxied('alfalfa', 80, done)) - }) - }) - - describe('when valid url is passed', function() { - - it('proxies request', function(done) { - send_request({ proxy: nonexisting_host + ':123/done' }, proxied(nonexisting_host, '123', done)) - }) - - it('does not set a Proxy-Authorization header', function(done) { - send_request({ proxy: nonexisting_host + ':123/done' }, no_proxy_auth(done)); - }) - - describe('and proxy url contains user:pass', function() { - - before(function() { - opts = { - proxy: 'http://mj:x@' + nonexisting_host + ':123/done' - } - }) - - it('proxies request', function(done) { - send_request(opts, proxied(nonexisting_host, '123', done)) - }) - - it('sets Proxy-Authorization header', function(done) { - send_request(opts, proxy_auth_set('mj', 'x', done)); - }) - - }) - - describe('and a proxy_user is passed', function() { - - before(function() { - opts = { - proxy: nonexisting_host + ':123', - proxy_user: 'someone', - proxy_pass: 'else' - } - }) - - it('proxies request', function(done) { - send_request(opts, proxied(nonexisting_host, '123', done)) - }) - - it('sets Proxy-Authorization header', function(done) { - send_request(opts, proxy_auth_set('someone', 'else', done)); - }) - - describe('and url also contains user:pass', function() { - - it('url user:pass wins', function(done) { - var opts = { - proxy: 'http://xxx:yyy@' + nonexisting_host + ':123', - proxy_user: 'someone', - proxy_pass: 'else' - } - - send_request(opts, proxy_auth_set('xxx', 'yyy', done)); - }) - - }) - - describe('and options.username is also present', function() { - - before(function() { - opts = { proxy_user: 'foobar', username: 'someone' }; - }) - - it('a separate Authorization header is set', function(done) { - var opts = { - proxy: nonexisting_host + ':123', - proxy_user: 'someone', - proxy_pass: 'else', - username: 'test', - password: 'X' - } - - send_request(opts, basic_auth_set('test', 'X', done)); - }) - - }) - - }) - - }) - -}) diff --git a/node_modules/needle/test/querystring_spec.js b/node_modules/needle/test/querystring_spec.js deleted file mode 100644 index 34c1748c..00000000 --- a/node_modules/needle/test/querystring_spec.js +++ /dev/null @@ -1,128 +0,0 @@ -var should = require('should'), - stringify = require('../lib/querystring').build; - -describe('stringify', function() { - - describe('with null', function() { - - it('throws', function() { - (function() { - var res = stringify(null); - }).should.throw(); - }) - - }) - - describe('with a number', function() { - - it('throws', function() { - (function() { - var res = stringify(100); - }).should.throw(); - }) - - }) - - describe('with a string', function() { - - describe('that is empty', function() { - - it('throws', function() { - (function() { - var res = stringify(''); - }).should.throw(); - }) - - }) - - describe('that doesnt contain an equal sign', function() { - - it('throws', function() { - (function() { - var res = stringify('boomshagalaga'); - }).should.throw(); - }) - - }) - - describe('that contains an equal sign', function() { - - it('works', function() { - var res = stringify('hello=123'); - res.should.eql('hello=123'); - }) - - }) - - }) - - describe('with an array', function() { - - describe('with key val objects', function() { - - it('works', function() { - var res = stringify([ {foo: 'bar'} ]); - res.should.eql('foo=bar'); - }) - - }) - - describe('where all elements are strings with an equal sign', function() { - - it('works', function() { - var res = stringify([ 'bar=123', 'quux=' ]); - res.should.eql('bar=123&quux='); - }) - - }) - - describe('with random words', function() { - - it('throws', function() { - (function() { - var res = stringify(['hello', 'there']); - }).should.throw(); - }) - - }) - - describe('with integers', function() { - - it('throws', function() { - (function() { - var res = stringify([123, 432]); - }).should.throw(); - }) - - }) - - }) - - describe('with an object', function() { - - it('works', function() { - var res = stringify({ test: 100 }); - res.should.eql('test=100'); - }) - - describe('with object where val is an array', function() { - - it('works', function() { - var res = stringify({ foo: ['bar', 'baz'] }); - res.should.eql('foo[]=bar&foo[]=baz'); - }) - - }) - - describe('with object where val is an array of key val objects', function() { - - it('works', function() { - var res = stringify({ foo: [{'1': 'bar'}, {'2': 'baz'}] }); - res.should.eql('foo[][1]=bar&foo[][2]=baz'); - }) - - }) - - }) - -}) diff --git a/node_modules/needle/test/redirect_spec.js b/node_modules/needle/test/redirect_spec.js deleted file mode 100644 index c3942e27..00000000 --- a/node_modules/needle/test/redirect_spec.js +++ /dev/null @@ -1,394 +0,0 @@ -var helpers = require('./helpers'), - should = require('should'), - sinon = require('sinon'), - needle = require('./../'); - -var ports = { - http : 8888, - https : 9999 -} - -var protocols = { - http : require('http'), - https : require('https') -} - -var code = 301; -var location; // var to set the response location - -function response_code() { - return code; -} - -function response_headers() { - return { 'Content-Type': 'text/plain', 'Location': location } -} - -describe('redirects', function() { - - var spies = {}, - servers = {}; - - var current_protocol; - var hostname = require('os').hostname(); - - // open two servers, one that responds to a redirect - before(function(done) { - - var conf = { - port : ports.http, - code : response_code, - headers : response_headers - } - - servers.http = helpers.server(conf, function() { - conf.port = ports.https; - conf.protocol = 'https'; - servers.https = helpers.server(conf, done); - }); - }) - - after(function(done) { - servers.http.close(function() { - servers.https.close(done); - }); - }) - - var prots = {'http': 'https'}; - Object.keys(prots).forEach(function(protocol) { - - current_protocol = protocol; - var other_protocol = protocol == 'http' ? 'https' : 'http'; - - var opts, // each test will modify this - host = '127.0.0.1', - url = protocol + '://' + host + ':' + ports[protocol] + '/hello'; - - function send_request(opts, cb) { - opts.rejectUnauthorized = false; - // console.log(' -- sending request ' + url + ' -- redirect to ' + location); - needle.post(url, { foo: 'bar' }, opts, cb); - } - - function not_followed(done) { - send_request(opts, function(err, resp) { - resp.statusCode.should.eql(301); - if (current_protocol == 'http') { - spies.http.callCount.should.eql(1); // only original request - spies.https.callCount.should.eql(0); - } else { - spies.http.callCount.should.eql(0); - spies.https.callCount.should.eql(1); // only original request - } - done(); - }) - } - - function followed_same_protocol(done) { - send_request(opts, function(err, resp) { - // the original request plus the redirect one - spies[current_protocol].callCount.should.eql(2); - done(); - }) - - } - - function followed_other_protocol(done) { - send_request(opts, function(err, resp) { - // on new-ish node versions, https.request calls http.request internally, - // so we need to amount for that additional call. - // update: this doesn't happen on node > 10.x - - var node_major_ver = process.version.split('.')[0].replace('v', ''); - var http_calls = protocols.http.Agent.defaultMaxSockets == Infinity && parseInt(node_major_ver) < 10 ? 2 : 1; - - spies.http.callCount.should.eql(http_calls); // the one(s) from http.request - spies.https.callCount.should.eql(1); // the one from https.request (redirect) - done(); - }) - } - - // set a spy on [protocol].request - // so we can see how many times a request was made - before(function() { - spies.http = sinon.spy(protocols.http, 'request'); - spies.https = sinon.spy(protocols.https, 'request'); - }) - - // and make sure it is restored after each test - afterEach(function() { - spies.http.reset(); - spies.https.reset(); - }) - - after(function() { - spies.http.restore(); - spies.https.restore(); - }) - - describe('when overriding defaults', function() { - - before(function() { - needle.defaults({ follow_max: 10 }); - opts = {}; - }) - - after(function() { - // reset values to previous - needle.defaults({ follow_max: 0 }); - }) - - describe('and redirected to the same path on same host and protocol', function() { - before(function() { - location = url; - }) - it('does not follow redirect', not_followed); - }) - - describe('and redirected to the same path on same host and different protocol', function() { - before(function() { - location = url.replace(protocol, other_protocol).replace(ports[protocol], ports[other_protocol]); - }) - - it('follows redirect', followed_other_protocol); - }) - - describe('and redirected to a different path on same host, same protocol', function() { - before(function() { - location = url.replace('/hello', '/goodbye'); - }) - it('follows redirect', followed_same_protocol); - }) - - describe('and redirected to a different path on same host, different protocol', function() { - before(function() { - location = url.replace('/hello', '/goodbye').replace(protocol, other_protocol).replace(ports[protocol], ports[other_protocol]); - }) - it('follows redirect', followed_other_protocol); - }) - - describe('and redirected to same path on another host, same protocol', function() { - before(function() { - location = url.replace(host, hostname); - }) - it('follows redirect', followed_same_protocol); - }) - - describe('and redirected to same path on another host, different protocol', function() { - before(function() { - location = url.replace(host, hostname).replace(protocol, other_protocol).replace(ports[protocol], ports[other_protocol]); - }) - it('follows redirect', followed_other_protocol); - }) - - }) - - // false and null have the same result - var values = [false, null]; - values.forEach(function(value) { - - describe('when follow is ' + value, function() { - - before(function() { - opts = { follow: value }; - }) - - - - describe('and redirected to the same path on same host and protocol', function() { - before(function() { - location = url; - }) - - it('throws an error', function() { - (function() { - send_request(opts, function() { }); - }).should.throw; - }) - - }) - - }) - - }) - - describe('when follow is true', function() { - - before(function() { - opts = { follow: true }; - }) - - describe('and redirected to the same path on same host and protocol', function() { - before(function() { location = url }) - - it('throws an error', function() { - (function() { - send_request(opts, function() { }); - }).should.throw; - }) - - }) - - }) - - describe('when follow is > 0', function() { - - before(function() { - needle.defaults({ follow: 10 }); - }) - - after(function() { - needle.defaults({ follow: 0 }); - }) - - describe('when keep_method is false', function() { - - before(function() { - opts = { follow_keep_method: false }; - }) - - // defaults to follow host and protocol - describe('and redirected to the same path on same host and different protocol', function() { - - before(function() { - location = url.replace(protocol, other_protocol); - }) - - it('follows redirect', followed_other_protocol); - - it('sends a GET request with no data', function(done) { - send_request(opts, function(err, resp) { - spies.http.args[0][0].method.should.eql('GET'); - // spy.args[0][3].should.eql(null); - done(); - }) - }) - - }) - - }) - - describe('and set_referer is true', function() { - - before(function() { - opts = { follow_set_referer: true }; - }) - - // defaults to follow host and protocol - describe('and redirected to the same path on same host and different protocol', function() { - - before(function() { - location = url.replace(protocol, other_protocol); - }) - - it('follows redirect', followed_other_protocol); - - it('sets Referer header when following redirect', function(done) { - send_request(opts, function(err, resp) { - spies.http.args[0][0].headers['referer'].should.eql("http://" + host + ":8888/hello"); - // spies.http.args[0][3].should.eql({ foo: 'bar'}); - done(); - }) - }) - - }) - - }) - - describe('and keep_method is true', function() { - - before(function() { - opts = { follow_keep_method: true }; - }) - - // defaults to follow host and protocol - describe('and redirected to the same path on same host and different protocol', function() { - - before(function() { - location = url.replace(protocol, other_protocol); - }) - - it('follows redirect', followed_other_protocol); - - it('sends a POST request with the original data', function(done) { - send_request(opts, function(err, resp) { - spies.http.args[0][0].method.should.eql('post'); - // spies.http.args[0][3].should.eql({ foo: 'bar'}); - done(); - }) - }) - - }) - - }) - - describe('and if_same_host is false', function() { - - before(function() { - opts = { follow_if_same_host: false }; - }) - - // by default it will follow other protocols - describe('and redirected to same path on another domain, same protocol', function() { - before(function() { - location = url.replace(host, hostname); - }) - it('follows redirect', followed_same_protocol); - }) - - }) - - describe('and if_same_host is true', function() { - - before(function() { - opts = { follow_if_same_host: true }; - }) - - // by default it will follow other protocols - describe('and redirected to same path on another domain, same protocol', function() { - before(function() { - location = url.replace(host, hostname); - }) - - it('does not follow redirect', not_followed); - }) - - }) - - describe('and if_same_protocol is false', function() { - - before(function() { - opts = { follow_if_same_protocol: false }; - }) - - // by default it will follow other hosts - describe('and redirected to same path on another domain, different protocol', function() { - before(function() { - location = url.replace(host, hostname).replace(protocol, other_protocol).replace(ports[protocol], ports[other_protocol]); - }) - it('follows redirect', followed_other_protocol); - }) - - }) - - describe('and if_same_protocol is true', function() { - - before(function() { - opts = { follow_if_same_protocol: true }; - }) - - // by default it will follow other hosts - describe('and redirected to same path on another domain, different protocol', function() { - before(function() { - location = url.replace(host, hostname).replace(protocol, other_protocol).replace(ports[protocol], ports[other_protocol]); - }) - it('does not follow redirect', not_followed); - }) - - }) - - }) - - }) - -}); diff --git a/node_modules/needle/test/redirect_with_timeout.js b/node_modules/needle/test/redirect_with_timeout.js deleted file mode 100644 index 7e8e02e6..00000000 --- a/node_modules/needle/test/redirect_with_timeout.js +++ /dev/null @@ -1,45 +0,0 @@ -var should = require('should') -var needle = require('./../') - -describe('follow redirects when read_timeout is set', function () { - - it('clear timeout before following redirect', function (done) { - var opts = { - open_timeout: 1000, - read_timeout: 3000, - follow: 5, - user_agent: 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36' - } - - var timedOut = 0 - var redirects = 0 - - var timer = setTimeout(function () { - var hasRedirects = redirects > 0 - hasRedirects.should.equal(true) - done() - }, opts.read_timeout || 3000) - - var resp = needle.get('http://google.com/', opts, function (err, resp, body) { - var noErr = err === null - var hasBody = body.length > 0 - noErr.should.equal(true); - hasBody.should.equal(true); - }); - - resp.on('redirect', function (location) { - redirects++ - // console.info(' Redirected to ', location) - }) - - resp.on('timeout', function (type) { - timedOut++ - timedOut.should.equal(0) - // console.error(' ', type, 'timeout') - clearTimeout(timer) - done() - }) - - }).timeout(30000) - -}) \ No newline at end of file diff --git a/node_modules/needle/test/request_stream_spec.js b/node_modules/needle/test/request_stream_spec.js deleted file mode 100644 index 0dfcb791..00000000 --- a/node_modules/needle/test/request_stream_spec.js +++ /dev/null @@ -1,237 +0,0 @@ -var fs = require('fs'), - needle = require('..'), - stream = require('stream'), - http = require('http'), - should = require('should'), - sinon = require('sinon'); - -var port = 2233; - -var node_major_ver = parseInt(process.version.split('.')[0].replace('v', '')); -var node_minor_ver = parseInt(process.version.split('.')[1]); - -describe('request stream length', function() { - - var server, writable; - - function createServer() { - return http.createServer(function(req, res) { - - req.on('data', function(chunk) { - // console.log(chunk.length); - }) - - req.on('end', function() { - res.writeHeader(200, { 'Content-Type': 'application/json'}) - res.end(JSON.stringify({ headers: req.headers })) - }) - - }) - } - - before(function(done) { - server = createServer(); - server.listen(port, done) - }) - - beforeEach(function() { - writable = new stream.Readable(); - writable._read = function() { - this.push('hello world'); - this.push(null); - } - }) - - after(function(done) { - server.close(done) - }) - - function send_request(opts, cb) { - needle.post('http://localhost:' + port, writable, opts, cb) - } - - describe('no stream_length set', function() { - - it('doesnt set Content-Length header', function(done) { - send_request({}, function(err, resp) { - should.not.exist(resp.body.headers['content-length']); - done() - }) - }) - - if (node_major_ver >= 10) { - it('returns 400 if Transfer-Encoding is set to a blank string', function(done) { - send_request({ headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(400); - done() - }) - }) - } else { - it('doesnt work if Transfer-Encoding is set to a blank string', function(done) { - send_request({ headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - err.code.should.eql('ECONNRESET'); - done() - }) - }) - } - - it('works if Transfer-Encoding is not set', function(done) { - send_request({}, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(200); - done() - }) - }) - - }) - - describe('stream_length set to invalid value', function() { - - if (node_major_ver >= 10) { - - it('returns 400 if Transfer-Encoding is set to a blank string', function(done) { - send_request({ stream_length: 5, headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(400); - done() - }) - }) - - it('returns 400 if Transfer-Encoding is not set', function(done) { - send_request({ stream_length: 5 }, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(400); - done() - }) - }) - - } else { - - it('doesnt work if Transfer-Encoding is set to a blank string', function(done) { - send_request({ stream_length: 5, headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - err.code.should.eql('ECONNRESET'); - done() - }) - }) - it('doesnt work if Transfer-Encoding is not set', function(done) { - send_request({ stream_length: 5 }, function(err, resp) { - err.code.should.eql('ECONNRESET'); - done() - }) - }) - - } - - }) - - describe('stream_length is set to valid value', function() { - - it('sets Content-Length header to that value', function(done) { - send_request({ stream_length: 11 }, function(err, resp) { - resp.body.headers['content-length'].should.eql('11'); - done() - }) - }) - - it('works if Transfer-Encoding is set to a blank string', function(done) { - send_request({ stream_length: 11, headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - should.not.exist(err); - var code = node_major_ver == 10 && node_minor_ver > 15 ? 400 : 200; - resp.statusCode.should.eql(code); - done() - }) - }) - - it('works if Transfer-Encoding is not set', function(done) { - send_request({ stream_length: 11 }, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(200); - done() - }) - }) - - }) - - - describe('stream_length set to 0', function() { - - describe('stream with path', function() { - - var stub; - - beforeEach(function() { - writable.path = '/foo/bar'; - stub = sinon.stub(fs, 'stat').callsFake(function(path, cb) { - cb(null, { size: 11 }) - }) - }) - - afterEach(function() { - stub.restore(); - }) - - it('sets Content-Length header to streams length', function(done) { - send_request({ stream_length: 0 }, function(err, resp) { - resp.body.headers['content-length'].should.eql('11'); - done() - }) - }) - - it('works if Transfer-Encoding is set to a blank string', function(done) { - send_request({ stream_length: 0, headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - should.not.exist(err); - var code = node_major_ver == 10 && node_minor_ver > 15 ? 400 : 200; - resp.statusCode.should.eql(code); - done() - }) - }) - - it('works if Transfer-Encoding is not set', function(done) { - send_request({ stream_length: 0 }, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(200); - done() - }) - }) - - }) - - describe('stream without path', function() { - - it('does not set Content-Length header', function(done) { - send_request({ stream_length: 0 }, function(err, resp) { - should.not.exist(resp.body.headers['content-length']); - done() - }) - }) - - if (node_major_ver >= 10) { - it('returns 400 if Transfer-Encoding is set to a blank string', function(done) { - send_request({ stream_length: 0, headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(400); - done() - }) - }) - } else { - it('throws ECONNRESET if Transfer-Encoding is set to a blank string', function(done) { - send_request({ stream_length: 0, headers: { 'Transfer-Encoding': '' }}, function(err, resp) { - err.code.should.eql('ECONNRESET'); - done() - }) - }) - } - - it('works if Transfer-Encoding is not set', function(done) { - send_request({ stream_length: 0 }, function(err, resp) { - should.not.exist(err); - resp.statusCode.should.eql(200); - done() - }) - }) - }) - - }) - -}) diff --git a/node_modules/needle/test/response_stream_spec.js b/node_modules/needle/test/response_stream_spec.js deleted file mode 100644 index a0ccef8e..00000000 --- a/node_modules/needle/test/response_stream_spec.js +++ /dev/null @@ -1,138 +0,0 @@ -var should = require('should'), - needle = require('./../'), - http = require('http'), - stream = require('stream'), - fs = require('fs'), - port = 11111, - server; - -describe('response streams', function() { - - describe('when the server sends back json', function(){ - - before(function(done) { - server = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'application/json') - res.end('{"foo":"bar"}') - }).listen(port, done); - }); - - after(function(done) { - server.close(done); - }) - - describe('and the client uses streams', function(){ - - it('creates a proper streams2 stream', function(done) { - var stream = needle.get('localhost:' + port) - - // newer node versions set this to null instead of false - var bool = !!stream._readableState.flowing; - should.equal(false, bool); - - var readableCalled = false; - stream.on('readable', function() { - readableCalled = true; - }) - - stream.on('finish', function() { - readableCalled.should.be.true; - done(); - }); - - stream.resume(); - }) - - it('emits a single data item which is our JSON object', function(done) { - var stream = needle.get('localhost:' + port) - - var chunks = []; - stream.on('readable', function () { - while (chunk = this.read()) { - chunk.should.be.an.Object; - chunks.push(chunk); - } - }) - - stream.on('done', function () { - chunks.should.have.length(1) - chunks[0].should.have.property('foo', 'bar'); - done(); - }); - }) - - it('emits a raw buffer if we do not want to parse JSON', function(done) { - var stream = needle.get('localhost:' + port, { parse: false }) - - var chunks = []; - stream.on('readable', function () { - while (chunk = this.read()) { - Buffer.isBuffer(chunk).should.be.true; - chunks.push(chunk); - } - }) - - stream.on('done', function() { - var body = Buffer.concat(chunks).toString(); - body.should.equal('{"foo":"bar"}') - done(); - }); - }) - - }) - }) - - describe('when the server sends back what was posted to it', function () { - var file = 'asdf.txt'; - - before(function(done){ - server = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'application/octet') - req.pipe(res); - }).listen(port); - - fs.writeFile(file, 'contents of stream', done); - }); - - after(function(done){ - server.close(); - fs.unlink(file, done); - }) - - it('can PUT a stream', function (done) { - var stream = needle.put('localhost:' + port, fs.createReadStream(file), { stream: true }); - - var chunks = []; - stream.on('readable', function () { - while (chunk = this.read()) { - Buffer.isBuffer(chunk).should.be.true; - chunks.push(chunk); - } - }) - - stream.on('end', function () { - var body = Buffer.concat(chunks).toString(); - body.should.equal('contents of stream') - done(); - }); - }); - - it('can PATCH a stream', function (done) { - var stream = needle.patch('localhost:' + port, fs.createReadStream(file), { stream: true }); - - var chunks = []; - stream.on('readable', function () { - while (chunk = this.read()) { - Buffer.isBuffer(chunk).should.be.true; - chunks.push(chunk); - } - }) - - stream.on('end', function () { - var body = Buffer.concat(chunks).toString(); - body.should.equal('contents of stream') - done(); - }); - }); - }) -}) diff --git a/node_modules/needle/test/socket_cleanup_spec.js b/node_modules/needle/test/socket_cleanup_spec.js deleted file mode 100644 index 483b4620..00000000 --- a/node_modules/needle/test/socket_cleanup_spec.js +++ /dev/null @@ -1,79 +0,0 @@ -var should = require('should'), - needle = require('./../'), - fs = require('fs'), - https = require('https'), - stream = require('stream'); - -describe('socket cleanup', function(){ - - var outFile = 'test/tmp'; - var httpAgent, readStream, writeStream - - var file = 'ubuntu-21.04-desktop-amd64.iso', - url = 'https://releases.ubuntu.com/21.04/' + file; - - function getActiveSockets() { - return Object.keys(httpAgent.sockets).length - } - - before(function() { - httpAgent = new https.Agent({ - keepAlive : true, - maxSockets : 1 - }); - }) - - after(function() { - httpAgent.destroy() - fs.unlinkSync(outFile); - }) - - it('should cleanup sockets on ERR_STREAM_PREMATURE_CLOSE (using .pipe)', function(done) { - getActiveSockets().should.eql(0); - - var resp = needle.get(url, { agent: httpAgent }); - var writable = fs.createWriteStream(outFile); - resp.pipe(writable); - - writable.on('close', function(e) { - if (!resp.done) resp.abort(); - }) - - setTimeout(function() { - getActiveSockets().should.eql(1); - writable.destroy(); - }, 50); - - setTimeout(function() { - getActiveSockets().should.eql(0); - done(); - }, 500); // takes a bit - }) - - it('should cleanup sockets on ERR_STREAM_PREMATURE_CLOSE (using stream.pipeline)', function(done) { - if (!stream.pipeline) - return done() - - getActiveSockets().should.eql(0); - - var resp = needle.get(url, { agent: httpAgent }); - var writable = fs.createWriteStream(outFile); - - stream.pipeline(resp, writable, function(err) { - err.code.should.eql('ERR_STREAM_PREMATURE_CLOSE') - // if (err) resp.request.destroy(); - }); - - setTimeout(function() { - getActiveSockets().should.eql(1); - writable.destroy(); - }, 50); - - setTimeout(function() { - getActiveSockets().should.eql(0); - done(); - }, 1000); // takes a bit - - }) - -}) \ No newline at end of file diff --git a/node_modules/needle/test/socket_pool_spec.js b/node_modules/needle/test/socket_pool_spec.js deleted file mode 100644 index 75080bdf..00000000 --- a/node_modules/needle/test/socket_pool_spec.js +++ /dev/null @@ -1,67 +0,0 @@ -var needle = require('../'), - should = require('should'), - http = require('http'); - -var server, port = 11112; - -describe('socket reuse', function() { - - var httpAgent = new http.Agent({ - keepAlive : true, - maxSockets : 1 - }); - - before(function(done) { - server = http.createServer(function(req, res) { - res.setHeader('Content-Type', 'application/json'); - setTimeout(function() { - res.end('{"foo":"bar"}'); - }, 50); - }).listen(port, done); - }); - - after(function(done) { - httpAgent.destroy(); - server.close(done); - }); - - describe('when sockets are reused', function() { - - it('does not duplicate listeners on .end', function(done) { - - var last_error; - var count = 10; - - function completed(err) { - --count || done(last_error); - } - - function send() { - needle.get('localhost:' + port, { agent: httpAgent }, function(err, resp) { - if (err) - throw new Error("Unexpected error: " + err); - - // lets go through all sockets and inspect all socket objects - for (hostTarget in httpAgent.sockets) { - httpAgent.sockets[hostTarget].forEach(function(socket) { - // normally, there are 2 internal listeners and 1 needle sets up, - // but to be sure the test does not fail even if newer node versions - // introduce additional listeners, we use a higher limit. - try { - socket.listeners('end').length.should.be.below(5, "too many listeners on the socket object's end event"); - } catch (e) { - last_error = e; - } - }); - } - - completed(); - }); - } - - for (var i = 0; i < count; i++) { - send(); - } - }); - }); -}); diff --git a/node_modules/needle/test/stream_events_spec.js b/node_modules/needle/test/stream_events_spec.js deleted file mode 100644 index 57ef9946..00000000 --- a/node_modules/needle/test/stream_events_spec.js +++ /dev/null @@ -1,144 +0,0 @@ -var needle = require('../'), - fs = require('fs'), - should = require('should'), - helpers = require('./helpers'); - -describe('stream events', function() { - - var server, - port = 3456, - responseData, - serverOpts = {}, - requestHandler = function(req, res) { res.end('OK') } - - before(function() { - var opts = { - port: port, - handler: function(req, res) { requestHandler(req, res) } - } - server = helpers.server(opts); - }) - - after(function() { - server.close(); - }) - - beforeEach(function() { - responseData = ''; - }) - - describe('when consuming data directly', function() { - - function send_request(opts, cb) { - return needle - .get('http://localhost:' + port, opts) - .on('data', function(data) { responseData += data }) - } - - describe('and request stream fails', function() { - - it('emits done event with error', function(done) { - requestHandler = function(req, res) { req.socket.destroy() } - - send_request({}).on('done', function(err) { - err.code.should.eql('ECONNRESET'); - responseData.should.eql(''); - done() - }) - }) - - }) - - describe('and request succeeds but decoding fails', function() { - - it('emits done event without error', function(done) { - requestHandler = function(req, res) { - res.setHeader('Content-Type', 'application/json') - res.end('invalid:json') - } - - send_request({ json: true }).on('done', function(err) { - should.not.exist(err); - responseData.should.eql('invalid:json'); - done() - }) - }) - - }) - - describe('and request succeeds and pipeline works ok', function() { - - it('emits done event without error', function(done) { - requestHandler = function(req, res) { res.end('{"ok":1}') } - - send_request({ json: true }).on('done', function(err) { - should.not.exist(err); - responseData.should.eql('{"ok":1}'); - done() - }) - }) - - }) - - }) - - describe('when piping to a fs writableStream', function() { - - var outFile = 'test/tmp.dat'; - - function send_request(opts, cb) { - return needle - .get('http://localhost:' + port, opts) - .pipe(fs.createWriteStream(outFile)) - .on('data', function(data) { responseData += data }) - } - - after(function(done) { - fs.unlink(outFile, done) - }) - - describe('and request stream fails', function() { - - it('final stream emits done event with error', function(done) { - requestHandler = function(req, res) { req.socket.destroy() } - - send_request({}).on('done', function(err) { - err.code.should.eql('ECONNRESET'); - done() - }) - }) - - }) - - describe('and request succeeds but decoding fails', function() { - - it('final stream emits done event without error', function(done) { - requestHandler = function(req, res) { - res.setHeader('Content-Type', 'application/json') - res.end('invalid:json') - } - - send_request({ json: true }).on('done', function(err) { - should.not.exist(err); - done() - }) - }) - - }) - - describe('and request succeeds and pipeline works ok', function() { - - it('final stream emits done event without error', function(done) { - requestHandler = function(req, res) { res.end('{"ok":1}') } - - send_request({ json: true }).on('done', function(err) { - should.not.exist(err); - done() - }) - }) - - }) - - }) - -}) \ No newline at end of file diff --git a/node_modules/needle/test/uri_modifier_spec.js b/node_modules/needle/test/uri_modifier_spec.js deleted file mode 100644 index 1a12a36c..00000000 --- a/node_modules/needle/test/uri_modifier_spec.js +++ /dev/null @@ -1,46 +0,0 @@ -var needle = require('../'), - sinon = require('sinon'), - should = require('should'), - http = require('http'), - helpers = require('./helpers'); - -var port = 3456; - -describe('uri_modifier config parameter function', function() { - - var server, uri; - - function send_request(mw, cb) { - needle.get(uri, { uri_modifier: mw }, cb); - } - - before(function(done){ - server = helpers.server({ port: port }, done); - }) - - after(function(done) { - server.close(done); - }) - - describe('modifies uri', function() { - - var path = '/foo/replace'; - - before(function() { - uri = 'localhost:' + port + path - }); - - it('should modify path', function(done) { - send_request(function(uri) { - return uri.replace('/replace', ''); - }, function(err, res) { - should.not.exist(err); - should(res.req.path).be.exactly('/foo'); - done(); - }); - - }); - - }) - -}) diff --git a/node_modules/needle/test/url_spec.js b/node_modules/needle/test/url_spec.js deleted file mode 100644 index 5154d584..00000000 --- a/node_modules/needle/test/url_spec.js +++ /dev/null @@ -1,155 +0,0 @@ -var needle = require('../'), - sinon = require('sinon'), - should = require('should'), - http = require('http'), - helpers = require('./helpers'); - -var port = 3456; - -describe('urls', function() { - - var server, url; - - function send_request(cb) { - return needle.get(url, cb); - } - - before(function(done){ - server = helpers.server({ port: port }, done); - }) - - after(function(done) { - server.close(done); - }) - - describe('null URL', function(){ - - it('throws', function(){ - (function() { - send_request() - }).should.throw(); - }) - - }) - - describe('invalid protocol', function(){ - - before(function() { - url = 'foo://google.com/what' - }) - - it('does not throw', function(done) { - (function() { - send_request(function(err) { - done(); - }) - }).should.not.throw() - }) - - it('returns an error', function(done) { - send_request(function(err) { - err.should.be.an.Error; - err.code.should.match(/ENOTFOUND|EADDRINFO|EAI_AGAIN/) - done(); - }) - }) - - }) - - describe('invalid host', function(){ - - before(function() { - url = 'http://s1\\\u0002.com/' - }) - - it('fails', function(done) { - (function() { - send_request(function(){ }) - }.should.throw(TypeError)) - done() - }) - - }) - -/* - describe('invalid path', function(){ - - before(function() { - url = 'http://www.google.com\\\/x\\\ %^&*() /x2.com/' - }) - - it('fails', function(done) { - send_request(function(err) { - err.should.be.an.Error; - done(); - }) - }) - - }) -*/ - - describe('valid protocol and path', function() { - - before(function() { - url = 'http://localhost:' + port + '/foo'; - }) - - it('works', function(done) { - send_request(function(err){ - should.not.exist(err); - done(); - }) - }) - - }) - - describe('no protocol but with slashes and valid path', function() { - - before(function() { - url = '//localhost:' + port + '/foo'; - }) - - it('works', function(done) { - send_request(function(err){ - should.not.exist(err); - done(); - }) - }) - - }) - - describe('no protocol nor slashes and valid path', function() { - - before(function() { - url = 'localhost:' + port + '/foo'; - }) - - it('works', function(done) { - send_request(function(err){ - should.not.exist(err); - done(); - }) - }) - - }) - - describe('double encoding', function() { - - var path = '/foo?email=' + encodeURIComponent('what-ever@Example.Com'); - - before(function() { - url = 'localhost:' + port + path - }); - - it('should not occur', function(done) { - send_request(function(err, res) { - should.not.exist(err); - should(res.req.path).be.exactly(path); - done(); - }); - - }); - - }) - -}) diff --git a/node_modules/needle/test/utils/formidable.js b/node_modules/needle/test/utils/formidable.js deleted file mode 100644 index ba1d983e..00000000 --- a/node_modules/needle/test/utils/formidable.js +++ /dev/null @@ -1,17 +0,0 @@ -var formidable = require('formidable'), - http = require('http'), - util = require('util'); - -var port = process.argv[2] || 8888; - -http.createServer(function(req, res) { - var form = new formidable.IncomingForm(); - form.parse(req, function(err, fields, files) { - res.writeHead(200, {'content-type': 'text/plain'}); - res.write('received upload:\n\n'); - console.log(util.inspect({fields: fields, files: files})) - res.end(util.inspect({fields: fields, files: files})); - }); -}).listen(port); - -console.log('HTTP server listening on port ' + port); \ No newline at end of file diff --git a/node_modules/needle/test/utils/proxy.js b/node_modules/needle/test/utils/proxy.js deleted file mode 100644 index 531bf493..00000000 --- a/node_modules/needle/test/utils/proxy.js +++ /dev/null @@ -1,62 +0,0 @@ -var http = require('http'), - https = require('https'), - url = require('url'); - -var port = 1234, - log = true, - request_auth = false; - -http.createServer(function(request, response) { - - console.log(request.headers); - console.log("Got request: " + request.url); - console.log("Forwarding request to " + request.headers['host']); - - if (request_auth) { - if (!request.headers['proxy-authorization']) { - response.writeHead(407, {'Proxy-Authenticate': 'Basic realm="proxy.com"'}) - return response.end('Hello.'); - } - } - - var remote = url.parse(request.url); - var protocol = remote.protocol == 'https:' ? https : http; - - var opts = { - host: request.headers['host'], - port: remote.port || (remote.protocol == 'https:' ? 443 : 80), - method: request.method, - path: remote.pathname, - headers: request.headers - } - - var proxy_request = protocol.request(opts, function(proxy_response){ - - proxy_response.on('data', function(chunk) { - if (log) console.log(chunk.toString()); - response.write(chunk, 'binary'); - }); - proxy_response.on('end', function() { - response.end(); - }); - - response.writeHead(proxy_response.statusCode, proxy_response.headers); - }); - - request.on('data', function(chunk) { - if (log) console.log(chunk.toString()); - proxy_request.write(chunk, 'binary'); - }); - - request.on('end', function() { - proxy_request.end(); - }); - -}).listen(port); - -process.on('uncaughtException', function(err){ - console.log('Uncaught exception!'); - console.log(err); -}); - -console.log("Proxy server listening on port " + port); diff --git a/node_modules/needle/test/utils/test.js b/node_modules/needle/test/utils/test.js deleted file mode 100644 index 8d58d70f..00000000 --- a/node_modules/needle/test/utils/test.js +++ /dev/null @@ -1,104 +0,0 @@ -// TODO: write specs. :) - -var fs = require('fs'), - client = require('./../../'); - -process.env.DEBUG = true; - -var response_callback = function(err, resp, body){ - console.log(err); - if(resp) console.log("Got status code " + resp.statusCode) - console.log(body); -} - -function simple_head(){ - client.head('http://www.amazon.com', response_callback); -} - -function simple_get(){ - client.get('http://www.nodejs.org', response_callback); -} - -function proxy_get(){ - client.get('https://www.google.com/search?q=nodejs', {proxy: 'http://localhost:1234'}, response_callback); -} - -function auth_get(){ - client.get('https://www.twitter.com', {username: 'asd', password: '123'}, response_callback); -} - -function simple_post(url){ - - var data = { - foo: 'bar', - baz: { - nested: 'attribute' - } - } - - client.post(url, data, response_callback); - -} - -function multipart_post(url){ - - var filename = 'test_file.txt'; - var data = 'Plain text data.\nLorem ipsum dolor sit amet.\nBla bla bla.\n'; - fs.writeFileSync(filename, data); - - var black_pixel = Buffer.from("data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=".replace(/^data:image\/\w+;base64,/, ""), "base64"); - - var data = { - foo: 'bar', - bar: 'baz', - nested: { - my_document: { file: filename, content_type: 'text/plain' }, - even: { - more: 'nesting' - } - }, - pixel: { filename: 'black_pixel.gif', buffer: black_pixel, content_type: 'image/gif' }, - field2: {value: JSON.stringify({"json":[ {"one":1}, {"two":2} ]}), content_type: 'application/json' } - } - - client.post(url, data, {multipart: true}, function(err, resp, body){ - - console.log(err); - console.log("Got status code " + resp.statusCode) - console.log(body); - fs.unlink(filename); - - }); - -} - -switch(process.argv[2]){ - case 'head': - simple_head(); - break; - case 'get': - simple_get(); - break; - case 'auth': - auth_get(); - break; - case 'proxy': - proxy_get(); - break; - case 'post': - simple_post(process.argv[3] || 'http://posttestserver.com/post.php'); - break; - case 'multipart': - multipart_post(process.argv[3] || 'http://posttestserver.com/post.php?dir=example'); - break; - case 'all': - simple_head(); - simple_get(); - auth_get(); - proxy_get(); - simple_post(process.argv[3] || 'http://posttestserver.com/post.php'); - multipart_post(process.argv[3] || 'http://posttestserver.com/post.php?dir=example'); - break; - default: - console.log("Usage: ./test.js [head|get|auth|proxy|multipart]") -} diff --git a/node_modules/prr/.jshintrc b/node_modules/prr/.jshintrc deleted file mode 100644 index 6a7a956c..00000000 --- a/node_modules/prr/.jshintrc +++ /dev/null @@ -1,61 +0,0 @@ -{ - "predef": [ ] - , "bitwise": false - , "camelcase": false - , "curly": false - , "eqeqeq": false - , "forin": false - , "immed": false - , "latedef": false - , "newcap": true - , "noarg": true - , "noempty": true - , "nonew": true - , "plusplus": false - , "quotmark": true - , "regexp": false - , "undef": true - , "unused": true - , "strict": false - , "trailing": true - , "maxlen": 120 - , "asi": true - , "boss": true - , "debug": true - , "eqnull": true - , "es5": true - , "esnext": true - , "evil": true - , "expr": true - , "funcscope": false - , "globalstrict": false - , "iterator": false - , "lastsemic": true - , "laxbreak": true - , "laxcomma": true - , "loopfunc": true - , "multistr": false - , "onecase": false - , "proto": false - , "regexdash": false - , "scripturl": true - , "smarttabs": false - , "shadow": false - , "sub": true - , "supernew": false - , "validthis": true - , "browser": true - , "couch": false - , "devel": false - , "dojo": false - , "mootools": false - , "node": true - , "nonstandard": true - , "prototypejs": false - , "rhino": false - , "worker": true - , "wsh": false - , "nomen": false - , "onevar": true - , "passfail": false -} \ No newline at end of file diff --git a/node_modules/prr/.npmignore b/node_modules/prr/.npmignore deleted file mode 100644 index b512c09d..00000000 --- a/node_modules/prr/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/node_modules/prr/.travis.yml b/node_modules/prr/.travis.yml deleted file mode 100644 index 33dcbc3a..00000000 --- a/node_modules/prr/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: node_js -node_js: - - 0.8 - - "0.10" -branches: - only: - - master -notifications: - email: - - rod@vagg.org \ No newline at end of file diff --git a/node_modules/prr/LICENSE.md b/node_modules/prr/LICENSE.md deleted file mode 100644 index 29b95e39..00000000 --- a/node_modules/prr/LICENSE.md +++ /dev/null @@ -1,11 +0,0 @@ -The MIT License (MIT) -===================== - -Copyright (c) 2014 Rod Vagg ---------------------------- - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/prr/README.md b/node_modules/prr/README.md deleted file mode 100644 index b9340482..00000000 --- a/node_modules/prr/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# prr [![Build Status](https://secure.travis-ci.org/rvagg/prr.png)](http://travis-ci.org/rvagg/prr) - -An sensible alternative to `Object.defineProperty()`. Available in npm and Ender as **prr**. - -## Usage - -Set the property `'foo'` (`obj.foo`) to have the value `'bar'` with default options (`'enumerable'`, `'configurable'` and `'writable'` are all `false`): - -```js -prr(obj, 'foo', 'bar') -``` - -Adjust the default options: - -```js -prr(obj, 'foo', 'bar', { enumerable: true, writable: true }) -``` - -Do the same operation for multiple properties: - -```js -prr(obj, { one: 'one', two: 'two' }) -// or with options: -prr(obj, { one: 'one', two: 'two' }, { enumerable: true, writable: true }) -``` - -### Simplify! - -But obviously, having to write out the full options object makes it nearly as bad as the original `Object.defineProperty()` so we can simplify. - -As an alternative method we can use an options string where each character represents a option: `'e'=='enumerable'`, `'c'=='configurable'` and `'w'=='writable'`: - -```js -prr(obj, 'foo', 'bar', 'ew') // enumerable and writable but not configurable -// muliple properties: -prr(obj, { one: 'one', two: 'two' }, 'ewc') // configurable too -``` - -## Where can I use it? - -Anywhere! For pre-ES5 environments *prr* will simply fall-back to an `object[property] = value` so you can get close to what you want. - -*prr* is Ender-compatible so you can include it in your Ender build and `$.prr(...)` or `var prr = require('prr'); prr(...)`. - -## Licence - -prr is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. diff --git a/node_modules/prr/package.json b/node_modules/prr/package.json deleted file mode 100644 index 5d298e59..00000000 --- a/node_modules/prr/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "prr", - "description": "A better Object.defineProperty()", - "version": "1.0.1", - "homepage": "https://github.com/rvagg/prr", - "author": "Rod Vagg (https://github.com/rvagg)", - "keywords": [ - "property", - "properties", - "defineProperty", - "ender" - ], - "main": "./prr.js", - "repository": { - "type": "git", - "url": "https://github.com/rvagg/prr.git" - }, - "dependencies": {}, - "devDependencies": { - "tap": "*" - }, - "scripts": { - "test": "node ./test.js" - }, - "license": "MIT" -} diff --git a/node_modules/prr/prr.js b/node_modules/prr/prr.js deleted file mode 100644 index 94f58628..00000000 --- a/node_modules/prr/prr.js +++ /dev/null @@ -1,63 +0,0 @@ -/*! - * prr - * (c) 2013 Rod Vagg - * https://github.com/rvagg/prr - * License: MIT - */ - -(function (name, context, definition) { - if (typeof module != 'undefined' && module.exports) - module.exports = definition() - else - context[name] = definition() -})('prr', this, function() { - - var setProperty = typeof Object.defineProperty == 'function' - ? function (obj, key, options) { - Object.defineProperty(obj, key, options) - return obj - } - : function (obj, key, options) { // < es5 - obj[key] = options.value - return obj - } - - , makeOptions = function (value, options) { - var oo = typeof options == 'object' - , os = !oo && typeof options == 'string' - , op = function (p) { - return oo - ? !!options[p] - : os - ? options.indexOf(p[0]) > -1 - : false - } - - return { - enumerable : op('enumerable') - , configurable : op('configurable') - , writable : op('writable') - , value : value - } - } - - , prr = function (obj, key, value, options) { - var k - - options = makeOptions(value, options) - - if (typeof key == 'object') { - for (k in key) { - if (Object.hasOwnProperty.call(key, k)) { - options.value = key[k] - setProperty(obj, k, options) - } - } - return obj - } - - return setProperty(obj, key, options) - } - - return prr -}) \ No newline at end of file diff --git a/node_modules/prr/test.js b/node_modules/prr/test.js deleted file mode 100644 index 5222e307..00000000 --- a/node_modules/prr/test.js +++ /dev/null @@ -1,169 +0,0 @@ -const test = require('tap').test - , prr = require('./') - -test('test prr(o, key, value) form', function (t) { - t.plan(2) - - var o = {} - prr(o, 'foo', 'bar') - t.equal(o.foo, 'bar', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo') - , { - enumerable : false - , configurable : false - , writable : false - , value : 'bar' - } - , 'correct property descriptor' - ) - t.end() -}) - -test('test prr(o, { key: value }) form', function (t) { - t.plan(2) - - var o = {} - prr(o, { foo: 'bar' }) - - t.equal(o.foo, 'bar', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo') - , { - enumerable : false - , configurable : false - , writable : false - , value : 'bar' - } - , 'correct property descriptor' - ) - t.end() -}) - -test('test multiple key:value pairs', function (t) { - var o = { foo: 'bar' } - - prr(o, { one: 'ONE', two: 'TWO', obj: { o: 'o' }}) - - t.deepEqual(o, { foo: 'bar' }, 'properties are not enumerable') - t.equal(o.one, 'ONE', 'correctly set property') - t.equal(o.two, 'TWO', 'correctly set property') - t.deepEqual(o.obj, { o: 'o' }, 'correctly set property') - - ;[ 'one', 'two', 'obj' ].forEach(function (p) { - t.deepEqual( - Object.getOwnPropertyDescriptor(o, p) - , { - enumerable : false - , configurable : false - , writable : false - , value : p == 'obj' ? { o: 'o' } : p.toUpperCase() - } - , 'correct property descriptor' - ) - }) - - t.end() -}) - -test('test descriptor options', function (t) { - var o = {} - - prr(o, 'foo', 'bar', { - enumerable : true - , configurable : false - }) - t.equal(o.foo, 'bar', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo') - , { - enumerable : true - , configurable : false - , writable : false - , value : 'bar' - } - , 'correct property descriptor' - ) - - prr(o, 'foo2', 'bar2', { - enumerable : true - , configurable : true - , writable : false - }) - t.equal(o.foo2, 'bar2', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo2') - , { - enumerable : true - , configurable : true - , writable : false - , value : 'bar2' - } - , 'correct property descriptor' - ) - - prr(o, 'foo3', 'bar3', { - enumerable : true - , configurable : true - , writable : true - }) - t.equal(o.foo3, 'bar3', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo3') - , { - enumerable : true - , configurable : true - , writable : true - , value : 'bar3' - } - , 'correct property descriptor' - ) - - t.end() -}) - - -test('test descriptor options, string form', function (t) { - var o = {} - - prr(o, 'foo', 'bar', 'e') - t.equal(o.foo, 'bar', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo') - , { - enumerable : true - , configurable : false - , writable : false - , value : 'bar' - } - , 'correct property descriptor' - ) - - prr(o, 'foo2', 'bar2', 'ec') - t.equal(o.foo2, 'bar2', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo2') - , { - enumerable : true - , configurable : true - , writable : false - , value : 'bar2' - } - , 'correct property descriptor' - ) - - prr(o, 'foo3', 'bar3', 'ecw') - t.equal(o.foo3, 'bar3', 'correct value') - t.deepEqual( - Object.getOwnPropertyDescriptor(o, 'foo3') - , { - enumerable : true - , configurable : true - , writable : true - , value : 'bar3' - } - , 'correct property descriptor' - ) - - t.end() -}) diff --git a/node_modules/sax/LICENSE b/node_modules/sax/LICENSE deleted file mode 100644 index ccffa082..00000000 --- a/node_modules/sax/LICENSE +++ /dev/null @@ -1,41 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -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. - -==== - -`String.fromCodePoint` by Mathias Bynens used according to terms of MIT -License, as follows: - - Copyright Mathias Bynens - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/sax/README.md b/node_modules/sax/README.md deleted file mode 100644 index afcd3f3d..00000000 --- a/node_modules/sax/README.md +++ /dev/null @@ -1,225 +0,0 @@ -# sax js - -A sax-style parser for XML and HTML. - -Designed with [node](http://nodejs.org/) in mind, but should work fine in -the browser or other CommonJS implementations. - -## What This Is - -* A very simple tool to parse through an XML string. -* A stepping stone to a streaming HTML parser. -* A handy way to deal with RSS and other mostly-ok-but-kinda-broken XML - docs. - -## What This Is (probably) Not - -* An HTML Parser - That's a fine goal, but this isn't it. It's just - XML. -* A DOM Builder - You can use it to build an object model out of XML, - but it doesn't do that out of the box. -* XSLT - No DOM = no querying. -* 100% Compliant with (some other SAX implementation) - Most SAX - implementations are in Java and do a lot more than this does. -* An XML Validator - It does a little validation when in strict mode, but - not much. -* A Schema-Aware XSD Thing - Schemas are an exercise in fetishistic - masochism. -* A DTD-aware Thing - Fetching DTDs is a much bigger job. - -## Regarding `Hello, world!').close(); - -// stream usage -// takes the same options as the parser -var saxStream = require("sax").createStream(strict, options) -saxStream.on("error", function (e) { - // unhandled errors will throw, since this is a proper node - // event emitter. - console.error("error!", e) - // clear the error - this._parser.error = null - this._parser.resume() -}) -saxStream.on("opentag", function (node) { - // same object as above -}) -// pipe is supported, and it's readable/writable -// same chunks coming in also go out. -fs.createReadStream("file.xml") - .pipe(saxStream) - .pipe(fs.createWriteStream("file-copy.xml")) -``` - - -## Arguments - -Pass the following arguments to the parser function. All are optional. - -`strict` - Boolean. Whether or not to be a jerk. Default: `false`. - -`opt` - Object bag of settings regarding string formatting. All default to `false`. - -Settings supported: - -* `trim` - Boolean. Whether or not to trim text and comment nodes. -* `normalize` - Boolean. If true, then turn any whitespace into a single - space. -* `lowercase` - Boolean. If true, then lowercase tag names and attribute names - in loose mode, rather than uppercasing them. -* `xmlns` - Boolean. If true, then namespaces are supported. -* `position` - Boolean. If false, then don't track line/col/position. -* `strictEntities` - Boolean. If true, only parse [predefined XML - entities](http://www.w3.org/TR/REC-xml/#sec-predefined-ent) - (`&`, `'`, `>`, `<`, and `"`) - -## Methods - -`write` - Write bytes onto the stream. You don't have to do this all at -once. You can keep writing as much as you want. - -`close` - Close the stream. Once closed, no more data may be written until -it is done processing the buffer, which is signaled by the `end` event. - -`resume` - To gracefully handle errors, assign a listener to the `error` -event. Then, when the error is taken care of, you can call `resume` to -continue parsing. Otherwise, the parser will not continue while in an error -state. - -## Members - -At all times, the parser object will have the following members: - -`line`, `column`, `position` - Indications of the position in the XML -document where the parser currently is looking. - -`startTagPosition` - Indicates the position where the current tag starts. - -`closed` - Boolean indicating whether or not the parser can be written to. -If it's `true`, then wait for the `ready` event to write again. - -`strict` - Boolean indicating whether or not the parser is a jerk. - -`opt` - Any options passed into the constructor. - -`tag` - The current tag being dealt with. - -And a bunch of other stuff that you probably shouldn't touch. - -## Events - -All events emit with a single argument. To listen to an event, assign a -function to `on`. Functions get executed in the this-context of -the parser object. The list of supported events are also in the exported -`EVENTS` array. - -When using the stream interface, assign handlers using the EventEmitter -`on` function in the normal fashion. - -`error` - Indication that something bad happened. The error will be hanging -out on `parser.error`, and must be deleted before parsing can continue. By -listening to this event, you can keep an eye on that kind of stuff. Note: -this happens *much* more in strict mode. Argument: instance of `Error`. - -`text` - Text node. Argument: string of text. - -`doctype` - The ``. Argument: -object with `name` and `body` members. Attributes are not parsed, as -processing instructions have implementation dependent semantics. - -`sgmldeclaration` - Random SGML declarations. Stuff like `` -would trigger this kind of event. This is a weird thing to support, so it -might go away at some point. SAX isn't intended to be used to parse SGML, -after all. - -`opentagstart` - Emitted immediately when the tag name is available, -but before any attributes are encountered. Argument: object with a -`name` field and an empty `attributes` set. Note that this is the -same object that will later be emitted in the `opentag` event. - -`opentag` - An opening tag. Argument: object with `name` and `attributes`. -In non-strict mode, tag names are uppercased, unless the `lowercase` -option is set. If the `xmlns` option is set, then it will contain -namespace binding information on the `ns` member, and will have a -`local`, `prefix`, and `uri` member. - -`closetag` - A closing tag. In loose mode, tags are auto-closed if their -parent closes. In strict mode, well-formedness is enforced. Note that -self-closing tags will have `closeTag` emitted immediately after `openTag`. -Argument: tag name. - -`attribute` - An attribute node. Argument: object with `name` and `value`. -In non-strict mode, attribute names are uppercased, unless the `lowercase` -option is set. If the `xmlns` option is set, it will also contains namespace -information. - -`comment` - A comment node. Argument: the string of the comment. - -`opencdata` - The opening tag of a ``) of a `` tags trigger a `"script"` -event, and their contents are not checked for special xml characters. -If you pass `noscript: true`, then this behavior is suppressed. - -## Reporting Problems - -It's best to write a failing test if you find an issue. I will always -accept pull requests with failing tests if they demonstrate intended -behavior, but it is very hard to figure out what issue you're describing -without a test. Writing a test is also the best way for you yourself -to figure out if you really understand the issue you think you have with -sax-js. diff --git a/node_modules/sax/lib/sax.js b/node_modules/sax/lib/sax.js deleted file mode 100644 index 795d607e..00000000 --- a/node_modules/sax/lib/sax.js +++ /dev/null @@ -1,1565 +0,0 @@ -;(function (sax) { // wrapper for non-node envs - sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } - sax.SAXParser = SAXParser - sax.SAXStream = SAXStream - sax.createStream = createStream - - // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. - // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), - // since that's the earliest that a buffer overrun could occur. This way, checks are - // as rare as required, but as often as necessary to ensure never crossing this bound. - // Furthermore, buffers are only tested at most once per write(), so passing a very - // large string into write() might have undesirable effects, but this is manageable by - // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme - // edge case, result in creating at most one complete copy of the string passed in. - // Set to Infinity to have unlimited buffers. - sax.MAX_BUFFER_LENGTH = 64 * 1024 - - var buffers = [ - 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', - 'procInstName', 'procInstBody', 'entity', 'attribName', - 'attribValue', 'cdata', 'script' - ] - - sax.EVENTS = [ - 'text', - 'processinginstruction', - 'sgmldeclaration', - 'doctype', - 'comment', - 'opentagstart', - 'attribute', - 'opentag', - 'closetag', - 'opencdata', - 'cdata', - 'closecdata', - 'error', - 'end', - 'ready', - 'script', - 'opennamespace', - 'closenamespace' - ] - - function SAXParser (strict, opt) { - if (!(this instanceof SAXParser)) { - return new SAXParser(strict, opt) - } - - var parser = this - clearBuffers(parser) - parser.q = parser.c = '' - parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH - parser.opt = opt || {} - parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags - parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase' - parser.tags = [] - parser.closed = parser.closedRoot = parser.sawRoot = false - parser.tag = parser.error = null - parser.strict = !!strict - parser.noscript = !!(strict || parser.opt.noscript) - parser.state = S.BEGIN - parser.strictEntities = parser.opt.strictEntities - parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES) - parser.attribList = [] - - // namespaces form a prototype chain. - // it always points at the current tag, - // which protos to its parent tag. - if (parser.opt.xmlns) { - parser.ns = Object.create(rootNS) - } - - // mostly just for error reporting - parser.trackPosition = parser.opt.position !== false - if (parser.trackPosition) { - parser.position = parser.line = parser.column = 0 - } - emit(parser, 'onready') - } - - if (!Object.create) { - Object.create = function (o) { - function F () {} - F.prototype = o - var newf = new F() - return newf - } - } - - if (!Object.keys) { - Object.keys = function (o) { - var a = [] - for (var i in o) if (o.hasOwnProperty(i)) a.push(i) - return a - } - } - - function checkBufferLength (parser) { - var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10) - var maxActual = 0 - for (var i = 0, l = buffers.length; i < l; i++) { - var len = parser[buffers[i]].length - if (len > maxAllowed) { - // Text/cdata nodes can get big, and since they're buffered, - // we can get here under normal conditions. - // Avoid issues by emitting the text node now, - // so at least it won't get any bigger. - switch (buffers[i]) { - case 'textNode': - closeText(parser) - break - - case 'cdata': - emitNode(parser, 'oncdata', parser.cdata) - parser.cdata = '' - break - - case 'script': - emitNode(parser, 'onscript', parser.script) - parser.script = '' - break - - default: - error(parser, 'Max buffer length exceeded: ' + buffers[i]) - } - } - maxActual = Math.max(maxActual, len) - } - // schedule the next check for the earliest possible buffer overrun. - var m = sax.MAX_BUFFER_LENGTH - maxActual - parser.bufferCheckPosition = m + parser.position - } - - function clearBuffers (parser) { - for (var i = 0, l = buffers.length; i < l; i++) { - parser[buffers[i]] = '' - } - } - - function flushBuffers (parser) { - closeText(parser) - if (parser.cdata !== '') { - emitNode(parser, 'oncdata', parser.cdata) - parser.cdata = '' - } - if (parser.script !== '') { - emitNode(parser, 'onscript', parser.script) - parser.script = '' - } - } - - SAXParser.prototype = { - end: function () { end(this) }, - write: write, - resume: function () { this.error = null; return this }, - close: function () { return this.write(null) }, - flush: function () { flushBuffers(this) } - } - - var Stream - try { - Stream = require('stream').Stream - } catch (ex) { - Stream = function () {} - } - - var streamWraps = sax.EVENTS.filter(function (ev) { - return ev !== 'error' && ev !== 'end' - }) - - function createStream (strict, opt) { - return new SAXStream(strict, opt) - } - - function SAXStream (strict, opt) { - if (!(this instanceof SAXStream)) { - return new SAXStream(strict, opt) - } - - Stream.apply(this) - - this._parser = new SAXParser(strict, opt) - this.writable = true - this.readable = true - - var me = this - - this._parser.onend = function () { - me.emit('end') - } - - this._parser.onerror = function (er) { - me.emit('error', er) - - // if didn't throw, then means error was handled. - // go ahead and clear error, so we can write again. - me._parser.error = null - } - - this._decoder = null - - streamWraps.forEach(function (ev) { - Object.defineProperty(me, 'on' + ev, { - get: function () { - return me._parser['on' + ev] - }, - set: function (h) { - if (!h) { - me.removeAllListeners(ev) - me._parser['on' + ev] = h - return h - } - me.on(ev, h) - }, - enumerable: true, - configurable: false - }) - }) - } - - SAXStream.prototype = Object.create(Stream.prototype, { - constructor: { - value: SAXStream - } - }) - - SAXStream.prototype.write = function (data) { - if (typeof Buffer === 'function' && - typeof Buffer.isBuffer === 'function' && - Buffer.isBuffer(data)) { - if (!this._decoder) { - var SD = require('string_decoder').StringDecoder - this._decoder = new SD('utf8') - } - data = this._decoder.write(data) - } - - this._parser.write(data.toString()) - this.emit('data', data) - return true - } - - SAXStream.prototype.end = function (chunk) { - if (chunk && chunk.length) { - this.write(chunk) - } - this._parser.end() - return true - } - - SAXStream.prototype.on = function (ev, handler) { - var me = this - if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) { - me._parser['on' + ev] = function () { - var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments) - args.splice(0, 0, ev) - me.emit.apply(me, args) - } - } - - return Stream.prototype.on.call(me, ev, handler) - } - - // this really needs to be replaced with character classes. - // XML allows all manner of ridiculous numbers and digits. - var CDATA = '[CDATA[' - var DOCTYPE = 'DOCTYPE' - var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace' - var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/' - var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE } - - // http://www.w3.org/TR/REC-xml/#NT-NameStartChar - // This implementation works on strings, a single character at a time - // as such, it cannot ever support astral-plane characters (10000-EFFFF) - // without a significant breaking change to either this parser, or the - // JavaScript language. Implementation of an emoji-capable xml parser - // is left as an exercise for the reader. - var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ - - var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/ - - var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ - var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/ - - function isWhitespace (c) { - return c === ' ' || c === '\n' || c === '\r' || c === '\t' - } - - function isQuote (c) { - return c === '"' || c === '\'' - } - - function isAttribEnd (c) { - return c === '>' || isWhitespace(c) - } - - function isMatch (regex, c) { - return regex.test(c) - } - - function notMatch (regex, c) { - return !isMatch(regex, c) - } - - var S = 0 - sax.STATE = { - BEGIN: S++, // leading byte order mark or whitespace - BEGIN_WHITESPACE: S++, // leading whitespace - TEXT: S++, // general stuff - TEXT_ENTITY: S++, // & and such. - OPEN_WAKA: S++, // < - SGML_DECL: S++, // - SCRIPT: S++, //