rezo 1.0.8 → 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.
@@ -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_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_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,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_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;;
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
@@ -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.
@@ -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.
@@ -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.
@@ -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.