wreq-js 2.2.2 → 2.3.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/dist/wreq-js.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Readable } from 'node:stream';
2
- import { ReadableStream } from 'node:stream/web';
1
+ import { Readable } from "node:stream";
2
+ import { ReadableStream } from "node:stream/web";
3
3
 
4
+ //#region src/generated-types.d.ts
4
5
  /**
5
6
  * Auto-generated from Rust build script
6
7
  * DO NOT EDIT MANUALLY
@@ -13,7 +14,8 @@ type BrowserProfile = 'chrome_100' | 'chrome_101' | 'chrome_104' | 'chrome_105'
13
14
  * Operating systems supported for emulation
14
15
  */
15
16
  type EmulationOS = 'windows' | 'macos' | 'linux' | 'android' | 'ios';
16
-
17
+ //#endregion
18
+ //#region src/types.d.ts
17
19
  /**
18
20
  * Controls how cookies are scoped for a request.
19
21
  * - "session": reuse an explicit Session or sessionId across calls.
@@ -25,7 +27,17 @@ type CookieMode = "session" | "ephemeral";
25
27
  * that only need to carry a session id.
26
28
  */
27
29
  interface SessionHandle {
28
- readonly id: string;
30
+ readonly id: string;
31
+ }
32
+ interface SessionCookie {
33
+ name: string;
34
+ value: string;
35
+ domain?: string;
36
+ path?: string;
37
+ secure: boolean;
38
+ httpOnly: boolean;
39
+ sameSite?: "lax" | "strict" | "none";
40
+ expiresAtMs?: number;
29
41
  }
30
42
  /**
31
43
  * A tuple of [name, value] pairs used for initializing headers.
@@ -58,89 +70,90 @@ type AlpnProtocol = "HTTP1" | "HTTP2" | "HTTP3";
58
70
  type AlpsProtocol = "HTTP1" | "HTTP2" | "HTTP3";
59
71
  type TlsVersion = "1.0" | "1.1" | "1.2" | "1.3" | "TLS1.0" | "TLS1.1" | "TLS1.2" | "TLS1.3";
60
72
  type Http2PseudoHeaderId = "Method" | "Scheme" | "Authority" | "Path" | "Protocol";
73
+ type TrustStoreMode = "combined" | "mozilla" | "defaultPaths";
61
74
  type Http2SettingId = "HeaderTableSize" | "EnablePush" | "MaxConcurrentStreams" | "InitialWindowSize" | "MaxFrameSize" | "MaxHeaderListSize" | "EnableConnectProtocol" | "NoRfc7540Priorities";
62
75
  interface Http2StreamDependency {
63
- dependencyId: number;
64
- weight: number;
65
- exclusive?: boolean;
76
+ dependencyId: number;
77
+ weight: number;
78
+ exclusive?: boolean;
66
79
  }
67
80
  interface Http2Priority {
68
- streamId: number;
69
- dependency: Http2StreamDependency;
81
+ streamId: number;
82
+ dependency: Http2StreamDependency;
70
83
  }
71
84
  interface Http2ExperimentalSetting {
72
- id: number;
73
- value: number;
85
+ id: number;
86
+ value: number;
74
87
  }
75
88
  interface CustomTlsOptions {
76
- alpnProtocols?: AlpnProtocol[];
77
- alpsProtocols?: AlpsProtocol[];
78
- alpsUseNewCodepoint?: boolean;
79
- sessionTicket?: boolean;
80
- minTlsVersion?: TlsVersion;
81
- maxTlsVersion?: TlsVersion;
82
- preSharedKey?: boolean;
83
- enableEchGrease?: boolean;
84
- permuteExtensions?: boolean;
85
- greaseEnabled?: boolean;
86
- enableOcspStapling?: boolean;
87
- enableSignedCertTimestamps?: boolean;
88
- recordSizeLimit?: number;
89
- pskSkipSessionTicket?: boolean;
90
- keySharesLimit?: number;
91
- pskDheKe?: boolean;
92
- renegotiation?: boolean;
93
- delegatedCredentials?: string;
94
- curvesList?: string;
95
- cipherList?: string;
96
- sigalgsList?: string;
97
- certificateCompressionAlgorithms?: Array<"zlib" | "brotli" | "zstd">;
98
- extensionPermutation?: number[];
99
- aesHwOverride?: boolean;
100
- preserveTls13CipherList?: boolean;
101
- randomAesHwOverride?: boolean;
89
+ alpnProtocols?: AlpnProtocol[];
90
+ alpsProtocols?: AlpsProtocol[];
91
+ alpsUseNewCodepoint?: boolean;
92
+ sessionTicket?: boolean;
93
+ minTlsVersion?: TlsVersion;
94
+ maxTlsVersion?: TlsVersion;
95
+ preSharedKey?: boolean;
96
+ enableEchGrease?: boolean;
97
+ permuteExtensions?: boolean;
98
+ greaseEnabled?: boolean;
99
+ enableOcspStapling?: boolean;
100
+ enableSignedCertTimestamps?: boolean;
101
+ recordSizeLimit?: number;
102
+ pskSkipSessionTicket?: boolean;
103
+ keySharesLimit?: number;
104
+ pskDheKe?: boolean;
105
+ renegotiation?: boolean;
106
+ delegatedCredentials?: string;
107
+ curvesList?: string;
108
+ cipherList?: string;
109
+ sigalgsList?: string;
110
+ certificateCompressionAlgorithms?: Array<"zlib" | "brotli" | "zstd">;
111
+ extensionPermutation?: number[];
112
+ aesHwOverride?: boolean;
113
+ preserveTls13CipherList?: boolean;
114
+ randomAesHwOverride?: boolean;
102
115
  }
103
116
  interface CustomHttp1Options {
104
- http09Responses?: boolean;
105
- writev?: boolean;
106
- maxHeaders?: number;
107
- readBufExactSize?: number;
108
- maxBufSize?: number;
109
- ignoreInvalidHeadersInResponses?: boolean;
110
- allowSpacesAfterHeaderNameInResponses?: boolean;
111
- allowObsoleteMultilineHeadersInResponses?: boolean;
117
+ http09Responses?: boolean;
118
+ writev?: boolean;
119
+ maxHeaders?: number;
120
+ readBufExactSize?: number;
121
+ maxBufSize?: number;
122
+ ignoreInvalidHeadersInResponses?: boolean;
123
+ allowSpacesAfterHeaderNameInResponses?: boolean;
124
+ allowObsoleteMultilineHeadersInResponses?: boolean;
112
125
  }
113
126
  interface CustomHttp2Options {
114
- adaptiveWindow?: boolean;
115
- initialStreamId?: number;
116
- initialConnectionWindowSize?: number;
117
- initialWindowSize?: number;
118
- initialMaxSendStreams?: number;
119
- maxFrameSize?: number;
120
- keepAliveInterval?: number;
121
- keepAliveTimeout?: number;
122
- keepAliveWhileIdle?: boolean;
123
- maxConcurrentResetStreams?: number;
124
- maxSendBufferSize?: number;
125
- maxConcurrentStreams?: number;
126
- maxHeaderListSize?: number;
127
- maxPendingAcceptResetStreams?: number;
128
- enablePush?: boolean;
129
- headerTableSize?: number;
130
- enableConnectProtocol?: boolean;
131
- noRfc7540Priorities?: boolean;
132
- settingsOrder?: Http2SettingId[];
133
- headersPseudoOrder?: Http2PseudoHeaderId[];
134
- headersStreamDependency?: Http2StreamDependency;
135
- priorities?: Http2Priority[];
136
- experimentalSettings?: Http2ExperimentalSetting[];
127
+ adaptiveWindow?: boolean;
128
+ initialStreamId?: number;
129
+ initialConnectionWindowSize?: number;
130
+ initialWindowSize?: number;
131
+ initialMaxSendStreams?: number;
132
+ maxFrameSize?: number;
133
+ keepAliveInterval?: number;
134
+ keepAliveTimeout?: number;
135
+ keepAliveWhileIdle?: boolean;
136
+ maxConcurrentResetStreams?: number;
137
+ maxSendBufferSize?: number;
138
+ maxConcurrentStreams?: number;
139
+ maxHeaderListSize?: number;
140
+ maxPendingAcceptResetStreams?: number;
141
+ enablePush?: boolean;
142
+ headerTableSize?: number;
143
+ enableConnectProtocol?: boolean;
144
+ noRfc7540Priorities?: boolean;
145
+ settingsOrder?: Http2SettingId[];
146
+ headersPseudoOrder?: Http2PseudoHeaderId[];
147
+ headersStreamDependency?: Http2StreamDependency;
148
+ priorities?: Http2Priority[];
149
+ experimentalSettings?: Http2ExperimentalSetting[];
137
150
  }
138
151
  interface CustomEmulationOptions {
139
- tlsOptions?: CustomTlsOptions;
140
- http1Options?: CustomHttp1Options;
141
- http2Options?: CustomHttp2Options;
142
- headers?: HeadersInit;
143
- origHeaders?: string[];
152
+ tlsOptions?: CustomTlsOptions;
153
+ http1Options?: CustomHttp1Options;
154
+ http2Options?: CustomHttp2Options;
155
+ headers?: HeadersInit;
156
+ origHeaders?: string[];
144
157
  }
145
158
  /**
146
159
  * Represents the various types of data that can be used as a request body.
@@ -168,43 +181,43 @@ type BodyInit = string | ArrayBuffer | ArrayBufferView | URLSearchParams | Buffe
168
181
  type WebSocketBinaryType = "nodebuffer" | "arraybuffer" | "blob";
169
182
  type WebSocketEventType = "open" | "message" | "close" | "error";
170
183
  interface WebSocketOpenEvent {
171
- type: "open";
172
- isTrusted: false;
173
- timeStamp: number;
174
- target: WebSocket;
175
- currentTarget: WebSocket;
184
+ type: "open";
185
+ isTrusted: false;
186
+ timeStamp: number;
187
+ target: WebSocket;
188
+ currentTarget: WebSocket;
176
189
  }
177
190
  interface WebSocketMessageEvent {
178
- type: "message";
179
- isTrusted: false;
180
- timeStamp: number;
181
- data: string | Buffer | ArrayBuffer | Blob;
182
- target: WebSocket;
183
- currentTarget: WebSocket;
191
+ type: "message";
192
+ isTrusted: false;
193
+ timeStamp: number;
194
+ data: string | Buffer | ArrayBuffer | Blob;
195
+ target: WebSocket;
196
+ currentTarget: WebSocket;
184
197
  }
185
198
  interface WebSocketErrorEvent {
186
- type: "error";
187
- isTrusted: false;
188
- timeStamp: number;
189
- message?: string;
190
- target: WebSocket;
191
- currentTarget: WebSocket;
199
+ type: "error";
200
+ isTrusted: false;
201
+ timeStamp: number;
202
+ message?: string;
203
+ target: WebSocket;
204
+ currentTarget: WebSocket;
192
205
  }
193
206
  interface WebSocketCloseEvent {
194
- type: "close";
195
- isTrusted: false;
196
- timeStamp: number;
197
- /**
198
- * WebSocket close status code (RFC 6455).
199
- */
200
- code: number;
201
- /**
202
- * UTF-8 close reason sent by the peer.
203
- */
204
- reason: string;
205
- wasClean: boolean;
206
- target: WebSocket;
207
- currentTarget: WebSocket;
207
+ type: "close";
208
+ isTrusted: false;
209
+ timeStamp: number;
210
+ /**
211
+ * WebSocket close status code (RFC 6455).
212
+ */
213
+ code: number;
214
+ /**
215
+ * UTF-8 close reason sent by the peer.
216
+ */
217
+ reason: string;
218
+ wasClean: boolean;
219
+ target: WebSocket;
220
+ currentTarget: WebSocket;
208
221
  }
