FIRMultiFactor.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include <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 FIRMultiFactorSessionCallback)completion;
  49. /** @fn enrollWithAssertion:displayName:completion:
  50. @brief Enrolls a second factor as identified by the `FIRMultiFactorAssertion` parameter for the
  51. current user.
  52. @param displayName An optional display name associated with the multi factor to enroll.
  53. @param completion The block invoked when the request is complete, or fails.
  54. */
  55. - (void)enrollWithAssertion:(FIRMultiFactorAssertion *)assertion
  56. displayName:(nullable NSString *)displayName
  57. completion:(nullable FIRAuthVoidErrorCallback)completion;
  58. /** @fn unenrollWithInfo:completion:
  59. @brief Unenroll the given multi factor.
  60. @param completion The block invoked when the request to send the verification email is complete,
  61. or fails.
  62. */
  63. - (void)unenrollWithInfo:(FIRMultiFactorInfo *)factorInfo
  64. completion:(nullable FIRAuthVoidErrorCallback)completion;
  65. /** @fn unenrollWithFactorUID:completion:
  66. @brief Unenroll the given multi factor.
  67. @param completion The block invoked when the request to send the verification email is complete,
  68. or fails.
  69. */
  70. - (void)unenrollWithFactorUID:(NSString *)factorUID
  71. completion:(nullable FIRAuthVoidErrorCallback)completion;
  72. @end
  73. NS_ASSUME_NONNULL_END
  74. #endif