wreq-js 0.2.0 → 1.1.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.
@@ -7,6 +7,7 @@ const node_assert_1 = __importDefault(require("node:assert"));
7
7
  const node_test_1 = require("node:test");
8
8
  const promises_1 = require("node:timers/promises");
9
9
  const wreq_js_1 = require("../wreq-js");
10
+ const WS_TEST_URL = process.env.WS_TEST_URL ?? "wss://echo.websocket.org";
10
11
  (0, node_test_1.describe)("WebSocket", () => {
11
12
  (0, node_test_1.before)(() => {
12
13
  console.log("🔌 WebSocket Test Suite\n");
@@ -15,8 +16,8 @@ const wreq_js_1 = require("../wreq-js");
15
16
  const messages = [];
16
17
  let isClosed = false;
17
18
  const ws = await (0, wreq_js_1.websocket)({
18
- url: "wss://echo.websocket.org",
19
- browser: "chrome_137",
19
+ url: WS_TEST_URL,
20
+ browser: "chrome_142",
20
21
  onMessage: (data) => {
21
22
  messages.push(data);
22
23
  },
@@ -30,21 +31,19 @@ const wreq_js_1 = require("../wreq-js");
30
31
  console.log("WebSocket connected");
31
32
  await ws.send("Hello!");
32
33
  // Wait for echo response
33
- await (0, promises_1.setTimeout)(1000);
34
+ await (0, promises_1.setTimeout)(100);
34
35
  node_assert_1.default.ok(messages.length > 0, "Should receive at least one message");
35
36
  // Wait a bit for close callback
36
37
  await ws.close();
37
- await (0, promises_1.setTimeout)(10000);
38
+ await (0, promises_1.setTimeout)(100);
38
39
  node_assert_1.default.ok(isClosed, "Should receive close event");
39
- // Rate limit protection: wait before next test
40
- await (0, promises_1.setTimeout)(2000);
41
40
  });
42
41
  (0, node_test_1.test)("should handle parallel sends on same WebSocket", async () => {
43
42
  const messages = [];
44
43
  const expectedMessages = ["Message 1", "Message 2", "Message 3", "Message 4", "Message 5"];
45
44
  const ws = await (0, wreq_js_1.websocket)({
46
- url: "wss://echo.websocket.org",
47
- browser: "chrome_137",
45
+ url: WS_TEST_URL,
46
+ browser: "chrome_142",
48
47
  onMessage: (data) => {
49
48
  messages.push(data);
50
49
  },
@@ -64,7 +63,7 @@ const wreq_js_1 = require("../wreq-js");
64
63
  ]);
65
64
  console.log("All messages sent in parallel");
66
65
  // Wait for echo responses
67
- await (0, promises_1.setTimeout)(2000);
66
+ await (0, promises_1.setTimeout)(200);
68
67
  node_assert_1.default.ok(messages.length >= 5, "Should receive at least 5 messages");
69
68
  // Verify that all expected messages were received (order may vary)
70
69
  const receivedStrings = messages.map((m) => (Buffer.isBuffer(m) ? m.toString() : m));
@@ -73,8 +72,6 @@ const wreq_js_1 = require("../wreq-js");
73
72
  }
74
73
  console.log("All messages received correctly:", receivedStrings.join(", "));
75
74
  await ws.close();
76
- // Rate limit protection: wait before next test
77
- await (0, promises_1.setTimeout)(2000);
78
75
  });
79
76
  (0, node_test_1.test)("should handle multiple WebSocket connections simultaneously", async () => {
80
77
  const ws1Messages = [];
@@ -82,14 +79,14 @@ const wreq_js_1 = require("../wreq-js");
82
79
  // Create two WebSocket connections in parallel
83
80
  const [ws1, ws2] = await Promise.all([
84
81
  (0, wreq_js_1.websocket)({
85
- url: "wss://echo.websocket.org",
86
- browser: "chrome_137",
82
+ url: WS_TEST_URL,
83
+ browser: "chrome_142",
87
84
  onMessage: (data) => ws1Messages.push(data),
88
85
  onClose: () => { },
89
86
  onError: () => { },
90
87
  }),
91
88
  (0, wreq_js_1.websocket)({
92
- url: "wss://echo.websocket.org",
89
+ url: WS_TEST_URL,
93
90
  browser: "firefox_139",
94
91
  onMessage: (data) => ws2Messages.push(data),
95
92
  onClose: () => { },
@@ -99,8 +96,8 @@ const wreq_js_1 = require("../wreq-js");
99
96
  console.log("WebSocket connections created");
100
97
  // Send unique messages on both connections in parallel
101
98
  await Promise.all([ws1.send("From WS1"), ws2.send("From WS2")]);
102
- // Wait for responses (long timeout for CI)
103
- await (0, promises_1.setTimeout)(5000);
99
+ // Wait for responses
100
+ await (0, promises_1.setTimeout)(200);
104
101
  node_assert_1.default.ok(ws1Messages.length > 0, "WS1 should receive messages");
105
102
  node_assert_1.default.ok(ws2Messages.length > 0, "WS2 should receive messages");
106
103
  // Verify that each connection received the correct message (not mixed up)
@@ -1 +1 @@
1
- {"version":3,"file":"websocket.spec.js","sourceRoot":"","sources":["../../src/test/websocket.spec.ts"],"names":[],"mappings":";;;;;AAAA,8DAAiC;AACjC,yCAAmD;AACnD,mDAA2D;AAC3D,wCAAuC;AAEvC,IAAA,oBAAQ,EAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAA,kBAAM,EAAC,GAAG,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,IAAA,gBAAI,EAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACvE,MAAM,QAAQ,GAAwB,EAAE,CAAC;QACzC,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,MAAM,EAAE,GAAG,MAAM,IAAA,mBAAS,EAAC;YACzB,GAAG,EAAE,0BAA0B;YAC/B,OAAO,EAAE,YAAY;YACrB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,OAAO,EAAE,GAAG,EAAE;gBACZ,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;YACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBACjB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAEnC,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAExB,yBAAyB;QACzB,MAAM,IAAA,qBAAK,EAAC,IAAI,CAAC,CAAC;QAClB,qBAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,qCAAqC,CAAC,CAAC;QAEtE,gCAAgC;Q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E,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,111 +1,368 @@
1
1
  import type { BrowserProfile } from "./generated-types";
2
2
  export type { BrowserProfile };
3
3
  /**
4
- * HTTP method types
4
+ * Controls how cookies are scoped for a request.
5
+ * - "session": reuse an explicit Session or sessionId across calls.
6
+ * - "ephemeral": create an isolated, single-use session.
7
+ */
8
+ export type CookieMode = "session" | "ephemeral";
9
+ /**
10
+ * Minimal handle implemented by {@link Session}. Exposed so {@link RequestInit.session}
11
+ * can accept either a Session instance or a compatible object.
12
+ */
13
+ export interface SessionHandle {
14
+ readonly id: string;
15
+ }
16
+ /**
17
+ * A tuple of [name, value] pairs used for initializing headers.
18
+ * Both name and value must be strings.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const headers: HeaderTuple = ['Content-Type', 'application/json'];
23
+ * ```
24
+ */
25
+ export type HeaderTuple = [string, string];
26
+ /**
27
+ * Represents various input types accepted when creating or initializing headers.
28
+ * Can be an iterable of header tuples, an array of tuples, or a plain object.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // As an object
33
+ * const headers: HeadersInit = { 'Content-Type': 'application/json' };
34
+ *
35
+ * // As an array of tuples
36
+ * const headers: HeadersInit = [['Content-Type', 'application/json']];
37
+ *
38
+ * // As an iterable
39
+ * const headers: HeadersInit = new Map([['Content-Type', 'application/json']]);
40
+ * ```
41
+ */
42
+ export type HeadersInit = Iterable<HeaderTuple> | Array<HeaderTuple> | Record<string, string | number | boolean | null | undefined>;
43
+ /**
44
+ * Represents the various types of data that can be used as a request body.
45
+ * Supports string, binary data (ArrayBuffer, ArrayBufferView), URL-encoded parameters, and Node.js Buffer.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // String body
50
+ * const body: BodyInit = JSON.stringify({ key: 'value' });
51
+ *
52
+ * // URLSearchParams
53
+ * const body: BodyInit = new URLSearchParams({ key: 'value' });
54
+ *
55
+ * // Buffer
56
+ * const body: BodyInit = Buffer.from('data');
57
+ * ```
58
+ */
59
+ export type BodyInit = string | ArrayBuffer | ArrayBufferView | URLSearchParams | Buffer;
60
+ /**
61
+ * Options for configuring a fetch request. Compatible with the standard Fetch API
62
+ * with additional wreq-specific extensions for browser impersonation, proxies, and timeouts.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const options: RequestInit = {
67
+ * method: 'POST',
68
+ * headers: { 'Content-Type': 'application/json' },
69
+ * body: JSON.stringify({ key: 'value' }),
70
+ * browser: 'chrome_142',
71
+ * proxy: 'http://proxy.example.com:8080',
72
+ * timeout: 5000
73
+ * };
74
+ * ```
75
+ */
76
+ export interface RequestInit {
77
+ /**
78
+ * A string to set request's method.
79
+ * @default 'GET'
80
+ */
81
+ method?: string;
82
+ /**
83
+ * A Headers object, an object literal, or an array of two-item arrays to set request's headers.
84
+ */
85
+ headers?: HeadersInit;
86
+ /**
87
+ * A BodyInit object or null to set request's body.
88
+ */
89
+ body?: BodyInit | null;
90
+ /**
91
+ * An AbortSignal to set request's signal.
92
+ */
93
+ signal?: AbortSignal | null;
94
+ /**
95
+ * A string indicating whether request follows redirects, results in an error upon
96
+ * encountering a redirect, or returns the redirect (in an opaque fashion).
97
+ * @default 'follow'
98
+ */
99
+ redirect?: "follow" | "manual" | "error";
100
+ /**
101
+ * Browser profile to impersonate for this request.
102
+ * Automatically applies browser-specific headers, TLS fingerprints, and HTTP/2 settings.
103
+ * @default 'chrome_142'
104
+ */
105
+ browser?: BrowserProfile;
106
+ /**
107
+ * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
108
+ * Supports HTTP and SOCKS5 proxies.
109
+ */
110
+ proxy?: string;
111
+ /**
112
+ * Request timeout in milliseconds. If the request takes longer than this value,
113
+ * it will be aborted.
114
+ * @default 30000
115
+ */
116
+ timeout?: number;
117
+ /**
118
+ * Controls how cookies are managed for this call.
119
+ * - "ephemeral": default when no session/sessionId is provided. Creates an isolated session per request.
120
+ * - "session": requires an explicit session or sessionId and reuses its cookie jar.
121
+ */
122
+ cookieMode?: CookieMode;
123
+ /**
124
+ * Session instance to bind this request to. When provided, {@link cookieMode}
125
+ * automatically behaves like `"session"`.
126
+ */
127
+ session?: SessionHandle;
128
+ /**
129
+ * Identifier of an existing session created elsewhere (e.g., via {@link createSession}).
130
+ */
131
+ sessionId?: string;
132
+ /**
133
+ * Disable default headers from browser emulation. When enabled, only explicitly
134
+ * provided headers will be sent with the request, preventing emulation headers
135
+ * from being automatically added or appended.
136
+ * @default false
137
+ */
138
+ disableDefaultHeaders?: boolean;
139
+ }
140
+ /**
141
+ * Configuration for {@link createSession}.
142
+ */
143
+ export interface CreateSessionOptions {
144
+ /**
145
+ * Provide a custom identifier instead of an auto-generated random ID.
146
+ */
147
+ sessionId?: string;
148
+ /**
149
+ * Browser profile to bind to this session. Defaults to 'chrome_142'.
150
+ */
151
+ browser?: BrowserProfile;
152
+ /**
153
+ * Optional proxy for every request made through the session.
154
+ */
155
+ proxy?: string;
156
+ /**
157
+ * Default timeout applied when {@link Session.fetch} is called without
158
+ * overriding `timeout`.
159
+ */
160
+ timeout?: number;
161
+ }
162
+ /**
163
+ * Standard HTTP request methods supported by wreq.
164
+ * Represents the most commonly used HTTP verbs for RESTful operations.
5
165
  */
6
166
  export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
7
167
  /**
8
- * Request options for making HTTP requests with browser impersonation
168
+ * Legacy request options interface. This interface is deprecated and will be removed in a future version.
169
+ *
170
+ * @deprecated Use {@link RequestInit} with the standard `fetch()` API instead.
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * // Old (deprecated):
175
+ * const options: RequestOptions = {
176
+ * url: 'https://api.example.com',
177
+ * method: 'POST',
178
+ * body: JSON.stringify({ data: 'value' })
179
+ * };
180
+ *
181
+ * // New (recommended):
182
+ * const response = await fetch('https://api.example.com', {
183
+ * method: 'POST',
184
+ * body: JSON.stringify({ data: 'value' })
185
+ * });
186
+ * ```
9
187
  */
10
188
  export interface RequestOptions {
11
189
  /**
12
- * The URL to request
190
+ * The URL to request.
13
191
  */
14
192
  url: string;
15
193
  /**
16
- * Browser profile to impersonate
17
- * @default 'chrome_137'
194
+ * Browser profile to impersonate.
195
+ * Automatically applies browser-specific headers, TLS fingerprints, and HTTP/2 settings.
196
+ * @default 'chrome_142'
18
197
  */
19
198
  browser?: BrowserProfile;
20
199
  /**
21
- * HTTP method
200
+ * HTTP method to use for the request.
22
201
  * @default 'GET'
23
202
  */
24
203
  method?: HttpMethod;
25
204
  /**
26
- * Additional headers to send with the request
27
- * Browser-specific headers will be automatically added
205
+ * Additional headers to send with the request.
206
+ * Browser-specific headers will be automatically added based on the selected browser profile.
28
207
  */
29
208
  headers?: Record<string, string>;
30
209
  /**
31
- * Request body (for POST, PUT, PATCH requests)
210
+ * Request body data (for POST, PUT, PATCH requests).
32
211
  */
33
212
  body?: string;
34
213
  /**
35
- * Proxy URL (e.g., 'http://proxy.example.com:8080')
214
+ * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
215
+ * Supports HTTP and SOCKS5 proxies.
36
216
  */
37
217
  proxy?: string;
38
218
  /**
39
- * Request timeout in milliseconds
219
+ * Request timeout in milliseconds. If the request takes longer than this value,
220
+ * it will be aborted.
40
221
  * @default 30000
41
222
  */
42
223
  timeout?: number;
224
+ /**
225
+ * Identifier for the session that should handle this request.
226
+ * @internal
227
+ */
228
+ sessionId?: string;
229
+ /**
230
+ * Internal flag indicating whether the session should be discarded once the
231
+ * request finishes.
232
+ * @internal
233
+ */
234
+ ephemeral?: boolean;
235
+ /**
236
+ * Disable default headers from browser emulation. When enabled, only explicitly
237
+ * provided headers will be sent with the request, preventing emulation headers
238
+ * from being automatically added or appended.
239
+ * @default false
240
+ */
241
+ disableDefaultHeaders?: boolean;
43
242
  }
44
243
  /**
45
- * Response object returned from HTTP requests
244
+ * Internal response payload returned from the native Rust binding.
245
+ * This interface represents the raw response data before it's converted
246
+ * to a standard Response object.
247
+ *
248
+ * @internal
46
249
  */
47
- export interface Response {
250
+ export interface NativeResponse {
48
251
  /**
49
- * HTTP status code
252
+ * HTTP status code (e.g., 200, 404, 500).
50
253
  */
51
254
  status: number;
52
255
  /**
53
- * Response headers
256
+ * Response headers as key-value pairs.
257
+ * Header names are normalized to lowercase.
54
258
  */
55
259
  headers: Record<string, string>;
56
260
  /**
57
- * Response body as string
261
+ * Response body as a UTF-8 encoded string.
58
262
  */
59
263
  body: string;
60
264
  /**
61
- * Cookies set by the server
265
+ * Cookies set by the server as key-value pairs.
62
266
  */
63
267
  cookies: Record<string, string>;
64
268
  /**
65
- * Final URL after redirects
269
+ * Final URL after following any redirects.
270
+ * If no redirects occurred, this will match the original request URL.
66
271
  */
67
272
  url: string;
68
273
  }
69
274
  /**
70
- * WebSocket options for creating a connection
275
+ * Configuration options for creating a WebSocket connection.
276
+ * Supports browser impersonation and proxies, similar to HTTP requests.
277
+ *
278
+ * @example
279
+ * ```typescript
280
+ * const ws = await createWebSocket({
281
+ * url: 'wss://echo.websocket.org',
282
+ * browser: 'chrome_142',
283
+ * headers: { 'Authorization': 'Bearer token' },
284
+ * onMessage: (data) => {
285
+ * console.log('Received:', data);
286
+ * },
287
+ * onClose: () => {
288
+ * console.log('Connection closed');
289
+ * },
290
+ * onError: (error) => {
291
+ * console.error('WebSocket error:', error);
292
+ * }
293
+ * });
294
+ * ```
71
295
  */
72
296
  export interface WebSocketOptions {
73
297
  /**
74
- * The WebSocket URL to connect to (wss:// or ws://)
298
+ * The WebSocket URL to connect to. Must use wss:// (secure) or ws:// (insecure) protocol.
75
299
  */
76
300
  url: string;
77
301
  /**
78
- * Browser profile to impersonate
79
- * @default 'chrome_137'
302
+ * Browser profile to impersonate for the WebSocket upgrade request.
303
+ * Automatically applies browser-specific headers and TLS fingerprints.
304
+ * @default 'chrome_142'
80
305
  */
81
306
  browser?: BrowserProfile;
82
307
  /**
83
- * Additional headers to send with the WebSocket upgrade request
308
+ * Additional headers to send with the WebSocket upgrade request.
309
+ * Common headers include Authorization, Origin, or custom application headers.
84
310
  */
85
311
  headers?: Record<string, string>;
86
312
  /**
87
- * Proxy URL (e.g., 'http://proxy.example.com:8080')
313
+ * Proxy URL to route the connection through (e.g., 'http://proxy.example.com:8080').
314
+ * Supports HTTP and SOCKS5 proxies.
88
315
  */
89
316
  proxy?: string;
90
317
  /**
91
- * Callback for incoming messages (required)
318
+ * Callback function invoked when a message is received from the server.
319
+ * The data parameter will be a string for text frames or a Buffer for binary frames.
320
+ *
321
+ * @param data - The received message as a string or Buffer
92
322
  */
93
323
  onMessage: (data: string | Buffer) => void;
94
324
  /**
95
- * Callback for connection close event
325
+ * Callback function invoked when the WebSocket connection is closed.
326
+ * This is called for both clean closes and connection errors.
96
327
  */
97
328
  onClose?: () => void;
98
329
  /**
99
- * Callback for error events
330
+ * Callback function invoked when a connection or protocol error occurs.
331
+ *
332
+ * @param error - A string describing the error that occurred
100
333
  */
101
334
  onError?: (error: string) => void;
102
335
  }
103
336
  /**
104
- * Internal WebSocket connection object returned from native binding
337
+ * Internal WebSocket connection object returned from the native Rust binding.
338
+ * This interface contains the connection ID used to reference the WebSocket
339
+ * in subsequent operations like sending messages or closing the connection.
340
+ *
341
+ * @internal
105
342
  */
106
343
  export interface NativeWebSocketConnection {
344
+ /**
345
+ * Unique identifier for this WebSocket connection.
346
+ * Used internally to track and manage the connection.
347
+ * @internal
348
+ */
107
349
  _id: number;
108
350
  }
351
+ /**
352
+ * Error thrown when a request fails. This can occur due to network errors,
353
+ * timeouts, invalid URLs, or other request-related issues.
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * try {
358
+ * const response = await fetch('https://api.example.com');
359
+ * } catch (error) {
360
+ * if (error instanceof RequestError) {
361
+ * console.error('Request failed:', error.message);
362
+ * }
363
+ * }
364
+ * ```
365
+ */
109
366
  export declare class RequestError extends Error {
110
367
  constructor(message: string);
111
368
  }
@@ -1 +1 @@
1
- {"version":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,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B"}
package/dist/types.js CHANGED
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequestError = void 0;
4
+ /**
5
+ * Error thrown when a request fails. This can occur due to network errors,
6
+ * timeouts, invalid URLs, or other request-related issues.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * try {
11
+ * const response = await fetch('https://api.example.com');
12
+ * } catch (error) {
13
+ * if (error instanceof RequestError) {
14
+ * console.error('Request failed:', error.message);
15
+ * }
16
+ * }
17
+ * ```
18
+ */
4
19
  class RequestError extends Error {
5
20
  constructor(message) {
6
21
  super(message);
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAmIA,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA6YA;;;;;;;;;;;;;;GAcG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC"}