FIRAuth_Internal.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FirebaseAuth/Interop/FIRAuthInterop.h"
  18. #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h"
  19. #import "FirebaseCore/Extension/FIRLogger.h"
  20. @class FIRAuthRequestConfiguration;
  21. @class FIRAuthURLPresenter;
  22. #if TARGET_OS_IOS
  23. @class FIRAuthAPNSTokenManager;
  24. @class FIRAuthAppCredentialManager;
  25. @class FIRAuthNotificationManager;
  26. #endif
  27. NS_ASSUME_NONNULL_BEGIN
  28. @interface FIRAuth () <FIRAuthInterop>
  29. /** @property requestConfiguration
  30. @brief The configuration object comprising of paramters needed to make a request to Firebase
  31. Auth's backend.
  32. */
  33. @property(nonatomic, copy, readonly) FIRAuthRequestConfiguration *requestConfiguration;
  34. #if TARGET_OS_IOS
  35. /** @property tokenManager
  36. @brief The manager for APNs tokens used by phone number auth.
  37. */
  38. @property(nonatomic, strong, readonly) FIRAuthAPNSTokenManager *tokenManager;
  39. /** @property appCredentailManager
  40. @brief The manager for app credentials used by phone number auth.
  41. */
  42. @property(nonatomic, strong, readonly) FIRAuthAppCredentialManager *appCredentialManager;
  43. /** @property notificationManager
  44. @brief The manager for remote notifications used by phone number auth.
  45. */
  46. @property(nonatomic, strong, readonly) FIRAuthNotificationManager *notificationManager;
  47. #endif // TARGET_OS_IOS
  48. /** @property authURLPresenter
  49. @brief An object that takes care of presenting URLs via the auth instance.
  50. */
  51. @property(nonatomic, strong, readonly) FIRAuthURLPresenter *authURLPresenter;
  52. /** @fn initWithAPIKey:appName:
  53. @brief Designated initializer.
  54. @param APIKey The Google Developers Console API key for making requests from your app.
  55. @param appName The name property of the previously created @c FIRApp instance.
  56. @param appID The app ID of the Firebase application.
  57. */
  58. - (nullable instancetype)initWithAPIKey:(NSString *)APIKey
  59. appName:(NSString *)appName
  60. appID:(NSString *)appID NS_DESIGNATED_INITIALIZER;
  61. /** @fn getUserID
  62. @brief Gets the identifier of the current user, if any.
  63. @return The identifier of the current user, or nil if there is no current user.
  64. */
  65. - (nullable NSString *)getUserID;
  66. /** @fn updateKeychainWithUser:error:
  67. @brief Updates the keychain for the given user.
  68. @param user The user to be updated.
  69. @param error The error caused the method to fail if the method returns NO.
  70. @return Whether updating keychain has succeeded or not.
  71. @remarks Called by @c FIRUser when user info or token changes occur.
  72. */
  73. - (BOOL)updateKeychainWithUser:(FIRUser *)user error:(NSError *_Nullable *_Nullable)error;
  74. /** @fn internalSignInWithCredential:callback:
  75. @brief Convenience method for @c internalSignInAndRetrieveDataWithCredential:callback:
  76. This method doesn't return additional identity provider data.
  77. */
  78. - (void)internalSignInWithCredential:(FIRAuthCredential *)credential
  79. callback:(FIRAuthResultCallback)callback;
  80. /** @fn internalSignInAndRetrieveDataWithCredential:callback:
  81. @brief Asynchronously signs in Firebase with the given 3rd party credentials (e.g. a Facebook
  82. login Access Token, a Google ID Token/Access Token pair, etc.) and returns additional
  83. identity provider data.
  84. @param credential The credential supplied by the IdP.
  85. @param isReauthentication Indicates whether or not the current invocation originated from an
  86. attempt to reauthenticate.
  87. @param callback A block which is invoked when the sign in finishes (or is cancelled.) Invoked
  88. asynchronously on the auth global work queue in the future.
  89. @remarks This is the internal counterpart of this method, which uses a callback that does not
  90. update the current user.
  91. */
  92. - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
  93. isReauthentication:(BOOL)isReauthentication
  94. callback:(nullable FIRAuthDataResultCallback)callback;
  95. /** @fn signOutByForceWithUserID:error:
  96. @brief Signs out the current user.
  97. @param userID The ID of the user to force sign out.
  98. @param error An optional out parameter for error results.
  99. @return @YES when the sign out request was successful. @NO otherwise.
  100. */
  101. - (BOOL)signOutByForceWithUserID:(NSString *)userID error:(NSError *_Nullable *_Nullable)error;
  102. /** @fn completeSignInWithTokenService:callback:
  103. @brief Completes a sign-in flow once we have access and refresh tokens for the user.
  104. @param accessToken The STS access token.
  105. @param accessTokenExpirationDate The approximate expiration date of the access token.
  106. @param refreshToken The STS refresh token.
  107. @param anonymous Whether or not the user is anonymous.
  108. @param callback Called when the user has been signed in or when an error occurred. Invoked
  109. asynchronously on the global auth work queue in the future.
  110. */
  111. - (void)completeSignInWithAccessToken:(nullable NSString *)accessToken
  112. accessTokenExpirationDate:(nullable NSDate *)accessTokenExpirationDate
  113. refreshToken:(nullable NSString *)refreshToken
  114. anonymous:(BOOL)anonymous
  115. callback:(FIRAuthResultCallback)callback;
  116. /** @fn signInFlowAuthResultCallbackByDecoratingCallback:
  117. @brief Creates a FIRAuthResultCallback block which wraps another FIRAuthResultCallback; trying
  118. to update the current user before forwarding it's invocations along to a subject block
  119. @param callback Called when the user has been updated or when an error has occurred. Invoked
  120. asynchronously on the main thread in the future.
  121. @return Returns a block that updates the current user.
  122. @remarks Typically invoked as part of the complete sign-in flow. For any other uses please
  123. consider alternative ways of updating the current user.
  124. */
  125. - (FIRAuthDataResultCallback)signInFlowAuthDataResultCallbackByDecoratingCallback:
  126. (nullable FIRAuthDataResultCallback)callback;
  127. @end
  128. /// Logger Service String
  129. extern FIRLoggerService kFIRLoggerAuth;
  130. NS_ASSUME_NONNULL_END