This commit is contained in:
2022-09-30 05:39:11 +00:00
parent 41ee9463ae
commit 4687fa49bc
11418 changed files with 1312504 additions and 0 deletions

18
buildfiles/node_modules/global-agent/dist/Logger.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _roarr = _interopRequireDefault(require("roarr"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const Logger = _roarr.default.child({
package: 'global-agent'
});
var _default = Logger;
exports.default = _default;
//# sourceMappingURL=Logger.js.map

View File

@ -0,0 +1,10 @@
// @flow
import Roarr from 'roarr';
const Logger = Roarr
.child({
package: 'global-agent',
});
export default Logger;

View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/Logger.js"],"names":["Logger","Roarr","child","package"],"mappings":";;;;;;;AAEA;;;;AAEA,MAAMA,MAAM,GAAGC,eACZC,KADY,CACN;AACLC,EAAAA,OAAO,EAAE;AADJ,CADM,CAAf;;eAKeH,M","sourcesContent":["// @flow\n\nimport Roarr from 'roarr';\n\nconst Logger = Roarr\n .child({\n package: 'global-agent',\n });\n\nexport default Logger;\n"],"file":"Logger.js"}

View File

@ -0,0 +1,174 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _serializeError = require("serialize-error");
var _boolean = require("boolean");
var _Logger = _interopRequireDefault(require("../Logger"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const log = _Logger.default.child({
namespace: 'Agent'
});
let requestId = 0;
class Agent {
constructor(isProxyConfigured, mustUrlUseProxy, getUrlProxy, fallbackAgent, socketConnectionTimeout) {
this.fallbackAgent = fallbackAgent;
this.isProxyConfigured = isProxyConfigured;
this.mustUrlUseProxy = mustUrlUseProxy;
this.getUrlProxy = getUrlProxy;
this.socketConnectionTimeout = socketConnectionTimeout;
}
addRequest(request, configuration) {
let requestUrl; // It is possible that addRequest was constructed for a proxied request already, e.g.
// "request" package does this when it detects that a proxy should be used
// https://github.com/request/request/blob/212570b6971a732b8dd9f3c73354bcdda158a737/request.js#L402
// https://gist.github.com/gajus/e2074cd3b747864ffeaabbd530d30218
if (request.path.startsWith('http://') || request.path.startsWith('https://')) {
requestUrl = request.path;
} else {
requestUrl = this.protocol + '//' + (configuration.hostname || configuration.host) + (configuration.port === 80 || configuration.port === 443 ? '' : ':' + configuration.port) + request.path;
}
if (!this.isProxyConfigured()) {
log.trace({
destination: requestUrl
}, 'not proxying request; GLOBAL_AGENT.HTTP_PROXY is not configured'); // $FlowFixMe It appears that Flow is missing the method description.
this.fallbackAgent.addRequest(request, configuration);
return;
}
if (!this.mustUrlUseProxy(requestUrl)) {
log.trace({
destination: requestUrl
}, 'not proxying request; url matches GLOBAL_AGENT.NO_PROXY'); // $FlowFixMe It appears that Flow is missing the method description.
this.fallbackAgent.addRequest(request, configuration);
return;
}
const currentRequestId = requestId++;
const proxy = this.getUrlProxy(requestUrl);
if (this.protocol === 'http:') {
request.path = requestUrl;
if (proxy.authorization) {
request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64'));
}
}
log.trace({
destination: requestUrl,
proxy: 'http://' + proxy.hostname + ':' + proxy.port,
requestId: currentRequestId
}, 'proxying request');
request.on('error', error => {
log.error({
error: (0, _serializeError.serializeError)(error)
}, 'request error');
});
request.once('response', response => {
log.trace({
headers: response.headers,
requestId: currentRequestId,
statusCode: response.statusCode
}, 'proxying response');
});
request.shouldKeepAlive = false;
const connectionConfiguration = {
host: configuration.hostname || configuration.host,
port: configuration.port || 80,
proxy,
tls: {}
}; // add optional tls options for https requests.
// @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback :
// > The following additional options from tls.connect()
// > - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback -
// > are also accepted:
// > ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder,
// > key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext.
if (this.protocol === 'https:') {
connectionConfiguration.tls = {
ca: configuration.ca,
cert: configuration.cert,
ciphers: configuration.ciphers,
clientCertEngine: configuration.clientCertEngine,
crl: configuration.crl,
dhparam: configuration.dhparam,
ecdhCurve: configuration.ecdhCurve,
honorCipherOrder: configuration.honorCipherOrder,
key: configuration.key,
passphrase: configuration.passphrase,
pfx: configuration.pfx,
rejectUnauthorized: configuration.rejectUnauthorized,
secureOptions: configuration.secureOptions,
secureProtocol: configuration.secureProtocol,
servername: configuration.servername || connectionConfiguration.host,
sessionIdContext: configuration.sessionIdContext
}; // This is not ideal because there is no way to override this setting using `tls` configuration if `NODE_TLS_REJECT_UNAUTHORIZED=0`.
// However, popular HTTP clients (such as https://github.com/sindresorhus/got) come with pre-configured value for `rejectUnauthorized`,
// which makes it impossible to override that value globally and respect `rejectUnauthorized` for specific requests only.
//
// eslint-disable-next-line no-process-env
if (typeof process.env.NODE_TLS_REJECT_UNAUTHORIZED === 'string' && (0, _boolean.boolean)(process.env.NODE_TLS_REJECT_UNAUTHORIZED) === false) {
connectionConfiguration.tls.rejectUnauthorized = false;
}
} // $FlowFixMe It appears that Flow is missing the method description.
this.createConnection(connectionConfiguration, (error, socket) => {
log.trace({
target: connectionConfiguration
}, 'connecting'); // @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057
if (socket) {
socket.setTimeout(this.socketConnectionTimeout, () => {
socket.destroy();
});
socket.once('connect', () => {
log.trace({
target: connectionConfiguration
}, 'connected');
socket.setTimeout(0);
});
socket.once('secureConnect', () => {
log.trace({
target: connectionConfiguration
}, 'connected (secure)');
socket.setTimeout(0);
});
}
if (error) {
request.emit('error', error);
} else {
log.debug('created socket');
socket.on('error', socketError => {
log.error({
error: (0, _serializeError.serializeError)(socketError)
}, 'socket error');
});
request.onSocket(socket);
}
});
}
}
var _default = Agent;
exports.default = _default;
//# sourceMappingURL=Agent.js.map

View File

@ -0,0 +1,212 @@
// @flow
import {
serializeError,
} from 'serialize-error';
import {
boolean,
} from 'boolean';
import Logger from '../Logger';
import type {
AgentType,
GetUrlProxyMethodType,
IsProxyConfiguredMethodType,
MustUrlUseProxyMethodType,
ProtocolType,
} from '../types';
const log = Logger.child({
namespace: 'Agent',
});
let requestId = 0;
class Agent {
defaultPort: number;
protocol: ProtocolType;
fallbackAgent: AgentType;
isProxyConfigured: IsProxyConfiguredMethodType;
mustUrlUseProxy: MustUrlUseProxyMethodType;
getUrlProxy: GetUrlProxyMethodType;
socketConnectionTimeout: number;
constructor (
isProxyConfigured: IsProxyConfiguredMethodType,
mustUrlUseProxy: MustUrlUseProxyMethodType,
getUrlProxy: GetUrlProxyMethodType,
fallbackAgent: AgentType,
socketConnectionTimeout: number,
) {
this.fallbackAgent = fallbackAgent;
this.isProxyConfigured = isProxyConfigured;
this.mustUrlUseProxy = mustUrlUseProxy;
this.getUrlProxy = getUrlProxy;
this.socketConnectionTimeout = socketConnectionTimeout;
}
addRequest (request: *, configuration: *) {
let requestUrl;
// It is possible that addRequest was constructed for a proxied request already, e.g.
// "request" package does this when it detects that a proxy should be used
// https://github.com/request/request/blob/212570b6971a732b8dd9f3c73354bcdda158a737/request.js#L402
// https://gist.github.com/gajus/e2074cd3b747864ffeaabbd530d30218
if (request.path.startsWith('http://') || request.path.startsWith('https://')) {
requestUrl = request.path;
} else {
requestUrl = this.protocol + '//' + (configuration.hostname || configuration.host) + (configuration.port === 80 || configuration.port === 443 ? '' : ':' + configuration.port) + request.path;
}
if (!this.isProxyConfigured()) {
log.trace({
destination: requestUrl,
}, 'not proxying request; GLOBAL_AGENT.HTTP_PROXY is not configured');
// $FlowFixMe It appears that Flow is missing the method description.
this.fallbackAgent.addRequest(request, configuration);
return;
}
if (!this.mustUrlUseProxy(requestUrl)) {
log.trace({
destination: requestUrl,
}, 'not proxying request; url matches GLOBAL_AGENT.NO_PROXY');
// $FlowFixMe It appears that Flow is missing the method description.
this.fallbackAgent.addRequest(request, configuration);
return;
}
const currentRequestId = requestId++;
const proxy = this.getUrlProxy(requestUrl);
if (this.protocol === 'http:') {
request.path = requestUrl;
if (proxy.authorization) {
request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64'));
}
}
log.trace({
destination: requestUrl,
proxy: 'http://' + proxy.hostname + ':' + proxy.port,
requestId: currentRequestId,
}, 'proxying request');
request.on('error', (error) => {
log.error({
error: serializeError(error),
}, 'request error');
});
request.once('response', (response) => {
log.trace({
headers: response.headers,
requestId: currentRequestId,
statusCode: response.statusCode,
}, 'proxying response');
});
request.shouldKeepAlive = false;
const connectionConfiguration = {
host: configuration.hostname || configuration.host,
port: configuration.port || 80,
proxy,
tls: {},
};
// add optional tls options for https requests.
// @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback :
// > The following additional options from tls.connect()
// > - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback -
// > are also accepted:
// > ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder,
// > key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext.
if (this.protocol === 'https:') {
connectionConfiguration.tls = {
ca: configuration.ca,
cert: configuration.cert,
ciphers: configuration.ciphers,
clientCertEngine: configuration.clientCertEngine,
crl: configuration.crl,
dhparam: configuration.dhparam,
ecdhCurve: configuration.ecdhCurve,
honorCipherOrder: configuration.honorCipherOrder,
key: configuration.key,
passphrase: configuration.passphrase,
pfx: configuration.pfx,
rejectUnauthorized: configuration.rejectUnauthorized,
secureOptions: configuration.secureOptions,
secureProtocol: configuration.secureProtocol,
servername: configuration.servername || connectionConfiguration.host,
sessionIdContext: configuration.sessionIdContext,
};
// This is not ideal because there is no way to override this setting using `tls` configuration if `NODE_TLS_REJECT_UNAUTHORIZED=0`.
// However, popular HTTP clients (such as https://github.com/sindresorhus/got) come with pre-configured value for `rejectUnauthorized`,
// which makes it impossible to override that value globally and respect `rejectUnauthorized` for specific requests only.
//
// eslint-disable-next-line no-process-env
if (typeof process.env.NODE_TLS_REJECT_UNAUTHORIZED === 'string' && boolean(process.env.NODE_TLS_REJECT_UNAUTHORIZED) === false) {
connectionConfiguration.tls.rejectUnauthorized = false;
}
}
// $FlowFixMe It appears that Flow is missing the method description.
this.createConnection(connectionConfiguration, (error, socket) => {
log.trace({
target: connectionConfiguration,
}, 'connecting');
// @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057
if (socket) {
socket.setTimeout(this.socketConnectionTimeout, () => {
socket.destroy();
});
socket.once('connect', () => {
log.trace({
target: connectionConfiguration,
}, 'connected');
socket.setTimeout(0);
});
socket.once('secureConnect', () => {
log.trace({
target: connectionConfiguration,
}, 'connected (secure)');
socket.setTimeout(0);
});
}
if (error) {
request.emit('error', error);
} else {
log.debug('created socket');
socket.on('error', (socketError) => {
log.error({
error: serializeError(socketError),
}, 'socket error');
});
request.onSocket(socket);
}
});
}
}
export default Agent;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _net = _interopRequireDefault(require("net"));
var _Agent = _interopRequireDefault(require("./Agent"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class HttpProxyAgent extends _Agent.default {
// @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/169#issuecomment-486980290
// eslint-disable-next-line unicorn/prevent-abbreviations
constructor(...args) {
super(...args);
this.protocol = 'http:';
this.defaultPort = 80;
}
createConnection(configuration, callback) {
const socket = _net.default.connect(configuration.proxy.port, configuration.proxy.hostname);
callback(null, socket);
}
}
var _default = HttpProxyAgent;
exports.default = _default;
//# sourceMappingURL=HttpProxyAgent.js.map

View File

@ -0,0 +1,30 @@
// @flow
import net from 'net';
import type {
ConnectionCallbackType,
ConnectionConfigurationType,
} from '../types';
import Agent from './Agent';
class HttpProxyAgent extends Agent {
// @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/169#issuecomment-486980290
// eslint-disable-next-line unicorn/prevent-abbreviations
constructor (...args: *) {
super(...args);
this.protocol = 'http:';
this.defaultPort = 80;
}
createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) {
const socket = net.connect(
configuration.proxy.port,
configuration.proxy.hostname,
);
callback(null, socket);
}
}
export default HttpProxyAgent;

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/classes/HttpProxyAgent.js"],"names":["HttpProxyAgent","Agent","constructor","args","protocol","defaultPort","createConnection","configuration","callback","socket","net","connect","proxy","port","hostname"],"mappings":";;;;;;;AAEA;;AAKA;;;;AAEA,MAAMA,cAAN,SAA6BC,cAA7B,CAAmC;AACjC;AACA;AACAC,EAAAA,WAAW,CAAE,GAAGC,IAAL,EAAc;AACvB,UAAM,GAAGA,IAAT;AAEA,SAAKC,QAAL,GAAgB,OAAhB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACD;;AAEDC,EAAAA,gBAAgB,CAAEC,aAAF,EAA8CC,QAA9C,EAAgF;AAC9F,UAAMC,MAAM,GAAGC,aAAIC,OAAJ,CACbJ,aAAa,CAACK,KAAd,CAAoBC,IADP,EAEbN,aAAa,CAACK,KAAd,CAAoBE,QAFP,CAAf;;AAKAN,IAAAA,QAAQ,CAAC,IAAD,EAAOC,MAAP,CAAR;AACD;;AAjBgC;;eAoBpBT,c","sourcesContent":["// @flow\n\nimport net from 'net';\nimport type {\n ConnectionCallbackType,\n ConnectionConfigurationType,\n} from '../types';\nimport Agent from './Agent';\n\nclass HttpProxyAgent extends Agent {\n // @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/169#issuecomment-486980290\n // eslint-disable-next-line unicorn/prevent-abbreviations\n constructor (...args: *) {\n super(...args);\n\n this.protocol = 'http:';\n this.defaultPort = 80;\n }\n\n createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) {\n const socket = net.connect(\n configuration.proxy.port,\n configuration.proxy.hostname,\n );\n\n callback(null, socket);\n }\n}\n\nexport default HttpProxyAgent;\n"],"file":"HttpProxyAgent.js"}

View File

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _net = _interopRequireDefault(require("net"));
var _tls = _interopRequireDefault(require("tls"));
var _Agent = _interopRequireDefault(require("./Agent"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class HttpsProxyAgent extends _Agent.default {
// eslint-disable-next-line unicorn/prevent-abbreviations
constructor(...args) {
super(...args);
this.protocol = 'https:';
this.defaultPort = 443;
}
createConnection(configuration, callback) {
const socket = _net.default.connect(configuration.proxy.port, configuration.proxy.hostname);
socket.on('error', error => {
callback(error);
});
socket.once('data', () => {
const secureSocket = _tls.default.connect({ ...configuration.tls,
socket
});
callback(null, secureSocket);
});
let connectMessage = '';
connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\r\n';
connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\r\n';
if (configuration.proxy.authorization) {
connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\r\n';
}
connectMessage += '\r\n';
socket.write(connectMessage);
}
}
var _default = HttpsProxyAgent;
exports.default = _default;
//# sourceMappingURL=HttpsProxyAgent.js.map

View File

@ -0,0 +1,54 @@
// @flow
import net from 'net';
import tls from 'tls';
import type {
ConnectionCallbackType,
ConnectionConfigurationType,
} from '../types';
import Agent from './Agent';
class HttpsProxyAgent extends Agent {
// eslint-disable-next-line unicorn/prevent-abbreviations
constructor (...args: *) {
super(...args);
this.protocol = 'https:';
this.defaultPort = 443;
}
createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) {
const socket = net.connect(
configuration.proxy.port,
configuration.proxy.hostname,
);
socket.on('error', (error) => {
callback(error);
});
socket.once('data', () => {
const secureSocket = tls.connect({
...configuration.tls,
socket,
});
callback(null, secureSocket);
});
let connectMessage = '';
connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\r\n';
connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\r\n';
if (configuration.proxy.authorization) {
connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\r\n';
}
connectMessage += '\r\n';
socket.write(connectMessage);
}
}
export default HttpsProxyAgent;

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/classes/HttpsProxyAgent.js"],"names":["HttpsProxyAgent","Agent","constructor","args","protocol","defaultPort","createConnection","configuration","callback","socket","net","connect","proxy","port","hostname","on","error","once","secureSocket","tls","connectMessage","host","authorization","Buffer","from","toString","write"],"mappings":";;;;;;;AAEA;;AACA;;AAKA;;;;AAEA,MAAMA,eAAN,SAA8BC,cAA9B,CAAoC;AAClC;AACAC,EAAAA,WAAW,CAAE,GAAGC,IAAL,EAAc;AACvB,UAAM,GAAGA,IAAT;AAEA,SAAKC,QAAL,GAAgB,QAAhB;AACA,SAAKC,WAAL,GAAmB,GAAnB;AACD;;AAEDC,EAAAA,gBAAgB,CAAEC,aAAF,EAA8CC,QAA9C,EAAgF;AAC9F,UAAMC,MAAM,GAAGC,aAAIC,OAAJ,CACbJ,aAAa,CAACK,KAAd,CAAoBC,IADP,EAEbN,aAAa,CAACK,KAAd,CAAoBE,QAFP,CAAf;;AAKAL,IAAAA,MAAM,CAACM,EAAP,CAAU,OAAV,EAAoBC,KAAD,IAAW;AAC5BR,MAAAA,QAAQ,CAACQ,KAAD,CAAR;AACD,KAFD;AAIAP,IAAAA,MAAM,CAACQ,IAAP,CAAY,MAAZ,EAAoB,MAAM;AACxB,YAAMC,YAAY,GAAGC,aAAIR,OAAJ,CAAY,EAC/B,GAAGJ,aAAa,CAACY,GADc;AAE/BV,QAAAA;AAF+B,OAAZ,CAArB;;AAKAD,MAAAA,QAAQ,CAAC,IAAD,EAAOU,YAAP,CAAR;AACD,KAPD;AASA,QAAIE,cAAc,GAAG,EAArB;AAEAA,IAAAA,cAAc,IAAI,aAAab,aAAa,CAACc,IAA3B,GAAkC,GAAlC,GAAwCd,aAAa,CAACM,IAAtD,GAA6D,eAA/E;AACAO,IAAAA,cAAc,IAAI,WAAWb,aAAa,CAACc,IAAzB,GAAgC,GAAhC,GAAsCd,aAAa,CAACM,IAApD,GAA2D,MAA7E;;AAEA,QAAIN,aAAa,CAACK,KAAd,CAAoBU,aAAxB,EAAuC;AACrCF,MAAAA,cAAc,IAAI,gCAAgCG,MAAM,CAACC,IAAP,CAAYjB,aAAa,CAACK,KAAd,CAAoBU,aAAhC,EAA+CG,QAA/C,CAAwD,QAAxD,CAAhC,GAAoG,MAAtH;AACD;;AAEDL,IAAAA,cAAc,IAAI,MAAlB;AAEAX,IAAAA,MAAM,CAACiB,KAAP,CAAaN,cAAb;AACD;;AAxCiC;;eA2CrBpB,e","sourcesContent":["// @flow\n\nimport net from 'net';\nimport tls from 'tls';\nimport type {\n ConnectionCallbackType,\n ConnectionConfigurationType,\n} from '../types';\nimport Agent from './Agent';\n\nclass HttpsProxyAgent extends Agent {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n constructor (...args: *) {\n super(...args);\n\n this.protocol = 'https:';\n this.defaultPort = 443;\n }\n\n createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) {\n const socket = net.connect(\n configuration.proxy.port,\n configuration.proxy.hostname,\n );\n\n socket.on('error', (error) => {\n callback(error);\n });\n\n socket.once('data', () => {\n const secureSocket = tls.connect({\n ...configuration.tls,\n socket,\n });\n\n callback(null, secureSocket);\n });\n\n let connectMessage = '';\n\n connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\\r\\n';\n connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\\r\\n';\n\n if (configuration.proxy.authorization) {\n connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\\r\\n';\n }\n\n connectMessage += '\\r\\n';\n\n socket.write(connectMessage);\n }\n}\n\nexport default HttpsProxyAgent;\n"],"file":"HttpsProxyAgent.js"}

View File

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Agent", {
enumerable: true,
get: function () {
return _Agent.default;
}
});
Object.defineProperty(exports, "HttpProxyAgent", {
enumerable: true,
get: function () {
return _HttpProxyAgent.default;
}
});
Object.defineProperty(exports, "HttpsProxyAgent", {
enumerable: true,
get: function () {
return _HttpsProxyAgent.default;
}
});
var _Agent = _interopRequireDefault(require("./Agent"));
var _HttpProxyAgent = _interopRequireDefault(require("./HttpProxyAgent"));
var _HttpsProxyAgent = _interopRequireDefault(require("./HttpsProxyAgent"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1,5 @@
// @flow
export {default as Agent} from './Agent';
export {default as HttpProxyAgent} from './HttpProxyAgent';
export {default as HttpsProxyAgent} from './HttpsProxyAgent';

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/classes/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA","sourcesContent":["// @flow\n\nexport {default as Agent} from './Agent';\nexport {default as HttpProxyAgent} from './HttpProxyAgent';\nexport {default as HttpsProxyAgent} from './HttpsProxyAgent';\n"],"file":"index.js"}

22
buildfiles/node_modules/global-agent/dist/errors.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UnexpectedStateError = void 0;
var _es6Error = _interopRequireDefault(require("es6-error"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable fp/no-class, fp/no-this */
class UnexpectedStateError extends _es6Error.default {
constructor(message, code = 'UNEXPECTED_STATE_ERROR') {
super(message);
this.code = code;
}
}
exports.UnexpectedStateError = UnexpectedStateError;
//# sourceMappingURL=errors.js.map

View File

@ -0,0 +1,15 @@
// @flow
/* eslint-disable fp/no-class, fp/no-this */
import ExtendableError from 'es6-error';
export class UnexpectedStateError extends ExtendableError {
code: string;
constructor (message: string, code: string = 'UNEXPECTED_STATE_ERROR') {
super(message);
this.code = code;
}
}

View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/errors.js"],"names":["UnexpectedStateError","ExtendableError","constructor","message","code"],"mappings":";;;;;;;AAIA;;;;AAFA;AAIO,MAAMA,oBAAN,SAAmCC,iBAAnC,CAAmD;AAGxDC,EAAAA,WAAW,CAAEC,OAAF,EAAmBC,IAAY,GAAG,wBAAlC,EAA4D;AACrE,UAAMD,OAAN;AAEA,SAAKC,IAAL,GAAYA,IAAZ;AACD;;AAPuD","sourcesContent":["// @flow\n\n/* eslint-disable fp/no-class, fp/no-this */\n\nimport ExtendableError from 'es6-error';\n\nexport class UnexpectedStateError extends ExtendableError {\n code: string;\n\n constructor (message: string, code: string = 'UNEXPECTED_STATE_ERROR') {\n super(message);\n\n this.code = code;\n }\n}\n"],"file":"errors.js"}

View File

@ -0,0 +1,175 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _http = _interopRequireDefault(require("http"));
var _https = _interopRequireDefault(require("https"));
var _boolean = require("boolean");
var _semver = _interopRequireDefault(require("semver"));
var _Logger = _interopRequireDefault(require("../Logger"));
var _classes = require("../classes");
var _errors = require("../errors");
var _utilities = require("../utilities");
var _createProxyController = _interopRequireDefault(require("./createProxyController"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const httpGet = _http.default.get;
const httpRequest = _http.default.request;
const httpsGet = _https.default.get;
const httpsRequest = _https.default.request;
const log = _Logger.default.child({
namespace: 'createGlobalProxyAgent'
});
const defaultConfigurationInput = {
environmentVariableNamespace: undefined,
forceGlobalAgent: undefined,
socketConnectionTimeout: 60000
};
const omitUndefined = subject => {
const keys = Object.keys(subject);
const result = {};
for (const key of keys) {
const value = subject[key];
if (value !== undefined) {
result[key] = value;
}
}
return result;
};
const createConfiguration = configurationInput => {
// eslint-disable-next-line no-process-env
const environment = process.env;
const defaultConfiguration = {
environmentVariableNamespace: typeof environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE === 'string' ? environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE : 'GLOBAL_AGENT_',
forceGlobalAgent: typeof environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT === 'string' ? (0, _boolean.boolean)(environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT) : true,
socketConnectionTimeout: typeof environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT === 'string' ? Number.parseInt(environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT, 10) : defaultConfigurationInput.socketConnectionTimeout
}; // $FlowFixMe
return { ...defaultConfiguration,
...omitUndefined(configurationInput)
};
};
const createGlobalProxyAgent = (configurationInput = defaultConfigurationInput) => {
const configuration = createConfiguration(configurationInput);
const proxyController = (0, _createProxyController.default)(); // eslint-disable-next-line no-process-env
proxyController.HTTP_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTP_PROXY'] || null; // eslint-disable-next-line no-process-env
proxyController.HTTPS_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTPS_PROXY'] || null; // eslint-disable-next-line no-process-env
proxyController.NO_PROXY = process.env[configuration.environmentVariableNamespace + 'NO_PROXY'] || null;
log.info({
configuration,
state: proxyController
}, 'global agent has been initialized');
const mustUrlUseProxy = getProxy => {
return url => {
if (!getProxy()) {
return false;
}
if (!proxyController.NO_PROXY) {
return true;
}
return !(0, _utilities.isUrlMatchingNoProxy)(url, proxyController.NO_PROXY);
};
};
const getUrlProxy = getProxy => {
return () => {
const proxy = getProxy();
if (!proxy) {
throw new _errors.UnexpectedStateError('HTTP(S) proxy must be configured.');
}
return (0, _utilities.parseProxyUrl)(proxy);
};
};
const getHttpProxy = () => {
return proxyController.HTTP_PROXY;
};
const BoundHttpProxyAgent = class extends _classes.HttpProxyAgent {
constructor() {
super(() => {
return getHttpProxy();
}, mustUrlUseProxy(getHttpProxy), getUrlProxy(getHttpProxy), _http.default.globalAgent, configuration.socketConnectionTimeout);
}
};
const httpAgent = new BoundHttpProxyAgent();
const getHttpsProxy = () => {
return proxyController.HTTPS_PROXY || proxyController.HTTP_PROXY;
};
const BoundHttpsProxyAgent = class extends _classes.HttpsProxyAgent {
constructor() {
super(() => {
return getHttpsProxy();
}, mustUrlUseProxy(getHttpsProxy), getUrlProxy(getHttpsProxy), _https.default.globalAgent, configuration.socketConnectionTimeout);
}
};
const httpsAgent = new BoundHttpsProxyAgent(); // Overriding globalAgent was added in v11.7.
// @see https://nodejs.org/uk/blog/release/v11.7.0/
if (_semver.default.gte(process.version, 'v11.7.0')) {
// @see https://github.com/facebook/flow/issues/7670
// $FlowFixMe
_http.default.globalAgent = httpAgent; // $FlowFixMe
_https.default.globalAgent = httpsAgent;
} // The reason this logic is used in addition to overriding http(s).globalAgent
// is because there is no guarantee that we set http(s).globalAgent variable
// before an instance of http(s).Agent has been already constructed by someone,
// e.g. Stripe SDK creates instances of http(s).Agent at the top-level.
// @see https://github.com/gajus/global-agent/pull/13
//
// We still want to override http(s).globalAgent when possible to enable logic
// in `bindHttpMethod`.
if (_semver.default.gte(process.version, 'v10.0.0')) {
// $FlowFixMe
_http.default.get = (0, _utilities.bindHttpMethod)(httpGet, httpAgent, configuration.forceGlobalAgent); // $FlowFixMe
_http.default.request = (0, _utilities.bindHttpMethod)(httpRequest, httpAgent, configuration.forceGlobalAgent); // $FlowFixMe
_https.default.get = (0, _utilities.bindHttpMethod)(httpsGet, httpsAgent, configuration.forceGlobalAgent); // $FlowFixMe
_https.default.request = (0, _utilities.bindHttpMethod)(httpsRequest, httpsAgent, configuration.forceGlobalAgent);
} else {
log.warn('attempt to initialize global-agent in unsupported Node.js version was ignored');
}
return proxyController;
};
var _default = createGlobalProxyAgent;
exports.default = _default;
//# sourceMappingURL=createGlobalProxyAgent.js.map

View File

@ -0,0 +1,197 @@
// @flow
import http from 'http';
import https from 'https';
import {
boolean as parseBoolean,
} from 'boolean';
import semver from 'semver';
import Logger from '../Logger';
import {
HttpProxyAgent,
HttpsProxyAgent,
} from '../classes';
import {
UnexpectedStateError,
} from '../errors';
import {
bindHttpMethod,
isUrlMatchingNoProxy,
parseProxyUrl,
} from '../utilities';
import type {
ProxyAgentConfigurationInputType,
ProxyAgentConfigurationType,
} from '../types';
import createProxyController from './createProxyController';
const httpGet = http.get;
const httpRequest = http.request;
const httpsGet = https.get;
const httpsRequest = https.request;
const log = Logger.child({
namespace: 'createGlobalProxyAgent',
});
const defaultConfigurationInput = {
environmentVariableNamespace: undefined,
forceGlobalAgent: undefined,
socketConnectionTimeout: 60000,
};
const omitUndefined = (subject) => {
const keys = Object.keys(subject);
const result = {};
for (const key of keys) {
const value = subject[key];
if (value !== undefined) {
result[key] = value;
}
}
return result;
};
const createConfiguration = (configurationInput: ProxyAgentConfigurationInputType): ProxyAgentConfigurationType => {
// eslint-disable-next-line no-process-env
const environment = process.env;
const defaultConfiguration = {
environmentVariableNamespace: typeof environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE === 'string' ? environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE : 'GLOBAL_AGENT_',
forceGlobalAgent: typeof environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT === 'string' ? parseBoolean(environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT) : true,
socketConnectionTimeout: typeof environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT === 'string' ? Number.parseInt(environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT, 10) : defaultConfigurationInput.socketConnectionTimeout,
};
// $FlowFixMe
return {
...defaultConfiguration,
...omitUndefined(configurationInput),
};
};
export default (configurationInput: ProxyAgentConfigurationInputType = defaultConfigurationInput) => {
const configuration = createConfiguration(configurationInput);
const proxyController = createProxyController();
// eslint-disable-next-line no-process-env
proxyController.HTTP_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTP_PROXY'] || null;
// eslint-disable-next-line no-process-env
proxyController.HTTPS_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTPS_PROXY'] || null;
// eslint-disable-next-line no-process-env
proxyController.NO_PROXY = process.env[configuration.environmentVariableNamespace + 'NO_PROXY'] || null;
log.info({
configuration,
state: proxyController,
}, 'global agent has been initialized');
const mustUrlUseProxy = (getProxy) => {
return (url) => {
if (!getProxy()) {
return false;
}
if (!proxyController.NO_PROXY) {
return true;
}
return !isUrlMatchingNoProxy(url, proxyController.NO_PROXY);
};
};
const getUrlProxy = (getProxy) => {
return () => {
const proxy = getProxy();
if (!proxy) {
throw new UnexpectedStateError('HTTP(S) proxy must be configured.');
}
return parseProxyUrl(proxy);
};
};
const getHttpProxy = () => {
return proxyController.HTTP_PROXY;
};
const BoundHttpProxyAgent = class extends HttpProxyAgent {
constructor () {
super(
() => {
return getHttpProxy();
},
mustUrlUseProxy(getHttpProxy),
getUrlProxy(getHttpProxy),
http.globalAgent,
configuration.socketConnectionTimeout,
);
}
};
const httpAgent = new BoundHttpProxyAgent();
const getHttpsProxy = () => {
return proxyController.HTTPS_PROXY || proxyController.HTTP_PROXY;
};
const BoundHttpsProxyAgent = class extends HttpsProxyAgent {
constructor () {
super(
() => {
return getHttpsProxy();
},
mustUrlUseProxy(getHttpsProxy),
getUrlProxy(getHttpsProxy),
https.globalAgent,
configuration.socketConnectionTimeout,
);
}
};
const httpsAgent = new BoundHttpsProxyAgent();
// Overriding globalAgent was added in v11.7.
// @see https://nodejs.org/uk/blog/release/v11.7.0/
if (semver.gte(process.version, 'v11.7.0')) {
// @see https://github.com/facebook/flow/issues/7670
// $FlowFixMe
http.globalAgent = httpAgent;
// $FlowFixMe
https.globalAgent = httpsAgent;
}
// The reason this logic is used in addition to overriding http(s).globalAgent
// is because there is no guarantee that we set http(s).globalAgent variable
// before an instance of http(s).Agent has been already constructed by someone,
// e.g. Stripe SDK creates instances of http(s).Agent at the top-level.
// @see https://github.com/gajus/global-agent/pull/13
//
// We still want to override http(s).globalAgent when possible to enable logic
// in `bindHttpMethod`.
if (semver.gte(process.version, 'v10.0.0')) {
// $FlowFixMe
http.get = bindHttpMethod(httpGet, httpAgent, configuration.forceGlobalAgent);
// $FlowFixMe
http.request = bindHttpMethod(httpRequest, httpAgent, configuration.forceGlobalAgent);
// $FlowFixMe
https.get = bindHttpMethod(httpsGet, httpsAgent, configuration.forceGlobalAgent);
// $FlowFixMe
https.request = bindHttpMethod(httpsRequest, httpsAgent, configuration.forceGlobalAgent);
} else {
log.warn('attempt to initialize global-agent in unsupported Node.js version was ignored');
}
return proxyController;
};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _Logger = _interopRequireDefault(require("../Logger"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const log = _Logger.default.child({
namespace: 'createProxyController'
});
const KNOWN_PROPERTY_NAMES = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY'];
const createProxyController = () => {
// eslint-disable-next-line fp/no-proxy
return new Proxy({
HTTP_PROXY: null,
HTTPS_PROXY: null,
NO_PROXY: null
}, {
set: (subject, name, value) => {
if (!KNOWN_PROPERTY_NAMES.includes(name)) {
throw new Error('Cannot set an unmapped property "' + name + '".');
}
subject[name] = value;
log.info({
change: {
name,
value
},
newConfiguration: subject
}, 'configuration changed');
return true;
}
});
};
var _default = createProxyController;
exports.default = _default;
//# sourceMappingURL=createProxyController.js.map

View File

@ -0,0 +1,46 @@
// @flow
import Logger from '../Logger';
type ProxyControllerType = {|
HTTP_PROXY: string | null,
HTTPS_PROXY: string | null,
NO_PROXY: string | null,
|};
const log = Logger.child({
namespace: 'createProxyController',
});
const KNOWN_PROPERTY_NAMES = [
'HTTP_PROXY',
'HTTPS_PROXY',
'NO_PROXY',
];
export default (): ProxyControllerType => {
// eslint-disable-next-line fp/no-proxy
return new Proxy({
HTTP_PROXY: null,
HTTPS_PROXY: null,
NO_PROXY: null,
}, {
set: (subject, name, value) => {
if (!KNOWN_PROPERTY_NAMES.includes(name)) {
throw new Error('Cannot set an unmapped property "' + name + '".');
}
subject[name] = value;
log.info({
change: {
name,
value,
},
newConfiguration: subject,
}, 'configuration changed');
return true;
},
});
};

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/factories/createProxyController.js"],"names":["log","Logger","child","namespace","KNOWN_PROPERTY_NAMES","Proxy","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","set","subject","name","value","includes","Error","info","change","newConfiguration"],"mappings":";;;;;;;AAEA;;;;AAQA,MAAMA,GAAG,GAAGC,gBAAOC,KAAP,CAAa;AACvBC,EAAAA,SAAS,EAAE;AADY,CAAb,CAAZ;;AAIA,MAAMC,oBAAoB,GAAG,CAC3B,YAD2B,EAE3B,aAF2B,EAG3B,UAH2B,CAA7B;;oCAM0C;AACxC;AACA,SAAO,IAAIC,KAAJ,CAAU;AACfC,IAAAA,UAAU,EAAE,IADG;AAEfC,IAAAA,WAAW,EAAE,IAFE;AAGfC,IAAAA,QAAQ,EAAE;AAHK,GAAV,EAIJ;AACDC,IAAAA,GAAG,EAAE,CAACC,OAAD,EAAUC,IAAV,EAAgBC,KAAhB,KAA0B;AAC7B,UAAI,CAACR,oBAAoB,CAACS,QAArB,CAA8BF,IAA9B,CAAL,EAA0C;AACxC,cAAM,IAAIG,KAAJ,CAAU,sCAAsCH,IAAtC,GAA6C,IAAvD,CAAN;AACD;;AAEDD,MAAAA,OAAO,CAACC,IAAD,CAAP,GAAgBC,KAAhB;AAEAZ,MAAAA,GAAG,CAACe,IAAJ,CAAS;AACPC,QAAAA,MAAM,EAAE;AACNL,UAAAA,IADM;AAENC,UAAAA;AAFM,SADD;AAKPK,QAAAA,gBAAgB,EAAEP;AALX,OAAT,EAMG,uBANH;AAQA,aAAO,IAAP;AACD;AAjBA,GAJI,CAAP;AAuBD,C","sourcesContent":["// @flow\n\nimport Logger from '../Logger';\n\ntype ProxyControllerType = {|\n HTTP_PROXY: string | null,\n HTTPS_PROXY: string | null,\n NO_PROXY: string | null,\n|};\n\nconst log = Logger.child({\n namespace: 'createProxyController',\n});\n\nconst KNOWN_PROPERTY_NAMES = [\n 'HTTP_PROXY',\n 'HTTPS_PROXY',\n 'NO_PROXY',\n];\n\nexport default (): ProxyControllerType => {\n // eslint-disable-next-line fp/no-proxy\n return new Proxy({\n HTTP_PROXY: null,\n HTTPS_PROXY: null,\n NO_PROXY: null,\n }, {\n set: (subject, name, value) => {\n if (!KNOWN_PROPERTY_NAMES.includes(name)) {\n throw new Error('Cannot set an unmapped property \"' + name + '\".');\n }\n\n subject[name] = value;\n\n log.info({\n change: {\n name,\n value,\n },\n newConfiguration: subject,\n }, 'configuration changed');\n\n return true;\n },\n });\n};\n"],"file":"createProxyController.js"}

View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "createGlobalProxyAgent", {
enumerable: true,
get: function () {
return _createGlobalProxyAgent.default;
}
});
Object.defineProperty(exports, "createProxyController", {
enumerable: true,
get: function () {
return _createProxyController.default;
}
});
var _createGlobalProxyAgent = _interopRequireDefault(require("./createGlobalProxyAgent"));
var _createProxyController = _interopRequireDefault(require("./createProxyController"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1,4 @@
// @flow
export {default as createGlobalProxyAgent} from './createGlobalProxyAgent';
export {default as createProxyController} from './createProxyController';

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/factories/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;AACA","sourcesContent":["// @flow\n\nexport {default as createGlobalProxyAgent} from './createGlobalProxyAgent';\nexport {default as createProxyController} from './createProxyController';\n"],"file":"index.js"}

22
buildfiles/node_modules/global-agent/dist/index.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "bootstrap", {
enumerable: true,
get: function () {
return _routines.bootstrap;
}
});
Object.defineProperty(exports, "createGlobalProxyAgent", {
enumerable: true,
get: function () {
return _factories.createGlobalProxyAgent;
}
});
var _routines = require("./routines");
var _factories = require("./factories");
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1,4 @@
// @flow
export {bootstrap} from './routines';
export {createGlobalProxyAgent} from './factories';

View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;AACA","sourcesContent":["// @flow\n\nexport {bootstrap} from './routines';\nexport {createGlobalProxyAgent} from './factories';\n"],"file":"index.js"}

View File

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _Logger = _interopRequireDefault(require("../Logger"));
var _factories = require("../factories");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const log = _Logger.default.child({
namespace: 'bootstrap'
});
const bootstrap = configurationInput => {
if (global.GLOBAL_AGENT) {
log.warn('found global.GLOBAL_AGENT; second attempt to bootstrap global-agent was ignored');
return false;
}
global.GLOBAL_AGENT = (0, _factories.createGlobalProxyAgent)(configurationInput);
return true;
};
var _default = bootstrap;
exports.default = _default;
//# sourceMappingURL=bootstrap.js.map

View File

@ -0,0 +1,25 @@
// @flow
import Logger from '../Logger';
import {
createGlobalProxyAgent,
} from '../factories';
import type {
ProxyAgentConfigurationInputType,
} from '../types';
const log = Logger.child({
namespace: 'bootstrap',
});
export default (configurationInput?: ProxyAgentConfigurationInputType): boolean => {
if (global.GLOBAL_AGENT) {
log.warn('found global.GLOBAL_AGENT; second attempt to bootstrap global-agent was ignored');
return false;
}
global.GLOBAL_AGENT = createGlobalProxyAgent(configurationInput);
return true;
};

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/routines/bootstrap.js"],"names":["log","Logger","child","namespace","configurationInput","global","GLOBAL_AGENT","warn"],"mappings":";;;;;;;AAEA;;AACA;;;;AAOA,MAAMA,GAAG,GAAGC,gBAAOC,KAAP,CAAa;AACvBC,EAAAA,SAAS,EAAE;AADY,CAAb,CAAZ;;kBAIgBC,kB,IAAmE;AACjF,MAAIC,MAAM,CAACC,YAAX,EAAyB;AACvBN,IAAAA,GAAG,CAACO,IAAJ,CAAS,iFAAT;AAEA,WAAO,KAAP;AACD;;AAEDF,EAAAA,MAAM,CAACC,YAAP,GAAsB,uCAAuBF,kBAAvB,CAAtB;AAEA,SAAO,IAAP;AACD,C","sourcesContent":["// @flow\n\nimport Logger from '../Logger';\nimport {\n createGlobalProxyAgent,\n} from '../factories';\nimport type {\n ProxyAgentConfigurationInputType,\n} from '../types';\n\nconst log = Logger.child({\n namespace: 'bootstrap',\n});\n\nexport default (configurationInput?: ProxyAgentConfigurationInputType): boolean => {\n if (global.GLOBAL_AGENT) {\n log.warn('found global.GLOBAL_AGENT; second attempt to bootstrap global-agent was ignored');\n\n return false;\n }\n\n global.GLOBAL_AGENT = createGlobalProxyAgent(configurationInput);\n\n return true;\n};\n"],"file":"bootstrap.js"}

View File

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "bootstrap", {
enumerable: true,
get: function () {
return _bootstrap.default;
}
});
var _bootstrap = _interopRequireDefault(require("./bootstrap"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1,3 @@
// @flow
export {default as bootstrap} from './bootstrap';

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/routines/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAEA","sourcesContent":["// @flow\n\nexport {default as bootstrap} from './bootstrap';\n"],"file":"index.js"}

10
buildfiles/node_modules/global-agent/dist/types.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"use strict";
var _net = require("net");
var _tls = require("tls");
var _http = require("http");
var _https = require("https");
//# sourceMappingURL=types.js.map

View File

@ -0,0 +1,66 @@
// @flow
import {
Socket,
} from 'net';
import {
TLSSocket,
} from 'tls';
import {
Agent as HttpAgent,
} from 'http';
import {
Agent as HttpsAgent,
} from 'https';
export type ProxyConfigurationType = {|
+authorization: string,
+hostname: string,
+port: number,
|};
export type TlsConfigurationType = {|
+ca?: string,
+cert?: string,
+ciphers?: string,
+clientCertEngine?: string,
+crl?: string,
+dhparam?: string,
+ecdhCurve?: string,
+honorCipherOrder?: boolean,
+key?: string,
+passphrase?: string,
+pfx?: string,
+rejectUnauthorized?: boolean,
+secureOptions?: number,
+secureProtocol?: string,
+servername?: string,
+sessionIdContext?: string,
|};
export type ConnectionConfigurationType = {|
+host: string,
+port: number,
+tls?: TlsConfigurationType,
+proxy: ProxyConfigurationType,
|};
export type ConnectionCallbackType = (error: Error | null, socket?: Socket | TLSSocket) => void;
export type AgentType = HttpAgent | HttpsAgent;
export type IsProxyConfiguredMethodType = () => boolean;
export type MustUrlUseProxyMethodType = (url: string) => boolean;
export type GetUrlProxyMethodType = (url: string) => ProxyConfigurationType;
export type ProtocolType = 'http:' | 'https:';
export type ProxyAgentConfigurationInputType = {|
+environmentVariableNamespace?: string,
+forceGlobalAgent?: boolean,
+socketConnectionTimeout?: number,
|};
export type ProxyAgentConfigurationType = {|
+environmentVariableNamespace: string,
+forceGlobalAgent: boolean,
+socketConnectionTimeout: number,
|};

View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/types.js"],"names":[],"mappings":";;AAEA;;AAGA;;AAGA;;AAGA","sourcesContent":["// @flow\n\nimport {\n Socket,\n} from 'net';\nimport {\n TLSSocket,\n} from 'tls';\nimport {\n Agent as HttpAgent,\n} from 'http';\nimport {\n Agent as HttpsAgent,\n} from 'https';\n\nexport type ProxyConfigurationType = {|\n +authorization: string,\n +hostname: string,\n +port: number,\n|};\n\nexport type TlsConfigurationType = {|\n +ca?: string,\n +cert?: string,\n +ciphers?: string,\n +clientCertEngine?: string,\n +crl?: string,\n +dhparam?: string,\n +ecdhCurve?: string,\n +honorCipherOrder?: boolean,\n +key?: string,\n +passphrase?: string,\n +pfx?: string,\n +rejectUnauthorized?: boolean,\n +secureOptions?: number,\n +secureProtocol?: string,\n +servername?: string,\n +sessionIdContext?: string,\n|};\n\nexport type ConnectionConfigurationType = {|\n +host: string,\n +port: number,\n +tls?: TlsConfigurationType,\n +proxy: ProxyConfigurationType,\n|};\n\nexport type ConnectionCallbackType = (error: Error | null, socket?: Socket | TLSSocket) => void;\n\nexport type AgentType = HttpAgent | HttpsAgent;\nexport type IsProxyConfiguredMethodType = () => boolean;\nexport type MustUrlUseProxyMethodType = (url: string) => boolean;\nexport type GetUrlProxyMethodType = (url: string) => ProxyConfigurationType;\nexport type ProtocolType = 'http:' | 'https:';\n\nexport type ProxyAgentConfigurationInputType = {|\n +environmentVariableNamespace?: string,\n +forceGlobalAgent?: boolean,\n +socketConnectionTimeout?: number,\n|};\n\nexport type ProxyAgentConfigurationType = {|\n +environmentVariableNamespace: string,\n +forceGlobalAgent: boolean,\n +socketConnectionTimeout: number,\n|};\n"],"file":"types.js"}

View File

@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _http = _interopRequireDefault(require("http"));
var _https = _interopRequireDefault(require("https"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-next-line flowtype/no-weak-types
const bindHttpMethod = (originalMethod, agent, forceGlobalAgent) => {
// eslint-disable-next-line unicorn/prevent-abbreviations
return (...args) => {
let url;
let options;
let callback;
if (typeof args[0] === 'string' || args[0] instanceof URL) {
url = args[0];
if (typeof args[1] === 'function') {
options = {};
callback = args[1];
} else {
options = { ...args[1]
};
callback = args[2];
}
} else {
options = { ...args[0]
};
callback = args[1];
}
if (forceGlobalAgent) {
options.agent = agent;
} else {
if (!options.agent) {
options.agent = agent;
}
if (options.agent === _http.default.globalAgent || options.agent === _https.default.globalAgent) {
options.agent = agent;
}
}
if (url) {
// $FlowFixMe
return originalMethod(url, options, callback);
} else {
return originalMethod(options, callback);
}
};
};
var _default = bindHttpMethod;
exports.default = _default;
//# sourceMappingURL=bindHttpMethod.js.map

View File

@ -0,0 +1,54 @@
// @flow
import http from 'http';
import https from 'https';
type AgentType = http.Agent | https.Agent;
// eslint-disable-next-line flowtype/no-weak-types
export default (originalMethod: Function, agent: AgentType, forceGlobalAgent: boolean) => {
// eslint-disable-next-line unicorn/prevent-abbreviations
return (...args: *) => {
let url;
let options;
let callback;
if (typeof args[0] === 'string' || args[0] instanceof URL) {
url = args[0];
if (typeof args[1] === 'function') {
options = {};
callback = args[1];
} else {
options = {
...args[1],
};
callback = args[2];
}
} else {
options = {
...args[0],
};
callback = args[1];
}
if (forceGlobalAgent) {
options.agent = agent;
} else {
if (!options.agent) {
options.agent = agent;
}
if (options.agent === http.globalAgent || options.agent === https.globalAgent) {
options.agent = agent;
}
}
if (url) {
// $FlowFixMe
return originalMethod(url, options, callback);
} else {
return originalMethod(options, callback);
}
};
};

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utilities/bindHttpMethod.js"],"names":["originalMethod","agent","forceGlobalAgent","args","url","options","callback","URL","http","globalAgent","https"],"mappings":";;;;;;;AAEA;;AACA;;;;AAIA;wBACgBA,c,EAA0BC,K,EAAkBC,gB,KAA8B;AACxF;AACA,SAAO,CAAC,GAAGC,IAAJ,KAAgB;AACrB,QAAIC,GAAJ;AACA,QAAIC,OAAJ;AACA,QAAIC,QAAJ;;AAEA,QAAI,OAAOH,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+BA,IAAI,CAAC,CAAD,CAAJ,YAAmBI,GAAtD,EAA2D;AACzDH,MAAAA,GAAG,GAAGD,IAAI,CAAC,CAAD,CAAV;;AAEA,UAAI,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,UAAvB,EAAmC;AACjCE,QAAAA,OAAO,GAAG,EAAV;AACAC,QAAAA,QAAQ,GAAGH,IAAI,CAAC,CAAD,CAAf;AACD,OAHD,MAGO;AACLE,QAAAA,OAAO,GAAG,EACR,GAAGF,IAAI,CAAC,CAAD;AADC,SAAV;AAGAG,QAAAA,QAAQ,GAAGH,IAAI,CAAC,CAAD,CAAf;AACD;AACF,KAZD,MAYO;AACLE,MAAAA,OAAO,GAAG,EACR,GAAGF,IAAI,CAAC,CAAD;AADC,OAAV;AAGAG,MAAAA,QAAQ,GAAGH,IAAI,CAAC,CAAD,CAAf;AACD;;AAED,QAAID,gBAAJ,EAAsB;AACpBG,MAAAA,OAAO,CAACJ,KAAR,GAAgBA,KAAhB;AACD,KAFD,MAEO;AACL,UAAI,CAACI,OAAO,CAACJ,KAAb,EAAoB;AAClBI,QAAAA,OAAO,CAACJ,KAAR,GAAgBA,KAAhB;AACD;;AAED,UAAII,OAAO,CAACJ,KAAR,KAAkBO,cAAKC,WAAvB,IAAsCJ,OAAO,CAACJ,KAAR,KAAkBS,eAAMD,WAAlE,EAA+E;AAC7EJ,QAAAA,OAAO,CAACJ,KAAR,GAAgBA,KAAhB;AACD;AACF;;AAED,QAAIG,GAAJ,EAAS;AACP;AACA,aAAOJ,cAAc,CAACI,GAAD,EAAMC,OAAN,EAAeC,QAAf,CAArB;AACD,KAHD,MAGO;AACL,aAAON,cAAc,CAACK,OAAD,EAAUC,QAAV,CAArB;AACD;AACF,GA1CD;AA2CD,C","sourcesContent":["// @flow\n\nimport http from 'http';\nimport https from 'https';\n\ntype AgentType = http.Agent | https.Agent;\n\n// eslint-disable-next-line flowtype/no-weak-types\nexport default (originalMethod: Function, agent: AgentType, forceGlobalAgent: boolean) => {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n return (...args: *) => {\n let url;\n let options;\n let callback;\n\n if (typeof args[0] === 'string' || args[0] instanceof URL) {\n url = args[0];\n\n if (typeof args[1] === 'function') {\n options = {};\n callback = args[1];\n } else {\n options = {\n ...args[1],\n };\n callback = args[2];\n }\n } else {\n options = {\n ...args[0],\n };\n callback = args[1];\n }\n\n if (forceGlobalAgent) {\n options.agent = agent;\n } else {\n if (!options.agent) {\n options.agent = agent;\n }\n\n if (options.agent === http.globalAgent || options.agent === https.globalAgent) {\n options.agent = agent;\n }\n }\n\n if (url) {\n // $FlowFixMe\n return originalMethod(url, options, callback);\n } else {\n return originalMethod(options, callback);\n }\n };\n};\n"],"file":"bindHttpMethod.js"}

View File

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "bindHttpMethod", {
enumerable: true,
get: function () {
return _bindHttpMethod.default;
}
});
Object.defineProperty(exports, "isUrlMatchingNoProxy", {
enumerable: true,
get: function () {
return _isUrlMatchingNoProxy.default;
}
});
Object.defineProperty(exports, "parseProxyUrl", {
enumerable: true,
get: function () {
return _parseProxyUrl.default;
}
});
var _bindHttpMethod = _interopRequireDefault(require("./bindHttpMethod"));
var _isUrlMatchingNoProxy = _interopRequireDefault(require("./isUrlMatchingNoProxy"));
var _parseProxyUrl = _interopRequireDefault(require("./parseProxyUrl"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1,5 @@
// @flow
export {default as bindHttpMethod} from './bindHttpMethod';
export {default as isUrlMatchingNoProxy} from './isUrlMatchingNoProxy';
export {default as parseProxyUrl} from './parseProxyUrl';

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utilities/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA","sourcesContent":["// @flow\n\nexport {default as bindHttpMethod} from './bindHttpMethod';\nexport {default as isUrlMatchingNoProxy} from './isUrlMatchingNoProxy';\nexport {default as parseProxyUrl} from './parseProxyUrl';\n"],"file":"index.js"}

View File

@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _url = require("url");
var _matcher = _interopRequireDefault(require("matcher"));
var _errors = require("../errors");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const isUrlMatchingNoProxy = (subjectUrl, noProxy) => {
const subjectUrlTokens = (0, _url.parse)(subjectUrl);
const rules = noProxy.split(/[\s,]/);
for (const rule of rules) {
const ruleMatch = rule.replace(/^(?<leadingDot>\.)/, '*').match(/^(?<hostname>.+?)(?::(?<port>\d+))?$/);
if (!ruleMatch || !ruleMatch.groups) {
throw new _errors.UnexpectedStateError('Invalid NO_PROXY pattern.');
}
if (!ruleMatch.groups.hostname) {
throw new _errors.UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.');
}
const hostnameIsMatch = _matcher.default.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname);
if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) {
return true;
}
}
return false;
};
var _default = isUrlMatchingNoProxy;
exports.default = _default;
//# sourceMappingURL=isUrlMatchingNoProxy.js.map

View File

@ -0,0 +1,37 @@
// @flow
import {
parse as parseUrl,
} from 'url';
import matcher from 'matcher';
import {
UnexpectedStateError,
} from '../errors';
export default (subjectUrl: string, noProxy: string) => {
const subjectUrlTokens = parseUrl(subjectUrl);
const rules = noProxy.split(/[\s,]/);
for (const rule of rules) {
const ruleMatch = rule
.replace(/^(?<leadingDot>\.)/, '*')
.match(/^(?<hostname>.+?)(?::(?<port>\d+))?$/);
if (!ruleMatch || !ruleMatch.groups) {
throw new UnexpectedStateError('Invalid NO_PROXY pattern.');
}
if (!ruleMatch.groups.hostname) {
throw new UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.');
}
const hostnameIsMatch = matcher.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname);
if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) {
return true;
}
}
return false;
};

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utilities/isUrlMatchingNoProxy.js"],"names":["subjectUrl","noProxy","subjectUrlTokens","rules","split","rule","ruleMatch","replace","match","groups","UnexpectedStateError","hostname","hostnameIsMatch","matcher","isMatch","port"],"mappings":";;;;;;;AAEA;;AAGA;;AACA;;;;8BAIgBA,U,EAAoBC,O,KAAoB;AACtD,QAAMC,gBAAgB,GAAG,gBAASF,UAAT,CAAzB;AAEA,QAAMG,KAAK,GAAGF,OAAO,CAACG,KAAR,CAAc,OAAd,CAAd;;AAEA,OAAK,MAAMC,IAAX,IAAmBF,KAAnB,EAA0B;AACxB,UAAMG,SAAS,GAAGD,IAAI,CACnBE,OADe,CACP,oBADO,EACe,GADf,EAEfC,KAFe,CAET,sCAFS,CAAlB;;AAIA,QAAI,CAACF,SAAD,IAAc,CAACA,SAAS,CAACG,MAA7B,EAAqC;AACnC,YAAM,IAAIC,4BAAJ,CAAyB,2BAAzB,CAAN;AACD;;AAED,QAAI,CAACJ,SAAS,CAACG,MAAV,CAAiBE,QAAtB,EAAgC;AAC9B,YAAM,IAAID,4BAAJ,CAAyB,4EAAzB,CAAN;AACD;;AAED,UAAME,eAAe,GAAGC,iBAAQC,OAAR,CAAgBZ,gBAAgB,CAACS,QAAjC,EAA2CL,SAAS,CAACG,MAAV,CAAiBE,QAA5D,CAAxB;;AAEA,QAAIC,eAAe,KAAK,CAACN,SAAS,CAACG,MAAX,IAAqB,CAACH,SAAS,CAACG,MAAV,CAAiBM,IAAvC,IAA+Cb,gBAAgB,CAACa,IAAjB,IAAyBb,gBAAgB,CAACa,IAAjB,KAA0BT,SAAS,CAACG,MAAV,CAAiBM,IAAxH,CAAnB,EAAkJ;AAChJ,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD,C","sourcesContent":["// @flow\n\nimport {\n parse as parseUrl,\n} from 'url';\nimport matcher from 'matcher';\nimport {\n UnexpectedStateError,\n} from '../errors';\n\nexport default (subjectUrl: string, noProxy: string) => {\n const subjectUrlTokens = parseUrl(subjectUrl);\n\n const rules = noProxy.split(/[\\s,]/);\n\n for (const rule of rules) {\n const ruleMatch = rule\n .replace(/^(?<leadingDot>\\.)/, '*')\n .match(/^(?<hostname>.+?)(?::(?<port>\\d+))?$/);\n\n if (!ruleMatch || !ruleMatch.groups) {\n throw new UnexpectedStateError('Invalid NO_PROXY pattern.');\n }\n\n if (!ruleMatch.groups.hostname) {\n throw new UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.');\n }\n\n const hostnameIsMatch = matcher.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname);\n\n if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) {\n return true;\n }\n }\n\n return false;\n};\n"],"file":"isUrlMatchingNoProxy.js"}

View File

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _url = require("url");
var _errors = require("../errors");
const parseProxyUrl = url => {
const urlTokens = (0, _url.parse)(url);
if (urlTokens.query !== null) {
throw new _errors.UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.');
}
if (urlTokens.hash !== null) {
throw new _errors.UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.');
}
if (urlTokens.protocol !== 'http:') {
throw new _errors.UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".');
}
let port = 80;
if (urlTokens.port) {
port = Number.parseInt(urlTokens.port, 10);
}
return {
authorization: urlTokens.auth || null,
hostname: urlTokens.hostname,
port
};
};
var _default = parseProxyUrl;
exports.default = _default;
//# sourceMappingURL=parseProxyUrl.js.map

View File

@ -0,0 +1,36 @@
// @flow
import {
parse as parseUrl,
} from 'url';
import {
UnexpectedStateError,
} from '../errors';
export default (url: string) => {
const urlTokens = parseUrl(url);
if (urlTokens.query !== null) {
throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.');
}
if (urlTokens.hash !== null) {
throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.');
}
if (urlTokens.protocol !== 'http:') {
throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".');
}
let port = 80;
if (urlTokens.port) {
port = Number.parseInt(urlTokens.port, 10);
}
return {
authorization: urlTokens.auth || null,
hostname: urlTokens.hostname,
port,
};
};

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utilities/parseProxyUrl.js"],"names":["url","urlTokens","query","UnexpectedStateError","hash","protocol","port","Number","parseInt","authorization","auth","hostname"],"mappings":";;;;;;;AAEA;;AAGA;;sBAIgBA,G,IAAgB;AAC9B,QAAMC,SAAS,GAAG,gBAASD,GAAT,CAAlB;;AAEA,MAAIC,SAAS,CAACC,KAAV,KAAoB,IAAxB,EAA8B;AAC5B,UAAM,IAAIC,4BAAJ,CAAyB,qFAAzB,CAAN;AACD;;AAED,MAAIF,SAAS,CAACG,IAAV,KAAmB,IAAvB,EAA6B;AAC3B,UAAM,IAAID,4BAAJ,CAAyB,oFAAzB,CAAN;AACD;;AAED,MAAIF,SAAS,CAACI,QAAV,KAAuB,OAA3B,EAAoC;AAClC,UAAM,IAAIF,4BAAJ,CAAyB,0FAAzB,CAAN;AACD;;AAED,MAAIG,IAAI,GAAG,EAAX;;AAEA,MAAIL,SAAS,CAACK,IAAd,EAAoB;AAClBA,IAAAA,IAAI,GAAGC,MAAM,CAACC,QAAP,CAAgBP,SAAS,CAACK,IAA1B,EAAgC,EAAhC,CAAP;AACD;;AAED,SAAO;AACLG,IAAAA,aAAa,EAAER,SAAS,CAACS,IAAV,IAAkB,IAD5B;AAELC,IAAAA,QAAQ,EAAEV,SAAS,CAACU,QAFf;AAGLL,IAAAA;AAHK,GAAP;AAKD,C","sourcesContent":["// @flow\n\nimport {\n parse as parseUrl,\n} from 'url';\nimport {\n UnexpectedStateError,\n} from '../errors';\n\nexport default (url: string) => {\n const urlTokens = parseUrl(url);\n\n if (urlTokens.query !== null) {\n throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.');\n }\n\n if (urlTokens.hash !== null) {\n throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.');\n }\n\n if (urlTokens.protocol !== 'http:') {\n throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be \"http:\".');\n }\n\n let port = 80;\n\n if (urlTokens.port) {\n port = Number.parseInt(urlTokens.port, 10);\n }\n\n return {\n authorization: urlTokens.auth || null,\n hostname: urlTokens.hostname,\n port,\n };\n};\n"],"file":"parseProxyUrl.js"}