@@ -307,9 +307,8 @@ - (void)invalidate {
307
307
: (RCTPromiseResolveBlock)resolve
308
308
: (RCTPromiseRejectBlock)reject) {
309
309
FIRUser *user = [FIRAuth authWithApp: firebaseApp].currentUser ;
310
-
311
310
if (user) {
312
- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
311
+ [self reloadAndReturnUser: user resolver: resolve rejecter: reject firebaseApp: firebaseApp ];
313
312
} else {
314
313
[self promiseNoUser: resolve rejecter: reject isError: YES ];
315
314
}
@@ -383,7 +382,10 @@ - (void)invalidate {
383
382
if (error) {
384
383
[self promiseRejectAuthException: reject error: error];
385
384
} else {
386
- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
385
+ [self reloadAndReturnUser: user
386
+ resolver: resolve
387
+ rejecter: reject
388
+ firebaseApp: firebaseApp];
387
389
}
388
390
}];
389
391
} else {
@@ -426,7 +428,8 @@ - (void)invalidate {
426
428
FIRPhoneAuthCredential *credential =
427
429
(FIRPhoneAuthCredential *)[self getCredentialForProvider: provider
428
430
token: authToken
429
- secret: authSecret];
431
+ secret: authSecret
432
+ firebaseApp: firebaseApp];
430
433
431
434
if (credential == nil ) {
432
435
[RNFBSharedUtils
@@ -481,7 +484,7 @@ - (void)invalidate {
481
484
if (error) {
482
485
[self promiseRejectAuthException: reject error: error];
483
486
} else {
484
- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
487
+ [self reloadAndReturnUser: user resolver: resolve rejecter: reject firebaseApp: firebaseApp ];
485
488
}
486
489
}];
487
490
} else {
@@ -565,8 +568,8 @@ - (void)invalidate {
565
568
: (RCTPromiseRejectBlock)reject) {
566
569
FIRAuthCredential *credential = [self getCredentialForProvider: provider
567
570
token: authToken
568
- secret: authSecret];
569
-
571
+ secret: authSecret
572
+ firebaseApp: firebaseApp];
570
573
if (credential == nil ) {
571
574
[RNFBSharedUtils rejectPromiseWithUserInfo: reject
572
575
userInfo: (NSMutableDictionary *)@{
@@ -575,8 +578,7 @@ - (void)invalidate {
575
578
@" has expired or is not currently supported." ,
576
579
}];
577
580
}
578
-
579
- [[FIRAuth authWithApp: firebaseApp]
581
+ DLog (@" using app SignInWithCredential: %@ " , firebaseApp.name )[[FIRAuth authWithApp: firebaseApp]
580
582
signInWithCredential: credential
581
583
completion: ^(FIRAuthDataResult *authResult, NSError *error) {
582
584
if (error) {
@@ -602,7 +604,8 @@ - (void)invalidate {
602
604
}];
603
605
}
604
606
605
- __block FIROAuthProvider *builder = [FIROAuthProvider providerWithProviderID: providerId];
607
+ __block FIROAuthProvider *builder =
608
+ [FIROAuthProvider providerWithProviderID: providerId auth: [FIRAuth authWithApp: firebaseApp]];
606
609
// Add scopes if present
607
610
if (provider[@" scopes" ]) {
608
611
[builder setScopes: provider[@" scopes" ]];
@@ -620,7 +623,7 @@ - (void)invalidate {
620
623
return ;
621
624
}
622
625
if (credential) {
623
- [[FIRAuth auth ]
626
+ [[FIRAuth authWithApp: firebaseApp ]
624
627
signInWithCredential: credential
625
628
completion: ^(FIRAuthDataResult *_Nullable authResult,
626
629
NSError *_Nullable error) {
@@ -817,7 +820,8 @@ - (void)invalidate {
817
820
: (NSString *)phoneNumber
818
821
: (RCTPromiseResolveBlock)resolve
819
822
: (RCTPromiseRejectBlock)reject) {
820
- [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
823
+ DLog (@" SignInWthPhoneNumber instance: %@ " ,
824
+ firebaseApp.name )[[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
821
825
verifyPhoneNumber: phoneNumber
822
826
UIDelegate: nil
823
827
completion: ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
@@ -858,8 +862,8 @@ - (void)invalidate {
858
862
}];
859
863
return ;
860
864
}
861
-
862
- [ FIRPhoneAuthProvider.provider
865
+ DLog ( @" using instance verifyPhoneNumberWithMultiFactorInfo: %@ " ,
866
+ firebaseApp. name )[[ FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
863
867
verifyPhoneNumberWithMultiFactorInfo: hint
864
868
UIDelegate: nil
865
869
multiFactorSession: session
@@ -868,7 +872,8 @@ - (void)invalidate {
868
872
if (error) {
869
873
[self promiseRejectAuthException: reject error: error];
870
874
} else {
871
- resolve (verificationID);
875
+ DLog (@" verificationID: %@ " , verificationID)
876
+ resolve (verificationID);
872
877
}
873
878
}];
874
879
}
@@ -880,7 +885,8 @@ - (void)invalidate {
880
885
: (RCTPromiseResolveBlock)resolve
881
886
: (RCTPromiseRejectBlock)reject) {
882
887
FIRMultiFactorSession *session = cachedSessions[sessionId];
883
- [FIRPhoneAuthProvider.provider
888
+ DLog (@" using instance VerifyPhoneNumberForMultifactor: %@ " ,
889
+ firebaseApp.name )[[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
884
890
verifyPhoneNumber: phoneNumber
885
891
UIDelegate: nil
886
892
multiFactorSession: session
@@ -901,19 +907,22 @@ - (void)invalidate {
901
907
: (NSString *)verificationCode
902
908
: (RCTPromiseResolveBlock)resolve
903
909
: (RCTPromiseRejectBlock)reject) {
904
- FIRPhoneAuthCredential *credential =
905
- [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
906
- credentialWithVerificationID: verificationId
907
- verificationCode: verificationCode];
908
- FIRMultiFactorAssertion *assertion =
910
+ DLog (@" using instance resolve MultiFactorSignIn: %@ " , firebaseApp.name )
911
+ FIRPhoneAuthCredential *credential =
912
+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
913
+ credentialWithVerificationID: verificationId
914
+ verificationCode: verificationCode];
915
+ DLog (@" credential: %@ " , credential) FIRMultiFactorAssertion *assertion =
909
916
[FIRPhoneMultiFactorGenerator assertionWithCredential: credential];
917
+
910
918
[cachedResolver[sessionKey] resolveSignInWithAssertion: assertion
911
919
completion: ^(FIRAuthDataResult *_Nullable authResult,
912
920
NSError *_Nullable error) {
913
- if (error) {
921
+ DLog ( @" authError: %@ " , error) if (error) {
914
922
[self promiseRejectAuthException: reject
915
923
error: error];
916
- } else {
924
+ }
925
+ else {
917
926
[self promiseWithAuthResult: resolve
918
927
rejecter: reject
919
928
authResult: authResult];
@@ -946,9 +955,11 @@ - (void)invalidate {
946
955
: (NSString *_Nullable)displayName
947
956
: (RCTPromiseResolveBlock)resolve
948
957
: (RCTPromiseRejectBlock)reject) {
949
- FIRPhoneAuthCredential *credential =
950
- [FIRPhoneAuthProvider.provider credentialWithVerificationID: verificationId
951
- verificationCode: verificationCode];
958
+ DLog (@" using instance finalizeMultifactorEnrollment: %@ " , firebaseApp.name )
959
+ FIRPhoneAuthCredential *credential =
960
+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
961
+ credentialWithVerificationID: verificationId
962
+ verificationCode: verificationCode];
952
963
FIRMultiFactorAssertion *assertion =
953
964
[FIRPhoneMultiFactorGenerator assertionWithCredential: credential];
954
965
FIRUser *user = [FIRAuth authWithApp: firebaseApp].currentUser ;
@@ -969,12 +980,13 @@ - (void)invalidate {
969
980
: (FIRApp *)firebaseApp
970
981
: (NSString *)phoneNumber
971
982
: (NSString *)requestKey) {
972
- [FIRPhoneAuthProvider.provider
983
+ DLog (@" using instance verifyPhoneNumber: %@ " ,
984
+ firebaseApp.name )[[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
973
985
verifyPhoneNumber: phoneNumber
974
986
UIDelegate: nil
975
987
completion: ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
976
988
if (error) {
977
- NSDictionary *jsError = [self getJSError: ( error) ];
989
+ NSDictionary *jsError = [self getJSError: error];
978
990
NSDictionary *body = @{
979
991
@" type" : @" onVerificationFailed" ,
980
992
@" requestKey" : requestKey,
@@ -1007,12 +1019,14 @@ - (void)invalidate {
1007
1019
NSString *verificationId = [defaults stringForKey: @" authVerificationID" ];
1008
1020
1009
1021
FIRAuthCredential *credential =
1010
- [[FIRPhoneAuthProvider provider ] credentialWithVerificationID: verificationId
1011
- verificationCode: verificationCode];
1022
+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
1023
+ credentialWithVerificationID: verificationId
1024
+ verificationCode: verificationCode];
1012
1025
1013
1026
[[FIRAuth authWithApp: firebaseApp]
1014
1027
signInWithCredential: credential
1015
1028
completion: ^(FIRAuthDataResult *authResult, NSError *error) {
1029
+ DLog (@" auth error: %lo ng" , (long )error.code );
1016
1030
if (error) {
1017
1031
[self promiseRejectAuthException: reject error: error];
1018
1032
} else {
@@ -1030,7 +1044,8 @@ - (void)invalidate {
1030
1044
: (RCTPromiseRejectBlock)reject) {
1031
1045
FIRAuthCredential *credential = [self getCredentialForProvider: provider
1032
1046
token: authToken
1033
- secret: authSecret];
1047
+ secret: authSecret
1048
+ firebaseApp: firebaseApp];
1034
1049
1035
1050
if (credential == nil ) {
1036
1051
[RNFBSharedUtils rejectPromiseWithUserInfo: reject
@@ -1077,7 +1092,8 @@ - (void)invalidate {
1077
1092
return ;
1078
1093
}
1079
1094
1080
- __block FIROAuthProvider *builder = [FIROAuthProvider providerWithProviderID: providerId];
1095
+ __block FIROAuthProvider *builder =
1096
+ [FIROAuthProvider providerWithProviderID: providerId auth: [FIRAuth authWithApp: firebaseApp]];
1081
1097
// Add scopes if present
1082
1098
if (provider[@" scopes" ]) {
1083
1099
[builder setScopes: provider[@" scopes" ]];
@@ -1131,7 +1147,10 @@ - (void)invalidate {
1131
1147
if (error) {
1132
1148
[self promiseRejectAuthException: reject error: error];
1133
1149
} else {
1134
- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
1150
+ [self reloadAndReturnUser: user
1151
+ resolver: resolve
1152
+ rejecter: reject
1153
+ firebaseApp: firebaseApp];
1135
1154
}
1136
1155
}];
1137
1156
} else {
@@ -1148,7 +1167,8 @@ - (void)invalidate {
1148
1167
: (RCTPromiseRejectBlock)reject) {
1149
1168
FIRAuthCredential *credential = [self getCredentialForProvider: provider
1150
1169
token: authToken
1151
- secret: authSecret];
1170
+ secret: authSecret
1171
+ firebaseApp: firebaseApp];
1152
1172
1153
1173
if (credential == nil ) {
1154
1174
[RNFBSharedUtils rejectPromiseWithUserInfo: reject
@@ -1199,7 +1219,8 @@ - (void)invalidate {
1199
1219
return ;
1200
1220
}
1201
1221
1202
- __block FIROAuthProvider *builder = [FIROAuthProvider providerWithProviderID: providerId];
1222
+ __block FIROAuthProvider *builder =
1223
+ [FIROAuthProvider providerWithProviderID: providerId auth: [FIRAuth authWithApp: firebaseApp]];
1203
1224
// Add scopes if present
1204
1225
if (provider[@" scopes" ]) {
1205
1226
[builder setScopes: provider[@" scopes" ]];
@@ -1305,7 +1326,8 @@ - (void)invalidate {
1305
1326
1306
1327
- (FIRAuthCredential *)getCredentialForProvider : (NSString *)provider
1307
1328
token : (NSString *)authToken
1308
- secret : (NSString *)authTokenSecret {
1329
+ secret : (NSString *)authTokenSecret
1330
+ firebaseApp : (FIRApp *)firebaseApp {
1309
1331
FIRAuthCredential *credential;
1310
1332
1311
1333
// First check if we cached an authToken
@@ -1334,8 +1356,10 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
1334
1356
} else if ([provider compare: @" github.com" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
1335
1357
credential = [FIRGitHubAuthProvider credentialWithToken: authToken];
1336
1358
} else if ([provider compare: @" phone" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
1337
- credential = [[FIRPhoneAuthProvider provider ] credentialWithVerificationID: authToken
1338
- verificationCode: authTokenSecret];
1359
+ DLog (@" using app credGen: %@ " , firebaseApp.name ) credential =
1360
+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
1361
+ credentialWithVerificationID: authToken
1362
+ verificationCode: authTokenSecret];
1339
1363
} else if ([provider compare: @" oauth" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
1340
1364
credential = [FIROAuthProvider credentialWithProviderID: @" oauth"
1341
1365
IDToken: authToken
@@ -1355,7 +1379,8 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
1355
1379
// correctly refresh the user object when performing certain operations
1356
1380
- (void )reloadAndReturnUser : (FIRUser *)user
1357
1381
resolver : (RCTPromiseResolveBlock)resolve
1358
- rejecter : (RCTPromiseRejectBlock)reject {
1382
+ rejecter : (RCTPromiseRejectBlock)reject
1383
+ firebaseApp : (FIRApp *)firebaseApp {
1359
1384
[user reloadWithCompletion: ^(NSError *_Nullable error) {
1360
1385
if (error) {
1361
1386
[self promiseRejectAuthException: reject error: error];
@@ -1386,6 +1411,7 @@ - (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver {
1386
1411
return @{
1387
1412
@" hints" : [self convertMultiFactorData: resolver.hints],
1388
1413
@" session" : sessionHash,
1414
+ @" auth" : resolver.auth
1389
1415
};
1390
1416
}
1391
1417
@@ -1399,7 +1425,7 @@ - (NSString *)getJSFactorId:(NSString *)factorId {
1399
1425
}
1400
1426
1401
1427
- (void )promiseRejectAuthException : (RCTPromiseRejectBlock)reject error : (NSError *)error {
1402
- NSDictionary *jsError = [self getJSError: ( error) ];
1428
+ NSDictionary *jsError = [self getJSError: error];
1403
1429
1404
1430
[RNFBSharedUtils
1405
1431
rejectPromiseWithUserInfo: reject
@@ -1499,8 +1525,7 @@ - (NSDictionary *)getJSError:(NSError *)error {
1499
1525
1500
1526
NSDictionary *resolverDict = nil ;
1501
1527
if ([error userInfo ][FIRAuthErrorUserInfoMultiFactorResolverKey] != nil ) {
1502
- FIRMultiFactorResolver *resolver =
1503
- (FIRMultiFactorResolver *)error.userInfo [FIRAuthErrorUserInfoMultiFactorResolverKey];
1528
+ FIRMultiFactorResolver *resolver = error.userInfo [FIRAuthErrorUserInfoMultiFactorResolverKey];
1504
1529
resolverDict = [self multiFactorResolverToDict: resolver];
1505
1530
1506
1531
NSString *sessionKey = [NSString stringWithFormat: @" %@ " , @([resolver.session hash ])];
@@ -1665,7 +1690,7 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
1665
1690
[[[NSISO8601DateFormatter alloc ] init ] stringFromDate: hint.enrollmentDate];
1666
1691
[enrolledFactors addObject: @{
1667
1692
@" uid" : hint.UID ,
1668
- @" factorId" : hint. factorID == nil ? [ NSNull null ] : [self getJSFactorId: (hint.factorID)],
1693
+ @" factorId" : [self getJSFactorId: (hint.factorID)],
1669
1694
@" displayName" : hint.displayName == nil ? [NSNull null ] : hint.displayName ,
1670
1695
@" enrollmentDate" : enrollmentDate,
1671
1696
}];
@@ -1720,4 +1745,4 @@ - (FIRActionCodeSettings *)buildActionCodeSettings:(NSDictionary *)actionCodeSet
1720
1745
return settings;
1721
1746
}
1722
1747
1723
- @end
1748
+ @end
0 commit comments