rezo 1.0.7 → 1.0.9

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 (51) hide show
  1. package/dist/adapters/entries/curl.cjs +2 -1
  2. package/dist/adapters/entries/curl.d.ts +100 -1
  3. package/dist/adapters/entries/curl.js +2 -2
  4. package/dist/adapters/entries/fetch.cjs +2 -1
  5. package/dist/adapters/entries/fetch.d.ts +100 -1
  6. package/dist/adapters/entries/fetch.js +2 -2
  7. package/dist/adapters/entries/http.cjs +2 -1
  8. package/dist/adapters/entries/http.d.ts +100 -1
  9. package/dist/adapters/entries/http.js +2 -1
  10. package/dist/adapters/entries/http2.cjs +2 -1
  11. package/dist/adapters/entries/http2.d.ts +100 -1
  12. package/dist/adapters/entries/http2.js +2 -2
  13. package/dist/adapters/entries/react-native.cjs +2 -1
  14. package/dist/adapters/entries/react-native.d.ts +100 -1
  15. package/dist/adapters/entries/react-native.js +2 -2
  16. package/dist/adapters/entries/xhr.cjs +2 -1
  17. package/dist/adapters/entries/xhr.d.ts +100 -1
  18. package/dist/adapters/entries/xhr.js +2 -2
  19. package/dist/adapters/index.cjs +6 -6
  20. package/dist/cache/index.cjs +13 -13
  21. package/dist/core/rezo.cjs +8 -0
  22. package/dist/core/rezo.js +8 -0
  23. package/dist/crawler.d.ts +99 -0
  24. package/dist/entries/crawler.cjs +5 -5
  25. package/dist/index.cjs +24 -23
  26. package/dist/index.d.ts +100 -1
  27. package/dist/index.js +1 -1
  28. package/dist/platform/browser.cjs +2 -1
  29. package/dist/platform/browser.d.ts +100 -1
  30. package/dist/platform/browser.js +2 -2
  31. package/dist/platform/bun.cjs +2 -1
  32. package/dist/platform/bun.d.ts +100 -1
  33. package/dist/platform/bun.js +2 -2
  34. package/dist/platform/deno.cjs +2 -1
  35. package/dist/platform/deno.d.ts +100 -1
  36. package/dist/platform/deno.js +2 -2
  37. package/dist/platform/node.cjs +2 -1
  38. package/dist/platform/node.d.ts +100 -1
  39. package/dist/platform/node.js +2 -2
  40. package/dist/platform/react-native.cjs +2 -1
  41. package/dist/platform/react-native.d.ts +100 -1
  42. package/dist/platform/react-native.js +2 -2
  43. package/dist/platform/worker.cjs +2 -1
  44. package/dist/platform/worker.d.ts +100 -1
  45. package/dist/platform/worker.js +2 -2
  46. package/dist/plugin/index.cjs +36 -36
  47. package/dist/proxy/index.cjs +2 -2
  48. package/dist/queue/index.cjs +8 -8
  49. package/dist/utils/cookies.cjs +0 -2
  50. package/dist/utils/cookies.js +0 -2
  51. package/package.json +1 -1
@@ -156,7 +156,7 @@ export interface SerializedCookie {
156
156
  lastAccessed?: string;
157
157
  [key: string]: unknown;
158
158
  }