209
222
  /**
210
223
  * Options for configuring a fetch style request with wreq-specific extensions
@@ -222,205 +235,264 @@ interface WebSocketCloseEvent {
222
235
  * };
223
236
  * ```
224
237
  */
238
+ type RequestEventType = "request_start" | "request_sent" | "response_headers" | "body_progress" | "body_complete" | "done" | "error";
239
+ interface RequestEvent {
240
+ type: RequestEventType;
241
+ timestamp: number;
242
+ status?: number;
243
+ url?: string;
244
+ contentLength?: number | null;
245
+ downloadedBytes?: number;
246
+ message?: string;
247
+ }
248
+ interface RequestDiagnostics {
249
+ totalDurationMs?: number;
250
+ headersDurationMs?: number;
251
+ status?: number;
252
+ localAddr?: string;
253
+ remoteAddr?: string;
254
+ tlsPeerCertificatePresent?: boolean;
255
+ tlsPeerCertificateChainLength?: number;
256
+ }
225
257
  interface RequestInit {
226
- /**
227
- * A string to set request's method.
228
- * @default 'GET'
229
- */
230
- method?: string;
231
- /**
232
- * A Headers object, an object literal, or an array of two-item arrays to set request's headers.
233
- */
234
- headers?: HeadersInit;
235
- /**
236
- * A BodyInit object or null to set request's body.
237
- */
238
- body?: BodyInit | null;
239
- /**
240
- * An AbortSignal to set request's signal.
241
- */
242
- signal?: AbortSignal | null;
243
- /**
244
- * A string indicating whether request follows redirects, results in an error upon
245
- * encountering a redirect, or returns the redirect (in an opaque fashion).
246
- * @default 'follow'
247
- */
248
- redirect?: "follow" | "manual" | "error";
249
- /**
250
- * Transport instance to use for this request. When provided, transport-level
251
- * options such as `browser`, `os`, `proxy`, and `insecure` must not be set.
252
- */
253
- transport?: Transport;
254
- /**
255
- * Browser profile to impersonate for this request.
256
- * Applies browser profile behavior handled by the native layer.
257
- * Ignored when `transport` is provided.
258
- * @default 'chrome_142'
259
- */
260
- browser?: BrowserProfile;
261
- /**
262
- * Operating system to emulate for this request.
263
- * Influences platform-specific behavior handled by the native layer.
264
- * Ignored when `transport` is provided.
265
- * @default 'macos'
266
- */
267
- os?: EmulationOS;
268
- /**
269
- * Custom emulation overrides. When `browser` or `os` is present, these fields
270
- * layer on top of the resolved preset profile. When both are omitted, this
271
- * switches the request into standalone custom emulation mode.
272
- */
273
- emulation?: CustomEmulationOptions;
274
- /**
275
- * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
276
- * Proxy support depends on the native layer and proxy scheme.
277
- * Ignored when `transport` is provided.
278
- */
279
- proxy?: string;
280
- /**
281
- * Request timeout in milliseconds. If the request takes longer than this value,
282
- * it will be aborted.
283
- * @default 30000
284
- */
285
- timeout?: number;
286
- /**
287
- * Controls how cookies are managed for this call.
288
- * - "ephemeral": default when no session/sessionId is provided. Creates an isolated session per request.
289
- * - "session": requires an explicit session or sessionId and reuses its cookie jar.
290
- */
291
- cookieMode?: CookieMode;
292
- /**
293
- * Session instance to bind this request to. When provided, {@link cookieMode}
294
- * automatically behaves like `"session"`.
295
- */
296
- session?: Session;
297
- /**
298
- * Identifier of an existing session created elsewhere (e.g., via {@link createSession}).
299
- */
300
- sessionId?: string;
301
- /**
302
- * Disable default headers from browser emulation. When enabled, only explicitly
303
- * provided headers will be sent with the request, preventing emulation headers
304
- * from being automatically added or appended.
305
- * @default false
306
- */
307
- disableDefaultHeaders?: boolean;
308
- /**
309
- * Disable HTTPS certificate verification. When enabled, self-signed and invalid
310
- * certificates will be accepted.
311
- * Ignored when `transport` is provided.
312
- *
313
- * # Warning
314
- *
315
- * You should think very carefully before using this method. If invalid
316
- * certificates are trusted, *any* certificate for *any* site will be
317
- * trusted for use. This includes expired certificates. This introduces
318
- * significant vulnerabilities, and should only be used as a last resort.
319
- *
320
- * @default false
321
- */
322
- insecure?: boolean;
323
- /**
324
- * Whether to automatically decompress response bodies. When set to `false`,
325
- * the raw compressed response body is returned as-is and the `Content-Encoding`
326
- * header is preserved. Useful for proxy scenarios where the downstream client
327
- * handles decompression.
328
- * @default true
329
- */
330
- compress?: boolean;
258
+ /**
259
+ * A string to set request's method.
260
+ * @default 'GET'
261
+ */
262
+ method?: string;
263
+ /**
264
+ * A Headers object, an object literal, or an array of two-item arrays to set request's headers.
265
+ */
266
+ headers?: HeadersInit;
267
+ /**
268
+ * A BodyInit object or null to set request's body.
269
+ */
270
+ body?: BodyInit | null;
271
+ /**
272
+ * An AbortSignal to set request's signal.
273
+ */
274
+ signal?: AbortSignal | null;
275
+ /**
276
+ * A string indicating whether request follows redirects, results in an error upon
277
+ * encountering a redirect, or returns the redirect (in an opaque fashion).
278
+ * @default 'follow'
279
+ */
280
+ redirect?: "follow" | "manual" | "error";
281
+ /**
282
+ * Transport instance to use for this request. When provided, transport-level
283
+ * options such as `browser`, `os`, `proxy`, and `insecure` must not be set.
284
+ */
285
+ transport?: Transport;
286
+ /**
287
+ * Browser profile to impersonate for this request.
288
+ * Applies browser profile behavior handled by the native layer.
289
+ * Ignored when `transport` is provided.
290
+ * @default 'chrome_142'
291
+ */
292
+ browser?: BrowserProfile;
293
+ /**
294
+ * Operating system to emulate for this request.
295
+ * Influences platform-specific behavior handled by the native layer.
296
+ * Ignored when `transport` is provided.
297
+ * @default 'macos'
298
+ */
299
+ os?: EmulationOS;
300
+ /**
301
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
302
+ * layer on top of the resolved preset profile. When both are omitted, this
303
+ * switches the request into standalone custom emulation mode.
304
+ */
305
+ emulation?: CustomEmulationOptions;
306
+ /**
307
+ * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
308
+ * Proxy support depends on the native layer and proxy scheme.
309
+ * Ignored when `transport` is provided.
310
+ */
311
+ proxy?: string;
312
+ /**
313
+ * Request timeout in milliseconds. If the request takes longer than this value,
314
+ * it will be aborted.
315
+ * @default 30000
316
+ */
317
+ timeout?: number;
318
+ /**
319
+ * Controls how cookies are managed for this call.
320
+ * - "ephemeral": default when no session/sessionId is provided. Creates an isolated session per request.
321
+ * - "session": requires an explicit session or sessionId and reuses its cookie jar.
322
+ */
323
+ cookieMode?: CookieMode;
324
+ /**
325
+ * Session instance to bind this request to. When provided, {@link cookieMode}
326
+ * automatically behaves like `"session"`.
327
+ */
328
+ session?: Session;
329
+ /**
330
+ * Identifier of an existing session created elsewhere (e.g., via {@link createSession}).
331
+ */
332
+ sessionId?: string;
333
+ /**
334
+ * Disable default headers from browser emulation. When enabled, only explicitly
335
+ * provided headers will be sent with the request, preventing emulation headers
336
+ * from being automatically added or appended.
337
+ * @default false
338
+ */
339
+ disableDefaultHeaders?: boolean;
340
+ /**
341
+ * Disable HTTPS certificate verification. When enabled, self-signed and invalid
342
+ * certificates will be accepted.
343
+ * Ignored when `transport` is provided.
344
+ *
345
+ * # Warning
346
+ *
347
+ * You should think very carefully before using this method. If invalid
348
+ * certificates are trusted, *any* certificate for *any* site will be
349
+ * trusted for use. This includes expired certificates. This introduces
350
+ * significant vulnerabilities, and should only be used as a last resort.
351
+ *
352
+ * @default false
353
+ */
354
+ insecure?: boolean;
355
+ /**
356
+ * Controls which certificate roots are used for TLS verification.
357
+ *
358
+ * - `"combined"` merges OpenSSL/BoringSSL default verify paths with bundled Mozilla roots.
359
+ * - `"mozilla"` uses only the bundled Mozilla roots.
360
+ * - `"defaultPaths"` uses only OpenSSL/BoringSSL default verify paths such as
361
+ * `SSL_CERT_FILE` / `SSL_CERT_DIR` when configured.
362
+ *
363
+ * Note: `"defaultPaths"` is not a native OS trust-store verifier.
364
+ * Ignored when `transport` is provided.
365
+ * @default "combined"
366
+ */
367
+ trustStore?: TrustStoreMode;
368
+ /**
369
+ * Whether to automatically decompress response bodies. When set to `false`,
370
+ * the raw compressed response body is returned as-is and the `Content-Encoding`
371
+ * header is preserved. Useful for proxy scenarios where the downstream client
372
+ * handles decompression.
373
+ * @default true
374
+ */
375
+ compress?: boolean;
376
+ /**
377
+ * Optional callback for structured request lifecycle events emitted by the
378
+ * native bridge.
379
+ */
380
+ onRequestEvent?: (event: RequestEvent) => void;
381
+ /**
382
+ * Capture a final diagnostics payload where supported by the native layer.
383
+ */
384
+ captureDiagnostics?: boolean;
331
385
  }
