import { EventEmitter } from '@angular/core'; import { Observable } from 'rxjs'; import 'firebase/auth'; import { User, UserInfo, UserCredential } from '@firebase/auth-types'; import { AngularFireAuth } from '@angular/fire/auth'; import { AuthFirestoreSyncService } from './firestore-sync.service'; import { AuthSharedConfig, AuthProvider, ISignInOptions, IAuthHooksService, ICredentialFactoryProvider } from '../interfaces'; import { UiService } from './ui.service'; import { FirebaseService } from './firebase.service'; export declare class AuthProcessService { config: AuthSharedConfig; hooksService: IAuthHooksService; credFactory: ICredentialFactoryProvider; private fireStoreService; private afa; private fire; private ui; readonly onErrorEmitter: EventEmitter; readonly onSignInEmitter: EventEmitter; readonly onRegisterEmitter: EventEmitter; readonly onSignOutEmitter: EventEmitter; readonly onUserUpdatedEmitter: EventEmitter; readonly onUserDeletedEmitter: EventEmitter; readonly showProfileDialog: EventEmitter; /** * Useful to know about auth state even between reloads. * **/ private _user$; get user(): User | null; readonly user$: Observable; /** * Useful to know about auth state even between reloads. **/ private _authState$; readonly authState$: Observable; /** * Obersable for current user - that only emits when the uid changes * Useful to reset session info when user changes. */ uid$: Observable; /** * UserInterface helper observables - indicating what user actions are currently permitted and * the current status of authentication. */ readonly isLoggedIn$: Observable; readonly isAnonymous$: Observable; readonly isNamedUser$: Observable; readonly isNotNamedUser$: Observable; readonly canEdit$: Observable; readonly canRegister$: Observable; readonly canSignIn$: Observable; readonly canSignInAsGuest$: Observable; readonly canSignOut$: Observable; /** * Observable. Emits whenever currentUser signsOut */ readonly onSignOut$: Observable; /** * Observable emits whenever a new user signsIn */ readonly onSignIn$: Observable; /** * Provides an array of authentication providers that are valid for the currently signed-in user */ get reauthenticateProviders$(): Observable; /** * Triggers subscriber actions when the current user token is refreshed */ private readonly tokenRefreshed$; constructor(config: AuthSharedConfig, hooksService: IAuthHooksService, credFactory: ICredentialFactoryProvider, fireStoreService: AuthFirestoreSyncService, afa: AngularFireAuth, // TODO should be private fire: FirebaseService, ui: UiService); /** * Returns true if current platform is webplatform supported by @angular/fire */ get isWebPlatform(): boolean; /** * Indicates if the specified provider is supported on the current platform * * A provider is supported if it is configured to be so in authUi.supportProviders and either the platform is a webplatform * (in which case @anguluar/fire will be used). Or the provider is supported by the injected credFactory (such as that provided by /capacitor). */ isProviderSupported(provider: AuthProvider): Promise; /** * Refreshes the current user IdToken, and triggers the tokenRefreshed$ subject */ refreshToken(): Promise; /** * Provides an observable that subscribes to the current user token and returns the value of the specified claim. * * @param claim Claim to be returned * @returns Observable for: Value of claim within current user token || null (if not signed in) || undefined (if no such claim exists) */ selectCurrentUserClaim(claim: string): Observable; /** * Get the value for a custom claim for the current user (extracted from their ID token) * * @param claim Claim to be returned * @returns Value of claim within current user token || null (if not signed in) || undefined (if no such claim exists) */ getCurrentUserClaim(claim: string): Promise; /** * Reset the password of currently authenticated user via email, * Firebase sends an email to the user - and managed the reset process directly via google's hosted pages. * * @param email - the email to reset */ resetPassword(email: string): Promise; /** * General sign in mechanism to authenticate the users with a firebase project * using a traditional way, via username and password or by using an authentication provider * like google, facebook, twitter and github * * [Current State -> Target State] * Null -> Anon/named: OK * Anon -> Anon: Throws Error * Anon -> Named: Triggers MergeService * Named -> Any: Throws Error * * @param provider - the provider to authenticate with (google, facebook, twitter, github) * @param credentials optional email and password */ signInWith(provider: AuthProvider, options?: ISignInOptions): Promise; /** * Reauthenicate the current user - a recent authentication is required for some sensitive operations * such as changing account details */ reauthenicateWithProvider(provider: AuthProvider, options?: ISignInOptions): Promise; /** * Link the current user to credentials from another auth provider. * * @param provider Provider to link. */ linkCurrentUserToProvider(provider: AuthProvider, options?: ISignInOptions): Promise; /** * Creates a firebase user account authenticated with the specified provider. * If AuthProvider.EmailAndPassword is specified credentials and displayname must also be provided. */ registerWith(provider: AuthProvider, options?: ISignInOptions): Promise; private socialAuth; /** * Present dialog and confirm the user agress to the privacy policy and terms of service (if either configured). * If nether configured returns true; * * @returns True if either user agrees to TOS/PrivacyUrl || no TOS/PrivacyUrl configured. */ private confirmTos; /** * Send the currently authenticated user another verficiation email. */ sendNewVerificationEmail(): Promise; /** * SignOut the currently authenticated user. */ signOut(): Promise; /** * Update the details for the authenticated user of in the firebase authentication and sync with firestore. * * @param userInfo - UserInfo object containing those properties for which change is requried. Only provider * the properties actually to be changed. Others should be ommitted. */ updateUserInfo(userInfo: Partial): Promise; /** * Extract UserInfo object from the User object * If multiple providers are supplied these are amalgamated to create the most complete * UserInfo object possible */ parseUserInfo(user: User): UserInfo; /** * Returns the UserPhotoUrl, or an appropraite placeholder if not provided * ToDo - this would probably bet better inside a user-photo component */ getUserPhotoUrl(): Observable; /** * Refresh user info. Can be useful for instance to get latest status regarding email verification. */ reloadUserInfo(): Promise; /** * Deletes the current user */ deleteUser(): Promise; /** * Logs the error and provides user error notifcation if appropriate */ handleError(error: any): Promise; /** * Returns a firebase auth provider object for the specified provider */ private getAuthProvider; }