159
- declare class Cookie extends TouchCookie {
159
+ export declare class Cookie extends TouchCookie {
160
160
  constructor(options?: CreateCookieOptions);
161
161
  /**
162
162
  * Fixes date fields that may have become strings during JSON deserialization.
@@ -4162,6 +4162,105 @@ export declare class Rezo {
4162
4162
  * ```
4163
4163
  */
4164
4164
  upload(url: string | URL, data: Buffer | FormData | RezoFormData | string | Record<string, any>, options?: RezoHttpRequest): RezoUploadResponse;
4165
+ /**
4166
+ * Set cookies in the cookie jar from various input formats.
4167
+ *
4168
+ * This method accepts multiple input formats for maximum flexibility:
4169
+ * - **Netscape cookie file content** (string): Full cookie file content in Netscape format
4170
+ * - **Set-Cookie header array** (string[]): Array of Set-Cookie header values
4171
+ * - **Serialized cookie objects** (SerializedCookie[]): Array of plain objects with cookie properties
4172
+ * - **Cookie instances** (Cookie[]): Array of Cookie class instances
4173
+ *
4174
+ * @param cookies - Cookies to set in one of the supported formats
4175
+ * @param url - Optional URL context for the cookies (used for domain/path inference)
4176
+ * @param startNew - If true, clears all existing cookies before setting new ones (default: false)
4177
+ *
4178
+ * @example
4179
+ * ```typescript
4180
+ * // From Netscape cookie file content
4181
+ * const netscapeContent = `# Netscape HTTP Cookie File
4182
+ * .example.com\tTRUE\t/\tFALSE\t0\tsession\tabc123`;
4183
+ * rezo.setCookies(netscapeContent);
4184
+ *
4185
+ * // From Set-Cookie header array
4186
+ * rezo.setCookies([
4187
+ * 'session=abc123; Domain=example.com; Path=/; HttpOnly',
4188
+ * 'user=john; Domain=example.com; Path=/; Max-Age=3600'
4189
+ * ], 'https://example.com');
4190
+ *
4191
+ * // From serialized cookie objects
4192
+ * rezo.setCookies([
4193
+ * { key: 'session', value: 'abc123', domain: 'example.com', path: '/' },
4194
+ * { key: 'user', value: 'john', domain: 'example.com', path: '/', maxAge: 3600 }
4195
+ * ]);
4196
+ *
4197
+ * // From Cookie instances
4198
+ * import { Cookie } from 'rezo';
4199
+ * const cookie = new Cookie({ key: 'token', value: 'xyz789', domain: 'api.example.com' });
4200
+ * rezo.setCookies([cookie]);
4201
+ *
4202
+ * // Replace all cookies (startNew = true)
4203
+ * rezo.setCookies([{ key: 'new', value: 'cookie' }], undefined, true);
4204
+ * ```
4205
+ *
4206
+ * @see {@link getCookies} - Retrieve cookies from the jar
4207
+ * @see {@link RezoCookieJar} - The underlying cookie jar class
4208
+ */
4209
+ setCookies(stringCookies: string): void;
4210
+ setCookies(stringCookies: string, url: string, startNew?: boolean): void;
4211
+ setCookies(serializedStringCookiesCookies: string, url: string | undefined, startNew: boolean): void;
4212
+ setCookies(serializedCookies: SerializedCookie[]): void;
4213
+ setCookies(serializedCookies: SerializedCookie[], url: string, startNew?: boolean): void;
4214
+ setCookies(serializedCookies: SerializedCookie[], url: string | undefined, startNew: boolean): void;
4215
+ setCookies(cookies: Cookie[]): void;
4216
+ setCookies(cookies: Cookie[], url: string, startNew?: boolean): void;
4217
+ setCookies(cookies: Cookie[], url: string | undefined, startNew: boolean): void;
4218
+ setCookies(setCookieArray: string[]): void;
4219
+ setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4220
+ setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4221
+ /**
4222
+ * Get all cookies from the cookie jar.
4223
+ *
4224
+ * Returns a `Cookies` object where keys are domain names and values are
4225
+ * arrays of Cookie objects for that domain. This provides easy access to
4226
+ * all stored cookies for inspection, serialization, or manual manipulation.
4227
+ *
4228
+ * @returns A Cookies object mapping domains to their Cookie arrays
4229
+ *
4230
+ * @example
4231
+ * ```typescript
4232
+ * // Get all cookies
4233
+ * const cookies = rezo.getCookies();
4234
+ *
4235
+ * // Access cookies for a specific domain
4236
+ * const exampleCookies = cookies['example.com'];
4237
+ * if (exampleCookies) {
4238
+ * for (const cookie of exampleCookies) {
4239
+ * console.log(`${cookie.key}=${cookie.value}`);
4240
+ * }
4241
+ * }
4242
+ *
4243
+ * // List all domains with cookies
4244
+ * const domains = Object.keys(cookies);
4245
+ * console.log('Cookies stored for:', domains);
4246
+ *
4247
+ * // Count total cookies
4248
+ * const totalCookies = Object.values(cookies)
4249
+ * .reduce((sum, arr) => sum + arr.length, 0);
4250
+ * console.log(`Total cookies: ${totalCookies}`);
4251
+ *
4252
+ * // Serialize all cookies to JSON
4253
+ * const serialized = JSON.stringify(cookies);
4254
+ *
4255
+ * // Check if a specific cookie exists
4256
+ * const hasSession = cookies['example.com']
4257
+ * ?.some(c => c.key === 'session');
4258
+ * ```
4259
+ *
4260
+ * @see {@link setCookies} - Set cookies in the jar
4261
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4262
+ */
4263
+ getCookies(): Cookies;
4165
4264
  }
4166
4265
  /**
4167
4266
  * Extended Rezo instance with Axios-compatible static helpers.
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
3
3
  import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
4
4
  import { RezoHeaders } from '../../utils/headers.js';
5
5
  import { RezoFormData } from '../../utils/form-data.js';
6
- import { RezoCookieJar } from '../../utils/cookies.js';
6
+ import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
7
7
  import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
8
8
  import packageJson from "../../../package.json" with { type: 'json' };
9
9
 
@@ -12,7 +12,7 @@ export { RezoError };
12
12
  export { RezoErrorCode };
13
13
  export { RezoHeaders };
14
14
  export { RezoFormData };
15
- export { RezoCookieJar };
15
+ export { RezoCookieJar, Cookie };
16
16
  export { createDefaultHooks };
17
17
  export { mergeHooks };
18
18
  export const isRezoError = RezoError.isRezoError;
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
3
3
  const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
4
4
  const { RezoHeaders } = require('../../utils/headers.cjs');
5
5
  const { RezoFormData } = require('../../utils/form-data.cjs');
6
- const { RezoCookieJar } = require('../../utils/cookies.cjs');
6
+ const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
7
7
  const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
8
8
  const packageJson = require("../../../package.json");
9
9
 
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
13
13
  exports.RezoHeaders = RezoHeaders;
14
14
  exports.RezoFormData = RezoFormData;
15
15
  exports.RezoCookieJar = RezoCookieJar;
16
+ exports.Cookie = Cookie;
16
17
  exports.createDefaultHooks = createDefaultHooks;
17
18
  exports.mergeHooks = mergeHooks;
18
19
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
@@ -156,7 +156,7 @@ export interface SerializedCookie {
156
156
  lastAccessed?: string;
157
157
  [key: string]: unknown;
158
158
  }
159
- declare class Cookie extends TouchCookie {
159
+ export declare class Cookie extends TouchCookie {
160
160
  constructor(options?: CreateCookieOptions);
161
161
  /**
162
162
  * Fixes date fields that may have become strings during JSON deserialization.
@@ -4162,6 +4162,105 @@ export declare class Rezo {
4162
4162
  * ```
4163
4163
  */
4164
4164
  upload(url: string | URL, data: Buffer | FormData | RezoFormData | string | Record<string, any>, options?: RezoHttpRequest): RezoUploadResponse;
4165
+ /**
4166
+ * Set cookies in the cookie jar from various input formats.
4167
+ *
4168
+ * This method accepts multiple input formats for maximum flexibility:
4169
+ * - **Netscape cookie file content** (string): Full cookie file content in Netscape format
4170
+ * - **Set-Cookie header array** (string[]): Array of Set-Cookie header values
4171
+ * - **Serialized cookie objects** (SerializedCookie[]): Array of plain objects with cookie properties
4172
+ * - **Cookie instances** (Cookie[]): Array of Cookie class instances
4173
+ *
4174
+ * @param cookies - Cookies to set in one of the supported formats
4175
+ * @param url - Optional URL context for the cookies (used for domain/path inference)
4176
+ * @param startNew - If true, clears all existing cookies before setting new ones (default: false)
4177
+ *
4178
+ * @example
4179
+ * ```typescript
4180
+ * // From Netscape cookie file content
4181
+ * const netscapeContent = `# Netscape HTTP Cookie File
4182
+ * .example.com\tTRUE\t/\tFALSE\t0\tsession\tabc123`;
4183
+ * rezo.setCookies(netscapeContent);
4184
+ *
4185
+ * // From Set-Cookie header array
4186
+ * rezo.setCookies([
4187
+ * 'session=abc123; Domain=example.com; Path=/; HttpOnly',
4188
+ * 'user=john; Domain=example.com; Path=/; Max-Age=3600'
4189
+ * ], 'https://example.com');
4190
+ *
4191
+ * // From serialized cookie objects
4192
+ * rezo.setCookies([
4193
+ * { key: 'session', value: 'abc123', domain: 'example.com', path: '/' },
4194
+ * { key: 'user', value: 'john', domain: 'example.com', path: '/', maxAge: 3600 }
4195
+ * ]);
4196
+ *
4197
+ * // From Cookie instances
4198
+ * import { Cookie } from 'rezo';
4199
+ * const cookie = new Cookie({ key: 'token', value: 'xyz789', domain: 'api.example.com' });
4200
+ * rezo.setCookies([cookie]);
4201
+ *
4202
+ * // Replace all cookies (startNew = true)
4203
+ * rezo.setCookies([{ key: 'new', value: 'cookie' }], undefined, true);
4204
+ * ```
4205
+ *
4206
+ * @see {@link getCookies} - Retrieve cookies from the jar
4207
+ * @see {@link RezoCookieJar} - The underlying cookie jar class
4208
+ */
4209
+ setCookies(stringCookies: string): void;
4210
+ setCookies(stringCookies: string, url: string, startNew?: boolean): void;
4211
+ setCookies(serializedStringCookiesCookies: string, url: string | undefined, startNew: boolean): void;
4212
+ setCookies(serializedCookies: SerializedCookie[]): void;
4213
+ setCookies(serializedCookies: SerializedCookie[], url: string, startNew?: boolean): void;
4214
+ setCookies(serializedCookies: SerializedCookie[], url: string | undefined, startNew: boolean): void;
4215
+ setCookies(cookies: Cookie[]): void;
4216
+ setCookies(cookies: Cookie[], url: string, startNew?: boolean): void;
4217
+ setCookies(cookies: Cookie[], url: string | undefined, startNew: boolean): void;
4218
+ setCookies(setCookieArray: string[]): void;
4219
+ setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4220
+ setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4221
+ /**
4222
+ * Get all cookies from the cookie jar.
4223
+ *
4224
+ * Returns a `Cookies` object where keys are domain names and values are
4225
+ * arrays of Cookie objects for that domain. This provides easy access to
4226
+ * all stored cookies for inspection, serialization, or manual manipulation.
4227
+ *
4228
+ * @returns A Cookies object mapping domains to their Cookie arrays
4229
+ *
4230
+ * @example
4231
+ * ```typescript
4232
+ * // Get all cookies
4233
+ * const cookies = rezo.getCookies();
4234
+ *
4235
+ * // Access cookies for a specific domain
4236
+ * const exampleCookies = cookies['example.com'];
4237
+ * if (exampleCookies) {
4238
+ * for (const cookie of exampleCookies) {
4239
+ * console.log(`${cookie.key}=${cookie.value}`);
4240
+ * }
4241
+ * }
4242
+ *
4243
+ * // List all domains with cookies
4244
+ * const domains = Object.keys(cookies);
4245
+ * console.log('Cookies stored for:', domains);
4246
+ *
4247
+ * // Count total cookies
4248
+ * const totalCookies = Object.values(cookies)
4249
+ * .reduce((sum, arr) => sum + arr.length, 0);
4250
+ * console.log(`Total cookies: ${totalCookies}`);
4251
+ *
4252
+ * // Serialize all cookies to JSON
4253
+ * const serialized = JSON.stringify(cookies);
4254
+ *
4255
+ * // Check if a specific cookie exists
4256
+ * const hasSession = cookies['example.com']
4257
+ * ?.some(c => c.key === 'session');
4258
+ * ```
4259
+ *
4260
+ * @see {@link setCookies} - Set cookies in the jar
4261
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4262
+ */
4263
+ getCookies(): Cookies;
4165
4264
  }
