@@ -64,6 +64,16 @@ function setPendingState(ui: FirebaseUI) {
6464 ui . setState ( "pending" ) ;
6565}
6666
67+ /**
68+ * Signs in with an email and password.
69+ *
70+ * If the `autoUpgradeAnonymousUsers` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
71+ *
72+ * @param ui - The FirebaseUI instance.
73+ * @param email - The email to sign in with.
74+ * @param password - The password to sign in with.
75+ * @returns {Promise<UserCredential> } A promise containing the user credential.
76+ */
6777export async function signInWithEmailAndPassword (
6878 ui : FirebaseUI ,
6979 email : string ,
@@ -90,6 +100,18 @@ export async function signInWithEmailAndPassword(
90100 }
91101}
92102
103+ /**
104+ * Creates a new user account with an email and password.
105+ *
106+ * If the `requireDisplayName` behavior is enabled, a display name must be provided.
107+ * If the `autoUpgradeAnonymousUsers` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
108+ *
109+ * @param ui - The FirebaseUI instance.
110+ * @param email - The email address for the new account.
111+ * @param password - The password for the new account.
112+ * @param displayName - Optional display name for the user.
113+ * @returns {Promise<UserCredential> } A promise containing the user credential.
114+ */
93115export async function createUserWithEmailAndPassword (
94116 ui : FirebaseUI ,
95117 email : string ,
@@ -130,6 +152,18 @@ export async function createUserWithEmailAndPassword(
130152 }
131153}
132154
155+ /**
156+ * Verifies a phone number for authentication.
157+ *
158+ * Supports regular phone authentication, MFA enrollment, and MFA assertion flows.
159+ *
160+ * @param ui - The FirebaseUI instance.
161+ * @param phoneNumber - The phone number to verify.
162+ * @param appVerifier - The application verifier (reCAPTCHA).
163+ * @param mfaUser - Optional multi-factor user for MFA enrollment flow.
164+ * @param mfaHint - Optional multi-factor info hint for MFA assertion flow.
165+ * @returns {Promise<string> } A promise containing the verification ID.
166+ */
133167export async function verifyPhoneNumber (
134168 ui : FirebaseUI ,
135169 phoneNumber : string ,
@@ -171,6 +205,16 @@ export async function verifyPhoneNumber(
171205 }
172206}
173207
208+ /**
209+ * Confirms a phone number verification code and signs in the user.
210+ *
211+ * If the `autoUpgradeAnonymousUsers` behavior is enabled and the current user is anonymous, it will attempt to upgrade the anonymous user to a regular user.
212+ *
213+ * @param ui - The FirebaseUI instance.
214+ * @param verificationId - The verification ID from the phone verification process.
215+ * @param verificationCode - The verification code sent to the phone.
216+ * @returns {Promise<UserCredential> } A promise containing the user credential.
217+ */
174218export async function confirmPhoneNumber (
175219 ui : FirebaseUI ,
176220 verificationId : string ,
@@ -198,6 +242,13 @@ export async function confirmPhoneNumber(
198242 }
199243}
200244
245+ /**
246+ * Sends a password reset email to the specified email address.
247+ *
248+ * @param ui - The FirebaseUI instance.
249+ * @param email - The email address to send the password reset email to.
250+ * @returns {Promise<void> } A promise that resolves when the email is sent.
251+ */
201252export async function sendPasswordResetEmail ( ui : FirebaseUI , email : string ) : Promise < void > {
202253 try {
203254 setPendingState ( ui ) ;
@@ -209,6 +260,15 @@ export async function sendPasswordResetEmail(ui: FirebaseUI, email: string): Pro
209260 }
210261}
211262
263+ /**
264+ * Sends a sign-in link to the specified email address.
265+ *
266+ * The email address is stored in localStorage for later use during the sign-in process.
267+ *
268+ * @param ui - The FirebaseUI instance.
269+ * @param email - The email address to send the sign-in link to.
270+ * @returns {Promise<void> } A promise that resolves when the email is sent.
271+ */
212272export async function sendSignInLinkToEmail ( ui : FirebaseUI , email : string ) : Promise < void > {
213273 try {
214274 setPendingState ( ui ) ;
@@ -228,11 +288,28 @@ export async function sendSignInLinkToEmail(ui: FirebaseUI, email: string): Prom
228288 }
229289}
230290
291+ /**
292+ * Signs in a user using an email link.
293+ *
294+ * @param ui - The FirebaseUI instance.
295+ * @param email - The email address associated with the sign-in link.
296+ * @param link - The sign-in link from the email.
297+ * @returns {Promise<UserCredential> } A promise containing the user credential.
298+ */
231299export async function signInWithEmailLink ( ui : FirebaseUI , email : string , link : string ) : Promise < UserCredential > {
232300 const credential = EmailAuthProvider . credentialWithLink ( email , link ) ;
233301 return signInWithCredential ( ui , credential ) ;
234302}
235303
304+ /**
305+ * Signs in a user with an authentication credential.
306+ *
307+ * If the `autoUpgradeAnonymousUsers` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
308+ *
309+ * @param ui - The FirebaseUI instance.
310+ * @param credential - The authentication credential to sign in with.
311+ * @returns {Promise<UserCredential> } A promise containing the user credential.
312+ */
236313export async function signInWithCredential ( ui : FirebaseUI , credential : AuthCredential ) : Promise < UserCredential > {
237314 try {
238315 setPendingState ( ui ) ;
@@ -255,6 +332,13 @@ export async function signInWithCredential(ui: FirebaseUI, credential: AuthCrede
255332 }
256333}
257334
335+ /**
336+ * Signs in a user with a custom token.
337+ *
338+ * @param ui - The FirebaseUI instance.
339+ * @param customToken - The custom token to sign in with.
340+ * @returns {Promise<UserCredential> } A promise containing the user credential.
341+ */
258342export async function signInWithCustomToken ( ui : FirebaseUI , customToken : string ) : Promise < UserCredential > {
259343 try {
260344 setPendingState ( ui ) ;
@@ -267,6 +351,12 @@ export async function signInWithCustomToken(ui: FirebaseUI, customToken: string)
267351 }
268352}
269353
354+ /**
355+ * Signs in a user anonymously.
356+ *
357+ * @param ui - The FirebaseUI instance.
358+ * @returns {Promise<UserCredential> } A promise containing the user credential.
359+ */
270360export async function signInAnonymously ( ui : FirebaseUI ) : Promise < UserCredential > {
271361 try {
272362 setPendingState ( ui ) ;
@@ -279,6 +369,16 @@ export async function signInAnonymously(ui: FirebaseUI): Promise<UserCredential>
279369 }
280370}
281371
372+ /**
373+ * Signs in a user with an authentication provider (e.g., Google, Facebook, etc.).
374+ *
375+ * If the `autoUpgradeAnonymousProvider` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
376+ * The sign-in strategy (popup or redirect) is determined by the `providerSignInStrategy` behavior.
377+ *
378+ * @param ui - The FirebaseUI instance.
379+ * @param provider - The authentication provider to sign in with.
380+ * @returns {Promise<UserCredential | never> } A promise containing the user credential, or never if using redirect strategy.
381+ */
282382export async function signInWithProvider ( ui : FirebaseUI , provider : AuthProvider ) : Promise < UserCredential | never > {
283383 try {
284384 setPendingState ( ui ) ;
@@ -305,6 +405,16 @@ export async function signInWithProvider(ui: FirebaseUI, provider: AuthProvider)
305405 }
306406}
307407
408+ /**
409+ * Completes the email link sign-in process using the current URL.
410+ *
411+ * Checks if the current URL is a valid email link sign-in URL and retrieves the email from localStorage.
412+ * Returns null if the URL is not a valid email link or if no email is found in localStorage.
413+ *
414+ * @param ui - The FirebaseUI instance.
415+ * @param currentUrl - The current URL to check for email link sign-in.
416+ * @returns {Promise<UserCredential | null> } A promise containing the user credential, or null if the sign-in cannot be completed.
417+ */
308418export async function completeEmailLinkSignIn ( ui : FirebaseUI , currentUrl : string ) : Promise < UserCredential | null > {
309419 try {
310420 if ( ! _isSignInWithEmailLink ( ui . auth , currentUrl ) ) {
@@ -322,6 +432,18 @@ export async function completeEmailLinkSignIn(ui: FirebaseUI, currentUrl: string
322432 }
323433}
324434
435+ /**
436+ * Generates a QR code data URL for TOTP (Time-based One-Time Password) multi-factor authentication.
437+ *
438+ * The QR code can be scanned by an authenticator app to set up TOTP MFA for the user.
439+ *
440+ * @param ui - The FirebaseUI instance.
441+ * @param secret - The TOTP secret to generate the QR code for.
442+ * @param accountName - Optional account name for the QR code. Defaults to the user's email if not provided.
443+ * @param issuer - Optional issuer name for the QR code.
444+ * @returns {string } A data URL containing the QR code image.
445+ * @throws {Error } Throws an error if the user is not authenticated.
446+ */
325447export function generateTotpQrCode ( ui : FirebaseUI , secret : TotpSecret , accountName ?: string , issuer ?: string ) : string {
326448 const currentUser = ui . auth . currentUser ;
327449
@@ -337,6 +459,15 @@ export function generateTotpQrCode(ui: FirebaseUI, secret: TotpSecret, accountNa
337459 return qr . createDataURL ( ) ;
338460}
339461
462+ /**
463+ * Signs in a user using a multi-factor assertion.
464+ *
465+ * Resolves the multi-factor challenge using the provided assertion and clears the multi-factor resolver from the UI state.
466+ *
467+ * @param ui - The FirebaseUI instance.
468+ * @param assertion - The multi-factor assertion to use for sign-in.
469+ * @returns {Promise<UserCredential> } A promise containing the user credential.
470+ */
340471export async function signInWithMultiFactorAssertion ( ui : FirebaseUI , assertion : MultiFactorAssertion ) {
341472 try {
342473 setPendingState ( ui ) ;
@@ -350,6 +481,14 @@ export async function signInWithMultiFactorAssertion(ui: FirebaseUI, assertion:
350481 }
351482}
352483
484+ /**
485+ * Enrolls a multi-factor authentication method for the current user.
486+ *
487+ * @param ui - The FirebaseUI instance.
488+ * @param assertion - The multi-factor assertion to enroll.
489+ * @param displayName - Optional display name for the enrolled MFA method.
490+ * @returns {Promise<void> } A promise that resolves when the enrollment is complete.
491+ */
353492export async function enrollWithMultiFactorAssertion (
354493 ui : FirebaseUI ,
355494 assertion : MultiFactorAssertion ,
@@ -365,6 +504,12 @@ export async function enrollWithMultiFactorAssertion(
365504 }
366505}
367506
507+ /**
508+ * Generates a TOTP (Time-based One-Time Password) secret for multi-factor authentication enrollment.
509+ *
510+ * @param ui - The FirebaseUI instance.
511+ * @returns {Promise<TotpSecret> } A promise containing the TOTP secret.
512+ */
368513export async function generateTotpSecret ( ui : FirebaseUI ) : Promise < TotpSecret > {
369514 try {
370515 setPendingState ( ui ) ;
0 commit comments