mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
* 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
23 lines
818 B
TypeScript
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>
|