Socket
Socket
Sign inDemoInstall

node-cookie-proxy-agent

Package Overview
Dependencies
19
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.0

bin/agents.d.ts

9

bin/agents.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpsCookieProxyAgent = exports.HttpCookieProxyAgent = void 0;
exports.SocksCookieProxyAgent = exports.HttpsCookieProxyAgent = exports.HttpCookieProxyAgent = void 0;
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 tough_cookie_1 = require("tough-cookie");

@@ -102,2 +103,8 @@ class BaseCookieProxyAgent extends agent_base_1.Agent {

exports.HttpsCookieProxyAgent = HttpsCookieProxyAgent;
class SocksCookieProxyAgent extends BaseCookieProxyAgent {
constructor(jar, proxy) {
super(jar, new socks_proxy_agent_1.SocksProxyAgent(proxy));
}
}
exports.SocksCookieProxyAgent = SocksCookieProxyAgent;
//# sourceMappingURL=agents.js.map
{
"name": "node-cookie-proxy-agent",
"version": "1.0.2",
"version": "1.1.0",
"description": "HTTP & HTTPS agents with cookie and proxy support",
"main": "bin/agents.js",
"types": "bin/agents.d.ts",
"files": [
"bin",
"src"
],
"scripts": {

@@ -24,6 +29,7 @@ "build": "tsc --build",

"https",
"socks",
"axios"
],
"author": "dmpzh",
"license": "ISC",
"license": "MIT",
"bugs": {

@@ -47,2 +53,3 @@ "url": "https://github.com/dmpzh/node-cookie-proxy-agent/issues"

"https-proxy-agent": "^5.0.1",
"socks-proxy-agent": "^6.2.0",
"tough-cookie": "^4.0.0"

@@ -49,0 +56,0 @@ },

# node-cookie-proxy-agent
[![npm](https://img.shields.io/npm/v/node-cookie-proxy-agent)](https://www.npmjs.com/package/node-cookie-proxy-agent)
HTTP & HTTPS agents with cookie and proxy support. HTTP(s) and SOCKS(v4/v5) are supported.
## Install
```bash
npm install node-cookie-proxy-agent http-proxy-agent https-proxy-agent tough-cookie
npm install node-cookie-proxy-agent http-proxy-agent https-proxy-agent socks-proxy-agent tough-cookie
```

@@ -11,4 +15,6 @@

Pass `http-cookie-agent` to HTTP clients instead of http(s).Agent.
Pass `node-cookie-proxy-agent` to HTTP clients instead of http(s).Agent.
Exemple with `axios` with HTTP proxy:
```ts

@@ -19,7 +25,9 @@ import axios from 'axios';

// HTTP(s) proxy
(async () => {
// initialise this first
const jar = new CookieJar();
const httpAgent = new HttpCookieProxyAgent(jar, 'http://127.0.0.1:8888'); // or http://id:password@127.0.0.1:8888 to use with authentication
const httpsAgent = new HttpsCookieProxyAgent(jar, 'http://127.0.0.1:8888');
const proxy = 'http://127.0.0.1:8888'; // or http://id:password@127.0.0.1:8888 to use with authentication
const httpAgent = new HttpCookieProxyAgent(jar, proxy);
const httpsAgent = new HttpsCookieProxyAgent(jar, proxy);

@@ -30,3 +38,21 @@ // add your agents to your http client

})().catch(err => console.error(err));
```
Exemple with `axios` with SOCKS proxy:
```ts
import axios from 'axios';
import { SocksCookieProxyAgent } from 'node-cookie-proxy-agent';
import { CookieJar } from 'tough-cookie';
// SOCKS proxy
(async () => {
// initialise this first
const jar = new CookieJar();
const agent = new SocksCookieProxyAgent(jar, 'socks://127.0.0.1:8888');
// add your agent to your http client
const axiosClient = axios.create({ httpAgent: agent, httpsAgent: agent });
console.log('result: ', (await axiosClient.get('https://api.ipify.org?format=json')).data);
})().catch(err => console.error(err));
```

@@ -6,2 +6,3 @@ import { Agent, ClientRequest, RequestOptions } from 'agent-base';

import { Socket } from 'net';
import createSocksProxyAgent, { SocksProxyAgent } from 'socks-proxy-agent';
import { Cookie, CookieJar } from 'tough-cookie';

@@ -26,5 +27,5 @@

private readonly jar: CookieJar;
private readonly proxyAgent: HttpProxyAgent | HttpsProxyAgent;
private readonly proxyAgent: HttpProxyAgent | HttpsProxyAgent | SocksProxyAgent;
constructor(jar: CookieJar, proxyAgent: HttpProxyAgent | HttpsProxyAgent) {
constructor(jar: CookieJar, proxyAgent: HttpProxyAgent | HttpsProxyAgent | SocksProxyAgent) {
super();

@@ -128,1 +129,7 @@ this.jar = jar;

}
export class SocksCookieProxyAgent extends BaseCookieProxyAgent {
constructor(jar: CookieJar, proxy: string | createSocksProxyAgent.SocksProxyAgentOptions) {
super(jar, new SocksProxyAgent(proxy));
}
}
.eslintignore
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc