FIRAuth_Internal.h 6.6 KB

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