Files
supabase/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/ThirdPartyAuthForm.utils.ts
Ivan Vasilov 9ac44f5985 feat: Add Third Party Auth settings (#27564)
* Add queries and mutations for third party auth.

* Show the ThirdPartyAuth form in the auth settings.

* Minor fixes to the mutations.

* Add a comment for TODO.

* Add all components for third party auth.

* Minor fixes.

* Update the firebase icons.

* Update the api-types.

* Fix the barrel file imports.

* Make the sheets more intuitive.

* Add a dialog for adding RLS policies for the firebase integration.

* Hide the 3rd party auth section behind a form.

* Fix a type error.

* Update the wording on the Add RLS policy dialog.

* Replace the sheets with dialogs.

* Add fixes for the comments on github.

* Minor fixes.

* Fix a type error.

* Make the delete integration awaitable.
2024-07-25 11:07:09 +02:00

52 lines
1.5 KiB
TypeScript

import { ThirdPartyAuthIntegration } from 'data/third-party-auth/integrations-query'
import { BASE_PATH } from 'lib/constants'
export const INTEGRATION_TYPES = ['firebase', 'auth0', 'awsCognito', 'custom'] as const
export type INTEGRATION_TYPES = (typeof INTEGRATION_TYPES)[number]
export const getIntegrationType = (integration?: ThirdPartyAuthIntegration): INTEGRATION_TYPES => {
if (
integration?.oidc_issuer_url &&
integration?.oidc_issuer_url.startsWith('https://securetoken.google.com/')
) {
return 'firebase'
}
if (integration?.oidc_issuer_url && integration?.oidc_issuer_url.includes('amazonaws.com')) {
return 'awsCognito'
}
if (integration?.oidc_issuer_url && integration?.oidc_issuer_url.includes('auth0.com')) {
return 'auth0'
}
return 'custom'
}
export const getIntegrationTypeLabel = (type: INTEGRATION_TYPES) => {
switch (type) {
case 'firebase':
return 'Firebase'
case 'auth0':
return 'Auth0'
case 'awsCognito':
return 'AWS Cognito'
case 'custom':
default:
return 'Custom'
}
}
export const getIntegrationTypeIcon = (type: INTEGRATION_TYPES) => {
switch (type) {
case 'firebase':
return `${BASE_PATH}/img/icons/firebase-icon.svg`
case 'auth0':
return `${BASE_PATH}/img/icons/auth0-icon.svg`
case 'awsCognito':
return `${BASE_PATH}/img/icons/cognito-icon.svg`
case 'custom':
default:
return `${BASE_PATH}/img/icons/cognito-icon.svg`
}
}