import { QueryClient } from '@tanstack/react-query'; import { AthenaAuthBindings, AthenaClient } from '@xylex-group/athena'; import { AuthClient, BetterAuthProviderProps as AuthProviderPropsPrimitive } from '../../compat/better-auth/primitive-provider.js'; import { AthenaAuthUiOptions } from '../../lib/auth/core/ui-options.js'; /** * Structural root carrier: only requires `.auth`. * * Prefer this over naming `AthenaClient` in public React props so * `createClient()` results and test doubles assign without `as never`. */ export interface AthenaUiRootClient { readonly auth: unknown; } /** * Published Athena root-client alias. Keep this as `AthenaClient` so * existing `client.from(...)` / `client.rpc(...)` call sites type-check. * Do not point this at {@link AthenaUiRootClient} — that firebreak is only * for React provider props. */ export type AthenaClientRoot = AthenaClient; /** * Client accepted by {@link AuthProvider}: * - Better Auth UI `AuthClient` * - Full Athena root client (`createClient()` / structural root) * - Standalone auth bindings from `createAthenaAuthClient()` / `createClient().auth` * * Canonical path: pass the root Athena client via `client={athena}` so Auth UI * consumes `athena.auth` without a second constructor. */ export type CompatibleAuthClient = AuthClient | AthenaUiRootClient | AthenaAuthBindings; /** * Stable package alias for the auth client passed into {@link AuthProvider}. * Use with organization hooks as {@link OrganizationCapableAuthClient} when the * organization plugin is installed. */ export type AthenaAuthClient = CompatibleAuthClient; type AuthProviderBaseProps = Omit, "authClient">; interface AuthProviderClientProps { authClient?: never; /** * Canonical Athena root client. Auth UI derives `.auth` and applies * compatibility shims once (no second `createClient`). * * Structural {@link AthenaUiRootClient} only — never name `AthenaClient` here * (TS2589 in consumer apps). */ client: AthenaUiRootClient; } interface AuthProviderAuthClientProps { /** * Prefer a plugin-typed client (e.g. organization plugin) so hooks under * this provider can reuse `TAuthClient` without widening to `unknown`. * * Full Athena root clients are accepted and normalized to `.auth`. */ authClient: TAuthClient; client?: never; } export type AuthProviderProps = AuthProviderBaseProps & (AuthProviderClientProps | AuthProviderAuthClientProps) & { /** * When true (default), mounts {@link AthenaToastProvider} so package toast * helpers work without a separate app-level `Toast.Provider`. * Set false if the host already mounts HeroUI `Toast.Provider` / `AthenaToastProvider`. */ toastProvider?: boolean; ui?: AthenaAuthUiOptions; /** Shared TanStack Query client (resource caches — not identity SSOT). */ queryClient?: QueryClient; /** Presentation override; prefer SDK capabilities when known. */ twoFactor?: boolean; }; /** * Heroui-flavored `AuthProvider`. Wraps the primitive provider with a * heroui `RouterProvider`, optional {@link AthenaToastProvider}, and the * heroui `ErrorToaster`. * * Prefer `client={athena}` from a single `createClient()` instance. */ export declare function AuthProvider({ children, navigate, toastProvider, ui, client, authClient, queryClient: queryClientProp, ...config }: AuthProviderProps): import("react").JSX.Element; export {};