332
386
  /**
333
387
  * Configuration for {@link createSession}.
334
388
  */
335
389
  interface CreateSessionOptions {
336
- /**
337
- * Provide a custom identifier instead of an auto-generated random ID.
338
- */
339
- sessionId?: string;
340
- /**
341
- * Default headers applied to every request made through this session.
342
- */
343
- defaultHeaders?: HeadersInit;
344
- /**
345
- * Browser profile to bind to this session. Defaults to 'chrome_142'.
346
- */
347
- browser?: BrowserProfile;
348
- /**
349
- * Operating system to bind to this session. Defaults to 'macos'.
350
- */
351
- os?: EmulationOS;
352
- /**
353
- * Custom emulation overrides or a standalone custom emulation for the session transport.
354
- */
355
- emulation?: CustomEmulationOptions;
356
- /**
357
- * Optional proxy for every request made through the session.
358
- */
359
- proxy?: string;
360
- /**
361
- * Default timeout applied when {@link Session.fetch} is called without
362
- * overriding `timeout`.
363
- */
364
- timeout?: number;
365
- /**
366
- * Disable HTTPS certificate verification. When enabled, self-signed and invalid
367
- * certificates will be accepted for all requests made through this session.
368
- *
369
- * # Warning
370
- *
371
- * You should think very carefully before using this method. If invalid
372
- * certificates are trusted, *any* certificate for *any* site will be
373
- * trusted for use. This includes expired certificates. This introduces
374
- * significant vulnerabilities, and should only be used as a last resort.
375
- *
376
- * @default false
377
- */
378
- insecure?: boolean;
390
+ /**
391
+ * Provide a custom identifier instead of an auto-generated random ID.
392
+ */
393
+ sessionId?: string;
394
+ /**
395
+ * Default headers applied to every request made through this session.
396
+ */
397
+ defaultHeaders?: HeadersInit;
398
+ /**
399
+ * Browser profile to bind to this session. Defaults to 'chrome_142'.
400
+ */
401
+ browser?: BrowserProfile;
402
+ /**
403
+ * Operating system to bind to this session. Defaults to 'macos'.
404
+ */
405
+ os?: EmulationOS;
406
+ /**
407
+ * Custom emulation overrides or a standalone custom emulation for the session transport.
408
+ */
409
+ emulation?: CustomEmulationOptions;
410
+ /**
411
+ * Optional proxy for every request made through the session.
412
+ */
413
+ proxy?: string;
414
+ /**
415
+ * Default timeout applied when {@link Session.fetch} is called without
416
+ * overriding `timeout`.
417
+ */
418
+ timeout?: number;
419
+ /**
420
+ * Disable HTTPS certificate verification. When enabled, self-signed and invalid
421
+ * certificates will be accepted for all requests made through this session.
422
+ *
423
+ * # Warning
424
+ *
425
+ * You should think very carefully before using this method. If invalid
426
+ * certificates are trusted, *any* certificate for *any* site will be
427
+ * trusted for use. This includes expired certificates. This introduces
428
+ * significant vulnerabilities, and should only be used as a last resort.
429
+ *
430
+ * @default false
431
+ */
432
+ insecure?: boolean;
433
+ /**
434
+ * Controls which certificate roots are used for TLS verification for this session.
435
+ * @default "combined"
436
+ */
437
+ trustStore?: TrustStoreMode;
438
+ /**
439
+ * Enable extra connection/TLS diagnostics for requests made through this session.
440
+ */
441
+ captureDiagnostics?: boolean;
379
442
  }
380
443
  /**
381
444
  * Configuration for {@link createTransport}.
382
445
  */
