rezo 1.0.129 → 1.0.130

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.
Files changed (45) hide show
  1. package/dist/adapters/entries/curl.d.ts +1 -1
  2. package/dist/adapters/entries/fetch.d.ts +1 -1
  3. package/dist/adapters/entries/http.d.ts +1 -1
  4. package/dist/adapters/entries/http2.d.ts +1 -1
  5. package/dist/adapters/entries/react-native.cjs +6 -6
  6. package/dist/adapters/entries/react-native.d.ts +1 -1
  7. package/dist/adapters/entries/xhr.d.ts +1 -1
  8. package/dist/adapters/index.cjs +6 -6
  9. package/dist/cache/dns-cache.cjs +1 -11
  10. package/dist/cache/dns-cache.js +1 -11
  11. package/dist/cache/index.cjs +9 -9
  12. package/dist/cache/response-cache.cjs +14 -40
  13. package/dist/cache/response-cache.js +14 -40
  14. package/dist/cookies/cookie-jar.cjs +12 -9
  15. package/dist/cookies/cookie-jar.js +8 -5
  16. package/dist/cookies/index.cjs +10 -10
  17. package/dist/crawler/addon/oxylabs/index.cjs +1 -1
  18. package/dist/crawler/index.cjs +42 -42
  19. package/dist/crawler/plugin/index.cjs +1 -1
  20. package/dist/entries/crawler.cjs +6 -6
  21. package/dist/index.cjs +48 -48
  22. package/dist/index.d.ts +1 -1
  23. package/dist/internal/agents/index.cjs +14 -14
  24. package/dist/platform/browser.d.ts +1 -1
  25. package/dist/platform/bun.d.ts +1 -1
  26. package/dist/platform/deno.d.ts +1 -1
  27. package/dist/platform/node.d.ts +1 -1
  28. package/dist/platform/react-native.cjs +6 -6
  29. package/dist/platform/react-native.d.ts +1 -1
  30. package/dist/platform/worker.d.ts +1 -1
  31. package/dist/proxy/index.cjs +4 -4
  32. package/dist/queue/index.cjs +8 -8
  33. package/dist/responses/universal/index.cjs +11 -11
  34. package/dist/responses/universal/stream.cjs +9 -11
  35. package/dist/responses/universal/stream.js +9 -11
  36. package/dist/stealth/index.cjs +17 -17
  37. package/dist/stealth/profiles/index.cjs +10 -10
  38. package/dist/utils/http-config.cjs +13 -21
  39. package/dist/utils/http-config.js +13 -21
  40. package/dist/version.cjs +1 -1
  41. package/dist/version.js +1 -1
  42. package/dist/wget/index.cjs +51 -51
  43. package/package.json +1 -1
  44. package/dist/utils/node-runtime.cjs +0 -29
  45. package/dist/utils/node-runtime.js +0 -26
