From b5d532b8cd64bc017369ef63431d8355d522d76e Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 12 Mar 2020 18:03:18 +0000 Subject: [PATCH] Test for cross-signing homeserver support during login, toasts This adds more checking of homeserver support for cross-signing at login and in toasts. Fixes https://github.com/vector-im/riot-web/issues/12228 --- src/DeviceListener.js | 6 +++++- src/components/structures/MatrixChat.js | 5 ++++- src/components/structures/auth/CompleteSecurity.js | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/DeviceListener.js b/src/DeviceListener.js index 4e7bc8470d..6a506db496 100644 --- a/src/DeviceListener.js +++ b/src/DeviceListener.js @@ -99,9 +99,13 @@ export default class DeviceListener { } async _recheck() { - if (!SettingsStore.isFeatureEnabled("feature_cross_signing")) return; const cli = MatrixClientPeg.get(); + if ( + !SettingsStore.isFeatureEnabled("feature_cross_signing") || + !await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing") + ) return; + if (!cli.isCryptoEnabled()) return; if (!cli.getCrossSigningId()) { if (this._dismissedThisDeviceToast) { diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index a0b9a8fe57..f1a5a372be 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1911,7 +1911,10 @@ export default createReactClass({ // secret storage. SettingsStore.setFeatureEnabled("feature_cross_signing", true); this.setStateForNewView({ view: VIEWS.COMPLETE_SECURITY }); - } else if (SettingsStore.isFeatureEnabled("feature_cross_signing")) { + } else if ( + SettingsStore.isFeatureEnabled("feature_cross_signing") && + await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing") + ) { // This will only work if the feature is set to 'enable' in the config, // since it's too early in the lifecycle for users to have turned the // labs flag on. diff --git a/src/components/structures/auth/CompleteSecurity.js b/src/components/structures/auth/CompleteSecurity.js index 6bf3e7f07c..2e95f668a6 100644 --- a/src/components/structures/auth/CompleteSecurity.js +++ b/src/components/structures/auth/CompleteSecurity.js @@ -59,9 +59,10 @@ export default class CompleteSecurity extends React.Component { phase: PHASE_BUSY, }); const cli = MatrixClientPeg.get(); - const backupInfo = await cli.getKeyBackupVersion(); - this.setState({backupInfo}); try { + const backupInfo = await cli.getKeyBackupVersion(); + this.setState({backupInfo}); + await accessSecretStorage(async () => { await cli.checkOwnCrossSigningTrust(); if (backupInfo) await cli.restoreKeyBackupWithSecretStorage(backupInfo);