From 26c9b64c3b6f856b99778695dde20a809e765487 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 31 Jan 2020 10:35:05 +0000 Subject: [PATCH 1/2] Log exceptions from accessSecretStorage Rather than ignoring everything assuming the user cancelled --- src/CrossSigningManager.js | 8 +++++++- src/components/structures/auth/CompleteSecurity.js | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/CrossSigningManager.js b/src/CrossSigningManager.js index 085764214f..d41580c292 100644 --- a/src/CrossSigningManager.js +++ b/src/CrossSigningManager.js @@ -29,6 +29,12 @@ import { _t } from './languageHandler'; let secretStorageKeys = {}; let cachingAllowed = false; +export class AccessCancelledError extends Error { + constructor() { + super("Secret storage access canceled"); + } +} + async function getSecretStorageKey({ keys: keyInfos }) { const keyInfoEntries = Object.entries(keyInfos); if (keyInfoEntries.length > 1) { @@ -66,7 +72,7 @@ async function getSecretStorageKey({ keys: keyInfos }) { ); const [input] = await finished; if (!input) { - throw new Error("Secret storage access canceled"); + throw new AccessCancelledError(); } const key = await inputToKey(input); diff --git a/src/components/structures/auth/CompleteSecurity.js b/src/components/structures/auth/CompleteSecurity.js index 66834deb2c..6d4abb0607 100644 --- a/src/components/structures/auth/CompleteSecurity.js +++ b/src/components/structures/auth/CompleteSecurity.js @@ -19,7 +19,7 @@ import PropTypes from 'prop-types'; import { _t } from '../../../languageHandler'; import * as sdk from '../../../index'; import { MatrixClientPeg } from '../../../MatrixClientPeg'; -import { accessSecretStorage } from '../../../CrossSigningManager'; +import { accessSecretStorage, AccessCancelledError } from '../../../CrossSigningManager'; const PHASE_INTRO = 0; const PHASE_BUSY = 1; @@ -73,6 +73,9 @@ export default class CompleteSecurity extends React.Component { }); } } catch (e) { + if (!e instanceof AccessCancelledError) { + console.log(e); + } // this will throw if the user hits cancel, so ignore this.setState({ phase: PHASE_INTRO, From ea7f160950c335810cbded6bfd00ff1a45aee01c Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 31 Jan 2020 10:38:20 +0000 Subject: [PATCH 2/2] lint --- src/components/structures/auth/CompleteSecurity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/auth/CompleteSecurity.js b/src/components/structures/auth/CompleteSecurity.js index 6d4abb0607..e7071bee0c 100644 --- a/src/components/structures/auth/CompleteSecurity.js +++ b/src/components/structures/auth/CompleteSecurity.js @@ -73,7 +73,7 @@ export default class CompleteSecurity extends React.Component { }); } } catch (e) { - if (!e instanceof AccessCancelledError) { + if (!(e instanceof AccessCancelledError)) { console.log(e); } // this will throw if the user hits cancel, so ignore