@webcrawl/curl-impersonate 1.3.0 → 1.3.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/dist/fetch.d.ts CHANGED
@@ -12,6 +12,8 @@ export interface ImpersonateFetchResult {
12
12
  contentType: string;
13
13
  /** Decompressed body bytes (the binary handles gzip/br/zstd itself). */
14
14
  body: Uint8Array;
15
+ /** Decompressed body size in bytes (body.length) — for bandwidth accounting. */
16
+ bytes: number;
15
17
  }
16
18
  export declare class ResourceTooLargeError extends Error {
17
19
  readonly bytes: number;
@@ -33,6 +35,12 @@ export interface ImpersonateFetchOptions {
33
35
  timeoutMs?: number;
34
36
  /** Declared-length guard before the body is accepted. */
35
37
  maxBytes?: number;
38
+ /**
39
+ * HTTP(S) proxy URL (credentials embedded, `http://user:pass@host:port`).
40
+ * Routes the hop through e.g. a residential proxy so the target sees a
41
+ * clean egress IP while the TLS fingerprint stays a real Chrome's.
42
+ */
43
+ proxy?: string;
36
44
  }
37
45
  /** Resolved binary path or null when the tier is unavailable. Memoized. */
38
46
  export declare function resolveBinary(): Promise<string | null>;
package/dist/fetch.js CHANGED
@@ -89,7 +89,7 @@ export async function impersonateFetch(url, options = {}) {
89
89
  if (!bin) {
90
90
  throw new ImpersonateUnavailableError("curl-impersonate binary unavailable");
91
91
  }
92
- const { profile = DEFAULT_IMPERSONATE_PROFILE, headers = {}, timeoutMs = 12_000, maxBytes, } = options;
92
+ const { profile = DEFAULT_IMPERSONATE_PROFILE, headers = {}, timeoutMs = 12_000, maxBytes, proxy, } = options;
93
93
  const navHeaders = profileHeaders(profile, headers);
94
94
  const headerArgs = Object.entries(navHeaders).flatMap(([k, v]) => ["-H", `${k}: ${v}`]);
95
95
  const dir = mkdtempSync(join(tmpdir(), "webcrawl-imp-"));
@@ -107,6 +107,7 @@ export async function impersonateFetch(url, options = {}) {
107
107
  "-w", "%{http_code}",
108
108
  url,
109
109
  ...headerArgs,
110
+ ...(proxy ? ["-x", proxy] : []),
110
111
  ], { stdio: ["ignore", "pipe", "pipe"] });
111
112
  let stdout = "";
112
113
  let stderr = "";
@@ -158,6 +159,7 @@ export async function impersonateFetch(url, options = {}) {
158
159
  .trim()
159
160
  .toLowerCase(),
160
161
  body,
162
+ bytes: body.byteLength,
161
163
  };
162
164
  }
163
165
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webcrawl/curl-impersonate",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Zero-dependency curl-impersonate fetch for Node.js — pinned lexiforest binary, Chrome TLS/HTTP2 fingerprint impersonation (chrome150 default), automatic per-platform download with sha256 verification",
5
5
  "type": "module",
6
6
  "license": "MIT",