Browse Source

Update to clang-format@13 (#8739)

Paul Beusterien 4 years ago
parent
commit
c7c0149351

+ 1 - 1
.github/workflows/check.yml

@@ -3,7 +3,7 @@ name: check
 on:
   pull_request:
     paths-ignore:
-      - 'Firestore/**'
+    - 'Firestore/**'
   push:
     branches: master
 

+ 1 - 1
CONTRIBUTING.md

@@ -130,7 +130,7 @@ To develop Firebase software, **install**:
    To install [clang-format] and [mint] using [Homebrew]:
 
     ```console
-    brew install clang-format@12
+    brew install clang-format@13
     brew install mint
     ```
 

+ 27 - 25
Crashlytics/Shared/FIRCLSNetworking/FIRCLSFABNetworkClient.m

@@ -134,18 +134,20 @@ const NSUInteger FIRCLSNetworkMaximumRetryCount = 10;
                                   }
 
                                   [self
-                                    runAfterRetryValueFromResponse:response
-                                                          attempts:tries
-                                                             block:^{
-                                                               [self
-                                                                   startDataTaskWithRequest:request
-                                                                                 retryLimit:
-                                                                                     retryLimit
-                                                                                      tries:(tries +
+                                      runAfterRetryValueFromResponse:response
+                                                            attempts:tries
+                                                               block:^{
+                                                                 [self
+                                                                     startDataTaskWithRequest:
+                                                                         request
+                                                                                   retryLimit:
+                                                                                       retryLimit
+                                                                                        tries:
+                                                                                            (tries +
                                                                                              1)
-                                                                          completionHandler:
-                                                                              completionHandler];
-                                                             }];
+                                                                            completionHandler:
+                                                                                completionHandler];
+                                                               }];
                                 }];
         }];
 
@@ -209,20 +211,20 @@ const NSUInteger FIRCLSNetworkMaximumRetryCount = 10;
                                       }
 
                                       [self
-                                        runAfterRetryValueFromResponse:response
-                                                              attempts:tries
-                                                                 block:^{
-                                                                   [self
-                                                                       startDownloadTaskWithRequest:
-                                                                           request
-                                                                                         retryLimit:
-                                                                                             retryLimit
-                                                                                              tries:
-                                                                                                  (tries +
-                                                                                                   1)
-                                                                                  completionHandler:
-                                                                                      completionHandler];
-                                                                 }];
+                                          runAfterRetryValueFromResponse:response
+                                                                attempts:tries
+                                                                   block:^{
+                                                                     [self
+                                                                         startDownloadTaskWithRequest:
+                                                                             request
+                                                                                           retryLimit:
+                                                                                               retryLimit
+                                                                                                tries:
+                                                                                                    (tries +
+                                                                                                     1)
+                                                                                    completionHandler:
+                                                                                        completionHandler];
+                                                                   }];
                                     }];
             }];
 

+ 11 - 11
FirebaseAppDistribution/Sources/FIRFADApiService.m

@@ -47,20 +47,20 @@ NSString *const kResponseReleasesKey = @"releases";
       return;
     }
 
-    [installations
-      installationIDWithCompletion:^(NSString *__nullable identifier, NSError *__nullable error) {
-        if ([self handleError:&error
-                  description:@"Failed to fetch Firebase Installation ID."
-                         code:FIRFADApiInstallationIdentifierError]) {
-          FIRFADErrorLog(@"Error getting installation id. Error: %@", [error localizedDescription]);
+    [installations installationIDWithCompletion:^(NSString *__nullable identifier,
+                                                  NSError *__nullable error) {
+      if ([self handleError:&error
+                description:@"Failed to fetch Firebase Installation ID."
+                       code:FIRFADApiInstallationIdentifierError]) {
+        FIRFADErrorLog(@"Error getting installation id. Error: %@", [error localizedDescription]);
 
-          completion(nil, nil, error);
+        completion(nil, nil, error);
 
-          return;
-        }
+        return;
+      }
 
-        completion(identifier, authTokenResult, nil);
-      }];
+      completion(identifier, authTokenResult, nil);
+    }];
   }];
 }
 

+ 115 - 112
FirebaseAuth/Sources/Auth/FIRAuth.m

@@ -597,9 +597,9 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
                                    return;
                                  }
                                  [self
-                                   internalSignInAndRetrieveDataWithCredential:credential
-                                                            isReauthentication:NO
-                                                                      callback:decoratedCallback];
+                                     internalSignInAndRetrieveDataWithCredential:credential
+                                                              isReauthentication:NO
+                                                                        callback:decoratedCallback];
                                }];
   });
 #endif  // TARGET_OS_IOS
