@@ -31,8 +31,8 @@ function credentialFromResponse(
3131function attachExtraErrorFields ( auth : exp . Auth , e : FirebaseError ) : void {
3232 // The response contains all fields from the server which may or may not
3333 // actually match the underlying type
34- const response = ( ( e . customData as exp . TaggedWithTokenResponse | undefined )
35- ?. _tokenResponse as unknown ) as Record < string , string > ;
34+ const response = ( e . customData as exp . TaggedWithTokenResponse | undefined )
35+ ?. _tokenResponse as unknown as Record < string , string > ;
3636 if ( e . code === 'auth/multi-factor-auth-required' ) {
3737 const mfaErr = e as compat . MultiFactorError ;
3838 mfaErr . resolver = new MultiFactorResolver (
@@ -54,9 +54,9 @@ function attachExtraErrorFields(auth: exp.Auth, e: FirebaseError): void {
5454function credentialFromObject (
5555 object : FirebaseError | exp . UserCredential
5656) : exp . AuthCredential | null {
57- const { _tokenResponse } = ( object instanceof FirebaseError
58- ? object . customData
59- : object ) as exp . TaggedWithTokenResponse ;
57+ const { _tokenResponse } = (
58+ object instanceof FirebaseError ? object . customData : object
59+ ) as exp . TaggedWithTokenResponse ;
6060 if ( ! _tokenResponse ) {
6161 return null ;
6262 }
@@ -138,31 +138,32 @@ function credentialFromObject(
138138 : provider . credentialFromResult ( object ) ;
139139}
140140
141- export async function convertCredential (
141+ export function convertCredential (
142142 auth : exp . Auth ,
143143 credentialPromise : Promise < exp . UserCredential >
144144) : Promise < compat . UserCredential > {
145- let credential : exp . UserCredential ;
146- try {
147- credential = await credentialPromise ;
148- } catch ( e ) {
149- if ( e instanceof FirebaseError ) {
150- attachExtraErrorFields ( auth , e ) ;
151- }
152- throw e ;
153- }
154- const { operationType, user } = credential ;
155-
156- return {
157- operationType,
158- credential : credentialFromResponse (
159- credential as exp . UserCredentialInternal
160- ) ,
161- additionalUserInfo : exp . getAdditionalUserInfo (
162- credential as exp . UserCredential
163- ) ,
164- user : User . getOrCreate ( user )
165- } ;
145+ return credentialPromise
146+ . catch ( e => {
147+ if ( e instanceof FirebaseError ) {
148+ attachExtraErrorFields ( auth , e ) ;
149+ }
150+ throw e ;
151+ } )
152+ . then ( credential => {
153+ const operationType = credential . operationType ;
154+ const user = credential . user ;
155+
156+ return {
157+ operationType,
158+ credential : credentialFromResponse (
159+ credential as exp . UserCredentialInternal
160+ ) ,
161+ additionalUserInfo : exp . getAdditionalUserInfo (
162+ credential as exp . UserCredential
163+ ) ,
164+ user : User . getOrCreate ( user )
165+ } ;
166+ } ) ;
166167}
167168
168169export async function convertConfirmationResult (
0 commit comments