Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 4cd065c

Browse files
committed
Add some comments on the last use of checkDeviceTrust
1 parent d52a0ac commit 4cd065c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/stores/SetupEncryptionStore.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,20 @@ export class SetupEncryptionStore extends EventEmitter {
109109
const dehydratedDevice = await cli.getDehydratedDevice();
110110
const ownUserId = cli.getUserId()!;
111111
const crossSigningInfo = cli.getStoredCrossSigningForUser(ownUserId);
112-
this.hasDevicesToVerifyAgainst = cli
113-
.getStoredDevicesForUser(ownUserId)
114-
.some(
115-
(device) =>
116-
device.getIdentityKey() &&
117-
(!dehydratedDevice || device.deviceId != dehydratedDevice.device_id) &&
118-
crossSigningInfo?.checkDeviceTrust(crossSigningInfo, device, false, true).isCrossSigningVerified(),
119-
);
112+
this.hasDevicesToVerifyAgainst = cli.getStoredDevicesForUser(ownUserId).some((device) => {
113+
if (!device.getIdentityKey() || (dehydratedDevice && device.deviceId == dehydratedDevice?.device_id)) {
114+
return false;
115+
}
116+
// check if the device is signed by the cross-signing key stored for our user. Note that this is
117+
// *different* to calling `cryptoApi.getDeviceVerificationStatus`, because even if we have stored
118+
// a cross-signing key for our user, we don't necessarily trust it yet (In legacy Crypto, we have not
119+
// yet imported it into `Crypto.crossSigningInfo`, which for maximal confusion is a different object to
120+
// `Crypto.getStoredCrossSigningForUser(ownUserId)`).
121+
//
122+
// TODO: figure out wtf to to here for rust-crypto
123+
const verificationStatus = crossSigningInfo?.checkDeviceTrust(crossSigningInfo, device, false, true);
124+
return !!verificationStatus?.isCrossSigningVerified();
125+
});
120126

121127
this.phase = Phase.Intro;
122128
this.emit("update");

0 commit comments

Comments
 (0)