@livedesk/client 0.1.226 → 0.1.227
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/bin/livedesk-client.js +19 -8
- package/package.json +1 -1
package/bin/livedesk-client.js
CHANGED
|
@@ -1326,10 +1326,13 @@ async function refreshSessionIfNeededCore(supabase) {
|
|
|
1326
1326
|
return null;
|
|
1327
1327
|
}
|
|
1328
1328
|
const session = { ...candidate, ...normalized.session };
|
|
1329
|
-
const expiresAt = Number(session.expires_at || 0);
|
|
1330
|
-
if (expiresAt <= 0 || expiresAt - Math.floor(Date.now() / 1000) > SESSION_REFRESH_SKEW_SECONDS) {
|
|
1331
|
-
|
|
1332
|
-
|
|
1329
|
+
const expiresAt = Number(session.expires_at || 0);
|
|
1330
|
+
if (expiresAt <= 0 || expiresAt - Math.floor(Date.now() / 1000) > SESSION_REFRESH_SKEW_SECONDS) {
|
|
1331
|
+
// A persisted session is not automatically installed into this
|
|
1332
|
+
// memory-only Supabase client after a process restart. Returning the
|
|
1333
|
+
// file value without setSession makes the UI say "Signed in" while
|
|
1334
|
+
// PostgREST still sends the publishable-key request as anon.
|
|
1335
|
+
return activateSupabaseSession(supabase, session);
|
|
1333
1336
|
}
|
|
1334
1337
|
const { data, error } = await supabase.auth.refreshSession(session);
|
|
1335
1338
|
if (error) {
|
|
@@ -3458,21 +3461,26 @@ async function chooseClientConnection(supabase, options = {}) {
|
|
|
3458
3461
|
});
|
|
3459
3462
|
},
|
|
3460
3463
|
changeRole: async (role, snapshot, currentSession) => {
|
|
3464
|
+
console.log('[LiveDesk Client] Hub role transition requested. Validating the signed-in session and local Hub port.');
|
|
3461
3465
|
const activeSupabase = await getSupabase();
|
|
3462
3466
|
if (!activeSupabase) {
|
|
3467
|
+
console.warn('[LiveDesk Client] Hub role transition rejected: Google sign-in is temporarily unavailable.');
|
|
3463
3468
|
return { ok: false, error: 'Google sign-in is temporarily unavailable. Try again in a moment.' };
|
|
3464
3469
|
}
|
|
3465
3470
|
const portPreflight = await preflightHubClientPort();
|
|
3466
3471
|
if (!portPreflight.ok) {
|
|
3472
|
+
console.warn(`[LiveDesk Client] Hub role transition rejected: ${hubClientPortPreflightError(portPreflight).error}`);
|
|
3467
3473
|
return hubClientPortPreflightError(portPreflight);
|
|
3468
3474
|
}
|
|
3469
3475
|
let session;
|
|
3470
3476
|
try {
|
|
3471
3477
|
session = await activateRoleChangeSession(activeSupabase, currentSession);
|
|
3472
3478
|
} catch (error) {
|
|
3479
|
+
console.warn(`[LiveDesk Client] Hub role transition rejected: ${formatDiscoveryError(error)}`);
|
|
3473
3480
|
return { ok: false, error: formatDiscoveryError(error) };
|
|
3474
3481
|
}
|
|
3475
3482
|
if (!session?.access_token) {
|
|
3483
|
+
console.warn('[LiveDesk Client] Hub role transition rejected: a fresh Google sign-in is required.');
|
|
3476
3484
|
return { ok: false, error: 'Sign in again before switching this computer to Hub.' };
|
|
3477
3485
|
}
|
|
3478
3486
|
const expectedRoleVersion = Number(snapshot?.roleVersion || 0);
|
|
@@ -3482,15 +3490,18 @@ async function chooseClientConnection(supabase, options = {}) {
|
|
|
3482
3490
|
p_assigned_hub_id: null,
|
|
3483
3491
|
p_expected_role_version: expectedRoleVersion > 0 ? expectedRoleVersion : null
|
|
3484
3492
|
}));
|
|
3485
|
-
const result = Array.isArray(data) ? data[0] : data;
|
|
3486
|
-
if (error || result?.ok === false) {
|
|
3487
|
-
|
|
3488
|
-
|
|
3493
|
+
const result = Array.isArray(data) ? data[0] : data;
|
|
3494
|
+
if (error || result?.ok === false) {
|
|
3495
|
+
const reason = error?.message || result?.reason || 'role-change-rejected';
|
|
3496
|
+
console.warn(`[LiveDesk Client] Hub role transition rejected: ${reason}`);
|
|
3497
|
+
return { ok: false, error: reason };
|
|
3498
|
+
}
|
|
3489
3499
|
const roleVersion = Number.isInteger(result?.role_version) ? result.role_version : expectedRoleVersion + 1;
|
|
3490
3500
|
writeLocalRoleCache(role, options.deviceId, roleVersion);
|
|
3491
3501
|
roleRestartRequest = { role, requestedAt: new Date().toISOString() };
|
|
3492
3502
|
requestLocalDiscoveryWake('role-change');
|
|
3493
3503
|
try { requestActiveAgentStop(); } catch { /* the lifecycle loop observes the role request */ }
|
|
3504
|
+
console.log(`[LiveDesk Client] Hub role transition accepted at role revision ${roleVersion}. Starting the Hub runtime.`);
|
|
3494
3505
|
return { ok: true, restarting: true, role, roleVersion };
|
|
3495
3506
|
},
|
|
3496
3507
|
videoAcceleration: linuxVideoAccelerationStatus,
|