rezo 1.0.9 → 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.
@@ -4219,48 +4219,101 @@ export declare class Rezo {
4219
4219
  setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4220
4220
  setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4221
4221
  /**
4222
- * Get all cookies from the cookie jar.
4222
+ * Get all cookies from the cookie jar in multiple convenient formats.
4223
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.
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
4227
  *
4228
- * @returns A Cookies object mapping domains to their Cookie arrays
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
4229
4236
  *
4230
4237
  * @example
4231
4238
  * ```typescript
4232
- * // Get all cookies
4233
4239
  * const cookies = rezo.getCookies();
4234
4240
  *
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
+ * // Access as Cookie instances for programmatic use
4242
+ * for (const cookie of cookies.array) {
4243
+ * console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
4241
4244
  * }
4242
4245
  *
4243
- * // List all domains with cookies
4244
- * const domains = Object.keys(cookies);
4245
- * console.log('Cookies stored for:', domains);
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);
4246
4251
  *
4247
- * // Count total cookies
4248
- * const totalCookies = Object.values(cookies)
4249
- * .reduce((sum, arr) => sum + arr.length, 0);
4250
- * console.log(`Total cookies: ${totalCookies}`);
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
+ * }
4251
4260
  *
4252
- * // Serialize all cookies to JSON
4253
- * const serialized = JSON.stringify(cookies);
4261
+ * // Check cookie count
4262
+ * console.log(`Total cookies: ${cookies.array.length}`);
4254
4263
  *
4255
- * // Check if a specific cookie exists
4256
- * const hasSession = cookies['example.com']
4257
- * ?.some(c => c.key === 'session');
4264
+ * // Find specific cookie
4265
+ * const sessionCookie = cookies.array.find(c => c.key === 'session');
4258
4266
  * ```
4259
4267
  *
4260
4268
  * @see {@link setCookies} - Set cookies in the jar
4269
+ * @see {@link clearCookies} - Remove all cookies from the jar
4261
4270
  * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4262
4271
  */
4263
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;
4264
4317
  }
4265
4318
  /**
4266
4319
  * Extended Rezo instance with Axios-compatible static helpers.
@@ -1,6 +1,6 @@
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
+ 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_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;;
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;;
@@ -404,6 +404,9 @@ class Rezo {
404
404
  getCookies() {
405
405
  return this.jar.cookies();
406
406
  }
407
+ clearCookies() {
408
+ this.jar?.removeAllCookiesSync();
409
+ }
407
410
  }
408
411
  const defaultTransforms = exports.defaultTransforms = {
409
412
  request: [
package/dist/core/rezo.js CHANGED
@@ -404,6 +404,9 @@ export class Rezo {
404
404
  getCookies() {
405
405
  return this.jar.cookies();
406
406
  }
407
+ clearCookies() {
408
+ this.jar?.removeAllCookiesSync();
409
+ }
407
410
  }
408
411
  export const defaultTransforms = {
409
412
  request: [
package/dist/crawler.d.ts CHANGED
@@ -4334,48 +4334,101 @@ declare class Rezo {
4334
4334
  setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4335
4335
  setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4336
4336
  /**
4337
- * Get all cookies from the cookie jar.
4337
+ * Get all cookies from the cookie jar in multiple convenient formats.
4338
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.
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
4342
  *
4343
- * @returns A Cookies object mapping domains to their Cookie arrays
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
4344
4351
  *
4345
4352
  * @example
4346
4353
  * ```typescript
4347
- * // Get all cookies
4348
4354
  * const cookies = rezo.getCookies();
4349
4355
  *
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
+ * // Access as Cookie instances for programmatic use
4357
+ * for (const cookie of cookies.array) {
4358
+ * console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
4356
4359
  * }
4357
4360
  *
4358
- * // List all domains with cookies
4359
- * const domains = Object.keys(cookies);
4360
- * console.log('Cookies stored for:', domains);
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);
4361
4366
  *
4362
- * // Count total cookies
4363
- * const totalCookies = Object.values(cookies)
4364
- * .reduce((sum, arr) => sum + arr.length, 0);
4365
- * console.log(`Total cookies: ${totalCookies}`);
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
+ * }
4366
4375
  *
4367
- * // Serialize all cookies to JSON
4368
- * const serialized = JSON.stringify(cookies);
4376
+ * // Check cookie count
4377
+ * console.log(`Total cookies: ${cookies.array.length}`);
4369
4378
  *
4370
- * // Check if a specific cookie exists
4371
- * const hasSession = cookies['example.com']
4372
- * ?.some(c => c.key === 'session');
4379
+ * // Find specific cookie
4380
+ * const sessionCookie = cookies.array.find(c => c.key === 'session');
4373
4381
  * ```
4374
4382
  *
4375
4383
  * @see {@link setCookies} - Set cookies in the jar
4384
+ * @see {@link clearCookies} - Remove all cookies from the jar
4376
4385
  * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4377
4386
  */
