Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

823 B
Raw Blame
import { useMemo } from 'react'

import { extractMethod } from '@/components/interfaces/Auth/Hooks/hooks.utils'
import { AuthConfigResponse, useAuthConfigQuery } from '@/data/auth/auth-config-query'

function authConfigToCustomAccessTokenHookDetails(authConfig?: AuthConfigResponse) {
  if (!authConfig || !authConfig.HOOK_CUSTOM_ACCESS_TOKEN_ENABLED) {
    return undefined
  }

  return extractMethod(
    authConfig.HOOK_CUSTOM_ACCESS_TOKEN_URI,
    authConfig.HOOK_CUSTOM_ACCESS_TOKEN_SECRETS
  )
}

export function useCustomAccessTokenHookDetails(projectRef: string | undefined) {
  const { data: authConfig } = useAuthConfigQuery({ projectRef })

  return useMemo(() => authConfigToCustomAccessTokenHookDetails(authConfig), [authConfig])
}

export type CustomAccessTokenHookDetails = ReturnType<typeof extractMethod>