From a8db02ff0253332fd532719a2fe19ddae49a5be9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Nov 2018 11:31:46 +0000 Subject: [PATCH 1/5] Handle crypto db version upgrade Display a dialog telling the user what the situation is with options to sign out or continue withwout e2e. Requires https://github.com/matrix-org/matrix-js-sdk/pull/785 --- src/MatrixClientPeg.js | 10 ++++++++++ src/i18n/strings/en_EN.json | 18 +++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 04b3b47e43..9a77901d2e 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -23,10 +23,12 @@ import Matrix from 'matrix-js-sdk'; import utils from 'matrix-js-sdk/lib/utils'; import EventTimeline from 'matrix-js-sdk/lib/models/event-timeline'; import EventTimelineSet from 'matrix-js-sdk/lib/models/event-timeline-set'; +import sdk from './index'; import createMatrixClient from './utils/createMatrixClient'; import SettingsStore from './settings/SettingsStore'; import MatrixActionCreators from './actions/MatrixActionCreators'; import {phasedRollOutExpiredForUser} from "./PhasedRollOut"; +import Modal from './Modal'; interface MatrixClientCreds { homeserverUrl: string, @@ -116,6 +118,14 @@ class MatrixClientPeg { await this.matrixClient.initCrypto(); } } catch (e) { + if (e.name === 'InvalidCryptoStoreError') { + // The js-sdk found a crypto DB too new for it to use + const CryptoStoreTooNewDialog = + sdk.getComponent("views.dialogs.CryptoStoreTooNewDialog"); + Modal.createDialog(CryptoStoreTooNewDialog, { + host: window.location.host, + }); + } // this can happen for a number of reasons, the most likely being // that the olm library was missing. It's not fatal. console.warn("Unable to initialise e2e: " + e); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 572cc0d2b3..06f834503b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -249,10 +249,11 @@ "Enable URL previews for this room (only affects you)": "Enable URL previews for this room (only affects you)", "Enable URL previews by default for participants in this room": "Enable URL previews by default for participants in this room", "Room Colour": "Room Colour", - "Pin unread rooms to the top of the room list": "Pin unread rooms to the top of the room list", "Pin rooms I'm mentioned in to the top of the room list": "Pin rooms I'm mentioned in to the top of the room list", + "Pin unread rooms to the top of the room list": "Pin unread rooms to the top of the room list", "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", @@ -553,6 +554,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", @@ -849,6 +851,11 @@ "Advanced options": "Advanced options", "Block users on other matrix homeservers from joining this room": "Block users on other matrix homeservers from joining this room", "This setting cannot be changed later!": "This setting cannot be changed later!", + "Sign out": "Sign out", + "To avoid losing your chat history, you must export your room keys before logging out. You will need to go back to the newer version of Riot to do this": "To avoid losing your chat history, you must export your room keys before logging out. You will need to go back to the newer version of Riot to do this", + "You've previously used a newer version of Riot on %(host)s. To use this version again with end to end encryption, you will need to sign out and back in again. ": "You've previously used a newer version of Riot on %(host)s. To use this version again with end to end encryption, you will need to sign out and back in again. ", + "Incompatible Database": "Incompatible Database", + "Continue With Encryption Disabled": "Continue With Encryption Disabled", "Failed to indicate account erasure": "Failed to indicate account erasure", "Unknown error": "Unknown error", "Incorrect password": "Incorrect password", @@ -903,7 +910,6 @@ "Update any local room aliases to point to the new room": "Update any local room aliases to point to the new room", "Stop users from speaking in the old version of the room, and post a message advising users to move to the new room": "Stop users from speaking in the old version of the room, and post a message advising users to move to the new room", "Put a link back to the old room at the start of the new room so people can see old messages": "Put a link back to the old room at the start of the new room so people can see old messages", - "Sign out": "Sign out", "Log out and remove encryption keys?": "Log out and remove encryption keys?", "Clear Storage and Sign Out": "Clear Storage and Sign Out", "Send Logs": "Send Logs", @@ -927,9 +933,7 @@ "Username available": "Username available", "To get started, please pick a username!": "To get started, please pick a username!", "This will be your account name on the homeserver, or you can pick a different server.": "This will be your account name on the homeserver, or you can pick a different server.", - "If you would like to create a Matrix account you can register now.": "If you would like to create a Matrix account you can register now.", "If you already have a Matrix account you can log in instead.": "If you already have a Matrix account you can log in instead.", - "You are currently using Riot anonymously as a guest.": "You are currently using Riot anonymously as a guest.", "You have successfully set a password!": "You have successfully set a password!", "You have successfully set a password and an email address!": "You have successfully set a password and an email address!", "You can now return to your account after signing out, and sign in on other devices.": "You can now return to your account after signing out, and sign in on other devices.", @@ -1036,6 +1040,8 @@ "This Home server does not support communities": "This Home server does not support communities", "Failed to load %(groupId)s": "Failed to load %(groupId)s", "Couldn't load home page": "Couldn't load home page", + "You are currently using Riot anonymously as a guest.": "You are currently using Riot anonymously as a guest.", + "If you would like to create a Matrix account you can register now.": "If you would like to create a Matrix account you can register now.", "Login": "Login", "Failed to reject invitation": "Failed to reject invitation", "This room is not public. You will not be able to rejoin without an invite.": "This room is not public. You will not be able to rejoin without an invite.", @@ -1272,7 +1278,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 ab40a0b264e90b51024df3a88e35cc413109b635 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Nov 2018 11:33:09 +0000 Subject: [PATCH 2/5] Actually add the dialog --- .../views/dialogs/CryptoStoreTooNewDialog.js | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/components/views/dialogs/CryptoStoreTooNewDialog.js diff --git a/src/components/views/dialogs/CryptoStoreTooNewDialog.js b/src/components/views/dialogs/CryptoStoreTooNewDialog.js new file mode 100644 index 0000000000..0146420f46 --- /dev/null +++ b/src/components/views/dialogs/CryptoStoreTooNewDialog.js @@ -0,0 +1,71 @@ +/* +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 sdk from '../../../index'; +import dis from '../../../dispatcher'; +import { _t } from '../../../languageHandler'; +import Modal from '../../../Modal'; + +export default (props) => { + const _onLogoutClicked = () => { + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + Modal.createTrackedDialog('Logout e2e db too new', '', QuestionDialog, { + title: _t("Sign out"), + description: _t( + "To avoid losing your chat history, you must export your room keys " + + "before logging out. You will need to go back to the newer version of " + + "Riot to do this", + ), + button: _t("Sign out"), + focus: false, + onFinished: (doLogout) => { + if (doLogout) { + dis.dispatch({action: 'logout'}); + props.onFinished(); + } + }, + }); + }; + + const description = + _t("You've previously used a newer version of Riot on %(host)s. " + + "To use this version again with end to end encryption, you will " + + "need to sign out and back in again. ", + {host: props.host}, + ); + + const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); + const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); + return ( +
+ { description } +
+ + + +
); +}; From a25ae924b12d32a04237eb156a9f1e3286298b88 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Nov 2018 16:49:20 +0000 Subject: [PATCH 3/5] js-sdk v0.14.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d2e54a2621..bf44460f80 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "linkifyjs": "^2.1.6", "lodash": "^4.13.1", "lolex": "2.3.2", - "matrix-js-sdk": "0.14.0", + "matrix-js-sdk": "0.14.1", "optimist": "^0.6.1", "pako": "^1.0.5", "prop-types": "^15.5.8", From e27a4af8179fc40c67c487dfda5e86c39e5f379b Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Nov 2018 16:54:21 +0000 Subject: [PATCH 4/5] Prepare changelog for v0.14.6 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1486578025..eea47dcb8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Changes in [0.14.6](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.14.6) (2018-11-22) +===================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.14.5...v0.14.6) + + * Warning when crypto DB is too new to use. + Changes in [0.14.5](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.14.5) (2018-11-19) ===================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.14.5-rc.2...v0.14.5) From 60e22b7e0fdf7a117357b6a8813935c57cf2a090 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Nov 2018 16:54:53 +0000 Subject: [PATCH 5/5] v0.14.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf44460f80..b356c72d03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "0.14.5", + "version": "0.14.6", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": {