rezo 1.0.8 → 1.0.10

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.
@@ -4162,6 +4162,158 @@ 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 in multiple convenient formats.
4223
+ *
4224
+ * Returns a `Cookies` object containing all stored cookies in various formats
4225
+ * for different use cases. This provides flexible access to cookies for
4226
+ * HTTP headers, file storage, serialization, or programmatic manipulation.
4227
+ *
4228
+ * The returned `Cookies` object contains:
4229
+ * - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
4230
+ * - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
4231
+ * - **netscape**: `string` - Netscape cookie file format for file-based storage
4232
+ * - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
4233
+ * - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
4234
+ *
4235
+ * @returns A Cookies object with cookies in multiple formats
4236
+ *
4237
+ * @example
4238
+ * ```typescript
4239
+ * const cookies = rezo.getCookies();
4240
+ *
4241
+ * // Access as Cookie instances for programmatic use
4242
+ * for (const cookie of cookies.array) {
4243
+ * console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
4244
+ * }
4245
+ *
4246
+ * // Get cookie header string for manual HTTP requests
4247
+ * console.log(cookies.string); // "session=abc123; user=john"
4248
+ *
4249
+ * // Save to Netscape cookie file
4250
+ * fs.writeFileSync('cookies.txt', cookies.netscape);
4251
+ *
4252
+ * // Serialize to JSON for storage
4253
+ * const json = JSON.stringify(cookies.serialized);
4254
+ * localStorage.setItem('cookies', json);
4255
+ *
4256
+ * // Get Set-Cookie headers (useful for proxying responses)
4257
+ * for (const setCookie of cookies.setCookiesString) {
4258
+ * console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
4259
+ * }
4260
+ *
4261
+ * // Check cookie count
4262
+ * console.log(`Total cookies: ${cookies.array.length}`);
4263
+ *
4264
+ * // Find specific cookie
4265
+ * const sessionCookie = cookies.array.find(c => c.key === 'session');
4266
+ * ```
4267
+ *
4268
+ * @see {@link setCookies} - Set cookies in the jar
4269
+ * @see {@link clearCookies} - Remove all cookies from the jar
4270
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4271
+ */
4272
+ getCookies(): Cookies;
4273
+ /**
4274
+ * Remove all cookies from the cookie jar.
4275
+ *
4276
+ * This method synchronously clears the entire cookie store, removing all
4277
+ * cookies regardless of domain, path, or expiration. Useful for:
4278
+ * - Logging out users and clearing session state
4279
+ * - Resetting the client to a clean state between test runs
4280
+ * - Implementing "clear cookies" functionality in applications
4281
+ * - Starting fresh before authenticating with different credentials
4282
+ *
4283
+ * This operation is immediate and cannot be undone. If you need to preserve
4284
+ * certain cookies, use {@link getCookies} to save them before clearing,
4285
+ * then restore specific ones with {@link setCookies}.
4286
+ *
4287
+ * @example
4288
+ * ```typescript
4289
+ * // Simple logout - clear all cookies
4290
+ * rezo.clearCookies();
4291
+ *
4292
+ * // Save cookies before clearing (if needed)
4293
+ * const savedCookies = rezo.getCookies();
4294
+ * rezo.clearCookies();
4295
+ * // Later, restore specific cookies if needed
4296
+ * const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
4297
+ * rezo.setCookies(importantCookies);
4298
+ *
4299
+ * // Clear and re-authenticate
4300
+ * rezo.clearCookies();
4301
+ * await rezo.post('https://api.example.com/login', {
4302
+ * username: 'newuser',
4303
+ * password: 'newpass'
4304
+ * });
4305
+ *
4306
+ * // Use in test teardown
4307
+ * afterEach(() => {
4308
+ * rezo.clearCookies(); // Clean state for next test
4309
+ * });
4310
+ * ```
4311
+ *
4312
+ * @see {@link getCookies} - Get all cookies before clearing
4313
+ * @see {@link setCookies} - Restore or set new cookies after clearing
4314
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
4315
+ */
4316
+ clearCookies(): void;
4165
4317
  }
