@lifeaitools/clauth 1.4.7 → 1.4.9
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.
- package/cli/commands/serve.js +28 -3
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -1217,8 +1217,25 @@ async function loadServices() {
|
|
|
1217
1217
|
err.style.display = "none";
|
|
1218
1218
|
grid.innerHTML = '<p class="loading">Loading…</p>';
|
|
1219
1219
|
|
|
1220
|
+
let status;
|
|
1221
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
1222
|
+
try {
|
|
1223
|
+
status = await Promise.race([
|
|
1224
|
+
fetch(BASE + "/status").then(r => r.json()),
|
|
1225
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), 8000))
|
|
1226
|
+
]);
|
|
1227
|
+
break;
|
|
1228
|
+
} catch (e) {
|
|
1229
|
+
if (attempt === 2) {
|
|
1230
|
+
err.textContent = "⚠ Could not load services — " + e.message;
|
|
1231
|
+
err.style.display = "block";
|
|
1232
|
+
grid.innerHTML = "";
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1220
1238
|
try {
|
|
1221
|
-
const status = await fetch(BASE + "/status").then(r => r.json());
|
|
1222
1239
|
if (status.locked) { showLockScreen(); return; }
|
|
1223
1240
|
if (status.error) throw new Error(status.error);
|
|
1224
1241
|
|
|
@@ -1758,8 +1775,16 @@ let tunnelPollTimer = null;
|
|
|
1758
1775
|
|
|
1759
1776
|
async function pollTunnel() {
|
|
1760
1777
|
if (tunnelPollTimer) clearInterval(tunnelPollTimer);
|
|
1778
|
+
// Give server 4s grace to run fetchTunnelConfig before showing "not_started" UI
|
|
1761
1779
|
const r = await apiFetch("/tunnel");
|
|
1762
|
-
if (r
|
|
1780
|
+
if (r && r.status !== "not_started") {
|
|
1781
|
+
renderTunnelPanel(r.status, r.url, r.error);
|
|
1782
|
+
} else {
|
|
1783
|
+
renderTunnelPanel("starting", null, null); // show spinner while server initialises
|
|
1784
|
+
await new Promise(res => setTimeout(res, 4000));
|
|
1785
|
+
const r2 = await apiFetch("/tunnel");
|
|
1786
|
+
if (r2) renderTunnelPanel(r2.status, r2.url, r2.error);
|
|
1787
|
+
}
|
|
1763
1788
|
// Poll every 3s; slow to 10s once live
|
|
1764
1789
|
tunnelPollTimer = setInterval(async () => {
|
|
1765
1790
|
const r = await apiFetch("/tunnel");
|
|
@@ -3503,7 +3528,7 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
|
|
|
3503
3528
|
const service = deleteMatch[1].toLowerCase();
|
|
3504
3529
|
try {
|
|
3505
3530
|
const { token, timestamp } = deriveToken(password, machineHash);
|
|
3506
|
-
const result = await api.removeService(password, machineHash, token, timestamp, service, service);
|
|
3531
|
+
const result = await api.removeService(password, machineHash, token, timestamp, service, `CONFIRM REMOVE ${service.toUpperCase()}`);
|
|
3507
3532
|
if (result.error) return strike(res, 502, result.error);
|
|
3508
3533
|
return ok(res, { ok: true, deleted: service });
|
|
3509
3534
|
} catch (err) {
|