Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pac-proxy-agent

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pac-proxy-agent - npm Package Compare versions

Comparing version 7.0.2 to 7.1.0

60

./dist/index.js

@@ -37,5 +37,2 @@ "use strict";

const agent_base_1 = require("agent-base");
const http_proxy_agent_1 = require("http-proxy-agent");
const https_proxy_agent_1 = require("https-proxy-agent");
const socks_proxy_agent_1 = require("socks-proxy-agent");
const get_uri_1 = require("get-uri");

@@ -45,2 +42,13 @@ const pac_resolver_1 = require("pac-resolver");

const debug = (0, debug_1.default)('pac-proxy-agent');
const setServernameFromNonIpHost = (options) => {
if (options.servername === undefined &&
options.host &&
!net.isIP(options.host)) {
return {
...options,
servername: options.host,
};
}
return options;
};
/**

@@ -140,2 +148,3 @@ * The `PacProxyAgent` class.

const { secureEndpoint } = opts;
const isWebSocket = req.getHeader('upgrade') === 'websocket';
// First, get a generated `FindProxyForURL()` function,

@@ -145,24 +154,7 @@ // either cached or retrieved from the source

// Calculate the `url` parameter
const protocol = secureEndpoint ? 'https:' : 'http:';
const host = opts.host && net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
const defaultPort = secureEndpoint ? 443 : 80;
let path = req.path;
let search = null;
const firstQuestion = path.indexOf('?');
if (firstQuestion !== -1) {
search = path.substring(firstQuestion);
path = path.substring(0, firstQuestion);
}
const urlOpts = {
...opts,
protocol: secureEndpoint ? 'https:' : 'http:',
pathname: path,
search,
// need to use `hostname` instead of `host` otherwise `port` is ignored
hostname: opts.host,
host: null,
href: null,
// set `port` to null when it is the protocol default port (80 / 443)
port: defaultPort === opts.port ? null : opts.port,
};
const url = (0, url_1.format)(urlOpts);
debug('url: %o', url);
const url = Object.assign(new url_1.URL(req.path, `${protocol}//${host}`), defaultPort ? undefined : { port: opts.port });
debug('url: %s', url);
let result = await resolver(url);

@@ -188,7 +180,3 @@ // Default to "DIRECT" if a falsey value was returned (or nothing)

if (secureEndpoint) {
const servername = opts.servername || opts.host;
socket = tls.connect({
...opts,
servername,
});
socket = tls.connect(setServernameFromNonIpHost(opts));
}

@@ -201,7 +189,9 @@ else {

// Use a SOCKSv5h proxy
agent = new socks_proxy_agent_1.SocksProxyAgent(`socks://${target}`, this.opts);
const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require('socks-proxy-agent')));
agent = new SocksProxyAgent(`socks://${target}`, this.opts);
}
else if (type === 'SOCKS4') {
// Use a SOCKSv4a proxy
agent = new socks_proxy_agent_1.SocksProxyAgent(`socks4a://${target}`, this.opts);
const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require('socks-proxy-agent')));
agent = new SocksProxyAgent(`socks4a://${target}`, this.opts);
}

@@ -214,7 +204,9 @@ else if (type === 'PROXY' ||

const proxyURL = `${type === 'HTTPS' ? 'https' : 'http'}://${target}`;
if (secureEndpoint) {
agent = new https_proxy_agent_1.HttpsProxyAgent(proxyURL, this.opts);
if (secureEndpoint || isWebSocket) {
const { HttpsProxyAgent } = await Promise.resolve().then(() => __importStar(require('https-proxy-agent')));
agent = new HttpsProxyAgent(proxyURL, this.opts);
}
else {
agent = new http_proxy_agent_1.HttpProxyAgent(proxyURL, this.opts);
const { HttpProxyAgent } = await Promise.resolve().then(() => __importStar(require('http-proxy-agent')));
agent = new HttpProxyAgent(proxyURL, this.opts);
}

@@ -221,0 +213,0 @@ }

@@ -10,5 +10,5 @@ /// <reference types="node" />

import { Agent, AgentConnectOpts } from 'agent-base';
import { HttpProxyAgentOptions } from 'http-proxy-agent';
import { HttpsProxyAgentOptions } from 'https-proxy-agent';
import { SocksProxyAgentOptions } from 'socks-proxy-agent';
import type { HttpProxyAgentOptions } from 'http-proxy-agent';
import type { HttpsProxyAgentOptions } from 'https-proxy-agent';
import type { SocksProxyAgentOptions } from 'socks-proxy-agent';
import { protocols as gProtocols, ProtocolOpts as GetUriOptions } from 'get-uri';

@@ -15,0 +15,0 @@ import { FindProxyForURL, PacResolverOptions } from 'pac-resolver';

@@ -37,5 +37,2 @@ "use strict";

const agent_base_1 = require("agent-base");
const http_proxy_agent_1 = require("http-proxy-agent");
const https_proxy_agent_1 = require("https-proxy-agent");
const socks_proxy_agent_1 = require("socks-proxy-agent");
const get_uri_1 = require("get-uri");

@@ -45,2 +42,13 @@ const pac_resolver_1 = require("pac-resolver");

const debug = (0, debug_1.default)('pac-proxy-agent');
const setServernameFromNonIpHost = (options) => {
if (options.servername === undefined &&
options.host &&
!net.isIP(options.host)) {
return {
...options,
servername: options.host,
};
}
return options;
};
/**

@@ -140,2 +148,3 @@ * The `PacProxyAgent` class.

const { secureEndpoint } = opts;
const isWebSocket = req.getHeader('upgrade') === 'websocket';
// First, get a generated `FindProxyForURL()` function,

@@ -145,24 +154,7 @@ // either cached or retrieved from the source

// Calculate the `url` parameter
const protocol = secureEndpoint ? 'https:' : 'http:';
const host = opts.host && net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
const defaultPort = secureEndpoint ? 443 : 80;
let path = req.path;
let search = null;
const firstQuestion = path.indexOf('?');
if (firstQuestion !== -1) {
search = path.substring(firstQuestion);
path = path.substring(0, firstQuestion);
}
const urlOpts = {
...opts,
protocol: secureEndpoint ? 'https:' : 'http:',
pathname: path,
search,
// need to use `hostname` instead of `host` otherwise `port` is ignored
hostname: opts.host,
host: null,
href: null,
// set `port` to null when it is the protocol default port (80 / 443)
port: defaultPort === opts.port ? null : opts.port,
};
const url = (0, url_1.format)(urlOpts);
debug('url: %o', url);
const url = Object.assign(new url_1.URL(req.path, `${protocol}//${host}`), defaultPort ? undefined : { port: opts.port });
debug('url: %s', url);
let result = await resolver(url);

@@ -188,7 +180,3 @@ // Default to "DIRECT" if a falsey value was returned (or nothing)

if (secureEndpoint) {
const servername = opts.servername || opts.host;
socket = tls.connect({
...opts,
servername,
});
socket = tls.connect(setServernameFromNonIpHost(opts));
}

@@ -201,7 +189,9 @@ else {

// Use a SOCKSv5h proxy
agent = new socks_proxy_agent_1.SocksProxyAgent(`socks://${target}`, this.opts);
const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require('socks-proxy-agent')));
agent = new SocksProxyAgent(`socks://${target}`, this.opts);
}
else if (type === 'SOCKS4') {
// Use a SOCKSv4a proxy
agent = new socks_proxy_agent_1.SocksProxyAgent(`socks4a://${target}`, this.opts);
const { SocksProxyAgent } = await Promise.resolve().then(() => __importStar(require('socks-proxy-agent')));
agent = new SocksProxyAgent(`socks4a://${target}`, this.opts);
}

@@ -214,7 +204,9 @@ else if (type === 'PROXY' ||

const proxyURL = `${type === 'HTTPS' ? 'https' : 'http'}://${target}`;
if (secureEndpoint) {
agent = new https_proxy_agent_1.HttpsProxyAgent(proxyURL, this.opts);
if (secureEndpoint || isWebSocket) {
const { HttpsProxyAgent } = await Promise.resolve().then(() => __importStar(require('https-proxy-agent')));
agent = new HttpsProxyAgent(proxyURL, this.opts);
}
else {
agent = new http_proxy_agent_1.HttpProxyAgent(proxyURL, this.opts);
const { HttpProxyAgent } = await Promise.resolve().then(() => __importStar(require('http-proxy-agent')));
agent = new HttpProxyAgent(proxyURL, this.opts);
}

@@ -221,0 +213,0 @@ }

{
"name": "pac-proxy-agent",
"version": "7.0.2",
"version": "7.1.0",
"description": "A PAC file proxy `http.Agent` implementation for HTTP",

@@ -29,9 +29,9 @@ "main": "./dist/index.js",

"@tootallnate/quickjs-emscripten": "^0.23.0",
"agent-base": "^7.0.2",
"agent-base": "^7.1.2",
"debug": "^4.3.4",
"get-uri": "^6.0.1",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.5",
"https-proxy-agent": "^7.0.6",
"pac-resolver": "^7.0.1",
"socks-proxy-agent": "^8.0.4"
"socks-proxy-agent": "^8.0.5"
},

@@ -47,4 +47,4 @@ "devDependencies": {

"typescript": "^5.0.4",
"tsconfig": "0.0.0",
"proxy": "2.2.0"
"proxy": "2.2.0",
"tsconfig": "0.0.0"
},

@@ -51,0 +51,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc