useCustomAccessTokenHookDetails.tsx23 lines · main
| 1 | import { useMemo } from 'react' |
| 2 | |
| 3 | import { extractMethod } from '@/components/interfaces/Auth/Hooks/hooks.utils' |
| 4 | import { AuthConfigResponse, useAuthConfigQuery } from '@/data/auth/auth-config-query' |
| 5 | |
| 6 | function authConfigToCustomAccessTokenHookDetails(authConfig?: AuthConfigResponse) { |
| 7 | if (!authConfig || !authConfig.HOOK_CUSTOM_ACCESS_TOKEN_ENABLED) { |
| 8 | return undefined |
| 9 | } |
| 10 | |
| 11 | return extractMethod( |
| 12 | authConfig.HOOK_CUSTOM_ACCESS_TOKEN_URI, |
| 13 | authConfig.HOOK_CUSTOM_ACCESS_TOKEN_SECRETS |
| 14 | ) |
| 15 | } |
| 16 | |
| 17 | export function useCustomAccessTokenHookDetails(projectRef: string | undefined) { |
| 18 | const { data: authConfig } = useAuthConfigQuery({ projectRef }) |
| 19 | |
| 20 | return useMemo(() => authConfigToCustomAccessTokenHookDetails(authConfig), [authConfig]) |
| 21 | } |
| 22 | |
| 23 | export type CustomAccessTokenHookDetails = ReturnType<typeof extractMethod> |