Skip to content

Commit

Permalink
Enable key backup by default
Browse files Browse the repository at this point in the history
When we set up cross signing, so the key backup key will be stored
locally along with the cross signing keys until the user sets up
recovery (4s). This will mean that a user can restore their backup
if they log in on a new device as long as they verify with the one
they registered on.
  • Loading branch information
dbkr committed Oct 22, 2024
1 parent d4cf388 commit 2c72477
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/structures/auth/E2eSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix";

import AuthPage from "../../views/auth/AuthPage";
import CompleteSecurityBody from "../../views/auth/CompleteSecurityBody";
import CreateCrossSigningDialog from "../../views/dialogs/security/CreateCrossSigningDialog";
import InitialCryptoSetup from "../../views/dialogs/security/InitialCryptoSetup";

interface IProps {
matrixClient: MatrixClient;
Expand All @@ -25,7 +25,7 @@ export default class E2eSetup extends React.Component<IProps> {
return (
<AuthPage>
<CompleteSecurityBody>
<CreateCrossSigningDialog
<InitialCryptoSetup
matrixClient={this.props.matrixClient}
onFinished={this.props.onFinished}
accountPassword={this.props.accountPassword}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,27 @@ interface Props {
}

/*
* Walks the user through the process of creating a cross-signing keys. In most
* cases, only a spinner is shown, but for more complex auth like SSO, the user
* may need to complete some steps to proceed.
* Walks the user through the process of creating a cross-signing keys and setting
* up message key backup. In most cases, only a spinner is shown, but for more
* complex auth like SSO, the user may need to complete some steps to proceed.
*/
const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPassword, tokenLogin, onFinished }) => {
const InitialCryptoSetup: React.FC<Props> = ({ matrixClient, accountPassword, tokenLogin, onFinished }) => {
const [error, setError] = useState(false);

const bootstrapCrossSigning = useCallback(async () => {
const doSetup = useCallback(async () => {
const cryptoApi = matrixClient.getCrypto();
if (!cryptoApi) return;

setError(false);

try {
await createCrossSigning(matrixClient, tokenLogin, accountPassword);

const backupInfo = await matrixClient.getKeyBackupVersion();
if (backupInfo === null) {
await cryptoApi.resetKeyBackup();
}

onFinished(true);
} catch (e) {
if (tokenLogin) {
Expand All @@ -58,8 +64,8 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
}, [onFinished]);

useEffect(() => {
bootstrapCrossSigning();
}, [bootstrapCrossSigning]);
doSetup();
}, [doSetup]);

let content;
if (error) {
Expand All @@ -69,7 +75,7 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
<div className="mx_Dialog_buttons">
<DialogButtons
primaryButton={_t("action|retry")}
onPrimaryButtonClick={bootstrapCrossSigning}
onPrimaryButtonClick={doSetup}
onCancel={onCancel}
/>
</div>
Expand All @@ -96,4 +102,4 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
);
};

export default CreateCrossSigningDialog;
export default InitialCryptoSetup;

0 comments on commit 2c72477

Please sign in to comment.