Replace remaining use of `checkDeviceTrust` (#10716)

* Fix remaing use of `checkDeviceTrust`

Followup to #10663

* fix strict type-checking error
pull/28788/head^2
Richard van der Hoff 2023-05-03 15:02:58 +01:00 committed by GitHub
parent e8cddcac3f
commit 42e6c9839c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 11 deletions

View File

@ -31,6 +31,7 @@ import Modal from "../Modal";
import InteractiveAuthDialog from "../components/views/dialogs/InteractiveAuthDialog"; import InteractiveAuthDialog from "../components/views/dialogs/InteractiveAuthDialog";
import { _t } from "../languageHandler"; import { _t } from "../languageHandler";
import { SdkContextClass } from "../contexts/SDKContext"; import { SdkContextClass } from "../contexts/SDKContext";
import { asyncSome } from "../utils/arrays";
export enum Phase { export enum Phase {
Loading = 0, Loading = 0,
@ -108,20 +109,12 @@ export class SetupEncryptionStore extends EventEmitter {
// do we have any other verified devices which are E2EE which we can verify against? // do we have any other verified devices which are E2EE which we can verify against?
const dehydratedDevice = await cli.getDehydratedDevice(); const dehydratedDevice = await cli.getDehydratedDevice();
const ownUserId = cli.getUserId()!; const ownUserId = cli.getUserId()!;
const crossSigningInfo = cli.getStoredCrossSigningForUser(ownUserId); this.hasDevicesToVerifyAgainst = await asyncSome(cli.getStoredDevicesForUser(ownUserId), async (device) => {
this.hasDevicesToVerifyAgainst = cli.getStoredDevicesForUser(ownUserId).some((device) => {
if (!device.getIdentityKey() || (dehydratedDevice && device.deviceId == dehydratedDevice?.device_id)) { if (!device.getIdentityKey() || (dehydratedDevice && device.deviceId == dehydratedDevice?.device_id)) {
return false; return false;
} }
// check if the device is signed by the cross-signing key stored for our user. Note that this is const verificationStatus = await cli.getCrypto()?.getDeviceVerificationStatus(ownUserId, device.deviceId);
// *different* to calling `cryptoApi.getDeviceVerificationStatus`, because even if we have stored return !!verificationStatus?.signedByOwner;
// 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();
}); });
this.phase = Phase.Intro; this.phase = Phase.Intro;