UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

115 lines • 3.53 kB
import { AuthClient, SessionData } from "./auth.mjs"; import { QueryClient } from "@tanstack/react-query"; //#region src/ui/auth-guards.d.ts interface AuthContext { isAuthenticated: boolean; user: SessionData["user"] | null; session: SessionData["session"] | null; activeOrganizationId: string | null; isAnonymous: boolean; isAdmin: boolean; isBanned: boolean; } interface AuthGuardContext { queryClient: QueryClient; authClient: AuthClient; } interface AuthGuardArgs { context: AuthGuardContext; location: { href: string; }; } declare function requireSession({ context, location }: AuthGuardArgs): Promise<{ auth: AuthContext; session: { user: import("better-auth").StripEmptyObjects<{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: boolean; name: string; image?: string | null | undefined; } & {} & { locale?: string | null | undefined; } & { banned: boolean | null | undefined; } & { banExpires?: Date | null | undefined; banReason?: string | null | undefined; role?: string | null | undefined; } & { isAnonymous: boolean | null | undefined; } & {} & {} & { phoneNumber?: string | null | undefined; phoneNumberVerified?: boolean | null | undefined; }>; session: import("better-auth").StripEmptyObjects<{ id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; } & {} & {} & {} & { impersonatedBy?: string | null | undefined; } & {} & { activeOrganizationId?: string | null | undefined; activeTeamId?: string | null | undefined; }>; }; }>; declare function requireAdmin(args: AuthGuardArgs): Promise<{ auth: AuthContext; session: { user: import("better-auth").StripEmptyObjects<{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: boolean; name: string; image?: string | null | undefined; } & {} & { locale?: string | null | undefined; } & { banned: boolean | null | undefined; } & { banExpires?: Date | null | undefined; banReason?: string | null | undefined; role?: string | null | undefined; } & { isAnonymous: boolean | null | undefined; } & {} & {} & { phoneNumber?: string | null | undefined; phoneNumberVerified?: boolean | null | undefined; }>; session: import("better-auth").StripEmptyObjects<{ id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; } & {} & {} & {} & { impersonatedBy?: string | null | undefined; } & {} & { activeOrganizationId?: string | null | undefined; activeTeamId?: string | null | undefined; }>; }; }>; /** * Clears private and public query data on sign-out while leaving an explicit * signed-out session entry — the cache must remember "signed out" so a late * router-context session cannot resurrect stale authed state. */ declare function clearAuthenticatedQueries(queryClient: QueryClient): Promise<void>; //#endregion export { AuthContext, AuthGuardArgs, clearAuthenticatedQueries, requireAdmin, requireSession }; //# sourceMappingURL=auth-guards.d.mts.map