4166
4265
  /**
4167
4266
  * Extended Rezo instance with Axios-compatible static helpers.
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
3
3
  import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
4
4
  import { RezoHeaders } from '../../utils/headers.js';
5
5
  import { RezoFormData } from '../../utils/form-data.js';
6
- import { RezoCookieJar } from '../../utils/cookies.js';
6
+ import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
7
7
  import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
8
8
  import packageJson from "../../../package.json" with { type: 'json' };
9
9
 
@@ -12,7 +12,7 @@ export { RezoError };
12
12
  export { RezoErrorCode };
13
13
  export { RezoHeaders };
14
14
  export { RezoFormData };
15
- export { RezoCookieJar };
15
+ export { RezoCookieJar, Cookie };
16
16
  export { createDefaultHooks };
17
17
  export { mergeHooks };
18
18
  export const isRezoError = RezoError.isRezoError;
@@ -1,6 +1,6 @@
1
- const _mod_1j8os6 = require('./picker.cjs');
2
- exports.detectRuntime = _mod_1j8os6.detectRuntime;
3
- exports.getAdapterCapabilities = _mod_1j8os6.getAdapterCapabilities;
4
- exports.buildAdapterContext = _mod_1j8os6.buildAdapterContext;
5
- exports.getAvailableAdapters = _mod_1j8os6.getAvailableAdapters;
6
- exports.selectAdapter = _mod_1j8os6.selectAdapter;;
1
+ const _mod_a49tp0 = require('./picker.cjs');
2
+ exports.detectRuntime = _mod_a49tp0.detectRuntime;
3
+ exports.getAdapterCapabilities = _mod_a49tp0.getAdapterCapabilities;
4
+ exports.buildAdapterContext = _mod_a49tp0.buildAdapterContext;
5
+ exports.getAvailableAdapters = _mod_a49tp0.getAvailableAdapters;
6
+ exports.selectAdapter = _mod_a49tp0.selectAdapter;;
@@ -1,13 +1,13 @@
1
- const _mod_5re24b = require('./lru-cache.cjs');
2
- exports.LRUCache = _mod_5re24b.LRUCache;;
3
- const _mod_nmlyd4 = require('./dns-cache.cjs');
4
- exports.DNSCache = _mod_nmlyd4.DNSCache;
5
- exports.getGlobalDNSCache = _mod_nmlyd4.getGlobalDNSCache;
6
- exports.resetGlobalDNSCache = _mod_nmlyd4.resetGlobalDNSCache;;
7
- const _mod_n1g00g = require('./response-cache.cjs');
8
- exports.ResponseCache = _mod_n1g00g.ResponseCache;
9
- exports.normalizeResponseCacheConfig = _mod_n1g00g.normalizeResponseCacheConfig;;
10
- const _mod_xmultr = require('./file-cacher.cjs');
11
- exports.FileCacher = _mod_xmultr.FileCacher;;
12
- const _mod_81d50n = require('./url-store.cjs');
13
- exports.UrlStore = _mod_81d50n.UrlStore;;
1
+ const _mod_jyz6s4 = require('./lru-cache.cjs');
2
+ exports.LRUCache = _mod_jyz6s4.LRUCache;;
3
+ const _mod_a0ftbg = require('./dns-cache.cjs');
4
+ exports.DNSCache = _mod_a0ftbg.DNSCache;
5
+ exports.getGlobalDNSCache = _mod_a0ftbg.getGlobalDNSCache;
6
+ exports.resetGlobalDNSCache = _mod_a0ftbg.resetGlobalDNSCache;;
7
+ const _mod_knf7z5 = require('./response-cache.cjs');
8
+ exports.ResponseCache = _mod_knf7z5.ResponseCache;
9
+ exports.normalizeResponseCacheConfig = _mod_knf7z5.normalizeResponseCacheConfig;;
10
+ const _mod_a13exp = require('./file-cacher.cjs');
11
+ exports.FileCacher = _mod_a13exp.FileCacher;;
12
+ const _mod_6bj6sb = require('./url-store.cjs');
13
+ exports.UrlStore = _mod_6bj6sb.UrlStore;;
@@ -396,6 +396,14 @@ class Rezo {
396
396
  _isUpload: true
397
397
  }, this.defaults, this.jar);
398
398
  }
399
+ setCookies(cookies, url, startNew) {
400
+ if (startNew)
401
+ this.jar.removeAllCookiesSync();
402
+ this.jar.setCookiesSync(cookies, url);
403
+ }
404
+ getCookies() {
405
+ return this.jar.cookies();
406
+ }
399
407
  }
400
408
  const defaultTransforms = exports.defaultTransforms = {
401
409
  request: [
package/dist/core/rezo.js CHANGED
@@ -396,6 +396,14 @@ export class Rezo {
396
396
  _isUpload: true
397
397
  }, this.defaults, this.jar);
398
398
  }
399
+ setCookies(cookies, url, startNew) {
400
+ if (startNew)
401
+ this.jar.removeAllCookiesSync();
402
+ this.jar.setCookiesSync(cookies, url);
403
+ }
404
+ getCookies() {
405
+ return this.jar.cookies();
406
+ }
399
407
  }
400
408
  export const defaultTransforms = {
401
409
  request: [
package/dist/crawler.d.ts CHANGED
@@ -4277,6 +4277,105 @@ declare class Rezo {
4277
4277
  * ```
4278
4278
  */
