add a feature flag for dehydration

pull/21833/head
Hubert Chathi 2020-10-01 21:41:03 -04:00
parent 503f32948c
commit 0db81e4093
2 changed files with 10 additions and 3 deletions

View File

@ -24,6 +24,7 @@ import {encodeBase64} from "matrix-js-sdk/src/crypto/olmlib";
import { isSecureBackupRequired } from './utils/WellKnownUtils'; import { isSecureBackupRequired } from './utils/WellKnownUtils';
import AccessSecretStorageDialog from './components/views/dialogs/security/AccessSecretStorageDialog'; import AccessSecretStorageDialog from './components/views/dialogs/security/AccessSecretStorageDialog';
import RestoreKeyBackupDialog from './components/views/dialogs/security/RestoreKeyBackupDialog'; 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 // 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 // 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]; const keyId = Object.keys(secretStorageKeys)[0];
if (keyId) { if (keyId && SettingsStore.getValue("feature_dehydration")) {
const dehydrationKeyInfo = const dehydrationKeyInfo =
secretStorageKeyInfo[keyId] && secretStorageKeyInfo[keyId].passphrase secretStorageKeyInfo[keyId] && secretStorageKeyInfo[keyId].passphrase
? {passphrase: secretStorageKeyInfo[keyId].passphrase} ? {passphrase: secretStorageKeyInfo[keyId].passphrase}
: {}; : {};
console.log("Setting dehydration key"); console.log("Setting dehydration key");
await cli.setDehydrationKey(secretStorageKeys[keyId], dehydrationKeyInfo); await cli.setDehydrationKey(secretStorageKeys[keyId], dehydrationKeyInfo, "Backup device");
} else { } else {
console.log("Not setting dehydration key: no SSSS key found"); console.log("Not setting dehydration key: no SSSS key found");
} }
@ -369,7 +370,7 @@ export async function tryToUnlockSecretStorageWithDehydrationKey(client) {
dehydrationCache.keyInfo && dehydrationCache.keyInfo.passphrase dehydrationCache.keyInfo && dehydrationCache.keyInfo.passphrase
? {passphrase: dehydrationCache.keyInfo.passphrase} ? {passphrase: dehydrationCache.keyInfo.passphrase}
: {}; : {};
await client.setDehydrationKey(key, dehydrationKeyInfo); await client.setDehydrationKey(key, dehydrationKeyInfo, "Backup device");
// and restore from backup // and restore from backup
const backupInfo = await client.getKeyBackupVersion(); const backupInfo = await client.getKeyBackupVersion();

View File

@ -186,6 +186,12 @@ export const SETTINGS: {[setting: string]: ISetting} = {
supportedLevels: LEVELS_FEATURE, supportedLevels: LEVELS_FEATURE,
default: false, default: false,
}, },
"feature_dehydration": {
isFeature: true,
displayName: _td("Offline encrypted messaging using dehydrated devices."),
supportedLevels: LEVELS_FEATURE,
default: false,
},
"advancedRoomListLogging": { "advancedRoomListLogging": {
// TODO: Remove flag before launch: https://github.com/vector-im/element-web/issues/14231 // TODO: Remove flag before launch: https://github.com/vector-im/element-web/issues/14231
displayName: _td("Enable advanced debugging for the room list"), displayName: _td("Enable advanced debugging for the room list"),