How to use https-proxy-agent - 9 common examples

To help you get started, we’ve selected a few https-proxy-agent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iTowns / itowns / test / unit / 3dtilesprocess.js View on Github external
import View from 'Core/View';
import GlobeView from 'Core/Prefab/GlobeView';
import HttpsProxyAgent from 'https-proxy-agent';
import Coordinates from 'Core/Geographic/Coordinates';
import Renderer from './mock';

const renderer = new Renderer();
const threedTilesLayer = new GeometryLayer('3d-tiles-discrete-lod', new Group());

threedTilesLayer.name = 'DiscreteLOD';
threedTilesLayer.url = 'https://raw.githubusercontent.com/AnalyticalGraphicsInc/3d-tiles-samples/master/tilesets/TilesetWithDiscreteLOD/tileset.json';
threedTilesLayer.protocol = '3d-tiles';
threedTilesLayer.overrideMaterials = true;  // custom cesium shaders are not functional

if (process.env.HTTPS_PROXY) {
    threedTilesLayer.networkOptions = { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) };
}

const p = { coord: new Coordinates('EPSG:4326', -75.6114, 40.03428, 0), heading: 180, range: 4000, tilt: 22 };
const viewer = new GlobeView(renderer.domElement, p, { renderer, noControls: true });

const context = {
    camera: viewer.camera,
    engine: viewer.mainLoop.gfxEngine,
    scheduler: viewer.mainLoop.scheduler,
    geometryLayer: threedTilesLayer,
    view: viewer,
};

