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

fetch-socks

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-socks - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

4

index.d.ts

@@ -7,3 +7,3 @@ import { SocksProxy } from "socks";

/**
* Create an undici connector which establish the connection through socks proxies.
* Create an Undici connector which establish the connection through socks proxies.
*

@@ -27,3 +27,3 @@ * If the proxies is an empty array, it will connect directly.

/**
* Create a undici Agent with socks connector.
* Create a Undici Agent with socks connector.
*

@@ -30,0 +30,0 @@ * If the proxies is an empty array, it will connect directly.

@@ -16,3 +16,3 @@ "use strict";

/**
* Create an undici connector which establish the connection through socks proxies.
* Create an Undici connector which establish the connection through socks proxies.
*

@@ -26,3 +26,3 @@ * If the proxies is an empty array, it will connect directly.

const chain = Array.isArray(proxies) ? proxies : [proxies];
const { timeout = 10e3 } = tlsOpts;
const { timeout = 1e4 } = tlsOpts;
const undiciConnect = (0, undici_1.buildConnector)(tlsOpts);

@@ -61,3 +61,3 @@ return async (options, callback) => {

* There are 2 cases here:
* If httpSocket doesn't exist, let undici make a connection.
* If httpSocket doesn't exist, let Undici make a connection.
* If httpSocket exists & protocol is HTTPS, do TLS upgrade.

@@ -70,3 +70,3 @@ */

/**
* Create a undici Agent with socks connector.
* Create a Undici Agent with socks connector.
*

@@ -73,0 +73,0 @@ * If the proxies is an empty array, it will connect directly.

{
"name": "fetch-socks",
"version": "1.2.0",
"version": "1.3.0",
"description": "Socks proxy for Node builtin `fetch`",

@@ -23,21 +23,29 @@ "license": "MIT",

"types": "index.d.ts",
"typeCoverage": {
"ignoreCatch": true,
"atLeast": 100
},
"dependencies": {
"socks": "^2.7.1",
"undici": "^5.14.0"
"socks": "^2.8.1",
"undici": "^6.10.1"
},
"devDependencies": {
"@e9x/simple-socks": "1.0.0-beta.1",
"@jest/globals": "^29.3.1",
"@kaciras/eslint-config-core": "^2.5.0",
"@kaciras/eslint-config-typescript": "^2.5.0",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"mockttp": "^3.6.1",
"ts-jest": "^29.0.3",
"typescript": "^4.9.4"
"@e9x/simple-socks": "1.0.0",
"@jest/globals": "^29.7.0",
"@kaciras/eslint-config-core": "^2.6.4",
"@kaciras/eslint-config-typescript": "^2.6.4",
"@types/ws": "^8.5.10",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"mockttp": "^3.10.1",
"ts-jest": "^29.1.2",
"type-coverage": "^2.27.1",
"typescript": "^5.4.2",
"ws": "^8.16.0"
},
"scripts": {
"lint": "eslint --fix .",
"test": "jest"
"test": "jest",
"type-coverage": "type-coverage"
}
}

@@ -6,2 +6,3 @@ # fetch-socks

[![codecov](https://codecov.io/gh/Kaciras/fetch-socks/branch/master/graph/badge.svg?token=DJLSKIKYBJ)](https://codecov.io/gh/Kaciras/fetch-socks)
[![type-coverage](https://img.shields.io/badge/dynamic/json?label=type-coverage&prefix=%E2%89%A5&query=%24.typeCoverage.atLeast&suffix=%25&url=https%3A%2F%2Fraw.githubusercontent.com%2FKaciras%2Ffetch-socks%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)

@@ -16,3 +17,3 @@ Socks proxy for Node builtin (also [undici](https://github.com/nodejs/undici)) `fetch`.

fetch `http://example.com` through `socks5://[::1]:1080`.
Fetch `http://example.com` through `socks5://[::1]:1080`.

@@ -26,2 +27,5 @@ ```javascript

port: 1080,
//userId: "username",
//password: "password",
});

@@ -34,2 +38,12 @@

Set the proxy globally.
```javascript
import { socksDispatcher } from "fetch-socks";
const dispatcher = socksDispatcher({ /* ... */});
global[Symbol.for("undici.globalDispatcher.1")] = dispatcher;
````
TypeScript example, fetch through proxy chain with two SOCKS proxies.

@@ -49,4 +63,2 @@

port: 1081,
//userId: "foo",
//password: "bar",
}];

@@ -94,1 +106,31 @@

```
# API
## `socksConnector(proxies, connectOptions?)`
Create an [Undici connector](https://undici.nodejs.org/#/docs/api/Connector) which establish the connection through socks proxies.
* `proxies` The proxy server to use or the list of proxy servers to chain. If you pass an empty array it will connect directly.
* `connectOptions` (optional) The options used to perform directly connect or TLS upgrade, see [here](https://undici.nodejs.org/#/docs/api/Connector?id=parameter-buildconnectorbuildoptions)
## `socksDispatcher(proxies, options?)`
Create a Undici Agent with socks connector.
* `proxies` Same as `socksConnector`'s.
* `options` (optional) [Agent options](https://undici.nodejs.org/#/docs/api/Agent). The `connect` property will be used to create socks connector.
```javascript
import { socksConnector, socksDispatcher } from "fetch-socks";
import { Agent } from "undici";
const proxy = { type: 5, host: "::1", port: 1080 };
const connect = { /* ... */ };
const agentOptions = { /* ... */ };
socksDispatcher(proxy, { ...agentOptions, connect });
// Is equivalent to
new Agent({ ...agentOptions, connect: socksConnector(proxy, connect) });
```

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