383
446
  interface CreateTransportOptions {
384
- /**
385
- * Proxy URL to route requests through (e.g., 'http://proxy.example.com:8080').
386
- */
387
- proxy?: string;
388
- /**
389
- * Browser profile to impersonate for this transport.
390
- */
391
- browser?: BrowserProfile;
392
- /**
393
- * Operating system to emulate for this transport.
394
- */
395
- os?: EmulationOS;
396
- /**
397
- * Custom emulation overrides or a standalone custom emulation for this transport.
398
- */
399
- emulation?: CustomEmulationOptions;
400
- /**
401
- * Disable HTTPS certificate verification for this transport.
402
- */
403
- insecure?: boolean;
404
- /**
405
- * Idle timeout for pooled connections (ms).
406
- */
407
- poolIdleTimeout?: number;
408
- /**
409
- * Maximum number of idle connections per host.
410
- */
411
- poolMaxIdlePerHost?: number;
412
- /**
413
- * Maximum total connections in the pool.
414
- */
415
- poolMaxSize?: number;
416
- /**
417
- * TCP connect timeout (ms).
418
- */
419
- connectTimeout?: number;
420
- /**
421
- * Read timeout (ms).
422
- */
423
- readTimeout?: number;
447
+ /**
448
+ * Proxy URL to route requests through (e.g., 'http://proxy.example.com:8080').
449
+ */
450
+ proxy?: string;
451
+ /**
452
+ * Browser profile to impersonate for this transport.
453
+ */
454
+ browser?: BrowserProfile;
455
+ /**
456
+ * Operating system to emulate for this transport.
457
+ */
458
+ os?: EmulationOS;
459
+ /**
460
+ * Custom emulation overrides or a standalone custom emulation for this transport.
461
+ */
462
+ emulation?: CustomEmulationOptions;
463
+ /**
464
+ * Disable HTTPS certificate verification for this transport.
465
+ */
466
+ insecure?: boolean;
467
+ /**
468
+ * Controls which certificate roots are used for TLS verification for this transport.
469
+ * @default "combined"
470
+ */
471
+ trustStore?: TrustStoreMode;
472
+ /**
473
+ * Idle timeout for pooled connections (ms).
474
+ */
475
+ poolIdleTimeout?: number;
476
+ /**
477
+ * Maximum number of idle connections per host.
478
+ */
479
+ poolMaxIdlePerHost?: number;
480
+ /**
481
+ * Maximum total connections in the pool.
482
+ */
483
+ poolMaxSize?: number;
484
+ /**
485
+ * TCP connect timeout (ms).
486
+ */
487
+ connectTimeout?: number;
488
+ /**
489
+ * Read timeout (ms).
490
+ */
491
+ readTimeout?: number;
492
+ /**
493
+ * Enable extra connection/TLS diagnostics for requests made through this transport.
494
+ */
495
+ captureDiagnostics?: boolean;
424
496
  }
425
497
  /**
426
498
  * Legacy request options interface. This interface is deprecated and will be removed in a future version.
@@ -444,106 +516,120 @@ interface CreateTransportOptions {
444
516
  * ```
445
517
  */
446
518
  interface RequestOptions {
447
- /**
448
- * The URL to request.
449
- */
450
- url: string;
451
- /**
452
- * Browser profile to impersonate.
453
- * Applies browser profile behavior handled by the native layer.
454
- * @default 'chrome_142'
455
- */
456
- browser?: BrowserProfile;
457
- /**
458
- * Operating system to emulate.
459
- * @default 'macos'
460
- */
461
- os?: EmulationOS;
462
- /**
463
- * Custom emulation overrides. When `browser` or `os` is present, these fields
464
- * layer on top of the resolved preset profile. When both are omitted, this
465
- * switches the request into standalone custom emulation mode.
466
- */
467
- emulation?: CustomEmulationOptions;
468
- /**
469
- * HTTP method to use for the request.
470
- * @default 'GET'
471
- */
472
- method?: string;
473
- /**
474
- * Additional headers to send with the request.
475
- * Browser-specific headers will be automatically added based on the selected browser profile.
476
- */
477
- headers?: Record<string, string> | HeaderTuple[];
478
- /**
479
- * Request body data (for POST, PUT, PATCH requests).
480
- */
481
- body?: BodyInit | null;
482
- /**
483
- * Transport instance to use for this request. When provided, transport-level
484
- * options such as `browser`, `os`, `proxy`, and `insecure` must not be set.
485
- */
486
- transport?: Transport;
487
- /**
488
- * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
489
- * Proxy support depends on the native layer and proxy scheme.
490
- */
491
- proxy?: string;
492
- /**
493
- * Redirect policy applied to this request. Matches the `redirect` option accepted by {@link fetch}.
494
- * @default "follow"
495
- */
496
- redirect?: "follow" | "manual" | "error";
497
- /**
498
- * Request timeout in milliseconds. If the request takes longer than this value,
499
- * it will be aborted.
500
- * @default 30000
501
- */
502
- timeout?: number;
503
- /**
504
- * Signal used to abort the request.
505
- */
506
- signal?: AbortSignal | null;
507
- /**
508
- * Session instance to bind this request to.
509
- */
510
- session?: Session;
511
- /**
512
- * Controls cookie scoping behavior for this request.
513
- */
514
- cookieMode?: CookieMode;
515
- /**
516
- * Identifier for the session that should handle this request.
517
- * @internal
518
- */
519
- sessionId?: string;
520
- /**
521
- * Internal flag indicating whether the session should be discarded once the
522
- * request finishes.
523
- * @internal
524
- */
525
- ephemeral?: boolean;
526
- /**
527
- * Disable default headers from browser emulation. When enabled, only explicitly
528
- * provided headers will be sent with the request, preventing emulation headers
529
- * from being automatically added or appended.
530
- * @default false
531
- */
532
- disableDefaultHeaders?: boolean;
533
- /**
534
- * Disable HTTPS certificate verification. When enabled, self-signed and invalid
535
- * certificates will be accepted.
536
- *
537
- * # Warning
538
- *
539
- * You should think very carefully before using this method. If invalid
540
- * certificates are trusted, *any* certificate for *any* site will be
541
- * trusted for use. This includes expired certificates. This introduces
542
- * significant vulnerabilities, and should only be used as a last resort.
543
- *
544
- * @default false
545
- */
546
- insecure?: boolean;
519
+ /**
520
+ * The URL to request.
521
+ */
522
+ url: string;
523
+ /**
524
+ * Browser profile to impersonate.
525
+ * Applies browser profile behavior handled by the native layer.
526
+ * @default 'chrome_142'
527
+ */
528
+ browser?: BrowserProfile;
529
+ /**
530
+ * Operating system to emulate.
531
+ * @default 'macos'
532
+ */
533
+ os?: EmulationOS;
534
+ /**
535
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
536
+ * layer on top of the resolved preset profile. When both are omitted, this
537
+ * switches the request into standalone custom emulation mode.
538
+ */
539
+ emulation?: CustomEmulationOptions;
540
+ /**
541
+ * HTTP method to use for the request.
542
+ * @default 'GET'
543
+ */
544
+ method?: string;
545
+ /**
546
+ * Additional headers to send with the request.
547
+ * Browser-specific headers will be automatically added based on the selected browser profile.
548
+ */
549
+ headers?: Record<string, string> | HeaderTuple[];
550
+ /**
551
+ * Request body data (for POST, PUT, PATCH requests).
552
+ */
553
+ body?: BodyInit | null;
554
+ /**
555
+ * Transport instance to use for this request. When provided, transport-level
556
+ * options such as `browser`, `os`, `proxy`, and `insecure` must not be set.
557
+ */
558
+ transport?: Transport;
559
+ /**
560
+ * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
561
+ * Proxy support depends on the native layer and proxy scheme.
562
+ */
563
+ proxy?: string;
564
+ /**
565
+ * Redirect policy applied to this request. Matches the `redirect` option accepted by {@link fetch}.
566
+ * @default "follow"
567
+ */
568
+ redirect?: "follow" | "manual" | "error";
569
+ /**
570
+ * Request timeout in milliseconds. If the request takes longer than this value,
571
+ * it will be aborted.
572
+ * @default 30000
573
+ */
574
+ timeout?: number;
575
+ /**
576
+ * Signal used to abort the request.
577
+ */
578
+ signal?: AbortSignal | null;
579
+ /**
580
+ * Session instance to bind this request to.
581
+ */
582
+ session?: Session;
583
+ /**
584
+ * Controls cookie scoping behavior for this request.
585
+ */
586
+ cookieMode?: CookieMode;
587
+ /**
588
+ * Identifier for the session that should handle this request.
589
+ * @internal
590
+ */
591
+ sessionId?: string;
592
+ /**
593
+ * Internal flag indicating whether the session should be discarded once the
594
+ * request finishes.
595
+ * @internal
596
+ */
597
+ ephemeral?: boolean;
598
+ /**
599
+ * Disable default headers from browser emulation. When enabled, only explicitly
600
+ * provided headers will be sent with the request, preventing emulation headers
601
+ * from being automatically added or appended.
602
+ * @default false
603
+ */
604
+ disableDefaultHeaders?: boolean;
605
+ /**
606
+ * Disable HTTPS certificate verification. When enabled, self-signed and invalid
607
+ * certificates will be accepted.
608
+ *
609
+ * # Warning
610
+ *
611
+ * You should think very carefully before using this method. If invalid
612
+ * certificates are trusted, *any* certificate for *any* site will be
613
+ * trusted for use. This includes expired certificates. This introduces
614
+ * significant vulnerabilities, and should only be used as a last resort.
615
+ *
616
+ * @default false
617
+ */
618
+ insecure?: boolean;
619
+ /**
620
+ * Controls which certificate roots are used for TLS verification.
621
+ * @default "combined"
622
+ */
623
+ trustStore?: TrustStoreMode;
624
+ /**
625
+ * Optional callback for structured request lifecycle events emitted by the
626
+ * native bridge.
627
+ */
628
+ onRequestEvent?: (event: RequestEvent) => void;
629
+ /**
630
+ * Capture a final diagnostics payload where supported by the native layer.
631
+ */
632
+ captureDiagnostics?: boolean;
547
633
  }
