Skip to content

Commit

Permalink
Replace remaining use of checkDeviceTrust (#10716)
Browse files Browse the repository at this point in the history
* Fix remaing use of `checkDeviceTrust`

Followup to #10663

* fix strict type-checking error
  • Loading branch information
richvdh committed May 3, 2023
1 parent e8cddca commit 42e6c98
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/stores/SetupEncryptionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Modal from "../Modal";
import InteractiveAuthDialog from "../components/views/dialogs/InteractiveAuthDialog";
import { _t } from "../languageHandler";
import { SdkContextClass } from "../contexts/SDKContext";
import { asyncSome } from "../utils/arrays";

export enum Phase {
Loading = 0,
Expand Down Expand Up @@ -108,20 +109,12 @@ export class SetupEncryptionStore extends EventEmitter {
// 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 crossSigningInfo = cli.getStoredCrossSigningForUser(ownUserId);
this.hasDevicesToVerifyAgainst = cli.getStoredDevicesForUser(ownUserId).some((device) => {
this.hasDevicesToVerifyAgainst = await asyncSome(cli.getStoredDevicesForUser(ownUserId), async (device) => {
if (!device.getIdentityKey() || (dehydratedDevice && device.deviceId == dehydratedDevice?.device_id)) {
return false;
}
// check if the device is signed by the cross-signing key stored for our user. Note that this is
// *different* to calling `cryptoApi.getDeviceVerificationStatus`, because even if we have stored
// a cross-signing key for our user, we don't necessarily trust it yet (In legacy Crypto, we have not
// yet imported it into `Crypto.crossSigningInfo`, which for maximal confusion is a different object to
// `Crypto.getStoredCrossSigningForUser(ownUserId)`).
//
// TODO: figure out wtf to to here for rust-crypto
const verificationStatus = crossSigningInfo?.checkDeviceTrust(crossSigningInfo, device, false, true);
return !!verificationStatus?.isCrossSigningVerified();
const verificationStatus = await cli.getCrypto()?.getDeviceVerificationStatus(ownUserId, device.deviceId);
return !!verificationStatus?.signedByOwner;
});

this.phase = Phase.Intro;
Expand Down

0 comments on commit 42e6c98

Please sign in to comment.