From f918994bd05ca965766cd573606ac35fb3032d6e Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 10 Aug 2016 17:44:56 -0700 Subject: [PATCH] request@2.74.0 tough-cookie@2.3.0 To address https://nodesecurity.io/advisories/130 Versions 0.9.7 through 2.2.2 contain a vulnerable regular expression that, under certain conditions involving long strings of semicolons in the "Set-Cookie" header, causes the event loop to block for excessive amounts of time. Credit: @stash-sfdc --- node_modules/request/.travis.yml | 4 +- node_modules/request/CHANGELOG.md | 38 +- node_modules/request/README.md | 5 +- node_modules/request/codecov.yml | 2 + .../node_modules/aws-sign2/package.json | 2 +- .../request/node_modules/aws4/aws4.js | 2 +- node_modules/request/node_modules/aws4/lru.js | 96 ++++ .../request/node_modules/aws4/package.json | 23 +- .../node_modules/core-util-is/package.json | 2 +- .../node_modules/isarray/package.json | 2 +- .../node_modules/string_decoder/package.json | 2 +- .../node_modules/util-deprecate/package.json | 2 +- .../node_modules/caseless/package.json | 2 +- .../node_modules/delayed-stream/package.json | 2 +- .../node_modules/combined-stream/package.json | 2 +- .../node_modules/forever-agent/package.json | 2 +- .../form-data/node_modules/async/package.json | 35 +- .../node_modules/form-data/package.json | 2 +- .../node_modules/supports-color/package.json | 2 +- .../graceful-readlink/package.json | 2 +- .../generate-function/package.json | 2 +- .../node_modules/is-property/package.json | 2 +- .../generate-object-property/package.json | 2 +- .../node_modules/xtend/package.json | 23 +- .../node_modules/pinkie/package.json | 2 +- .../hawk/node_modules/cryptiles/package.json | 2 +- .../hawk/node_modules/sntp/package.json | 2 +- .../node_modules/assert-plus/package.json | 2 +- .../node_modules/jsprim/CHANGES.md | 5 + .../node_modules/jsprim/README.md | 17 +- .../node_modules/jsprim/lib/jsprim.js | 14 +- .../node_modules/extsprintf/package.json | 2 +- .../node_modules/jsprim/package.json | 24 +- .../node_modules/sshpk/README.md | 217 +++++++- .../node_modules/sshpk/lib/certificate.js | 291 +++++++++++ .../node_modules/sshpk/lib/errors.js | 15 +- .../node_modules/sshpk/lib/fingerprint.js | 35 +- .../sshpk/lib/formats/openssh-cert.js | 289 +++++++++++ .../node_modules/sshpk/lib/formats/pkcs8.js | 9 +- .../sshpk/lib/formats/x509-pem.js | 77 +++ .../node_modules/sshpk/lib/formats/x509.js | 484 ++++++++++++++++++ .../node_modules/sshpk/lib/identity.js | 255 +++++++++ .../node_modules/sshpk/lib/index.js | 14 +- .../node_modules/sshpk/lib/key.js | 1 + .../node_modules/sshpk/lib/signature.js | 20 +- .../node_modules/sshpk/lib/ssh-buffer.js | 24 + .../node_modules/assert-plus/package.json | 2 +- .../node_modules/dashdash/lib/dashdash.js | 33 ++ .../sshpk/node_modules/dashdash/package.json | 18 +- .../sshpk/node_modules/ecc-jsbn/package.json | 2 +- .../node_modules/jodid25519/package.json | 2 +- .../sshpk/node_modules/jsbn/package.json | 2 +- .../node_modules/sshpk/package.json | 26 +- .../node_modules/http-signature/package.json | 2 +- .../node_modules/is-typedarray/package.json | 2 +- .../node_modules/isstream/package.json | 2 +- .../request/node_modules/qs/.npmignore | 18 - .../request/node_modules/qs/.travis.yml | 69 --- .../request/node_modules/qs/CHANGELOG.md | 17 +- .../request/node_modules/qs/README.md | 41 ++ .../request/node_modules/qs/bower.json | 21 - .../request/node_modules/qs/component.json | 15 - .../request/node_modules/qs/dist/qs.js | 158 +++--- .../request/node_modules/qs/lib/parse.js | 82 +-- .../request/node_modules/qs/lib/stringify.js | 66 +-- .../request/node_modules/qs/lib/utils.js | 10 +- .../request/node_modules/qs/package.json | 39 +- .../request/node_modules/qs/test/parse.js | 68 ++- .../request/node_modules/qs/test/stringify.js | 54 +- .../node_modules/stringstream/package.json | 2 +- .../node_modules/tough-cookie/README.md | 20 +- .../node_modules/tough-cookie/lib/cookie.js | 18 +- .../node_modules/tough-cookie/package.json | 33 +- node_modules/request/package.json | 44 +- node_modules/request/request.js | 32 +- package.json | 2 +- 76 files changed, 2403 insertions(+), 556 deletions(-) create mode 100644 node_modules/request/codecov.yml create mode 100644 node_modules/request/node_modules/aws4/lru.js create mode 100644 node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/certificate.js create mode 100644 node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/openssh-cert.js create mode 100644 node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509-pem.js create mode 100644 node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509.js create mode 100644 node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/identity.js delete mode 100644 node_modules/request/node_modules/qs/.npmignore delete mode 100644 node_modules/request/node_modules/qs/.travis.yml delete mode 100644 node_modules/request/node_modules/qs/bower.json delete mode 100644 node_modules/request/node_modules/qs/component.json diff --git a/node_modules/request/.travis.yml b/node_modules/request/.travis.yml index e5d9bde2626..6f2d753b615 100644 --- a/node_modules/request/.travis.yml +++ b/node_modules/request/.travis.yml @@ -1,13 +1,15 @@ + language: node_js node_js: - node + - 4 - 0.12 - 0.10 after_script: - npm run test-cov - - cat ./coverage/lcov.info | codecov + - codecov - cat ./coverage/lcov.info | coveralls webhooks: diff --git a/node_modules/request/CHANGELOG.md b/node_modules/request/CHANGELOG.md index ce6826f2f65..2b5d17765a8 100644 --- a/node_modules/request/CHANGELOG.md +++ b/node_modules/request/CHANGELOG.md @@ -1,5 +1,24 @@ ## Change Log +### v2.74.0 (2016/07/22) +- [#2295](https://github.com/request/request/pull/2295) Update tough-cookie to 2.3.0 (@stash-sfdc) +- [#2280](https://github.com/request/request/pull/2280) Update karma-tap to version 2.0.1 πŸš€ (@greenkeeperio-bot) + +### v2.73.0 (2016/07/09) +- [#2240](https://github.com/request/request/pull/2240) Remove connectionErrorHandler to fix #1903 (@zarenner) +- [#2251](https://github.com/request/request/pull/2251) tape@4.6.0 breaks build 🚨 (@greenkeeperio-bot) +- [#2225](https://github.com/request/request/pull/2225) Update docs (@ArtskydJ) +- [#2203](https://github.com/request/request/pull/2203) Update browserify to version 13.0.1 πŸš€ (@greenkeeperio-bot) +- [#2275](https://github.com/request/request/pull/2275) Update karma to version 1.1.1 πŸš€ (@greenkeeperio-bot) +- [#2204](https://github.com/request/request/pull/2204) Add codecov.yml and disable PR comments (@simov) +- [#2212](https://github.com/request/request/pull/2212) Fix link to http.IncomingMessage documentation (@nazieb) +- [#2208](https://github.com/request/request/pull/2208) Update to form-data RC4 and pass null values to it (@simov) +- [#2207](https://github.com/request/request/pull/2207) Move aws4 require statement to the top (@simov) +- [#2199](https://github.com/request/request/pull/2199) Update karma-coverage to version 1.0.0 πŸš€ (@greenkeeperio-bot) +- [#2206](https://github.com/request/request/pull/2206) Update qs to version 6.2.0 πŸš€ (@greenkeeperio-bot) +- [#2205](https://github.com/request/request/pull/2205) Use server-destory to close hanging sockets in tests (@simov) +- [#2200](https://github.com/request/request/pull/2200) Update karma-cli to version 1.0.0 πŸš€ (@greenkeeperio-bot) + ### v2.72.0 (2016/04/17) - [#2176](https://github.com/request/request/pull/2176) Do not try to pipe Gzip responses with no body (@simov) - [#2175](https://github.com/request/request/pull/2175) Add 'delete' alias for the 'del' API method (@simov, @MuhanZou) @@ -53,7 +72,7 @@ - [#1902](https://github.com/request/request/pull/1902) node-uuid@1.4.7 breaks build 🚨 (@greenkeeperio-bot) - [#1894](https://github.com/request/request/pull/1894) Fix tunneling after redirection from https (Original: #1881) (@simov, @falms) - [#1893](https://github.com/request/request/pull/1893) Update eslint to version 1.9.0 πŸš€ (@greenkeeperio-bot) -- [#1852](https://github.com/request/request/pull/1852) Update eslint to version 1.7.3 πŸš€ (@simov, @greenkeeperio-bot, @paulomcnally, @michelsalib, @arbaaz, @vladimirich, @LoicMahieu, @JoshWillik, @jzaefferer, @ryanwholey, @djchie, @thisconnect, @mgenereu, @acroca, @Sebmaster, @Bloutiouf) +- [#1852](https://github.com/request/request/pull/1852) Update eslint to version 1.7.3 πŸš€ (@simov, @greenkeeperio-bot, @paulomcnally, @michelsalib, @arbaaz, @vladimirich, @LoicMahieu, @JoshWillik, @jzaefferer, @ryanwholey, @djchie, @thisconnect, @mgenereu, @acroca, @Sebmaster, @KoltesDigital) - [#1876](https://github.com/request/request/pull/1876) Implement loose matching for har mime types (@simov) - [#1875](https://github.com/request/request/pull/1875) Update bluebird to version 3.0.2 πŸš€ (@simov, @greenkeeperio-bot) - [#1871](https://github.com/request/request/pull/1871) Update browserify to version 12.0.1 πŸš€ (@greenkeeperio-bot) @@ -64,7 +83,7 @@ - [#1857](https://github.com/request/request/pull/1857) Fix Referer header to point to the original host name (@simov) - [#1850](https://github.com/request/request/pull/1850) Update karma-coverage to version 0.5.3 πŸš€ (@greenkeeperio-bot) - [#1847](https://github.com/request/request/pull/1847) Use node's latest version when building (@simov) -- [#1836](https://github.com/request/request/pull/1836) Tunnel: fix wrong property name (@Bloutiouf) +- [#1836](https://github.com/request/request/pull/1836) Tunnel: fix wrong property name (@KoltesDigital) - [#1820](https://github.com/request/request/pull/1820) Set href as request.js uses it (@mgenereu) - [#1840](https://github.com/request/request/pull/1840) Update http-signature to version 1.0.2 πŸš€ (@greenkeeperio-bot) - [#1845](https://github.com/request/request/pull/1845) Update istanbul to version 0.4.0 πŸš€ (@greenkeeperio-bot) @@ -114,8 +133,7 @@ - [#1687](https://github.com/request/request/pull/1687) Fix caseless bug - content-type not being set for multipart/form-data (@simov, @garymathews) ### v2.59.0 (2015/07/20) -- [#1671](https://github.com/request/request/pull/1671) Add tests and docs for using the agent, agentClass, agentOptions and forever options. - Forever option defaults to using http(s).Agent in node 0.12+ (@simov) +- [#1671](https://github.com/request/request/pull/1671) Add tests and docs for using the agent, agentClass, agentOptions and forever options. Forever option defaults to using http(s).Agent in node 0.12+ (@simov) - [#1679](https://github.com/request/request/pull/1679) Fix - do not remove OAuth param when using OAuth realm (@simov, @jhalickman) - [#1668](https://github.com/request/request/pull/1668) updated dependencies (@deamme) - [#1656](https://github.com/request/request/pull/1656) Fix form method (@simov) @@ -182,7 +200,7 @@ - [#1460](https://github.com/request/request/pull/1460) localAddress or proxy config is lost when redirecting (@simov, @0x4139) - [#1453](https://github.com/request/request/pull/1453) Test on Node.js 0.12 and io.js with allowed failures (@nicolasmccurdy, @demohi) - [#1426](https://github.com/request/request/pull/1426) Fixing tests to pass on io.js and node 0.12 (only test-https.js stiff failing) (@mikeal) -- [#1446](https://github.com/request/request/pull/1446) Missing HTTP referer header with redirects Fixes #1038 (@simov, @guimonz) +- [#1446](https://github.com/request/request/pull/1446) Missing HTTP referer header with redirects Fixes #1038 (@simov, @guimon) - [#1428](https://github.com/request/request/pull/1428) Deprecate Node v0.8.x (@nylen) - [#1436](https://github.com/request/request/pull/1436) Add ability to set a requester without setting default options (@tikotzky) - [#1435](https://github.com/request/request/pull/1435) dry up verb methods (@sethpollack) @@ -310,7 +328,7 @@ - [#1131](https://github.com/request/request/pull/1131) Update pool documentation (@FredKSchott) - [#1143](https://github.com/request/request/pull/1143) Rewrite all tests to use tape (@nylen) - [#1137](https://github.com/request/request/pull/1137) Add ability to specifiy querystring lib in options. (@jgrund) -- [#1138](https://github.com/request/request/pull/1138) allow hostname and port in place of host on uri (@cappslock) +- [#1138](https://github.com/request/request/pull/1138) allow hostname and port in place of host on uri (@slimelabs) - [#1134](https://github.com/request/request/pull/1134) Fix multiple redirects and `self.followRedirect` (@blakeembrey) - [#1130](https://github.com/request/request/pull/1130) documentation fix: add note about npm test for contributing (@FredKSchott) - [#1120](https://github.com/request/request/pull/1120) Support/refactor request setup tunnel (@seanstrom) @@ -479,28 +497,20 @@ - [#596](https://github.com/request/request/pull/596) Global agent is being used when pool is specified (@Cauldrath) - [#594](https://github.com/request/request/pull/594) Emit complete event when there is no callback (@RomainLK) - [#601](https://github.com/request/request/pull/601) Fixed a small typo (@michalstanko) - -### v2.23.0 (2013/07/23) - [#589](https://github.com/request/request/pull/589) Prevent setting headers after they are sent (@geek) - [#587](https://github.com/request/request/pull/587) Global cookie jar disabled by default (@threepointone) - -### v2.22.0 (2013/07/05) - [#544](https://github.com/request/request/pull/544) Update http-signature version. (@davidlehn) - [#581](https://github.com/request/request/pull/581) Fix spelling of "ignoring." (@bigeasy) - [#568](https://github.com/request/request/pull/568) use agentOptions to create agent when specified in request (@SamPlacette) - [#564](https://github.com/request/request/pull/564) Fix redirections (@criloz) - [#541](https://github.com/request/request/pull/541) The exported request function doesn't have an auth method (@tschaub) - [#542](https://github.com/request/request/pull/542) Expose Request class (@regality) - -### v2.21.0 (2013/04/30) - [#536](https://github.com/request/request/pull/536) Allow explicitly empty user field for basic authentication. (@mikeando) - [#532](https://github.com/request/request/pull/532) fix typo (@fredericosilva) - [#497](https://github.com/request/request/pull/497) Added redirect event (@Cauldrath) - [#503](https://github.com/request/request/pull/503) Fix basic auth for passwords that contain colons (@tonistiigi) - [#521](https://github.com/request/request/pull/521) Improving test-localAddress.js (@noway421) - [#529](https://github.com/request/request/pull/529) dependencies versions bump (@jodaka) - -### v2.20.0 (2013/04/22) - [#523](https://github.com/request/request/pull/523) Updating dependencies (@noway421) - [#520](https://github.com/request/request/pull/520) Fixing test-tunnel.js (@noway421) - [#519](https://github.com/request/request/pull/519) Update internal path state on post-creation QS changes (@jblebrun) diff --git a/node_modules/request/README.md b/node_modules/request/README.md index cf9072a21a2..81ecac50999 100644 --- a/node_modules/request/README.md +++ b/node_modules/request/README.md @@ -67,7 +67,7 @@ Request can also `pipe` to itself. When doing so, `content-type` and `content-le request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')) ``` -Request emits a "response" event when a response is received. The `response` argument will be an instance of [http.IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage). +Request emits a "response" event when a response is received. The `response` argument will be an instance of [http.IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage). ```js request @@ -601,7 +601,6 @@ var options = { key: fs.readFileSync(keyFile), passphrase: 'password', ca: fs.readFileSync(caFile) - } }; request.get(options); @@ -819,7 +818,7 @@ default in Linux can be anywhere from 20-120 seconds][linux-timeout]). The callback argument gets 3 arguments: 1. An `error` when applicable (usually from [`http.ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest) object) -2. An [`http.IncomingMessage`](http://nodejs.org/api/http.html#http_http_incomingmessage) object +2. An [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) object 3. The third is the `response` body (`String` or `Buffer`, or JSON object if the `json` option is supplied) [back to top](#table-of-contents) diff --git a/node_modules/request/codecov.yml b/node_modules/request/codecov.yml new file mode 100644 index 00000000000..acd3f33ceb5 --- /dev/null +++ b/node_modules/request/codecov.yml @@ -0,0 +1,2 @@ + +comment: false diff --git a/node_modules/request/node_modules/aws-sign2/package.json b/node_modules/request/node_modules/aws-sign2/package.json index 0fe40d0b6e8..68572c7b125 100644 --- a/node_modules/request/node_modules/aws-sign2/package.json +++ b/node_modules/request/node_modules/aws-sign2/package.json @@ -41,7 +41,7 @@ ], "dist": { "shasum": "14342dd38dbcc94d0e5b87d763cd63612c0e794f", - "tarball": "http://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz" + "tarball": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", diff --git a/node_modules/request/node_modules/aws4/aws4.js b/node_modules/request/node_modules/aws4/aws4.js index 71e08bbc17c..cbe5dc90494 100644 --- a/node_modules/request/node_modules/aws4/aws4.js +++ b/node_modules/request/node_modules/aws4/aws4.js @@ -2,7 +2,7 @@ var aws4 = exports, url = require('url'), querystring = require('querystring'), crypto = require('crypto'), - lru = require('lru-cache'), + lru = require('./lru'), credentialsCache = lru(1000) // http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html diff --git a/node_modules/request/node_modules/aws4/lru.js b/node_modules/request/node_modules/aws4/lru.js new file mode 100644 index 00000000000..333f66a4436 --- /dev/null +++ b/node_modules/request/node_modules/aws4/lru.js @@ -0,0 +1,96 @@ +module.exports = function(size) { + return new LruCache(size) +} + +function LruCache(size) { + this.capacity = size | 0 + this.map = Object.create(null) + this.list = new DoublyLinkedList() +} + +LruCache.prototype.get = function(key) { + var node = this.map[key] + if (node == null) return undefined + this.used(node) + return node.val +} + +LruCache.prototype.set = function(key, val) { + var node = this.map[key] + if (node != null) { + node.val = val + } else { + if (!this.capacity) this.prune() + if (!this.capacity) return false + node = new DoublyLinkedNode(key, val) + this.map[key] = node + this.capacity-- + } + this.used(node) + return true +} + +LruCache.prototype.used = function(node) { + this.list.moveToFront(node) +} + +LruCache.prototype.prune = function() { + var node = this.list.pop() + if (node != null) { + delete this.map[node.key] + this.capacity++ + } +} + + +function DoublyLinkedList() { + this.firstNode = null + this.lastNode = null +} + +DoublyLinkedList.prototype.moveToFront = function(node) { + if (this.firstNode == node) return + + this.remove(node) + + if (this.firstNode == null) { + this.firstNode = node + this.lastNode = node + node.prev = null + node.next = null + } else { + node.prev = null + node.next = this.firstNode + node.next.prev = node + this.firstNode = node + } +} + +DoublyLinkedList.prototype.pop = function() { + var lastNode = this.lastNode + if (lastNode != null) { + this.remove(lastNode) + } + return lastNode +} + +DoublyLinkedList.prototype.remove = function(node) { + if (this.firstNode == node) { + this.firstNode = node.next + } else if (node.prev != null) { + node.prev.next = node.next + } + if (this.lastNode == node) { + this.lastNode = node.prev + } else if (node.next != null) { + node.next.prev = node.prev + } +} + + +function DoublyLinkedNode(key, val) { + this.key = key + this.val = val + this.prev = null + this.next = null +} diff --git a/node_modules/request/node_modules/aws4/package.json b/node_modules/request/node_modules/aws4/package.json index d0c94cc307d..d643c933bc0 100644 --- a/node_modules/request/node_modules/aws4/package.json +++ b/node_modules/request/node_modules/aws4/package.json @@ -1,6 +1,6 @@ { "name": "aws4", - "version": "1.3.2", + "version": "1.4.1", "description": "Signs and prepares requests using AWS Signature Version 4", "author": { "name": "Michael Hart", @@ -65,9 +65,6 @@ "url": "git+https://github.com/mhart/aws4.git" }, "license": "MIT", - "dependencies": { - "lru-cache": "^4.0.0" - }, "devDependencies": { "mocha": "^2.4.5", "should": "^8.2.2" @@ -75,16 +72,16 @@ "scripts": { "test": "mocha ./test/fast.js ./test/slow.js -b -t 100s -R list" }, - "gitHead": "e899db3aacbf2a034398f7dd483345dc793e8d72", + "gitHead": "f126d3ff80be1ddde0fc6b50bb51a7f199547e81", "bugs": { "url": "https://github.com/mhart/aws4/issues" }, "homepage": "https://github.com/mhart/aws4#readme", - "_id": "aws4@1.3.2", - "_shasum": "d39e0bee412ced0e8ed94a23e314f313a95b9fd1", + "_id": "aws4@1.4.1", + "_shasum": "fde7d5292466d230e5ee0f4e038d9dfaab08fc61", "_from": "aws4@>=1.2.1 <2.0.0", - "_npmVersion": "2.14.21", - "_nodeVersion": "4.3.1", + "_npmVersion": "2.15.4", + "_nodeVersion": "4.4.3", "_npmUser": { "name": "hichaelmart", "email": "michael.hart.au@gmail.com" @@ -96,14 +93,14 @@ } ], "dist": { - "shasum": "d39e0bee412ced0e8ed94a23e314f313a95b9fd1", - "tarball": "http://registry.npmjs.org/aws4/-/aws4-1.3.2.tgz" + "shasum": "fde7d5292466d230e5ee0f4e038d9dfaab08fc61", + "tarball": "https://registry.npmjs.org/aws4/-/aws4-1.4.1.tgz" }, "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/aws4-1.3.2.tgz_1456871543899_0.13955276948399842" + "tmp": "tmp/aws4-1.4.1.tgz_1462643218465_0.6527479749638587" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.3.2.tgz", + "_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.4.1.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json index ddd227e64f9..19fb85922bc 100644 --- a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json +++ b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json @@ -46,7 +46,7 @@ }, "dist": { "shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", - "tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" + "tarball": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/package.json b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/package.json index 703ea43cb4d..e86d232e609 100644 --- a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/package.json +++ b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/package.json @@ -57,7 +57,7 @@ }, "dist": { "shasum": "bb935d48582cba168c06834957a54a3e07124f11", - "tarball": "http://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" + "tarball": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/package.json b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/package.json index 0364d54ba46..8e8b77db7b4 100644 --- a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/package.json +++ b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/package.json @@ -46,7 +46,7 @@ ], "dist": { "shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", - "tarball": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + "tarball": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", diff --git a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/util-deprecate/package.json b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/util-deprecate/package.json index ae0c70f6c63..a018135492d 100644 --- a/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/util-deprecate/package.json +++ b/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/util-deprecate/package.json @@ -46,7 +46,7 @@ ], "dist": { "shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", - "tarball": "http://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + "tarball": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/node_modules/request/node_modules/caseless/package.json b/node_modules/request/node_modules/caseless/package.json index 2cd79ea01ab..5ba522e077b 100644 --- a/node_modules/request/node_modules/caseless/package.json +++ b/node_modules/request/node_modules/caseless/package.json @@ -54,7 +54,7 @@ ], "dist": { "shasum": "715b96ea9841593cc33067923f5ec60ebda4f7d7", - "tarball": "http://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz" + "tarball": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", diff --git a/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/package.json b/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/package.json index 8ac66b814c8..a471728816c 100644 --- a/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/package.json +++ b/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/package.json @@ -46,7 +46,7 @@ }, "dist": { "shasum": "df3ae199acadfb7d440aaae0b29e2272b24ec619", - "tarball": "http://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" + "tarball": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/combined-stream/package.json b/node_modules/request/node_modules/combined-stream/package.json index e0cd160ff6d..74d35f122bb 100644 --- a/node_modules/request/node_modules/combined-stream/package.json +++ b/node_modules/request/node_modules/combined-stream/package.json @@ -41,7 +41,7 @@ }, "dist": { "shasum": "938370a57b4a51dea2c77c15d5c5fdf895164009", - "tarball": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz" + "tarball": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/forever-agent/package.json b/node_modules/request/node_modules/forever-agent/package.json index f57036b527b..36c4f59445a 100644 --- a/node_modules/request/node_modules/forever-agent/package.json +++ b/node_modules/request/node_modules/forever-agent/package.json @@ -48,7 +48,7 @@ ], "dist": { "shasum": "fbc71f0c41adeb37f96c577ad1ed42d8fdacca91", - "tarball": "http://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz" + "tarball": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", diff --git a/node_modules/request/node_modules/form-data/node_modules/async/package.json b/node_modules/request/node_modules/form-data/node_modules/async/package.json index cdcd14153b7..1102b34382e 100644 --- a/node_modules/request/node_modules/form-data/node_modules/async/package.json +++ b/node_modules/request/node_modules/form-data/node_modules/async/package.json @@ -84,40 +84,11 @@ "tests" ] }, - "gitHead": "9ab5c67b7cb3a4c3dad4a2d4552a2f6775545d6c", + "readme": "# Async.js\n\n[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async)\n[![NPM version](http://img.shields.io/npm/v/async.svg)](https://www.npmjs.org/package/async)\n[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)\n[![Join the chat at https://gitter.im/caolan/async](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n\nAsync is a utility module which provides straight-forward, powerful functions\nfor working with asynchronous JavaScript. Although originally designed for\nuse with [Node.js](http://nodejs.org) and installable via `npm install async`,\nit can also be used directly in the browser.\n\nAsync is also installable via:\n\n- [bower](http://bower.io/): `bower install async`\n- [component](https://github.com/component/component): `component install\n caolan/async`\n- [jam](http://jamjs.org/): `jam install async`\n- [spm](http://spmjs.io/): `spm install async`\n\nAsync provides around 20 functions that include the usual 'functional'\nsuspects (`map`, `reduce`, `filter`, `each`…) as well as some common patterns\nfor asynchronous control flow (`parallel`, `series`, `waterfall`…). All these\nfunctions assume you follow the Node.js convention of providing a single\ncallback as the last argument of your `async` function.\n\n\n## Quick Examples\n\n```javascript\nasync.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n});\n\nasync.filter(['file1','file2','file3'], fs.exists, function(results){\n // results now equals an array of the existing files\n});\n\nasync.parallel([\n function(){ ... },\n function(){ ... }\n], callback);\n\nasync.series([\n function(){ ... },\n function(){ ... }\n]);\n```\n\nThere are many more functions available so take a look at the docs below for a\nfull list. This module aims to be comprehensive, so if you feel anything is\nmissing please create a GitHub issue for it.\n\n## Common Pitfalls [(StackOverflow)](http://stackoverflow.com/questions/tagged/async.js)\n### Synchronous iteration functions\n\nIf you get an error like `RangeError: Maximum call stack size exceeded.` or other stack overflow issues when using async, you are likely using a synchronous iterator. By *synchronous* we mean a function that calls its callback on the same tick in the javascript event loop, without doing any I/O or using any timers. Calling many callbacks iteratively will quickly overflow the stack. If you run into this issue, just defer your callback with `async.setImmediate` to start a new call stack on the next tick of the event loop.\n\nThis can also arise by accident if you callback early in certain cases:\n\n```js\nasync.eachSeries(hugeArray, function iterator(item, callback) {\n if (inCache(item)) {\n callback(null, cache[item]); // if many items are cached, you'll overflow\n } else {\n doSomeIO(item, callback);\n }\n}, function done() {\n //...\n});\n```\n\nJust change it to:\n\n```js\nasync.eachSeries(hugeArray, function iterator(item, callback) {\n if (inCache(item)) {\n async.setImmediate(function () {\n callback(null, cache[item]);\n });\n } else {\n doSomeIO(item, callback);\n //...\n```\n\nAsync guards against synchronous functions in some, but not all, cases. If you are still running into stack overflows, you can defer as suggested above, or wrap functions with [`async.ensureAsync`](#ensureAsync) Functions that are asynchronous by their nature do not have this problem and don't need the extra callback deferral.\n\nIf JavaScript's event loop is still a bit nebulous, check out [this article](http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/) or [this talk](http://2014.jsconf.eu/speakers/philip-roberts-what-the-heck-is-the-event-loop-anyway.html) for more detailed information about how it works.\n\n\n### Multiple callbacks\n\nMake sure to always `return` when calling a callback early, otherwise you will cause multiple callbacks and unpredictable behavior in many cases.\n\n```js\nasync.waterfall([\n function (callback) {\n getSomething(options, function (err, result) {\n if (err) {\n callback(new Error(\"failed getting something:\" + err.message));\n // we should return here\n }\n // since we did not return, this callback still will be called and\n // `processData` will be called twice\n callback(null, result);\n });\n },\n processData\n], done)\n```\n\nIt is always good practice to `return callback(err, result)` whenever a callback call is not the last statement of a function.\n\n\n### Binding a context to an iterator\n\nThis section is really about `bind`, not about `async`. If you are wondering how to\nmake `async` execute your iterators in a given context, or are confused as to why\na method of another library isn't working as an iterator, study this example:\n\n```js\n// Here is a simple object with an (unnecessarily roundabout) squaring method\nvar AsyncSquaringLibrary = {\n squareExponent: 2,\n square: function(number, callback){\n var result = Math.pow(number, this.squareExponent);\n setTimeout(function(){\n callback(null, result);\n }, 200);\n }\n};\n\nasync.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result){\n // result is [NaN, NaN, NaN]\n // This fails because the `this.squareExponent` expression in the square\n // function is not evaluated in the context of AsyncSquaringLibrary, and is\n // therefore undefined.\n});\n\nasync.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){\n // result is [1, 4, 9]\n // With the help of bind we can attach a context to the iterator before\n // passing it to async. Now the square function will be executed in its\n // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent`\n // will be as expected.\n});\n```\n\n## Download\n\nThe source is available for download from\n[GitHub](https://github.com/caolan/async/blob/master/lib/async.js).\nAlternatively, you can install using Node Package Manager (`npm`):\n\n npm install async\n\nAs well as using Bower:\n\n bower install async\n\n__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 29.6kb Uncompressed\n\n## In the Browser\n\nSo far it's been tested in IE6, IE7, IE8, FF3.6 and Chrome 5.\n\nUsage:\n\n```html\n\n\n```\n\n## Documentation\n\nSome functions are also available in the following forms:\n* `Series` - the same as `` but runs only a single async operation at a time\n* `Limit` - the same as `` but runs a maximum of `limit` async operations at a time\n\n### Collections\n\n* [`each`](#each), `eachSeries`, `eachLimit`\n* [`forEachOf`](#forEachOf), `forEachOfSeries`, `forEachOfLimit`\n* [`map`](#map), `mapSeries`, `mapLimit`\n* [`filter`](#filter), `filterSeries`, `filterLimit`\n* [`reject`](#reject), `rejectSeries`, `rejectLimit`\n* [`reduce`](#reduce), [`reduceRight`](#reduceRight)\n* [`detect`](#detect), `detectSeries`, `detectLimit`\n* [`sortBy`](#sortBy)\n* [`some`](#some), `someLimit`\n* [`every`](#every), `everyLimit`\n* [`concat`](#concat), `concatSeries`\n\n### Control Flow\n\n* [`series`](#seriestasks-callback)\n* [`parallel`](#parallel), `parallelLimit`\n* [`whilst`](#whilst), [`doWhilst`](#doWhilst)\n* [`until`](#until), [`doUntil`](#doUntil)\n* [`during`](#during), [`doDuring`](#doDuring)\n* [`forever`](#forever)\n* [`waterfall`](#waterfall)\n* [`compose`](#compose)\n* [`seq`](#seq)\n* [`applyEach`](#applyEach), `applyEachSeries`\n* [`queue`](#queue), [`priorityQueue`](#priorityQueue)\n* [`cargo`](#cargo)\n* [`auto`](#auto)\n* [`retry`](#retry)\n* [`iterator`](#iterator)\n* [`times`](#times), `timesSeries`, `timesLimit`\n\n### Utils\n\n* [`apply`](#apply)\n* [`nextTick`](#nextTick)\n* [`memoize`](#memoize)\n* [`unmemoize`](#unmemoize)\n* [`ensureAsync`](#ensureAsync)\n* [`constant`](#constant)\n* [`asyncify`](#asyncify)\n* [`wrapSync`](#wrapSync)\n* [`log`](#log)\n* [`dir`](#dir)\n* [`noConflict`](#noConflict)\n\n## Collections\n\n\n\n### each(arr, iterator, [callback])\n\nApplies the function `iterator` to each item in `arr`, in parallel.\nThe `iterator` is called with an item from the list, and a callback for when it\nhas finished. If the `iterator` passes an error to its `callback`, the main\n`callback` (for the `each` function) is immediately called with the error.\n\nNote, that since this function applies `iterator` to each item in parallel,\nthere is no guarantee that the iterator functions will complete in order.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A function to apply to each item in `arr`.\n The iterator is passed a `callback(err)` which must be called once it has\n completed. If no error has occurred, the `callback` should be run without\n arguments or with an explicit `null` argument. The array index is not passed\n to the iterator. If you need the index, use [`forEachOf`](#forEachOf).\n* `callback(err)` - *Optional* A callback which is called when all `iterator` functions\n have finished, or an error occurs.\n\n__Examples__\n\n\n```js\n// assuming openFiles is an array of file names and saveFile is a function\n// to save the modified contents of that file:\n\nasync.each(openFiles, saveFile, function(err){\n // if any of the saves produced an error, err would equal that error\n});\n```\n\n```js\n// assuming openFiles is an array of file names\n\nasync.each(openFiles, function(file, callback) {\n\n // Perform operation on file here.\n console.log('Processing file ' + file);\n\n if( file.length > 32 ) {\n console.log('This file name is too long');\n callback('File name too long');\n } else {\n // Do work to process file here\n console.log('File processed');\n callback();\n }\n}, function(err){\n // if any of the file processing produced an error, err would equal that error\n if( err ) {\n // One of the iterations produced an error.\n // All processing will now stop.\n console.log('A file failed to process');\n } else {\n console.log('All files have been processed successfully');\n }\n});\n```\n\n__Related__\n\n* eachSeries(arr, iterator, [callback])\n* eachLimit(arr, limit, iterator, [callback])\n\n---------------------------------------\n\n\n\n\n### forEachOf(obj, iterator, [callback])\n\nLike `each`, except that it iterates over objects, and passes the key as the second argument to the iterator.\n\n__Arguments__\n\n* `obj` - An object or array to iterate over.\n* `iterator(item, key, callback)` - A function to apply to each item in `obj`.\nThe `key` is the item's key, or index in the case of an array. The iterator is\npassed a `callback(err)` which must be called once it has completed. If no\nerror has occurred, the callback should be run without arguments or with an\nexplicit `null` argument.\n* `callback(err)` - *Optional* A callback which is called when all `iterator` functions have finished, or an error occurs.\n\n__Example__\n\n```js\nvar obj = {dev: \"/dev.json\", test: \"/test.json\", prod: \"/prod.json\"};\nvar configs = {};\n\nasync.forEachOf(obj, function (value, key, callback) {\n fs.readFile(__dirname + value, \"utf8\", function (err, data) {\n if (err) return callback(err);\n try {\n configs[key] = JSON.parse(data);\n } catch (e) {\n return callback(e);\n }\n callback();\n })\n}, function (err) {\n if (err) console.error(err.message);\n // configs is now a map of JSON data\n doSomethingWith(configs);\n})\n```\n\n__Related__\n\n* forEachOfSeries(obj, iterator, [callback])\n* forEachOfLimit(obj, limit, iterator, [callback])\n\n---------------------------------------\n\n\n### map(arr, iterator, [callback])\n\nProduces a new array of values by mapping each value in `arr` through\nthe `iterator` function. The `iterator` is called with an item from `arr` and a\ncallback for when it has finished processing. Each of these callback takes 2 arguments:\nan `error`, and the transformed item from `arr`. If `iterator` passes an error to its\ncallback, the main `callback` (for the `map` function) is immediately called with the error.\n\nNote, that since this function applies the `iterator` to each item in parallel,\nthere is no guarantee that the `iterator` functions will complete in order.\nHowever, the results array will be in the same order as the original `arr`.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A function to apply to each item in `arr`.\n The iterator is passed a `callback(err, transformed)` which must be called once\n it has completed with an error (which can be `null`) and a transformed item.\n* `callback(err, results)` - *Optional* A callback which is called when all `iterator`\n functions have finished, or an error occurs. Results is an array of the\n transformed items from the `arr`.\n\n__Example__\n\n```js\nasync.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n});\n```\n\n__Related__\n* mapSeries(arr, iterator, [callback])\n* mapLimit(arr, limit, iterator, [callback])\n\n---------------------------------------\n\n\n\n### filter(arr, iterator, [callback])\n\n__Alias:__ `select`\n\nReturns a new array of all the values in `arr` which pass an async truth test.\n_The callback for each `iterator` call only accepts a single argument of `true` or\n`false`; it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like `fs.exists`. This operation is\nperformed in parallel, but the results array will be in the same order as the\noriginal.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A truth test to apply to each item in `arr`.\n The `iterator` is passed a `callback(truthValue)`, which must be called with a\n boolean argument once it has completed.\n* `callback(results)` - *Optional* A callback which is called after all the `iterator`\n functions have finished.\n\n__Example__\n\n```js\nasync.filter(['file1','file2','file3'], fs.exists, function(results){\n // results now equals an array of the existing files\n});\n```\n\n__Related__\n\n* filterSeries(arr, iterator, [callback])\n* filterLimit(arr, limit, iterator, [callback])\n\n---------------------------------------\n\n\n### reject(arr, iterator, [callback])\n\nThe opposite of [`filter`](#filter). Removes values that pass an `async` truth test.\n\n__Related__\n\n* rejectSeries(arr, iterator, [callback])\n* rejectLimit(arr, limit, iterator, [callback])\n\n---------------------------------------\n\n\n### reduce(arr, memo, iterator, [callback])\n\n__Aliases:__ `inject`, `foldl`\n\nReduces `arr` into a single value using an async `iterator` to return\neach successive step. `memo` is the initial state of the reduction.\nThis function only operates in series.\n\nFor performance reasons, it may make sense to split a call to this function into\na parallel map, and then use the normal `Array.prototype.reduce` on the results.\nThis function is for situations where each step in the reduction needs to be async;\nif you can get the data before reducing it, then it's probably a good idea to do so.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `memo` - The initial state of the reduction.\n* `iterator(memo, item, callback)` - A function applied to each item in the\n array to produce the next step in the reduction. The `iterator` is passed a\n `callback(err, reduction)` which accepts an optional error as its first\n argument, and the state of the reduction as the second. If an error is\n passed to the callback, the reduction is stopped and the main `callback` is\n immediately called with the error.\n* `callback(err, result)` - *Optional* A callback which is called after all the `iterator`\n functions have finished. Result is the reduced value.\n\n__Example__\n\n```js\nasync.reduce([1,2,3], 0, function(memo, item, callback){\n // pointless async:\n process.nextTick(function(){\n callback(null, memo + item)\n });\n}, function(err, result){\n // result is now equal to the last value of memo, which is 6\n});\n```\n\n---------------------------------------\n\n\n### reduceRight(arr, memo, iterator, [callback])\n\n__Alias:__ `foldr`\n\nSame as [`reduce`](#reduce), only operates on `arr` in reverse order.\n\n\n---------------------------------------\n\n\n### detect(arr, iterator, [callback])\n\nReturns the first value in `arr` that passes an async truth test. The\n`iterator` is applied in parallel, meaning the first iterator to return `true` will\nfire the detect `callback` with that result. That means the result might not be\nthe first item in the original `arr` (in terms of order) that passes the test.\n\nIf order within the original `arr` is important, then look at [`detectSeries`](#detectSeries).\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A truth test to apply to each item in `arr`.\n The iterator is passed a `callback(truthValue)` which must be called with a\n boolean argument once it has completed. **Note: this callback does not take an error as its first argument.**\n* `callback(result)` - *Optional* A callback which is called as soon as any iterator returns\n `true`, or after all the `iterator` functions have finished. Result will be\n the first item in the array that passes the truth test (iterator) or the\n value `undefined` if none passed. **Note: this callback does not take an error as its first argument.**\n\n__Example__\n\n```js\nasync.detect(['file1','file2','file3'], fs.exists, function(result){\n // result now equals the first file in the list that exists\n});\n```\n\n__Related__\n\n* detectSeries(arr, iterator, [callback])\n* detectLimit(arr, limit, iterator, [callback])\n\n---------------------------------------\n\n\n### sortBy(arr, iterator, [callback])\n\nSorts a list by the results of running each `arr` value through an async `iterator`.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A function to apply to each item in `arr`.\n The iterator is passed a `callback(err, sortValue)` which must be called once it\n has completed with an error (which can be `null`) and a value to use as the sort\n criteria.\n* `callback(err, results)` - *Optional* A callback which is called after all the `iterator`\n functions have finished, or an error occurs. Results is the items from\n the original `arr` sorted by the values returned by the `iterator` calls.\n\n__Example__\n\n```js\nasync.sortBy(['file1','file2','file3'], function(file, callback){\n fs.stat(file, function(err, stats){\n callback(err, stats.mtime);\n });\n}, function(err, results){\n // results is now the original array of files sorted by\n // modified date\n});\n```\n\n__Sort Order__\n\nBy modifying the callback parameter the sorting order can be influenced:\n\n```js\n//ascending order\nasync.sortBy([1,9,3,5], function(x, callback){\n callback(null, x);\n}, function(err,result){\n //result callback\n} );\n\n//descending order\nasync.sortBy([1,9,3,5], function(x, callback){\n callback(null, x*-1); //<- x*-1 instead of x, turns the order around\n}, function(err,result){\n //result callback\n} );\n```\n\n---------------------------------------\n\n\n### some(arr, iterator, [callback])\n\n__Alias:__ `any`\n\nReturns `true` if at least one element in the `arr` satisfies an async test.\n_The callback for each iterator call only accepts a single argument of `true` or\n`false`; it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like `fs.exists`. Once any iterator\ncall returns `true`, the main `callback` is immediately called.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A truth test to apply to each item in the array\n in parallel. The iterator is passed a `callback(truthValue)`` which must be\n called with a boolean argument once it has completed.\n* `callback(result)` - *Optional* A callback which is called as soon as any iterator returns\n `true`, or after all the iterator functions have finished. Result will be\n either `true` or `false` depending on the values of the async tests.\n\n **Note: the callbacks do not take an error as their first argument.**\n__Example__\n\n```js\nasync.some(['file1','file2','file3'], fs.exists, function(result){\n // if result is true then at least one of the files exists\n});\n```\n\n__Related__\n\n* someLimit(arr, limit, iterator, callback)\n\n---------------------------------------\n\n\n### every(arr, iterator, [callback])\n\n__Alias:__ `all`\n\nReturns `true` if every element in `arr` satisfies an async test.\n_The callback for each `iterator` call only accepts a single argument of `true` or\n`false`; it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like `fs.exists`.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A truth test to apply to each item in the array\n in parallel. The iterator is passed a `callback(truthValue)` which must be\n called with a boolean argument once it has completed.\n* `callback(result)` - *Optional* A callback which is called as soon as any iterator returns\n `false`, or after all the iterator functions have finished. Result will be\n either `true` or `false` depending on the values of the async tests.\n\n **Note: the callbacks do not take an error as their first argument.**\n\n__Example__\n\n```js\nasync.every(['file1','file2','file3'], fs.exists, function(result){\n // if result is true then every file exists\n});\n```\n\n__Related__\n\n* everyLimit(arr, limit, iterator, callback)\n\n---------------------------------------\n\n\n### concat(arr, iterator, [callback])\n\nApplies `iterator` to each item in `arr`, concatenating the results. Returns the\nconcatenated list. The `iterator`s are called in parallel, and the results are\nconcatenated as they return. There is no guarantee that the results array will\nbe returned in the original order of `arr` passed to the `iterator` function.\n\n__Arguments__\n\n* `arr` - An array to iterate over.\n* `iterator(item, callback)` - A function to apply to each item in `arr`.\n The iterator is passed a `callback(err, results)` which must be called once it\n has completed with an error (which can be `null`) and an array of results.\n* `callback(err, results)` - *Optional* A callback which is called after all the `iterator`\n functions have finished, or an error occurs. Results is an array containing\n the concatenated results of the `iterator` function.\n\n__Example__\n\n```js\nasync.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){\n // files is now a list of filenames that exist in the 3 directories\n});\n```\n\n__Related__\n\n* concatSeries(arr, iterator, [callback])\n\n\n## Control Flow\n\n\n### series(tasks, [callback])\n\nRun the functions in the `tasks` array in series, each one running once the previous\nfunction has completed. If any functions in the series pass an error to its\ncallback, no more functions are run, and `callback` is immediately called with the value of the error.\nOtherwise, `callback` receives an array of results when `tasks` have completed.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function, and the results will be passed to the final `callback` as an object\ninstead of an array. This can be a more readable way of handling results from\n[`series`](#series).\n\n**Note** that while many implementations preserve the order of object properties, the\n[ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)\nexplicitly states that\n\n> The mechanics and order of enumerating the properties is not specified.\n\nSo if you rely on the order in which your series of functions are executed, and want\nthis to work on all platforms, consider using an array.\n\n__Arguments__\n\n* `tasks` - An array or object containing functions to run, each function is passed\n a `callback(err, result)` it must call on completion with an error `err` (which can\n be `null`) and an optional `result` value.\n* `callback(err, results)` - An optional callback to run once all the functions\n have completed. This function gets a results array (or object) containing all\n the result arguments passed to the `task` callbacks.\n\n__Example__\n\n```js\nasync.series([\n function(callback){\n // do some stuff ...\n callback(null, 'one');\n },\n function(callback){\n // do some more stuff ...\n callback(null, 'two');\n }\n],\n// optional callback\nfunction(err, results){\n // results is now equal to ['one', 'two']\n});\n\n\n// an example using an object instead of an array\nasync.series({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n }\n},\nfunction(err, results) {\n // results is now equal to: {one: 1, two: 2}\n});\n```\n\n---------------------------------------\n\n\n### parallel(tasks, [callback])\n\nRun the `tasks` array of functions in parallel, without waiting until the previous\nfunction has completed. If any of the functions pass an error to its\ncallback, the main `callback` is immediately called with the value of the error.\nOnce the `tasks` have completed, the results are passed to the final `callback` as an\narray.\n\n**Note:** `parallel` is about kicking-off I/O tasks in parallel, not about parallel execution of code. If your tasks do not use any timers or perform any I/O, they will actually be executed in series. Any synchronous setup sections for each task will happen one after the other. JavaScript remains single-threaded.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function and the results will be passed to the final `callback` as an object\ninstead of an array. This can be a more readable way of handling results from\n[`parallel`](#parallel).\n\n\n__Arguments__\n\n* `tasks` - An array or object containing functions to run. Each function is passed\n a `callback(err, result)` which it must call on completion with an error `err`\n (which can be `null`) and an optional `result` value.\n* `callback(err, results)` - An optional callback to run once all the functions\n have completed successfully. This function gets a results array (or object) containing all\n the result arguments passed to the task callbacks.\n\n__Example__\n\n```js\nasync.parallel([\n function(callback){\n setTimeout(function(){\n callback(null, 'one');\n }, 200);\n },\n function(callback){\n setTimeout(function(){\n callback(null, 'two');\n }, 100);\n }\n],\n// optional callback\nfunction(err, results){\n // the results array will equal ['one','two'] even though\n // the second function had a shorter timeout.\n});\n\n\n// an example using an object instead of an array\nasync.parallel({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n }\n},\nfunction(err, results) {\n // results is now equals to: {one: 1, two: 2}\n});\n```\n\n__Related__\n\n* parallelLimit(tasks, limit, [callback])\n\n---------------------------------------\n\n\n### whilst(test, fn, callback)\n\nRepeatedly call `fn`, while `test` returns `true`. Calls `callback` when stopped,\nor an error occurs.\n\n__Arguments__\n\n* `test()` - synchronous truth test to perform before each execution of `fn`.\n* `fn(callback)` - A function which is called each time `test` passes. The function is\n passed a `callback(err)`, which must be called once it has completed with an\n optional `err` argument.\n* `callback(err, [results])` - A callback which is called after the test\n function has failed and repeated execution of `fn` has stopped. `callback`\n will be passed an error and any arguments passed to the final `fn`'s callback.\n\n__Example__\n\n```js\nvar count = 0;\n\nasync.whilst(\n function () { return count < 5; },\n function (callback) {\n count++;\n setTimeout(function () {\n callback(null, count);\n }, 1000);\n },\n function (err, n) {\n // 5 seconds have passed, n = 5\n }\n);\n```\n\n---------------------------------------\n\n\n### doWhilst(fn, test, callback)\n\nThe post-check version of [`whilst`](#whilst). To reflect the difference in\nthe order of operations, the arguments `test` and `fn` are switched.\n\n`doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.\n\n---------------------------------------\n\n\n### until(test, fn, callback)\n\nRepeatedly call `fn` until `test` returns `true`. Calls `callback` when stopped,\nor an error occurs. `callback` will be passed an error and any arguments passed\nto the final `fn`'s callback.\n\nThe inverse of [`whilst`](#whilst).\n\n---------------------------------------\n\n\n### doUntil(fn, test, callback)\n\nLike [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument ordering differs from `until`.\n\n---------------------------------------\n\n\n### during(test, fn, callback)\n\nLike [`whilst`](#whilst), except the `test` is an asynchronous function that is passed a callback in the form of `function (err, truth)`. If error is passed to `test` or `fn`, the main callback is immediately called with the value of the error.\n\n__Example__\n\n```js\nvar count = 0;\n\nasync.during(\n function (callback) {\n return callback(null, count < 5);\n },\n function (callback) {\n count++;\n setTimeout(callback, 1000);\n },\n function (err) {\n // 5 seconds have passed\n }\n);\n```\n\n---------------------------------------\n\n\n### doDuring(fn, test, callback)\n\nThe post-check version of [`during`](#during). To reflect the difference in\nthe order of operations, the arguments `test` and `fn` are switched.\n\nAlso a version of [`doWhilst`](#doWhilst) with asynchronous `test` function.\n\n---------------------------------------\n\n\n### forever(fn, [errback])\n\nCalls the asynchronous function `fn` with a callback parameter that allows it to\ncall itself again, in series, indefinitely.\n\nIf an error is passed to the callback then `errback` is called with the\nerror, and execution stops, otherwise it will never be called.\n\n```js\nasync.forever(\n function(next) {\n // next is suitable for passing to things that need a callback(err [, whatever]);\n // it will result in this function being called again.\n },\n function(err) {\n // if next is called with a value in its first parameter, it will appear\n // in here as 'err', and execution will stop.\n }\n);\n```\n\n---------------------------------------\n\n\n### waterfall(tasks, [callback])\n\nRuns the `tasks` array of functions in series, each passing their results to the next in\nthe array. However, if any of the `tasks` pass an error to their own callback, the\nnext function is not executed, and the main `callback` is immediately called with\nthe error.\n\n__Arguments__\n\n* `tasks` - An array of functions to run, each function is passed a\n `callback(err, result1, result2, ...)` it must call on completion. The first\n argument is an error (which can be `null`) and any further arguments will be\n passed as arguments in order to the next task.\n* `callback(err, [results])` - An optional callback to run once all the functions\n have completed. This will be passed the results of the last task's callback.\n\n\n\n__Example__\n\n```js\nasync.waterfall([\n function(callback) {\n callback(null, 'one', 'two');\n },\n function(arg1, arg2, callback) {\n // arg1 now equals 'one' and arg2 now equals 'two'\n callback(null, 'three');\n },\n function(arg1, callback) {\n // arg1 now equals 'three'\n callback(null, 'done');\n }\n], function (err, result) {\n // result now equals 'done'\n});\n```\nOr, with named functions:\n\n```js\nasync.waterfall([\n myFirstFunction,\n mySecondFunction,\n myLastFunction,\n], function (err, result) {\n // result now equals 'done'\n});\nfunction myFirstFunction(callback) {\n callback(null, 'one', 'two');\n}\nfunction mySecondFunction(arg1, arg2, callback) {\n // arg1 now equals 'one' and arg2 now equals 'two'\n callback(null, 'three');\n}\nfunction myLastFunction(arg1, callback) {\n // arg1 now equals 'three'\n callback(null, 'done');\n}\n```\n\nOr, if you need to pass any argument to the first function:\n\n```js\nasync.waterfall([\n async.apply(myFirstFunction, 'zero'),\n mySecondFunction,\n myLastFunction,\n], function (err, result) {\n // result now equals 'done'\n});\nfunction myFirstFunction(arg1, callback) {\n // arg1 now equals 'zero'\n callback(null, 'one', 'two');\n}\nfunction mySecondFunction(arg1, arg2, callback) {\n // arg1 now equals 'one' and arg2 now equals 'two'\n callback(null, 'three');\n}\nfunction myLastFunction(arg1, callback) {\n // arg1 now equals 'three'\n callback(null, 'done');\n}\n```\n\n---------------------------------------\n\n### compose(fn1, fn2...)\n\nCreates a function which is a composition of the passed asynchronous\nfunctions. Each function consumes the return value of the function that\nfollows. Composing functions `f()`, `g()`, and `h()` would produce the result of\n`f(g(h()))`, only this version uses callbacks to obtain the return values.\n\nEach function is executed with the `this` binding of the composed function.\n\n__Arguments__\n\n* `functions...` - the asynchronous functions to compose\n\n\n__Example__\n\n```js\nfunction add1(n, callback) {\n setTimeout(function () {\n callback(null, n + 1);\n }, 10);\n}\n\nfunction mul3(n, callback) {\n setTimeout(function () {\n callback(null, n * 3);\n }, 10);\n}\n\nvar add1mul3 = async.compose(mul3, add1);\n\nadd1mul3(4, function (err, result) {\n // result now equals 15\n});\n```\n\n---------------------------------------\n\n### seq(fn1, fn2...)\n\nVersion of the compose function that is more natural to read.\nEach function consumes the return value of the previous function.\nIt is the equivalent of [`compose`](#compose) with the arguments reversed.\n\nEach function is executed with the `this` binding of the composed function.\n\n__Arguments__\n\n* `functions...` - the asynchronous functions to compose\n\n\n__Example__\n\n```js\n// Requires lodash (or underscore), express3 and dresende's orm2.\n// Part of an app, that fetches cats of the logged user.\n// This example uses `seq` function to avoid overnesting and error\n// handling clutter.\napp.get('/cats', function(request, response) {\n var User = request.models.User;\n async.seq(\n _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))\n function(user, fn) {\n user.getCats(fn); // 'getCats' has signature (callback(err, data))\n }\n )(req.session.user_id, function (err, cats) {\n if (err) {\n console.error(err);\n response.json({ status: 'error', message: err.message });\n } else {\n response.json({ status: 'ok', message: 'Cats found', data: cats });\n }\n });\n});\n```\n\n---------------------------------------\n\n### applyEach(fns, args..., callback)\n\nApplies the provided arguments to each function in the array, calling\n`callback` after all functions have completed. If you only provide the first\nargument, then it will return a function which lets you pass in the\narguments as if it were a single function call.\n\n__Arguments__\n\n* `fns` - the asynchronous functions to all call with the same arguments\n* `args...` - any number of separate arguments to pass to the function\n* `callback` - the final argument should be the callback, called when all\n functions have completed processing\n\n\n__Example__\n\n```js\nasync.applyEach([enableSearch, updateSchema], 'bucket', callback);\n\n// partial application example:\nasync.each(\n buckets,\n async.applyEach([enableSearch, updateSchema]),\n callback\n);\n```\n\n__Related__\n\n* applyEachSeries(tasks, args..., [callback])\n\n---------------------------------------\n\n\n### queue(worker, [concurrency])\n\nCreates a `queue` object with the specified `concurrency`. Tasks added to the\n`queue` are processed in parallel (up to the `concurrency` limit). If all\n`worker`s are in progress, the task is queued until one becomes available.\nOnce a `worker` completes a `task`, that `task`'s callback is called.\n\n__Arguments__\n\n* `worker(task, callback)` - An asynchronous function for processing a queued\n task, which must call its `callback(err)` argument when finished, with an\n optional `error` as an argument. If you want to handle errors from an individual task, pass a callback to `q.push()`.\n* `concurrency` - An `integer` for determining how many `worker` functions should be\n run in parallel. If omitted, the concurrency defaults to `1`. If the concurrency is `0`, an error is thrown.\n\n__Queue objects__\n\nThe `queue` object returned by this function has the following properties and\nmethods:\n\n* `length()` - a function returning the number of items waiting to be processed.\n* `started` - a function returning whether or not any items have been pushed and processed by the queue\n* `running()` - a function returning the number of items currently being processed.\n* `workersList()` - a function returning the array of items currently being processed.\n* `idle()` - a function returning false if there are items waiting or being processed, or true if not.\n* `concurrency` - an integer for determining how many `worker` functions should be\n run in parallel. This property can be changed after a `queue` is created to\n alter the concurrency on-the-fly.\n* `push(task, [callback])` - add a new task to the `queue`. Calls `callback` once\n the `worker` has finished processing the task. Instead of a single task, a `tasks` array\n can be submitted. The respective callback is used for every task in the list.\n* `unshift(task, [callback])` - add a new task to the front of the `queue`.\n* `saturated` - a callback that is called when the `queue` length hits the `concurrency` limit,\n and further tasks will be queued.\n* `empty` - a callback that is called when the last item from the `queue` is given to a `worker`.\n* `drain` - a callback that is called when the last item from the `queue` has returned from the `worker`.\n* `paused` - a boolean for determining whether the queue is in a paused state\n* `pause()` - a function that pauses the processing of tasks until `resume()` is called.\n* `resume()` - a function that resumes the processing of queued tasks when the queue is paused.\n* `kill()` - a function that removes the `drain` callback and empties remaining tasks from the queue forcing it to go idle.\n\n__Example__\n\n```js\n// create a queue object with concurrency 2\n\nvar q = async.queue(function (task, callback) {\n console.log('hello ' + task.name);\n callback();\n}, 2);\n\n\n// assign a callback\nq.drain = function() {\n console.log('all items have been processed');\n}\n\n// add some items to the queue\n\nq.push({name: 'foo'}, function (err) {\n console.log('finished processing foo');\n});\nq.push({name: 'bar'}, function (err) {\n console.log('finished processing bar');\n});\n\n// add some items to the queue (batch-wise)\n\nq.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) {\n console.log('finished processing item');\n});\n\n// add some items to the front of the queue\n\nq.unshift({name: 'bar'}, function (err) {\n console.log('finished processing bar');\n});\n```\n\n\n---------------------------------------\n\n\n### priorityQueue(worker, concurrency)\n\nThe same as [`queue`](#queue) only tasks are assigned a priority and completed in ascending priority order. There are two differences between `queue` and `priorityQueue` objects:\n\n* `push(task, priority, [callback])` - `priority` should be a number. If an array of\n `tasks` is given, all tasks will be assigned the same priority.\n* The `unshift` method was removed.\n\n---------------------------------------\n\n\n### cargo(worker, [payload])\n\nCreates a `cargo` object with the specified payload. Tasks added to the\ncargo will be processed altogether (up to the `payload` limit). If the\n`worker` is in progress, the task is queued until it becomes available. Once\nthe `worker` has completed some tasks, each callback of those tasks is called.\nCheck out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) for how `cargo` and `queue` work.\n\nWhile [queue](#queue) passes only one task to one of a group of workers\nat a time, cargo passes an array of tasks to a single worker, repeating\nwhen the worker is finished.\n\n__Arguments__\n\n* `worker(tasks, callback)` - An asynchronous function for processing an array of\n queued tasks, which must call its `callback(err)` argument when finished, with\n an optional `err` argument.\n* `payload` - An optional `integer` for determining how many tasks should be\n processed per round; if omitted, the default is unlimited.\n\n__Cargo objects__\n\nThe `cargo` object returned by this function has the following properties and\nmethods:\n\n* `length()` - A function returning the number of items waiting to be processed.\n* `payload` - An `integer` for determining how many tasks should be\n process per round. This property can be changed after a `cargo` is created to\n alter the payload on-the-fly.\n* `push(task, [callback])` - Adds `task` to the `queue`. The callback is called\n once the `worker` has finished processing the task. Instead of a single task, an array of `tasks`\n can be submitted. The respective callback is used for every task in the list.\n* `saturated` - A callback that is called when the `queue.length()` hits the concurrency and further tasks will be queued.\n* `empty` - A callback that is called when the last item from the `queue` is given to a `worker`.\n* `drain` - A callback that is called when the last item from the `queue` has returned from the `worker`.\n* `idle()`, `pause()`, `resume()`, `kill()` - cargo inherits all of the same methods and event calbacks as [`queue`](#queue)\n\n__Example__\n\n```js\n// create a cargo object with payload 2\n\nvar cargo = async.cargo(function (tasks, callback) {\n for(var i=0; i\n### auto(tasks, [concurrency], [callback])\n\nDetermines the best order for running the functions in `tasks`, based on their requirements. Each function can optionally depend on other functions being completed first, and each function is run as soon as its requirements are satisfied.\n\nIf any of the functions pass an error to their callback, the `auto` sequence will stop. Further tasks will not execute (so any other functions depending on it will not run), and the main `callback` is immediately called with the error. Functions also receive an object containing the results of functions which have completed so far.\n\nNote, all functions are called with a `results` object as a second argument,\nso it is unsafe to pass functions in the `tasks` object which cannot handle the\nextra argument.\n\nFor example, this snippet of code:\n\n```js\nasync.auto({\n readData: async.apply(fs.readFile, 'data.txt', 'utf-8')\n}, callback);\n```\n\nwill have the effect of calling `readFile` with the results object as the last\nargument, which will fail:\n\n```js\nfs.readFile('data.txt', 'utf-8', cb, {});\n```\n\nInstead, wrap the call to `readFile` in a function which does not forward the\n`results` object:\n\n```js\nasync.auto({\n readData: function(cb, results){\n fs.readFile('data.txt', 'utf-8', cb);\n }\n}, callback);\n```\n\n__Arguments__\n\n* `tasks` - An object. Each of its properties is either a function or an array of\n requirements, with the function itself the last item in the array. The object's key\n of aΒ property serves asΒ theΒ name of theΒ task defined byΒ thatΒ property,\n i.e. canΒ beΒ used when specifying requirements forΒ otherΒ tasks.\n The function receives two arguments: (1) a `callback(err, result)` which must be\n called when finished, passing an `error` (which can be `null`) and the result of\n the function's execution, and (2) a `results` object, containing the results of\n the previously executed functions.\n* `concurrency` - An optional `integer` for determining the maximum number of tasks that can be run in parallel. By default, as many as possible.\n* `callback(err, results)` - An optional callback which is called when all the\n tasks have been completed. It receives the `err` argument if any `tasks`\n pass an error to their callback. Results are always returned; however, if\n an error occurs, no further `tasks` will be performed, and the results\n object will only contain partial results.\n\n\n__Example__\n\n```js\nasync.auto({\n get_data: function(callback){\n console.log('in get_data');\n // async code to get some data\n callback(null, 'data', 'converted to array');\n },\n make_folder: function(callback){\n console.log('in make_folder');\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n callback(null, 'folder');\n },\n write_file: ['get_data', 'make_folder', function(callback, results){\n console.log('in write_file', JSON.stringify(results));\n // once there is some data and the directory exists,\n // write the data to a file in the directory\n callback(null, 'filename');\n }],\n email_link: ['write_file', function(callback, results){\n console.log('in email_link', JSON.stringify(results));\n // once the file is written let's email a link to it...\n // results.write_file contains the filename returned by write_file.\n callback(null, {'file':results.write_file, 'email':'user@example.com'});\n }]\n}, function(err, results) {\n console.log('err = ', err);\n console.log('results = ', results);\n});\n```\n\nThis is a fairly trivial example, but to do this using the basic parallel and\nseries functions would look like this:\n\n```js\nasync.parallel([\n function(callback){\n console.log('in get_data');\n // async code to get some data\n callback(null, 'data', 'converted to array');\n },\n function(callback){\n console.log('in make_folder');\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n callback(null, 'folder');\n }\n],\nfunction(err, results){\n async.series([\n function(callback){\n console.log('in write_file', JSON.stringify(results));\n // once there is some data and the directory exists,\n // write the data to a file in the directory\n results.push('filename');\n callback(null);\n },\n function(callback){\n console.log('in email_link', JSON.stringify(results));\n // once the file is written let's email a link to it...\n callback(null, {'file':results.pop(), 'email':'user@example.com'});\n }\n ]);\n});\n```\n\nFor a complicated series of `async` tasks, using the [`auto`](#auto) function makes adding\nnew tasks much easier (and the code more readable).\n\n\n---------------------------------------\n\n\n### retry([opts = {times: 5, interval: 0}| 5], task, [callback])\n\nAttempts to get a successful response from `task` no more than `times` times before\nreturning an error. If the task is successful, the `callback` will be passed the result\nof the successful task. If all attempts fail, the callback will be passed the error and\nresult (if any) of the final attempt.\n\n__Arguments__\n\n* `opts` - Can be either an object with `times` and `interval` or a number.\n * `times` - The number of attempts to make before giving up. The default is `5`.\n * `interval` - The time to wait between retries, in milliseconds. The default is `0`.\n * If `opts` is a number, the number specifies the number of times to retry, with the default interval of `0`. \n* `task(callback, results)` - A function which receives two arguments: (1) a `callback(err, result)`\n which must be called when finished, passing `err` (which can be `null`) and the `result` of\n the function's execution, and (2) a `results` object, containing the results of\n the previously executed functions (if nested inside another control flow).\n* `callback(err, results)` - An optional callback which is called when the\n task has succeeded, or after the final failed attempt. It receives the `err` and `result` arguments of the last attempt at completing the `task`.\n\nThe [`retry`](#retry) function can be used as a stand-alone control flow by passing a callback, as shown below:\n\n```js\n// try calling apiMethod 3 times\nasync.retry(3, apiMethod, function(err, result) {\n // do something with the result\n});\n```\n\n```js\n// try calling apiMethod 3 times, waiting 200 ms between each retry \nasync.retry({times: 3, interval: 200}, apiMethod, function(err, result) {\n // do something with the result\n});\n```\n\n```js\n// try calling apiMethod the default 5 times no delay between each retry \nasync.retry(apiMethod, function(err, result) {\n // do something with the result\n});\n```\n\nIt can also be embedded within other control flow functions to retry individual methods\nthat are not as reliable, like this:\n\n```js\nasync.auto({\n users: api.getUsers.bind(api),\n payments: async.retry(3, api.getPayments.bind(api))\n}, function(err, results) {\n // do something with the results\n});\n```\n\n\n---------------------------------------\n\n\n### iterator(tasks)\n\nCreates an iterator function which calls the next function in the `tasks` array,\nreturning a continuation to call the next one after that. It's also possible to\nβ€œpeek” at the next iterator with `iterator.next()`.\n\nThis function is used internally by the `async` module, but can be useful when\nyou want to manually control the flow of functions in series.\n\n__Arguments__\n\n* `tasks` - An array of functions to run.\n\n__Example__\n\n```js\nvar iterator = async.iterator([\n function(){ sys.p('one'); },\n function(){ sys.p('two'); },\n function(){ sys.p('three'); }\n]);\n\nnode> var iterator2 = iterator();\n'one'\nnode> var iterator3 = iterator2();\n'two'\nnode> iterator3();\n'three'\nnode> var nextfn = iterator2.next();\nnode> nextfn();\n'three'\n```\n\n---------------------------------------\n\n\n### apply(function, arguments..)\n\nCreates a continuation function with some arguments already applied.\n\nUseful as a shorthand when combined with other control flow functions. Any arguments\npassed to the returned function are added to the arguments originally passed\nto apply.\n\n__Arguments__\n\n* `function` - The function you want to eventually apply all arguments to.\n* `arguments...` - Any number of arguments to automatically apply when the\n continuation is called.\n\n__Example__\n\n```js\n// using apply\n\nasync.parallel([\n async.apply(fs.writeFile, 'testfile1', 'test1'),\n async.apply(fs.writeFile, 'testfile2', 'test2'),\n]);\n\n\n// the same process without using apply\n\nasync.parallel([\n function(callback){\n fs.writeFile('testfile1', 'test1', callback);\n },\n function(callback){\n fs.writeFile('testfile2', 'test2', callback);\n }\n]);\n```\n\nIt's possible to pass any number of additional arguments when calling the\ncontinuation:\n\n```js\nnode> var fn = async.apply(sys.puts, 'one');\nnode> fn('two', 'three');\none\ntwo\nthree\n```\n\n---------------------------------------\n\n\n### nextTick(callback), setImmediate(callback)\n\nCalls `callback` on a later loop around the event loop. In Node.js this just\ncalls `process.nextTick`; in the browser it falls back to `setImmediate(callback)`\nif available, otherwise `setTimeout(callback, 0)`, which means other higher priority\nevents may precede the execution of `callback`.\n\nThis is used internally for browser-compatibility purposes.\n\n__Arguments__\n\n* `callback` - The function to call on a later loop around the event loop.\n\n__Example__\n\n```js\nvar call_order = [];\nasync.nextTick(function(){\n call_order.push('two');\n // call_order now equals ['one','two']\n});\ncall_order.push('one')\n```\n\n\n### times(n, iterator, [callback])\n\nCalls the `iterator` function `n` times, and accumulates results in the same manner\nyou would use with [`map`](#map).\n\n__Arguments__\n\n* `n` - The number of times to run the function.\n* `iterator` - The function to call `n` times.\n* `callback` - see [`map`](#map)\n\n__Example__\n\n```js\n// Pretend this is some complicated async factory\nvar createUser = function(id, callback) {\n callback(null, {\n id: 'user' + id\n })\n}\n// generate 5 users\nasync.times(5, function(n, next){\n createUser(n, function(err, user) {\n next(err, user)\n })\n}, function(err, users) {\n // we should now have 5 users\n});\n```\n\n__Related__\n\n* timesSeries(n, iterator, [callback])\n* timesLimit(n, limit, iterator, [callback])\n\n\n## Utils\n\n\n### memoize(fn, [hasher])\n\nCaches the results of an `async` function. When creating a hash to store function\nresults against, the callback is omitted from the hash and an optional hash\nfunction can be used.\n\nIf no hash function is specified, the first argument is used as a hash key, which may work reasonably if it is a string or a data type that converts to a distinct string. Note that objects and arrays will not behave reasonably. Neither will cases where the other arguments are significant. In such cases, specify your own hash function.\n\nThe cache of results is exposed as the `memo` property of the function returned\nby `memoize`.\n\n__Arguments__\n\n* `fn` - The function to proxy and cache results from.\n* `hasher` - An optional function for generating a custom hash for storing\n results. It has all the arguments applied to it apart from the callback, and\n must be synchronous.\n\n__Example__\n\n```js\nvar slow_fn = function (name, callback) {\n // do something\n callback(null, result);\n};\nvar fn = async.memoize(slow_fn);\n\n// fn can now be used as if it were slow_fn\nfn('some name', function () {\n // callback\n});\n```\n\n\n### unmemoize(fn)\n\nUndoes a [`memoize`](#memoize)d function, reverting it to the original, unmemoized\nform. Handy for testing.\n\n__Arguments__\n\n* `fn` - the memoized function\n\n---------------------------------------\n\n\n### ensureAsync(fn)\n\nWrap an async function and ensure it calls its callback on a later tick of the event loop. If the function already calls its callback on a next tick, no extra deferral is added. This is useful for preventing stack overflows (`RangeError: Maximum call stack size exceeded`) and generally keeping [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) contained.\n\n__Arguments__\n\n* `fn` - an async function, one that expects a node-style callback as its last argument\n\nReturns a wrapped function with the exact same call signature as the function passed in.\n\n__Example__\n\n```js\nfunction sometimesAsync(arg, callback) {\n if (cache[arg]) {\n return callback(null, cache[arg]); // this would be synchronous!!\n } else {\n doSomeIO(arg, callback); // this IO would be asynchronous\n }\n}\n\n// this has a risk of stack overflows if many results are cached in a row\nasync.mapSeries(args, sometimesAsync, done);\n\n// this will defer sometimesAsync's callback if necessary,\n// preventing stack overflows\nasync.mapSeries(args, async.ensureAsync(sometimesAsync), done);\n\n```\n\n---------------------------------------\n\n\n### constant(values...)\n\nReturns a function that when called, calls-back with the values provided. Useful as the first function in a `waterfall`, or for plugging values in to `auto`.\n\n__Example__\n\n```js\nasync.waterfall([\n async.constant(42),\n function (value, next) {\n // value === 42\n },\n //...\n], callback);\n\nasync.waterfall([\n async.constant(filename, \"utf8\"),\n fs.readFile,\n function (fileData, next) {\n //...\n }\n //...\n], callback);\n\nasync.auto({\n hostname: async.constant(\"https://server.net/\"),\n port: findFreePort,\n launchServer: [\"hostname\", \"port\", function (cb, options) {\n startServer(options, cb);\n }],\n //...\n}, callback);\n\n```\n\n---------------------------------------\n\n\n\n### asyncify(func)\n\n__Alias:__ `wrapSync`\n\nTake a sync function and make it async, passing its return value to a callback. This is useful for plugging sync functions into a waterfall, series, or other async functions. Any arguments passed to the generated function will be passed to the wrapped function (except for the final callback argument). Errors thrown will be passed to the callback.\n\n__Example__\n\n```js\nasync.waterfall([\n async.apply(fs.readFile, filename, \"utf8\"),\n async.asyncify(JSON.parse),\n function (data, next) {\n // data is the result of parsing the text.\n // If there was a parsing error, it would have been caught.\n }\n], callback)\n```\n\nIf the function passed to `asyncify` returns a Promise, that promises's resolved/rejected state will be used to call the callback, rather than simply the synchronous return value. Example:\n\n```js\nasync.waterfall([\n async.apply(fs.readFile, filename, \"utf8\"),\n async.asyncify(function (contents) {\n return db.model.create(contents);\n }),\n function (model, next) {\n // `model` is the instantiated model object. \n // If there was an error, this function would be skipped.\n }\n], callback)\n```\n\nThis also means you can asyncify ES2016 `async` functions.\n\n```js\nvar q = async.queue(async.asyncify(async function (file) {\n var intermediateStep = await processFile(file);\n return await somePromise(intermediateStep)\n}));\n\nq.push(files);\n```\n\n---------------------------------------\n\n\n### log(function, arguments)\n\nLogs the result of an `async` function to the `console`. Only works in Node.js or\nin browsers that support `console.log` and `console.error` (such as FF and Chrome).\nIf multiple arguments are returned from the async function, `console.log` is\ncalled on each argument in order.\n\n__Arguments__\n\n* `function` - The function you want to eventually apply all arguments to.\n* `arguments...` - Any number of arguments to apply to the function.\n\n__Example__\n\n```js\nvar hello = function(name, callback){\n setTimeout(function(){\n callback(null, 'hello ' + name);\n }, 1000);\n};\n```\n```js\nnode> async.log(hello, 'world');\n'hello world'\n```\n\n---------------------------------------\n\n\n### dir(function, arguments)\n\nLogs the result of an `async` function to the `console` using `console.dir` to\ndisplay the properties of the resulting object. Only works in Node.js or\nin browsers that support `console.dir` and `console.error` (such as FF and Chrome).\nIf multiple arguments are returned from the async function, `console.dir` is\ncalled on each argument in order.\n\n__Arguments__\n\n* `function` - The function you want to eventually apply all arguments to.\n* `arguments...` - Any number of arguments to apply to the function.\n\n__Example__\n\n```js\nvar hello = function(name, callback){\n setTimeout(function(){\n callback(null, {hello: name});\n }, 1000);\n};\n```\n```js\nnode> async.dir(hello, 'world');\n{hello: 'world'}\n```\n\n---------------------------------------\n\n\n### noConflict()\n\nChanges the value of `async` back to its original value, returning a reference to the\n`async` object.\n", + "readmeFilename": "README.md", "homepage": "https://github.com/caolan/async#readme", "_id": "async@1.5.2", "_shasum": "ec6a61ae56480c0c3cb241c95618e20892f9672a", - "_from": "async@>=1.5.2 <2.0.0", - "_npmVersion": "3.5.2", - "_nodeVersion": "4.2.3", - "_npmUser": { - "name": "aearly", - "email": "alexander.early@gmail.com" - }, - "maintainers": [ - { - "name": "caolan", - "email": "caolan.mcmahon@gmail.com" - }, - { - "name": "beaugunderson", - "email": "beau@beaugunderson.com" - }, - { - "name": "aearly", - "email": "alexander.early@gmail.com" - }, - { - "name": "megawac", - "email": "megawac@gmail.com" - } - ], - "dist": { - "shasum": "ec6a61ae56480c0c3cb241c95618e20892f9672a", - "tarball": "https://registry.npmjs.org/async/-/async-1.5.2.tgz" - }, - "directories": {}, "_resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "readme": "ERROR: No README data found!" + "_from": "async@>=1.5.2 <2.0.0" } diff --git a/node_modules/request/node_modules/form-data/package.json b/node_modules/request/node_modules/form-data/package.json index 95ab6c1dd6d..a230be3af99 100644 --- a/node_modules/request/node_modules/form-data/package.json +++ b/node_modules/request/node_modules/form-data/package.json @@ -57,7 +57,7 @@ "homepage": "https://github.com/form-data/form-data#readme", "_id": "form-data@1.0.0-rc4", "_shasum": "05ac6bc22227b43e4461f488161554699d4f8b5e", - "_from": "form-data@>=1.0.0-rc3 <1.1.0", + "_from": "form-data@>=1.0.0-rc4 <1.1.0", "_npmVersion": "2.14.9", "_nodeVersion": "0.12.11", "_npmUser": { diff --git a/node_modules/request/node_modules/har-validator/node_modules/chalk/node_modules/supports-color/package.json b/node_modules/request/node_modules/har-validator/node_modules/chalk/node_modules/supports-color/package.json index 38a1ecb3ceb..cf1119fe28e 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/chalk/node_modules/supports-color/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/chalk/node_modules/supports-color/package.json @@ -71,7 +71,7 @@ }, "dist": { "shasum": "535d045ce6b6363fa40117084629995e9df324c7", - "tarball": "http://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" + "tarball": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", diff --git a/node_modules/request/node_modules/har-validator/node_modules/commander/node_modules/graceful-readlink/package.json b/node_modules/request/node_modules/har-validator/node_modules/commander/node_modules/graceful-readlink/package.json index 5b8486a16f8..018563f7d02 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/commander/node_modules/graceful-readlink/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/commander/node_modules/graceful-readlink/package.json @@ -40,7 +40,7 @@ ], "dist": { "shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725", - "tarball": "http://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" + "tarball": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", diff --git a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-function/package.json b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-function/package.json index db1ac2aa364..1554b2ed643 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-function/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-function/package.json @@ -45,7 +45,7 @@ ], "dist": { "shasum": "6858fe7c0969b7d4e9093337647ac79f60dfbe74", - "tarball": "http://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz" + "tarball": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", diff --git a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/node_modules/is-property/package.json b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/node_modules/is-property/package.json index 9f236194773..5244786db85 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/node_modules/is-property/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/node_modules/is-property/package.json @@ -52,7 +52,7 @@ ], "dist": { "shasum": "57fe1c4e48474edd65b09911f26b1cd4095dda84", - "tarball": "http://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz" + "tarball": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz" }, "_resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", "readme": "ERROR: No README data found!" diff --git a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/package.json b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/package.json index 8bc73da759f..8442cb17833 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/package.json @@ -43,7 +43,7 @@ ], "dist": { "shasum": "9c0e1c40308ce804f4783618b937fa88f99d50d0", - "tarball": "http://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz" + "tarball": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", diff --git a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/xtend/package.json b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/xtend/package.json index 08542c5ff93..cc323c6f449 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/xtend/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/xtend/package.json @@ -58,27 +58,10 @@ "engines": { "node": ">=0.4" }, - "gitHead": "23dc302a89756da89c1897bc732a752317e35390", + "readme": "# xtend\n\n[![browser support][3]][4]\n\n[![locked](http://badges.github.io/stability-badges/dist/locked.svg)](http://github.com/badges/stability-badges)\n\nExtend like a boss\n\nxtend is a basic utility library which allows you to extend an object by appending all of the properties from each object in a list. When there are identical properties, the right-most property takes precedence.\n\n## Examples\n\n```js\nvar extend = require(\"xtend\")\n\n// extend returns a new object. Does not mutate arguments\nvar combination = extend({\n a: \"a\",\n b: 'c'\n}, {\n b: \"b\"\n})\n// { a: \"a\", b: \"b\" }\n```\n\n## Stability status: Locked\n\n## MIT Licenced\n\n\n [3]: http://ci.testling.com/Raynos/xtend.png\n [4]: http://ci.testling.com/Raynos/xtend\n", + "readmeFilename": "README.md", "_id": "xtend@4.0.1", "_shasum": "a5c6d532be656e23db820efb943a1f04998d63af", - "_from": "xtend@>=4.0.0 <5.0.0", - "_npmVersion": "2.14.1", - "_nodeVersion": "0.10.32", - "_npmUser": { - "name": "raynos", - "email": "raynos2@gmail.com" - }, - "dist": { - "shasum": "a5c6d532be656e23db820efb943a1f04998d63af", - "tarball": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - }, - "maintainers": [ - { - "name": "raynos", - "email": "raynos2@gmail.com" - } - ], - "directories": {}, "_resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "readme": "ERROR: No README data found!" + "_from": "xtend@>=4.0.0 <5.0.0" } diff --git a/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/node_modules/pinkie/package.json b/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/node_modules/pinkie/package.json index 3d6fdc4ad5a..89a4b67c316 100644 --- a/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/node_modules/pinkie/package.json +++ b/node_modules/request/node_modules/har-validator/node_modules/pinkie-promise/node_modules/pinkie/package.json @@ -52,7 +52,7 @@ }, "dist": { "shasum": "72556b80cfa0d48a974e80e77248e80ed4f7f870", - "tarball": "http://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz" + "tarball": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json b/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json index c65fd094047..bf368d3fb77 100644 --- a/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +++ b/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json @@ -43,7 +43,7 @@ }, "dist": { "shasum": "3bdfecdc608147c1c67202fa291e7dca59eaa3b8", - "tarball": "http://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz" + "tarball": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/hawk/node_modules/sntp/package.json b/node_modules/request/node_modules/hawk/node_modules/sntp/package.json index 8b664b60fcd..36a4c033eeb 100644 --- a/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +++ b/node_modules/request/node_modules/hawk/node_modules/sntp/package.json @@ -57,7 +57,7 @@ ], "dist": { "shasum": "6541184cc90aeea6c6e7b35e2659082443c66198", - "tarball": "http://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" + "tarball": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", diff --git a/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json b/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json index 0be073fdcca..6b14225c233 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json @@ -66,7 +66,7 @@ }, "dist": { "shasum": "d74e1b87e7affc0db8aadb7021f3fe48101ab234", - "tarball": "http://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz" + "tarball": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/http-signature/node_modules/jsprim/CHANGES.md b/node_modules/request/node_modules/http-signature/node_modules/jsprim/CHANGES.md index 75bc4f025c8..ab3a66417a6 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/jsprim/CHANGES.md +++ b/node_modules/request/node_modules/http-signature/node_modules/jsprim/CHANGES.md @@ -4,6 +4,11 @@ None yet. +## v1.3.0 (2016-06-22) + +* #14 add safer version of hasOwnProperty() +* #15 forEachKey() should ignore inherited properties + ## v1.2.2 (2015-10-15) * #11 NPM package shouldn't include any code that does `require('JSV')` diff --git a/node_modules/request/node_modules/http-signature/node_modules/jsprim/README.md b/node_modules/request/node_modules/http-signature/node_modules/jsprim/README.md index b502b2d3a4d..7303642e016 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/jsprim/README.md +++ b/node_modules/request/node_modules/http-signature/node_modules/jsprim/README.md @@ -19,14 +19,23 @@ Returns whether two objects are equal. Returns true if the given object has no properties and false otherwise. This is O(1) (unlike `Object.keys(obj).length === 0`, which is O(N)). +### hasKey(obj, key) + +Returns true if the given object has an enumerable, non-inherited property +called `key`. [For information on enumerability and ownership of properties, see +the MDN +documentation.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties) ### forEachKey(obj, callback) -Like Array.forEach, but iterates properties of an object rather than elements -of an array. Equivalent to: +Like Array.forEach, but iterates enumerable, owned properties of an object +rather than elements of an array. Equivalent to: - for (var key in obj) - callback(key, obj[key]); + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + callback(key, obj[key]); + } + } ### flattenObject(obj, depth) diff --git a/node_modules/request/node_modules/http-signature/node_modules/jsprim/lib/jsprim.js b/node_modules/request/node_modules/http-signature/node_modules/jsprim/lib/jsprim.js index 5ee46889223..26c3ba1c076 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/jsprim/lib/jsprim.js +++ b/node_modules/request/node_modules/http-signature/node_modules/jsprim/lib/jsprim.js @@ -15,6 +15,7 @@ var mod_jsonschema = require('json-schema'); exports.deepCopy = deepCopy; exports.deepEqual = deepEqual; exports.isEmpty = isEmpty; +exports.hasKey = hasKey; exports.forEachKey = forEachKey; exports.pluck = pluck; exports.flattenObject = flattenObject; @@ -122,10 +123,19 @@ function isEmpty(obj) return (true); } +function hasKey(obj, key) +{ + mod_assert.equal(typeof (key), 'string'); + return (Object.prototype.hasOwnProperty.call(obj, key)); +} + function forEachKey(obj, callback) { - for (var key in obj) - callback(key, obj[key]); + for (var key in obj) { + if (hasKey(obj, key)) { + callback(key, obj[key]); + } + } } function pluck(obj, key) diff --git a/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/extsprintf/package.json b/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/extsprintf/package.json index 8be381aaccd..ed08acb72e1 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/extsprintf/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/extsprintf/package.json @@ -13,7 +13,7 @@ "_id": "extsprintf@1.0.2", "dist": { "shasum": "e1080e0658e300b06294990cc70e1502235fd550", - "tarball": "http://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz" + "tarball": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz" }, "_npmVersion": "1.1.65", "_npmUser": { diff --git a/node_modules/request/node_modules/http-signature/node_modules/jsprim/package.json b/node_modules/request/node_modules/http-signature/node_modules/jsprim/package.json index e77992ef32d..ab64d862744 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/jsprim/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/jsprim/package.json @@ -1,6 +1,6 @@ { "name": "jsprim", - "version": "1.2.2", + "version": "1.3.0", "description": "utilities for primitive JavaScript types", "main": "./lib/jsprim.js", "repository": { @@ -16,17 +16,17 @@ "node >=0.6.0" ], "license": "MIT", - "gitHead": "0e709876c35eddfe4c1f95104ac3c4abfc9dab84", + "gitHead": "694edcb22e2291c21f6c2a23907bf02e1edbfdf4", "bugs": { "url": "https://github.com/davepacheco/node-jsprim/issues" }, - "homepage": "https://github.com/davepacheco/node-jsprim", - "_id": "jsprim@1.2.2", + "homepage": "https://github.com/davepacheco/node-jsprim#readme", + "_id": "jsprim@1.3.0", "scripts": {}, - "_shasum": "f20c906ac92abd58e3b79ac8bc70a48832512da1", + "_shasum": "ce2e1bef835204b4f3099928c602f8b6ae615650", "_from": "jsprim@>=1.2.2 <2.0.0", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.2", + "_npmVersion": "2.11.3", + "_nodeVersion": "0.12.7", "_npmUser": { "name": "dap", "email": "dap@cs.brown.edu" @@ -38,10 +38,14 @@ } ], "dist": { - "shasum": "f20c906ac92abd58e3b79ac8bc70a48832512da1", - "tarball": "http://registry.npmjs.org/jsprim/-/jsprim-1.2.2.tgz" + "shasum": "ce2e1bef835204b4f3099928c602f8b6ae615650", + "tarball": "https://registry.npmjs.org/jsprim/-/jsprim-1.3.0.tgz" + }, + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/jsprim-1.3.0.tgz_1466708163640_0.5282344303559512" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.2.2.tgz", + "_resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.3.0.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/README.md b/node_modules/request/node_modules/http-signature/node_modules/sshpk/README.md index d0fa88dfa29..00a4055204f 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/README.md +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/README.md @@ -401,6 +401,206 @@ Parameters Same as `this.toBuffer(format).toString('base64')`. +## Certificates + +`sshpk` includes basic support for parsing certificates in X.509 (PEM) format +and the OpenSSH certificate format. This feature is intended to be used mainly +to access basic metadata about certificates, extract public keys from them, and +also to generate simple self-signed certificates from an existing key. + +Notably, there is no implementation of CA chain-of-trust verification, and no +support for key usage restrictions (or other kinds of restrictions). Please do +the security world a favour, and DO NOT use this code for certificate +verification in the traditional X.509 CA chain style. + +### `parseCertificate(data, format)` + +Parameters + + - `data` -- a Buffer or String + - `format` -- a String, format to use, one of `'openssh'`, `'pem'` (X.509 in a + PEM wrapper), or `'x509'` (raw DER encoded) + +### `createSelfSignedCertificate(subject, privateKey[, options])` + +Parameters + + - `subject` -- an Identity, the subject of the certificate + - `privateKey` -- a PrivateKey, the key of the subject: will be used both to be + placed in the certificate and also to sign it (since this is + a self-signed certificate) + - `options` -- optional Object, with keys: + - `lifetime` -- optional Number, lifetime of the certificate from now in + seconds + - `validFrom`, `validUntil` -- optional Dates, beginning and end of + certificate validity period. If given + `lifetime` will be ignored + - `serial` -- optional Buffer, the serial number of the certificate + +### `createCertificate(subject, key, issuer, issuerKey[, options])` + +Parameters + + - `subject` -- an Identity, the subject of the certificate + - `key` -- a Key, the public key of the subject + - `issuer` -- an Identity, the issuer of the certificate who will sign it + - `issuerKey` -- a PrivateKey, the issuer's private key for signing + - `options` -- optional Object, with keys: + - `lifetime` -- optional Number, lifetime of the certificate from now in + seconds + - `validFrom`, `validUntil` -- optional Dates, beginning and end of + certificate validity period. If given + `lifetime` will be ignored + - `serial` -- optional Buffer, the serial number of the certificate + +### `Certificate#subjects` + +Array of `Identity` instances describing the subject of this certificate. + +### `Certificate#issuer` + +The `Identity` of the Certificate's issuer (signer). + +### `Certificate#subjectKey` + +The public key of the subject of the certificate, as a `Key` instance. + +### `Certificate#issuerKey` + +The public key of the signing issuer of this certificate, as a `Key` instance. +May be `undefined` if the issuer's key is unknown (e.g. on an X509 certificate). + +### `Certificate#serial` + +The serial number of the certificate. As this is normally a 64-bit or wider +integer, it is returned as a Buffer. + +### `Certificate#isExpired([when])` + +Tests whether the Certificate is currently expired (i.e. the `validFrom` and +`validUntil` dates specify a range of time that does not include the current +time). + +Parameters + + - `when` -- optional Date, if specified, tests whether the Certificate was or + will be expired at the specified time instead of now + +Returns a Boolean. + +### `Certificate#isSignedByKey(key)` + +Tests whether the Certificate was validly signed by the given (public) Key. + +Parameters + + - `key` -- a Key instance + +Returns a Boolean. + +### `Certificate#isSignedBy(certificate)` + +Tests whether this Certificate was validly signed by the subject of the given +certificate. Also tests that the issuer Identity of this Certificate and the +subject Identity of the other Certificate are equivalent. + +Parameters + + - `certificate` -- another Certificate instance + +Returns a Boolean. + +### `Certificate#fingerprint([hashAlgo])` + +Returns the X509-style fingerprint of the entire certificate (as a Fingerprint +instance). This matches what a web-browser or similar would display as the +certificate fingerprint and should not be confused with the fingerprint of the +subject's public key. + +Parameters + + - `hashAlgo` -- an optional String, any hash function name + +### `Certificate#toBuffer([format])` + +Serializes the Certificate to a Buffer and returns it. + +Parameters + + - `format` -- an optional String, output format, one of `'openssh'`, `'pem'` or + `'x509'`. Defaults to `'x509'`. + +Returns a Buffer. + +### `Certificate#toString([format])` + + - `format` -- an optional String, output format, one of `'openssh'`, `'pem'` or + `'x509'`. Defaults to `'pem'`. + +Returns a String. + +## Certificate identities + +### `identityForHost(hostname)` + +Constructs a host-type Identity for a given hostname. + +Parameters + + - `hostname` -- the fully qualified DNS name of the host + +Returns an Identity instance. + +### `identityForUser(uid)` + +Constructs a user-type Identity for a given UID. + +Parameters + + - `uid` -- a String, user identifier (login name) + +Returns an Identity instance. + +### `identityForEmail(email)` + +Constructs an email-type Identity for a given email address. + +Parameters + + - `email` -- a String, email address + +Returns an Identity instance. + +### `identityFromDN(dn)` + +Parses an LDAP-style DN string (e.g. `'CN=foo, C=US'`) and turns it into an +Identity instance. + +Parameters + + - `dn` -- a String + +Returns an Identity instance. + +### `Identity#toString()` + +Returns the identity as an LDAP-style DN string. +e.g. `'CN=foo, O=bar corp, C=us'` + +### `Identity#type` + +The type of identity. One of `'host'`, `'user'`, `'email'` or `'unknown'` + +### `Identity#hostname` +### `Identity#uid` +### `Identity#email` + +Set when `type` is `'host'`, `'user'`, or `'email'`, respectively. Strings. + +### `Identity#cn` + +The value of the first `CN=` in the DN, if any. + Errors ------ @@ -433,8 +633,8 @@ The key data given could not be parsed as a valid key. Properties -- `keyName` -- `filename` that was given to `Key#parse` -- `format` -- the `format` that was trying to parse the key +- `keyName` -- `filename` that was given to `parseKey` +- `format` -- the `format` that was trying to parse the key (see `parseKey`) - `innerErr` -- the inner Error thrown by the format parser ### `KeyEncryptedError` @@ -444,10 +644,21 @@ parsing operation would succeed if it was given the `passphrase` option. Properties -- `keyName` -- `filename` that was given to `Key#parse` +- `keyName` -- `filename` that was given to `parseKey` - `format` -- the `format` that was trying to parse the key (currently can only be `"pem"`) +### `CertificateParseError` + +The certificate data given could not be parsed as a valid certificate. + +Properties + +- `certName` -- `filename` that was given to `parseCertificate` +- `format` -- the `format` that was trying to parse the key + (see `parseCertificate`) +- `innerErr` -- the inner Error thrown by the format parser + Friends of sshpk ---------------- diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/certificate.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/certificate.js new file mode 100644 index 00000000000..4fbe6abad45 --- /dev/null +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/certificate.js @@ -0,0 +1,291 @@ +// Copyright 2016 Joyent, Inc. + +module.exports = Certificate; + +var assert = require('assert-plus'); +var algs = require('./algs'); +var crypto = require('crypto'); +var Fingerprint = require('./fingerprint'); +var Signature = require('./signature'); +var errs = require('./errors'); +var util = require('util'); +var utils = require('./utils'); +var Key = require('./key'); +var PrivateKey = require('./private-key'); +var Identity = require('./identity'); + +var formats = {}; +formats['openssh'] = require('./formats/openssh-cert'); +formats['x509'] = require('./formats/x509'); +formats['pem'] = require('./formats/x509-pem'); + +var CertificateParseError = errs.CertificateParseError; +var InvalidAlgorithmError = errs.InvalidAlgorithmError; + +function Certificate(opts) { + assert.object(opts, 'options'); + assert.arrayOfObject(opts.subjects, 'options.subjects'); + utils.assertCompatible(opts.subjects[0], Identity, [1, 0], + 'options.subjects'); + utils.assertCompatible(opts.subjectKey, Key, [1, 0], + 'options.subjectKey'); + utils.assertCompatible(opts.issuer, Identity, [1, 0], 'options.issuer'); + if (opts.issuerKey !== undefined) { + utils.assertCompatible(opts.issuerKey, Key, [1, 0], + 'options.issuerKey'); + } + assert.object(opts.signatures, 'options.signatures'); + assert.buffer(opts.serial, 'options.serial'); + assert.date(opts.validFrom, 'options.validFrom'); + assert.date(opts.validUntil, 'optons.validUntil'); + + this._hashCache = {}; + + this.subjects = opts.subjects; + this.issuer = opts.issuer; + this.subjectKey = opts.subjectKey; + this.issuerKey = opts.issuerKey; + this.signatures = opts.signatures; + this.serial = opts.serial; + this.validFrom = opts.validFrom; + this.validUntil = opts.validUntil; +} + +Certificate.formats = formats; + +Certificate.prototype.toBuffer = function (format, options) { + if (format === undefined) + format = 'x509'; + assert.string(format, 'format'); + assert.object(formats[format], 'formats[format]'); + assert.optionalObject(options, 'options'); + + return (formats[format].write(this, options)); +}; + +Certificate.prototype.toString = function (format, options) { + if (format === undefined) + format = 'pem'; + return (this.toBuffer(format, options).toString()); +}; + +Certificate.prototype.fingerprint = function (algo) { + if (algo === undefined) + algo = 'sha256'; + assert.string(algo, 'algorithm'); + var opts = { + type: 'certificate', + hash: this.hash(algo), + algorithm: algo + }; + return (new Fingerprint(opts)); +}; + +Certificate.prototype.hash = function (algo) { + assert.string(algo, 'algorithm'); + algo = algo.toLowerCase(); + if (algs.hashAlgs[algo] === undefined) + throw (new InvalidAlgorithmError(algo)); + + if (this._hashCache[algo]) + return (this._hashCache[algo]); + + var hash = crypto.createHash(algo). + update(this.toBuffer('x509')).digest(); + this._hashCache[algo] = hash; + return (hash); +}; + +Certificate.prototype.isExpired = function (when) { + if (when === undefined) + when = new Date(); + return (!((when.getTime() >= this.validFrom.getTime()) && + (when.getTime() < this.validUntil.getTime()))); +}; + +Certificate.prototype.isSignedBy = function (issuerCert) { + utils.assertCompatible(issuerCert, Certificate, [1, 0], 'issuer'); + + if (!this.issuer.equals(issuerCert.subjects[0])) + return (false); + + return (this.isSignedByKey(issuerCert.subjectKey)); +}; + +Certificate.prototype.isSignedByKey = function (issuerKey) { + utils.assertCompatible(issuerKey, Key, [1, 2], 'issuerKey'); + + if (this.issuerKey !== undefined) { + return (this.issuerKey. + fingerprint('sha512').matches(issuerKey)); + } + + var fmt = Object.keys(this.signatures)[0]; + var valid = formats[fmt].verify(this, issuerKey); + if (valid) + this.issuerKey = issuerKey; + return (valid); +}; + +Certificate.prototype.signWith = function (key) { + utils.assertCompatible(key, PrivateKey, [1, 2], 'key'); + var fmts = Object.keys(formats); + var didOne = false; + for (var i = 0; i < fmts.length; ++i) { + if (fmts[i] !== 'pem') { + var ret = formats[fmts[i]].sign(this, key); + if (ret === true) + didOne = true; + } + } + if (!didOne) { + throw (new Error('Failed to sign the certificate for any ' + + 'available certificate formats')); + } +}; + +Certificate.createSelfSigned = function (subjectOrSubjects, key, options) { + var subjects; + if (Array.isArray(subjectOrSubjects)) + subjects = subjectOrSubjects; + else + subjects = [subjectOrSubjects]; + + assert.arrayOfObject(subjects); + subjects.forEach(function (subject) { + utils.assertCompatible(subject, Identity, [1, 0], 'subject'); + }); + + utils.assertCompatible(key, PrivateKey, [1, 2], 'private key'); + + assert.optionalObject(options, 'options'); + if (options === undefined) + options = {}; + assert.optionalObject(options.validFrom, 'options.validFrom'); + assert.optionalObject(options.validUntil, 'options.validUntil'); + var validFrom = options.validFrom; + var validUntil = options.validUntil; + if (validFrom === undefined) + validFrom = new Date(); + if (validUntil === undefined) { + assert.optionalNumber(options.lifetime, 'options.lifetime'); + var lifetime = options.lifetime; + if (lifetime === undefined) + lifetime = 10*365*24*3600; + validUntil = new Date(); + validUntil.setTime(validUntil.getTime() + lifetime*1000); + } + assert.optionalBuffer(options.serial, 'options.serial'); + var serial = options.serial; + if (serial === undefined) + serial = new Buffer('0000000000000001', 'hex'); + + var cert = new Certificate({ + subjects: subjects, + issuer: subjects[0], + subjectKey: key.toPublic(), + issuerKey: key.toPublic(), + signatures: {}, + serial: serial, + validFrom: validFrom, + validUntil: validUntil + }); + cert.signWith(key); + + return (cert); +}; + +Certificate.create = + function (subjectOrSubjects, key, issuer, issuerKey, options) { + var subjects; + if (Array.isArray(subjectOrSubjects)) + subjects = subjectOrSubjects; + else + subjects = [subjectOrSubjects]; + + assert.arrayOfObject(subjects); + subjects.forEach(function (subject) { + utils.assertCompatible(subject, Identity, [1, 0], 'subject'); + }); + + utils.assertCompatible(key, Key, [1, 0], 'key'); + if (PrivateKey.isPrivateKey(key)) + key = key.toPublic(); + utils.assertCompatible(issuer, Identity, [1, 0], 'issuer'); + utils.assertCompatible(issuerKey, PrivateKey, [1, 2], 'issuer key'); + + assert.optionalObject(options, 'options'); + if (options === undefined) + options = {}; + assert.optionalObject(options.validFrom, 'options.validFrom'); + assert.optionalObject(options.validUntil, 'options.validUntil'); + var validFrom = options.validFrom; + var validUntil = options.validUntil; + if (validFrom === undefined) + validFrom = new Date(); + if (validUntil === undefined) { + assert.optionalNumber(options.lifetime, 'options.lifetime'); + var lifetime = options.lifetime; + if (lifetime === undefined) + lifetime = 10*365*24*3600; + validUntil = new Date(); + validUntil.setTime(validUntil.getTime() + lifetime*1000); + } + assert.optionalBuffer(options.serial, 'options.serial'); + var serial = options.serial; + if (serial === undefined) + serial = new Buffer('0000000000000001', 'hex'); + + var cert = new Certificate({ + subjects: subjects, + issuer: issuer, + subjectKey: key, + issuerKey: issuerKey.toPublic(), + signatures: {}, + serial: serial, + validFrom: validFrom, + validUntil: validUntil + }); + cert.signWith(issuerKey); + + return (cert); +}; + +Certificate.parse = function (data, format, options) { + if (typeof (data) !== 'string') + assert.buffer(data, 'data'); + if (format === undefined) + format = 'auto'; + assert.string(format, 'format'); + if (typeof (options) === 'string') + options = { filename: options }; + assert.optionalObject(options, 'options'); + if (options === undefined) + options = {}; + assert.optionalString(options.filename, 'options.filename'); + if (options.filename === undefined) + options.filename = '(unnamed)'; + + assert.object(formats[format], 'formats[format]'); + + try { + var k = formats[format].read(data, options); + return (k); + } catch (e) { + throw (new CertificateParseError(options.filename, format, e)); + } +}; + +Certificate.isCertificate = function (obj, ver) { + return (utils.isCompatible(obj, Certificate, ver)); +}; + +/* + * API versions for Certificate: + * [1,0] -- initial ver + */ +Certificate.prototype._sshpkApiVersion = [1, 0]; + +Certificate._oldVersionDetect = function (obj) { + return ([1, 0]); +}; diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/errors.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/errors.js index d984f1ac3f6..1cc09ec71d4 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/errors.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/errors.js @@ -50,6 +50,18 @@ function SignatureParseError(type, format, innerErr) { } util.inherits(SignatureParseError, Error); +function CertificateParseError(name, format, innerErr) { + if (Error.captureStackTrace) + Error.captureStackTrace(this, CertificateParseError); + this.name = 'CertificateParseError'; + this.format = format; + this.certName = name; + this.innerErr = innerErr; + this.message = 'Failed to parse ' + name + ' as a valid ' + format + + ' format certificate: ' + innerErr.message; +} +util.inherits(CertificateParseError, Error); + function KeyEncryptedError(name, format) { if (Error.captureStackTrace) Error.captureStackTrace(this, KeyEncryptedError); @@ -67,5 +79,6 @@ module.exports = { InvalidAlgorithmError: InvalidAlgorithmError, KeyParseError: KeyParseError, SignatureParseError: SignatureParseError, - KeyEncryptedError: KeyEncryptedError + KeyEncryptedError: KeyEncryptedError, + CertificateParseError: CertificateParseError }; diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/fingerprint.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/fingerprint.js index c607330e7f5..7ed7e513046 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/fingerprint.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/fingerprint.js @@ -7,6 +7,7 @@ var algs = require('./algs'); var crypto = require('crypto'); var errs = require('./errors'); var Key = require('./key'); +var Certificate = require('./certificate'); var utils = require('./utils'); var FingerprintFormatError = errs.FingerprintFormatError; @@ -14,6 +15,7 @@ var InvalidAlgorithmError = errs.InvalidAlgorithmError; function Fingerprint(opts) { assert.object(opts, 'options'); + assert.string(opts.type, 'options.type'); assert.buffer(opts.hash, 'options.hash'); assert.string(opts.algorithm, 'options.algorithm'); @@ -22,6 +24,7 @@ function Fingerprint(opts) { throw (new InvalidAlgorithmError(this.algorithm)); this.hash = opts.hash; + this.type = opts.type; } Fingerprint.prototype.toString = function (format) { @@ -44,11 +47,16 @@ Fingerprint.prototype.toString = function (format) { } }; -Fingerprint.prototype.matches = function (key) { - assert.object(key, 'key'); - utils.assertCompatible(key, Key, [1, 0], 'key'); +Fingerprint.prototype.matches = function (other) { + assert.object(other, 'key or certificate'); + if (this.type === 'key') { + utils.assertCompatible(other, Key, [1, 0], 'key'); + } else { + utils.assertCompatible(other, Certificate, [1, 0], + 'certificate'); + } - var theirHash = key.hash(this.algorithm); + var theirHash = other.hash(this.algorithm); var theirHash2 = crypto.createHash(this.algorithm). update(theirHash).digest('base64'); @@ -59,10 +67,19 @@ Fingerprint.prototype.matches = function (key) { return (this.hash2 === theirHash2); }; -Fingerprint.parse = function (fp, enAlgs) { +Fingerprint.parse = function (fp, options) { assert.string(fp, 'fingerprint'); - var alg, hash; + var alg, hash, enAlgs; + if (Array.isArray(options)) { + enAlgs = options; + options = {}; + } + assert.optionalObject(options, 'options'); + if (options === undefined) + options = {}; + if (options.enAlgs !== undefined) + enAlgs = options.enAlgs; assert.optionalArrayOfString(enAlgs, 'algorithms'); var parts = fp.split(':'); @@ -105,7 +122,11 @@ Fingerprint.parse = function (fp, enAlgs) { throw (new InvalidAlgorithmError(alg)); } - return (new Fingerprint({algorithm: alg, hash: hash})); + return (new Fingerprint({ + algorithm: alg, + hash: hash, + type: options.type || 'key' + })); }; function addColons(s) { diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/openssh-cert.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/openssh-cert.js new file mode 100644 index 00000000000..8ce7350fee2 --- /dev/null +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/openssh-cert.js @@ -0,0 +1,289 @@ +// Copyright 2016 Joyent, Inc. + +module.exports = { + read: read, + verify: verify, + sign: sign, + write: write, + + /* Internal private API */ + fromBuffer: fromBuffer, + toBuffer: toBuffer +}; + +var assert = require('assert-plus'); +var SSHBuffer = require('../ssh-buffer'); +var crypto = require('crypto'); +var algs = require('../algs'); +var Key = require('../key'); +var PrivateKey = require('../private-key'); +var Identity = require('../identity'); +var rfc4253 = require('./rfc4253'); +var Signature = require('../signature'); +var utils = require('../utils'); +var Certificate = require('../certificate'); + +function verify(cert, key) { + /* + * We always give an issuerKey, so if our verify() is being called then + * there was no signature. Return false. + */ + return (false); +} + +var TYPES = { + 'user': 1, + 'host': 2 +}; +Object.keys(TYPES).forEach(function (k) { TYPES[TYPES[k]] = k; }); + +var ECDSA_ALGO = /^ecdsa-sha2-([^@-]+)-cert-v01@openssh.com$/; + +function read(buf, options) { + if (Buffer.isBuffer(buf)) + buf = buf.toString('ascii'); + var parts = buf.trim().split(/[ \t\n]+/g); + if (parts.length < 2 || parts.length > 3) + throw (new Error('Not a valid SSH certificate line')); + + var algo = parts[0]; + var data = parts[1]; + + data = new Buffer(data, 'base64'); + return (fromBuffer(data, algo)); +} + +function fromBuffer(data, algo, partial) { + var sshbuf = new SSHBuffer({ buffer: data }); + var innerAlgo = sshbuf.readString(); + if (algo !== undefined && innerAlgo !== algo) + throw (new Error('SSH certificate algorithm mismatch')); + if (algo === undefined) + algo = innerAlgo; + + var cert = {}; + cert.signatures = {}; + cert.signatures.openssh = {}; + + cert.signatures.openssh.nonce = sshbuf.readBuffer(); + + var key = {}; + var parts = (key.parts = []); + key.type = getAlg(algo); + + var partCount = algs.info[key.type].parts.length; + while (parts.length < partCount) + parts.push(sshbuf.readPart()); + assert.ok(parts.length >= 1, 'key must have at least one part'); + + var algInfo = algs.info[key.type]; + if (key.type === 'ecdsa') { + var res = ECDSA_ALGO.exec(algo); + assert.ok(res !== null); + assert.strictEqual(res[1], parts[0].data.toString()); + } + + for (var i = 0; i < algInfo.parts.length; ++i) { + parts[i].name = algInfo.parts[i]; + if (parts[i].name !== 'curve' && + algInfo.normalize !== false) { + var p = parts[i]; + p.data = utils.mpNormalize(p.data); + } + } + + cert.subjectKey = new Key(key); + + cert.serial = sshbuf.readInt64(); + + var type = TYPES[sshbuf.readInt()]; + assert.string(type, 'valid cert type'); + + cert.signatures.openssh.keyId = sshbuf.readString(); + + var principals = []; + var pbuf = sshbuf.readBuffer(); + var psshbuf = new SSHBuffer({ buffer: pbuf }); + while (!psshbuf.atEnd()) + principals.push(psshbuf.readString()); + if (principals.length === 0) + principals = ['*']; + + cert.subjects = principals.map(function (pr) { + if (type === 'user') + return (Identity.forUser(pr)); + else if (type === 'host') + return (Identity.forHost(pr)); + throw (new Error('Unknown identity type ' + type)); + }); + + cert.validFrom = int64ToDate(sshbuf.readInt64()); + cert.validUntil = int64ToDate(sshbuf.readInt64()); + + cert.signatures.openssh.critical = sshbuf.readBuffer(); + cert.signatures.openssh.exts = sshbuf.readBuffer(); + + /* reserved */ + sshbuf.readBuffer(); + + var signingKeyBuf = sshbuf.readBuffer(); + cert.issuerKey = rfc4253.read(signingKeyBuf); + + /* + * OpenSSH certs don't give the identity of the issuer, just their + * public key. So, we use an Identity that matches anything. The + * isSignedBy() function will later tell you if the key matches. + */ + cert.issuer = Identity.forHost('**'); + + var sigBuf = sshbuf.readBuffer(); + cert.signatures.openssh.signature = + Signature.parse(sigBuf, cert.issuerKey.type, 'ssh'); + + if (partial !== undefined) { + partial.remainder = sshbuf.remainder(); + partial.consumed = sshbuf._offset; + } + + return (new Certificate(cert)); +} + +function int64ToDate(buf) { + var i = buf.readUInt32BE(0) * 4294967296; + i += buf.readUInt32BE(4); + var d = new Date(); + d.setTime(i * 1000); + d.sourceInt64 = buf; + return (d); +} + +function dateToInt64(date) { + if (date.sourceInt64 !== undefined) + return (date.sourceInt64); + var i = Math.round(date.getTime() / 1000); + var upper = Math.floor(i / 4294967296); + var lower = Math.floor(i % 4294967296); + var buf = new Buffer(8); + buf.writeUInt32BE(upper, 0); + buf.writeUInt32BE(lower, 4); + return (buf); +} + +function sign(cert, key) { + if (cert.signatures.openssh === undefined) + cert.signatures.openssh = {}; + try { + var blob = toBuffer(cert, true); + } catch (e) { + delete (cert.signatures.openssh); + return (false); + } + var sig = cert.signatures.openssh; + var hashAlgo = undefined; + if (key.type === 'rsa' || key.type === 'dsa') + hashAlgo = 'sha1'; + var signer = key.createSign(hashAlgo); + signer.write(blob); + sig.signature = signer.sign(); + return (true); +} + +function write(cert, options) { + if (options === undefined) + options = {}; + + var blob = toBuffer(cert); + var out = getCertType(cert.subjectKey) + ' ' + blob.toString('base64'); + if (options.comment) + out = out + ' ' + options.comment; + return (out); +} + + +function toBuffer(cert, noSig) { + assert.object(cert.signatures.openssh, 'signature for openssh format'); + var sig = cert.signatures.openssh; + + if (sig.nonce === undefined) + sig.nonce = crypto.randomBytes(16); + var buf = new SSHBuffer({}); + buf.writeString(getCertType(cert.subjectKey)); + buf.writeBuffer(sig.nonce); + + var key = cert.subjectKey; + var algInfo = algs.info[key.type]; + algInfo.parts.forEach(function (part) { + buf.writePart(key.part[part]); + }); + + buf.writeInt64(cert.serial); + + var type = cert.subjects[0].type; + assert.notStrictEqual(type, 'unknown'); + cert.subjects.forEach(function (id) { + assert.strictEqual(id.type, type); + }); + type = TYPES[type]; + buf.writeInt(type); + + if (sig.keyId === undefined) { + sig.keyId = cert.subjects[0].type + '_' + + (cert.subjects[0].uid || cert.subjects[0].hostname); + } + buf.writeString(sig.keyId); + + var sub = new SSHBuffer({}); + cert.subjects.forEach(function (id) { + if (type === TYPES.host) + sub.writeString(id.hostname); + else if (type === TYPES.user) + sub.writeString(id.uid); + }); + buf.writeBuffer(sub.toBuffer()); + + buf.writeInt64(dateToInt64(cert.validFrom)); + buf.writeInt64(dateToInt64(cert.validUntil)); + + if (sig.critical === undefined) + sig.critical = new Buffer(0); + buf.writeBuffer(sig.critical); + + if (sig.exts === undefined) + sig.exts = new Buffer(0); + buf.writeBuffer(sig.exts); + + /* reserved */ + buf.writeBuffer(new Buffer(0)); + + sub = rfc4253.write(cert.issuerKey); + buf.writeBuffer(sub); + + if (!noSig) + buf.writeBuffer(sig.signature.toBuffer('ssh')); + + return (buf.toBuffer()); +} + +function getAlg(certType) { + if (certType === 'ssh-rsa-cert-v01@openssh.com') + return ('rsa'); + if (certType === 'ssh-dss-cert-v01@openssh.com') + return ('dsa'); + if (certType.match(ECDSA_ALGO)) + return ('ecdsa'); + if (certType === 'ssh-ed25519-cert-v01@openssh.com') + return ('ed25519'); + throw (new Error('Unsupported cert type ' + certType)); +} + +function getCertType(key) { + if (key.type === 'rsa') + return ('ssh-rsa-cert-v01@openssh.com'); + if (key.type === 'dsa') + return ('ssh-dss-cert-v01@openssh.com'); + if (key.type === 'ecdsa') + return ('ecdsa-sha2-' + key.curve + '-cert-v01@openssh.com'); + if (key.type === 'ed25519') + return ('ssh-ed25519-cert-v01@openssh.com'); + throw (new Error('Unsupported key type ' + key.type)); +} diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/pkcs8.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/pkcs8.js index 33fb7cc4759..4ccbefcbec2 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/pkcs8.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/pkcs8.js @@ -42,10 +42,12 @@ function readPkcs8(alg, type, der) { } der.readSequence(); + var next = der.offset + der.length; var oid = der.readOID(); switch (oid) { case '1.2.840.113549.1.1.1': + der._offset = next; if (type === 'public') return (readPkcs8RSAPublic(der)); else @@ -66,10 +68,6 @@ function readPkcs8(alg, type, der) { } function readPkcs8RSAPublic(der) { - // Null -- XXX this probably isn't good practice - der.readByte(); - der.readByte(); - // bit string sequence der.readSequence(asn1.Ber.BitString); der.readByte(); @@ -93,9 +91,6 @@ function readPkcs8RSAPublic(der) { } function readPkcs8RSAPrivate(der) { - der.readByte(); - der.readByte(); - der.readSequence(asn1.Ber.OctetString); der.readSequence(); diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509-pem.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509-pem.js new file mode 100644 index 00000000000..c59c7d5ff0a --- /dev/null +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509-pem.js @@ -0,0 +1,77 @@ +// Copyright 2016 Joyent, Inc. + +var x509 = require('./x509'); + +module.exports = { + read: read, + verify: x509.verify, + sign: x509.sign, + write: write +}; + +var assert = require('assert-plus'); +var asn1 = require('asn1'); +var algs = require('../algs'); +var utils = require('../utils'); +var Key = require('../key'); +var PrivateKey = require('../private-key'); +var pem = require('./pem'); +var Identity = require('../identity'); +var Signature = require('../signature'); +var Certificate = require('../certificate'); + +function read(buf, options) { + if (typeof (buf) !== 'string') { + assert.buffer(buf, 'buf'); + buf = buf.toString('ascii'); + } + + var lines = buf.trim().split(/[\r\n]+/g); + + var m = lines[0].match(/*JSSTYLED*/ + /[-]+[ ]*BEGIN CERTIFICATE[ ]*[-]+/); + assert.ok(m, 'invalid PEM header'); + + var m2 = lines[lines.length - 1].match(/*JSSTYLED*/ + /[-]+[ ]*END CERTIFICATE[ ]*[-]+/); + assert.ok(m2, 'invalid PEM footer'); + + var headers = {}; + while (true) { + lines = lines.slice(1); + m = lines[0].match(/*JSSTYLED*/ + /^([A-Za-z0-9-]+): (.+)$/); + if (!m) + break; + headers[m[1].toLowerCase()] = m[2]; + } + + /* Chop off the first and last lines */ + lines = lines.slice(0, -1).join(''); + buf = new Buffer(lines, 'base64'); + + return (x509.read(buf, options)); +} + +function write(cert, options) { + var dbuf = x509.write(cert, options); + + var header = 'CERTIFICATE'; + var tmp = dbuf.toString('base64'); + var len = tmp.length + (tmp.length / 64) + + 18 + 16 + header.length*2 + 10; + var buf = new Buffer(len); + var o = 0; + o += buf.write('-----BEGIN ' + header + '-----\n', o); + for (var i = 0; i < tmp.length; ) { + var limit = i + 64; + if (limit > tmp.length) + limit = tmp.length; + o += buf.write(tmp.slice(i, limit), o); + buf[o++] = 10; + i = limit; + } + o += buf.write('-----END ' + header + '-----\n', o); + + return (buf.slice(0, o)); +} diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509.js new file mode 100644 index 00000000000..a2975404a52 --- /dev/null +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/formats/x509.js @@ -0,0 +1,484 @@ +// Copyright 2016 Joyent, Inc. + +module.exports = { + read: read, + verify: verify, + sign: sign, + write: write +}; + +var assert = require('assert-plus'); +var asn1 = require('asn1'); +var algs = require('../algs'); +var utils = require('../utils'); +var Key = require('../key'); +var PrivateKey = require('../private-key'); +var pem = require('./pem'); +var Identity = require('../identity'); +var Signature = require('../signature'); +var Certificate = require('../certificate'); +var pkcs8 = require('./pkcs8'); + +/* + * This file is based on RFC5280 (X.509). + */ + +/* Helper to read in a single mpint */ +function readMPInt(der, nm) { + assert.strictEqual(der.peek(), asn1.Ber.Integer, + nm + ' is not an Integer'); + return (utils.mpNormalize(der.readString(asn1.Ber.Integer, true))); +} + +function verify(cert, key) { + var sig = cert.signatures.x509; + assert.object(sig, 'x509 signature'); + + var algParts = sig.algo.split('-'); + if (algParts[0] !== key.type) + return (false); + + var blob = sig.cache; + if (blob === undefined) { + var der = new asn1.BerWriter(); + writeTBSCert(cert, der); + blob = der.buffer; + } + + var verifier = key.createVerify(algParts[1]); + verifier.write(blob); + return (verifier.verify(sig.signature)); +} + +function Local(i) { + return (asn1.Ber.Context | asn1.Ber.Constructor | i); +} + +function Context(i) { + return (asn1.Ber.Context | i); +} + +var SIGN_ALGS = { + 'rsa-md5': '1.2.840.113549.1.1.4', + 'rsa-sha1': '1.2.840.113549.1.1.5', + 'rsa-sha256': '1.2.840.113549.1.1.11', + 'rsa-sha384': '1.2.840.113549.1.1.12', + 'rsa-sha512': '1.2.840.113549.1.1.13', + 'dsa-sha1': '1.2.840.10040.4.3', + 'dsa-sha256': '2.16.840.1.101.3.4.3.2', + 'ecdsa-sha1': '1.2.840.10045.4.1', + 'ecdsa-sha256': '1.2.840.10045.4.3.2', + 'ecdsa-sha384': '1.2.840.10045.4.3.3', + 'ecdsa-sha512': '1.2.840.10045.4.3.4' +}; +Object.keys(SIGN_ALGS).forEach(function (k) { + SIGN_ALGS[SIGN_ALGS[k]] = k; +}); +SIGN_ALGS['1.3.14.3.2.3'] = 'rsa-md5'; +SIGN_ALGS['1.3.14.3.2.29'] = 'rsa-sha1'; + +var EXTS = { + 'issuerKeyId': '2.5.29.35', + 'altName': '2.5.29.17' +}; + +function read(buf, options) { + if (typeof (buf) === 'string') { + buf = new Buffer(buf, 'binary'); + } + assert.buffer(buf, 'buf'); + + var der = new asn1.BerReader(buf); + + der.readSequence(); + if (Math.abs(der.length - der.remain) > 1) { + throw (new Error('DER sequence does not contain whole byte ' + + 'stream')); + } + + var tbsStart = der.offset; + der.readSequence(); + var sigOffset = der.offset + der.length; + var tbsEnd = sigOffset; + + if (der.peek() === Local(0)) { + der.readSequence(Local(0)); + var version = der.readInt(); + assert.ok(version <= 3, + 'only x.509 versions up to v3 supported'); + } + + var cert = {}; + cert.signatures = {}; + var sig = (cert.signatures.x509 = {}); + sig.extras = {}; + + cert.serial = readMPInt(der, 'serial'); + + der.readSequence(); + var after = der.offset + der.length; + var certAlgOid = der.readOID(); + var certAlg = SIGN_ALGS[certAlgOid]; + if (certAlg === undefined) + throw (new Error('unknown signature algorithm ' + certAlgOid)); + + der._offset = after; + cert.issuer = Identity.parseAsn1(der); + + der.readSequence(); + cert.validFrom = readDate(der); + cert.validUntil = readDate(der); + + cert.subjects = [Identity.parseAsn1(der)]; + + der.readSequence(); + after = der.offset + der.length; + cert.subjectKey = pkcs8.readPkcs8(undefined, 'public', der); + der._offset = after; + + /* issuerUniqueID */ + if (der.peek() === Local(1)) { + der.readSequence(Local(1)); + sig.extras.issuerUniqueID = + buf.slice(der.offset, der.offset + der.length); + der._offset += der.length; + } + + /* subjectUniqueID */ + if (der.peek() === Local(2)) { + der.readSequence(Local(2)); + sig.extras.subjectUniqueID = + buf.slice(der.offset, der.offset + der.length); + der._offset += der.length; + } + + /* extensions */ + if (der.peek() === Local(3)) { + der.readSequence(Local(3)); + var extEnd = der.offset + der.length; + der.readSequence(); + + while (der.offset < extEnd) + readExtension(cert, buf, der); + + assert.strictEqual(der.offset, extEnd); + } + + assert.strictEqual(der.offset, sigOffset); + + der.readSequence(); + after = der.offset + der.length; + var sigAlgOid = der.readOID(); + var sigAlg = SIGN_ALGS[sigAlgOid]; + if (sigAlg === undefined) + throw (new Error('unknown signature algorithm ' + sigAlgOid)); + der._offset = after; + + var sigData = der.readString(asn1.Ber.BitString, true); + if (sigData[0] === 0) + sigData = sigData.slice(1); + var algParts = sigAlg.split('-'); + + sig.signature = Signature.parse(sigData, algParts[0], 'asn1'); + sig.signature.hashAlgorithm = algParts[1]; + sig.algo = sigAlg; + sig.cache = buf.slice(tbsStart, tbsEnd); + + return (new Certificate(cert)); +} + +function readDate(der) { + if (der.peek() === asn1.Ber.UTCTime) { + return (utcTimeToDate(der.readString(asn1.Ber.UTCTime))); + } else if (der.peek() === asn1.Ber.GeneralizedTime) { + return (gTimeToDate(der.readString(asn1.Ber.GeneralizedTime))); + } else { + throw (new Error('Unsupported date format')); + } +} + +/* RFC5280, section 4.2.1.6 (GeneralName type) */ +var ALTNAME = { + OtherName: Local(0), + RFC822Name: Context(1), + DNSName: Context(2), + X400Address: Local(3), + DirectoryName: Local(4), + EDIPartyName: Local(5), + URI: Context(6), + IPAddress: Context(7), + OID: Context(8) +}; + +function readExtension(cert, buf, der) { + der.readSequence(); + var after = der.offset + der.length; + var extId = der.readOID(); + var id; + var sig = cert.signatures.x509; + sig.extras.exts = []; + + var critical; + if (der.peek() === asn1.Ber.Boolean) + critical = der.readBoolean(); + + switch (extId) { + case (EXTS.altName): + der.readSequence(asn1.Ber.OctetString); + der.readSequence(); + var aeEnd = der.offset + der.length; + while (der.offset < aeEnd) { + switch (der.peek()) { + case ALTNAME.OtherName: + case ALTNAME.EDIPartyName: + der.readSequence(); + der._offset += der.length; + break; + case ALTNAME.OID: + der.readOID(ALTNAME.OID); + break; + case ALTNAME.RFC822Name: + /* RFC822 specifies email addresses */ + var email = der.readString(ALTNAME.RFC822Name); + id = Identity.forEmail(email); + if (!cert.subjects[0].equals(id)) + cert.subjects.push(id); + break; + case ALTNAME.DirectoryName: + der.readSequence(ALTNAME.DirectoryName); + id = Identity.parseAsn1(der); + if (!cert.subjects[0].equals(id)) + cert.subjects.push(id); + break; + case ALTNAME.DNSName: + var host = der.readString( + ALTNAME.DNSName); + id = Identity.forHost(host); + if (!cert.subjects[0].equals(id)) + cert.subjects.push(id); + break; + default: + der.readString(der.peek()); + break; + } + } + sig.extras.exts.push({ oid: extId, critical: critical }); + break; + default: + sig.extras.exts.push({ + oid: extId, + critical: critical, + data: der.readString(asn1.Ber.OctetString, true) + }); + break; + } + + der._offset = after; +} + +var UTCTIME_RE = + /^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})?Z$/; +function utcTimeToDate(t) { + var m = t.match(UTCTIME_RE); + assert.ok(m, 'timestamps must be in UTC'); + var d = new Date(); + + var thisYear = d.getUTCFullYear(); + var century = Math.floor(thisYear / 100) * 100; + + var year = parseInt(m[1], 10); + if (thisYear % 100 < 50 && year >= 60) + year += (century - 1); + else + year += century; + d.setUTCFullYear(year, parseInt(m[2], 10) - 1, parseInt(m[3], 10)); + d.setUTCHours(parseInt(m[4], 10), parseInt(m[5], 10)); + if (m[6] && m[6].length > 0) + d.setUTCSeconds(parseInt(m[6], 10)); + return (d); +} + +var GTIME_RE = + /^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})?Z$/; +function gTimeToDate(t) { + var m = t.match(GTIME_RE); + assert.ok(m); + var d = new Date(); + + d.setUTCFullYear(parseInt(m[1], 10), parseInt(m[2], 10) - 1, + parseInt(m[3], 10)); + d.setUTCHours(parseInt(m[4], 10), parseInt(m[5], 10)); + if (m[6] && m[6].length > 0) + d.setUTCSeconds(parseInt(m[6], 10)); + return (d); +} + +function zeroPad(n) { + var s = '' + n; + while (s.length < 2) + s = '0' + s; + return (s); +} + +function dateToUTCTime(d) { + var s = ''; + s += zeroPad(d.getUTCFullYear() % 100); + s += zeroPad(d.getUTCMonth() + 1); + s += zeroPad(d.getUTCDate()); + s += zeroPad(d.getUTCHours()); + s += zeroPad(d.getUTCMinutes()); + s += zeroPad(d.getUTCSeconds()); + s += 'Z'; + return (s); +} + +function sign(cert, key) { + if (cert.signatures.x509 === undefined) + cert.signatures.x509 = {}; + var sig = cert.signatures.x509; + + sig.algo = key.type + '-' + key.defaultHashAlgorithm(); + if (SIGN_ALGS[sig.algo] === undefined) + return (false); + + var der = new asn1.BerWriter(); + writeTBSCert(cert, der); + var blob = der.buffer; + sig.cache = blob; + + var signer = key.createSign(); + signer.write(blob); + cert.signatures.x509.signature = signer.sign(); + + return (true); +} + +function write(cert, options) { + var sig = cert.signatures.x509; + assert.object(sig, 'x509 signature'); + + var der = new asn1.BerWriter(); + der.startSequence(); + if (sig.cache) { + der._ensure(sig.cache.length); + sig.cache.copy(der._buf, der._offset); + der._offset += sig.cache.length; + } else { + writeTBSCert(cert, der); + } + + der.startSequence(); + der.writeOID(SIGN_ALGS[sig.algo]); + if (sig.algo.match(/^rsa-/)) + der.writeNull(); + der.endSequence(); + + var sigData = sig.signature.toBuffer('asn1'); + var data = new Buffer(sigData.length + 1); + data[0] = 0; + sigData.copy(data, 1); + der.writeBuffer(data, asn1.Ber.BitString); + der.endSequence(); + + return (der.buffer); +} + +function writeTBSCert(cert, der) { + var sig = cert.signatures.x509; + assert.object(sig, 'x509 signature'); + + der.startSequence(); + + der.startSequence(Local(0)); + der.writeInt(2); + der.endSequence(); + + der.writeBuffer(utils.mpNormalize(cert.serial), asn1.Ber.Integer); + + der.startSequence(); + der.writeOID(SIGN_ALGS[sig.algo]); + der.endSequence(); + + cert.issuer.toAsn1(der); + + der.startSequence(); + der.writeString(dateToUTCTime(cert.validFrom), asn1.Ber.UTCTime); + der.writeString(dateToUTCTime(cert.validUntil), asn1.Ber.UTCTime); + der.endSequence(); + + var subject = cert.subjects[0]; + var altNames = cert.subjects.slice(1); + subject.toAsn1(der); + + pkcs8.writePkcs8(der, cert.subjectKey); + + if (sig.extras && sig.extras.issuerUniqueID) { + der.writeBuffer(sig.extras.issuerUniqueID, Local(1)); + } + + if (sig.extras && sig.extras.subjectUniqueID) { + der.writeBuffer(sig.extras.subjectUniqueID, Local(2)); + } + + if (altNames.length > 0 || subject.type === 'host' || + (sig.extras && sig.extras.exts)) { + der.startSequence(Local(3)); + der.startSequence(); + + var exts = [ + { oid: EXTS.altName } + ]; + if (sig.extras && sig.extras.exts) + exts = sig.extras.exts; + + for (var i = 0; i < exts.length; ++i) { + der.startSequence(); + der.writeOID(exts[i].oid); + + if (exts[i].critical !== undefined) + der.writeBoolean(exts[i].critical); + + if (exts[i].oid === EXTS.altName) { + der.startSequence(asn1.Ber.OctetString); + der.startSequence(); + if (subject.type === 'host') { + der.writeString(subject.hostname, + Context(2)); + } + for (var j = 0; j < altNames.length; ++j) { + if (altNames[j].type === 'host') { + der.writeString( + altNames[j].hostname, + ALTNAME.DNSName); + } else if (altNames[j].type === + 'email') { + der.writeString( + altNames[j].email, + ALTNAME.RFC822Name); + } else { + /* + * Encode anything else as a + * DN style name for now. + */ + der.startSequence( + ALTNAME.DirectoryName); + altNames[j].toAsn1(der); + der.endSequence(); + } + } + der.endSequence(); + der.endSequence(); + } else { + der.writeBuffer(exts[i].data, + asn1.Ber.OctetString); + } + + der.endSequence(); + } + + der.endSequence(); + der.endSequence(); + } + + der.endSequence(); +} diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/identity.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/identity.js new file mode 100644 index 00000000000..b4f5cd73ec5 --- /dev/null +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/identity.js @@ -0,0 +1,255 @@ +// Copyright 2016 Joyent, Inc. + +module.exports = Identity; + +var assert = require('assert-plus'); +var algs = require('./algs'); +var crypto = require('crypto'); +var Fingerprint = require('./fingerprint'); +var Signature = require('./signature'); +var errs = require('./errors'); +var util = require('util'); +var utils = require('./utils'); +var asn1 = require('asn1'); + +/*JSSTYLED*/ +var DNS_NAME_RE = /^([*]|[a-z0-9][a-z0-9\-]{0,62})(?:\.([*]|[a-z0-9][a-z0-9\-]{0,62}))*$/i; + +var oids = {}; +oids.cn = '2.5.4.3'; +oids.o = '2.5.4.10'; +oids.ou = '2.5.4.11'; +oids.l = '2.5.4.7'; +oids.s = '2.5.4.8'; +oids.c = '2.5.4.6'; +oids.sn = '2.5.4.4'; +oids.dc = '0.9.2342.19200300.100.1.25'; +oids.uid = '0.9.2342.19200300.100.1.1'; +oids.mail = '0.9.2342.19200300.100.1.3'; + +var unoids = {}; +Object.keys(oids).forEach(function (k) { + unoids[oids[k]] = k; +}); + +function Identity(opts) { + var self = this; + assert.object(opts, 'options'); + assert.arrayOfObject(opts.components, 'options.components'); + this.components = opts.components; + this.componentLookup = {}; + this.components.forEach(function (c) { + if (c.name && !c.oid) + c.oid = oids[c.name]; + if (c.oid && !c.name) + c.name = unoids[c.oid]; + if (self.componentLookup[c.name] === undefined) + self.componentLookup[c.name] = []; + self.componentLookup[c.name].push(c); + }); + if (this.componentLookup.cn && this.componentLookup.cn.length > 0) { + this.cn = this.componentLookup.cn[0].value; + } + assert.optionalString(opts.type, 'options.type'); + if (opts.type === undefined) { + if (this.components.length === 1 && + this.componentLookup.cn && + this.componentLookup.cn.length === 1 && + this.componentLookup.cn[0].value.match(DNS_NAME_RE)) { + this.type = 'host'; + this.hostname = this.componentLookup.cn[0].value; + + } else if (this.componentLookup.dc && + this.components.length === this.componentLookup.dc.length) { + this.type = 'host'; + this.hostname = this.componentLookup.dc.map( + function (c) { + return (c.value); + }).join('.'); + + } else if (this.componentLookup.uid && + this.components.length === + this.componentLookup.uid.length) { + this.type = 'user'; + this.uid = this.componentLookup.uid[0].value; + + } else if (this.componentLookup.cn && + this.componentLookup.cn.length === 1 && + this.componentLookup.cn[0].value.match(DNS_NAME_RE)) { + this.type = 'host'; + this.hostname = this.componentLookup.cn[0].value; + + } else if (this.componentLookup.uid && + this.componentLookup.uid.length === 1) { + this.type = 'user'; + this.uid = this.componentLookup.uid[0].value; + + } else if (this.componentLookup.mail && + this.componentLookup.mail.length === 1) { + this.type = 'email'; + this.email = this.componentLookup.mail[0].value; + + } else if (this.componentLookup.cn && + this.componentLookup.cn.length === 1) { + this.type = 'user'; + this.uid = this.componentLookup.cn[0].value; + + } else { + this.type = 'unknown'; + } + } else { + this.type = opts.type; + if (this.type === 'host') + this.hostname = opts.hostname; + else if (this.type === 'user') + this.uid = opts.uid; + else if (this.type === 'email') + this.email = opts.email; + else + throw (new Error('Unknown type ' + this.type)); + } +} + +Identity.prototype.toString = function () { + return (this.components.map(function (c) { + return (c.name.toUpperCase() + '=' + c.value); + }).join(', ')); +}; + +Identity.prototype.toAsn1 = function (der, tag) { + der.startSequence(tag); + this.components.forEach(function (c) { + der.startSequence(asn1.Ber.Constructor | asn1.Ber.Set); + der.startSequence(); + der.writeOID(c.oid); + der.writeString(c.value, asn1.Ber.PrintableString); + der.endSequence(); + der.endSequence(); + }); + der.endSequence(); +}; + +function globMatch(a, b) { + if (a === '**' || b === '**') + return (true); + var aParts = a.split('.'); + var bParts = b.split('.'); + if (aParts.length !== bParts.length) + return (false); + for (var i = 0; i < aParts.length; ++i) { + if (aParts[i] === '*' || bParts[i] === '*') + continue; + if (aParts[i] !== bParts[i]) + return (false); + } + return (true); +} + +Identity.prototype.equals = function (other) { + if (!Identity.isIdentity(other, [1, 0])) + return (false); + if (other.components.length !== this.components.length) + return (false); + for (var i = 0; i < this.components.length; ++i) { + if (this.components[i].oid !== other.components[i].oid) + return (false); + if (!globMatch(this.components[i].value, + other.components[i].value)) { + return (false); + } + } + return (true); +}; + +Identity.forHost = function (hostname) { + assert.string(hostname, 'hostname'); + return (new Identity({ + type: 'host', + hostname: hostname, + components: [ { name: 'cn', value: hostname } ] + })); +}; + +Identity.forUser = function (uid) { + assert.string(uid, 'uid'); + return (new Identity({ + type: 'user', + uid: uid, + components: [ { name: 'uid', value: uid } ] + })); +}; + +Identity.forEmail = function (email) { + assert.string(email, 'email'); + return (new Identity({ + type: 'email', + email: email, + components: [ { name: 'mail', value: email } ] + })); +}; + +Identity.parseDN = function (dn) { + assert.string(dn, 'dn'); + var parts = dn.split(','); + var cmps = parts.map(function (c) { + c = c.trim(); + var eqPos = c.indexOf('='); + var name = c.slice(0, eqPos).toLowerCase(); + var value = c.slice(eqPos + 1); + return ({ name: name, value: value }); + }); + return (new Identity({ components: cmps })); +}; + +Identity.parseAsn1 = function (der, top) { + var components = []; + der.readSequence(top); + var end = der.offset + der.length; + while (der.offset < end) { + der.readSequence(asn1.Ber.Constructor | asn1.Ber.Set); + var after = der.offset + der.length; + der.readSequence(); + var oid = der.readOID(); + var type = der.peek(); + var value; + switch (type) { + case asn1.Ber.PrintableString: + case asn1.Ber.IA5String: + case asn1.Ber.OctetString: + case asn1.Ber.T61String: + value = der.readString(type); + break; + case asn1.Ber.Utf8String: + value = der.readString(type, true); + value = value.toString('utf8'); + break; + case asn1.Ber.CharacterString: + case asn1.Ber.BMPString: + value = der.readString(type, true); + value = value.toString('utf16le'); + break; + default: + throw (new Error('Unknown asn1 type ' + type)); + } + components.push({ oid: oid, value: value }); + der._offset = after; + } + der._offset = end; + return (new Identity({ + components: components + })); +}; + +Identity.isIdentity = function (obj, ver) { + return (utils.isCompatible(obj, Identity, ver)); +}; + +/* + * API versions for Identity: + * [1,0] -- initial ver + */ +Identity.prototype._sshpkApiVersion = [1, 0]; + +Identity._oldVersionDetect = function (obj) { + return ([1, 0]); +}; diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/index.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/index.js index 0b40429c95c..96a1384286a 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/index.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/index.js @@ -4,6 +4,8 @@ var Key = require('./key'); var Fingerprint = require('./fingerprint'); var Signature = require('./signature'); var PrivateKey = require('./private-key'); +var Certificate = require('./certificate'); +var Identity = require('./identity'); var errs = require('./errors'); module.exports = { @@ -16,11 +18,21 @@ module.exports = { parseSignature: Signature.parse, PrivateKey: PrivateKey, parsePrivateKey: PrivateKey.parse, + Certificate: Certificate, + parseCertificate: Certificate.parse, + createSelfSignedCertificate: Certificate.createSelfSigned, + createCertificate: Certificate.create, + Identity: Identity, + identityFromDN: Identity.parseDN, + identityForHost: Identity.forHost, + identityForUser: Identity.forUser, + identityForEmail: Identity.forEmail, /* errors */ FingerprintFormatError: errs.FingerprintFormatError, InvalidAlgorithmError: errs.InvalidAlgorithmError, KeyParseError: errs.KeyParseError, SignatureParseError: errs.SignatureParseError, - KeyEncryptedError: errs.KeyEncryptedError + KeyEncryptedError: errs.KeyEncryptedError, + CertificateParseError: errs.CertificateParseError }; diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/key.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/key.js index edc5143426a..ff5c3637337 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/key.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/key.js @@ -117,6 +117,7 @@ Key.prototype.fingerprint = function (algo) { algo = 'sha256'; assert.string(algo, 'algorithm'); var opts = { + type: 'key', hash: this.hash(algo), algorithm: algo }; diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/signature.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/signature.js index ddf4a8c988c..964f55cb566 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/signature.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/signature.js @@ -65,23 +65,31 @@ Signature.prototype.toBuffer = function (format) { buf = new SSHBuffer({}); buf.writeString('ssh-dss'); r = this.part.r.data; - if (r[0] === 0x00) + if (r.length > 20 && r[0] === 0x00) r = r.slice(1); s = this.part.s.data; + if (s.length > 20 && s[0] === 0x00) + s = s.slice(1); + if ((this.hashAlgorithm && + this.hashAlgorithm !== 'sha1') || + r.length + s.length !== 40) { + throw (new Error('OpenSSH only supports ' + + 'DSA signatures with SHA1 hash')); + } buf.writeBuffer(Buffer.concat([r, s])); return (buf.toBuffer()); } else if (format === 'ssh' && this.type === 'ecdsa') { var inner = new SSHBuffer({}); - r = this.part.r; - if (r[0] === 0x00) - r = r.slice(1); - inner.writePart(r); + r = this.part.r.data; + inner.writeBuffer(r); inner.writePart(this.part.s); buf = new SSHBuffer({}); /* XXX: find a more proper way to do this? */ var curve; - var sz = this.part.r.data.length * 8; + if (r[0] === 0x00) + r = r.slice(1); + var sz = r.length * 8; if (sz === 256) curve = 'nistp256'; else if (sz === 384) diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/ssh-buffer.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/ssh-buffer.js index 0b002773495..8fc2cb87852 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/ssh-buffer.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/lib/ssh-buffer.js @@ -73,6 +73,14 @@ SSHBuffer.prototype.readInt = function () { return (v); }; +SSHBuffer.prototype.readInt64 = function () { + assert.ok(this._offset + 8 < this._buffer.length, + 'buffer not long enough to read Int64'); + var v = this._buffer.slice(this._offset, this._offset + 8); + this._offset += 8; + return (v); +}; + SSHBuffer.prototype.readChar = function () { var v = this._buffer[this._offset++]; return (v); @@ -106,6 +114,22 @@ SSHBuffer.prototype.writeInt = function (v) { this._offset += 4; }; +SSHBuffer.prototype.writeInt64 = function (v) { + assert.buffer(v, 'value'); + if (v.length > 8) { + var lead = v.slice(0, v.length - 8); + for (var i = 0; i < lead.length; ++i) { + assert.strictEqual(lead[i], 0, + 'must fit in 64 bits of precision'); + } + v = v.slice(v.length - 8, v.length); + } + while (this._offset + 8 > this._size) + this.expand(); + v.copy(this._buffer, this._offset); + this._offset += 8; +}; + SSHBuffer.prototype.writeChar = function (v) { while (this._offset + 1 > this._size) this.expand(); diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/assert-plus/package.json b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/assert-plus/package.json index 6e7ed68b9e4..32e06bf4c8a 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/assert-plus/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/assert-plus/package.json @@ -76,7 +76,7 @@ ], "dist": { "shasum": "f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525", - "tarball": "http://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz" + "tarball": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz" }, "directories": {}, "readme": "ERROR: No README data found!" diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/lib/dashdash.js b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/lib/dashdash.js index 882bb3ff415..adb6f13b158 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/lib/dashdash.js +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/lib/dashdash.js @@ -999,12 +999,45 @@ function getOptionType(name) { } +/** + * Return a synopsis string for the given option spec. + * + * Examples: + * > synopsisFromOpt({names: ['help', 'h'], type: 'bool'}); + * '[ --help | -h ]' + * > synopsisFromOpt({name: 'file', type: 'string', helpArg: 'FILE'}); + * '[ --file=FILE ]' + */ +function synopsisFromOpt(o) { + assert.object(o, 'o'); + + if (o.hasOwnProperty('group')) { + return null; + } + var names = o.names || [o.name]; + // `type` here could be undefined if, for example, the command has a + // dashdash option spec with a bogus 'type'. + var type = getOptionType(o.type); + var helpArg = o.helpArg || (type && type.helpArg) || 'ARG'; + var parts = []; + names.forEach(function (name) { + var part = (name.length === 1 ? '-' : '--') + name; + if (type && type.takesArg) { + part += (name.length === 1 ? ' ' + helpArg : '=' + helpArg); + } + parts.push(part); + }); + return ('[ ' + parts.join(' | ') + ' ]'); +}; + + module.exports = { createParser: createParser, Parser: Parser, parse: parse, addOptionType: addOptionType, getOptionType: getOptionType, + synopsisFromOpt: synopsisFromOpt, // Bash completion-related exports BASH_COMPLETION_TEMPLATE_PATH: BASH_COMPLETION_TEMPLATE_PATH, diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/package.json b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/package.json index 882ca5b416e..d4c70ff8ed2 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/dashdash/package.json @@ -1,7 +1,7 @@ { "name": "dashdash", "description": "A light, featureful and explicit option parsing library.", - "version": "1.13.1", + "version": "1.14.0", "author": { "name": "Trent Mick", "email": "trentm@gmail.com", @@ -58,13 +58,13 @@ "url": "https://github.com/davepacheco" } ], - "gitHead": "aabf8a7e71ce7ed3d24c3c57d64a57b78c1a8546", + "gitHead": "2f70d248a509418e4473922ee034faf9cd91b3f8", "bugs": { "url": "https://github.com/trentm/node-dashdash/issues" }, "homepage": "https://github.com/trentm/node-dashdash", - "_id": "dashdash@1.13.1", - "_shasum": "3530ed38b9026be9af05c83423c9154122e3d47c", + "_id": "dashdash@1.14.0", + "_shasum": "29e486c5418bf0f356034a993d51686a33e84141", "_from": "dashdash@>=1.12.0 <2.0.0", "_npmVersion": "1.4.29", "_npmUser": { @@ -78,14 +78,14 @@ } ], "dist": { - "shasum": "3530ed38b9026be9af05c83423c9154122e3d47c", - "tarball": "https://registry.npmjs.org/dashdash/-/dashdash-1.13.1.tgz" + "shasum": "29e486c5418bf0f356034a993d51686a33e84141", + "tarball": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.0.tgz" }, "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/dashdash-1.13.1.tgz_1461355198185_0.31851457548327744" + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/dashdash-1.14.0.tgz_1464847169030_0.07120498712174594" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.13.1.tgz", + "_resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.0.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/ecc-jsbn/package.json b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/ecc-jsbn/package.json index 2bb7aa8ee81..25fa1104076 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/ecc-jsbn/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/ecc-jsbn/package.json @@ -48,7 +48,7 @@ }, "dist": { "shasum": "0fc73a9ed5f0d53c38193398523ef7e543777505", - "tarball": "http://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz" + "tarball": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jodid25519/package.json b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jodid25519/package.json index 6d38314518f..22f89a989d4 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jodid25519/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jodid25519/package.json @@ -58,7 +58,7 @@ }, "dist": { "shasum": "06d4912255093419477d425633606e0e90782967", - "tarball": "http://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz" + "tarball": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jsbn/package.json b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jsbn/package.json index ffac6c28799..0113b45676e 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jsbn/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/node_modules/jsbn/package.json @@ -36,7 +36,7 @@ }, "dist": { "shasum": "650987da0dd74f4ebf5a11377a2aa2d273e97dfd", - "tarball": "http://registry.npmjs.org/jsbn/-/jsbn-0.1.0.tgz" + "tarball": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.0.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/http-signature/node_modules/sshpk/package.json b/node_modules/request/node_modules/http-signature/node_modules/sshpk/package.json index f46a6bd9f22..aacc2955b9d 100644 --- a/node_modules/request/node_modules/http-signature/node_modules/sshpk/package.json +++ b/node_modules/request/node_modules/http-signature/node_modules/sshpk/package.json @@ -1,6 +1,6 @@ { "name": "sshpk", - "version": "1.8.3", + "version": "1.9.2", "description": "A library for finding and using SSH public keys", "main": "lib/index.js", "scripts": { @@ -63,28 +63,28 @@ "temp": "^0.8.2" }, "man": [ - "/Users/alex.wilson/dev/sshpk/man/man1/sshpk-conv.1", - "/Users/alex.wilson/dev/sshpk/man/man1/sshpk-sign.1", - "/Users/alex.wilson/dev/sshpk/man/man1/sshpk-verify.1" + "/Users/alex.wilson/dev/node-sshpk/man/man1/sshpk-conv.1", + "/Users/alex.wilson/dev/node-sshpk/man/man1/sshpk-sign.1", + "/Users/alex.wilson/dev/node-sshpk/man/man1/sshpk-verify.1" ], "bin": { "sshpk-conv": "bin/sshpk-conv", "sshpk-sign": "bin/sshpk-sign", "sshpk-verify": "bin/sshpk-verify" }, - "gitHead": "82d39066b2df4e8284350ff5ebb08c5b95c74652", - "_id": "sshpk@1.8.3", - "_shasum": "890cc9d614dc5292e5cb1a543b03c9abaa5c374e", + "gitHead": "a8b794384822a52eea5ed3b2f192a780b7909609", + "_id": "sshpk@1.9.2", + "_shasum": "3b41351bbad5c34ddf4bd8119937efee31a46765", "_from": "sshpk@>=1.7.0 <2.0.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "0.12.13", + "_npmVersion": "2.15.8", + "_nodeVersion": "0.12.15", "_npmUser": { "name": "arekinath", "email": "alex@cooperi.net" }, "dist": { - "shasum": "890cc9d614dc5292e5cb1a543b03c9abaa5c374e", - "tarball": "https://registry.npmjs.org/sshpk/-/sshpk-1.8.3.tgz" + "shasum": "3b41351bbad5c34ddf4bd8119937efee31a46765", + "tarball": "https://registry.npmjs.org/sshpk/-/sshpk-1.9.2.tgz" }, "maintainers": [ { @@ -94,8 +94,8 @@ ], "_npmOperationalInternal": { "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/sshpk-1.8.3.tgz_1461968607532_0.32797130732797086" + "tmp": "tmp/sshpk-1.9.2.tgz_1469841656006_0.10793639998883009" }, - "_resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.8.3.tgz", + "_resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.9.2.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/request/node_modules/http-signature/package.json b/node_modules/request/node_modules/http-signature/package.json index d7463088a62..12b32f8ecfa 100644 --- a/node_modules/request/node_modules/http-signature/package.json +++ b/node_modules/request/node_modules/http-signature/package.json @@ -61,7 +61,7 @@ }, "dist": { "shasum": "df72e267066cd0ac67fb76adf8e134a8fbcf91bf", - "tarball": "http://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz" + "tarball": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/is-typedarray/package.json b/node_modules/request/node_modules/is-typedarray/package.json index 861ef4f7c29..750da78e653 100644 --- a/node_modules/request/node_modules/is-typedarray/package.json +++ b/node_modules/request/node_modules/is-typedarray/package.json @@ -43,7 +43,7 @@ }, "dist": { "shasum": "e479c80858df0c1b11ddda6940f96011fcda4a9a", - "tarball": "http://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz" + "tarball": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz" }, "maintainers": [ { diff --git a/node_modules/request/node_modules/isstream/package.json b/node_modules/request/node_modules/isstream/package.json index 85cb14c9cbe..266fd5d1d69 100644 --- a/node_modules/request/node_modules/isstream/package.json +++ b/node_modules/request/node_modules/isstream/package.json @@ -51,7 +51,7 @@ ], "dist": { "shasum": "47e63f7af55afa6f92e1500e690eb8b8529c099a", - "tarball": "http://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" + "tarball": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", diff --git a/node_modules/request/node_modules/qs/.npmignore b/node_modules/request/node_modules/qs/.npmignore deleted file mode 100644 index 7e1574dc5c3..00000000000 --- a/node_modules/request/node_modules/qs/.npmignore +++ /dev/null @@ -1,18 +0,0 @@ -.idea -*.iml -npm-debug.log -dump.rdb -node_modules -results.tap -results.xml -npm-shrinkwrap.json -config.json -.DS_Store -*/.DS_Store -*/*/.DS_Store -._* -*/._* -*/*/._* -coverage.* -lib-cov -complexity.md diff --git a/node_modules/request/node_modules/qs/.travis.yml b/node_modules/request/node_modules/qs/.travis.yml deleted file mode 100644 index 63bdc12bebd..00000000000 --- a/node_modules/request/node_modules/qs/.travis.yml +++ /dev/null @@ -1,69 +0,0 @@ -language: node_js -node_js: - - "5.3" - - "5.2" - - "5.1" - - "5.0" - - "4.2" - - "4.1" - - "4.0" - - "iojs-v3.3" - - "iojs-v3.2" - - "iojs-v3.1" - - "iojs-v3.0" - - "iojs-v2.5" - - "iojs-v2.4" - - "iojs-v2.3" - - "iojs-v2.2" - - "iojs-v2.1" - - "iojs-v2.0" - - "iojs-v1.8" - - "iojs-v1.7" - - "iojs-v1.6" - - "iojs-v1.5" - - "iojs-v1.4" - - "iojs-v1.3" - - "iojs-v1.2" - - "iojs-v1.1" - - "iojs-v1.0" - - "0.12" - - "0.11" - - "0.10" - - "0.9" - - "0.8" - - "0.6" - - "0.4" -before_install: - - 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' - - 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' -script: - - 'if [ "${TRAVIS_NODE_VERSION}" != "4.2" ]; then npm run tests-only ; else npm test ; fi' -sudo: false -matrix: - fast_finish: true - allow_failures: - - node_js: "5.2" - - node_js: "5.1" - - node_js: "5.0" - - node_js: "4.1" - - node_js: "4.0" - - node_js: "iojs-v3.2" - - node_js: "iojs-v3.1" - - node_js: "iojs-v3.0" - - node_js: "iojs-v2.4" - - node_js: "iojs-v2.3" - - node_js: "iojs-v2.2" - - node_js: "iojs-v2.1" - - node_js: "iojs-v2.0" - - node_js: "iojs-v1.7" - - node_js: "iojs-v1.6" - - node_js: "iojs-v1.5" - - node_js: "iojs-v1.4" - - node_js: "iojs-v1.3" - - node_js: "iojs-v1.2" - - node_js: "iojs-v1.1" - - node_js: "iojs-v1.0" - - node_js: "0.11" - - node_js: "0.9" - - node_js: "0.6" - - node_js: "0.4" diff --git a/node_modules/request/node_modules/qs/CHANGELOG.md b/node_modules/request/node_modules/qs/CHANGELOG.md index 5c66ea44464..86bea763886 100644 --- a/node_modules/request/node_modules/qs/CHANGELOG.md +++ b/node_modules/request/node_modules/qs/CHANGELOG.md @@ -1,4 +1,16 @@ -## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=34&state=closed) +## **6.2.1** +- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values +- [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call` +- [Tests] remove `parallelshell` since it does not reliably report failures +- [Tests] up to `node` `v6.3`, `v5.12` +- [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config`, `qs-iconv` + +## [**6.2.0**](https://github.com/ljharb/qs/issues?milestone=36&state=closed) +- [New] pass Buffers to the encoder/decoder directly (#161) +- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160) +- [Fix] fix compacting of nested sparse arrays (#150) + +## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed) - [New] allowDots option for `stringify` (#151) - [Fix] "sort" option should work at a depth of 3 or more (#151) - [Fix] Restore `dist` directory; will be removed in v7 (#148) @@ -12,6 +24,9 @@ ## [**6.0.0**](https://github.com/ljharb/qs/issues?milestone=31&state=closed) - [**#124**](https://github.com/ljharb/qs/issues/124) Use ES6 and drop support for node < v4 +## **5.2.1** +- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values + ## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed) - [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string diff --git a/node_modules/request/node_modules/qs/README.md b/node_modules/request/node_modules/qs/README.md index 335eafb4be5..97e390796c7 100644 --- a/node_modules/request/node_modules/qs/README.md +++ b/node_modules/request/node_modules/qs/README.md @@ -225,6 +225,26 @@ var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false }); assert.equal(unencoded, 'a[b]=c'); ``` +This encoding can also be replaced by a custom encoding method set as `encoder` option: + +```javascript +var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) { + // Passed in values `a`, `b`, `c` + return // Return encoded string +}}) +``` + +_(Note: the `encoder` option does not apply if `encode` is `false`)_ + +Analogue to the `encoder` there is a `decoder` option for `parse` to override decoding of properties and values: + +```javascript +var decoded = qs.parse('x=z', { decoder: function (str) { + // Passed in values `x`, `z` + return // Return decoded string +}}) +``` + Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage. When arrays are stringified, by default they are given explicit indices: @@ -333,3 +353,24 @@ To completely skip rendering keys with `null` values, use the `skipNulls` flag: var nullsSkipped = qs.stringify({ a: 'b', c: null}, { skipNulls: true }); assert.equal(nullsSkipped, 'a=b'); ``` + +### Dealing with special character sets + +By default the encoding and decoding of characters is done in `utf-8`. If you +wish to encode querystrings to a different character set (i.e. +[Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the +[`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library: + +```javascript +var encoder = require('qs-iconv/encoder')('shift_jis'); +var shiftJISEncoded = qs.stringify({ a: 'こんにけは!' }, { encoder: encoder }); +assert.equal(shiftJISEncoded, 'a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I'); +``` + +This also works for decoding of query strings: + +```javascript +var decoder = require('qs-iconv/decoder')('shift_jis'); +var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder }); +assert.deepEqual(obj, { a: 'こんにけは!' }); +``` diff --git a/node_modules/request/node_modules/qs/bower.json b/node_modules/request/node_modules/qs/bower.json deleted file mode 100644 index 44f050642d7..00000000000 --- a/node_modules/request/node_modules/qs/bower.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "qs", - "main": "dist/qs.js", - "homepage": "https://github.com/hapijs/qs", - "authors": [ - "Nathan LaFreniere " - ], - "description": "A querystring parser that supports nesting and arrays, with a depth limit", - "keywords": [ - "querystring", - "qs" - ], - "license": "BSD-3-Clause", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} diff --git a/node_modules/request/node_modules/qs/component.json b/node_modules/request/node_modules/qs/component.json deleted file mode 100644 index cb8d93fb1fe..00000000000 --- a/node_modules/request/node_modules/qs/component.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "qs", - "repository": "hapijs/qs", - "description": "query-string parser / stringifier with nesting support", - "version": "6.1.0", - "keywords": ["querystring", "query", "parser"], - "main": "lib/index.js", - "scripts": [ - "lib/index.js", - "lib/parse.js", - "lib/stringify.js", - "lib/utils.js" - ], - "license": "BSD-3-Clause" -} diff --git a/node_modules/request/node_modules/qs/dist/qs.js b/node_modules/request/node_modules/qs/dist/qs.js index bb8ea31a957..fcf825b5840 100644 --- a/node_modules/request/node_modules/qs/dist/qs.js +++ b/node_modules/request/node_modules/qs/dist/qs.js @@ -14,7 +14,9 @@ module.exports = { var Utils = require('./utils'); -var internals = { +var has = Object.prototype.hasOwnProperty; + +var defaults = { delimiter: '&', depth: 5, arrayLimit: 20, @@ -22,10 +24,11 @@ var internals = { strictNullHandling: false, plainObjects: false, allowPrototypes: false, - allowDots: false + allowDots: false, + decoder: Utils.decode }; -internals.parseValues = function (str, options) { +var parseValues = function parseValues(str, options) { var obj = {}; var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); @@ -33,28 +36,25 @@ internals.parseValues = function (str, options) { var part = parts[i]; var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; + var key, val; if (pos === -1) { - obj[Utils.decode(part)] = ''; - - if (options.strictNullHandling) { - obj[Utils.decode(part)] = null; - } + key = options.decoder(part); + val = options.strictNullHandling ? null : ''; } else { - var key = Utils.decode(part.slice(0, pos)); - var val = Utils.decode(part.slice(pos + 1)); - - if (Object.prototype.hasOwnProperty.call(obj, key)) { - obj[key] = [].concat(obj[key]).concat(val); - } else { - obj[key] = val; - } + key = options.decoder(part.slice(0, pos)); + val = options.decoder(part.slice(pos + 1)); + } + if (has.call(obj, key)) { + obj[key] = [].concat(obj[key]).concat(val); + } else { + obj[key] = val; } } return obj; }; -internals.parseObject = function (chain, val, options) { +var parseObject = function parseObject(chain, val, options) { if (!chain.length) { return val; } @@ -64,7 +64,7 @@ internals.parseObject = function (chain, val, options) { var obj; if (root === '[]') { obj = []; - obj = obj.concat(internals.parseObject(chain, val, options)); + obj = obj.concat(parseObject(chain, val, options)); } else { obj = options.plainObjects ? Object.create(null) : {}; var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; @@ -77,16 +77,16 @@ internals.parseObject = function (chain, val, options) { (options.parseArrays && index <= options.arrayLimit) ) { obj = []; - obj[index] = internals.parseObject(chain, val, options); + obj[index] = parseObject(chain, val, options); } else { - obj[cleanRoot] = internals.parseObject(chain, val, options); + obj[cleanRoot] = parseObject(chain, val, options); } } return obj; }; -internals.parseKeys = function (givenKey, val, options) { +var parseKeys = function parseKeys(givenKey, val, options) { if (!givenKey) { return; } @@ -109,7 +109,7 @@ internals.parseKeys = function (givenKey, val, options) { if (segment[1]) { // If we aren't using plain objects, optionally prefix keys // that would overwrite object prototype properties - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) { + if (!options.plainObjects && has.call(Object.prototype, segment[1])) { if (!options.allowPrototypes) { return; } @@ -123,7 +123,7 @@ internals.parseKeys = function (givenKey, val, options) { var i = 0; while ((segment = child.exec(key)) !== null && i < options.depth) { i += 1; - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { + if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) { if (!options.allowPrototypes) { continue; } @@ -137,30 +137,32 @@ internals.parseKeys = function (givenKey, val, options) { keys.push('[' + key.slice(segment.index) + ']'); } - return internals.parseObject(keys, val, options); + return parseObject(keys, val, options); }; module.exports = function (str, opts) { var options = opts || {}; - options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter; - options.depth = typeof options.depth === 'number' ? options.depth : internals.depth; - options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit; + + if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { + throw new TypeError('Decoder has to be a function.'); + } + + options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; + options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; + options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; options.parseArrays = options.parseArrays !== false; - options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : internals.allowDots; - options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects; - options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes; - options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit; - options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; - - if ( - str === '' || - str === null || - typeof str === 'undefined' - ) { + options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; + options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; + options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; + options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; + options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; + options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + + if (str === '' || str === null || typeof str === 'undefined') { return options.plainObjects ? Object.create(null) : {}; } - var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str; + var tempObj = typeof str === 'string' ? parseValues(str, options) : str; var obj = options.plainObjects ? Object.create(null) : {}; // Iterate over the keys and setup the new object @@ -168,7 +170,7 @@ module.exports = function (str, opts) { var keys = Object.keys(tempObj); for (var i = 0; i < keys.length; ++i) { var key = keys[i]; - var newObj = internals.parseKeys(key, tempObj[key], options); + var newObj = parseKeys(key, tempObj[key], options); obj = Utils.merge(obj, newObj, options); } @@ -180,45 +182,45 @@ module.exports = function (str, opts) { var Utils = require('./utils'); -var internals = { - delimiter: '&', - arrayPrefixGenerators: { - brackets: function (prefix) { - return prefix + '[]'; - }, - indices: function (prefix, key) { - return prefix + '[' + key + ']'; - }, - repeat: function (prefix) { - return prefix; - } +var arrayPrefixGenerators = { + brackets: function brackets(prefix) { + return prefix + '[]'; + }, + indices: function indices(prefix, key) { + return prefix + '[' + key + ']'; }, + repeat: function repeat(prefix) { + return prefix; + } +}; + +var defaults = { + delimiter: '&', strictNullHandling: false, skipNulls: false, - encode: true + encode: true, + encoder: Utils.encode }; -internals.stringify = function (object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots) { +var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) { var obj = object; if (typeof filter === 'function') { obj = filter(prefix, obj); - } else if (Utils.isBuffer(obj)) { - obj = String(obj); } else if (obj instanceof Date) { obj = obj.toISOString(); } else if (obj === null) { if (strictNullHandling) { - return encode ? Utils.encode(prefix) : prefix; + return encoder ? encoder(prefix) : prefix; } obj = ''; } - if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') { - if (encode) { - return [Utils.encode(prefix) + '=' + Utils.encode(obj)]; + if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) { + if (encoder) { + return [encoder(prefix) + '=' + encoder(obj)]; } - return [prefix + '=' + obj]; + return [prefix + '=' + String(obj)]; } var values = []; @@ -243,9 +245,9 @@ internals.stringify = function (object, prefix, generateArrayPrefix, strictNullH } if (Array.isArray(obj)) { - values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots)); + values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); } else { - values = values.concat(internals.stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots)); + values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); } } @@ -255,14 +257,20 @@ internals.stringify = function (object, prefix, generateArrayPrefix, strictNullH module.exports = function (object, opts) { var obj = object; var options = opts || {}; - var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter; - var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; - var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : internals.skipNulls; - var encode = typeof options.encode === 'boolean' ? options.encode : internals.encode; + var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; + var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; + var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; + var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; var sort = typeof options.sort === 'function' ? options.sort : null; var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; var objKeys; var filter; + + if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + if (typeof options.filter === 'function') { filter = options.filter; obj = filter('', obj); @@ -277,7 +285,7 @@ module.exports = function (object, opts) { } var arrayFormat; - if (options.arrayFormat in internals.arrayPrefixGenerators) { + if (options.arrayFormat in arrayPrefixGenerators) { arrayFormat = options.arrayFormat; } else if ('indices' in options) { arrayFormat = options.indices ? 'indices' : 'repeat'; @@ -285,7 +293,7 @@ module.exports = function (object, opts) { arrayFormat = 'indices'; } - var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat]; + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; if (!objKeys) { objKeys = Object.keys(obj); @@ -302,7 +310,7 @@ module.exports = function (object, opts) { continue; } - keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots)); + keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); } return keys.join(delimiter); @@ -357,7 +365,7 @@ exports.merge = function (target, source, options) { mergeTarget = exports.arrayToObject(target, options); } - return Object.keys(source).reduce(function (acc, key) { + return Object.keys(source).reduce(function (acc, key) { var value = source[key]; if (Object.prototype.hasOwnProperty.call(acc, key)) { @@ -365,7 +373,7 @@ exports.merge = function (target, source, options) { } else { acc[key] = value; } - return acc; + return acc; }, mergeTarget); }; @@ -420,7 +428,7 @@ exports.encode = function (str) { i += 1; c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += (hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; } return out; @@ -443,7 +451,9 @@ exports.compact = function (obj, references) { var compacted = []; for (var i = 0; i < obj.length; ++i) { - if (typeof obj[i] !== 'undefined') { + if (obj[i] && typeof obj[i] === 'object') { + compacted.push(exports.compact(obj[i], refs)); + } else if (typeof obj[i] !== 'undefined') { compacted.push(obj[i]); } } diff --git a/node_modules/request/node_modules/qs/lib/parse.js b/node_modules/request/node_modules/qs/lib/parse.js index 9b6cbd22198..8b37cb3b294 100755 --- a/node_modules/request/node_modules/qs/lib/parse.js +++ b/node_modules/request/node_modules/qs/lib/parse.js @@ -2,7 +2,9 @@ var Utils = require('./utils'); -var internals = { +var has = Object.prototype.hasOwnProperty; + +var defaults = { delimiter: '&', depth: 5, arrayLimit: 20, @@ -10,10 +12,11 @@ var internals = { strictNullHandling: false, plainObjects: false, allowPrototypes: false, - allowDots: false + allowDots: false, + decoder: Utils.decode }; -internals.parseValues = function (str, options) { +var parseValues = function parseValues(str, options) { var obj = {}; var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); @@ -21,28 +24,25 @@ internals.parseValues = function (str, options) { var part = parts[i]; var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; + var key, val; if (pos === -1) { - obj[Utils.decode(part)] = ''; - - if (options.strictNullHandling) { - obj[Utils.decode(part)] = null; - } + key = options.decoder(part); + val = options.strictNullHandling ? null : ''; } else { - var key = Utils.decode(part.slice(0, pos)); - var val = Utils.decode(part.slice(pos + 1)); - - if (Object.prototype.hasOwnProperty.call(obj, key)) { - obj[key] = [].concat(obj[key]).concat(val); - } else { - obj[key] = val; - } + key = options.decoder(part.slice(0, pos)); + val = options.decoder(part.slice(pos + 1)); + } + if (has.call(obj, key)) { + obj[key] = [].concat(obj[key]).concat(val); + } else { + obj[key] = val; } } return obj; }; -internals.parseObject = function (chain, val, options) { +var parseObject = function parseObject(chain, val, options) { if (!chain.length) { return val; } @@ -52,7 +52,7 @@ internals.parseObject = function (chain, val, options) { var obj; if (root === '[]') { obj = []; - obj = obj.concat(internals.parseObject(chain, val, options)); + obj = obj.concat(parseObject(chain, val, options)); } else { obj = options.plainObjects ? Object.create(null) : {}; var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; @@ -65,16 +65,16 @@ internals.parseObject = function (chain, val, options) { (options.parseArrays && index <= options.arrayLimit) ) { obj = []; - obj[index] = internals.parseObject(chain, val, options); + obj[index] = parseObject(chain, val, options); } else { - obj[cleanRoot] = internals.parseObject(chain, val, options); + obj[cleanRoot] = parseObject(chain, val, options); } } return obj; }; -internals.parseKeys = function (givenKey, val, options) { +var parseKeys = function parseKeys(givenKey, val, options) { if (!givenKey) { return; } @@ -97,7 +97,7 @@ internals.parseKeys = function (givenKey, val, options) { if (segment[1]) { // If we aren't using plain objects, optionally prefix keys // that would overwrite object prototype properties - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) { + if (!options.plainObjects && has.call(Object.prototype, segment[1])) { if (!options.allowPrototypes) { return; } @@ -111,7 +111,7 @@ internals.parseKeys = function (givenKey, val, options) { var i = 0; while ((segment = child.exec(key)) !== null && i < options.depth) { i += 1; - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { + if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) { if (!options.allowPrototypes) { continue; } @@ -125,30 +125,32 @@ internals.parseKeys = function (givenKey, val, options) { keys.push('[' + key.slice(segment.index) + ']'); } - return internals.parseObject(keys, val, options); + return parseObject(keys, val, options); }; module.exports = function (str, opts) { var options = opts || {}; - options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter; - options.depth = typeof options.depth === 'number' ? options.depth : internals.depth; - options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit; + + if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { + throw new TypeError('Decoder has to be a function.'); + } + + options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; + options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; + options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; options.parseArrays = options.parseArrays !== false; - options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : internals.allowDots; - options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects; - options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes; - options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit; - options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; - - if ( - str === '' || - str === null || - typeof str === 'undefined' - ) { + options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; + options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; + options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; + options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; + options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; + options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + + if (str === '' || str === null || typeof str === 'undefined') { return options.plainObjects ? Object.create(null) : {}; } - var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str; + var tempObj = typeof str === 'string' ? parseValues(str, options) : str; var obj = options.plainObjects ? Object.create(null) : {}; // Iterate over the keys and setup the new object @@ -156,7 +158,7 @@ module.exports = function (str, opts) { var keys = Object.keys(tempObj); for (var i = 0; i < keys.length; ++i) { var key = keys[i]; - var newObj = internals.parseKeys(key, tempObj[key], options); + var newObj = parseKeys(key, tempObj[key], options); obj = Utils.merge(obj, newObj, options); } diff --git a/node_modules/request/node_modules/qs/lib/stringify.js b/node_modules/request/node_modules/qs/lib/stringify.js index 892dad45a9f..6e1c9a263cd 100755 --- a/node_modules/request/node_modules/qs/lib/stringify.js +++ b/node_modules/request/node_modules/qs/lib/stringify.js @@ -2,45 +2,45 @@ var Utils = require('./utils'); -var internals = { - delimiter: '&', - arrayPrefixGenerators: { - brackets: function (prefix) { - return prefix + '[]'; - }, - indices: function (prefix, key) { - return prefix + '[' + key + ']'; - }, - repeat: function (prefix) { - return prefix; - } +var arrayPrefixGenerators = { + brackets: function brackets(prefix) { + return prefix + '[]'; + }, + indices: function indices(prefix, key) { + return prefix + '[' + key + ']'; }, + repeat: function repeat(prefix) { + return prefix; + } +}; + +var defaults = { + delimiter: '&', strictNullHandling: false, skipNulls: false, - encode: true + encode: true, + encoder: Utils.encode }; -internals.stringify = function (object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots) { +var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) { var obj = object; if (typeof filter === 'function') { obj = filter(prefix, obj); - } else if (Utils.isBuffer(obj)) { - obj = String(obj); } else if (obj instanceof Date) { obj = obj.toISOString(); } else if (obj === null) { if (strictNullHandling) { - return encode ? Utils.encode(prefix) : prefix; + return encoder ? encoder(prefix) : prefix; } obj = ''; } - if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') { - if (encode) { - return [Utils.encode(prefix) + '=' + Utils.encode(obj)]; + if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) { + if (encoder) { + return [encoder(prefix) + '=' + encoder(obj)]; } - return [prefix + '=' + obj]; + return [prefix + '=' + String(obj)]; } var values = []; @@ -65,9 +65,9 @@ internals.stringify = function (object, prefix, generateArrayPrefix, strictNullH } if (Array.isArray(obj)) { - values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots)); + values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); } else { - values = values.concat(internals.stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots)); + values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); } } @@ -77,14 +77,20 @@ internals.stringify = function (object, prefix, generateArrayPrefix, strictNullH module.exports = function (object, opts) { var obj = object; var options = opts || {}; - var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter; - var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; - var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : internals.skipNulls; - var encode = typeof options.encode === 'boolean' ? options.encode : internals.encode; + var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; + var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; + var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; + var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; + var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; var sort = typeof options.sort === 'function' ? options.sort : null; var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; var objKeys; var filter; + + if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + if (typeof options.filter === 'function') { filter = options.filter; obj = filter('', obj); @@ -99,7 +105,7 @@ module.exports = function (object, opts) { } var arrayFormat; - if (options.arrayFormat in internals.arrayPrefixGenerators) { + if (options.arrayFormat in arrayPrefixGenerators) { arrayFormat = options.arrayFormat; } else if ('indices' in options) { arrayFormat = options.indices ? 'indices' : 'repeat'; @@ -107,7 +113,7 @@ module.exports = function (object, opts) { arrayFormat = 'indices'; } - var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat]; + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; if (!objKeys) { objKeys = Object.keys(obj); @@ -124,7 +130,7 @@ module.exports = function (object, opts) { continue; } - keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots)); + keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots)); } return keys.join(delimiter); diff --git a/node_modules/request/node_modules/qs/lib/utils.js b/node_modules/request/node_modules/qs/lib/utils.js index 5d433560306..2c5c8ee5033 100755 --- a/node_modules/request/node_modules/qs/lib/utils.js +++ b/node_modules/request/node_modules/qs/lib/utils.js @@ -46,7 +46,7 @@ exports.merge = function (target, source, options) { mergeTarget = exports.arrayToObject(target, options); } - return Object.keys(source).reduce(function (acc, key) { + return Object.keys(source).reduce(function (acc, key) { var value = source[key]; if (Object.prototype.hasOwnProperty.call(acc, key)) { @@ -54,7 +54,7 @@ exports.merge = function (target, source, options) { } else { acc[key] = value; } - return acc; + return acc; }, mergeTarget); }; @@ -109,7 +109,7 @@ exports.encode = function (str) { i += 1; c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += (hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; } return out; @@ -132,7 +132,9 @@ exports.compact = function (obj, references) { var compacted = []; for (var i = 0; i < obj.length; ++i) { - if (typeof obj[i] !== 'undefined') { + if (obj[i] && typeof obj[i] === 'object') { + compacted.push(exports.compact(obj[i], refs)); + } else if (typeof obj[i] !== 'undefined') { compacted.push(obj[i]); } } diff --git a/node_modules/request/node_modules/qs/package.json b/node_modules/request/node_modules/qs/package.json index 6b481626571..a3cff0a0829 100644 --- a/node_modules/request/node_modules/qs/package.json +++ b/node_modules/request/node_modules/qs/package.json @@ -2,7 +2,7 @@ "name": "qs", "description": "A querystring parser that supports nesting and arrays, with a depth limit", "homepage": "https://github.com/ljharb/qs", - "version": "6.1.0", + "version": "6.2.1", "repository": { "type": "git", "url": "git+https://github.com/ljharb/qs.git" @@ -24,17 +24,20 @@ }, "dependencies": {}, "devDependencies": { - "browserify": "^12.0.1", - "tape": "^4.3.0", + "browserify": "^13.0.1", + "tape": "^4.6.0", "covert": "^1.1.0", "mkdirp": "^0.5.1", - "eslint": "^1.10.3", - "@ljharb/eslint-config": "^1.6.1", + "eslint": "^3.1.0", + "@ljharb/eslint-config": "^6.0.0", "parallelshell": "^2.0.0", - "evalmd": "^0.0.16" + "iconv-lite": "^0.4.13", + "qs-iconv": "^1.0.3", + "evalmd": "^0.0.17" }, "scripts": { - "test": "parallelshell 'npm run readme' 'npm run lint' 'npm run coverage'", + "pretest": "npm run --silent readme && npm run --silent lint", + "test": "npm run --silent coverage", "tests-only": "node test", "readme": "evalmd README.md", "lint": "eslint lib/*.js text/*.js", @@ -43,22 +46,22 @@ "prepublish": "npm run dist" }, "license": "BSD-3-Clause", - "gitHead": "5bd79545edb33d6a43398fec7df9ecef2da005ea", + "gitHead": "335f839142e6c2c69f5302c4940d92acb0e77561", "bugs": { "url": "https://github.com/ljharb/qs/issues" }, - "_id": "qs@6.1.0", - "_shasum": "ec1d1626b24278d99f0fdf4549e524e24eceeb26", - "_from": "qs@>=6.1.0 <6.2.0", - "_npmVersion": "3.3.12", - "_nodeVersion": "5.5.0", + "_id": "qs@6.2.1", + "_shasum": "ce03c5ff0935bc1d9d69a9f14cbd18e568d67625", + "_from": "qs@>=6.2.0 <6.3.0", + "_npmVersion": "3.10.3", + "_nodeVersion": "6.3.0", "_npmUser": { "name": "ljharb", "email": "ljharb@gmail.com" }, "dist": { - "shasum": "ec1d1626b24278d99f0fdf4549e524e24eceeb26", - "tarball": "http://registry.npmjs.org/qs/-/qs-6.1.0.tgz" + "shasum": "ce03c5ff0935bc1d9d69a9f14cbd18e568d67625", + "tarball": "https://registry.npmjs.org/qs/-/qs-6.2.1.tgz" }, "maintainers": [ { @@ -75,10 +78,10 @@ } ], "_npmOperationalInternal": { - "host": "packages-5-east.internal.npmjs.com", - "tmp": "tmp/qs-6.1.0.tgz_1454565583082_0.44599376199766994" + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/qs-6.2.1.tgz_1469044929716_0.06957711698487401" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/qs/-/qs-6.1.0.tgz", + "_resolved": "https://registry.npmjs.org/qs/-/qs-6.2.1.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/request/node_modules/qs/test/parse.js b/node_modules/request/node_modules/qs/test/parse.js index 5665d074e95..ccf8c8c4c53 100755 --- a/node_modules/request/node_modules/qs/test/parse.js +++ b/node_modules/request/node_modules/qs/test/parse.js @@ -2,6 +2,7 @@ var test = require('tape'); var qs = require('../'); +var iconv = require('iconv-lite'); test('parse()', function (t) { t.test('parses a simple string', function (st) { @@ -120,8 +121,11 @@ test('parse()', function (t) { st.deepEqual(qs.parse('foo[]=bar&foo[bad]=baz'), { foo: { '0': 'bar', bad: 'baz' } }); st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); - st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c'), { a: { '0': 'b', t: 'u', c: true } }); - st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y'), { a: { '0': 'b', '1': 'c', x: 'y' } }); + + st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { '0': 'b', c: true, t: 'u' } }); + st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { '0': 'b', t: 'u', hasOwnProperty: 'c' } }); + st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { '0': 'b', '1': 'c', x: 'y' } }); + st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { '0': 'b', hasOwnProperty: 'c', x: 'y' } }); st.end(); }); @@ -173,14 +177,42 @@ test('parse()', function (t) { t.test('allows for empty strings in arrays', function (st) { st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] }); - st.deepEqual(qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true }), { a: ['b', null, 'c', ''] }); - st.deepEqual(qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true }), { a: ['b', '', 'c', null] }); - st.deepEqual(qs.parse('a[]=&a[]=b&a[]=c'), { a: ['', 'b', 'c'] }); + + st.deepEqual( + qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true, arrayLimit: 20 }), + { a: ['b', null, 'c', ''] }, + 'with arrayLimit 20 + array indices: null then empty string works' + ); + st.deepEqual( + qs.parse('a[]=b&a[]&a[]=c&a[]=', { strictNullHandling: true, arrayLimit: 0 }), + { a: ['b', null, 'c', ''] }, + 'with arrayLimit 0 + array brackets: null then empty string works' + ); + + st.deepEqual( + qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true, arrayLimit: 20 }), + { a: ['b', '', 'c', null] }, + 'with arrayLimit 20 + array indices: empty string then null works' + ); + st.deepEqual( + qs.parse('a[]=b&a[]=&a[]=c&a[]', { strictNullHandling: true, arrayLimit: 0 }), + { a: ['b', '', 'c', null] }, + 'with arrayLimit 0 + array brackets: empty string then null works' + ); + + st.deepEqual( + qs.parse('a[]=&a[]=b&a[]=c'), + { a: ['', 'b', 'c'] }, + 'array brackets: empty strings work' + ); st.end(); }); t.test('compacts sparse arrays', function (st) { st.deepEqual(qs.parse('a[10]=1&a[2]=2'), { a: ['2', '1'] }); + st.deepEqual(qs.parse('a[1][b][2][c]=1'), { a: [{ b: [{ c: '1' }] }] }); + st.deepEqual(qs.parse('a[1][2][3][c]=1'), { a: [[[{ c: '1' }]]] }); + st.deepEqual(qs.parse('a[1][2][3][c][1]=1'), { a: [[[{ c: ['1'] }]]] }); st.end(); }); @@ -390,4 +422,30 @@ test('parse()', function (t) { st.deepEqual(qs.parse('a[]=b&a[c]=d', { plainObjects: true }), expectedArray); st.end(); }); + + t.test('can parse with custom encoding', function (st) { + st.deepEqual(qs.parse('%8c%a7=%91%e5%8d%e3%95%7b', { + decoder: function (str) { + var reg = /\%([0-9A-F]{2})/ig; + var result = []; + var parts; + var last = 0; + while (parts = reg.exec(str)) { + result.push(parseInt(parts[1], 16)); + last = parts.index + parts[0].length; + } + return iconv.decode(new Buffer(result), 'shift_jis').toString(); + } + }), { 県: '倧ι˜ͺ府' }); + st.end(); + }); + + t.test('throws error with wrong decoder', function (st) { + st.throws(function () { + qs.parse({}, { + decoder: 'string' + }); + }, new TypeError('Decoder has to be a function.')); + st.end(); + }); }); diff --git a/node_modules/request/node_modules/qs/test/stringify.js b/node_modules/request/node_modules/qs/test/stringify.js index da72839d262..699397e3346 100755 --- a/node_modules/request/node_modules/qs/test/stringify.js +++ b/node_modules/request/node_modules/qs/test/stringify.js @@ -2,6 +2,7 @@ var test = require('tape'); var qs = require('../'); +var iconv = require('iconv-lite'); test('stringify()', function (t) { t.test('stringifies a querystring object', function (st) { @@ -21,7 +22,7 @@ test('stringify()', function (t) { st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e'); st.end(); }); - + t.test('stringifies a nested object with dots notation', function (st) { st.equal(qs.stringify({ a: { b: 'c' } }, { allowDots: true }), 'a.b=c'); st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }, { allowDots: true }), 'a.b.c.d=e'); @@ -53,7 +54,7 @@ test('stringify()', function (t) { st.equal(qs.stringify({ a: { b: ['c', 'd'] } }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d'); st.end(); }); - + t.test('stringifies a nested array value with dots notation', function (st) { st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { allowDots: true, encode: false }), 'a.b[0]=c&a.b[1]=d'); st.end(); @@ -64,7 +65,12 @@ test('stringify()', function (t) { st.equal(qs.stringify({ a: [{ b: { c: [1] } }] }), 'a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1'); st.end(); }); - + + t.test('stringifies an array with mixed objects and primitives', function (st) { + st.equal(qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encode: false }), 'a[0][b]=1&a[1]=2&a[2]=3'); + st.end(); + }); + t.test('stringifies an object inside an array with dots notation', function (st) { st.equal(qs.stringify({ a: [{ b: 'c' }] }, { allowDots: true, encode: false }), 'a[0].b=c'); st.equal(qs.stringify({ a: [{ b: { c: [1] } }] }, { allowDots: true, encode: false }), 'a[0].b.c[0]=1'); @@ -249,11 +255,51 @@ test('stringify()', function (t) { st.equal(qs.stringify({ a: 'c', z: { j: 'a', i: 'b' }, b: 'f' }, { sort: sort }), 'a=c&b=f&z%5Bi%5D=b&z%5Bj%5D=a'); st.end(); }); - + t.test('can sort the keys at depth 3 or more too', function (st) { var sort = function (a, b) { return a.localeCompare(b); }; st.equal(qs.stringify({ a: 'a', z: { zj: {zjb: 'zjb', zja: 'zja'}, zi: {zib: 'zib', zia: 'zia'} }, b: 'b' }, { sort: sort, encode: false }), 'a=a&b=b&z[zi][zia]=zia&z[zi][zib]=zib&z[zj][zja]=zja&z[zj][zjb]=zjb'); st.equal(qs.stringify({ a: 'a', z: { zj: {zjb: 'zjb', zja: 'zja'}, zi: {zib: 'zib', zia: 'zia'} }, b: 'b' }, { sort: null, encode: false }), 'a=a&z[zj][zjb]=zjb&z[zj][zja]=zja&z[zi][zib]=zib&z[zi][zia]=zia&b=b'); st.end(); }); + + t.test('can stringify with custom encoding', function (st) { + st.equal(qs.stringify({ 県: '倧ι˜ͺ府', '': ''}, { + encoder: function (str) { + if (str.length === 0) { + return ''; + } + var buf = iconv.encode(str, 'shiftjis'); + var result = []; + for (var i=0; i < buf.length; ++i) { + result.push(buf.readUInt8(i).toString(16)); + } + return '%' + result.join('%'); + } + }), '%8c%a7=%91%e5%8d%e3%95%7b&='); + st.end(); + }); + + t.test('throws error with wrong encoder', function (st) { + st.throws(function () { + qs.stringify({}, { + encoder: 'string' + }); + }, new TypeError('Encoder has to be a function.')); + st.end(); + }); + + t.test('can use custom encoder for a buffer object', { + skip: typeof Buffer === 'undefined' + }, function (st) { + st.equal(qs.stringify({ a: new Buffer([1]) }, { + encoder: function (buffer) { + if (typeof buffer === 'string') { + return buffer; + } + return String.fromCharCode(buffer.readUInt8(0) + 97); + } + }), 'a=b'); + st.end(); + }); }); diff --git a/node_modules/request/node_modules/stringstream/package.json b/node_modules/request/node_modules/stringstream/package.json index 39474baa0b5..2c6d7cdca6d 100644 --- a/node_modules/request/node_modules/stringstream/package.json +++ b/node_modules/request/node_modules/stringstream/package.json @@ -42,7 +42,7 @@ ], "dist": { "shasum": "4e484cd4de5a0bbbee18e46307710a8a81621878", - "tarball": "http://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz" + "tarball": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/node_modules/request/node_modules/tough-cookie/README.md b/node_modules/request/node_modules/tough-cookie/README.md index 9899dbf6eed..126f222b904 100644 --- a/node_modules/request/node_modules/tough-cookie/README.md +++ b/node_modules/request/node_modules/tough-cookie/README.md @@ -1,9 +1,8 @@ [RFC6265](https://tools.ietf.org/html/rfc6265) Cookies and CookieJar for Node.js -[![Build Status](https://travis-ci.org/SalesforceEng/tough-cookie.png?branch=master)](https://travis-ci.org/SalesforceEng/tough-cookie) +[![npm package](https://nodei.co/npm/tough-cookie.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/tough-cookie/) -[![NPM Stats](https://nodei.co/npm/tough-cookie.png?downloads=true&stars=true)](https://npmjs.org/package/tough-cookie) -![NPM Downloads](https://nodei.co/npm-dl/tough-cookie.png?months=9) +[![Build Status](https://travis-ci.org/SalesforceEng/tough-cookie.png?branch=master)](https://travis-ci.org/SalesforceEng/tough-cookie) # Synopsis @@ -30,6 +29,10 @@ It's _so_ easy! Why the name? NPM modules `cookie`, `cookies` and `cookiejar` were already taken. +## Version Support + +Support for versions of node.js will follow that of the [request](https://www.npmjs.com/package/request) module. + # API ## tough @@ -426,6 +429,17 @@ Inherits from `Store`. A just-in-memory CookieJar synchronous store implementation, used by default. Despite being a synchronous implementation, it's usable with both the synchronous and asynchronous forms of the `CookieJar` API. +## Community Cookie Stores + +These are some Store implementations authored and maintained by the community. They aren't official and we don't vouch for them but you may be interested to have a look: + +- [`db-cookie-store`](https://github.com/JSBizon/db-cookie-store): SQL including SQLite-based databases +- [`file-cookie-store`](https://github.com/JSBizon/file-cookie-store): Netscape cookie file format on disk +- [`redis-cookie-store`](https://github.com/benkroeger/redis-cookie-store): Redis +- [`tough-cookie-filestore`](https://github.com/mitsuru/tough-cookie-filestore): JSON on disk +- [`tough-cookie-web-storage-store`](https://github.com/exponentjs/tough-cookie-web-storage-store): DOM localStorage and sessionStorage + + # Serialization Format **NOTE**: if you want to have custom `Cookie` properties serialized, add the property name to `Cookie.serializableProperties`. diff --git a/node_modules/request/node_modules/tough-cookie/lib/cookie.js b/node_modules/request/node_modules/tough-cookie/lib/cookie.js index 12da297ac4d..c3dacfe44a3 100644 --- a/node_modules/request/node_modules/tough-cookie/lib/cookie.js +++ b/node_modules/request/node_modules/tough-cookie/lib/cookie.js @@ -68,9 +68,6 @@ var LOOSE_COOKIE_PAIR = /^((?:=)?([^=;]*)\s*=\s*)?([^\n\r\0]*)/; // Note ';' is \x3B var PATH_VALUE = /[\x20-\x3A\x3C-\x7E]+/; -// Used for checking whether or not there is a trailing semi-colon -var TRAILING_SEMICOLON = /;+$/; - var DAY_OF_MONTH = /^(\d{1,2})[^\d]*$/; var TIME = /^(\d{1,2})[^\d]*:(\d{1,2})[^\d]*:(\d{1,2})[^\d]*$/; var MONTH = /^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/i; @@ -327,12 +324,6 @@ function parse(str, options) { } str = str.trim(); - // S4.1.1 Trailing semi-colons are not part of the specification. - var semiColonCheck = TRAILING_SEMICOLON.exec(str); - if (semiColonCheck) { - str = str.slice(0, semiColonCheck.index); - } - // We use a regex to parse the "name-value-pair" part of S5.2 var firstSemi = str.indexOf(';'); // S5.2 step 1 var pairRe = options.loose ? LOOSE_COOKIE_PAIR : COOKIE_PAIR; @@ -362,7 +353,7 @@ function parse(str, options) { // S5.2.3 "unparsed-attributes consist of the remainder of the set-cookie-string // (including the %x3B (";") in question)." plus later on in the same section // "discard the first ";" and trim". - var unparsed = str.slice(firstSemi).replace(/^\s*;\s*/,'').trim(); + var unparsed = str.slice(firstSemi + 1).trim(); // "If the unparsed-attributes string is empty, skip the rest of these // steps." @@ -378,9 +369,12 @@ function parse(str, options) { * cookie-attribute-list". Therefore, in this implementation, we overwrite * the previous value. */ - var cookie_avs = unparsed.split(/\s*;\s*/); + var cookie_avs = unparsed.split(';'); while (cookie_avs.length) { - var av = cookie_avs.shift(); + var av = cookie_avs.shift().trim(); + if (av.length === 0) { // happens if ";;" appears + continue; + } var av_sep = av.indexOf('='); var av_key, av_value; diff --git a/node_modules/request/node_modules/tough-cookie/package.json b/node_modules/request/node_modules/tough-cookie/package.json index cc1aebfc8ef..289a4ab253b 100644 --- a/node_modules/request/node_modules/tough-cookie/package.json +++ b/node_modules/request/node_modules/tough-cookie/package.json @@ -36,7 +36,7 @@ "RFC6265", "RFC2965" ], - "version": "2.2.2", + "version": "2.3.1", "homepage": "https://github.com/SalesforceEng/tough-cookie", "repository": { "type": "git", @@ -54,41 +54,42 @@ "test": "vows test/*_test.js" }, "engines": { - "node": ">=0.10.0" + "node": ">=0.8" }, "devDependencies": { "async": "^1.4.2", + "string.prototype.repeat": "^0.2.0", "vows": "^0.8.1" }, - "gitHead": "cc46628c4d7d2e8c372ecba29293ca8a207ec192", - "_id": "tough-cookie@2.2.2", - "_shasum": "c83a1830f4e5ef0b93ef2a3488e724f8de016ac7", - "_from": "tough-cookie@>=2.2.0 <2.3.0", - "_npmVersion": "3.3.12", - "_nodeVersion": "5.1.1", + "gitHead": "c11a2d11d12348a35ef595c809e30e641a804a7d", + "_id": "tough-cookie@2.3.1", + "_shasum": "99c77dfbb7d804249e8a299d4cb0fd81fef083fd", + "_from": "tough-cookie@>=2.3.0 <2.4.0", + "_npmVersion": "3.10.3", + "_nodeVersion": "6.3.1", "_npmUser": { "name": "jstash", "email": "jstash@gmail.com" }, "dist": { - "shasum": "c83a1830f4e5ef0b93ef2a3488e724f8de016ac7", - "tarball": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz" + "shasum": "99c77dfbb7d804249e8a299d4cb0fd81fef083fd", + "tarball": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.1.tgz" }, "maintainers": [ { "name": "jstash", - "email": "jeremy@goinstant.com" + "email": "jstash@gmail.com" }, { - "name": "goinstant", - "email": "services@goinstant.com" + "name": "nexxy", + "email": "emily@contactvibe.com" } ], "_npmOperationalInternal": { - "host": "packages-13-west.internal.npmjs.com", - "tmp": "tmp/tough-cookie-2.2.2.tgz_1457564639182_0.5129188685677946" + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/tough-cookie-2.3.1.tgz_1469494891088_0.8524557144846767" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz", + "_resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.1.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/request/package.json b/node_modules/request/package.json index 70c7f76dc77..591e8bbf54d 100644 --- a/node_modules/request/package.json +++ b/node_modules/request/package.json @@ -7,7 +7,7 @@ "util", "utility" ], - "version": "2.72.0", + "version": "2.74.0", "author": { "name": "Mikeal Rogers", "email": "mikeal.rogers@gmail.com" @@ -32,7 +32,7 @@ "combined-stream": "~1.0.5", "extend": "~3.0.0", "forever-agent": "~0.6.1", - "form-data": "~1.0.0-rc3", + "form-data": "~1.0.0-rc4", "har-validator": "~2.0.6", "hawk": "~3.1.3", "http-signature": "~1.1.0", @@ -42,9 +42,9 @@ "mime-types": "~2.1.7", "node-uuid": "~1.4.7", "oauth-sign": "~0.8.1", - "qs": "~6.1.0", + "qs": "~6.2.0", "stringstream": "~0.0.4", - "tough-cookie": "~2.2.0", + "tough-cookie": "~2.3.0", "tunnel-agent": "~0.4.1" }, "scripts": { @@ -56,40 +56,40 @@ }, "devDependencies": { "bluebird": "^3.2.1", - "browserify": "^12.0.2", + "browserify": "^13.0.1", "browserify-istanbul": "^2.0.0", "buffer-equal": "^1.0.0", - "codecov.io": "^0.1.6", + "codecov": "^1.0.1", "coveralls": "^2.11.4", "eslint": "^2.5.3", "function-bind": "^1.0.2", "istanbul": "^0.4.0", - "karma": "^0.13.10", + "karma": "^1.1.1", "karma-browserify": "^5.0.1", - "karma-cli": "^0.1.1", - "karma-coverage": "^0.5.3", + "karma-cli": "^1.0.0", + "karma-coverage": "^1.0.0", "karma-phantomjs-launcher": "^1.0.0", - "karma-tap": "^1.0.3", + "karma-tap": "^2.0.1", "phantomjs-prebuilt": "^2.1.3", "rimraf": "^2.2.8", "server-destroy": "^1.0.1", - "tape": "^4.2.0", + "tape": "^4.6.0", "taper": "^0.4.0" }, - "gitHead": "6dcac13642955577592fdafb5ff3cdc8a6ff1b1b", + "gitHead": "76e82351cbc21049441b1763c6f2bbd504fa8f5a", "homepage": "https://github.com/request/request#readme", - "_id": "request@2.72.0", - "_shasum": "0ce3a179512620b10441f14c82e21c12c0ddb4e1", - "_from": "request@2.72.0", - "_npmVersion": "3.8.5", - "_nodeVersion": "5.9.0", + "_id": "request@2.74.0", + "_shasum": "7693ca768bbb0ea5c8ce08c084a45efa05b892ab", + "_from": "request@2.74.0", + "_npmVersion": "2.15.6", + "_nodeVersion": "6.2.2", "_npmUser": { "name": "simov", "email": "simeonvelichkov@gmail.com" }, "dist": { - "shasum": "0ce3a179512620b10441f14c82e21c12c0ddb4e1", - "tarball": "https://registry.npmjs.org/request/-/request-2.72.0.tgz" + "shasum": "7693ca768bbb0ea5c8ce08c084a45efa05b892ab", + "tarball": "https://registry.npmjs.org/request/-/request-2.74.0.tgz" }, "maintainers": [ { @@ -110,10 +110,10 @@ } ], "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/request-2.72.0.tgz_1460901215210_0.9173020373564214" + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/request-2.74.0.tgz_1469231082306_0.13140005595050752" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/request/-/request-2.72.0.tgz", + "_resolved": "https://registry.npmjs.org/request/-/request-2.74.0.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/request/request.js b/node_modules/request/request.js index 124157e8677..8267c125375 100644 --- a/node_modules/request/request.js +++ b/node_modules/request/request.js @@ -9,6 +9,7 @@ var http = require('http') , bl = require('bl') , hawk = require('hawk') , aws2 = require('aws-sign2') + , aws4 = require('aws4') , httpSignature = require('http-signature') , mime = require('mime-types') , stringstream = require('stringstream') @@ -70,20 +71,6 @@ function filterOutReservedFunctions(reserved, options) { } -// Function for properly handling a connection error -function connectionErrorHandler(error) { - var socket = this - if (socket.res) { - if (socket.res.request) { - socket.res.request.emit('error', error) - } else { - socket.res.emit('error', error) - } - } else { - socket._httpMessage.emit('error', error) - } -} - // Return a simpler request object to allow serialization function requestToJSON() { var self = this @@ -335,7 +322,7 @@ Request.prototype.init = function (options) { var formData = options.formData var requestForm = self.form() var appendFormValue = function (key, value) { - if (value.hasOwnProperty('value') && value.hasOwnProperty('options')) { + if (value && value.hasOwnProperty('value') && value.hasOwnProperty('options')) { requestForm.append(key, value.value, value.options) } else { requestForm.append(key, value) @@ -804,11 +791,6 @@ Request.prototype.start = function () { self.emit('socket', socket) }) - self.on('end', function() { - if ( self.req.connection ) { - self.req.connection.removeListener('error', connectionErrorHandler) - } - }) self.emit('request', self.req) } @@ -843,11 +825,6 @@ Request.prototype.onRequestResponse = function (response) { debug('response end', self.uri.href, response.statusCode, response.headers) }) - // The check on response.connection is a workaround for browserify. - if (response.connection && response.connection.listeners('error').indexOf(connectionErrorHandler) === -1) { - response.connection.setMaxListeners(0) - response.connection.once('error', connectionErrorHandler) - } if (self._aborted) { debug('aborted', self.uri.href) response.resume() @@ -1264,10 +1241,9 @@ Request.prototype.aws = function (opts, now) { self._aws = opts return self } - + if (opts.sign_version == 4 || opts.sign_version == '4') { - var aws4 = require('aws4') - // use aws4 + // use aws4 var options = { host: self.uri.host, path: self.uri.path, diff --git a/package.json b/package.json index ab917190555..c6688a84388 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "read-package-json": "~2.0.4", "readable-stream": "~2.1.4", "realize-package-specifier": "~3.0.1", - "request": "~2.72.0", + "request": "~2.74.0", "retry": "~0.9.0", "rimraf": "~2.5.2", "semver": "~5.1.0",