548
634
  /**
549
635
  * Internal response payload returned from the native Rust binding.
@@ -553,38 +639,42 @@ interface RequestOptions {
553
639
  * @internal
554
640
  */
555
641
  interface NativeResponse {
556
- /**
557
- * HTTP status code (e.g., 200, 404, 500).
558
- */
559
- status: number;
560
- /**
561
- * Response headers as [name, value] tuples.
562
- * Header names are normalized to lowercase.
563
- */
564
- headers: HeaderTuple[];
565
- /**
566
- * Handle for streaming response body chunks from the native layer.
567
- * When `null`, the response does not have a body (e.g., HEAD/204/304).
568
- */
569
- bodyHandle: number | null;
570
- /**
571
- * Inline body buffer returned for small payloads. When present, `bodyHandle`
572
- * will be `null` to avoid a second native round-trip to read the body.
573
- */
574
- bodyBytes: Buffer | null;
575
- /**
576
- * Optional Content-Length hint reported by the server after decompression.
577
- */
578
- contentLength: number | null;
579
- /**
580
- * Cookies set by the server as [name, value] tuples.
581
- */
582
- cookies: HeaderTuple[];
583
- /**
584
- * Final URL after following any redirects.
585
- * If no redirects occurred, this will match the original request URL.
586
- */
587
- url: string;
642
+ /**
643
+ * HTTP status code (e.g., 200, 404, 500).
644
+ */
645
+ status: number;
646
+ /**
647
+ * Response headers as [name, value] tuples.
648
+ * Header names are normalized to lowercase.
649
+ */
650
+ headers: HeaderTuple[];
651
+ /**
652
+ * Handle for streaming response body chunks from the native layer.
653
+ * When `null`, the response does not have a body (e.g., HEAD/204/304).
654
+ */
655
+ bodyHandle: number | null;
656
+ /**
657
+ * Inline body buffer returned for small payloads. When present, `bodyHandle`
658
+ * will be `null` to avoid a second native round-trip to read the body.
659
+ */
660
+ bodyBytes: Buffer | null;
661
+ /**
662
+ * Optional Content-Length hint reported by the server after decompression.
663
+ */
664
+ contentLength: number | null;
665
+ /**
666
+ * Cookies set by the server as [name, value] tuples.
667
+ */
668
+ cookies: HeaderTuple[];
669
+ /**
670
+ * Final URL after following any redirects.
671
+ * If no redirects occurred, this will match the original request URL.
672
+ */
673
+ url: string;
674
+ /**
675
+ * Optional diagnostics payload collected by the native layer.
676
+ */
677
+ diagnostics?: RequestDiagnostics | null;
588
678
  }
589
679
  /**
590
680
  * Configuration options for creating a WebSocket connection.
@@ -603,83 +693,93 @@ interface NativeResponse {
603
693
  * ```
604
694
  */
605
695
  interface WebSocketOptions {
606
- /**
607
- * Browser profile to impersonate for the WebSocket upgrade request.
608
- * Automatically applies browser-specific headers and TLS fingerprints.
609
- * @default 'chrome_142'
610
- */
611
- browser?: BrowserProfile;
612
- /**
613
- * Operating system to emulate for the WebSocket handshake.
614
- * @default 'macos'
615
- */
616
- os?: EmulationOS;
617
- /**
618
- * Custom emulation overrides. When `browser` or `os` is present, these fields
619
- * layer on top of the resolved preset profile. When both are omitted, this
620
- * switches the handshake into standalone custom emulation mode.
621
- */
622
- emulation?: CustomEmulationOptions;
623
- /**
624
- * Additional headers to send with the WebSocket upgrade request.
625
- * Common headers include Authorization, Origin, or custom application headers.
626
- */
627
- headers?: HeadersInit;
628
- /**
629
- * Proxy URL to route the connection through (e.g., 'http://proxy.example.com:8080').
630
- * Proxy support depends on the native layer and proxy scheme.
631
- */
632
- proxy?: string;
633
- /**
634
- * Optional subprotocols for compatibility with the WHATWG WebSocket constructor.
635
- * Values are validated for non-empty, unique entries and sent in
636
- * the `Sec-WebSocket-Protocol` handshake header.
637
- */
638
- protocols?: string | string[];
639
- /**
640
- * Controls the binary payload type exposed via `MessageEvent.data`.
641
- * - "nodebuffer": delivers Node.js Buffer instances (default)
642
- * - "arraybuffer": delivers ArrayBuffer instances
643
- * - "blob": delivers Blob instances
644
- */
645
- binaryType?: WebSocketBinaryType;
696
+ /**
697
+ * Browser profile to impersonate for the WebSocket upgrade request.
698
+ * Automatically applies browser-specific headers and TLS fingerprints.
699
+ * @default 'chrome_142'
700
+ */
701
+ browser?: BrowserProfile;
702
+ /**
703
+ * Operating system to emulate for the WebSocket handshake.
704
+ * @default 'macos'
705
+ */
706
+ os?: EmulationOS;
707
+ /**
708
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
709
+ * layer on top of the resolved preset profile. When both are omitted, this
710
+ * switches the handshake into standalone custom emulation mode.
711
+ */
712
+ emulation?: CustomEmulationOptions;
713
+ /**
714
+ * Additional headers to send with the WebSocket upgrade request.
715
+ * Common headers include Authorization, Origin, or custom application headers.
716
+ */
717
+ headers?: HeadersInit;
718
+ /**
719
+ * Proxy URL to route the connection through (e.g., 'http://proxy.example.com:8080').
720
+ * Proxy support depends on the native layer and proxy scheme.
721
+ */
722
+ proxy?: string;
723
+ /**
724
+ * Optional subprotocols for compatibility with the WHATWG WebSocket constructor.
725
+ * Values are validated for non-empty, unique entries and sent in
726
+ * the `Sec-WebSocket-Protocol` handshake header.
727
+ */
728
+ protocols?: string | string[];
729
+ /**
730
+ * Maximum size in bytes for a single incoming WebSocket frame.
731
+ * Increase this when the peer sends large unfragmented frames.
732
+ */
733
+ maxFrameSize?: number;
734
+ /**
735
+ * Maximum size in bytes for a complete incoming WebSocket message.
736
+ * Increase this when the peer sends very large fragmented messages.
737
+ */
738
+ maxMessageSize?: number;
739
+ /**
740
+ * Controls the binary payload type exposed via `MessageEvent.data`.
741
+ * - "nodebuffer": delivers Node.js Buffer instances (default)
742
+ * - "arraybuffer": delivers ArrayBuffer instances
743
+ * - "blob": delivers Blob instances
744
+ */
745
+ binaryType?: WebSocketBinaryType;
646
746
  }
647
747
  interface LegacyWebSocketOptions extends WebSocketOptions {
648
- /**
649
- * @deprecated Use `websocket(url, options)` or `new WebSocket(...)`.
650
- */
651
- url: string;
652
- /**
653
- * @deprecated Use `onmessage` or `addEventListener("message", ...)`.
654
- */
655
- onMessage?: (data: string | Buffer) => void;
656
- /**
657
- * @deprecated Use `onclose` or `addEventListener("close", ...)`.
658
- */
659
- onClose?: (event: WebSocketCloseEvent) => void;
660
- /**
661
- * @deprecated Use `onerror` or `addEventListener("error", ...)`.
662
- */
663
- onError?: (error: string) => void;
748
+ /**
749
+ * @deprecated Use `websocket(url, options)` or `new WebSocket(...)`.
750
+ */
751
+ url: string;
752
+ /**
753
+ * @deprecated Use `onmessage` or `addEventListener("message", ...)`.
754
+ */
755
+ onMessage?: (data: string | Buffer) => void;
756
+ /**
757
+ * @deprecated Use `onclose` or `addEventListener("close", ...)`.
758
+ */
759
+ onClose?: (event: WebSocketCloseEvent) => void;
760
+ /**
761
+ * @deprecated Use `onerror` or `addEventListener("error", ...)`.
762
+ */
763
+ onError?: (error: string) => void;
664
764
  }
665
765
  type SessionWebSocketOptions = Omit<WebSocketOptions, "browser" | "os" | "proxy" | "emulation">;
