import type { FirebaseApp, ReactNativeFirebase } from '@react-native-firebase/app'; import type { ActionCodeOperation, FactorId, OperationType } from '../constants'; import type { AuthCredential, EmailAuthCredential, OAuthCredential, PhoneAuthCredential } from '../credentials'; export type { AuthCredential, EmailAuthCredential, OAuthCredential, PhoneAuthCredential }; export type CompleteFn = () => void; export type ErrorFn = (error: Error) => void; export type NextFn = (value: T) => void; export type Unsubscribe = () => void; interface Observer { next?: NextFn | null; error?: ErrorFn | null; complete?: CompleteFn | null; } export interface Auth { readonly app: FirebaseApp; readonly name: string; /** @remarks Always returns `{}` at runtime. Native iOS/Android Firebase Auth SDKs do not expose the web config object. */ readonly config: Config; /** * @remarks * **Not supported on React Native Firebase.** The modular {@link setPersistence} helper always throws * synchronously because auth state is managed by the native SDKs. */ setPersistence(persistence: Persistence): Promise; languageCode: string | null; /** Writable tenant ID. Assigning a value delegates to `setTenantId`. */ tenantId: string | null; readonly settings: AuthSettings; onAuthStateChanged(nextOrObserver: NextOrObserver, error?: ErrorFn, completed?: CompleteFn): Unsubscribe; beforeAuthStateChanged(callback: (user: User | null) => void | Promise, onAbort?: () => void): Unsubscribe; onIdTokenChanged(nextOrObserver: NextOrObserver, error?: ErrorFn, completed?: CompleteFn): Unsubscribe; /** Resolves when the initial auth state has been determined. */ authStateReady(): Promise; readonly currentUser: User | null; /** Populated after {@link connectAuthEmulator} is called; otherwise `null`. */ readonly emulatorConfig: EmulatorConfig | null; updateCurrentUser(user: User | null): Promise; /** * @remarks * **Not supported on React Native Firebase.** Always throws synchronously. Set `languageCode` * directly or use {@link setLanguageCode}. */ useDeviceLanguage(): void; signOut(): Promise; } export interface AuthError extends ReactNativeFirebase.NativeFirebaseError { readonly customData: { readonly appName: string; readonly email?: string; readonly phoneNumber?: string; readonly tenantId?: string; }; } export interface NativeFirebaseAuthError extends ReactNativeFirebase.NativeFirebaseError { readonly userInfo: { readonly authCredential: AuthCredential | null; readonly resolver: MultiFactorResolver | null; }; } /** * @deprecated Use {@link OAuthProvider} with provider ID `oidc.` instead. */ export interface OIDCProvider { readonly PROVIDER_ID: string; credential(oidcSuffix: string, idToken: string): AuthCredential; } export interface MultiFactorError extends AuthError { readonly customData: AuthError['customData'] & { readonly operationType: (typeof OperationType)[keyof typeof OperationType]; }; } export interface PhoneAuthSnapshot { readonly state: 'sent' | 'timeout' | 'verified' | 'error'; readonly verificationId: string; readonly code: string | null; readonly error: ReactNativeFirebase.NativeFirebaseError | null; } export interface PhoneAuthError { readonly code: string | null; readonly verificationId: string; readonly message: string | null; readonly stack: string | null; } export interface PhoneAuthListener { on(event: string, observer: (snapshot: PhoneAuthSnapshot) => void, errorCb?: (error: PhoneAuthError) => void, successCb?: (snapshot: PhoneAuthSnapshot) => void): PhoneAuthListener; then(onFulfilled?: ((value: PhoneAuthSnapshot) => any) | null, onRejected?: ((error: ReactNativeFirebase.NativeFirebaseError) => any) | null): Promise; catch(onRejected: (error: ReactNativeFirebase.NativeFirebaseError) => any): Promise; } export { ActionCodeURL } from '../ActionCodeURL'; /** * Firebase JS SDK auth configuration. Native iOS/Android Firebase Auth SDKs do not expose * this object, so {@link Auth.config} always returns an empty object on React Native. */ export interface Config { apiKey: string; apiHost: string; apiScheme: string; tokenApiHost: string; sdkClientVersion: string; authDomain?: string; } export interface AuthErrorMap { } export interface PopupRedirectResolver { } export interface Dependencies { persistence?: Persistence | Persistence[]; popupRedirectResolver?: PopupRedirectResolver; errorMap?: AuthErrorMap; } export interface ApplicationVerifier { readonly type: string; verify(): Promise; } export type CustomParameters = Record; /** * The user's full name, as shared by Sign in with Apple. * * Apple only shares this data on the user's first authorization for a given app; it is * omitted from the `ASAuthorizationAppleIDCredential` on subsequent sign-ins, so it should be * captured and forwarded on the first sign-in. */ export interface AppleFullPersonName { namePrefix?: string | null; givenName?: string | null; middleName?: string | null; familyName?: string | null; nameSuffix?: string | null; nickname?: string | null; } export interface OAuthCredentialOptions { idToken?: string; accessToken?: string; rawNonce?: string; /** * The user's full name, as shared by Sign in with Apple on the user's first authorization. * * @remarks Only retained for `apple.com` credentials with at least one non-empty name field, * and only forwarded to the native SDK on iOS, where it is passed to * `FIROAuthProvider.appleCredentialWithIDToken:rawNonce:fullName:` so Firebase can store it as * {@link User.displayName} while creating the account. The Firebase Android SDK has no * equivalent credential-level API; on Android (and Web) this field is ignored and the display * name must be set with {@link updateProfile} after sign-in. */ fullName?: AppleFullPersonName; } export interface AuthProvider { readonly providerId: string; } export interface AuthSettings { appVerificationDisabledForTesting: boolean; } export interface EmulatorConfig { readonly protocol: string; readonly host: string; readonly port: number | null; readonly options: { readonly disableWarnings: boolean; }; } export interface PasswordPolicy { readonly customStrengthOptions: { readonly minPasswordLength?: number; readonly maxPasswordLength?: number; readonly containsLowercaseLetter?: boolean; readonly containsUppercaseLetter?: boolean; readonly containsNumericCharacter?: boolean; readonly containsNonAlphanumericCharacter?: boolean; }; readonly allowedNonAlphanumericCharacters: string; readonly enforcementState: string; readonly forceUpgradeOnSignin: boolean; } export interface PasswordValidationStatus { readonly isValid: boolean; readonly meetsMinPasswordLength?: boolean; readonly meetsMaxPasswordLength?: boolean; readonly containsLowercaseLetter?: boolean; readonly containsUppercaseLetter?: boolean; readonly containsNumericCharacter?: boolean; readonly containsNonAlphanumericCharacter?: boolean; readonly passwordPolicy: PasswordPolicy; } export interface Persistence { readonly type: 'SESSION' | 'LOCAL' | 'NONE' | 'COOKIE'; } export type NextOrObserver = NextFn | Observer; export interface ParsedToken { 'exp'?: string; 'sub'?: string; 'auth_time'?: string; 'iat'?: string; 'firebase'?: { 'sign_in_provider'?: string; 'sign_in_second_factor'?: string; 'identities'?: Record; }; [key: string]: unknown; } export type UserProfile = Record; export interface AdditionalUserInfo { readonly isNewUser: boolean; readonly profile: Record | null; readonly providerId: string | null; readonly username?: string | null; } /** * firebase-js-sdk `AdditionalUserInfo` fields plus any extra keys returned by the native bridge. * Extra keys are preserved for backwards compatibility when native adds provider-specific fields. */ export type AdditionalUserInfoNative = AdditionalUserInfo & Record; export interface UserInfo { readonly displayName: string | null; readonly email: string | null; readonly phoneNumber: string | null; readonly photoURL: string | null; readonly providerId: string; readonly uid: string; } export interface UserMetadata { readonly creationTime?: string; readonly lastSignInTime?: string; } export interface IdTokenResult { authTime: string; expirationTime: string; issuedAtTime: string; signInProvider: string | null; signInSecondFactor: string | null; token: string; claims: ParsedToken; } export interface User extends UserInfo { readonly emailVerified: boolean; readonly isAnonymous: boolean; readonly metadata: UserMetadata; readonly providerData: UserInfo[]; readonly refreshToken: string; readonly tenantId: string | null; /** Present on native user instances returned from auth state listeners. */ readonly multiFactor?: MultiFactor | null; delete(): Promise; getIdToken(forceRefresh?: boolean): Promise; getIdTokenResult(forceRefresh?: boolean): Promise; reload(): Promise; toJSON(): object; } /** * @remarks Modular helpers populate top-level `providerId` and `operationType`. When present, * `additionalUserInfo` is enumerable and includes firebase-js-sdk fields plus any extra native keys. */ export interface UserCredential { user: User; providerId: string | null; operationType: (typeof OperationType)[keyof typeof OperationType]; /** * Present on modular sign-in results when the native bridge returns federated metadata. * Includes firebase-js-sdk core fields; extra native keys are preserved at runtime — see * {@link AdditionalUserInfoNative} and {@link getAdditionalUserInfo}. */ additionalUserInfo?: AdditionalUserInfo; } export interface ConfirmationResult { readonly verificationId: string; confirm(verificationCode: string): Promise; } export interface ActionCodeSettings { android?: { installApp?: boolean; minimumVersion?: string; packageName: string; }; handleCodeInApp?: boolean; iOS?: { bundleId: string; }; url: string; dynamicLinkDomain?: string; linkDomain?: string; } export interface ActionCodeInfo { data: { email?: string | null; multiFactorInfo?: MultiFactorInfo | null; previousEmail?: string | null; }; operation: (typeof ActionCodeOperation)[keyof typeof ActionCodeOperation]; } export interface MultiFactorAssertion { readonly factorId: (typeof FactorId)[keyof typeof FactorId]; } export interface MultiFactorInfo { readonly uid: string; readonly displayName?: string | null; readonly enrollmentTime: string; readonly factorId: (typeof FactorId)[keyof typeof FactorId]; } export interface MultiFactorSession { } export interface MultiFactorResolver { readonly hints: MultiFactorInfo[]; readonly session: MultiFactorSession; resolveSignIn(assertion: MultiFactorAssertion): Promise; } export interface MultiFactorUser { readonly enrolledFactors: MultiFactorInfo[]; getSession(): Promise; enroll(assertion: MultiFactorAssertion, displayName?: string | null): Promise; unenroll(option: MultiFactorInfo | string): Promise; } export interface PhoneMultiFactorAssertion extends MultiFactorAssertion { } export interface PhoneMultiFactorEnrollInfoOptions { phoneNumber: string; session: MultiFactorSession; } export interface PhoneMultiFactorInfo extends MultiFactorInfo { readonly phoneNumber: string; } export interface PhoneMultiFactorSignInInfoOptions { multiFactorHint?: MultiFactorInfo; multiFactorUid?: string; session: MultiFactorSession; } export interface PhoneSingleFactorInfoOptions { phoneNumber: string; } export type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions; export interface TotpMultiFactorAssertion extends MultiFactorAssertion { } export interface TotpMultiFactorInfo extends MultiFactorInfo { } export type AuthListenerCallback = (user: User | null) => void; export type CallbackOrObserver any> = T | { next: T; }; export interface UpdateProfile { displayName?: string | null; photoURL?: string | null; } export interface MultiFactor { enrolledFactors: MultiFactorInfo[]; } //# sourceMappingURL=auth.d.ts.map