From a233af67eab6f15bc2a1743976e9f0966f3e897c Mon Sep 17 00:00:00 2001
From: Matthew Hodgson
Date: Mon, 15 Jan 2018 02:02:48 +0000
Subject: [PATCH 01/26] initial pseudocode WIP for e2e online backups
---
src/SuggestKeyRestoreHandler.js | 96 +++++++++++++++++++
src/components/structures/MatrixChat.js | 6 ++
.../views/dialogs/SuggestKeyBackupDialog.js | 68 +++++++++++++
.../views/dialogs/SuggestKeyRestoreDialog.js | 77 +++++++++++++++
4 files changed, 247 insertions(+)
create mode 100644 src/SuggestKeyRestoreHandler.js
create mode 100644 src/components/views/dialogs/SuggestKeyBackupDialog.js
create mode 100644 src/components/views/dialogs/SuggestKeyRestoreDialog.js
diff --git a/src/SuggestKeyRestoreHandler.js b/src/SuggestKeyRestoreHandler.js
new file mode 100644
index 0000000000..3383889c1e
--- /dev/null
+++ b/src/SuggestKeyRestoreHandler.js
@@ -0,0 +1,96 @@
+/*
+Copyright 2018 New Vector Ltd
+
+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 sdk from './index';
+import Modal from './Modal';
+
+export default class SuggestKeyRestoreHandler {
+ constructor(matrixClient) {
+ this._matrixClient = matrixClient;
+ }
+
+ handleSuggestKeyRestore() {
+ const onVerifyDevice = () => {
+ const DeviceVerifyDialog = sdk.getComponent('views.dialogs.DeviceVerifyDialog');
+
+ Modal.createTrackedDialog('Key Restore', 'Starting verification', DeviceVerifyDialog, {
+ // userId: this.props.userId,
+ // device: this.state.deviceInfo,
+ onFinished: (verified) => {
+ if (verified) {
+ this.props.onFinished();
+ }
+ },
+ });
+ };
+
+ const onRecoverFromBackup = () => {
+ // XXX: we need this so that you can get at it from UserSettings too
+ // * prompt for recovery key
+ // * Download the current backup version info from the server and check the key decrypts it okay.
+ // * Check that the public key for that backup version matches the recovery key
+ // * show a spinner
+ // * Download all the existing keys from the server
+ // * Decrypt them using the recovery key
+ // * Add them to the local store (which encrypts them as normal with "DEFAULT KEY"
+ // * Enable incremental backups for this device.
+ };
+
+ const onIgnoreSuggestion = () => {
+ };
+
+ const onFinished = () => {
+ this.suggestBackup();
+ };
+
+ // FIXME: need a way to know if an account has ever touched E2E before.
+ // Perhaps we can extend toDevice to include a flag if it's the first time the
+ // server has ever sent a room_key to a client or something?
+ const virginAccount = false;
+
+ if (virginAccount) {
+ this.suggestBackup();
+ return;
+ }
+
+ const SuggestKeyRestoreDialog = sdk.getComponent("dialogs.SuggestKeyRestoreDialog");
+ Modal.createTrackedDialog('Key Restore', 'Key Restore', SuggestKeyRestoreDialog, {
+ matrixClient: this._matrixClient,
+ isOnlyDevice: false, // FIXME
+ hasOnlineBackup: false, // FIXME
+ onVerifyDevice: onVerifyDevice,
+ onRecoverFromBackup: onRecoverFromBackup,
+ onIgnoreSuggestion: onIgnoreSuggestion,
+ onFinished: onFinished,
+ });
+ }
+
+ suggestBackup() {
+ if (hasOnlineBackup) return;
+
+ const onStartNewBackup = () => {
+ // XXX: we need this so that you can get at it from UserSettings too
+ // * Upload all their existing keys from their session store to the backup using the bulk upload API.
+ // (Having re-encrypted them using the backup keypair rather than the static one used to store them on disk)
+ };
+
+ const SuggestKeyBackupDialog = sdk.getComponent("dialogs.SuggestKeyBackupDialog");
+ Modal.createTrackedDialog('Key Backup', 'Key Backup', SuggestKeyBackupDialog, {
+ onStartNewBackup: onStartNewBackup,
+ });
+ }
+}
+
diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index 733007677b..4b04f4cf1d 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -1129,6 +1129,12 @@ export default React.createClass({
cli.on("crypto.roomKeyRequestCancellation", (req) => {
krh.handleKeyRequestCancellation(req);
});
+
+ const skrh = new SuggestKeyRestoreHandler(cli);
+ cli.on("crypto.suggestKeyRestore", () => {
+ skrh.handleSuggestKeyRestore();
+ });
+
cli.on("Room", (room) => {
if (MatrixClientPeg.get().isCryptoEnabled()) {
const blacklistEnabled = SettingsStore.getValueAt(
diff --git a/src/components/views/dialogs/SuggestKeyBackupDialog.js b/src/components/views/dialogs/SuggestKeyBackupDialog.js
new file mode 100644
index 0000000000..c2d6cfc60f
--- /dev/null
+++ b/src/components/views/dialogs/SuggestKeyBackupDialog.js
@@ -0,0 +1,68 @@
+/*
+Copyright 2018 New Vector Ltd
+
+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 Modal from '../../../Modal';
+import React from 'react';
+import PropTypes from 'prop-types';
+import sdk from '../../../index';
+
+import { _t, _td } from '../../../languageHandler';
+
+/**
+ * Dialog which asks the user whether they want to restore megolm keys
+ * from various sources when they first start using E2E on a new device.
+ */
+export default React.createClass({
+ propTypes: {
+ onStartNewBackup: PropTypes.func.isRequired,
+ },
+
+ render: function() {
+ const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+
+ return (
+
+
+
To avoid ever losing your encrypted message history, you
+ can save your encryption keys on the server, protected by a recovery key.
+
+
To maximise security, your recovery key is never stored by the app,
+ so you must store it yourself somewhere safe.
+
+
Warning: storing your encryption keys on the server means that
+ if someone gains access to your account and also steals your recovery key,
+ they will be able to read all of your encrypted conversation history.
+
+
+
Do you wish to generate a recovery key and backup your encryption
+ keys on the server?
+
+
+
+
+
+
+
+ );
+ },
+});
diff --git a/src/components/views/dialogs/SuggestKeyRestoreDialog.js b/src/components/views/dialogs/SuggestKeyRestoreDialog.js
new file mode 100644
index 0000000000..2a711e0231
--- /dev/null
+++ b/src/components/views/dialogs/SuggestKeyRestoreDialog.js
@@ -0,0 +1,77 @@
+/*
+Copyright 2018 New Vector Ltd
+
+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 Modal from '../../../Modal';
+import React from 'react';
+import PropTypes from 'prop-types';
+import sdk from '../../../index';
+
+import { _t, _td } from '../../../languageHandler';
+
+/**
+ * Dialog which asks the user whether they want to restore megolm keys
+ * from various sources when they first start using E2E on a new device.
+ */
+export default React.createClass({
+ propTypes: {
+ matrixClient: PropTypes.object.isRequired,
+ isOnlyDevice: PropTypes.bool.isRequired,
+ hasOnlineBackup: PropTypes.bool.isRequired,
+ onVerifyDevice: PropTypes.func.isRequired,
+ onImportBackup: PropTypes.func.isRequired,
+ onRecoverFromBackup: PropTypes.func.isRequired,
+ onIgnoreSuggestion: PropTypes.func.isRequired,
+ },
+
+ render: function() {
+ const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
+
+ return (
+
+
+
We don't have a way to decrypt older messages on this device.
+
+
Your options are:
+
+
+ { !this.props.isOnlyDevice ?
Verify this device from one or more of your other ones to automatically sync keys
: '' }
+ { this.props.hasOnlineBackup ?
Enter your recovery key to restore encryption keys from your online backup
: '' }
+
Import encryption keys from an offline backup
+
Continue without restoring keys, syncing keys from your other devices on a best effort basis
We don't have a way to decrypt older messages on this device.
+
+
We don't have a way to decrypt older messages on this device.
-
Your options are:
+
Your options are:
-
- { !this.props.isOnlyDevice ?
Verify this device from one or more of your other ones to automatically sync keys
: '' }
- { this.props.hasOnlineBackup ?
Enter your recovery key to restore encryption keys from your online backup
: '' }
-
Import encryption keys from an offline backup
-
Continue without restoring keys, syncing keys from your other devices on a best effort basis
-
+
+ { !this.props.isOnlyDevice ?
Verify this device from one or more of your other ones to automatically sync keys
: '' }
+ { this.props.hasOnlineBackup ?
Enter your recovery key to restore encryption keys from your online backup
: '' }
+
Import encryption keys from an offline backup
+
Continue without restoring keys, syncing keys from your other devices on a best effort basis
+
-
-
-
-
-
+
+
+
+
+
+
-
);
},
From 292b1f09af60b294a1a73cb512339cbc3179ad6d Mon Sep 17 00:00:00 2001
From: David Baker
Date: Thu, 13 Sep 2018 17:11:46 +0100
Subject: [PATCH 03/26] WIP e2e key backups
Continues from Matthew's work: adds a feature flag & panel in
user settings to create a backup.
Can't restore a backup yet, nor even continue backing up to the same
backup after a refresh.
---
res/css/_components.scss | 1 +
.../views/dialogs/_CreateKeyBackupDialog.scss | 25 ++
src/components/structures/MatrixChat.js | 2 +
src/components/structures/UserSettings.js | 11 +
.../views/dialogs/SuggestKeyBackupDialog.js | 68 ------
.../keybackup/CreateKeyBackupDialog.js | 230 ++++++++++++++++++
.../views/settings/KeyBackupPanel.js | 134 ++++++++++
src/i18n/strings/en_EN.json | 33 +++
src/settings/Settings.js | 6 +
9 files changed, 442 insertions(+), 68 deletions(-)
create mode 100644 res/css/views/dialogs/_CreateKeyBackupDialog.scss
delete mode 100644 src/components/views/dialogs/SuggestKeyBackupDialog.js
create mode 100644 src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
create mode 100644 src/components/views/settings/KeyBackupPanel.js
diff --git a/res/css/_components.scss b/res/css/_components.scss
index 0e40b40a29..e8a8877d62 100644
--- a/res/css/_components.scss
+++ b/res/css/_components.scss
@@ -33,6 +33,7 @@
@import "./views/dialogs/_ChatInviteDialog.scss";
@import "./views/dialogs/_ConfirmUserActionDialog.scss";
@import "./views/dialogs/_CreateGroupDialog.scss";
+@import "./views/dialogs/_CreateKeyBackupDialog.scss";
@import "./views/dialogs/_CreateRoomDialog.scss";
@import "./views/dialogs/_DeactivateAccountDialog.scss";
@import "./views/dialogs/_DevtoolsDialog.scss";
diff --git a/res/css/views/dialogs/_CreateKeyBackupDialog.scss b/res/css/views/dialogs/_CreateKeyBackupDialog.scss
new file mode 100644
index 0000000000..a422cf858c
--- /dev/null
+++ b/res/css/views/dialogs/_CreateKeyBackupDialog.scss
@@ -0,0 +1,25 @@
+/*
+Copyright 2018 New Vector Ltd
+
+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.
+*/
+
+.mx_CreateKeyBackupDialog {
+ padding-right: 40px;
+}
+
+.mx_CreateKeyBackupDialog_recoveryKey {
+ padding: 20px;
+ color: $info-plinth-fg-color;
+ background-color: $info-plinth-bg-color;
+}
diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index 39e973e8f7..900cd57b90 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -48,6 +48,8 @@ import SettingsStore, {SettingLevel} from "../../settings/SettingsStore";
import { startAnyRegistrationFlow } from "../../Registration.js";
import { messageForSyncError } from '../../utils/ErrorUtils';
+import SuggestKeyRestoreHandler from "../../SuggestKeyRestoreHandler";
+
/** constants for MatrixChat.state.view */
const VIEWS = {
// a special initial state which is only used at startup, while we are
diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js
index 53e1ddea71..b5cbf5bd89 100644
--- a/src/components/structures/UserSettings.js
+++ b/src/components/structures/UserSettings.js
@@ -736,6 +736,16 @@ module.exports = React.createClass({
);
}
+
+ let keyBackupSection;
+ if (SettingsStore.isFeatureEnabled("feature_keybackup")) {
+ const KeyBackupPanel = sdk.getComponent('views.settings.KeyBackupPanel');
+ keyBackupSection =
);
},
diff --git a/src/components/views/dialogs/SuggestKeyBackupDialog.js b/src/components/views/dialogs/SuggestKeyBackupDialog.js
deleted file mode 100644
index c2d6cfc60f..0000000000
--- a/src/components/views/dialogs/SuggestKeyBackupDialog.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-Copyright 2018 New Vector Ltd
-
-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 Modal from '../../../Modal';
-import React from 'react';
-import PropTypes from 'prop-types';
-import sdk from '../../../index';
-
-import { _t, _td } from '../../../languageHandler';
-
-/**
- * Dialog which asks the user whether they want to restore megolm keys
- * from various sources when they first start using E2E on a new device.
- */
-export default React.createClass({
- propTypes: {
- onStartNewBackup: PropTypes.func.isRequired,
- },
-
- render: function() {
- const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
-
- return (
-
-
-
To avoid ever losing your encrypted message history, you
- can save your encryption keys on the server, protected by a recovery key.
-
-
To maximise security, your recovery key is never stored by the app,
- so you must store it yourself somewhere safe.
-
-
Warning: storing your encryption keys on the server means that
- if someone gains access to your account and also steals your recovery key,
- they will be able to read all of your encrypted conversation history.
-
-
-
Do you wish to generate a recovery key and backup your encryption
- keys on the server?
-
-
-
-
-
-
-
- );
- },
-});
diff --git a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
new file mode 100644
index 0000000000..03410f4f7d
--- /dev/null
+++ b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
@@ -0,0 +1,230 @@
+/*
+Copyright 2018 New Vector Ltd
+
+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 Modal from '../../../../Modal';
+import React from 'react';
+import PropTypes from 'prop-types';
+import sdk from '../../../../index';
+import MatrixClientPeg from '../../../../MatrixClientPeg';
+import { formatCryptoKey } from '../../../../utils/FormattingUtils';
+import Promise from 'bluebird';
+
+import { _t, _td } from '../../../../languageHandler';
+
+const PHASE_INTRO = 0;
+const PHASE_GENERATING = 1;
+const PHASE_SHOWKEY = 2;
+const PHASE_MAKEBACKUP = 3;
+const PHASE_UPLOAD = 4;
+const PHASE_DONE = 5;
+
+// XXX: copied from ShareDialog: factor out into utils
+function selectText(target) {
+ const range = document.createRange();
+ range.selectNodeContents(target);
+
+ const selection = window.getSelection();
+ selection.removeAllRanges();
+ selection.addRange(range);
+}
+
+/**
+ * Walks the user through the process of creating an e22 key backup
+ * on the server.
+ */
+export default React.createClass({
+ getInitialState: function() {
+ return {
+ phase: PHASE_INTRO,
+ };
+ },
+
+ componentWillMount: function() {
+ this._recoveryKeyNode = null;
+ this._keyBackupInfo = null;
+ },
+
+ _collectRecoveryKeyNode: function(n) {
+ this._recoveryKeyNode = n;
+ },
+
+ _copyRecoveryKey: function() {
+ selectText(this._recoveryKeyNode);
+ const successful = document.execCommand('copy');
+ if (successful) {
+ this.setState({copied: true});
+ }
+ },
+
+ _createBackup: function() {
+ this.setState({
+ phase: PHASE_MAKEBACKUP,
+ error: null,
+ });
+ this._createBackupPromise = MatrixClientPeg.get().createKeyBackupVersion(
+ this._keyBackupInfo,
+ ).then((info) => {
+ this.setState({
+ phase: PHASE_UPLOAD,
+ });
+ return MatrixClientPeg.get().backupAllGroupSessions(info.version);
+ }).then(() => {
+ this.setState({
+ phase: PHASE_DONE,
+ });
+ }).catch(e => {
+ console.log("Error creating key backup", e);
+ this.setState({
+ error: e,
+ });
+ });
+ },
+
+ _onCancel: function() {
+ this.props.onFinished(false);
+ },
+
+ _onDone: function() {
+ this.props.onFinished(true);
+ },
+
+ _generateKey: async function() {
+ this.setState({
+ phase: PHASE_GENERATING,
+ });
+ // Look, work is being done!
+ await Promise.delay(1200);
+ this._keyBackupInfo = MatrixClientPeg.get().prepareKeyBackupVersion();
+ this.setState({
+ phase: PHASE_SHOWKEY,
+ });
+ },
+
+ _renderPhaseIntro: function() {
+ const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
+ return
+
To avoid ever losing your encrypted message history, you
+ can save your encryption keys on the server, protected by a recovery key.
+
+
To maximise security, your recovery key is never stored by the app,
+ so you must store it yourself somewhere safe.
+
Warning: storing your encryption keys on the server means that
+ if someone gains access to your account and also steals your recovery key,
+ they will be able to read all of your encrypted conversation history.
+
+
+
Do you wish to generate a recovery key and backup your encryption
+ keys on the server?
{_t("This key can decrypt your full message history.")}
+
{_t(
+ "When you've saved it somewhere safe, proceed to the next step where the key will be used to "+
+ "create an encrypted backup of your message keys and then destroyed."
+ )}
+
+ );
+ },
+});
diff --git a/src/components/views/settings/KeyBackupPanel.js b/src/components/views/settings/KeyBackupPanel.js
new file mode 100644
index 0000000000..3b452e77f8
--- /dev/null
+++ b/src/components/views/settings/KeyBackupPanel.js
@@ -0,0 +1,134 @@
+/*
+Copyright 2018 New Vector Ltd
+
+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 PropTypes from 'prop-types';
+
+import sdk from '../../../index';
+import MatrixClientPeg from '../../../MatrixClientPeg';
+import { _t } from '../../../languageHandler';
+import Modal from '../../../Modal';
+
+export default class KeyBackupPanel extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this._startNewBackup = this._startNewBackup.bind(this);
+ this._deleteBackup = this._deleteBackup.bind(this);
+
+ this._unmounted = false;
+ this.state = {
+ loading: true,
+ error: null,
+ backupInfo: null,
+ };
+ this._loadBackupStatus();
+ }
+
+ componentWillUnmount() {
+ this._unmounted = true;
+ }
+
+ async _loadBackupStatus() {
+ this.setState({loading: true});
+ try {
+ const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion();
+ if (this._unmounted) return;
+ this.setState({
+ backupInfo,
+ loading: false,
+ });
+ } catch (e) {
+ console.log("Unable to fetch key backup status", e);
+ if (this._unmounted) return;
+ this.setState({
+ error: e,
+ loading: false,
+ });
+ return;
+ }
+ }
+
+ _startNewBackup() {
+ const CreateKeyBackupDialog = sdk.getComponent("dialogs.keybackup.CreateKeyBackupDialog");
+ Modal.createTrackedDialog('Key Backup', 'Key Backup', CreateKeyBackupDialog, {
+ onFinished: () => {
+ this._loadBackupStatus();
+ },
+ });
+ }
+
+ _deleteBackup() {
+ const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
+ Modal.createTrackedDialog('Delete Backup', '', QuestionDialog, {
+ title: _t("Delete Backup"),
+ description: _t(
+ "Delete your backed up encryption keys from the server? " +
+ "You will no longer be able to use your recovery key to read encrypted message history"
+ ),
+ button: _t('Delete backup'),
+ danger: true,
+ onFinished: (proceed) => {
+ if (!proceed) return;
+ this.setState({loading: true});
+ MatrixClientPeg.get().deleteKeyBackupVersion(this.state.backupInfo.version).then(() => {
+ this._loadBackupStatus();
+ });
+ },
+ });
+
+ }
+
+ render() {
+ const Spinner = sdk.getComponent("elements.Spinner");
+ const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
+
+ if (this.state.error) {
+ return (
+
+ {_t("Unable to load key backup status")}
+
+ );
+ } else if (this.state.loading) {
+ return ;
+ } else if (this.state.backupInfo) {
+ let clientBackupStatus;
+ if (MatrixClientPeg.get().getKeyBackupEnabled()) {
+ clientBackupStatus = _t("This device is uploading keys to this backup");
+ } else {
+ // XXX: display why and how to fix it
+ clientBackupStatus = _t("This device is not uploading keys to this backup", {}, {b: x => {x}});
+ }
+ return
+
{ _t("Delete backup") }
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 16695c8ec8..acad2b7e33 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -304,6 +304,11 @@
"Unable to load key backup status": "Unable to load key backup status",
"This device is uploading keys to this backup": "This device is uploading keys to this backup",
"This device is not uploading keys to this backup": "This device is not uploading keys to this backup",
+ "Backup has a valid signature from verified device x": "Backup has a valid signature from verified device x",
+ "Backup has a valid signature from unverified device ": "Backup has a valid signature from unverified device ",
+ "Backup has an invalid signature from verified device ": "Backup has an invalid signature from verified device ",
+ "Backup has an invalid signature from unverified device ": "Backup has an invalid signature from unverified device ",
+ "Backup is not signed by any of your devices": "Backup is not signed by any of your devices",
"Backup version: ": "Backup version: ",
"Algorithm: ": "Algorithm: ",
"No backup is present": "No backup is present",
@@ -937,6 +942,10 @@
"Share Room Message": "Share Room Message",
"Link to selected message": "Link to selected message",
"COPY": "COPY",
+ "Restore encryption keys": "Restore encryption keys",
+ "Verify this device": "Verify this device",
+ "Restore from online backup": "Restore from online backup",
+ "Restore from offline backup": "Restore from offline backup",
"You are currently blacklisting unverified devices; to send messages to these devices you must verify them.": "You are currently blacklisting unverified devices; to send messages to these devices you must verify them.",
"We recommend you go through the verification process for each device to confirm they belong to their legitimate owner, but you can resend the message without verifying if you prefer.": "We recommend you go through the verification process for each device to confirm they belong to their legitimate owner, but you can resend the message without verifying if you prefer.",
"Room contains unknown devices": "Room contains unknown devices",
@@ -957,12 +966,6 @@
"Creating backup...": "Creating backup...",
"Uploading keys...": "Uploading keys...",
"Create Key Backup": "Create Key Backup",
- "Backup encryption keys on your server?": "Backup encryption keys on your server?",
- "Generate recovery key and enable online backups": "Generate recovery key and enable online backups",
- "Restore encryption keys": "Restore encryption keys",
- "Verify this device": "Verify this device",
- "Restore from online backup": "Restore from online backup",
- "Restore from offline backup": "Restore from offline backup",
"Private Chat": "Private Chat",
"Public Chat": "Public Chat",
"Custom": "Custom",
From 2e6d27717cdd17310beb72e77e973ca3fa541408 Mon Sep 17 00:00:00 2001
From: David Baker
Date: Fri, 14 Sep 2018 17:33:25 +0100
Subject: [PATCH 05/26] LIIIIIIIIIIIIIIIINT!
---
.../views/dialogs/SuggestKeyRestoreDialog.js | 3 +-
.../keybackup/CreateKeyBackupDialog.js | 4 +-
.../views/settings/KeyBackupPanel.js | 43 ++++++++++++++-----
3 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/src/components/views/dialogs/SuggestKeyRestoreDialog.js b/src/components/views/dialogs/SuggestKeyRestoreDialog.js
index 3419b6235c..993bc74666 100644
--- a/src/components/views/dialogs/SuggestKeyRestoreDialog.js
+++ b/src/components/views/dialogs/SuggestKeyRestoreDialog.js
@@ -14,12 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import Modal from '../../../Modal';
import React from 'react';
import PropTypes from 'prop-types';
import sdk from '../../../index';
-import { _t, _td } from '../../../languageHandler';
+import { _t } from '../../../languageHandler';
/**
* Dialog which asks the user whether they want to restore megolm keys
diff --git a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
index 03410f4f7d..6e83e4c032 100644
--- a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
@@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import Modal from '../../../../Modal';
import React from 'react';
-import PropTypes from 'prop-types';
import sdk from '../../../../index';
import MatrixClientPeg from '../../../../MatrixClientPeg';
import { formatCryptoKey } from '../../../../utils/FormattingUtils';
@@ -146,7 +144,7 @@ export default React.createClass({
{_t("This key can decrypt your full message history.")}
{_t(
"When you've saved it somewhere safe, proceed to the next step where the key will be used to "+
- "create an encrypted backup of your message keys and then destroyed."
+ "create an encrypted backup of your message keys and then destroyed.",
)}
+ {"\uD83D\uDC4D "}{_t("This looks like a valid recovery key!")}
+
;
+ } else {
+ keyStatus =
+ {"\uD83D\uDC4E "}{_t("Not a valid recovery key")}
+
;
+ }
+
content =
{_t("Please enter the recovery key generated when you set up key backup")}
+ {keyStatus}
;
}
diff --git a/src/components/views/elements/DialogButtons.js b/src/components/views/elements/DialogButtons.js
index baf831415f..e8e1c78e71 100644
--- a/src/components/views/elements/DialogButtons.js
+++ b/src/components/views/elements/DialogButtons.js
@@ -43,7 +43,11 @@ module.exports = React.createClass({
focus: PropTypes.bool,
+ // disables the primary and cancel buttons
disabled: PropTypes.bool,
+
+ // disables only the primary button
+ primaryDisabled: PropTypes.bool,
},
getDefaultProps: function() {
@@ -73,7 +77,7 @@ module.exports = React.createClass({
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 1be2845787..511b007eca 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -972,6 +972,8 @@
"No backup found!": "No backup found!",
"Failed to decrypt %(failedCount)s sessions!": "Failed to decrypt %(failedCount)s sessions!",
"Restored %(sessionCount)s session keys": "Restored %(sessionCount)s session keys",
+ "This looks like a valid recovery key!": "This looks like a valid recovery key!",
+ "Not a valid recovery key": "Not a valid recovery key",
"Please enter the recovery key generated when you set up key backup": "Please enter the recovery key generated when you set up key backup",
"Recover": "Recover",
"Restore Key Backup": "Restore Key Backup",
From 12d10cccefb606a7b57ecec89a101cc17c47fdb7 Mon Sep 17 00:00:00 2001
From: David Baker
Date: Mon, 17 Sep 2018 17:14:03 +0100
Subject: [PATCH 08/26] Show if sig is from this device
---
src/components/views/settings/KeyBackupPanel.js | 7 ++++++-
src/i18n/strings/en_EN.json | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/components/views/settings/KeyBackupPanel.js b/src/components/views/settings/KeyBackupPanel.js
index ebf9daf0d2..7cbee9c501 100644
--- a/src/components/views/settings/KeyBackupPanel.js
+++ b/src/components/views/settings/KeyBackupPanel.js
@@ -164,7 +164,12 @@ export default class KeyBackupPanel extends React.Component {
device: sub => {sig.device.getDisplayName()},
};
let sigStat;
- if (sig.valid && sig.device.isVerified()) {
+ if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key()) {
+ sigStat = _t(
+ "Backup has a valid signature from this device",
+ {}, sigStatSub,
+ );
+ } else if (sig.valid && sig.device.isVerified()) {
sigStat = _t(
"Backup has a valid signature from " +
"verified device x",
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 511b007eca..300a1f67cf 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -304,6 +304,7 @@
"Unable to load key backup status": "Unable to load key backup status",
"This device is uploading keys to this backup": "This device is uploading keys to this backup",
"This device is not uploading keys to this backup": "This device is not uploading keys to this backup",
+ "Backup has a valid signature from this device": "Backup has a valid signature from this device",
"Backup has a valid signature from verified device x": "Backup has a valid signature from verified device x",
"Backup has a valid signature from unverified device ": "Backup has a valid signature from unverified device ",
"Backup has an invalid signature from verified device ": "Backup has an invalid signature from verified device ",
From 2cef0f7f727e9237759bb82f4264f24e41786d06 Mon Sep 17 00:00:00 2001
From: David Baker
Date: Tue, 18 Sep 2018 15:04:51 +0100
Subject: [PATCH 09/26] lint
---
src/SuggestKeyRestoreHandler.js | 96 -------------------
.../views/dialogs/SuggestKeyRestoreDialog.js | 76 ---------------
.../keybackup/RestoreKeyBackupDialog.js | 8 +-
3 files changed, 2 insertions(+), 178 deletions(-)
delete mode 100644 src/SuggestKeyRestoreHandler.js
delete mode 100644 src/components/views/dialogs/SuggestKeyRestoreDialog.js
diff --git a/src/SuggestKeyRestoreHandler.js b/src/SuggestKeyRestoreHandler.js
deleted file mode 100644
index 3383889c1e..0000000000
--- a/src/SuggestKeyRestoreHandler.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-Copyright 2018 New Vector Ltd
-
-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 sdk from './index';
-import Modal from './Modal';
-
-export default class SuggestKeyRestoreHandler {
- constructor(matrixClient) {
- this._matrixClient = matrixClient;
- }
-
- handleSuggestKeyRestore() {
- const onVerifyDevice = () => {
- const DeviceVerifyDialog = sdk.getComponent('views.dialogs.DeviceVerifyDialog');
-
- Modal.createTrackedDialog('Key Restore', 'Starting verification', DeviceVerifyDialog, {
- // userId: this.props.userId,
- // device: this.state.deviceInfo,
- onFinished: (verified) => {
- if (verified) {
- this.props.onFinished();
- }
- },
- });
- };
-
- const onRecoverFromBackup = () => {
- // XXX: we need this so that you can get at it from UserSettings too
- // * prompt for recovery key
- // * Download the current backup version info from the server and check the key decrypts it okay.
- // * Check that the public key for that backup version matches the recovery key
- // * show a spinner
- // * Download all the existing keys from the server
- // * Decrypt them using the recovery key
- // * Add them to the local store (which encrypts them as normal with "DEFAULT KEY"
- // * Enable incremental backups for this device.
- };
-
- const onIgnoreSuggestion = () => {
- };
-
- const onFinished = () => {
- this.suggestBackup();
- };
-
- // FIXME: need a way to know if an account has ever touched E2E before.
- // Perhaps we can extend toDevice to include a flag if it's the first time the
- // server has ever sent a room_key to a client or something?
- const virginAccount = false;
-
- if (virginAccount) {
- this.suggestBackup();
- return;
- }
-
- const SuggestKeyRestoreDialog = sdk.getComponent("dialogs.SuggestKeyRestoreDialog");
- Modal.createTrackedDialog('Key Restore', 'Key Restore', SuggestKeyRestoreDialog, {
- matrixClient: this._matrixClient,
- isOnlyDevice: false, // FIXME
- hasOnlineBackup: false, // FIXME
- onVerifyDevice: onVerifyDevice,
- onRecoverFromBackup: onRecoverFromBackup,
- onIgnoreSuggestion: onIgnoreSuggestion,
- onFinished: onFinished,
- });
- }
-
- suggestBackup() {
- if (hasOnlineBackup) return;
-
- const onStartNewBackup = () => {
- // XXX: we need this so that you can get at it from UserSettings too
- // * Upload all their existing keys from their session store to the backup using the bulk upload API.
- // (Having re-encrypted them using the backup keypair rather than the static one used to store them on disk)
- };
-
- const SuggestKeyBackupDialog = sdk.getComponent("dialogs.SuggestKeyBackupDialog");
- Modal.createTrackedDialog('Key Backup', 'Key Backup', SuggestKeyBackupDialog, {
- onStartNewBackup: onStartNewBackup,
- });
- }
-}
-
diff --git a/src/components/views/dialogs/SuggestKeyRestoreDialog.js b/src/components/views/dialogs/SuggestKeyRestoreDialog.js
deleted file mode 100644
index 993bc74666..0000000000
--- a/src/components/views/dialogs/SuggestKeyRestoreDialog.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-Copyright 2018 New Vector Ltd
-
-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 PropTypes from 'prop-types';
-import sdk from '../../../index';
-
-import { _t } from '../../../languageHandler';
-
-/**
- * Dialog which asks the user whether they want to restore megolm keys
- * from various sources when they first start using E2E on a new device.
- */
-export default React.createClass({
- propTypes: {
- matrixClient: PropTypes.object.isRequired,
- isOnlyDevice: PropTypes.bool.isRequired,
- hasOnlineBackup: PropTypes.bool.isRequired,
- onVerifyDevice: PropTypes.func.isRequired,
- onImportBackup: PropTypes.func.isRequired,
- onRecoverFromBackup: PropTypes.func.isRequired,
- onIgnoreSuggestion: PropTypes.func.isRequired,
- },
-
- render: function() {
- const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
-
- return (
-
-
-
We don't have a way to decrypt older messages on this device.
-
-
Your options are:
-
-
- { !this.props.isOnlyDevice ?
Verify this device from one or more of your other ones to automatically sync keys
: '' }
- { this.props.hasOnlineBackup ?
Enter your recovery key to restore encryption keys from your online backup
: '' }
-
Import encryption keys from an offline backup
-
Continue without restoring keys, syncing keys from your other devices on a best effort basis
-
-
-
-
-
-
-
-
-
-
- );
- },
-});
diff --git a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
index 5c02fd1227..149f6a6d1f 100644
--- a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
@@ -14,15 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import Modal from '../../../../Modal';
import React from 'react';
-import PropTypes from 'prop-types';
import sdk from '../../../../index';
import MatrixClientPeg from '../../../../MatrixClientPeg';
-import { formatCryptoKey } from '../../../../utils/FormattingUtils';
-import Promise from 'bluebird';
-import { _t, _td } from '../../../../languageHandler';
+import { _t } from '../../../../languageHandler';
function isRecoveryKeyValid(r) {
return MatrixClientPeg.get().isValidRecoveryKey(r.replace(/ /g, ''));
@@ -149,7 +145,7 @@ export default React.createClass({
content =
{_t("Please enter the recovery key generated when you set up key backup")}
-
+ Without setting up Secure Message Recovery, you won't be able to restore your
+ encrypted message history if you log out or use another device.
+
+
+
+
;
} else {
switch (this.state.phase) {
- case PHASE_INTRO:
- content = this._renderPhaseIntro();
+ case PHASE_PASSPHRASE:
+ content = this._renderPhasePassPhrase();
break;
- case PHASE_GENERATING:
- content = this._renderBusyPhase(_td("Generating recovery key..."));
+ case PHASE_PASSPHRASE_CONFIRM:
+ content = this._renderPhasePassPhraseConfirm();
break;
case PHASE_SHOWKEY:
content = this._renderPhaseShowKey();
break;
- case PHASE_MAKEBACKUP:
- content = this._renderBusyPhase(_td("Creating backup..."));
+ case PHASE_KEEPITSAFE:
+ content = this._renderPhaseKeepItSafe();
break;
- case PHASE_UPLOAD:
- content = this._renderBusyPhase(_td("Uploading keys..."));
+ case PHASE_BACKINGUP:
+ content = this._renderBusyPhase(_td("Backing up..."));
break;
case PHASE_DONE:
content = this._renderPhaseDone();
break;
+ case PHASE_OPTOUT_CONFIRM:
+ content = this._renderPhaseOptOutConfirm();
+ break;
}
}
return (
{content}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 3da5ff15a2..cac9b4ef59 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -252,6 +252,7 @@
"Room Colour": "Room Colour",
"Enable widget screenshots on supported widgets": "Enable widget screenshots on supported widgets",
"Show empty room list headings": "Show empty room list headings",
+ "Show developer tools": "Show developer tools",
"Collecting app version information": "Collecting app version information",
"Collecting logs": "Collecting logs",
"Uploading report": "Uploading report",
@@ -570,6 +571,7 @@
"Click here to fix": "Click here to fix",
"To send events of type , you must be a": "To send events of type , you must be a",
"Upgrade room to version %(ver)s": "Upgrade room to version %(ver)s",
+ "Open Devtools": "Open Devtools",
"Who can access this room?": "Who can access this room?",
"Only people who have been invited": "Only people who have been invited",
"Anyone who knows the room's link, apart from guests": "Anyone who knows the room's link, apart from guests",
@@ -959,30 +961,42 @@
"Share Room Message": "Share Room Message",
"Link to selected message": "Link to selected message",
"COPY": "COPY",
- "Restore encryption keys": "Restore encryption keys",
- "Verify this device": "Verify this device",
- "Restore from online backup": "Restore from online backup",
- "Restore from offline backup": "Restore from offline backup",
"You are currently blacklisting unverified devices; to send messages to these devices you must verify them.": "You are currently blacklisting unverified devices; to send messages to these devices you must verify them.",
"We recommend you go through the verification process for each device to confirm they belong to their legitimate owner, but you can resend the message without verifying if you prefer.": "We recommend you go through the verification process for each device to confirm they belong to their legitimate owner, but you can resend the message without verifying if you prefer.",
"Room contains unknown devices": "Room contains unknown devices",
"\"%(RoomName)s\" contains devices that you haven't seen before.": "\"%(RoomName)s\" contains devices that you haven't seen before.",
"Unknown devices": "Unknown devices",
- "Generate recovery key": "Generate recovery key",
- "I'll stick to manual backups": "I'll stick to manual backups",
- "Here is your recovery key:": "Here is your recovery key:",
- "This key can decrypt your full message history.": "This key can decrypt your full message history.",
- "When you've saved it somewhere safe, proceed to the next step where the key will be used to create an encrypted backup of your message keys and then destroyed.": "When you've saved it somewhere safe, proceed to the next step where the key will be used to create an encrypted backup of your message keys and then destroyed.",
+ "Secure your encrypted message history with a Recovery Passphrase.": "Secure your encrypted message history with a Recovery Passphrase.",
+ "You'll need it if you log out or lose access to this device.": "You'll need it if you log out or lose access to this device.",
+ "Enter a passphrase...": "Enter a passphrase...",
+ "Next": "Next",
+ "If you don't want encrypted message history to be availble on other devices, .": "If you don't want encrypted message history to be availble on other devices, .",
+ "Or, if you don't want to create a Recovery Passphrase, skip this step and .": "Or, if you don't want to create a Recovery Passphrase, skip this step and .",
+ "That matches!": "That matches!",
+ "That doesn't match.": "That doesn't match.",
+ "Go back to set it again.": "Go back to set it again.",
+ "Repeat your passphrase...": "Repeat your passphrase...",
+ "Make a copy of this Recovery Key and keep it safe.": "Make a copy of this Recovery Key and keep it safe.",
+ "As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.": "As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.",
+ "Your Recovery Key": "Your Recovery Key",
"Copy to clipboard": "Copy to clipboard",
- "Proceed": "Proceed",
+ "I've made a copy": "I've made a copy",
+ "Your Recovery Key has been copied to your clipboard, paste it to:": "Your Recovery Key has been copied to your clipboard, paste it to:",
+ "Print it and store it somewhere safe": "Print it and store it somewhere safe",
+ "Save it on a USB key or backup drive": "Save it on a USB key or backup drive",
+ "Copy it to your personal cloud storage": "Copy it to your personal cloud storage",
+ "Got it": "Got it",
"Backup created": "Backup created",
"Your encryption keys are now being backed up to your Homeserver.": "Your encryption keys are now being backed up to your Homeserver.",
+ "Set up Secure Message Recovery": "Set up Secure Message Recovery",
+ "Create a Recovery Passphrase": "Create a Recovery Passphrase",
+ "Confirm Recovery Passphrase": "Confirm Recovery Passphrase",
+ "Recovery Key": "Recovery Key",
+ "Keep it safe": "Keep it safe",
+ "Backing up...": "Backing up...",
+ "Create Key Backup": "Create Key Backup",
"Unable to create key backup": "Unable to create key backup",
"Retry": "Retry",
- "Generating recovery key...": "Generating recovery key...",
- "Creating backup...": "Creating backup...",
- "Uploading keys...": "Uploading keys...",
- "Create Key Backup": "Create Key Backup",
"Unable to load backup status": "Unable to load backup status",
"Unable to restore backup": "Unable to restore backup",
"No backup found!": "No backup found!",
@@ -1316,7 +1330,5 @@
"Import": "Import",
"Failed to set direct chat tag": "Failed to set direct chat tag",
"Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room",
- "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room",
- "Open Devtools": "Open Devtools",
- "Show developer tools": "Show developer tools"
+ "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room"
}
From 132408cf02512a90c97903714ee33c4217640ab6 Mon Sep 17 00:00:00 2001
From: David Baker
Date: Tue, 20 Nov 2018 16:16:24 +0000
Subject: [PATCH 20/26] Add e2e backup recovery with passphrase
---
res/css/_components.scss | 1 +
.../keybackup/_RestoreKeyBackupDialog.scss | 29 +++
.../keybackup/RestoreKeyBackupDialog.js | 170 ++++++++++++++++--
src/i18n/strings/en_EN.json | 10 +-
4 files changed, 188 insertions(+), 22 deletions(-)
create mode 100644 res/css/views/dialogs/keybackup/_RestoreKeyBackupDialog.scss
diff --git a/res/css/_components.scss b/res/css/_components.scss
index 039bcd545b..083071ef6c 100644
--- a/res/css/_components.scss
+++ b/res/css/_components.scss
@@ -47,6 +47,7 @@
@import "./views/dialogs/_ShareDialog.scss";
@import "./views/dialogs/_UnknownDeviceDialog.scss";
@import "./views/dialogs/keybackup/_CreateKeyBackupDialog.scss";
+@import "./views/dialogs/keybackup/_RestoreKeyBackupDialog.scss";
@import "./views/directory/_NetworkDropdown.scss";
@import "./views/elements/_AccessibleButton.scss";
@import "./views/elements/_AddressSelector.scss";
diff --git a/res/css/views/dialogs/keybackup/_RestoreKeyBackupDialog.scss b/res/css/views/dialogs/keybackup/_RestoreKeyBackupDialog.scss
new file mode 100644
index 0000000000..612c921038
--- /dev/null
+++ b/res/css/views/dialogs/keybackup/_RestoreKeyBackupDialog.scss
@@ -0,0 +1,29 @@
+/*
+Copyright 2018 New Vector Ltd
+
+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.
+*/
+
+.mx_RestoreKeyBackupDialog_primaryContainer {
+ /*FIXME: plinth colour in new theme(s). background-color: $accent-color;*/
+ padding: 20px
+}
+
+.mx_RestoreKeyBackupDialog_passPhraseInput,
+.mx_RestoreKeyBackupDialog_recoveryKeyInput {
+ width: 300px;
+ border: 1px solid $accent-color;
+ border-radius: 5px;
+ padding: 10px;
+}
+
diff --git a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
index 9e5e61cb1a..e4250814d0 100644
--- a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js
@@ -17,6 +17,7 @@ limitations under the License.
import React from 'react';
import sdk from '../../../../index';
import MatrixClientPeg from '../../../../MatrixClientPeg';
+import Modal from '../../../../Modal';
import { _t } from '../../../../languageHandler';
@@ -33,6 +34,9 @@ export default React.createClass({
recoveryKey: "",
recoverInfo: null,
recoveryKeyValid: false,
+ forceRecoveryKey: false,
+ passPhrase: '',
+ recoveryKey: '',
};
},
@@ -48,6 +52,18 @@ export default React.createClass({
this.props.onFinished(true);
},
+ _onUseRecoveryKeyClick: function() {
+ this.setState({
+ forceRecoveryKey: true,
+ });
+ },
+
+ _onResetRecoveryClick: function() {
+ this.props.onFinished(false);
+ const CreateKeyBackupDialog = sdk.getComponent("dialogs.keybackup.CreateKeyBackupDialog");
+ Modal.createTrackedDialog('Create Key Backup', '', CreateKeyBackupDialog, {});
+ },
+
_onRecoveryKeyChange: function(e) {
this.setState({
recoveryKey: e.target.value,
@@ -55,13 +71,35 @@ export default React.createClass({
});
},
- _onRecoverClick: async function() {
+ _onPassPhraseNext: async function() {
this.setState({
loading: true,
restoreError: null,
});
try {
- const recoverInfo = await MatrixClientPeg.get().restoreKeyBackups(
+ const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithPassword(
+ this.state.passPhrase, undefined, undefined, this.state.backupInfo.version,
+ );
+ this.setState({
+ loading: false,
+ recoverInfo,
+ });
+ } catch (e) {
+ console.log("Error restoring backup", e);
+ this.setState({
+ loading: false,
+ restoreError: e,
+ });
+ }
+ },
+
+ _onRecoveryKeyNext: async function() {
+ this.setState({
+ loading: true,
+ restoreError: null,
+ });
+ try {
+ const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithRecoveryKey(
this.state.recoveryKey, undefined, undefined, this.state.backupInfo.version,
);
this.setState({
@@ -77,6 +115,24 @@ export default React.createClass({
}
},
+ _onPassPhraseChange: function(e) {
+ this.setState({
+ passPhrase: e.target.value,
+ });
+ },
+
+ _onPassPhraseKeyPress: function(e) {
+ if (e.key === "Enter") {
+ this._onPassPhraseNext();
+ }
+ },
+
+ _onRecoveryKeyKeyPress: function(e) {
+ if (e.key === "Enter" && this.state.recoveryKeyValid) {
+ this._onRecoveryKeyNext();
+ }
+ },
+
_loadBackupStatus: async function() {
this.setState({
loading: true,
@@ -102,16 +158,29 @@ export default React.createClass({
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const Spinner = sdk.getComponent("elements.Spinner");
+ const backupHasPassphrase = (
+ this.state.backupInfo &&
+ this.state.backupInfo.auth_data &&
+ this.state.backupInfo.auth_data.private_key_salt &&
+ this.state.backupInfo.auth_data.private_key_iterations
+ );
+
let content;
+ let title;
if (this.state.loading) {
+ title = _t("Loading...");
content = ;
} else if (this.state.loadError) {
+ title = _t("Error");
content = _t("Unable to load backup status");
} else if (this.state.restoreError) {
+ title = _t("Error");
content = _t("Unable to restore backup");
} else if (this.state.backupInfo === null) {
+ title = _t("Error");
content = _t("No backup found!");
} else if (this.state.recoverInfo) {
+ title = _t("Backup Restored");
let failedToDecrypt;
if (this.state.recoverInfo.total > this.state.recoverInfo.imported) {
failedToDecrypt =
- {_t("Please enter the recovery key generated when you set up key backup")}
-
- {keyStatus}
-
+ {_t(
+ "Access your secure message history and set up secure " +
+ "messaging by entering your recovery key.",
+ )}
+
+
+
+ {keyStatus}
+
+
+ {_t(
+ "If you've forgotten your recovery passphrase you can "+
+ ""
+ , {}, {
+ button: s =>
+ {s}
+ ,
+ })}
;
}
return (
{content}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index cac9b4ef59..58e10ff149 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -1000,13 +1000,17 @@
"Unable to load backup status": "Unable to load backup status",
"Unable to restore backup": "Unable to restore backup",
"No backup found!": "No backup found!",
+ "Backup Restored": "Backup Restored",
"Failed to decrypt %(failedCount)s sessions!": "Failed to decrypt %(failedCount)s sessions!",
"Restored %(sessionCount)s session keys": "Restored %(sessionCount)s session keys",
+ "Enter Recovery Passphrase": "Enter Recovery Passphrase",
+ "Access your secure message history and set up secure messaging by entering your recovery passphrase.": "Access your secure message history and set up secure messaging by entering your recovery passphrase.",
+ "If you've forgotten your recovery passphrase you can use your recovery key or set up new recovery options": "If you've forgotten your recovery passphrase you can use your recovery key or set up new recovery options",
+ "Enter Recovery Key": "Enter Recovery Key",
"This looks like a valid recovery key!": "This looks like a valid recovery key!",
"Not a valid recovery key": "Not a valid recovery key",
- "Please enter the recovery key generated when you set up key backup": "Please enter the recovery key generated when you set up key backup",
- "Recover": "Recover",
- "Restore Key Backup": "Restore Key Backup",
+ "Access your secure message history and set up secure messaging by entering your recovery key.": "Access your secure message history and set up secure messaging by entering your recovery key.",
+ "If you've forgotten your recovery passphrase you can ": "If you've forgotten your recovery passphrase you can ",
"Private Chat": "Private Chat",
"Public Chat": "Public Chat",
"Custom": "Custom",
From 63a7ff5273185aca994ab5b3c3c6a2589ed6a354 Mon Sep 17 00:00:00 2001
From: David Baker
Date: Tue, 20 Nov 2018 16:20:31 +0000
Subject: [PATCH 21/26] lint
---
.../dialogs/keybackup/CreateKeyBackupDialog.js | 17 ++++++++++++++---
.../dialogs/keybackup/RestoreKeyBackupDialog.js | 1 -
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
index ad68e15293..aeb0c33b67 100644
--- a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
@@ -17,7 +17,6 @@ limitations under the License.
import React from 'react';
import sdk from '../../../../index';
import MatrixClientPeg from '../../../../MatrixClientPeg';
-import Promise from 'bluebird';
import { _t, _td } from '../../../../languageHandler';
@@ -196,7 +195,13 @@ export default React.createClass({
".",
{},
{
- button: sub => {sub},
+ button: sub =>
+ {sub}
+ ,
},
)}
+ {
+ // FIXME REDESIGN: buttons should be adjacent but insufficient room in current design
+ }
+
+
{this._keyBackupInfo.recovery_key}
+ copied to your clipboard, paste it to:",
+ {}, {b: s => {s}},
+ );
+ } else if (this.state.downloaded) {
+ introText = _t(
+ "Your Recovery Key is in your Downloads folder.",
+ {}, {b: s => {s}},
+ );
}
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index be713bdb37..20618e305e 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -986,8 +986,10 @@
"As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.": "As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.",
"Your Recovery Key": "Your Recovery Key",
"Copy to clipboard": "Copy to clipboard",
+ "Download": "Download",
"I've made a copy": "I've made a copy",
- "Your Recovery Key has been copied to your clipboard, paste it to:": "Your Recovery Key has been copied to your clipboard, paste it to:",
+ "Your Recovery Key has been copied to your clipboard, paste it to:": "Your Recovery Key has been copied to your clipboard, paste it to:",
+ "Your Recovery Key is in your Downloads folder.": "Your Recovery Key is in your Downloads folder.",
"Print it and store it somewhere safe": "Print it and store it somewhere safe",
"Save it on a USB key or backup drive": "Save it on a USB key or backup drive",
"Copy it to your personal cloud storage": "Copy it to your personal cloud storage",
From 08e2ba8c6c704aa1ad7e3aab76918ffbca3aa889 Mon Sep 17 00:00:00 2001
From: David Baker
Date: Wed, 21 Nov 2018 18:02:58 +0000
Subject: [PATCH 23/26] Don't allow enter to submit if field invalid
---
.../views/dialogs/keybackup/CreateKeyBackupDialog.js | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
index aeb0c33b67..eec4c9f414 100644
--- a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
@@ -122,7 +122,7 @@ export default React.createClass({
},
_onPassPhraseKeyPress: function(e) {
- if (e.key === 'Enter') {
+ if (e.key === 'Enter' && this._passPhraseIsValid()) {
this._onPassPhraseNextClick();
}
},
@@ -136,7 +136,7 @@ export default React.createClass({
},
_onPassPhraseConfirmKeyPress: function(e) {
- if (e.key === 'Enter') {
+ if (e.key === 'Enter' && this.state.passPhrase === this.state.passPhraseConfirm) {
this._onPassPhraseConfirmNextClick();
}
},
@@ -167,6 +167,10 @@ export default React.createClass({
});
},
+ _passPhraseIsValid: function() {
+ return this.state.passPhrase !== '';
+ },
+
_renderPhasePassPhrase: function() {
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
@@ -187,7 +191,7 @@ export default React.createClass({
- Type in your Recovery Passphrase to confirm you remember it.
- If it helps, add it to your password manager or store it
- somewhere safe.
-
+
{_t(
+ "Type in your Recovery Passphrase to confirm you remember it. " +
+ "If it helps, add it to your password manager or store it " +
+ "somewhere safe.",
+ )}
{passPhraseMatch}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index be713bdb37..ba2df1052a 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -981,6 +981,7 @@
"That matches!": "That matches!",
"That doesn't match.": "That doesn't match.",
"Go back to set it again.": "Go back to set it again.",
+ "Type in your Recovery Passphrase to confirm you remember it. If it helps, add it to your password manager or store it somewhere safe.": "Type in your Recovery Passphrase to confirm you remember it. If it helps, add it to your password manager or store it somewhere safe.",
"Repeat your passphrase...": "Repeat your passphrase...",
"Make a copy of this Recovery Key and keep it safe.": "Make a copy of this Recovery Key and keep it safe.",
"As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.": "As a safety net, you can use it to restore your encrypted message history if you forget your Recovery Passphrase.",
From 40ef2e0cf4d42f36d4ba51eef9b14d69c0efc42a Mon Sep 17 00:00:00 2001
From: David Baker
Date: Wed, 21 Nov 2018 18:08:44 +0000
Subject: [PATCH 25/26] another missed translation
---
.../views/dialogs/keybackup/CreateKeyBackupDialog.js | 6 ++++--
src/i18n/strings/en_EN.json | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
index 4a5ba67514..8601463e80 100644
--- a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
@@ -340,8 +340,10 @@ export default React.createClass({
_renderPhaseOptOutConfirm: function() {
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return
- Without setting up Secure Message Recovery, you won't be able to restore your
- encrypted message history if you log out or use another device.
+ {_t(
+ "Without setting up Secure Message Recovery, you won't be able to restore your " +
+ "encrypted message history if you log out or use another device."
+ )}
Date: Wed, 21 Nov 2018 18:17:26 +0000
Subject: [PATCH 26/26] lint
---
src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
index 8601463e80..a3ef8e7f19 100644
--- a/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
+++ b/src/components/views/dialogs/keybackup/CreateKeyBackupDialog.js
@@ -342,7 +342,7 @@ export default React.createClass({
return
{_t(
"Without setting up Secure Message Recovery, you won't be able to restore your " +
- "encrypted message history if you log out or use another device."
+ "encrypted message history if you log out or use another device.",
)}