This commit is contained in:
eric sciple 2020-01-24 12:20:19 -05:00
parent beb1329f9f
commit 2b95e76931
7736 changed files with 1874747 additions and 51184 deletions

15
node_modules/request-promise-core/LICENSE generated vendored Normal file
View file

@ -0,0 +1,15 @@
ISC License
Copyright (c) 2016, Nicolai Kamenzky and contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

125
node_modules/request-promise-core/README.md generated vendored Normal file
View file

@ -0,0 +1,125 @@
<a href="http://promisesaplus.com/">
<img src="https://promises-aplus.github.io/promises-spec/assets/logo-small.png" align="right" alt="Promises/A+ logo" />
</a>
# request-promise-core
[![Gitter](https://img.shields.io/badge/gitter-join_chat-blue.svg?style=flat-square&maxAge=2592000)](https://gitter.im/request/request-promise?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://img.shields.io/travis/request/promise-core/master.svg?style=flat-square&maxAge=2592000)](https://travis-ci.org/request/promise-core)
[![Coverage Status](https://img.shields.io/coveralls/request/promise-core.svg?style=flat-square&maxAge=2592000)](https://coveralls.io/r/request/promise-core)
[![Dependency Status](https://img.shields.io/david/request/promise-core.svg?style=flat-square&maxAge=2592000)](https://david-dm.org/request/promise-core)
[![Known Vulnerabilities](https://snyk.io/test/npm/promise-core/badge.svg?style=flat-square&maxAge=2592000)](https://snyk.io/test/npm/promise-core)
This package is the core for the following packages:
- [`request-promise`](https://github.com/request/request-promise)
- [`request-promise-any`](https://github.com/request/request-promise-any)
- [`request-promise-bluebird`](https://github.com/request/request-promise-bluebird)
- [`request-promise-native`](https://github.com/request/request-promise-native)
`request-promise-core` contains the core logic to add Promise support to [`request`](https://github.com/request/request).
Please use one of the libraries above. It is only recommended to use this library directly, if you have very specific requirements.
## Installation for `request@^2.34`
This module is installed via npm:
```
npm install --save request
npm install --save request-promise-core
```
`request` is defined as a peer-dependency and thus has to be installed separately.
## Usage for `request@^2.34`
``` js
// 1. Load the request library
// Only use a direct require if you are 100% sure that:
// - Your project does not use request directly. That is without the Promise capabilities by calling require('request').
// - Any of the installed libraries use request.
// ...because Request's prototype will be patched in step 2.
/* var request = require('request'); */
// Instead use:
var stealthyRequire = require('stealthy-require');
var request = stealthyRequire(require.cache, function () {
return require('request');
});
// 2. Add Promise support to request
var configure = require('request-promise-core/configure/request2');
configure({
request: request,
// Pass your favorite ES6-compatible promise implementation
PromiseImpl: Promise,
// Expose all methods of the promise instance you want to call on the request(...) call
expose: [
'then', // Allows to use request(...).then(...)
'catch', // Allows to use request(...).catch(...)
'promise' // Allows to use request(...).promise() which returns the promise instance
],
// Optional: Pass a callback that is called within the Promise constructor
constructorMixin: function (resolve, reject) {
// `this` is the request object
// Additional arguments may be passed depending on the PromiseImpl used
}
});
// 3. Use request with its promise capabilities
// E.g. crawl a web page:
request('http://www.google.com')
.then(function (htmlString) {
// Process html...
})
.catch(function (err) {
// Crawling failed...
});
```
## Installation and Usage for `request@next`
[Request Next](https://github.com/request/request/issues/1982) is still in alpha. However, `request-promise-core` is already designed to be compatible and ships with a configuration helper `require('request-promise-core/configure/request-next')` that is [used by `request-promise`](https://github.com/request/request-promise/blob/next/lib/rp.js) in its "next" branch.
## Contributing
To set up your development environment:
1. clone the repo to your desktop,
2. in the shell `cd` to the main folder,
3. hit `npm install`,
4. hit `npm install gulp -g` if you haven't installed gulp globally yet, and
5. run `gulp dev`. (Or run `node ./node_modules/.bin/gulp dev` if you don't want to install gulp globally.)
`gulp dev` watches all source files and if you save some changes it will lint the code and execute all tests. The test coverage report can be viewed from `./coverage/lcov-report/index.html`.
If you want to debug a test you should use `gulp test-without-coverage` to run all tests without obscuring the code by the test coverage instrumentation.
## Change History
- 1.1.2 (2019-02-14)
- Security fix: bumped `lodash` to `^4.17.11`. See [vulnerabilty reports](https://snyk.io/vuln/search?q=lodash&type=npm).
*(Thanks to @lucaswillering and @sam-warren-finnair for reporting this in issues [#12](https://github.com/request/promise-core/issues/12) and [#13](https://github.com/request/promise-core/issues/13) and thanks to @Alec321 for pull request [#14](https://github.com/request/promise-core/pull/14).)*
- 1.1.1 (2016-08-08)
- Renamed package to `request-promise-core` because there were [too](https://github.com/request/request-promise/issues/137) [many](https://github.com/request/request-promise/issues/141) issues with the scoped package name `@request/promise-core`
- 1.1.0 (2016-07-30)
- Added `constructorMixin` option to enable [request/request-promise#123](https://github.com/request/request-promise/pull/123)
- 1.0.0 (2016-07-15)
- All tests green, ready for prime time
- 1.0.0-rc.1 (2016-07-10)
- Reimplementation of core logic based on `request-promise@3.0.0`
- Plus `transform2xxOnly` option (fixes [request/request-promise#131](https://github.com/request/request-promise/issues/131))
## License (ISC)
In case you never heard about the [ISC license](http://en.wikipedia.org/wiki/ISC_license) it is functionally equivalent to the MIT license.
See the [LICENSE file](LICENSE) for details.

View file

@ -0,0 +1,67 @@
'use strict';
var core = require('../'),
isArray = require('lodash/isArray'),
isFunction = require('lodash/isFunction'),
isObjectLike = require('lodash/isObjectLike');
module.exports = function (options) {
var errorText = 'Please verify options'; // For better minification because this string is repeating
if (!isObjectLike(options)) {
throw new TypeError(errorText);
}
if (!isFunction(options.client)) {
throw new TypeError(errorText + '.client');
}
if (!isArray(options.expose) || options.expose.length === 0) {
throw new TypeError(errorText + '.expose');
}
var thenExposed = false;
for ( var i = 0; i < options.expose.length; i+=1 ) {
if (options.expose[i] === 'then') {
thenExposed = true;
break;
}
}
if (!thenExposed) {
throw new Error('Please expose "then"');
}
var plumbing = core({
PromiseImpl: options.PromiseImpl,
constructorMixin: options.constructorMixin
});
return function (requestOptions) {
var self = {};
plumbing.init.call(self, requestOptions);
var request = options.client(requestOptions);
for ( var k = 0; k < options.expose.length; k+=1 ) {
var method = options.expose[k];
plumbing[ method === 'promise' ? 'exposePromise' : 'exposePromiseMethod' ](
request,
self,
'_rp_promise',
method
);
}
return request;
};
};

View file

@ -0,0 +1,74 @@
'use strict';
var core = require('../'),
isArray = require('lodash/isArray'),
isFunction = require('lodash/isFunction'),
isObjectLike = require('lodash/isObjectLike');
module.exports = function (options) {
var errorText = 'Please verify options'; // For better minification because this string is repeating
if (!isObjectLike(options)) {
throw new TypeError(errorText);
}
if (!isFunction(options.request)) {
throw new TypeError(errorText + '.request');
}
if (!isArray(options.expose) || options.expose.length === 0) {
throw new TypeError(errorText + '.expose');
}
var plumbing = core({
PromiseImpl: options.PromiseImpl,
constructorMixin: options.constructorMixin
});
// Intercepting Request's init method
var originalInit = options.request.Request.prototype.init;
options.request.Request.prototype.init = function RP$initInterceptor(requestOptions) {
// Init may be called again - currently in case of redirects
if (isObjectLike(requestOptions) && !this._callback && !this._rp_promise) {
plumbing.init.call(this, requestOptions);
}
return originalInit.apply(this, arguments);
};
// Exposing the Promise capabilities
var thenExposed = false;
for ( var i = 0; i < options.expose.length; i+=1 ) {
var method = options.expose[i];
plumbing[ method === 'promise' ? 'exposePromise' : 'exposePromiseMethod' ](
options.request.Request.prototype,
null,
'_rp_promise',
method
);
if (method === 'then') {
thenExposed = true;
}
}
if (!thenExposed) {
throw new Error('Please expose "then"');
}
};

3
node_modules/request-promise-core/errors.js generated vendored Normal file
View file

@ -0,0 +1,3 @@
'use strict';
module.exports = require('./lib/errors.js');

62
node_modules/request-promise-core/lib/errors.js generated vendored Normal file
View file

@ -0,0 +1,62 @@
'use strict';
function RequestError(cause, options, response) {
this.name = 'RequestError';
this.message = String(cause);
this.cause = cause;
this.error = cause; // legacy attribute
this.options = options;
this.response = response;
if (Error.captureStackTrace) { // required for non-V8 environments
Error.captureStackTrace(this);
}
}
RequestError.prototype = Object.create(Error.prototype);
RequestError.prototype.constructor = RequestError;
function StatusCodeError(statusCode, body, options, response) {
this.name = 'StatusCodeError';
this.statusCode = statusCode;
this.message = statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(body) : body);
this.error = body; // legacy attribute
this.options = options;
this.response = response;
if (Error.captureStackTrace) { // required for non-V8 environments
Error.captureStackTrace(this);
}
}
StatusCodeError.prototype = Object.create(Error.prototype);
StatusCodeError.prototype.constructor = StatusCodeError;
function TransformError(cause, options, response) {
this.name = 'TransformError';
this.message = String(cause);
this.cause = cause;
this.error = cause; // legacy attribute
this.options = options;
this.response = response;
if (Error.captureStackTrace) { // required for non-V8 environments
Error.captureStackTrace(this);
}
}
TransformError.prototype = Object.create(Error.prototype);
TransformError.prototype.constructor = TransformError;
module.exports = {
RequestError: RequestError,
StatusCodeError: StatusCodeError,
TransformError: TransformError
};

167
node_modules/request-promise-core/lib/plumbing.js generated vendored Normal file
View file

@ -0,0 +1,167 @@
'use strict';
var errors = require('./errors.js'),
isFunction = require('lodash/isFunction'),
isObjectLike = require('lodash/isObjectLike'),
isString = require('lodash/isString'),
isUndefined = require('lodash/isUndefined');
module.exports = function (options) {
var errorText = 'Please verify options'; // For better minification because this string is repeating
if (!isObjectLike(options)) {
throw new TypeError(errorText);
}
if (!isFunction(options.PromiseImpl)) {
throw new TypeError(errorText + '.PromiseImpl');
}
if (!isUndefined(options.constructorMixin) && !isFunction(options.constructorMixin)) {
throw new TypeError(errorText + '.PromiseImpl');
}
var PromiseImpl = options.PromiseImpl;
var constructorMixin = options.constructorMixin;
var plumbing = {};
plumbing.init = function (requestOptions) {
var self = this;
self._rp_promise = new PromiseImpl(function (resolve, reject) {
self._rp_resolve = resolve;
self._rp_reject = reject;
if (constructorMixin) {
constructorMixin.apply(self, arguments); // Using arguments since specific Promise libraries may pass additional parameters
}
});
self._rp_callbackOrig = requestOptions.callback;
requestOptions.callback = self.callback = function RP$callback(err, response, body) {
plumbing.callback.call(self, err, response, body);
};
if (isString(requestOptions.method)) {
requestOptions.method = requestOptions.method.toUpperCase();
}
requestOptions.transform = requestOptions.transform || plumbing.defaultTransformations[requestOptions.method];
self._rp_options = requestOptions;
self._rp_options.simple = requestOptions.simple !== false;
self._rp_options.resolveWithFullResponse = requestOptions.resolveWithFullResponse === true;
self._rp_options.transform2xxOnly = requestOptions.transform2xxOnly === true;
};
plumbing.defaultTransformations = {
HEAD: function (body, response, resolveWithFullResponse) {
return resolveWithFullResponse ? response : response.headers;
}
};
plumbing.callback = function (err, response, body) {
var self = this;
var origCallbackThrewException = false, thrownException = null;
if (isFunction(self._rp_callbackOrig)) {
try {
self._rp_callbackOrig.apply(self, arguments); // TODO: Apply to self mimics behavior of request@2. Is that also right for request@next?
} catch (e) {
origCallbackThrewException = true;
thrownException = e;
}
}
var is2xx = !err && /^2/.test('' + response.statusCode);
if (err) {
self._rp_reject(new errors.RequestError(err, self._rp_options, response));
} else if (self._rp_options.simple && !is2xx) {
if (isFunction(self._rp_options.transform) && self._rp_options.transform2xxOnly === false) {
(new PromiseImpl(function (resolve) {
resolve(self._rp_options.transform(body, response, self._rp_options.resolveWithFullResponse)); // transform may return a Promise
}))
.then(function (transformedResponse) {
self._rp_reject(new errors.StatusCodeError(response.statusCode, body, self._rp_options, transformedResponse));
})
.catch(function (transformErr) {
self._rp_reject(new errors.TransformError(transformErr, self._rp_options, response));
});
} else {
self._rp_reject(new errors.StatusCodeError(response.statusCode, body, self._rp_options, response));
}
} else {
if (isFunction(self._rp_options.transform) && (is2xx || self._rp_options.transform2xxOnly === false)) {
(new PromiseImpl(function (resolve) {
resolve(self._rp_options.transform(body, response, self._rp_options.resolveWithFullResponse)); // transform may return a Promise
}))
.then(function (transformedResponse) {
self._rp_resolve(transformedResponse);
})
.catch(function (transformErr) {
self._rp_reject(new errors.TransformError(transformErr, self._rp_options, response));
});
} else if (self._rp_options.resolveWithFullResponse) {
self._rp_resolve(response);
} else {
self._rp_resolve(body);
}
}
if (origCallbackThrewException) {
throw thrownException;
}
};
plumbing.exposePromiseMethod = function (exposeTo, bindTo, promisePropertyKey, methodToExpose, exposeAs) {
exposeAs = exposeAs || methodToExpose;
if (exposeAs in exposeTo) {
throw new Error('Unable to expose method "' + exposeAs + '"');
}
exposeTo[exposeAs] = function RP$exposed() {
var self = bindTo || this;
return self[promisePropertyKey][methodToExpose].apply(self[promisePropertyKey], arguments);
};
};
plumbing.exposePromise = function (exposeTo, bindTo, promisePropertyKey, exposeAs) {
exposeAs = exposeAs || 'promise';
if (exposeAs in exposeTo) {
throw new Error('Unable to expose method "' + exposeAs + '"');
}
exposeTo[exposeAs] = function RP$promise() {
var self = bindTo || this;
return self[promisePropertyKey];
};
};
return plumbing;
};

92
node_modules/request-promise-core/package.json generated vendored Normal file
View file

@ -0,0 +1,92 @@
{
"_args": [
[
"request-promise-core@1.1.2",
"/Users/eric/repos/actions/setup-node"
]
],
"_development": true,
"_from": "request-promise-core@1.1.2",
"_id": "request-promise-core@1.1.2",
"_inBundle": false,
"_integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==",
"_location": "/request-promise-core",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "request-promise-core@1.1.2",
"name": "request-promise-core",
"escapedName": "request-promise-core",
"rawSpec": "1.1.2",
"saveSpec": null,
"fetchSpec": "1.1.2"
},
"_requiredBy": [
"/request-promise-native"
],
"_resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz",
"_spec": "1.1.2",
"_where": "/Users/eric/repos/actions/setup-node",
"author": {
"name": "Nicolai Kamenzky",
"url": "https://github.com/analog-nico"
},
"bugs": {
"url": "https://github.com/request/promise-core/issues"
},
"dependencies": {
"lodash": "^4.17.11"
},
"description": "Core Promise support implementation for the simplified HTTP request client 'request'.",
"devDependencies": {
"@request/api": "^0.6.0",
"@request/client": "^0.1.0",
"bluebird": "~3.4.1",
"body-parser": "~1.15.2",
"chai": "~3.5.0",
"chalk": "~1.1.3",
"gulp": "~3.9.1",
"gulp-coveralls": "~0.1.4",
"gulp-eslint": "~2.1.0",
"gulp-istanbul": "~1.0.0",
"gulp-mocha": "~2.2.0",
"node-version": "~1.0.0",
"publish-please": "~5.4.3",
"request": "^2.34.0",
"rimraf": "~2.5.3",
"run-sequence": "~1.2.2",
"stealthy-require": "~1.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"homepage": "https://github.com/request/promise-core#readme",
"keywords": [
"xhr",
"http",
"https",
"promise",
"request",
"then",
"thenable",
"core"
],
"license": "ISC",
"main": "./lib/plumbing.js",
"name": "request-promise-core",
"peerDependencies": {
"request": "^2.34"
},
"repository": {
"type": "git",
"url": "git+https://github.com/request/promise-core.git"
},
"scripts": {
"prepublish": "publish-please guard",
"publish-please": "publish-please",
"test": "gulp ci",
"test-publish": "gulp ci-no-cov"
},
"version": "1.1.2"
}