1
0
mirror of https://github.com/element-hq/element-web.git synced 2025-08-09 14:42:51 +03:00

Fix up UIA types and remove unused prop (#29255)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-02-17 09:53:26 +00:00
committed by GitHub
parent 52060235e4
commit dd2da5c132
7 changed files with 18 additions and 42 deletions

View File

@@ -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<IAddThreePidOnlyBody> | 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<IAddThreePidOnlyBody> | Error | null]> {
): Promise<[success?: boolean, result?: IAddThreePidOnlyBody | Error | null]> {
const authClient = new IdentityAuthClient();
if (this.submitUrl) {

View File

@@ -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<void> {
export async function uiAuthCallback(
matrixClient: MatrixClient,
makeRequest: (authData: AuthDict) => Promise<UIAResponse<void>>,
makeRequest: (authData: AuthDict) => Promise<void>,
): Promise<void> {
try {
await makeRequest({});

View File

@@ -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<IProp
});
};
private doBootstrapUIAuth = async (
makeRequest: (authData: AuthDict) => Promise<UIAResponse<void>>,
): Promise<void> => {
private doBootstrapUIAuth = async (makeRequest: (authData: AuthDict) => Promise<void>): Promise<void> => {
const dialogAesthetics = {
[SSOAuthEntry.PHASE_PREAUTH]: {
title: _t("auth|uia|sso_title"),

View File

@@ -27,13 +27,10 @@ import Spinner from "../views/elements/Spinner";
export const ERROR_USER_CANCELLED = new Error("User cancelled auth session");
type InteractiveAuthCallbackSuccess<T> = (
success: true,
response: T,
extra?: { emailSid?: string; clientSecret?: string },
) => Promise<void>;
type InteractiveAuthCallbackFailure = (success: false, response: IAuthData | Error) => Promise<void>;
export type InteractiveAuthCallback<T> = InteractiveAuthCallbackSuccess<T> & InteractiveAuthCallbackFailure;
export type InteractiveAuthCallback<T> = {
(success: true, response: T, extra?: { emailSid?: string; clientSecret?: string }): Promise<void>;
(success: false, response: IAuthData | Error): Promise<void>;
};
export interface InteractiveAuthProps<T> {
// matrix client to use for UI auth requests
@@ -49,10 +46,6 @@ export interface InteractiveAuthProps<T> {
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<T> extends React.Component<Interac
stageState={this.state.stageState}
fail={this.onAuthStageFailed}
setEmailSid={this.setEmailSid}
showContinue={!this.props.continueIsManaged}
onPhaseChange={this.onPhaseChange}
requestEmailToken={this.authLogic.requestEmailToken}
continueText={this.props.continueText}

View File

@@ -85,7 +85,6 @@ interface IAuthEntryProps {
requestEmailToken?: () => Promise<void>;
fail: (error: Error) => void;
clientSecret: string;
showContinue: boolean;
}
interface IPasswordAuthEntryState {
@@ -361,9 +360,11 @@ export class TermsAuthEntry extends React.Component<ITermsAuthEntryProps, ITerms
);
}
let submitButton: JSX.Element | undefined;
if (this.props.showContinue !== false) {
submitButton = (
return (
<div className="mx_InteractiveAuthEntryComponents">
<p>{_t("auth|uia|terms")}</p>
{checkboxes}
{errorSection}
<AccessibleButton
kind="primary"
className="mx_InteractiveAuthEntryComponents_termsSubmit"
@@ -372,15 +373,6 @@ export class TermsAuthEntry extends React.Component<ITermsAuthEntryProps, ITerms
>
{_t("action|accept")}
</AccessibleButton>
);
}
return (
<div className="mx_InteractiveAuthEntryComponents">
<p>{_t("auth|uia|terms")}</p>
{checkboxes}
{errorSection}
{submitButton}
</div>
);
}

View File

@@ -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<T = unknown>
// Default is defined in _getDefaultDialogAesthetics()
aestheticsForStagePhases?: DialogAesthetics;
onFinished(success?: boolean, result?: UIAResponse<T> | Error | null): void;
onFinished(success?: boolean, result?: T | Error | null): void;
}
interface IState {
@@ -111,7 +111,7 @@ export default class InteractiveAuthDialog<T> extends React.Component<Interactiv
private onAuthFinished: InteractiveAuthCallback<T> = async (success, result): Promise<void> => {
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);

View File

@@ -31,7 +31,6 @@ describe("<EmailIdentityAuthEntry/>", () => {
submitAuthDict={jest.fn()}
fail={jest.fn()}
clientSecret="my secret"
showContinue={true}
inputs={{ emailAddress: "alice@example.xyz" }}
/>,
);
@@ -73,7 +72,6 @@ describe("<MasUnlockCrossSigningAuthEntry/>", () => {
submitAuthDict={jest.fn()}
fail={jest.fn()}
clientSecret="my secret"
showContinue={true}
stageParams={{ url: "https://example.com" }}
{...props}
/>,
@@ -114,7 +112,6 @@ describe("<TermsAuthEntry/>", () => {
submitAuthDict={jest.fn()}
fail={jest.fn()}
clientSecret="my secret"
showContinue={true}
stageParams={{
policies: {
test_policy: policy,