fexios
Version:
Fetch based HTTP client with similar API to axios for browser and Node.js
105 lines (101 loc) • 2.53 kB
text/typescript
import { n as FexiosPlugin } from '../shared/fexios.Dv4hmoGv.mjs';
import '../shared/fexios.uBjPg0Vb.mjs';
/**
* Cookie object interface
*/
interface CookieJarItem {
name: string;
value: string;
domain?: string;
path?: string;
expires?: Date;
maxAge?: number;
secure?: boolean;
httpOnly?: boolean;
sameSite?: 'Strict' | 'Lax' | 'None';
_createdAt?: Date;
_hostOnly?: boolean;
}
/**
* Cookie Jar
*
* @author dragon-fish <dragon-fish@qq.com>
* @license MIT
*/
declare class CookieJar {
private cookies;
/**
* Set a cookie
*/
setCookie(cookie: CookieJarItem, domain?: string, path?: string): void;
/**
* Get a cookie
*/
getCookie(name: string, domain?: string, path?: string): CookieJarItem | undefined;
/**
* Get all matching cookies
*/
getCookies(domain?: string, path?: string): CookieJarItem[];
/**
* Delete a cookie
*/
deleteCookie(name: string, domain?: string, path?: string): boolean;
/**
* Clear all cookies
*/
clear(): void;
/**
* Clean expired cookies
*/
cleanExpiredCookies(): number;
/**
* Get all cookies (including expired ones)
*/
getAllCookies(domain?: string, path?: string): CookieJarItem[];
/**
* Parse cookies from Set-Cookie header
*/
parseSetCookieHeader(setCookieHeader: string, domain?: string, path?: string): void;
/**
* Generate Cookie header string
*/
getCookieHeader(domain?: string, path?: string): string;
/**
* Get the unique key for a cookie
*/
private getCookieKey;
/**
* Check if cookie matches the given domain and path
*/
private isCookieMatch;
/**
* Check if domain matches
*/
private isDomainMatch;
/**
* Check if path matches
*/
private isPathMatch;
/**
* Check if cookie is expired
*/
private isCookieExpired;
/**
* Parse cookie string
*/
private parseCookieString;
/**
* Safely split a possibly-combined Set-Cookie header string into individual cookie strings.
* Split on commas that are followed by the start of a new cookie-pair (name=),
* avoiding commas inside Expires attribute values.
*/
private splitSetCookieHeader;
}
declare module '@/index.js' {
interface Fexios {
cookieJar?: CookieJar;
}
}
declare const pluginCookieJar: FexiosPlugin;
export { CookieJar, pluginCookieJar };
export type { CookieJarItem };