Files
SnowLuma/.pnpm-store/v11/files/7d/390dcfe5754de150a3ca4bd3ddde8311ece5652e9784e432621b8a46ef1c2ae9ef18f57f0ea2f93d98df8ba2f130e8d5be8f6e863fd5fbb6ceff772842135d
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

43 lines
1.5 KiB
Plaintext

//#region src/utils/cookie.d.ts
/**
* @module
* Cookie utility.
*/
export type Cookie = Record<string, string>;
export type SignedCookie = Record<string, string | false>;
type PartitionedCookieConstraint = {
partitioned: true;
secure: true;
} | {
partitioned?: boolean;
secure?: boolean;
};
type SecureCookieConstraint = {
secure: true;
};
type HostCookieConstraint = {
secure: true;
path: '/';
domain?: undefined;
};
export type CookieOptions = {
domain?: string;
expires?: Date;
httpOnly?: boolean;
maxAge?: number;
path?: string;
secure?: boolean;
sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none';
partitioned?: boolean;
priority?: 'Low' | 'Medium' | 'High' | 'low' | 'medium' | 'high';
prefix?: CookiePrefixOptions;
} & PartitionedCookieConstraint;
export type CookiePrefixOptions = 'host' | 'secure';
export type CookieConstraint<Name> = Name extends `__Secure-${string}` ? CookieOptions & SecureCookieConstraint : Name extends `__Host-${string}` ? CookieOptions & HostCookieConstraint : CookieOptions;
export declare const parse: (cookie: string, name?: string) => Cookie;
export declare const parseSigned: (cookie: string, secret: string | BufferSource, name?: string) => Promise<SignedCookie>;
export declare const serialize: <Name extends string>(name: Name, value: string, opt?: CookieConstraint<Name>) => string;
export declare const serializeSigned: (name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<string>;
//#endregion
export {};