import { createClient, type SupabaseClient } from '@supabase/supabase-js' import type { Database } from './database.types' /** Typed Supabase client for the Faunosteo database. */ export type FaunosteoClient = SupabaseClient /** * Public connection settings. The anon (publishable) key is safe to ship to * the browser: every table is behind RLS. The service-role key never is. */ export interface SupabaseConnection { url: string anonKey: string } /** * Browser client: session persisted in localStorage, tokens refreshed in the * background, PKCE for OAuth and magic-link redirects. */ export function createBrowserClient( connection: SupabaseConnection, ): FaunosteoClient { return createClient(connection.url, connection.anonKey, { auth: { persistSession: true, autoRefreshToken: true, detectSessionInUrl: true, flowType: 'pkce', }, }) }