4279
4279
  upload(url: string | URL, data: Buffer | FormData | RezoFormData | string | Record<string, any>, options?: RezoHttpRequest): RezoUploadResponse;
4280
+ /**
4281
+ * Set cookies in the cookie jar from various input formats.
4282
+ *
4283
+ * This method accepts multiple input formats for maximum flexibility:
4284
+ * - **Netscape cookie file content** (string): Full cookie file content in Netscape format
4285
+ * - **Set-Cookie header array** (string[]): Array of Set-Cookie header values
4286
+ * - **Serialized cookie objects** (SerializedCookie[]): Array of plain objects with cookie properties
4287
+ * - **Cookie instances** (Cookie[]): Array of Cookie class instances
4288
+ *
4289
+ * @param cookies - Cookies to set in one of the supported formats
4290
+ * @param url - Optional URL context for the cookies (used for domain/path inference)
4291
+ * @param startNew - If true, clears all existing cookies before setting new ones (default: false)
4292
+ *
4293
+ * @example
4294
+ * ```typescript
4295
+ * // From Netscape cookie file content
4296
+ * const netscapeContent = `# Netscape HTTP Cookie File
4297
+ * .example.com\tTRUE\t/\tFALSE\t0\tsession\tabc123`;
4298
+ * rezo.setCookies(netscapeContent);
4299
+ *
4300
+ * // From Set-Cookie header array
4301
+ * rezo.setCookies([
4302
+ * 'session=abc123; Domain=example.com; Path=/; HttpOnly',
4303
+ * 'user=john; Domain=example.com; Path=/; Max-Age=3600'
4304
+ * ], 'https://example.com');
4305
+ *
4306
+ * // From serialized cookie objects
4307
+ * rezo.setCookies([
4308
+ * { key: 'session', value: 'abc123', domain: 'example.com', path: '/' },
4309
+ * { key: 'user', value: 'john', domain: 'example.com', path: '/', maxAge: 3600 }
4310
+ * ]);
4311
+ *
4312
+ * // From Cookie instances
4313
+ * import { Cookie } from 'rezo';
4314
+ * const cookie = new Cookie({ key: 'token', value: 'xyz789', domain: 'api.example.com' });
4315
+ * rezo.setCookies([cookie]);
4316
+ *
4317
+ * // Replace all cookies (startNew = true)
4318
+ * rezo.setCookies([{ key: 'new', value: 'cookie' }], undefined, true);
4319
+ * ```
4320
+ *
4321
+ * @see {@link getCookies} - Retrieve cookies from the jar
4322
+ * @see {@link RezoCookieJar} - The underlying cookie jar class
4323
+ */
4324
+ setCookies(stringCookies: string): void;
4325
+ setCookies(stringCookies: string, url: string, startNew?: boolean): void;
4326
+ setCookies(serializedStringCookiesCookies: string, url: string | undefined, startNew: boolean): void;
4327
+ setCookies(serializedCookies: SerializedCookie[]): void;
4328
+ setCookies(serializedCookies: SerializedCookie[], url: string, startNew?: boolean): void;
4329
+ setCookies(serializedCookies: SerializedCookie[], url: string | undefined, startNew: boolean): void;
4330
+ setCookies(cookies: Cookie[]): void;
4331
+ setCookies(cookies: Cookie[], url: string, startNew?: boolean): void;
4332
+ setCookies(cookies: Cookie[], url: string | undefined, startNew: boolean): void;
4333
+ setCookies(setCookieArray: string[]): void;
4334
+ setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4335
+ setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4336
+ /**
4337
+ * Get all cookies from the cookie jar.
4338
+ *
4339
+ * Returns a `Cookies` object where keys are domain names and values are
4340
+ * arrays of Cookie objects for that domain. This provides easy access to
4341
+ * all stored cookies for inspection, serialization, or manual manipulation.
4342
+ *
4343
+ * @returns A Cookies object mapping domains to their Cookie arrays
4344
+ *
4345
+ * @example
4346
+ * ```typescript
4347
+ * // Get all cookies
4348
+ * const cookies = rezo.getCookies();
4349
+ *
4350
+ * // Access cookies for a specific domain
4351
+ * const exampleCookies = cookies['example.com'];
4352
+ * if (exampleCookies) {
4353
+ * for (const cookie of exampleCookies) {
4354
+ * console.log(`${cookie.key}=${cookie.value}`);
4355
+ * }
4356
+ * }
4357
+ *
4358
+ * // List all domains with cookies
4359
+ * const domains = Object.keys(cookies);
4360
+ * console.log('Cookies stored for:', domains);
4361
+ *
4362
+ * // Count total cookies
4363
+ * const totalCookies = Object.values(cookies)
4364
+ * .reduce((sum, arr) => sum + arr.length, 0);
4365
+ * console.log(`Total cookies: ${totalCookies}`);
4366
+ *
4367
+ * // Serialize all cookies to JSON
4368
+ * const serialized = JSON.stringify(cookies);
4369
+ *
4370
+ * // Check if a specific cookie exists
4371
+ * const hasSession = cookies['example.com']
4372
+ * ?.some(c => c.key === 'session');
4373
+ * ```
4374
+ *
4375
+ * @see {@link setCookies} - Set cookies in the jar
4376
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4377
+ */
4378
+ getCookies(): Cookies;
4280
4379
  }
