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.
- package/dist/adapters/entries/curl.d.ts +77 -24
- package/dist/adapters/entries/fetch.d.ts +77 -24
- package/dist/adapters/entries/http.d.ts +77 -24
- package/dist/adapters/entries/http2.d.ts +77 -24
- package/dist/adapters/entries/react-native.d.ts +77 -24
- package/dist/adapters/entries/xhr.d.ts +77 -24
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/core/rezo.cjs +3 -0
- package/dist/core/rezo.js +3 -0
- package/dist/crawler.d.ts +77 -24
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +77 -24
- package/dist/platform/browser.d.ts +77 -24
- package/dist/platform/bun.d.ts +77 -24
- package/dist/platform/deno.d.ts +77 -24
- package/dist/platform/node.d.ts +77 -24
- package/dist/platform/react-native.d.ts +77 -24
- package/dist/platform/worker.d.ts +77 -24
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/queue/index.cjs +8 -8
- package/package.json +1 -1
|
@@ -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
|
|
4225
|
-
*
|
|
4226
|
-
*
|
|
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
|
-
*
|
|
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
|
|
4236
|
-
* const
|
|
4237
|
-
*
|
|
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
|
-
* //
|
|
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);
|
|
4246
4251
|
*
|
|
4247
|
-
* //
|
|
4248
|
-
* const
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
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
|
-
* //
|
|
4253
|
-
*
|
|
4261
|
+
* // Check cookie count
|
|
4262
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4254
4263
|
*
|
|
4255
|
-
* //
|
|
4256
|
-
* const
|
|
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.
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.detectRuntime =
|
|
3
|
-
exports.getAdapterCapabilities =
|
|
4
|
-
exports.buildAdapterContext =
|
|
5
|
-
exports.getAvailableAdapters =
|
|
6
|
-
exports.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;;
|
package/dist/cache/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.LRUCache =
|
|
3
|
-
const
|
|
4
|
-
exports.DNSCache =
|
|
5
|
-
exports.getGlobalDNSCache =
|
|
6
|
-
exports.resetGlobalDNSCache =
|
|
7
|
-
const
|
|
8
|
-
exports.ResponseCache =
|
|
9
|
-
exports.normalizeResponseCacheConfig =
|
|
10
|
-
const
|
|
11
|
-
exports.FileCacher =
|
|
12
|
-
const
|
|
13
|
-
exports.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;;
|
package/dist/core/rezo.cjs
CHANGED
package/dist/core/rezo.js
CHANGED
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
|
|
4340
|
-
*
|
|
4341
|
-
*
|
|
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
|
-
*
|
|
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
|
|
4351
|
-
* const
|
|
4352
|
-
*
|
|
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
|
-
* //
|
|
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);
|
|
4361
4366
|
*
|
|
4362
|
-
* //
|
|
4363
|
-
* const
|
|
4364
|
-
*
|
|
4365
|
-
*
|
|
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
|
-
* //
|
|
4368
|
-
*
|
|
4376
|
+
* // Check cookie count
|
|
4377
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4369
4378
|
*
|
|
4370
|
-
* //
|
|
4371
|
-
* const
|
|
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
|
package/dist/entries/crawler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.Crawler =
|
|
3
|
-
const
|
|
4
|
-
exports.CrawlerOptions =
|
|
5
|
-
exports.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
|
|
2
|
-
exports.Rezo =
|
|
3
|
-
exports.createRezoInstance =
|
|
4
|
-
exports.createDefaultInstance =
|
|
5
|
-
const
|
|
6
|
-
exports.RezoError =
|
|
7
|
-
exports.RezoErrorCode =
|
|
8
|
-
const
|
|
9
|
-
exports.RezoHeaders =
|
|
10
|
-
const
|
|
11
|
-
exports.RezoFormData =
|
|
12
|
-
const
|
|
13
|
-
exports.RezoCookieJar =
|
|
14
|
-
exports.Cookie =
|
|
15
|
-
const
|
|
16
|
-
exports.createDefaultHooks =
|
|
17
|
-
exports.mergeHooks =
|
|
18
|
-
const
|
|
19
|
-
exports.ProxyManager =
|
|
20
|
-
const
|
|
21
|
-
exports.RezoQueue =
|
|
22
|
-
exports.HttpQueue =
|
|
23
|
-
exports.Priority =
|
|
24
|
-
exports.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
|
|
4370
|
-
*
|
|
4371
|
-
*
|
|
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
|
-
*
|
|
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
|
|
4381
|
-
* const
|
|
4382
|
-
*
|
|
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
|
-
* //
|
|
4389
|
-
*
|
|
4390
|
-
*
|
|
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
|
-
* //
|
|
4393
|
-
* const
|
|
4394
|
-
*
|
|
4395
|
-
*
|
|
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
|
-
* //
|
|
4398
|
-
*
|
|
4406
|
+
* // Check cookie count
|
|
4407
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4399
4408
|
*
|
|
4400
|
-
* //
|
|
4401
|
-
* const
|
|
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
|
|
4225
|
-
*
|
|
4226
|
-
*
|
|
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
|
-
*
|
|
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
|
|
4236
|
-
* const
|
|
4237
|
-
*
|
|
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
|
-
* //
|
|
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);
|
|
4246
4251
|
*
|
|
4247
|
-
* //
|
|
4248
|
-
* const
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
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
|
-
* //
|
|
4253
|
-
*
|
|
4261
|
+
* // Check cookie count
|
|
4262
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4254
4263
|
*
|
|
4255
|
-
* //
|
|
4256
|
-
* const
|
|
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.
|