@grabbit-labs/dynafetch 0.1.0 → 0.1.2
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 +109 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# dynafetch
|
|
2
|
+
|
|
3
|
+
Fetch any website like a real browser. One function call.
|
|
4
|
+
|
|
5
|
+
dynafetch provides Chrome-level TLS fingerprinting, JavaScript execution, and full network interception. The response includes fully rendered HTML and all captured requests.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { dynafetch } from "@grabbit-labs/dynafetch";
|
|
9
|
+
|
|
10
|
+
const page = await dynafetch("https://example.com");
|
|
11
|
+
console.log(page.html); // fully rendered HTML
|
|
12
|
+
console.log(page.framework); // "nextjs", "inertia", "nuxt", ...
|
|
13
|
+
console.log(page.status); // 200
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- **Chrome TLS fingerprint**: indistinguishable from a real browser at the network layer
|
|
19
|
+
- **Full JS execution**: SPAs, client-rendered content, and lazy-loaded data
|
|
20
|
+
- **Request interception**: captures every `fetch()`, XHR, and WebSocket call
|
|
21
|
+
- **Framework detection**: identifies Next.js, Nuxt, Inertia, Remix, Astro, SvelteKit, and more
|
|
22
|
+
- **Performance**: parallel module resolution and batch network calls; 700+ module Vite apps render in under 5 seconds
|
|
23
|
+
|
|
24
|
+
## Hyper-Proxying
|
|
25
|
+
|
|
26
|
+
Route specific request types through your proxy while letting others connect directly. This reduces proxy bandwidth and latency for requests that don't need it.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// Proxy all requests
|
|
30
|
+
const page = await dynafetch({
|
|
31
|
+
url: "https://example.com",
|
|
32
|
+
proxy: "http://user:pass@ip:port",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Only proxy the page fetch and API calls, not static assets
|
|
36
|
+
const page = await dynafetch({
|
|
37
|
+
url: "https://example.com",
|
|
38
|
+
proxy: {
|
|
39
|
+
url: "http://user:pass@ip:port",
|
|
40
|
+
only: ["page", "api"],
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Scope | Covers |
|
|
46
|
+
|-|-|
|
|
47
|
+
| `"page"` | Initial HTML document fetch |
|
|
48
|
+
| `"api"` | `fetch()` and XHR calls from page scripts |
|
|
49
|
+
| `"assets"` | JS scripts, ES modules, static resources |
|
|
50
|
+
|
|
51
|
+
## Headers and cookies
|
|
52
|
+
|
|
53
|
+
Chrome 146 headers are included by default. Custom headers merge on top; your values override the defaults, everything else is preserved.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const page = await dynafetch({
|
|
57
|
+
url: "https://example.com",
|
|
58
|
+
headers: { "Accept-Language": "fr-FR" },
|
|
59
|
+
cookies: { session: "abc123" },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quiescence tuning
|
|
64
|
+
|
|
65
|
+
dynafetch waits for async network activity to complete before returning. These options control that behavior:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
// Return quickly
|
|
69
|
+
const page = await dynafetch({
|
|
70
|
+
url: "https://example.com",
|
|
71
|
+
maxWaitMs: 1000,
|
|
72
|
+
idleWaitMs: 50,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Wait longer for slow endpoints
|
|
76
|
+
const page = await dynafetch({
|
|
77
|
+
url: "https://example.com",
|
|
78
|
+
maxWaitMs: 5000,
|
|
79
|
+
idleWaitMs: 200,
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
| Option | Default | Description |
|
|
84
|
+
|-|-|-|
|
|
85
|
+
| `minWaitMs` | `75` | Minimum ms before checking idle state |
|
|
86
|
+
| `idleWaitMs` | `100` | Ms of zero pending requests to consider settled |
|
|
87
|
+
| `maxWaitMs` | `2000` | Hard cap on wait time |
|
|
88
|
+
| `moduleWaitMs` | `6000` | Max wait for ES module bundling |
|
|
89
|
+
| `timeoutMs` | none | Overall operation timeout |
|
|
90
|
+
|
|
91
|
+
## Architecture
|
|
92
|
+
|
|
93
|
+
1. **Harvest**: fetches the HTML document through a Go-based TLS client matching Chrome's handshake. Parses scripts, modulepreloads, and SSR state.
|
|
94
|
+
|
|
95
|
+
2. **Module graph resolution**: recursively discovers and batch-fetches the full JS dependency tree in parallel. 700+ modules resolve in approximately 5 batch rounds.
|
|
96
|
+
|
|
97
|
+
3. **Execute**: runs scripts in a sandboxed environment with browser API shims. All network calls are intercepted and routed through the TLS proxy.
|
|
98
|
+
|
|
99
|
+
4. **Settle**: waits for async activity to complete, then returns rendered HTML, framework metadata, and timing breakdown.
|
|
100
|
+
|
|
101
|
+
## Requirements
|
|
102
|
+
|
|
103
|
+
- Node.js 18+
|
|
104
|
+
|
|
105
|
+
The TLS proxy ships as precompiled binaries for macOS (arm64, x64), Linux (arm64, x64), and Windows (x64). No additional toolchain required.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grabbit-labs/dynafetch",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Fetch any website like a real browser. Chrome TLS fingerprinting, JS execution, and request interception in one function call.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|