rezo 1.0.25 → 1.0.27

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.
@@ -205,6 +205,51 @@ export declare class RezoCookieJar extends TouchCookieJar {
205
205
  toArray(): Cookie[];
206
206
  toSetCookies(): string[];
207
207
  toSerializedCookies(): SerializedCookie[];
208
+ /**
209
+ * Get cookies for a request URL with proper browser-like matching.
210
+ * This method properly handles:
211
+ * - Domain matching (exact or parent domain)
212
+ * - Path matching (cookie path must be prefix of request path)
213
+ * - Secure flag (secure cookies only over HTTPS)
214
+ * - Expiry (expired cookies not returned)
215
+ *
216
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
217
+ * @returns Array of Cookie objects that should be sent with the request
218
+ */
219
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
220
+ /**
221
+ * Get the Cookie header value for a request URL with proper browser-like matching.
222
+ * Returns cookies in the format: "key1=value1; key2=value2"
223
+ *
224
+ * This is the browser-accurate way to build the Cookie header, properly filtering
225
+ * cookies by domain, path, secure flag, and expiry.
226
+ *
227
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
228
+ * @returns Cookie header string in "key=value; key=value" format
229
+ */
230
+ getCookieHeader(requestUrl: string | URL): string;
231
+ /**
232
+ * Debug method to show which cookies would be sent for a given URL.
233
+ * Useful for troubleshooting cookie matching issues.
234
+ *
235
+ * @param requestUrl - The full request URL including path
236
+ * @returns Object with matching cookies and the Cookie header that would be sent
237
+ */
238
+ debugCookiesForRequest(requestUrl: string | URL): {
239
+ url: string;
240
+ matchingCookies: Array<{
241
+ key: string;
242
+ value: string;
243
+ domain: string;
244
+ path: string;
245
+ }>;
246
+ cookieHeader: string;
247
+ allCookies: Array<{
248
+ key: string;
249
+ domain: string;
250
+ path: string;
251
+ }>;
252
+ };
208
253
  setCookiesSync(setCookieArray: string[]): Cookies;
209
254
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
210
255
  setCookiesSync(cookiesString: string): Cookies;
@@ -205,6 +205,51 @@ export declare class RezoCookieJar extends TouchCookieJar {
205
205
  toArray(): Cookie[];
206
206
  toSetCookies(): string[];
207
207
  toSerializedCookies(): SerializedCookie[];
208
+ /**
209
+ * Get cookies for a request URL with proper browser-like matching.
210
+ * This method properly handles:
211
+ * - Domain matching (exact or parent domain)
212
+ * - Path matching (cookie path must be prefix of request path)
213
+ * - Secure flag (secure cookies only over HTTPS)
214
+ * - Expiry (expired cookies not returned)
215
+ *
216
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
217
+ * @returns Array of Cookie objects that should be sent with the request
218
+ */
219
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
220
+ /**
221
+ * Get the Cookie header value for a request URL with proper browser-like matching.
222
+ * Returns cookies in the format: "key1=value1; key2=value2"
223
+ *
224
+ * This is the browser-accurate way to build the Cookie header, properly filtering
225
+ * cookies by domain, path, secure flag, and expiry.
226
+ *
227
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
228
+ * @returns Cookie header string in "key=value; key=value" format
229
+ */
230
+ getCookieHeader(requestUrl: string | URL): string;
231
+ /**
232
+ * Debug method to show which cookies would be sent for a given URL.
233
+ * Useful for troubleshooting cookie matching issues.
234
+ *
235
+ * @param requestUrl - The full request URL including path
236
+ * @returns Object with matching cookies and the Cookie header that would be sent
237
+ */
238
+ debugCookiesForRequest(requestUrl: string | URL): {
239
+ url: string;
240
+ matchingCookies: Array<{
241
+ key: string;
242
+ value: string;
243
+ domain: string;
244
+ path: string;
245
+ }>;
246
+ cookieHeader: string;
247
+ allCookies: Array<{
248
+ key: string;
249
+ domain: string;
250
+ path: string;
251
+ }>;
252
+ };
208
253
  setCookiesSync(setCookieArray: string[]): Cookies;
209
254
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
210
255
  setCookiesSync(cookiesString: string): Cookies;
@@ -205,6 +205,51 @@ export declare class RezoCookieJar extends TouchCookieJar {
205
205
  toArray(): Cookie[];
206
206
  toSetCookies(): string[];
207
207
  toSerializedCookies(): SerializedCookie[];
208
+ /**
209
+ * Get cookies for a request URL with proper browser-like matching.
210
+ * This method properly handles:
211
+ * - Domain matching (exact or parent domain)
212
+ * - Path matching (cookie path must be prefix of request path)
213
+ * - Secure flag (secure cookies only over HTTPS)
214
+ * - Expiry (expired cookies not returned)
215
+ *
216
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
217
+ * @returns Array of Cookie objects that should be sent with the request
218
+ */
219
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
220
+ /**
221
+ * Get the Cookie header value for a request URL with proper browser-like matching.
222
+ * Returns cookies in the format: "key1=value1; key2=value2"
223
+ *
224
+ * This is the browser-accurate way to build the Cookie header, properly filtering
225
+ * cookies by domain, path, secure flag, and expiry.
226
+ *
227
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
228
+ * @returns Cookie header string in "key=value; key=value" format
229
+ */
230
+ getCookieHeader(requestUrl: string | URL): string;
231
+ /**
232
+ * Debug method to show which cookies would be sent for a given URL.
233
+ * Useful for troubleshooting cookie matching issues.
234
+ *
235
+ * @param requestUrl - The full request URL including path
236
+ * @returns Object with matching cookies and the Cookie header that would be sent
237
+ */
238
+ debugCookiesForRequest(requestUrl: string | URL): {
239
+ url: string;
240
+ matchingCookies: Array<{
241
+ key: string;
242
+ value: string;
243
+ domain: string;
244
+ path: string;
245
+ }>;
246
+ cookieHeader: string;
247
+ allCookies: Array<{
248
+ key: string;
249
+ domain: string;
250
+ path: string;
251
+ }>;
252
+ };
208
253
  setCookiesSync(setCookieArray: string[]): Cookies;
209
254
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
210
255
  setCookiesSync(cookiesString: string): Cookies;
@@ -205,6 +205,51 @@ export declare class RezoCookieJar extends TouchCookieJar {
205
205
  toArray(): Cookie[];
206
206
  toSetCookies(): string[];
207
207
  toSerializedCookies(): SerializedCookie[];
208
+ /**
209
+ * Get cookies for a request URL with proper browser-like matching.
210
+ * This method properly handles:
211
+ * - Domain matching (exact or parent domain)
212
+ * - Path matching (cookie path must be prefix of request path)
213
+ * - Secure flag (secure cookies only over HTTPS)
214
+ * - Expiry (expired cookies not returned)
215
+ *
216
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
217
+ * @returns Array of Cookie objects that should be sent with the request
218
+ */
219
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
220
+ /**
221
+ * Get the Cookie header value for a request URL with proper browser-like matching.
222
+ * Returns cookies in the format: "key1=value1; key2=value2"
223
+ *
224
+ * This is the browser-accurate way to build the Cookie header, properly filtering
225
+ * cookies by domain, path, secure flag, and expiry.
226
+ *
227
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
228
+ * @returns Cookie header string in "key=value; key=value" format
229
+ */
230
+ getCookieHeader(requestUrl: string | URL): string;
231
+ /**
232
+ * Debug method to show which cookies would be sent for a given URL.
233
+ * Useful for troubleshooting cookie matching issues.
234
+ *
235
+ * @param requestUrl - The full request URL including path
236
+ * @returns Object with matching cookies and the Cookie header that would be sent
237
+ */
238
+ debugCookiesForRequest(requestUrl: string | URL): {
239
+ url: string;
240
+ matchingCookies: Array<{
241
+ key: string;
242
+ value: string;
243
+ domain: string;
244
+ path: string;
245
+ }>;
246
+ cookieHeader: string;
247
+ allCookies: Array<{
248
+ key: string;
249
+ domain: string;
250
+ path: string;
251
+ }>;
252
+ };
208
253
  setCookiesSync(setCookieArray: string[]): Cookies;
209
254
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
210
255
  setCookiesSync(cookiesString: string): Cookies;
@@ -205,6 +205,51 @@ export declare class RezoCookieJar extends TouchCookieJar {
205
205
  toArray(): Cookie[];
206
206
  toSetCookies(): string[];
207
207
  toSerializedCookies(): SerializedCookie[];
208
+ /**
209
+ * Get cookies for a request URL with proper browser-like matching.
210
+ * This method properly handles:
211
+ * - Domain matching (exact or parent domain)
212
+ * - Path matching (cookie path must be prefix of request path)
213
+ * - Secure flag (secure cookies only over HTTPS)
214
+ * - Expiry (expired cookies not returned)
215
+ *
216
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
217
+ * @returns Array of Cookie objects that should be sent with the request
218
+ */
219
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
220
+ /**
221
+ * Get the Cookie header value for a request URL with proper browser-like matching.
222
+ * Returns cookies in the format: "key1=value1; key2=value2"
223
+ *
224
+ * This is the browser-accurate way to build the Cookie header, properly filtering
225
+ * cookies by domain, path, secure flag, and expiry.
226
+ *
227
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
228
+ * @returns Cookie header string in "key=value; key=value" format
229
+ */
230
+ getCookieHeader(requestUrl: string | URL): string;
231
+ /**
232
+ * Debug method to show which cookies would be sent for a given URL.
233
+ * Useful for troubleshooting cookie matching issues.
234
+ *
235
+ * @param requestUrl - The full request URL including path
236
+ * @returns Object with matching cookies and the Cookie header that would be sent
237
+ */
238
+ debugCookiesForRequest(requestUrl: string | URL): {
239
+ url: string;
240
+ matchingCookies: Array<{
241
+ key: string;
242
+ value: string;
243
+ domain: string;
244
+ path: string;
245
+ }>;
246
+ cookieHeader: string;
247
+ allCookies: Array<{
248
+ key: string;
249
+ domain: string;
250
+ path: string;
251
+ }>;
252
+ };
208
253
  setCookiesSync(setCookieArray: string[]): Cookies;
209
254
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
210
255
  setCookiesSync(cookiesString: string): Cookies;
@@ -205,6 +205,51 @@ export declare class RezoCookieJar extends TouchCookieJar {
205
205
  toArray(): Cookie[];
206
206
  toSetCookies(): string[];
207
207
  toSerializedCookies(): SerializedCookie[];
208
+ /**
209
+ * Get cookies for a request URL with proper browser-like matching.
210
+ * This method properly handles:
211
+ * - Domain matching (exact or parent domain)
212
+ * - Path matching (cookie path must be prefix of request path)
213
+ * - Secure flag (secure cookies only over HTTPS)
214
+ * - Expiry (expired cookies not returned)
215
+ *
216
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
217
+ * @returns Array of Cookie objects that should be sent with the request
218
+ */
219
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
220
+ /**
221
+ * Get the Cookie header value for a request URL with proper browser-like matching.
222
+ * Returns cookies in the format: "key1=value1; key2=value2"
223
+ *
224
+ * This is the browser-accurate way to build the Cookie header, properly filtering
225
+ * cookies by domain, path, secure flag, and expiry.
226
+ *
227
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
228
+ * @returns Cookie header string in "key=value; key=value" format
229
+ */
230
+ getCookieHeader(requestUrl: string | URL): string;
231
+ /**
232
+ * Debug method to show which cookies would be sent for a given URL.
233
+ * Useful for troubleshooting cookie matching issues.
234
+ *
235
+ * @param requestUrl - The full request URL including path
236
+ * @returns Object with matching cookies and the Cookie header that would be sent
237
+ */
238
+ debugCookiesForRequest(requestUrl: string | URL): {
239
+ url: string;
240
+ matchingCookies: Array<{
241
+ key: string;
242
+ value: string;
243
+ domain: string;
244
+ path: string;
245
+ }>;
246
+ cookieHeader: string;
247
+ allCookies: Array<{
248
+ key: string;
249
+ domain: string;
250
+ path: string;
251
+ }>;
252
+ };
208
253
  setCookiesSync(setCookieArray: string[]): Cookies;
209
254
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
210
255
  setCookiesSync(cookiesString: string): Cookies;
@@ -183,7 +183,7 @@ async function parseCookiesFromHeaders(headers, url, config) {
183
183
  } else {
184
184
  acceptedCookies.push(...parsedCookies.array);
185
185
  }
186
- const acceptedCookieStrings = acceptedCookies.map((c) => c.cookieString());
186
+ const acceptedCookieStrings = acceptedCookies.map((c) => c.toSetCookieString());
187
187
  const jar = new RezoCookieJar;
188
188
  jar.setCookiesSync(acceptedCookieStrings, url);
189
189
  if (config?.enableCookieJar && config?.cookieJar) {
@@ -183,7 +183,7 @@ async function parseCookiesFromHeaders(headers, url, config) {
183
183
  } else {
184
184
  acceptedCookies.push(...parsedCookies.array);
185
185
  }
186
- const acceptedCookieStrings = acceptedCookies.map((c) => c.cookieString());
186
+ const acceptedCookieStrings = acceptedCookies.map((c) => c.toSetCookieString());
187
187
  const jar = new RezoCookieJar;
188
188
  jar.setCookiesSync(acceptedCookieStrings, url);
189
189
  if (config?.enableCookieJar && config?.cookieJar) {
@@ -134,6 +134,10 @@ function getResponseCache(option) {
134
134
  let cache = responseCacheInstances.get(key);
135
135
  if (!cache) {
136
136
  cache = new ResponseCache(option);
137
+ const existing = responseCacheInstances.get(key);
138
+ if (existing) {
139
+ return existing;
140
+ }
137
141
  responseCacheInstances.set(key, cache);
138
142
  }
139
143
  return cache;
@@ -981,7 +985,8 @@ async function request(config, fetchOptions, requestCount, timing, _stats, respo
981
985
  config.security.validationResults = {
982
986
  certificateValid: !cert.fingerprint?.includes("error"),
983
987
  hostnameMatch: cert.subject?.CN === url.hostname,
984
- chainValid: true
988
+ chainValid: socket.authorized === true,
989
+ authorizationError: socket.authorizationError || null
985
990
  };
986
991
  if (config.hooks?.onTls && config.hooks.onTls.length > 0) {
987
992
  for (const hook of config.hooks.onTls) {
@@ -1207,7 +1212,7 @@ function buildHTTPOptions(fetchOptions, isSecure, url) {
1207
1212
  keepAliveMsecs: keepAlive ? keepAliveMsecs : undefined
1208
1213
  }) : undefined;
1209
1214
  const customAgent = url.protocol === "https:" && httpsAgent ? httpsAgent : httpAgent ? httpAgent : undefined;
1210
- const agent = parseProxy(proxy) || customAgent || secureContext;
1215
+ const agent = parseProxy(proxy, isSecure, rejectUnauthorized) || customAgent || secureContext;
1211
1216
  let lookup;
1212
1217
  if (dnsCacheOption) {
1213
1218
  if (!dnsCache) {
@@ -1477,7 +1482,7 @@ async function updateCookies(config, headers, url) {
1477
1482
  } else {
1478
1483
  acceptedCookies.push(...parsedCookies.array);
1479
1484
  }
1480
- const acceptedCookieStrings = acceptedCookies.map((c) => c.cookieString());
1485
+ const acceptedCookieStrings = acceptedCookies.map((c) => c.toSetCookieString());
1481
1486
  if (config.enableCookieJar && config.cookieJar) {
1482
1487
  config.cookieJar.setCookiesSync(acceptedCookieStrings, url);
1483
1488
  }
@@ -134,6 +134,10 @@ function getResponseCache(option) {
134
134
  let cache = responseCacheInstances.get(key);
135
135
  if (!cache) {
136
136
  cache = new ResponseCache(option);
137
+ const existing = responseCacheInstances.get(key);
138
+ if (existing) {
139
+ return existing;
140
+ }
137
141
  responseCacheInstances.set(key, cache);
138
142
  }
139
143
  return cache;
@@ -981,7 +985,8 @@ async function request(config, fetchOptions, requestCount, timing, _stats, respo
981
985
  config.security.validationResults = {
982
986
  certificateValid: !cert.fingerprint?.includes("error"),
983
987
  hostnameMatch: cert.subject?.CN === url.hostname,
984
- chainValid: true
988
+ chainValid: socket.authorized === true,
989
+ authorizationError: socket.authorizationError || null
985
990
  };
986
991
  if (config.hooks?.onTls && config.hooks.onTls.length > 0) {
987
992
  for (const hook of config.hooks.onTls) {
@@ -1207,7 +1212,7 @@ function buildHTTPOptions(fetchOptions, isSecure, url) {
1207
1212
  keepAliveMsecs: keepAlive ? keepAliveMsecs : undefined
1208
1213
  }) : undefined;
1209
1214
  const customAgent = url.protocol === "https:" && httpsAgent ? httpsAgent : httpAgent ? httpAgent : undefined;
1210
- const agent = parseProxy(proxy) || customAgent || secureContext;
1215
+ const agent = parseProxy(proxy, isSecure, rejectUnauthorized) || customAgent || secureContext;
1211
1216
  let lookup;
1212
1217
  if (dnsCacheOption) {
1213
1218
  if (!dnsCache) {
@@ -1477,7 +1482,7 @@ async function updateCookies(config, headers, url) {
1477
1482
  } else {
1478
1483
  acceptedCookies.push(...parsedCookies.array);
1479
1484
  }
1480
- const acceptedCookieStrings = acceptedCookies.map((c) => c.cookieString());
1485
+ const acceptedCookieStrings = acceptedCookies.map((c) => c.toSetCookieString());
1481
1486
  if (config.enableCookieJar && config.cookieJar) {
1482
1487
  config.cookieJar.setCookiesSync(acceptedCookieStrings, url);
1483
1488
  }
@@ -341,7 +341,7 @@ async function updateCookies(config, headers, url) {
341
341
  } else {
342
342
  acceptedCookies.push(...parsedCookies.array);
343
343
  }
344
- const acceptedCookieStrings = acceptedCookies.map((c) => c.cookieString());
344
+ const acceptedCookieStrings = acceptedCookies.map((c) => c.toSetCookieString());
345
345
  const jar = new RezoCookieJar;
346
346
  jar.setCookiesSync(acceptedCookieStrings, url);
347
347
  if (config.enableCookieJar && config.cookieJar) {
@@ -341,7 +341,7 @@ async function updateCookies(config, headers, url) {
341
341
  } else {
342
342
  acceptedCookies.push(...parsedCookies.array);
343
343
  }
344
- const acceptedCookieStrings = acceptedCookies.map((c) => c.cookieString());
344
+ const acceptedCookieStrings = acceptedCookies.map((c) => c.toSetCookieString());
345
345
  const jar = new RezoCookieJar;
346
346
  jar.setCookiesSync(acceptedCookieStrings, url);
347
347
  if (config.enableCookieJar && config.cookieJar) {
@@ -1,6 +1,6 @@
1
- const _mod_8vsbsk = require('./picker.cjs');
2
- exports.detectRuntime = _mod_8vsbsk.detectRuntime;
3
- exports.getAdapterCapabilities = _mod_8vsbsk.getAdapterCapabilities;
4
- exports.buildAdapterContext = _mod_8vsbsk.buildAdapterContext;
5
- exports.getAvailableAdapters = _mod_8vsbsk.getAvailableAdapters;
6
- exports.selectAdapter = _mod_8vsbsk.selectAdapter;;
1
+ const _mod_c82agb = require('./picker.cjs');
2
+ exports.detectRuntime = _mod_c82agb.detectRuntime;
3
+ exports.getAdapterCapabilities = _mod_c82agb.getAdapterCapabilities;
4
+ exports.buildAdapterContext = _mod_c82agb.buildAdapterContext;
5
+ exports.getAvailableAdapters = _mod_c82agb.getAvailableAdapters;
6
+ exports.selectAdapter = _mod_c82agb.selectAdapter;;
@@ -1,13 +1,13 @@
1
- const _mod_3nlvak = require('./lru-cache.cjs');
2
- exports.LRUCache = _mod_3nlvak.LRUCache;;
3
- const _mod_jjdx5e = require('./dns-cache.cjs');
4
- exports.DNSCache = _mod_jjdx5e.DNSCache;
5
- exports.getGlobalDNSCache = _mod_jjdx5e.getGlobalDNSCache;
6
- exports.resetGlobalDNSCache = _mod_jjdx5e.resetGlobalDNSCache;;
7
- const _mod_6grfwd = require('./response-cache.cjs');
8
- exports.ResponseCache = _mod_6grfwd.ResponseCache;
9
- exports.normalizeResponseCacheConfig = _mod_6grfwd.normalizeResponseCacheConfig;;
10
- const _mod_ietsvu = require('./file-cacher.cjs');
11
- exports.FileCacher = _mod_ietsvu.FileCacher;;
12
- const _mod_o14hsh = require('./url-store.cjs');
13
- exports.UrlStore = _mod_o14hsh.UrlStore;;
1
+ const _mod_wg0295 = require('./lru-cache.cjs');
2
+ exports.LRUCache = _mod_wg0295.LRUCache;;
3
+ const _mod_udgn2v = require('./dns-cache.cjs');
4
+ exports.DNSCache = _mod_udgn2v.DNSCache;
5
+ exports.getGlobalDNSCache = _mod_udgn2v.getGlobalDNSCache;
6
+ exports.resetGlobalDNSCache = _mod_udgn2v.resetGlobalDNSCache;;
7
+ const _mod_6kolan = require('./response-cache.cjs');
8
+ exports.ResponseCache = _mod_6kolan.ResponseCache;
9
+ exports.normalizeResponseCacheConfig = _mod_6kolan.normalizeResponseCacheConfig;;
10
+ const _mod_pl3tv0 = require('./file-cacher.cjs');
11
+ exports.FileCacher = _mod_pl3tv0.FileCacher;;
12
+ const _mod_zya6gr = require('./url-store.cjs');
13
+ exports.UrlStore = _mod_zya6gr.UrlStore;;
package/dist/crawler.d.ts CHANGED
@@ -428,6 +428,51 @@ declare class RezoCookieJar extends TouchCookieJar {
428
428
  toArray(): Cookie[];
429
429
  toSetCookies(): string[];
430
430
  toSerializedCookies(): SerializedCookie[];
431
+ /**
432
+ * Get cookies for a request URL with proper browser-like matching.
433
+ * This method properly handles:
434
+ * - Domain matching (exact or parent domain)
435
+ * - Path matching (cookie path must be prefix of request path)
436
+ * - Secure flag (secure cookies only over HTTPS)
437
+ * - Expiry (expired cookies not returned)
438
+ *
439
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
440
+ * @returns Array of Cookie objects that should be sent with the request
441
+ */
442
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
443
+ /**
444
+ * Get the Cookie header value for a request URL with proper browser-like matching.
445
+ * Returns cookies in the format: "key1=value1; key2=value2"
446
+ *
447
+ * This is the browser-accurate way to build the Cookie header, properly filtering
448
+ * cookies by domain, path, secure flag, and expiry.
449
+ *
450
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
451
+ * @returns Cookie header string in "key=value; key=value" format
452
+ */
453
+ getCookieHeader(requestUrl: string | URL): string;
454
+ /**
455
+ * Debug method to show which cookies would be sent for a given URL.
456
+ * Useful for troubleshooting cookie matching issues.
457
+ *
458
+ * @param requestUrl - The full request URL including path
459
+ * @returns Object with matching cookies and the Cookie header that would be sent
460
+ */
461
+ debugCookiesForRequest(requestUrl: string | URL): {
462
+ url: string;
463
+ matchingCookies: Array<{
464
+ key: string;
465
+ value: string;
466
+ domain: string;
467
+ path: string;
468
+ }>;
469
+ cookieHeader: string;
470
+ allCookies: Array<{
471
+ key: string;
472
+ domain: string;
473
+ path: string;
474
+ }>;
475
+ };
431
476
  setCookiesSync(setCookieArray: string[]): Cookies;
432
477
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
433
478
  setCookiesSync(cookiesString: string): Cookies;
@@ -1,5 +1,5 @@
1
- const _mod_n2jqd1 = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_n2jqd1.Crawler;;
3
- const _mod_wyfomf = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_wyfomf.CrawlerOptions;
5
- exports.Domain = _mod_wyfomf.Domain;;
1
+ const _mod_lymkfq = require('../plugin/crawler.cjs');
2
+ exports.Crawler = _mod_lymkfq.Crawler;;
3
+ const _mod_kvs0ei = require('../plugin/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_kvs0ei.CrawlerOptions;
5
+ exports.Domain = _mod_kvs0ei.Domain;;
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
- const _mod_c5wnbk = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_c5wnbk.Rezo;
3
- exports.createRezoInstance = _mod_c5wnbk.createRezoInstance;
4
- exports.createDefaultInstance = _mod_c5wnbk.createDefaultInstance;;
5
- const _mod_vk9phy = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_vk9phy.RezoError;
7
- exports.RezoErrorCode = _mod_vk9phy.RezoErrorCode;;
8
- const _mod_smhm1d = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_smhm1d.RezoHeaders;;
10
- const _mod_umbtma = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_umbtma.RezoFormData;;
12
- const _mod_s4d2mf = require('./utils/cookies.cjs');
13
- exports.RezoCookieJar = _mod_s4d2mf.RezoCookieJar;
14
- exports.Cookie = _mod_s4d2mf.Cookie;;
15
- const _mod_lqyqqc = require('./core/hooks.cjs');
16
- exports.createDefaultHooks = _mod_lqyqqc.createDefaultHooks;
17
- exports.mergeHooks = _mod_lqyqqc.mergeHooks;;
18
- const _mod_9k2fte = require('./proxy/manager.cjs');
19
- exports.ProxyManager = _mod_9k2fte.ProxyManager;;
20
- const _mod_dw7oqs = require('./queue/index.cjs');
21
- exports.RezoQueue = _mod_dw7oqs.RezoQueue;
22
- exports.HttpQueue = _mod_dw7oqs.HttpQueue;
23
- exports.Priority = _mod_dw7oqs.Priority;
24
- exports.HttpMethodPriority = _mod_dw7oqs.HttpMethodPriority;;
1
+ const _mod_lyypom = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_lyypom.Rezo;
3
+ exports.createRezoInstance = _mod_lyypom.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_lyypom.createDefaultInstance;;
5
+ const _mod_z2q5wr = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_z2q5wr.RezoError;
7
+ exports.RezoErrorCode = _mod_z2q5wr.RezoErrorCode;;
8
+ const _mod_qyu99x = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_qyu99x.RezoHeaders;;
10
+ const _mod_z17ic3 = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_z17ic3.RezoFormData;;
12
+ const _mod_2sml8j = require('./utils/cookies.cjs');
13
+ exports.RezoCookieJar = _mod_2sml8j.RezoCookieJar;
14
+ exports.Cookie = _mod_2sml8j.Cookie;;
15
+ const _mod_vuhwqj = require('./core/hooks.cjs');
16
+ exports.createDefaultHooks = _mod_vuhwqj.createDefaultHooks;
17
+ exports.mergeHooks = _mod_vuhwqj.mergeHooks;;
18
+ const _mod_srexi8 = require('./proxy/manager.cjs');
19
+ exports.ProxyManager = _mod_srexi8.ProxyManager;;
20
+ const _mod_p29w3c = require('./queue/index.cjs');
21
+ exports.RezoQueue = _mod_p29w3c.RezoQueue;
22
+ exports.HttpQueue = _mod_p29w3c.HttpQueue;
23
+ exports.Priority = _mod_p29w3c.Priority;
24
+ exports.HttpMethodPriority = _mod_p29w3c.HttpMethodPriority;;
25
25
  const { RezoError } = require('./errors/rezo-error.cjs');
26
26
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
27
27
  const Cancel = exports.Cancel = RezoError;
package/dist/index.d.ts CHANGED
@@ -205,6 +205,51 @@ export declare class RezoCookieJar extends TouchCookieJar {
205
205
  toArray(): Cookie[];
206
206
  toSetCookies(): string[];
207
207
  toSerializedCookies(): SerializedCookie[];
208
+ /**
209
+ * Get cookies for a request URL with proper browser-like matching.
210
+ * This method properly handles:
211
+ * - Domain matching (exact or parent domain)
212
+ * - Path matching (cookie path must be prefix of request path)
213
+ * - Secure flag (secure cookies only over HTTPS)
214
+ * - Expiry (expired cookies not returned)
215
+ *
216
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
217
+ * @returns Array of Cookie objects that should be sent with the request
218
+ */
219
+ getCookiesForRequest(requestUrl: string | URL): Cookie[];
220
+ /**
221
+ * Get the Cookie header value for a request URL with proper browser-like matching.
222
+ * Returns cookies in the format: "key1=value1; key2=value2"
223
+ *
224
+ * This is the browser-accurate way to build the Cookie header, properly filtering
225
+ * cookies by domain, path, secure flag, and expiry.
226
+ *
227
+ * @param requestUrl - The full request URL including path (e.g., 'https://example.com/api/users')
228
+ * @returns Cookie header string in "key=value; key=value" format
229
+ */
230
+ getCookieHeader(requestUrl: string | URL): string;
231
+ /**
232
+ * Debug method to show which cookies would be sent for a given URL.
233
+ * Useful for troubleshooting cookie matching issues.
234
+ *
235
+ * @param requestUrl - The full request URL including path
236
+ * @returns Object with matching cookies and the Cookie header that would be sent
237
+ */
238
+ debugCookiesForRequest(requestUrl: string | URL): {
239
+ url: string;
240
+ matchingCookies: Array<{
241
+ key: string;
242
+ value: string;
243
+ domain: string;
244
+ path: string;
245
+ }>;
246
+ cookieHeader: string;
247
+ allCookies: Array<{
248
+ key: string;
249
+ domain: string;
250
+ path: string;
251
+ }>;
252
+ };
208
253
  setCookiesSync(setCookieArray: string[]): Cookies;
209
254
  setCookiesSync(setCookieArray: string[], url: string): Cookies;
210
255
  setCookiesSync(cookiesString: string): Cookies;