FIRMultiFactor.h 3.9 KB

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