rezo 1.0.7 → 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.
- package/dist/adapters/entries/curl.cjs +2 -1
- package/dist/adapters/entries/curl.d.ts +100 -1
- package/dist/adapters/entries/curl.js +2 -2
- package/dist/adapters/entries/fetch.cjs +2 -1
- package/dist/adapters/entries/fetch.d.ts +100 -1
- package/dist/adapters/entries/fetch.js +2 -2
- package/dist/adapters/entries/http.cjs +2 -1
- package/dist/adapters/entries/http.d.ts +100 -1
- package/dist/adapters/entries/http.js +2 -1
- package/dist/adapters/entries/http2.cjs +2 -1
- package/dist/adapters/entries/http2.d.ts +100 -1
- package/dist/adapters/entries/http2.js +2 -2
- package/dist/adapters/entries/react-native.cjs +2 -1
- package/dist/adapters/entries/react-native.d.ts +100 -1
- package/dist/adapters/entries/react-native.js +2 -2
- package/dist/adapters/entries/xhr.cjs +2 -1
- package/dist/adapters/entries/xhr.d.ts +100 -1
- package/dist/adapters/entries/xhr.js +2 -2
- 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 +99 -0
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +24 -23
- package/dist/index.d.ts +100 -1
- package/dist/index.js +1 -1
- package/dist/platform/browser.cjs +2 -1
- package/dist/platform/browser.d.ts +100 -1
- package/dist/platform/browser.js +2 -2
- package/dist/platform/bun.cjs +2 -1
- package/dist/platform/bun.d.ts +100 -1
- package/dist/platform/bun.js +2 -2
- package/dist/platform/deno.cjs +2 -1
- package/dist/platform/deno.d.ts +100 -1
- package/dist/platform/deno.js +2 -2
- package/dist/platform/node.cjs +2 -1
- package/dist/platform/node.d.ts +100 -1
- package/dist/platform/node.js +2 -2
- package/dist/platform/react-native.cjs +2 -1
- package/dist/platform/react-native.d.ts +100 -1
- package/dist/platform/react-native.js +2 -2
- package/dist/platform/worker.cjs +2 -1
- package/dist/platform/worker.d.ts +100 -1
- package/dist/platform/worker.js +2 -2
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/queue/index.cjs +8 -8
- package/dist/utils/cookies.cjs +0 -2
- package/dist/utils/cookies.js +0 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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.
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ export { RezoError };
|
|
|
12
12
|
export { RezoErrorCode };
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
|
-
export { RezoCookieJar };
|
|
15
|
+
export { RezoCookieJar, Cookie };
|
|
16
16
|
export { createDefaultHooks };
|
|
17
17
|
export { mergeHooks };
|
|
18
18
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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.
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ export { RezoError };
|
|
|
12
12
|
export { RezoErrorCode };
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
|
-
export { RezoCookieJar };
|
|
15
|
+
export { RezoCookieJar, Cookie };
|
|
16
16
|
export { createDefaultHooks };
|
|
17
17
|
export { mergeHooks };
|
|
18
18
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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.
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ export { RezoErrorCode };
|
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
15
|
export { RezoCookieJar };
|
|
16
|
+
export { Cookie };
|
|
16
17
|
export { createDefaultHooks };
|
|
17
18
|
export { mergeHooks };
|
|
18
19
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|
|
@@ -156,7 +156,7 @@ export interface SerializedCookie {
|
|
|
156
156
|
lastAccessed?: string;
|
|
157
157
|
[key: string]: unknown;
|
|
158
158
|
}
|
|
159
|
-
declare class Cookie extends TouchCookie {
|
|
159
|
+
export declare class Cookie extends TouchCookie {
|
|
160
160
|
constructor(options?: CreateCookieOptions);
|
|
161
161
|
/**
|
|
162
162
|
* Fixes date fields that may have become strings during JSON deserialization.
|
|
@@ -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.
|
|
@@ -3,7 +3,7 @@ import { setGlobalAdapter, createRezoInstance, Rezo } from '../../core/rezo.js';
|
|
|
3
3
|
import { RezoError, RezoErrorCode } from '../../errors/rezo-error.js';
|
|
4
4
|
import { RezoHeaders } from '../../utils/headers.js';
|
|
5
5
|
import { RezoFormData } from '../../utils/form-data.js';
|
|
6
|
-
import { RezoCookieJar } from '../../utils/cookies.js';
|
|
6
|
+
import { RezoCookieJar, Cookie } from '../../utils/cookies.js';
|
|
7
7
|
import { createDefaultHooks, mergeHooks } from '../../core/hooks.js';
|
|
8
8
|
import packageJson from "../../../package.json" with { type: 'json' };
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ export { RezoError };
|
|
|
12
12
|
export { RezoErrorCode };
|
|
13
13
|
export { RezoHeaders };
|
|
14
14
|
export { RezoFormData };
|
|
15
|
-
export { RezoCookieJar };
|
|
15
|
+
export { RezoCookieJar, Cookie };
|
|
16
16
|
export { createDefaultHooks };
|
|
17
17
|
export { mergeHooks };
|
|
18
18
|
export const isRezoError = RezoError.isRezoError;
|
|
@@ -3,7 +3,7 @@ const { setGlobalAdapter, createRezoInstance, Rezo } = require('../../core/rezo.
|
|
|
3
3
|
const { RezoError, RezoErrorCode } = require('../../errors/rezo-error.cjs');
|
|
4
4
|
const { RezoHeaders } = require('../../utils/headers.cjs');
|
|
5
5
|
const { RezoFormData } = require('../../utils/form-data.cjs');
|
|
6
|
-
const { RezoCookieJar } = require('../../utils/cookies.cjs');
|
|
6
|
+
const { RezoCookieJar, Cookie } = require('../../utils/cookies.cjs');
|
|
7
7
|
const { createDefaultHooks, mergeHooks } = require('../../core/hooks.cjs');
|
|
8
8
|
const packageJson = require("../../../package.json");
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ exports.RezoErrorCode = RezoErrorCode;
|
|
|
13
13
|
exports.RezoHeaders = RezoHeaders;
|
|
14
14
|
exports.RezoFormData = RezoFormData;
|
|
15
15
|
exports.RezoCookieJar = RezoCookieJar;
|
|
16
|
+
exports.Cookie = Cookie;
|
|
16
17
|
exports.createDefaultHooks = createDefaultHooks;
|
|
17
18
|
exports.mergeHooks = mergeHooks;
|
|
18
19
|
const isRezoError = exports.isRezoError = RezoError.isRezoError;
|