@@ -31,8 +31,8 @@ function credentialFromResponse(
31
31
function attachExtraErrorFields ( auth : exp . Auth , e : FirebaseError ) : void {
32
32
// The response contains all fields from the server which may or may not
33
33
// 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 > ;
36
36
if ( e . code === 'auth/multi-factor-auth-required' ) {
37
37
const mfaErr = e as compat . MultiFactorError ;
38
38
mfaErr . resolver = new MultiFactorResolver (
@@ -54,9 +54,9 @@ function attachExtraErrorFields(auth: exp.Auth, e: FirebaseError): void {
54
54
function credentialFromObject (
55
55
object : FirebaseError | exp . UserCredential
56
56
) : 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 ;
60
60
if ( ! _tokenResponse ) {
61
61
return null ;
62
62
}
@@ -138,31 +138,32 @@ function credentialFromObject(
138
138
: provider . credentialFromResult ( object ) ;
139
139
}
140
140
141
- export async function convertCredential (
141
+ export function convertCredential (
142
142
auth : exp . Auth ,
143
143
credentialPromise : Promise < exp . UserCredential >
144
144
) : 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
+ } ) ;
166
167
}
167
168
168
169
export async function convertConfirmationResult (
0 commit comments