diff --git a/src/AddThreepid.ts b/src/AddThreepid.ts index 8924399886..7d2c4cefb5 100644 --- a/src/AddThreepid.ts +++ b/src/AddThreepid.ts @@ -16,7 +16,6 @@ import { MatrixError, HTTPError, type IThreepid, - type UIAResponse, } from "matrix-js-sdk/src/matrix"; import Modal from "./Modal"; @@ -181,9 +180,7 @@ export default class AddThreepid { * with a "message" property which contains a human-readable message detailing why * the request failed. */ - public async checkEmailLinkClicked(): Promise< - [success?: boolean, result?: UIAResponse | Error | null] - > { + public async checkEmailLinkClicked(): Promise<[success?: boolean, result?: IAddThreePidOnlyBody | Error | null]> { try { if (this.bind) { const authClient = new IdentityAuthClient(); @@ -270,7 +267,7 @@ export default class AddThreepid { */ public async haveMsisdnToken( msisdnToken: string, - ): Promise<[success?: boolean, result?: UIAResponse | Error | null]> { + ): Promise<[success?: boolean, result?: IAddThreePidOnlyBody | Error | null]> { const authClient = new IdentityAuthClient(); if (this.submitUrl) { diff --git a/src/CreateCrossSigning.ts b/src/CreateCrossSigning.ts index cb1eb528af..db9bc3e3fe 100644 --- a/src/CreateCrossSigning.ts +++ b/src/CreateCrossSigning.ts @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import { type AuthDict, type MatrixClient, MatrixError, type UIAResponse } from "matrix-js-sdk/src/matrix"; +import { type AuthDict, type MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix"; import { SSOAuthEntry } from "./components/views/auth/InteractiveAuthEntryComponents"; import Modal from "./Modal"; @@ -38,7 +38,7 @@ export async function createCrossSigning(cli: MatrixClient): Promise { export async function uiAuthCallback( matrixClient: MatrixClient, - makeRequest: (authData: AuthDict) => Promise>, + makeRequest: (authData: AuthDict) => Promise, ): Promise { try { await makeRequest({}); diff --git a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx index daefa267bc..2bcf577d9f 100644 --- a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx @@ -10,7 +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 UIAResponse } from "matrix-js-sdk/src/matrix"; +import { type AuthDict } 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"; @@ -177,9 +177,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent Promise>, - ): Promise => { + private doBootstrapUIAuth = async (makeRequest: (authData: AuthDict) => Promise): Promise => { const dialogAesthetics = { [SSOAuthEntry.PHASE_PREAUTH]: { title: _t("auth|uia|sso_title"), diff --git a/src/components/structures/InteractiveAuth.tsx b/src/components/structures/InteractiveAuth.tsx index f9c389679c..d1c670c27c 100644 --- a/src/components/structures/InteractiveAuth.tsx +++ b/src/components/structures/InteractiveAuth.tsx @@ -27,13 +27,10 @@ import Spinner from "../views/elements/Spinner"; export const ERROR_USER_CANCELLED = new Error("User cancelled auth session"); -type InteractiveAuthCallbackSuccess = ( - success: true, - response: T, - extra?: { emailSid?: string; clientSecret?: string }, -) => Promise; -type InteractiveAuthCallbackFailure = (success: false, response: IAuthData | Error) => Promise; -export type InteractiveAuthCallback = InteractiveAuthCallbackSuccess & InteractiveAuthCallbackFailure; +export type InteractiveAuthCallback = { + (success: true, response: T, extra?: { emailSid?: string; clientSecret?: string }): Promise; + (success: false, response: IAuthData | Error): Promise; +}; export interface InteractiveAuthProps { // matrix client to use for UI auth requests @@ -49,10 +46,6 @@ export interface InteractiveAuthProps { emailSid?: string; // If true, poll to see if the auth flow has been completed out-of-band poll?: boolean; - // If true, components will be told that the 'Continue' button - // is managed by some other party and should not be managed by - // the component itself. - continueIsManaged?: boolean; // continueText and continueKind are passed straight through to the AuthEntryComponent. continueText?: string; continueKind?: ContinueKind; @@ -288,7 +281,6 @@ export default class InteractiveAuthComponent extends React.Component Promise; fail: (error: Error) => void; clientSecret: string; - showContinue: boolean; } interface IPasswordAuthEntryState { @@ -361,9 +360,11 @@ export class TermsAuthEntry extends React.Component +

{_t("auth|uia|terms")}

+ {checkboxes} + {errorSection} {_t("action|accept")} - ); - } - - return ( -
-

{_t("auth|uia|terms")}

- {checkboxes} - {errorSection} - {submitButton}
); } diff --git a/src/components/views/dialogs/InteractiveAuthDialog.tsx b/src/components/views/dialogs/InteractiveAuthDialog.tsx index 8ba67bcc5d..5800153fed 100644 --- a/src/components/views/dialogs/InteractiveAuthDialog.tsx +++ b/src/components/views/dialogs/InteractiveAuthDialog.tsx @@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details. */ import React from "react"; -import { type MatrixClient, type UIAResponse } from "matrix-js-sdk/src/matrix"; +import { type MatrixClient } from "matrix-js-sdk/src/matrix"; import { type AuthType } from "matrix-js-sdk/src/interactive-auth"; import { _t } from "../../../languageHandler"; @@ -63,7 +63,7 @@ export interface InteractiveAuthDialogProps // Default is defined in _getDefaultDialogAesthetics() aestheticsForStagePhases?: DialogAesthetics; - onFinished(success?: boolean, result?: UIAResponse | Error | null): void; + onFinished(success?: boolean, result?: T | Error | null): void; } interface IState { @@ -111,7 +111,7 @@ export default class InteractiveAuthDialog extends React.Component = async (success, result): Promise => { if (success) { - this.props.onFinished(true, result); + this.props.onFinished(true, result as T); } else { if (result === ERROR_USER_CANCELLED) { this.props.onFinished(false, null); diff --git a/test/unit-tests/components/views/auth/InteractiveAuthEntryComponents-test.tsx b/test/unit-tests/components/views/auth/InteractiveAuthEntryComponents-test.tsx index adba9d1f75..4768eed4dc 100644 --- a/test/unit-tests/components/views/auth/InteractiveAuthEntryComponents-test.tsx +++ b/test/unit-tests/components/views/auth/InteractiveAuthEntryComponents-test.tsx @@ -31,7 +31,6 @@ describe("", () => { submitAuthDict={jest.fn()} fail={jest.fn()} clientSecret="my secret" - showContinue={true} inputs={{ emailAddress: "alice@example.xyz" }} />, ); @@ -73,7 +72,6 @@ describe("", () => { submitAuthDict={jest.fn()} fail={jest.fn()} clientSecret="my secret" - showContinue={true} stageParams={{ url: "https://example.com" }} {...props} />, @@ -114,7 +112,6 @@ describe("", () => { submitAuthDict={jest.fn()} fail={jest.fn()} clientSecret="my secret" - showContinue={true} stageParams={{ policies: { test_policy: policy,