From f3f5a49e456dc8ae1595b05008e487bb75a837d2 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 30 Sep 2025 08:27:48 +0000 Subject: [PATCH] Add link/unlink identity support cgen-4f85ab2d1842464284ddc3cb13f488a9 --- client/lib/supabase.ts | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/client/lib/supabase.ts b/client/lib/supabase.ts index 445bcc2e..c9b75774 100644 --- a/client/lib/supabase.ts +++ b/client/lib/supabase.ts @@ -129,6 +129,54 @@ export const supabase = new Proxy(supabaseClient || {}, { // Mock fallback return await mockAuth.signInWithOAuth(provider); }, + linkIdentity: async (options: { provider: string; redirectTo?: string }) => { + if ( + isSupabaseConfigured && + target && + target.auth && + typeof target.auth.linkIdentity === "function" + ) { + try { + return await target.auth.linkIdentity(options); + } catch (error: any) { + console.warn( + "Supabase linkIdentity failed:", + error?.message || error, + ); + try { + return await mockAuth.linkIdentity({ provider: options.provider }); + } catch { + throw error; + } + } + } + + return await mockAuth.linkIdentity({ provider: options.provider }); + }, + unlinkIdentity: async (options: { identity_id?: string; provider?: string }) => { + if ( + isSupabaseConfigured && + target && + target.auth && + typeof target.auth.unlinkIdentity === "function" + ) { + try { + return await target.auth.unlinkIdentity(options); + } catch (error: any) { + console.warn( + "Supabase unlinkIdentity failed:", + error?.message || error, + ); + try { + return await mockAuth.unlinkIdentity(options); + } catch { + throw error; + } + } + } + + return await mockAuth.unlinkIdentity(options); + }, signOut: async () => { if (isSupabaseConfigured && target && target.auth) { try {