@@ -11,6 +11,8 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix";
11
11
import { AuthType , AuthDict , IInputs , IStageStatus } from "matrix-js-sdk/src/interactive-auth" ;
12
12
import { logger } from "matrix-js-sdk/src/logger" ;
13
13
import React , { ChangeEvent , createRef , FormEvent , Fragment } from "react" ;
14
+ import { Button , Text } from "@vector-im/compound-web" ;
15
+ import PopOutIcon from "@vector-im/compound-design-tokens/assets/web/icons/pop-out" ;
14
16
15
17
import EmailPromptIcon from "../../../../res/img/element-icons/email-prompt.svg" ;
16
18
import { _t } from "../../../languageHandler" ;
@@ -21,6 +23,7 @@ import AccessibleButton, { AccessibleButtonKind, ButtonEvent } from "../elements
21
23
import Field from "../elements/Field" ;
22
24
import Spinner from "../elements/Spinner" ;
23
25
import CaptchaForm from "./CaptchaForm" ;
26
+ import { Flex } from "../../utils/Flex" ;
24
27
25
28
/* This file contains a collection of components which are used by the
26
29
* InteractiveAuth to prompt the user to enter the information needed
@@ -905,11 +908,11 @@ export class SSOAuthEntry extends React.Component<ISSOAuthEntryProps, ISSOAuthEn
905
908
}
906
909
}
907
910
908
- export class FallbackAuthEntry extends React . Component < IAuthEntryProps > {
909
- private popupWindow : Window | null ;
910
- private fallbackButton = createRef < HTMLButtonElement > ( ) ;
911
+ export class FallbackAuthEntry < T = { } > extends React . Component < IAuthEntryProps & T > {
912
+ protected popupWindow : Window | null ;
913
+ protected fallbackButton = createRef < HTMLButtonElement > ( ) ;
911
914
912
- public constructor ( props : IAuthEntryProps ) {
915
+ public constructor ( props : IAuthEntryProps & T ) {
913
916
super ( props ) ;
914
917
915
918
// we have to make the user click a button, as browsers will block
@@ -967,6 +970,50 @@ export class FallbackAuthEntry extends React.Component<IAuthEntryProps> {
967
970
}
968
971
}
969
972
973
+ export enum CustomAuthType {
974
+ // Workaround for MAS requiring non-UIA authentication for resetting cross-signing.
975
+ MasCrossSigningReset = "org.matrix.cross_signing_reset" ,
976
+ }
977
+
978
+ export class MasUnlockCrossSigningAuthEntry extends FallbackAuthEntry < {
979
+ stageParams ?: {
980
+ url ?: string ;
981
+ } ;
982
+ } > {
983
+ public static LOGIN_TYPE = CustomAuthType . MasCrossSigningReset ;
984
+
985
+ private onGoToAccountClick = ( ) : void => {
986
+ if ( ! this . props . stageParams ?. url ) return ;
987
+ this . popupWindow = window . open ( this . props . stageParams . url , "_blank" ) ;
988
+ } ;
989
+
990
+ private onRetryClick = ( ) : void => {
991
+ this . props . submitAuthDict ( { } ) ;
992
+ } ;
993
+
994
+ public render ( ) : React . ReactNode {
995
+ return (
996
+ < div >
997
+ < Text > { _t ( "auth|uia|mas_cross_signing_reset_description" ) } </ Text >
998
+ < Flex gap = "var(--cpd-space-4x)" >
999
+ < Button
1000
+ Icon = { PopOutIcon }
1001
+ onClick = { this . onGoToAccountClick }
1002
+ autoFocus
1003
+ kind = "primary"
1004
+ className = "mx_Dialog_nonDialogButton"
1005
+ >
1006
+ { _t ( "auth|uia|mas_cross_signing_reset_cta" ) }
1007
+ </ Button >
1008
+ < Button onClick = { this . onRetryClick } kind = "secondary" className = "mx_Dialog_nonDialogButton" >
1009
+ { _t ( "action|retry" ) }
1010
+ </ Button >
1011
+ </ Flex >
1012
+ </ div >
1013
+ ) ;
1014
+ }
1015
+ }
1016
+
970
1017
export interface IStageComponentProps extends IAuthEntryProps {
971
1018
stageParams ?: Record < string , any > ;
972
1019
inputs ?: IInputs ;
@@ -983,8 +1030,10 @@ export interface IStageComponent extends React.ComponentClass<React.PropsWithRef
983
1030
focus ?( ) : void ;
984
1031
}
985
1032
986
- export default function getEntryComponentForLoginType ( loginType : AuthType ) : IStageComponent {
1033
+ export default function getEntryComponentForLoginType ( loginType : AuthType | CustomAuthType ) : IStageComponent {
987
1034
switch ( loginType ) {
1035
+ case CustomAuthType . MasCrossSigningReset :
1036
+ return MasUnlockCrossSigningAuthEntry ;
988
1037
case AuthType . Password :
989
1038
return PasswordAuthEntry ;
990
1039
case AuthType . Recaptcha :
0 commit comments