2018-09-13 19:11:46 +03:00
|
|
|
|
/*
|
|
|
|
|
Copyright 2018 New Vector Ltd
|
2019-11-28 19:45:29 +03:00
|
|
|
|
Copyright 2019 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';
|
|
|
|
|
|
|
|
|
|
import sdk from '../../../index';
|
|
|
|
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
|
|
|
|
import { _t } from '../../../languageHandler';
|
|
|
|
|
import Modal from '../../../Modal';
|
2019-12-11 19:32:47 +03:00
|
|
|
|
import SettingsStore from '../../../../lib/settings/SettingsStore';
|
|
|
|
|
import { accessSecretStorage } from '../../../CrossSigningManager';
|
2018-09-13 19:11:46 +03:00
|
|
|
|
|
2019-01-08 22:57:22 +03:00
|
|
|
|
export default class KeyBackupPanel extends React.PureComponent {
|
2018-09-13 19:11:46 +03:00
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this._unmounted = false;
|
|
|
|
|
this.state = {
|
|
|
|
|
loading: true,
|
|
|
|
|
error: null,
|
|
|
|
|
backupInfo: null,
|
2019-12-12 17:06:44 +03:00
|
|
|
|
backupSigStatus: null,
|
|
|
|
|
backupKeyStored: 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillMount() {
|
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() {
|
|
|
|
|
try {
|
|
|
|
|
const {backupInfo, trustInfo} = await MatrixClientPeg.get().checkKeyBackup();
|
2019-12-12 17:06:44 +03:00
|
|
|
|
const backupKeyStored = await MatrixClientPeg.get().isKeyBackupKeyStored();
|
2019-02-13 18:40:44 +03:00
|
|
|
|
this.setState({
|
|
|
|
|
backupInfo,
|
|
|
|
|
backupSigStatus: trustInfo,
|
2019-12-12 17:06:44 +03:00
|
|
|
|
backupKeyStored,
|
2019-02-13 18:40:44 +03:00
|
|
|
|
error: null,
|
|
|
|
|
loading: false,
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log("Unable to fetch check backup status", e);
|
|
|
|
|
if (this._unmounted) return;
|
|
|
|
|
this.setState({
|
|
|
|
|
error: e,
|
|
|
|
|
backupInfo: null,
|
|
|
|
|
backupSigStatus: null,
|
2019-12-12 17:06:44 +03:00
|
|
|
|
backupKeyStored: null,
|
2019-02-13 18:40:44 +03:00
|
|
|
|
loading: false,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 19:11:46 +03:00
|
|
|
|
async _loadBackupStatus() {
|
|
|
|
|
this.setState({loading: true});
|
|
|
|
|
try {
|
|
|
|
|
const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion();
|
2018-09-14 19:08:02 +03:00
|
|
|
|
const backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo);
|
2019-12-12 17:06:44 +03:00
|
|
|
|
const backupKeyStored = await MatrixClientPeg.get().isKeyBackupKeyStored();
|
2018-09-13 19:11:46 +03:00
|
|
|
|
if (this._unmounted) return;
|
|
|
|
|
this.setState({
|
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,
|
2019-12-12 17:06:44 +03:00
|
|
|
|
backupKeyStored,
|
2018-09-13 19:11:46 +03:00
|
|
|
|
loading: false,
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log("Unable to fetch key backup status", e);
|
|
|
|
|
if (this._unmounted) return;
|
|
|
|
|
this.setState({
|
|
|
|
|
error: e,
|
2019-02-13 18:40:44 +03:00
|
|
|
|
backupInfo: null,
|
|
|
|
|
backupSigStatus: null,
|
2019-12-12 17:06:44 +03:00
|
|
|
|
backupKeyStored: null,
|
2018-09-13 19:11:46 +03:00
|
|
|
|
loading: false,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-18 15:50:54 +03:00
|
|
|
|
_startNewBackup = () => {
|
2018-11-23 13:55:18 +03:00
|
|
|
|
Modal.createTrackedDialogAsync('Key Backup', 'Key Backup',
|
|
|
|
|
import('../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog'),
|
|
|
|
|
{
|
|
|
|
|
onFinished: () => {
|
|
|
|
|
this._loadBackupStatus();
|
|
|
|
|
},
|
2018-09-13 19:11:46 +03:00
|
|
|
|
},
|
2018-11-23 13:55:18 +03:00
|
|
|
|
);
|
2018-09-13 19:11:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 19:32:47 +03:00
|
|
|
|
_startNewBackupWithSecureSecretStorage = async () => {
|
|
|
|
|
const cli = MatrixClientPeg.get();
|
|
|
|
|
let info;
|
|
|
|
|
try {
|
|
|
|
|
await accessSecretStorage(async () => {
|
|
|
|
|
info = await cli.prepareKeyBackupVersion(
|
|
|
|
|
null /* random key */,
|
|
|
|
|
{ secureSecretStorage: true },
|
|
|
|
|
);
|
|
|
|
|
info = await cli.createKeyBackupVersion(info);
|
|
|
|
|
});
|
|
|
|
|
await MatrixClientPeg.get().scheduleAllGroupSessionsForBackup();
|
|
|
|
|
this._loadBackupStatus();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Error creating key backup", e);
|
|
|
|
|
// TODO: If creating a version succeeds, but backup fails, should we
|
|
|
|
|
// delete the version, disable backup, or do nothing? If we just
|
|
|
|
|
// disable without deleting, we'll enable on next app reload since
|
|
|
|
|
// it is trusted.
|
|
|
|
|
if (info && info.version) {
|
|
|
|
|
MatrixClientPeg.get().deleteKeyBackupVersion(info.version);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-18 15:50:54 +03:00
|
|
|
|
_deleteBackup = () => {
|
2018-10-31 22:56:34 +03:00
|
|
|
|
const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog');
|
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 () => {
|
|
|
|
|
// Use legacy path if backup key not stored in secret storage
|
|
|
|
|
if (!this.state.backupKeyStored) {
|
|
|
|
|
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
|
|
|
|
|
Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await accessSecretStorage(async () => {
|
|
|
|
|
await MatrixClientPeg.get().restoreKeyBackupWithSecretStorage(
|
|
|
|
|
this.state.backupInfo,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log("Error restoring backup", e);
|
|
|
|
|
}
|
2018-09-17 18:00:23 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 19:11:46 +03:00
|
|
|
|
render() {
|
|
|
|
|
const Spinner = sdk.getComponent("elements.Spinner");
|
|
|
|
|
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
|
2019-02-12 19:01:38 +03:00
|
|
|
|
const encryptedMessageAreEncrypted = _t(
|
|
|
|
|
"Encrypted messages are secured with end-to-end encryption. " +
|
|
|
|
|
"Only you and the recipient(s) have the keys to read these messages.",
|
|
|
|
|
);
|
2018-09-13 19:11:46 +03:00
|
|
|
|
|
|
|
|
|
if (this.state.error) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="error">
|
|
|
|
|
{_t("Unable to load key backup status")}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
} else if (this.state.loading) {
|
|
|
|
|
return <Spinner />;
|
|
|
|
|
} else if (this.state.backupInfo) {
|
|
|
|
|
let clientBackupStatus;
|
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()) {
|
2019-02-12 19:01:38 +03:00
|
|
|
|
clientBackupStatus = <div>
|
|
|
|
|
<p>{encryptedMessageAreEncrypted}</p>
|
2019-05-22 17:19:42 +03:00
|
|
|
|
<p>✅ {_t("This device is backing up your keys. ")}</p>
|
2019-02-12 19:01:38 +03:00
|
|
|
|
</div>;
|
2018-09-13 19:11:46 +03:00
|
|
|
|
} else {
|
2019-02-12 19:01:38 +03:00
|
|
|
|
clientBackupStatus = <div>
|
|
|
|
|
<p>{encryptedMessageAreEncrypted}</p>
|
|
|
|
|
<p>{_t(
|
2019-04-12 19:40:22 +03:00
|
|
|
|
"This device 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(
|
2019-04-15 17:10:19 +03:00
|
|
|
|
"Connect this device to key backup before signing out to avoid " +
|
|
|
|
|
"losing any keys that may only be on this device.",
|
2019-04-12 19:40:22 +03:00
|
|
|
|
)}</p>
|
2019-02-12 19:01:38 +03:00
|
|
|
|
</div>;
|
2019-04-15 17:10:19 +03:00
|
|
|
|
restoreButtonCaption = _t("Connect this device to Key Backup");
|
2018-09-13 19:11:46 +03:00
|
|
|
|
}
|
2018-09-14 19:08:02 +03:00
|
|
|
|
|
2019-12-12 17:06:44 +03:00
|
|
|
|
let keyStatus;
|
|
|
|
|
if (this.state.backupKeyStored === true) {
|
|
|
|
|
keyStatus = _t("in secret storage");
|
|
|
|
|
} else {
|
|
|
|
|
keyStatus = _t("not stored");
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-09 03:05:48 +03:00
|
|
|
|
let uploadStatus;
|
|
|
|
|
const { sessionsRemaining } = this.state;
|
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
|
|
|
|
}
|
|
|
|
|
|
2018-09-14 19:08:02 +03:00
|
|
|
|
let backupSigStatuses = this.state.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 =>
|
|
|
|
|
<span className={sig.valid ? 'mx_KeyBackupPanel_sigValid' : 'mx_KeyBackupPanel_sigInvalid'}>
|
|
|
|
|
{sub}
|
|
|
|
|
</span>;
|
|
|
|
|
const verify = sub =>
|
2019-01-17 19:45:00 +03:00
|
|
|
|
<span className={sig.device && sig.device.isVerified() ? 'mx_KeyBackupPanel_deviceVerified' : 'mx_KeyBackupPanel_deviceNotVerified'}>
|
2019-01-08 02:59:57 +03:00
|
|
|
|
{sub}
|
|
|
|
|
</span>;
|
|
|
|
|
const device = sub => <span className="mx_KeyBackupPanel_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(
|
2019-12-12 16:51:45 +03:00
|
|
|
|
"Backup has a signature from <verify>unknown</verify> device 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(
|
2018-09-17 19:14:03 +03:00
|
|
|
|
"Backup has a <validity>valid</validity> signature from this device",
|
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(
|
|
|
|
|
"Backup has an <validity>invalid</validity> signature from this device",
|
|
|
|
|
{}, { validity },
|
|
|
|
|
);
|
2018-09-17 19:14:03 +03:00
|
|
|
|
} else if (sig.valid && sig.device.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 " +
|
2018-12-13 18:55:48 +03:00
|
|
|
|
"<verify>verified</verify> device <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
|
|
|
|
} else if (sig.valid && !sig.device.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 " +
|
|
|
|
|
"<verify>unverified</verify> device <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
|
|
|
|
} else if (!sig.valid && sig.device.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 " +
|
|
|
|
|
"<verify>verified</verify> device <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
|
|
|
|
} else if (!sig.valid && !sig.device.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 " +
|
|
|
|
|
"<verify>unverified</verify> device <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>;
|
|
|
|
|
});
|
|
|
|
|
if (this.state.backupSigStatus.sigs.length === 0) {
|
|
|
|
|
backupSigStatuses = _t("Backup is not signed by any of your devices");
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-07 17:39:47 +03:00
|
|
|
|
let trustedLocally;
|
|
|
|
|
if (this.state.backupSigStatus.trusted_locally) {
|
|
|
|
|
trustedLocally = _t("This backup is trusted because it has been restored on this device");
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-12 18:18:36 +03:00
|
|
|
|
let buttonRow = (
|
|
|
|
|
<div className="mx_KeyBackupPanel_buttonRow">
|
|
|
|
|
<AccessibleButton kind="primary" onClick={this._restoreBackup}>
|
|
|
|
|
{restoreButtonCaption}
|
|
|
|
|
</AccessibleButton>
|
|
|
|
|
<AccessibleButton kind="danger" onClick={this._deleteBackup}>
|
|
|
|
|
{_t("Delete Backup")}
|
|
|
|
|
</AccessibleButton>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
if (this.state.backupKeyStored && !SettingsStore.isFeatureEnabled("feature_cross_signing")) {
|
|
|
|
|
buttonRow = <p>⚠️ {_t(
|
|
|
|
|
"Backup key stored in secret storage, but this feature is not " +
|
|
|
|
|
"enabled on this device. Please enable cross-signing in Labs to " +
|
|
|
|
|
"modify key backup state.",
|
|
|
|
|
)}</p>;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 19:11:46 +03:00
|
|
|
|
return <div>
|
2019-02-08 13:46:38 +03:00
|
|
|
|
<div>{clientBackupStatus}</div>
|
2019-02-08 14:51:22 +03:00
|
|
|
|
<details>
|
|
|
|
|
<summary>{_t("Advanced")}</summary>
|
|
|
|
|
<div>{_t("Backup version: ")}{this.state.backupInfo.version}</div>
|
|
|
|
|
<div>{_t("Algorithm: ")}{this.state.backupInfo.algorithm}</div>
|
2019-12-12 17:06:44 +03:00
|
|
|
|
<div>{_t("Backup key stored: ")}{keyStatus}</div>
|
2019-02-08 14:51:22 +03:00
|
|
|
|
{uploadStatus}
|
|
|
|
|
<div>{backupSigStatuses}</div>
|
|
|
|
|
<div>{trustedLocally}</div>
|
|
|
|
|
</details>
|
2019-12-12 18:18:36 +03:00
|
|
|
|
{buttonRow}
|
2018-09-13 19:11:46 +03:00
|
|
|
|
</div>;
|
|
|
|
|
} else {
|
2019-12-11 19:32:47 +03:00
|
|
|
|
// This is a temporary button for testing the new path which stores
|
|
|
|
|
// the key backup key in SSSS. Initialising SSSS depends on
|
|
|
|
|
// cross-signing and is part of the same project, so we only show
|
|
|
|
|
// this mode when the cross-signing feature is enabled.
|
|
|
|
|
// TODO: Clean this up when removing the feature flag.
|
|
|
|
|
let secureSecretStorageKeyBackup;
|
|
|
|
|
if (SettingsStore.isFeatureEnabled("feature_cross_signing")) {
|
|
|
|
|
secureSecretStorageKeyBackup = (
|
|
|
|
|
<div className="mx_KeyBackupPanel_buttonRow">
|
|
|
|
|
<AccessibleButton kind="primary" onClick={this._startNewBackupWithSecureSecretStorage}>
|
|
|
|
|
{_t("Start using Key Backup with Secure Secret Storage")}
|
|
|
|
|
</AccessibleButton>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 19:11:46 +03:00
|
|
|
|
return <div>
|
2019-02-12 19:01:38 +03:00
|
|
|
|
<div>
|
|
|
|
|
<p>{_t(
|
|
|
|
|
"Your keys are <b>not being backed up from this device</b>.", {},
|
2019-02-12 21:08:16 +03:00
|
|
|
|
{b: sub => <b>{sub}</b>},
|
2019-02-12 19:01:38 +03:00
|
|
|
|
)}</p>
|
|
|
|
|
<p>{encryptedMessageAreEncrypted}</p>
|
|
|
|
|
<p>{_t("Back up your keys before signing out to avoid losing them.")}</p>
|
|
|
|
|
</div>
|
2019-11-20 20:56:44 +03:00
|
|
|
|
<div className="mx_KeyBackupPanel_buttonRow">
|
|
|
|
|
<AccessibleButton kind="primary" onClick={this._startNewBackup}>
|
|
|
|
|
{_t("Start using Key Backup")}
|
|
|
|
|
</AccessibleButton>
|
|
|
|
|
</div>
|
2019-12-11 19:32:47 +03:00
|
|
|
|
{secureSecretStorageKeyBackup}
|
2018-09-13 19:11:46 +03:00
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|