666
766
  interface LegacySessionWebSocketOptions extends SessionWebSocketOptions {
667
- /**
668
- * @deprecated Use `session.websocket(url, options)`.
669
- */
670
- url: string;
671
- /**
672
- * @deprecated Use `onmessage` or `addEventListener("message", ...)`.
673
- */
674
- onMessage?: (data: string | Buffer) => void;
675
- /**
676
- * @deprecated Use `onclose` or `addEventListener("close", ...)`.
677
- */
678
- onClose?: (event: WebSocketCloseEvent) => void;
679
- /**
680
- * @deprecated Use `onerror` or `addEventListener("error", ...)`.
681
- */
682
- onError?: (error: string) => void;
767
+ /**
768
+ * @deprecated Use `session.websocket(url, options)`.
769
+ */
770
+ url: string;
771
+ /**
772
+ * @deprecated Use `onmessage` or `addEventListener("message", ...)`.
773
+ */
774
+ onMessage?: (data: string | Buffer) => void;
775
+ /**
776
+ * @deprecated Use `onclose` or `addEventListener("close", ...)`.
777
+ */
778
+ onClose?: (event: WebSocketCloseEvent) => void;
779
+ /**
780
+ * @deprecated Use `onerror` or `addEventListener("error", ...)`.
781
+ */
782
+ onError?: (error: string) => void;
683
783
  }
684
784
  /**
685
785
  * Internal WebSocket connection object returned from the native Rust binding.
@@ -689,22 +789,22 @@ interface LegacySessionWebSocketOptions extends SessionWebSocketOptions {
689
789
  * @internal
690
790
  */
691
791
  interface NativeWebSocketConnection {
692
- /**
693
- * Unique identifier for this WebSocket connection.
694
- * Used internally to track and manage the connection.
695
- * @internal
696
- */
697
- _id: number;
698
- /**
699
- * Selected subprotocol returned by the server, when present.
700
- * @internal
701
- */
702
- protocol?: string;
703
- /**
704
- * Negotiated extension string returned by the server, when present.
705
- * @internal
706
- */
707
- extensions?: string;
792
+ /**
793
+ * Unique identifier for this WebSocket connection.
794
+ * Used internally to track and manage the connection.
795
+ * @internal
796
+ */
797
+ _id: number;
798
+ /**
799
+ * Selected subprotocol returned by the server, when present.
800
+ * @internal
801
+ */
802
+ protocol?: string;
803
+ /**
804
+ * Negotiated extension string returned by the server, when present.
805
+ * @internal
806
+ */
807
+ extensions?: string;
708
808
  }
709
809
  /**
710
810
  * Error thrown when a request fails. This can occur due to network errors,
@@ -722,138 +822,143 @@ interface NativeWebSocketConnection {
722
822
  * ```
723
823
  */
724
824
  declare class RequestError extends TypeError {
725
- constructor(message: string);
825
+ constructor(message: string);
726
826
  }
727
-
827
+ //#endregion
828
+ //#region src/wreq-js.d.ts
728
829
  interface NativeWebSocketCloseEvent {
729
- code: number;
730
- reason: string;
830
+ code: number;
831
+ reason: string;
731
832
  }
732
833
  type SessionDefaults = {
733
- transportMode: ResolvedEmulationMode;
734
- proxy?: string;
735
- timeout?: number;
736
- insecure?: boolean;
737
- defaultHeaders?: HeaderTuple[];
738
- transportId?: string;
739
- ownsTransport?: boolean;
834
+ transportMode: ResolvedEmulationMode;
835
+ proxy?: string;
836
+ timeout?: number;
837
+ insecure?: boolean;
838
+ trustStore?: TrustStoreMode;
839
+ defaultHeaders?: HeaderTuple[];
840
+ captureDiagnostics?: boolean;
841
+ transportId?: string;
842
+ ownsTransport?: boolean;
740
843
  };
741
844
  type PresetEmulationMode = {
742
- kind: "preset";
743
- browser: BrowserProfile;
744
- os: EmulationOS;
745
- emulationJson?: string;
845
+ kind: "preset";
846
+ browser: BrowserProfile;
847
+ os: EmulationOS;
848
+ emulationJson?: string;
746
849
  };
747
850
  type CustomEmulationMode = {
748
- kind: "custom";
749
- emulationJson: string;
851
+ kind: "custom";
852
+ emulationJson: string;
750
853
  };
751
854
  type ResolvedEmulationMode = PresetEmulationMode | CustomEmulationMode;
752
855
  type LegacyWebSocketCallbacks = {
753
- onMessage?: (data: string | Buffer) => void;
754
- onClose?: (event: WebSocketCloseEvent) => void;
755
- onError?: (error: string) => void;
856
+ onMessage?: (data: string | Buffer) => void;
857
+ onClose?: (event: WebSocketCloseEvent) => void;
858
+ onError?: (error: string) => void;
756
859
  };
757
860
  type WebSocketOpenDispatchMode = "automatic" | "deferred";
758
861
  type InternalWebSocketInit = {
759
- readonly _internal: true;
760
- url: string;
761
- options: WebSocketOptions;
762
- openDispatchMode: WebSocketOpenDispatchMode;
763
- connect: (callbacks: {
764
- onMessage: (data: string | Buffer) => void;
765
- onClose: (event: NativeWebSocketCloseEvent) => void;
766
- onError: (message: string) => void;
767
- }) => Promise<NativeWebSocketConnection>;
768
- legacyCallbacks: LegacyWebSocketCallbacks | undefined;
862
+ readonly _internal: true;
863
+ url: string;
864
+ options: WebSocketOptions;
865
+ openDispatchMode: WebSocketOpenDispatchMode;
866
+ connect: (callbacks: {
867
+ onMessage: (data: string | Buffer) => void;
868
+ onClose: (event: NativeWebSocketCloseEvent) => void;
869
+ onError: (message: string) => void;
870
+ }) => Promise<NativeWebSocketConnection>;
871
+ legacyCallbacks: LegacyWebSocketCallbacks | undefined;
769
872
  };
770
873
  declare class Headers implements Iterable<[string, string]> {
771
- private readonly store;
772
- constructor(init?: HeadersInit);
773
- private applyInit;
774
- private normalizeName;
775
- private assertValue;
776
- append(name: string, value: unknown): void;
777
- set(name: string, value: unknown): void;
778
- get(name: string): string | null;
779
- has(name: string): boolean;
780
- delete(name: string): void;
781
- entries(): IterableIterator<[string, string]>;
782
- keys(): IterableIterator<string>;
783
- values(): IterableIterator<string>;
784
- forEach(callback: (value: string, name: string, parent: Headers) => void, thisArg?: unknown): void;
785
- [Symbol.iterator](): IterableIterator<[string, string]>;
786
- toObject(): Record<string, string>;
787
- toTuples(): HeaderTuple[];
874
+ private readonly store;
875
+ constructor(init?: HeadersInit);
876
+ private applyInit;
877
+ private normalizeName;
878
+ private assertValue;
879
+ append(name: string, value: unknown): void;
880
+ set(name: string, value: unknown): void;
881
+ get(name: string): string | null;
882
+ has(name: string): boolean;
883
+ delete(name: string): void;
884
+ entries(): IterableIterator<[string, string]>;
885
+ keys(): IterableIterator<string>;
886
+ values(): IterableIterator<string>;
887
+ forEach(callback: (value: string, name: string, parent: Headers) => void, thisArg?: unknown): void;
888
+ [Symbol.iterator](): IterableIterator<[string, string]>;
889
+ toObject(): Record<string, string>;
890
+ toTuples(): HeaderTuple[];
788
891
  }
789
892
  type ResponseType = "basic" | "cors" | "error" | "opaque" | "opaqueredirect";
790
893
  declare class Response {
791
- readonly status: number;
792
- readonly ok: boolean;
793
- readonly contentLength: number | null;
794
- readonly url: string;
795
- readonly type: ResponseType;
796
- bodyUsed: boolean;
797
- private readonly payload;
798
- private readonly requestUrl;
799
- private redirectedMemo;
800
- private readonly headersInit;
801
- private headersInstance;
802
- private readonly cookiesInit;
803
- private cookiesRecord;
804
- private inlineBody;
805
- private bodySource;
806
- private bodyStream;
807
- private nativeHandleAvailable;
808
- private nativeHandle;
809
- constructor(payload: NativeResponse, requestUrl: string, bodySource?: ReadableStream<Uint8Array> | null);
810
- get redirected(): boolean;
811
- get statusText(): string;
812
- get headers(): Headers;
813
- get cookies(): Record<string, string | string[]>;
814
- get body(): ReadableStream<Uint8Array> | null;
815
- json<T = unknown>(): Promise<T>;
816
- arrayBuffer(): Promise<ArrayBuffer>;
817
- text(): Promise<string>;
818
- blob(): Promise<Blob>;
819
- formData(): Promise<FormData>;
820
- readable(): Readable;
821
- clone(): Response;
822
- private assertBodyAvailable;
823
- private consumeBody;
894
+ readonly status: number;
895
+ readonly ok: boolean;
896
+ readonly contentLength: number | null;
897
+ readonly url: string;
898
+ readonly diagnostics: RequestDiagnostics | null;
899
+ readonly type: ResponseType;
900
+ bodyUsed: boolean;
901
+ private readonly payload;
902
+ private readonly requestUrl;
903
+ private redirectedMemo;
904
+ private readonly headersInit;
905
+ private headersInstance;
906
+ private readonly cookiesInit;
907
+ private cookiesRecord;
908
+ private inlineBody;
909
+ private bodySource;
910
+ private bodyStream;
911
+ private nativeHandleAvailable;
912
+ private nativeHandle;
913
+ constructor(payload: NativeResponse, requestUrl: string, bodySource?: ReadableStream<Uint8Array> | null);
914
+ get redirected(): boolean;
915
+ get statusText(): string;
916
+ get headers(): Headers;
917
+ get cookies(): Record<string, string | string[]>;
918
+ get body(): ReadableStream<Uint8Array> | null;
919
+ json<T = unknown>(): Promise<T>;
920
+ arrayBuffer(): Promise<ArrayBuffer>;
921
+ text(): Promise<string>;
922
+ blob(): Promise<Blob>;
923
+ formData(): Promise<FormData>;
924
+ readable(): Readable;
925
+ clone(): Response;
926
+ private assertBodyAvailable;
927
+ private consumeBody;
824
928
  }
