-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
342 lines (310 loc) · 12.9 KB
/
Copy pathindex.html
File metadata and controls
342 lines (310 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>360 × Supabase — Connect</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--blueprint: #0f2742;
--blueprint-line: #2c4d70;
--blueprint-grid: rgba(143, 211, 232, 0.06);
--ink: #cfe8f2;
--ink-dim: #7fa3bd;
--cyan: #8fd3e8;
--amber: #e8a33d;
--paper: #f4f1ea;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
background-color: var(--blueprint);
background-image:
linear-gradient(var(--blueprint-grid) 1px, transparent 1px),
linear-gradient(90deg, var(--blueprint-grid) 1px, transparent 1px);
background-size: 28px 28px;
color: var(--ink);
font-family: 'Space Grotesk', sans-serif;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.mono { font-family: 'IBM Plex Mono', monospace; }
header {
border-bottom: 1px solid var(--blueprint-line);
padding: 20px 28px;
display: flex;
justify-content: space-between;
align-items: center;
}
.wordmark { display: flex; align-items: center; gap: 10px; }
.wordmark svg { width: 28px; height: 28px; }
.wordmark span { font-weight: 700; font-size: 18px; letter-spacing: 0.02em; }
.env-tag {
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--cyan);
border: 1px solid var(--blueprint-line);
padding: 4px 10px;
border-radius: 3px;
}
main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.panel { width: 100%; max-width: 480px; }
.schematic { width: 100%; margin-bottom: 28px; }
.node-label { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; fill: var(--ink-dim); }
.node-title { font-size: 15px; font-weight: 600; fill: var(--ink); font-family: 'Space Grotesk', sans-serif; }
.pipe { stroke: var(--blueprint-line); stroke-width: 1.5; fill: none; }
.pipe.live { stroke: var(--cyan); stroke-dasharray: 4 5; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -18; } }
.node-box { fill: rgba(143,211,232,0.03); stroke: var(--blueprint-line); stroke-width: 1; }
.node-box.live { stroke: var(--cyan); }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
p.desc { color: var(--ink-dim); font-size: 14px; line-height: 1.5; margin: 0 0 28px; }
button.primary {
width: 100%;
background: var(--cyan);
color: var(--blueprint);
border: none;
border-radius: 6px;
padding: 14px 18px;
font-family: 'Space Grotesk', sans-serif;
font-weight: 600;
font-size: 14px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
transition: transform 0.12s ease, background 0.12s ease;
}
button.primary:hover { background: #a7dfef; }
button.primary:active { transform: scale(0.98); }
.connection-card {
border: 1px solid var(--blueprint-line);
background: rgba(232, 163, 61, 0.06);
border-radius: 6px;
padding: 16px 18px;
text-align: left;
}
.connection-card .label { color: var(--amber); font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.connection-card .meta { color: var(--ink-dim); font-size: 12px; }
.connection-card button.text-btn {
background: none;
border: none;
color: #e88a8a;
font-size: 12px;
text-decoration: underline;
cursor: pointer;
padding: 0;
margin-top: 10px;
}
.specs { margin-top: 32px; border-top: 1px solid var(--blueprint-line); padding-top: 20px; }
.specs .eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 10px; }
.spec-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; }
.spec-row .k { color: var(--ink-dim); }
.spec-row .v { color: var(--cyan); }
.hidden { display: none !important; }
footer {
border-top: 1px solid var(--blueprint-line);
padding: 18px;
text-align: center;
color: var(--ink-dim);
font-size: 11px;
}
</style>
<script type="module">
// ---------------------------------------------------------------------
// CONFIG
// ---------------------------------------------------------------------
const CONFIG = {
mgmtClientId: "c89a2441-cb70-43f2-b78b-34db6223b33a",
redirectUri: "https://360digitalco.github.io",
exchangeUrl: "https://wiswfpfsjiowtrdyqpxy.supabase.co/functions/v1/partner-mgmt-exchange",
statusUrl: "https://wiswfpfsjiowtrdyqpxy.supabase.co/functions/v1/partner-mgmt-status",
disconnectUrl: "https://wiswfpfsjiowtrdyqpxy.supabase.co/functions/v1/partner-mgmt-disconnect",
};
function getOrCreateOwnerKey() {
let key = localStorage.getItem("partner_owner_key");
if (!key) {
const bytes = new Uint8Array(32);
crypto.getRandomValues(bytes);
key = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
localStorage.setItem("partner_owner_key", key);
}
return key;
}
const ownerKey = getOrCreateOwnerKey();
async function sha256(text) {
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
return new Uint8Array(digest);
}
function base64url(bytes) {
let binary = "";
for (const b of bytes) binary += String.fromCharCode(b);
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
}
function randomString(length = 64) {
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const arr = new Uint8Array(length);
crypto.getRandomValues(arr);
return [...arr].map((v) => chars[v % chars.length]).join("");
}
const els = {};
window.addEventListener("DOMContentLoaded", () => {
els.status = document.getElementById("display-status");
els.desc = document.getElementById("display-desc");
els.connectBtn = document.getElementById("connect-btn");
els.disconnectBtn = document.getElementById("disconnect-btn");
els.connectionCard = document.getElementById("connection-card");
els.pipe = document.getElementById("pipe-line");
els.nodeSupabase = document.getElementById("node-supabase");
els.connectBtn.addEventListener("click", startManagementConnect);
els.disconnectBtn.addEventListener("click", handleDisconnect);
boot();
});
function setStatus(title, desc) {
els.status.textContent = title;
els.desc.textContent = desc;
}
function setLive(isLive) {
els.pipe.classList.toggle("live", isLive);
els.nodeSupabase.classList.toggle("live", isLive);
}
async function startManagementConnect() {
const state = crypto.randomUUID();
const codeVerifier = randomString(96);
const codeChallenge = base64url(await sha256(codeVerifier));
sessionStorage.setItem("mgmt_oauth_state", state);
sessionStorage.setItem("mgmt_code_verifier", codeVerifier);
const params = new URLSearchParams({
client_id: CONFIG.mgmtClientId,
redirect_uri: CONFIG.redirectUri,
response_type: "code",
state,
code_challenge: codeChallenge,
code_challenge_method: "S256",
});
window.location.href = `https://api.supabase.com/v1/oauth/authorize?${params.toString()}`;
}
async function processOAuthCallback() {
const params = new URLSearchParams(window.location.search);
const code = params.get("code");
if (!code) return false;
const error = params.get("error");
if (error) {
setStatus("Connection declined", `Supabase returned: ${error}`);
history.replaceState({}, document.title, window.location.pathname);
return true;
}
const state = params.get("state");
const storedState = sessionStorage.getItem("mgmt_oauth_state");
if (!state || state !== storedState) {
setStatus("Security check failed", "OAuth state did not match. Try connecting again.");
history.replaceState({}, document.title, window.location.pathname);
return true;
}
const verifier = sessionStorage.getItem("mgmt_code_verifier");
setStatus("Connecting…", "Exchanging your authorization for an access token.");
try {
const res = await fetch(CONFIG.exchangeUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code, redirect_uri: CONFIG.redirectUri, code_verifier: verifier, owner_key: ownerKey }),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error || "Unknown error");
sessionStorage.removeItem("mgmt_oauth_state");
sessionStorage.removeItem("mgmt_code_verifier");
history.replaceState({}, document.title, window.location.pathname);
setStatus("Workspace connected", "Your Supabase organization is now wired into 360Digital.");
} catch (err) {
setStatus("Connection failed", String(err.message || err));
}
return true;
}
async function refreshConnectionStatus() {
const res = await fetch(CONFIG.statusUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ owner_key: ownerKey }),
});
const data = await res.json().catch(() => ({ connected: false }));
if (data.connected) {
els.connectBtn.classList.add("hidden");
els.connectionCard.classList.remove("hidden");
document.getElementById("connection-expires").textContent = new Date(data.expires_at).toLocaleString();
setLive(true);
} else {
els.connectBtn.classList.remove("hidden");
els.connectionCard.classList.add("hidden");
setLive(false);
}
}
async function handleDisconnect() {
await fetch(CONFIG.disconnectUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ owner_key: ownerKey }),
});
await refreshConnectionStatus();
setStatus("Disconnected", "360Digital no longer has access to your Supabase organization.");
}
async function boot() {
const handledCallback = await processOAuthCallback();
await refreshConnectionStatus();
if (!handledCallback) {
setStatus("Connect your workspace", "Authorize 360Digital to manage your Supabase projects.");
}
}
</script>
</head>
<body>
<header>
<div class="wordmark">
<svg viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="16" cy="16" r="13" stroke="#8fd3e8" stroke-width="1.5"/>
<path d="M16 3 A13 13 0 0 1 29 16" stroke="#e8a33d" stroke-width="2" stroke-linecap="round"/>
<circle cx="16" cy="16" r="2.5" fill="#8fd3e8"/>
</svg>
<span>360<span style="color:var(--ink-dim); font-weight:400;">DIGITAL</span></span>
</div>
<span class="env-tag mono">gh-pages · prod</span>
</header>
<main>
<div class="panel">
<svg class="schematic" viewBox="0 0 440 120" xmlns="http://www.w3.org/2000/svg">
<rect x="8" y="34" width="120" height="52" rx="4" class="node-box" />
<text x="68" y="56" text-anchor="middle" class="node-label mono">ORG</text>
<text x="68" y="76" text-anchor="middle" class="node-title">360Digital</text>
<path id="pipe-line" class="pipe" d="M 128 60 H 200 Q 220 60 220 40 V 20 Q 220 0 240 0" />
<path class="pipe" d="M 128 60 H 312" />
<rect id="node-supabase" x="312" y="34" width="120" height="52" rx="4" class="node-box" />
<text x="372" y="56" text-anchor="middle" class="node-label mono">API</text>
<text x="372" y="76" text-anchor="middle" class="node-title">Supabase</text>
</svg>
<h1 id="display-status">Loading…</h1>
<p id="display-desc" class="desc"></p>
<button id="connect-btn" class="primary hidden">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M21.362 9.354H13.62V1.9a1.218 1.218 0 0 0-2.072-.868l-8.91 8.91a1.217 1.217 0 0 0 .86 2.076h7.743v7.454a1.218 1.218 0 0 0 2.072.868l8.91-8.91a1.217 1.217 0 0 0-.86-2.076z"/></svg>
Connect Supabase
</button>
<div id="connection-card" class="connection-card hidden">
<div class="label mono">● CONNECTED</div>
<div class="meta mono">token refreshes until <span id="connection-expires"></span></div>
<button id="disconnect-btn" class="text-btn mono">disconnect</button>
</div>
<div class="specs">
<div class="eyebrow mono">system status</div>
<div class="spec-row mono"><span class="k">pkce</span><span class="v">enabled</span></div>
<div class="spec-row mono"><span class="k">state validation</span><span class="v">enabled</span></div>
<div class="spec-row mono"><span class="k">secret exposure</span><span class="v">server-side only</span></div>
</div>
</div>
</main>
<footer class="mono">© 2026 360Digital, Co. — powered by Supabase Management OAuth</footer>
</body>
</html>