httpcloak 1.5.7 → 1.5.9

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 CHANGED
@@ -334,8 +334,8 @@ console.log(cookies);
334
334
  // Access cookies as property
335
335
  console.log(session.cookies);
336
336
 
337
- // Clear a cookie
338
- session.clearCookie("session_id");
337
+ // Delete a cookie
338
+ session.deleteCookie("session_id");
339
339
 
340
340
  // Clear all cookies
341
341
  session.clearCookies();
@@ -506,6 +506,153 @@ 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
+ ### HTTPS with True Streaming (Recommended)
514
+
515
+ For HTTPS requests with full fingerprinting AND true streaming (request/response bodies not materialized into memory), use the `X-HTTPCloak-Scheme` header:
516
+
517
+ ```javascript
518
+ const { LocalProxy } = require("httpcloak");
519
+ const axios = require("axios");
520
+
521
+ // Start local proxy with Chrome fingerprint
522
+ const proxy = new LocalProxy({ preset: "chrome-143" });
523
+ console.log(`Proxy running on ${proxy.proxyUrl}`);
524
+
525
+ // Use X-HTTPCloak-Scheme header for HTTPS with fingerprinting + streaming
526
+ const response = await axios.get("http://example.com/api", {
527
+ // Note: http:// URL
528
+ proxy: {
529
+ host: "127.0.0.1",
530
+ port: proxy.port,
531
+ },
532
+ headers: {
533
+ "X-HTTPCloak-Scheme": "https", // Upgrades to HTTPS with fingerprinting
534
+ },
535
+ });
536
+
537
+ // This provides:
538
+ // - Full TLS fingerprinting (Chrome/Firefox JA3/JA4)
539
+ // - HTTP/3 support
540
+ // - True streaming (request body NOT materialized into memory)
541
+ // - Header modification capabilities
542
+
543
+ proxy.close();
544
+ ```
545
+
546
+ **Why use `X-HTTPCloak-Scheme`?**
547
+
548
+ Standard HTTP proxy clients use CONNECT tunneling for HTTPS, which means the proxy can't inspect or modify the request. The `X-HTTPCloak-Scheme: https` header tells LocalProxy to:
549
+ 1. Accept the request as plain HTTP
550
+ 2. Upgrade it to HTTPS internally
551
+ 3. Apply full TLS fingerprinting
552
+ 4. Stream request/response bodies without memory materialization
553
+
554
+ ### Basic Usage
555
+
556
+ ```javascript
557
+ const { LocalProxy } = require("httpcloak");
558
+ const axios = require("axios");
559
+
560
+ // Start local proxy with Chrome fingerprint
561
+ const proxy = new LocalProxy({ preset: "chrome-143" });
562
+
563
+ // Standard HTTPS (uses CONNECT tunnel - fingerprinting via upstream proxy only)
564
+ const response = await axios.get("https://example.com", {
565
+ proxy: {
566
+ host: "127.0.0.1",
567
+ port: proxy.port,
568
+ },
569
+ });
570
+
571
+ // Per-request upstream proxy rotation
572
+ const rotatedResponse = await axios.get("https://example.com", {
573
+ proxy: {
574
+ host: "127.0.0.1",
575
+ port: proxy.port,
576
+ },
577
+ headers: {
578
+ "X-Upstream-Proxy": "http://user:pass@rotating-proxy.com:8080",
579
+ },
580
+ });
581
+
582
+ proxy.close();
583
+ ```
584
+
585
+ ### TLS-Only Mode
586
+
587
+ When your client already provides authentic browser headers, use TLS-only mode:
588
+
589
+ ```javascript
590
+ const { LocalProxy } = require("httpcloak");
591
+
592
+ // Only apply TLS fingerprint, pass headers through
593
+ const proxy = new LocalProxy({ preset: "chrome-143", tlsOnly: true });
594
+
595
+ // Your client's headers are preserved
596
+ const response = await fetch("https://example.com", {
597
+ agent: new HttpsProxyAgent(proxy.proxyUrl),
598
+ headers: { "User-Agent": "My Custom UA" },
599
+ });
600
+
601
+ proxy.close();
602
+ ```
603
+
604
+ ### Session Registry
605
+
606
+ Route different requests through different browser fingerprints:
607
+
608
+ ```javascript
609
+ const { LocalProxy, Session } = require("httpcloak");
610
+
611
+ const proxy = new LocalProxy({ preset: "chrome-143" });
612
+
613
+ // Create sessions with different fingerprints
614
+ const chromeSession = new Session({ preset: "chrome-143" });
615
+ const firefoxSession = new Session({ preset: "firefox-133" });
616
+
617
+ // Register sessions with the proxy
618
+ proxy.registerSession("chrome-user", chromeSession);
619
+ proxy.registerSession("firefox-user", firefoxSession);
620
+
621
+ // Route requests using X-HTTPCloak-Session header
622
+ const response = await axios.get("https://example.com", {
623
+ proxy: { host: "127.0.0.1", port: proxy.port },
624
+ headers: { "X-HTTPCloak-Session": "firefox-user" }, // Uses firefox fingerprint
625
+ });
626
+
627
+ // Unregister when done
628
+ proxy.unregisterSession("chrome-user");
629
+ proxy.unregisterSession("firefox-user");
630
+
631
+ chromeSession.close();
632
+ firefoxSession.close();
633
+ proxy.close();
634
+ ```
635
+
636
+ ### LocalProxy Options
637
+
638
+ ```javascript
639
+ const proxy = new LocalProxy({
640
+ port: 0, // Port (0 = auto-select)
641
+ preset: "chrome-143", // Browser fingerprint
642
+ timeout: 30, // Request timeout in seconds
643
+ maxConnections: 1000, // Max concurrent connections
644
+ tcpProxy: null, // Default upstream TCP proxy
645
+ udpProxy: null, // Default upstream UDP proxy
646
+ tlsOnly: false, // TLS-only mode
647
+ });
648
+
649
+ proxy.port; // Actual port number
650
+ proxy.proxyUrl; // Full proxy URL (http://127.0.0.1:port)
651
+ proxy.isRunning; // True if proxy is active
652
+ proxy.getStats(); // Returns object with request/connection stats
653
+ proxy.close(); // Stop the proxy
654
+ ```
655
+
509
656
  ## Platform Support
510
657
 
511
658
  - Linux (x64, arm64)