Skip to content

Commit

Permalink
fix(auth, tvOS): guard all phone & MFA with iOS-only compile ifdef
Browse files Browse the repository at this point in the history
this matches upstream style
  • Loading branch information
mikehardy committed Nov 2, 2024
1 parent 760080c commit 62d28d4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/auth/ios/RNFBAuth/RNFBAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
static __strong NSMutableDictionary *emulatorConfigs;
// Used for caching credentials between method calls.
static __strong NSMutableDictionary<NSString *, FIRAuthCredential *> *credentials;
#if !TARGET_OS_TV
#if TARGET_OS_IOS
static __strong NSMutableDictionary<NSString *, FIRMultiFactorResolver *> *cachedResolver;
static __strong NSMutableDictionary<NSString *, FIRMultiFactorSession *> *cachedSessions;
#endif
Expand All @@ -78,7 +78,7 @@ - (id)init {
idTokenHandlers = [[NSMutableDictionary alloc] init];
emulatorConfigs = [[NSMutableDictionary alloc] init];
credentials = [[NSMutableDictionary alloc] init];
#if !TARGET_OS_TV
#if TARGET_OS_IOS
cachedResolver = [[NSMutableDictionary alloc] init];
cachedSessions = [[NSMutableDictionary alloc] init];
#endif
Expand Down Expand Up @@ -107,7 +107,7 @@ - (void)invalidate {
[idTokenHandlers removeAllObjects];

[credentials removeAllObjects];
#if !TARGET_OS_TV
#if TARGET_OS_IOS
[cachedResolver removeAllObjects];
[cachedSessions removeAllObjects];
#endif
Expand Down Expand Up @@ -421,7 +421,7 @@ - (void)invalidate {
}
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
RCT_EXPORT_METHOD(updatePhoneNumber
: (FIRApp *)firebaseApp
: (NSString *)provider
Expand Down Expand Up @@ -625,7 +625,7 @@ - (void)invalidate {
[builder setCustomParameters:provider[@"customParameters"]];
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
[builder getCredentialWithUIDelegate:nil
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
Expand Down Expand Up @@ -827,7 +827,7 @@ - (void)invalidate {
}];
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
RCT_EXPORT_METHOD(signInWithPhoneNumber
: (FIRApp *)firebaseApp
: (NSString *)phoneNumber
Expand Down Expand Up @@ -1134,7 +1134,7 @@ - (void)invalidate {
[builder setCustomParameters:provider[@"parameters"]];
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
[builder getCredentialWithUIDelegate:nil
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
Expand Down Expand Up @@ -1262,7 +1262,7 @@ - (void)invalidate {
if (provider[@"parameters"]) {
[builder setCustomParameters:provider[@"parameters"]];
}
#if !TARGET_OS_TV
#if TARGET_OS_IOS
[builder getCredentialWithUIDelegate:nil
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
Expand Down Expand Up @@ -1390,7 +1390,7 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
} else if ([provider compare:@"github.com" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
credential = [FIRGitHubAuthProvider credentialWithToken:authToken];
} else if ([provider compare:@"phone" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
#if !TARGET_OS_TV
#if TARGET_OS_IOS
DLog(@"using app credGen: %@", firebaseApp.name) credential =
[[FIRPhoneAuthProvider providerWithAuth:[FIRAuth authWithApp:firebaseApp]]
credentialWithVerificationID:authToken
Expand Down Expand Up @@ -1440,7 +1440,7 @@ - (void)promiseNoUser:(RCTPromiseResolveBlock)resolve
}
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
- (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver {
// Temporarily store the non-serializable session for later
NSString *sessionHash = [NSString stringWithFormat:@"%@", @([resolver.session hash])];
Expand Down Expand Up @@ -1563,7 +1563,7 @@ - (NSDictionary *)getJSError:(NSError *)error {


NSDictionary *resolverDict = nil;
#if !TARGET_OS_TV
#if TARGET_OS_IOS
if ([error userInfo][FIRAuthErrorUserInfoMultiFactorResolverKey] != nil) {
FIRMultiFactorResolver *resolver = error.userInfo[FIRAuthErrorUserInfoMultiFactorResolverKey];
resolverDict = [self multiFactorResolverToDict:resolver];
Expand Down Expand Up @@ -1718,14 +1718,14 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
@"refreshToken" : user.refreshToken,
@"tenantId" : user.tenantID ? (id)user.tenantID : [NSNull null],
keyUid : user.uid,
#if !TARGET_OS_TV
#if TARGET_OS_IOS
@"multiFactor" :
@{@"enrolledFactors" : [self convertMultiFactorData:user.multiFactor.enrolledFactors]}
#endif
};
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
- (NSArray<NSMutableDictionary *> *)convertMultiFactorData:(NSArray<FIRMultiFactorInfo *> *)hints {
NSMutableArray *enrolledFactors = [NSMutableArray array];

Expand Down

0 comments on commit 62d28d4

Please sign in to comment.