@@ -678,18 +678,18 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
     return;
   }
   [FIRAuthBackend
-    verifyPassword:request
-          callback:^(FIRVerifyPasswordResponse *_Nullable response, NSError *_Nullable error) {
-            if (error) {
-              callback(nil, error);
-              return;
-            }
-            [self completeSignInWithAccessToken:response.IDToken
-                      accessTokenExpirationDate:response.approximateExpirationDate
-                                   refreshToken:response.refreshToken
-                                      anonymous:NO
-                                       callback:callback];
-          }];
+      verifyPassword:request
+            callback:^(FIRVerifyPasswordResponse *_Nullable response, NSError *_Nullable error) {
+              if (error) {
+                callback(nil, error);
+                return;
+              }
+              [self completeSignInWithAccessToken:response.IDToken
+                        accessTokenExpirationDate:response.approximateExpirationDate
+                                     refreshToken:response.refreshToken
+                                        anonymous:NO
+                                         callback:callback];
+            }];
 }
 
 /** @fn internalSignInAndRetrieveDataWithEmail:password:callback:
@@ -739,31 +739,32 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
                     }
 
                     [self
-                      completeSignInWithAccessToken:response.IDToken
-                          accessTokenExpirationDate:response.approximateExpirationDate
-                                       refreshToken:response.refreshToken
-                                          anonymous:NO
-                                           callback:^(FIRUser *_Nullable user,
-                                                      NSError *_Nullable error) {
-                                             if (error && callback) {
-                                               callback(nil, error);
-                                               return;
-                                             }
-                                             FIRAdditionalUserInfo *additionalUserInfo =
-                                                 [[FIRAdditionalUserInfo alloc]
-                                                     initWithProviderID:FIRGameCenterAuthProviderID
-                                                                profile:nil
-                                                               username:nil
-                                                              isNewUser:response.isNewUser];
-                                             FIRAuthDataResult *result =
-                                                 user ? [[FIRAuthDataResult alloc]
-                                                                  initWithUser:user
-                                                            additionalUserInfo:additionalUserInfo]
-                                                      : nil;
-                                             if (callback) {
-                                               callback(result, error);
-                                             }
-                                           }];
+                        completeSignInWithAccessToken:response.IDToken
+                            accessTokenExpirationDate:response.approximateExpirationDate
+                                         refreshToken:response.refreshToken
+                                            anonymous:NO
+                                             callback:^(FIRUser *_Nullable user,
+                                                        NSError *_Nullable error) {
+                                               if (error && callback) {
+                                                 callback(nil, error);
+                                                 return;
+                                               }
+                                               FIRAdditionalUserInfo *additionalUserInfo =
+                                                   [[FIRAdditionalUserInfo alloc]
+                                                       initWithProviderID:
+                                                           FIRGameCenterAuthProviderID
+                                                                  profile:nil
+                                                                 username:nil
+                                                                isNewUser:response.isNewUser];
+                                               FIRAuthDataResult *result =
+                                                   user ? [[FIRAuthDataResult alloc]
+                                                                    initWithUser:user
+                                                              additionalUserInfo:additionalUserInfo]
+                                                        : nil;
+                                               if (callback) {
+                                                 callback(result, error);
+                                               }
+                                             }];
                   }];
 }
 
@@ -907,17 +908,18 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
     FIRPhoneAuthCredential *phoneCredential = (FIRPhoneAuthCredential *)credential;
     FIRAuthOperationType operation =
         isReauthentication ? FIRAuthOperationTypeReauth : FIRAuthOperationTypeSignUpOrSignIn;
-    [self signInWithPhoneCredential:phoneCredential
-                          operation:operation
-                           callback:^(FIRVerifyPhoneNumberResponse *_Nullable response,
-                                      NSError *_Nullable error) {
-                             if (callback) {
-                               if (error) {
-                                 callback(nil, error);
-                                 return;
-                               }
-
-                               [self
+    [self
+        signInWithPhoneCredential:phoneCredential
+                        operation:operation
+                         callback:^(FIRVerifyPhoneNumberResponse *_Nullable response,
+                                    NSError *_Nullable error) {
+                           if (callback) {
+                             if (error) {
+                               callback(nil, error);
+                               return;
+                             }
+
+                             [self
                                  completeSignInWithAccessToken:response.IDToken
                                      accessTokenExpirationDate:response.approximateExpirationDate
                                                   refreshToken:response.refreshToken
@@ -946,8 +948,8 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
                                                           callback(result, error);
                                                         }
                                                       }];
-                             }
-                           }];
+                           }
+                         }];
     return;
   }
 #endif
@@ -987,32 +989,33 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
                  return;
                }
                [self
-                 completeSignInWithAccessToken:response.IDToken
-                     accessTokenExpirationDate:response.approximateExpirationDate
-                                  refreshToken:response.refreshToken
-                                     anonymous:NO
-                                      callback:^(FIRUser *_Nullable user,
-                                                 NSError *_Nullable error) {
-                                        if (callback) {
-                                          if (error) {
-                                            callback(nil, error);
-                                            return;
+                   completeSignInWithAccessToken:response.IDToken
+                       accessTokenExpirationDate:response.approximateExpirationDate
+                                    refreshToken:response.refreshToken
+                                       anonymous:NO
+                                        callback:^(FIRUser *_Nullable user,
+                                                   NSError *_Nullable error) {
+                                          if (callback) {
+                                            if (error) {
+                                              callback(nil, error);
+                                              return;
+                                            }
+                                            FIRAdditionalUserInfo *additionalUserInfo =
+                                                [FIRAdditionalUserInfo
+                                                    userInfoWithVerifyAssertionResponse:response];
+                                            FIROAuthCredential *updatedOAuthCredential =
+                                                [[FIROAuthCredential alloc]
+                                                    initWithVerifyAssertionResponse:response];
+                                            FIRAuthDataResult *result =
+                                                user
+                                                    ? [[FIRAuthDataResult alloc]
+                                                                initWithUser:user
+                                                          additionalUserInfo:additionalUserInfo
+                                                                  credential:updatedOAuthCredential]
+                                                    : nil;
+                                            callback(result, error);
                                           }
-                                          FIRAdditionalUserInfo *additionalUserInfo =
-                                              [FIRAdditionalUserInfo
-                                                  userInfoWithVerifyAssertionResponse:response];
-                                          FIROAuthCredential *updatedOAuthCredential =
-                                              [[FIROAuthCredential alloc]
-                                                  initWithVerifyAssertionResponse:response];
-                                          FIRAuthDataResult *result =
-                                              user ? [[FIRAuthDataResult alloc]
-                                                               initWithUser:user
-                                                         additionalUserInfo:additionalUserInfo
-                                                                 credential:updatedOAuthCredential]
-                                                   : nil;
-                                          callback(result, error);
-                                        }
-                                      }];
+                                        }];
              }];
 }
 
@@ -1085,31 +1088,31 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
                                return;
                              }
                              [self
-                               completeSignInWithAccessToken:response.IDToken
-                                   accessTokenExpirationDate:response.approximateExpirationDate
-                                                refreshToken:response.refreshToken
-                                                   anonymous:NO
-                                                    callback:^(FIRUser *_Nullable user,
-                                                               NSError *_Nullable error) {
-                                                      if (error) {
-                                                        decoratedCallback(nil, error);
-                                                        return;
-                                                      }
-                                                      FIRAdditionalUserInfo *additionalUserInfo =
-                                                          [[FIRAdditionalUserInfo alloc]
-                                                              initWithProviderID:
-                                                                  FIREmailAuthProviderID
-                                                                         profile:nil
-                                                                        username:nil
-                                                                       isNewUser:YES];
-                                                      FIRAuthDataResult *authDataResult =
-                                                          user ? [[FIRAuthDataResult alloc]
-                                                                           initWithUser:user
-                                                                     additionalUserInfo:
-                                                                         additionalUserInfo]
-                                                               : nil;
-                                                      decoratedCallback(authDataResult, error);
-                                                    }];
+                                 completeSignInWithAccessToken:response.IDToken
+                                     accessTokenExpirationDate:response.approximateExpirationDate
+                                                  refreshToken:response.refreshToken
+                                                     anonymous:NO
+                                                      callback:^(FIRUser *_Nullable user,
+                                                                 NSError *_Nullable error) {
+                                                        if (error) {
+                                                          decoratedCallback(nil, error);
+                                                          return;
+                                                        }
+                                                        FIRAdditionalUserInfo *additionalUserInfo =
+                                                            [[FIRAdditionalUserInfo alloc]
+                                                                initWithProviderID:
+                                                                    FIREmailAuthProviderID
+                                                                           profile:nil
+                                                                          username:nil
+                                                                         isNewUser:YES];
+                                                        FIRAuthDataResult *authDataResult =
+                                                            user ? [[FIRAuthDataResult alloc]
+                                                                             initWithUser:user
+                                                                       additionalUserInfo:
+                                                                           additionalUserInfo]
+                                                                 : nil;
+                                                        decoratedCallback(authDataResult, error);
+                                                      }];
                            }];
   });
 }
@@ -1835,9 +1838,9 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
                                                       rescheduleDelay = 60;
                                                     }
                                                     [strongSelf
-                                                      scheduleAutoTokenRefreshWithDelay:
-                                                          rescheduleDelay
-                                                                                  retry:YES];
+                                                        scheduleAutoTokenRefreshWithDelay:
+                                                            rescheduleDelay
+                                                                                    retry:YES];
                                                   }
                                                 }];
                     }];
@@ -2180,12 +2183,12 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
     }
     // Call back with current user token.
     [strongSelf->_currentUser
-      internalGetTokenForcingRefresh:forceRefresh
-                            callback:^(NSString *_Nullable token, NSError *_Nullable error) {
-                              dispatch_async(dispatch_get_main_queue(), ^{
-                                callback(token, error);
-                              });
-                            }];
+        internalGetTokenForcingRefresh:forceRefresh
+                              callback:^(NSString *_Nullable token, NSError *_Nullable error) {
+                                dispatch_async(dispatch_get_main_queue(), ^{
+                                  callback(token, error);
+                                });
+                              }];
   });
 }
 

+ 25 - 25
FirebaseAuth/Sources/AuthProvider/GameCenter/FIRGameCenterAuthProvider.m

@@ -55,36 +55,36 @@ NS_ASSUME_NONNULL_BEGIN
     return;
   }
 
-  [localPlayer
-    generateIdentityVerificationSignatureWithCompletionHandler:^(
-        NSURL *publicKeyURL, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error) {
-      if (error) {
-        if (completion) {
-          completion(nil, error);
-        }
-      } else {
-        if (completion) {
-          /**
-           @c `localPlayer.alias` is actually the displayname needed, instead of
-           `localPlayer.displayname`. For more information, check
-           https://developer.apple.com/documentation/gamekit/gkplayer
-           **/
-          NSString *displayName = localPlayer.alias;
+  [localPlayer generateIdentityVerificationSignatureWithCompletionHandler:^(
+                   NSURL *publicKeyURL, NSData *signature, NSData *salt, uint64_t timestamp,
+                   NSError *error) {
+    if (error) {
+      if (completion) {
+        completion(nil, error);
+      }
+    } else {
+      if (completion) {
+        /**
+         @c `localPlayer.alias` is actually the displayname needed, instead of
+         `localPlayer.displayname`. For more information, check
+         https://developer.apple.com/documentation/gamekit/gkplayer
+         **/
+        NSString *displayName = localPlayer.alias;
 // iOS 13 deprecation
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-          FIRGameCenterAuthCredential *credential =
-              [[FIRGameCenterAuthCredential alloc] initWithPlayerID:localPlayer.playerID
-                                                       publicKeyURL:publicKeyURL
-                                                          signature:signature
-                                                               salt:salt
-                                                          timestamp:timestamp
-                                                        displayName:displayName];
+        FIRGameCenterAuthCredential *credential =
+            [[FIRGameCenterAuthCredential alloc] initWithPlayerID:localPlayer.playerID
+                                                     publicKeyURL:publicKeyURL
+                                                        signature:signature
+                                                             salt:salt
+                                                        timestamp:timestamp
+                                                      displayName:displayName];
 #pragma clang diagnostic pop
-          completion(credential, nil);
-        }
+        completion(credential, nil);
       }
-    }];
+    }
+  }];
 }
 
 @end

+ 195 - 192
FirebaseAuth/Sources/AuthProvider/Phone/FIRPhoneAuthProvider.m