4378
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;
4379
4432
  }
4380
4433
  /**
4381
4434
  * Rezo HTTP Client - Core Types
@@ -1,5 +1,5 @@
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;;
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_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;;
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;
package/dist/index.d.ts CHANGED
@@ -4364,48 +4364,101 @@ export declare class Rezo {
4364
4364
  setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4365
4365
  setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4366
4366
  /**
4367
- * Get all cookies from the cookie jar.
4367
+ * Get all cookies from the cookie jar in multiple convenient formats.
4368
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.
4369
+ * Returns a `Cookies` object containing all stored cookies in various formats
4370
+ * for different use cases. This provides flexible access to cookies for
4371
+ * HTTP headers, file storage, serialization, or programmatic manipulation.
4372
4372
  *
4373
- * @returns A Cookies object mapping domains to their Cookie arrays
4373
+ * The returned `Cookies` object contains:
4374
+ * - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
4375
+ * - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
4376
+ * - **netscape**: `string` - Netscape cookie file format for file-based storage
4377
+ * - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
4378
+ * - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
4379
+ *
4380
+ * @returns A Cookies object with cookies in multiple formats
4374
4381
  *
4375
4382
  * @example
4376
4383
  * ```typescript
4377
- * // Get all cookies
4378
4384
  * const cookies = rezo.getCookies();
4379
4385
  *
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
+ * // Access as Cookie instances for programmatic use
4387
+ * for (const cookie of cookies.array) {
4388
+ * console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
4386
4389
  * }
4387
4390
  *
4388
- * // List all domains with cookies
4389
- * const domains = Object.keys(cookies);
4390
- * console.log('Cookies stored for:', domains);
4391
+ * // Get cookie header string for manual HTTP requests
4392
+ * console.log(cookies.string); // "session=abc123; user=john"
4393
+ *
4394
+ * // Save to Netscape cookie file
4395
+ * fs.writeFileSync('cookies.txt', cookies.netscape);
4391
4396
  *
4392
- * // Count total cookies
4393
- * const totalCookies = Object.values(cookies)
4394
- * .reduce((sum, arr) => sum + arr.length, 0);
4395
- * console.log(`Total cookies: ${totalCookies}`);
4397
+ * // Serialize to JSON for storage
4398
+ * const json = JSON.stringify(cookies.serialized);
4399
+ * localStorage.setItem('cookies', json);
4400
+ *
4401
+ * // Get Set-Cookie headers (useful for proxying responses)
4402
+ * for (const setCookie of cookies.setCookiesString) {
4403
+ * console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
4404
+ * }
4396
4405
  *
4397
- * // Serialize all cookies to JSON
4398
- * const serialized = JSON.stringify(cookies);
4406
+ * // Check cookie count
4407
+ * console.log(`Total cookies: ${cookies.array.length}`);
4399
4408
  *
4400
- * // Check if a specific cookie exists
4401
- * const hasSession = cookies['example.com']
4402
- * ?.some(c => c.key === 'session');
4409
+ * // Find specific cookie
4410
+ * const sessionCookie = cookies.array.find(c => c.key === 'session');
4403
4411
  * ```
4404
4412
  *
4405
4413
  * @see {@link setCookies} - Set cookies in the jar
4414
+ * @see {@link clearCookies} - Remove all cookies from the jar
4406
4415
  * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4407
4416
  */
