integratedhub/utils.ts
2026-02-14 02:20:19 +00:00

28 lines
710 B
TypeScript
Executable File

// utils.ts
import { createDefine, type PageProps as FreshPageProps } from "fresh";
import type { SessionCookie } from "./routes/auth/callback.ts";
import type { User } from "./services/userService.ts";
export interface AuthState {
isAuthenticated: boolean;
userId: string | null;
userType: string | null;
roles: string[];
}
export interface State {
data: SessionCookie;
urlRoute: string;
host: string;
photoUrl: string;
stateId: string;
sealKey?: string; // The validated seal key for the current session
user?: User | null;
auth?: AuthState;
authError?: string;
}
export type PageProps<Data = unknown> = FreshPageProps<Data, State>;
export const define = createDefine<State>();