wreq-js 1.7.0 → 2.0.0

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
@@ -4,27 +4,29 @@
4
4
  [![CI](https://github.com/sqdshguy/wreq-js/actions/workflows/test.yml/badge.svg)](https://github.com/sqdshguy/wreq-js/actions/workflows/test.yml)
5
5
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/sqdshguy/wreq-js)
6
6
 
7
- Node.js/TypeScript HTTP client with browser TLS fingerprint impersonation (JA3/JA4). Bypass Cloudflare, DataDome, and other anti-bot TLS fingerprinting. Rust-powered via [wreq](https://github.com/0x676e67/wreq).
8
-
9
- - **Bypass anti-bot TLS detection** (Cloudflare, DataDome, Akamai, etc.)
10
- - Native Rust performance (no browser/process spawning)
11
- - Real browser TLS fingerprints (JA3/JA4)
12
- - HTTP/2 impersonation (SETTINGS/PRIORITY/header ordering)
13
- - Multiple browser profiles (Chrome/Firefox/Safari/Edge/Opera/OkHttp)
14
- - `fetch()`-compatible API with sessions, cookies, and proxies
15
- - WebSocket support with fingerprint consistency
16
- - Prebuilt native binaries for macOS/Linux/Windows
17
- - TypeScript-first with generated definitions
7
+ `wreq-js` is a Node.js and TypeScript HTTP client that helps you bypass TLS fingerprinting checks used by services like Cloudflare and DataDome, powered by native Rust bindings from [wreq](https://github.com/0x676e67/wreq).
8
+
9
+ If your requests work in a browser but get blocked from Node.js because your network fingerprint looks wrong, this is for you.
10
+ You keep a fetch style API and get browser profile level network behavior without running a full browser.
11
+
12
+ 1. Built in browser TLS and HTTP fingerprint profiles across Chrome, Firefox, Safari, Edge, Opera, and OkHttp families
13
+ 2. Native Rust engine for high throughput traffic with no browser process overhead
14
+ 3. Fetch style API with sessions, cookies, proxies, and transport controls
15
+ 4. WebSocket helper and constructor APIs with session cookie and transport reuse
16
+ 5. TypeScript first developer experience with generated definitions
17
+ 6. Native targets for macOS, Linux, and Windows
18
+
19
+ Common search terms: cloudflare bypass, datadome bypass, tls fingerprinting, ja3, ja4, browser impersonation, nodejs fetch, typescript http client.
18
20
 
19
21
  ## Alternatives comparison
20
22
 
21
- | Library | Approach | Maintained | API | Performance | Fingerprint profiles |
22
- |---------|----------|:----------:|-----|:-----------:|:--------------------:|
23
- | **wreq-js** | Rust native bindings ([wreq](https://github.com/0x676e67/wreq)) | Yes | `fetch()`-compatible, TypeScript-first | Native Rust, no subprocess overhead | Built-in, kept current via [wreq-util](https://github.com/0x676e67/wreq-util) |
24
- | [CycleTLS](https://github.com/Danny-Dasilva/CycleTLS) | Go subprocess | Sporadic | Promise-based | IPC overhead (Go subprocess) | BYO (manual JA3 strings) |
25
- | [got-scraping](https://github.com/apify/got-scraping) | Pure JS header tweaking | Yes | `got`-based | JS-only, no real TLS spoofing | N/A (header-level only) |
26
- | [node-tls-client](https://github.com/Sahil1337/node-tls-client) | Go shared lib (bogdanfinn) | Sporadic | Custom | FFI overhead | Depends on upstream |
27
- | [curl-impersonate](https://github.com/lwthiker/curl-impersonate) | Modified curl binary | Inactive (last release Mar 2024) | CLI/bindings | Subprocess | Stale |
23
+ | Library | Approach | API | Notes |
24
+ |---------|----------|-----|-------|
25
+ | **wreq-js** | Rust native bindings ([wreq](https://github.com/0x676e67/wreq)) | Fetch style, TypeScript first | Profile labels and network behavior come from the native layer |
26
+ | [CycleTLS](https://github.com/Danny-Dasilva/CycleTLS) | Go subprocess bridge | Promise based | Subprocess model |
27
+ | [got-scraping](https://github.com/apify/got-scraping) | JavaScript HTTP client customization | `got` based | Header and request customization |
28
+ | [node-tls-client](https://github.com/Sahil1337/node-tls-client) | Native shared library bindings | Custom | Behavior depends on upstream native layer |
29
+ | [curl-impersonate](https://github.com/lwthiker/curl-impersonate) | curl based tooling | CLI and bindings | Binary/tooling workflow |
28
30
 
29
31
  ## Documentation
30
32
 
@@ -34,6 +36,13 @@ All guides, concepts, and API reference live at:
34
36
 
35
37
  (If you're looking for examples, sessions/cookies, proxy usage, streaming, WebSockets, or the full API surface - it's all there.)
36
38
 
39
+ Quick links:
40
+ 1. Quickstart: https://wreq.sqdsh.win/quickstart
41
+ 2. API overview: https://wreq.sqdsh.win/api-reference/overview
42
+ 3. Sessions: https://wreq.sqdsh.win/concepts/sessions
43
+ 4. WebSockets: https://wreq.sqdsh.win/guides/websockets
44
+ 5. Compatibility matrix: https://wreq.sqdsh.win/concepts/compatibility-matrix
45
+
37
46
  ## Installation
38
47
 
39
48
  ```bash
@@ -44,12 +53,12 @@ pnpm add wreq-js
44
53
  bun add wreq-js
45
54
  ```
46
55
 
47
- Prebuilt binaries are provided for:
48
- - macOS (Intel & Apple Silicon)
49
- - Linux (x64 & ARM64, glibc & musl)
50
- - Windows (x64)
56
+ Current configured native target matrix in `package.json` includes:
57
+ 1. macOS (Intel and Apple Silicon)
58
+ 2. Linux (x64 glibc and musl, arm64 glibc)
59
+ 3. Windows (x64)
51
60
 
52
- If a prebuilt binary for your platform/commit is unavailable, the package will build from source (requires a Rust toolchain).
61
+ If a matching prebuilt artifact is unavailable for your environment, installation may build from source (requires a Rust toolchain).
53
62
 
54
63
  ## Quick start
55
64
 
@@ -64,10 +73,13 @@ const res = await fetch('https://example.com/api', {
64
73
  console.log(await res.json());
65
74
  ```
66
75
 
76
+ By default, standalone `fetch()` calls use isolated ephemeral cookie storage.
77
+ Use `createSession()` when you want cookie persistence across requests.
78
+
67
79
  ## Use sessions (recommended)
68
80
 
69
81
  For **most real-world workloads**, start with a session and reuse it across requests.
70
- This keeps TLS/cookies warm and avoids paying setup costs on every call.
82
+ This keeps one cookie and request context for multi step flows.
71
83
 
72
84
  ```ts
73
85
  import { createSession } from 'wreq-js';
@@ -85,12 +97,84 @@ try {
85
97
 
86
98
  More session patterns: https://wreq.sqdsh.win
87
99
 
100
+ ## WebSockets
101
+
102
+ Use the helper for a connected socket from one `await`.
103
+
104
+ ```ts
105
+ import { websocket } from 'wreq-js';
106
+
107
+ const ws = await websocket('wss://example.com/ws', {
108
+ browser: 'chrome_142',
109
+ headers: {
110
+ Authorization: 'Bearer token',
111
+ },
112
+ });
113
+
114
+ ws.onmessage = (event) => {
115
+ console.log(event.data);
116
+ };
117
+
118
+ ws.send('hello');
119
+ ws.close(1000, 'done');
120
+ ```
121
+
122
+ Use the constructor when you want browser like `CONNECTING` behavior.
123
+
124
+ ```ts
125
+ import { WebSocket } from 'wreq-js';
126
+
127
+ const ws = new WebSocket('wss://example.com/ws', {
128
+ browser: 'chrome_142',
129
+ os: 'windows',
130
+ });
131
+
132
+ ws.onopen = () => {
133
+ void ws.send('connected');
134
+ };
135
+ ```
136
+
137
+ Use `session.websocket(...)` to reuse cookies and transport settings from session HTTP calls.
138
+
139
+ ```ts
140
+ import { createSession } from 'wreq-js';
141
+
142
+ const session = await createSession({ browser: 'chrome_142' });
143
+
144
+ try {
145
+ await session.fetch('https://example.com/login', {
146
+ method: 'POST',
147
+ body: new URLSearchParams({ user: 'name', pass: 'secret' }),
148
+ });
149
+
150
+ const ws = await session.websocket('wss://example.com/ws');
151
+ ws.onmessage = (event) => {
152
+ console.log(event.data);
153
+ };
154
+ } finally {
155
+ await session.close();
156
+ }
157
+ ```
158
+
88
159
  ## When to use
89
160
 
90
- Use `wreq-js` when you need to make HTTP requests that pass Cloudflare, DataDome, or other anti-bot TLS fingerprinting checks without spinning up a real browser. It's a drop-in `fetch()` replacement that impersonates real browser TLS/HTTP2 fingerprints at the network level.
161
+ Use `wreq-js` when your Node.js HTTP or WebSocket traffic gets blocked because of TLS fingerprinting or browser profile mismatches.
162
+ It is a good fit when you want Cloudflare bypass and DataDome bypass style network behavior with a familiar fetch style API.
163
+ It handles transport and fingerprint level behavior, not CAPTCHA solving and not in page JavaScript execution.
91
164
 
92
165
  If you need DOM/JS execution, CAPTCHA solving, or full browser automation, use Playwright/Puppeteer instead.
93
166
 
167
+ ## FAQ
168
+
169
+ 1. Why use sessions?
170
+ Use sessions for multi-step flows where cookie and request context should be shared.
171
+
172
+ 2. Why does install compile from source on some machines?
173
+ If a matching prebuilt native artifact is unavailable, npm may build from source.
174
+
175
+ 3. Can I use per-request proxy overrides inside a session?
176
+ Yes, by passing a `transport` on that specific `session.fetch(...)` call. The `proxy` field itself remains session-scoped.
177
+
94
178
  ## Contributing
95
179
 
96
180
  See [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -102,5 +186,5 @@ This is a maintained fork of [will-work-for-meal/node-wreq](https://github.com/w
102
186
  ## Acknowledgments
103
187
 
104
188
  - [wreq](https://github.com/0x676e67/wreq) - Rust HTTP client with browser impersonation
105
- - [wreq-util](https://github.com/0x676e67/wreq-util) - source of up-to-date browser profiles
189
+ - [wreq-util](https://github.com/0x676e67/wreq-util) - related browser profile tooling in the upstream ecosystem
106
190
  - [NAPI-RS](https://napi.rs/) - Rust ↔ Node.js bindings