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.cjs +2046 -2605
- package/dist/wreq-js.cjs.map +1 -1
- package/dist/wreq-js.d.ts +829 -724
- package/dist/wreq-js.js +2029 -2569
- package/dist/wreq-js.js.map +1 -1
- package/package.json +10 -13
- 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/dist/wreq-js.d.cts +0 -1041
package/dist/wreq-js.d.cts
DELETED
|
@@ -1,1041 +0,0 @@
|
|
|
1
|
-
import { Readable } from 'node:stream';
|
|
2
|
-
import { ReadableStream } from 'node:stream/web';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Auto-generated from Rust build script
|
|
6
|
-
* DO NOT EDIT MANUALLY
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Browser profile names supported
|
|
10
|
-
*/
|
|
11
|
-
type BrowserProfile = 'chrome_100' | 'chrome_101' | 'chrome_104' | 'chrome_105' | 'chrome_106' | 'chrome_107' | 'chrome_108' | 'chrome_109' | 'chrome_110' | 'chrome_114' | 'chrome_116' | 'chrome_117' | 'chrome_118' | 'chrome_119' | 'chrome_120' | 'chrome_123' | 'chrome_124' | 'chrome_126' | 'chrome_127' | 'chrome_128' | 'chrome_129' | 'chrome_130' | 'chrome_131' | 'chrome_132' | 'chrome_133' | 'chrome_134' | 'chrome_135' | 'chrome_136' | 'chrome_137' | 'chrome_138' | 'chrome_139' | 'chrome_140' | 'chrome_141' | 'chrome_142' | 'chrome_143' | 'chrome_144' | 'chrome_145' | 'edge_101' | 'edge_122' | 'edge_127' | 'edge_131' | 'edge_134' | 'edge_135' | 'edge_136' | 'edge_137' | 'edge_138' | 'edge_139' | 'edge_140' | 'edge_141' | 'edge_142' | 'edge_143' | 'edge_144' | 'edge_145' | 'opera_116' | 'opera_117' | 'opera_118' | 'opera_119' | 'firefox_109' | 'firefox_117' | 'firefox_128' | 'firefox_133' | 'firefox_135' | 'firefox_private_135' | 'firefox_android_135' | 'firefox_136' | 'firefox_private_136' | 'firefox_139' | 'firefox_142' | 'firefox_143' | 'firefox_144' | 'firefox_145' | 'firefox_146' | 'firefox_147' | 'safari_ios_17.2' | 'safari_ios_17.4.1' | 'safari_ios_16.5' | 'safari_15.3' | 'safari_15.5' | 'safari_15.6.1' | 'safari_16' | 'safari_16.5' | 'safari_17.0' | 'safari_17.2.1' | 'safari_17.4.1' | 'safari_17.5' | 'safari_17.6' | 'safari_18' | 'safari_ipad_18' | 'safari_18.2' | 'safari_ios_18.1.1' | 'safari_18.3' | 'safari_18.3.1' | 'safari_18.5' | 'safari_26' | 'safari_26.1' | 'safari_26.2' | 'safari_ipad_26' | 'safari_ipad_26.2' | 'safari_ios_26' | 'safari_ios_26.2' | 'okhttp_3.9' | 'okhttp_3.11' | 'okhttp_3.13' | 'okhttp_3.14' | 'okhttp_4.9' | 'okhttp_4.10' | 'okhttp_4.12' | 'okhttp_5';
|
|
12
|
-
/**
|
|
13
|
-
* Operating systems supported for emulation
|
|
14
|
-
*/
|
|
15
|
-
type EmulationOS = 'windows' | 'macos' | 'linux' | 'android' | 'ios';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Controls how cookies are scoped for a request.
|
|
19
|
-
* - "session": reuse an explicit Session or sessionId across calls.
|
|
20
|
-
* - "ephemeral": create an isolated, single-use session.
|
|
21
|
-
*/
|
|
22
|
-
type CookieMode = "session" | "ephemeral";
|
|
23
|
-
/**
|
|
24
|
-
* Minimal handle implemented by {@link Session}. Exposed for integrations
|
|
25
|
-
* that only need to carry a session id.
|
|
26
|
-
*/
|
|
27
|
-
interface SessionHandle {
|
|
28
|
-
readonly id: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* A tuple of [name, value] pairs used for initializing headers.
|
|
32
|
-
* Both name and value must be strings.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* const headers: HeaderTuple = ['Content-Type', 'application/json'];
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
type HeaderTuple = [string, string];
|
|
40
|
-
/**
|
|
41
|
-
* Represents various input types accepted when creating or initializing headers.
|
|
42
|
-
* Can be an iterable of header tuples, an array of tuples, or a plain object.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* // As an object
|
|
47
|
-
* const headers: HeadersInit = { 'Content-Type': 'application/json' };
|
|
48
|
-
*
|
|
49
|
-
* // As an array of tuples
|
|
50
|
-
* const headers: HeadersInit = [['Content-Type', 'application/json']];
|
|
51
|
-
*
|
|
52
|
-
* // As an iterable
|
|
53
|
-
* const headers: HeadersInit = new Map([['Content-Type', 'application/json']]);
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
type HeadersInit = Iterable<HeaderTuple> | Array<HeaderTuple> | Record<string, string | number | boolean | null | undefined>;
|
|
57
|
-
type AlpnProtocol = "HTTP1" | "HTTP2" | "HTTP3";
|
|
58
|
-
type AlpsProtocol = "HTTP1" | "HTTP2" | "HTTP3";
|
|
59
|
-
type TlsVersion = "1.0" | "1.1" | "1.2" | "1.3" | "TLS1.0" | "TLS1.1" | "TLS1.2" | "TLS1.3";
|
|
60
|
-
type Http2PseudoHeaderId = "Method" | "Scheme" | "Authority" | "Path" | "Protocol";
|
|
61
|
-
type Http2SettingId = "HeaderTableSize" | "EnablePush" | "MaxConcurrentStreams" | "InitialWindowSize" | "MaxFrameSize" | "MaxHeaderListSize" | "EnableConnectProtocol" | "NoRfc7540Priorities";
|
|
62
|
-
interface Http2StreamDependency {
|
|
63
|
-
dependencyId: number;
|
|
64
|
-
weight: number;
|
|
65
|
-
exclusive?: boolean;
|
|
66
|
-
}
|
|
67
|
-
interface Http2Priority {
|
|
68
|
-
streamId: number;
|
|
69
|
-
dependency: Http2StreamDependency;
|
|
70
|
-
}
|
|
71
|
-
interface Http2ExperimentalSetting {
|
|
72
|
-
id: number;
|
|
73
|
-
value: number;
|
|
74
|
-
}
|
|
75
|
-
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;
|
|
102
|
-
}
|
|
103
|
-
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;
|
|
112
|
-
}
|
|
113
|
-
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[];
|
|
137
|
-
}
|
|
138
|
-
interface CustomEmulationOptions {
|
|
139
|
-
tlsOptions?: CustomTlsOptions;
|
|
140
|
-
http1Options?: CustomHttp1Options;
|
|
141
|
-
http2Options?: CustomHttp2Options;
|
|
142
|
-
headers?: HeadersInit;
|
|
143
|
-
origHeaders?: string[];
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Represents the various types of data that can be used as a request body.
|
|
147
|
-
* Supports strings, binary payloads, URL-encoded parameters, multipart forms, and blobs.
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* // String body
|
|
152
|
-
* const body: BodyInit = JSON.stringify({ key: 'value' });
|
|
153
|
-
*
|
|
154
|
-
* // URLSearchParams
|
|
155
|
-
* const body: BodyInit = new URLSearchParams({ key: 'value' });
|
|
156
|
-
*
|
|
157
|
-
* // Buffer
|
|
158
|
-
* const body: BodyInit = Buffer.from('data');
|
|
159
|
-
*
|
|
160
|
-
* // FormData
|
|
161
|
-
* const body: BodyInit = new FormData();
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
type BodyInit = string | ArrayBuffer | ArrayBufferView | URLSearchParams | Buffer | Blob | FormData;
|
|
165
|
-
/**
|
|
166
|
-
* Details about why a WebSocket connection closed.
|
|
167
|
-
*/
|
|
168
|
-
type WebSocketBinaryType = "nodebuffer" | "arraybuffer" | "blob";
|
|
169
|
-
type WebSocketEventType = "open" | "message" | "close" | "error";
|
|
170
|
-
interface WebSocketOpenEvent {
|
|
171
|
-
type: "open";
|
|
172
|
-
isTrusted: false;
|
|
173
|
-
timeStamp: number;
|
|
174
|
-
target: WebSocket;
|
|
175
|
-
currentTarget: WebSocket;
|
|
176
|
-
}
|
|
177
|
-
interface WebSocketMessageEvent {
|
|
178
|
-
type: "message";
|
|
179
|
-
isTrusted: false;
|
|
180
|
-
timeStamp: number;
|
|
181
|
-
data: string | Buffer | ArrayBuffer | Blob;
|
|
182
|
-
target: WebSocket;
|
|
183
|
-
currentTarget: WebSocket;
|
|
184
|
-
}
|
|
185
|
-
interface WebSocketErrorEvent {
|
|
186
|
-
type: "error";
|
|
187
|
-
isTrusted: false;
|
|
188
|
-
timeStamp: number;
|
|
189
|
-
message?: string;
|
|
190
|
-
target: WebSocket;
|
|
191
|
-
currentTarget: WebSocket;
|
|
192
|
-
}
|
|
193
|
-
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;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Options for configuring a fetch style request with wreq-specific extensions
|
|
211
|
-
* for browser impersonation, proxies, sessions, and timeouts.
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* const options: RequestInit = {
|
|
216
|
-
* method: 'POST',
|
|
217
|
-
* headers: { 'Content-Type': 'application/json' },
|
|
218
|
-
* body: JSON.stringify({ key: 'value' }),
|
|
219
|
-
* browser: 'chrome_142',
|
|
220
|
-
* proxy: 'http://proxy.example.com:8080',
|
|
221
|
-
* timeout: 5000
|
|
222
|
-
* };
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
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;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Configuration for {@link createSession}.
|
|
334
|
-
*/
|
|
335
|
-
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;
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Configuration for {@link createTransport}.
|
|
382
|
-
*/
|
|
383
|
-
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;
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Legacy request options interface. This interface is deprecated and will be removed in a future version.
|
|
427
|
-
*
|
|
428
|
-
* @deprecated Use {@link RequestInit} with the standard `fetch()` API instead.
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* ```typescript
|
|
432
|
-
* // Old (deprecated):
|
|
433
|
-
* const options: RequestOptions = {
|
|
434
|
-
* url: 'https://api.example.com',
|
|
435
|
-
* method: 'POST',
|
|
436
|
-
* body: JSON.stringify({ data: 'value' })
|
|
437
|
-
* };
|
|
438
|
-
*
|
|
439
|
-
* // New (recommended):
|
|
440
|
-
* const response = await fetch('https://api.example.com', {
|
|
441
|
-
* method: 'POST',
|
|
442
|
-
* body: JSON.stringify({ data: 'value' })
|
|
443
|
-
* });
|
|
444
|
-
* ```
|
|
445
|
-
*/
|
|
446
|
-
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;
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Internal response payload returned from the native Rust binding.
|
|
550
|
-
* This interface represents the raw response data before it's converted
|
|
551
|
-
* to a standard Response object.
|
|
552
|
-
*
|
|
553
|
-
* @internal
|
|
554
|
-
*/
|
|
555
|
-
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;
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Configuration options for creating a WebSocket connection.
|
|
591
|
-
* Supports browser impersonation and proxies, similar to HTTP requests.
|
|
592
|
-
*
|
|
593
|
-
* @example
|
|
594
|
-
* ```typescript
|
|
595
|
-
* const ws = await websocket('wss://example.com/socket', {
|
|
596
|
-
* browser: 'chrome_142',
|
|
597
|
-
* headers: { 'Authorization': 'Bearer token' },
|
|
598
|
-
* });
|
|
599
|
-
*
|
|
600
|
-
* ws.onmessage = (event) => {
|
|
601
|
-
* console.log('Received:', event.data);
|
|
602
|
-
* };
|
|
603
|
-
* ```
|
|
604
|
-
*/
|
|
605
|
-
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;
|
|
646
|
-
}
|
|
647
|
-
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;
|
|
664
|
-
}
|
|
665
|
-
type SessionWebSocketOptions = Omit<WebSocketOptions, "browser" | "os" | "proxy" | "emulation">;
|
|
666
|
-
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;
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Internal WebSocket connection object returned from the native Rust binding.
|
|
686
|
-
* This interface contains the connection ID used to reference the WebSocket
|
|
687
|
-
* in subsequent operations like sending messages or closing the connection.
|
|
688
|
-
*
|
|
689
|
-
* @internal
|
|
690
|
-
*/
|
|
691
|
-
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;
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Error thrown when a request fails. This can occur due to network errors,
|
|
711
|
-
* timeouts, invalid URLs, or other request-related issues.
|
|
712
|
-
*
|
|
713
|
-
* @example
|
|
714
|
-
* ```typescript
|
|
715
|
-
* try {
|
|
716
|
-
* const response = await fetch('https://api.example.com');
|
|
717
|
-
* } catch (error) {
|
|
718
|
-
* if (error instanceof RequestError) {
|
|
719
|
-
* console.error('Request failed:', error.message);
|
|
720
|
-
* }
|
|
721
|
-
* }
|
|
722
|
-
* ```
|
|
723
|
-
*/
|
|
724
|
-
declare class RequestError extends TypeError {
|
|
725
|
-
constructor(message: string);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
interface NativeWebSocketCloseEvent {
|
|
729
|
-
code: number;
|
|
730
|
-
reason: string;
|
|
731
|
-
}
|
|
732
|
-
type SessionDefaults = {
|
|
733
|
-
transportMode: ResolvedEmulationMode;
|
|
734
|
-
proxy?: string;
|
|
735
|
-
timeout?: number;
|
|
736
|
-
insecure?: boolean;
|
|
737
|
-
defaultHeaders?: HeaderTuple[];
|
|
738
|
-
transportId?: string;
|
|
739
|
-
ownsTransport?: boolean;
|
|
740
|
-
};
|
|
741
|
-
type PresetEmulationMode = {
|
|
742
|
-
kind: "preset";
|
|
743
|
-
browser: BrowserProfile;
|
|
744
|
-
os: EmulationOS;
|
|
745
|
-
emulationJson?: string;
|
|
746
|
-
};
|
|
747
|
-
type CustomEmulationMode = {
|
|
748
|
-
kind: "custom";
|
|
749
|
-
emulationJson: string;
|
|
750
|
-
};
|
|
751
|
-
type ResolvedEmulationMode = PresetEmulationMode | CustomEmulationMode;
|
|
752
|
-
type LegacyWebSocketCallbacks = {
|
|
753
|
-
onMessage?: (data: string | Buffer) => void;
|
|
754
|
-
onClose?: (event: WebSocketCloseEvent) => void;
|
|
755
|
-
onError?: (error: string) => void;
|
|
756
|
-
};
|
|
757
|
-
type WebSocketOpenDispatchMode = "automatic" | "deferred";
|
|
758
|
-
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;
|
|
769
|
-
};
|
|
770
|
-
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[];
|
|
788
|
-
}
|
|
789
|
-
type ResponseType = "basic" | "cors" | "error" | "opaque" | "opaqueredirect";
|
|
790
|
-
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;
|
|
824
|
-
}
|
|
825
|
-
declare class Transport {
|
|
826
|
-
readonly id: string;
|
|
827
|
-
private disposed;
|
|
828
|
-
constructor(id: string);
|
|
829
|
-
get closed(): boolean;
|
|
830
|
-
close(): Promise<void>;
|
|
831
|
-
}
|
|
832
|
-
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>;
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* Fetch-compatible entry point that adds browser impersonation controls.
|
|
860
|
-
*
|
|
861
|
-
* **Important:** The default fetch path is isolated and non-persistent by design.
|
|
862
|
-
* Each call uses an isolated request context, so cookies are not shared across calls.
|
|
863
|
-
* Connection and TLS reuse behavior is handled by the native layer.
|
|
864
|
-
*
|
|
865
|
-
* **Use {@link createSession} or {@link withSession} if you need:**
|
|
866
|
-
* - Cookie persistence across requests
|
|
867
|
-
* - Shared session defaults across requests
|
|
868
|
-
* - A single session context for multi-step flows
|
|
869
|
-
*
|
|
870
|
-
* **Concurrency:** The core is unthrottled by design. Callers are expected to implement
|
|
871
|
-
* their own concurrency control (e.g., p-limit) if needed. Built-in throttling would
|
|
872
|
-
* reduce performance for high-throughput workloads.
|
|
873
|
-
*
|
|
874
|
-
* @param input - Request URL (string or URL) or a Request object
|
|
875
|
-
* @param init - Fetch-compatible init options
|
|
876
|
-
*
|
|
877
|
-
* @example
|
|
878
|
-
* ```typescript
|
|
879
|
-
* // Isolated request (no state persistence)
|
|
880
|
-
* const response = await fetch('https://example.com');
|
|
881
|
-
*
|
|
882
|
-
* // For persistent cookies and connection reuse, use a session:
|
|
883
|
-
* await withSession(async (session) => {
|
|
884
|
-
* await session.fetch('https://example.com/login', { method: 'POST', body: loginData });
|
|
885
|
-
* await session.fetch('https://example.com/protected'); // Cookies from login are sent
|
|
886
|
-
* });
|
|
887
|
-
* ```
|
|
888
|
-
*/
|
|
889
|
-
declare function fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
890
|
-
declare function createTransport(options?: CreateTransportOptions): Promise<Transport>;
|
|
891
|
-
declare function createSession(options?: CreateSessionOptions): Promise<Session>;
|
|
892
|
-
declare function withSession<T>(fn: (session: Session) => Promise<T> | T, options?: CreateSessionOptions): Promise<T>;
|
|
893
|
-
/**
|
|
894
|
-
* @deprecated Use {@link fetch} instead.
|
|
895
|
-
*/
|
|
896
|
-
declare function request(options: RequestOptions): Promise<Response>;
|
|
897
|
-
/**
|
|
898
|
-
* Get list of available browser profiles
|
|
899
|
-
*
|
|
900
|
-
* @returns Array of browser profile names
|
|
901
|
-
*
|
|
902
|
-
* @example
|
|
903
|
-
* ```typescript
|
|
904
|
-
* import { getProfiles } from 'wreq-js';
|
|
905
|
-
*
|
|
906
|
-
* const profiles = getProfiles();
|
|
907
|
-
* console.log(profiles); // ['chrome_131', 'chrome_142', 'firefox_135', 'safari_18', ...]
|
|
908
|
-
* ```
|
|
909
|
-
*/
|
|
910
|
-
declare function getProfiles(): BrowserProfile[];
|
|
911
|
-
/**
|
|
912
|
-
* Get list of supported operating systems for emulation.
|
|
913
|
-
*
|
|
914
|
-
* @returns Array of operating system identifiers
|
|
915
|
-
*/
|
|
916
|
-
declare function getOperatingSystems(): EmulationOS[];
|
|
917
|
-
/**
|
|
918
|
-
* Convenience helper for GET requests using {@link fetch}.
|
|
919
|
-
*/
|
|
920
|
-
declare function get(url: string | URL | Request, init?: Omit<RequestInit, "method">): Promise<Response>;
|
|
921
|
-
/**
|
|
922
|
-
* Convenience helper for POST requests using {@link fetch}.
|
|
923
|
-
*/
|
|
924
|
-
declare function post(url: string | URL | Request, body?: BodyInit | null, init?: Omit<RequestInit, "method" | "body">): Promise<Response>;
|
|
925
|
-
type WebSocketAddEventListenerOptions = boolean | {
|
|
926
|
-
once?: boolean;
|
|
927
|
-
signal?: AbortSignal | null;
|
|
928
|
-
};
|
|
929
|
-
/**
|
|
930
|
-
* WHATWG-style WebSocket API with async connection establishment.
|
|
931
|
-
*/
|
|
932
|
-
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;
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* Create a WebSocket connection with browser impersonation.
|
|
1018
|
-
*/
|
|
1019
|
-
declare function websocket(url: string | URL, options?: WebSocketOptions): Promise<WebSocket>;
|
|
1020
|
-
declare function websocket(options: LegacyWebSocketOptions): Promise<WebSocket>;
|
|
1021
|
-
|
|
1022
|
-
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;
|
|
1039
|
-
};
|
|
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 };
|