4281
4380
  /**
4282
4381
  * Rezo HTTP Client - Core Types
@@ -1,5 +1,5 @@
1
- const _mod_juod8q = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_juod8q.Crawler;;
3
- const _mod_lugvyb = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_lugvyb.CrawlerOptions;
5
- exports.Domain = _mod_lugvyb.Domain;;
1
+ const _mod_ap8v7n = require('../plugin/crawler.cjs');
2
+ exports.Crawler = _mod_ap8v7n.Crawler;;
3
+ const _mod_ldttq4 = require('../plugin/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_ldttq4.CrawlerOptions;
5
+ exports.Domain = _mod_ldttq4.Domain;;
package/dist/index.cjs CHANGED
@@ -1,26 +1,27 @@
1
- const _mod_8g1zwb = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_8g1zwb.Rezo;
3
- exports.createRezoInstance = _mod_8g1zwb.createRezoInstance;
4
- exports.createDefaultInstance = _mod_8g1zwb.createDefaultInstance;;
5
- const _mod_brpqyx = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_brpqyx.RezoError;
7
- exports.RezoErrorCode = _mod_brpqyx.RezoErrorCode;;
8
- const _mod_nxs9mv = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_nxs9mv.RezoHeaders;;
10
- const _mod_sp17k6 = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_sp17k6.RezoFormData;;
12
- const _mod_rt2h0v = require('./utils/cookies.cjs');
13
- exports.RezoCookieJar = _mod_rt2h0v.RezoCookieJar;;
14
- const _mod_pg0wwn = require('./core/hooks.cjs');
15
- exports.createDefaultHooks = _mod_pg0wwn.createDefaultHooks;
16
- exports.mergeHooks = _mod_pg0wwn.mergeHooks;;
17
- const _mod_qipnt4 = require('./proxy/manager.cjs');
18
- exports.ProxyManager = _mod_qipnt4.ProxyManager;;
19
- const _mod_z8k198 = require('./queue/index.cjs');
20
- exports.RezoQueue = _mod_z8k198.RezoQueue;
21
- exports.HttpQueue = _mod_z8k198.HttpQueue;
22
- exports.Priority = _mod_z8k198.Priority;
23
- exports.HttpMethodPriority = _mod_z8k198.HttpMethodPriority;;
1
+ const _mod_7p8ab6 = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_7p8ab6.Rezo;
3
+ exports.createRezoInstance = _mod_7p8ab6.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_7p8ab6.createDefaultInstance;;
5
+ const _mod_gwad13 = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_gwad13.RezoError;
7
+ exports.RezoErrorCode = _mod_gwad13.RezoErrorCode;;
8
+ const _mod_0u5sf4 = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_0u5sf4.RezoHeaders;;
10
+ const _mod_y55mzr = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_y55mzr.RezoFormData;;
12
+ const _mod_8ixff7 = require('./utils/cookies.cjs');
13
+ exports.RezoCookieJar = _mod_8ixff7.RezoCookieJar;
14
+ exports.Cookie = _mod_8ixff7.Cookie;;
15
+ const _mod_6glzgm = require('./core/hooks.cjs');
16
+ exports.createDefaultHooks = _mod_6glzgm.createDefaultHooks;
17
+ exports.mergeHooks = _mod_6glzgm.mergeHooks;;
18
+ const _mod_k6rnmv = require('./proxy/manager.cjs');
19
+ exports.ProxyManager = _mod_k6rnmv.ProxyManager;;
20
+ const _mod_mjbdct = require('./queue/index.cjs');
21
+ exports.RezoQueue = _mod_mjbdct.RezoQueue;
22
+ exports.HttpQueue = _mod_mjbdct.HttpQueue;
23
+ exports.Priority = _mod_mjbdct.Priority;
24
+ exports.HttpMethodPriority = _mod_mjbdct.HttpMethodPriority;;
24
25
  const { RezoError } = require('./errors/rezo-error.cjs');
25
26
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
26
27
  const Cancel = exports.Cancel = RezoError;
package/dist/index.d.ts CHANGED
@@ -156,7 +156,7 @@ export interface SerializedCookie {
156
156
  lastAccessed?: string;
157
157
  [key: string]: unknown;
158
158
  }
159
- declare class Cookie extends TouchCookie {
159
+ export declare class Cookie extends TouchCookie {
160
160
  constructor(options?: CreateCookieOptions);
161
161
  /**
162
162
  * Fixes date fields that may have become strings during JSON deserialization.
@@ -4307,6 +4307,105 @@ export declare class Rezo {
4307
4307
  * ```
4308
4308
  */
