Merge pull request #3850 from matrix-org/zip/11225-shields-distinguish-encrypt-from-verify
Room header & message box shields now reflect cross-signing statepull/21833/head
commit
264ca1ecba
|
@ -173,6 +173,7 @@ export default createReactClass({
|
||||||
MatrixClientPeg.get().on("accountData", this.onAccountData);
|
MatrixClientPeg.get().on("accountData", this.onAccountData);
|
||||||
MatrixClientPeg.get().on("crypto.keyBackupStatus", this.onKeyBackupStatus);
|
MatrixClientPeg.get().on("crypto.keyBackupStatus", this.onKeyBackupStatus);
|
||||||
MatrixClientPeg.get().on("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
MatrixClientPeg.get().on("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
||||||
|
MatrixClientPeg.get().on("userTrustStatusChanged", this.onUserVerificationChanged);
|
||||||
// Start listening for RoomViewStore updates
|
// Start listening for RoomViewStore updates
|
||||||
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
||||||
this._onRoomViewStoreUpdate(true);
|
this._onRoomViewStoreUpdate(true);
|
||||||
|
@ -492,6 +493,7 @@ export default createReactClass({
|
||||||
MatrixClientPeg.get().removeListener("accountData", this.onAccountData);
|
MatrixClientPeg.get().removeListener("accountData", this.onAccountData);
|
||||||
MatrixClientPeg.get().removeListener("crypto.keyBackupStatus", this.onKeyBackupStatus);
|
MatrixClientPeg.get().removeListener("crypto.keyBackupStatus", this.onKeyBackupStatus);
|
||||||
MatrixClientPeg.get().removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
MatrixClientPeg.get().removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
||||||
|
MatrixClientPeg.get().removeListener("userTrustStatusChanged", this.onUserVerificationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.removeEventListener('beforeunload', this.onPageUnload);
|
window.removeEventListener('beforeunload', this.onPageUnload);
|
||||||
|
@ -762,6 +764,14 @@ export default createReactClass({
|
||||||
this._updateE2EStatus(room);
|
this._updateE2EStatus(room);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onUserVerificationChanged: function(userId, _trustStatus) {
|
||||||
|
const room = this.state.room;
|
||||||
|
if (!room.currentState.getMember(userId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._updateE2EStatus(room);
|
||||||
|
},
|
||||||
|
|
||||||
_updateE2EStatus: async function(room) {
|
_updateE2EStatus: async function(room) {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (!cli.isRoomEncrypted(room.roomId)) {
|
if (!cli.isRoomEncrypted(room.roomId)) {
|
||||||
|
@ -782,32 +792,41 @@ export default createReactClass({
|
||||||
e2eStatus: hasUnverifiedDevices ? "warning" : "verified",
|
e2eStatus: hasUnverifiedDevices ? "warning" : "verified",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
debuglog("e2e check is warning/verified only as cross-signing is off");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* At this point, the user has encryption on and cross-signing on */
|
||||||
const e2eMembers = await room.getEncryptionTargetMembers();
|
const e2eMembers = await room.getEncryptionTargetMembers();
|
||||||
for (const member of e2eMembers) {
|
const verified = [];
|
||||||
const { userId } = member;
|
const unverified = [];
|
||||||
const userVerified = cli.checkUserTrust(userId).isCrossSigningVerified();
|
e2eMembers.map(({userId}) => userId)
|
||||||
if (!userVerified) {
|
.filter((userId) => userId !== cli.getUserId())
|
||||||
this.setState({
|
.forEach((userId) => {
|
||||||
e2eStatus: "warning",
|
(cli.checkUserTrust(userId).isCrossSigningVerified() ?
|
||||||
});
|
verified : unverified).push(userId)
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
|
debuglog("e2e verified", verified, "unverified", unverified);
|
||||||
|
|
||||||
|
/* Check all verified user devices. */
|
||||||
|
for (const userId of verified) {
|
||||||
const devices = await cli.getStoredDevicesForUser(userId);
|
const devices = await cli.getStoredDevicesForUser(userId);
|
||||||
const allDevicesVerified = devices.every(device => {
|
const allDevicesVerified = devices.every(({deviceId}) => {
|
||||||
const { deviceId } = device;
|
return cli.checkDeviceTrust(userId, deviceId).isVerified();
|
||||||
return cli.checkDeviceTrust(userId, deviceId).isCrossSigningVerified();
|
|
||||||
});
|
});
|
||||||
if (!allDevicesVerified) {
|
if (!allDevicesVerified) {
|
||||||
this.setState({
|
this.setState({
|
||||||
e2eStatus: "warning",
|
e2eStatus: "warning",
|
||||||
});
|
});
|
||||||
|
debuglog("e2e status set to warning as not all users trust all of their devices." +
|
||||||
|
" Aborted on user", userId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
e2eStatus: "verified",
|
e2eStatus: unverified.length === 0 ? "verified" : "normal",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue