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

@pnpm/network.proxy-agent

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/network.proxy-agent - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

dist/preview-1707304045348.js

7

dist/proxy-agent.d.ts

@@ -12,3 +12,10 @@ export interface ProxyAgentOptions {

timeout?: number;
clientCertificates?: {
[registryUrl: string]: {
cert: string;
key: string;
ca?: string;
};
};
}
export declare function getProxyAgent(uri: string, opts: ProxyAgentOptions): unknown;

18

dist/proxy-agent.js

@@ -15,3 +15,2 @@ "use strict";

function getProxyAgent(uri, opts) {
var _a, _b, _c;
const parsedUri = new URL(uri);

@@ -26,6 +25,6 @@ const pxuri = getProxyUri(parsedUri, opts);

`proxy:${pxuri.protocol}//${pxuri.username}:${pxuri.password}@${pxuri.host}:${pxuri.port}`,
`local-address:${(_a = opts.localAddress) !== null && _a !== void 0 ? _a : '>no-local-address<'}`,
`local-address:${opts.localAddress ?? '>no-local-address<'}`,
`strict-ssl:${isHttps ? Boolean(opts.strictSsl).toString() : '>no-strict-ssl<'}`,
`ca:${(isHttps && ((_b = opts.ca) === null || _b === void 0 ? void 0 : _b.toString())) || '>no-ca<'}`,
`cert:${(isHttps && ((_c = opts.cert) === null || _c === void 0 ? void 0 : _c.toString())) || '>no-cert<'}`,
`ca:${(isHttps && opts.ca?.toString()) || '>no-ca<'}`,
`cert:${(isHttps && opts.cert?.toString()) || '>no-cert<'}`,
`key:${(isHttps && opts.key) || '>no-key<'}`,

@@ -74,3 +73,2 @@ ].join(':');

function getProxy(proxyUrl, opts, isHttps) {
var _a, _b;
const popts = {

@@ -83,3 +81,3 @@ auth: getAuth(proxyUrl),

localAddress: opts.localAddress,
maxSockets: (_a = opts.maxSockets) !== null && _a !== void 0 ? _a : DEFAULT_MAX_SOCKETS,
maxSockets: opts.maxSockets ?? DEFAULT_MAX_SOCKETS,
path: proxyUrl.pathname,

@@ -89,3 +87,5 @@ port: proxyUrl.port,

rejectUnauthorized: opts.strictSsl,
timeout: typeof opts.timeout !== 'number' || opts.timeout === 0 ? 0 : opts.timeout + 1,
timeout: typeof opts.timeout !== 'number' || opts.timeout === 0
? 0
: opts.timeout + 1,
};

@@ -100,3 +100,3 @@ if (proxyUrl.protocol === 'http:' || proxyUrl.protocol === 'https:') {

}
if ((_b = proxyUrl.protocol) === null || _b === void 0 ? void 0 : _b.startsWith('socks')) {
if (proxyUrl.protocol?.startsWith('socks')) {
return (0, socks_proxy_agent_1.default)(popts);

@@ -124,5 +124,5 @@ }

callback(req, opts) {
return super.callback(req, Object.assign(Object.assign({}, this[extraOpts]), opts));
return super.callback(req, { ...this[extraOpts], ...opts });
}
}
//# sourceMappingURL=proxy-agent.js.map

@@ -15,3 +15,6 @@ "use strict";

return function Agent(opts) {
return Object.assign(Object.assign({}, opts), { __type: type });
return {
...opts,
__type: type,
};
};

@@ -30,3 +33,7 @@ }

