From 5d62d6cf7fd1eb2046b2e5f3b147b1c8dcc19fe8 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 5 Feb 2025 18:00:08 +0000 Subject: [PATCH 1/5] CreateSecretStorageDialog: remove unused state `accountPasswordCorrect` This was never set to anything other than `null`, and never read. --- .../views/dialogs/security/CreateSecretStorageDialog.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx index 5d40967bb4e..8e547f9db36 100644 --- a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx @@ -81,7 +81,6 @@ interface IState { // for /keys/device_signing/upload? canUploadKeysWithPasswordOnly: boolean | null; accountPassword: string; - accountPasswordCorrect: boolean | null; canSkip: boolean; passPhraseKeySelected: string; error?: boolean; @@ -140,7 +139,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent Date: Wed, 5 Feb 2025 18:33:53 +0000 Subject: [PATCH 2/5] CreateSecretStorageDialog: remove unused prop `accountPassword` This was never set, so we may as well remove it. --- .../security/CreateSecretStorageDialog.tsx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx index 8e547f9db36..e9007ad73ff 100644 --- a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx @@ -62,7 +62,6 @@ const PASSWORD_MIN_SCORE = 4; // So secure, many characters, much complex, wow, interface IProps { hasCancel?: boolean; - accountPassword?: string; forceReset?: boolean; resetCrossSigning?: boolean; onFinished(ok?: boolean): void; @@ -116,16 +115,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent Date: Wed, 5 Feb 2025 18:01:50 +0000 Subject: [PATCH 3/5] CreateSecretStorageDialog: remove unused state `accountPassword` This is now no longer set to anything other than `""`. --- .../security/CreateSecretStorageDialog.tsx | 67 ++++++++----------- 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx index e9007ad73ff..45a91645db7 100644 --- a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx @@ -79,7 +79,6 @@ interface IState { // does the server offer a UI auth flow with just m.login.password // for /keys/device_signing/upload? canUploadKeysWithPasswordOnly: boolean | null; - accountPassword: string; canSkip: boolean; passPhraseKeySelected: string; error?: boolean; @@ -131,7 +130,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent Promise>, ): Promise => { - if (this.state.canUploadKeysWithPasswordOnly && this.state.accountPassword) { - await makeRequest({ - type: "m.login.password", - identifier: { - type: "m.id.user", - user: MatrixClientPeg.safeGet().getSafeUserId(), - }, - password: this.state.accountPassword, - }); - } else { - const dialogAesthetics = { - [SSOAuthEntry.PHASE_PREAUTH]: { - title: _t("auth|uia|sso_title"), - body: _t("auth|uia|sso_preauth_body"), - continueText: _t("auth|sso"), - continueKind: "primary", - }, - [SSOAuthEntry.PHASE_POSTAUTH]: { - title: _t("encryption|confirm_encryption_setup_title"), - body: _t("encryption|confirm_encryption_setup_body"), - continueText: _t("action|confirm"), - continueKind: "primary", - }, - }; - - const { finished } = Modal.createDialog(InteractiveAuthDialog, { - title: _t("encryption|bootstrap_title"), - matrixClient: MatrixClientPeg.safeGet(), - makeRequest, - aestheticsForStagePhases: { - [SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics, - [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics, - }, - }); - const [confirmed] = await finished; - if (!confirmed) { - throw new Error("Cross-signing key upload auth canceled"); - } + const dialogAesthetics = { + [SSOAuthEntry.PHASE_PREAUTH]: { + title: _t("auth|uia|sso_title"), + body: _t("auth|uia|sso_preauth_body"), + continueText: _t("auth|sso"), + continueKind: "primary", + }, + [SSOAuthEntry.PHASE_POSTAUTH]: { + title: _t("encryption|confirm_encryption_setup_title"), + body: _t("encryption|confirm_encryption_setup_body"), + continueText: _t("action|confirm"), + continueKind: "primary", + }, + }; + + const { finished } = Modal.createDialog(InteractiveAuthDialog, { + title: _t("encryption|bootstrap_title"), + matrixClient: MatrixClientPeg.safeGet(), + makeRequest, + aestheticsForStagePhases: { + [SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics, + [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics, + }, + }); + const [confirmed] = await finished; + if (!confirmed) { + throw new Error("Cross-signing key upload auth canceled"); } }; From bc604df40ee63fa363c0097d4275526091c65f4b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 5 Feb 2025 18:05:12 +0000 Subject: [PATCH 4/5] CreateSecretStorageDialog: remove unused state `canUploadKeysWithPasswordOnly` This is no longer read, so let's remove the code that populates it. --- .../security/CreateSecretStorageDialog.tsx | 37 +------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx index 45a91645db7..294297a226e 100644 --- a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx @@ -10,13 +10,7 @@ Please see LICENSE files in the repository root for full details. import React, { createRef } from "react"; import FileSaver from "file-saver"; import { logger } from "matrix-js-sdk/src/logger"; -import { - type AuthDict, - type CrossSigningKeys, - MatrixError, - type UIAFlow, - type UIAResponse, -} from "matrix-js-sdk/src/matrix"; +import { type AuthDict, type UIAResponse } from "matrix-js-sdk/src/matrix"; import { type GeneratedSecretStorageKey } from "matrix-js-sdk/src/crypto-api"; import classNames from "classnames"; import CheckmarkIcon from "@vector-im/compound-design-tokens/assets/web/icons/check"; @@ -76,9 +70,6 @@ interface IState { downloaded: boolean; setPassphrase: boolean; - // does the server offer a UI auth flow with just m.login.password - // for /keys/device_signing/upload? - canUploadKeysWithPasswordOnly: boolean | null; canSkip: boolean; passPhraseKeySelected: string; error?: boolean; @@ -128,7 +119,6 @@ export default class CreateSecretStorageDialog extends React.PureComponent { - try { - await MatrixClientPeg.safeGet().uploadDeviceSigningKeys(undefined, {} as CrossSigningKeys); - // We should never get here: the server should always require - // UI auth to upload device signing keys. If we do, we upload - // no keys which would be a no-op. - logger.log("uploadDeviceSigningKeys unexpectedly succeeded without UI auth!"); - } catch (error) { - if (!(error instanceof MatrixError) || !error.data || !error.data.flows) { - logger.log("uploadDeviceSigningKeys advertised no flows!"); - return; - } - const canUploadKeysWithPasswordOnly = error.data.flows.some((f: UIAFlow) => { - return f.stages.length === 1 && f.stages[0] === "m.login.password"; - }); - this.setState({ - canUploadKeysWithPasswordOnly, - }); - } - } - private onKeyPassphraseChange = (e: React.ChangeEvent): void => { this.setState({ passPhraseKeySelected: e.target.value, From 7e2e6d6e1f9917e733f5b31ceab3d4b302255dd7 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 5 Feb 2025 18:08:46 +0000 Subject: [PATCH 5/5] CreateSecretStorageDialog: remove unused prop `hasCancel` This is never set, so may as well remove --- .../views/dialogs/security/CreateSecretStorageDialog.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx index 294297a226e..917286ee057 100644 --- a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx @@ -55,7 +55,6 @@ enum Phase { const PASSWORD_MIN_SCORE = 4; // So secure, many characters, much complex, wow, etc, etc. interface IProps { - hasCancel?: boolean; forceReset?: boolean; resetCrossSigning?: boolean; onFinished(ok?: boolean): void; @@ -84,7 +83,6 @@ interface IState { */ export default class CreateSecretStorageDialog extends React.PureComponent { public static defaultProps: Partial = { - hasCancel: true, forceReset: false, resetCrossSigning: false, }; @@ -750,7 +748,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent
{content}