2018-09-13 19:11:46 +03:00
|
|
|
/*
|
|
|
|
Copyright 2018 New Vector Ltd
|
2020-01-03 16:33:32 +03:00
|
|
|
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
|
2018-09-13 19:11:46 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
2019-12-21 00:13:46 +03:00
|
|
|
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
2018-09-13 19:11:46 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
|
|
|
import Modal from '../../../Modal';
|
2020-08-17 18:00:30 +03:00
|
|
|
import { isSecureBackupRequired } from '../../../utils/WellKnownUtils';
|
2020-09-04 15:55:25 +03:00
|
|
|
import Spinner from '../elements/Spinner';
|
|
|
|
import AccessibleButton from '../elements/AccessibleButton';
|
|
|
|
import QuestionDialog from '../dialogs/QuestionDialog';
|
2020-09-10 15:56:07 +03:00
|
|
|
import RestoreKeyBackupDialog from '../dialogs/security/RestoreKeyBackupDialog';
|
2020-09-08 20:01:56 +03:00
|
|
|
import { accessSecretStorage } from '../../../SecurityManager';
|
2018-09-13 19:11:46 +03:00
|
|
|
|
2020-09-04 13:37:06 +03:00
|
|
|
export default class SecureBackupPanel extends React.PureComponent {
|
2018-09-13 19:11:46 +03:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._unmounted = false;
|
|
|
|
this.state = {
|
|
|
|
loading: true,
|
|
|
|
error: null,
|
2020-09-08 16:10:34 +03:00
|
|
|
backupKeyStored: null,
|
|
|
|
backupKeyCached: null,
|
|
|
|
backupKeyWellFormed: null,
|
|
|
|
secretStorageKeyInAccount: null,
|
|
|
|
secretStorageReady: null,
|
2018-09-13 19:11:46 +03:00
|
|
|
backupInfo: null,
|
2019-12-12 17:06:44 +03:00
|
|
|
backupSigStatus: null,
|
2019-01-09 03:05:48 +03:00
|
|
|
sessionsRemaining: 0,
|
2018-09-13 19:11:46 +03:00
|
|
|
};
|
2018-09-14 19:08:02 +03:00
|
|
|
}
|
|
|
|
|
2020-03-31 23:14:17 +03:00
|
|
|
componentDidMount() {
|
2019-02-13 18:40:44 +03:00
|
|
|
this._checkKeyBackupStatus();
|
2018-09-14 19:08:02 +03:00
|
|
|
|
2018-10-31 21:07:29 +03:00
|
|
|
MatrixClientPeg.get().on('crypto.keyBackupStatus', this._onKeyBackupStatus);
|
2019-01-09 03:05:48 +03:00
|
|
|
MatrixClientPeg.get().on(
|
|
|
|
'crypto.keyBackupSessionsRemaining',
|
|
|
|
this._onKeyBackupSessionsRemaining,
|
|
|
|
);
|
2018-09-13 19:11:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
this._unmounted = true;
|
2018-09-14 19:08:02 +03:00
|
|
|
|
2018-09-17 18:00:23 +03:00
|
|
|
if (MatrixClientPeg.get()) {
|
2018-10-31 21:07:29 +03:00
|
|
|
MatrixClientPeg.get().removeListener('crypto.keyBackupStatus', this._onKeyBackupStatus);
|
2019-01-09 03:05:48 +03:00
|
|
|
MatrixClientPeg.get().removeListener(
|
|
|
|
'crypto.keyBackupSessionsRemaining',
|
|
|
|
this._onKeyBackupSessionsRemaining,
|
|
|
|
);
|
2018-09-17 18:00:23 +03:00
|
|
|
}
|
2018-09-14 19:08:02 +03:00
|
|
|
}
|
|
|
|
|
2019-11-18 15:50:54 +03:00
|
|
|
_onKeyBackupSessionsRemaining = (sessionsRemaining) => {
|
2019-01-09 03:05:48 +03:00
|
|
|
this.setState({
|
|
|
|
sessionsRemaining,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-11-18 15:50:54 +03:00
|
|
|
_onKeyBackupStatus = () => {
|
2019-02-13 18:40:44 +03:00
|
|
|
// This just loads the current backup status rather than forcing
|
|
|
|
// a re-check otherwise we risk causing infinite loops
|
2018-09-14 19:08:02 +03:00
|
|
|
this._loadBackupStatus();
|
2018-09-13 19:11:46 +03:00
|
|
|
}
|
|
|
|
|
2019-02-13 18:40:44 +03:00
|
|
|
async _checkKeyBackupStatus() {
|
2020-09-08 16:10:34 +03:00
|
|
|
this._getUpdatedDiagnostics();
|
2019-02-13 18:40:44 +03:00
|
|
|
try {
|
|
|
|
const {backupInfo, trustInfo} = await MatrixClientPeg.get().checkKeyBackup();
|
|
|
|
this.setState({
|
2020-09-08 16:10:34 +03:00
|
|
|
loading: false,
|
|
|
|
error: null,
|
2019-02-13 18:40:44 +03:00
|
|
|
backupInfo,
|
|
|
|
backupSigStatus: trustInfo,
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Unable to fetch check backup status", e);
|
|
|
|
if (this._unmounted) return;
|
|
|
|
this.setState({
|
2020-09-08 16:10:34 +03:00
|
|
|
loading: false,
|
2019-02-13 18:40:44 +03:00
|
|
|
error: e,
|
|
|
|
backupInfo: null,
|
|
|
|
backupSigStatus: null,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-13 19:11:46 +03:00
|
|
|
async _loadBackupStatus() {
|
2020-09-08 16:10:34 +03:00
|
|
|
this.setState({ loading: true });
|
|
|
|
this._getUpdatedDiagnostics();
|
2018-09-13 19:11:46 +03:00
|
|
|
try {
|
|
|
|
const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion();
|
2018-09-14 19:08:02 +03:00
|
|
|
const backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo);
|
2018-09-13 19:11:46 +03:00
|
|
|
if (this._unmounted) return;
|
|
|
|
this.setState({
|
2020-09-08 16:10:34 +03:00
|
|
|
loading: false,
|
2019-02-13 18:40:44 +03:00
|
|
|
error: null,
|
2018-09-13 19:11:46 +03:00
|
|
|
backupInfo,
|
2018-09-14 19:08:02 +03:00
|
|
|
backupSigStatus,
|
2018-09-13 19:11:46 +03:00
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Unable to fetch key backup status", e);
|
|
|
|
if (this._unmounted) return;
|
|
|
|
this.setState({
|
2020-09-08 16:10:34 +03:00
|
|
|
loading: false,
|
2018-09-13 19:11:46 +03:00
|
|
|
error: e,
|
2019-02-13 18:40:44 +03:00
|
|
|
backupInfo: null,
|
|
|
|
backupSigStatus: null,
|
2018-09-13 19:11:46 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 16:10:34 +03:00
|
|
|
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,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-11-18 15:50:54 +03:00
|
|
|
_startNewBackup = () => {
|
2018-11-23 13:55:18 +03:00
|
|
|
Modal.createTrackedDialogAsync('Key Backup', 'Key Backup',
|
2020-09-10 15:56:07 +03:00
|
|
|
import('../../../async-components/views/dialogs/security/CreateKeyBackupDialog'),
|
2018-11-23 13:55:18 +03:00
|
|
|
{
|
2020-01-03 18:34:03 +03:00
|
|
|
onFinished: () => {
|
|
|
|
this._loadBackupStatus();
|
|
|
|
},
|
|
|
|
}, null, /* priority = */ false, /* static = */ true,
|
|
|
|
);
|
2019-12-11 19:32:47 +03:00
|
|
|
}
|
|
|
|
|
2019-11-18 15:50:54 +03:00
|
|
|
_deleteBackup = () => {
|
2018-09-13 19:11:46 +03:00
|
|
|
Modal.createTrackedDialog('Delete Backup', '', QuestionDialog, {
|
2018-10-31 22:56:34 +03:00
|
|
|
title: _t('Delete Backup'),
|
2018-09-13 19:11:46 +03:00
|
|
|
description: _t(
|
2019-02-12 19:03:46 +03:00
|
|
|
"Are you sure? You will lose your encrypted messages if your " +
|
|
|
|
"keys are not backed up properly.",
|
2018-09-13 19:11:46 +03:00
|
|
|
),
|
2019-02-12 19:01:38 +03:00
|
|
|
button: _t('Delete Backup'),
|
2018-09-13 19:11:46 +03:00
|
|
|
danger: true,
|
|
|
|
onFinished: (proceed) => {
|
|
|
|
if (!proceed) return;
|
|
|
|
this.setState({loading: true});
|
|
|
|
MatrixClientPeg.get().deleteKeyBackupVersion(this.state.backupInfo.version).then(() => {
|
|
|
|
this._loadBackupStatus();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-12-12 18:18:36 +03:00
|
|
|
_restoreBackup = async () => {
|
2020-01-03 16:33:32 +03:00
|
|
|
Modal.createTrackedDialog(
|
|
|
|
'Restore Backup', '', RestoreKeyBackupDialog, null, null,
|
|
|
|
/* priority = */ false, /* static = */ true,
|
|
|
|
);
|
2018-09-17 18:00:23 +03:00
|
|
|
}
|
|
|
|
|
2020-09-08 20:01:56 +03:00
|
|
|
_resetSecretStorage = async () => {
|
|
|
|
this.setState({ error: null });
|
|
|
|
try {
|
|
|
|
await accessSecretStorage(() => { }, /* forceReset = */ true);
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Error resetting secret storage", e);
|
|
|
|
if (this._unmounted) return;
|
|
|
|
this.setState({ error: e });
|
|
|
|
}
|
|
|
|
if (this._unmounted) return;
|
|
|
|
this._loadBackupStatus();
|
|
|
|
}
|
|
|
|
|
2018-09-13 19:11:46 +03:00
|
|
|
render() {
|
2020-09-04 15:52:14 +03:00
|
|
|
const {
|
|
|
|
loading,
|
|
|
|
error,
|
2020-09-08 16:10:34 +03:00
|
|
|
backupKeyStored,
|
|
|
|
backupKeyCached,
|
|
|
|
backupKeyWellFormed,
|
|
|
|
secretStorageKeyInAccount,
|
|
|
|
secretStorageReady,
|
2020-09-04 15:52:14 +03:00
|
|
|
backupInfo,
|
|
|
|
backupSigStatus,
|
|
|
|
sessionsRemaining,
|
|
|
|
} = this.state;
|
2018-09-13 19:11:46 +03:00
|
|
|
|
2020-09-04 15:05:30 +03:00
|
|
|
let statusDescription;
|
2020-09-04 16:09:34 +03:00
|
|
|
let extraDetailsTableRows;
|
2020-09-04 15:52:14 +03:00
|
|
|
let extraDetails;
|
2020-09-09 16:12:36 +03:00
|
|
|
const actions = [];
|
2020-09-04 15:52:14 +03:00
|
|
|
if (error) {
|
2020-09-04 15:05:30 +03:00
|
|
|
statusDescription = (
|
2018-09-13 19:11:46 +03:00
|
|
|
<div className="error">
|
|
|
|
{_t("Unable to load key backup status")}
|
|
|
|
</div>
|
|
|
|
);
|
2020-09-04 15:52:14 +03:00
|
|
|
} else if (loading) {
|
2020-09-04 15:05:30 +03:00
|
|
|
statusDescription = <Spinner />;
|
2020-09-04 15:52:14 +03:00
|
|
|
} else if (backupInfo) {
|
2019-04-15 17:10:19 +03:00
|
|
|
let restoreButtonCaption = _t("Restore from Backup");
|
2019-02-12 19:01:38 +03:00
|
|
|
|
2018-09-13 19:11:46 +03:00
|
|
|
if (MatrixClientPeg.get().getKeyBackupEnabled()) {
|
2020-09-04 15:05:30 +03:00
|
|
|
statusDescription = <p>✅ {_t("This session is backing up your keys. ")}</p>;
|
2018-09-13 19:11:46 +03:00
|
|
|
} else {
|
2020-09-04 15:05:30 +03:00
|
|
|
statusDescription = <>
|
2019-02-12 19:01:38 +03:00
|
|
|
<p>{_t(
|
2020-01-29 18:48:25 +03:00
|
|
|
"This session is <b>not backing up your keys</b>, " +
|
2019-04-15 17:10:19 +03:00
|
|
|
"but you do have an existing backup you can restore from " +
|
2019-04-12 19:40:22 +03:00
|
|
|
"and add to going forward.", {},
|
2019-02-12 21:08:16 +03:00
|
|
|
{b: sub => <b>{sub}</b>},
|
2019-02-12 19:01:38 +03:00
|
|
|
)}</p>
|
2019-04-12 19:40:22 +03:00
|
|
|
<p>{_t(
|
2020-01-29 18:48:25 +03:00
|
|
|
"Connect this session to key backup before signing out to avoid " +
|
|
|
|
"losing any keys that may only be on this session.",
|
2019-04-12 19:40:22 +03:00
|
|
|
)}</p>
|
2020-09-04 15:05:30 +03:00
|
|
|
</>;
|
2020-01-29 18:48:25 +03:00
|
|
|
restoreButtonCaption = _t("Connect this session to Key Backup");
|
2018-09-13 19:11:46 +03:00
|
|
|
}
|
2018-09-14 19:08:02 +03:00
|
|
|
|
2019-01-09 03:05:48 +03:00
|
|
|
let uploadStatus;
|
2019-01-09 14:24:15 +03:00
|
|
|
if (!MatrixClientPeg.get().getKeyBackupEnabled()) {
|
|
|
|
// No upload status to show when backup disabled.
|
|
|
|
uploadStatus = "";
|
|
|
|
} else if (sessionsRemaining > 0) {
|
|
|
|
uploadStatus = <div>
|
|
|
|
{_t("Backing up %(sessionsRemaining)s keys...", { sessionsRemaining })} <br />
|
|
|
|
</div>;
|
2019-01-09 03:05:48 +03:00
|
|
|
} else {
|
2019-01-09 14:24:15 +03:00
|
|
|
uploadStatus = <div>
|
|
|
|
{_t("All keys backed up")} <br />
|
|
|
|
</div>;
|
2019-01-09 03:05:48 +03:00
|
|
|
}
|
|
|
|
|
2020-09-04 15:52:14 +03:00
|
|
|
let backupSigStatuses = backupSigStatus.sigs.map((sig, i) => {
|
2019-01-17 19:45:00 +03:00
|
|
|
const deviceName = sig.device ? (sig.device.getDisplayName() || sig.device.deviceId) : null;
|
2019-01-08 02:59:57 +03:00
|
|
|
const validity = sub =>
|
2020-09-04 13:37:56 +03:00
|
|
|
<span className={sig.valid ? 'mx_SecureBackupPanel_sigValid' : 'mx_SecureBackupPanel_sigInvalid'}>
|
2019-01-08 02:59:57 +03:00
|
|
|
{sub}
|
|
|
|
</span>;
|
|
|
|
const verify = sub =>
|
2020-09-04 13:37:56 +03:00
|
|
|
<span className={sig.device && sig.deviceTrust.isVerified() ? 'mx_SecureBackupPanel_deviceVerified' : 'mx_SecureBackupPanel_deviceNotVerified'}>
|
2019-01-08 02:59:57 +03:00
|
|
|
{sub}
|
|
|
|
</span>;
|
2020-09-04 13:37:56 +03:00
|
|
|
const device = sub => <span className="mx_SecureBackupPanel_deviceName">{deviceName}</span>;
|
2019-04-12 18:23:54 +03:00
|
|
|
const fromThisDevice = (
|
|
|
|
sig.device &&
|
|
|
|
sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key()
|
|
|
|
);
|
2019-12-12 16:51:45 +03:00
|
|
|
const fromThisUser = (
|
|
|
|
sig.crossSigningId &&
|
|
|
|
sig.deviceId === MatrixClientPeg.get().getCrossSigningId()
|
|
|
|
);
|
2018-10-31 23:01:36 +03:00
|
|
|
let sigStatus;
|
2019-12-12 16:51:45 +03:00
|
|
|
if (sig.valid && fromThisUser) {
|
|
|
|
sigStatus = _t(
|
|
|
|
"Backup has a <validity>valid</validity> signature from this user",
|
|
|
|
{}, { validity },
|
|
|
|
);
|
|
|
|
} else if (!sig.valid && fromThisUser) {
|
|
|
|
sigStatus = _t(
|
|
|
|
"Backup has a <validity>invalid</validity> signature from this user",
|
|
|
|
{}, { validity },
|
|
|
|
);
|
|
|
|
} else if (sig.crossSigningId) {
|
|
|
|
sigStatus = _t(
|
|
|
|
"Backup has a signature from <verify>unknown</verify> user with ID %(deviceId)s",
|
|
|
|
{ deviceId: sig.deviceId }, { verify },
|
|
|
|
);
|
|
|
|
} else if (!sig.device) {
|
2019-01-17 19:45:00 +03:00
|
|
|
sigStatus = _t(
|
2020-01-29 18:48:25 +03:00
|
|
|
"Backup has a signature from <verify>unknown</verify> session with ID %(deviceId)s",
|
2019-01-17 19:45:00 +03:00
|
|
|
{ deviceId: sig.deviceId }, { verify },
|
|
|
|
);
|
2019-04-09 15:47:25 +03:00
|
|
|
} else if (sig.valid && fromThisDevice) {
|
2018-10-31 23:01:36 +03:00
|
|
|
sigStatus = _t(
|
2020-01-29 18:48:25 +03:00
|
|
|
"Backup has a <validity>valid</validity> signature from this session",
|
2019-01-08 02:59:57 +03:00
|
|
|
{}, { validity },
|
2018-09-17 19:14:03 +03:00
|
|
|
);
|
2019-04-09 15:47:25 +03:00
|
|
|
} else if (!sig.valid && fromThisDevice) {
|
2019-04-09 15:22:35 +03:00
|
|
|
// it can happen...
|
|
|
|
sigStatus = _t(
|
2020-01-29 18:48:25 +03:00
|
|
|
"Backup has an <validity>invalid</validity> signature from this session",
|
2019-04-09 15:22:35 +03:00
|
|
|
{}, { validity },
|
|
|
|
);
|
2020-03-16 21:59:07 +03:00
|
|
|
} else if (sig.valid && sig.deviceTrust.isVerified()) {
|
2018-10-31 23:01:36 +03:00
|
|
|
sigStatus = _t(
|
2018-09-14 19:33:25 +03:00
|
|
|
"Backup has a <validity>valid</validity> signature from " +
|
2020-01-29 18:48:25 +03:00
|
|
|
"<verify>verified</verify> session <device></device>",
|
2019-01-08 02:59:57 +03:00
|
|
|
{}, { validity, verify, device },
|
2018-09-14 19:33:25 +03:00
|
|
|
);
|
2020-03-16 21:59:07 +03:00
|
|
|
} else if (sig.valid && !sig.deviceTrust.isVerified()) {
|
2018-10-31 23:01:36 +03:00
|
|
|
sigStatus = _t(
|
2018-09-14 19:33:25 +03:00
|
|
|
"Backup has a <validity>valid</validity> signature from " +
|
2020-01-29 18:48:25 +03:00
|
|
|
"<verify>unverified</verify> session <device></device>",
|
2019-01-08 02:59:57 +03:00
|
|
|
{}, { validity, verify, device },
|
2018-09-14 19:33:25 +03:00
|
|
|
);
|
2020-03-16 21:59:07 +03:00
|
|
|
} else if (!sig.valid && sig.deviceTrust.isVerified()) {
|
2018-10-31 23:01:36 +03:00
|
|
|
sigStatus = _t(
|
2018-09-14 19:33:25 +03:00
|
|
|
"Backup has an <validity>invalid</validity> signature from " +
|
2020-01-29 18:48:25 +03:00
|
|
|
"<verify>verified</verify> session <device></device>",
|
2019-01-08 02:59:57 +03:00
|
|
|
{}, { validity, verify, device },
|
2018-09-14 19:33:25 +03:00
|
|
|
);
|
2020-03-16 21:59:07 +03:00
|
|
|
} else if (!sig.valid && !sig.deviceTrust.isVerified()) {
|
2018-10-31 23:01:36 +03:00
|
|
|
sigStatus = _t(
|
2018-09-14 19:33:25 +03:00
|
|
|
"Backup has an <validity>invalid</validity> signature from " +
|
2020-01-29 18:48:25 +03:00
|
|
|
"<verify>unverified</verify> session <device></device>",
|
2019-01-08 02:59:57 +03:00
|
|
|
{}, { validity, verify, device },
|
2018-09-14 19:33:25 +03:00
|
|
|
);
|
2018-09-14 19:08:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return <div key={i}>
|
2018-10-31 23:01:36 +03:00
|
|
|
{sigStatus}
|
2018-09-14 19:08:02 +03:00
|
|
|
</div>;
|
|
|
|
});
|
2020-09-04 15:52:14 +03:00
|
|
|
if (backupSigStatus.sigs.length === 0) {
|
2020-01-29 18:48:25 +03:00
|
|
|
backupSigStatuses = _t("Backup is not signed by any of your sessions");
|
2018-09-14 19:08:02 +03:00
|
|
|
}
|
|
|
|
|
2019-02-07 17:39:47 +03:00
|
|
|
let trustedLocally;
|
2020-09-04 15:52:14 +03:00
|
|
|
if (backupSigStatus.trusted_locally) {
|
2020-01-29 18:48:25 +03:00
|
|
|
trustedLocally = _t("This backup is trusted because it has been restored on this session");
|
2019-02-07 17:39:47 +03:00
|
|
|
}
|
|
|
|
|
2020-09-04 16:09:34 +03:00
|
|
|
extraDetailsTableRows = <>
|
|
|
|
<tr>
|
|
|
|
<td>{_t("Backup version:")}</td>
|
|
|
|
<td>{backupInfo.version}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>{_t("Algorithm:")}</td>
|
|
|
|
<td>{backupInfo.algorithm}</td>
|
|
|
|
</tr>
|
|
|
|
</>;
|
|
|
|
|
2020-09-04 15:52:14 +03:00
|
|
|
extraDetails = <>
|
|
|
|
{uploadStatus}
|
|
|
|
<div>{backupSigStatuses}</div>
|
|
|
|
<div>{trustedLocally}</div>
|
|
|
|
</>;
|
2020-09-04 15:05:30 +03:00
|
|
|
|
2020-09-08 20:01:56 +03:00
|
|
|
actions.push(
|
2020-09-15 14:45:08 +03:00
|
|
|
<AccessibleButton key="restore" kind="primary" onClick={this._restoreBackup}>
|
2020-09-08 20:01:56 +03:00
|
|
|
{restoreButtonCaption}
|
|
|
|
</AccessibleButton>,
|
2020-09-04 15:05:30 +03:00
|
|
|
);
|
2020-09-08 20:01:56 +03:00
|
|
|
|
|
|
|
if (!isSecureBackupRequired()) {
|
|
|
|
actions.push(
|
2020-09-15 14:45:08 +03:00
|
|
|
<AccessibleButton key="delete" kind="danger" onClick={this._deleteBackup}>
|
2020-09-08 20:01:56 +03:00
|
|
|
{_t("Delete Backup")}
|
|
|
|
</AccessibleButton>,
|
|
|
|
);
|
|
|
|
}
|
2020-09-04 15:05:30 +03:00
|
|
|
} else {
|
|
|
|
statusDescription = <>
|
|
|
|
<p>{_t(
|
|
|
|
"Your keys are <b>not being backed up from this session</b>.", {},
|
|
|
|
{b: sub => <b>{sub}</b>},
|
|
|
|
)}</p>
|
|
|
|
<p>{_t("Back up your keys before signing out to avoid losing them.")}</p>
|
|
|
|
</>;
|
2020-09-08 20:01:56 +03:00
|
|
|
actions.push(
|
2020-09-15 14:45:08 +03:00
|
|
|
<AccessibleButton key="setup" kind="primary" onClick={this._startNewBackup}>
|
2020-09-08 20:01:56 +03:00
|
|
|
{_t("Set up")}
|
|
|
|
</AccessibleButton>,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (secretStorageKeyInAccount) {
|
|
|
|
actions.push(
|
2020-09-15 14:45:08 +03:00
|
|
|
<AccessibleButton key="reset" kind="danger" onClick={this._resetSecretStorage}>
|
2020-09-08 20:01:56 +03:00
|
|
|
{_t("Reset")}
|
|
|
|
</AccessibleButton>,
|
2020-09-04 15:05:30 +03:00
|
|
|
);
|
2018-09-13 19:11:46 +03:00
|
|
|
}
|
2020-09-04 15:05:30 +03:00
|
|
|
|
2020-09-08 16:10:34 +03:00
|
|
|
let backupKeyWellFormedText = "";
|
|
|
|
if (backupKeyCached) {
|
|
|
|
backupKeyWellFormedText = ", ";
|
|
|
|
if (backupKeyWellFormed) {
|
|
|
|
backupKeyWellFormedText += _t("well formed");
|
|
|
|
} else {
|
|
|
|
backupKeyWellFormedText += _t("unexpected type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 20:01:56 +03:00
|
|
|
let actionRow;
|
|
|
|
if (actions.length) {
|
|
|
|
actionRow = <div className="mx_SecureBackupPanel_buttonRow">
|
|
|
|
{actions}
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
|
2020-09-04 15:05:30 +03:00
|
|
|
return (
|
|
|
|
<div>
|
2020-09-04 15:52:14 +03:00
|
|
|
<p>{_t(
|
|
|
|
"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.",
|
|
|
|
)}</p>
|
2020-09-04 15:05:30 +03:00
|
|
|
{statusDescription}
|
2020-09-04 15:52:14 +03:00
|
|
|
<details>
|
|
|
|
<summary>{_t("Advanced")}</summary>
|
2020-09-04 16:09:34 +03:00
|
|
|
<table className="mx_SecureBackupPanel_statusList"><tbody>
|
|
|
|
<tr>
|
|
|
|
<td>{_t("Backup key stored:")}</td>
|
|
|
|
<td>{
|
|
|
|
backupKeyStored === true ? _t("in secret storage") : _t("not stored")
|
|
|
|
}</td>
|
|
|
|
</tr>
|
2020-09-08 16:10:34 +03:00
|
|
|
<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>
|
2020-09-04 16:09:34 +03:00
|
|
|
{extraDetailsTableRows}
|
|
|
|
</tbody></table>
|
2020-09-04 15:52:14 +03:00
|
|
|
{extraDetails}
|
|
|
|
</details>
|
2020-09-08 20:01:56 +03:00
|
|
|
{actionRow}
|
2020-09-04 15:05:30 +03:00
|
|
|
</div>
|
|
|
|
);
|
2018-09-13 19:11:46 +03:00
|
|
|
}
|
|
|
|
}
|