@lifeaitools/clauth 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1282,39 +1282,31 @@ function createServer(initPassword, whitelist, port, tunnelHostname = null) {
1282
1282
  // ── Build status (populated via Supabase Realtime) ─────────
1283
1283
  let buildStatus = { active: false, status: "idle", apps: [], updated_at: null };
1284
1284
 
1285
- (async () => {
1285
+ // Poll Supabase REST API for build status (no extra deps needed)
1286
+ async function fetchBuildStatus() {
1286
1287
  try {
1287
1288
  const sbUrl = (api.getBaseUrl() || "").replace("/functions/v1/auth-vault", "");
1288
1289
  const sbKey = api.getAnonKey();
1289
1290
  if (!sbUrl || !sbKey) return;
1290
1291
 
1291
- const { createClient: createSB } = await import("@supabase/supabase-js");
1292
- const sb = createSB(sbUrl, sbKey);
1293
-
1294
- // Initial fetch
1295
- const { data } = await sb.from("prt_storage").select("value").eq("key", "build_status").single();
1296
- if (data?.value) buildStatus = typeof data.value === "string" ? JSON.parse(data.value) : data.value;
1297
-
1298
- // Realtime subscription
1299
- sb.channel("build-status")
1300
- .on("postgres_changes", { event: "*", schema: "public", table: "prt_storage", filter: "key=eq.build_status" },
1301
- (payload) => {
1302
- const val = payload.new?.value;
1303
- if (val) {
1304
- buildStatus = typeof val === "string" ? JSON.parse(val) : val;
1305
- const logMsg = `[${new Date().toISOString()}] Build status update: ${buildStatus.status} (${buildStatus.commit?.slice(0,8) || "?"})\n`;
1306
- try { fs.appendFileSync(LOG_FILE, logMsg); } catch {}
1307
- }
1308
- })
1309
- .subscribe();
1310
-
1311
- const logMsg = `[${new Date().toISOString()}] Build status: Realtime subscription active\n`;
1312
- try { fs.appendFileSync(LOG_FILE, logMsg); } catch {}
1313
- } catch (err) {
1314
- const logMsg = `[${new Date().toISOString()}] Build status subscription failed: ${err.message}\n`;
1315
- try { fs.appendFileSync(LOG_FILE, logMsg); } catch {}
1316
- }
1317
- })();
1292
+ const r = await fetch(
1293
+ `${sbUrl}/rest/v1/prt_storage?key=eq.build_status&select=value`,
1294
+ { headers: { apikey: sbKey, Authorization: `Bearer ${sbKey}` }, signal: AbortSignal.timeout(5000) }
1295
+ );
1296
+ if (!r.ok) return;
1297
+ const rows = await r.json();
1298
+ if (rows.length > 0 && rows[0].value) {
1299
+ const prev = buildStatus.status;
1300
+ buildStatus = typeof rows[0].value === "string" ? JSON.parse(rows[0].value) : rows[0].value;
1301
+ if (buildStatus.status !== prev) {
1302
+ const logMsg = `[${new Date().toISOString()}] Build status: ${buildStatus.status} (${buildStatus.commit?.slice(0,8) || "?"})\n`;
1303
+ try { fs.appendFileSync(LOG_FILE, logMsg); } catch {}
1304
+ }
1305
+ }
1306
+ } catch {}
1307
+ }
1308
+ fetchBuildStatus();
1309
+ setInterval(fetchBuildStatus, 15000);
1318
1310
 
1319
1311
  const server = http.createServer(async (req, res) => {
1320
1312
  const remote = req.socket.remoteAddress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/clauth",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "Hardware-bound credential vault for the LIFEAI infrastructure stack",
5
5
  "type": "module",
6
6
  "bin": {