@@ -305,22 +305,22 @@ extern NSString *const FIRPhoneMultiFactorID;
     return;
   }
   [_auth.notificationManager
-    checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
-      if (!isNotificationBeingForwarded) {
-        completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
-        return;
-      }
-      FIRVerificationResultCallback callback =
-          ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
-            if (completion) {
-              completion(verificationID, error);
-            }
-          };
-      [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
-                                 retryOnInvalidAppCredential:YES
-                                                  UIDelegate:UIDelegate
-                                                    callback:callback];
-    }];
+      checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
+        if (!isNotificationBeingForwarded) {
+          completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
+          return;
+        }
+        FIRVerificationResultCallback callback =
+            ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
+              if (completion) {
+                completion(verificationID, error);
+              }
+            };
+        [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
+                                   retryOnInvalidAppCredential:YES
+                                                    UIDelegate:UIDelegate
+                                                      callback:callback];
+      }];
 }
 
 - (void)internalVerifyPhoneNumber:(NSString *)phoneNumber
@@ -334,25 +334,25 @@ extern NSString *const FIRPhoneMultiFactorID;
     return;
   }
   [_auth.notificationManager
-    checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
-      if (!isNotificationBeingForwarded) {
-        if (completion) {
-          completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
+      checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
+        if (!isNotificationBeingForwarded) {
+          if (completion) {
+            completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
+          }
+          return;
         }
-        return;
-      }
-      FIRVerificationResultCallback callback =
-          ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
-            if (completion) {
-              completion(verificationID, error);
-            }
-          };
-      [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
-                                 retryOnInvalidAppCredential:YES
-                                                  UIDelegate:UIDelegate
-                                          multiFactorSession:session
-                                                    callback:callback];
-    }];
+        FIRVerificationResultCallback callback =
+            ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
+              if (completion) {
+                completion(verificationID, error);
+              }
+            };
+        [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
+                                   retryOnInvalidAppCredential:YES
+                                                    UIDelegate:UIDelegate
+                                            multiFactorSession:session
+                                                      callback:callback];
+      }];
 }
 
 /** @fn verifyClientAndSendVerificationCodeToPhoneNumber:retryOnInvalidAppCredential:callback:
@@ -381,64 +381,66 @@ extern NSString *const FIRPhoneMultiFactorID;
     return;
   }
   [self
-    verifyClientWithUIDelegate:UIDelegate
-                    completion:^(FIRAuthAppCredential *_Nullable appCredential,
-                                 NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
-                      if (error) {
-                        callback(nil, error);
-                        return;
-                      }
-                      FIRSendVerificationCodeRequest *_Nullable request;
-                      if (appCredential) {
-                        request = [[FIRSendVerificationCodeRequest alloc]
-                             initWithPhoneNumber:phoneNumber
-                                   appCredential:appCredential
-                                  reCAPTCHAToken:nil
-                            requestConfiguration:self->_auth.requestConfiguration];
-                      } else if (reCAPTCHAToken) {
-                        request = [[FIRSendVerificationCodeRequest alloc]
-                             initWithPhoneNumber:phoneNumber
-                                   appCredential:nil
-                                  reCAPTCHAToken:reCAPTCHAToken
-                            requestConfiguration:self->_auth.requestConfiguration];
-                      }
-                      if (request) {
-                        [FIRAuthBackend
-                            sendVerificationCode:request
-                                        callback:^(
-                                            FIRSendVerificationCodeResponse *_Nullable response,
-                                            NSError *_Nullable error) {
-                                          if (error) {
-                                            if (error.code ==
-                                                FIRAuthErrorCodeInvalidAppCredential) {
-                                              if (retryOnInvalidAppCredential) {
-                                                [self->_auth.appCredentialManager clearCredential];
-                                                [self
-                                                    verifyClientAndSendVerificationCodeToPhoneNumber:
-                                                        phoneNumber
-                                                                         retryOnInvalidAppCredential:
-                                                                             NO
-                                                                                          UIDelegate:
-                                                                                              UIDelegate
-                                                                                            callback:
-                                                                                                callback];
+      verifyClientWithUIDelegate:UIDelegate
+                      completion:^(FIRAuthAppCredential *_Nullable appCredential,
+                                   NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
+                        if (error) {
+                          callback(nil, error);
+                          return;
+                        }
+                        FIRSendVerificationCodeRequest *_Nullable request;
+                        if (appCredential) {
+                          request = [[FIRSendVerificationCodeRequest alloc]
+                               initWithPhoneNumber:phoneNumber
+                                     appCredential:appCredential
+                                    reCAPTCHAToken:nil
+                              requestConfiguration:self->_auth.requestConfiguration];
+                        } else if (reCAPTCHAToken) {
+                          request = [[FIRSendVerificationCodeRequest alloc]
+                               initWithPhoneNumber:phoneNumber
+                                     appCredential:nil
+                                    reCAPTCHAToken:reCAPTCHAToken
+                              requestConfiguration:self->_auth.requestConfiguration];
+                        }
+                        if (request) {
+                          [FIRAuthBackend
+                              sendVerificationCode:request
+                                          callback:^(
+                                              FIRSendVerificationCodeResponse *_Nullable response,
+                                              NSError *_Nullable error) {
+                                            if (error) {
+                                              if (error.code ==
+                                                  FIRAuthErrorCodeInvalidAppCredential) {
+                                                if (retryOnInvalidAppCredential) {
+                                                  [self->_auth
+                                                          .appCredentialManager clearCredential];
+                                                  [self
+                                                      verifyClientAndSendVerificationCodeToPhoneNumber:
+                                                          phoneNumber
+                                                                           retryOnInvalidAppCredential:
+                                                                               NO
+                                                                                            UIDelegate:
+                                                                                                UIDelegate
+                                                                                              callback:
+                                                                                                  callback];
+                                                  return;
+                                                }
+                                                callback(
+                                                    nil,
+                                                    [FIRAuthErrorUtils
+                                                        unexpectedResponseWithDeserializedResponse:
+                                                            nil
+                                                                                   underlyingError:
+                                                                                       error]);
                                                 return;
                                               }
-                                              callback(
-                                                  nil,
-                                                  [FIRAuthErrorUtils
-                                                      unexpectedResponseWithDeserializedResponse:nil
-                                                                                 underlyingError:
-                                                                                     error]);
+                                              callback(nil, error);
                                               return;
                                             }
-                                            callback(nil, error);
-                                            return;
-                                          }
-                                          callback(response.verificationID, nil);
-                                        }];
-                      }
-                    }];
+                                            callback(response.verificationID, nil);
+                                          }];
+                        }
+                      }];
 }
 
 - (void)verifyClientAndSendVerificationCodeToPhoneNumber:(NSString *)phoneNumber
@@ -461,127 +463,128 @@ extern NSString *const FIRPhoneMultiFactorID;
   }
 
   [self
-    verifyClientWithUIDelegate:UIDelegate
-                    completion:^(FIRAuthAppCredential *_Nullable appCredential,
-                                 NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
-                      if (error) {
-                        if (callback) {
-                          callback(nil, error);
+      verifyClientWithUIDelegate:UIDelegate
+                      completion:^(FIRAuthAppCredential *_Nullable appCredential,
+                                   NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
+                        if (error) {
+                          if (callback) {
+                            callback(nil, error);
+                          }
+                          return;
                         }
-                        return;
-                      }
-
-                      NSString *IDToken = session.IDToken;
-                      FIRAuthProtoStartMFAPhoneRequestInfo *startMFARequestInfo =
-                          [[FIRAuthProtoStartMFAPhoneRequestInfo alloc]
-                              initWithPhoneNumber:phoneNumber
-                                    appCredential:appCredential
-                                   reCAPTCHAToken:reCAPTCHAToken];
-                      if (session.IDToken) {
-                        FIRStartMFAEnrollmentRequest *request =
-                            [[FIRStartMFAEnrollmentRequest alloc]
-                                     initWithIDToken:IDToken
-                                      enrollmentInfo:startMFARequestInfo
-                                requestConfiguration:self->_auth.requestConfiguration];
-                        [FIRAuthBackend
-                            startMultiFactorEnrollment:request
-                                              callback:^(
-                                                  FIRStartMFAEnrollmentResponse *_Nullable response,
-                                                  NSError *_Nullable error) {
-                                                if (error) {
-                                                  if (error.code ==
-                                                      FIRAuthErrorCodeInvalidAppCredential) {
-                                                    if (retryOnInvalidAppCredential) {
-                                                      [self->_auth.appCredentialManager
-                                                              clearCredential];
-                                                      [self
-                                                          verifyClientAndSendVerificationCodeToPhoneNumber:
-                                                              phoneNumber
-                                                                               retryOnInvalidAppCredential:
-                                                                                   NO
-                                                                                                UIDelegate:
-                                                                                                    UIDelegate
-                                                                                        multiFactorSession:
-                                                                                            session
-                                                                                                  callback:
-                                                                                                      callback];
+
+                        NSString *IDToken = session.IDToken;
+                        FIRAuthProtoStartMFAPhoneRequestInfo *startMFARequestInfo =
+                            [[FIRAuthProtoStartMFAPhoneRequestInfo alloc]
+                                initWithPhoneNumber:phoneNumber
+                                      appCredential:appCredential
+                                     reCAPTCHAToken:reCAPTCHAToken];
+                        if (session.IDToken) {
+                          FIRStartMFAEnrollmentRequest *request =
+                              [[FIRStartMFAEnrollmentRequest alloc]
+                                       initWithIDToken:IDToken
+                                        enrollmentInfo:startMFARequestInfo
+                                  requestConfiguration:self->_auth.requestConfiguration];
+                          [FIRAuthBackend
+                              startMultiFactorEnrollment:request
+                                                callback:^(FIRStartMFAEnrollmentResponse
+                                                               *_Nullable response,
+                                                           NSError *_Nullable error) {
+                                                  if (error) {
+                                                    if (error.code ==
+                                                        FIRAuthErrorCodeInvalidAppCredential) {
+                                                      if (retryOnInvalidAppCredential) {
+                                                        [self->_auth.appCredentialManager
+                                                                clearCredential];
+                                                        [self
+                                                            verifyClientAndSendVerificationCodeToPhoneNumber:
+                                                                phoneNumber
+                                                                                 retryOnInvalidAppCredential:
+                                                                                     NO
+                                                                                                  UIDelegate:
+                                                                                                      UIDelegate
+                                                                                          multiFactorSession:
+                                                                                              session
+                                                                                                    callback:
+                                                                                                        callback];
+                                                        return;
+                                                      }
+                                                      if (callback) {
+                                                        callback(
+                                                            nil,
+                                                            [FIRAuthErrorUtils
+                                                                unexpectedResponseWithDeserializedResponse:
+                                                                    nil
+                                                                                           underlyingError:
+                                                                                               error]);
+                                                      }
                                                       return;
+                                                    } else {
+                                                      if (callback) {
+                                                        callback(nil, error);
+                                                      }
                                                     }
+                                                  } else {
                                                     if (callback) {
                                                       callback(
-                                                          nil,
-                                                          [FIRAuthErrorUtils
-                                                              unexpectedResponseWithDeserializedResponse:
-                                                                  nil
-                                                                                         underlyingError:
-                                                                                             error]);
+                                                          response.enrollmentResponse.sessionInfo,
+                                                          nil);
                                                     }
+                                                  }
+                                                }];
+                        } else {
+                          FIRStartMFASignInRequest *request = [[FIRStartMFASignInRequest alloc]
+                              initWithMFAPendingCredential:session.MFAPendingCredential
+                                           MFAEnrollmentID:session.multiFactorInfo.UID
+                                                signInInfo:startMFARequestInfo
+                                      requestConfiguration:self->_auth.requestConfiguration];
+                          [FIRAuthBackend
+                              startMultiFactorSignIn:request
+                                            callback:^(
+                                                FIRStartMFASignInResponse *_Nullable response,
+                                                NSError *_Nullable error) {
+                                              if (error) {
+                                                if (error.code ==
+                                                    FIRAuthErrorCodeInvalidAppCredential) {
+                                                  if (retryOnInvalidAppCredential) {
+                                                    [self->_auth
+                                                            .appCredentialManager clearCredential];
+                                                    [self
+                                                        verifyClientAndSendVerificationCodeToPhoneNumber:
+                                                            phoneNumber
+                                                                             retryOnInvalidAppCredential:
+                                                                                 NO
+                                                                                              UIDelegate:
+                                                                                                  UIDelegate
+                                                                                      multiFactorSession:
+                                                                                          session
+                                                                                                callback:
+                                                                                                    callback];
                                                     return;
-                                                  } else {
-                                                    if (callback) {
-                                                      callback(nil, error);
-                                                    }
                                                   }
-                                                } else {
                                                   if (callback) {
                                                     callback(
-                                                        response.enrollmentResponse.sessionInfo,
-                                                        nil);
+                                                        nil,
+                                                        [FIRAuthErrorUtils
+                                                            unexpectedResponseWithDeserializedResponse:
+                                                                nil
+                                                                                       underlyingError:
+                                                                                           error]);
                                                   }
-                                                }
-                                              }];
-                      } else {
-                        FIRStartMFASignInRequest *request = [[FIRStartMFASignInRequest alloc]
-                            initWithMFAPendingCredential:session.MFAPendingCredential
-                                         MFAEnrollmentID:session.multiFactorInfo.UID
-                                              signInInfo:startMFARequestInfo
-                                    requestConfiguration:self->_auth.requestConfiguration];
-                        [FIRAuthBackend
-                            startMultiFactorSignIn:request
-                                          callback:^(FIRStartMFASignInResponse *_Nullable response,
-                                                     NSError *_Nullable error) {
-                                            if (error) {
-                                              if (error.code ==
-                                                  FIRAuthErrorCodeInvalidAppCredential) {
-                                                if (retryOnInvalidAppCredential) {
-                                                  [self->_auth
-                                                          .appCredentialManager clearCredential];
-                                                  [self
-                                                      verifyClientAndSendVerificationCodeToPhoneNumber:
-                                                          phoneNumber
-                                                                           retryOnInvalidAppCredential:
-                                                                               NO
-                                                                                            UIDelegate:
-                                                                                                UIDelegate
-                                                                                    multiFactorSession:
-                                                                                        session
-                                                                                              callback:
-                                                                                                  callback];
                                                   return;
+                                                } else {
+                                                  if (callback) {
+                                                    callback(nil, error);
+                                                  }
                                                 }
-                                                if (callback) {
-                                                  callback(
-                                                      nil,
-                                                      [FIRAuthErrorUtils
-                                                          unexpectedResponseWithDeserializedResponse:
-                                                              nil
-                                                                                     underlyingError:
-                                                                                         error]);
-                                                }
-                                                return;
                                               } else {
                                                 if (callback) {
-                                                  callback(nil, error);
+                                                  callback(response.responseInfo.sessionInfo, nil);
                                                 }
                                               }
-                                            } else {
-                                              if (callback) {
-                                                callback(response.responseInfo.sessionInfo, nil);
-                                              }
-                                            }
-                                          }];
-                      }
-                    }];
+                                            }];
+                        }
+                      }];
 }
 
 /** @fn verifyClientWithCompletion:completion:

+ 111 - 109
FirebaseAuth/Sources/Backend/FIRAuthBackend.m

@@ -1019,125 +1019,127 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
   }
 
   [_RPCIssuer
-    asyncPostToURLWithRequestConfiguration:[request requestConfiguration]
-                                       URL:[request requestURL]
-                                      body:bodyData
-                               contentType:kJSONContentType
-                         completionHandler:^(NSData *data, NSError *error) {
-                           // If there is an error with no body data at all, then this must be a
-                           // network error.
-                           if (error && !data) {
-                             callback([FIRAuthErrorUtils networkErrorWithUnderlyingError:error]);
-                             return;
-                           }
-
-                           // Try to decode the HTTP response data which may contain either a
-                           // successful response or error message.
-                           NSError *jsonError;
-                           NSDictionary *dictionary =
-                               [NSJSONSerialization JSONObjectWithData:data
-                                                               options:NSJSONReadingMutableLeaves
-                                                                 error:&jsonError];
-                           if (!dictionary) {
-                             if (error) {
-                               // We have an error, but we couldn't decode the body, so we have no
-                               // additional information other than the raw response and the
-                               // original NSError (the jsonError is infered by the error code
-                               // (FIRAuthErrorCodeUnexpectedHTTPResponse, and is irrelevant.)
-                               callback([FIRAuthErrorUtils unexpectedErrorResponseWithData:data
-                                                                           underlyingError:error]);
-                             } else {
-                               // This is supposed to be a "successful" response, but we couldn't
-                               // deserialize the body.
-                               callback([FIRAuthErrorUtils unexpectedResponseWithData:data
-                                                                      underlyingError:jsonError]);
+      asyncPostToURLWithRequestConfiguration:[request requestConfiguration]
+                                         URL:[request requestURL]
+                                        body:bodyData
+                                 contentType:kJSONContentType
+                           completionHandler:^(NSData *data, NSError *error) {
+                             // If there is an error with no body data at all, then this must be a
+                             // network error.
+                             if (error && !data) {
+                               callback([FIRAuthErrorUtils networkErrorWithUnderlyingError:error]);
+                               return;
+                             }
+
+                             // Try to decode the HTTP response data which may contain either a
+                             // successful response or error message.
+                             NSError *jsonError;
+                             NSDictionary *dictionary =
+                                 [NSJSONSerialization JSONObjectWithData:data
+                                                                 options:NSJSONReadingMutableLeaves
+                                                                   error:&jsonError];
+                             if (!dictionary) {
+                               if (error) {
+                                 // We have an error, but we couldn't decode the body, so we have no
+                                 // additional information other than the raw response and the
+                                 // original NSError (the jsonError is infered by the error code
+                                 // (FIRAuthErrorCodeUnexpectedHTTPResponse, and is irrelevant.)
+                                 callback([FIRAuthErrorUtils
+                                     unexpectedErrorResponseWithData:data
+                                                     underlyingError:error]);
+                               } else {
+                                 // This is supposed to be a "successful" response, but we couldn't
+                                 // deserialize the body.
+                                 callback([FIRAuthErrorUtils unexpectedResponseWithData:data
+                                                                        underlyingError:jsonError]);
+                               }
+                               return;
+                             }
+                             if (![dictionary isKindOfClass:[NSDictionary class]]) {
+                               if (error) {
+                                 callback([FIRAuthErrorUtils
+                                     unexpectedErrorResponseWithDeserializedResponse:dictionary
+                                                                     underlyingError:error]);
+                               } else {
+                                 callback([FIRAuthErrorUtils
+                                     unexpectedResponseWithDeserializedResponse:dictionary]);
+                               }
+                               return;
                              }
-                             return;
-                           }
-                           if (![dictionary isKindOfClass:[NSDictionary class]]) {
+
+                             // At this point we either have an error with successfully decoded
+                             // details in the body, or we have a response which must pass further
+                             // validation before we know it's truly successful. We deal with the
+                             // case where we have an error with successfully decoded error details
+                             // first:
                              if (error) {
+                               NSDictionary *errorDictionary = dictionary[kErrorKey];
+                               if ([errorDictionary isKindOfClass:[NSDictionary class]]) {
+                                 id<NSObject> errorMessage = errorDictionary[kErrorMessageKey];
+                                 if ([errorMessage isKindOfClass:[NSString class]]) {
+                                   NSString *errorMessageString = (NSString *)errorMessage;
+
+                                   // Contruct client error.
+                                   NSError *clientError = [[self class]
+                                       clientErrorWithServerErrorMessage:errorMessageString
+                                                         errorDictionary:errorDictionary
+                                                                response:response];
+                                   if (clientError) {
+                                     callback(clientError);
+                                     return;
+                                   }
+                                 }
+                                 // Not a message we know, return the message directly.
+                                 if (errorMessage) {
+                                   NSError *unexpecterErrorResponse = [FIRAuthErrorUtils
+                                       unexpectedErrorResponseWithDeserializedResponse:
+                                           errorDictionary
+                                                                       underlyingError:error];
+                                   callback(unexpecterErrorResponse);
+                                   return;
+                                 }
+                               }
+                               // No error message at all, return the decoded response.
                                callback([FIRAuthErrorUtils
                                    unexpectedErrorResponseWithDeserializedResponse:dictionary
                                                                    underlyingError:error]);
-                             } else {
-                               callback([FIRAuthErrorUtils
-                                   unexpectedResponseWithDeserializedResponse:dictionary]);
+                               return;
                              }
-                             return;
-                           }
-
-                           // At this point we either have an error with successfully decoded
-                           // details in the body, or we have a response which must pass further
-                           // validation before we know it's truly successful. We deal with the
-                           // case where we have an error with successfully decoded error details
-                           // first:
-                           if (error) {
-                             NSDictionary *errorDictionary = dictionary[kErrorKey];
-                             if ([errorDictionary isKindOfClass:[NSDictionary class]]) {
-                               id<NSObject> errorMessage = errorDictionary[kErrorMessageKey];
-                               if ([errorMessage isKindOfClass:[NSString class]]) {
-                                 NSString *errorMessageString = (NSString *)errorMessage;
-
-                                 // Contruct client error.
-                                 NSError *clientError = [[self class]
-                                     clientErrorWithServerErrorMessage:errorMessageString
-                                                       errorDictionary:errorDictionary
-                                                              response:response];
-                                 if (clientError) {
-                                   callback(clientError);
-                                   return;
-                                 }
-                               }
-                               // Not a message we know, return the message directly.
-                               if (errorMessage) {
-                                 NSError *unexpecterErrorResponse = [FIRAuthErrorUtils
-                                     unexpectedErrorResponseWithDeserializedResponse:errorDictionary
-                                                                     underlyingError:error];
-                                 callback(unexpecterErrorResponse);
-                                 return;
-                               }
+
+                             // Finally, we try to populate the response object with the JSON
+                             // values.
+                             if (![response setWithDictionary:dictionary error:&error]) {
+                               callback([FIRAuthErrorUtils
+                                   RPCResponseDecodingErrorWithDeserializedResponse:dictionary
+                                                                    underlyingError:error]);
+                               return;
                              }
-                             // No error message at all, return the decoded response.
-                             callback([FIRAuthErrorUtils
-                                 unexpectedErrorResponseWithDeserializedResponse:dictionary
-                                                                 underlyingError:error]);
-                             return;
-                           }
-
-                           // Finally, we try to populate the response object with the JSON
-                           // values.
-                           if (![response setWithDictionary:dictionary error:&error]) {
-                             callback([FIRAuthErrorUtils
-                                 RPCResponseDecodingErrorWithDeserializedResponse:dictionary
-                                                                  underlyingError:error]);
-                             return;
-                           }
-                           // In case returnIDPCredential of a verifyAssertion request is set to
-                           // @YES, the server may return a 200 with a response that may contain a
-                           // server error.
-                           if ([request isKindOfClass:[FIRVerifyAssertionRequest class]]) {
-                             FIRVerifyAssertionRequest *verifyAssertionRequest =
-                                 (FIRVerifyAssertionRequest *)request;
-                             if (verifyAssertionRequest.returnIDPCredential) {
-                               NSString *errorMessage =
-                                   dictionary[kReturnIDPCredentialErrorMessageKey];
-                               if ([errorMessage isKindOfClass:[NSString class]]) {
-                                 NSString *errorString = (NSString *)errorMessage;
-                                 NSError *clientError =
-                                     [[self class] clientErrorWithServerErrorMessage:errorString
-                                                                     errorDictionary:@{}
-                                                                            response:response];
-                                 if (clientError) {
-                                   callback(clientError);
-                                   return;
+                             // In case returnIDPCredential of a verifyAssertion request is set to
+                             // @YES, the server may return a 200 with a response that may contain a
+                             // server error.
+                             if ([request isKindOfClass:[FIRVerifyAssertionRequest class]]) {
+                               FIRVerifyAssertionRequest *verifyAssertionRequest =
+                                   (FIRVerifyAssertionRequest *)request;
+                               if (verifyAssertionRequest.returnIDPCredential) {
+                                 NSString *errorMessage =
+                                     dictionary[kReturnIDPCredentialErrorMessageKey];
+                                 if ([errorMessage isKindOfClass:[NSString class]]) {
+                                   NSString *errorString = (NSString *)errorMessage;
+                                   NSError *clientError =
+                                       [[self class] clientErrorWithServerErrorMessage:errorString
+                                                                       errorDictionary:@{}
+                                                                              response:response];
+                                   if (clientError) {
+                                     callback(clientError);
+                                     return;
+                                   }
                                  }
                                }
                              }
-                           }
-                           // Success! The response object originally passed in can be used by the
-                           // caller.
-                           callback(nil);
-                         }];
+                             // Success! The response object originally passed in can be used by the
+                             // caller.
+                             callback(nil);
+                           }];
 }
 
 /** @fn clientErrorWithServerErrorMessage:errorDictionary:

+ 19 - 19
FirebaseAuth/Sources/SystemService/FIRSecureTokenService.m

@@ -185,25 +185,25 @@ static const NSTimeInterval kFiveMinutes = 5 * 60;
                                         requestConfiguration:_requestConfiguration];
   }
   [FIRAuthBackend
-    secureToken:request
-       callback:^(FIRSecureTokenResponse *_Nullable response, NSError *_Nullable error) {
-         BOOL tokenUpdated = NO;
-         NSString *newAccessToken = response.accessToken;
-         if (newAccessToken.length && ![newAccessToken isEqualToString:self->_accessToken]) {
-           self->_accessToken = [newAccessToken copy];
-           self->_accessTokenExpirationDate = response.approximateExpirationDate;
-           tokenUpdated = YES;
-           FIRLogDebug(kFIRLoggerAuth, @"I-AUT000017",
-                       @"Updated access token. Estimated expiration date: %@, current date: %@",
-                       self->_accessTokenExpirationDate, [NSDate date]);
-         }
-         NSString *newRefreshToken = response.refreshToken;
-         if (newRefreshToken.length && ![newRefreshToken isEqualToString:self->_refreshToken]) {
-           self->_refreshToken = [newRefreshToken copy];
-           tokenUpdated = YES;
-         }
-         callback(newAccessToken, error, tokenUpdated);
-       }];
+      secureToken:request
+         callback:^(FIRSecureTokenResponse *_Nullable response, NSError *_Nullable error) {
+           BOOL tokenUpdated = NO;
+           NSString *newAccessToken = response.accessToken;
+           if (newAccessToken.length && ![newAccessToken isEqualToString:self->_accessToken]) {
+             self->_accessToken = [newAccessToken copy];
+             self->_accessTokenExpirationDate = response.approximateExpirationDate;
+             tokenUpdated = YES;
+             FIRLogDebug(kFIRLoggerAuth, @"I-AUT000017",
+                         @"Updated access token. Estimated expiration date: %@, current date: %@",
+                         self->_accessTokenExpirationDate, [NSDate date]);
+           }
+           NSString *newRefreshToken = response.refreshToken;
+           if (newRefreshToken.length && ![newRefreshToken isEqualToString:self->_refreshToken]) {
+             self->_refreshToken = [newRefreshToken copy];
+             tokenUpdated = YES;
+           }
+           callback(newAccessToken, error, tokenUpdated);
+         }];
 }
 
 - (BOOL)hasValidAccessToken {

+ 45 - 45
FirebaseAuth/Sources/User/FIRUser.m

@@ -488,47 +488,47 @@ static void callInMainThreadWithAuthDataResultAndError(
         callback(error);
         return;
       }
-      [self
-        internalGetTokenWithCallback:^(NSString *_Nullable accessToken, NSError *_Nullable error) {
-          if (error) {
-            complete();
-            callback(error);
-            return;
-          }
-          FIRAuthRequestConfiguration *configuration = self->_auth.requestConfiguration;
-          // Mutate setAccountInfoRequest in block:
-          FIRSetAccountInfoRequest *setAccountInfoRequest =
-              [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:configuration];
-          setAccountInfoRequest.accessToken = accessToken;
-          changeBlock(user, setAccountInfoRequest);
-          // Execute request:
-          [FIRAuthBackend
-              setAccountInfo:setAccountInfoRequest
-                    callback:^(FIRSetAccountInfoResponse *_Nullable response,
-                               NSError *_Nullable error) {
-                      if (error) {
-                        [self signOutIfTokenIsInvalidWithError:error];
-                        complete();
-                        callback(error);
-                        return;
-                      }
-                      if (response.IDToken && response.refreshToken) {
-                        FIRSecureTokenService *tokenService = [[FIRSecureTokenService alloc]
-                            initWithRequestConfiguration:configuration
-                                             accessToken:response.IDToken
-                               accessTokenExpirationDate:response.approximateExpirationDate
-                                            refreshToken:response.refreshToken];
-                        [self setTokenService:tokenService
-                                     callback:^(NSError *_Nullable error) {
-                                       complete();
-                                       callback(error);
-                                     }];
-                        return;
-                      }
+      [self internalGetTokenWithCallback:^(NSString *_Nullable accessToken,
+                                           NSError *_Nullable error) {
+        if (error) {
+          complete();
+          callback(error);
+          return;
+        }
+        FIRAuthRequestConfiguration *configuration = self->_auth.requestConfiguration;
+        // Mutate setAccountInfoRequest in block:
+        FIRSetAccountInfoRequest *setAccountInfoRequest =
+            [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:configuration];
+        setAccountInfoRequest.accessToken = accessToken;
+        changeBlock(user, setAccountInfoRequest);
+        // Execute request:
+        [FIRAuthBackend
+            setAccountInfo:setAccountInfoRequest
+                  callback:^(FIRSetAccountInfoResponse *_Nullable response,
+                             NSError *_Nullable error) {
+                    if (error) {
+                      [self signOutIfTokenIsInvalidWithError:error];
                       complete();
-                      callback(nil);
-                    }];
-        }];
+                      callback(error);
+                      return;
+                    }
+                    if (response.IDToken && response.refreshToken) {
+                      FIRSecureTokenService *tokenService = [[FIRSecureTokenService alloc]
+                          initWithRequestConfiguration:configuration
+                                           accessToken:response.IDToken
+                             accessTokenExpirationDate:response.approximateExpirationDate
+                                          refreshToken:response.refreshToken];
+                      [self setTokenService:tokenService
+                                   callback:^(NSError *_Nullable error) {
+                                     complete();
+                                     callback(error);
+                                   }];
+                      return;
+                    }
+                    complete();
+                    callback(nil);
+                  }];
+      }];
     }];
   }];
 }
@@ -824,11 +824,11 @@ static void callInMainThreadWithAuthDataResultAndError(
                                              }
                                              // Successful reauthenticate
                                              [self
-                                               setTokenService:authResult.user->_tokenService
-                                                      callback:^(NSError *_Nullable error) {
-                                                        callInMainThreadWithAuthDataResultAndError(
-                                                            completion, authResult, error);
-                                                      }];
+                                                 setTokenService:authResult.user->_tokenService
+                                                        callback:^(NSError *_Nullable error) {
+                                                          callInMainThreadWithAuthDataResultAndError(
+                                                              completion, authResult, error);
+                                                        }];
                                            }];
   });
 }

+ 2 - 2
FirebaseCore/Sources/FIRApp.m

@@ -409,8 +409,8 @@ static FIRApp *sDefaultApp;
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
   [[FIRAnalyticsConfiguration sharedInstance]
-    setAnalyticsCollectionEnabled:dataCollectionDefaultEnabled
-                   persistSetting:NO];
+      setAnalyticsCollectionEnabled:dataCollectionDefaultEnabled
+                     persistSetting:NO];
 #pragma clang diagnostic pop
 }
 

+ 12 - 12
FirebaseDatabase/Tests/Integration/FData.m

@@ -3199,10 +3199,10 @@ XCTAssertTrue([target isEqualTo:recvd], @"Expected %@ to match %@", target, recv
               }];
   }
   [self
-    waitUntil:^BOOL {
-      return done;
-    }
-      timeout:300];
+      waitUntil:^BOOL {
+        return done;
+      }
+        timeout:300];
   NSTimeInterval elapsed = [finished timeIntervalSinceDate:start];
   NSLog(@"Elapsed: %f", elapsed);
 }
@@ -3232,10 +3232,10 @@ XCTAssertTrue([target isEqualTo:recvd], @"Expected %@ to match %@", target, recv
                    }];
   }
   [self
-    waitUntil:^BOOL {
-      return done;
-    }
-      timeout:300];
+      waitUntil:^BOOL {
+        return done;
+      }
+        timeout:300];
 
   NSTimeInterval elapsed = [finished timeIntervalSinceDate:start];
   NSLog(@"Elapsed: %f", elapsed);
@@ -3269,10 +3269,10 @@ XCTAssertTrue([target isEqualTo:recvd], @"Expected %@ to match %@", target, recv
             }];
   }
   [self
-    waitUntil:^BOOL {
-      return done;
-    }
-      timeout:300];
+      waitUntil:^BOOL {
+        return done;
+      }
+        timeout:300];
 
   NSTimeInterval elapsed = [finished timeIntervalSinceDate:start];
   NSLog(@"Elapsed: %f", elapsed);

+ 11 - 11
FirebaseDatabase/Tests/Integration/FOrder.m

@@ -31,17 +31,17 @@
   }
 
   [super
-    snapWaiter:node
-     withBlock:^(FIRDataSnapshot *snapshot) {
-       int expected = 0;
-       for (FIRDataSnapshot *child in snapshot.children) {
-         XCTAssertEqualObjects([NSNumber numberWithInt:expected], [child value],
-                               @"Expects values match.");
-         expected = expected + 1;
-       }
-       XCTAssertTrue(expected == 10, @"Should get all of the children");
-       XCTAssertTrue(expected == snapshot.childrenCount, @"Snapshot should report correct count");
-     }];
+      snapWaiter:node
+       withBlock:^(FIRDataSnapshot *snapshot) {
+         int expected = 0;
+         for (FIRDataSnapshot *child in snapshot.children) {
+           XCTAssertEqualObjects([NSNumber numberWithInt:expected], [child value],
+                                 @"Expects values match.");
+           expected = expected + 1;
+         }
+         XCTAssertTrue(expected == 10, @"Should get all of the children");
+         XCTAssertTrue(expected == snapshot.childrenCount, @"Snapshot should report correct count");
+       }];
 }
 
 - (void)testPushEnumerateManyPathsWriteAndCheckOrder {

+ 25 - 25
FirebaseInAppMessaging/Sources/Flows/FIRIAMClientInfoFetcher.m

@@ -55,31 +55,31 @@
     return;
   }
 
-  [self.installations
-    authTokenWithCompletion:^(FIRInstallationsAuthTokenResult *_Nullable tokenResult,
-                              NSError *_Nullable error) {
-      if (error) {
-        FIRLogWarning(kFIRLoggerInAppMessaging, @"I-IAM190006", @"Error in fetching FIS token: %@",
-                      error.localizedDescription);
-        completion(nil, nil, error);
-      } else {
-        FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM190007", @"Successfully generated FIS token");
-
-        [self.installations installationIDWithCompletion:^(NSString *_Nullable identifier,
-                                                           NSError *_Nullable error) {
-          if (error) {
-            FIRLogWarning(kFIRLoggerInAppMessaging, @"I-IAM190008", @"Error in fetching FID: %@",
-                          error.localizedDescription);
-            completion(nil, tokenResult.authToken, error);
-          } else {
-            FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM190009",
-                        @"Successfully in fetching both FID as %@ and FIS token as %@", identifier,
-                        tokenResult.authToken);
-            completion(identifier, tokenResult.authToken, nil);
-          }
-        }];
-      }
-    }];
+  [self.installations authTokenWithCompletion:^(
+                          FIRInstallationsAuthTokenResult *_Nullable tokenResult,
+                          NSError *_Nullable error) {
+    if (error) {
+      FIRLogWarning(kFIRLoggerInAppMessaging, @"I-IAM190006", @"Error in fetching FIS token: %@",
+                    error.localizedDescription);
+      completion(nil, nil, error);
+    } else {
+      FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM190007", @"Successfully generated FIS token");
+
+      [self.installations
+          installationIDWithCompletion:^(NSString *_Nullable identifier, NSError *_Nullable error) {
+            if (error) {
+              FIRLogWarning(kFIRLoggerInAppMessaging, @"I-IAM190008", @"Error in fetching FID: %@",
+                            error.localizedDescription);
+              completion(nil, tokenResult.authToken, error);
+            } else {
+              FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM190009",
+                          @"Successfully in fetching both FID as %@ and FIS token as %@",
+                          identifier, tokenResult.authToken);
+              completion(identifier, tokenResult.authToken, nil);
+            }
+          }];
+    }
+  }];
 }
 
 - (nullable NSString *)getDeviceLanguageCode {

+ 1 - 1
FirebaseInAppMessaging/Sources/Runtime/FIRIAMRuntimeManager.m

@@ -429,7 +429,7 @@ static NSString *const kFirebaseInAppMessagingAutoDataCollectionKey =
                                  // One-time triggering of checks for both fetch flow
                                  // upon SDK/app startup.
                                  [self.fetchOnAppForegroundFlow
-                                   checkAndFetchForInitialAppLaunch:YES];
+                                     checkAndFetchForInitialAppLaunch:YES];
                                } else {
                                  FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM180009",
                                              @"No FIAM SDK startup due to settings.");

+ 8 - 8
FirebaseMessaging/Sources/FIRMessaging.m

@@ -578,14 +578,14 @@ BOOL FIRMessagingIsContextManagerMessage(NSDictionary *message) {
                            senderID);
   }
   [self.tokenManager
-    tokenWithAuthorizedEntity:senderID
-                        scope:kFIRMessagingDefaultTokenScope
-                      options:options
-                      handler:^(NSString *_Nullable FCMToken, NSError *_Nullable error) {
-                        if (completion) {
-                          completion(FCMToken, error);
-                        }
-                      }];
+      tokenWithAuthorizedEntity:senderID
+                          scope:kFIRMessagingDefaultTokenScope
+                        options:options
+                        handler:^(NSString *_Nullable FCMToken, NSError *_Nullable error) {
+                          if (completion) {
+                            completion(FCMToken, error);
+                          }
+                        }];
 }
 
 - (void)deleteFCMTokenForSenderID:(nonnull NSString *)senderID

+ 64 - 63
FirebaseMessaging/Sources/Token/FIRMessagingAuthService.m

@@ -181,70 +181,71 @@ static const int64_t kMaxCheckinRetryIntervalInSeconds = 1 << 5;
     _isCheckinInProgress = YES;
   }
   [self.checkinService
-    checkinWithExistingCheckin:self.checkinPreferences
-                    completion:^(FIRMessagingCheckinPreferences *checkinPreferences,
-                                 NSError *error) {
-                      @synchronized(self) {
-                        self->_isCheckinInProgress = NO;
-                      }
-                      if (error) {
-                        FIRMessagingLoggerDebug(kFIRMessagingMessageCodeAuthService003,
-                                                @"Failed to checkin device %@", error);
-                        [self notifyCheckinHandlersWithCheckin:nil error:error];
-                        return;
-                      }
-
-                      FIRMessagingLoggerDebug(kFIRMessagingMessageCodeAuthService004,
-                                              @"Successfully got checkin credentials");
-                      BOOL hasSameCachedPreferences =
-                          [self cachedCheckinMatchesCheckin:checkinPreferences];
-                      checkinPreferences.hasPreCachedAuthCredentials = hasSameCachedPreferences;
-
-                      // Update to the most recent checkin preferences
-                      self.checkinPreferences = checkinPreferences;
-
-                      // Save the checkin info to disk
-                      // Keychain might not be accessible, so confirm that checkin preferences can
-                      // be saved
-                      [self->_checkinStore
-                          saveCheckinPreferences:checkinPreferences
-                                         handler:^(NSError *checkinSaveError) {
-                                           if (checkinSaveError && !hasSameCachedPreferences) {
-                                             // The checkin info was new, but it couldn't be
-                                             // written to the Keychain. Delete any stuff that was
-                                             // cached in memory. This doesn't delete any
-                                             // previously persisted preferences.
-                                             FIRMessagingLoggerError(
-                                                 kFIRMessagingMessageCodeService004,
-                                                 @"Unable to save checkin info, resetting "
-                                                 @"checkin preferences "
-                                                  "in memory.");
-                                             [checkinPreferences reset];
-                                             [self
-                                                 notifyCheckinHandlersWithCheckin:nil
-                                                                            error:checkinSaveError];
-                                           } else {
-                                             // The checkin is either new, or it was the same (and
-                                             // it couldn't be saved). Either way, report that the
-                                             // checkin preferences were received successfully.
-                                             [self
-                                                 notifyCheckinHandlersWithCheckin:checkinPreferences
-                                                                            error:nil];
-                                             if (!hasSameCachedPreferences) {
-                                               // Checkin is new.
-                                               // Notify any listeners that might be waiting for
-                                               // checkin to be fetched, such as Firebase
-                                               // Messaging (for its MCS connection).
-                                               dispatch_async(dispatch_get_main_queue(), ^{
-                                                 [[NSNotificationCenter defaultCenter]
-                                                     postNotificationName:
-                                                         kFIRMessagingCheckinFetchedNotification
-                                                                   object:nil];
-                                               });
+      checkinWithExistingCheckin:self.checkinPreferences
+                      completion:^(FIRMessagingCheckinPreferences *checkinPreferences,
+                                   NSError *error) {
+                        @synchronized(self) {
+                          self->_isCheckinInProgress = NO;
+                        }
+                        if (error) {
+                          FIRMessagingLoggerDebug(kFIRMessagingMessageCodeAuthService003,
+                                                  @"Failed to checkin device %@", error);
+                          [self notifyCheckinHandlersWithCheckin:nil error:error];
+                          return;
+                        }
+
+                        FIRMessagingLoggerDebug(kFIRMessagingMessageCodeAuthService004,
+                                                @"Successfully got checkin credentials");
+                        BOOL hasSameCachedPreferences =
+                            [self cachedCheckinMatchesCheckin:checkinPreferences];
+                        checkinPreferences.hasPreCachedAuthCredentials = hasSameCachedPreferences;
+
+                        // Update to the most recent checkin preferences
+                        self.checkinPreferences = checkinPreferences;
+
+                        // Save the checkin info to disk
+                        // Keychain might not be accessible, so confirm that checkin preferences can
+                        // be saved
+                        [self->_checkinStore
+                            saveCheckinPreferences:checkinPreferences
+                                           handler:^(NSError *checkinSaveError) {
+                                             if (checkinSaveError && !hasSameCachedPreferences) {
+                                               // The checkin info was new, but it couldn't be
+                                               // written to the Keychain. Delete any stuff that was
+                                               // cached in memory. This doesn't delete any
+                                               // previously persisted preferences.
+                                               FIRMessagingLoggerError(
+                                                   kFIRMessagingMessageCodeService004,
+                                                   @"Unable to save checkin info, resetting "
+                                                   @"checkin preferences "
+                                                    "in memory.");
+                                               [checkinPreferences reset];
+                                               [self
+                                                   notifyCheckinHandlersWithCheckin:nil
+                                                                              error:
+                                                                                  checkinSaveError];
+                                             } else {
+                                               // The checkin is either new, or it was the same (and
+                                               // it couldn't be saved). Either way, report that the
+                                               // checkin preferences were received successfully.
+                                               [self notifyCheckinHandlersWithCheckin:
+                                                         checkinPreferences
+                                                                                error:nil];
+                                               if (!hasSameCachedPreferences) {
+                                                 // Checkin is new.
+                                                 // Notify any listeners that might be waiting for
+                                                 // checkin to be fetched, such as Firebase
+                                                 // Messaging (for its MCS connection).
+                                                 dispatch_async(dispatch_get_main_queue(), ^{
+                                                   [[NSNotificationCenter defaultCenter]
+                                                       postNotificationName:
+                                                           kFIRMessagingCheckinFetchedNotification
+                                                                     object:nil];
+                                                 });
+                                               }
                                              }
-                                           }
-                                         }];
-                    }];
+                                           }];
+                      }];
 }
 
 - (FIRMessagingCheckinPreferences *)checkinPreferences {

+ 36 - 36
FirebaseRemoteConfig/Sources/RCNConfigFetch.m

@@ -244,46 +244,46 @@ static const NSInteger sFIRErrorCodeConfigFailed = -114;
     }
 
     // We have a valid token. Get the backing installationID.
-    [installations
-      installationIDWithCompletion:^(NSString *_Nullable identifier, NSError *_Nullable error) {
-        RCNConfigFetch *strongSelf = weakSelf;
-        if (strongSelf == nil) {
+    [installations installationIDWithCompletion:^(NSString *_Nullable identifier,
+                                                  NSError *_Nullable error) {
+      RCNConfigFetch *strongSelf = weakSelf;
+      if (strongSelf == nil) {
+        return;
+      }
+
+      // Dispatch to the RC serial queue to update settings on the queue.
+      dispatch_async(strongSelf->_lockQueue, ^{
+        RCNConfigFetch *strongSelfQueue = weakSelf;
+        if (strongSelfQueue == nil) {
           return;
         }
 
-        // Dispatch to the RC serial queue to update settings on the queue.
-        dispatch_async(strongSelf->_lockQueue, ^{
-          RCNConfigFetch *strongSelfQueue = weakSelf;
-          if (strongSelfQueue == nil) {
-            return;
-          }
-
-          // Update config settings with the IID and token.
-          strongSelfQueue->_settings.configInstallationsToken = tokenResult.authToken;
-          strongSelfQueue->_settings.configInstallationsIdentifier = identifier;
-
-          if (!identifier || error) {
-            NSString *errorDescription =
-                [NSString stringWithFormat:@"Error getting iid : %@.", error];
-            FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000055", @"%@",
-                        [NSString stringWithFormat:@"%@", errorDescription]);
-            strongSelfQueue->_settings.isFetchInProgress = NO;
-            return [strongSelfQueue
-                reportCompletionOnHandler:completionHandler
-                               withStatus:FIRRemoteConfigFetchStatusFailure
-                                withError:[NSError
-                                              errorWithDomain:FIRRemoteConfigErrorDomain
-                                                         code:FIRRemoteConfigErrorInternalError
-                                                     userInfo:@{
-                                                       NSLocalizedDescriptionKey : errorDescription
-                                                     }]];
-          }
+        // Update config settings with the IID and token.
+        strongSelfQueue->_settings.configInstallationsToken = tokenResult.authToken;
+        strongSelfQueue->_settings.configInstallationsIdentifier = identifier;
+
+        if (!identifier || error) {
+          NSString *errorDescription =
+              [NSString stringWithFormat:@"Error getting iid : %@.", error];
+          FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000055", @"%@",
+                      [NSString stringWithFormat:@"%@", errorDescription]);
+          strongSelfQueue->_settings.isFetchInProgress = NO;
+          return [strongSelfQueue
+              reportCompletionOnHandler:completionHandler
+                             withStatus:FIRRemoteConfigFetchStatusFailure
+                              withError:[NSError
+                                            errorWithDomain:FIRRemoteConfigErrorDomain
+                                                       code:FIRRemoteConfigErrorInternalError
+                                                   userInfo:@{
+                                                     NSLocalizedDescriptionKey : errorDescription
+                                                   }]];
+        }
 
-          FIRLogInfo(kFIRLoggerRemoteConfig, @"I-RCN000022", @"Success to get iid : %@.",
-                     strongSelfQueue->_settings.configInstallationsIdentifier);
-          [strongSelf doFetchCall:completionHandler];
-        });
-      }];
+        FIRLogInfo(kFIRLoggerRemoteConfig, @"I-RCN000022", @"Success to get iid : %@.",
+                   strongSelfQueue->_settings.configInstallationsIdentifier);
+        [strongSelf doFetchCall:completionHandler];
+      });
+    }];
   };
 
   FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000039", @"Starting requesting token.");

+ 4 - 4
FirebaseRemoteConfig/Tests/Sample/RemoteConfigSampleApp/ViewController.m

@@ -126,8 +126,8 @@ static NSString *const FIRSecondFIRAppName = @"secondFIRApp";
       return;
     }
     [[FRCLog sharedInstance]
-      logToConsole:[NSString stringWithFormat:@"Fetch completed. Status=%@",
-                                              [strongSelf statusString:status]]];
+        logToConsole:[NSString stringWithFormat:@"Fetch completed. Status=%@",
+                                                [strongSelf statusString:status]]];
     if (error) {
       [[FRCLog sharedInstance] logToConsole:[NSString stringWithFormat:@"Fetch Error=%@", error]];
     }
@@ -281,8 +281,8 @@ static NSString *const FIRSecondFIRAppName = @"secondFIRApp";
       showText = @"config defaults";
     }
     [[FRCLog sharedInstance]
-      logToConsole:[NSString stringWithFormat:@"New %@ added %@ : %@\n", showText,
-                                              self.keyLabel.text, self.valueLabel.text]];
+        logToConsole:[NSString stringWithFormat:@"New %@ added %@ : %@\n", showText,
+                                                self.keyLabel.text, self.valueLabel.text]];
 
     self.keyLabel.text = @"";
     self.valueLabel.text = @"";

+ 6 - 6
FirebaseStorage/Sources/FIRStorageObservableTask.m

@@ -204,12 +204,12 @@
     handlersCopy = [handlers copy];
   }  // @synchronized(self)
   [handlersCopy
-    enumerateKeysAndObjectsUsingBlock:^(
-        NSString *_Nonnull key, FIRStorageVoidSnapshot _Nonnull handler, BOOL *_Nonnull stop) {
-      dispatch_async(callbackQueue, ^{
-        handler(snapshot);
-      });
-    }];
+      enumerateKeysAndObjectsUsingBlock:^(
+          NSString *_Nonnull key, FIRStorageVoidSnapshot _Nonnull handler, BOOL *_Nonnull stop) {
+        dispatch_async(callbackQueue, ^{
+          handler(snapshot);
+        });
+      }];
 }
 
 @end

+ 1 - 1
README.md

@@ -165,7 +165,7 @@ GitHub Actions will verify that any code changes are done in a style compliant
 way. Install `clang-format` and `mint`:
 
 ```console
-brew install clang-format@12
+brew install clang-format@13
 brew install mint
 ```
 

+ 1 - 1
scripts/setup_check.sh

@@ -35,7 +35,7 @@ fi
 
 # install clang-format
 brew update
-brew install clang-format@12
+brew install clang-format@13
 
 # mint installs tools from Mintfile on demand.
 brew install mint

+ 1 - 1
scripts/style.sh

@@ -42,7 +42,7 @@ version="${version/ (*)/}"
 version="${version/.*/}"
 
 case "$version" in
-  12)
+  13)
     ;;
   google3-trunk)
     echo "Please use a publicly released clang-format; a recent LLVM release"