feat(desktop): implement client token rotation and session management enhancements
Desktop Client Build / Resolve Build Metadata (push) Successful in 27s
Desktop Client Build / Build Desktop Client (push) Successful in 22m14s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 26s

This commit is contained in:
Xu Liang
2026-05-08 11:43:25 +08:00
parent 73f1b2aca8
commit f38930b0ac
7 changed files with 317 additions and 6 deletions
@@ -1,5 +1,11 @@
type RuntimeInvalidationReason = 'account-health' | 'publish-task-lease'
type RuntimeAuthExpiredListener = (event: {
reason: 'client-auth-expired'
at: number
message: string
}) => void
type RuntimeInvalidationListener = (event: {
reason: RuntimeInvalidationReason
at: number
@@ -8,6 +14,7 @@ type RuntimeInvalidationListener = (event: {
}) => void
const listeners = new Set<RuntimeInvalidationListener>()
const authExpiredListeners = new Set<RuntimeAuthExpiredListener>()
export function emitRuntimeInvalidated(
reason: RuntimeInvalidationReason,
@@ -37,3 +44,28 @@ export function onRuntimeInvalidated(listener: RuntimeInvalidationListener): ()
listeners.delete(listener)
}
}
export function emitRuntimeAuthExpired(message: string): void {
const event = {
reason: 'client-auth-expired',
at: Date.now(),
message,
} as const
for (const listener of authExpiredListeners) {
try {
listener(event)
} catch (error) {
console.warn('[desktop-runtime] auth-expired listener failed', {
message: error instanceof Error ? error.message : String(error),
})
}
}
}
export function onRuntimeAuthExpired(listener: RuntimeAuthExpiredListener): () => void {
authExpiredListeners.add(listener)
return () => {
authExpiredListeners.delete(listener)
}
}