describe('3Dtiles layer', function () {
    it('Add 3dtiles layer', function (done) {
        View.prototype.addLayer.call(viewer, threedTilesLayer).then((layer) => {
github auth0 / auth0-deploy-cli / src / index.js View on Github external
async function run() {
  // Run command
  const cmd = commands[params._[0]];

  // TODO: Prob a native/better way to enforce command choices in yargs.
  if (!cmd) {
    log.error(`Command ${params._[0]} not supported\n`);
    args.showHelp();
    process.exit(1);
  }

  // Monkey Patch the superagent for proxy use
  const proxy = params.proxy_url;
  if (proxy) {
    const proxyAgent = new HttpProxyAgent(proxy);
    const proxyAgentSsl = new HttpsProxyAgent(proxy);
    const OrigRequest = superagent.Request;
    superagent.Request = function RequestWithAgent(method, url) {
      const req = new OrigRequest(method, url);
      log.info(`Setting proxy for ${method} to ${url}`);
      if (url.startsWith('https')) return req.agent(proxyAgentSsl);
      return req.agent(proxyAgent);
    };
  }

  log.debug(`Start command ${params._[0]}`);
  await cmd(params);
  log.debug(`Finished command ${params._[0]}`);
}
github serverless / platform-sdk / src / fetch.js View on Github external
if (cafile) {
    // Can be a single certificate file path or multiple paths, comma separated.
    const caPathArr = cafile.split(',')
    caCerts = caCerts.concat(caPathArr.map((cafilePath) => fs.readFileSync(cafilePath.trim())))
  }

  if (caCerts.length > 0) {
    Object.assign(agentOptions, {
      rejectUnauthorized: true,
      ca: caCerts
    })
  }

  if (proxy) {
    return new HttpsProxyAgent(agentOptions)
  } else if (agentOptions.ca) {
    return new https.Agent(agentOptions)
  }
  return undefined
}
github TencentCloudBase / cloudbase-manager-node / src / utils / http-request.ts View on Github external
export async function fetchStream(url: string, config: Record = {}, proxy) {
    if (proxy || process.env.http_proxy) {
        config.agent = new HttpsProxyAgent(proxy || process.env.http_proxy)
    }
    // 解决中文编码问题
    const escapeUrl = new URL(url).toString()
    return _fetch(escapeUrl, config)
}
github danger / danger-js / source / platforms / bitbucket_cloud / BitBucketCloudAPI.ts View on Github external
private performAPI = (url: string, headers: any = {}, body: any = {}, method: string, suppressErrors?: boolean) => {
    this.d(`${method} ${url}`)
    // Allow using a proxy configured through environmental variables
    // Remember that to avoid the error "Error: self signed certificate in certificate chain"
    // you should also do: "export NODE_TLS_REJECT_UNAUTHORIZED=0". See: https://github.com/request/request/issues/2061
    let agent: Agent | undefined = undefined
    let proxy = process.env.http_proxy || process.env.https_proxy
    if (proxy) {
      agent = new HttpsProxyAgent(proxy)
    }

    return this.fetch(
      url,
      {
        method,
        body,
        headers: {
          "Content-Type": "application/json",
          ...headers,
        },
        agent,
      },
      suppressErrors
    )
  }
github danger / danger-js / source / platforms / bitbucket_server / BitBucketServerAPI.ts View on Github external
} else if (this.repoCredentials.password) {
      headers["Authorization"] = `Basic ${new Buffer(
        this.repoCredentials.username + ":" + this.repoCredentials.password
      ).toString("base64")}`
    }

    const url = `${this.repoCredentials.host}/${path}`
    this.d(`${method} ${url}`)

    // Allow using a proxy configured through environmental variables
    // Remember that to avoid the error "Error: self signed certificate in certificate chain"
    // you should also do: "export NODE_TLS_REJECT_UNAUTHORIZED=0". See: https://github.com/request/request/issues/2061
    let agent: Agent | undefined = undefined
    let proxy = process.env.http_proxy || process.env.https_proxy
    if (proxy) {
      agent = new HttpsProxyAgent(proxy)
    }

    return this.fetch(
      url,
      {
        method,
        body,
        headers: {
          "Content-Type": "application/json",
          ...headers,
        },
        agent,
      },
      suppressErrors
    )
  }
github elastic / kibana / src / cli_plugin / install / downloaders / http.js View on Github external
function getProxyAgent(sourceUrl, logger) {
  const proxy = getProxyForUrl(sourceUrl);

  if (!proxy) {
    return null;
  }

  logger.log(`Picked up proxy ${proxy} from environment variable.`);

  if (/^https/.test(sourceUrl)) {
    return new HttpsProxyAgent(proxy);
  } else {
    return new HttpProxyAgent(proxy);
  }
}
github ShellMonkeys / fb-messenger-es6 / src / client / client.js View on Github external
setProxy(proxy) {
        if (validate.null(proxy)) {
            this.proxyAgent = null;
            return this;
        }
        validate.required(proxy, ['hostname', 'port'], 'Client.setProxy');
        this.proxyAgent = new HttpsProxyAgent(`${proxy.hostname}:${proxy.port}`);
        return this;
    }
github jspm / jspm-cli / lib / install / fetch.js View on Github external
}
        if (common_1.hasProperties(agentOptions) && url.startsWith('https:')) {
            let existingAgents;
            if (credentials.proxy)
                existingAgents = proxyAgents.get(credentials.proxy);
            else
                existingAgents = agents;
            if (existingAgents)
                agent = agents.find(agent => {
                    return !Object.keys(agentOptions).some(opt => agent.options[opt] !== agentOptions[opt]);
                });
            if (!agent) {
                if (credentials.proxy) {
                    if (!existingAgents)
                        proxyAgents.set(credentials.proxy, existingAgents = []);
                    existingAgents.push(agent = new https_proxy_agent_1.default(Object.assign({}, credentials.proxy)));
                }
                else {
                    agents.push(agent = (new https_1.Agent(agentOptions)));
                }
            }
        }
        this.debugLog(`${method} ${url}${writeCredentialLog(credentials)}`);
        if (credentials.basicAuth) {
            const urlObj = new url_1.URL(url);
            if (!urlObj.username && !urlObj.password) {
                ({ username: urlObj.username, password: urlObj.password } = credentials.basicAuth);
                requestUrl = urlObj.href;
            }
        }
        if (agent)
            options = Object.assign({ agent }, options);

https-proxy-agent

An HTTP(s) proxy `http.Agent` implementation for HTTPS

MIT
Latest version published 2 months ago

Package Health Score

85 / 100
Full package analysis

Popular https-proxy-agent functions