SPA gate should come from EC config not a URL param

This commit is contained in:
David Langley
2026-07-10 19:21:09 +01:00
parent 23a9e0c85e
commit a75eeaeda1
7 changed files with 56 additions and 10 deletions

View File

@@ -123,6 +123,28 @@ describe("UrlParams", () => {
});
});
describe("enableClientWellKnownLookups", () => {
it("is undefined when not set (so the config value applies)", () => {
expect(
computeUrlParams().enableClientWellKnownLookups,
).toBeUndefined();
});
it("is false when set to false", () => {
expect(
computeUrlParams("?enableClientWellKnownLookups=false")
.enableClientWellKnownLookups,
).toBe(false);
});
it("is true when set to true", () => {
expect(
computeUrlParams("?enableClientWellKnownLookups=true")
.enableClientWellKnownLookups,
).toBe(true);
});
});
describe("returnToLobby", () => {
it("is false in SPA mode", () => {
expect(computeUrlParams("?returnToLobby=true").returnToLobby).toBe(false);

View File

@@ -190,9 +190,10 @@ export interface UrlConfiguration {
/**
* Whether the app may make client `.well-known` lookups against the user's
* homeserver `server_name` (the post-login well-known poll and the legacy
* MatrixRTC foci `.well-known` fallback). Defaults to true.
* MatrixRTC foci `.well-known` fallback). Set by the embedder in widget mode;
* when unset the `enable_client_well_known_lookups` config value applies.
*/
enableClientWellKnownLookups: boolean;
enableClientWellKnownLookups?: boolean;
/**
* Whether the app should use per participant keys for E2EE.
@@ -378,7 +379,6 @@ export const computeUrlParams = (search = "", hash = ""): UrlParams => {
showControls: true,
hideScreensharing: false,
allowIceFallback: true,
enableClientWellKnownLookups: true,
perParticipantE2EE: true,
controlledAudioDevices: platform === "desktop" ? false : true,
skipLobby: true,
@@ -434,7 +434,6 @@ export const computeUrlParams = (search = "", hash = ""): UrlParams => {
showControls: true,
hideScreensharing: false,
allowIceFallback: false,
enableClientWellKnownLookups: true,
perParticipantE2EE: false,
controlledAudioDevices: false,
skipLobby: false,

View File

@@ -90,6 +90,19 @@ export class Config {
return Config.get().default_server_config?.["m.homeserver"].server_name;
}
/**
* Whether the app may make client `.well-known` lookups against the
* homeserver `server_name`. The embedded (widget) deployment sets this via
* the `enableClientWellKnownLookups` URL parameter; the standalone (SPA)
* deployment sets it via `enable_client_well_known_lookups` in config.json.
*/
public static clientWellKnownLookupsEnabled(): boolean {
return (
getUrlParams().enableClientWellKnownLookups ??
Config.get().enable_client_well_known_lookups
);
}
public config?: ResolvedConfigOptions;
private initPromise?: Promise<void>;
}

View File

@@ -70,6 +70,16 @@ export interface ConfigOptions {
};
};
/**
* Whether the app may make client `.well-known` lookups against the user's
* homeserver `server_name` (the post-login well-known poll and the legacy
* MatrixRTC foci `.well-known` fallback). Set to false to keep the app on the
* homeserver base URL. This is the standalone (SPA) deployment control;
* embedded deployments set it via the `enableClientWellKnownLookups` URL
* parameter instead. Defaults to true.
*/
enable_client_well_known_lookups?: boolean;
// Describes the LiveKit configuration to be used.
livekit?: {
// The link to the service that returns a livekit url and token to use it.
@@ -189,6 +199,7 @@ export interface ResolvedConfigOptions extends ConfigOptions {
server_name: string;
};
};
enable_client_well_known_lookups: boolean;
sync_disconnect_grace_period_ms: number;
ssla: string;
matrix_rtc_session: {
@@ -211,6 +222,7 @@ export const DEFAULT_CONFIG: ResolvedConfigOptions = {
features: {
feature_use_device_session_member_events: true,
},
enable_client_well_known_lookups: true,
sync_disconnect_grace_period_ms: 10000,
ssla: "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf",
matrix_rtc_session: {

View File

@@ -44,7 +44,6 @@ import {
} from "../../../livekit/openIDSFU.ts";
import { areLivekitTransportsEqual } from "../remoteMembers/MatrixLivekitMembers.ts";
import { customLivekitUrl } from "../../../settings/settings.ts";
import { getUrlParams } from "../../../UrlParams.ts";
import { RtcTransportAutoDiscovery } from "./RtcTransportAutoDiscovery.ts";
const logger = rootLogger.getChild("[LocalTransport]");
@@ -148,7 +147,7 @@ export const createLocalTransport$ = ({
const transportDiscovery = new RtcTransportAutoDiscovery({
client: client,
resolvedConfig: Config.get(),
enableClientWellKnownLookups: getUrlParams().enableClientWellKnownLookups,
enableClientWellKnownLookups: Config.clientWellKnownLookupsEnabled(),
wellKnownFetcher: AutoDiscovery.getRawClientConfig.bind(AutoDiscovery),
logger: logger,
});

View File

@@ -112,7 +112,7 @@ export async function initClient(
// the values around, but we initialise the matrix client in
// many different places so we'd have to pass it into all of
// them.
const { e2eEnabled, enableClientWellKnownLookups } = getUrlParams();
const { e2eEnabled } = getUrlParams();
if (!e2eEnabled) {
logger.info("Disabling E2E: group call signalling will NOT be encrypted.");
}
@@ -169,7 +169,9 @@ export async function initClient(
// Leaving `clientWellKnownPollPeriod` unset stops the SDK polling the
// homeserver's `server_name` `.well-known` after login.
await client.startClient({
clientWellKnownPollPeriod: enableClientWellKnownLookups ? 60 * 10 : undefined,
clientWellKnownPollPeriod: Config.clientWellKnownLookupsEnabled()
? 60 * 10
: undefined,
});
await syncPromise;

View File

@@ -82,7 +82,6 @@ export const initializeWidget = (
baseUrl,
e2eEnabled,
allowIceFallback,
enableClientWellKnownLookups,
} = getUrlParams();
if (!roomId) throw new Error("Room ID must be supplied");
@@ -199,7 +198,7 @@ export const initializeWidget = (
// Leaving `clientWellKnownPollPeriod` unset stops the SDK polling the
// homeserver's `server_name` `.well-known` after login.
await client.startClient({
clientWellKnownPollPeriod: enableClientWellKnownLookups
clientWellKnownPollPeriod: Config.clientWellKnownLookupsEnabled()
? 60 * 10
: undefined,
});