4166
4318
  /**
4167
4319
  * Extended Rezo instance with Axios-compatible static helpers.
@@ -4162,6 +4162,158 @@ 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 in multiple convenient formats.
4223
+ *
4224
+ * Returns a `Cookies` object containing all stored cookies in various formats
4225
+ * for different use cases. This provides flexible access to cookies for
4226
+ * HTTP headers, file storage, serialization, or programmatic manipulation.
4227
+ *
4228
+ * The returned `Cookies` object contains:
4229
+ * - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
4230
+ * - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
4231
+ * - **netscape**: `string` - Netscape cookie file format for file-based storage
4232
+ * - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
4233
+ * - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
4234
+ *
4235
+ * @returns A Cookies object with cookies in multiple formats
4236
+ *
4237
+ * @example
4238
+ * ```typescript
4239
+ * const cookies = rezo.getCookies();
4240
+ *
4241
+ * // Access as Cookie instances for programmatic use
4242
+ * for (const cookie of cookies.array) {
4243
+ * console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
4244
+ * }
4245
+ *
4246
+ * // Get cookie header string for manual HTTP requests
4247
+ * console.log(cookies.string); // "session=abc123; user=john"
4248
+ *
4249
+ * // Save to Netscape cookie file
4250
+ * fs.writeFileSync('cookies.txt', cookies.netscape);
4251
+ *
4252
+ * // Serialize to JSON for storage
4253
+ * const json = JSON.stringify(cookies.serialized);
4254
+ * localStorage.setItem('cookies', json);
4255
+ *
4256
+ * // Get Set-Cookie headers (useful for proxying responses)
4257
+ * for (const setCookie of cookies.setCookiesString) {
4258
+ * console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
4259
+ * }
4260
+ *
4261
+ * // Check cookie count
4262
+ * console.log(`Total cookies: ${cookies.array.length}`);
4263
+ *
4264
+ * // Find specific cookie
4265
+ * const sessionCookie = cookies.array.find(c => c.key === 'session');
4266
+ * ```
4267
+ *
4268
+ * @see {@link setCookies} - Set cookies in the jar
4269
+ * @see {@link clearCookies} - Remove all cookies from the jar
4270
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4271
+ */
4272
+ getCookies(): Cookies;
4273
+ /**
4274
+ * Remove all cookies from the cookie jar.
4275
+ *
4276
+ * This method synchronously clears the entire cookie store, removing all
4277
+ * cookies regardless of domain, path, or expiration. Useful for:
4278
+ * - Logging out users and clearing session state
4279
+ * - Resetting the client to a clean state between test runs
4280
+ * - Implementing "clear cookies" functionality in applications
4281
+ * - Starting fresh before authenticating with different credentials
4282
+ *
4283
+ * This operation is immediate and cannot be undone. If you need to preserve
4284
+ * certain cookies, use {@link getCookies} to save them before clearing,
4285
+ * then restore specific ones with {@link setCookies}.
4286
+ *
4287
+ * @example
4288
+ * ```typescript
4289
+ * // Simple logout - clear all cookies
4290
+ * rezo.clearCookies();
4291
+ *
4292
+ * // Save cookies before clearing (if needed)
4293
+ * const savedCookies = rezo.getCookies();
4294
+ * rezo.clearCookies();
4295
+ * // Later, restore specific cookies if needed
4296
+ * const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
4297
+ * rezo.setCookies(importantCookies);
4298
+ *
4299
+ * // Clear and re-authenticate
4300
+ * rezo.clearCookies();
4301
+ * await rezo.post('https://api.example.com/login', {
4302
+ * username: 'newuser',
4303
+ * password: 'newpass'
4304
+ * });
4305
+ *
4306
+ * // Use in test teardown
4307
+ * afterEach(() => {
4308
+ * rezo.clearCookies(); // Clean state for next test
4309
+ * });
4310
+ * ```
4311
+ *
4312
+ * @see {@link getCookies} - Get all cookies before clearing
4313
+ * @see {@link setCookies} - Restore or set new cookies after clearing
4314
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
4315
+ */
4316
+ clearCookies(): void;
4165
4317
  }
