@livedesk/hub 0.1.35 → 0.1.36
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/package.json +32 -32
- package/src/server.js +33 -0
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@livedesk/hub",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "LiveDesk local Hub API and browser frame bridge",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "src/server.js",
|
|
7
|
-
"files": [
|
|
8
|
-
"src/",
|
|
9
|
-
"README.md"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"dev": "node src/server.js",
|
|
13
|
-
"start": "node src/server.js",
|
|
14
|
-
"check": "node --check src/server.js && node --check src/remote-hub.js",
|
|
15
|
-
"prepublishOnly": "node ../../scripts/livedesk-release-git-gate.mjs"
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
19
|
-
"@livedesk/runtime-core": "0.1.4",
|
|
20
|
-
"@openai/codex-sdk": "0.145.0",
|
|
21
|
-
"cors": "^2.8.5",
|
|
22
|
-
"express": "^4.21.2",
|
|
23
|
-
"path-to-regexp": "0.1.13",
|
|
24
|
-
"ws": "^8.18.3"
|
|
25
|
-
},
|
|
26
|
-
"engines": {
|
|
27
|
-
"node": ">=20"
|
|
28
|
-
},
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@livedesk/hub",
|
|
3
|
+
"version": "0.1.36",
|
|
4
|
+
"description": "LiveDesk local Hub API and browser frame bridge",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/server.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"src/",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "node src/server.js",
|
|
13
|
+
"start": "node src/server.js",
|
|
14
|
+
"check": "node --check src/server.js && node --check src/remote-hub.js",
|
|
15
|
+
"prepublishOnly": "node ../../scripts/livedesk-release-git-gate.mjs"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
19
|
+
"@livedesk/runtime-core": "0.1.4",
|
|
20
|
+
"@openai/codex-sdk": "0.145.0",
|
|
21
|
+
"cors": "^2.8.5",
|
|
22
|
+
"express": "^4.21.2",
|
|
23
|
+
"path-to-regexp": "0.1.13",
|
|
24
|
+
"ws": "^8.18.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/server.js
CHANGED
|
@@ -647,6 +647,36 @@ async function getRuntimeAccessToken() {
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
+
async function restorePersistedHubSessionAtStartup() {
|
|
651
|
+
if (runtimeRole !== 'hub' || runtimeManager.getSnapshot().authenticated) {
|
|
652
|
+
return { ok: true, skipped: true, reason: 'not-required' };
|
|
653
|
+
}
|
|
654
|
+
const persisted = readPersistedRuntimeSession();
|
|
655
|
+
const normalized = normalizeRuntimeAuthSession(persisted, { requireRefreshToken: true });
|
|
656
|
+
const userId = String(normalized.ok ? normalized.session?.user?.id || '' : '').trim();
|
|
657
|
+
if (!normalized.ok || !userId) {
|
|
658
|
+
return { ok: false, skipped: true, reason: normalized.ok ? 'saved-user-missing' : normalized.error };
|
|
659
|
+
}
|
|
660
|
+
runtimeSessionGeneration += 1;
|
|
661
|
+
runtimeRefreshPromise = null;
|
|
662
|
+
runtimeAccessToken = String(normalized.session.access_token || '').trim();
|
|
663
|
+
runtimeRefreshToken = String(normalized.session.refresh_token || '').trim();
|
|
664
|
+
runtimeAccessTokenExpiresAt = normalizeSessionExpiryMs(normalized.session.expires_at);
|
|
665
|
+
const accessToken = await getRuntimeAccessToken();
|
|
666
|
+
if (!accessToken) throw new Error('saved-hub-session-access-token-unavailable');
|
|
667
|
+
runtimeManager.setAuthenticated(true, userId);
|
|
668
|
+
persistRuntimeSession({
|
|
669
|
+
access_token: runtimeAccessToken,
|
|
670
|
+
refresh_token: runtimeRefreshToken,
|
|
671
|
+
expires_at: Math.floor(runtimeAccessTokenExpiresAt / 1000),
|
|
672
|
+
user: normalized.session.user
|
|
673
|
+
});
|
|
674
|
+
const hostTarget = await publishHubHostTargetWithPendingRoleTakeover('saved-session-restored');
|
|
675
|
+
startHubHostTargetLeaseRenewal();
|
|
676
|
+
console.log(`[LiveDesk Hub] Saved sign-in restored locally; host target publication ${hostTarget?.ok === false ? 'will retry' : 'is active'}.`);
|
|
677
|
+
return { ok: true, skipped: false, hostTarget };
|
|
678
|
+
}
|
|
679
|
+
|
|
650
680
|
function isLoopbackBindHost(value) {
|
|
651
681
|
const host = String(value || '').trim().toLowerCase().replace(/^\[|\]$/g, '');
|
|
652
682
|
return host === '127.0.0.1' || host === 'localhost' || host === '::1';
|
|
@@ -6471,6 +6501,9 @@ httpServer.listen(httpPort, httpHost, () => {
|
|
|
6471
6501
|
console.log(`[LiveDesk Hub] Version ${managerVersion}`);
|
|
6472
6502
|
console.log(`[LiveDesk Hub] HTTP API http://${httpHost}:${httpPort}`);
|
|
6473
6503
|
console.log(`[LiveDesk Hub] Client endpoint ${status.agentEndpoint} pair=${status.pairTokenPreview}`);
|
|
6504
|
+
void restorePersistedHubSessionAtStartup().catch(error => {
|
|
6505
|
+
console.warn(`[LiveDesk Hub] Saved sign-in startup restore deferred to the Hub page: ${error?.message || error}`);
|
|
6506
|
+
});
|
|
6474
6507
|
});
|
|
6475
6508
|
|
|
6476
6509
|
const roleWatchTimer = runtimeRole === 'hub'
|