Verify-then-fix batch of minor bugs; each staged diff reviewed by 2 agents (both SHIP). Two listed items (N6 receipt-avatar refresh, H10 room-name length reject) were already handled and left unchanged. Threads: - T5: a just-sent reply no longer under-notifies — `participated` also checks the local thread timeline for our own events, since the server-bundle `hasCurrentUserParticipated` lags. - T6: a room set to "Mentions & Keywords only" no longer over-notifies Default thread replies — new `roomMentionsOnly` gate (behavior-identical when false; +4 unit tests). - T7: thread-mode account-data writes are serialized with content carried forward (setAccountData is a bare PUT whose result lags the /sync echo, so plain serialization wouldn't stop the lost update); carry only on success. Calls / audio: - C-L2: a real incoming ring cancels a lingering Settings ringtone preview. - C-L3: the ringtone AudioContext is primed on the first page gesture (via the always-mounted CallEmbedProvider) so the first ring after a cold load isn't silent. - C-L5: useCallSpeakers depends on a stable boolean, so the tile MutationObserver + io.lotus.call_state subscription aren't rebuilt on every membership change. Crypto: - F5: the OIDC refresher forwards the freshly-refreshed token expiry (passed on the tokens object at runtime) as expiresInMs, so the persisted expiresAt no longer goes stale across reloads. Gates: tsc 0, eslint 0, prettier clean, 860/860 tests, build ok. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { OidcTokenRefresher } from 'matrix-js-sdk';
|
|
import type { IdTokenClaims } from 'oidc-client-ts';
|
|
import { OidcSessionMeta, setFallbackSession } from '../app/state/sessions';
|
|
|
|
/**
|
|
* OidcTokenRefresher that persists rotated tokens back to the fallback session,
|
|
* so a page reload keeps the freshest access/refresh token. The matrix client
|
|
* calls this automatically (reactively on a 401) when a refresh token is set.
|
|
*/
|
|
export class LotusOidcTokenRefresher extends OidcTokenRefresher {
|
|
private readonly deviceIdRef: string;
|
|
|
|
private readonly userIdRef: string;
|
|
|
|
private readonly baseUrlRef: string;
|
|
|
|
private readonly oidcRef: OidcSessionMeta;
|
|
|
|
constructor(oidc: OidcSessionMeta, deviceId: string, userId: string, baseUrl: string) {
|
|
super(
|
|
oidc.issuer,
|
|
oidc.clientId,
|
|
oidc.redirectUri,
|
|
deviceId,
|
|
(oidc.idTokenClaims ?? {}) as unknown as IdTokenClaims,
|
|
);
|
|
this.deviceIdRef = deviceId;
|
|
this.userIdRef = userId;
|
|
this.baseUrlRef = baseUrl;
|
|
this.oidcRef = oidc;
|
|
}
|
|
|
|
// F5 — persist the new expiry so the stored `expiresAt` stays fresh across
|
|
// reloads instead of going stale. The SDK invokes persistTokens synchronously
|
|
// inside the refresh and passes the freshly-refreshed `expiry` (a Date) on the
|
|
// tokens object at runtime, even though its published type omits it — so read
|
|
// it here directly (a doRefreshAccessToken override would run too late, since
|
|
// persistTokens is called before that method returns).
|
|
protected async persistTokens(tokens: {
|
|
accessToken: string;
|
|
refreshToken?: string;
|
|
expiry?: Date;
|
|
}): Promise<void> {
|
|
const expiresInMs =
|
|
tokens.expiry instanceof Date ? Math.max(0, tokens.expiry.getTime() - Date.now()) : undefined;
|
|
setFallbackSession(tokens.accessToken, this.deviceIdRef, this.userIdRef, this.baseUrlRef, {
|
|
refreshToken: tokens.refreshToken,
|
|
oidc: this.oidcRef,
|
|
expiresInMs,
|
|
});
|
|
}
|
|
}
|