Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- static/dashboard.html +2 -2
- static/dashboard.js +11 -15
- static/index.html +2 -2
- static/login.js +29 -22
- static/vendor/supabase-loader.js +102 -0
static/dashboard.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<title>Dashboard - autonomy-labs</title>
|
| 8 |
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
|
| 9 |
-
<script src="/static/vendor/supabase-
|
| 10 |
<link href="https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.css" rel="stylesheet">
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.min.js"></script>
|
| 12 |
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.8.0/lib/xterm-addon-fit.min.js"></script>
|
|
@@ -1022,7 +1022,7 @@
|
|
| 1022 |
<div>autonomy-labs — ship ideas faster.</div>
|
| 1023 |
<div class="hidden md:block">Chat • Autonomous • Terminal</div>
|
| 1024 |
</footer>
|
| 1025 |
-
<script src="/static/dashboard.js"></script>
|
| 1026 |
</body>
|
| 1027 |
|
| 1028 |
</html>
|
|
|
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<title>Dashboard - autonomy-labs</title>
|
| 8 |
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
|
| 9 |
+
<script src="/static/vendor/supabase-loader.js" defer></script>
|
| 10 |
<link href="https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.css" rel="stylesheet">
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.min.js"></script>
|
| 12 |
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.8.0/lib/xterm-addon-fit.min.js"></script>
|
|
|
|
| 1022 |
<div>autonomy-labs — ship ideas faster.</div>
|
| 1023 |
<div class="hidden md:block">Chat • Autonomous • Terminal</div>
|
| 1024 |
</footer>
|
| 1025 |
+
<script src="/static/dashboard.js" defer></script>
|
| 1026 |
</body>
|
| 1027 |
|
| 1028 |
</html>
|
static/dashboard.js
CHANGED
|
@@ -327,20 +327,10 @@ let supabase;
|
|
| 327 |
|
| 328 |
async function requireSupabaseLibrary() {
|
| 329 |
if (window.supabase && typeof window.supabase.createClient === 'function') return;
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
const res = await fetch(url, { method: 'GET' });
|
| 333 |
-
if (!res.ok) {
|
| 334 |
-
throw new Error(`Supabase JS bundle missing (${res.status}) at ${url}`);
|
| 335 |
-
}
|
| 336 |
-
const text = await res.text();
|
| 337 |
-
if (text.trimStart().startsWith('<')) {
|
| 338 |
-
throw new Error(`Supabase JS bundle URL returned HTML (likely 404 page): ${url}`);
|
| 339 |
-
}
|
| 340 |
-
} catch (e) {
|
| 341 |
-
throw new Error(e?.message || String(e));
|
| 342 |
}
|
| 343 |
-
|
| 344 |
}
|
| 345 |
|
| 346 |
function configEndpoint(path) {
|
|
@@ -349,6 +339,12 @@ let supabase;
|
|
| 349 |
return new URL(cleaned, base).toString();
|
| 350 |
}
|
| 351 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
async function fetchConfig() {
|
| 353 |
const candidates = ['config', 'api/config'];
|
| 354 |
let lastError = null;
|
|
@@ -1039,7 +1035,7 @@ let supabase;
|
|
| 1039 |
window.__supabaseClient = supabase;
|
| 1040 |
|
| 1041 |
const { data: { session } } = await supabase.auth.getSession();
|
| 1042 |
-
if (!session) { window.location.href = '
|
| 1043 |
window.__sbAccessToken = (session.access_token || '').trim();
|
| 1044 |
supabase.auth.onAuthStateChange((_event, nextSession) => {
|
| 1045 |
window.__sbAccessToken = (nextSession?.access_token || '').trim();
|
|
@@ -1119,7 +1115,7 @@ let supabase;
|
|
| 1119 |
|
| 1120 |
document.getElementById('logout-btn').addEventListener('click', async () => {
|
| 1121 |
await supabase.auth.signOut();
|
| 1122 |
-
window.location.href = '
|
| 1123 |
});
|
| 1124 |
|
| 1125 |
initProviderPresets();
|
|
|
|
| 327 |
|
| 328 |
async function requireSupabaseLibrary() {
|
| 329 |
if (window.supabase && typeof window.supabase.createClient === 'function') return;
|
| 330 |
+
if (typeof window.__loadSupabase !== 'function') {
|
| 331 |
+
throw new Error('Supabase loader is missing (static/vendor/supabase-loader.js).');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
}
|
| 333 |
+
await window.__loadSupabase();
|
| 334 |
}
|
| 335 |
|
| 336 |
function configEndpoint(path) {
|
|
|
|
| 339 |
return new URL(cleaned, base).toString();
|
| 340 |
}
|
| 341 |
|
| 342 |
+
function routeUrl(path) {
|
| 343 |
+
const base = new URL('.', window.location.href);
|
| 344 |
+
const cleaned = String(path || '').replace(/^\/+/, '');
|
| 345 |
+
return new URL(cleaned, base).toString();
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
async function fetchConfig() {
|
| 349 |
const candidates = ['config', 'api/config'];
|
| 350 |
let lastError = null;
|
|
|
|
| 1035 |
window.__supabaseClient = supabase;
|
| 1036 |
|
| 1037 |
const { data: { session } } = await supabase.auth.getSession();
|
| 1038 |
+
if (!session) { window.location.href = routeUrl('login'); return; }
|
| 1039 |
window.__sbAccessToken = (session.access_token || '').trim();
|
| 1040 |
supabase.auth.onAuthStateChange((_event, nextSession) => {
|
| 1041 |
window.__sbAccessToken = (nextSession?.access_token || '').trim();
|
|
|
|
| 1115 |
|
| 1116 |
document.getElementById('logout-btn').addEventListener('click', async () => {
|
| 1117 |
await supabase.auth.signOut();
|
| 1118 |
+
window.location.href = routeUrl('login');
|
| 1119 |
});
|
| 1120 |
|
| 1121 |
initProviderPresets();
|
static/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<title>Login - autonomy-labs</title>
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
-
<script src="/static/vendor/supabase-
|
| 10 |
<link rel="stylesheet" href="/static/theme.css">
|
| 11 |
</head>
|
| 12 |
|
|
@@ -84,7 +84,7 @@
|
|
| 84 |
</div>
|
| 85 |
</div>
|
| 86 |
</div>
|
| 87 |
-
<script src="/static/login.js"></script>
|
| 88 |
</body>
|
| 89 |
|
| 90 |
</html>
|
|
|
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<title>Login - autonomy-labs</title>
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="/static/vendor/supabase-loader.js" defer></script>
|
| 10 |
<link rel="stylesheet" href="/static/theme.css">
|
| 11 |
</head>
|
| 12 |
|
|
|
|
| 84 |
</div>
|
| 85 |
</div>
|
| 86 |
</div>
|
| 87 |
+
<script src="/static/login.js" defer></script>
|
| 88 |
</body>
|
| 89 |
|
| 90 |
</html>
|
static/login.js
CHANGED
|
@@ -69,21 +69,20 @@ var supabaseReady = false;
|
|
| 69 |
|
| 70 |
async function requireSupabaseLibrary() {
|
| 71 |
if (window.supabase && typeof window.supabase.createClient === 'function') return;
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
const url = configEndpoint('static/vendor/supabase-js.min.js');
|
| 75 |
-
const res = await fetch(url, { method: 'GET' });
|
| 76 |
-
if (!res.ok) {
|
| 77 |
-
throw new Error(`Supabase JS bundle missing (${res.status}) at ${url}`);
|
| 78 |
-
}
|
| 79 |
-
const text = await res.text();
|
| 80 |
-
if (text.trimStart().startsWith('<')) {
|
| 81 |
-
throw new Error(`Supabase JS bundle URL returned HTML (likely 404 page): ${url}`);
|
| 82 |
-
}
|
| 83 |
-
} catch (e) {
|
| 84 |
-
throw new Error(e?.message || String(e));
|
| 85 |
}
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
function isRecoveryUrl() {
|
|
@@ -110,7 +109,11 @@ var supabaseReady = false;
|
|
| 110 |
const hasSession = !!data?.session;
|
| 111 |
if (hasSession) {
|
| 112 |
// Clean up URL to avoid leaking tokens via screenshots/logs/referrers.
|
| 113 |
-
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
}
|
| 115 |
return { ok: hasSession, isRecovery: true, error: null };
|
| 116 |
} catch (e) {
|
|
@@ -144,20 +147,24 @@ var supabaseReady = false;
|
|
| 144 |
supabase.auth.onAuthStateChange((event, session) => {
|
| 145 |
if (event === 'PASSWORD_RECOVERY') {
|
| 146 |
// Best-effort URL cleanup.
|
| 147 |
-
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
showUpdatePanel();
|
| 149 |
return;
|
| 150 |
}
|
| 151 |
const recovery = isRecoveryUrl();
|
| 152 |
if (session && !recovery) {
|
| 153 |
-
window.location.href = '
|
| 154 |
}
|
| 155 |
});
|
| 156 |
|
| 157 |
const recovery = consumed.isRecovery || isRecoveryUrl();
|
| 158 |
const { data: { session } } = await supabase.auth.getSession();
|
| 159 |
if (session && !recovery) {
|
| 160 |
-
window.location.href = '
|
| 161 |
return;
|
| 162 |
}
|
| 163 |
if (recovery) {
|
|
@@ -248,12 +255,12 @@ var supabaseReady = false;
|
|
| 248 |
if (type === 'register') {
|
| 249 |
if (result.data && result.data.session) {
|
| 250 |
// Email verification is disabled, user is logged in
|
| 251 |
-
window.location.href = '
|
| 252 |
} else {
|
| 253 |
showAlert('Registration successful! Please check your email to verify (if enabled) or try logging in.', 'success');
|
| 254 |
}
|
| 255 |
} else {
|
| 256 |
-
window.location.href = '
|
| 257 |
}
|
| 258 |
} catch (error) {
|
| 259 |
showAlert(error.message);
|
|
@@ -297,7 +304,7 @@ var supabaseReady = false;
|
|
| 297 |
|
| 298 |
document.getElementById('cancel-update-btn').addEventListener('click', async () => {
|
| 299 |
try { await supabase.auth.signOut(); } catch { }
|
| 300 |
-
|
| 301 |
});
|
| 302 |
|
| 303 |
document.getElementById('update-password-btn').addEventListener('click', async () => {
|
|
@@ -325,7 +332,7 @@ var supabaseReady = false;
|
|
| 325 |
if (error) throw error;
|
| 326 |
showAlert('Password updated. You can log in now.', 'success');
|
| 327 |
try { await supabase.auth.signOut(); } catch { }
|
| 328 |
-
|
| 329 |
} catch (e) {
|
| 330 |
showAlert(e?.message || String(e));
|
| 331 |
}
|
|
|
|
| 69 |
|
| 70 |
async function requireSupabaseLibrary() {
|
| 71 |
if (window.supabase && typeof window.supabase.createClient === 'function') return;
|
| 72 |
+
if (typeof window.__loadSupabase !== 'function') {
|
| 73 |
+
throw new Error('Supabase loader is missing (static/vendor/supabase-loader.js).');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
+
await window.__loadSupabase();
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function routeUrl(path) {
|
| 79 |
+
const base = new URL('.', window.location.href);
|
| 80 |
+
const cleaned = String(path || '').replace(/^\/+/, '');
|
| 81 |
+
return new URL(cleaned, base).toString();
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
function replaceUrl(path) {
|
| 85 |
+
try { window.location.replace(routeUrl(path)); } catch { window.location.href = routeUrl(path); }
|
| 86 |
}
|
| 87 |
|
| 88 |
function isRecoveryUrl() {
|
|
|
|
| 109 |
const hasSession = !!data?.session;
|
| 110 |
if (hasSession) {
|
| 111 |
// Clean up URL to avoid leaking tokens via screenshots/logs/referrers.
|
| 112 |
+
try {
|
| 113 |
+
const u = new URL(routeUrl('login'));
|
| 114 |
+
u.hash = 'type=recovery';
|
| 115 |
+
history.replaceState({}, '', u.pathname + u.search + u.hash);
|
| 116 |
+
} catch { }
|
| 117 |
}
|
| 118 |
return { ok: hasSession, isRecovery: true, error: null };
|
| 119 |
} catch (e) {
|
|
|
|
| 147 |
supabase.auth.onAuthStateChange((event, session) => {
|
| 148 |
if (event === 'PASSWORD_RECOVERY') {
|
| 149 |
// Best-effort URL cleanup.
|
| 150 |
+
try {
|
| 151 |
+
const u = new URL(routeUrl('login'));
|
| 152 |
+
u.hash = 'type=recovery';
|
| 153 |
+
history.replaceState({}, '', u.pathname + u.search + u.hash);
|
| 154 |
+
} catch { }
|
| 155 |
showUpdatePanel();
|
| 156 |
return;
|
| 157 |
}
|
| 158 |
const recovery = isRecoveryUrl();
|
| 159 |
if (session && !recovery) {
|
| 160 |
+
window.location.href = routeUrl('app');
|
| 161 |
}
|
| 162 |
});
|
| 163 |
|
| 164 |
const recovery = consumed.isRecovery || isRecoveryUrl();
|
| 165 |
const { data: { session } } = await supabase.auth.getSession();
|
| 166 |
if (session && !recovery) {
|
| 167 |
+
window.location.href = routeUrl('app');
|
| 168 |
return;
|
| 169 |
}
|
| 170 |
if (recovery) {
|
|
|
|
| 255 |
if (type === 'register') {
|
| 256 |
if (result.data && result.data.session) {
|
| 257 |
// Email verification is disabled, user is logged in
|
| 258 |
+
window.location.href = routeUrl('app');
|
| 259 |
} else {
|
| 260 |
showAlert('Registration successful! Please check your email to verify (if enabled) or try logging in.', 'success');
|
| 261 |
}
|
| 262 |
} else {
|
| 263 |
+
window.location.href = routeUrl('app');
|
| 264 |
}
|
| 265 |
} catch (error) {
|
| 266 |
showAlert(error.message);
|
|
|
|
| 304 |
|
| 305 |
document.getElementById('cancel-update-btn').addEventListener('click', async () => {
|
| 306 |
try { await supabase.auth.signOut(); } catch { }
|
| 307 |
+
replaceUrl('login');
|
| 308 |
});
|
| 309 |
|
| 310 |
document.getElementById('update-password-btn').addEventListener('click', async () => {
|
|
|
|
| 332 |
if (error) throw error;
|
| 333 |
showAlert('Password updated. You can log in now.', 'success');
|
| 334 |
try { await supabase.auth.signOut(); } catch { }
|
| 335 |
+
replaceUrl('login');
|
| 336 |
} catch (e) {
|
| 337 |
showAlert(e?.message || String(e));
|
| 338 |
}
|
static/vendor/supabase-loader.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Minimal loader to make Supabase available as `window.supabase.createClient` without relying on external CDNs.
|
| 2 |
+
// This is designed for environments like Hugging Face Spaces where third-party CDNs may be blocked.
|
| 3 |
+
(function () {
|
| 4 |
+
async function fetchText(url) {
|
| 5 |
+
const res = await fetch(url, { method: "GET" });
|
| 6 |
+
if (!res.ok) throw new Error(`Supabase JS bundle missing (${res.status}) at ${url}`);
|
| 7 |
+
return await res.text();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function isProbablyHtml(text) {
|
| 11 |
+
return String(text || "").trimStart().startsWith("<");
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function looksLikeEsm(text) {
|
| 15 |
+
const t = String(text || "");
|
| 16 |
+
return /\bexport\s+(?:\{|\*)/m.test(t) || /^\s*export\s+/m.test(t) || /\bimport\s+.*from\b/m.test(t);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function loadClassicScript(url) {
|
| 20 |
+
return new Promise((resolve, reject) => {
|
| 21 |
+
const s = document.createElement("script");
|
| 22 |
+
s.src = url;
|
| 23 |
+
s.async = true;
|
| 24 |
+
s.onload = () => resolve();
|
| 25 |
+
s.onerror = () => reject(new Error(`Failed to load script ${url}`));
|
| 26 |
+
document.head.appendChild(s);
|
| 27 |
+
});
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
async function loadAsModule(url) {
|
| 31 |
+
// Use dynamic import to support ESM bundles. This will still execute even if it exports nothing.
|
| 32 |
+
// eslint-disable-next-line no-new-func
|
| 33 |
+
const importer = new Function("u", "return import(u)");
|
| 34 |
+
try {
|
| 35 |
+
return await importer(url);
|
| 36 |
+
} catch (e) {
|
| 37 |
+
throw new Error(`Failed to import module ${url}: ${e?.message || e}`);
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
async function ensureSupabaseLoaded() {
|
| 42 |
+
if (window.supabase && typeof window.supabase.createClient === "function") return;
|
| 43 |
+
const url = new URL("static/vendor/supabase-js.min.js", new URL(".", window.location.href)).toString();
|
| 44 |
+
|
| 45 |
+
// Fetch first so we can provide better errors, and decide whether to use module import.
|
| 46 |
+
const text = await fetchText(url);
|
| 47 |
+
if (isProbablyHtml(text)) {
|
| 48 |
+
throw new Error(`Supabase JS bundle URL returned HTML (likely 404 page): ${url}`);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
// Prefer classic script for UMD/IIFE bundles; fall back to module import for ESM bundles.
|
| 52 |
+
const esm = looksLikeEsm(text);
|
| 53 |
+
let mod = null;
|
| 54 |
+
if (!esm) {
|
| 55 |
+
await loadClassicScript(url);
|
| 56 |
+
} else {
|
| 57 |
+
mod = await loadAsModule(url);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// Some bundles may be ESM and not set any global; wire it up if possible.
|
| 61 |
+
const exportedCreateClient =
|
| 62 |
+
(mod && typeof mod.createClient === "function" && mod.createClient) ||
|
| 63 |
+
(mod && mod.default && typeof mod.default.createClient === "function" && mod.default.createClient) ||
|
| 64 |
+
null;
|
| 65 |
+
|
| 66 |
+
if (exportedCreateClient) {
|
| 67 |
+
window.supabase = window.supabase || {};
|
| 68 |
+
window.supabase.createClient = exportedCreateClient;
|
| 69 |
+
return;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
// Some bundles may set a global without providing createClient directly.
|
| 73 |
+
if (window.supabase && typeof window.supabase.createClient === "function") return;
|
| 74 |
+
if (typeof window.createClient === "function") {
|
| 75 |
+
window.supabase = window.supabase || {};
|
| 76 |
+
window.supabase.createClient = window.createClient;
|
| 77 |
+
return;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// Last resort: even if we loaded as a classic script, try importing as a module to access exports.
|
| 81 |
+
// This helps when the copied bundle is ESM but our heuristic missed it.
|
| 82 |
+
if (!mod) {
|
| 83 |
+
try {
|
| 84 |
+
mod = await loadAsModule(url);
|
| 85 |
+
const cc =
|
| 86 |
+
(mod && typeof mod.createClient === "function" && mod.createClient) ||
|
| 87 |
+
(mod && mod.default && typeof mod.default.createClient === "function" && mod.default.createClient) ||
|
| 88 |
+
null;
|
| 89 |
+
if (cc) {
|
| 90 |
+
window.supabase = window.supabase || {};
|
| 91 |
+
window.supabase.createClient = cc;
|
| 92 |
+
return;
|
| 93 |
+
}
|
| 94 |
+
} catch (_e) {
|
| 95 |
+
// ignore
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
throw new Error("Supabase loaded but window.supabase.createClient is missing.");
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
window.__loadSupabase = ensureSupabaseLoaded;
|
| 102 |
+
})();
|