rezo 1.0.10 → 1.0.12
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/adapters/entries/curl.d.ts +67 -1
- package/dist/adapters/entries/fetch.d.ts +67 -1
- package/dist/adapters/entries/http.d.ts +67 -1
- package/dist/adapters/entries/http2.d.ts +67 -1
- package/dist/adapters/entries/react-native.d.ts +67 -1
- package/dist/adapters/entries/xhr.d.ts +67 -1
- package/dist/adapters/http.cjs +8 -2
- package/dist/adapters/http.js +8 -2
- package/dist/adapters/http2.cjs +4 -0
- package/dist/adapters/http2.js +4 -0
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/core/rezo.cjs +5 -0
- package/dist/core/rezo.js +5 -0
- package/dist/crawler.d.ts +67 -1
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +67 -1
- package/dist/platform/browser.d.ts +67 -1
- package/dist/platform/bun.d.ts +67 -1
- package/dist/platform/deno.d.ts +67 -1
- package/dist/platform/node.d.ts +67 -1
- package/dist/platform/react-native.d.ts +67 -1
- package/dist/platform/worker.d.ts +67 -1
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/queue/index.cjs +8 -8
- package/dist/responses/buildResponse.cjs +28 -3
- package/dist/responses/buildResponse.js +28 -3
- package/dist/utils/http-config.cjs +8 -1
- package/dist/utils/http-config.js +8 -1
- package/package.json +1 -1
|
@@ -2502,8 +2502,73 @@ export interface RezoRequestConfig<D = any> {
|
|
|
2502
2502
|
maxRedirects?: number;
|
|
2503
2503
|
/** Whether to automatically decompress response data */
|
|
2504
2504
|
decompress?: boolean;
|
|
2505
|
-
/**
|
|
2505
|
+
/**
|
|
2506
|
+
* Whether to keep TCP connections alive for reuse across multiple requests.
|
|
2507
|
+
*
|
|
2508
|
+
* When enabled, the underlying TCP connection is kept open after a request completes,
|
|
2509
|
+
* allowing subsequent requests to the same host to reuse the connection. This reduces
|
|
2510
|
+
* latency by avoiding the overhead of establishing new connections (TCP handshake,
|
|
2511
|
+
* TLS negotiation for HTTPS).
|
|
2512
|
+
*
|
|
2513
|
+
* **Behavior:**
|
|
2514
|
+
* - `false` (default) - Connection closes after each request. Process exits immediately.
|
|
2515
|
+
* - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
|
|
2516
|
+
*
|
|
2517
|
+
* **When to use `keepAlive: true`:**
|
|
2518
|
+
* - Making multiple requests to the same host in sequence
|
|
2519
|
+
* - Long-running applications (servers, bots, scrapers)
|
|
2520
|
+
* - Performance-critical applications where connection overhead matters
|
|
2521
|
+
*
|
|
2522
|
+
* **When to use `keepAlive: false` (default):**
|
|
2523
|
+
* - Single requests or scripts that should exit immediately
|
|
2524
|
+
* - CLI tools that make one-off requests
|
|
2525
|
+
* - When you need predictable process termination
|
|
2526
|
+
*
|
|
2527
|
+
* @example
|
|
2528
|
+
* ```typescript
|
|
2529
|
+
* // Default: process exits immediately after request
|
|
2530
|
+
* const { data } = await rezo.get('https://api.example.com/data');
|
|
2531
|
+
*
|
|
2532
|
+
* // Keep connection alive for 1 minute (default) for subsequent requests
|
|
2533
|
+
* const client = new Rezo({ keepAlive: true });
|
|
2534
|
+
* await client.get('https://api.example.com/users');
|
|
2535
|
+
* await client.get('https://api.example.com/posts'); // Reuses connection
|
|
2536
|
+
*
|
|
2537
|
+
* // Custom keep-alive timeout (30 seconds)
|
|
2538
|
+
* const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
|
|
2539
|
+
* ```
|
|
2540
|
+
*
|
|
2541
|
+
* @default false
|
|
2542
|
+
*/
|
|
2506
2543
|
keepAlive?: boolean;
|
|
2544
|
+
/**
|
|
2545
|
+
* How long to keep idle connections alive in milliseconds.
|
|
2546
|
+
*
|
|
2547
|
+
* Only applies when `keepAlive: true`. After this duration of inactivity,
|
|
2548
|
+
* the connection is closed automatically. This prevents resource leaks
|
|
2549
|
+
* from connections that are no longer needed.
|
|
2550
|
+
*
|
|
2551
|
+
* **Note:** Even with keep-alive enabled, the Node.js process can still exit
|
|
2552
|
+
* cleanly when there's no other work to do, thanks to socket unreferencing.
|
|
2553
|
+
*
|
|
2554
|
+
* @example
|
|
2555
|
+
* ```typescript
|
|
2556
|
+
* // Keep connections alive for 30 seconds
|
|
2557
|
+
* const client = new Rezo({
|
|
2558
|
+
* keepAlive: true,
|
|
2559
|
+
* keepAliveMsecs: 30000
|
|
2560
|
+
* });
|
|
2561
|
+
*
|
|
2562
|
+
* // Keep connections alive for 2 minutes
|
|
2563
|
+
* const client = new Rezo({
|
|
2564
|
+
* keepAlive: true,
|
|
2565
|
+
* keepAliveMsecs: 120000
|
|
2566
|
+
* });
|
|
2567
|
+
* ```
|
|
2568
|
+
*
|
|
2569
|
+
* @default 60000 (1 minute)
|
|
2570
|
+
*/
|
|
2571
|
+
keepAliveMsecs?: number;
|
|
2507
2572
|
withoutBodyOnRedirect?: boolean;
|
|
2508
2573
|
autoSetReferer?: boolean;
|
|
2509
2574
|
autoSetOrigin?: boolean;
|
|
@@ -4104,6 +4169,7 @@ export declare class Rezo {
|
|
|
4104
4169
|
private __create;
|
|
4105
4170
|
/** Get the cookie jar for this instance */
|
|
4106
4171
|
get cookieJar(): RezoCookieJar;
|
|
4172
|
+
set cookieJar(jar: RezoCookieJar);
|
|
4107
4173
|
/**
|
|
4108
4174
|
* Save cookies to file (if cookieFile is configured).
|
|
4109
4175
|
* Can also specify a different path to save to.
|
package/dist/plugin/index.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.Crawler =
|
|
3
|
-
const
|
|
4
|
-
exports.CrawlerOptions =
|
|
5
|
-
const
|
|
6
|
-
exports.FileCacher =
|
|
7
|
-
const
|
|
8
|
-
exports.UrlStore =
|
|
9
|
-
const
|
|
10
|
-
exports.Oxylabs =
|
|
11
|
-
const
|
|
12
|
-
exports.OXYLABS_BROWSER_TYPES =
|
|
13
|
-
exports.OXYLABS_COMMON_LOCALES =
|
|
14
|
-
exports.OXYLABS_COMMON_GEO_LOCATIONS =
|
|
15
|
-
exports.OXYLABS_US_STATES =
|
|
16
|
-
exports.OXYLABS_EUROPEAN_COUNTRIES =
|
|
17
|
-
exports.OXYLABS_ASIAN_COUNTRIES =
|
|
18
|
-
exports.getRandomOxylabsBrowserType =
|
|
19
|
-
exports.getRandomOxylabsLocale =
|
|
20
|
-
exports.getRandomOxylabsGeoLocation =
|
|
21
|
-
const
|
|
22
|
-
exports.Decodo =
|
|
23
|
-
const
|
|
24
|
-
exports.DECODO_DEVICE_TYPES =
|
|
25
|
-
exports.DECODO_HEADLESS_MODES =
|
|
26
|
-
exports.DECODO_COMMON_LOCALES =
|
|
27
|
-
exports.DECODO_COMMON_COUNTRIES =
|
|
28
|
-
exports.DECODO_EUROPEAN_COUNTRIES =
|
|
29
|
-
exports.DECODO_ASIAN_COUNTRIES =
|
|
30
|
-
exports.DECODO_US_STATES =
|
|
31
|
-
exports.DECODO_COMMON_CITIES =
|
|
32
|
-
exports.getRandomDecodoDeviceType =
|
|
33
|
-
exports.getRandomDecodoLocale =
|
|
34
|
-
exports.getRandomDecodoCountry =
|
|
35
|
-
exports.getRandomDecodoCity =
|
|
36
|
-
exports.generateDecodoSessionId =
|
|
1
|
+
const _mod_a9kn57 = require('./crawler.cjs');
|
|
2
|
+
exports.Crawler = _mod_a9kn57.Crawler;;
|
|
3
|
+
const _mod_6ccm6s = require('./crawler-options.cjs');
|
|
4
|
+
exports.CrawlerOptions = _mod_6ccm6s.CrawlerOptions;;
|
|
5
|
+
const _mod_7naagm = require('../cache/file-cacher.cjs');
|
|
6
|
+
exports.FileCacher = _mod_7naagm.FileCacher;;
|
|
7
|
+
const _mod_22i2ua = require('../cache/url-store.cjs');
|
|
8
|
+
exports.UrlStore = _mod_22i2ua.UrlStore;;
|
|
9
|
+
const _mod_37jf5t = require('./addon/oxylabs/index.cjs');
|
|
10
|
+
exports.Oxylabs = _mod_37jf5t.Oxylabs;;
|
|
11
|
+
const _mod_u1lbrx = require('./addon/oxylabs/options.cjs');
|
|
12
|
+
exports.OXYLABS_BROWSER_TYPES = _mod_u1lbrx.OXYLABS_BROWSER_TYPES;
|
|
13
|
+
exports.OXYLABS_COMMON_LOCALES = _mod_u1lbrx.OXYLABS_COMMON_LOCALES;
|
|
14
|
+
exports.OXYLABS_COMMON_GEO_LOCATIONS = _mod_u1lbrx.OXYLABS_COMMON_GEO_LOCATIONS;
|
|
15
|
+
exports.OXYLABS_US_STATES = _mod_u1lbrx.OXYLABS_US_STATES;
|
|
16
|
+
exports.OXYLABS_EUROPEAN_COUNTRIES = _mod_u1lbrx.OXYLABS_EUROPEAN_COUNTRIES;
|
|
17
|
+
exports.OXYLABS_ASIAN_COUNTRIES = _mod_u1lbrx.OXYLABS_ASIAN_COUNTRIES;
|
|
18
|
+
exports.getRandomOxylabsBrowserType = _mod_u1lbrx.getRandomBrowserType;
|
|
19
|
+
exports.getRandomOxylabsLocale = _mod_u1lbrx.getRandomLocale;
|
|
20
|
+
exports.getRandomOxylabsGeoLocation = _mod_u1lbrx.getRandomGeoLocation;;
|
|
21
|
+
const _mod_mozpwt = require('./addon/decodo/index.cjs');
|
|
22
|
+
exports.Decodo = _mod_mozpwt.Decodo;;
|
|
23
|
+
const _mod_g6f0a3 = require('./addon/decodo/options.cjs');
|
|
24
|
+
exports.DECODO_DEVICE_TYPES = _mod_g6f0a3.DECODO_DEVICE_TYPES;
|
|
25
|
+
exports.DECODO_HEADLESS_MODES = _mod_g6f0a3.DECODO_HEADLESS_MODES;
|
|
26
|
+
exports.DECODO_COMMON_LOCALES = _mod_g6f0a3.DECODO_COMMON_LOCALES;
|
|
27
|
+
exports.DECODO_COMMON_COUNTRIES = _mod_g6f0a3.DECODO_COMMON_COUNTRIES;
|
|
28
|
+
exports.DECODO_EUROPEAN_COUNTRIES = _mod_g6f0a3.DECODO_EUROPEAN_COUNTRIES;
|
|
29
|
+
exports.DECODO_ASIAN_COUNTRIES = _mod_g6f0a3.DECODO_ASIAN_COUNTRIES;
|
|
30
|
+
exports.DECODO_US_STATES = _mod_g6f0a3.DECODO_US_STATES;
|
|
31
|
+
exports.DECODO_COMMON_CITIES = _mod_g6f0a3.DECODO_COMMON_CITIES;
|
|
32
|
+
exports.getRandomDecodoDeviceType = _mod_g6f0a3.getRandomDeviceType;
|
|
33
|
+
exports.getRandomDecodoLocale = _mod_g6f0a3.getRandomLocale;
|
|
34
|
+
exports.getRandomDecodoCountry = _mod_g6f0a3.getRandomCountry;
|
|
35
|
+
exports.getRandomDecodoCity = _mod_g6f0a3.getRandomCity;
|
|
36
|
+
exports.generateDecodoSessionId = _mod_g6f0a3.generateSessionId;;
|
package/dist/proxy/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { SocksProxyAgent: RezoSocksProxy } = require("socks-proxy-agent");
|
|
2
2
|
const { HttpsProxyAgent: RezoHttpsSocks } = require("https-proxy-agent");
|
|
3
3
|
const { HttpProxyAgent: RezoHttpSocks } = require("http-proxy-agent");
|
|
4
|
-
const
|
|
5
|
-
exports.ProxyManager =
|
|
4
|
+
const _mod_448ob0 = require('./manager.cjs');
|
|
5
|
+
exports.ProxyManager = _mod_448ob0.ProxyManager;;
|
|
6
6
|
function createOptions(uri, opts) {
|
|
7
7
|
if (uri instanceof URL || typeof uri === "string") {
|
|
8
8
|
return {
|
package/dist/queue/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.RezoQueue =
|
|
3
|
-
const
|
|
4
|
-
exports.HttpQueue =
|
|
5
|
-
exports.extractDomain =
|
|
6
|
-
const
|
|
7
|
-
exports.Priority =
|
|
8
|
-
exports.HttpMethodPriority =
|
|
1
|
+
const _mod_ipfe1q = require('./queue.cjs');
|
|
2
|
+
exports.RezoQueue = _mod_ipfe1q.RezoQueue;;
|
|
3
|
+
const _mod_sc99zf = require('./http-queue.cjs');
|
|
4
|
+
exports.HttpQueue = _mod_sc99zf.HttpQueue;
|
|
5
|
+
exports.extractDomain = _mod_sc99zf.extractDomain;;
|
|
6
|
+
const _mod_4akyyt = require('./types.cjs');
|
|
7
|
+
exports.Priority = _mod_4akyyt.Priority;
|
|
8
|
+
exports.HttpMethodPriority = _mod_4akyyt.HttpMethodPriority;;
|
|
@@ -297,11 +297,36 @@ function buildResponse(params) {
|
|
|
297
297
|
const rezoHeaders = new RezoHeaders(headers);
|
|
298
298
|
rezoHeaders.delete("set-cookie");
|
|
299
299
|
let cookieData;
|
|
300
|
+
const mergedCookiesArray = [];
|
|
301
|
+
const cookieKeyDomainMap = new Map;
|
|
302
|
+
if (config.requestCookies && config.requestCookies.length > 0) {
|
|
303
|
+
for (const cookie of config.requestCookies) {
|
|
304
|
+
const key = `${cookie.key}|${cookie.domain || ""}`;
|
|
305
|
+
mergedCookiesArray.push(cookie);
|
|
306
|
+
cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
let responseCookiesArray = [];
|
|
300
310
|
if (config.responseCookies && config.responseCookies.array && config.responseCookies.array.length > 0) {
|
|
301
|
-
|
|
311
|
+
responseCookiesArray = config.responseCookies.array;
|
|
302
312
|
} else if (cookies.length > 0) {
|
|
303
|
-
const
|
|
304
|
-
|
|
313
|
+
const tempJar = new RezoCookieJar;
|
|
314
|
+
const parsed = tempJar.setCookiesSync(cookies, url);
|
|
315
|
+
responseCookiesArray = parsed.array;
|
|
316
|
+
}
|
|
317
|
+
for (const cookie of responseCookiesArray) {
|
|
318
|
+
const key = `${cookie.key}|${cookie.domain || ""}`;
|
|
319
|
+
const existingIndex = cookieKeyDomainMap.get(key);
|
|
320
|
+
if (existingIndex !== undefined) {
|
|
321
|
+
mergedCookiesArray[existingIndex] = cookie;
|
|
322
|
+
} else {
|
|
323
|
+
mergedCookiesArray.push(cookie);
|
|
324
|
+
cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (mergedCookiesArray.length > 0) {
|
|
328
|
+
const mergedJar = new RezoCookieJar(mergedCookiesArray, url);
|
|
329
|
+
cookieData = mergedJar.cookies();
|
|
305
330
|
} else {
|
|
306
331
|
cookieData = {
|
|
307
332
|
array: [],
|
|
@@ -297,11 +297,36 @@ export function buildResponse(params) {
|
|
|
297
297
|
const rezoHeaders = new RezoHeaders(headers);
|
|
298
298
|
rezoHeaders.delete("set-cookie");
|
|
299
299
|
let cookieData;
|
|
300
|
+
const mergedCookiesArray = [];
|
|
301
|
+
const cookieKeyDomainMap = new Map;
|
|
302
|
+
if (config.requestCookies && config.requestCookies.length > 0) {
|
|
303
|
+
for (const cookie of config.requestCookies) {
|
|
304
|
+
const key = `${cookie.key}|${cookie.domain || ""}`;
|
|
305
|
+
mergedCookiesArray.push(cookie);
|
|
306
|
+
cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
let responseCookiesArray = [];
|
|
300
310
|
if (config.responseCookies && config.responseCookies.array && config.responseCookies.array.length > 0) {
|
|
301
|
-
|
|
311
|
+
responseCookiesArray = config.responseCookies.array;
|
|
302
312
|
} else if (cookies.length > 0) {
|
|
303
|
-
const
|
|
304
|
-
|
|
313
|
+
const tempJar = new RezoCookieJar;
|
|
314
|
+
const parsed = tempJar.setCookiesSync(cookies, url);
|
|
315
|
+
responseCookiesArray = parsed.array;
|
|
316
|
+
}
|
|
317
|
+
for (const cookie of responseCookiesArray) {
|
|
318
|
+
const key = `${cookie.key}|${cookie.domain || ""}`;
|
|
319
|
+
const existingIndex = cookieKeyDomainMap.get(key);
|
|
320
|
+
if (existingIndex !== undefined) {
|
|
321
|
+
mergedCookiesArray[existingIndex] = cookie;
|
|
322
|
+
} else {
|
|
323
|
+
mergedCookiesArray.push(cookie);
|
|
324
|
+
cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (mergedCookiesArray.length > 0) {
|
|
328
|
+
const mergedJar = new RezoCookieJar(mergedCookiesArray, url);
|
|
329
|
+
cookieData = mergedJar.cookies();
|
|
305
330
|
} else {
|
|
306
331
|
cookieData = {
|
|
307
332
|
array: [],
|
|
@@ -170,7 +170,11 @@ function setSignal() {
|
|
|
170
170
|
clearTimeout(this.timeoutClearInstanse);
|
|
171
171
|
if (this.timeout && typeof this.timeout === "number" && this.timeout > 100) {
|
|
172
172
|
const controller = new AbortController;
|
|
173
|
-
|
|
173
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
174
|
+
if (typeof timer === "object" && "unref" in timer) {
|
|
175
|
+
timer.unref();
|
|
176
|
+
}
|
|
177
|
+
this.timeoutClearInstanse = timer;
|
|
174
178
|
this.signal = controller.signal;
|
|
175
179
|
}
|
|
176
180
|
}
|
|
@@ -285,6 +289,9 @@ function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
285
289
|
}
|
|
286
290
|
}
|
|
287
291
|
}
|
|
292
|
+
if (cookiesString) {
|
|
293
|
+
fetchOptions.headers.set("Cookie", cookiesString);
|
|
294
|
+
}
|
|
288
295
|
if (options.body) {
|
|
289
296
|
fetchOptions.body = options.body;
|
|
290
297
|
}
|
|
@@ -170,7 +170,11 @@ function setSignal() {
|
|
|
170
170
|
clearTimeout(this.timeoutClearInstanse);
|
|
171
171
|
if (this.timeout && typeof this.timeout === "number" && this.timeout > 100) {
|
|
172
172
|
const controller = new AbortController;
|
|
173
|
-
|
|
173
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
174
|
+
if (typeof timer === "object" && "unref" in timer) {
|
|
175
|
+
timer.unref();
|
|
176
|
+
}
|
|
177
|
+
this.timeoutClearInstanse = timer;
|
|
174
178
|
this.signal = controller.signal;
|
|
175
179
|
}
|
|
176
180
|
}
|
|
@@ -285,6 +289,9 @@ export function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
285
289
|
}
|
|
286
290
|
}
|
|
287
291
|
}
|
|
292
|
+
if (cookiesString) {
|
|
293
|
+
fetchOptions.headers.set("Cookie", cookiesString);
|
|
294
|
+
}
|
|
288
295
|
if (options.body) {
|
|
289
296
|
fetchOptions.body = options.body;
|
|
290
297
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rezo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Lightning-fast, enterprise-grade HTTP client for modern JavaScript. Full HTTP/2 support, intelligent cookie management, multiple adapters (HTTP, Fetch, cURL, XHR), streaming, proxy support (HTTP/HTTPS/SOCKS), and cross-environment compatibility.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|