Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DeviceListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { UIFeature } from "./settings/UIFeature";
import { isBulkUnverifiedDeviceReminderSnoozed } from "./utils/device/snoozeBulkUnverifiedDeviceReminder";
import { getUserDeviceIds } from "./utils/crypto/deviceInfo";
import { asyncSomeParallel } from "./utils/arrays.ts";
import { doesServerSupportCrossSigning } from "./utils/crypto/doesServerSupportCrossSigning";

const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;

Expand Down Expand Up @@ -318,8 +319,7 @@ export default class DeviceListener {

const cli = this.client;

// cross-signing support was added to Matrix in MSC1756, which landed in spec v1.1
if (!(await cli.isVersionSupported("v1.1"))) {
if (!(await doesServerSupportCrossSigning(cli))) {
logSpan.debug("cross-signing not supported");
return;
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import { ShareFormat, type SharePayload } from "../../dispatcher/payloads/ShareP
import Markdown from "../../Markdown";
import { sanitizeHtmlParams } from "../../Linkify";
import { isOnlyAdmin } from "../../utils/membership";
import { doesServerSupportCrossSigning } from "../../utils/crypto/doesServerSupportCrossSigning";

// legacy export
export { default as Views } from "../../Views";
Expand Down Expand Up @@ -424,10 +425,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
} else {
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
}
} else if (
(await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")) &&
!(await shouldSkipSetupEncryption(cli))
) {
} else if ((await doesServerSupportCrossSigning(cli)) && !(await shouldSkipSetupEncryption(cli))) {
// if cross-signing is not yet set up, do so now if possible.
InitialCryptoSetupStore.sharedInstance().startInitialCryptoSetup(
cli,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MatrixClientContext from "../../../../contexts/MatrixClientContext";
import { type IDevice } from "../../../views/right_panel/UserInfo";
import { useAsyncMemo } from "../../../../hooks/useAsyncMemo";
import { verifyUser } from "../../../../verification";
import { doesServerSupportCrossSigning } from "../../../../utils/crypto/doesServerSupportCrossSigning";

export interface UserInfoVerificationSectionState {
/**
Expand All @@ -32,7 +33,7 @@ export interface UserInfoVerificationSectionState {
const useHomeserverSupportsCrossSigning = (cli: MatrixClient): boolean => {
return useAsyncMemo<boolean>(
async () => {
return cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing");
return doesServerSupportCrossSigning(cli);
},
[cli],
false,
Expand Down
19 changes: 19 additions & 0 deletions src/utils/crypto/doesServerSupportCrossSigning.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2025 New Vector Ltd.

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/

import { type MatrixClient } from "matrix-js-sdk/src/matrix";

/**
* If the server supports cross-signing.
*/
export async function doesServerSupportCrossSigning(cli: MatrixClient): Promise<boolean> {
// cross-signing support was added to Matrix in MSC1756, which landed in spec v1.1
return (
(await cli.isVersionSupported("v1.1")) ||
(await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing"))
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest dropping this check altogether. I'm not sure about EW, but the js-sdk claims a minimum supported server version of 1.1, so we should be good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds sane, if js-sdk flags that your server version is not supported then you will not be able to login anyway iirc

Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ beforeEach(() => {
on: jest.fn(),
off: jest.fn(),
isSynapseAdministrator: jest.fn().mockResolvedValue(false),
isVersionSupported: jest.fn().mockResolvedValue(false),
doesServerSupportUnstableFeature: jest.fn().mockReturnValue(false),
doesServerSupportExtendedProfiles: jest.fn().mockResolvedValue(false),
getExtendedProfileProperty: jest.fn().mockRejectedValue(new Error("Not supported")),
Expand Down