mirror of
https://github.com/github/codeql-action.git
synced 2026-01-05 14:10:11 +08:00
Merge branch 'main' into dependabot/npm_and_yarn/actions/exec-1.1.0
This commit is contained in:
32
node_modules/.package-lock.json
generated
vendored
32
node_modules/.package-lock.json
generated
vendored
@@ -15,13 +15,6 @@
|
||||
"tmp-promise": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/artifact/node_modules/@actions/http-client": {
|
||||
"version": "1.0.11",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tunnel": "0.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
"version": "1.2.6",
|
||||
"license": "MIT"
|
||||
@@ -45,8 +38,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "1.0.8",
|
||||
"license": "MIT",
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||
"dependencies": {
|
||||
"tunnel": "0.0.6"
|
||||
}
|
||||
@@ -3361,6 +3355,12 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash.set": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz",
|
||||
"integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/lodash.snakecase": {
|
||||
"version": "4.1.1",
|
||||
"dev": true,
|
||||
@@ -3583,13 +3583,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/nock": {
|
||||
"version": "12.0.3",
|
||||
"version": "13.1.1",
|
||||
"resolved": "https://registry.npmjs.org/nock/-/nock-13.1.1.tgz",
|
||||
"integrity": "sha512-YKTR9MjfK3kS9/l4nuTxyYm30cgOExRHzkLNhL8nhEUyU4f8Za/dRxOqjhVT1vGs0svWo3dDnJTUX1qxYeWy5w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.1.0",
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"lodash": "^4.17.13",
|
||||
"lodash.set": "^4.3.2",
|
||||
"propagate": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -5005,13 +5006,6 @@
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/tunnel": {
|
||||
"version": "0.0.6",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"dev": true,
|
||||
|
||||
21
node_modules/@actions/artifact/node_modules/@actions/http-client/LICENSE
generated
vendored
21
node_modules/@actions/artifact/node_modules/@actions/http-client/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
79
node_modules/@actions/artifact/node_modules/@actions/http-client/README.md
generated
vendored
79
node_modules/@actions/artifact/node_modules/@actions/http-client/README.md
generated
vendored
@@ -1,79 +0,0 @@
|
||||
|
||||
<p align="center">
|
||||
<img src="actions.png">
|
||||
</p>
|
||||
|
||||
# Actions Http-Client
|
||||
|
||||
[](https://github.com/actions/http-client/actions)
|
||||
|
||||
A lightweight HTTP client optimized for use with actions, TypeScript with generics and async await.
|
||||
|
||||
## Features
|
||||
|
||||
- HTTP client with TypeScript generics and async/await/Promises
|
||||
- Typings included so no need to acquire separately (great for intellisense and no versioning drift)
|
||||
- [Proxy support](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-self-hosted-runners#using-a-proxy-server-with-self-hosted-runners) just works with actions and the runner
|
||||
- Targets ES2019 (runner runs actions with node 12+). Only supported on node 12+.
|
||||
- Basic, Bearer and PAT Support out of the box. Extensible handlers for others.
|
||||
- Redirects supported
|
||||
|
||||
Features and releases [here](./RELEASES.md)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install @actions/http-client --save
|
||||
```
|
||||
|
||||
## Samples
|
||||
|
||||
See the [HTTP](./__tests__) tests for detailed examples.
|
||||
|
||||
## Errors
|
||||
|
||||
### HTTP
|
||||
|
||||
The HTTP client does not throw unless truly exceptional.
|
||||
|
||||
* A request that successfully executes resulting in a 404, 500 etc... will return a response object with a status code and a body.
|
||||
* Redirects (3xx) will be followed by default.
|
||||
|
||||
See [HTTP tests](./__tests__) for detailed examples.
|
||||
|
||||
## Debugging
|
||||
|
||||
To enable detailed console logging of all HTTP requests and responses, set the NODE_DEBUG environment varible:
|
||||
|
||||
```
|
||||
export NODE_DEBUG=http
|
||||
```
|
||||
|
||||
## Node support
|
||||
|
||||
The http-client is built using the latest LTS version of Node 12. It may work on previous node LTS versions but it's tested and officially supported on Node12+.
|
||||
|
||||
## Support and Versioning
|
||||
|
||||
We follow semver and will hold compatibility between major versions and increment the minor version with new features and capabilities (while holding compat).
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome PRs. Please create an issue and if applicable, a design before proceeding with code.
|
||||
|
||||
once:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
To build:
|
||||
|
||||
```bash
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
To run all tests:
|
||||
```bash
|
||||
$ npm test
|
||||
```
|
||||
26
node_modules/@actions/artifact/node_modules/@actions/http-client/RELEASES.md
generated
vendored
26
node_modules/@actions/artifact/node_modules/@actions/http-client/RELEASES.md
generated
vendored
@@ -1,26 +0,0 @@
|
||||
## Releases
|
||||
|
||||
## 1.0.10
|
||||
|
||||
Contains a bug fix where proxy is defined without a user and password. see [PR here](https://github.com/actions/http-client/pull/42)
|
||||
|
||||
## 1.0.9
|
||||
Throw HttpClientError instead of a generic Error from the \<verb>Json() helper methods when the server responds with a non-successful status code.
|
||||
|
||||
## 1.0.8
|
||||
Fixed security issue where a redirect (e.g. 302) to another domain would pass headers. The fix was to strip the authorization header if the hostname was different. More [details in PR #27](https://github.com/actions/http-client/pull/27)
|
||||
|
||||
## 1.0.7
|
||||
Update NPM dependencies and add 429 to the list of HttpCodes
|
||||
|
||||
## 1.0.6
|
||||
Automatically sends Content-Type and Accept application/json headers for \<verb>Json() helper methods if not set in the client or parameters.
|
||||
|
||||
## 1.0.5
|
||||
Adds \<verb>Json() helper methods for json over http scenarios.
|
||||
|
||||
## 1.0.4
|
||||
Started to add \<verb>Json() helper methods. Do not use this release for that. Use >= 1.0.5 since there was an issue with types.
|
||||
|
||||
## 1.0.1 to 1.0.3
|
||||
Adds proxy support.
|
||||
BIN
node_modules/@actions/artifact/node_modules/@actions/http-client/actions.png
generated
vendored
BIN
node_modules/@actions/artifact/node_modules/@actions/http-client/actions.png
generated
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB |
23
node_modules/@actions/artifact/node_modules/@actions/http-client/auth.d.ts
generated
vendored
23
node_modules/@actions/artifact/node_modules/@actions/http-client/auth.d.ts
generated
vendored
@@ -1,23 +0,0 @@
|
||||
import ifm = require('./interfaces');
|
||||
export declare class BasicCredentialHandler implements ifm.IRequestHandler {
|
||||
username: string;
|
||||
password: string;
|
||||
constructor(username: string, password: string);
|
||||
prepareRequest(options: any): void;
|
||||
canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;
|
||||
handleAuthentication(httpClient: ifm.IHttpClient, requestInfo: ifm.IRequestInfo, objs: any): Promise<ifm.IHttpClientResponse>;
|
||||
}
|
||||
export declare class BearerCredentialHandler implements ifm.IRequestHandler {
|
||||
token: string;
|
||||
constructor(token: string);
|
||||
prepareRequest(options: any): void;
|
||||
canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;
|
||||
handleAuthentication(httpClient: ifm.IHttpClient, requestInfo: ifm.IRequestInfo, objs: any): Promise<ifm.IHttpClientResponse>;
|
||||
}
|
||||
export declare class PersonalAccessTokenCredentialHandler implements ifm.IRequestHandler {
|
||||
token: string;
|
||||
constructor(token: string);
|
||||
prepareRequest(options: any): void;
|
||||
canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;
|
||||
handleAuthentication(httpClient: ifm.IHttpClient, requestInfo: ifm.IRequestInfo, objs: any): Promise<ifm.IHttpClientResponse>;
|
||||
}
|
||||
58
node_modules/@actions/artifact/node_modules/@actions/http-client/auth.js
generated
vendored
58
node_modules/@actions/artifact/node_modules/@actions/http-client/auth.js
generated
vendored
@@ -1,58 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class BasicCredentialHandler {
|
||||
constructor(username, password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
prepareRequest(options) {
|
||||
options.headers['Authorization'] =
|
||||
'Basic ' +
|
||||
Buffer.from(this.username + ':' + this.password).toString('base64');
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication(response) {
|
||||
return false;
|
||||
}
|
||||
handleAuthentication(httpClient, requestInfo, objs) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||||
class BearerCredentialHandler {
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
}
|
||||
// currently implements pre-authorization
|
||||
// TODO: support preAuth = false where it hooks on 401
|
||||
prepareRequest(options) {
|
||||
options.headers['Authorization'] = 'Bearer ' + this.token;
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication(response) {
|
||||
return false;
|
||||
}
|
||||
handleAuthentication(httpClient, requestInfo, objs) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||||
class PersonalAccessTokenCredentialHandler {
|
||||
constructor(token) {
|
||||
this.token = token;
|
||||
}
|
||||
// currently implements pre-authorization
|
||||
// TODO: support preAuth = false where it hooks on 401
|
||||
prepareRequest(options) {
|
||||
options.headers['Authorization'] =
|
||||
'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication(response) {
|
||||
return false;
|
||||
}
|
||||
handleAuthentication(httpClient, requestInfo, objs) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
||||
124
node_modules/@actions/artifact/node_modules/@actions/http-client/index.d.ts
generated
vendored
124
node_modules/@actions/artifact/node_modules/@actions/http-client/index.d.ts
generated
vendored
@@ -1,124 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import http = require('http');
|
||||
import ifm = require('./interfaces');
|
||||
export declare enum HttpCodes {
|
||||
OK = 200,
|
||||
MultipleChoices = 300,
|
||||
MovedPermanently = 301,
|
||||
ResourceMoved = 302,
|
||||
SeeOther = 303,
|
||||
NotModified = 304,
|
||||
UseProxy = 305,
|
||||
SwitchProxy = 306,
|
||||
TemporaryRedirect = 307,
|
||||
PermanentRedirect = 308,
|
||||
BadRequest = 400,
|
||||
Unauthorized = 401,
|
||||
PaymentRequired = 402,
|
||||
Forbidden = 403,
|
||||
NotFound = 404,
|
||||
MethodNotAllowed = 405,
|
||||
NotAcceptable = 406,
|
||||
ProxyAuthenticationRequired = 407,
|
||||
RequestTimeout = 408,
|
||||
Conflict = 409,
|
||||
Gone = 410,
|
||||
TooManyRequests = 429,
|
||||
InternalServerError = 500,
|
||||
NotImplemented = 501,
|
||||
BadGateway = 502,
|
||||
ServiceUnavailable = 503,
|
||||
GatewayTimeout = 504
|
||||
}
|
||||
export declare enum Headers {
|
||||
Accept = "accept",
|
||||
ContentType = "content-type"
|
||||
}
|
||||
export declare enum MediaTypes {
|
||||
ApplicationJson = "application/json"
|
||||
}
|
||||
/**
|
||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
export declare function getProxyUrl(serverUrl: string): string;
|
||||
export declare class HttpClientError extends Error {
|
||||
constructor(message: string, statusCode: number);
|
||||
statusCode: number;
|
||||
result?: any;
|
||||
}
|
||||
export declare class HttpClientResponse implements ifm.IHttpClientResponse {
|
||||
constructor(message: http.IncomingMessage);
|
||||
message: http.IncomingMessage;
|
||||
readBody(): Promise<string>;
|
||||
}
|
||||
export declare function isHttps(requestUrl: string): boolean;
|
||||
export declare class HttpClient {
|
||||
userAgent: string | undefined;
|
||||
handlers: ifm.IRequestHandler[];
|
||||
requestOptions: ifm.IRequestOptions;
|
||||
private _ignoreSslError;
|
||||
private _socketTimeout;
|
||||
private _allowRedirects;
|
||||
private _allowRedirectDowngrade;
|
||||
private _maxRedirects;
|
||||
private _allowRetries;
|
||||
private _maxRetries;
|
||||
private _agent;
|
||||
private _proxyAgent;
|
||||
private _keepAlive;
|
||||
private _disposed;
|
||||
constructor(userAgent?: string, handlers?: ifm.IRequestHandler[], requestOptions?: ifm.IRequestOptions);
|
||||
options(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
get(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
del(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
post(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
patch(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
put(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
head(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
sendStream(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, additionalHeaders?: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
/**
|
||||
* Gets a typed object from an endpoint
|
||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||
*/
|
||||
getJson<T>(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<ifm.ITypedResponse<T>>;
|
||||
postJson<T>(requestUrl: string, obj: any, additionalHeaders?: ifm.IHeaders): Promise<ifm.ITypedResponse<T>>;
|
||||
putJson<T>(requestUrl: string, obj: any, additionalHeaders?: ifm.IHeaders): Promise<ifm.ITypedResponse<T>>;
|
||||
patchJson<T>(requestUrl: string, obj: any, additionalHeaders?: ifm.IHeaders): Promise<ifm.ITypedResponse<T>>;
|
||||
/**
|
||||
* Makes a raw http request.
|
||||
* All other methods such as get, post, patch, and request ultimately call this.
|
||||
* Prefer get, del, post and patch
|
||||
*/
|
||||
request(verb: string, requestUrl: string, data: string | NodeJS.ReadableStream, headers: ifm.IHeaders): Promise<ifm.IHttpClientResponse>;
|
||||
/**
|
||||
* Needs to be called if keepAlive is set to true in request options.
|
||||
*/
|
||||
dispose(): void;
|
||||
/**
|
||||
* Raw request.
|
||||
* @param info
|
||||
* @param data
|
||||
*/
|
||||
requestRaw(info: ifm.IRequestInfo, data: string | NodeJS.ReadableStream): Promise<ifm.IHttpClientResponse>;
|
||||
/**
|
||||
* Raw request with callback.
|
||||
* @param info
|
||||
* @param data
|
||||
* @param onResult
|
||||
*/
|
||||
requestRawWithCallback(info: ifm.IRequestInfo, data: string | NodeJS.ReadableStream, onResult: (err: any, res: ifm.IHttpClientResponse) => void): void;
|
||||
/**
|
||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
getAgent(serverUrl: string): http.Agent;
|
||||
private _prepareRequest;
|
||||
private _mergeHeaders;
|
||||
private _getExistingOrDefaultHeader;
|
||||
private _getAgent;
|
||||
private _performExponentialBackoff;
|
||||
private static dateTimeDeserializer;
|
||||
private _processResponse;
|
||||
}
|
||||
537
node_modules/@actions/artifact/node_modules/@actions/http-client/index.js
generated
vendored
537
node_modules/@actions/artifact/node_modules/@actions/http-client/index.js
generated
vendored
@@ -1,537 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const http = require("http");
|
||||
const https = require("https");
|
||||
const pm = require("./proxy");
|
||||
let tunnel;
|
||||
var HttpCodes;
|
||||
(function (HttpCodes) {
|
||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
||||
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
||||
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
||||
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
||||
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
||||
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
||||
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
||||
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
||||
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
||||
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
||||
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
||||
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
||||
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
||||
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
||||
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
||||
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
||||
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
||||
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
||||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
||||
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
||||
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
||||
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
||||
var Headers;
|
||||
(function (Headers) {
|
||||
Headers["Accept"] = "accept";
|
||||
Headers["ContentType"] = "content-type";
|
||||
})(Headers = exports.Headers || (exports.Headers = {}));
|
||||
var MediaTypes;
|
||||
(function (MediaTypes) {
|
||||
MediaTypes["ApplicationJson"] = "application/json";
|
||||
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
||||
/**
|
||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
function getProxyUrl(serverUrl) {
|
||||
let proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||
return proxyUrl ? proxyUrl.href : '';
|
||||
}
|
||||
exports.getProxyUrl = getProxyUrl;
|
||||
const HttpRedirectCodes = [
|
||||
HttpCodes.MovedPermanently,
|
||||
HttpCodes.ResourceMoved,
|
||||
HttpCodes.SeeOther,
|
||||
HttpCodes.TemporaryRedirect,
|
||||
HttpCodes.PermanentRedirect
|
||||
];
|
||||
const HttpResponseRetryCodes = [
|
||||
HttpCodes.BadGateway,
|
||||
HttpCodes.ServiceUnavailable,
|
||||
HttpCodes.GatewayTimeout
|
||||
];
|
||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||
const ExponentialBackoffCeiling = 10;
|
||||
const ExponentialBackoffTimeSlice = 5;
|
||||
class HttpClientError extends Error {
|
||||
constructor(message, statusCode) {
|
||||
super(message);
|
||||
this.name = 'HttpClientError';
|
||||
this.statusCode = statusCode;
|
||||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
||||
}
|
||||
}
|
||||
exports.HttpClientError = HttpClientError;
|
||||
class HttpClientResponse {
|
||||
constructor(message) {
|
||||
this.message = message;
|
||||
}
|
||||
readBody() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let output = Buffer.alloc(0);
|
||||
this.message.on('data', (chunk) => {
|
||||
output = Buffer.concat([output, chunk]);
|
||||
});
|
||||
this.message.on('end', () => {
|
||||
resolve(output.toString());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.HttpClientResponse = HttpClientResponse;
|
||||
function isHttps(requestUrl) {
|
||||
let parsedUrl = new URL(requestUrl);
|
||||
return parsedUrl.protocol === 'https:';
|
||||
}
|
||||
exports.isHttps = isHttps;
|
||||
class HttpClient {
|
||||
constructor(userAgent, handlers, requestOptions) {
|
||||
this._ignoreSslError = false;
|
||||
this._allowRedirects = true;
|
||||
this._allowRedirectDowngrade = false;
|
||||
this._maxRedirects = 50;
|
||||
this._allowRetries = false;
|
||||
this._maxRetries = 1;
|
||||
this._keepAlive = false;
|
||||
this._disposed = false;
|
||||
this.userAgent = userAgent;
|
||||
this.handlers = handlers || [];
|
||||
this.requestOptions = requestOptions;
|
||||
if (requestOptions) {
|
||||
if (requestOptions.ignoreSslError != null) {
|
||||
this._ignoreSslError = requestOptions.ignoreSslError;
|
||||
}
|
||||
this._socketTimeout = requestOptions.socketTimeout;
|
||||
if (requestOptions.allowRedirects != null) {
|
||||
this._allowRedirects = requestOptions.allowRedirects;
|
||||
}
|
||||
if (requestOptions.allowRedirectDowngrade != null) {
|
||||
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
||||
}
|
||||
if (requestOptions.maxRedirects != null) {
|
||||
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
||||
}
|
||||
if (requestOptions.keepAlive != null) {
|
||||
this._keepAlive = requestOptions.keepAlive;
|
||||
}
|
||||
if (requestOptions.allowRetries != null) {
|
||||
this._allowRetries = requestOptions.allowRetries;
|
||||
}
|
||||
if (requestOptions.maxRetries != null) {
|
||||
this._maxRetries = requestOptions.maxRetries;
|
||||
}
|
||||
}
|
||||
}
|
||||
options(requestUrl, additionalHeaders) {
|
||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
||||
}
|
||||
get(requestUrl, additionalHeaders) {
|
||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
||||
}
|
||||
del(requestUrl, additionalHeaders) {
|
||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
||||
}
|
||||
post(requestUrl, data, additionalHeaders) {
|
||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
||||
}
|
||||
patch(requestUrl, data, additionalHeaders) {
|
||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
||||
}
|
||||
put(requestUrl, data, additionalHeaders) {
|
||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
||||
}
|
||||
head(requestUrl, additionalHeaders) {
|
||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
||||
}
|
||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
||||
}
|
||||
/**
|
||||
* Gets a typed object from an endpoint
|
||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||
*/
|
||||
async getJson(requestUrl, additionalHeaders = {}) {
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
let res = await this.get(requestUrl, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
}
|
||||
async postJson(requestUrl, obj, additionalHeaders = {}) {
|
||||
let data = JSON.stringify(obj, null, 2);
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||
let res = await this.post(requestUrl, data, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
}
|
||||
async putJson(requestUrl, obj, additionalHeaders = {}) {
|
||||
let data = JSON.stringify(obj, null, 2);
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||
let res = await this.put(requestUrl, data, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
}
|
||||
async patchJson(requestUrl, obj, additionalHeaders = {}) {
|
||||
let data = JSON.stringify(obj, null, 2);
|
||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||
let res = await this.patch(requestUrl, data, additionalHeaders);
|
||||
return this._processResponse(res, this.requestOptions);
|
||||
}
|
||||
/**
|
||||
* Makes a raw http request.
|
||||
* All other methods such as get, post, patch, and request ultimately call this.
|
||||
* Prefer get, del, post and patch
|
||||
*/
|
||||
async request(verb, requestUrl, data, headers) {
|
||||
if (this._disposed) {
|
||||
throw new Error('Client has already been disposed.');
|
||||
}
|
||||
let parsedUrl = new URL(requestUrl);
|
||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||
// Only perform retries on reads since writes may not be idempotent.
|
||||
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
|
||||
? this._maxRetries + 1
|
||||
: 1;
|
||||
let numTries = 0;
|
||||
let response;
|
||||
while (numTries < maxTries) {
|
||||
response = await this.requestRaw(info, data);
|
||||
// Check if it's an authentication challenge
|
||||
if (response &&
|
||||
response.message &&
|
||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||
let authenticationHandler;
|
||||
for (let i = 0; i < this.handlers.length; i++) {
|
||||
if (this.handlers[i].canHandleAuthentication(response)) {
|
||||
authenticationHandler = this.handlers[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (authenticationHandler) {
|
||||
return authenticationHandler.handleAuthentication(this, info, data);
|
||||
}
|
||||
else {
|
||||
// We have received an unauthorized response but have no handlers to handle it.
|
||||
// Let the response return to the caller.
|
||||
return response;
|
||||
}
|
||||
}
|
||||
let redirectsRemaining = this._maxRedirects;
|
||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
|
||||
this._allowRedirects &&
|
||||
redirectsRemaining > 0) {
|
||||
const redirectUrl = response.message.headers['location'];
|
||||
if (!redirectUrl) {
|
||||
// if there's no location to redirect to, we won't
|
||||
break;
|
||||
}
|
||||
let parsedRedirectUrl = new URL(redirectUrl);
|
||||
if (parsedUrl.protocol == 'https:' &&
|
||||
parsedUrl.protocol != parsedRedirectUrl.protocol &&
|
||||
!this._allowRedirectDowngrade) {
|
||||
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
||||
}
|
||||
// we need to finish reading the response before reassigning response
|
||||
// which will leak the open socket.
|
||||
await response.readBody();
|
||||
// strip authorization header if redirected to a different hostname
|
||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||
for (let header in headers) {
|
||||
// header names are case insensitive
|
||||
if (header.toLowerCase() === 'authorization') {
|
||||
delete headers[header];
|
||||
}
|
||||
}
|
||||
}
|
||||
// let's make the request with the new redirectUrl
|
||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||
response = await this.requestRaw(info, data);
|
||||
redirectsRemaining--;
|
||||
}
|
||||
if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {
|
||||
// If not a retry code, return immediately instead of retrying
|
||||
return response;
|
||||
}
|
||||
numTries += 1;
|
||||
if (numTries < maxTries) {
|
||||
await response.readBody();
|
||||
await this._performExponentialBackoff(numTries);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
/**
|
||||
* Needs to be called if keepAlive is set to true in request options.
|
||||
*/
|
||||
dispose() {
|
||||
if (this._agent) {
|
||||
this._agent.destroy();
|
||||
}
|
||||
this._disposed = true;
|
||||
}
|
||||
/**
|
||||
* Raw request.
|
||||
* @param info
|
||||
* @param data
|
||||
*/
|
||||
requestRaw(info, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let callbackForResult = function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve(res);
|
||||
};
|
||||
this.requestRawWithCallback(info, data, callbackForResult);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Raw request with callback.
|
||||
* @param info
|
||||
* @param data
|
||||
* @param onResult
|
||||
*/
|
||||
requestRawWithCallback(info, data, onResult) {
|
||||
let socket;
|
||||
if (typeof data === 'string') {
|
||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||
}
|
||||
let callbackCalled = false;
|
||||
let handleResult = (err, res) => {
|
||||
if (!callbackCalled) {
|
||||
callbackCalled = true;
|
||||
onResult(err, res);
|
||||
}
|
||||
};
|
||||
let req = info.httpModule.request(info.options, (msg) => {
|
||||
let res = new HttpClientResponse(msg);
|
||||
handleResult(null, res);
|
||||
});
|
||||
req.on('socket', sock => {
|
||||
socket = sock;
|
||||
});
|
||||
// If we ever get disconnected, we want the socket to timeout eventually
|
||||
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
||||
if (socket) {
|
||||
socket.end();
|
||||
}
|
||||
handleResult(new Error('Request timeout: ' + info.options.path), null);
|
||||
});
|
||||
req.on('error', function (err) {
|
||||
// err has statusCode property
|
||||
// res should have headers
|
||||
handleResult(err, null);
|
||||
});
|
||||
if (data && typeof data === 'string') {
|
||||
req.write(data, 'utf8');
|
||||
}
|
||||
if (data && typeof data !== 'string') {
|
||||
data.on('close', function () {
|
||||
req.end();
|
||||
});
|
||||
data.pipe(req);
|
||||
}
|
||||
else {
|
||||
req.end();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
getAgent(serverUrl) {
|
||||
let parsedUrl = new URL(serverUrl);
|
||||
return this._getAgent(parsedUrl);
|
||||
}
|
||||
_prepareRequest(method, requestUrl, headers) {
|
||||
const info = {};
|
||||
info.parsedUrl = requestUrl;
|
||||
const usingSsl = info.parsedUrl.protocol === 'https:';
|
||||
info.httpModule = usingSsl ? https : http;
|
||||
const defaultPort = usingSsl ? 443 : 80;
|
||||
info.options = {};
|
||||
info.options.host = info.parsedUrl.hostname;
|
||||
info.options.port = info.parsedUrl.port
|
||||
? parseInt(info.parsedUrl.port)
|
||||
: defaultPort;
|
||||
info.options.path =
|
||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||||
info.options.method = method;
|
||||
info.options.headers = this._mergeHeaders(headers);
|
||||
if (this.userAgent != null) {
|
||||
info.options.headers['user-agent'] = this.userAgent;
|
||||
}
|
||||
info.options.agent = this._getAgent(info.parsedUrl);
|
||||
// gives handlers an opportunity to participate
|
||||
if (this.handlers) {
|
||||
this.handlers.forEach(handler => {
|
||||
handler.prepareRequest(info.options);
|
||||
});
|
||||
}
|
||||
return info;
|
||||
}
|
||||
_mergeHeaders(headers) {
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
||||
}
|
||||
return lowercaseKeys(headers || {});
|
||||
}
|
||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
let clientHeader;
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||
}
|
||||
return additionalHeaders[header] || clientHeader || _default;
|
||||
}
|
||||
_getAgent(parsedUrl) {
|
||||
let agent;
|
||||
let proxyUrl = pm.getProxyUrl(parsedUrl);
|
||||
let useProxy = proxyUrl && proxyUrl.hostname;
|
||||
if (this._keepAlive && useProxy) {
|
||||
agent = this._proxyAgent;
|
||||
}
|
||||
if (this._keepAlive && !useProxy) {
|
||||
agent = this._agent;
|
||||
}
|
||||
// if agent is already assigned use that agent.
|
||||
if (!!agent) {
|
||||
return agent;
|
||||
}
|
||||
const usingSsl = parsedUrl.protocol === 'https:';
|
||||
let maxSockets = 100;
|
||||
if (!!this.requestOptions) {
|
||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
||||
}
|
||||
if (useProxy) {
|
||||
// If using proxy, need tunnel
|
||||
if (!tunnel) {
|
||||
tunnel = require('tunnel');
|
||||
}
|
||||
const agentOptions = {
|
||||
maxSockets: maxSockets,
|
||||
keepAlive: this._keepAlive,
|
||||
proxy: {
|
||||
...((proxyUrl.username || proxyUrl.password) && {
|
||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||
}),
|
||||
host: proxyUrl.hostname,
|
||||
port: proxyUrl.port
|
||||
}
|
||||
};
|
||||
let tunnelAgent;
|
||||
const overHttps = proxyUrl.protocol === 'https:';
|
||||
if (usingSsl) {
|
||||
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
||||
}
|
||||
else {
|
||||
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
||||
}
|
||||
agent = tunnelAgent(agentOptions);
|
||||
this._proxyAgent = agent;
|
||||
}
|
||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||
if (this._keepAlive && !agent) {
|
||||
const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
|
||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||||
this._agent = agent;
|
||||
}
|
||||
// if not using private agent and tunnel agent isn't setup then use global agent
|
||||
if (!agent) {
|
||||
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
||||
}
|
||||
if (usingSsl && this._ignoreSslError) {
|
||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||||
// we have to cast it to any and change it directly
|
||||
agent.options = Object.assign(agent.options || {}, {
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
}
|
||||
return agent;
|
||||
}
|
||||
_performExponentialBackoff(retryNumber) {
|
||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
||||
}
|
||||
static dateTimeDeserializer(key, value) {
|
||||
if (typeof value === 'string') {
|
||||
let a = new Date(value);
|
||||
if (!isNaN(a.valueOf())) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
async _processResponse(res, options) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const statusCode = res.message.statusCode;
|
||||
const response = {
|
||||
statusCode: statusCode,
|
||||
result: null,
|
||||
headers: {}
|
||||
};
|
||||
// not found leads to null obj returned
|
||||
if (statusCode == HttpCodes.NotFound) {
|
||||
resolve(response);
|
||||
}
|
||||
let obj;
|
||||
let contents;
|
||||
// get the result from the body
|
||||
try {
|
||||
contents = await res.readBody();
|
||||
if (contents && contents.length > 0) {
|
||||
if (options && options.deserializeDates) {
|
||||
obj = JSON.parse(contents, HttpClient.dateTimeDeserializer);
|
||||
}
|
||||
else {
|
||||
obj = JSON.parse(contents);
|
||||
}
|
||||
response.result = obj;
|
||||
}
|
||||
response.headers = res.message.headers;
|
||||
}
|
||||
catch (err) {
|
||||
// Invalid resource (contents not json); leaving result obj null
|
||||
}
|
||||
// note that 3xx redirects are handled by the http layer.
|
||||
if (statusCode > 299) {
|
||||
let msg;
|
||||
// if exception/error in body, attempt to get better error
|
||||
if (obj && obj.message) {
|
||||
msg = obj.message;
|
||||
}
|
||||
else if (contents && contents.length > 0) {
|
||||
// it may be the case that the exception is in the body message as string
|
||||
msg = contents;
|
||||
}
|
||||
else {
|
||||
msg = 'Failed request: (' + statusCode + ')';
|
||||
}
|
||||
let err = new HttpClientError(msg, statusCode);
|
||||
err.result = response.result;
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.HttpClient = HttpClient;
|
||||
49
node_modules/@actions/artifact/node_modules/@actions/http-client/interfaces.d.ts
generated
vendored
49
node_modules/@actions/artifact/node_modules/@actions/http-client/interfaces.d.ts
generated
vendored
@@ -1,49 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import http = require('http');
|
||||
export interface IHeaders {
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface IHttpClient {
|
||||
options(requestUrl: string, additionalHeaders?: IHeaders): Promise<IHttpClientResponse>;
|
||||
get(requestUrl: string, additionalHeaders?: IHeaders): Promise<IHttpClientResponse>;
|
||||
del(requestUrl: string, additionalHeaders?: IHeaders): Promise<IHttpClientResponse>;
|
||||
post(requestUrl: string, data: string, additionalHeaders?: IHeaders): Promise<IHttpClientResponse>;
|
||||
patch(requestUrl: string, data: string, additionalHeaders?: IHeaders): Promise<IHttpClientResponse>;
|
||||
put(requestUrl: string, data: string, additionalHeaders?: IHeaders): Promise<IHttpClientResponse>;
|
||||
sendStream(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, additionalHeaders?: IHeaders): Promise<IHttpClientResponse>;
|
||||
request(verb: string, requestUrl: string, data: string | NodeJS.ReadableStream, headers: IHeaders): Promise<IHttpClientResponse>;
|
||||
requestRaw(info: IRequestInfo, data: string | NodeJS.ReadableStream): Promise<IHttpClientResponse>;
|
||||
requestRawWithCallback(info: IRequestInfo, data: string | NodeJS.ReadableStream, onResult: (err: any, res: IHttpClientResponse) => void): void;
|
||||
}
|
||||
export interface IRequestHandler {
|
||||
prepareRequest(options: http.RequestOptions): void;
|
||||
canHandleAuthentication(response: IHttpClientResponse): boolean;
|
||||
handleAuthentication(httpClient: IHttpClient, requestInfo: IRequestInfo, objs: any): Promise<IHttpClientResponse>;
|
||||
}
|
||||
export interface IHttpClientResponse {
|
||||
message: http.IncomingMessage;
|
||||
readBody(): Promise<string>;
|
||||
}
|
||||
export interface IRequestInfo {
|
||||
options: http.RequestOptions;
|
||||
parsedUrl: URL;
|
||||
httpModule: any;
|
||||
}
|
||||
export interface IRequestOptions {
|
||||
headers?: IHeaders;
|
||||
socketTimeout?: number;
|
||||
ignoreSslError?: boolean;
|
||||
allowRedirects?: boolean;
|
||||
allowRedirectDowngrade?: boolean;
|
||||
maxRedirects?: number;
|
||||
maxSockets?: number;
|
||||
keepAlive?: boolean;
|
||||
deserializeDates?: boolean;
|
||||
allowRetries?: boolean;
|
||||
maxRetries?: number;
|
||||
}
|
||||
export interface ITypedResponse<T> {
|
||||
statusCode: number;
|
||||
result: T | null;
|
||||
headers: Object;
|
||||
}
|
||||
2
node_modules/@actions/artifact/node_modules/@actions/http-client/interfaces.js
generated
vendored
2
node_modules/@actions/artifact/node_modules/@actions/http-client/interfaces.js
generated
vendored
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
39
node_modules/@actions/artifact/node_modules/@actions/http-client/package.json
generated
vendored
39
node_modules/@actions/artifact/node_modules/@actions/http-client/package.json
generated
vendored
@@ -1,39 +0,0 @@
|
||||
{
|
||||
"name": "@actions/http-client",
|
||||
"version": "1.0.11",
|
||||
"description": "Actions Http Client",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "rm -Rf ./_out && tsc && cp package*.json ./_out && cp *.md ./_out && cp LICENSE ./_out && cp actions.png ./_out",
|
||||
"test": "jest",
|
||||
"format": "prettier --write *.ts && prettier --write **/*.ts",
|
||||
"format-check": "prettier --check *.ts && prettier --check **/*.ts",
|
||||
"audit-check": "npm audit --audit-level=moderate"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/http-client.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Actions",
|
||||
"Http"
|
||||
],
|
||||
"author": "GitHub, Inc.",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/http-client/issues"
|
||||
},
|
||||
"homepage": "https://github.com/actions/http-client#readme",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^12.12.31",
|
||||
"jest": "^25.1.0",
|
||||
"prettier": "^2.0.4",
|
||||
"proxy": "^1.0.1",
|
||||
"ts-jest": "^25.2.1",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"tunnel": "0.0.6"
|
||||
}
|
||||
}
|
||||
2
node_modules/@actions/artifact/node_modules/@actions/http-client/proxy.d.ts
generated
vendored
2
node_modules/@actions/artifact/node_modules/@actions/http-client/proxy.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
export declare function getProxyUrl(reqUrl: URL): URL | undefined;
|
||||
export declare function checkBypass(reqUrl: URL): boolean;
|
||||
57
node_modules/@actions/artifact/node_modules/@actions/http-client/proxy.js
generated
vendored
57
node_modules/@actions/artifact/node_modules/@actions/http-client/proxy.js
generated
vendored
@@ -1,57 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function getProxyUrl(reqUrl) {
|
||||
let usingSsl = reqUrl.protocol === 'https:';
|
||||
let proxyUrl;
|
||||
if (checkBypass(reqUrl)) {
|
||||
return proxyUrl;
|
||||
}
|
||||
let proxyVar;
|
||||
if (usingSsl) {
|
||||
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||
}
|
||||
else {
|
||||
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||
}
|
||||
if (proxyVar) {
|
||||
proxyUrl = new URL(proxyVar);
|
||||
}
|
||||
return proxyUrl;
|
||||
}
|
||||
exports.getProxyUrl = getProxyUrl;
|
||||
function checkBypass(reqUrl) {
|
||||
if (!reqUrl.hostname) {
|
||||
return false;
|
||||
}
|
||||
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||
if (!noProxy) {
|
||||
return false;
|
||||
}
|
||||
// Determine the request port
|
||||
let reqPort;
|
||||
if (reqUrl.port) {
|
||||
reqPort = Number(reqUrl.port);
|
||||
}
|
||||
else if (reqUrl.protocol === 'http:') {
|
||||
reqPort = 80;
|
||||
}
|
||||
else if (reqUrl.protocol === 'https:') {
|
||||
reqPort = 443;
|
||||
}
|
||||
// Format the request hostname and hostname with port
|
||||
let upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
||||
if (typeof reqPort === 'number') {
|
||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||
}
|
||||
// Compare request host against noproxy
|
||||
for (let upperNoProxyItem of noProxy
|
||||
.split(',')
|
||||
.map(x => x.trim().toUpperCase())
|
||||
.filter(x => x)) {
|
||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.checkBypass = checkBypass;
|
||||
12
node_modules/@actions/http-client/RELEASES.md
generated
vendored
12
node_modules/@actions/http-client/RELEASES.md
generated
vendored
@@ -1,5 +1,15 @@
|
||||
## Releases
|
||||
|
||||
## 1.0.10
|
||||
|
||||
Contains a bug fix where proxy is defined without a user and password. see [PR here](https://github.com/actions/http-client/pull/42)
|
||||
|
||||
## 1.0.9
|
||||
Throw HttpClientError instead of a generic Error from the \<verb>Json() helper methods when the server responds with a non-successful status code.
|
||||
|
||||
## 1.0.8
|
||||
Fixed security issue where a redirect (e.g. 302) to another domain would pass headers. The fix was to strip the authorization header if the hostname was different. More [details in PR #27](https://github.com/actions/http-client/pull/27)
|
||||
|
||||
## 1.0.7
|
||||
Update NPM dependencies and add 429 to the list of HttpCodes
|
||||
|
||||
@@ -13,4 +23,4 @@ Adds \<verb>Json() helper methods for json over http scenarios.
|
||||
Started to add \<verb>Json() helper methods. Do not use this release for that. Use >= 1.0.5 since there was an issue with types.
|
||||
|
||||
## 1.0.1 to 1.0.3
|
||||
Adds proxy support.
|
||||
Adds proxy support.
|
||||
|
||||
5
node_modules/@actions/http-client/index.d.ts
generated
vendored
5
node_modules/@actions/http-client/index.d.ts
generated
vendored
@@ -42,6 +42,11 @@ export declare enum MediaTypes {
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
export declare function getProxyUrl(serverUrl: string): string;
|
||||
export declare class HttpClientError extends Error {
|
||||
constructor(message: string, statusCode: number);
|
||||
statusCode: number;
|
||||
result?: any;
|
||||
}
|
||||
export declare class HttpClientResponse implements ifm.IHttpClientResponse {
|
||||
constructor(message: http.IncomingMessage);
|
||||
message: http.IncomingMessage;
|
||||
|
||||
32
node_modules/@actions/http-client/index.js
generated
vendored
32
node_modules/@actions/http-client/index.js
generated
vendored
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const url = require("url");
|
||||
const http = require("http");
|
||||
const https = require("https");
|
||||
const pm = require("./proxy");
|
||||
@@ -49,7 +48,7 @@ var MediaTypes;
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
function getProxyUrl(serverUrl) {
|
||||
let proxyUrl = pm.getProxyUrl(url.parse(serverUrl));
|
||||
let proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||
return proxyUrl ? proxyUrl.href : '';
|
||||
}
|
||||
exports.getProxyUrl = getProxyUrl;
|
||||
@@ -68,6 +67,15 @@ const HttpResponseRetryCodes = [
|
||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||
const ExponentialBackoffCeiling = 10;
|
||||
const ExponentialBackoffTimeSlice = 5;
|
||||
class HttpClientError extends Error {
|
||||
constructor(message, statusCode) {
|
||||
super(message);
|
||||
this.name = 'HttpClientError';
|
||||
this.statusCode = statusCode;
|
||||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
||||
}
|
||||
}
|
||||
exports.HttpClientError = HttpClientError;
|
||||
class HttpClientResponse {
|
||||
constructor(message) {
|
||||
this.message = message;
|
||||
@@ -86,7 +94,7 @@ class HttpClientResponse {
|
||||
}
|
||||
exports.HttpClientResponse = HttpClientResponse;
|
||||
function isHttps(requestUrl) {
|
||||
let parsedUrl = url.parse(requestUrl);
|
||||
let parsedUrl = new URL(requestUrl);
|
||||
return parsedUrl.protocol === 'https:';
|
||||
}
|
||||
exports.isHttps = isHttps;
|
||||
@@ -191,7 +199,7 @@ class HttpClient {
|
||||
if (this._disposed) {
|
||||
throw new Error('Client has already been disposed.');
|
||||
}
|
||||
let parsedUrl = url.parse(requestUrl);
|
||||
let parsedUrl = new URL(requestUrl);
|
||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||
// Only perform retries on reads since writes may not be idempotent.
|
||||
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
|
||||
@@ -230,7 +238,7 @@ class HttpClient {
|
||||
// if there's no location to redirect to, we won't
|
||||
break;
|
||||
}
|
||||
let parsedRedirectUrl = url.parse(redirectUrl);
|
||||
let parsedRedirectUrl = new URL(redirectUrl);
|
||||
if (parsedUrl.protocol == 'https:' &&
|
||||
parsedUrl.protocol != parsedRedirectUrl.protocol &&
|
||||
!this._allowRedirectDowngrade) {
|
||||
@@ -346,7 +354,7 @@ class HttpClient {
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
getAgent(serverUrl) {
|
||||
let parsedUrl = url.parse(serverUrl);
|
||||
let parsedUrl = new URL(serverUrl);
|
||||
return this._getAgent(parsedUrl);
|
||||
}
|
||||
_prepareRequest(method, requestUrl, headers) {
|
||||
@@ -419,7 +427,9 @@ class HttpClient {
|
||||
maxSockets: maxSockets,
|
||||
keepAlive: this._keepAlive,
|
||||
proxy: {
|
||||
proxyAuth: proxyUrl.auth,
|
||||
...((proxyUrl.username || proxyUrl.password) && {
|
||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||
}),
|
||||
host: proxyUrl.hostname,
|
||||
port: proxyUrl.port
|
||||
}
|
||||
@@ -514,12 +524,8 @@ class HttpClient {
|
||||
else {
|
||||
msg = 'Failed request: (' + statusCode + ')';
|
||||
}
|
||||
let err = new Error(msg);
|
||||
// attach statusCode and body obj (if available) to the error object
|
||||
err['statusCode'] = statusCode;
|
||||
if (response.result) {
|
||||
err['result'] = response.result;
|
||||
}
|
||||
let err = new HttpClientError(msg, statusCode);
|
||||
err.result = response.result;
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
|
||||
3
node_modules/@actions/http-client/interfaces.d.ts
generated
vendored
3
node_modules/@actions/http-client/interfaces.d.ts
generated
vendored
@@ -1,6 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import http = require('http');
|
||||
import url = require('url');
|
||||
export interface IHeaders {
|
||||
[key: string]: any;
|
||||
}
|
||||
@@ -27,7 +26,7 @@ export interface IHttpClientResponse {
|
||||
}
|
||||
export interface IRequestInfo {
|
||||
options: http.RequestOptions;
|
||||
parsedUrl: url.Url;
|
||||
parsedUrl: URL;
|
||||
httpModule: any;
|
||||
}
|
||||
export interface IRequestOptions {
|
||||
|
||||
2
node_modules/@actions/http-client/package.json
generated
vendored
2
node_modules/@actions/http-client/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@actions/http-client",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.11",
|
||||
"description": "Actions Http Client",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
6
node_modules/@actions/http-client/proxy.d.ts
generated
vendored
6
node_modules/@actions/http-client/proxy.d.ts
generated
vendored
@@ -1,4 +1,2 @@
|
||||
/// <reference types="node" />
|
||||
import * as url from 'url';
|
||||
export declare function getProxyUrl(reqUrl: url.Url): url.Url | undefined;
|
||||
export declare function checkBypass(reqUrl: url.Url): boolean;
|
||||
export declare function getProxyUrl(reqUrl: URL): URL | undefined;
|
||||
export declare function checkBypass(reqUrl: URL): boolean;
|
||||
|
||||
3
node_modules/@actions/http-client/proxy.js
generated
vendored
3
node_modules/@actions/http-client/proxy.js
generated
vendored
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const url = require("url");
|
||||
function getProxyUrl(reqUrl) {
|
||||
let usingSsl = reqUrl.protocol === 'https:';
|
||||
let proxyUrl;
|
||||
@@ -15,7 +14,7 @@ function getProxyUrl(reqUrl) {
|
||||
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||
}
|
||||
if (proxyVar) {
|
||||
proxyUrl = url.parse(proxyVar);
|
||||
proxyUrl = new URL(proxyVar);
|
||||
}
|
||||
return proxyUrl;
|
||||
}
|
||||
|
||||
47
node_modules/lodash.set/LICENSE
generated
vendored
Normal file
47
node_modules/lodash.set/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||
|
||||
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/lodash/lodash
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
Copyright and related rights for sample code are waived via CC0. Sample
|
||||
code is defined as all source code displayed within the prose of the
|
||||
documentation.
|
||||
|
||||
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
====
|
||||
|
||||
Files located in the node_modules and vendor directories are externally
|
||||
maintained libraries used by this software which have their own
|
||||
licenses; we recommend you read them, as their terms may differ from the
|
||||
terms above.
|
||||
18
node_modules/lodash.set/README.md
generated
vendored
Normal file
18
node_modules/lodash.set/README.md
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# lodash.set v4.3.2
|
||||
|
||||
The [lodash](https://lodash.com/) method `_.set` exported as a [Node.js](https://nodejs.org/) module.
|
||||
|
||||
## Installation
|
||||
|
||||
Using npm:
|
||||
```bash
|
||||
$ {sudo -H} npm i -g npm
|
||||
$ npm i --save lodash.set
|
||||
```
|
||||
|
||||
In Node.js:
|
||||
```js
|
||||
var set = require('lodash.set');
|
||||
```
|
||||
|
||||
See the [documentation](https://lodash.com/docs#set) or [package source](https://github.com/lodash/lodash/blob/4.3.2-npm-packages/lodash.set) for more details.
|
||||
990
node_modules/lodash.set/index.js
generated
vendored
Normal file
990
node_modules/lodash.set/index.js
generated
vendored
Normal file
@@ -0,0 +1,990 @@
|
||||
/**
|
||||
* lodash (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize exports="npm" -o ./`
|
||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||
* Released under MIT license <https://lodash.com/license>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
*/
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to stand-in for `undefined` hash values. */
|
||||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0,
|
||||
MAX_SAFE_INTEGER = 9007199254740991;
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var funcTag = '[object Function]',
|
||||
genTag = '[object GeneratorFunction]',
|
||||
symbolTag = '[object Symbol]';
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
||||
reIsPlainProp = /^\w*$/,
|
||||
reLeadingDot = /^\./,
|
||||
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||||
|
||||
/**
|
||||
* Used to match `RegExp`
|
||||
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
||||
*/
|
||||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||||
|
||||
/** Used to match backslashes in property paths. */
|
||||
var reEscapeChar = /\\(\\)?/g;
|
||||
|
||||
/** Used to detect host constructors (Safari). */
|
||||
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||||
|
||||
/** Used to detect unsigned integer values. */
|
||||
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
||||
|
||||
/** Detect free variable `self`. */
|
||||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||||
|
||||
/** Used as a reference to the global object. */
|
||||
var root = freeGlobal || freeSelf || Function('return this')();
|
||||
|
||||
/**
|
||||
* Gets the value at `key` of `object`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} [object] The object to query.
|
||||
* @param {string} key The key of the property to get.
|
||||
* @returns {*} Returns the property value.
|
||||
*/
|
||||
function getValue(object, key) {
|
||||
return object == null ? undefined : object[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a host object in IE < 9.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
||||
*/
|
||||
function isHostObject(value) {
|
||||
// Many host objects are `Object` objects that can coerce to strings
|
||||
// despite having improperly defined `toString` methods.
|
||||
var result = false;
|
||||
if (value != null && typeof value.toString != 'function') {
|
||||
try {
|
||||
result = !!(value + '');
|
||||
} catch (e) {}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype,
|
||||
funcProto = Function.prototype,
|
||||
objectProto = Object.prototype;
|
||||
|
||||
/** Used to detect overreaching core-js shims. */
|
||||
var coreJsData = root['__core-js_shared__'];
|
||||
|
||||
/** Used to detect methods masquerading as native. */
|
||||
var maskSrcKey = (function() {
|
||||
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
||||
return uid ? ('Symbol(src)_1.' + uid) : '';
|
||||
}());
|
||||
|
||||
/** Used to resolve the decompiled source of functions. */
|
||||
var funcToString = funcProto.toString;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/** Used to detect if a method is native. */
|
||||
var reIsNative = RegExp('^' +
|
||||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
||||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
||||
);
|
||||
|
||||
/** Built-in value references. */
|
||||
var Symbol = root.Symbol,
|
||||
splice = arrayProto.splice;
|
||||
|
||||
/* Built-in method references that are verified to be native. */
|
||||
var Map = getNative(root, 'Map'),
|
||||
nativeCreate = getNative(Object, 'create');
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
||||
|
||||
/**
|
||||
* Creates a hash object.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [entries] The key-value pairs to cache.
|
||||
*/
|
||||
function Hash(entries) {
|
||||
var index = -1,
|
||||
length = entries ? entries.length : 0;
|
||||
|
||||
this.clear();
|
||||
while (++index < length) {
|
||||
var entry = entries[index];
|
||||
this.set(entry[0], entry[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all key-value entries from the hash.
|
||||
*
|
||||
* @private
|
||||
* @name clear
|
||||
* @memberOf Hash
|
||||
*/
|
||||
function hashClear() {
|
||||
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes `key` and its value from the hash.
|
||||
*
|
||||
* @private
|
||||
* @name delete
|
||||
* @memberOf Hash
|
||||
* @param {Object} hash The hash to modify.
|
||||
* @param {string} key The key of the value to remove.
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
function hashDelete(key) {
|
||||
return this.has(key) && delete this.__data__[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hash value for `key`.
|
||||
*
|
||||
* @private
|
||||
* @name get
|
||||
* @memberOf Hash
|
||||
* @param {string} key The key of the value to get.
|
||||
* @returns {*} Returns the entry value.
|
||||
*/
|
||||
function hashGet(key) {
|
||||
var data = this.__data__;
|
||||
if (nativeCreate) {
|
||||
var result = data[key];
|
||||
return result === HASH_UNDEFINED ? undefined : result;
|
||||
}
|
||||
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a hash value for `key` exists.
|
||||
*
|
||||
* @private
|
||||
* @name has
|
||||
* @memberOf Hash
|
||||
* @param {string} key The key of the entry to check.
|
||||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||||
*/
|
||||
function hashHas(key) {
|
||||
var data = this.__data__;
|
||||
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the hash `key` to `value`.
|
||||
*
|
||||
* @private
|
||||
* @name set
|
||||
* @memberOf Hash
|
||||
* @param {string} key The key of the value to set.
|
||||
* @param {*} value The value to set.
|
||||
* @returns {Object} Returns the hash instance.
|
||||
*/
|
||||
function hashSet(key, value) {
|
||||
var data = this.__data__;
|
||||
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Add methods to `Hash`.
|
||||
Hash.prototype.clear = hashClear;
|
||||
Hash.prototype['delete'] = hashDelete;
|
||||
Hash.prototype.get = hashGet;
|
||||
Hash.prototype.has = hashHas;
|
||||
Hash.prototype.set = hashSet;
|
||||
|
||||
/**
|
||||
* Creates an list cache object.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [entries] The key-value pairs to cache.
|
||||
*/
|
||||
function ListCache(entries) {
|
||||
var index = -1,
|
||||
length = entries ? entries.length : 0;
|
||||
|
||||
this.clear();
|
||||
while (++index < length) {
|
||||
var entry = entries[index];
|
||||
this.set(entry[0], entry[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all key-value entries from the list cache.
|
||||
*
|
||||
* @private
|
||||
* @name clear
|
||||
* @memberOf ListCache
|
||||
*/
|
||||
function listCacheClear() {
|
||||
this.__data__ = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes `key` and its value from the list cache.
|
||||
*
|
||||
* @private
|
||||
* @name delete
|
||||
* @memberOf ListCache
|
||||
* @param {string} key The key of the value to remove.
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
function listCacheDelete(key) {
|
||||
var data = this.__data__,
|
||||
index = assocIndexOf(data, key);
|
||||
|
||||
if (index < 0) {
|
||||
return false;
|
||||
}
|
||||
var lastIndex = data.length - 1;
|
||||
if (index == lastIndex) {
|
||||
data.pop();
|
||||
} else {
|
||||
splice.call(data, index, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list cache value for `key`.
|
||||
*
|
||||
* @private
|
||||
* @name get
|
||||
* @memberOf ListCache
|
||||
* @param {string} key The key of the value to get.
|
||||
* @returns {*} Returns the entry value.
|
||||
*/
|
||||
function listCacheGet(key) {
|
||||
var data = this.__data__,
|
||||
index = assocIndexOf(data, key);
|
||||
|
||||
return index < 0 ? undefined : data[index][1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a list cache value for `key` exists.
|
||||
*
|
||||
* @private
|
||||
* @name has
|
||||
* @memberOf ListCache
|
||||
* @param {string} key The key of the entry to check.
|
||||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||||
*/
|
||||
function listCacheHas(key) {
|
||||
return assocIndexOf(this.__data__, key) > -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list cache `key` to `value`.
|
||||
*
|
||||
* @private
|
||||
* @name set
|
||||
* @memberOf ListCache
|
||||
* @param {string} key The key of the value to set.
|
||||
* @param {*} value The value to set.
|
||||
* @returns {Object} Returns the list cache instance.
|
||||
*/
|
||||
function listCacheSet(key, value) {
|
||||
var data = this.__data__,
|
||||
index = assocIndexOf(data, key);
|
||||
|
||||
if (index < 0) {
|
||||
data.push([key, value]);
|
||||
} else {
|
||||
data[index][1] = value;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// Add methods to `ListCache`.
|
||||
ListCache.prototype.clear = listCacheClear;
|
||||
ListCache.prototype['delete'] = listCacheDelete;
|
||||
ListCache.prototype.get = listCacheGet;
|
||||
ListCache.prototype.has = listCacheHas;
|
||||
ListCache.prototype.set = listCacheSet;
|
||||
|
||||
/**
|
||||
* Creates a map cache object to store key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [entries] The key-value pairs to cache.
|
||||
*/
|
||||
function MapCache(entries) {
|
||||
var index = -1,
|
||||
length = entries ? entries.length : 0;
|
||||
|
||||
this.clear();
|
||||
while (++index < length) {
|
||||
var entry = entries[index];
|
||||
this.set(entry[0], entry[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all key-value entries from the map.
|
||||
*
|
||||
* @private
|
||||
* @name clear
|
||||
* @memberOf MapCache
|
||||
*/
|
||||
function mapCacheClear() {
|
||||
this.__data__ = {
|
||||
'hash': new Hash,
|
||||
'map': new (Map || ListCache),
|
||||
'string': new Hash
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes `key` and its value from the map.
|
||||
*
|
||||
* @private
|
||||
* @name delete
|
||||
* @memberOf MapCache
|
||||
* @param {string} key The key of the value to remove.
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
function mapCacheDelete(key) {
|
||||
return getMapData(this, key)['delete'](key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map value for `key`.
|
||||
*
|
||||
* @private
|
||||
* @name get
|
||||
* @memberOf MapCache
|
||||
* @param {string} key The key of the value to get.
|
||||
* @returns {*} Returns the entry value.
|
||||
*/
|
||||
function mapCacheGet(key) {
|
||||
return getMapData(this, key).get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a map value for `key` exists.
|
||||
*
|
||||
* @private
|
||||
* @name has
|
||||
* @memberOf MapCache
|
||||
* @param {string} key The key of the entry to check.
|
||||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||||
*/
|
||||
function mapCacheHas(key) {
|
||||
return getMapData(this, key).has(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the map `key` to `value`.
|
||||
*
|
||||
* @private
|
||||
* @name set
|
||||
* @memberOf MapCache
|
||||
* @param {string} key The key of the value to set.
|
||||
* @param {*} value The value to set.
|
||||
* @returns {Object} Returns the map cache instance.
|
||||
*/
|
||||
function mapCacheSet(key, value) {
|
||||
getMapData(this, key).set(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Add methods to `MapCache`.
|
||||
MapCache.prototype.clear = mapCacheClear;
|
||||
MapCache.prototype['delete'] = mapCacheDelete;
|
||||
MapCache.prototype.get = mapCacheGet;
|
||||
MapCache.prototype.has = mapCacheHas;
|
||||
MapCache.prototype.set = mapCacheSet;
|
||||
|
||||
/**
|
||||
* Assigns `value` to `key` of `object` if the existing value is not equivalent
|
||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {string} key The key of the property to assign.
|
||||
* @param {*} value The value to assign.
|
||||
*/
|
||||
function assignValue(object, key, value) {
|
||||
var objValue = object[key];
|
||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||
(value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {*} key The key to search for.
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
function assocIndexOf(array, key) {
|
||||
var length = array.length;
|
||||
while (length--) {
|
||||
if (eq(array[length][0], key)) {
|
||||
return length;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isNative` without bad shim checks.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a native function,
|
||||
* else `false`.
|
||||
*/
|
||||
function baseIsNative(value) {
|
||||
if (!isObject(value) || isMasked(value)) {
|
||||
return false;
|
||||
}
|
||||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
||||
return pattern.test(toSource(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.set`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to set.
|
||||
* @param {*} value The value to set.
|
||||
* @param {Function} [customizer] The function to customize path creation.
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseSet(object, path, value, customizer) {
|
||||
if (!isObject(object)) {
|
||||
return object;
|
||||
}
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
lastIndex = length - 1,
|
||||
nested = object;
|
||||
|
||||
while (nested != null && ++index < length) {
|
||||
var key = toKey(path[index]),
|
||||
newValue = value;
|
||||
|
||||
if (index != lastIndex) {
|
||||
var objValue = nested[key];
|
||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||
if (newValue === undefined) {
|
||||
newValue = isObject(objValue)
|
||||
? objValue
|
||||
: (isIndex(path[index + 1]) ? [] : {});
|
||||
}
|
||||
}
|
||||
assignValue(nested, key, newValue);
|
||||
nested = nested[key];
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.toString` which doesn't convert nullish
|
||||
* values to empty strings.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {string} Returns the string.
|
||||
*/
|
||||
function baseToString(value) {
|
||||
// Exit early for strings to avoid a performance hit in some environments.
|
||||
if (typeof value == 'string') {
|
||||
return value;
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return symbolToString ? symbolToString.call(value) : '';
|
||||
}
|
||||
var result = (value + '');
|
||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts `value` to a path array if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the cast property path array.
|
||||
*/
|
||||
function castPath(value) {
|
||||
return isArray(value) ? value : stringToPath(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data for `map`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} map The map to query.
|
||||
* @param {string} key The reference key.
|
||||
* @returns {*} Returns the map data.
|
||||
*/
|
||||
function getMapData(map, key) {
|
||||
var data = map.__data__;
|
||||
return isKeyable(key)
|
||||
? data[typeof key == 'string' ? 'string' : 'hash']
|
||||
: data.map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the native function at `key` of `object`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @param {string} key The key of the method to get.
|
||||
* @returns {*} Returns the function if it's native, else `undefined`.
|
||||
*/
|
||||
function getNative(object, key) {
|
||||
var value = getValue(object, key);
|
||||
return baseIsNative(value) ? value : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a valid array-like index.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||
*/
|
||||
function isIndex(value, length) {
|
||||
length = length == null ? MAX_SAFE_INTEGER : length;
|
||||
return !!length &&
|
||||
(typeof value == 'number' || reIsUint.test(value)) &&
|
||||
(value > -1 && value % 1 == 0 && value < length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a property name and not a property path.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @param {Object} [object] The object to query keys on.
|
||||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
||||
*/
|
||||
function isKey(value, object) {
|
||||
if (isArray(value)) {
|
||||
return false;
|
||||
}
|
||||
var type = typeof value;
|
||||
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
||||
value == null || isSymbol(value)) {
|
||||
return true;
|
||||
}
|
||||
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||||
(object != null && value in Object(object));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is suitable for use as unique object key.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
||||
*/
|
||||
function isKeyable(value) {
|
||||
var type = typeof value;
|
||||
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
||||
? (value !== '__proto__')
|
||||
: (value === null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `func` has its source masked.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to check.
|
||||
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
||||
*/
|
||||
function isMasked(func) {
|
||||
return !!maskSrcKey && (maskSrcKey in func);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `string` to a property path array.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
var stringToPath = memoize(function(string) {
|
||||
string = toString(string);
|
||||
|
||||
var result = [];
|
||||
if (reLeadingDot.test(string)) {
|
||||
result.push('');
|
||||
}
|
||||
string.replace(rePropName, function(match, number, quote, string) {
|
||||
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
/**
|
||||
* Converts `value` to a string key if it's not a string or symbol.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {string|symbol} Returns the key.
|
||||
*/
|
||||
function toKey(value) {
|
||||
if (typeof value == 'string' || isSymbol(value)) {
|
||||
return value;
|
||||
}
|
||||
var result = (value + '');
|
||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `func` to its source code.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to process.
|
||||
* @returns {string} Returns the source code.
|
||||
*/
|
||||
function toSource(func) {
|
||||
if (func != null) {
|
||||
try {
|
||||
return funcToString.call(func);
|
||||
} catch (e) {}
|
||||
try {
|
||||
return (func + '');
|
||||
} catch (e) {}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that memoizes the result of `func`. If `resolver` is
|
||||
* provided, it determines the cache key for storing the result based on the
|
||||
* arguments provided to the memoized function. By default, the first argument
|
||||
* provided to the memoized function is used as the map cache key. The `func`
|
||||
* is invoked with the `this` binding of the memoized function.
|
||||
*
|
||||
* **Note:** The cache is exposed as the `cache` property on the memoized
|
||||
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
||||
* constructor with one whose instances implement the
|
||||
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
||||
* method interface of `delete`, `get`, `has`, and `set`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to have its output memoized.
|
||||
* @param {Function} [resolver] The function to resolve the cache key.
|
||||
* @returns {Function} Returns the new memoized function.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': 2 };
|
||||
* var other = { 'c': 3, 'd': 4 };
|
||||
*
|
||||
* var values = _.memoize(_.values);
|
||||
* values(object);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* values(other);
|
||||
* // => [3, 4]
|
||||
*
|
||||
* object.a = 2;
|
||||
* values(object);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* // Modify the result cache.
|
||||
* values.cache.set(object, ['a', 'b']);
|
||||
* values(object);
|
||||
* // => ['a', 'b']
|
||||
*
|
||||
* // Replace `_.memoize.Cache`.
|
||||
* _.memoize.Cache = WeakMap;
|
||||
*/
|
||||
function memoize(func, resolver) {
|
||||
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
var memoized = function() {
|
||||
var args = arguments,
|
||||
key = resolver ? resolver.apply(this, args) : args[0],
|
||||
cache = memoized.cache;
|
||||
|
||||
if (cache.has(key)) {
|
||||
return cache.get(key);
|
||||
}
|
||||
var result = func.apply(this, args);
|
||||
memoized.cache = cache.set(key, result);
|
||||
return result;
|
||||
};
|
||||
memoized.cache = new (memoize.Cache || MapCache);
|
||||
return memoized;
|
||||
}
|
||||
|
||||
// Assign cache to `_.memoize`.
|
||||
memoize.Cache = MapCache;
|
||||
|
||||
/**
|
||||
* Performs a
|
||||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* comparison between two values to determine if they are equivalent.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1 };
|
||||
* var other = { 'a': 1 };
|
||||
*
|
||||
* _.eq(object, object);
|
||||
* // => true
|
||||
*
|
||||
* _.eq(object, other);
|
||||
* // => false
|
||||
*
|
||||
* _.eq('a', 'a');
|
||||
* // => true
|
||||
*
|
||||
* _.eq('a', Object('a'));
|
||||
* // => false
|
||||
*
|
||||
* _.eq(NaN, NaN);
|
||||
* // => true
|
||||
*/
|
||||
function eq(value, other) {
|
||||
return value === other || (value !== value && other !== other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as an `Array` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isArray([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* _.isArray(document.body.children);
|
||||
* // => false
|
||||
*
|
||||
* _.isArray('abc');
|
||||
* // => false
|
||||
*
|
||||
* _.isArray(_.noop);
|
||||
* // => false
|
||||
*/
|
||||
var isArray = Array.isArray;
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `Function` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isFunction(_);
|
||||
* // => true
|
||||
*
|
||||
* _.isFunction(/abc/);
|
||||
* // => false
|
||||
*/
|
||||
function isFunction(value) {
|
||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
||||
var tag = isObject(value) ? objectToString.call(value) : '';
|
||||
return tag == funcTag || tag == genTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is the
|
||||
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
||||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isObject({});
|
||||
* // => true
|
||||
*
|
||||
* _.isObject([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* _.isObject(_.noop);
|
||||
* // => true
|
||||
*
|
||||
* _.isObject(null);
|
||||
* // => false
|
||||
*/
|
||||
function isObject(value) {
|
||||
var type = typeof value;
|
||||
return !!value && (type == 'object' || type == 'function');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
||||
* and has a `typeof` result of "object".
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isObjectLike({});
|
||||
* // => true
|
||||
*
|
||||
* _.isObjectLike([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* _.isObjectLike(_.noop);
|
||||
* // => false
|
||||
*
|
||||
* _.isObjectLike(null);
|
||||
* // => false
|
||||
*/
|
||||
function isObjectLike(value) {
|
||||
return !!value && typeof value == 'object';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `Symbol` primitive or object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isSymbol(Symbol.iterator);
|
||||
* // => true
|
||||
*
|
||||
* _.isSymbol('abc');
|
||||
* // => false
|
||||
*/
|
||||
function isSymbol(value) {
|
||||
return typeof value == 'symbol' ||
|
||||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `value` to a string. An empty string is returned for `null`
|
||||
* and `undefined` values. The sign of `-0` is preserved.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to process.
|
||||
* @returns {string} Returns the string.
|
||||
* @example
|
||||
*
|
||||
* _.toString(null);
|
||||
* // => ''
|
||||
*
|
||||
* _.toString(-0);
|
||||
* // => '-0'
|
||||
*
|
||||
* _.toString([1, 2, 3]);
|
||||
* // => '1,2,3'
|
||||
*/
|
||||
function toString(value) {
|
||||
return value == null ? '' : baseToString(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
|
||||
* it's created. Arrays are created for missing index properties while objects
|
||||
* are created for all other missing properties. Use `_.setWith` to customize
|
||||
* `path` creation.
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.7.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to set.
|
||||
* @param {*} value The value to set.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
*
|
||||
* _.set(object, 'a[0].b.c', 4);
|
||||
* console.log(object.a[0].b.c);
|
||||
* // => 4
|
||||
*
|
||||
* _.set(object, ['x', '0', 'y', 'z'], 5);
|
||||
* console.log(object.x[0].y.z);
|
||||
* // => 5
|
||||
*/
|
||||
function set(object, path, value) {
|
||||
return object == null ? object : baseSet(object, path, value);
|
||||
}
|
||||
|
||||
module.exports = set;
|
||||
19
node_modules/lodash.set/package.json
generated
vendored
Normal file
19
node_modules/lodash.set/package.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "lodash.set",
|
||||
"version": "4.3.2",
|
||||
"description": "The lodash method `_.set` exported as a module.",
|
||||
"homepage": "https://lodash.com/",
|
||||
"icon": "https://lodash.com/icon.svg",
|
||||
"license": "MIT",
|
||||
"keywords": "lodash-modularized, set",
|
||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"contributors": [
|
||||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)",
|
||||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
|
||||
],
|
||||
"repository": "lodash/lodash",
|
||||
"scripts": {
|
||||
"test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\""
|
||||
}
|
||||
}
|
||||
5
node_modules/nock/CHANGELOG.md
generated
vendored
5
node_modules/nock/CHANGELOG.md
generated
vendored
@@ -1,3 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
Nock’s changelog can be found directly in the [GitHub release notes](https://github.com/nock/nock/releases). These are automatically created by [semantic-release](https://github.com/semantic-release/semantic-release) based on their [commit message conventions](https://semantic-release.gitbook.io/semantic-release#commit-message-format).
|
||||
Nock’s changelog can be found directly in the [GitHub release notes](https://github.com/nock/nock/releases).
|
||||
These are automatically created by [semantic-release](https://github.com/semantic-release/semantic-release) based on their [commit message conventions](https://semantic-release.gitbook.io/semantic-release#commit-message-format).
|
||||
|
||||
Migration guides are available for major versions in the [migration guides directory](https://github.com/nock/nock/tree/main/migration_guides).
|
||||
|
||||
263
node_modules/nock/README.md
generated
vendored
263
node_modules/nock/README.md
generated
vendored
@@ -3,7 +3,6 @@
|
||||
[][npmjs]
|
||||
[][build]
|
||||

|
||||
[](https://greenkeeper.io/)
|
||||
[](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
@@ -43,10 +42,11 @@ For instance, if a module performs HTTP requests to a CouchDB server or makes HT
|
||||
- [Support for HTTP and HTTPS](#support-for-http-and-https)
|
||||
- [Non-standard ports](#non-standard-ports)
|
||||
- [Repeat response n times](#repeat-response-n-times)
|
||||
- [Delay the response body](#delay-the-response-body)
|
||||
- [Delay the response](#delay-the-response)
|
||||
- [Delay the connection](#delay-the-connection)
|
||||
- [Socket timeout](#socket-timeout)
|
||||
- [Delay the connection](#delay-the-connection)
|
||||
- [Technical Details](#technical-details)
|
||||
- [Delay the response body](#delay-the-response-body)
|
||||
- [Technical Details](#technical-details-1)
|
||||
- [Chaining](#chaining)
|
||||
- [Scope filtering](#scope-filtering)
|
||||
- [Conditional scope filtering](#conditional-scope-filtering)
|
||||
@@ -63,7 +63,6 @@ For instance, if a module performs HTTP requests to a CouchDB server or makes HT
|
||||
- [.pendingMocks()](#pendingmocks)
|
||||
- [.activeMocks()](#activemocks)
|
||||
- [.isActive()](#isactive)
|
||||
- [Logging](#logging)
|
||||
- [Restoring](#restoring)
|
||||
- [Activating](#activating)
|
||||
- [Turning Nock Off (experimental!)](#turning-nock-off-experimental)
|
||||
@@ -86,9 +85,10 @@ For instance, if a module performs HTTP requests to a CouchDB server or makes HT
|
||||
- [Usage](#usage-1)
|
||||
- [Options](#options-1)
|
||||
- [Example](#example)
|
||||
- [Modes](#modes)
|
||||
- [Modes](#modes)
|
||||
- [Common issues](#common-issues)
|
||||
- [Axios](#axios)
|
||||
- [Memory issues with Jest](#memory-issues-with-jest)
|
||||
- [Debugging](#debugging)
|
||||
- [Contributing](#contributing)
|
||||
- [Contributors](#contributors)
|
||||
@@ -260,9 +260,7 @@ nock('http://www.example.com')
|
||||
Nock understands query strings. Search parameters can be included as part of the path:
|
||||
|
||||
```js
|
||||
nock('http://example.com')
|
||||
.get('/users?foo=bar')
|
||||
.reply(200)
|
||||
nock('http://example.com').get('/users?foo=bar').reply(200)
|
||||
```
|
||||
|
||||
Instead of placing the entire URL, you can specify the query part as an object:
|
||||
@@ -294,10 +292,7 @@ A `URLSearchParams` instance can be provided.
|
||||
```js
|
||||
const params = new URLSearchParams({ foo: 'bar' })
|
||||
|
||||
nock('http://example.com')
|
||||
.get('/')
|
||||
.query(params)
|
||||
.reply(200)
|
||||
nock('http://example.com').get('/').query(params).reply(200)
|
||||
```
|
||||
|
||||
Nock supports passing a function to query. The function determines if the actual query matches or not.
|
||||
@@ -338,9 +333,7 @@ nock('http://example.com', { encodedQueryParams: true })
|
||||
You can specify the return status code for a path on the first argument of reply like this:
|
||||
|
||||
```js
|
||||
const scope = nock('http://myapp.iriscouch.com')
|
||||
.get('/users/1')
|
||||
.reply(404)
|
||||
const scope = nock('http://myapp.iriscouch.com').get('/users/1').reply(404)
|
||||
```
|
||||
|
||||
You can also specify the reply body as a string:
|
||||
@@ -354,13 +347,11 @@ const scope = nock('http://www.google.com')
|
||||
or as a JSON-encoded object:
|
||||
|
||||
```js
|
||||
const scope = nock('http://myapp.iriscouch.com')
|
||||
.get('/')
|
||||
.reply(200, {
|
||||
username: 'pgte',
|
||||
email: 'pedro.teixeira@gmail.com',
|
||||
_id: '4324243fsd',
|
||||
})
|
||||
const scope = nock('http://myapp.iriscouch.com').get('/').reply(200, {
|
||||
username: 'pgte',
|
||||
email: 'pedro.teixeira@gmail.com',
|
||||
_id: '4324243fsd',
|
||||
})
|
||||
```
|
||||
|
||||
or even as a file:
|
||||
@@ -384,7 +375,7 @@ const scope = nock('http://www.google.com')
|
||||
In Nock 11.x it was possible to invoke `.reply()` with a status code and a
|
||||
function that returns an array containing a status code and body. (The status
|
||||
code from the array would take precedence over the one passed directly to
|
||||
reply.) This is no longer allowed. In 12.x, either call `.reply()` with a
|
||||
reply.) This is no longer allowed. In Nock 12 and later, either call `.reply()` with a
|
||||
status code and a function that returns the body, or call it with a single
|
||||
argument: a function that returns an array containing both the status code and
|
||||
body.
|
||||
@@ -443,7 +434,7 @@ If you're using the reply callback style, you can access the original client req
|
||||
```js
|
||||
const scope = nock('http://www.google.com')
|
||||
.get('/cat-poems')
|
||||
.reply(function(uri, requestBody) {
|
||||
.reply(function (uri, requestBody) {
|
||||
console.log('path:', this.req.path)
|
||||
console.log('headers:', this.req.headers)
|
||||
// ...
|
||||
@@ -465,12 +456,10 @@ nock('http://www.google.com')
|
||||
JSON error responses are allowed too:
|
||||
|
||||
```js
|
||||
nock('http://www.google.com')
|
||||
.get('/cat-poems')
|
||||
.replyWithError({
|
||||
message: 'something awful happened',
|
||||
code: 'AWFUL_ERROR',
|
||||
})
|
||||
nock('http://www.google.com').get('/cat-poems').replyWithError({
|
||||
message: 'something awful happened',
|
||||
code: 'AWFUL_ERROR',
|
||||
})
|
||||
```
|
||||
|
||||
> Note: This will emit an `error` event on the `request` object, not the reply.
|
||||
@@ -584,7 +573,7 @@ const scope = nock('http://www.headdy.com')
|
||||
|
||||
#### Including Content-Length Header Automatically
|
||||
|
||||
When using `scope.reply()` to set a response body manually, you can have the
|
||||
When using `interceptor.reply()` to set a response body manually, you can have the
|
||||
`Content-Length` header calculated automatically.
|
||||
|
||||
```js
|
||||
@@ -644,61 +633,45 @@ You are able to specify a non-standard port like this:
|
||||
|
||||
```js
|
||||
const scope = nock('http://my.server.com:8081')
|
||||
...
|
||||
```
|
||||
|
||||
### Repeat response n times
|
||||
|
||||
You are able to specify the number of times to repeat the same response.
|
||||
|
||||
**NOTE:** When request times is more than the number you specified, you will get an error before cleaning this interceptor.
|
||||
|
||||
```js
|
||||
nock('http://zombo.com')
|
||||
.get('/')
|
||||
.times(4)
|
||||
.reply(200, 'Ok')
|
||||
nock('http://zombo.com').get('/').times(4).reply(200, 'Ok')
|
||||
|
||||
http.get('http://zombo.com/') // respond body "Ok"
|
||||
http.get('http://zombo.com/') // respond body "Ok"
|
||||
http.get('http://zombo.com/') // respond body "Ok"
|
||||
http.get('http://zombo.com/') // respond body "Ok"
|
||||
http.get('http://zombo.com/') // respond with zombo.com result
|
||||
|
||||
// This code will get an error with message:
|
||||
// Nock: No match for request
|
||||
http.get('http://zombo.com/')
|
||||
|
||||
// clean your interceptor
|
||||
nock.cleanAll()
|
||||
|
||||
http.get('http://zombo.com/') // real respond with zombo.com result
|
||||
```
|
||||
|
||||
Sugar syntax
|
||||
|
||||
```js
|
||||
nock('http://zombo.com')
|
||||
.get('/')
|
||||
.once()
|
||||
.reply(200, 'Ok')
|
||||
nock('http://zombo.com')
|
||||
.get('/')
|
||||
.twice()
|
||||
.reply(200, 'Ok')
|
||||
nock('http://zombo.com')
|
||||
.get('/')
|
||||
.thrice()
|
||||
.reply(200, 'Ok')
|
||||
nock('http://zombo.com').get('/').once().reply(200, 'Ok')
|
||||
nock('http://zombo.com').get('/').twice().reply(200, 'Ok')
|
||||
nock('http://zombo.com').get('/').thrice().reply(200, 'Ok')
|
||||
```
|
||||
|
||||
To repeat this response for as long as nock is active, use [.persist()](#persist).
|
||||
|
||||
### Delay the response body
|
||||
|
||||
You are able to specify the number of milliseconds that the response body should be delayed. Response header will be replied immediately.
|
||||
`delayBody(1000)` is equivalent to `delay({body: 1000})`.
|
||||
|
||||
```js
|
||||
nock('http://my.server.com')
|
||||
.get('/')
|
||||
.delayBody(2000) // 2 seconds
|
||||
.reply(200, '<html></html>')
|
||||
```
|
||||
|
||||
NOTE: the [`'response'`](http://nodejs.org/api/http.html#http_event_response) event will occur immediately, but the [IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage) will not emit its `'end'` event until after the delay.
|
||||
|
||||
### Delay the response
|
||||
|
||||
Nock can simulate response latency to allow you to test timeouts, race conditions, an other timing related scenarios.
|
||||
You are able to specify the number of milliseconds that your reply should be delayed.
|
||||
|
||||
```js
|
||||
@@ -708,53 +681,54 @@ nock('http://my.server.com')
|
||||
.reply(200, '<html></html>')
|
||||
```
|
||||
|
||||
`delay()` could also be used as
|
||||
`delay(1000)` is an alias for `delayConnection(1000).delayBody(0)`
|
||||
`delay({ head: 1000, body: 2000 })` is an alias for `delayConnection(1000).delayBody(2000)`
|
||||
Both of which are covered in detail below.
|
||||
|
||||
```
|
||||
delay({
|
||||
head: headDelayInMs,
|
||||
body: bodyDelayInMs
|
||||
})
|
||||
```
|
||||
#### Delay the connection
|
||||
|
||||
for example
|
||||
You are able to specify the number of milliseconds that your connection should be idle before it starts to receive the response.
|
||||
|
||||
To simulate a socket timeout, provide a larger value than the timeout setting on the request.
|
||||
|
||||
```js
|
||||
nock('http://my.server.com')
|
||||
.get('/')
|
||||
.delay({
|
||||
head: 2000, // header will be delayed for 2 seconds, i.e. the whole response will be delayed for 2 seconds.
|
||||
body: 3000, // body will be delayed for another 3 seconds after header is sent out.
|
||||
})
|
||||
.delayConnection(2000) // 2 seconds
|
||||
.reply(200, '<html></html>')
|
||||
|
||||
req = http.request('http://my.server.com', { timeout: 1000 })
|
||||
```
|
||||
|
||||
### Delay the connection
|
||||
Nock emits timeout events almost immediately by comparing the requested connection delay to the timeout parameter passed to `http.request()` or `http.ClientRequest#setTimeout()`.
|
||||
This allows you to test timeouts without using fake timers or slowing down your tests.
|
||||
If the client chooses to _not_ take an action (e.g. abort the request), the request and response will continue on as normal, after real clock time has passed.
|
||||
|
||||
`delayConnection(1000)` is equivalent to `delay({ head: 1000 })`.
|
||||
##### Technical Details
|
||||
|
||||
### Socket timeout
|
||||
Following the `'finish'` event being emitted by `ClientRequest`, Nock will wait for the next event loop iteration before checking if the request has been aborted.
|
||||
At this point, any connection delay value is compared against any request timeout setting and a [`'timeout'`](https://nodejs.org/api/http.html#http_event_timeout) is emitted when appropriate from the socket and the request objects.
|
||||
A Node timeout timer is then registered with any connection delay value to delay real time before checking again if the request has been aborted and the [`'response'`](http://nodejs.org/api/http.html#http_event_response) is emitted by the request.
|
||||
|
||||
You are able to specify the number of milliseconds that your connection should be idle, to simulate a socket timeout.
|
||||
A similar method, `.socketDelay()` was removed in version 13. It was thought that having two methods so subtlety similar was confusing.
|
||||
The discussion can be found at https://github.com/nock/nock/pull/1974.
|
||||
|
||||
#### Delay the response body
|
||||
|
||||
You are able to specify the number of milliseconds that the response body should be delayed.
|
||||
This is the time between the headers being received and the body starting to be received.
|
||||
|
||||
```js
|
||||
nock('http://my.server.com')
|
||||
.get('/')
|
||||
.socketDelay(2000) // 2 seconds
|
||||
.delayBody(2000) // 2 seconds
|
||||
.reply(200, '<html></html>')
|
||||
```
|
||||
|
||||
To test a request like the following:
|
||||
##### Technical Details
|
||||
|
||||
```js
|
||||
req = http.request('http://my.server.com', res => {
|
||||
...
|
||||
})
|
||||
req.setTimeout(1000, () => { req.abort() })
|
||||
req.end()
|
||||
```
|
||||
|
||||
NOTE: the timeout will be fired immediately, and will not leave the simulated connection idle for the specified period of time.
|
||||
Following the [`'response'`](http://nodejs.org/api/http.html#http_event_response) being emitted by `ClientRequest`,
|
||||
Nock will register a timeout timer with the body delay value to delay real time before the [IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage) emits its first `'data'` or the `'end'` event.
|
||||
|
||||
### Chaining
|
||||
|
||||
@@ -914,20 +888,14 @@ example.pendingMocks() // ["GET http://example.com:80/path"]
|
||||
// ...After a request to example.com/pathA:
|
||||
example.pendingMocks() // []
|
||||
|
||||
example
|
||||
.get('/pathB')
|
||||
.optionally()
|
||||
.reply(200)
|
||||
example.get('/pathB').optionally().reply(200)
|
||||
example.pendingMocks() // []
|
||||
|
||||
// You can also pass a boolean argument to `optionally()`. This
|
||||
// is useful if you want to conditionally make a mocked request
|
||||
// optional.
|
||||
const getMock = optional =>
|
||||
example
|
||||
.get('/pathC')
|
||||
.optionally(optional)
|
||||
.reply(200)
|
||||
example.get('/pathC').optionally(optional).reply(200)
|
||||
|
||||
getMock(true)
|
||||
example.pendingMocks() // []
|
||||
@@ -977,9 +945,7 @@ setTimeout(() => {
|
||||
You can call `isDone()` on a single expectation to determine if the expectation was met:
|
||||
|
||||
```js
|
||||
const scope = nock('http://google.com')
|
||||
.get('/')
|
||||
.reply(200)
|
||||
const scope = nock('http://google.com').get('/').reply(200)
|
||||
|
||||
scope.isDone() // will return false
|
||||
```
|
||||
@@ -1022,10 +988,7 @@ Note that while a persisted scope will always intercept the requests, it is cons
|
||||
If you want to stop persisting an individual persisted mock you can call `persist(false)`:
|
||||
|
||||
```js
|
||||
const scope = nock('http://example.com')
|
||||
.persist()
|
||||
.get('/')
|
||||
.reply(200, 'ok')
|
||||
const scope = nock('http://example.com').persist().get('/').reply(200, 'ok')
|
||||
|
||||
// Do some tests ...
|
||||
|
||||
@@ -1081,16 +1044,6 @@ if (!nock.isActive()) {
|
||||
}
|
||||
```
|
||||
|
||||
## Logging
|
||||
|
||||
Nock can log matches if you pass in a log function like this:
|
||||
|
||||
```js
|
||||
const scope = nock('http://google.com')
|
||||
.log(console.log)
|
||||
...
|
||||
```
|
||||
|
||||
## Restoring
|
||||
|
||||
You can restore the HTTP interceptor to the normal unmocked behaviour by calling:
|
||||
@@ -1119,7 +1072,7 @@ You can bypass Nock completely by setting the `NOCK_OFF` environment variable to
|
||||
|
||||
This way you can have your tests hit the real servers just by switching on this environment variable.
|
||||
|
||||
```js
|
||||
```shell script
|
||||
$ NOCK_OFF=true node my_test.js
|
||||
```
|
||||
|
||||
@@ -1260,7 +1213,7 @@ If you save this as a JSON file, you can load them directly through `nock.load(p
|
||||
|
||||
```js
|
||||
nocks = nock.load(pathToJson)
|
||||
nocks.forEach(function(nock) {
|
||||
nocks.forEach(function (nock) {
|
||||
nock.filteringRequestBody = (body, aRecordedBody) => {
|
||||
if (typeof body !== 'string' || typeof aRecordedBody !== 'string') {
|
||||
return body
|
||||
@@ -1269,9 +1222,12 @@ nocks.forEach(function(nock) {
|
||||
const recordedBodyResult = /timestamp:([0-9]+)/.exec(aRecordedBody)
|
||||
if (recordedBodyResult) {
|
||||
const recordedTimestamp = recordedBodyResult[1]
|
||||
return body.replace(/(timestamp):([0-9]+)/g, function(match, key, value) {
|
||||
return key + ':' + recordedTimestamp
|
||||
})
|
||||
return body.replace(
|
||||
/(timestamp):([0-9]+)/g,
|
||||
function (match, key, value) {
|
||||
return key + ':' + recordedTimestamp
|
||||
}
|
||||
)
|
||||
} else {
|
||||
return body
|
||||
}
|
||||
@@ -1355,10 +1311,10 @@ nock.removeInterceptor({
|
||||
|
||||
```js
|
||||
nock.removeInterceptor({
|
||||
hostname : 'localhost',
|
||||
path : '/login'
|
||||
method: 'POST'
|
||||
proto : 'https'
|
||||
hostname: 'localhost',
|
||||
path: '/login',
|
||||
method: 'POST',
|
||||
proto: 'https',
|
||||
})
|
||||
```
|
||||
|
||||
@@ -1425,7 +1381,7 @@ nockBack('zomboFixture.json', nockDone => {
|
||||
nockDone()
|
||||
|
||||
// usage of the created fixture
|
||||
nockBack('zomboFixture.json', function(nockDone) {
|
||||
nockBack('zomboFixture.json', function (nockDone) {
|
||||
http.get('http://zombo.com/').end() // respond body "Ok"
|
||||
|
||||
this.assertScopesFinished() //throws an exception if all nocks in fixture were not satisfied
|
||||
@@ -1439,12 +1395,10 @@ nockBack('zomboFixture.json', nockDone => {
|
||||
|
||||
If your tests are using promises then use `nockBack` like this:
|
||||
|
||||
```
|
||||
return nockBack('promisedFixture.json')
|
||||
.then(({ nockDone, context }) => {
|
||||
// do your tests returning a promise and chain it with
|
||||
// `.then(nockDone)`
|
||||
})
|
||||
```js
|
||||
return nockBack('promisedFixture.json').then(({ nockDone, context }) => {
|
||||
// do your tests returning a promise and chain it with
|
||||
// `.then(nockDone)`
|
||||
})
|
||||
```
|
||||
|
||||
@@ -1462,7 +1416,7 @@ As an optional second parameter you can pass the following options
|
||||
```js
|
||||
function prepareScope(scope) {
|
||||
scope.filteringRequestBody = (body, aRecordedBody) => {
|
||||
if (typeof(body) !== 'string' || typeof(aRecordedBody) !== 'string') {
|
||||
if (typeof body !== 'string' || typeof aRecordedBody !== 'string') {
|
||||
return body
|
||||
}
|
||||
|
||||
@@ -1479,15 +1433,15 @@ function prepareScope(scope) {
|
||||
}
|
||||
}
|
||||
|
||||
nockBack('zomboFixture.json', { before: prepareScope }, nockDone => {
|
||||
request.get('http://zombo.com', function(err, res, body) {
|
||||
nockBack('exampleFixture.json', { before: prepareScope }, nockDone => {
|
||||
request.get('http://example.com', function (err, res, body) {
|
||||
// do your tests
|
||||
nockDone()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
#### Modes
|
||||
### Modes
|
||||
|
||||
To set the mode call `nockBack.setMode(mode)` or run the tests with the `NOCK_BACK_MODE` environment variable set before loading nock. If the mode needs to be changed programmatically, the following is valid: `nockBack.setMode(nockBack.currentMode)`
|
||||
|
||||
@@ -1512,14 +1466,14 @@ The same is true for `.replyWithError()`.
|
||||
|
||||
Adding `{ retry: 0 }` to the `got` invocations will disable retrying, e.g.:
|
||||
|
||||
```
|
||||
await got("http://example.test/", { retry: 0 })
|
||||
```js
|
||||
await got('http://example.test/', { retry: 0 })
|
||||
```
|
||||
|
||||
If you need to do this in all your tests, you can create a module
|
||||
`got_client.js` which exports a custom got instance:
|
||||
|
||||
```
|
||||
```js
|
||||
const got = require('got')
|
||||
|
||||
module.exports = got.extend({ retry: 0 })
|
||||
@@ -1566,12 +1520,37 @@ test('can fetch test response', async t => {
|
||||
|
||||
[axios]: https://github.com/axios/axios
|
||||
|
||||
### Memory issues with Jest
|
||||
|
||||
Memory issues can be avoided by calling [`nock.restore()`](#restoring) after each test suite.
|
||||
One of the core principles of [Jest](https://jestjs.io/) is that it runs tests in isolation.
|
||||
It does this by manipulating the modules cache of Node in a way that conflicts with how Nock monkey patches the builtin `http` and `https` modules.
|
||||
[Related issue with more details](https://github.com/nock/nock/issues/1817).
|
||||
|
||||
## Debugging
|
||||
|
||||
Nock uses [`debug`](https://github.com/visionmedia/debug), so just run with environmental variable `DEBUG` set to `nock.*`.
|
||||
|
||||
```console
|
||||
user@local$ DEBUG=nock.* node my_test.js
|
||||
```
|
||||
|
||||
Each step in the matching process is logged this way and can be useful when determining why a request was not intercepted by Nock.
|
||||
|
||||
For example the following shows that matching failed because the request had an extra search parameter.
|
||||
|
||||
```js
|
||||
$ DEBUG=nock.* node my_test.js
|
||||
nock('http://example.com').get('/').query({ foo: 'bar' }).reply()
|
||||
|
||||
await got('http://example.com/?foo=bar&baz=foz')
|
||||
```
|
||||
|
||||
```console
|
||||
user@local$ DEBUG=nock.scope:example.com node my_test.js
|
||||
...
|
||||
nock.scope:example.com Interceptor queries: {"foo":"bar"} +1ms
|
||||
nock.scope:example.com Request queries: {"foo":"bar","baz":"foz"} +0ms
|
||||
nock.scope:example.com query matching failed +0ms
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
30
node_modules/nock/lib/back.js
generated
vendored
30
node_modules/nock/lib/back.js
generated
vendored
@@ -73,7 +73,7 @@ function Back(fixtureName, options, nockedFn) {
|
||||
const fixture = path.join(Back.fixtures, fixtureName)
|
||||
const context = _mode.start(fixture, options)
|
||||
|
||||
const nockDone = function() {
|
||||
const nockDone = function () {
|
||||
_mode.finish(fixture, options, context)
|
||||
}
|
||||
|
||||
@@ -92,24 +92,24 @@ function Back(fixtureName, options, nockedFn) {
|
||||
*******************************************************************************/
|
||||
|
||||
const wild = {
|
||||
setup: function() {
|
||||
setup: function () {
|
||||
cleanAll()
|
||||
recorder.restore()
|
||||
activate()
|
||||
enableNetConnect()
|
||||
},
|
||||
|
||||
start: function() {
|
||||
start: function () {
|
||||
return load() // don't load anything but get correct context
|
||||
},
|
||||
|
||||
finish: function() {
|
||||
finish: function () {
|
||||
// nothing to do
|
||||
},
|
||||
}
|
||||
|
||||
const dryrun = {
|
||||
setup: function() {
|
||||
setup: function () {
|
||||
recorder.restore()
|
||||
cleanAll()
|
||||
activate()
|
||||
@@ -117,20 +117,20 @@ const dryrun = {
|
||||
enableNetConnect()
|
||||
},
|
||||
|
||||
start: function(fixture, options) {
|
||||
start: function (fixture, options) {
|
||||
const contexts = load(fixture, options)
|
||||
|
||||
enableNetConnect()
|
||||
return contexts
|
||||
},
|
||||
|
||||
finish: function() {
|
||||
finish: function () {
|
||||
// nothing to do
|
||||
},
|
||||
}
|
||||
|
||||
const record = {
|
||||
setup: function() {
|
||||
setup: function () {
|
||||
recorder.restore()
|
||||
recorder.clear()
|
||||
cleanAll()
|
||||
@@ -138,7 +138,7 @@ const record = {
|
||||
disableNetConnect()
|
||||
},
|
||||
|
||||
start: function(fixture, options) {
|
||||
start: function (fixture, options) {
|
||||
if (!fs) {
|
||||
throw new Error('no fs')
|
||||
}
|
||||
@@ -157,7 +157,7 @@ const record = {
|
||||
return context
|
||||
},
|
||||
|
||||
finish: function(fixture, options, context) {
|
||||
finish: function (fixture, options, context) {
|
||||
if (context.isRecording) {
|
||||
let outputs = recorder.outputs()
|
||||
|
||||
@@ -176,7 +176,7 @@ const record = {
|
||||
}
|
||||
|
||||
const lockdown = {
|
||||
setup: function() {
|
||||
setup: function () {
|
||||
recorder.restore()
|
||||
recorder.clear()
|
||||
cleanAll()
|
||||
@@ -184,11 +184,11 @@ const lockdown = {
|
||||
disableNetConnect()
|
||||
},
|
||||
|
||||
start: function(fixture, options) {
|
||||
start: function (fixture, options) {
|
||||
return load(fixture, options)
|
||||
},
|
||||
|
||||
finish: function() {
|
||||
finish: function () {
|
||||
// nothing to do
|
||||
},
|
||||
}
|
||||
@@ -196,7 +196,7 @@ const lockdown = {
|
||||
function load(fixture, options) {
|
||||
const context = {
|
||||
scopes: [],
|
||||
assertScopesFinished: function() {
|
||||
assertScopesFinished: function () {
|
||||
assertScopes(this.scopes, fixture)
|
||||
},
|
||||
}
|
||||
@@ -261,7 +261,7 @@ const Modes = {
|
||||
lockdown, // use recorded nocks, disables all http calls even when not nocked, doesnt record
|
||||
}
|
||||
|
||||
Back.setMode = function(mode) {
|
||||
Back.setMode = function (mode) {
|
||||
if (!(mode in Modes)) {
|
||||
throw new Error(`Unknown mode: ${mode}`)
|
||||
}
|
||||
|
||||
203
node_modules/nock/lib/common.js
generated
vendored
203
node_modules/nock/lib/common.js
generated
vendored
@@ -1,9 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
const _ = require('lodash')
|
||||
const debug = require('debug')('nock.common')
|
||||
const url = require('url')
|
||||
const set = require('lodash.set')
|
||||
const timers = require('timers')
|
||||
const url = require('url')
|
||||
const util = require('util')
|
||||
|
||||
/**
|
||||
* Normalizes the request options so that it always has `host` property.
|
||||
@@ -28,7 +29,7 @@ function normalizeRequestOptions(options) {
|
||||
debug('options.host in the end: %j', options.host)
|
||||
|
||||
/// lowercase host names
|
||||
;['hostname', 'host'].forEach(function(attr) {
|
||||
;['hostname', 'host'].forEach(function (attr) {
|
||||
if (options[attr]) {
|
||||
options[attr] = options[attr].toLowerCase()
|
||||
}
|
||||
@@ -66,7 +67,7 @@ let requestOverrides = {}
|
||||
*/
|
||||
function overrideRequests(newRequest) {
|
||||
debug('overriding requests')
|
||||
;['http', 'https'].forEach(function(proto) {
|
||||
;['http', 'https'].forEach(function (proto) {
|
||||
debug('- overriding request for', proto)
|
||||
|
||||
const moduleName = proto // 1 to 1 match of protocol and module is fortunate :)
|
||||
@@ -90,7 +91,7 @@ function overrideRequests(newRequest) {
|
||||
get: overriddenGet,
|
||||
}
|
||||
// https://nodejs.org/api/http.html#http_http_request_url_options_callback
|
||||
module.request = function(input, options, callback) {
|
||||
module.request = function (input, options, callback) {
|
||||
return newRequest(proto, overriddenRequest.bind(module), [
|
||||
input,
|
||||
options,
|
||||
@@ -98,7 +99,7 @@ function overrideRequests(newRequest) {
|
||||
])
|
||||
}
|
||||
// https://nodejs.org/api/http.html#http_http_get_options_callback
|
||||
module.get = function(input, options, callback) {
|
||||
module.get = function (input, options, callback) {
|
||||
const req = newRequest(proto, overriddenGet.bind(module), [
|
||||
input,
|
||||
options,
|
||||
@@ -179,7 +180,7 @@ function isContentEncoded(headers) {
|
||||
|
||||
function contentEncoding(headers, encoder) {
|
||||
const contentEncoding = headers['content-encoding']
|
||||
return contentEncoding === encoder
|
||||
return contentEncoding !== undefined && contentEncoding.toString() === encoder
|
||||
}
|
||||
|
||||
function isJSONContent(headers) {
|
||||
@@ -194,7 +195,7 @@ function isJSONContent(headers) {
|
||||
* Duplicates throw an error.
|
||||
*/
|
||||
function headersFieldNamesToLowerCase(headers) {
|
||||
if (!_.isPlainObject(headers)) {
|
||||
if (!isPlainObject(headers)) {
|
||||
throw Error('Headers must be provided as an object')
|
||||
}
|
||||
|
||||
@@ -243,11 +244,11 @@ function headersInputToRawArray(headers) {
|
||||
}
|
||||
|
||||
// [].concat(...) is used instead of Array.flat until v11 is the minimum Node version
|
||||
if (_.isMap(headers)) {
|
||||
if (util.types.isMap(headers)) {
|
||||
return [].concat(...Array.from(headers, ([k, v]) => [k.toString(), v]))
|
||||
}
|
||||
|
||||
if (_.isPlainObject(headers)) {
|
||||
if (isPlainObject(headers)) {
|
||||
return [].concat(...Object.entries(headers))
|
||||
}
|
||||
|
||||
@@ -359,7 +360,7 @@ function addHeaderLine(headers, name, value) {
|
||||
* @fieldName {String} field name - string with the case-insensitive field name
|
||||
*/
|
||||
function deleteHeadersField(headers, fieldNameToDelete) {
|
||||
if (!_.isPlainObject(headers)) {
|
||||
if (!isPlainObject(headers)) {
|
||||
throw Error('headers must be an object')
|
||||
}
|
||||
|
||||
@@ -406,11 +407,8 @@ function percentDecode(str) {
|
||||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
|
||||
*/
|
||||
function percentEncode(str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
||||
return `%${c
|
||||
.charCodeAt(0)
|
||||
.toString(16)
|
||||
.toUpperCase()}`
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
||||
return `%${c.charCodeAt(0).toString(16).toUpperCase()}`
|
||||
})
|
||||
}
|
||||
|
||||
@@ -418,9 +416,12 @@ function matchStringOrRegexp(target, pattern) {
|
||||
const targetStr =
|
||||
target === undefined || target === null ? '' : String(target)
|
||||
|
||||
return pattern instanceof RegExp
|
||||
? pattern.test(targetStr)
|
||||
: targetStr === String(pattern)
|
||||
if (pattern instanceof RegExp) {
|
||||
// if the regexp happens to have a global flag, we want to ensure we test the entire target
|
||||
pattern.lastIndex = 0
|
||||
return pattern.test(targetStr)
|
||||
}
|
||||
return targetStr === String(pattern)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,13 +453,13 @@ function formatQueryValue(key, value, stringFormattingFn) {
|
||||
case value instanceof RegExp:
|
||||
break
|
||||
case Array.isArray(value): {
|
||||
value = value.map(function(val, idx) {
|
||||
value = value.map(function (val, idx) {
|
||||
return formatQueryValue(idx, val, stringFormattingFn)[1]
|
||||
})
|
||||
break
|
||||
}
|
||||
case typeof value === 'object': {
|
||||
value = Object.entries(value).reduce(function(acc, [subKey, subVal]) {
|
||||
value = Object.entries(value).reduce(function (acc, [subKey, subVal]) {
|
||||
const subPair = formatQueryValue(subKey, subVal, stringFormattingFn)
|
||||
acc[subPair[0]] = subPair[1]
|
||||
|
||||
@@ -550,8 +551,15 @@ function urlToOptions(url) {
|
||||
* - The expected data can use regexp to compare values
|
||||
* - JSON path notation and nested objects are considered equal
|
||||
*/
|
||||
const dataEqual = (expected, actual) =>
|
||||
deepEqual(expand(expected), expand(actual))
|
||||
const dataEqual = (expected, actual) => {
|
||||
if (isPlainObject(expected)) {
|
||||
expected = expand(expected)
|
||||
}
|
||||
if (isPlainObject(actual)) {
|
||||
actual = expand(actual)
|
||||
}
|
||||
return deepEqual(expected, actual)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts flat objects whose keys use JSON path notation to nested objects.
|
||||
@@ -562,7 +570,7 @@ const dataEqual = (expected, actual) =>
|
||||
* { 'foo[bar][0]': 'baz' } -> { foo: { bar: [ 'baz' ] } }
|
||||
*/
|
||||
const expand = input =>
|
||||
Object.entries(input).reduce((acc, [k, v]) => _.set(acc, k, v), {})
|
||||
Object.entries(input).reduce((acc, [k, v]) => set(acc, k, v), {})
|
||||
|
||||
/**
|
||||
* Performs a recursive strict comparison between two values.
|
||||
@@ -575,22 +583,70 @@ function deepEqual(expected, actual) {
|
||||
return expected.test(actual)
|
||||
}
|
||||
|
||||
if (Array.isArray(expected) || _.isPlainObject(expected)) {
|
||||
if (actual === undefined) {
|
||||
if (Array.isArray(expected) && Array.isArray(actual)) {
|
||||
if (expected.length !== actual.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
const expKeys = Object.keys(expected)
|
||||
if (expKeys.length !== Object.keys(actual).length) {
|
||||
return false
|
||||
}
|
||||
return expected.every((expVal, idx) => deepEqual(expVal, actual[idx]))
|
||||
}
|
||||
|
||||
return expKeys.every(key => deepEqual(expected[key], actual[key]))
|
||||
if (isPlainObject(expected) && isPlainObject(actual)) {
|
||||
const allKeys = Array.from(
|
||||
new Set(Object.keys(expected).concat(Object.keys(actual)))
|
||||
)
|
||||
|
||||
return allKeys.every(key => deepEqual(expected[key], actual[key]))
|
||||
}
|
||||
|
||||
return expected === actual
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a plain object, that is, an object created by the
|
||||
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
||||
* https://github.com/lodash/lodash/blob/588bf3e20db0ae039a822a14a8fa238c5b298e65/isPlainObject.js
|
||||
*
|
||||
* @param {*} value The value to check.
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isPlainObject(value) {
|
||||
const isObjectLike = typeof value === 'object' && value !== null
|
||||
const tag = Object.prototype.toString.call(value)
|
||||
if (!isObjectLike || tag !== '[object Object]') {
|
||||
return false
|
||||
}
|
||||
if (Object.getPrototypeOf(value) === null) {
|
||||
return true
|
||||
}
|
||||
let proto = value
|
||||
while (Object.getPrototypeOf(proto) !== null) {
|
||||
proto = Object.getPrototypeOf(proto)
|
||||
}
|
||||
return Object.getPrototypeOf(value) === proto
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated
|
||||
* by running each own enumerable string keyed property of `object` thru
|
||||
* `iteratee`. (iteration order is not guaranteed)
|
||||
* The iteratee is invoked with three arguments: (value, key, object).
|
||||
* https://github.com/lodash/lodash/blob/588bf3e20db0ae039a822a14a8fa238c5b298e65/mapValue.js
|
||||
*
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} iteratee The function invoked per iteration.
|
||||
* @returns {Object} Returns the new mapped object.
|
||||
*/
|
||||
function mapValue(object, iteratee) {
|
||||
object = Object(object)
|
||||
const result = {}
|
||||
|
||||
Object.keys(object).forEach(key => {
|
||||
result[key] = iteratee(object[key], key, object)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
const timeouts = []
|
||||
const intervals = []
|
||||
const immediates = []
|
||||
@@ -617,29 +673,62 @@ function removeAllTimers() {
|
||||
clearTimer(clearImmediate, immediates)
|
||||
}
|
||||
|
||||
exports.normalizeClientRequestArgs = normalizeClientRequestArgs
|
||||
exports.normalizeRequestOptions = normalizeRequestOptions
|
||||
exports.normalizeOrigin = normalizeOrigin
|
||||
exports.isUtf8Representable = isUtf8Representable
|
||||
exports.overrideRequests = overrideRequests
|
||||
exports.restoreOverriddenRequests = restoreOverriddenRequests
|
||||
exports.stringifyRequest = stringifyRequest
|
||||
exports.isContentEncoded = isContentEncoded
|
||||
exports.contentEncoding = contentEncoding
|
||||
exports.isJSONContent = isJSONContent
|
||||
exports.headersFieldNamesToLowerCase = headersFieldNamesToLowerCase
|
||||
exports.headersFieldsArrayToLowerCase = headersFieldsArrayToLowerCase
|
||||
exports.headersArrayToObject = headersArrayToObject
|
||||
exports.headersInputToRawArray = headersInputToRawArray
|
||||
exports.deleteHeadersField = deleteHeadersField
|
||||
exports.forEachHeader = forEachHeader
|
||||
exports.percentEncode = percentEncode
|
||||
exports.percentDecode = percentDecode
|
||||
exports.matchStringOrRegexp = matchStringOrRegexp
|
||||
exports.formatQueryValue = formatQueryValue
|
||||
exports.isStream = isStream
|
||||
exports.dataEqual = dataEqual
|
||||
exports.setTimeout = setTimeout
|
||||
exports.setInterval = setInterval
|
||||
exports.setImmediate = setImmediate
|
||||
exports.removeAllTimers = removeAllTimers
|
||||
/**
|
||||
* Check if the Client Request has been cancelled.
|
||||
*
|
||||
* Until Node 14 is the minimum, we need to look at both flags to see if the request has been cancelled.
|
||||
* The two flags have the same purpose, but the Node maintainers are migrating from `abort(ed)` to
|
||||
* `destroy(ed)` terminology, to be more consistent with `stream.Writable`.
|
||||
* In Node 14.x+, Calling `abort()` will set both `aborted` and `destroyed` to true, however,
|
||||
* calling `destroy()` will only set `destroyed` to true.
|
||||
* Falling back on checking if the socket is destroyed to cover the case of Node <14.x where
|
||||
* `destroy()` is called, but `destroyed` is undefined.
|
||||
*
|
||||
* Node Client Request history:
|
||||
* - `request.abort()`: Added in: v0.3.8, Deprecated since: v14.1.0, v13.14.0
|
||||
* - `request.aborted`: Added in: v0.11.14, Became a boolean instead of a timestamp: v11.0.0, Not deprecated (yet)
|
||||
* - `request.destroy()`: Added in: v0.3.0
|
||||
* - `request.destroyed`: Added in: v14.1.0, v13.14.0
|
||||
*
|
||||
* @param {ClientRequest} req
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isRequestDestroyed(req) {
|
||||
return !!(
|
||||
req.destroyed === true ||
|
||||
req.aborted ||
|
||||
(req.socket && req.socket.destroyed)
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
contentEncoding,
|
||||
dataEqual,
|
||||
deleteHeadersField,
|
||||
forEachHeader,
|
||||
formatQueryValue,
|
||||
headersArrayToObject,
|
||||
headersFieldNamesToLowerCase,
|
||||
headersFieldsArrayToLowerCase,
|
||||
headersInputToRawArray,
|
||||
isContentEncoded,
|
||||
isJSONContent,
|
||||
isPlainObject,
|
||||
isRequestDestroyed,
|
||||
isStream,
|
||||
isUtf8Representable,
|
||||
mapValue,
|
||||
matchStringOrRegexp,
|
||||
normalizeClientRequestArgs,
|
||||
normalizeOrigin,
|
||||
normalizeRequestOptions,
|
||||
overrideRequests,
|
||||
percentDecode,
|
||||
percentEncode,
|
||||
removeAllTimers,
|
||||
restoreOverriddenRequests,
|
||||
setImmediate,
|
||||
setInterval,
|
||||
setTimeout,
|
||||
stringifyRequest,
|
||||
}
|
||||
|
||||
52
node_modules/nock/lib/delayed_body.js
generated
vendored
52
node_modules/nock/lib/delayed_body.js
generated
vendored
@@ -1,52 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Creates a stream which becomes the response body of the interceptor when a
|
||||
* delay is set. The stream outputs the intended body and EOF after the delay.
|
||||
*
|
||||
* @param {String|Buffer|Stream} body - the body to write/pipe out
|
||||
* @param {Integer} ms - The delay in milliseconds
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
const { Transform } = require('stream')
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = class DelayedBody extends Transform {
|
||||
constructor(ms, body) {
|
||||
super()
|
||||
|
||||
const self = this
|
||||
let data = ''
|
||||
let ended = false
|
||||
|
||||
if (common.isStream(body)) {
|
||||
body.on('data', function(chunk) {
|
||||
data += Buffer.isBuffer(chunk) ? chunk.toString() : chunk
|
||||
})
|
||||
|
||||
body.once('end', function() {
|
||||
ended = true
|
||||
})
|
||||
|
||||
body.resume()
|
||||
}
|
||||
|
||||
// TODO: This would be more readable if the stream case were moved into
|
||||
// the `if` statement above.
|
||||
common.setTimeout(function() {
|
||||
if (common.isStream(body) && !ended) {
|
||||
body.once('end', function() {
|
||||
self.end(data)
|
||||
})
|
||||
} else {
|
||||
self.end(data || body)
|
||||
}
|
||||
}, ms)
|
||||
}
|
||||
|
||||
_transform(chunk, encoding, cb) {
|
||||
this.push(chunk)
|
||||
process.nextTick(cb)
|
||||
}
|
||||
}
|
||||
16
node_modules/nock/lib/intercept.js
generated
vendored
16
node_modules/nock/lib/intercept.js
generated
vendored
@@ -121,14 +121,14 @@ function remove(interceptor) {
|
||||
// TODO: There is a clearer way to write that we want to delete the first
|
||||
// matching instance. I'm also not sure why we couldn't delete _all_
|
||||
// matching instances.
|
||||
interceptors.some(function(thisInterceptor, i) {
|
||||
interceptors.some(function (thisInterceptor, i) {
|
||||
return thisInterceptor === interceptor ? interceptors.splice(i, 1) : false
|
||||
})
|
||||
}
|
||||
|
||||
function removeAll() {
|
||||
Object.keys(allInterceptors).forEach(function(key) {
|
||||
allInterceptors[key].interceptors.forEach(function(interceptor) {
|
||||
Object.keys(allInterceptors).forEach(function (key) {
|
||||
allInterceptors[key].interceptors.forEach(function (interceptor) {
|
||||
interceptor.scope.keyedInterceptors = {}
|
||||
})
|
||||
})
|
||||
@@ -159,7 +159,7 @@ function interceptorsFor(options) {
|
||||
// If scope filtering function is defined and returns a truthy value then
|
||||
// we have to treat this as a match.
|
||||
if (filteringScope && filteringScope(basePath)) {
|
||||
debug('found matching scope interceptor')
|
||||
interceptor.scope.logger('found matching scope interceptor')
|
||||
|
||||
// Keep the filtered scope (its key) to signal the rest of the module
|
||||
// that this wasn't an exact but filtered match.
|
||||
@@ -237,7 +237,7 @@ let originalClientRequest
|
||||
function ErroringClientRequest(error) {
|
||||
http.OutgoingMessage.call(this)
|
||||
process.nextTick(
|
||||
function() {
|
||||
function () {
|
||||
this.emit('error', error)
|
||||
}.bind(this)
|
||||
)
|
||||
@@ -281,6 +281,8 @@ function overrideClientRequest() {
|
||||
debug('using', interceptors.length, 'interceptors')
|
||||
|
||||
// Use filtered interceptors to intercept requests.
|
||||
// TODO: this shouldn't be a class anymore
|
||||
// the overrider explicitly overrides methods and attrs on the request so the `assign` below should be removed.
|
||||
const overrider = new InterceptedRequestRouter({
|
||||
req: this,
|
||||
options,
|
||||
@@ -299,7 +301,7 @@ function overrideClientRequest() {
|
||||
originalClientRequest.apply(this, arguments)
|
||||
} else {
|
||||
common.setImmediate(
|
||||
function() {
|
||||
function () {
|
||||
const error = new NetConnectNotAllowedError(
|
||||
options.host,
|
||||
options.path
|
||||
@@ -368,7 +370,7 @@ function activate() {
|
||||
|
||||
// ----- Overriding http.request and https.request:
|
||||
|
||||
common.overrideRequests(function(proto, overriddenRequest, args) {
|
||||
common.overrideRequests(function (proto, overriddenRequest, args) {
|
||||
// NOTE: overriddenRequest is already bound to its module.
|
||||
|
||||
const { options, callback } = common.normalizeClientRequestArgs(...args)
|
||||
|
||||
229
node_modules/nock/lib/intercepted_request_router.js
generated
vendored
229
node_modules/nock/lib/intercepted_request_router.js
generated
vendored
@@ -13,6 +13,20 @@ const globalEmitter = require('./global_emitter')
|
||||
const Socket = require('./socket')
|
||||
const { playbackInterceptor } = require('./playback_interceptor')
|
||||
|
||||
function socketOnClose(req) {
|
||||
debug('socket close')
|
||||
|
||||
if (!req.res && !req.socket._hadError) {
|
||||
// If we don't have a response then we know that the socket
|
||||
// ended prematurely and we need to emit an error on the request.
|
||||
req.socket._hadError = true
|
||||
const err = new Error('socket hang up')
|
||||
err.code = 'ECONNRESET'
|
||||
req.emit('error', err)
|
||||
}
|
||||
req.emit('close')
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a group of interceptors, appropriately route an outgoing request.
|
||||
* Identify which interceptor ought to respond, if any, then delegate to
|
||||
@@ -39,16 +53,24 @@ class InterceptedRequestRouter {
|
||||
}
|
||||
|
||||
this.response = new IncomingMessage(this.socket)
|
||||
this.playbackStarted = false
|
||||
this.requestBodyBuffers = []
|
||||
this.playbackStarted = false
|
||||
|
||||
// For parity with Node, it's important the socket event is emitted before we begin playback.
|
||||
// This flag is set when playback is triggered if we haven't yet gotten the
|
||||
// socket event to indicate that playback should start as soon as it comes in.
|
||||
this.readyToStartPlaybackOnSocketEvent = false
|
||||
|
||||
this.attachToReq()
|
||||
|
||||
// Emit a fake socket event on the next tick to mimic what would happen on a real request.
|
||||
// Some clients listen for a 'socket' event to be emitted before calling end(),
|
||||
// which causes Nock to hang.
|
||||
process.nextTick(() => this.connectSocket())
|
||||
}
|
||||
|
||||
attachToReq() {
|
||||
const { req, response, socket, options } = this
|
||||
|
||||
response.req = req
|
||||
const { req, options } = this
|
||||
|
||||
for (const [name, val] of Object.entries(options.headers)) {
|
||||
req.setHeader(name.toLowerCase(), val)
|
||||
@@ -65,18 +87,9 @@ class InterceptedRequestRouter {
|
||||
req.path = options.path
|
||||
req.method = options.method
|
||||
|
||||
// ClientRequest.connection is an alias for ClientRequest.socket
|
||||
// https://nodejs.org/api/http.html#http_request_socket
|
||||
// https://github.com/nodejs/node/blob/b0f75818f39ed4e6bd80eb7c4010c1daf5823ef7/lib/_http_client.js#L640-L641
|
||||
// The same Socket is shared between the request and response to mimic native behavior.
|
||||
req.socket = req.connection = socket
|
||||
|
||||
propagate(['error', 'timeout'], req.socket, req)
|
||||
|
||||
req.write = (...args) => this.handleWrite(...args)
|
||||
req.end = (...args) => this.handleEnd(...args)
|
||||
req.flushHeaders = (...args) => this.handleFlushHeaders(...args)
|
||||
req.abort = (...args) => this.handleAbort(...args)
|
||||
|
||||
// https://github.com/nock/nock/issues/256
|
||||
if (options.headers.expect === '100-continue') {
|
||||
@@ -85,53 +98,79 @@ class InterceptedRequestRouter {
|
||||
req.emit('continue')
|
||||
})
|
||||
}
|
||||
|
||||
// Emit a fake socket event on the next tick to mimic what would happen on a real request.
|
||||
// Some clients listen for a 'socket' event to be emitted before calling end(),
|
||||
// which causes nock to hang.
|
||||
process.nextTick(() => {
|
||||
req.emit('socket', socket)
|
||||
|
||||
// https://nodejs.org/api/net.html#net_event_connect
|
||||
socket.emit('connect')
|
||||
|
||||
// https://nodejs.org/api/tls.html#tls_event_secureconnect
|
||||
if (socket.authorized) {
|
||||
socket.emit('secureConnect')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
emitError(error) {
|
||||
const { req } = this
|
||||
process.nextTick(() => {
|
||||
req.emit('error', error)
|
||||
})
|
||||
}
|
||||
connectSocket() {
|
||||
const { req, socket } = this
|
||||
|
||||
handleWrite(buffer, encoding, callback) {
|
||||
debug('write', arguments)
|
||||
const { req } = this
|
||||
|
||||
if (!req.aborted) {
|
||||
if (buffer) {
|
||||
if (!Buffer.isBuffer(buffer)) {
|
||||
buffer = Buffer.from(buffer, encoding)
|
||||
}
|
||||
this.requestBodyBuffers.push(buffer)
|
||||
}
|
||||
// can't use instanceof Function because some test runners
|
||||
// run tests in vm.runInNewContext where Function is not same
|
||||
// as that in the current context
|
||||
// https://github.com/nock/nock/pull/1754#issuecomment-571531407
|
||||
if (typeof callback === 'function') {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
this.emitError(new Error('Request aborted'))
|
||||
if (common.isRequestDestroyed(req)) {
|
||||
return
|
||||
}
|
||||
|
||||
common.setImmediate(function() {
|
||||
// ClientRequest.connection is an alias for ClientRequest.socket
|
||||
// https://nodejs.org/api/http.html#http_request_socket
|
||||
// https://github.com/nodejs/node/blob/b0f75818f39ed4e6bd80eb7c4010c1daf5823ef7/lib/_http_client.js#L640-L641
|
||||
// The same Socket is shared between the request and response to mimic native behavior.
|
||||
req.socket = req.connection = socket
|
||||
|
||||
propagate(['error', 'timeout'], socket, req)
|
||||
socket.on('close', () => socketOnClose(req))
|
||||
|
||||
socket.connecting = false
|
||||
req.emit('socket', socket)
|
||||
|
||||
// https://nodejs.org/api/net.html#net_event_connect
|
||||
socket.emit('connect')
|
||||
|
||||
// https://nodejs.org/api/tls.html#tls_event_secureconnect
|
||||
if (socket.authorized) {
|
||||
socket.emit('secureConnect')
|
||||
}
|
||||
|
||||
if (this.readyToStartPlaybackOnSocketEvent) {
|
||||
this.maybeStartPlayback()
|
||||
}
|
||||
}
|
||||
|
||||
// from docs: When write function is called with empty string or buffer, it does nothing and waits for more input.
|
||||
// However, actually implementation checks the state of finished and aborted before checking if the first arg is empty.
|
||||
handleWrite(buffer, encoding, callback) {
|
||||
debug('request write')
|
||||
const { req } = this
|
||||
|
||||
if (req.finished) {
|
||||
const err = new Error('write after end')
|
||||
err.code = 'ERR_STREAM_WRITE_AFTER_END'
|
||||
process.nextTick(() => req.emit('error', err))
|
||||
|
||||
// It seems odd to return `true` here, not sure why you'd want to have
|
||||
// the stream potentially written to more, but it's what Node does.
|
||||
// https://github.com/nodejs/node/blob/a9270dcbeba4316b1e179b77ecb6c46af5aa8c20/lib/_http_outgoing.js#L662-L665
|
||||
return true
|
||||
}
|
||||
|
||||
if (req.socket && req.socket.destroyed) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!buffer || buffer.length === 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!Buffer.isBuffer(buffer)) {
|
||||
buffer = Buffer.from(buffer, encoding)
|
||||
}
|
||||
this.requestBodyBuffers.push(buffer)
|
||||
|
||||
// can't use instanceof Function because some test runners
|
||||
// run tests in vm.runInNewContext where Function is not same
|
||||
// as that in the current context
|
||||
// https://github.com/nock/nock/pull/1754#issuecomment-571531407
|
||||
if (typeof callback === 'function') {
|
||||
callback()
|
||||
}
|
||||
|
||||
common.setImmediate(function () {
|
||||
req.emit('drain')
|
||||
})
|
||||
|
||||
@@ -139,10 +178,10 @@ class InterceptedRequestRouter {
|
||||
}
|
||||
|
||||
handleEnd(chunk, encoding, callback) {
|
||||
debug('req.end')
|
||||
debug('request end')
|
||||
const { req } = this
|
||||
|
||||
// handle the different overloaded param signatures
|
||||
// handle the different overloaded arg signatures
|
||||
if (typeof chunk === 'function') {
|
||||
callback = chunk
|
||||
chunk = null
|
||||
@@ -155,51 +194,18 @@ class InterceptedRequestRouter {
|
||||
req.once('finish', callback)
|
||||
}
|
||||
|
||||
if (!req.aborted && !this.playbackStarted) {
|
||||
if (chunk) {
|
||||
req.write(chunk, encoding)
|
||||
this.startPlayback()
|
||||
}
|
||||
if (req.aborted) {
|
||||
this.emitError(new Error('Request aborted'))
|
||||
}
|
||||
req.finished = true
|
||||
this.maybeStartPlayback()
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
handleFlushHeaders() {
|
||||
debug('req.flushHeaders')
|
||||
const { req } = this
|
||||
|
||||
if (!req.aborted && !this.playbackStarted) {
|
||||
this.startPlayback()
|
||||
}
|
||||
if (req.aborted) {
|
||||
this.emitError(new Error('Request aborted'))
|
||||
}
|
||||
}
|
||||
|
||||
handleAbort() {
|
||||
debug('req.abort')
|
||||
const { req, response, socket } = this
|
||||
|
||||
if (req.aborted) {
|
||||
return
|
||||
}
|
||||
req.aborted = Date.now()
|
||||
if (!this.playbackStarted) {
|
||||
this.startPlayback()
|
||||
}
|
||||
const err = new Error()
|
||||
err.code = 'aborted'
|
||||
response.emit('close', err)
|
||||
|
||||
socket.destroy()
|
||||
|
||||
req.emit('abort')
|
||||
|
||||
const connResetError = new Error('socket hang up')
|
||||
connResetError.code = 'ECONNRESET'
|
||||
this.emitError(connResetError)
|
||||
debug('request flushHeaders')
|
||||
this.maybeStartPlayback()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,6 +239,21 @@ class InterceptedRequestRouter {
|
||||
}
|
||||
}
|
||||
|
||||
maybeStartPlayback() {
|
||||
const { req, socket, playbackStarted } = this
|
||||
|
||||
// In order to get the events in the right order we need to delay playback
|
||||
// if we get here before the `socket` event is emitted.
|
||||
if (socket.connecting) {
|
||||
this.readyToStartPlaybackOnSocketEvent = true
|
||||
return
|
||||
}
|
||||
|
||||
if (!common.isRequestDestroyed(req) && !playbackStarted) {
|
||||
this.startPlayback()
|
||||
}
|
||||
}
|
||||
|
||||
startPlayback() {
|
||||
debug('ending')
|
||||
this.playbackStarted = true
|
||||
@@ -270,11 +291,14 @@ class InterceptedRequestRouter {
|
||||
)
|
||||
|
||||
if (matchedInterceptor) {
|
||||
debug('interceptor identified, starting mocking')
|
||||
matchedInterceptor.scope.logger(
|
||||
'interceptor identified, starting mocking'
|
||||
)
|
||||
|
||||
matchedInterceptor.markConsumed()
|
||||
|
||||
// wait to emit the finish event until we know for sure an Interceptor is going to playback.
|
||||
// otherwise an unmocked request might emit finish twice.
|
||||
req.finished = true
|
||||
req.emit('finish')
|
||||
|
||||
playbackInterceptor({
|
||||
@@ -304,14 +328,11 @@ class InterceptedRequestRouter {
|
||||
// We send the raw buffer as we received it, not as we interpreted it.
|
||||
newReq.end(requestBodyBuffer)
|
||||
} else {
|
||||
const err = new Error(
|
||||
`Nock: No match for request ${common.stringifyRequest(
|
||||
options,
|
||||
requestBodyString
|
||||
)}`
|
||||
)
|
||||
const reqStr = common.stringifyRequest(options, requestBodyString)
|
||||
const err = new Error(`Nock: No match for request ${reqStr}`)
|
||||
err.code = 'ERR_NOCK_NO_MATCH'
|
||||
err.statusCode = err.status = 404
|
||||
this.emitError(err)
|
||||
req.destroy(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
73
node_modules/nock/lib/interceptor.js
generated
vendored
73
node_modules/nock/lib/interceptor.js
generated
vendored
@@ -1,8 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const debug = require('debug')('nock.interceptor')
|
||||
const stringify = require('json-stringify-safe')
|
||||
const _ = require('lodash')
|
||||
const querystring = require('querystring')
|
||||
const { URL, URLSearchParams } = require('url')
|
||||
|
||||
@@ -34,8 +32,9 @@ module.exports = class Interceptor {
|
||||
// When enabled filteringScope ignores the passed URL entirely so we skip validation.
|
||||
|
||||
if (
|
||||
!scope.scopeOptions.filteringScope &&
|
||||
uriIsStr &&
|
||||
!scope.scopeOptions.filteringScope &&
|
||||
!scope.basePathname &&
|
||||
!uri.startsWith('/') &&
|
||||
!uri.startsWith('*')
|
||||
) {
|
||||
@@ -73,7 +72,7 @@ module.exports = class Interceptor {
|
||||
scope.scopeOptions.badheaders || []
|
||||
)
|
||||
|
||||
this.delayInMs = 0
|
||||
this.delayBodyInMs = 0
|
||||
this.delayConnectionInMs = 0
|
||||
|
||||
this.optional = false
|
||||
@@ -181,8 +180,8 @@ module.exports = class Interceptor {
|
||||
}
|
||||
}
|
||||
|
||||
debug('reply.headers:', this.headers)
|
||||
debug('reply.rawHeaders:', this.rawHeaders)
|
||||
this.scope.logger('reply.headers:', this.headers)
|
||||
this.scope.logger('reply.rawHeaders:', this.rawHeaders)
|
||||
|
||||
this.body = body
|
||||
|
||||
@@ -228,13 +227,23 @@ module.exports = class Interceptor {
|
||||
}
|
||||
}
|
||||
|
||||
debug("request header field doesn't match:", key, header, reqHeader)
|
||||
this.scope.logger(
|
||||
"request header field doesn't match:",
|
||||
key,
|
||||
header,
|
||||
reqHeader
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
match(req, options, body) {
|
||||
if (debug.enabled) {
|
||||
debug('match %s, body = %s', stringify(options), stringify(body))
|
||||
// check if the logger is enabled because the stringifies can be expensive.
|
||||
if (this.scope.logger.enabled) {
|
||||
this.scope.logger(
|
||||
'attempting match %s, body = %s',
|
||||
stringify(options),
|
||||
stringify(body)
|
||||
)
|
||||
}
|
||||
|
||||
const method = (options.method || 'GET').toUpperCase()
|
||||
@@ -244,7 +253,7 @@ module.exports = class Interceptor {
|
||||
const { proto } = options
|
||||
|
||||
if (this.method !== method) {
|
||||
debug(
|
||||
this.scope.logger(
|
||||
`Method did not match. Request ${method} Interceptor ${this.method}`
|
||||
)
|
||||
return false
|
||||
@@ -276,6 +285,7 @@ module.exports = class Interceptor {
|
||||
)
|
||||
|
||||
if (!reqHeadersMatch) {
|
||||
this.scope.logger("headers don't match")
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -283,26 +293,32 @@ module.exports = class Interceptor {
|
||||
this.scope.scopeOptions.conditionally &&
|
||||
!this.scope.scopeOptions.conditionally()
|
||||
) {
|
||||
this.scope.logger(
|
||||
'matching failed because Scope.conditionally() did not validate'
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
const reqContainsBadHeaders = this.badheaders.some(
|
||||
const badHeaders = this.badheaders.filter(
|
||||
header => header in options.headers
|
||||
)
|
||||
|
||||
if (reqContainsBadHeaders) {
|
||||
if (badHeaders.length) {
|
||||
this.scope.logger('request contains bad headers', ...badHeaders)
|
||||
return false
|
||||
}
|
||||
|
||||
// Match query strings when using query()
|
||||
if (this.queries === null) {
|
||||
debug('query matching skipped')
|
||||
this.scope.logger('query matching skipped')
|
||||
} else {
|
||||
// can't rely on pathname or search being in the options, but path has a default
|
||||
const [pathname, search] = path.split('?')
|
||||
const matchQueries = this.matchQuery({ search })
|
||||
|
||||
debug(matchQueries ? 'query matching succeeded' : 'query matching failed')
|
||||
this.scope.logger(
|
||||
matchQueries ? 'query matching succeeded' : 'query matching failed'
|
||||
)
|
||||
|
||||
if (!matchQueries) {
|
||||
return false
|
||||
@@ -405,8 +421,8 @@ module.exports = class Interceptor {
|
||||
}
|
||||
|
||||
const reqQueries = querystring.parse(options.search)
|
||||
debug('Interceptor queries: %j', this.queries)
|
||||
debug(' Request queries: %j', reqQueries)
|
||||
this.scope.logger('Interceptor queries: %j', this.queries)
|
||||
this.scope.logger(' Request queries: %j', reqQueries)
|
||||
|
||||
if (typeof this.queries === 'function') {
|
||||
return this.queries(reqQueries)
|
||||
@@ -483,7 +499,7 @@ module.exports = class Interceptor {
|
||||
// Normalize the data into the shape that is matched against.
|
||||
// Duplicate keys are handled by combining the values into an array.
|
||||
queries = querystring.parse(queries.toString())
|
||||
} else if (!_.isPlainObject(queries)) {
|
||||
} else if (!common.isPlainObject(queries)) {
|
||||
throw Error(`Argument Error: ${queries}`)
|
||||
}
|
||||
|
||||
@@ -583,7 +599,7 @@ module.exports = class Interceptor {
|
||||
* @return {Interceptor} - the current interceptor for chaining
|
||||
*/
|
||||
delayBody(ms) {
|
||||
this.delayInMs += ms
|
||||
this.delayBodyInMs = ms
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -594,26 +610,7 @@ module.exports = class Interceptor {
|
||||
* @return {Interceptor} - the current interceptor for chaining
|
||||
*/
|
||||
delayConnection(ms) {
|
||||
this.delayConnectionInMs += ms
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {number}
|
||||
*/
|
||||
getTotalDelay() {
|
||||
return this.delayInMs + this.delayConnectionInMs
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the socket idle for a certain number of ms (simulated).
|
||||
*
|
||||
* @param {integer} ms - Number of milliseconds to wait
|
||||
* @return {Interceptor} - the current interceptor for chaining
|
||||
*/
|
||||
socketDelay(ms) {
|
||||
this.socketDelayInMs = ms
|
||||
this.delayConnectionInMs = ms
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
5
node_modules/nock/lib/match_body.js
generated
vendored
5
node_modules/nock/lib/match_body.js
generated
vendored
@@ -1,6 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const _ = require('lodash')
|
||||
const querystring = require('querystring')
|
||||
|
||||
const common = require('./common')
|
||||
@@ -70,8 +69,8 @@ function mapValuesDeep(obj, cb) {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(v => mapValuesDeep(v, cb))
|
||||
}
|
||||
if (_.isPlainObject(obj)) {
|
||||
return _.mapValues(obj, v => mapValuesDeep(v, cb))
|
||||
if (common.isPlainObject(obj)) {
|
||||
return common.mapValue(obj, v => mapValuesDeep(v, cb))
|
||||
}
|
||||
return cb(obj)
|
||||
}
|
||||
|
||||
255
node_modules/nock/lib/playback_interceptor.js
generated
vendored
255
node_modules/nock/lib/playback_interceptor.js
generated
vendored
@@ -1,10 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
const stream = require('stream')
|
||||
const util = require('util')
|
||||
const zlib = require('zlib')
|
||||
const debug = require('debug')('nock.playback_interceptor')
|
||||
const common = require('./common')
|
||||
const DelayedBody = require('./delayed_body')
|
||||
|
||||
function parseJSONRequestBody(req, requestBody) {
|
||||
if (!requestBody || !common.isJSONContent(req.headers)) {
|
||||
@@ -71,6 +71,44 @@ function selectDefaultHeaders(existingHeaders, defaultHeaders) {
|
||||
return result
|
||||
}
|
||||
|
||||
// Presents a list of Buffers as a Readable
|
||||
class ReadableBuffers extends stream.Readable {
|
||||
constructor(buffers, opts = {}) {
|
||||
super(opts)
|
||||
|
||||
this.buffers = buffers
|
||||
}
|
||||
|
||||
_read(size) {
|
||||
while (this.buffers.length) {
|
||||
if (!this.push(this.buffers.shift())) {
|
||||
return
|
||||
}
|
||||
}
|
||||
this.push(null)
|
||||
}
|
||||
}
|
||||
|
||||
function convertBodyToStream(body) {
|
||||
if (common.isStream(body)) {
|
||||
return body
|
||||
}
|
||||
|
||||
if (body === undefined) {
|
||||
return new ReadableBuffers([])
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(body)) {
|
||||
return new ReadableBuffers([body])
|
||||
}
|
||||
|
||||
if (typeof body !== 'string') {
|
||||
body = JSON.stringify(body)
|
||||
}
|
||||
|
||||
return new ReadableBuffers([Buffer.from(body)])
|
||||
}
|
||||
|
||||
/**
|
||||
* Play back an interceptor using the given request and mock response.
|
||||
*/
|
||||
@@ -83,28 +121,23 @@ function playbackInterceptor({
|
||||
response,
|
||||
interceptor,
|
||||
}) {
|
||||
function emitError(error) {
|
||||
process.nextTick(() => {
|
||||
req.emit('error', error)
|
||||
})
|
||||
}
|
||||
const { logger } = interceptor.scope
|
||||
|
||||
function start() {
|
||||
interceptor.req = req
|
||||
req.headers = req.getHeaders()
|
||||
|
||||
interceptor.scope.emit('request', req, interceptor, requestBodyString)
|
||||
|
||||
if (typeof interceptor.errorMessage !== 'undefined') {
|
||||
interceptor.markConsumed()
|
||||
|
||||
let error
|
||||
if (typeof interceptor.errorMessage === 'object') {
|
||||
error = interceptor.errorMessage
|
||||
} else {
|
||||
error = new Error(interceptor.errorMessage)
|
||||
}
|
||||
common.setTimeout(() => emitError(error), interceptor.getTotalDelay())
|
||||
|
||||
const delay = interceptor.delayBodyInMs + interceptor.delayConnectionInMs
|
||||
common.setTimeout(() => req.destroy(error), delay)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -114,7 +147,14 @@ function playbackInterceptor({
|
||||
|
||||
// Clone headers/rawHeaders to not override them when evaluating later
|
||||
response.rawHeaders = [...interceptor.rawHeaders]
|
||||
debug('response.rawHeaders:', response.rawHeaders)
|
||||
logger('response.rawHeaders:', response.rawHeaders)
|
||||
|
||||
// TODO: MAJOR: Don't tack the request onto the interceptor.
|
||||
// The only reason we do this is so that it's available inside reply functions.
|
||||
// It would be better to pass the request as an argument to the functions instead.
|
||||
// Not adding the req as a third arg now because it should first be decided if (path, body, req)
|
||||
// is the signature we want to go with going forward.
|
||||
interceptor.req = req
|
||||
|
||||
if (interceptor.replyFunction) {
|
||||
const parsedRequestBody = parseJSONRequestBody(req, requestBodyString)
|
||||
@@ -128,8 +168,8 @@ function playbackInterceptor({
|
||||
// At this point `fn` is either a synchronous function or a promise-returning function;
|
||||
// wrapping in `Promise.resolve` makes it into a promise either way.
|
||||
Promise.resolve(fn.call(interceptor, options.path, parsedRequestBody))
|
||||
.then(responseBody => continueWithResponseBody({ responseBody }))
|
||||
.catch(err => emitError(err))
|
||||
.then(continueWithResponseBody)
|
||||
.catch(err => req.destroy(err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -142,8 +182,8 @@ function playbackInterceptor({
|
||||
}
|
||||
|
||||
Promise.resolve(fn.call(interceptor, options.path, parsedRequestBody))
|
||||
.then(fullReplyResult => continueWithFullResponse({ fullReplyResult }))
|
||||
.catch(err => emitError(err))
|
||||
.then(continueWithFullResponse)
|
||||
.catch(err => req.destroy(err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -155,21 +195,12 @@ function playbackInterceptor({
|
||||
// of response buffers which should be mocked one by one.
|
||||
// (otherwise decompressions after the first one fails as unzip expects to receive
|
||||
// buffer by buffer and not one single merged buffer)
|
||||
|
||||
if (interceptor.delayInMs) {
|
||||
emitError(
|
||||
new Error(
|
||||
'Response delay of the body is currently not supported with content-encoded responses.'
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const bufferData = Array.isArray(interceptor.body)
|
||||
? interceptor.body
|
||||
: [interceptor.body]
|
||||
const responseBuffers = bufferData.map(data => Buffer.from(data, 'hex'))
|
||||
continueWithResponseBody({ responseBuffers })
|
||||
const responseBody = new ReadableBuffers(responseBuffers)
|
||||
continueWithResponseBody(responseBody)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -194,155 +225,103 @@ function playbackInterceptor({
|
||||
}
|
||||
}
|
||||
|
||||
return continueWithResponseBody({ responseBody })
|
||||
return continueWithResponseBody(responseBody)
|
||||
}
|
||||
|
||||
function continueWithFullResponse({ fullReplyResult }) {
|
||||
function continueWithFullResponse(fullReplyResult) {
|
||||
let responseBody
|
||||
try {
|
||||
responseBody = parseFullReplyResult(response, fullReplyResult)
|
||||
} catch (innerErr) {
|
||||
emitError(innerErr)
|
||||
} catch (err) {
|
||||
req.destroy(err)
|
||||
return
|
||||
}
|
||||
|
||||
continueWithResponseBody({ responseBody })
|
||||
continueWithResponseBody(responseBody)
|
||||
}
|
||||
|
||||
function continueWithResponseBody({ responseBuffers, responseBody }) {
|
||||
// Transform the response body if it exists (it may not exist
|
||||
// if we have `responseBuffers` instead)
|
||||
if (responseBody !== undefined) {
|
||||
debug('transform the response body')
|
||||
function prepareResponseHeaders(body) {
|
||||
const defaultHeaders = [...interceptor.scope._defaultReplyHeaders]
|
||||
|
||||
if (interceptor.delayInMs) {
|
||||
debug(
|
||||
'delaying the response for',
|
||||
interceptor.delayInMs,
|
||||
'milliseconds'
|
||||
)
|
||||
// Because setTimeout is called immediately in DelayedBody(), so we
|
||||
// need count in the delayConnectionInMs.
|
||||
responseBody = new DelayedBody(
|
||||
interceptor.getTotalDelay(),
|
||||
responseBody
|
||||
)
|
||||
}
|
||||
// Include a JSON content type when JSON.stringify is called on the body.
|
||||
// This is a convenience added by Nock that has no analog in Node. It's added to the
|
||||
// defaults, so it will be ignored if the caller explicitly provided the header already.
|
||||
const isJSON =
|
||||
body !== undefined &&
|
||||
typeof body !== 'string' &&
|
||||
!Buffer.isBuffer(body) &&
|
||||
!common.isStream(body)
|
||||
|
||||
if (common.isStream(responseBody)) {
|
||||
debug('response body is a stream')
|
||||
responseBody.pause()
|
||||
responseBody.on('data', function(d) {
|
||||
response.push(d)
|
||||
})
|
||||
responseBody.on('end', function() {
|
||||
response.push(null)
|
||||
// https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_message_complete
|
||||
response.complete = true
|
||||
})
|
||||
responseBody.on('error', function(err) {
|
||||
response.emit('error', err)
|
||||
})
|
||||
} else if (!Buffer.isBuffer(responseBody)) {
|
||||
if (typeof responseBody === 'string') {
|
||||
responseBody = Buffer.from(responseBody)
|
||||
} else {
|
||||
responseBody = JSON.stringify(responseBody)
|
||||
response.rawHeaders.push('Content-Type', 'application/json')
|
||||
}
|
||||
}
|
||||
// Why are strings converted to a Buffer, but JSON data is left as a string?
|
||||
// Related to https://github.com/nock/nock/issues/1542 ?
|
||||
}
|
||||
|
||||
interceptor.markConsumed()
|
||||
|
||||
if (req.aborted) {
|
||||
return
|
||||
if (isJSON) {
|
||||
defaultHeaders.push('Content-Type', 'application/json')
|
||||
}
|
||||
|
||||
response.rawHeaders.push(
|
||||
...selectDefaultHeaders(
|
||||
response.rawHeaders,
|
||||
interceptor.scope._defaultReplyHeaders
|
||||
)
|
||||
...selectDefaultHeaders(response.rawHeaders, defaultHeaders)
|
||||
)
|
||||
|
||||
// Evaluate functional headers.
|
||||
common.forEachHeader(response.rawHeaders, (value, fieldName, i) => {
|
||||
if (typeof value === 'function') {
|
||||
response.rawHeaders[i + 1] = value(req, response, responseBody)
|
||||
response.rawHeaders[i + 1] = value(req, response, body)
|
||||
}
|
||||
})
|
||||
|
||||
response.headers = common.headersArrayToObject(response.rawHeaders)
|
||||
|
||||
process.nextTick(() =>
|
||||
respondUsingInterceptor({
|
||||
responseBody,
|
||||
responseBuffers,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
function respondUsingInterceptor({ responseBody, responseBuffers }) {
|
||||
if (req.aborted) {
|
||||
return
|
||||
}
|
||||
function continueWithResponseBody(rawBody) {
|
||||
prepareResponseHeaders(rawBody)
|
||||
const bodyAsStream = convertBodyToStream(rawBody)
|
||||
bodyAsStream.pause()
|
||||
|
||||
// IncomingMessage extends Readable so we can't simply pipe.
|
||||
bodyAsStream.on('data', function (chunk) {
|
||||
response.push(chunk)
|
||||
})
|
||||
bodyAsStream.on('end', function () {
|
||||
// https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_message_complete
|
||||
response.complete = true
|
||||
response.push(null)
|
||||
|
||||
interceptor.scope.emit('replied', req, interceptor)
|
||||
})
|
||||
bodyAsStream.on('error', function (err) {
|
||||
response.emit('error', err)
|
||||
})
|
||||
|
||||
const { delayBodyInMs, delayConnectionInMs } = interceptor
|
||||
|
||||
function respond() {
|
||||
if (req.aborted) {
|
||||
if (common.isRequestDestroyed(req)) {
|
||||
return
|
||||
}
|
||||
|
||||
debug('emitting response')
|
||||
// Even though we've had the response object for awhile at this point,
|
||||
// we only attach it to the request immediately before the `response`
|
||||
// event because, as in Node, it alters the error handling around aborts.
|
||||
req.res = response
|
||||
response.req = req
|
||||
|
||||
logger('emitting response')
|
||||
req.emit('response', response)
|
||||
|
||||
if (common.isStream(responseBody)) {
|
||||
debug('resuming response stream')
|
||||
responseBody.resume()
|
||||
} else {
|
||||
responseBuffers = responseBuffers || []
|
||||
if (typeof responseBody !== 'undefined') {
|
||||
debug('adding body to buffer list')
|
||||
responseBuffers.push(responseBody)
|
||||
}
|
||||
|
||||
// Stream the response chunks one at a time.
|
||||
common.setImmediate(function emitChunk() {
|
||||
const chunk = responseBuffers.shift()
|
||||
|
||||
if (chunk) {
|
||||
debug('emitting response chunk')
|
||||
response.push(chunk)
|
||||
common.setImmediate(emitChunk)
|
||||
} else {
|
||||
debug('ending response stream')
|
||||
response.push(null)
|
||||
// https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_message_complete
|
||||
response.complete = true
|
||||
interceptor.scope.emit('replied', req, interceptor)
|
||||
}
|
||||
})
|
||||
}
|
||||
common.setTimeout(() => bodyAsStream.resume(), delayBodyInMs)
|
||||
}
|
||||
|
||||
if (interceptor.socketDelayInMs && interceptor.socketDelayInMs > 0) {
|
||||
socket.applyDelay(interceptor.socketDelayInMs)
|
||||
}
|
||||
|
||||
if (
|
||||
interceptor.delayConnectionInMs &&
|
||||
interceptor.delayConnectionInMs > 0
|
||||
) {
|
||||
socket.applyDelay(interceptor.delayConnectionInMs)
|
||||
common.setTimeout(respond, interceptor.delayConnectionInMs)
|
||||
} else {
|
||||
respond()
|
||||
}
|
||||
socket.applyDelay(delayConnectionInMs)
|
||||
common.setTimeout(respond, delayConnectionInMs)
|
||||
}
|
||||
|
||||
start()
|
||||
// Calling `start` immediately could take the request all the way to the connection delay
|
||||
// during a single microtask execution. This setImmediate stalls the playback to ensure the
|
||||
// correct events are emitted first ('socket', 'finish') and any aborts in the in the queue or
|
||||
// called during a 'finish' listener can be called.
|
||||
common.setImmediate(() => {
|
||||
if (!common.isRequestDestroyed(req)) {
|
||||
start()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { playbackInterceptor }
|
||||
|
||||
20
node_modules/nock/lib/recorder.js
generated
vendored
20
node_modules/nock/lib/recorder.js
generated
vendored
@@ -110,6 +110,10 @@ function generateRequestAndResponse({
|
||||
const queryStr = req.path.slice(queryIndex + 1)
|
||||
queryObj = querystring.parse(queryStr)
|
||||
}
|
||||
|
||||
// Escape any single quotes in the path as the output uses them
|
||||
path = path.replace(/'/g, `\\'`)
|
||||
|
||||
// Always encode the query parameters when recording.
|
||||
const encodedQueryObj = {}
|
||||
for (const key in queryObj) {
|
||||
@@ -211,7 +215,7 @@ function record(recOptions) {
|
||||
restoreOverriddenClientRequest()
|
||||
|
||||
// We override the requests so that we can save information on them before executing.
|
||||
common.overrideRequests(function(proto, overriddenRequest, rawArgs) {
|
||||
common.overrideRequests(function (proto, overriddenRequest, rawArgs) {
|
||||
const { options, callback } = common.normalizeClientRequestArgs(...rawArgs)
|
||||
const bodyChunks = []
|
||||
|
||||
@@ -223,11 +227,11 @@ function record(recOptions) {
|
||||
}
|
||||
options._recording = true
|
||||
|
||||
const req = overriddenRequest(options, function(res) {
|
||||
const req = overriddenRequest(options, function (res) {
|
||||
debug(thisRecordingId, 'intercepting', proto, 'request to record')
|
||||
|
||||
// We put our 'end' listener to the front of the listener array.
|
||||
res.once('end', function() {
|
||||
res.once('end', function () {
|
||||
debug(thisRecordingId, proto, 'intercepted request ended')
|
||||
|
||||
let reqheaders
|
||||
@@ -284,7 +288,7 @@ function record(recOptions) {
|
||||
// We need to be aware of changes to the stream's encoding so that we
|
||||
// don't accidentally mangle the data.
|
||||
const { setEncoding } = res
|
||||
res.setEncoding = function(newEncoding) {
|
||||
res.setEncoding = function (newEncoding) {
|
||||
encoding = newEncoding
|
||||
return setEncoding.apply(this, arguments)
|
||||
}
|
||||
@@ -292,7 +296,7 @@ function record(recOptions) {
|
||||
const dataChunks = []
|
||||
// Replace res.push with our own implementation that stores chunks
|
||||
const origResPush = res.push
|
||||
res.push = function(data) {
|
||||
res.push = function (data) {
|
||||
if (data) {
|
||||
if (encoding) {
|
||||
data = Buffer.from(data, encoding)
|
||||
@@ -305,8 +309,6 @@ function record(recOptions) {
|
||||
|
||||
if (callback) {
|
||||
callback(res, options, callback)
|
||||
} else {
|
||||
res.resume()
|
||||
}
|
||||
|
||||
debug('finished setting up intercepting')
|
||||
@@ -329,7 +331,7 @@ function record(recOptions) {
|
||||
}
|
||||
|
||||
const oldWrite = req.write
|
||||
req.write = function(chunk, encoding) {
|
||||
req.write = function (chunk, encoding) {
|
||||
if (typeof chunk !== 'undefined') {
|
||||
recordChunk(chunk, encoding)
|
||||
oldWrite.apply(req, arguments)
|
||||
@@ -342,7 +344,7 @@ function record(recOptions) {
|
||||
// `write_` function instead of proxying to the public
|
||||
// `OutgoingMessage.write()` method, so we have to wrap `end` too.
|
||||
const oldEnd = req.end
|
||||
req.end = function(chunk, encoding, callback) {
|
||||
req.end = function (chunk, encoding, callback) {
|
||||
debug('req.end')
|
||||
if (typeof chunk === 'function') {
|
||||
callback = chunk
|
||||
|
||||
40
node_modules/nock/lib/scope.js
generated
vendored
40
node_modules/nock/lib/scope.js
generated
vendored
@@ -9,7 +9,6 @@ const assert = require('assert')
|
||||
const url = require('url')
|
||||
const debug = require('debug')('nock.scope')
|
||||
const { EventEmitter } = require('events')
|
||||
const util = require('util')
|
||||
const Interceptor = require('./interceptor')
|
||||
|
||||
let fs
|
||||
@@ -40,7 +39,6 @@ class Scope extends EventEmitter {
|
||||
this.transformPathFunction = null
|
||||
this.transformRequestBodyFunction = null
|
||||
this.matchHeaders = []
|
||||
this.logger = debug
|
||||
this.scopeOptions = options || {}
|
||||
this.urlParts = {}
|
||||
this._persist = false
|
||||
@@ -51,13 +49,18 @@ class Scope extends EventEmitter {
|
||||
this.port = null
|
||||
this._defaultReplyHeaders = []
|
||||
|
||||
let logNamespace = String(basePath)
|
||||
|
||||
if (!(basePath instanceof RegExp)) {
|
||||
this.urlParts = url.parse(basePath)
|
||||
this.port =
|
||||
this.urlParts.port || (this.urlParts.protocol === 'http:' ? 80 : 443)
|
||||
this.basePathname = this.urlParts.pathname.replace(/\/$/, '')
|
||||
this.basePath = `${this.urlParts.protocol}//${this.urlParts.hostname}:${this.port}`
|
||||
logNamespace = this.urlParts.host
|
||||
}
|
||||
|
||||
this.logger = debug.extend(logNamespace)
|
||||
}
|
||||
|
||||
add(key, interceptor) {
|
||||
@@ -170,7 +173,7 @@ class Scope extends EventEmitter {
|
||||
const filteringArguments = arguments
|
||||
|
||||
if (arguments[0] instanceof RegExp) {
|
||||
return function(candidate) {
|
||||
return function (candidate) {
|
||||
/* istanbul ignore if */
|
||||
if (typeof candidate !== 'string') {
|
||||
// Given the way nock is written, it seems like `candidate` will always
|
||||
@@ -219,11 +222,6 @@ class Scope extends EventEmitter {
|
||||
return this
|
||||
}
|
||||
|
||||
log(newLogger) {
|
||||
this.logger = newLogger
|
||||
return this
|
||||
}
|
||||
|
||||
persist(flag = true) {
|
||||
if (typeof flag !== 'boolean') {
|
||||
throw new Error('Invalid arguments: argument should be a boolean')
|
||||
@@ -306,17 +304,10 @@ function tryJsonParse(string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Use a noop deprecate util instead calling emitWarning directly so we get --no-deprecation and single warning behavior for free.
|
||||
const emitAsteriskDeprecation = util.deprecate(
|
||||
() => {},
|
||||
'Skipping body matching using "*" is deprecated. Set the definition body to undefined instead.',
|
||||
'NOCK1579'
|
||||
)
|
||||
|
||||
function define(nockDefs) {
|
||||
const scopes = []
|
||||
|
||||
nockDefs.forEach(function(nockDef) {
|
||||
nockDefs.forEach(function (nockDef) {
|
||||
const nscope = getScopeFromDefinition(nockDef)
|
||||
const npath = nockDef.path
|
||||
if (!nockDef.method) {
|
||||
@@ -335,23 +326,12 @@ function define(nockDefs) {
|
||||
options.reqheaders = reqheaders
|
||||
options.badheaders = badheaders
|
||||
|
||||
let { body } = nockDef
|
||||
|
||||
if (body === '*') {
|
||||
// In previous versions, it was impossible to NOT filter on request bodies. This special value
|
||||
// is sniffed out for users manipulating the definitions and not wanting to match on the
|
||||
// request body. For newer versions, users should remove the `body` key or set to `undefined`
|
||||
// to achieve the same affect. Maintaining legacy behavior for now.
|
||||
emitAsteriskDeprecation()
|
||||
body = undefined
|
||||
}
|
||||
|
||||
// Response is not always JSON as it could be a string or binary data or
|
||||
// even an array of binary buffers (e.g. when content is encoded).
|
||||
let response
|
||||
if (!nockDef.response) {
|
||||
response = ''
|
||||
// TODO: Rename `responseIsBinary` to `reponseIsUtf8Representable`.
|
||||
// TODO: Rename `responseIsBinary` to `responseIsUtf8Representable`.
|
||||
} else if (nockDef.responseIsBinary) {
|
||||
response = Buffer.from(nockDef.response, 'hex')
|
||||
} else {
|
||||
@@ -375,7 +355,9 @@ function define(nockDefs) {
|
||||
}
|
||||
})
|
||||
|
||||
scope.intercept(npath, method, body).reply(status, response, rawHeaders)
|
||||
scope
|
||||
.intercept(npath, method, nockDef.body)
|
||||
.reply(status, response, rawHeaders)
|
||||
|
||||
scopes.push(scope)
|
||||
})
|
||||
|
||||
55
node_modules/nock/lib/socket.js
generated
vendored
55
node_modules/nock/lib/socket.js
generated
vendored
@@ -7,9 +7,12 @@ module.exports = class Socket extends EventEmitter {
|
||||
constructor(options) {
|
||||
super()
|
||||
|
||||
// Pretend this is a TLSSocket
|
||||
if (options.proto === 'https') {
|
||||
// https://github.com/nock/nock/issues/158
|
||||
this.authorized = true
|
||||
// https://github.com/nock/nock/issues/2147
|
||||
this.encrypted = true
|
||||
}
|
||||
|
||||
this.bufferSize = 0
|
||||
@@ -18,14 +21,13 @@ module.exports = class Socket extends EventEmitter {
|
||||
this.readable = true
|
||||
this.pending = false
|
||||
this.destroyed = false
|
||||
this.connecting = false
|
||||
this.connecting = true
|
||||
|
||||
// totalDelay that has already been applied to the current
|
||||
// request/connection, timeout error will be generated if
|
||||
// it is timed-out.
|
||||
this.totalDelayMs = 0
|
||||
// Maximum allowed delay. Null means unlimited.
|
||||
this.timeoutMs = null
|
||||
// Undocumented flag used by ClientRequest to ensure errors aren't double-fired
|
||||
this._hadError = false
|
||||
|
||||
// Maximum allowed delay. 0 means unlimited.
|
||||
this.timeout = 0
|
||||
|
||||
const ipv6 = options.family === 6
|
||||
this.remoteFamily = ipv6 ? 'IPv6' : 'IPv4'
|
||||
@@ -48,16 +50,22 @@ module.exports = class Socket extends EventEmitter {
|
||||
}
|
||||
|
||||
setTimeout(timeoutMs, fn) {
|
||||
this.timeoutMs = timeoutMs
|
||||
this.timeout = timeoutMs
|
||||
if (fn) {
|
||||
this.once('timeout', fn)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Artificial delay that will trip socket timeouts when appropriate.
|
||||
*
|
||||
* Doesn't actually wait for time to pass.
|
||||
* Timeout events don't necessarily end the request.
|
||||
* While many clients choose to abort the request upon a timeout, Node itself does not.
|
||||
*/
|
||||
applyDelay(delayMs) {
|
||||
this.totalDelayMs += delayMs
|
||||
|
||||
if (this.timeoutMs && this.totalDelayMs > this.timeoutMs) {
|
||||
if (this.timeout && delayMs > this.timeout) {
|
||||
debug('socket timeout')
|
||||
this.emit('timeout')
|
||||
}
|
||||
@@ -69,12 +77,31 @@ module.exports = class Socket extends EventEmitter {
|
||||
).toString('base64')
|
||||
}
|
||||
|
||||
/**
|
||||
* Denotes that no more I/O activity should happen on this socket.
|
||||
*
|
||||
* The implementation in Node if far more complex as it juggles underlying async streams.
|
||||
* For the purposes of Nock, we just need it to set some flags and on the first call
|
||||
* emit a 'close' and optional 'error' event. Both events propagate through the request object.
|
||||
*/
|
||||
destroy(err) {
|
||||
if (this.destroyed) {
|
||||
return this
|
||||
}
|
||||
|
||||
debug('socket destroy')
|
||||
this.destroyed = true
|
||||
this.readable = this.writable = false
|
||||
if (err) {
|
||||
this.emit('error', err)
|
||||
}
|
||||
this.readableEnded = this.writableFinished = true
|
||||
|
||||
process.nextTick(() => {
|
||||
if (err) {
|
||||
this._hadError = true
|
||||
this.emit('error', err)
|
||||
}
|
||||
this.emit('close')
|
||||
})
|
||||
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
65
node_modules/nock/package.json
generated
vendored
65
node_modules/nock/package.json
generated
vendored
@@ -7,7 +7,7 @@
|
||||
"testing",
|
||||
"isolation"
|
||||
],
|
||||
"version": "12.0.3",
|
||||
"version": "13.1.1",
|
||||
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,36 +24,35 @@
|
||||
"dependencies": {
|
||||
"debug": "^4.1.0",
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"lodash": "^4.17.13",
|
||||
"lodash.set": "^4.3.2",
|
||||
"propagate": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sinonjs/fake-timers": "^7.0.2",
|
||||
"assert-rejects": "^1.0.0",
|
||||
"chai": "^4.1.2",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"dtslint": "^3.0.0",
|
||||
"eslint": "^6.0.0",
|
||||
"eslint-config-prettier": "^6.0.0",
|
||||
"eslint-config-standard": "^14.0.0",
|
||||
"dtslint": "^4.0.4",
|
||||
"eslint": "^7.3.1",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-config-standard": "^16.0.2",
|
||||
"eslint-plugin-import": "^2.16.0",
|
||||
"eslint-plugin-mocha": "^6.2.0",
|
||||
"eslint-plugin-mocha": "^8.0.0",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"eslint-plugin-promise": "^4.1.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"got": "^10.5.2",
|
||||
"@sinonjs/fake-timers": "^6.0.0",
|
||||
"mocha": "^7.0.1",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"form-data": "^4.0.0",
|
||||
"got": "^11.3.0",
|
||||
"mocha": "^8.0.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "1.19.0",
|
||||
"prettier": "2.2.1",
|
||||
"proxyquire": "^2.1.0",
|
||||
"request": "^2.83.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"semantic-release": "^17.0.2",
|
||||
"sinon": "^9.0.0",
|
||||
"sinon": "^10.0.0",
|
||||
"sinon-chai": "^3.3.0",
|
||||
"superagent": "^5.0.2",
|
||||
"tap": "14.6.1"
|
||||
"typescript": "^4.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"format:fix": "prettier --write '**/*.{js,json,md,ts,yml,yaml}'",
|
||||
@@ -62,25 +61,29 @@
|
||||
"lint:js": "eslint --cache --cache-location './.cache/eslint' '**/*.js'",
|
||||
"lint:js:fix": "eslint --cache --cache-location './.cache/eslint' --fix '**/*.js'",
|
||||
"lint:ts": "dtslint types",
|
||||
"semantic-release": "semantic-release",
|
||||
"test": "run-s test:mocha test:tap",
|
||||
"test:coverage": "tap --coverage-report=html && open coverage/lcov-report/index.html",
|
||||
"test:mocha": "nyc mocha $(grep -lr '^\\s*it(' tests)",
|
||||
"test:tap": "tap --100 --coverage --coverage-report=text ./tests/test_*.js"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
],
|
||||
"exclude": [
|
||||
"tests/"
|
||||
]
|
||||
"test": "nyc mocha tests",
|
||||
"test:coverage": "open coverage/lcov-report/index.html"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib",
|
||||
"types/index.d.ts"
|
||||
]
|
||||
],
|
||||
"release": {
|
||||
"branches": [
|
||||
"+([0-9])?(.{+([0-9]),x}).x",
|
||||
"main",
|
||||
"next",
|
||||
"next-major",
|
||||
{
|
||||
"name": "beta",
|
||||
"prerelease": true
|
||||
},
|
||||
{
|
||||
"name": "alpha",
|
||||
"prerelease": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
4
node_modules/nock/types/index.d.ts
generated
vendored
4
node_modules/nock/types/index.d.ts
generated
vendored
@@ -52,7 +52,7 @@ declare namespace nock {
|
||||
| RegExp
|
||||
| DataMatcherArray
|
||||
| DataMatcherMap
|
||||
interface DataMatcherArray extends Array<DataMatcher> {}
|
||||
interface DataMatcherArray extends ReadonlyArray<DataMatcher> {}
|
||||
interface DataMatcherMap {
|
||||
[key: string]: DataMatcher
|
||||
}
|
||||
@@ -120,7 +120,6 @@ declare namespace nock {
|
||||
filteringRequestBody(regex: RegExp, replace: string): this
|
||||
filteringRequestBody(fn: (body: string) => string): this
|
||||
|
||||
log(out: (message: any, ...optionalParams: any[]) => void): this
|
||||
persist(flag?: boolean): this
|
||||
replyContentLength(): this
|
||||
replyDate(d?: Date): this
|
||||
@@ -204,7 +203,6 @@ declare namespace nock {
|
||||
delay(opts: number | { head?: number; body?: number }): this
|
||||
delayBody(timeMs: number): this
|
||||
delayConnection(timeMs: number): this
|
||||
socketDelay(timeMs: number): this
|
||||
}
|
||||
|
||||
interface Options {
|
||||
|
||||
6
node_modules/tunnel/.idea/encodings.xml
generated
vendored
6
node_modules/tunnel/.idea/encodings.xml
generated
vendored
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
8
node_modules/tunnel/.idea/modules.xml
generated
vendored
8
node_modules/tunnel/.idea/modules.xml
generated
vendored
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/node-tunnel.iml" filepath="$PROJECT_DIR$/.idea/node-tunnel.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
12
node_modules/tunnel/.idea/node-tunnel.iml
generated
vendored
12
node_modules/tunnel/.idea/node-tunnel.iml
generated
vendored
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
node_modules/tunnel/.idea/vcs.xml
generated
vendored
6
node_modules/tunnel/.idea/vcs.xml
generated
vendored
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
797
node_modules/tunnel/.idea/workspace.xml
generated
vendored
797
node_modules/tunnel/.idea/workspace.xml
generated
vendored
@@ -1,797 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3caed8aa-31ae-4b3d-ad18-6f9796663516" name="Default" comment="">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.travis.yml" afterPath="$PROJECT_DIR$/.travis.yml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/CHANGELOG.md" afterPath="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.tmp/" />
|
||||
<ignored path="$PROJECT_DIR$/temp/" />
|
||||
<ignored path="$PROJECT_DIR$/tmp/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="package.json" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/package.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="34">
|
||||
<caret line="2" column="19" lean-forward="false" selection-start-line="2" selection-start-column="19" selection-end-line="2" selection-end-column="19" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="2312">
|
||||
<caret line="136" column="67" lean-forward="false" selection-start-line="136" selection-start-column="67" selection-end-line="136" selection-end-column="67" />
|
||||
<folding>
|
||||
<marker date="1497272379133" expanded="true" signature="590:646" ph="{...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="601:644" ph="{"host": 'localhost'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="674:737" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="884:1330" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="964:1328" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1103:1192" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1290:1324" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1357:1419" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1514:2209" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1540:1623" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1842:2207" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1981:2070" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2168:2202" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2237:2300" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2395:3180" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2475:3178" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2615:2704" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2802:2836" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3207:3269" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3366:4398" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3392:3475" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="3694:4396" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3834:3923" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="4021:4055" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="4426:4489" ph="{"host": 'example.com'...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name=".travis.yml" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/.travis.yml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="6" column="0" lean-forward="true" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="tunnel.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/tunnel.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="697">
|
||||
<caret line="41" column="19" lean-forward="false" selection-start-line="41" selection-start-column="19" selection-end-line="41" selection-end-column="19" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="http-over-http-error.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http-error.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="935">
|
||||
<caret line="55" column="26" lean-forward="true" selection-start-line="55" selection-start-column="26" selection-end-line="55" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="http-over-http-error2.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http-error2.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1207">
|
||||
<caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="https-over-http.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-http.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1479">
|
||||
<caret line="87" column="0" lean-forward="false" selection-start-line="87" selection-start-column="0" selection-end-line="87" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="https-over-https.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-https.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="http-over-http.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1088">
|
||||
<caret line="64" column="26" lean-forward="true" selection-start-line="64" selection-start-column="26" selection-end-line="64" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="102">
|
||||
<caret line="6" column="0" lean-forward="false" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
|
||||
<folding />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="JavaScript File" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>max</find>
|
||||
<find>onconne</find>
|
||||
</findStrings>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/test/http-over-http-error.js" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
<option value="$PROJECT_DIR$/package.json" />
|
||||
<option value="$PROJECT_DIR$/test/http-over-http-error2.js" />
|
||||
<option value="$PROJECT_DIR$/test/https-over-http-localaddress.js" />
|
||||
<option value="$PROJECT_DIR$/test/https-over-http.js" />
|
||||
<option value="$PROJECT_DIR$/lib/tunnel.js" />
|
||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<option value="$PROJECT_DIR$/.travis.yml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
|
||||
<package-json value="$PROJECT_DIR$/package.json" />
|
||||
</component>
|
||||
<component name="JsFlowSettings">
|
||||
<service-enabled>false</service-enabled>
|
||||
<exe-path />
|
||||
<annotation-enable>false</annotation-enable>
|
||||
<other-services-enabled>false</other-services-enabled>
|
||||
<auto-save>true</auto-save>
|
||||
</component>
|
||||
<component name="JsGulpfileManager">
|
||||
<detection-done>true</detection-done>
|
||||
<sorting>DEFINITION_ORDER</sorting>
|
||||
</component>
|
||||
<component name="NodeModulesDirectoryManager">
|
||||
<handled-path value="$PROJECT_DIR$/node_modules" />
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="785" />
|
||||
<option name="y" value="40" />
|
||||
<option name="width" value="1788" />
|
||||
<option name="height" value="1407" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
<showLibraryContents />
|
||||
<hideEmptyPackages />
|
||||
<abbreviatePackageNames />
|
||||
<autoscrollToSource />
|
||||
<autoscrollFromSource ProjectPane="true" />
|
||||
<sortByType />
|
||||
<manualOrder />
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="Scratches" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="node-tunnel" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="node-tunnel" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="node-tunnel" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="node-tunnel" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="node-tunnel" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="node-tunnel" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="test" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="HbShouldOpenHtmlAsHb" value="" />
|
||||
<property name="nodejs_interpreter_path" value="$PROJECT_DIR$/../../nvmw/v6.10.3/node" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\koichik\git\koichik\node-tunnel\test" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
|
||||
<node-interpreter>project</node-interpreter>
|
||||
<node-options />
|
||||
<gulpfile />
|
||||
<tasks />
|
||||
<arguments />
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="DartTestRunConfigurationType" factoryName="Dart Test">
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="JavaScriptTestRunnerJest" factoryName="Jest">
|
||||
<node-interpreter value="project" />
|
||||
<working-dir value="" />
|
||||
<envs />
|
||||
<scope-kind value="ALL" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma">
|
||||
<config-file value="" />
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="JavaScriptTestRunnerProtractor" factoryName="Protractor">
|
||||
<config-file value="" />
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="project" working-dir="">
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="cucumber.js" factoryName="Cucumber.js">
|
||||
<option name="cucumberJsArguments" value="" />
|
||||
<option name="executablePath" />
|
||||
<option name="filePath" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="js.build_tools.npm" factoryName="npm">
|
||||
<command value="run" />
|
||||
<scripts />
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
|
||||
<node-interpreter>project</node-interpreter>
|
||||
<node-options />
|
||||
<working-directory />
|
||||
<pass-parent-env>true</pass-parent-env>
|
||||
<envs />
|
||||
<ui />
|
||||
<extra-mocha-options />
|
||||
<test-kind>DIRECTORY</test-kind>
|
||||
<test-directory />
|
||||
<recursive>false</recursive>
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="ShelveChangesManager" show_recycled="false">
|
||||
<option name="remove_strategy" value="false" />
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="3caed8aa-31ae-4b3d-ad18-6f9796663516" name="Default" comment="" />
|
||||
<created>1497256565348</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1497256565348</updated>
|
||||
<workItem from="1497256566573" duration="8794000" />
|
||||
<workItem from="1497272051717" duration="2328000" />
|
||||
<workItem from="1536577850117" duration="8708000" />
|
||||
<workItem from="1536636907096" duration="739000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="20569000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="785" y="40" width="1788" height="1407" extended-state="0" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="SvgViewer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32967034" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/package.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="34">
|
||||
<caret line="2" column="19" lean-forward="false" selection-start-line="2" selection-start-column="19" selection-end-line="2" selection-end-column="19" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="2312">
|
||||
<caret line="136" column="67" lean-forward="false" selection-start-line="136" selection-start-column="67" selection-end-line="136" selection-end-column="67" />
|
||||
<folding>
|
||||
<marker date="1497272379133" expanded="true" signature="590:646" ph="{...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="601:644" ph="{"host": 'localhost'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="674:737" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="884:1330" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="964:1328" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1103:1192" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1290:1324" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1357:1419" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1514:2209" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1540:1623" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1842:2207" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1981:2070" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2168:2202" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2237:2300" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2395:3180" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2475:3178" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2615:2704" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2802:2836" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3207:3269" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3366:4398" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3392:3475" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="3694:4396" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3834:3923" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="4021:4055" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="4426:4489" ph="{"host": 'example.com'...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.travis.yml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="6" column="0" lean-forward="true" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http-error.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="935">
|
||||
<caret line="55" column="26" lean-forward="true" selection-start-line="55" selection-start-column="26" selection-end-line="55" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http-error2.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1207">
|
||||
<caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-http.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1479">
|
||||
<caret line="87" column="0" lean-forward="false" selection-start-line="87" selection-start-column="0" selection-end-line="87" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-https.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1088">
|
||||
<caret line="64" column="26" lean-forward="true" selection-start-line="64" selection-start-column="26" selection-end-line="64" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/tunnel.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="697">
|
||||
<caret line="41" column="19" lean-forward="false" selection-start-line="41" selection-start-column="19" selection-end-line="41" selection-end-column="19" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/package.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="34">
|
||||
<caret line="2" column="19" lean-forward="false" selection-start-line="2" selection-start-column="19" selection-end-line="2" selection-end-column="19" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="2312">
|
||||
<caret line="136" column="67" lean-forward="false" selection-start-line="136" selection-start-column="67" selection-end-line="136" selection-end-column="67" />
|
||||
<folding>
|
||||
<marker date="1497272379133" expanded="true" signature="590:646" ph="{...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="601:644" ph="{"host": 'localhost'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="674:737" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="884:1330" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="964:1328" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1103:1192" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1290:1324" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1357:1419" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1514:2209" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1540:1623" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1842:2207" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1981:2070" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2168:2202" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2237:2300" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2395:3180" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2475:3178" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2615:2704" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2802:2836" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3207:3269" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3366:4398" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3392:3475" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="3694:4396" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3834:3923" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="4021:4055" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="4426:4489" ph="{"host": 'example.com'...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/tunnel.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2550">
|
||||
<caret line="150" column="0" lean-forward="false" selection-start-line="150" selection-start-column="0" selection-end-line="150" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="51">
|
||||
<caret line="3" column="21" lean-forward="false" selection-start-line="3" selection-start-column="21" selection-end-line="3" selection-end-column="21" />
|
||||
<folding />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.travis.yml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="7" column="0" lean-forward="true" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/package.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<marker date="1497272379133" expanded="true" signature="590:646" ph="{...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="601:644" ph="{"host": 'localhost'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="674:737" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="884:1330" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="964:1328" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1103:1192" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1290:1324" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1357:1419" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1514:2209" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1540:1623" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1842:2207" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1981:2070" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2168:2202" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2237:2300" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2395:3180" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2475:3178" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2615:2704" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2802:2836" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3207:3269" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3366:4398" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3392:3475" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="3694:4396" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3834:3923" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="4021:4055" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="4426:4489" ph="{"host": 'example.com'...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.travis.yml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/tunnel.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2550">
|
||||
<caret line="150" column="0" lean-forward="false" selection-start-line="150" selection-start-column="0" selection-end-line="150" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-https.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-https-error.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="136">
|
||||
<caret line="8" column="0" lean-forward="false" selection-start-line="7" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http-error.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1309">
|
||||
<caret line="77" column="0" lean-forward="false" selection-start-line="77" selection-start-column="0" selection-end-line="77" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-https.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-https.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-https-error.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="2312">
|
||||
<caret line="136" column="67" lean-forward="false" selection-start-line="136" selection-start-column="67" selection-end-line="136" selection-end-column="67" />
|
||||
<folding>
|
||||
<marker date="1497272379133" expanded="true" signature="590:646" ph="{...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="601:644" ph="{"host": 'localhost'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="674:737" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="884:1330" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="964:1328" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1103:1192" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1290:1324" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1357:1419" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1514:2209" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1540:1623" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="1842:2207" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="1981:2070" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2168:2202" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2237:2300" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2395:3180" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2475:3178" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="2615:2704" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="2802:2836" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3207:3269" ph="{"host": 'example.com'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3366:4398" ph="{"maxSockets": poolSize...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3392:3475" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="3694:4396" ph="{"host": proxyHost...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="3834:3923" ph="//..." />
|
||||
<marker date="1497272379133" expanded="true" signature="4021:4055" ph="{"User-Agent": 'Node'...}" />
|
||||
<marker date="1497272379133" expanded="true" signature="4426:4489" ph="{"host": 'example.com'...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/package.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="34">
|
||||
<caret line="2" column="19" lean-forward="false" selection-start-line="2" selection-start-column="19" selection-end-line="2" selection-end-column="19" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http-error.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="935">
|
||||
<caret line="55" column="26" lean-forward="true" selection-start-line="55" selection-start-column="26" selection-end-line="55" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http-error2.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1207">
|
||||
<caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-http-localaddress.js" />
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-https.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/http-over-http.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1088">
|
||||
<caret line="64" column="26" lean-forward="true" selection-start-line="64" selection-start-column="26" selection-end-line="64" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/https-over-http.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1479">
|
||||
<caret line="87" column="0" lean-forward="false" selection-start-line="87" selection-start-column="0" selection-end-line="87" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/tunnel.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="697">
|
||||
<caret line="41" column="19" lean-forward="false" selection-start-line="41" selection-start-column="19" selection-end-line="41" selection-end-column="19" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="102">
|
||||
<caret line="6" column="0" lean-forward="false" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
|
||||
<folding />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.travis.yml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="6" column="0" lean-forward="true" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
||||
6
node_modules/tunnel/.travis.yml
generated
vendored
6
node_modules/tunnel/.travis.yml
generated
vendored
@@ -1,6 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4"
|
||||
- "6"
|
||||
- "8"
|
||||
- "10"
|
||||
22
node_modules/tunnel/CHANGELOG.md
generated
vendored
22
node_modules/tunnel/CHANGELOG.md
generated
vendored
@@ -1,22 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
- 0.0.6 (2018/09/11)
|
||||
- Fix `localAddress` not working (#25)
|
||||
- Fix `Host:` header for CONNECT method by @tmurakam (#29, #30)
|
||||
- Fix default port for https (#32)
|
||||
- Fix error handling when the proxy send illegal response body (#33)
|
||||
|
||||
- 0.0.5 (2017/06/12)
|
||||
- Fix socket leak.
|
||||
|
||||
- 0.0.4 (2016/01/23)
|
||||
- supported Node v0.12 or later.
|
||||
|
||||
- 0.0.3 (2014/01/20)
|
||||
- fixed package.json
|
||||
|
||||
- 0.0.1 (2012/02/18)
|
||||
- supported Node v0.6.x (0.6.11 or later).
|
||||
|
||||
- 0.0.0 (2012/02/11)
|
||||
- first release.
|
||||
21
node_modules/tunnel/LICENSE
generated
vendored
21
node_modules/tunnel/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
185
node_modules/tunnel/README.md
generated
vendored
185
node_modules/tunnel/README.md
generated
vendored
@@ -1,185 +0,0 @@
|
||||
# node-tunnel - HTTP/HTTPS Agents for tunneling proxies
|
||||
|
||||
[](https://travis-ci.org/koichik/node-tunnel)
|
||||
[](https://david-dm.org/koichik/node-tunnel#info=dependencies)
|
||||
[](https://david-dm.org/koichik/node-tunnel#info=devDependencies)
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
var tunnel = require('tunnel');
|
||||
|
||||
var tunnelingAgent = tunnel.httpsOverHttp({
|
||||
proxy: {
|
||||
host: 'localhost',
|
||||
port: 3128
|
||||
}
|
||||
});
|
||||
|
||||
var req = https.request({
|
||||
host: 'example.com',
|
||||
port: 443,
|
||||
agent: tunnelingAgent
|
||||
});
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install tunnel
|
||||
|
||||
## Usages
|
||||
|
||||
### HTTP over HTTP tunneling
|
||||
|
||||
```javascript
|
||||
var tunnelingAgent = tunnel.httpOverHttp({
|
||||
maxSockets: poolSize, // Defaults to http.Agent.defaultMaxSockets
|
||||
|
||||
proxy: { // Proxy settings
|
||||
host: proxyHost, // Defaults to 'localhost'
|
||||
port: proxyPort, // Defaults to 80
|
||||
localAddress: localAddress, // Local interface if necessary
|
||||
|
||||
// Basic authorization for proxy server if necessary
|
||||
proxyAuth: 'user:password',
|
||||
|
||||
// Header fields for proxy server if necessary
|
||||
headers: {
|
||||
'User-Agent': 'Node'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var req = http.request({
|
||||
host: 'example.com',
|
||||
port: 80,
|
||||
agent: tunnelingAgent
|
||||
});
|
||||
```
|
||||
|
||||
### HTTPS over HTTP tunneling
|
||||
|
||||
```javascript
|
||||
var tunnelingAgent = tunnel.httpsOverHttp({
|
||||
maxSockets: poolSize, // Defaults to http.Agent.defaultMaxSockets
|
||||
|
||||
// CA for origin server if necessary
|
||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
||||
|
||||
// Client certification for origin server if necessary
|
||||
key: fs.readFileSync('origin-server-key.pem'),
|
||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
||||
|
||||
proxy: { // Proxy settings
|
||||
host: proxyHost, // Defaults to 'localhost'
|
||||
port: proxyPort, // Defaults to 80
|
||||
localAddress: localAddress, // Local interface if necessary
|
||||
|
||||
// Basic authorization for proxy server if necessary
|
||||
proxyAuth: 'user:password',
|
||||
|
||||
// Header fields for proxy server if necessary
|
||||
headers: {
|
||||
'User-Agent': 'Node'
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
var req = https.request({
|
||||
host: 'example.com',
|
||||
port: 443,
|
||||
agent: tunnelingAgent
|
||||
});
|
||||
```
|
||||
|
||||
### HTTP over HTTPS tunneling
|
||||
|
||||
```javascript
|
||||
var tunnelingAgent = tunnel.httpOverHttps({
|
||||
maxSockets: poolSize, // Defaults to http.Agent.defaultMaxSockets
|
||||
|
||||
proxy: { // Proxy settings
|
||||
host: proxyHost, // Defaults to 'localhost'
|
||||
port: proxyPort, // Defaults to 443
|
||||
localAddress: localAddress, // Local interface if necessary
|
||||
|
||||
// Basic authorization for proxy server if necessary
|
||||
proxyAuth: 'user:password',
|
||||
|
||||
// Header fields for proxy server if necessary
|
||||
headers: {
|
||||
'User-Agent': 'Node'
|
||||
},
|
||||
|
||||
// CA for proxy server if necessary
|
||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
||||
|
||||
// Server name for verification if necessary
|
||||
servername: 'example.com',
|
||||
|
||||
// Client certification for proxy server if necessary
|
||||
key: fs.readFileSync('origin-server-key.pem'),
|
||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
||||
}
|
||||
});
|
||||
|
||||
var req = http.request({
|
||||
host: 'example.com',
|
||||
port: 80,
|
||||
agent: tunnelingAgent
|
||||
});
|
||||
```
|
||||
|
||||
### HTTPS over HTTPS tunneling
|
||||
|
||||
```javascript
|
||||
var tunnelingAgent = tunnel.httpsOverHttps({
|
||||
maxSockets: poolSize, // Defaults to http.Agent.defaultMaxSockets
|
||||
|
||||
// CA for origin server if necessary
|
||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
||||
|
||||
// Client certification for origin server if necessary
|
||||
key: fs.readFileSync('origin-server-key.pem'),
|
||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
||||
|
||||
proxy: { // Proxy settings
|
||||
host: proxyHost, // Defaults to 'localhost'
|
||||
port: proxyPort, // Defaults to 443
|
||||
localAddress: localAddress, // Local interface if necessary
|
||||
|
||||
// Basic authorization for proxy server if necessary
|
||||
proxyAuth: 'user:password',
|
||||
|
||||
// Header fields for proxy server if necessary
|
||||
headers: {
|
||||
'User-Agent': 'Node'
|
||||
}
|
||||
|
||||
// CA for proxy server if necessary
|
||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
||||
|
||||
// Server name for verification if necessary
|
||||
servername: 'example.com',
|
||||
|
||||
// Client certification for proxy server if necessary
|
||||
key: fs.readFileSync('origin-server-key.pem'),
|
||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
||||
}
|
||||
});
|
||||
|
||||
var req = https.request({
|
||||
host: 'example.com',
|
||||
port: 443,
|
||||
agent: tunnelingAgent
|
||||
});
|
||||
```
|
||||
|
||||
## CONTRIBUTORS
|
||||
* [Aleksis Brezas (abresas)](https://github.com/abresas)
|
||||
* [Jackson Tian (JacksonTian)](https://github.com/JacksonTian)
|
||||
* [Dmitry Sorin (1999)](https://github.com/1999)
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the [MIT](https://github.com/koichik/node-tunnel/blob/master/LICENSE) license.
|
||||
1
node_modules/tunnel/index.js
generated
vendored
1
node_modules/tunnel/index.js
generated
vendored
@@ -1 +0,0 @@
|
||||
module.exports = require('./lib/tunnel');
|
||||
264
node_modules/tunnel/lib/tunnel.js
generated
vendored
264
node_modules/tunnel/lib/tunnel.js
generated
vendored
@@ -1,264 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var events = require('events');
|
||||
var assert = require('assert');
|
||||
var util = require('util');
|
||||
|
||||
|
||||
exports.httpOverHttp = httpOverHttp;
|
||||
exports.httpsOverHttp = httpsOverHttp;
|
||||
exports.httpOverHttps = httpOverHttps;
|
||||
exports.httpsOverHttps = httpsOverHttps;
|
||||
|
||||
|
||||
function httpOverHttp(options) {
|
||||
var agent = new TunnelingAgent(options);
|
||||
agent.request = http.request;
|
||||
return agent;
|
||||
}
|
||||
|
||||
function httpsOverHttp(options) {
|
||||
var agent = new TunnelingAgent(options);
|
||||
agent.request = http.request;
|
||||
agent.createSocket = createSecureSocket;
|
||||
agent.defaultPort = 443;
|
||||
return agent;
|
||||
}
|
||||
|
||||
function httpOverHttps(options) {
|
||||
var agent = new TunnelingAgent(options);
|
||||
agent.request = https.request;
|
||||
return agent;
|
||||
}
|
||||
|
||||
function httpsOverHttps(options) {
|
||||
var agent = new TunnelingAgent(options);
|
||||
agent.request = https.request;
|
||||
agent.createSocket = createSecureSocket;
|
||||
agent.defaultPort = 443;
|
||||
return agent;
|
||||
}
|
||||
|
||||
|
||||
function TunnelingAgent(options) {
|
||||
var self = this;
|
||||
self.options = options || {};
|
||||
self.proxyOptions = self.options.proxy || {};
|
||||
self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;
|
||||
self.requests = [];
|
||||
self.sockets = [];
|
||||
|
||||
self.on('free', function onFree(socket, host, port, localAddress) {
|
||||
var options = toOptions(host, port, localAddress);
|
||||
for (var i = 0, len = self.requests.length; i < len; ++i) {
|
||||
var pending = self.requests[i];
|
||||
if (pending.host === options.host && pending.port === options.port) {
|
||||
// Detect the request to connect same origin server,
|
||||
// reuse the connection.
|
||||
self.requests.splice(i, 1);
|
||||
pending.request.onSocket(socket);
|
||||
return;
|
||||
}
|
||||
}
|
||||
socket.destroy();
|
||||
self.removeSocket(socket);
|
||||
});
|
||||
}
|
||||
util.inherits(TunnelingAgent, events.EventEmitter);
|
||||
|
||||
TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) {
|
||||
var self = this;
|
||||
var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress));
|
||||
|
||||
if (self.sockets.length >= this.maxSockets) {
|
||||
// We are over limit so we'll add it to the queue.
|
||||
self.requests.push(options);
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are under maxSockets create a new one.
|
||||
self.createSocket(options, function(socket) {
|
||||
socket.on('free', onFree);
|
||||
socket.on('close', onCloseOrRemove);
|
||||
socket.on('agentRemove', onCloseOrRemove);
|
||||
req.onSocket(socket);
|
||||
|
||||
function onFree() {
|
||||
self.emit('free', socket, options);
|
||||
}
|
||||
|
||||
function onCloseOrRemove(err) {
|
||||
self.removeSocket(socket);
|
||||
socket.removeListener('free', onFree);
|
||||
socket.removeListener('close', onCloseOrRemove);
|
||||
socket.removeListener('agentRemove', onCloseOrRemove);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
TunnelingAgent.prototype.createSocket = function createSocket(options, cb) {
|
||||
var self = this;
|
||||
var placeholder = {};
|
||||
self.sockets.push(placeholder);
|
||||
|
||||
var connectOptions = mergeOptions({}, self.proxyOptions, {
|
||||
method: 'CONNECT',
|
||||
path: options.host + ':' + options.port,
|
||||
agent: false,
|
||||
headers: {
|
||||
host: options.host + ':' + options.port
|
||||
}
|
||||
});
|
||||
if (options.localAddress) {
|
||||
connectOptions.localAddress = options.localAddress;
|
||||
}
|
||||
if (connectOptions.proxyAuth) {
|
||||
connectOptions.headers = connectOptions.headers || {};
|
||||
connectOptions.headers['Proxy-Authorization'] = 'Basic ' +
|
||||
new Buffer(connectOptions.proxyAuth).toString('base64');
|
||||
}
|
||||
|
||||
debug('making CONNECT request');
|
||||
var connectReq = self.request(connectOptions);
|
||||
connectReq.useChunkedEncodingByDefault = false; // for v0.6
|
||||
connectReq.once('response', onResponse); // for v0.6
|
||||
connectReq.once('upgrade', onUpgrade); // for v0.6
|
||||
connectReq.once('connect', onConnect); // for v0.7 or later
|
||||
connectReq.once('error', onError);
|
||||
connectReq.end();
|
||||
|
||||
function onResponse(res) {
|
||||
// Very hacky. This is necessary to avoid http-parser leaks.
|
||||
res.upgrade = true;
|
||||
}
|
||||
|
||||
function onUpgrade(res, socket, head) {
|
||||
// Hacky.
|
||||
process.nextTick(function() {
|
||||
onConnect(res, socket, head);
|
||||
});
|
||||
}
|
||||
|
||||
function onConnect(res, socket, head) {
|
||||
connectReq.removeAllListeners();
|
||||
socket.removeAllListeners();
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
debug('tunneling socket could not be established, statusCode=%d',
|
||||
res.statusCode);
|
||||
socket.destroy();
|
||||
var error = new Error('tunneling socket could not be established, ' +
|
||||
'statusCode=' + res.statusCode);
|
||||
error.code = 'ECONNRESET';
|
||||
options.request.emit('error', error);
|
||||
self.removeSocket(placeholder);
|
||||
return;
|
||||
}
|
||||
if (head.length > 0) {
|
||||
debug('got illegal response body from proxy');
|
||||
socket.destroy();
|
||||
var error = new Error('got illegal response body from proxy');
|
||||
error.code = 'ECONNRESET';
|
||||
options.request.emit('error', error);
|
||||
self.removeSocket(placeholder);
|
||||
return;
|
||||
}
|
||||
debug('tunneling connection has established');
|
||||
self.sockets[self.sockets.indexOf(placeholder)] = socket;
|
||||
return cb(socket);
|
||||
}
|
||||
|
||||
function onError(cause) {
|
||||
connectReq.removeAllListeners();
|
||||
|
||||
debug('tunneling socket could not be established, cause=%s\n',
|
||||
cause.message, cause.stack);
|
||||
var error = new Error('tunneling socket could not be established, ' +
|
||||
'cause=' + cause.message);
|
||||
error.code = 'ECONNRESET';
|
||||
options.request.emit('error', error);
|
||||
self.removeSocket(placeholder);
|
||||
}
|
||||
};
|
||||
|
||||
TunnelingAgent.prototype.removeSocket = function removeSocket(socket) {
|
||||
var pos = this.sockets.indexOf(socket)
|
||||
if (pos === -1) {
|
||||
return;
|
||||
}
|
||||
this.sockets.splice(pos, 1);
|
||||
|
||||
var pending = this.requests.shift();
|
||||
if (pending) {
|
||||
// If we have pending requests and a socket gets closed a new one
|
||||
// needs to be created to take over in the pool for the one that closed.
|
||||
this.createSocket(pending, function(socket) {
|
||||
pending.request.onSocket(socket);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function createSecureSocket(options, cb) {
|
||||
var self = this;
|
||||
TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {
|
||||
var hostHeader = options.request.getHeader('host');
|
||||
var tlsOptions = mergeOptions({}, self.options, {
|
||||
socket: socket,
|
||||
servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host
|
||||
});
|
||||
|
||||
// 0 is dummy port for v0.6
|
||||
var secureSocket = tls.connect(0, tlsOptions);
|
||||
self.sockets[self.sockets.indexOf(socket)] = secureSocket;
|
||||
cb(secureSocket);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function toOptions(host, port, localAddress) {
|
||||
if (typeof host === 'string') { // since v0.10
|
||||
return {
|
||||
host: host,
|
||||
port: port,
|
||||
localAddress: localAddress
|
||||
};
|
||||
}
|
||||
return host; // for v0.11 or later
|
||||
}
|
||||
|
||||
function mergeOptions(target) {
|
||||
for (var i = 1, len = arguments.length; i < len; ++i) {
|
||||
var overrides = arguments[i];
|
||||
if (typeof overrides === 'object') {
|
||||
var keys = Object.keys(overrides);
|
||||
for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {
|
||||
var k = keys[j];
|
||||
if (overrides[k] !== undefined) {
|
||||
target[k] = overrides[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
var debug;
|
||||
if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
||||
debug = function() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
if (typeof args[0] === 'string') {
|
||||
args[0] = 'TUNNEL: ' + args[0];
|
||||
} else {
|
||||
args.unshift('TUNNEL:');
|
||||
}
|
||||
console.error.apply(console, args);
|
||||
}
|
||||
} else {
|
||||
debug = function() {};
|
||||
}
|
||||
exports.debug = debug; // for test
|
||||
34
node_modules/tunnel/package.json
generated
vendored
34
node_modules/tunnel/package.json
generated
vendored
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"name": "tunnel",
|
||||
"version": "0.0.6",
|
||||
"description": "Node HTTP/HTTPS Agents for tunneling proxies",
|
||||
"keywords": [
|
||||
"http",
|
||||
"https",
|
||||
"agent",
|
||||
"proxy",
|
||||
"tunnel"
|
||||
],
|
||||
"homepage": "https://github.com/koichik/node-tunnel/",
|
||||
"bugs": "https://github.com/koichik/node-tunnel/issues",
|
||||
"license": "MIT",
|
||||
"author": "Koichi Kobayashi <koichik@improvement.jp>",
|
||||
"main": "./index.js",
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/koichik/node-tunnel.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^5.2.0",
|
||||
"should": "^13.2.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user