Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add hidden button for bootstrapping SSSS
Browse files Browse the repository at this point in the history
This adds an testing button to the key backup panel which bootstraps the Secure
Secret Storage system (and also cross-signing keys).

Fixes element-hq/element-web#11212
  • Loading branch information
jryans committed Nov 20, 2019
1 parent c568c15 commit e6dea37
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
46 changes: 43 additions & 3 deletions src/components/views/settings/KeyBackupPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import sdk from '../../../index';
import MatrixClientPeg from '../../../MatrixClientPeg';
import { _t } from '../../../languageHandler';
import Modal from '../../../Modal';
import SettingsStore from '../../../../lib/settings/SettingsStore';

export default class KeyBackupPanel extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -124,6 +125,27 @@ export default class KeyBackupPanel extends React.PureComponent {
);
}

_bootstrapSecureSecretStorage = async () => {
try {
const InteractiveAuthDialog = sdk.getComponent("dialogs.InteractiveAuthDialog");
await MatrixClientPeg.get().bootstrapSecretStorage({
doInteractiveAuthFlow: async (makeRequest) => {
const { finished } = Modal.createTrackedDialog(
'Cross-signing keys dialog', '', InteractiveAuthDialog,
{
title: _t("Send cross-signing keys to homeserver"),
matrixClient: MatrixClientPeg.get(),
makeRequest,
},
);
await finished;
},
});
} catch (e) {
console.error(e);
}
}

_deleteBackup = () => {
const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog');
Modal.createTrackedDialog('Delete Backup', '', QuestionDialog, {
Expand Down Expand Up @@ -298,6 +320,21 @@ export default class KeyBackupPanel extends React.PureComponent {
</div>
</div>;
} else {
// This is a temporary button for testing SSSS. Initialising SSSS
// depends on cross-signing and is part of the same project, so we
// only show this mode when the cross-signing feature is enabled.
// TODO: Clean this up when removing the feature flag.
let bootstrapSecureSecretStorage;
if (SettingsStore.isFeatureEnabled("feature_cross_signing")) {
bootstrapSecureSecretStorage = (
<div className="mx_KeyBackupPanel_buttonRow">
<AccessibleButton kind="primary" onClick={this._bootstrapSecureSecretStorage}>
{_t("Bootstrap Secure Secret Storage (MSC1946)")}
</AccessibleButton>
</div>
);
}

return <div>
<div>
<p>{_t(
Expand All @@ -307,9 +344,12 @@ export default class KeyBackupPanel extends React.PureComponent {
<p>{encryptedMessageAreEncrypted}</p>
<p>{_t("Back up your keys before signing out to avoid losing them.")}</p>
</div>
<AccessibleButton kind="primary" onClick={this._startNewBackup}>
{ _t("Start using Key Backup") }
</AccessibleButton>
<div className="mx_KeyBackupPanel_buttonRow">
<AccessibleButton kind="primary" onClick={this._startNewBackup}>
{_t("Start using Key Backup")}
</AccessibleButton>
</div>
{bootstrapSecureSecretStorage}
</div>;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@
"Connecting to integrations server...": "Connecting to integrations server...",
"Cannot connect to integrations server": "Cannot connect to integrations server",
"The integrations server is offline or it cannot reach your homeserver.": "The integrations server is offline or it cannot reach your homeserver.",
"Send cross-signing keys to homeserver": "Send cross-signing keys to homeserver",
"Delete Backup": "Delete Backup",
"Are you sure? You will lose your encrypted messages if your keys are not backed up properly.": "Are you sure? You will lose your encrypted messages if your keys are not backed up properly.",
"Encrypted messages are secured with end-to-end encryption. Only you and the recipient(s) have the keys to read these messages.": "Encrypted messages are secured with end-to-end encryption. Only you and the recipient(s) have the keys to read these messages.",
Expand All @@ -533,6 +534,7 @@
"This backup is trusted because it has been restored on this device": "This backup is trusted because it has been restored on this device",
"Backup version: ": "Backup version: ",
"Algorithm: ": "Algorithm: ",
"Bootstrap Secure Secret Storage (MSC1946)": "Bootstrap Secure Secret Storage (MSC1946)",
"Your keys are <b>not being backed up from this device</b>.": "Your keys are <b>not being backed up from this device</b>.",
"Back up your keys before signing out to avoid losing them.": "Back up your keys before signing out to avoid losing them.",
"Start using Key Backup": "Start using Key Backup",
Expand Down

0 comments on commit e6dea37

Please sign in to comment.