diff --git a/src/components/views/settings/CrossSigningPanel.js b/src/components/views/settings/CrossSigningPanel.js index 3eeb072e2d..8ef68e4b2a 100644 --- a/src/components/views/settings/CrossSigningPanel.js +++ b/src/components/views/settings/CrossSigningPanel.js @@ -31,13 +31,13 @@ export default class CrossSigningPanel extends React.PureComponent { this.state = { error: null, - crossSigningPublicKeysOnDevice: false, - crossSigningPrivateKeysInStorage: false, - masterPrivateKeyCached: false, - selfSigningPrivateKeyCached: false, - userSigningPrivateKeyCached: false, - sessionBackupKeyCached: false, - secretStorageKeyInAccount: false, + crossSigningPublicKeysOnDevice: null, + crossSigningPrivateKeysInStorage: null, + masterPrivateKeyCached: null, + selfSigningPrivateKeyCached: null, + userSigningPrivateKeyCached: null, + homeserverSupportsCrossSigning: null, + crossSigningReady: null, }; } @@ -83,14 +83,9 @@ export default class CrossSigningPanel extends React.PureComponent { const masterPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("master")); const selfSigningPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("self_signing")); const userSigningPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("user_signing")); - const sessionBackupKeyFromCache = await cli._crypto.getSessionBackupPrivateKey(); - const sessionBackupKeyCached = !!(sessionBackupKeyFromCache); - const sessionBackupKeyWellFormed = sessionBackupKeyFromCache instanceof Uint8Array; - const secretStorageKeyInAccount = await secretStorage.hasKey(); const homeserverSupportsCrossSigning = await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing"); const crossSigningReady = await cli.isCrossSigningReady(); - const secretStorageReady = await cli.isSecretStorageReady(); this.setState({ crossSigningPublicKeysOnDevice, @@ -98,12 +93,8 @@ export default class CrossSigningPanel extends React.PureComponent { masterPrivateKeyCached, selfSigningPrivateKeyCached, userSigningPrivateKeyCached, - sessionBackupKeyCached, - sessionBackupKeyWellFormed, - secretStorageKeyInAccount, homeserverSupportsCrossSigning, crossSigningReady, - secretStorageReady, }); } @@ -149,12 +140,8 @@ export default class CrossSigningPanel extends React.PureComponent { masterPrivateKeyCached, selfSigningPrivateKeyCached, userSigningPrivateKeyCached, - sessionBackupKeyCached, - sessionBackupKeyWellFormed, - secretStorageKeyInAccount, homeserverSupportsCrossSigning, crossSigningReady, - secretStorageReady, } = this.state; let errorSection; @@ -169,14 +156,9 @@ export default class CrossSigningPanel extends React.PureComponent { summarisedStatus =

{_t( "Your homeserver does not support cross-signing.", )}