@@ -6027,7 +6027,7 @@ export interface RezoInstance extends Rezo, RezoCallable {
6027
6027
  *
6028
6028
  * IMPORTANT: Update these values when bumping package version.
6029
6029
  */
6030
- export declare const VERSION = "1.0.129";
6030
+ export declare const VERSION = "1.0.130";
6031
6031
  /**
6032
6032
  * cURL Options Configuration
6033
6033
  *
@@ -6027,7 +6027,7 @@ export interface RezoInstance extends Rezo, RezoCallable {
6027
6027
  *
6028
6028
  * IMPORTANT: Update these values when bumping package version.
6029
6029
  */
6030
- export declare const VERSION = "1.0.129";
6030
+ export declare const VERSION = "1.0.130";
6031
6031
  export declare const isRezoError: typeof RezoError.isRezoError;
6032
6032
  export declare const Cancel: typeof RezoError;
6033
6033
  export declare const CancelToken: {
@@ -6027,7 +6027,7 @@ export interface RezoInstance extends Rezo, RezoCallable {
6027
6027
  *
6028
6028
  * IMPORTANT: Update these values when bumping package version.
6029
6029
  */
6030
- export declare const VERSION = "1.0.129";
6030
+ export declare const VERSION = "1.0.130";
6031
6031
  /**
6032
6032
  * Type guard to check if an error is a RezoError instance.
6033
6033
  */
@@ -6027,7 +6027,7 @@ export interface RezoInstance extends Rezo, RezoCallable {
6027
6027
  *
6028
6028
  * IMPORTANT: Update these values when bumping package version.
6029
6029
  */
6030
- export declare const VERSION = "1.0.129";
6030
+ export declare const VERSION = "1.0.130";
6031
6031
  export declare const isRezoError: typeof RezoError.isRezoError;
6032
6032
  export declare const Cancel: typeof RezoError;
6033
6033
  export declare const CancelToken: {
@@ -6,12 +6,12 @@ const { RezoFormData } = require('../../utils/form-data.cjs');
6
6
  const { RezoCookieJar, Cookie } = require('../../cookies/cookie-jar.cjs');
7
7
  const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
8
8
  const { VERSION } = require('../../version.cjs');
9
- const _mod_fi01d9 = require('../../platform/react-native-providers.cjs');
10
- exports.createFetchStreamTransport = _mod_fi01d9.createFetchStreamTransport;
11
- exports.createExpoFileSystemAdapter = _mod_fi01d9.createExpoFileSystemAdapter;
12
- exports.createReactNativeFsAdapter = _mod_fi01d9.createReactNativeFsAdapter;
13
- exports.createNetInfoProvider = _mod_fi01d9.createNetInfoProvider;
14
- exports.createExpoBackgroundTaskProvider = _mod_fi01d9.createExpoBackgroundTaskProvider;;
9
+ const _mod_fft01t = require('../../platform/react-native-providers.cjs');
10
+ exports.createFetchStreamTransport = _mod_fft01t.createFetchStreamTransport;
11
+ exports.createExpoFileSystemAdapter = _mod_fft01t.createExpoFileSystemAdapter;
12
+ exports.createReactNativeFsAdapter = _mod_fft01t.createReactNativeFsAdapter;
13
+ exports.createNetInfoProvider = _mod_fft01t.createNetInfoProvider;
14
+ exports.createExpoBackgroundTaskProvider = _mod_fft01t.createExpoBackgroundTaskProvider;;
15
15
  exports.Rezo = Rezo;
16
16
  exports.RezoError = RezoError;
17
17
  exports.RezoErrorCode = RezoErrorCode;
@@ -6027,7 +6027,7 @@ export interface RezoInstance extends Rezo, RezoCallable {
6027
6027
  *
6028
6028
  * IMPORTANT: Update these values when bumping package version.
6029
6029
  */
6030
- export declare const VERSION = "1.0.129";
6030
+ export declare const VERSION = "1.0.130";
6031
6031
  export interface ExpoFileSystemFileLike {
6032
6032
  uri?: string;
6033
6033
  size?: number;
@@ -6027,7 +6027,7 @@ export interface RezoInstance extends Rezo, RezoCallable {
6027
6027
  *
6028
6028
  * IMPORTANT: Update these values when bumping package version.
6029
6029
  */
6030
- export declare const VERSION = "1.0.129";
6030
+ export declare const VERSION = "1.0.130";
6031
6031
  export declare const isRezoError: typeof RezoError.isRezoError;
6032
6032
  export declare const Cancel: typeof RezoError;
6033
6033
  export declare const CancelToken: {
@@ -1,6 +1,6 @@
1
- const _mod_bjhzfo = require('./picker.cjs');
2
- exports.detectRuntime = _mod_bjhzfo.detectRuntime;
3
- exports.getAdapterCapabilities = _mod_bjhzfo.getAdapterCapabilities;
4
- exports.buildAdapterContext = _mod_bjhzfo.buildAdapterContext;
5
- exports.getAvailableAdapters = _mod_bjhzfo.getAvailableAdapters;
6
- exports.selectAdapter = _mod_bjhzfo.selectAdapter;;
1
+ const _mod_qhux44 = require('./picker.cjs');
2
+ exports.detectRuntime = _mod_qhux44.detectRuntime;
3
+ exports.getAdapterCapabilities = _mod_qhux44.getAdapterCapabilities;
4
+ exports.buildAdapterContext = _mod_qhux44.buildAdapterContext;
5
+ exports.getAvailableAdapters = _mod_qhux44.getAvailableAdapters;
6
+ exports.selectAdapter = _mod_qhux44.selectAdapter;;
@@ -1,5 +1,5 @@
1
1
  const { LRUCache } = require('./lru-cache.cjs');
2
- const { requireNodeModule } = require('../utils/node-runtime.cjs');
2
+ const dns = require("node:dns");
3
3
  const DEFAULT_DNS_TTL = 60000;
4
4
  const DEFAULT_DNS_MAX_ENTRIES = 1000;
5
5
 
@@ -59,11 +59,6 @@ class DNSCache {
59
59
  }
60
60
  resolveDNS(hostname, family) {
61
61
  return new Promise((resolve) => {
62
- const dns = requireNodeModule("node:dns");
63
- if (!dns?.lookup) {
64
- resolve(undefined);
65
- return;
66
- }
67
62
  const options = { family: family ?? 0 };
68
63
  dns.lookup(hostname, options, (err, address, resultFamily) => {
69
64
  if (err || !address || typeof address !== "string") {
@@ -76,11 +71,6 @@ class DNSCache {
76
71
  }
77
72
  resolveAllDNS(hostname, family) {
78
73
  return new Promise((resolve) => {
79
- const dns = requireNodeModule("node:dns");
80
- if (!dns?.lookup) {
81
- resolve([]);
82
- return;
83
- }
84
74
  const options = { family: family ?? 0, all: true };
85
75
  dns.lookup(hostname, options, (err, addresses) => {
86
76
  if (err || !addresses || !Array.isArray(addresses)) {
@@ -1,5 +1,5 @@
1
1
  import { LRUCache } from './lru-cache.js';
2
- import { requireNodeModule } from '../utils/node-runtime.js';
2
+ import dns from "node:dns";
3
3
  const DEFAULT_DNS_TTL = 60000;
4
4
  const DEFAULT_DNS_MAX_ENTRIES = 1000;
5
5
 
@@ -59,11 +59,6 @@ export class DNSCache {
59
59
  }
60
60
  resolveDNS(hostname, family) {
61
61
  return new Promise((resolve) => {
62
- const dns = requireNodeModule("node:dns");
63
- if (!dns?.lookup) {
64
- resolve(undefined);
65
- return;
66
- }
67
62
  const options = { family: family ?? 0 };
68
63
  dns.lookup(hostname, options, (err, address, resultFamily) => {
69
64
  if (err || !address || typeof address !== "string") {
@@ -76,11 +71,6 @@ export class DNSCache {
76
71
  }
77
72
  resolveAllDNS(hostname, family) {
78
73
  return new Promise((resolve) => {
79
- const dns = requireNodeModule("node:dns");
80
- if (!dns?.lookup) {
81
- resolve([]);
82
- return;
83
- }
84
74
  const options = { family: family ?? 0, all: true };
85
75
  dns.lookup(hostname, options, (err, addresses) => {
86
76
  if (err || !addresses || !Array.isArray(addresses)) {
@@ -1,9 +1,9 @@
1
- const _mod_snxaxs = require('./lru-cache.cjs');
2
- exports.LRUCache = _mod_snxaxs.LRUCache;;
3
- const _mod_e700bz = require('./dns-cache.cjs');
4
- exports.DNSCache = _mod_e700bz.DNSCache;
5
- exports.getGlobalDNSCache = _mod_e700bz.getGlobalDNSCache;
6
- exports.resetGlobalDNSCache = _mod_e700bz.resetGlobalDNSCache;;
7
- const _mod_4lcu8q = require('./response-cache.cjs');
8
- exports.ResponseCache = _mod_4lcu8q.ResponseCache;
9
- exports.normalizeResponseCacheConfig = _mod_4lcu8q.normalizeResponseCacheConfig;;
1
+ const _mod_66d5y0 = require('./lru-cache.cjs');
2
+ exports.LRUCache = _mod_66d5y0.LRUCache;;
3
+ const _mod_fiylx5 = require('./dns-cache.cjs');
4
+ exports.DNSCache = _mod_fiylx5.DNSCache;
5
+ exports.getGlobalDNSCache = _mod_fiylx5.getGlobalDNSCache;
6
+ exports.resetGlobalDNSCache = _mod_fiylx5.resetGlobalDNSCache;;
7
+ const _mod_t0ymbs = require('./response-cache.cjs');
8
+ exports.ResponseCache = _mod_t0ymbs.ResponseCache;
9
+ exports.normalizeResponseCacheConfig = _mod_t0ymbs.normalizeResponseCacheConfig;;
@@ -1,11 +1,7 @@
1
1
  const { LRUCache } = require('./lru-cache.cjs');
2
- const { requireNodeModule } = require('../utils/node-runtime.cjs');
3
- function getFsModule() {
4
- return requireNodeModule("node:fs");
5
- }
6
- function getPathModule() {
7
- return requireNodeModule("node:path");
8
- }
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+ const fsPromises = fs.promises;
9
5
  const DEFAULT_TTL = 3000000;
10
6
  const DEFAULT_MAX_ENTRIES = 500;
11
7
  const DEFAULT_METHODS = ["GET", "HEAD"];
@@ -26,7 +22,7 @@ class ResponseCache {
26
22
  methods: config.methods ?? DEFAULT_METHODS,
27
23
  respectHeaders: config.respectHeaders ?? true
28
24
  };
29
- this.persistenceEnabled = !!this.config.cacheDir && !!getFsModule() && !!getPathModule();
25
+ this.persistenceEnabled = !!this.config.cacheDir;
30
26
  this.memoryCache = new LRUCache({
31
27
  maxEntries: this.config.maxEntries,
32
28
  ttl: this.config.ttl,
@@ -46,13 +42,8 @@ class ResponseCache {
46
42
  async initializePersistenceAsync() {
47
43
  if (!this.config.cacheDir)
48
44
  return;
49
- const fs = getFsModule();
50
- if (!fs?.promises) {
51
- this.persistenceEnabled = false;
52
- return;
53
- }
54
45
  try {
55
- await fs.promises.mkdir(this.config.cacheDir, { recursive: true });
46
+ await fsPromises.mkdir(this.config.cacheDir, { recursive: true });
56
47
  await this.loadFromDiskAsync();
57
48
  this.initialized = true;
58
49
  } catch {
@@ -60,42 +51,34 @@ class ResponseCache {
60
51
  }
61
52
  }
62
53
  getCacheFilePath(key) {
63
- const path = getPathModule();
64
54
  const safeKey = Buffer.from(key).toString("base64url");
65
- return path && this.config.cacheDir ? path.join(this.config.cacheDir, `${safeKey}.json`) : `${this.config.cacheDir || ""}/${safeKey}.json`;
55
+ return path.join(this.config.cacheDir, `${safeKey}.json`);
66
56
  }
67
57
  persistToDisk(key, entry) {
68
58
  if (!this.persistenceEnabled || !this.config.cacheDir)
69
59
  return;
70
- const fs = getFsModule();
71
- if (!fs?.promises)
72
- return;
73
60
  const filePath = this.getCacheFilePath(key);
74
- fs.promises.writeFile(filePath, JSON.stringify(entry), "utf-8").catch(() => {});
61
+ fsPromises.writeFile(filePath, JSON.stringify(entry), "utf-8").catch(() => {});
75
62
  }
76
63
  async loadFromDiskAsync() {
77
64
  if (!this.persistenceEnabled || !this.config.cacheDir)
78
65
  return;
79
- const fs = getFsModule();
80
- const path = getPathModule();
81
- if (!fs?.promises || !path)
82
- return;
83
66
  try {
84
- const files = await fs.promises.readdir(this.config.cacheDir);
67
+ const files = await fsPromises.readdir(this.config.cacheDir);
85
68
  const now = Date.now();
86
69
  for (const file of files) {
87
70
  if (!file.endsWith(".json"))
88
71
  continue;
89
72
  try {
90
73
  const filePath = path.join(this.config.cacheDir, file);
91
- const content = await fs.promises.readFile(filePath, "utf-8");
74
+ const content = await fsPromises.readFile(filePath, "utf-8");
92
75
  const entry = JSON.parse(content);
93
76
  if (entry.timestamp + entry.ttl > now) {
94
77
  const key = Buffer.from(file.replace(".json", ""), "base64url").toString("utf-8");
95
78
  const remainingTTL = entry.timestamp + entry.ttl - now;
96
79
  this.memoryCache.set(key, entry, remainingTTL);
97
80
  } else {
98
- fs.promises.unlink(filePath).catch(() => {});
81
+ fsPromises.unlink(filePath).catch(() => {});
99
82
  }
100
83
  } catch {}
101
84
  }
@@ -162,9 +145,6 @@ class ResponseCache {
162
145
  loadSingleFromDisk(key) {
163
146
  if (!this.persistenceEnabled || !this.config.cacheDir)
164
147
  return;
165
- const fs = getFsModule();
166
- if (!fs)
167
- return;
168
148
  try {
169
149
  const filePath = this.getCacheFilePath(key);
170
150
  if (!fs.existsSync(filePath))
@@ -261,8 +241,7 @@ class ResponseCache {
261
241
  this.memoryCache.delete(key);
262
242
  if (this.persistenceEnabled) {
263
243
  const filePath = this.getCacheFilePath(key);
264
- const fs = getFsModule();
265
- fs?.promises?.unlink(filePath).catch(() => {});
244
+ fsPromises.unlink(filePath).catch(() => {});
266
245
  }
267
246
  return;
268
247
  }
@@ -291,23 +270,18 @@ class ResponseCache {
291
270
  this.memoryCache.delete(key);
292
271
  if (this.persistenceEnabled) {
293
272
  const filePath = this.getCacheFilePath(key);
294
- const fs = getFsModule();
295
- fs?.promises?.unlink(filePath).catch(() => {});
273
+ fsPromises.unlink(filePath).catch(() => {});
296
274
  }
297
275
  }
298
276
  }
299
277
  clear() {
300
278
  this.memoryCache.clear();
301
279
  if (this.persistenceEnabled && this.config.cacheDir) {
302
- const fs = getFsModule();
303
- const path = getPathModule();
304
- if (!fs?.promises || !path)
305
- return;
306
280
  const cacheDir = this.config.cacheDir;
307
- fs.promises.readdir(cacheDir).then((files) => {
281
+ fsPromises.readdir(cacheDir).then((files) => {
308
282
  for (const file of files) {
309
283
  if (file.endsWith(".json")) {
310
- fs.promises.unlink(path.join(cacheDir, file)).catch(() => {});
284
+ fsPromises.unlink(path.join(cacheDir, file)).catch(() => {});
311
285
  }
312
286
  }
313
287
  }).catch(() => {});
@@ -1,11 +1,7 @@
1
1
  import { LRUCache } from './lru-cache.js';
2
- import { requireNodeModule } from '../utils/node-runtime.js';
3
- function getFsModule() {
4
- return requireNodeModule("node:fs");
5
- }
6
- function getPathModule() {
7
- return requireNodeModule("node:path");
8
- }
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ const fsPromises = fs.promises;
9
5
  const DEFAULT_TTL = 3000000;
10
6
  const DEFAULT_MAX_ENTRIES = 500;
11
7
  const DEFAULT_METHODS = ["GET", "HEAD"];
@@ -26,7 +22,7 @@ export class ResponseCache {
26
22
  methods: config.methods ?? DEFAULT_METHODS,
27
23
  respectHeaders: config.respectHeaders ?? true
28
24
  };
29
- this.persistenceEnabled = !!this.config.cacheDir && !!getFsModule() && !!getPathModule();
25
+ this.persistenceEnabled = !!this.config.cacheDir;
30
26
  this.memoryCache = new LRUCache({
31
27
  maxEntries: this.config.maxEntries,
32
28
  ttl: this.config.ttl,
@@ -46,13 +42,8 @@ export class ResponseCache {
46
42
  async initializePersistenceAsync() {
47
43
  if (!this.config.cacheDir)
48
44
  return;
49
- const fs = getFsModule();
50
- if (!fs?.promises) {
51
- this.persistenceEnabled = false;
52
- return;
53
- }
54
45
  try {
55
- await fs.promises.mkdir(this.config.cacheDir, { recursive: true });
46
+ await fsPromises.mkdir(this.config.cacheDir, { recursive: true });
56
47
  await this.loadFromDiskAsync();
57
48
  this.initialized = true;
58
49
  } catch {
@@ -60,42 +51,34 @@ export class ResponseCache {
60
51
  }
61
52
  }
62
53
  getCacheFilePath(key) {
63
- const path = getPathModule();
64
54
  const safeKey = Buffer.from(key).toString("base64url");
65
- return path && this.config.cacheDir ? path.join(this.config.cacheDir, `${safeKey}.json`) : `${this.config.cacheDir || ""}/${safeKey}.json`;
55
+ return path.join(this.config.cacheDir, `${safeKey}.json`);
66
56
  }
67
57
  persistToDisk(key, entry) {
68
58
  if (!this.persistenceEnabled || !this.config.cacheDir)
69
59
  return;
70
- const fs = getFsModule();
71
- if (!fs?.promises)
72
- return;
73
60
  const filePath = this.getCacheFilePath(key);
74
- fs.promises.writeFile(filePath, JSON.stringify(entry), "utf-8").catch(() => {});
61
+ fsPromises.writeFile(filePath, JSON.stringify(entry), "utf-8").catch(() => {});
75
62
  }
76
63
  async loadFromDiskAsync() {
77
64
  if (!this.persistenceEnabled || !this.config.cacheDir)
78
65
  return;
79
- const fs = getFsModule();
80
- const path = getPathModule();
81
- if (!fs?.promises || !path)
82
- return;
83
66
  try {
84
- const files = await fs.promises.readdir(this.config.cacheDir);
67
+ const files = await fsPromises.readdir(this.config.cacheDir);
85
68
  const now = Date.now();
86
69
  for (const file of files) {
87
70
  if (!file.endsWith(".json"))
88
71
  continue;
89
72
  try {
90
73
  const filePath = path.join(this.config.cacheDir, file);
91
- const content = await fs.promises.readFile(filePath, "utf-8");
74
+ const content = await fsPromises.readFile(filePath, "utf-8");
92
75
  const entry = JSON.parse(content);
93
76
  if (entry.timestamp + entry.ttl > now) {
94
77
  const key = Buffer.from(file.replace(".json", ""), "base64url").toString("utf-8");
95
78
  const remainingTTL = entry.timestamp + entry.ttl - now;
96
79
  this.memoryCache.set(key, entry, remainingTTL);
97
80
  } else {
98
- fs.promises.unlink(filePath).catch(() => {});
81
+ fsPromises.unlink(filePath).catch(() => {});
99
82
  }
100
83
  } catch {}
101
84
  }
@@ -162,9 +145,6 @@ export class ResponseCache {
162
145
  loadSingleFromDisk(key) {
163
146
  if (!this.persistenceEnabled || !this.config.cacheDir)
164
147
  return;
165
- const fs = getFsModule();
166
- if (!fs)
167
- return;
168
148
  try {
169
149
  const filePath = this.getCacheFilePath(key);
170
150
  if (!fs.existsSync(filePath))
@@ -261,8 +241,7 @@ export class ResponseCache {
261
241
  this.memoryCache.delete(key);
262
242
  if (this.persistenceEnabled) {
263
243
  const filePath = this.getCacheFilePath(key);
264
- const fs = getFsModule();
265
- fs?.promises?.unlink(filePath).catch(() => {});
244
+ fsPromises.unlink(filePath).catch(() => {});
266
245
  }
267
246
  return;
268
247
  }
@@ -291,23 +270,18 @@ export class ResponseCache {
291
270
  this.memoryCache.delete(key);
292
271
  if (this.persistenceEnabled) {
293
272
  const filePath = this.getCacheFilePath(key);
294
- const fs = getFsModule();
295
- fs?.promises?.unlink(filePath).catch(() => {});
273
+ fsPromises.unlink(filePath).catch(() => {});
296
274
  }
297
275
  }
298
276
  }
299
277
  clear() {
300
278
  this.memoryCache.clear();
301
279
  if (this.persistenceEnabled && this.config.cacheDir) {
302
- const fs = getFsModule();
303
- const path = getPathModule();
304
- if (!fs?.promises || !path)
305
- return;
306
280
  const cacheDir = this.config.cacheDir;
307
- fs.promises.readdir(cacheDir).then((files) => {
281
+ fsPromises.readdir(cacheDir).then((files) => {
308
282
  for (const file of files) {
309
283
  if (file.endsWith(".json")) {
310
- fs.promises.unlink(path.join(cacheDir, file)).catch(() => {});
284
+ fsPromises.unlink(path.join(cacheDir, file)).catch(() => {});
311
285
  }
312
286
  }
313
287
  }).catch(() => {});
@@ -1,8 +1,7 @@
1
1
  const { CookieJar: TouchCookieJar } = require("tough-cookie");
2
2
  const { Cookie } = require('./cookie.cjs');
3
- const { requireNodeModule } = require('../utils/node-runtime.cjs');
4
- const _mod_p2kzqp = require('./cookie.cjs');
5
- exports.Cookie = _mod_p2kzqp.Cookie;;
3
+ const _mod_y8mmg9 = require('./cookie.cjs');
4
+ exports.Cookie = _mod_y8mmg9.Cookie;;
6
5
 
7
6
  class RezoCookieJar extends TouchCookieJar {
8
7
  constructor(store, options) {
@@ -403,8 +402,10 @@ class RezoCookieJar extends TouchCookieJar {
403
402
  return this._cookieFile;
404
403
  }
405
404
  loadFromFile(filePath, _defaultUrl) {
406
- const fs = requireNodeModule("node:fs");
407
- if (!fs) {
405
+ let fs;
406
+ try {
407
+ fs = require("node:fs");
408
+ } catch {
408
409
  throw new Error("loadFromFile() requires Node.js, Bun, or Deno. Not available in browsers or React Native.");
409
410
  }
410
411
  if (!fs.existsSync(filePath)) {
@@ -455,8 +456,10 @@ class RezoCookieJar extends TouchCookieJar {
455
456
  if (!targetPath) {
456
457
  throw new Error("No cookie file path specified. Provide a path or load from a file first.");
457
458
  }
458
- const fs = requireNodeModule("node:fs");
459
- if (!fs) {
459
+ let fs;
460
+ try {
461
+ fs = require("node:fs");
462
+ } catch {
460
463
  throw new Error("saveToFile() requires Node.js, Bun, or Deno. Not available in browsers or React Native.");
461
464
  }
462
465
  const isJson = targetPath.toLowerCase().endsWith(".json");
@@ -481,7 +484,7 @@ class RezoCookieJar extends TouchCookieJar {
481
484
  }
482
485
  }
483
486
  const CookieJar = exports.CookieJar = RezoCookieJar;
484
- const _mod_nfmlpp = require("tough-cookie");
485
- exports.Store = _mod_nfmlpp.Store;;
487
+ const _mod_2m96de = require("tough-cookie");
488
+ exports.Store = _mod_2m96de.Store;;
486
489
 
487
490
  exports.RezoCookieJar = RezoCookieJar;
@@ -1,6 +1,5 @@
1
1
  import { CookieJar as TouchCookieJar } from "tough-cookie";
2
2
  import { Cookie } from './cookie.js';
3
- import { requireNodeModule } from '../utils/node-runtime.js';
4
3
  export { Cookie } from './cookie.js';
5
4
 
6
5
  export class RezoCookieJar extends TouchCookieJar {
@@ -402,8 +401,10 @@ export class RezoCookieJar extends TouchCookieJar {
402
401
  return this._cookieFile;
403
402
  }
404
403
  loadFromFile(filePath, _defaultUrl) {
405
- const fs = requireNodeModule("node:fs");
406
- if (!fs) {
404
+ let fs;
405
+ try {
406
+ fs = require("node:fs");
407
+ } catch {
407
408
  throw new Error("loadFromFile() requires Node.js, Bun, or Deno. Not available in browsers or React Native.");
408
409
  }
409
410
  if (!fs.existsSync(filePath)) {
@@ -454,8 +455,10 @@ export class RezoCookieJar extends TouchCookieJar {
454
455
  if (!targetPath) {
455
456
  throw new Error("No cookie file path specified. Provide a path or load from a file first.");
456
457
  }
457
- const fs = requireNodeModule("node:fs");
458
- if (!fs) {
458
+ let fs;
459
+ try {
460
+ fs = require("node:fs");
461
+ } catch {
459
462
  throw new Error("saveToFile() requires Node.js, Bun, or Deno. Not available in browsers or React Native.");
460
463
  }
461
464
  const isJson = targetPath.toLowerCase().endsWith(".json");
@@ -1,10 +1,10 @@
1
- const _mod_5f7e7j = require('./cookie.cjs');
2
- exports.Cookie = _mod_5f7e7j.Cookie;
3
- exports.RezoCookie = _mod_5f7e7j.RezoCookie;;
4
- const _mod_qgxkmc = require('./cookie-store.cjs');
5
- exports.RezoCookieStore = _mod_qgxkmc.RezoCookieStore;;
6
- const _mod_tenk2p = require('./cookie-jar.cjs');
7
- exports.RezoCookieJar = _mod_tenk2p.RezoCookieJar;
8
- exports.CookieJar = _mod_tenk2p.CookieJar;;
9
- const _mod_01bx46 = require("tough-cookie");
10
- exports.Store = _mod_01bx46.Store;;
1
+ const _mod_pjz10g = require('./cookie.cjs');
2
+ exports.Cookie = _mod_pjz10g.Cookie;
3
+ exports.RezoCookie = _mod_pjz10g.RezoCookie;;
4
+ const _mod_r06e2k = require('./cookie-store.cjs');
5
+ exports.RezoCookieStore = _mod_r06e2k.RezoCookieStore;;
6
+ const _mod_8gcdod = require('./cookie-jar.cjs');
7
+ exports.RezoCookieJar = _mod_8gcdod.RezoCookieJar;
8
+ exports.CookieJar = _mod_8gcdod.CookieJar;;
9
+ const _mod_jxvzsj = require("tough-cookie");
10
+ exports.Store = _mod_jxvzsj.Store;;
@@ -1 +1 @@
1
- var{Rezo:h}=require("../../../core/rezo.cjs"),a=require("./options.cjs");exports.OXYLABS_BROWSER_TYPES=a.OXYLABS_BROWSER_TYPES;exports.OXYLABS_COMMON_LOCALES=a.OXYLABS_COMMON_LOCALES;exports.OXYLABS_COMMON_GEO_LOCATIONS=a.OXYLABS_COMMON_GEO_LOCATIONS;exports.OXYLABS_US_STATES=a.OXYLABS_US_STATES;exports.OXYLABS_EUROPEAN_COUNTRIES=a.OXYLABS_EUROPEAN_COUNTRIES;exports.OXYLABS_ASIAN_COUNTRIES=a.OXYLABS_ASIAN_COUNTRIES;exports.getRandomBrowserType=a.getRandomBrowserType;exports.getRandomLocale=a.getRandomLocale;exports.getRandomGeoLocation=a.getRandomGeoLocation;var i="https://realtime.oxylabs.io/v1/queries";class d{config;http;authHeader;constructor(t){if(!t.username||!t.password)throw Error("Oxylabs username and password are required");this.config={username:t.username,password:t.password,browserType:t.browserType??"desktop",locale:t.locale??"en-US",geoLocation:t.geoLocation??"",render:t.render??!1,context:t.context??{},timeout:t.timeout??120000},this.http=new h({baseURL:i,timeout:this.config.timeout}),this.authHeader=`Basic ${Buffer.from(`${t.username}:${t.password}`).toString("base64")}`}async scrape(t,e){let s={...this.config,...e},r=this.buildRequestBody(t,s),o=(await this.http.postJson(i,r,{headers:{Authorization:this.authHeader,"Content-Type":"application/json"}})).data;if(o.error)throw Error(`Oxylabs API error: ${o.error}`);if(!o.results||o.results.length===0)throw Error("Oxylabs API returned no results");let n=o.results[0],l=n._response?.cookies||[],_=n._response?.headers||{};return{statusCode:n.status_code,url:n.url,content:n.content,cookies:l,headers:_,jobId:o.job_id||n.job_id,rendered:s.render,geoLocation:s.geoLocation||void 0,locale:s.locale,browserType:s.browserType,raw:o}}async scrapeMany(t,e,s=1000){let r=[];for(let u=0;u<t.length;u++){let o=await this.scrape(t[u],e);if(r.push(o),u<t.length-1&&s>0)await new Promise((n)=>setTimeout(n,s))}return r}buildRequestBody(t,e){let s=[];if(s.push({key:"return_page_cookies",value:!0}),s.push({key:"return_page_headers",value:!0}),e.context)for(let[u,o]of Object.entries(e.context))s.push({key:u,value:o});if(e.headers&&Object.keys(e.headers).length>0)s.push({key:"headers",value:e.headers});if(e.cookies&&e.cookies.length>0)s.push({key:"cookies",value:e.cookies});if(e.session_id)s.push({key:"session_id",value:e.session_id});if(e.http_method)s.push({key:"http_method",value:e.http_method});if(e.base64Body)s.push({key:"content",value:e.base64Body});if(typeof e.follow_redirects==="boolean")s.push({key:"follow_redirects",value:e.follow_redirects});if(e.successful_status_codes&&e.successful_status_codes.length>0)s.push({key:"successful_status_codes",value:e.successful_status_codes});let r={source:"universal",url:t,context:s};if(e.render||e.javascript_rendering)r.render="html";if(e.browserType)r.user_agent_type=e.browserType;if(e.locale)r.locale=e.locale;if(e.geoLocation)r.geo_location=e.geoLocation;if(e.returnAsBase64)r.content_encoding="base64";return r}getConfig(){return{...this.config,password:"***"}}withConfig(t){return new d({...this.config,...t})}async testConnection(){try{return await this.scrape("https://httpbin.org/ip"),!0}catch(t){throw Error(`Oxylabs connection test failed: ${t.message}`)}}}exports.Oxylabs=d;exports.default=d;module.exports=Object.assign(d,exports);
1
+ var{Rezo:h}=require("../../../core/rezo.cjs"),a=require("./options.cjs");exports.OXYLABS_BROWSER_TYPES=a.OXYLABS_BROWSER_TYPES;exports.OXYLABS_COMMON_LOCALES=a.OXYLABS_COMMON_LOCALES;exports.OXYLABS_COMMON_GEO_LOCATIONS=a.OXYLABS_COMMON_GEO_LOCATIONS;exports.OXYLABS_US_STATES=a.OXYLABS_US_STATES;exports.OXYLABS_EUROPEAN_COUNTRIES=a.OXYLABS_EUROPEAN_COUNTRIES;exports.OXYLABS_ASIAN_COUNTRIES=a.OXYLABS_ASIAN_COUNTRIES;exports.getRandomBrowserType=a.getRandomBrowserType;exports.getRandomLocale=a.getRandomLocale;exports.getRandomGeoLocation=a.getRandomGeoLocation;var i="https://realtime.oxylabs.io/v1/queries";class d{config;http;authHeader;constructor(s){if(!s.username||!s.password)throw Error("Oxylabs username and password are required");this.config={username:s.username,password:s.password,browserType:s.browserType??"desktop",locale:s.locale??"en-US",geoLocation:s.geoLocation??"",render:s.render??!1,context:s.context??{},timeout:s.timeout??120000},this.http=new h({baseURL:i,timeout:this.config.timeout}),this.authHeader=`Basic ${Buffer.from(`${s.username}:${s.password}`).toString("base64")}`}async scrape(s,e){let t={...this.config,...e},r=this.buildRequestBody(s,t),o=(await this.http.postJson(i,r,{headers:{Authorization:this.authHeader,"Content-Type":"application/json"}})).data;if(o.error)throw Error(`Oxylabs API error: ${o.error}`);if(!o.results||o.results.length===0)throw Error("Oxylabs API returned no results");let n=o.results[0],l=n._response?.cookies||[],_=n._response?.headers||{};return{statusCode:n.status_code,url:n.url,content:n.content,cookies:l,headers:_,jobId:o.job_id||n.job_id,rendered:t.render,geoLocation:t.geoLocation||void 0,locale:t.locale,browserType:t.browserType,raw:o}}async scrapeMany(s,e,t=1000){let r=[];for(let u=0;u<s.length;u++){let o=await this.scrape(s[u],e);if(r.push(o),u<s.length-1&&t>0)await new Promise((n)=>setTimeout(n,t))}return r}buildRequestBody(s,e){let t=[];if(t.push({key:"return_page_cookies",value:!0}),t.push({key:"return_page_headers",value:!0}),e.context)for(let[u,o]of Object.entries(e.context))t.push({key:u,value:o});if(e.headers&&Object.keys(e.headers).length>0)t.push({key:"headers",value:e.headers});if(e.cookies&&e.cookies.length>0)t.push({key:"cookies",value:e.cookies});if(e.session_id)t.push({key:"session_id",value:e.session_id});if(e.http_method)t.push({key:"http_method",value:e.http_method});if(e.base64Body)t.push({key:"content",value:e.base64Body});if(typeof e.follow_redirects==="boolean")t.push({key:"follow_redirects",value:e.follow_redirects});if(e.successful_status_codes&&e.successful_status_codes.length>0)t.push({key:"successful_status_codes",value:e.successful_status_codes});let r={source:"universal",url:s,context:t};if(e.render||e.javascript_rendering)r.render="html";if(e.browserType)r.user_agent_type=e.browserType;if(e.locale)r.locale=e.locale;if(e.geoLocation)r.geo_location=e.geoLocation;if(e.returnAsBase64)r.content_encoding="base64";return r}getConfig(){return{...this.config,password:"***"}}withConfig(s){return new d({...this.config,...s})}async testConnection(){try{return await this.scrape("https://httpbin.org/ip"),!0}catch(s){throw Error(`Oxylabs connection test failed: ${s.message}`)}}}exports.Oxylabs=d;exports.default=d;module.exports=Object.assign(d,exports);