mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 02:45:07 +03:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import type { AuthMFAGetAuthenticatorAssuranceLevelResponse } from '@supabase/supabase-js'
|
|
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import { profileKeys } from './keys'
|
|
import type { Profile } from './types'
|
|
import { auth } from '@/lib/gotrue'
|
|
import { UseCustomQueryOptions } from '@/types'
|
|
|
|
export type ProfileResponse = Profile
|
|
|
|
export async function getMfaAuthenticatorAssuranceLevel() {
|
|
const { error, data } = await auth.mfa.getAuthenticatorAssuranceLevel()
|
|
|
|
if (error) throw error
|
|
return data
|
|
}
|
|
|
|
type CustomAuthMFAGetAuthenticatorAssuranceLevelData = NonNullable<
|
|
AuthMFAGetAuthenticatorAssuranceLevelResponse['data']
|
|
>
|
|
type CustomAuthMFAGetAuthenticatorAssuranceLevelError = NonNullable<
|
|
AuthMFAGetAuthenticatorAssuranceLevelResponse['error']
|
|
>
|
|
|
|
export const useAuthenticatorAssuranceLevelQuery = <
|
|
TData = CustomAuthMFAGetAuthenticatorAssuranceLevelData,
|
|
>({
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<
|
|
CustomAuthMFAGetAuthenticatorAssuranceLevelData,
|
|
CustomAuthMFAGetAuthenticatorAssuranceLevelError,
|
|
TData
|
|
> = {}) => {
|
|
return useQuery<
|
|
CustomAuthMFAGetAuthenticatorAssuranceLevelData,
|
|
CustomAuthMFAGetAuthenticatorAssuranceLevelError,
|
|
TData
|
|
>({
|
|
queryKey: profileKeys.aaLevel(),
|
|
queryFn: () => getMfaAuthenticatorAssuranceLevel(),
|
|
staleTime: 1000 * 60 * 30,
|
|
...options,
|
|
})
|
|
}
|