UNPKG

@better-auth-ui/core

Version:

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

30 lines (29 loc) 2.84 kB
import { QueryClient, QueryOptions, skipToken } from '@tanstack/query-core'; import { InferData } from '../../lib/auth-client'; import { OAuthProviderAuthClient } from './oauth-provider-auth-client'; export type ListOAuthConsentsData<TAuthClient extends OAuthProviderAuthClient = OAuthProviderAuthClient> = InferData<TAuthClient["oauth2"]["getConsents"]>; export type ListedOAuthConsent<TAuthClient extends OAuthProviderAuthClient = OAuthProviderAuthClient> = NonNullable<ListOAuthConsentsData<TAuthClient>>[number]; export type ListOAuthConsentsParams<TAuthClient extends OAuthProviderAuthClient = OAuthProviderAuthClient> = Parameters<TAuthClient["oauth2"]["getConsents"]>[0]; export type ListOAuthConsentsOptions<TAuthClient extends OAuthProviderAuthClient = OAuthProviderAuthClient> = Omit<QueryOptions<ListOAuthConsentsData<TAuthClient>>, "queryKey"> & ListOAuthConsentsParams<TAuthClient>; /** * Query options factory for the OAuth applications the user has authorized. * * @param authClient - The Better Auth client with the OAuth provider plugin. * @param userId - The signed-in user's ID. Used for cache partitioning. * @param params - Parameters forwarded to `oauth2.getConsents`. */ export declare function listOAuthConsentsOptions<TAuthClient extends OAuthProviderAuthClient>(authClient: TAuthClient, userId?: string, params?: ListOAuthConsentsParams<TAuthClient>): { queryKey: readonly ["auth", "user", string | undefined, "oauthProvider", "consents", null]; 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["oauth2"]["getConsents"]>>); }; export declare const ensureListOAuthConsents: <TAuthClient extends OAuthProviderAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: ListOAuthConsentsOptions<TAuthClient>) => Promise<InferData<TAuthClient["oauth2"]["getConsents"]>>; export declare const prefetchListOAuthConsents: <TAuthClient extends OAuthProviderAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: ListOAuthConsentsOptions<TAuthClient>) => Promise<void>; export declare const fetchListOAuthConsents: <TAuthClient extends OAuthProviderAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, options?: ListOAuthConsentsOptions<TAuthClient>) => Promise<InferData<TAuthClient["oauth2"]["getConsents"]>>; export declare const getListOAuthConsents: <TAuthClient extends OAuthProviderAuthClient = OAuthProviderAuthClient>(queryClient: QueryClient, _authClient?: TAuthClient, userId?: string) => InferData<TAuthClient["oauth2"]["getConsents"]> | undefined;