feat(supabase): auth, profile and roles services; professional columns on profiles; OAuth + TOTP config

- packages/supabase: signIn/signUp/OAuth/reset/updatePassword/signOut wrappers with a closed AuthFailure kind, fetch/update own profile, own platform roles
- migration 20261011100000: practice_name, professional_title, siret (format-checked, column grants); pgTAP 009; database.types regenerated
- config.toml: TOTP enroll/verify on, [auth.external.google|apple] via env(), wildcard redirect URLs
- app config: authProviders (APP_AUTH_PROVIDERS / VITE_AUTH_PROVIDERS), entrypoint env.js, DEPLOY table
- TODO: Step 7 plan
This commit is contained in:
bchanot committed 2026-10-11 23:16:13 +02:00
1 parent c746952d7f
commit b10b227ee9
13 files changed
+427 -10

No files matched your search

+28 -2
View File
@@ -1,5 +1,5 @@
/// <reference types="vite/client" />
import type { SupabaseConnection } from '@faunosteo/supabase'
import type { OAuthProvider, SupabaseConnection } from '@faunosteo/supabase'
/**
* Runtime application config.
@@ -15,6 +15,8 @@ export interface AppConfig {
tagline: string
/** null = no backend configured; the app keeps its local-only behaviour. */
supabase: SupabaseConnection | null
/** OAuth buttons to show on the auth screens; the server must enable the same providers. */
authProviders: OAuthProvider[]
}
/** Shape written by docker/entrypoint.sh (flat strings, empty = unset). */
@@ -25,6 +27,8 @@ export interface RuntimeConfig {
tagline?: string
supabaseUrl?: string
supabaseAnonKey?: string
/** Comma-separated: "google,apple". */
authProviders?: string
}
declare global {
@@ -33,7 +37,7 @@ declare global {
}
}
const DEFAULTS: Omit<AppConfig, 'supabase'> = {
const DEFAULTS: Omit<AppConfig, 'supabase' | 'authProviders'> = {
siteName: 'Faunosteo',
brandName: 'Faunosteo',
footerName: 'Faunosteo',
@@ -61,6 +65,25 @@ export function resolveSupabaseConnection(
return null
}
const KNOWN_PROVIDERS: readonly string[] = ['google', 'apple']
/** "google, apple" → ['google', 'apple']; unknown names are dropped (warned in DEV). */
export function resolveAuthProviders(
raw: string | undefined,
): OAuthProvider[] {
const names = (nonEmpty(raw) ?? '')
.split(',')
.map((name) => name.trim().toLowerCase())
.filter((name) => name !== '')
const known = names.filter((name): name is OAuthProvider =>
KNOWN_PROVIDERS.includes(name),
)
if (known.length !== names.length && import.meta.env.DEV) {
console.warn(`[config] unknown auth provider in "${raw}"; ignored`)
}
return [...new Set(known)]
}
export function resolveConfig(runtime: RuntimeConfig = {}): AppConfig {
return {
siteName:
@@ -81,6 +104,9 @@ export function resolveConfig(runtime: RuntimeConfig = {}): AppConfig {
runtime.supabaseUrl ?? import.meta.env.VITE_SUPABASE_URL,
runtime.supabaseAnonKey ?? import.meta.env.VITE_SUPABASE_ANON_KEY,
),
authProviders: resolveAuthProviders(
runtime.authProviders ?? import.meta.env.VITE_AUTH_PROVIDERS,
),
}
}