; - } else if (crossSigningReady && secretStorageReady) { + } else if (crossSigningReady) { summarisedStatus =

✅ {_t( - "Cross-signing and secret storage are ready for use.", - )}

; - } else if (crossSigningReady && !secretStorageReady) { - summarisedStatus =

✅ {_t( - "Cross-signing is ready for use, but secret storage is " + - "currently not being used to backup your keys.", + "Cross-signing is ready for use.", )}

; } else if (crossSigningPrivateKeysInStorage) { summarisedStatus =

{_t( @@ -185,17 +167,15 @@ export default class CrossSigningPanel extends React.PureComponent { )}

; } else { summarisedStatus =

{_t( - "Cross-signing and secret storage are not yet set up.", + "Cross-signing is not set up.", )}

; } const keysExistAnywhere = ( - secretStorageKeyInAccount || crossSigningPrivateKeysInStorage || crossSigningPublicKeysOnDevice ); const keysExistEverywhere = ( - secretStorageKeyInAccount && crossSigningPrivateKeysInStorage && crossSigningPublicKeysOnDevice ); @@ -223,16 +203,6 @@ export default class CrossSigningPanel extends React.PureComponent { ); } - let sessionBackupKeyWellFormedText = ""; - if (sessionBackupKeyCached) { - sessionBackupKeyWellFormedText = ", "; - if (sessionBackupKeyWellFormed) { - sessionBackupKeyWellFormedText += _t("well formed"); - } else { - sessionBackupKeyWellFormedText += _t("unexpected type"); - } - } - return (
{summarisedStatus} @@ -259,17 +229,6 @@ export default class CrossSigningPanel extends React.PureComponent { {_t("User signing private key:")} {userSigningPrivateKeyCached ? _t("cached locally") : _t("not found locally")} - - {_t("Session backup key:")} - - {sessionBackupKeyCached ? _t("cached locally") : _t("not found locally")} - {sessionBackupKeyWellFormedText} - - - - {_t("Secret storage public key:")} - {secretStorageKeyInAccount ? _t("in account data") : _t("not found")} - {_t("Homeserver feature support:")} {homeserverSupportsCrossSigning ? _t("exists") : _t("not found")} diff --git a/src/components/views/settings/SecureBackupPanel.js b/src/components/views/settings/SecureBackupPanel.js index 7f7a014df9..0f43770288 100644 --- a/src/components/views/settings/SecureBackupPanel.js +++ b/src/components/views/settings/SecureBackupPanel.js @@ -34,9 +34,13 @@ export default class SecureBackupPanel extends React.PureComponent { this.state = { loading: true, error: null, + backupKeyStored: null, + backupKeyCached: null, + backupKeyWellFormed: null, + secretStorageKeyInAccount: null, + secretStorageReady: null, backupInfo: null, backupSigStatus: null, - backupKeyStored: null, sessionsRemaining: 0, }; } @@ -76,56 +80,73 @@ export default class SecureBackupPanel extends React.PureComponent { } async _checkKeyBackupStatus() { + this._getUpdatedDiagnostics(); try { const {backupInfo, trustInfo} = await MatrixClientPeg.get().checkKeyBackup(); - const backupKeyStored = Boolean(await MatrixClientPeg.get().isKeyBackupKeyStored()); this.setState({ + loading: false, + error: null, backupInfo, backupSigStatus: trustInfo, - backupKeyStored, - error: null, - loading: false, }); } catch (e) { console.log("Unable to fetch check backup status", e); if (this._unmounted) return; this.setState({ + loading: false, error: e, backupInfo: null, backupSigStatus: null, - backupKeyStored: null, - loading: false, }); } } async _loadBackupStatus() { - this.setState({loading: true}); + this.setState({ loading: true }); + this._getUpdatedDiagnostics(); try { const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion(); const backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo); - const backupKeyStored = await MatrixClientPeg.get().isKeyBackupKeyStored(); if (this._unmounted) return; this.setState({ + loading: false, error: null, backupInfo, backupSigStatus, - backupKeyStored, - loading: false, }); } catch (e) { console.log("Unable to fetch key backup status", e); if (this._unmounted) return; this.setState({ + loading: false, error: e, backupInfo: null, backupSigStatus: null, - backupKeyStored: null, - loading: false, }); } } + async _getUpdatedDiagnostics() { + const cli = MatrixClientPeg.get(); + const secretStorage = cli._crypto._secretStorage; + + const backupKeyStored = await cli.isKeyBackupKeyStored(); + const backupKeyFromCache = await cli._crypto.getSessionBackupPrivateKey(); + const backupKeyCached = !!(backupKeyFromCache); + const backupKeyWellFormed = backupKeyFromCache instanceof Uint8Array; + const secretStorageKeyInAccount = await secretStorage.hasKey(); + const secretStorageReady = await cli.isSecretStorageReady(); + + if (this._unmounted) return; + this.setState({ + backupKeyStored, + backupKeyCached, + backupKeyWellFormed, + secretStorageKeyInAccount, + secretStorageReady, + }); + } + _startNewBackup = () => { Modal.createTrackedDialogAsync('Key Backup', 'Key Backup', import('../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog'), @@ -167,9 +188,13 @@ export default class SecureBackupPanel extends React.PureComponent { const { loading, error, + backupKeyStored, + backupKeyCached, + backupKeyWellFormed, + secretStorageKeyInAccount, + secretStorageReady, backupInfo, backupSigStatus, - backupKeyStored, sessionsRemaining, } = this.state; @@ -359,6 +384,16 @@ export default class SecureBackupPanel extends React.PureComponent { ); } + let backupKeyWellFormedText = ""; + if (backupKeyCached) { + backupKeyWellFormedText = ", "; + if (backupKeyWellFormed) { + backupKeyWellFormedText += _t("well formed"); + } else { + backupKeyWellFormedText += _t("unexpected type"); + } + } + return (

{_t( @@ -376,6 +411,21 @@ export default class SecureBackupPanel extends React.PureComponent { backupKeyStored === true ? _t("in secret storage") : _t("not stored") } + + {_t("Backup key cached:")} + + {backupKeyCached ? _t("cached locally") : _t("not found locally")} + {backupKeyWellFormedText} + + + + {_t("Secret storage public key:")} + {secretStorageKeyInAccount ? _t("in account data") : _t("not found")} + + + {_t("Secret storage:")} + {secretStorageReady ? _t("ready") : _t("not ready")} + {extraDetailsTableRows} {extraDetails} diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 476ce11b2d..1bf431f6e0 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -645,14 +645,11 @@ "Confirm password": "Confirm password", "Change Password": "Change Password", "Your homeserver does not support cross-signing.": "Your homeserver does not support cross-signing.", - "Cross-signing and secret storage are ready for use.": "Cross-signing and secret storage are ready for use.", - "Cross-signing is ready for use, but secret storage is currently not being used to backup your keys.": "Cross-signing is ready for use, but secret storage is currently not being used to backup your keys.", + "Cross-signing is ready for use.": "Cross-signing is ready for use.", "Your account has a cross-signing identity in secret storage, but it is not yet trusted by this session.": "Your account has a cross-signing identity in secret storage, but it is not yet trusted by this session.", - "Cross-signing and secret storage are not yet set up.": "Cross-signing and secret storage are not yet set up.", + "Cross-signing is not set up.": "Cross-signing is not set up.", "Reset cross-signing and secret storage": "Reset cross-signing and secret storage", "Bootstrap cross-signing and secret storage": "Bootstrap cross-signing and secret storage", - "well formed": "well formed", - "unexpected type": "unexpected type", "Cross-signing public keys:": "Cross-signing public keys:", "in memory": "in memory", "not found": "not found", @@ -663,9 +660,6 @@ "not found locally": "not found locally", "Self signing private key:": "Self signing private key:", "User signing private key:": "User signing private key:", - "Session backup key:": "Session backup key:", - "Secret storage public key:": "Secret storage public key:", - "in account data": "in account data", "Homeserver feature support:": "Homeserver feature support:", "exists": "exists", "Your homeserver does not support session management.": "Your homeserver does not support session management.", @@ -755,9 +749,17 @@ "Your keys are not being backed up from this session.": "Your keys are not being backed up from this session.", "Back up your keys before signing out to avoid losing them.": "Back up your keys before signing out to avoid losing them.", "Start using Key Backup": "Start using Key Backup", + "well formed": "well formed", + "unexpected type": "unexpected type", "Back up your encryption keys with your account data in case you lose access to your sessions. Your keys will be secured with a unique Recovery Key.": "Back up your encryption keys with your account data in case you lose access to your sessions. Your keys will be secured with a unique Recovery Key.", "Backup key stored:": "Backup key stored:", "not stored": "not stored", + "Backup key cached:": "Backup key cached:", + "Secret storage public key:": "Secret storage public key:", + "in account data": "in account data", + "Secret storage:": "Secret storage:", + "ready": "ready", + "not ready": "not ready", "Identity Server URL must be HTTPS": "Identity Server URL must be HTTPS", "Not a valid Identity Server (status code %(code)s)": "Not a valid Identity Server (status code %(code)s)", "Could not connect to Identity Server": "Could not connect to Identity Server",