diff options
Diffstat (limited to 'node_modules/global-agent/dist/classes')
12 files changed, 597 insertions, 0 deletions
| diff --git a/node_modules/global-agent/dist/classes/Agent.js b/node_modules/global-agent/dist/classes/Agent.js new file mode 100644 index 0000000..ba8cc1a --- /dev/null +++ b/node_modules/global-agent/dist/classes/Agent.js @@ -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
\ No newline at end of file diff --git a/node_modules/global-agent/dist/classes/Agent.js.flow b/node_modules/global-agent/dist/classes/Agent.js.flow new file mode 100644 index 0000000..801dd1f --- /dev/null +++ b/node_modules/global-agent/dist/classes/Agent.js.flow @@ -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; diff --git a/node_modules/global-agent/dist/classes/Agent.js.map b/node_modules/global-agent/dist/classes/Agent.js.map new file mode 100644 index 0000000..af6283e --- /dev/null +++ b/node_modules/global-agent/dist/classes/Agent.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/classes/Agent.js"],"names":["log","Logger","child","namespace","requestId","Agent","constructor","isProxyConfigured","mustUrlUseProxy","getUrlProxy","fallbackAgent","socketConnectionTimeout","addRequest","request","configuration","requestUrl","path","startsWith","protocol","hostname","host","port","trace","destination","currentRequestId","proxy","authorization","setHeader","Buffer","from","toString","on","error","once","response","headers","statusCode","shouldKeepAlive","connectionConfiguration","tls","ca","cert","ciphers","clientCertEngine","crl","dhparam","ecdhCurve","honorCipherOrder","key","passphrase","pfx","rejectUnauthorized","secureOptions","secureProtocol","servername","sessionIdContext","process","env","NODE_TLS_REJECT_UNAUTHORIZED","createConnection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AAA,OAAO,CAACmD,IAAR,CAAa,OAAb,EAAsBhC,KAAtB;AACD,OAFD,MAEO;AACLhC,QAAAA,GAAG,CAACiE,KAAJ,CAAU,gBAAV;AAEAL,QAAAA,MAAM,CAAC7B,EAAP,CAAU,OAAV,EAAoBmC,WAAD,IAAiB;AAClClE,UAAAA,GAAG,CAACgC,KAAJ,CAAU;AACRA,YAAAA,KAAK,EAAE,oCAAekC,WAAf;AADC,WAAV,EAEG,cAFH;AAGD,SAJD;AAMArD,QAAAA,OAAO,CAACsD,QAAR,CAAiBP,MAAjB;AACD;AACF,KAzCD;AA0CD;;AAzLS;;eA4LGvD,K","sourcesContent":["// @flow\n\nimport {\n  serializeError,\n} from 'serialize-error';\nimport {\n  boolean,\n} from 'boolean';\nimport Logger from '../Logger';\nimport type {\n  AgentType,\n  GetUrlProxyMethodType,\n  IsProxyConfiguredMethodType,\n  MustUrlUseProxyMethodType,\n  ProtocolType,\n} from '../types';\n\nconst log = Logger.child({\n  namespace: 'Agent',\n});\n\nlet requestId = 0;\n\nclass Agent {\n  defaultPort: number;\n\n  protocol: ProtocolType;\n\n  fallbackAgent: AgentType;\n\n  isProxyConfigured: IsProxyConfiguredMethodType;\n\n  mustUrlUseProxy: MustUrlUseProxyMethodType;\n\n  getUrlProxy: GetUrlProxyMethodType;\n\n  socketConnectionTimeout: number;\n\n  constructor (\n    isProxyConfigured: IsProxyConfiguredMethodType,\n    mustUrlUseProxy: MustUrlUseProxyMethodType,\n    getUrlProxy: GetUrlProxyMethodType,\n    fallbackAgent: AgentType,\n    socketConnectionTimeout: number,\n  ) {\n    this.fallbackAgent = fallbackAgent;\n    this.isProxyConfigured = isProxyConfigured;\n    this.mustUrlUseProxy = mustUrlUseProxy;\n    this.getUrlProxy = getUrlProxy;\n    this.socketConnectionTimeout = socketConnectionTimeout;\n  }\n\n  addRequest (request: *, configuration: *) {\n    let requestUrl;\n\n    // It is possible that addRequest was constructed for a proxied request already, e.g.\n    // \"request\" package does this when it detects that a proxy should be used\n    // https://github.com/request/request/blob/212570b6971a732b8dd9f3c73354bcdda158a737/request.js#L402\n    // https://gist.github.com/gajus/e2074cd3b747864ffeaabbd530d30218\n    if (request.path.startsWith('http://') || request.path.startsWith('https://')) {\n      requestUrl = request.path;\n    } else {\n      requestUrl = this.protocol + '//' + (configuration.hostname || configuration.host) + (configuration.port === 80 || configuration.port === 443 ? '' : ':' + configuration.port) + request.path;\n    }\n\n    if (!this.isProxyConfigured()) {\n      log.trace({\n        destination: requestUrl,\n      }, 'not proxying request; GLOBAL_AGENT.HTTP_PROXY is not configured');\n\n      // $FlowFixMe It appears that Flow is missing the method description.\n      this.fallbackAgent.addRequest(request, configuration);\n\n      return;\n    }\n\n    if (!this.mustUrlUseProxy(requestUrl)) {\n      log.trace({\n        destination: requestUrl,\n      }, 'not proxying request; url matches GLOBAL_AGENT.NO_PROXY');\n\n      // $FlowFixMe It appears that Flow is missing the method description.\n      this.fallbackAgent.addRequest(request, configuration);\n\n      return;\n    }\n\n    const currentRequestId = requestId++;\n\n    const proxy = this.getUrlProxy(requestUrl);\n\n    if (this.protocol === 'http:') {\n      request.path = requestUrl;\n\n      if (proxy.authorization) {\n        request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64'));\n      }\n    }\n\n    log.trace({\n      destination: requestUrl,\n      proxy: 'http://' + proxy.hostname + ':' + proxy.port,\n      requestId: currentRequestId,\n    }, 'proxying request');\n\n    request.on('error', (error) => {\n      log.error({\n        error: serializeError(error),\n      }, 'request error');\n    });\n\n    request.once('response', (response) => {\n      log.trace({\n        headers: response.headers,\n        requestId: currentRequestId,\n        statusCode: response.statusCode,\n      }, 'proxying response');\n    });\n\n    request.shouldKeepAlive = false;\n\n    const connectionConfiguration = {\n      host: configuration.hostname || configuration.host,\n      port: configuration.port || 80,\n      proxy,\n      tls: {},\n    };\n\n    // add optional tls options for https requests.\n    // @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback :\n    // > The following additional options from tls.connect()\n    // >   - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback -\n    // > are also accepted:\n    // >   ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder,\n    // >   key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext.\n    if (this.protocol === 'https:') {\n      connectionConfiguration.tls = {\n        ca: configuration.ca,\n        cert: configuration.cert,\n        ciphers: configuration.ciphers,\n        clientCertEngine: configuration.clientCertEngine,\n        crl: configuration.crl,\n        dhparam: configuration.dhparam,\n        ecdhCurve: configuration.ecdhCurve,\n        honorCipherOrder: configuration.honorCipherOrder,\n        key: configuration.key,\n        passphrase: configuration.passphrase,\n        pfx: configuration.pfx,\n        rejectUnauthorized: configuration.rejectUnauthorized,\n        secureOptions: configuration.secureOptions,\n        secureProtocol: configuration.secureProtocol,\n        servername: configuration.servername || connectionConfiguration.host,\n        sessionIdContext: configuration.sessionIdContext,\n      };\n\n      // This is not ideal because there is no way to override this setting using `tls` configuration if `NODE_TLS_REJECT_UNAUTHORIZED=0`.\n      // However, popular HTTP clients (such as https://github.com/sindresorhus/got) come with pre-configured value for `rejectUnauthorized`,\n      // which makes it impossible to override that value globally and respect `rejectUnauthorized` for specific requests only.\n      //\n      // eslint-disable-next-line no-process-env\n      if (typeof process.env.NODE_TLS_REJECT_UNAUTHORIZED === 'string' && boolean(process.env.NODE_TLS_REJECT_UNAUTHORIZED) === false) {\n        connectionConfiguration.tls.rejectUnauthorized = false;\n      }\n    }\n\n    // $FlowFixMe It appears that Flow is missing the method description.\n    this.createConnection(connectionConfiguration, (error, socket) => {\n      log.trace({\n        target: connectionConfiguration,\n      }, 'connecting');\n\n      // @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057\n      if (socket) {\n        socket.setTimeout(this.socketConnectionTimeout, () => {\n          socket.destroy();\n        });\n\n        socket.once('connect', () => {\n          log.trace({\n            target: connectionConfiguration,\n          }, 'connected');\n\n          socket.setTimeout(0);\n        });\n\n        socket.once('secureConnect', () => {\n          log.trace({\n            target: connectionConfiguration,\n          }, 'connected (secure)');\n\n          socket.setTimeout(0);\n        });\n      }\n\n      if (error) {\n        request.emit('error', error);\n      } else {\n        log.debug('created socket');\n\n        socket.on('error', (socketError) => {\n          log.error({\n            error: serializeError(socketError),\n          }, 'socket error');\n        });\n\n        request.onSocket(socket);\n      }\n    });\n  }\n}\n\nexport default Agent;\n"],"file":"Agent.js"}
\ No newline at end of file diff --git a/node_modules/global-agent/dist/classes/HttpProxyAgent.js b/node_modules/global-agent/dist/classes/HttpProxyAgent.js new file mode 100644 index 0000000..6d1c831 --- /dev/null +++ b/node_modules/global-agent/dist/classes/HttpProxyAgent.js @@ -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
\ No newline at end of file diff --git a/node_modules/global-agent/dist/classes/HttpProxyAgent.js.flow b/node_modules/global-agent/dist/classes/HttpProxyAgent.js.flow new file mode 100644 index 0000000..8b9b471 --- /dev/null +++ b/node_modules/global-agent/dist/classes/HttpProxyAgent.js.flow @@ -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; diff --git a/node_modules/global-agent/dist/classes/HttpProxyAgent.js.map b/node_modules/global-agent/dist/classes/HttpProxyAgent.js.map new file mode 100644 index 0000000..f2586b9 --- /dev/null +++ b/node_modules/global-agent/dist/classes/HttpProxyAgent.js.map @@ -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"}
\ No newline at end of file diff --git a/node_modules/global-agent/dist/classes/HttpsProxyAgent.js b/node_modules/global-agent/dist/classes/HttpsProxyAgent.js new file mode 100644 index 0000000..1206ffa --- /dev/null +++ b/node_modules/global-agent/dist/classes/HttpsProxyAgent.js @@ -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
\ No newline at end of file diff --git a/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.flow b/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.flow new file mode 100644 index 0000000..24d724f --- /dev/null +++ b/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.flow @@ -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; diff --git a/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.map b/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.map new file mode 100644 index 0000000..0bad4a9 --- /dev/null +++ b/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.map @@ -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","Buff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;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"}
\ No newline at end of file diff --git a/node_modules/global-agent/dist/classes/index.js b/node_modules/global-agent/dist/classes/index.js new file mode 100644 index 0000000..b3889d2 --- /dev/null +++ b/node_modules/global-agent/dist/classes/index.js @@ -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
\ No newline at end of file diff --git a/node_modules/global-agent/dist/classes/index.js.flow b/node_modules/global-agent/dist/classes/index.js.flow new file mode 100644 index 0000000..9e8418a --- /dev/null +++ b/node_modules/global-agent/dist/classes/index.js.flow @@ -0,0 +1,5 @@ +// @flow + +export {default as Agent} from './Agent'; +export {default as HttpProxyAgent} from './HttpProxyAgent'; +export {default as HttpsProxyAgent} from './HttpsProxyAgent'; diff --git a/node_modules/global-agent/dist/classes/index.js.map b/node_modules/global-agent/dist/classes/index.js.map new file mode 100644 index 0000000..59a05bb --- /dev/null +++ b/node_modules/global-agent/dist/classes/index.js.map @@ -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"}
\ No newline at end of file | 