4408
4417
  getCookies(): Cookies;
4418
+ /**
4419
+ * Remove all cookies from the cookie jar.
4420
+ *
4421
+ * This method synchronously clears the entire cookie store, removing all
4422
+ * cookies regardless of domain, path, or expiration. Useful for:
4423
+ * - Logging out users and clearing session state
4424
+ * - Resetting the client to a clean state between test runs
4425
+ * - Implementing "clear cookies" functionality in applications
4426
+ * - Starting fresh before authenticating with different credentials
4427
+ *
4428
+ * This operation is immediate and cannot be undone. If you need to preserve
4429
+ * certain cookies, use {@link getCookies} to save them before clearing,
4430
+ * then restore specific ones with {@link setCookies}.
4431
+ *
4432
+ * @example
4433
+ * ```typescript
4434
+ * // Simple logout - clear all cookies
4435
+ * rezo.clearCookies();
4436
+ *
4437
+ * // Save cookies before clearing (if needed)
4438
+ * const savedCookies = rezo.getCookies();
4439
+ * rezo.clearCookies();
4440
+ * // Later, restore specific cookies if needed
4441
+ * const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
4442
+ * rezo.setCookies(importantCookies);
4443
+ *
4444
+ * // Clear and re-authenticate
4445
+ * rezo.clearCookies();
4446
+ * await rezo.post('https://api.example.com/login', {
4447
+ * username: 'newuser',
4448
+ * password: 'newpass'
4449
+ * });
4450
+ *
4451
+ * // Use in test teardown
4452
+ * afterEach(() => {
4453
+ * rezo.clearCookies(); // Clean state for next test
4454
+ * });
4455
+ * ```
4456
+ *
4457
+ * @see {@link getCookies} - Get all cookies before clearing
4458
+ * @see {@link setCookies} - Restore or set new cookies after clearing
4459
+ * @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
4460
+ */
4461
+ clearCookies(): void;
4409
4462
  }
4410
4463
  /**
4411
4464
  * Extended Rezo instance with Axios-compatible static helpers.
@@ -4219,48 +4219,101 @@ export declare class Rezo {
4219
4219
  setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
4220
4220
  setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
4221
4221
  /**
4222
- * Get all cookies from the cookie jar.
4222
+ * Get all cookies from the cookie jar in multiple convenient formats.
4223
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.
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
4227
  *
4228
- * @returns A Cookies object mapping domains to their Cookie arrays
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
4229
4236
  *
4230
4237
  * @example
4231
4238
  * ```typescript
4232
- * // Get all cookies
4233
4239
  * const cookies = rezo.getCookies();
4234
4240
  *
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
+ * // Access as Cookie instances for programmatic use
4242
+ * for (const cookie of cookies.array) {
4243
+ * console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
4241
4244
  * }
4242
4245
  *
4243
- * // List all domains with cookies
4244
- * const domains = Object.keys(cookies);
4245
- * console.log('Cookies stored for:', domains);
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);
4246
4251
  *
4247
- * // Count total cookies
4248
- * const totalCookies = Object.values(cookies)
4249
- * .reduce((sum, arr) => sum + arr.length, 0);
4250
- * console.log(`Total cookies: ${totalCookies}`);
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
+ * }
4251
4260
  *
4252
- * // Serialize all cookies to JSON
4253
- * const serialized = JSON.stringify(cookies);
4261
+ * // Check cookie count
4262
+ * console.log(`Total cookies: ${cookies.array.length}`);
4254
4263
  *
4255
- * // Check if a specific cookie exists
4256
- * const hasSession = cookies['example.com']
4257
- * ?.some(c => c.key === 'session');
4264
+ * // Find specific cookie
4265
+ * const sessionCookie = cookies.array.find(c => c.key === 'session');
4258
4266
  * ```
4259
4267
  *
4260
4268
  * @see {@link setCookies} - Set cookies in the jar
4269
+ * @see {@link clearCookies} - Remove all cookies from the jar
4261
4270
  * @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
4262
4271
  */
4263
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;
4264
4317
  }
4265
4318
  /**
4266
4319
  * Extended Rezo instance with Axios-compatible static helpers.