import type { AuthUser } from "@getstrata/core/auth/authContext"; import { type AuthGuard, AuthManager } from "@getstrata/core/auth/guard"; export interface SessionUser { id: number; name: string; email: string; learn_subscriber?: boolean; is_admin?: boolean; email_verified_at?: Date | string | null; } type SqlClient = { unsafe(query: string, params?: readonly unknown[]): Promise; }; type SqlSource = SqlClient | (() => SqlClient); export type LoadSessionUser = (sql: SqlClient, sessionId: string) => Promise; export interface SessionCreateMeta { userAgent?: string | null; ipAddress?: string | null; } export interface BrowserSessionRecord { id: string; user_id: number; user_agent: string | null; ip_address: string | null; last_active_at: Date | string | null; expires_at: Date | string; } declare function defaultSessionSql(): SqlClient; export type MapSessionUser = (user: SessionUser) => AuthUser; declare function defaultMapSessionUser(user: SessionUser): AuthUser; export declare class CookieSessionStore { private readonly sqlSource; private readonly secret; private readonly cookieName; private readonly maxAgeSeconds; private readonly loadSessionUser; constructor(sqlSource: SqlSource, secret: string, cookieName?: string, maxAgeSeconds?: number, loadSessionUser?: LoadSessionUser); cookieHeader(_user: SessionUser, sessionId: string): string; clearCookieHeader(): string; sessionIdFromRequest(request: Request): string | null; private withSecureFlag; private sql; create(user: SessionUser, meta?: SessionCreateMeta): Promise; destroy(sessionId: string): Promise; destroyAllSessions(userId: number): Promise; destroyOtherSessions(userId: number, keepSessionId: string): Promise; listForUser(userId: number): Promise; touch(sessionId: string): Promise; read(request: Request): Promise; private sign; } export declare class CookieSessionGuard implements AuthGuard { private readonly store; private readonly mapUser; constructor(store: CookieSessionStore, mapUser?: MapSessionUser); resolve(request: Request): Promise; } export declare class CookieSessionAuthManager extends AuthManager { readonly store: CookieSessionStore; constructor(store: CookieSessionStore, mapUser?: MapSessionUser); signIn(user: SessionUser, meta?: SessionCreateMeta): Promise<{ sessionId: string; setCookie: string; }>; signOut(request: Request): Promise<{ setCookie: string; }>; signInRedirect(user: SessionUser, location: string, status?: number, meta?: SessionCreateMeta): Promise; signOutRedirect(request: Request, location: string, status?: number): Promise; } export interface CreateCookieSessionAuthManagerOptions { store?: CookieSessionStore; sql?: SqlSource; secret?: string; cookieName?: string; maxAgeSeconds?: number; mapUser?: MapSessionUser; loadSessionUser?: LoadSessionUser; } declare function createCookieSessionAuthManager(options?: CreateCookieSessionAuthManagerOptions): CookieSessionAuthManager; export { createCookieSessionAuthManager, defaultMapSessionUser, defaultSessionSql };