Move 4S status to backup panel

This moves the various 4S status diagnostics to the backup panel and out of the
cross-signing panel. The available actions are unchanged as part of this commit,
but they will be updated next.
pull/21833/head
J. Ryan Stinnett 2020-09-08 14:10:34 +01:00
parent 2fbb551035
commit aae68f7d1a
3 changed files with 84 additions and 73 deletions

View File

@ -31,13 +31,13 @@ export default class CrossSigningPanel extends React.PureComponent {
this.state = { this.state = {
error: null, error: null,
crossSigningPublicKeysOnDevice: false, crossSigningPublicKeysOnDevice: null,
crossSigningPrivateKeysInStorage: false, crossSigningPrivateKeysInStorage: null,
masterPrivateKeyCached: false, masterPrivateKeyCached: null,
selfSigningPrivateKeyCached: false, selfSigningPrivateKeyCached: null,
userSigningPrivateKeyCached: false, userSigningPrivateKeyCached: null,
sessionBackupKeyCached: false, homeserverSupportsCrossSigning: null,
secretStorageKeyInAccount: false, crossSigningReady: null,
}; };
} }
@ -83,14 +83,9 @@ export default class CrossSigningPanel extends React.PureComponent {
const masterPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("master")); const masterPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("master"));
const selfSigningPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("self_signing")); const selfSigningPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("self_signing"));
const userSigningPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("user_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 = const homeserverSupportsCrossSigning =
await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing"); await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing");
const crossSigningReady = await cli.isCrossSigningReady(); const crossSigningReady = await cli.isCrossSigningReady();
const secretStorageReady = await cli.isSecretStorageReady();
this.setState({ this.setState({
crossSigningPublicKeysOnDevice, crossSigningPublicKeysOnDevice,
@ -98,12 +93,8 @@ export default class CrossSigningPanel extends React.PureComponent {
masterPrivateKeyCached, masterPrivateKeyCached,
selfSigningPrivateKeyCached, selfSigningPrivateKeyCached,
userSigningPrivateKeyCached, userSigningPrivateKeyCached,
sessionBackupKeyCached,
sessionBackupKeyWellFormed,
secretStorageKeyInAccount,
homeserverSupportsCrossSigning, homeserverSupportsCrossSigning,
crossSigningReady, crossSigningReady,
secretStorageReady,
}); });
} }
@ -149,12 +140,8 @@ export default class CrossSigningPanel extends React.PureComponent {
masterPrivateKeyCached, masterPrivateKeyCached,
selfSigningPrivateKeyCached, selfSigningPrivateKeyCached,
userSigningPrivateKeyCached, userSigningPrivateKeyCached,
sessionBackupKeyCached,
sessionBackupKeyWellFormed,
secretStorageKeyInAccount,
homeserverSupportsCrossSigning, homeserverSupportsCrossSigning,
crossSigningReady, crossSigningReady,
secretStorageReady,
} = this.state; } = this.state;
let errorSection; let errorSection;
@ -169,14 +156,9 @@ export default class CrossSigningPanel extends React.PureComponent {
summarisedStatus = <p>{_t( summarisedStatus = <p>{_t(
"Your homeserver does not support cross-signing.", "Your homeserver does not support cross-signing.",
)}</p>; )}</p>;
} else if (crossSigningReady && secretStorageReady) { } else if (crossSigningReady) {
summarisedStatus = <p> {_t( summarisedStatus = <p> {_t(
"Cross-signing and secret storage are ready for use.", "Cross-signing is ready for use.",
)}</p>;
} else if (crossSigningReady && !secretStorageReady) {
summarisedStatus = <p> {_t(
"Cross-signing is ready for use, but secret storage is " +
"currently not being used to backup your keys.",
)}</p>; )}</p>;
} else if (crossSigningPrivateKeysInStorage) { } else if (crossSigningPrivateKeysInStorage) {
summarisedStatus = <p>{_t( summarisedStatus = <p>{_t(
@ -185,17 +167,15 @@ export default class CrossSigningPanel extends React.PureComponent {
)}</p>; )}</p>;
} else { } else {
summarisedStatus = <p>{_t( summarisedStatus = <p>{_t(
"Cross-signing and secret storage are not yet set up.", "Cross-signing is not set up.",
)}</p>; )}</p>;
} }
const keysExistAnywhere = ( const keysExistAnywhere = (
secretStorageKeyInAccount ||
crossSigningPrivateKeysInStorage || crossSigningPrivateKeysInStorage ||
crossSigningPublicKeysOnDevice crossSigningPublicKeysOnDevice
); );
const keysExistEverywhere = ( const keysExistEverywhere = (
secretStorageKeyInAccount &&
crossSigningPrivateKeysInStorage && crossSigningPrivateKeysInStorage &&
crossSigningPublicKeysOnDevice 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 ( return (
<div> <div>
{summarisedStatus} {summarisedStatus}
@ -259,17 +229,6 @@ export default class CrossSigningPanel extends React.PureComponent {
<td>{_t("User signing private key:")}</td> <td>{_t("User signing private key:")}</td>
<td>{userSigningPrivateKeyCached ? _t("cached locally") : _t("not found locally")}</td> <td>{userSigningPrivateKeyCached ? _t("cached locally") : _t("not found locally")}</td>
</tr> </tr>
<tr>
<td>{_t("Session backup key:")}</td>
<td>
{sessionBackupKeyCached ? _t("cached locally") : _t("not found locally")}
{sessionBackupKeyWellFormedText}
</td>
</tr>
<tr>
<td>{_t("Secret storage public key:")}</td>
<td>{secretStorageKeyInAccount ? _t("in account data") : _t("not found")}</td>
</tr>
<tr> <tr>
<td>{_t("Homeserver feature support:")}</td> <td>{_t("Homeserver feature support:")}</td>
<td>{homeserverSupportsCrossSigning ? _t("exists") : _t("not found")}</td> <td>{homeserverSupportsCrossSigning ? _t("exists") : _t("not found")}</td>

View File

@ -34,9 +34,13 @@ export default class SecureBackupPanel extends React.PureComponent {
this.state = { this.state = {
loading: true, loading: true,
error: null, error: null,
backupKeyStored: null,
backupKeyCached: null,
backupKeyWellFormed: null,
secretStorageKeyInAccount: null,
secretStorageReady: null,
backupInfo: null, backupInfo: null,
backupSigStatus: null, backupSigStatus: null,
backupKeyStored: null,
sessionsRemaining: 0, sessionsRemaining: 0,
}; };
} }
@ -76,56 +80,73 @@ export default class SecureBackupPanel extends React.PureComponent {
} }
async _checkKeyBackupStatus() { async _checkKeyBackupStatus() {
this._getUpdatedDiagnostics();
try { try {
const {backupInfo, trustInfo} = await MatrixClientPeg.get().checkKeyBackup(); const {backupInfo, trustInfo} = await MatrixClientPeg.get().checkKeyBackup();
const backupKeyStored = Boolean(await MatrixClientPeg.get().isKeyBackupKeyStored());
this.setState({ this.setState({
loading: false,
error: null,
backupInfo, backupInfo,
backupSigStatus: trustInfo, backupSigStatus: trustInfo,
backupKeyStored,
error: null,
loading: false,
}); });
} catch (e) { } catch (e) {
console.log("Unable to fetch check backup status", e); console.log("Unable to fetch check backup status", e);
if (this._unmounted) return; if (this._unmounted) return;
this.setState({ this.setState({
loading: false,
error: e, error: e,
backupInfo: null, backupInfo: null,
backupSigStatus: null, backupSigStatus: null,
backupKeyStored: null,
loading: false,
}); });
} }
} }
async _loadBackupStatus() { async _loadBackupStatus() {
this.setState({loading: true}); this.setState({ loading: true });
this._getUpdatedDiagnostics();
try { try {
const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion(); const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion();
const backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo); const backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo);
const backupKeyStored = await MatrixClientPeg.get().isKeyBackupKeyStored();
if (this._unmounted) return; if (this._unmounted) return;
this.setState({ this.setState({
loading: false,
error: null, error: null,
backupInfo, backupInfo,
backupSigStatus, backupSigStatus,
backupKeyStored,
loading: false,
}); });
} catch (e) { } catch (e) {
console.log("Unable to fetch key backup status", e); console.log("Unable to fetch key backup status", e);
if (this._unmounted) return; if (this._unmounted) return;
this.setState({ this.setState({
loading: false,
error: e, error: e,
backupInfo: null, backupInfo: null,
backupSigStatus: 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 = () => { _startNewBackup = () => {
Modal.createTrackedDialogAsync('Key Backup', 'Key Backup', Modal.createTrackedDialogAsync('Key Backup', 'Key Backup',
import('../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog'), import('../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog'),
@ -167,9 +188,13 @@ export default class SecureBackupPanel extends React.PureComponent {
const { const {
loading, loading,
error, error,
backupKeyStored,
backupKeyCached,
backupKeyWellFormed,
secretStorageKeyInAccount,
secretStorageReady,
backupInfo, backupInfo,
backupSigStatus, backupSigStatus,
backupKeyStored,
sessionsRemaining, sessionsRemaining,
} = this.state; } = 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 ( return (
<div> <div>
<p>{_t( <p>{_t(
@ -376,6 +411,21 @@ export default class SecureBackupPanel extends React.PureComponent {
backupKeyStored === true ? _t("in secret storage") : _t("not stored") backupKeyStored === true ? _t("in secret storage") : _t("not stored")
}</td> }</td>
</tr> </tr>
<tr>
<td>{_t("Backup key cached:")}</td>
<td>
{backupKeyCached ? _t("cached locally") : _t("not found locally")}
{backupKeyWellFormedText}
</td>
</tr>
<tr>
<td>{_t("Secret storage public key:")}</td>
<td>{secretStorageKeyInAccount ? _t("in account data") : _t("not found")}</td>
</tr>
<tr>
<td>{_t("Secret storage:")}</td>
<td>{secretStorageReady ? _t("ready") : _t("not ready")}</td>
</tr>
{extraDetailsTableRows} {extraDetailsTableRows}
</tbody></table> </tbody></table>
{extraDetails} {extraDetails}

View File

@ -645,14 +645,11 @@
"Confirm password": "Confirm password", "Confirm password": "Confirm password",
"Change Password": "Change Password", "Change Password": "Change Password",
"Your homeserver does not support cross-signing.": "Your homeserver does not support cross-signing.", "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.": "Cross-signing is 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.",
"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.", "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", "Reset cross-signing and secret storage": "Reset cross-signing and secret storage",
"Bootstrap cross-signing and secret storage": "Bootstrap 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:", "Cross-signing public keys:": "Cross-signing public keys:",
"in memory": "in memory", "in memory": "in memory",
"not found": "not found", "not found": "not found",
@ -663,9 +660,6 @@
"not found locally": "not found locally", "not found locally": "not found locally",
"Self signing private key:": "Self signing private key:", "Self signing private key:": "Self signing private key:",
"User signing private key:": "User 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:", "Homeserver feature support:": "Homeserver feature support:",
"exists": "exists", "exists": "exists",
"Your homeserver does not support session management.": "Your homeserver does not support session management.", "Your homeserver does not support session management.": "Your homeserver does not support session management.",
@ -755,9 +749,17 @@
"Your keys are <b>not being backed up from this session</b>.": "Your keys are <b>not being backed up from this session</b>.", "Your keys are <b>not being backed up from this session</b>.": "Your keys are <b>not being backed up from this session</b>.",
"Back up your keys before signing out to avoid losing them.": "Back up your keys before signing out to avoid losing them.", "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", "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.", "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:", "Backup key stored:": "Backup key stored:",
"not stored": "not 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", "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)", "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", "Could not connect to Identity Server": "Could not connect to Identity Server",