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, MatrixError,
HTTPError, HTTPError,
type IThreepid, type IThreepid,
type UIAResponse,
} from "matrix-js-sdk/src/matrix"; } from "matrix-js-sdk/src/matrix";
import Modal from "./Modal"; import Modal from "./Modal";
@@ -181,9 +180,7 @@ export default class AddThreepid {
* with a "message" property which contains a human-readable message detailing why * with a "message" property which contains a human-readable message detailing why
* the request failed. * the request failed.
*/ */
public async checkEmailLinkClicked(): Promise< public async checkEmailLinkClicked(): Promise<[success?: boolean, result?: IAddThreePidOnlyBody | Error | null]> {
[success?: boolean, result?: UIAResponse<IAddThreePidOnlyBody> | Error | null]
> {
try { try {
if (this.bind) { if (this.bind) {
const authClient = new IdentityAuthClient(); const authClient = new IdentityAuthClient();
@@ -270,7 +267,7 @@ export default class AddThreepid {
*/ */
public async haveMsisdnToken( public async haveMsisdnToken(
msisdnToken: string, msisdnToken: string,
): Promise<[success?: boolean, result?: UIAResponse<IAddThreePidOnlyBody> | Error | null]> { ): Promise<[success?: boolean, result?: IAddThreePidOnlyBody | Error | null]> {
const authClient = new IdentityAuthClient(); const authClient = new IdentityAuthClient();
if (this.submitUrl) { 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. 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 { SSOAuthEntry } from "./components/views/auth/InteractiveAuthEntryComponents";
import Modal from "./Modal"; import Modal from "./Modal";
@@ -38,7 +38,7 @@ export async function createCrossSigning(cli: MatrixClient): Promise<void> {
export async function uiAuthCallback( export async function uiAuthCallback(
matrixClient: MatrixClient, matrixClient: MatrixClient,
makeRequest: (authData: AuthDict) => Promise<UIAResponse<void>>, makeRequest: (authData: AuthDict) => Promise<void>,
): Promise<void> { ): Promise<void> {
try { try {
await makeRequest({}); 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 React, { createRef } from "react";
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import { logger } from "matrix-js-sdk/src/logger"; 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 { type GeneratedSecretStorageKey } from "matrix-js-sdk/src/crypto-api";
import classNames from "classnames"; import classNames from "classnames";
import CheckmarkIcon from "@vector-im/compound-design-tokens/assets/web/icons/check"; 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 ( private doBootstrapUIAuth = async (makeRequest: (authData: AuthDict) => Promise<void>): Promise<void> => {
makeRequest: (authData: AuthDict) => Promise<UIAResponse<void>>,
): Promise<void> => {
const dialogAesthetics = { const dialogAesthetics = {
[SSOAuthEntry.PHASE_PREAUTH]: { [SSOAuthEntry.PHASE_PREAUTH]: {
title: _t("auth|uia|sso_title"), 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"); export const ERROR_USER_CANCELLED = new Error("User cancelled auth session");
type InteractiveAuthCallbackSuccess<T> = ( export type InteractiveAuthCallback<T> = {
success: true, (success: true, response: T, extra?: { emailSid?: string; clientSecret?: string }): Promise<void>;
response: T, (success: false, response: IAuthData | Error): Promise<void>;
extra?: { emailSid?: string; clientSecret?: string }, };
) => Promise<void>;
type InteractiveAuthCallbackFailure = (success: false, response: IAuthData | Error) => Promise<void>;
export type InteractiveAuthCallback<T> = InteractiveAuthCallbackSuccess<T> & InteractiveAuthCallbackFailure;
export interface InteractiveAuthProps<T> { export interface InteractiveAuthProps<T> {
// matrix client to use for UI auth requests // matrix client to use for UI auth requests
@@ -49,10 +46,6 @@ export interface InteractiveAuthProps<T> {
emailSid?: string; emailSid?: string;
// If true, poll to see if the auth flow has been completed out-of-band // If true, poll to see if the auth flow has been completed out-of-band
poll?: boolean; 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 and continueKind are passed straight through to the AuthEntryComponent.
continueText?: string; continueText?: string;
continueKind?: ContinueKind; continueKind?: ContinueKind;
@@ -288,7 +281,6 @@ export default class InteractiveAuthComponent<T> extends React.Component<Interac
stageState={this.state.stageState} stageState={this.state.stageState}
fail={this.onAuthStageFailed} fail={this.onAuthStageFailed}
setEmailSid={this.setEmailSid} setEmailSid={this.setEmailSid}
showContinue={!this.props.continueIsManaged}
onPhaseChange={this.onPhaseChange} onPhaseChange={this.onPhaseChange}
requestEmailToken={this.authLogic.requestEmailToken} requestEmailToken={this.authLogic.requestEmailToken}
continueText={this.props.continueText} continueText={this.props.continueText}

View File

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

View File

@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
*/ */
import React from "react"; 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 { type AuthType } from "matrix-js-sdk/src/interactive-auth";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
@@ -63,7 +63,7 @@ export interface InteractiveAuthDialogProps<T = unknown>
// Default is defined in _getDefaultDialogAesthetics() // Default is defined in _getDefaultDialogAesthetics()
aestheticsForStagePhases?: DialogAesthetics; aestheticsForStagePhases?: DialogAesthetics;
onFinished(success?: boolean, result?: UIAResponse<T> | Error | null): void; onFinished(success?: boolean, result?: T | Error | null): void;
} }
interface IState { interface IState {
@@ -111,7 +111,7 @@ export default class InteractiveAuthDialog<T> extends React.Component<Interactiv
private onAuthFinished: InteractiveAuthCallback<T> = async (success, result): Promise<void> => { private onAuthFinished: InteractiveAuthCallback<T> = async (success, result): Promise<void> => {
if (success) { if (success) {
this.props.onFinished(true, result); this.props.onFinished(true, result as T);
} else { } else {
if (result === ERROR_USER_CANCELLED) { if (result === ERROR_USER_CANCELLED) {
this.props.onFinished(false, null); this.props.onFinished(false, null);

View File

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