httpcloak 1.5.7 → 1.5.8
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.
- package/README.md +107 -2
- package/lib/index.d.ts +598 -0
- package/lib/index.js +802 -1
- package/npm/darwin-arm64/package.json +1 -1
- package/npm/darwin-x64/package.json +1 -1
- package/npm/linux-arm64/package.json +1 -1
- package/npm/linux-x64/package.json +1 -1
- package/npm/win32-arm64/package.json +1 -1
- package/npm/win32-x64/package.json +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -334,8 +334,8 @@ console.log(cookies);
|
|
|
334
334
|
// Access cookies as property
|
|
335
335
|
console.log(session.cookies);
|
|
336
336
|
|
|
337
|
-
//
|
|
338
|
-
session.
|
|
337
|
+
// Delete a cookie
|
|
338
|
+
session.deleteCookie("session_id");
|
|
339
339
|
|
|
340
340
|
// Clear all cookies
|
|
341
341
|
session.clearCookies();
|
|
@@ -506,6 +506,111 @@ async function downloadLargeFile(): Promise<void> {
|
|
|
506
506
|
}
|
|
507
507
|
```
|
|
508
508
|
|
|
509
|
+
## Local Proxy
|
|
510
|
+
|
|
511
|
+
Use `LocalProxy` to apply TLS fingerprinting to any HTTP client (axios, node-fetch, etc.):
|
|
512
|
+
|
|
513
|
+
```javascript
|
|
514
|
+
const { LocalProxy } = require("httpcloak");
|
|
515
|
+
const axios = require("axios");
|
|
516
|
+
|
|
517
|
+
// Start local proxy with Chrome fingerprint
|
|
518
|
+
const proxy = new LocalProxy({ preset: "chrome-143" });
|
|
519
|
+
console.log(`Proxy running on ${proxy.proxyUrl}`);
|
|
520
|
+
|
|
521
|
+
// Use with axios
|
|
522
|
+
const response = await axios.get("https://example.com", {
|
|
523
|
+
proxy: {
|
|
524
|
+
host: "127.0.0.1",
|
|
525
|
+
port: proxy.port,
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// Per-request upstream proxy rotation
|
|
530
|
+
const rotatedResponse = await axios.get("https://example.com", {
|
|
531
|
+
proxy: {
|
|
532
|
+
host: "127.0.0.1",
|
|
533
|
+
port: proxy.port,
|
|
534
|
+
},
|
|
535
|
+
headers: {
|
|
536
|
+
"X-Upstream-Proxy": "http://user:pass@rotating-proxy.com:8080",
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
proxy.close();
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### TLS-Only Mode
|
|
544
|
+
|
|
545
|
+
When your client already provides authentic browser headers, use TLS-only mode:
|
|
546
|
+
|
|
547
|
+
```javascript
|
|
548
|
+
const { LocalProxy } = require("httpcloak");
|
|
549
|
+
|
|
550
|
+
// Only apply TLS fingerprint, pass headers through
|
|
551
|
+
const proxy = new LocalProxy({ preset: "chrome-143", tlsOnly: true });
|
|
552
|
+
|
|
553
|
+
// Your client's headers are preserved
|
|
554
|
+
const response = await fetch("https://example.com", {
|
|
555
|
+
agent: new HttpsProxyAgent(proxy.proxyUrl),
|
|
556
|
+
headers: { "User-Agent": "My Custom UA" },
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
proxy.close();
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### Session Registry
|
|
563
|
+
|
|
564
|
+
Route different requests through different browser fingerprints:
|
|
565
|
+
|
|
566
|
+
```javascript
|
|
567
|
+
const { LocalProxy, Session } = require("httpcloak");
|
|
568
|
+
|
|
569
|
+
const proxy = new LocalProxy({ preset: "chrome-143" });
|
|
570
|
+
|
|
571
|
+
// Create sessions with different fingerprints
|
|
572
|
+
const chromeSession = new Session({ preset: "chrome-143" });
|
|
573
|
+
const firefoxSession = new Session({ preset: "firefox-133" });
|
|
574
|
+
|
|
575
|
+
// Register sessions with the proxy
|
|
576
|
+
proxy.registerSession("chrome-user", chromeSession);
|
|
577
|
+
proxy.registerSession("firefox-user", firefoxSession);
|
|
578
|
+
|
|
579
|
+
// Route requests using X-HTTPCloak-Session header
|
|
580
|
+
const response = await axios.get("https://example.com", {
|
|
581
|
+
proxy: { host: "127.0.0.1", port: proxy.port },
|
|
582
|
+
headers: { "X-HTTPCloak-Session": "firefox-user" }, // Uses firefox fingerprint
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
// Unregister when done
|
|
586
|
+
proxy.unregisterSession("chrome-user");
|
|
587
|
+
proxy.unregisterSession("firefox-user");
|
|
588
|
+
|
|
589
|
+
chromeSession.close();
|
|
590
|
+
firefoxSession.close();
|
|
591
|
+
proxy.close();
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### LocalProxy Options
|
|
595
|
+
|
|
596
|
+
```javascript
|
|
597
|
+
const proxy = new LocalProxy({
|
|
598
|
+
port: 0, // Port (0 = auto-select)
|
|
599
|
+
preset: "chrome-143", // Browser fingerprint
|
|
600
|
+
timeout: 30, // Request timeout in seconds
|
|
601
|
+
maxConnections: 1000, // Max concurrent connections
|
|
602
|
+
tcpProxy: null, // Default upstream TCP proxy
|
|
603
|
+
udpProxy: null, // Default upstream UDP proxy
|
|
604
|
+
tlsOnly: false, // TLS-only mode
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
proxy.port; // Actual port number
|
|
608
|
+
proxy.proxyUrl; // Full proxy URL (http://127.0.0.1:port)
|
|
609
|
+
proxy.isRunning; // True if proxy is active
|
|
610
|
+
proxy.getStats(); // Returns object with request/connection stats
|
|
611
|
+
proxy.close(); // Stop the proxy
|
|
612
|
+
```
|
|
613
|
+
|
|
509
614
|
## Platform Support
|
|
510
615
|
|
|
511
616
|
- Linux (x64, arm64)
|