From 0db81e4093b7fa36efa5fd25da1353f0a8070e6e Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Thu, 1 Oct 2020 21:41:03 -0400 Subject: [PATCH] add a feature flag for dehydration --- src/SecurityManager.js | 7 ++++--- src/settings/Settings.ts | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/SecurityManager.js b/src/SecurityManager.js index 323c0c3a4f..3272c0f015 100644 --- a/src/SecurityManager.js +++ b/src/SecurityManager.js @@ -24,6 +24,7 @@ import {encodeBase64} from "matrix-js-sdk/src/crypto/olmlib"; import { isSecureBackupRequired } from './utils/WellKnownUtils'; import AccessSecretStorageDialog from './components/views/dialogs/security/AccessSecretStorageDialog'; import RestoreKeyBackupDialog from './components/views/dialogs/security/RestoreKeyBackupDialog'; +import SettingsStore from "./settings/SettingsStore"; // This stores the secret storage private keys in memory for the JS SDK. This is // only meant to act as a cache to avoid prompting the user multiple times @@ -327,13 +328,13 @@ export async function accessSecretStorage(func = async () => { }, forceReset = f }); const keyId = Object.keys(secretStorageKeys)[0]; - if (keyId) { + if (keyId && SettingsStore.getValue("feature_dehydration")) { const dehydrationKeyInfo = secretStorageKeyInfo[keyId] && secretStorageKeyInfo[keyId].passphrase ? {passphrase: secretStorageKeyInfo[keyId].passphrase} : {}; console.log("Setting dehydration key"); - await cli.setDehydrationKey(secretStorageKeys[keyId], dehydrationKeyInfo); + await cli.setDehydrationKey(secretStorageKeys[keyId], dehydrationKeyInfo, "Backup device"); } else { console.log("Not setting dehydration key: no SSSS key found"); } @@ -369,7 +370,7 @@ export async function tryToUnlockSecretStorageWithDehydrationKey(client) { dehydrationCache.keyInfo && dehydrationCache.keyInfo.passphrase ? {passphrase: dehydrationCache.keyInfo.passphrase} : {}; - await client.setDehydrationKey(key, dehydrationKeyInfo); + await client.setDehydrationKey(key, dehydrationKeyInfo, "Backup device"); // and restore from backup const backupInfo = await client.getKeyBackupVersion(); diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 737c882919..a94ad24256 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -186,6 +186,12 @@ export const SETTINGS: {[setting: string]: ISetting} = { supportedLevels: LEVELS_FEATURE, default: false, }, + "feature_dehydration": { + isFeature: true, + displayName: _td("Offline encrypted messaging using dehydrated devices."), + supportedLevels: LEVELS_FEATURE, + default: false, + }, "advancedRoomListLogging": { // TODO: Remove flag before launch: https://github.com/vector-im/element-web/issues/14231 displayName: _td("Enable advanced debugging for the room list"),