4166
4318
  /**
4167
4319
  * Extended Rezo instance with Axios-compatible static helpers.
@@ -1,6 +1,6 @@
1
- const _mod_eif00c = require('./picker.cjs');
2
- exports.detectRuntime = _mod_eif00c.detectRuntime;
3
- exports.getAdapterCapabilities = _mod_eif00c.getAdapterCapabilities;
4
- exports.buildAdapterContext = _mod_eif00c.buildAdapterContext;
5
- exports.getAvailableAdapters = _mod_eif00c.getAvailableAdapters;
6
- exports.selectAdapter = _mod_eif00c.selectAdapter;;
1
+ const _mod_f2hgfc = require('./picker.cjs');
2
+ exports.detectRuntime = _mod_f2hgfc.detectRuntime;
3
+ exports.getAdapterCapabilities = _mod_f2hgfc.getAdapterCapabilities;
4
+ exports.buildAdapterContext = _mod_f2hgfc.buildAdapterContext;
5
+ exports.getAvailableAdapters = _mod_f2hgfc.getAvailableAdapters;
6
+ exports.selectAdapter = _mod_f2hgfc.selectAdapter;;
@@ -1,13 +1,13 @@
1
- const _mod_9e4qn8 = require('./lru-cache.cjs');
2
- exports.LRUCache = _mod_9e4qn8.LRUCache;;
3
- const _mod_gs3doh = require('./dns-cache.cjs');
4
- exports.DNSCache = _mod_gs3doh.DNSCache;
5
- exports.getGlobalDNSCache = _mod_gs3doh.getGlobalDNSCache;
6
- exports.resetGlobalDNSCache = _mod_gs3doh.resetGlobalDNSCache;;
7
- const _mod_9ffg9j = require('./response-cache.cjs');
8
- exports.ResponseCache = _mod_9ffg9j.ResponseCache;
9
- exports.normalizeResponseCacheConfig = _mod_9ffg9j.normalizeResponseCacheConfig;;
10
- const _mod_4dvgnu = require('./file-cacher.cjs');
11
- exports.FileCacher = _mod_4dvgnu.FileCacher;;
12
- const _mod_avqpi9 = require('./url-store.cjs');
13
- exports.UrlStore = _mod_avqpi9.UrlStore;;
1
+ const _mod_vpvlaj = require('./lru-cache.cjs');
2
+ exports.LRUCache = _mod_vpvlaj.LRUCache;;
3
+ const _mod_37phlu = require('./dns-cache.cjs');
4
+ exports.DNSCache = _mod_37phlu.DNSCache;
5
+ exports.getGlobalDNSCache = _mod_37phlu.getGlobalDNSCache;
6
+ exports.resetGlobalDNSCache = _mod_37phlu.resetGlobalDNSCache;;
7
+ const _mod_23ag1b = require('./response-cache.cjs');
8
+ exports.ResponseCache = _mod_23ag1b.ResponseCache;
9
+ exports.normalizeResponseCacheConfig = _mod_23ag1b.normalizeResponseCacheConfig;;
10
+ const _mod_ni47l3 = require('./file-cacher.cjs');
11
+ exports.FileCacher = _mod_ni47l3.FileCacher;;
12
+ const _mod_pgav4z = require('./url-store.cjs');
13
+ exports.UrlStore = _mod_pgav4z.UrlStore;;
@@ -396,6 +396,17 @@ 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
+ }
407
+ clearCookies() {
408
+ this.jar?.removeAllCookiesSync();
409
+ }
399
410
  }
400
411
  const defaultTransforms = exports.defaultTransforms = {
401
412
  request: [
package/dist/core/rezo.js CHANGED
@@ -396,6 +396,17 @@ 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
+ }
407
+ clearCookies() {
408
+ this.jar?.removeAllCookiesSync();
409
+ }
399
410
  }
400
411
  export const defaultTransforms = {
401
412
  request: [
package/dist/crawler.d.ts CHANGED
@@ -4277,6 +4277,158 @@ 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 in multiple convenient formats.
4338
+ *
4339
+ * Returns a `Cookies` object containing all stored cookies in various formats
4340
+ * for different use cases. This provides flexible access to cookies for
4341
+ * HTTP headers, file storage, serialization, or programmatic manipulation.
4342
+ *
4343
+ * The returned `Cookies` object contains:
4344
+ * - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
4345
+ * - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
4346
+ * - **netscape**: `string` - Netscape cookie file format for file-based storage
4347
+ * - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
4348
+ * - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
4349
+ *
4350
+ * @returns A Cookies object with cookies in multiple formats
4351
+ *
4352
+ * @example
4353
+ * ```typescript
4354
+ * const cookies = rezo.getCookies();
4355
+ *
4356
+ * // Access as Cookie instances for programmatic use
4357
+ * for (const cookie of cookies.array) {
4358
+ * console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
4359
+ * }
4360
+ *
4361
+ * // Get cookie header string for manual HTTP requests
4362
+ * console.log(cookies.string); // "session=abc123; user=john"
4363
+ *
4364
+ * // Save to Netscape cookie file
4365
+ * fs.writeFileSync('cookies.txt', cookies.netscape);
4366
+ *
4367
+ * // Serialize to JSON for storage
4368
+ * const json = JSON.stringify(cookies.serialized);
4369
+ * localStorage.setItem('cookies', json);
4370
+ *
4371
+ * // Get Set-Cookie headers (useful for proxying responses)
4372
+ * for (const setCookie of cookies.setCookiesString) {
4373
+ * console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
4374
+ * }
4375
+ *
4376
+ * // Check cookie count
4377
+ * console.log(`Total cookies: ${cookies.array.length}`);
4378
+ *
4379
+ * // Find specific cookie
4380
+ * const sessionCookie = cookies.array.find(c => c.key === 'session');
4381
+ * ```
4382
+ *
4383
+ * @see {@link setCookies} - Set cookies in the jar
4384
+ * @see {@link clearCookies} - Remove all cookies from the jar
4385
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4386
+ */
4387
+ getCookies(): Cookies;
4388
+ /**
4389
+ * Remove all cookies from the cookie jar.
4390
+ *
4391
+ * This method synchronously clears the entire cookie store, removing all
4392
+ * cookies regardless of domain, path, or expiration. Useful for:
4393
+ * - Logging out users and clearing session state
4394
+ * - Resetting the client to a clean state between test runs
4395
+ * - Implementing "clear cookies" functionality in applications
4396
+ * - Starting fresh before authenticating with different credentials
4397
+ *
4398
+ * This operation is immediate and cannot be undone. If you need to preserve
4399
+ * certain cookies, use {@link getCookies} to save them before clearing,
4400
+ * then restore specific ones with {@link setCookies}.
4401
+ *
4402
+ * @example
4403
+ * ```typescript
4404
+ * // Simple logout - clear all cookies
4405
+ * rezo.clearCookies();
4406
+ *
4407
+ * // Save cookies before clearing (if needed)
4408
+ * const savedCookies = rezo.getCookies();
4409
+ * rezo.clearCookies();
4410
+ * // Later, restore specific cookies if needed
4411
+ * const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
4412
+ * rezo.setCookies(importantCookies);
4413
+ *
4414
+ * // Clear and re-authenticate
4415
+ * rezo.clearCookies();
4416
+ * await rezo.post('https://api.example.com/login', {
4417
+ * username: 'newuser',
4418
+ * password: 'newpass'
4419
+ * });
4420
+ *
4421
+ * // Use in test teardown
4422
+ * afterEach(() => {
4423
+ * rezo.clearCookies(); // Clean state for next test
4424
+ * });
4425
+ * ```
4426
+ *
4427
+ * @see {@link getCookies} - Get all cookies before clearing
4428
+ * @see {@link setCookies} - Restore or set new cookies after clearing
4429
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
4430
+ */
4431
+ clearCookies(): void;
4280
4432
  }
