Skip to content

Commit 13513e6

Browse files
committed
don't need to check for server support
matrix-js-sdk already requires spec version 1.1 support
1 parent b3d8fa6 commit 13513e6

File tree

5 files changed

+4
-71
lines changed

5 files changed

+4
-71
lines changed

src/DeviceListener.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import { UIFeature } from "./settings/UIFeature";
4646
import { isBulkUnverifiedDeviceReminderSnoozed } from "./utils/device/snoozeBulkUnverifiedDeviceReminder";
4747
import { getUserDeviceIds } from "./utils/crypto/deviceInfo";
4848
import { asyncSomeParallel } from "./utils/arrays.ts";
49-
import { doesServerSupportCrossSigning } from "./utils/crypto/doesServerSupportCrossSigning";
5049

5150
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
5251

@@ -319,11 +318,6 @@ export default class DeviceListener {
319318

320319
const cli = this.client;
321320

322-
if (!(await doesServerSupportCrossSigning(cli))) {
323-
logSpan.debug("cross-signing not supported");
324-
return;
325-
}
326-
327321
const crypto = cli.getCrypto();
328322
if (!crypto) {
329323
logSpan.debug("crypto not enabled");

src/components/structures/MatrixChat.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ import { ShareFormat, type SharePayload } from "../../dispatcher/payloads/ShareP
140140
import Markdown from "../../Markdown";
141141
import { sanitizeHtmlParams } from "../../Linkify";
142142
import { isOnlyAdmin } from "../../utils/membership";
143-
import { doesServerSupportCrossSigning } from "../../utils/crypto/doesServerSupportCrossSigning";
144143

145144
// legacy export
146145
export { default as Views } from "../../Views";
@@ -425,7 +424,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
425424
} else {
426425
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
427426
}
428-
} else if ((await doesServerSupportCrossSigning(cli)) && !(await shouldSkipSetupEncryption(cli))) {
427+
} else if (!(await shouldSkipSetupEncryption(cli))) {
429428
// if cross-signing is not yet set up, do so now if possible.
430429
InitialCryptoSetupStore.sharedInstance().startInitialCryptoSetup(
431430
cli,
@@ -1373,10 +1372,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
13731372
const crypto = client.getCrypto();
13741373
if (!crypto) return false;
13751374

1376-
// If the server doesn't support cross-signing, the user won't have an
1377-
// identity to confirm.
1378-
if (!(await doesServerSupportCrossSigning(client))) return false;
1379-
13801375
// If we skip setting up encryption, this takes priority over forcing
13811376
// verification.
13821377
if (await shouldSkipSetupEncryption(client)) return false;

src/components/viewmodels/right_panel/user_info/UserInfoHeaderVerificationViewModel.tsx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import MatrixClientContext from "../../../../contexts/MatrixClientContext";
1212
import { type IDevice } from "../../../views/right_panel/UserInfo";
1313
import { useAsyncMemo } from "../../../../hooks/useAsyncMemo";
1414
import { verifyUser } from "../../../../verification";
15-
import { doesServerSupportCrossSigning } from "../../../../utils/crypto/doesServerSupportCrossSigning";
1615

1716
export interface UserInfoVerificationSectionState {
1817
/**
@@ -30,16 +29,6 @@ export interface UserInfoVerificationSectionState {
3029
verifySelectedUser: () => Promise<void>;
3130
}
3231

33-
const useHomeserverSupportsCrossSigning = (cli: MatrixClient): boolean => {
34-
return useAsyncMemo<boolean>(
35-
async () => {
36-
return doesServerSupportCrossSigning(cli);
37-
},
38-
[cli],
39-
false,
40-
);
41-
};
42-
4332
const useHasCrossSigningKeys = (cli: MatrixClient, member: User, canVerify: boolean): boolean | undefined => {
4433
return useAsyncMemo(async () => {
4534
if (!canVerify) return undefined;
@@ -57,8 +46,6 @@ export const useUserInfoVerificationViewModel = (
5746
): UserInfoVerificationSectionState => {
5847
const cli = useContext(MatrixClientContext);
5948

60-
const homeserverSupportsCrossSigning = useHomeserverSupportsCrossSigning(cli);
61-
6249
const userTrust = useAsyncMemo<UserVerificationStatus | undefined>(
6350
async () => cli.getCrypto()?.getUserVerificationStatus(member.userId),
6451
[member.userId],
@@ -68,13 +55,7 @@ export const useUserInfoVerificationViewModel = (
6855
const hasUserVerificationStatus = Boolean(userTrust);
6956
const isUserVerified = Boolean(userTrust?.isVerified());
7057
const isMe = member.userId === cli.getUserId();
71-
const canVerify =
72-
hasUserVerificationStatus &&
73-
homeserverSupportsCrossSigning &&
74-
!isUserVerified &&
75-
!isMe &&
76-
devices &&
77-
devices.length > 0;
58+
const canVerify = hasUserVerificationStatus && !isUserVerified && !isMe && devices && devices.length > 0;
7859

7960
const hasCrossSigningKeys = useHasCrossSigningKeys(cli, member as User, canVerify);
8061
const verifySelectedUser = (): Promise<void> => verifyUser(cli, member as User);

src/utils/crypto/doesServerSupportCrossSigning.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/unit-tests/components/structures/MatrixChat-test.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,22 +1343,8 @@ describe("<MatrixChat />", () => {
13431343
expect(screen.getByRole("heading", { name: "Welcome Ernie" })).toBeInTheDocument();
13441344
});
13451345

1346-
it("should go straight to logged in view when user does not have cross signing keys and server does not support cross signing", async () => {
1347-
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(false);
1348-
1349-
await getComponentAndLogin(false);
1350-
1351-
expect(loginClient.doesServerSupportUnstableFeature).toHaveBeenCalledWith(
1352-
"org.matrix.e2e_cross_signing",
1353-
);
1354-
1355-
// logged in
1356-
await screen.findByLabelText("User menu");
1357-
});
1358-
1359-
describe("when server supports cross signing and user does not have cross signing setup", () => {
1346+
describe("when user does not have cross signing setup", () => {
13601347
beforeEach(() => {
1361-
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(true);
13621348
jest.spyOn(loginClient.getCrypto()!, "userHasCrossSigningKeys").mockResolvedValue(false);
13631349
});
13641350

@@ -1403,8 +1389,6 @@ describe("<MatrixChat />", () => {
14031389
});
14041390

14051391
it("should go to setup e2e screen", async () => {
1406-
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(true);
1407-
14081392
await getComponentAndLogin();
14091393

14101394
expect(loginClient.getCrypto()!.userHasCrossSigningKeys).toHaveBeenCalled();
@@ -1427,9 +1411,7 @@ describe("<MatrixChat />", () => {
14271411
expect(screen.getByText("Confirm your identity")).toBeInTheDocument();
14281412
});
14291413

1430-
it("should setup e2e when server supports cross signing", async () => {
1431-
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(true);
1432-
1414+
it("should setup e2e", async () => {
14331415
await getComponentAndLogin();
14341416

14351417
expect(loginClient.getCrypto()!.userHasCrossSigningKeys).toHaveBeenCalled();

0 commit comments

Comments
 (0)