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 +110 -26
- package/dist/wreq-js.cjs +796 -94
- package/dist/wreq-js.cjs.map +1 -1
- package/dist/wreq-js.d.cts +248 -102
- package/dist/wreq-js.d.ts +248 -102
- package/dist/wreq-js.js +796 -94
- package/dist/wreq-js.js.map +1 -1
- package/package.json +4 -1
- package/rust/wreq-js.darwin-arm64.node +0 -0
- package/rust/wreq-js.darwin-x64.node +0 -0
- package/rust/wreq-js.linux-arm64-gnu.node +0 -0
- package/rust/wreq-js.linux-x64-gnu.node +0 -0
- package/rust/wreq-js.linux-x64-musl.node +0 -0
- package/rust/wreq-js.win32-x64-msvc.node +0 -0
package/README.md
CHANGED
|
@@ -4,27 +4,29 @@
|
|
|
4
4
|
[](https://github.com/sqdshguy/wreq-js/actions/workflows/test.yml)
|
|
5
5
|
[](https://deepwiki.com/sqdshguy/wreq-js)
|
|
6
6
|
|
|
7
|
-
Node.js
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 |
|
|
22
|
-
|
|
23
|
-
| **wreq-js** | Rust native bindings ([wreq](https://github.com/0x676e67/wreq)) |
|
|
24
|
-
| [CycleTLS](https://github.com/Danny-Dasilva/CycleTLS) | Go subprocess
|
|
25
|
-
| [got-scraping](https://github.com/apify/got-scraping) |
|
|
26
|
-
| [node-tls-client](https://github.com/Sahil1337/node-tls-client) |
|
|
27
|
-
| [curl-impersonate](https://github.com/lwthiker/curl-impersonate) |
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
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
|
|
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
|
|
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) -
|
|
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
|