import { QueryClient } from '@tanstack/react-query'; import { ReactNode } from 'react'; import { AthenaAuthRoutingDebugConfig, AthenaAuthRoutingDebugPersistenceOptions } from '../../auth/routing-debug.js'; import { AthenaUiPrimitives } from '../../design/primitives/index.js'; import { AuthPlugin } from '../../lib/auth/core/auth-plugin.js'; import { AthenaAuthUiOptions } from '../../lib/auth/core/ui-options.js'; import { AthenaUiRootClient, CompatibleAuthClient } from './auth-provider.js'; import { AthenaInitialAuthState } from './initial-auth-state.js'; export interface AthenaProvidersRoutingDebugOptions { config?: AthenaAuthRoutingDebugConfig; defaultConfig: AthenaAuthRoutingDebugConfig | string; enabled?: boolean; onConfigChange?: (config: AthenaAuthRoutingDebugConfig) => void; persistence?: AthenaAuthRoutingDebugPersistenceOptions; publicUpstreamUrl?: string; } export type { AthenaInitialAuthState } from './initial-auth-state.js'; export type AthenaProvidersNavigate = (args: { to: string; replace?: boolean; }) => void | Promise; /** * Presentation / feature overrides for Auth UI. * * Backend capabilities should normally come from `athena.auth.capabilities`. * These fields remain for presentation overrides and advanced composition — * they are not a second auth client configuration. */ export interface AthenaProvidersUiFeatureProps { /** * @advanced Page-tree Auth UI path prefix. Not Discovery 1.1 / Auth HTTP. */ basePath?: string; /** * @advanced Cookie presentation for Auth UI fetches. Not ordinary topology. */ credentials?: RequestCredentials; /** * @advanced Password/email form presentation overrides. * Prefer capabilities for enablement when status is known. */ emailAndPassword?: { confirmPassword?: boolean; enabled?: boolean; forgotPassword?: boolean; name?: boolean; requireEmailVerification?: boolean; }; /** @advanced Organization UI presentation override. */ organization?: boolean; /** @advanced Passkey presentation override. */ passkey?: boolean; /** @advanced Athena Auth UI plugins (organization, passkey, billing, …). */ plugins?: AuthPlugin[]; /** Optional renderer-neutral primitive overrides. */ primitives?: Partial; /** Post-auth redirect path. */ redirectTo?: string; /** * @advanced Explicit social provider list override. * Prefer discovery via `athena.auth.capabilities` when status is known. */ socialProviders?: string[]; /** * @advanced 2FA presentation override. * Prefer `athena.auth.capabilities.twoFactor` when the snapshot includes it. * Never inferred from Better Auth plugin ids. */ twoFactor?: boolean; /** @advanced Username sign-in presentation. */ username?: boolean | { enabled?: boolean; }; /** * @deprecated Prefer sparse `ui.auth.routes` / defaults. * @advanced */ viewPaths?: Record; } /** * Public client prop is structural-only ({@link AthenaUiRootClient}). * Do not union `AthenaClient` / `AthenaClientRoot` here — assignability checks * against those aliases re-enter schema generics and hit TS2589 in app tsconfigs. */ type AthenaProvidersClientSource = { /** Canonical Athena root client (`createClient()`). Structural at boundary. */ client: AthenaUiRootClient; authClient?: never; } | { /** * @deprecated Use `client={athena}` with the root Athena client. * Standalone `createAthenaAuthClient()` / bindings remain assignable. */ authClient: CompatibleAuthClient; client?: never; }; /** * Public Athena Auth UI shell props. * * Getting-started surface: `client` + `children`. * Do not extend Better Auth `AuthProviderProps` — that leaks implementation types. * * Not generic: schema generics must not flow through the React provider props * (TS2589 / consumer `as never`). See {@link AthenaClientRoot}. */ export type AthenaProvidersProps = AthenaProvidersClientSource & AthenaProvidersUiFeatureProps & { children: ReactNode; /** * Server-validated identity for the first paint. Seeded into * `athena.auth.session` during this render (not in an effect). */ initialAuthState?: AthenaInitialAuthState | null; /** * Client navigation. Next App Router apps should use * `AthenaNextAuthProvider` from `@xylex-group/athena-auth-ui/next/client` * (`router.push` / `router.replace`). The `./next` entry is server-safe * path/proxy helpers only. When omitted, falls back to `window.location`. */ navigation?: AthenaProvidersNavigate; /** * @deprecated Use `navigation`. Kept for one-release compatibility with * `AthenaAppProviders`. */ navigate?: AthenaProvidersNavigate; ui?: AthenaAuthUiOptions; /** @advanced Shared TanStack Query client (resource caches — not identity SSOT). */ queryClient?: QueryClient; /** @advanced */ toastProvider?: boolean; /** * @deprecated Prefer composing DevTools outside production construction. * Retained for compatibility. */ routingDebug?: AthenaProvidersRoutingDebugOptions; }; /** * Canonical app shell for Athena Auth UI. * * Ordinary path: pass the root client from Discovery 1.1. Auth HTTP comes from * Athena JS — do not set `basePath` or `credentials` on the default shell. * * @example * ```tsx * const athena = createClient({ topology: { discover: "next" } }) * * * {children} * * ``` */ export declare function AthenaAuthProvider({ children, client, authClient, initialAuthState, navigation, navigate, ui, queryClient: queryClientProp, toastProvider, routingDebug, plugins, primitives: primitiveOverrides, redirectTo, socialProviders, emailAndPassword, username, passkey, twoFactor, organization, credentials, basePath, viewPaths }: AthenaProvidersProps): import("react").JSX.Element; /** Existing name; aliases {@link AthenaAuthProvider}. */ export declare const AthenaProviders: typeof AthenaAuthProvider; /** @deprecated Use {@link AthenaAuthProvider} (or {@link AthenaProviders}). */ export declare const AthenaAppProviders: typeof AthenaAuthProvider;