Files
supabase/apps/studio/hooks/misc/useCustomAccessTokenHookDetails.tsx
Alaister Young 1085987eb3 feat: support postgres custom access token hooks (#34893)
* chore: refactor role impersonation

* fix: handle undefined claims in role impersonation SQL generation

* feat: support postgres custom access token hooks

* remove unused hook

* fix ts
2025-04-17 17:30:22 +08:00

23 lines
818 B
TypeScript

import { extractMethod } from 'components/interfaces/Auth/Hooks/hooks.utils'
import { AuthConfigResponse, useAuthConfigQuery } from 'data/auth/auth-config-query'
import { useMemo } from 'react'
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>