4281
4433
  /**
4282
4434
  * Rezo HTTP Client - Core Types
@@ -1,5 +1,5 @@
1
- const _mod_wpalft = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_wpalft.Crawler;;
3
- const _mod_0yhulz = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_0yhulz.CrawlerOptions;
5
- exports.Domain = _mod_0yhulz.Domain;;
1
+ const _mod_f905u8 = require('../plugin/crawler.cjs');
2
+ exports.Crawler = _mod_f905u8.Crawler;;
3
+ const _mod_885b6l = require('../plugin/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_885b6l.CrawlerOptions;
5
+ exports.Domain = _mod_885b6l.Domain;;
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
- const _mod_8dr47b = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_8dr47b.Rezo;
3
- exports.createRezoInstance = _mod_8dr47b.createRezoInstance;
4
- exports.createDefaultInstance = _mod_8dr47b.createDefaultInstance;;
5
- const _mod_z7hw1b = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_z7hw1b.RezoError;
7
- exports.RezoErrorCode = _mod_z7hw1b.RezoErrorCode;;
8
- const _mod_3vh4fg = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_3vh4fg.RezoHeaders;;
10
- const _mod_ad6idl = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_ad6idl.RezoFormData;;
12
- const _mod_8x9fab = require('./utils/cookies.cjs');
13
- exports.RezoCookieJar = _mod_8x9fab.RezoCookieJar;
14
- exports.Cookie = _mod_8x9fab.Cookie;;
15
- const _mod_ii7ay0 = require('./core/hooks.cjs');
16
- exports.createDefaultHooks = _mod_ii7ay0.createDefaultHooks;
17
- exports.mergeHooks = _mod_ii7ay0.mergeHooks;;
18
- const _mod_tcxc6y = require('./proxy/manager.cjs');
19
- exports.ProxyManager = _mod_tcxc6y.ProxyManager;;
20
- const _mod_zco8m1 = require('./queue/index.cjs');
21
- exports.RezoQueue = _mod_zco8m1.RezoQueue;
22
- exports.HttpQueue = _mod_zco8m1.HttpQueue;
23
- exports.Priority = _mod_zco8m1.Priority;
24
- exports.HttpMethodPriority = _mod_zco8m1.HttpMethodPriority;;
1
+ const _mod_3dvs8m = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_3dvs8m.Rezo;
3
+ exports.createRezoInstance = _mod_3dvs8m.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_3dvs8m.createDefaultInstance;;
5
+ const _mod_r7o6q6 = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_r7o6q6.RezoError;
7
+ exports.RezoErrorCode = _mod_r7o6q6.RezoErrorCode;;
8
+ const _mod_6y2l73 = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_6y2l73.RezoHeaders;;
10
+ const _mod_5033qo = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_5033qo.RezoFormData;;
12
+ const _mod_wvl5qh = require('./utils/cookies.cjs');
13
+ exports.RezoCookieJar = _mod_wvl5qh.RezoCookieJar;
14
+ exports.Cookie = _mod_wvl5qh.Cookie;;
15
+ const _mod_gqvwg5 = require('./core/hooks.cjs');
16
+ exports.createDefaultHooks = _mod_gqvwg5.createDefaultHooks;
17
+ exports.mergeHooks = _mod_gqvwg5.mergeHooks;;
18
+ const _mod_xy25q8 = require('./proxy/manager.cjs');
19
+ exports.ProxyManager = _mod_xy25q8.ProxyManager;;
20
+ const _mod_k77c7o = require('./queue/index.cjs');
21
+ exports.RezoQueue = _mod_k77c7o.RezoQueue;
22
+ exports.HttpQueue = _mod_k77c7o.HttpQueue;
23
+ exports.Priority = _mod_k77c7o.Priority;
24
+ exports.HttpMethodPriority = _mod_k77c7o.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;