test('all expected options passed down to proxy agent', () => {
const opts = Object.assign({ httpsProxy: 'https://user:pass@my.proxy:1234/foo/', noProxy: 'qar.com, bar.com' }, OPTS);
const opts = {
httpsProxy: 'https://user:pass@my.proxy:1234/foo/',
noProxy: 'qar.com, bar.com',
...OPTS,
};
expect((0, proxy_agent_1.getProxyAgent)('https://foo.com/bar', opts).proxy).toEqual({

@@ -48,6 +55,9 @@ ALPNProtocols: ['http 1.1'],

test('a socks proxy', () => {
const opts = Object.assign({ httpsProxy: 'socks://user:pass@my.proxy:1234/foo' }, OPTS);
const opts = {
httpsProxy: 'socks://user:pass@my.proxy:1234/foo',
...OPTS,
};
const agent = (0, proxy_agent_1.getProxyAgent)('https://foo.com/bar', opts);
expect(agent instanceof socks_proxy_agent_1.default).toBeTruthy();
expect(agent['proxy']).toEqual({
expect(agent.proxy).toEqual({
host: 'my.proxy',

@@ -59,3 +69,6 @@ port: 1234,

test('proxy credentials are decoded', () => {
const opts = Object.assign({ httpsProxy: `https://${encodeURIComponent('use@!r')}:${encodeURIComponent('p#as*s')}@my.proxy:1234/foo` }, OPTS);
const opts = {
httpsProxy: `https://${encodeURIComponent('use@!r')}:${encodeURIComponent('p#as*s')}@my.proxy:1234/foo`,
...OPTS,
};
expect((0, proxy_agent_1.getProxyAgent)('https://foo.com/bar', opts).proxy).toEqual({

@@ -77,5 +90,8 @@ ALPNProtocols: ['http 1.1'],

test('proxy credentials are decoded', () => {
const opts = Object.assign({ httpsProxy: 'https://use@!r:p#as*s@my.proxy:1234/foo' }, OPTS);
const opts = {
httpsProxy: 'https://use@!r:p#as*s@my.proxy:1234/foo',
...OPTS,
};
expect(() => (0, proxy_agent_1.getProxyAgent)('https://foo.com/bar', opts)).toThrow("Couldn't parse proxy URL");
});
//# sourceMappingURL=proxy-agent.spec.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -33,3 +24,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

});
it('should not throw an error if strictSsl is set to false', () => __awaiter(void 0, void 0, void 0, function* () {
it('should not throw an error if strictSsl is set to false', async () => {
const url = 'https://self-signed.badssl.com';

@@ -40,5 +31,5 @@ const agent = (0, proxy_agent_1.getProxyAgent)(url, {

});
yield (0, node_fetch_1.default)(url, { agent });
}));
it('should throw an error if strictSsl is not set', () => __awaiter(void 0, void 0, void 0, function* () {
await (0, node_fetch_1.default)(url, { agent });
});
it('should throw an error if strictSsl is not set', async () => {
const url = 'https://self-signed.badssl.com';

@@ -49,5 +40,5 @@ const agent = (0, proxy_agent_1.getProxyAgent)(url, {

});
yield expect((0, node_fetch_1.default)(url, { agent })).rejects.toThrow(/self signed certificate/);
}));
await expect((0, node_fetch_1.default)(url, { agent })).rejects.toThrow(/self[- ]signed certificate/);
});
});
//# sourceMappingURL=proxy-agent.strict-ssl.spec.js.map
{
"name": "@pnpm/network.proxy-agent",
"version": "0.1.0",
"homepage": "https://bit.dev/pnpm/network/proxy-agent",
"version": "1.0.0",
"homepage": "https://bit.cloud/pnpm/network/proxy-agent",
"main": "dist/index.js",

@@ -9,3 +9,3 @@ "componentId": {

"name": "proxy-agent",
"version": "0.1.0"
"version": "1.0.0"
},

@@ -20,10 +20,17 @@ "dependencies": {

"devDependencies": {
"node-fetch": "3.0.0-beta.9",
"@types/node-fetch": "^2.6.11",
"@types/proxy": "^1.0.4",
"node-fetch": "^2.6.7",
"proxy": "1.0.2",
"@types/jest": "26.0.20",
"@types/node": "12.20.4",
"@babel/runtime": "7.20.0"
"@types/node": "^18.11.9",
"@types/jest": "^29.2.2",
"@pnpm/tsconfig": "^2.0.0",
"@pnpm/eslint-config": "^1.1.0",
"@pnpm/env.envs.pnpm-env": "1.0.0"
},
"peerDependencies": {},
"license": "MIT",
"optionalDependencies": {},
"peerDependenciesMeta": {},
"type": "module",
"private": false,

@@ -41,2 +48,2 @@ "engines": {

}
}
}

@@ -59,3 +59,3 @@ import { getProxyAgent } from './proxy-agent';

expect(agent instanceof SocksProxyAgent).toBeTruthy()
expect(agent['proxy']).toEqual({
expect((agent as any).proxy).toEqual({
host: 'my.proxy',

@@ -62,0 +62,0 @@ port: 1234,

@@ -6,3 +6,3 @@ import fetch from 'node-fetch'

describe('untrusted certificate', () => {
let proxy: Proxy
let proxy: any
let proxyPort: number

@@ -35,4 +35,4 @@ beforeAll((done) => {

})
await expect(fetch(url, { agent })).rejects.toThrow(/self signed certificate/)
await expect(fetch(url, { agent })).rejects.toThrow(/self[- ]signed certificate/)
})
})
})

@@ -22,2 +22,9 @@ import { PnpmError } from '@pnpm/error'

timeout?: number
clientCertificates?: {
[registryUrl: string]: {
cert: string
key: string
ca?: string
}
}
}

@@ -36,3 +43,5 @@

`local-address:${opts.localAddress ?? '>no-local-address<'}`,
`strict-ssl:${isHttps ? Boolean(opts.strictSsl).toString() : '>no-strict-ssl<'}`,
`strict-ssl:${
isHttps ? Boolean(opts.strictSsl).toString() : '>no-strict-ssl<'
}`,
`ca:${(isHttps && opts.ca?.toString()) || '>no-ca<'}`,

@@ -63,11 +72,11 @@ `cert:${(isHttps && opts.cert?.toString()) || '>no-cert<'}`,

switch (protocol) {
case 'http:': {
proxy = opts.httpProxy
break
case 'http:': {
proxy = opts.httpProxy
break
}
case 'https:': {
proxy = opts.httpsProxy
break
}
}
case 'https:': {
proxy = opts.httpsProxy
break
}
}

@@ -120,3 +129,6 @@ if (!proxy) {

rejectUnauthorized: opts.strictSsl,
timeout: typeof opts.timeout !== 'number' || opts.timeout === 0 ? 0 : opts.timeout + 1,
timeout:
typeof opts.timeout !== 'number' || opts.timeout === 0
? 0
: opts.timeout + 1,
}

@@ -123,0 +135,0 @@

{
"compilerOptions": {
"lib": [
"es2019",
"DOM",
"ES6",
"DOM.Iterable"
],
"target": "es2015",
"module": "CommonJS",
"jsx": "react",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"composite": true,
"declaration": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
"preserveConstEnums": true,
"removeComments": false,
"sourceMap": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"outDir": "dist",
"moduleResolution": "node",
"esModuleInterop": true,
"rootDir": ".",
"resolveJsonModule": true
"strict": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es2020",
"ignoreDeprecations": "5.0",
"outDir": "dist"
},
"atom": {
"rewriteTsconfig": true
},
"exclude": [
"artifacts",
"public",
"dist",
"package.json"
"node_modules",
"package.json",
"**/*.cjs"
],
"include": [
"**/*",
"**/*.json"
"**/*.json",
".mocharc.js",
".mocharc.js"
]
}

@@ -0,1 +1,5 @@

/**
* this file is copied into your components' build output.
*/
declare module '*.png' {

@@ -8,8 +12,8 @@ const value: any;

export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
export const ReactComponent: FunctionComponent<
SVGProps<SVGSVGElement> & { title?: string }
>;
const src: string;
export default src;
}
// @TODO Gilad
declare module '*.jpg' {

@@ -16,0 +20,0 @@ const value: any;

@@ -1,42 +0,47 @@

declare module '*.module.css' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.module.scss' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.module.sass' {
const classes: { readonly [key: string]: string };
export default classes;
}
/**
* this file is copied into your components' build output.
*/
declare module '*.module.less' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.less' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.css' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.sass' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.scss' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.mdx' {
const component: any;
export default component;
}
declare module '*.module.css' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.module.scss' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.module.sass' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.module.less' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.less' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.css' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.sass' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.scss' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.mdx' {
const component: any;
export default component;
}

Sorry, the diff of this file is not supported yet

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