1515 */ 
1616
1717import  { 
18-   createUserWithEmailAndPassword  as  _createUserWithEmailAndPassword , 
19-   isSignInWithEmailLink  as  _isSignInWithEmailLink , 
20-   sendPasswordResetEmail  as  _sendPasswordResetEmail , 
21-   sendSignInLinkToEmail  as  _sendSignInLinkToEmail , 
22-   signInAnonymously  as  _signInAnonymously , 
23-   signInWithPhoneNumber  as  _signInWithPhoneNumber , 
24-   ActionCodeSettings , 
25-   AuthProvider , 
26-   ConfirmationResult , 
18+   type  ActionCodeSettings , 
19+   type  AuthProvider , 
20+   type  ConfirmationResult , 
21+   type  RecaptchaVerifier , 
22+   type  UserCredential , 
2723  EmailAuthProvider , 
28-   linkWithCredential , 
2924  PhoneAuthProvider , 
30-   RecaptchaVerifier , 
31-   signInWithCredential , 
32-   signInWithRedirect , 
33-   UserCredential , 
3425}  from  "firebase/auth" ; 
3526import  {  getBehavior ,  hasBehavior  }  from  "./behaviors" ; 
3627import  {  FirebaseUIConfiguration  }  from  "./config" ; 
3728import  {  handleFirebaseError  }  from  "./errors" ; 
29+ import  {  getAuthImp  }  from  "./imp/auth" ; 
3830
3931async  function  handlePendingCredential ( ui : FirebaseUIConfiguration ,  user : UserCredential ) : Promise < UserCredential >  { 
4032  const  pendingCredString  =  window . sessionStorage . getItem ( "pendingCred" ) ; 
@@ -43,7 +35,7 @@ async function handlePendingCredential(ui: FirebaseUIConfiguration, user: UserCr
4335  try  { 
4436    const  pendingCred  =  JSON . parse ( pendingCredString ) ; 
4537    ui . setState ( "pending" ) ; 
46-     const  result  =  await  linkWithCredential ( user . user ,  pendingCred ) ; 
38+     const  result  =  await  getAuthImp ( ui ) . linkWithCredential ( user . user ,  pendingCred ) ; 
4739    ui . setState ( "idle" ) ; 
4840    window . sessionStorage . removeItem ( "pendingCred" ) ; 
4941    return  result ; 
@@ -63,14 +55,14 @@ export async function signInWithEmailAndPassword(
6355
6456    if  ( hasBehavior ( ui ,  "autoUpgradeAnonymousCredential" ) )  { 
6557      const  result  =  await  getBehavior ( ui ,  "autoUpgradeAnonymousCredential" ) ( ui ,  credential ) ; 
66-        
58+ 
6759      if  ( result )  { 
6860        return  handlePendingCredential ( ui ,  result ) ; 
6961      } 
7062    } 
7163
7264    ui . setState ( "pending" ) ; 
73-     const  result  =  await  signInWithCredential ( ui . auth ,  credential ) ; 
65+     const  result  =  await  getAuthImp ( ui ) . signInWithCredential ( ui . auth ,  credential ) ; 
7466    return  handlePendingCredential ( ui ,  result ) ; 
7567  }  catch  ( error )  { 
7668    handleFirebaseError ( ui ,  error ) ; 
@@ -96,7 +88,7 @@ export async function createUserWithEmailAndPassword(
9688    } 
9789
9890    ui . setState ( "pending" ) ; 
99-     const  result  =  await  _createUserWithEmailAndPassword ( ui . auth ,  email ,  password ) ; 
91+     const  result  =  await  getAuthImp ( ui ) . createUserWithEmailAndPassword ( ui . auth ,  email ,  password ) ; 
10092    return  handlePendingCredential ( ui ,  result ) ; 
10193  }  catch  ( error )  { 
10294    handleFirebaseError ( ui ,  error ) ; 
@@ -112,7 +104,7 @@ export async function signInWithPhoneNumber(
112104) : Promise < ConfirmationResult >  { 
113105  try  { 
114106    ui . setState ( "pending" ) ; 
115-     return  await  _signInWithPhoneNumber ( ui . auth ,  phoneNumber ,  recaptchaVerifier ) ; 
107+     return  await  getAuthImp ( ui ) . signInWithPhoneNumber ( ui . auth ,  phoneNumber ,  recaptchaVerifier ) ; 
116108  }  catch  ( error )  { 
117109    handleFirebaseError ( ui ,  error ) ; 
118110  }  finally  { 
@@ -138,7 +130,7 @@ export async function confirmPhoneNumber(
138130    } 
139131
140132    ui . setState ( "pending" ) ; 
141-     const  result  =  await  signInWithCredential ( ui . auth ,  credential ) ; 
133+     const  result  =  await  getAuthImp ( ui ) . signInWithCredential ( ui . auth ,  credential ) ; 
142134    return  handlePendingCredential ( ui ,  result ) ; 
143135  }  catch  ( error )  { 
144136    handleFirebaseError ( ui ,  error ) ; 
@@ -150,7 +142,7 @@ export async function confirmPhoneNumber(
150142export  async  function  sendPasswordResetEmail ( ui : FirebaseUIConfiguration ,  email : string ) : Promise < void >  { 
151143  try  { 
152144    ui . setState ( "pending" ) ; 
153-     await  _sendPasswordResetEmail ( ui . auth ,  email ) ; 
145+     await  getAuthImp ( ui ) . sendPasswordResetEmail ( ui . auth ,  email ) ; 
154146  }  catch  ( error )  { 
155147    handleFirebaseError ( ui ,  error ) ; 
156148  }  finally  { 
@@ -167,7 +159,7 @@ export async function sendSignInLinkToEmail(ui: FirebaseUIConfiguration, email:
167159    }  satisfies  ActionCodeSettings ; 
168160
169161    ui . setState ( "pending" ) ; 
170-     await  _sendSignInLinkToEmail ( ui . auth ,  email ,  actionCodeSettings ) ; 
162+     await  getAuthImp ( ui ) . sendSignInLinkToEmail ( ui . auth ,  email ,  actionCodeSettings ) ; 
171163    // TODO: Should this be a behavior ("storageStrategy")? 
172164    window . localStorage . setItem ( "emailForSignIn" ,  email ) ; 
173165  }  catch  ( error )  { 
@@ -193,7 +185,7 @@ export async function signInWithEmailLink(
193185    } 
194186
195187    ui . setState ( "pending" ) ; 
196-     const  result  =  await  signInWithCredential ( ui . auth ,  credential ) ; 
188+     const  result  =  await  getAuthImp ( ui ) . signInWithCredential ( ui . auth ,  credential ) ; 
197189    return  handlePendingCredential ( ui ,  result ) ; 
198190  }  catch  ( error )  { 
199191    handleFirebaseError ( ui ,  error ) ; 
@@ -205,7 +197,7 @@ export async function signInWithEmailLink(
205197export  async  function  signInAnonymously ( ui : FirebaseUIConfiguration ) : Promise < UserCredential >  { 
206198  try  { 
207199    ui . setState ( "pending" ) ; 
208-     const  result  =  await  _signInAnonymously ( ui . auth ) ; 
200+     const  result  =  await  getAuthImp ( ui ) . signInAnonymously ( ui . auth ) ; 
209201    return  handlePendingCredential ( ui ,  result ) ; 
210202  }  catch  ( error )  { 
211203    handleFirebaseError ( ui ,  error ) ; 
@@ -225,7 +217,7 @@ export async function signInWithProvider(ui: FirebaseUIConfiguration, provider:
225217    ui . setState ( "pending" ) ; 
226218
227219    // TODO(ehesp): Handle popup or redirect based on behavior 
228-     await  signInWithRedirect ( ui . auth ,  provider ) ; 
220+     await  getAuthImp ( ui ) . signInWithRedirect ( ui . auth ,  provider ) ; 
229221    // We don't modify state here since the user is redirected. 
230222    // If we support popups, we'd need to modify state here. 
231223  }  catch  ( error )  { 
@@ -240,15 +232,15 @@ export async function completeEmailLinkSignIn(
240232  currentUrl : string 
241233) : Promise < UserCredential  |  null >  { 
242234  try  { 
243-     if  ( ! _isSignInWithEmailLink ( ui . auth ,  currentUrl ) )  { 
235+     if  ( ! getAuthImp ( ui ) . isSignInWithEmailLink ( ui . auth ,  currentUrl ) )  { 
244236      return  null ; 
245237    } 
246238
247239    const  email  =  window . localStorage . getItem ( "emailForSignIn" ) ; 
248240    if  ( ! email )  return  null ; 
249241
250242    ui . setState ( "pending" ) ; 
251-     const  result  =  await  signInWithEmailLink ( ui ,  email ,  currentUrl ) ; 
243+     const  result  =  await  getAuthImp ( ui ) . signInWithEmailLink ( ui . auth ,  email ,  currentUrl ) ; 
252244    ui . setState ( "idle" ) ;  // TODO(ehesp): Do we need this here? 
253245    return  handlePendingCredential ( ui ,  result ) ; 
254246  }  catch  ( error )  { 
0 commit comments