825
929
  declare class Transport {
826
- readonly id: string;
827
- private disposed;
828
- constructor(id: string);
829
- get closed(): boolean;
830
- close(): Promise<void>;
930
+ readonly id: string;
931
+ private disposed;
932
+ constructor(id: string);
933
+ get closed(): boolean;
934
+ close(): Promise<void>;
831
935
  }
832
936
  declare class Session implements SessionHandle {
833
- readonly id: string;
834
- private disposed;
835
- private readonly defaults;
836
- constructor(id: string, defaults: SessionDefaults);
837
- get closed(): boolean;
838
- private ensureActive;
839
- /** @internal */
840
- getDefaults(): SessionDefaults;
841
- /** @internal */
842
- _defaultsRef(): SessionDefaults;
843
- fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
844
- clearCookies(): Promise<void>;
845
- getCookies(url: string | URL): Record<string, string>;
846
- setCookie(name: string, value: string, url: string | URL): void;
847
- /**
848
- * Create a WebSocket connection that shares this session's cookies and TLS configuration.
849
- *
850
- * @param urlOrOptions - WebSocket URL or legacy options object
851
- * @param options - Session WebSocket options
852
- * @returns Promise that resolves to the WebSocket instance
853
- */
854
- websocket(url: string | URL, options?: SessionWebSocketOptions): Promise<WebSocket>;
855
- websocket(options: LegacySessionWebSocketOptions): Promise<WebSocket>;
856
- close(): Promise<void>;
937
+ readonly id: string;
938
+ private disposed;
939
+ private readonly defaults;
940
+ constructor(id: string, defaults: SessionDefaults);
941
+ get closed(): boolean;
942
+ private ensureActive;
943
+ /** @internal */
944
+ getDefaults(): SessionDefaults;
945
+ /** @internal */
946
+ _defaultsRef(): SessionDefaults;
947
+ fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
948
+ clearCookies(): Promise<void>;
949
+ getCookies(url: string | URL): Record<string, string>;
950
+ getAllCookies(): SessionCookie[];
951
+ setCookie(name: string, value: string, url: string | URL): void;
952
+ /**
953
+ * Create a WebSocket connection that shares this session's cookies and TLS configuration.
954
+ *
955
+ * @param urlOrOptions - WebSocket URL or legacy options object
956
+ * @param options - Session WebSocket options
957
+ * @returns Promise that resolves to the WebSocket instance
958
+ */
959
+ websocket(url: string | URL, options?: SessionWebSocketOptions): Promise<WebSocket>;
960
+ websocket(options: LegacySessionWebSocketOptions): Promise<WebSocket>;
961
+ close(): Promise<void>;
857
962
  }
858
963
  /**
859
964
  * Fetch-compatible entry point that adds browser impersonation controls.
@@ -923,119 +1028,119 @@ declare function get(url: string | URL | Request, init?: Omit<RequestInit, "meth
923
1028
  */
924
1029
  declare function post(url: string | URL | Request, body?: BodyInit | null, init?: Omit<RequestInit, "method" | "body">): Promise<Response>;
925
1030
  type WebSocketAddEventListenerOptions = boolean | {
926
- once?: boolean;
927
- signal?: AbortSignal | null;
1031
+ once?: boolean;
1032
+ signal?: AbortSignal | null;
928
1033
  };
929
1034
  /**
930
1035
  * WHATWG-style WebSocket API with async connection establishment.
931
1036
  */
