fetch-tor-proxy 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +76 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # fetch-tor-proxy
2
+
3
+ `fetch-tor-proxy` lets you perform HTTP(S) requests through a SOCKS proxy (Tor), using `node-fetch` and `socks-proxy-agent`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install fetch-tor-proxy
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ import { proxiedFetch } from 'fetch-tor-proxy';
15
+
16
+ const response = await proxiedFetch('https://api.ipify.org?format=json');
17
+ const body = await response.text();
18
+ console.log(body);
19
+ ```
20
+
21
+ Available alias:
22
+
23
+ ```ts
24
+ import { fetch } from 'fetch-tor-proxy';
25
+ ```
26
+
27
+ ## Options
28
+
29
+ `proxiedFetch(url, options)` accepts `node-fetch` `RequestInit` options and adds:
30
+
31
+ - `proxyUrl?: string` (default: `socks5h://127.0.0.1:9050`)
32
+ - `killTor?: boolean` (default: `true`)
33
+
34
+ Example:
35
+
36
+ ```ts
37
+ import { proxiedFetch } from 'fetch-tor-proxy';
38
+
39
+ const response = await proxiedFetch('https://httpbin.org/anything', {
40
+ method: 'POST',
41
+ headers: { 'content-type': 'application/json' },
42
+ body: JSON.stringify({ hello: 'world' }),
43
+ killTor: false,
44
+ });
45
+
46
+ console.log(await response.json());
47
+ ```
48
+
49
+ ## Tor Process Management
50
+
51
+ The library also exports `TorProcessManager`:
52
+
53
+ ```ts
54
+ import { TorProcessManager } from 'fetch-tor-proxy';
55
+
56
+ const manager = new TorProcessManager({
57
+ bootstrapTimeoutMs: 30_000,
58
+ });
59
+
60
+ await manager.start();
61
+ // ... your network calls ...
62
+ manager.stop();
63
+ ```
64
+
65
+ ## Platform Behavior
66
+
67
+ - Windows (`win32`): the library starts `tor` using `tor-expert-bundle/tor` and waits for `Bootstrapped 100%`.
68
+ - Linux/macOS: the library does not spawn a Tor process. Tor must already be available (system service, container, etc.).
69
+
70
+ ## Development
71
+
72
+ ```bash
73
+ pnpm build
74
+ ```
75
+
76
+ The TypeScript build output is generated in the `build/` folder.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetch-tor-proxy",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Allows fetching resources through a proxy server, with support for authentication and custom headers.",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {