Няма описание

FIRUser_Internal.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 "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. /** @property auth
  40. @brief A weak reference to a FIRAuth instance associated with this instance.
  41. */
  42. @property(nonatomic, weak) FIRAuth *auth;
  43. /** @property auth
  44. @brief A strong reference to a requestConfiguration instance associated with this user instance.
  45. */
  46. @property(nonatomic, strong) FIRAuthRequestConfiguration *requestConfiguration;
  47. /** @var accessTokenExpirationDate
  48. @brief The expiration date of the cached access token.
  49. */
  50. @property(nonatomic, copy, readonly) NSDate *accessTokenExpirationDate;
  51. /** @fn retrieveUserWithAuth:accessToken:accessTokenExpirationDate:refreshToken:callback:
  52. @brief Constructs a user with Secure Token Service tokens, and obtains user details from the
  53. getAccountInfo endpoint.
  54. @param auth The associated FIRAuth instance.
  55. @param accessToken The Secure Token Service access token.
  56. @param accessTokenExpirationDate The approximate expiration date of the access token.
  57. @param refreshToken The Secure Token Service refresh token.
  58. @param anonymous Whether or not the user is anonymous.
  59. @param callback A block which is invoked when the construction succeeds or fails. Invoked
  60. asynchronously on the auth global work queue in the future.
  61. */
  62. + (void)retrieveUserWithAuth:(FIRAuth *)auth
  63. accessToken:(nullable NSString *)accessToken
  64. accessTokenExpirationDate:(nullable NSDate *)accessTokenExpirationDate
  65. refreshToken:(nullable NSString *)refreshToken
  66. anonymous:(BOOL)anonymous
  67. callback:(FIRRetrieveUserCallback)callback;
  68. /** @fn internalGetTokenForcingRefresh:callback:
  69. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  70. @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
  71. other than an expiration.
  72. @param callback The block to invoke when the token is available. Invoked asynchronously on the
  73. global work thread in the future.
  74. */
  75. - (void)internalGetTokenForcingRefresh:(BOOL)forceRefresh
  76. callback:(nonnull FIRAuthTokenCallback)callback;
  77. /** @fn internalVerifyBeforeUpdateEmailWithNewEmail:actionCodeSettings:callback:
  78. @brief Sends a verification email to newEmail. Upon redemption of the link in the email,
  79. this user's email will be changed to newEmail and that email will be marked verified.
  80. @param newEmail the user's new email.
  81. @param actionCodeSettings the optional FIRActionCodeSettings object to allow linking back
  82. to your app in the email.
  83. @param completion The block to invoke when the call succeeds or fails. Invoked asynchronously on
  84. the global work thread in the future.
  85. */
  86. - (void)internalVerifyBeforeUpdateEmailWithNewEmail:(NSString *)newEmail
  87. actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
  88. completion:(FIRVerifyBeforeUpdateEmailCallback)completion;
  89. @end
  90. NS_ASSUME_NONNULL_END