rezo 1.0.9 → 1.0.11
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 +78 -24
- package/dist/adapters/entries/fetch.d.ts +78 -24
- package/dist/adapters/entries/http.d.ts +78 -24
- package/dist/adapters/entries/http2.d.ts +78 -24
- package/dist/adapters/entries/react-native.d.ts +78 -24
- package/dist/adapters/entries/xhr.d.ts +78 -24
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/core/rezo.cjs +8 -0
- package/dist/core/rezo.js +8 -0
- package/dist/crawler.d.ts +78 -24
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +78 -24
- package/dist/platform/browser.d.ts +78 -24
- package/dist/platform/bun.d.ts +78 -24
- package/dist/platform/deno.d.ts +78 -24
- package/dist/platform/node.d.ts +78 -24
- package/dist/platform/react-native.d.ts +78 -24
- package/dist/platform/worker.d.ts +78 -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
|
@@ -4104,6 +4104,7 @@ export declare class Rezo {
|
|
|
4104
4104
|
private __create;
|
|
4105
4105
|
/** Get the cookie jar for this instance */
|
|
4106
4106
|
get cookieJar(): RezoCookieJar;
|
|
4107
|
+
set cookieJar(jar: RezoCookieJar);
|
|
4107
4108
|
/**
|
|
4108
4109
|
* Save cookies to file (if cookieFile is configured).
|
|
4109
4110
|
* Can also specify a different path to save to.
|
|
@@ -4219,48 +4220,101 @@ export declare class Rezo {
|
|
|
4219
4220
|
setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
|
|
4220
4221
|
setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
|
|
4221
4222
|
/**
|
|
4222
|
-
* Get all cookies from the cookie jar.
|
|
4223
|
+
* Get all cookies from the cookie jar in multiple convenient formats.
|
|
4223
4224
|
*
|
|
4224
|
-
* Returns a `Cookies` object
|
|
4225
|
-
*
|
|
4226
|
-
*
|
|
4225
|
+
* Returns a `Cookies` object containing all stored cookies in various formats
|
|
4226
|
+
* for different use cases. This provides flexible access to cookies for
|
|
4227
|
+
* HTTP headers, file storage, serialization, or programmatic manipulation.
|
|
4227
4228
|
*
|
|
4228
|
-
*
|
|
4229
|
+
* The returned `Cookies` object contains:
|
|
4230
|
+
* - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
|
|
4231
|
+
* - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
|
|
4232
|
+
* - **netscape**: `string` - Netscape cookie file format for file-based storage
|
|
4233
|
+
* - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
|
|
4234
|
+
* - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
|
|
4235
|
+
*
|
|
4236
|
+
* @returns A Cookies object with cookies in multiple formats
|
|
4229
4237
|
*
|
|
4230
4238
|
* @example
|
|
4231
4239
|
* ```typescript
|
|
4232
|
-
* // Get all cookies
|
|
4233
4240
|
* const cookies = rezo.getCookies();
|
|
4234
4241
|
*
|
|
4235
|
-
* // Access
|
|
4236
|
-
* const
|
|
4237
|
-
*
|
|
4238
|
-
* for (const cookie of exampleCookies) {
|
|
4239
|
-
* console.log(`${cookie.key}=${cookie.value}`);
|
|
4240
|
-
* }
|
|
4242
|
+
* // Access as Cookie instances for programmatic use
|
|
4243
|
+
* for (const cookie of cookies.array) {
|
|
4244
|
+
* console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
|
|
4241
4245
|
* }
|
|
4242
4246
|
*
|
|
4243
|
-
* //
|
|
4244
|
-
*
|
|
4245
|
-
*
|
|
4247
|
+
* // Get cookie header string for manual HTTP requests
|
|
4248
|
+
* console.log(cookies.string); // "session=abc123; user=john"
|
|
4249
|
+
*
|
|
4250
|
+
* // Save to Netscape cookie file
|
|
4251
|
+
* fs.writeFileSync('cookies.txt', cookies.netscape);
|
|
4246
4252
|
*
|
|
4247
|
-
* //
|
|
4248
|
-
* const
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
4253
|
+
* // Serialize to JSON for storage
|
|
4254
|
+
* const json = JSON.stringify(cookies.serialized);
|
|
4255
|
+
* localStorage.setItem('cookies', json);
|
|
4256
|
+
*
|
|
4257
|
+
* // Get Set-Cookie headers (useful for proxying responses)
|
|
4258
|
+
* for (const setCookie of cookies.setCookiesString) {
|
|
4259
|
+
* console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
|
|
4260
|
+
* }
|
|
4251
4261
|
*
|
|
4252
|
-
* //
|
|
4253
|
-
*
|
|
4262
|
+
* // Check cookie count
|
|
4263
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4254
4264
|
*
|
|
4255
|
-
* //
|
|
4256
|
-
* const
|
|
4257
|
-
* ?.some(c => c.key === 'session');
|
|
4265
|
+
* // Find specific cookie
|
|
4266
|
+
* const sessionCookie = cookies.array.find(c => c.key === 'session');
|
|
4258
4267
|
* ```
|
|
4259
4268
|
*
|
|
4260
4269
|
* @see {@link setCookies} - Set cookies in the jar
|
|
4270
|
+
* @see {@link clearCookies} - Remove all cookies from the jar
|
|
4261
4271
|
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
|
|
4262
4272
|
*/
|
|
4263
4273
|
getCookies(): Cookies;
|
|
4274
|
+
/**
|
|
4275
|
+
* Remove all cookies from the cookie jar.
|
|
4276
|
+
*
|
|
4277
|
+
* This method synchronously clears the entire cookie store, removing all
|
|
4278
|
+
* cookies regardless of domain, path, or expiration. Useful for:
|
|
4279
|
+
* - Logging out users and clearing session state
|
|
4280
|
+
* - Resetting the client to a clean state between test runs
|
|
4281
|
+
* - Implementing "clear cookies" functionality in applications
|
|
4282
|
+
* - Starting fresh before authenticating with different credentials
|
|
4283
|
+
*
|
|
4284
|
+
* This operation is immediate and cannot be undone. If you need to preserve
|
|
4285
|
+
* certain cookies, use {@link getCookies} to save them before clearing,
|
|
4286
|
+
* then restore specific ones with {@link setCookies}.
|
|
4287
|
+
*
|
|
4288
|
+
* @example
|
|
4289
|
+
* ```typescript
|
|
4290
|
+
* // Simple logout - clear all cookies
|
|
4291
|
+
* rezo.clearCookies();
|
|
4292
|
+
*
|
|
4293
|
+
* // Save cookies before clearing (if needed)
|
|
4294
|
+
* const savedCookies = rezo.getCookies();
|
|
4295
|
+
* rezo.clearCookies();
|
|
4296
|
+
* // Later, restore specific cookies if needed
|
|
4297
|
+
* const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
|
|
4298
|
+
* rezo.setCookies(importantCookies);
|
|
4299
|
+
*
|
|
4300
|
+
* // Clear and re-authenticate
|
|
4301
|
+
* rezo.clearCookies();
|
|
4302
|
+
* await rezo.post('https://api.example.com/login', {
|
|
4303
|
+
* username: 'newuser',
|
|
4304
|
+
* password: 'newpass'
|
|
4305
|
+
* });
|
|
4306
|
+
*
|
|
4307
|
+
* // Use in test teardown
|
|
4308
|
+
* afterEach(() => {
|
|
4309
|
+
* rezo.clearCookies(); // Clean state for next test
|
|
4310
|
+
* });
|
|
4311
|
+
* ```
|
|
4312
|
+
*
|
|
4313
|
+
* @see {@link getCookies} - Get all cookies before clearing
|
|
4314
|
+
* @see {@link setCookies} - Restore or set new cookies after clearing
|
|
4315
|
+
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
|
|
4316
|
+
*/
|
|
4317
|
+
clearCookies(): void;
|
|
4264
4318
|
}
|
|
4265
4319
|
/**
|
|
4266
4320
|
* Extended Rezo instance with Axios-compatible static helpers.
|
|
@@ -4104,6 +4104,7 @@ export declare class Rezo {
|
|
|
4104
4104
|
private __create;
|
|
4105
4105
|
/** Get the cookie jar for this instance */
|
|
4106
4106
|
get cookieJar(): RezoCookieJar;
|
|
4107
|
+
set cookieJar(jar: RezoCookieJar);
|
|
4107
4108
|
/**
|
|
4108
4109
|
* Save cookies to file (if cookieFile is configured).
|
|
4109
4110
|
* Can also specify a different path to save to.
|
|
@@ -4219,48 +4220,101 @@ export declare class Rezo {
|
|
|
4219
4220
|
setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
|
|
4220
4221
|
setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
|
|
4221
4222
|
/**
|
|
4222
|
-
* Get all cookies from the cookie jar.
|
|
4223
|
+
* Get all cookies from the cookie jar in multiple convenient formats.
|
|
4223
4224
|
*
|
|
4224
|
-
* Returns a `Cookies` object
|
|
4225
|
-
*
|
|
4226
|
-
*
|
|
4225
|
+
* Returns a `Cookies` object containing all stored cookies in various formats
|
|
4226
|
+
* for different use cases. This provides flexible access to cookies for
|
|
4227
|
+
* HTTP headers, file storage, serialization, or programmatic manipulation.
|
|
4227
4228
|
*
|
|
4228
|
-
*
|
|
4229
|
+
* The returned `Cookies` object contains:
|
|
4230
|
+
* - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
|
|
4231
|
+
* - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
|
|
4232
|
+
* - **netscape**: `string` - Netscape cookie file format for file-based storage
|
|
4233
|
+
* - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
|
|
4234
|
+
* - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
|
|
4235
|
+
*
|
|
4236
|
+
* @returns A Cookies object with cookies in multiple formats
|
|
4229
4237
|
*
|
|
4230
4238
|
* @example
|
|
4231
4239
|
* ```typescript
|
|
4232
|
-
* // Get all cookies
|
|
4233
4240
|
* const cookies = rezo.getCookies();
|
|
4234
4241
|
*
|
|
4235
|
-
* // Access
|
|
4236
|
-
* const
|
|
4237
|
-
*
|
|
4238
|
-
* for (const cookie of exampleCookies) {
|
|
4239
|
-
* console.log(`${cookie.key}=${cookie.value}`);
|
|
4240
|
-
* }
|
|
4242
|
+
* // Access as Cookie instances for programmatic use
|
|
4243
|
+
* for (const cookie of cookies.array) {
|
|
4244
|
+
* console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
|
|
4241
4245
|
* }
|
|
4242
4246
|
*
|
|
4243
|
-
* //
|
|
4244
|
-
*
|
|
4245
|
-
*
|
|
4247
|
+
* // Get cookie header string for manual HTTP requests
|
|
4248
|
+
* console.log(cookies.string); // "session=abc123; user=john"
|
|
4249
|
+
*
|
|
4250
|
+
* // Save to Netscape cookie file
|
|
4251
|
+
* fs.writeFileSync('cookies.txt', cookies.netscape);
|
|
4246
4252
|
*
|
|
4247
|
-
* //
|
|
4248
|
-
* const
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
4253
|
+
* // Serialize to JSON for storage
|
|
4254
|
+
* const json = JSON.stringify(cookies.serialized);
|
|
4255
|
+
* localStorage.setItem('cookies', json);
|
|
4256
|
+
*
|
|
4257
|
+
* // Get Set-Cookie headers (useful for proxying responses)
|
|
4258
|
+
* for (const setCookie of cookies.setCookiesString) {
|
|
4259
|
+
* console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
|
|
4260
|
+
* }
|
|
4251
4261
|
*
|
|
4252
|
-
* //
|
|
4253
|
-
*
|
|
4262
|
+
* // Check cookie count
|
|
4263
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4254
4264
|
*
|
|
4255
|
-
* //
|
|
4256
|
-
* const
|
|
4257
|
-
* ?.some(c => c.key === 'session');
|
|
4265
|
+
* // Find specific cookie
|
|
4266
|
+
* const sessionCookie = cookies.array.find(c => c.key === 'session');
|
|
4258
4267
|
* ```
|
|
4259
4268
|
*
|
|
4260
4269
|
* @see {@link setCookies} - Set cookies in the jar
|
|
4270
|
+
* @see {@link clearCookies} - Remove all cookies from the jar
|
|
4261
4271
|
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
|
|
4262
4272
|
*/
|
|
4263
4273
|
getCookies(): Cookies;
|
|
4274
|
+
/**
|
|
4275
|
+
* Remove all cookies from the cookie jar.
|
|
4276
|
+
*
|
|
4277
|
+
* This method synchronously clears the entire cookie store, removing all
|
|
4278
|
+
* cookies regardless of domain, path, or expiration. Useful for:
|
|
4279
|
+
* - Logging out users and clearing session state
|
|
4280
|
+
* - Resetting the client to a clean state between test runs
|
|
4281
|
+
* - Implementing "clear cookies" functionality in applications
|
|
4282
|
+
* - Starting fresh before authenticating with different credentials
|
|
4283
|
+
*
|
|
4284
|
+
* This operation is immediate and cannot be undone. If you need to preserve
|
|
4285
|
+
* certain cookies, use {@link getCookies} to save them before clearing,
|
|
4286
|
+
* then restore specific ones with {@link setCookies}.
|
|
4287
|
+
*
|
|
4288
|
+
* @example
|
|
4289
|
+
* ```typescript
|
|
4290
|
+
* // Simple logout - clear all cookies
|
|
4291
|
+
* rezo.clearCookies();
|
|
4292
|
+
*
|
|
4293
|
+
* // Save cookies before clearing (if needed)
|
|
4294
|
+
* const savedCookies = rezo.getCookies();
|
|
4295
|
+
* rezo.clearCookies();
|
|
4296
|
+
* // Later, restore specific cookies if needed
|
|
4297
|
+
* const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
|
|
4298
|
+
* rezo.setCookies(importantCookies);
|
|
4299
|
+
*
|
|
4300
|
+
* // Clear and re-authenticate
|
|
4301
|
+
* rezo.clearCookies();
|
|
4302
|
+
* await rezo.post('https://api.example.com/login', {
|
|
4303
|
+
* username: 'newuser',
|
|
4304
|
+
* password: 'newpass'
|
|
4305
|
+
* });
|
|
4306
|
+
*
|
|
4307
|
+
* // Use in test teardown
|
|
4308
|
+
* afterEach(() => {
|
|
4309
|
+
* rezo.clearCookies(); // Clean state for next test
|
|
4310
|
+
* });
|
|
4311
|
+
* ```
|
|
4312
|
+
*
|
|
4313
|
+
* @see {@link getCookies} - Get all cookies before clearing
|
|
4314
|
+
* @see {@link setCookies} - Restore or set new cookies after clearing
|
|
4315
|
+
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
|
|
4316
|
+
*/
|
|
4317
|
+
clearCookies(): void;
|
|
4264
4318
|
}
|
|
4265
4319
|
/**
|
|
4266
4320
|
* Extended Rezo instance with Axios-compatible static helpers.
|
|
@@ -4104,6 +4104,7 @@ export declare class Rezo {
|
|
|
4104
4104
|
private __create;
|
|
4105
4105
|
/** Get the cookie jar for this instance */
|
|
4106
4106
|
get cookieJar(): RezoCookieJar;
|
|
4107
|
+
set cookieJar(jar: RezoCookieJar);
|
|
4107
4108
|
/**
|
|
4108
4109
|
* Save cookies to file (if cookieFile is configured).
|
|
4109
4110
|
* Can also specify a different path to save to.
|
|
@@ -4219,48 +4220,101 @@ export declare class Rezo {
|
|
|
4219
4220
|
setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
|
|
4220
4221
|
setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
|
|
4221
4222
|
/**
|
|
4222
|
-
* Get all cookies from the cookie jar.
|
|
4223
|
+
* Get all cookies from the cookie jar in multiple convenient formats.
|
|
4223
4224
|
*
|
|
4224
|
-
* Returns a `Cookies` object
|
|
4225
|
-
*
|
|
4226
|
-
*
|
|
4225
|
+
* Returns a `Cookies` object containing all stored cookies in various formats
|
|
4226
|
+
* for different use cases. This provides flexible access to cookies for
|
|
4227
|
+
* HTTP headers, file storage, serialization, or programmatic manipulation.
|
|
4227
4228
|
*
|
|
4228
|
-
*
|
|
4229
|
+
* The returned `Cookies` object contains:
|
|
4230
|
+
* - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
|
|
4231
|
+
* - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
|
|
4232
|
+
* - **netscape**: `string` - Netscape cookie file format for file-based storage
|
|
4233
|
+
* - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
|
|
4234
|
+
* - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
|
|
4235
|
+
*
|
|
4236
|
+
* @returns A Cookies object with cookies in multiple formats
|
|
4229
4237
|
*
|
|
4230
4238
|
* @example
|
|
4231
4239
|
* ```typescript
|
|
4232
|
-
* // Get all cookies
|
|
4233
4240
|
* const cookies = rezo.getCookies();
|
|
4234
4241
|
*
|
|
4235
|
-
* // Access
|
|
4236
|
-
* const
|
|
4237
|
-
*
|
|
4238
|
-
* for (const cookie of exampleCookies) {
|
|
4239
|
-
* console.log(`${cookie.key}=${cookie.value}`);
|
|
4240
|
-
* }
|
|
4242
|
+
* // Access as Cookie instances for programmatic use
|
|
4243
|
+
* for (const cookie of cookies.array) {
|
|
4244
|
+
* console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
|
|
4241
4245
|
* }
|
|
4242
4246
|
*
|
|
4243
|
-
* //
|
|
4244
|
-
*
|
|
4245
|
-
*
|
|
4247
|
+
* // Get cookie header string for manual HTTP requests
|
|
4248
|
+
* console.log(cookies.string); // "session=abc123; user=john"
|
|
4249
|
+
*
|
|
4250
|
+
* // Save to Netscape cookie file
|
|
4251
|
+
* fs.writeFileSync('cookies.txt', cookies.netscape);
|
|
4246
4252
|
*
|
|
4247
|
-
* //
|
|
4248
|
-
* const
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
4253
|
+
* // Serialize to JSON for storage
|
|
4254
|
+
* const json = JSON.stringify(cookies.serialized);
|
|
4255
|
+
* localStorage.setItem('cookies', json);
|
|
4256
|
+
*
|
|
4257
|
+
* // Get Set-Cookie headers (useful for proxying responses)
|
|
4258
|
+
* for (const setCookie of cookies.setCookiesString) {
|
|
4259
|
+
* console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
|
|
4260
|
+
* }
|
|
4251
4261
|
*
|
|
4252
|
-
* //
|
|
4253
|
-
*
|
|
4262
|
+
* // Check cookie count
|
|
4263
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4254
4264
|
*
|
|
4255
|
-
* //
|
|
4256
|
-
* const
|
|
4257
|
-
* ?.some(c => c.key === 'session');
|
|
4265
|
+
* // Find specific cookie
|
|
4266
|
+
* const sessionCookie = cookies.array.find(c => c.key === 'session');
|
|
4258
4267
|
* ```
|
|
4259
4268
|
*
|
|
4260
4269
|
* @see {@link setCookies} - Set cookies in the jar
|
|
4270
|
+
* @see {@link clearCookies} - Remove all cookies from the jar
|
|
4261
4271
|
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
|
|
4262
4272
|
*/
|
|
4263
4273
|
getCookies(): Cookies;
|
|
4274
|
+
/**
|
|
4275
|
+
* Remove all cookies from the cookie jar.
|
|
4276
|
+
*
|
|
4277
|
+
* This method synchronously clears the entire cookie store, removing all
|
|
4278
|
+
* cookies regardless of domain, path, or expiration. Useful for:
|
|
4279
|
+
* - Logging out users and clearing session state
|
|
4280
|
+
* - Resetting the client to a clean state between test runs
|
|
4281
|
+
* - Implementing "clear cookies" functionality in applications
|
|
4282
|
+
* - Starting fresh before authenticating with different credentials
|
|
4283
|
+
*
|
|
4284
|
+
* This operation is immediate and cannot be undone. If you need to preserve
|
|
4285
|
+
* certain cookies, use {@link getCookies} to save them before clearing,
|
|
4286
|
+
* then restore specific ones with {@link setCookies}.
|
|
4287
|
+
*
|
|
4288
|
+
* @example
|
|
4289
|
+
* ```typescript
|
|
4290
|
+
* // Simple logout - clear all cookies
|
|
4291
|
+
* rezo.clearCookies();
|
|
4292
|
+
*
|
|
4293
|
+
* // Save cookies before clearing (if needed)
|
|
4294
|
+
* const savedCookies = rezo.getCookies();
|
|
4295
|
+
* rezo.clearCookies();
|
|
4296
|
+
* // Later, restore specific cookies if needed
|
|
4297
|
+
* const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
|
|
4298
|
+
* rezo.setCookies(importantCookies);
|
|
4299
|
+
*
|
|
4300
|
+
* // Clear and re-authenticate
|
|
4301
|
+
* rezo.clearCookies();
|
|
4302
|
+
* await rezo.post('https://api.example.com/login', {
|
|
4303
|
+
* username: 'newuser',
|
|
4304
|
+
* password: 'newpass'
|
|
4305
|
+
* });
|
|
4306
|
+
*
|
|
4307
|
+
* // Use in test teardown
|
|
4308
|
+
* afterEach(() => {
|
|
4309
|
+
* rezo.clearCookies(); // Clean state for next test
|
|
4310
|
+
* });
|
|
4311
|
+
* ```
|
|
4312
|
+
*
|
|
4313
|
+
* @see {@link getCookies} - Get all cookies before clearing
|
|
4314
|
+
* @see {@link setCookies} - Restore or set new cookies after clearing
|
|
4315
|
+
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
|
|
4316
|
+
*/
|
|
4317
|
+
clearCookies(): void;
|
|
4264
4318
|
}
|
|
4265
4319
|
/**
|
|
4266
4320
|
* Extended Rezo instance with Axios-compatible static helpers.
|
|
@@ -4104,6 +4104,7 @@ export declare class Rezo {
|
|
|
4104
4104
|
private __create;
|
|
4105
4105
|
/** Get the cookie jar for this instance */
|
|
4106
4106
|
get cookieJar(): RezoCookieJar;
|
|
4107
|
+
set cookieJar(jar: RezoCookieJar);
|
|
4107
4108
|
/**
|
|
4108
4109
|
* Save cookies to file (if cookieFile is configured).
|
|
4109
4110
|
* Can also specify a different path to save to.
|
|
@@ -4219,48 +4220,101 @@ export declare class Rezo {
|
|
|
4219
4220
|
setCookies(setCookieArray: string[], url: string, startNew?: boolean): void;
|
|
4220
4221
|
setCookies(setCookieArray: string[], url: string | undefined, startNew: boolean): void;
|
|
4221
4222
|
/**
|
|
4222
|
-
* Get all cookies from the cookie jar.
|
|
4223
|
+
* Get all cookies from the cookie jar in multiple convenient formats.
|
|
4223
4224
|
*
|
|
4224
|
-
* Returns a `Cookies` object
|
|
4225
|
-
*
|
|
4226
|
-
*
|
|
4225
|
+
* Returns a `Cookies` object containing all stored cookies in various formats
|
|
4226
|
+
* for different use cases. This provides flexible access to cookies for
|
|
4227
|
+
* HTTP headers, file storage, serialization, or programmatic manipulation.
|
|
4227
4228
|
*
|
|
4228
|
-
*
|
|
4229
|
+
* The returned `Cookies` object contains:
|
|
4230
|
+
* - **array**: `Cookie[]` - Array of Cookie class instances for programmatic access
|
|
4231
|
+
* - **serialized**: `SerializedCookie[]` - Plain objects for JSON serialization/storage
|
|
4232
|
+
* - **netscape**: `string` - Netscape cookie file format for file-based storage
|
|
4233
|
+
* - **string**: `string` - Cookie header format (`key=value; key2=value2`) for HTTP requests
|
|
4234
|
+
* - **setCookiesString**: `string[]` - Array of Set-Cookie header strings
|
|
4235
|
+
*
|
|
4236
|
+
* @returns A Cookies object with cookies in multiple formats
|
|
4229
4237
|
*
|
|
4230
4238
|
* @example
|
|
4231
4239
|
* ```typescript
|
|
4232
|
-
* // Get all cookies
|
|
4233
4240
|
* const cookies = rezo.getCookies();
|
|
4234
4241
|
*
|
|
4235
|
-
* // Access
|
|
4236
|
-
* const
|
|
4237
|
-
*
|
|
4238
|
-
* for (const cookie of exampleCookies) {
|
|
4239
|
-
* console.log(`${cookie.key}=${cookie.value}`);
|
|
4240
|
-
* }
|
|
4242
|
+
* // Access as Cookie instances for programmatic use
|
|
4243
|
+
* for (const cookie of cookies.array) {
|
|
4244
|
+
* console.log(`${cookie.key}=${cookie.value} (expires: ${cookie.expires})`);
|
|
4241
4245
|
* }
|
|
4242
4246
|
*
|
|
4243
|
-
* //
|
|
4244
|
-
*
|
|
4245
|
-
*
|
|
4247
|
+
* // Get cookie header string for manual HTTP requests
|
|
4248
|
+
* console.log(cookies.string); // "session=abc123; user=john"
|
|
4249
|
+
*
|
|
4250
|
+
* // Save to Netscape cookie file
|
|
4251
|
+
* fs.writeFileSync('cookies.txt', cookies.netscape);
|
|
4246
4252
|
*
|
|
4247
|
-
* //
|
|
4248
|
-
* const
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
4253
|
+
* // Serialize to JSON for storage
|
|
4254
|
+
* const json = JSON.stringify(cookies.serialized);
|
|
4255
|
+
* localStorage.setItem('cookies', json);
|
|
4256
|
+
*
|
|
4257
|
+
* // Get Set-Cookie headers (useful for proxying responses)
|
|
4258
|
+
* for (const setCookie of cookies.setCookiesString) {
|
|
4259
|
+
* console.log(setCookie); // "session=abc123; Domain=example.com; Path=/; HttpOnly"
|
|
4260
|
+
* }
|
|
4251
4261
|
*
|
|
4252
|
-
* //
|
|
4253
|
-
*
|
|
4262
|
+
* // Check cookie count
|
|
4263
|
+
* console.log(`Total cookies: ${cookies.array.length}`);
|
|
4254
4264
|
*
|
|
4255
|
-
* //
|
|
4256
|
-
* const
|
|
4257
|
-
* ?.some(c => c.key === 'session');
|
|
4265
|
+
* // Find specific cookie
|
|
4266
|
+
* const sessionCookie = cookies.array.find(c => c.key === 'session');
|
|
4258
4267
|
* ```
|
|
4259
4268
|
*
|
|
4260
4269
|
* @see {@link setCookies} - Set cookies in the jar
|
|
4270
|
+
* @see {@link clearCookies} - Remove all cookies from the jar
|
|
4261
4271
|
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more methods
|
|
4262
4272
|
*/
|
|
4263
4273
|
getCookies(): Cookies;
|
|
4274
|
+
/**
|
|
4275
|
+
* Remove all cookies from the cookie jar.
|
|
4276
|
+
*
|
|
4277
|
+
* This method synchronously clears the entire cookie store, removing all
|
|
4278
|
+
* cookies regardless of domain, path, or expiration. Useful for:
|
|
4279
|
+
* - Logging out users and clearing session state
|
|
4280
|
+
* - Resetting the client to a clean state between test runs
|
|
4281
|
+
* - Implementing "clear cookies" functionality in applications
|
|
4282
|
+
* - Starting fresh before authenticating with different credentials
|
|
4283
|
+
*
|
|
4284
|
+
* This operation is immediate and cannot be undone. If you need to preserve
|
|
4285
|
+
* certain cookies, use {@link getCookies} to save them before clearing,
|
|
4286
|
+
* then restore specific ones with {@link setCookies}.
|
|
4287
|
+
*
|
|
4288
|
+
* @example
|
|
4289
|
+
* ```typescript
|
|
4290
|
+
* // Simple logout - clear all cookies
|
|
4291
|
+
* rezo.clearCookies();
|
|
4292
|
+
*
|
|
4293
|
+
* // Save cookies before clearing (if needed)
|
|
4294
|
+
* const savedCookies = rezo.getCookies();
|
|
4295
|
+
* rezo.clearCookies();
|
|
4296
|
+
* // Later, restore specific cookies if needed
|
|
4297
|
+
* const importantCookies = savedCookies.array.filter(c => c.key === 'preferences');
|
|
4298
|
+
* rezo.setCookies(importantCookies);
|
|
4299
|
+
*
|
|
4300
|
+
* // Clear and re-authenticate
|
|
4301
|
+
* rezo.clearCookies();
|
|
4302
|
+
* await rezo.post('https://api.example.com/login', {
|
|
4303
|
+
* username: 'newuser',
|
|
4304
|
+
* password: 'newpass'
|
|
4305
|
+
* });
|
|
4306
|
+
*
|
|
4307
|
+
* // Use in test teardown
|
|
4308
|
+
* afterEach(() => {
|
|
4309
|
+
* rezo.clearCookies(); // Clean state for next test
|
|
4310
|
+
* });
|
|
4311
|
+
* ```
|
|
4312
|
+
*
|
|
4313
|
+
* @see {@link getCookies} - Get all cookies before clearing
|
|
4314
|
+
* @see {@link setCookies} - Restore or set new cookies after clearing
|
|
4315
|
+
* @see {@link cookieJar} - Access the underlying RezoCookieJar for more control
|
|
4316
|
+
*/
|
|
4317
|
+
clearCookies(): void;
|
|
4264
4318
|
}
|
|
4265
4319
|
/**
|
|
4266
4320
|
* Extended Rezo instance with Axios-compatible static helpers.
|