UNPKG

@better-auth-ui/core

Version:

Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.

37 lines (36 loc) 2.5 kB
import { QueryClient, QueryOptions, skipToken } from '@tanstack/query-core'; import { AuthClient, InferData } from '../lib/auth-client'; export type AccountInfoData<TAuthClient extends AuthClient = AuthClient> = InferData<TAuthClient["accountInfo"]>; export type AccountInfoParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["accountInfo"]>[0]; export type AccountInfoOptions<TAuthClient extends AuthClient> = Omit<QueryOptions<AccountInfoData<TAuthClient>>, "queryKey"> & AccountInfoParams<TAuthClient>; /** * Query options factory for provider-specific account info. * * @param authClient - The Better Auth client. * @param userId - The current signed-in user's ID. Used for cache partitioning. * @param params - Parameters forwarded to `authClient.accountInfo`. */ export declare function accountInfoOptions<TAuthClient extends AuthClient>(authClient: TAuthClient, userId?: string, params?: AccountInfoParams<TAuthClient>): { queryKey: readonly ["auth", "user", string | undefined, "accountInfo", NonNullable<{ accountId: string; userId?: string | undefined; } | { useAccountCookie: true; userId?: string | undefined; }> | null]; meta: { errorPresentation: string; }; queryFn: typeof skipToken | (({ signal }: { client: QueryClient; queryKey: readonly unknown[]; signal: AbortSignal; meta: import('@tanstack/query-core').QueryMeta | undefined; pageParam?: unknown; direction?: unknown; }) => Promise<InferData<TAuthClient["accountInfo"]>>); }; export declare const ensureAccountInfo: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: AccountInfoOptions<TAuthClient>) => Promise<InferData<TAuthClient["accountInfo"]>>; export declare const prefetchAccountInfo: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: AccountInfoOptions<TAuthClient>) => Promise<void>; export declare const fetchAccountInfo: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: AccountInfoOptions<TAuthClient>) => Promise<InferData<TAuthClient["accountInfo"]>>; export declare const getAccountInfo: <TAuthClient extends AuthClient = AuthClient>(queryClient: QueryClient, _authClient?: TAuthClient, userId?: string, params?: AccountInfoParams<TAuthClient>) => InferData<TAuthClient["accountInfo"]> | undefined;