From f8642b10a6cf540ad3d6531a8adc62cd58459d42 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Mon, 21 Oct 2024 14:58:57 +0200 Subject: [PATCH] Remove `MatrixClient.getDehydratedDevice` call --- src/stores/SetupEncryptionStore.ts | 10 +++----- .../stores/SetupEncryptionStore-test.ts | 23 ------------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/stores/SetupEncryptionStore.ts b/src/stores/SetupEncryptionStore.ts index 6fafd6efaa2..6b67bcfc492 100644 --- a/src/stores/SetupEncryptionStore.ts +++ b/src/stores/SetupEncryptionStore.ts @@ -101,18 +101,14 @@ export class SetupEncryptionStore extends EventEmitter { this.keyInfo = keys[this.keyId]; } - // do we have any other verified devices which are E2EE which we can verify against? - const dehydratedDevice = await cli.getDehydratedDevice(); const ownUserId = cli.getUserId()!; const crypto = cli.getCrypto()!; + // do we have any other verified devices which are E2EE which we can verify against? const userDevices: Iterable = (await crypto.getUserDeviceInfo([ownUserId])).get(ownUserId)?.values() ?? []; this.hasDevicesToVerifyAgainst = await asyncSome(userDevices, async (device) => { - // Ignore dehydrated devices. `dehydratedDevice` is set by the - // implementation of MSC2697, whereas MSC3814 proposes that devices - // should set a `dehydrated` flag in the device key. We ignore - // both types of dehydrated devices. - if (dehydratedDevice && device.deviceId == dehydratedDevice?.device_id) return false; + // Ignore dehydrated devices. MSC3814 proposes that devices + // should set a `dehydrated` flag in the device key. if (device.dehydrated) return false; // ignore devices without an identity key diff --git a/test/unit-tests/stores/SetupEncryptionStore-test.ts b/test/unit-tests/stores/SetupEncryptionStore-test.ts index a39f3c7a8e0..cc798968550 100644 --- a/test/unit-tests/stores/SetupEncryptionStore-test.ts +++ b/test/unit-tests/stores/SetupEncryptionStore-test.ts @@ -10,7 +10,6 @@ import { mocked, Mocked } from "jest-mock"; import { IBootstrapCrossSigningOpts } from "matrix-js-sdk/src/crypto"; import { MatrixClient, Device } from "matrix-js-sdk/src/matrix"; import { SecretStorageKeyDescriptionAesV1, ServerSideSecretStorage } from "matrix-js-sdk/src/secret-storage"; -import { IDehydratedDevice } from "matrix-js-sdk/src/crypto/dehydration"; import { CryptoApi, DeviceVerificationStatus } from "matrix-js-sdk/src/crypto-api"; import { SdkContextClass } from "../../../src/contexts/SDKContext"; @@ -97,28 +96,6 @@ describe("SetupEncryptionStore", () => { expect(setupEncryptionStore.hasDevicesToVerifyAgainst).toBe(true); }); - it("should ignore the MSC2697 dehydrated device", async () => { - mockSecretStorage.isStored.mockResolvedValue({ sskeyid: {} as SecretStorageKeyDescriptionAesV1 }); - - client.getDehydratedDevice.mockResolvedValue({ device_id: "dehydrated" } as IDehydratedDevice); - - const fakeDevice = new Device({ - deviceId: "dehydrated", - userId: "", - algorithms: [], - keys: new Map([["curve25519:dehydrated", "identityKey"]]), - }); - mockCrypto.getUserDeviceInfo.mockResolvedValue( - new Map([[client.getSafeUserId(), new Map([[fakeDevice.deviceId, fakeDevice]])]]), - ); - - setupEncryptionStore.start(); - await emitPromise(setupEncryptionStore, "update"); - - expect(setupEncryptionStore.hasDevicesToVerifyAgainst).toBe(false); - expect(mockCrypto.getDeviceVerificationStatus).not.toHaveBeenCalled(); - }); - it("should ignore the MSC3812 dehydrated device", async () => { mockSecretStorage.isStored.mockResolvedValue({ sskeyid: {} as SecretStorageKeyDescriptionAesV1 });