4309
4309
  upload(url: string | URL, data: Buffer | FormData | RezoFormData | string | Record<string, any>, options?: RezoHttpRequest): RezoUploadResponse;
4310
+ /**
4311
+ * Set cookies in the cookie jar from various input formats.
4312
+ *
4313
+ * This method accepts multiple input formats for maximum flexibility:
4314
+ * - **Netscape cookie file content** (string): Full cookie file content in Netscape format
4315
+ * - **Set-Cookie header array** (string[]): Array of Set-Cookie header values
4316
+ * - **Serialized cookie objects** (SerializedCookie[]): Array of plain objects with cookie properties
4317
+ * - **Cookie instances** (Cookie[]): Array of Cookie class instances
4318
+ *
4319
+ * @param cookies - Cookies to set in one of the supported formats
4320
+ * @param url - Optional URL context for the cookies (used for domain/path inference)
4321
+ * @param startNew - If true, clears all existing cookies before setting new ones (default: false)
4322
+ *
4323
+ * @example
4324
+ * ```typescript
4325
+ * // From Netscape cookie file content
4326
+ * const netscapeContent = `# Netscape HTTP Cookie File
4327
+ * .example.com\tTRUE\t/\tFALSE\t0\tsession\tabc123`;
4328
+ * rezo.setCookies(netscapeContent);
4329
+ *
4330
+ * // From Set-Cookie header array
4331
+ * rezo.setCookies([
4332
+ * 'session=abc123; Domain=example.com; Path=/; HttpOnly',
4333
+ * 'user=john; Domain=example.com; Path=/; Max-Age=3600'
4334
+ * ], 'https://example.com');
4335
+ *
4336
+ * // From serialized cookie objects
4337
+ * rezo.setCookies([
4338
+ * { key: 'session', value: 'abc123', domain: 'example.com', path: '/' },
4339
+ * { key: 'user', value: 'john', domain: 'example.com', path: '/', maxAge: 3600 }
4340
+ * ]);
4341
+ *
4342
+ * // From Cookie instances
4343
+ * import { Cookie } from 'rezo';
4344
+ * const cookie = new Cookie({ key: 'token', value: 'xyz789', domain: 'api.example.com' });
4345
+ * rezo.setCookies([cookie]);
4346
+ *
4347
+ * // Replace all cookies (startNew = true)
4348
+ * rezo.setCookies([{ key: 'new', value: 'cookie' }], undefined, true);
4349
+ * ```
4350
+ *
4351
+ * @see {@link getCookies} - Retrieve cookies from the jar
4352
+ * @see {@link RezoCookieJar} - The underlying cookie jar class
4353
+ */
4354
+ setCookies(stringCookies: string): void;
4355
+ setCookies(stringCookies: string, url: string, startNew?: boolean): void;
4356
+ setCookies(serializedStringCookiesCookies: string, url: string | undefined, startNew: boolean): void;
4357
+ setCookies(serializedCookies: SerializedCookie[]): void;
4358
+ setCookies(serializedCookies: SerializedCookie[], url: string, startNew?: boolean): void;
4359
+ setCookies(serializedCookies: SerializedCookie[], url: string | undefined, startNew: boolean): void;
4360
+ setCookies(cookies: Cookie[]): void;
4361
+ setCookies(cookies: Cookie[], url: string, startNew?: boolean): void;
4362
+ setCookies(cookies: Cookie[], url: string | undefined, startNew: boolean): void;
4363
+ setCookies(setCookieArray: string[]): void;
4364
+ setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4365
+ setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4366
+ /**
4367
+ * Get all cookies from the cookie jar.
4368
+ *
4369
+ * Returns a `Cookies` object where keys are domain names and values are
4370
+ * arrays of Cookie objects for that domain. This provides easy access to
4371
+ * all stored cookies for inspection, serialization, or manual manipulation.
4372
+ *
4373
+ * @returns A Cookies object mapping domains to their Cookie arrays
4374
+ *
4375
+ * @example
4376
+ * ```typescript
4377
+ * // Get all cookies
4378
+ * const cookies = rezo.getCookies();
4379
+ *
4380
+ * // Access cookies for a specific domain
4381
+ * const exampleCookies = cookies['example.com'];
4382
+ * if (exampleCookies) {
4383
+ * for (const cookie of exampleCookies) {
4384
+ * console.log(`${cookie.key}=${cookie.value}`);
4385
+ * }
4386
+ * }
4387
+ *
4388
+ * // List all domains with cookies
4389
+ * const domains = Object.keys(cookies);
4390
+ * console.log('Cookies stored for:', domains);
4391
+ *
4392
+ * // Count total cookies
4393
+ * const totalCookies = Object.values(cookies)
4394
+ * .reduce((sum, arr) => sum + arr.length, 0);
4395
+ * console.log(`Total cookies: ${totalCookies}`);
4396
+ *
4397
+ * // Serialize all cookies to JSON
4398
+ * const serialized = JSON.stringify(cookies);
4399
+ *
4400
+ * // Check if a specific cookie exists
4401
+ * const hasSession = cookies['example.com']
4402
+ * ?.some(c => c.key === 'session');
4403
+ * ```
4404
+ *
4405
+ * @see {@link setCookies} - Set cookies in the jar
4406
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4407
+ */
4408
+ getCookies(): Cookies;
4310
4409
  }
4311
4410
  /**
4312
4411
  * Extended Rezo instance with Axios-compatible static helpers.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ export {
6
6
  export { RezoError, RezoErrorCode } from './errors/rezo-error.js';
7
7
  export { RezoHeaders } from './utils/headers.js';
8
8
  export { RezoFormData } from './utils/form-data.js';
9
- export { RezoCookieJar } from './utils/cookies.js';
9
+ export { RezoCookieJar, Cookie } from './utils/cookies.js';
10
10
  export { createDefaultHooks, mergeHooks } from './core/hooks.js';
11
11
  export { ProxyManager } from './proxy/manager.js';
12
12
  export { RezoQueue, HttpQueue, Priority, HttpMethodPriority } from './queue/index.js';