55
55
static __strong NSMutableDictionary *emulatorConfigs;
56
56
// Used for caching credentials between method calls.
57
57
static __strong NSMutableDictionary <NSString *, FIRAuthCredential *> *credentials;
58
+ #if !TARGET_OS_TV
58
59
static __strong NSMutableDictionary <NSString *, FIRMultiFactorResolver *> *cachedResolver;
59
60
static __strong NSMutableDictionary <NSString *, FIRMultiFactorSession *> *cachedSessions;
61
+ #endif
60
62
61
63
@implementation RNFBAuthModule
62
64
#pragma mark -
@@ -76,8 +78,10 @@ - (id)init {
76
78
idTokenHandlers = [[NSMutableDictionary alloc ] init ];
77
79
emulatorConfigs = [[NSMutableDictionary alloc ] init ];
78
80
credentials = [[NSMutableDictionary alloc ] init ];
81
+ #if !TARGET_OS_TV
79
82
cachedResolver = [[NSMutableDictionary alloc ] init ];
80
83
cachedSessions = [[NSMutableDictionary alloc ] init ];
84
+ #endif
81
85
});
82
86
return self;
83
87
}
@@ -103,8 +107,10 @@ - (void)invalidate {
103
107
[idTokenHandlers removeAllObjects ];
104
108
105
109
[credentials removeAllObjects ];
110
+ #if !TARGET_OS_TV
106
111
[cachedResolver removeAllObjects ];
107
112
[cachedSessions removeAllObjects ];
113
+ #endif
108
114
}
109
115
110
116
#pragma mark -
@@ -415,6 +421,7 @@ - (void)invalidate {
415
421
}
416
422
}
417
423
424
+ #if !TARGET_OS_TV
418
425
RCT_EXPORT_METHOD (updatePhoneNumber
419
426
: (FIRApp *)firebaseApp
420
427
: (NSString *)provider
@@ -455,6 +462,7 @@ - (void)invalidate {
455
462
[self promiseNoUser: resolve rejecter: reject isError: YES ];
456
463
}
457
464
}
465
+ #endif
458
466
459
467
RCT_EXPORT_METHOD (updateProfile
460
468
: (FIRApp *)firebaseApp
@@ -617,6 +625,7 @@ - (void)invalidate {
617
625
[builder setCustomParameters: provider[@" customParameters" ]];
618
626
}
619
627
628
+ #if !TARGET_OS_TV
620
629
[builder getCredentialWithUIDelegate: nil
621
630
completion: ^(FIRAuthCredential *_Nullable credential,
622
631
NSError *_Nullable error) {
@@ -647,6 +656,7 @@ - (void)invalidate {
647
656
}];
648
657
}
649
658
}];
659
+ #endif
650
660
}
651
661
652
662
RCT_EXPORT_METHOD (confirmPasswordReset
@@ -817,6 +827,7 @@ - (void)invalidate {
817
827
}];
818
828
}
819
829
830
+ #if !TARGET_OS_TV
820
831
RCT_EXPORT_METHOD (signInWithPhoneNumber
821
832
: (FIRApp *)firebaseApp
822
833
: (NSString *)phoneNumber
@@ -1053,6 +1064,7 @@ - (void)invalidate {
1053
1064
}
1054
1065
}];
1055
1066
}
1067
+ #endif
1056
1068
1057
1069
RCT_EXPORT_METHOD (linkWithCredential
1058
1070
: (FIRApp *)firebaseApp
@@ -1122,6 +1134,7 @@ - (void)invalidate {
1122
1134
[builder setCustomParameters: provider[@" parameters" ]];
1123
1135
}
1124
1136
1137
+ #if !TARGET_OS_TV
1125
1138
[builder getCredentialWithUIDelegate: nil
1126
1139
completion: ^(FIRAuthCredential *_Nullable credential,
1127
1140
NSError *_Nullable error) {
@@ -1151,6 +1164,7 @@ - (void)invalidate {
1151
1164
}];
1152
1165
}
1153
1166
}];
1167
+ #endif
1154
1168
}
1155
1169
1156
1170
RCT_EXPORT_METHOD (unlink
@@ -1248,7 +1262,7 @@ - (void)invalidate {
1248
1262
if (provider[@" parameters" ]) {
1249
1263
[builder setCustomParameters: provider[@" parameters" ]];
1250
1264
}
1251
-
1265
+ # if !TARGET_OS_TV
1252
1266
[builder getCredentialWithUIDelegate: nil
1253
1267
completion: ^(FIRAuthCredential *_Nullable credential,
1254
1268
NSError *_Nullable error) {
@@ -1279,6 +1293,7 @@ - (void)invalidate {
1279
1293
}];
1280
1294
}
1281
1295
}];
1296
+ #endif
1282
1297
}
1283
1298
1284
1299
RCT_EXPORT_METHOD (fetchSignInMethodsForEmail
@@ -1375,10 +1390,12 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
1375
1390
} else if ([provider compare: @" github.com" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
1376
1391
credential = [FIRGitHubAuthProvider credentialWithToken: authToken];
1377
1392
} else if ([provider compare: @" phone" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
1393
+ #if !TARGET_OS_TV
1378
1394
DLog (@" using app credGen: %@ " , firebaseApp.name ) credential =
1379
1395
[[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
1380
1396
credentialWithVerificationID: authToken
1381
1397
verificationCode: authTokenSecret];
1398
+ #endif
1382
1399
} else if ([provider compare: @" oauth" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
1383
1400
credential = [FIROAuthProvider credentialWithProviderID: @" oauth"
1384
1401
IDToken: authToken
@@ -1423,6 +1440,7 @@ - (void)promiseNoUser:(RCTPromiseResolveBlock)resolve
1423
1440
}
1424
1441
}
1425
1442
1443
+ #if !TARGET_OS_TV
1426
1444
- (NSDictionary *)multiFactorResolverToDict : (FIRMultiFactorResolver *)resolver {
1427
1445
// Temporarily store the non-serializable session for later
1428
1446
NSString *sessionHash = [NSString stringWithFormat: @" %@ " , @([resolver.session hash ])];
@@ -1433,6 +1451,7 @@ - (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver {
1433
1451
@" auth" : resolver.auth
1434
1452
};
1435
1453
}
1454
+ #endif
1436
1455
1437
1456
- (NSString *)getJSFactorId : (NSString *)factorId {
1438
1457
if ([factorId isEqualToString: @" 1" ]) {
@@ -1542,14 +1561,17 @@ - (NSDictionary *)getJSError:(NSError *)error {
1542
1561
authCredentialDict = [self authCredentialToDict: authCredential];
1543
1562
}
1544
1563
1564
+
1545
1565
NSDictionary *resolverDict = nil ;
1566
+ #if !TARGET_OS_TV
1546
1567
if ([error userInfo ][FIRAuthErrorUserInfoMultiFactorResolverKey] != nil ) {
1547
1568
FIRMultiFactorResolver *resolver = error.userInfo [FIRAuthErrorUserInfoMultiFactorResolverKey];
1548
1569
resolverDict = [self multiFactorResolverToDict: resolver];
1549
1570
1550
1571
NSString *sessionKey = [NSString stringWithFormat: @" %@ " , @([resolver.session hash ])];
1551
1572
cachedResolver[sessionKey] = resolver;
1552
1573
}
1574
+ #endif
1553
1575
1554
1576
return @{
1555
1577
@" code" : code,
@@ -1696,11 +1718,14 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
1696
1718
@" refreshToken" : user.refreshToken ,
1697
1719
@" tenantId" : user.tenantID ? (id )user.tenantID : [NSNull null ],
1698
1720
keyUid : user.uid ,
1721
+ #if !TARGET_OS_TV
1699
1722
@" multiFactor" :
1700
1723
@{@" enrolledFactors" : [self convertMultiFactorData: user.multiFactor.enrolledFactors]}
1724
+ #endif
1701
1725
};
1702
1726
}
1703
1727
1728
+ #if !TARGET_OS_TV
1704
1729
- (NSArray <NSMutableDictionary *> *)convertMultiFactorData : (NSArray <FIRMultiFactorInfo *> *)hints {
1705
1730
NSMutableArray *enrolledFactors = [NSMutableArray array ];
1706
1731
@@ -1720,6 +1745,7 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
1720
1745
}
1721
1746
return enrolledFactors;
1722
1747
}
1748
+ #endif
1723
1749
1724
1750
- (NSDictionary *)authCredentialToDict : (FIRAuthCredential *)authCredential {
1725
1751
NSString *authCredentialHash = [NSString stringWithFormat: @" %@ " , @([authCredential hash ])];
0 commit comments