import { type Request, type Response } from 'express'; import { z } from 'zod'; export { setCookie } from './cookie-policy.js'; /** * Parameters used for auth-flow redirects and context persistence. */ export declare const AuthFlowParamsSchema: z.ZodObject<{ redirectTo: z.ZodEffects, string | undefined, unknown>; appRedirectTo: z.ZodEffects, string | undefined, unknown>; source: z.ZodEffects, string | undefined, unknown>; clientId: z.ZodEffects, string | undefined, unknown>; codeChallenge: z.ZodEffects, string | undefined, unknown>; projectId: z.ZodEffects, string | undefined, unknown>; extraParams: z.ZodEffects>, Record | undefined, unknown>; }, "strip", z.ZodTypeAny, { clientId?: string | undefined; source?: string | undefined; projectId?: string | undefined; appRedirectTo?: string | undefined; redirectTo?: string | undefined; codeChallenge?: string | undefined; extraParams?: Record | undefined; }, { clientId?: unknown; source?: unknown; projectId?: unknown; appRedirectTo?: unknown; redirectTo?: unknown; codeChallenge?: unknown; extraParams?: unknown; }>; export type AuthFlowParams = z.infer; export declare function parseAuthFlowParams(value: unknown): AuthFlowParams | undefined; export declare function parseSerializedAuthFlowParams(value: unknown): AuthFlowParams | undefined; export declare function serializeAuthFlowParams(params?: AuthFlowParams): string | null; /** * Centralized state handling with single-source validation. */ export declare class StateManager { private readonly req; private readonly stateFromCookie; private readonly queryState; constructor(req: Request); extract(): string; extractFromCookie(): string; hasMismatch(): boolean; persist(res: Response, state: string): void; } declare module 'express' { interface Request { _stateManager?: StateManager; } } /** * Returns a cached StateManager instance for the request. */ export declare function getStateManager(req: Request): StateManager; /** * Reads a cookie value from request headers or cookie parser. */ export declare function getCookie(req: Request, name: string): string | undefined; /** * Reads a single query string value by key. * Returns the first item when query param is an array. */ export declare function readQueryString(req: Request, key: string): string | undefined; /** * Clears auth-flow cookies (state and params). */ export declare function clearAuthFlowCookies(res: Response, req?: Request): void; /** * Clears only the auth-flow PKCE state cookie. */ export declare function clearAuthFlowStateCookie(res: Response, req?: Request): void; /** * Clears Better Auth session and CSRF cookies. */ export declare function clearBetterAuthCookies(res: Response, req?: Request): void; /** * Clears all auth-related cookies (Platform + Better Auth). */ export declare function clearAllAuthCookies(res: Response, req?: Request): void; /** * Persists the PKCE state into a cookie. */ export declare function persistStateCookie(req: Request, res: Response, state: string): void; /** * Extracts state from cookie or query, with mismatch protection. */ export declare function extractState(req: Request): string; /** * Extracts state only from the cookie. */ export declare function extractStateFromCookie(req: Request): string; /** * Returns true when cookie state and query state mismatch. */ export declare function hasStateMismatch(req: Request): boolean; /** * Extracts redirect parameters from cookie or query. */ export declare function extractAuthFlowParams(req: Request): AuthFlowParams; /** * Persists redirect parameters into a cookie. */ export declare function persistAuthFlowParams(req: Request, res: Response, params: AuthFlowParams): void; /** * Persists both state and redirect parameters into cookies. */ export declare function persistAuthFlowContext(req: Request, res: Response, context: { state?: string; params: AuthFlowParams; }): void; /** * Extracts the core refresh token from cookies. */ export declare const extractRefreshToken: (req: Request) => string | undefined; //# sourceMappingURL=request-utils.d.ts.map