FIRUser_Internal.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRUser.h"
  17. @class FIRAuth;
  18. @class FIRAuthRequestConfiguration;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /** @typedef FIRRetrieveUserCallback
  21. @brief The type of block that is invoked when the construction of a user succeeds or fails.
  22. @param user The user that was constructed, or nil if user construction failed.
  23. @param error The error which occurred, or nil if the request was successful.
  24. */
  25. typedef void (^FIRRetrieveUserCallback)(FIRUser *_Nullable user, NSError *_Nullable error);
  26. /** @typedef FIRVerifyBeforeUpdateEmailCallback
  27. @brief The type of block called when a request to verify before update email has finished.
  28. @param error Optionally; the error which occurred - or nil if the request was successful.
  29. */
  30. typedef void (^FIRVerifyBeforeUpdateEmailCallback)(NSError *_Nullable error);
  31. @interface FIRUser () <NSSecureCoding>
  32. /** @property rawAccessToken
  33. @brief The cached access token.
  34. @remarks This method is specifically for providing the access token to internal clients during
  35. deserialization and sign-in events, and should not be used to retrieve the access token by
  36. anyone else.
  37. */
  38. @property(nonatomic, copy, readonly) NSString *rawAccessToken;
  39. /**
  40. @property passkeyName
  41. @brief A cached passkey name that being passed from startPasskeyEnrollmentWithName:completion: call
  42. and consumed at finalizePasskeyEnrollmentWithPlatformCredential:completion: call
  43. */
  44. @property(nonatomic, copy, nullable) NSString *passkeyName;
  45. /** @property auth
  46. @brief A weak reference to a FIRAuth instance associated with this instance.
  47. */
  48. @property(nonatomic, weak) FIRAuth *auth;
  49. /** @property auth
  50. @brief A strong reference to a requestConfiguration instance associated with this user instance.
  51. */
  52. @property(nonatomic, strong) FIRAuthRequestConfiguration *requestConfiguration;
  53. /** @var accessTokenExpirationDate
  54. @brief The expiration date of the cached access token.
  55. */
  56. @property(nonatomic, copy, readonly) NSDate *accessTokenExpirationDate;
  57. /** @fn retrieveUserWithAuth:accessToken:accessTokenExpirationDate:refreshToken:callback:
  58. @brief Constructs a user with Secure Token Service tokens, and obtains user details from the
  59. getAccountInfo endpoint.
  60. @param auth The associated FIRAuth instance.
  61. @param accessToken The Secure Token Service access token.
  62. @param accessTokenExpirationDate The approximate expiration date of the access token.
  63. @param refreshToken The Secure Token Service refresh token.
  64. @param anonymous Whether or not the user is anonymous.
  65. @param callback A block which is invoked when the construction succeeds or fails. Invoked
  66. asynchronously on the auth global work queue in the future.
  67. */
  68. + (void)retrieveUserWithAuth:(FIRAuth *)auth
  69. accessToken:(nullable NSString *)accessToken
  70. accessTokenExpirationDate:(nullable NSDate *)accessTokenExpirationDate
  71. refreshToken:(nullable NSString *)refreshToken
  72. anonymous:(BOOL)anonymous
  73. callback:(FIRRetrieveUserCallback)callback;
  74. /** @fn internalGetTokenForcingRefresh:callback:
  75. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  76. @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
  77. other than an expiration.
  78. @param callback The block to invoke when the token is available. Invoked asynchronously on the
  79. global work thread in the future.
  80. */
  81. - (void)internalGetTokenForcingRefresh:(BOOL)forceRefresh
  82. callback:(nonnull FIRAuthTokenCallback)callback;
  83. /** @fn internalVerifyBeforeUpdateEmailWithNewEmail:actionCodeSettings:callback:
  84. @brief Sends a verification email to newEmail. Upon redemption of the link in the email,
  85. this user's email will be changed to newEmail and that email will be marked verified.
  86. @param newEmail the user's new email.
  87. @param actionCodeSettings the optional FIRActionCodeSettings object to allow linking back
  88. to your app in the email.
  89. @param completion The block to invoke when the call succeeds or fails. Invoked asynchronously on
  90. the global work thread in the future.
  91. */
  92. - (void)internalVerifyBeforeUpdateEmailWithNewEmail:(NSString *)newEmail
  93. actionCodeSettings:
  94. (nullable FIRActionCodeSettings *)actionCodeSettings
  95. completion:(FIRVerifyBeforeUpdateEmailCallback)completion;
  96. @end
  97. NS_ASSUME_NONNULL_END