Skip to content

Commit 351774d

Browse files
authored
Merge branch 'develop' into t3chguy/fix/20721
2 parents 70f898c + 4f276c1 commit 351774d

File tree

11 files changed

+34
-72
lines changed

11 files changed

+34
-72
lines changed

playwright/plugins/homeserver/synapse/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { randB64Bytes } from "../../utils/rand";
2020
// Docker tag to use for synapse docker image.
2121
// We target a specific digest as every now and then a Synapse update will break our CI.
2222
// This digest is updated by the playwright-image-updates.yaml workflow periodically.
23-
const DOCKER_TAG = "develop@sha256:b261d81d9a3615a7716fc92423ee5689b0b450ed49f87a4887e49ecab7aefe45";
23+
const DOCKER_TAG = "develop@sha256:489fe921e03440af87e001106c41c70ffc55a1e8078d1a7f45e16fbaddc5088a";
2424

2525
async function cfgDirFromTemplate(opts: StartHomeserverOpts): Promise<Omit<HomeserverConfig, "dockerUrl">> {
2626
const templateDir = path.join(__dirname, "templates", opts.template);

src/MatrixClientPeg.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ import IdentityAuthClient from "./IdentityAuthClient";
3535
import { crossSigningCallbacks } from "./SecurityManager";
3636
import { SlidingSyncManager } from "./SlidingSyncManager";
3737
import { _t, UserFriendlyError } from "./languageHandler";
38-
import { SettingLevel } from "./settings/SettingLevel";
3938
import MatrixClientBackedController from "./settings/controllers/MatrixClientBackedController";
4039
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
4140
import PlatformPeg from "./PlatformPeg";
4241
import { formatList } from "./utils/FormattingUtils";
4342
import SdkConfig from "./SdkConfig";
44-
import { Features } from "./settings/Settings";
4543
import { setDeviceIsolationMode } from "./settings/controllers/DeviceIsolationModeController.ts";
4644

4745
export interface IMatrixClientCreds {
@@ -333,11 +331,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
333331
logger.error("Warning! Not using an encryption key for rust crypto store.");
334332
}
335333

336-
// Record the fact that we used the Rust crypto stack with this client. This just guards against people
337-
// rolling back to versions of EW that did not default to Rust crypto (which would lead to an error, since
338-
// we cannot migrate from Rust to Legacy crypto).
339-
await SettingsStore.setValue(Features.RustCrypto, null, SettingLevel.DEVICE, true);
340-
341334
await this.matrixClient.initRustCrypto({
342335
storageKey: rustCryptoStoreKey,
343336
storagePassword: rustCryptoStorePassword,

src/components/structures/RoomView.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
671671
// the RoomView instance
672672
if (initial) {
673673
newState.room = this.context.client!.getRoom(newState.roomId) || undefined;
674+
newState.isRoomEncrypted = null;
674675
if (newState.room) {
675676
newState.showApps = this.shouldShowApps(newState.room);
676677
this.onRoomLoaded(newState.room);
@@ -713,6 +714,14 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
713714
if (initial) {
714715
this.setupRoom(newState.room, newState.roomId, !!newState.joining, !!newState.shouldPeek);
715716
}
717+
718+
// We don't block the initial setup but we want to make it early to not block the timeline rendering
719+
const isRoomEncrypted = await this.getIsRoomEncrypted(newState.roomId);
720+
this.setState({
721+
isRoomEncrypted,
722+
...(isRoomEncrypted &&
723+
newState.roomId && { e2eStatus: RoomView.e2eStatusCache.get(newState.roomId) ?? E2EStatus.Warning }),
724+
});
716725
};
717726

718727
private onConnectedCalls = (): void => {
@@ -863,7 +872,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
863872
return isManuallyShown && widgets.length > 0;
864873
}
865874

866-
public async componentDidMount(): Promise<void> {
875+
public componentDidMount(): void {
867876
this.unmounted = false;
868877

869878
this.dispatcherRef = defaultDispatcher.register(this.onAction);
@@ -1482,24 +1491,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
14821491

14831492
private async updateE2EStatus(room: Room): Promise<void> {
14841493
if (!this.context.client || !this.state.isRoomEncrypted) return;
1485-
1486-
// If crypto is not currently enabled, we aren't tracking devices at all,
1487-
// so we don't know what the answer is. Let's error on the safe side and show
1488-
// a warning for this case.
1489-
let e2eStatus = RoomView.e2eStatusCache.get(room.roomId) ?? E2EStatus.Warning;
1490-
// set the state immediately then update, so we don't scare the user into thinking the room is unencrypted
1494+
const e2eStatus = await this.cacheAndGetE2EStatus(room, this.context.client);
1495+
if (this.unmounted) return;
14911496
this.setState({ e2eStatus });
1492-
1493-
if (this.context.client.getCrypto()) {
1494-
/* At this point, the user has encryption on and cross-signing on */
1495-
e2eStatus = await this.cacheAndGetE2EStatus(room, this.context.client);
1496-
if (this.unmounted) return;
1497-
this.setState({ e2eStatus });
1498-
}
14991497
}
15001498

15011499
private async cacheAndGetE2EStatus(room: Room, client: MatrixClient): Promise<E2EStatus> {
1502-
const e2eStatus = await shieldStatusForRoom(client, room);
1500+
let e2eStatus = RoomView.e2eStatusCache.get(room.roomId);
1501+
// set the state immediately then update, so we don't scare the user into thinking the room is unencrypted
1502+
if (e2eStatus) this.setState({ e2eStatus });
1503+
1504+
e2eStatus = await shieldStatusForRoom(client, room);
15031505
RoomView.e2eStatusCache.set(room.roomId, e2eStatus);
15041506
return e2eStatus;
15051507
}

src/components/views/auth/LoginWithQR.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,9 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
108108
private generateAndShowCode = async (): Promise<void> => {
109109
let rendezvous: MSC4108SignInWithQR;
110110
try {
111-
const fallbackRzServer = this.props.client?.getClientWellKnown()?.["io.element.rendezvous"]?.server;
112-
113111
const transport = new MSC4108RendezvousSession({
114112
onFailure: this.onFailure,
115113
client: this.props.client,
116-
fallbackRzServer,
117114
});
118115
await transport.send("");
119116
const channel = new MSC4108SecureChannel(transport, undefined, this.onFailure);

src/components/views/rooms/MessageComposerFormatBar.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ interface IState {
3333

3434
export default class MessageComposerFormatBar extends React.PureComponent<IProps, IState> {
3535
private readonly formatBarRef = createRef<HTMLDivElement>();
36+
/**
37+
* The height of the format bar in pixels.
38+
* Height 32px + 2px border
39+
* @private
40+
*/
41+
private readonly BAR_HEIGHT = 34;
3642

3743
public constructor(props: IProps) {
3844
super(props);
@@ -96,7 +102,7 @@ export default class MessageComposerFormatBar extends React.PureComponent<IProps
96102
this.setState({ visible: true });
97103
const parentRect = this.formatBarRef.current.parentElement.getBoundingClientRect();
98104
this.formatBarRef.current.style.left = `${selectionRect.left - parentRect.left}px`;
99-
const halfBarHeight = this.formatBarRef.current.clientHeight / 2; // used to center the bar
105+
const halfBarHeight = this.BAR_HEIGHT / 2; // used to center the bar
100106
const offset = halfBarHeight + 2; // makes sure the bar won't cover selected text
101107
const offsetLimit = halfBarHeight + offset;
102108
const position = Math.max(selectionRect.top - parentRect.top - offsetLimit, -offsetLimit);

src/components/views/settings/devices/LoginWithQRSection.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import React from "react";
10-
import {
11-
IServerVersions,
12-
IClientWellKnown,
13-
OidcClientConfig,
14-
MatrixClient,
15-
DEVICE_CODE_SCOPE,
16-
} from "matrix-js-sdk/src/matrix";
10+
import { IServerVersions, OidcClientConfig, MatrixClient, DEVICE_CODE_SCOPE } from "matrix-js-sdk/src/matrix";
1711
import QrCodeIcon from "@vector-im/compound-design-tokens/assets/web/icons/qr-code";
1812
import { Text } from "@vector-im/compound-web";
1913

@@ -25,7 +19,6 @@ import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext
2519
interface IProps {
2620
onShowQr: () => void;
2721
versions?: IServerVersions;
28-
wellKnown?: IClientWellKnown;
2922
oidcClientConfig?: OidcClientConfig;
3023
isCrossSigningReady?: boolean;
3124
}
@@ -35,10 +28,8 @@ export function shouldShowQr(
3528
isCrossSigningReady: boolean,
3629
oidcClientConfig?: OidcClientConfig,
3730
versions?: IServerVersions,
38-
wellKnown?: IClientWellKnown,
3931
): boolean {
40-
const msc4108Supported =
41-
!!versions?.unstable_features?.["org.matrix.msc4108"] || !!wellKnown?.["io.element.rendezvous"]?.server;
32+
const msc4108Supported = !!versions?.unstable_features?.["org.matrix.msc4108"];
4233

4334
const deviceAuthorizationGrantSupported =
4435
oidcClientConfig?.metadata?.grant_types_supported.includes(DEVICE_CODE_SCOPE);
@@ -51,15 +42,9 @@ export function shouldShowQr(
5142
);
5243
}
5344

54-
const LoginWithQRSection: React.FC<IProps> = ({
55-
onShowQr,
56-
versions,
57-
wellKnown,
58-
oidcClientConfig,
59-
isCrossSigningReady,
60-
}) => {
45+
const LoginWithQRSection: React.FC<IProps> = ({ onShowQr, versions, oidcClientConfig, isCrossSigningReady }) => {
6146
const cli = useMatrixClientContext();
62-
const offerShowQr = shouldShowQr(cli, !!isCrossSigningReady, oidcClientConfig, versions, wellKnown);
47+
const offerShowQr = shouldShowQr(cli, !!isCrossSigningReady, oidcClientConfig, versions);
6348

6449
return (
6550
<SettingsSubsection heading={_t("settings|sessions|sign_in_with_qr")}>

src/components/views/settings/tabs/user/SessionManagerTab.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
66
Please see LICENSE files in the repository root for full details.
77
*/
88

9-
import React, { lazy, Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
9+
import React, { lazy, Suspense, useCallback, useContext, useEffect, useRef, useState } from "react";
1010
import { discoverAndValidateOIDCIssuerWellKnown, MatrixClient } from "matrix-js-sdk/src/matrix";
1111
import { logger } from "matrix-js-sdk/src/logger";
1212
import { defer } from "matrix-js-sdk/src/utils";
@@ -184,7 +184,6 @@ const SessionManagerTab: React.FC<{
184184
const userId = matrixClient?.getUserId();
185185
const currentUserMember = (userId && matrixClient?.getUser(userId)) || undefined;
186186
const clientVersions = useAsyncMemo(() => matrixClient.getVersions(), [matrixClient]);
187-
const wellKnown = useMemo(() => matrixClient?.getClientWellKnown(), [matrixClient]);
188187
const oidcClientConfig = useAsyncMemo(async () => {
189188
try {
190189
const authIssuer = await matrixClient?.getAuthIssuer();
@@ -305,7 +304,6 @@ const SessionManagerTab: React.FC<{
305304
<LoginWithQRSection
306305
onShowQr={onShowQrClicked}
307306
versions={clientVersions}
308-
wellKnown={wellKnown}
309307
oidcClientConfig={oidcClientConfig}
310308
isCrossSigningReady={isCrossSigningReady}
311309
/>

src/settings/Settings.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ export enum Features {
9090
NotificationSettings2 = "feature_notification_settings2",
9191
OidcNativeFlow = "feature_oidc_native_flow",
9292
ReleaseAnnouncement = "feature_release_announcement",
93-
94-
/** If true, use the Rust crypto implementation.
95-
*
96-
* This is no longer read, but we continue to populate it on all devices, to guard against people rolling back to
97-
* old versions of EW that do not use rust crypto by default.
98-
*/
99-
RustCrypto = "feature_rust_crypto",
10093
}
10194

10295
export const labGroupNames: Record<LabGroup, TranslationKey> = {
@@ -469,10 +462,6 @@ export const SETTINGS: { [setting: string]: ISetting } = {
469462
description: _td("labs|oidc_native_flow_description"),
470463
default: false,
471464
},
472-
[Features.RustCrypto]: {
473-
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
474-
default: true,
475-
},
476465
/**
477466
* @deprecated in favor of {@link fontSizeDelta}
478467
*/

src/vector/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ function checkBrowserFeatures(): boolean {
6767
// although this would start to make (more) assumptions about how rust-crypto loads its wasm.
6868
window.Modernizr.addTest("wasm", () => typeof WebAssembly === "object" && typeof WebAssembly.Module === "function");
6969

70+
// Check that the session is in a secure context otherwise most Crypto & WebRTC APIs will be unavailable
71+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext
72+
window.Modernizr.addTest("securecontext", () => window.isSecureContext);
73+
7074
const featureList = Object.keys(window.Modernizr) as Array<keyof ModernizrStatic>;
7175

7276
let featureComplete = true;

test/unit-tests/MatrixClientPeg-test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import fetchMockJest from "fetch-mock-jest";
1111

1212
import { advanceDateAndTime, stubClient } from "../test-utils";
1313
import { IMatrixClientPeg, MatrixClientPeg as peg } from "../../src/MatrixClientPeg";
14-
import SettingsStore from "../../src/settings/SettingsStore";
15-
import { SettingLevel } from "../../src/settings/SettingLevel";
1614

1715
jest.useFakeTimers();
1816

@@ -81,27 +79,18 @@ describe("MatrixClientPeg", () => {
8179
});
8280

8381
it("should initialise the rust crypto library by default", async () => {
84-
const mockSetValue = jest.spyOn(SettingsStore, "setValue").mockResolvedValue(undefined);
85-
8682
const mockInitRustCrypto = jest.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
8783

8884
const cryptoStoreKey = new Uint8Array([1, 2, 3, 4]);
8985
await testPeg.start({ rustCryptoStoreKey: cryptoStoreKey });
9086
expect(mockInitRustCrypto).toHaveBeenCalledWith({ storageKey: cryptoStoreKey });
91-
92-
// we should have stashed the setting in the settings store
93-
expect(mockSetValue).toHaveBeenCalledWith("feature_rust_crypto", null, SettingLevel.DEVICE, true);
9487
});
9588

9689
it("Should migrate existing login", async () => {
97-
const mockSetValue = jest.spyOn(SettingsStore, "setValue").mockResolvedValue(undefined);
9890
const mockInitRustCrypto = jest.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
9991

10092
await testPeg.start();
10193
expect(mockInitRustCrypto).toHaveBeenCalledTimes(1);
102-
103-
// we should have stashed the setting in the settings store
104-
expect(mockSetValue).toHaveBeenCalledWith("feature_rust_crypto", null, SettingLevel.DEVICE, true);
10594
});
10695
});
10796
});

test/unit-tests/components/views/settings/devices/LoginWithQRSection-test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ describe("<LoginWithQRSection />", () => {
5656
const defaultProps = {
5757
onShowQr: () => {},
5858
versions: makeVersions({ "org.matrix.msc4108": true }),
59-
wellKnown: {},
6059
};
6160

6261
const getComponent = (props = {}) => <LoginWithQRSection {...defaultProps} {...props} />;

0 commit comments

Comments
 (0)