mirror of
https://github.com/vector-im/element-web.git
synced 2025-12-05 09:21:17 +01:00
Remove obsolete checks that the server supports cross-signing (#31275)
We already depend on an API version that includes cross-signing
This commit is contained in:
parent
dd89cee328
commit
0a46edaaff
@ -318,12 +318,6 @@ export default class DeviceListener {
|
|||||||
|
|
||||||
const cli = this.client;
|
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"))) {
|
|
||||||
logSpan.debug("cross-signing not supported");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const crypto = cli.getCrypto();
|
const crypto = cli.getCrypto();
|
||||||
if (!crypto) {
|
if (!crypto) {
|
||||||
logSpan.debug("crypto not enabled");
|
logSpan.debug("crypto not enabled");
|
||||||
|
|||||||
@ -427,10 +427,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
} else {
|
} else {
|
||||||
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
|
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (!(await shouldSkipSetupEncryption(cli))) {
|
||||||
(await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")) &&
|
|
||||||
!(await shouldSkipSetupEncryption(cli))
|
|
||||||
) {
|
|
||||||
// if cross-signing is not yet set up, do so now if possible.
|
// if cross-signing is not yet set up, do so now if possible.
|
||||||
InitialCryptoSetupStore.sharedInstance().startInitialCryptoSetup(
|
InitialCryptoSetupStore.sharedInstance().startInitialCryptoSetup(
|
||||||
cli,
|
cli,
|
||||||
|
|||||||
@ -29,16 +29,6 @@ export interface UserInfoVerificationSectionState {
|
|||||||
verifySelectedUser: () => Promise<void>;
|
verifySelectedUser: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useHomeserverSupportsCrossSigning = (cli: MatrixClient): boolean => {
|
|
||||||
return useAsyncMemo<boolean>(
|
|
||||||
async () => {
|
|
||||||
return cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing");
|
|
||||||
},
|
|
||||||
[cli],
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const useHasCrossSigningKeys = (cli: MatrixClient, member: User, canVerify: boolean): boolean | undefined => {
|
const useHasCrossSigningKeys = (cli: MatrixClient, member: User, canVerify: boolean): boolean | undefined => {
|
||||||
return useAsyncMemo(async () => {
|
return useAsyncMemo(async () => {
|
||||||
if (!canVerify) return undefined;
|
if (!canVerify) return undefined;
|
||||||
@ -56,8 +46,6 @@ export const useUserInfoVerificationViewModel = (
|
|||||||
): UserInfoVerificationSectionState => {
|
): UserInfoVerificationSectionState => {
|
||||||
const cli = useContext(MatrixClientContext);
|
const cli = useContext(MatrixClientContext);
|
||||||
|
|
||||||
const homeserverSupportsCrossSigning = useHomeserverSupportsCrossSigning(cli);
|
|
||||||
|
|
||||||
const userTrust = useAsyncMemo<UserVerificationStatus | undefined>(
|
const userTrust = useAsyncMemo<UserVerificationStatus | undefined>(
|
||||||
async () => cli.getCrypto()?.getUserVerificationStatus(member.userId),
|
async () => cli.getCrypto()?.getUserVerificationStatus(member.userId),
|
||||||
[member.userId],
|
[member.userId],
|
||||||
@ -67,13 +55,7 @@ export const useUserInfoVerificationViewModel = (
|
|||||||
const hasUserVerificationStatus = Boolean(userTrust);
|
const hasUserVerificationStatus = Boolean(userTrust);
|
||||||
const isUserVerified = Boolean(userTrust?.isVerified());
|
const isUserVerified = Boolean(userTrust?.isVerified());
|
||||||
const isMe = member.userId === cli.getUserId();
|
const isMe = member.userId === cli.getUserId();
|
||||||
const canVerify =
|
const canVerify = hasUserVerificationStatus && !isUserVerified && !isMe && devices && devices.length > 0;
|
||||||
hasUserVerificationStatus &&
|
|
||||||
homeserverSupportsCrossSigning &&
|
|
||||||
!isUserVerified &&
|
|
||||||
!isMe &&
|
|
||||||
devices &&
|
|
||||||
devices.length > 0;
|
|
||||||
|
|
||||||
const hasCrossSigningKeys = useHasCrossSigningKeys(cli, member as User, canVerify);
|
const hasCrossSigningKeys = useHasCrossSigningKeys(cli, member as User, canVerify);
|
||||||
const verifySelectedUser = (): Promise<void> => verifyUser(cli, member as User);
|
const verifySelectedUser = (): Promise<void> => verifyUser(cli, member as User);
|
||||||
|
|||||||
@ -275,13 +275,6 @@ describe("DeviceListener", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("recheck", () => {
|
describe("recheck", () => {
|
||||||
it("does nothing when cross signing feature is not supported", async () => {
|
|
||||||
mockClient!.isVersionSupported.mockResolvedValue(false);
|
|
||||||
await createAndStart();
|
|
||||||
|
|
||||||
expect(mockClient!.isVersionSupported).toHaveBeenCalledWith("v1.1");
|
|
||||||
expect(mockCrypto!.isCrossSigningReady).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
it("does nothing when crypto is not enabled", async () => {
|
it("does nothing when crypto is not enabled", async () => {
|
||||||
mockClient!.getCrypto.mockReturnValue(undefined);
|
mockClient!.getCrypto.mockReturnValue(undefined);
|
||||||
await createAndStart();
|
await createAndStart();
|
||||||
|
|||||||
@ -554,8 +554,8 @@ describe("<MatrixChat />", () => {
|
|||||||
expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: "client_started" }),
|
expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: "client_started" }),
|
||||||
);
|
);
|
||||||
|
|
||||||
// check we get to logged in view
|
// set up keys screen is rendered
|
||||||
await waitForSyncAndLoad(loginClient, true);
|
expect(screen.getByText("Setting up keys")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should persist device language when available", async () => {
|
it("should persist device language when available", async () => {
|
||||||
@ -1166,6 +1166,8 @@ describe("<MatrixChat />", () => {
|
|||||||
// Given force_verification is on (outer describe)
|
// Given force_verification is on (outer describe)
|
||||||
// And we just logged in via OIDC (inner describe)
|
// And we just logged in via OIDC (inner describe)
|
||||||
|
|
||||||
|
mocked(loginClient.getCrypto()!.userHasCrossSigningKeys).mockResolvedValue(true);
|
||||||
|
|
||||||
// When we load the page
|
// When we load the page
|
||||||
getComponent({ realQueryParams });
|
getComponent({ realQueryParams });
|
||||||
|
|
||||||
@ -1340,22 +1342,8 @@ describe("<MatrixChat />", () => {
|
|||||||
expect(screen.getByRole("heading", { name: "Welcome Ernie" })).toBeInTheDocument();
|
expect(screen.getByRole("heading", { name: "Welcome Ernie" })).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should go straight to logged in view when user does not have cross signing keys and server does not support cross signing", async () => {
|
|
||||||
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(false);
|
|
||||||
|
|
||||||
await getComponentAndLogin(false);
|
|
||||||
|
|
||||||
expect(loginClient.doesServerSupportUnstableFeature).toHaveBeenCalledWith(
|
|
||||||
"org.matrix.e2e_cross_signing",
|
|
||||||
);
|
|
||||||
|
|
||||||
// logged in
|
|
||||||
await screen.findByLabelText("User menu");
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when server supports cross signing and user does not have cross signing setup", () => {
|
describe("when server supports cross signing and user does not have cross signing setup", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(true);
|
|
||||||
jest.spyOn(loginClient.getCrypto()!, "userHasCrossSigningKeys").mockResolvedValue(false);
|
jest.spyOn(loginClient.getCrypto()!, "userHasCrossSigningKeys").mockResolvedValue(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1400,8 +1388,6 @@ describe("<MatrixChat />", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should go to setup e2e screen", async () => {
|
it("should go to setup e2e screen", async () => {
|
||||||
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(true);
|
|
||||||
|
|
||||||
await getComponentAndLogin();
|
await getComponentAndLogin();
|
||||||
|
|
||||||
expect(loginClient.getCrypto()!.userHasCrossSigningKeys).toHaveBeenCalled();
|
expect(loginClient.getCrypto()!.userHasCrossSigningKeys).toHaveBeenCalled();
|
||||||
@ -1424,9 +1410,7 @@ describe("<MatrixChat />", () => {
|
|||||||
expect(screen.getByText("Confirm your identity")).toBeInTheDocument();
|
expect(screen.getByText("Confirm your identity")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should setup e2e when server supports cross signing", async () => {
|
it("should setup e2e", async () => {
|
||||||
loginClient.doesServerSupportUnstableFeature.mockResolvedValue(true);
|
|
||||||
|
|
||||||
await getComponentAndLogin();
|
await getComponentAndLogin();
|
||||||
|
|
||||||
expect(loginClient.getCrypto()!.userHasCrossSigningKeys).toHaveBeenCalled();
|
expect(loginClient.getCrypto()!.userHasCrossSigningKeys).toHaveBeenCalled();
|
||||||
@ -1587,8 +1571,8 @@ describe("<MatrixChat />", () => {
|
|||||||
action: "will_start_client",
|
action: "will_start_client",
|
||||||
});
|
});
|
||||||
|
|
||||||
// logged in but waiting for sync screen
|
// set up keys screen is rendered
|
||||||
await screen.findByText("Logout");
|
expect(await screen.findByText("Setting up keys")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user