import { IEvent } from 'common/utils/event' ; import { MagicLinkRequestReasons } from 'common/models/dtos/auth' ; export type AuthUser = { uid : string ; displayName : string ; email : string ; photoURL : string ; providers : ReadonlyArray < AuthProviders > ; currentProvider : AuthProviders ; } ; export enum AuthProviders { None = '' , EmailLink = 'emaillink' , EmailAndPassword = 'emailpassword' , Google = 'google' , Apple = 'apple' , DevLogin = 'devLogin' } export type FirebaseError = Error & { code : string ; } ; export interface IAuthController { readonly authUser : Readonly < AuthUser > ; readonly initializing : boolean ; readonly needsCreatePassword : boolean | null ; readonly magicLinkSucceeded : IEvent < MagicLinkRequestReasons > ; readonly onPreProcessUser : IEvent < AuthUser > ; readonly onSignOut : IEvent ; readonly setPasswordMode : boolean ; skipPasswordMode ( ) : void ; getEmailAuthMethod ( email ) : Promise < AuthProviders [ ] > ; getHasAccount ( email ) : Promise < boolean > ; hasAccount ( email ) : Promise < boolean > ; validateCode ( email , code ) : Promise < { result : boolean ; } > ; signInWithEmailLink ( email , reason ) : Promise < void > ; signInWithEmailPassword ( email , password ) : Promise < void > ; createAccountForEmailAndPassword ( email , password ) : Promise < void > ; resetPassword ( email , newPassword ) : Promise < { result : boolean ; } > ; createAccountForEmailAfterVerificationCode ( email ) : Promise < { result : boolean ; } > ; sendVerificationCodeByEmail ( email ) : Promise < { result : boolean ; } | 'noInvitation' > ; signInWithEmailOnly ( email ) : Promise < { result : boolean ; } > ; signInWithGoogle ( ) : Promise < boolean > ; signOut ( ) : Promise < void > ; updatePassword ( password , oldPassword ? ) : Promise < AuthResult > ; updatePasswordWithEmail ( email , password , oldPassword ? ) : Promise < AuthResult > ; devLogin ( email ) : Promise < void > ; updatePhotoUrl ( photoUrl ) : Promise < void > ; } export type AuthResult = { result : true ; } | { result : false ; error : AuthErrors ; original : FirebaseError ; } ; export enum AuthErrors { Unknown = 0 , InvalidAuthState , WrongPassword , NeedsReauthentication }