FIRMultiFactor.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright 2019 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/LICENSE2.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 <TargetConditionals.h>
  17. #if TARGET_OS_IOS
  18. #import <Foundation/Foundation.h>
  19. #import "FIRAuth.h"
  20. #import "FIRMultiFactorAssertion.h"
  21. #import "FIRMultiFactorInfo.h"
  22. #import "FIRMultiFactorSession.h"
  23. NS_ASSUME_NONNULL_BEGIN
  24. /** @typedef FIRMultiFactorSessionCallback
  25. @brief The callback that triggered when a developer calls `getSessionWithCompletion`.
  26. @param session The multi factor session returned, if any.
  27. @param error The error which occurred, if any.
  28. */
  29. typedef void (^FIRMultiFactorSessionCallback)(FIRMultiFactorSession *_Nullable session,
  30. NSError *_Nullable error)
  31. NS_SWIFT_NAME(MultiFactorSessionCallback);
  32. /**
  33. @brief The string identifier for second factors. e.g. "phone".
  34. */
  35. extern NSString *const _Nonnull FIRPhoneMultiFactorID NS_SWIFT_NAME(PhoneMultiFactorID);
  36. /** @class FIRMultiFactor
  37. @brief The interface defining the multi factor related properties and operations pertaining to a
  38. user.
  39. */
  40. NS_SWIFT_NAME(MultiFactor)
  41. @interface FIRMultiFactor : NSObject
  42. @property(nonatomic, readonly) NSArray<FIRMultiFactorInfo *> *enrolledFactors;
  43. /** @fn getSessionWithCompletion:
  44. @brief Get a session for a second factor enrollment operation.
  45. @param completion A block with the session identifier for a second factor enrollment operation.
  46. This is used to identify the current user trying to enroll a second factor.
  47. */
  48. - (void)getSessionWithCompletion:(nullable void (^)(FIRMultiFactorSession *_Nullable credential,
  49. NSError *_Nullable error))completion;
  50. /** @fn enrollWithAssertion:displayName:completion:
  51. @brief Enrolls a second factor as identified by the `FIRMultiFactorAssertion` parameter for the
  52. current user.
  53. @param displayName An optional display name associated with the multi factor to enroll.
  54. @param completion The block invoked when the request is complete, or fails.
  55. */
  56. - (void)enrollWithAssertion:(FIRMultiFactorAssertion *)assertion
  57. displayName:(nullable NSString *)displayName
  58. completion:(nullable void (^)(NSError *_Nullable error))completion;
  59. /** @fn unenrollWithInfo:completion:
  60. @brief Unenroll the given multi factor.
  61. @param completion The block invoked when the request to send the verification email is complete,
  62. or fails.
  63. */
  64. - (void)unenrollWithInfo:(FIRMultiFactorInfo *)factorInfo
  65. completion:(nullable void (^)(NSError *_Nullable error))completion;
  66. /** @fn unenrollWithFactorUID:completion:
  67. @brief Unenroll the given multi factor.
  68. @param completion The block invoked when the request to send the verification email is complete,
  69. or fails.
  70. */
  71. - (void)unenrollWithFactorUID:(NSString *)factorUID
  72. completion:(nullable void (^)(NSError *_Nullable error))completion;
  73. @end
  74. NS_ASSUME_NONNULL_END
  75. #endif