PageSourceSearch

https://roxima.io/shared/supabase.js?v=4

js roxima.io collected 2026-10-02 01:58:13 UTC 3,250 bytes, 94 lines download raw bytes

1
2/**
3 * Supabase Client Initialization
4 * Re-implemented based on "MemoSpark" reference.
5 * Simple, clean configuration.
6 */
7
8// Import via ESM CDN
9import { createClient } from 'https://esm.sh/@supabase/[email protected]';
10
11// --- CONFIGURATION ---
12const SUPABASE_URL = 'https://zykdrmobttgdxbfukefe.supabase.co';
13const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp5a2RybW9idHRnZHhiZnVrZWZlIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjgwNjEyMTMsImV4cCI6MjA4MzYzNzIxM30.h5W_6aFhQv1oDo2DUqYW2WgMLjtOs--hkpdplw7fvzo';
14
15const isConfigured = SUPABASE_URL.startsWith('https://') && !SUPABASE_ANON_KEY.includes('YOUR_');
16
17let client;
18
19if (isConfigured) {
20    try {
21        console.log("🔌 Initializing Supabase Client (MemoSpark clean implementation)...");
22        client = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
23            auth: {
24                persistSession: true,
25                autoRefreshToken: true,
26                detectSessionInUrl: true,
27                flowType: 'implicit',
28                storage: window.localStorage
29            }
30        });
31    } catch (err) {
32        console.warn("❌ Supabase init failed:", err);
33    }
34}
35
36export const supabase = client || {
37    auth: {
38        getUser: async () => ({ data: { user: null } }),
39        getSession: async () => ({ data: { session: null } }),
40        setSession: async () => ({ data: { session: null, user: null }, error: { message: "Supabase n'est pas configuré." } }),
41        signInWithPassword: async () => ({ error: { message: "Supabase n'est pas configuré." } }),
42        signUp: async () => ({ error: { message: "Supabase n'est pas configuré." } }),
43        signOut: async () => ({ error: null }),
44        signInWithOAuth: async () => ({ error: { message: "Supabase n'est pas configuré." } }),
45        onAuthStateChange: () => { return { data: { subscription: { unsubscribe: () => { } } } }; }
46    }
47};
48
49if (!client) console.warn("⚠️ Supabase Client NOT configured. Using mock.");
50
51// --- AUTH HELPERS ---
52
53export async function signIn(email, password) {
54    const { data, error } = await supabase.auth.signInWithPassword({
55        email,
56        password,
57    });
58    return { data, error };
59}
60
61export async function signUp(email, password) {
62    const { data, error } = await supabase.auth.signUp({
63        email,
64        password,
65    });
66    return { data, error };
67}
68
69export async function signOut() {
70    localStorage.removeItem('roxima_is_ambassador');
71    const { error } = await supabase.auth.signOut();
72    return { error };
73}
74
75export async function getUser() {
76    const { data: { user } } = await supabase.auth.getUser();
77    return user;
78}
79
80export async function signInWithGoogle() {
81    console.log("👉 Initiating Google Sign-In...");
82
83    // We explicitly tell Supabase to redirect back to the current page (e.g. 127.0.0.1:5500...)
84    // This fixed the issue previously.
85    const { data, error } = await supabase.auth.signInWithOAuth({
86        provider: 'google',
87        options: {
88            redirectTo: `${window.location.origin}${window.location.pathname}${window.location.search}`
89        }
90    });
91
92    if (error) console.error("❌ Google Sign-In Error:", error);
93    return { data, error };
94}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.