From 73ad8e4eb566fe682107fa7e50ef624591199e99 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Tue, 15 Sep 2026 02:16:39 +0200 Subject: feat(hub): session lifetime is an admin setting, and a browser signs out when idle Browser idle sign-out (media playback counts as activity; not the desktop app), refresh idle window and maximum session length, in hours. Sign-out now revokes on the hub, and the profile has "sign out everywhere". Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01XuNrwLf5EFWCMHzfoEvnpm --- .../meshbay-hub/src/meshbay_hub/static/hub-client.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/hub-client.js') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/hub-client.js b/packages/meshbay-hub/src/meshbay_hub/static/hub-client.js index e72961c..7ba6f92 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/hub-client.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/hub-client.js @@ -245,6 +245,22 @@ async function refreshAccessToken() { return _refreshing; } +/** + * Revoke this session's refresh token on the hub. + * + * Fire and forget, and read synchronously: the caller clears the session on the + * next line, and signing out must not wait on the network or fail with it. + */ +function logoutOnHub() { + const refreshToken = _auth && _auth.refreshToken; + if (!refreshToken) return; + platform.apiFetch(HUB + '/v1/users/logout', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ refresh_token: refreshToken }), + }).catch(() => {}); +} + /** Renew before it bites, rather than after. */ async function ensureFreshToken() { if (!_auth || !_auth.token) return null; @@ -290,5 +306,5 @@ export { cacheGroupIndex, getCachedGroupIndex, getAllCachedIndexes, clearAllCachedIndexes, _storeBundleKey, _loadBundleKey, _storeRecoveryKey, _loadRecoveryKey, _clearKeyDB, loadAuth, saveAuth, setAuth, setAuthChangeListener, - tokenLifeLeft, refreshAccessToken, ensureFreshToken, hubFetch, + tokenLifeLeft, refreshAccessToken, ensureFreshToken, logoutOnHub, hubFetch, }; -- cgit v1.2.3