import { Check } from 'lucide-react' import Image from 'next/image' import { Badge, Button } from 'ui' import { AWS_IDP_REGIONS } from './AwsRegionSelector' import { getIntegrationType, getIntegrationTypeIcon, getIntegrationTypeLabel, INTEGRATION_TYPES, } from './ThirdPartyAuthForm.utils' import { ThirdPartyAuthIntegration } from '@/data/third-party-auth/integrations-query' import { DOCS_URL } from '@/lib/constants' interface IntegrationCardProps { integration: ThirdPartyAuthIntegration canUpdateConfig: boolean onDelete: () => void } export const getIntegrationTypeDescription = (type: INTEGRATION_TYPES) => { switch (type) { case 'firebase': return ( <> Allow users to use Supabase with Firebase project. You'll need to setup RLS policies for all tables that you want to access with a Firebase JWT token. Additionally, you'll need to add custom code to set the authenticated role to all your present and future users. You can read more in the{' '} documentation . ) case 'auth0': return ( <> Allow users to use Supabase with Auth0 project. Additional setup may be required. You can read more in the{' '} documentation . ) case 'awsCognito': return ( <> Allow users to use Supabase with an Amazon Cognito. Additional setup may be required. You can read more in the{' '} documentation . ) case 'clerk': return ( <> Allow users to use Supabase with Clerk. Additional setup may be required. You can read more in the{' '} documentation . ) case 'workos': return ( <> Allow users to use Supabase with WorkOS. Additional setup may be required. You can read more in the{' '} documentation . ) case 'custom': default: return 'Custom' } } export const IntegrationTypeContent = ({ type, integration, }: { type: INTEGRATION_TYPES integration: ThirdPartyAuthIntegration }) => { switch (type) { case 'firebase': { const projectName = integration.oidc_issuer_url?.replace('https://securetoken.google.com/', '') || '' return (
Firebase Project ID {projectName}
) } case 'auth0': const domainName = integration.oidc_issuer_url?.replace('https://', '').replace('.auth0.com', '') || '' return (
Auth0 Domain Name {domainName}
) case 'awsCognito': { const region = integration.oidc_issuer_url?.split('.').filter((s) => AWS_IDP_REGIONS.includes(s))[0] || '' const userPoolId = integration.oidc_issuer_url?.split('/').filter((s) => s.startsWith(region || ''))[0] || '' return (
Region {region}
User Pool ID {userPoolId}
) } case 'clerk': return (
Domain {integration?.oidc_issuer_url ?? ''}
) case 'workos': return (
Issuer URL {integration?.oidc_issuer_url ?? ''}
) case 'custom': default: return <>Custom } } export const IntegrationCard = ({ integration, canUpdateConfig, onDelete, }: IntegrationCardProps) => { let type = getIntegrationType(integration) if (type === 'custom') { return null } return ( <>
{`${type}
{getIntegrationTypeLabel(type)}
{getIntegrationTypeDescription(type)}
{/* TODO: this should be a configure integration where it would show the sheet and the user can disable or delete the integration but there's no "edit integration" endpoing for now. */}
{true ? (
Enabled
) : ( Disabled )}
) }