932
1037
  declare class WebSocket {
933
- static readonly CONNECTING = 0;
934
- static readonly OPEN = 1;
935
- static readonly CLOSING = 2;
936
- static readonly CLOSED = 3;
937
- readonly url: string;
938
- protocol: string;
939
- extensions: string;
940
- readyState: number;
941
- private _binaryType;
942
- private _bufferedAmount;
943
- private _onopen;
944
- private _onmessage;
945
- private _onclose;
946
- private _onerror;
947
- private _onHandlerOrder;
948
- private _listenerOrderCounter;
949
- private readonly _listeners;
950
- private readonly _legacyCallbacks;
951
- private readonly _openDispatchMode;
952
- private _connection;
953
- private _connectPromise;
954
- private _closeOptions;
955
- private _finalizerToken;
956
- private _openEventDispatched;
957
- private _openEventQueued;
958
- private _closeEventDispatched;
959
- private _nativeCloseStarted;
960
- private _pendingMessages;
961
- private _sendChain;
962
- constructor(init: InternalWebSocketInit);
963
- constructor(url: string | URL, protocols?: string | string[]);
964
- constructor(url: string | URL, protocols?: string | string[], options?: WebSocketOptions);
965
- constructor(url: string | URL, options?: WebSocketOptions);
966
- get binaryType(): WebSocketBinaryType;
967
- set binaryType(value: WebSocketBinaryType);
968
- get bufferedAmount(): number;
969
- get onopen(): ((this: WebSocket, event: WebSocketOpenEvent) => void) | null;
970
- set onopen(listener: ((this: WebSocket, event: WebSocketOpenEvent) => void) | null);
971
- get onmessage(): ((this: WebSocket, event: WebSocketMessageEvent) => void) | null;
972
- set onmessage(listener: ((this: WebSocket, event: WebSocketMessageEvent) => void) | null);
973
- get onclose(): ((this: WebSocket, event: WebSocketCloseEvent) => void) | null;
974
- set onclose(listener: ((this: WebSocket, event: WebSocketCloseEvent) => void) | null);
975
- get onerror(): ((this: WebSocket, event: WebSocketErrorEvent) => void) | null;
976
- set onerror(listener: ((this: WebSocket, event: WebSocketErrorEvent) => void) | null);
977
- static _connectWithInit(init: InternalWebSocketInit): Promise<WebSocket>;
978
- private static buildStandaloneInit;
979
- private connect;
980
- private _waitUntilConnected;
981
- private scheduleOpenEventAfterConnect;
982
- private scheduleOpenEventAfterAwait;
983
- private scheduleOpenEventWithDepth;
984
- private releaseConnectionTracking;
985
- private toMessageEventData;
986
- private invokeListener;
987
- private createBaseEvent;
988
- private getOnHandler;
989
- private getOnHandlerOrder;
990
- private getListenerMap;
991
- private dispatchEvent;
992
- private dispatchOpenEvent;
993
- private dispatchMessageEvent;
994
- private dispatchCloseEvent;
995
- private dispatchErrorEvent;
996
- private handleNativeMessage;
997
- private handleNativeError;
998
- private handleNativeClose;
999
- private finalizeClosed;
1000
- private startNativeClose;
1001
- addEventListener(type: "open", listener: ((event: WebSocketOpenEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1002
- addEventListener(type: "message", listener: ((event: WebSocketMessageEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1003
- addEventListener(type: "close", listener: ((event: WebSocketCloseEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1004
- addEventListener(type: "error", listener: ((event: WebSocketErrorEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1005
- addEventListener(type: string, listener: unknown, options?: WebSocketAddEventListenerOptions): void;
1006
- removeEventListener(type: "open", listener: ((event: WebSocketOpenEvent) => void) | null): void;
1007
- removeEventListener(type: "message", listener: ((event: WebSocketMessageEvent) => void) | null): void;
1008
- removeEventListener(type: "close", listener: ((event: WebSocketCloseEvent) => void) | null): void;
1009
- removeEventListener(type: "error", listener: ((event: WebSocketErrorEvent) => void) | null): void;
1010
- removeEventListener(type: string, listener: unknown): void;
1011
- private getSendByteLength;
1012
- private normalizeSendPayload;
1013
- send(data: string | Buffer | ArrayBuffer | ArrayBufferView | Blob): void;
1014
- close(code?: number, reason?: string): void;
1038
+ static readonly CONNECTING = 0;
1039
+ static readonly OPEN = 1;
1040
+ static readonly CLOSING = 2;
1041
+ static readonly CLOSED = 3;
1042
+ readonly url: string;
1043
+ protocol: string;
1044
+ extensions: string;
1045
+ readyState: number;
1046
+ private _binaryType;
1047
+ private _bufferedAmount;
1048
+ private _onopen;
1049
+ private _onmessage;
1050
+ private _onclose;
1051
+ private _onerror;
1052
+ private _onHandlerOrder;
1053
+ private _listenerOrderCounter;
1054
+ private readonly _listeners;
1055
+ private readonly _legacyCallbacks;
1056
+ private readonly _openDispatchMode;
1057
+ private _connection;
1058
+ private _connectPromise;
1059
+ private _closeOptions;
1060
+ private _finalizerToken;
1061
+ private _openEventDispatched;
1062
+ private _openEventQueued;
1063
+ private _closeEventDispatched;
1064
+ private _nativeCloseStarted;
1065
+ private _pendingMessages;
1066
+ private _sendChain;
1067
+ constructor(init: InternalWebSocketInit);
1068
+ constructor(url: string | URL, protocols?: string | string[]);
1069
+ constructor(url: string | URL, protocols?: string | string[], options?: WebSocketOptions);
1070
+ constructor(url: string | URL, options?: WebSocketOptions);
1071
+ get binaryType(): WebSocketBinaryType;
1072
+ set binaryType(value: WebSocketBinaryType);
1073
+ get bufferedAmount(): number;
1074
+ get onopen(): ((this: WebSocket, event: WebSocketOpenEvent) => void) | null;
1075
+ set onopen(listener: ((this: WebSocket, event: WebSocketOpenEvent) => void) | null);
1076
+ get onmessage(): ((this: WebSocket, event: WebSocketMessageEvent) => void) | null;
1077
+ set onmessage(listener: ((this: WebSocket, event: WebSocketMessageEvent) => void) | null);
1078
+ get onclose(): ((this: WebSocket, event: WebSocketCloseEvent) => void) | null;
1079
+ set onclose(listener: ((this: WebSocket, event: WebSocketCloseEvent) => void) | null);
1080
+ get onerror(): ((this: WebSocket, event: WebSocketErrorEvent) => void) | null;
1081
+ set onerror(listener: ((this: WebSocket, event: WebSocketErrorEvent) => void) | null);
1082
+ static _connectWithInit(init: InternalWebSocketInit): Promise<WebSocket>;
1083
+ private static buildStandaloneInit;
1084
+ private connect;
1085
+ private _waitUntilConnected;
1086
+ private scheduleOpenEventAfterConnect;
1087
+ private scheduleOpenEventAfterAwait;
1088
+ private scheduleOpenEventWithDepth;
1089
+ private releaseConnectionTracking;
1090
+ private toMessageEventData;
1091
+ private invokeListener;
1092
+ private createBaseEvent;
1093
+ private getOnHandler;
1094
+ private getOnHandlerOrder;
1095
+ private getListenerMap;
1096
+ private dispatchEvent;
1097
+ private dispatchOpenEvent;
1098
+ private dispatchMessageEvent;
1099
+ private dispatchCloseEvent;
1100
+ private dispatchErrorEvent;
1101
+ private handleNativeMessage;
1102
+ private handleNativeError;
1103
+ private handleNativeClose;
1104
+ private finalizeClosed;
1105
+ private startNativeClose;
1106
+ addEventListener(type: "open", listener: ((event: WebSocketOpenEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1107
+ addEventListener(type: "message", listener: ((event: WebSocketMessageEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1108
+ addEventListener(type: "close", listener: ((event: WebSocketCloseEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1109
+ addEventListener(type: "error", listener: ((event: WebSocketErrorEvent) => void) | null, options?: WebSocketAddEventListenerOptions): void;
1110
+ addEventListener(type: string, listener: unknown, options?: WebSocketAddEventListenerOptions): void;
1111
+ removeEventListener(type: "open", listener: ((event: WebSocketOpenEvent) => void) | null): void;
1112
+ removeEventListener(type: "message", listener: ((event: WebSocketMessageEvent) => void) | null): void;
1113
+ removeEventListener(type: "close", listener: ((event: WebSocketCloseEvent) => void) | null): void;
1114
+ removeEventListener(type: "error", listener: ((event: WebSocketErrorEvent) => void) | null): void;
1115
+ removeEventListener(type: string, listener: unknown): void;
1116
+ private getSendByteLength;
1117
+ private normalizeSendPayload;
1118
+ send(data: string | Buffer | ArrayBuffer | ArrayBufferView | Blob): void;
1119
+ close(code?: number, reason?: string): void;
1015
1120
  }
1016
1121
  /**
1017
1122
  * Create a WebSocket connection with browser impersonation.
1018
1123
  */
1019
1124
  declare function websocket(url: string | URL, options?: WebSocketOptions): Promise<WebSocket>;
1020
1125
  declare function websocket(options: LegacyWebSocketOptions): Promise<WebSocket>;
1021
-
1022
1126
  declare const _default: {
1023
- fetch: typeof fetch;
1024
- request: typeof request;
1025
- get: typeof get;
1026
- post: typeof post;
1027
- getProfiles: typeof getProfiles;
1028
- getOperatingSystems: typeof getOperatingSystems;
1029
- createTransport: typeof createTransport;
1030
- createSession: typeof createSession;
1031
- withSession: typeof withSession;
1032
- websocket: typeof websocket;
1033
- WebSocket: typeof WebSocket;
1034
- Headers: typeof Headers;
1035
- Response: typeof Response;
1036
- Transport: typeof Transport;
1037
- Session: typeof Session;
1038
- RequestError: typeof RequestError;
1127
+ fetch: typeof fetch;
1128
+ request: typeof request;
1129
+ get: typeof get;
1130
+ post: typeof post;
1131
+ getProfiles: typeof getProfiles;
1132
+ getOperatingSystems: typeof getOperatingSystems;
1133
+ createTransport: typeof createTransport;
1134
+ createSession: typeof createSession;
1135
+ withSession: typeof withSession;
1136
+ websocket: typeof websocket;
1137
+ WebSocket: typeof WebSocket;
1138
+ Headers: typeof Headers;
1139
+ Response: typeof Response;
1140
+ Transport: typeof Transport;
1141
+ Session: typeof Session;
1142
+ RequestError: typeof RequestError;
1039
1143
  };
1040
-
1041
- export { type AlpnProtocol, type AlpsProtocol, type BodyInit, type BrowserProfile, type CookieMode, type CreateSessionOptions, type CreateTransportOptions, type CustomEmulationOptions, type CustomHttp1Options, type CustomHttp2Options, type CustomTlsOptions, type EmulationOS, Headers, type HeadersInit, type Http2ExperimentalSetting, type Http2Priority, type Http2PseudoHeaderId, type Http2SettingId, type Http2StreamDependency, RequestError, type RequestInit, type RequestOptions, Response, Session, type SessionHandle, type SessionWebSocketOptions, type TlsVersion, Transport, WebSocket, type WebSocketBinaryType, type WebSocketCloseEvent, type WebSocketErrorEvent, type WebSocketEventType, type WebSocketMessageEvent, type WebSocketOpenEvent, type WebSocketOptions, createSession, createTransport, _default as default, fetch, get, getOperatingSystems, getProfiles, post, request, websocket, withSession };
1144
+ //#endregion
1145
+ export { type AlpnProtocol, type AlpsProtocol, type BodyInit, type BrowserProfile, type CookieMode, type CreateSessionOptions, type CreateTransportOptions, type CustomEmulationOptions, type CustomHttp1Options, type CustomHttp2Options, type CustomTlsOptions, type EmulationOS, Headers, type HeadersInit, type Http2ExperimentalSetting, type Http2Priority, type Http2PseudoHeaderId, type Http2SettingId, type Http2StreamDependency, type RequestDiagnostics, RequestError, type RequestEvent, type RequestEventType, type RequestInit, type RequestOptions, Response, Session, type SessionHandle, type SessionWebSocketOptions, type TlsVersion, Transport, WebSocket, type WebSocketBinaryType, type WebSocketCloseEvent, type WebSocketErrorEvent, type WebSocketEventType, type WebSocketMessageEvent, type WebSocketOpenEvent, type WebSocketOptions, createSession, createTransport, _default as default, fetch, get, getOperatingSystems, getProfiles, post, request, websocket, withSession };
1146
+ //# sourceMappingURL=wreq-js.d.ts.map