CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (pull_request) Successful in 3m24s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 10s
CI / Playwright smoke (e2e) (pull_request) Successful in 16m50s
Picks up three releases of MatrixRTC / delayed-event fixes and matrix-sdk-crypto-wasm 18.3.1 -> 18.9.0. SDK 43 moved OAuth (MSC3861) into the SDK and dropped oidc-client-ts, so the native-OAuth sign-in is ported: - login discovers the auth server via /auth_metadata, registers with OAuth2.registerClient, and keeps the PKCE verifier + device in its own sessionStorage entry keyed by `state` (single use; CSRF check); - refresh is done by the SDK (oauthClientId + onTokenRefresh); the #16 cross-tab protection is kept by a narrow guard on refresh-token grants (the SDK calls the global fetch for OAuth, not fetchFn), which serialises them with a Web Lock and adopts a sibling tab's tokens; - logout and forced logout revoke via mx.logout() (the SDK revokes at the auth server for OAuth sessions); - the callback page parsed its params on every render, re-running the single-use code exchange in a loop; parsed once now. Also: notification_type is deprecated in MSC4075 (ring in DMs, notify elsewhere when omitted), _onRTCSessionMemberUpdate -> ensureRecalculateSessionMembers, precache limit 6 -> 10 MB for the 7.8 MB crypto wasm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { ReactNode, useCallback, useMemo } from 'react';
|
|
import { Capabilities, ValidatedAuthMetadata } from 'matrix-js-sdk';
|
|
import { AsyncStatus, useAsyncCallbackValue } from '../hooks/useAsyncCallback';
|
|
import { useMatrixClient } from '../hooks/useMatrixClient';
|
|
import { MediaConfig } from '../hooks/useMediaConfig';
|
|
import { promiseFulfilledResult } from '../utils/common';
|
|
|
|
export type ServerConfigs = {
|
|
capabilities?: Capabilities;
|
|
mediaConfig?: MediaConfig;
|
|
authMetadata?: ValidatedAuthMetadata;
|
|
};
|
|
|
|
type ServerConfigsLoaderProps = {
|
|
children: (configs: ServerConfigs) => ReactNode;
|
|
};
|
|
export function ServerConfigsLoader({ children }: ServerConfigsLoaderProps) {
|
|
const mx = useMatrixClient();
|
|
const fallbackConfigs = useMemo(() => ({}), []);
|
|
|
|
const [configsState] = useAsyncCallbackValue<ServerConfigs, unknown>(
|
|
useCallback(async () => {
|
|
const result = await Promise.allSettled([
|
|
mx.getCapabilities(),
|
|
mx.getMediaConfig(),
|
|
mx.getAuthMetadata(),
|
|
]);
|
|
|
|
const capabilities = promiseFulfilledResult(result[0]);
|
|
const mediaConfig = promiseFulfilledResult(result[1]);
|
|
// getAuthMetadata validates (and rejects when the server has no native
|
|
// OAuth, which is normal for servers using traditional SSO).
|
|
const authMetadata = promiseFulfilledResult(result[2]);
|
|
|
|
return {
|
|
capabilities,
|
|
mediaConfig,
|
|
authMetadata,
|
|
};
|
|
}, [mx]),
|
|
);
|
|
|
|
const configs: ServerConfigs =
|
|
configsState.status === AsyncStatus.Success ? configsState.data : fallbackConfigs;
|
|
|
|
return children(configs);
|
|
}
|