FIRAuthRecaptchaVerifier.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2023 Google LLC
  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 <Foundation/Foundation.h>
  17. #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST && (!defined(TARGET_OS_VISION) || !TARGET_OS_VISION)
  18. #import <RecaptchaInterop/RCARecaptchaProtocol.h>
  19. #import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
  20. NS_ASSUME_NONNULL_BEGIN
  21. @interface FIRAuthRecaptchaConfig : NSObject
  22. @property(nonatomic, nonnull, copy) NSString *siteKey;
  23. @property(nonatomic, nonnull, strong) NSDictionary<NSString *, NSNumber *> *enablementStatus;
  24. @end
  25. typedef void (^FIRAuthRecaptchaTokenCallback)(NSString *_Nullable token, NSError *_Nullable error);
  26. typedef void (^FIRAuthRecaptchaConfigCallback)(NSError *_Nullable error);
  27. typedef void (^FIRAuthInjectRequestCallback)(FIRIdentityToolkitRequest<FIRAuthRPCRequest> *request);
  28. typedef NS_ENUM(NSInteger, FIRAuthRecaptchaProvider) {
  29. FIRAuthRecaptchaProviderPassword,
  30. };
  31. typedef NS_ENUM(NSInteger, FIRAuthRecaptchaAction) {
  32. FIRAuthRecaptchaActionDefault,
  33. FIRAuthRecaptchaActionSignInWithPassword,
  34. FIRAuthRecaptchaActionGetOobCode,
  35. FIRAuthRecaptchaActionSignUpPassword
  36. };
  37. @interface FIRAuthRecaptchaVerifier : NSObject
  38. @property(nonatomic, weak, nullable) FIRAuth *auth;
  39. @property(nonatomic, strong, nullable) FIRAuthRecaptchaConfig *agentConfig;
  40. @property(nonatomic, strong, nullable)
  41. NSMutableDictionary<NSString *, FIRAuthRecaptchaConfig *> *tenantConfigs;
  42. @property(nonatomic, strong) id<RCARecaptchaClientProtocol> recaptchaClient;
  43. - (void)verifyForceRefresh:(BOOL)forceRefresh
  44. action:(FIRAuthRecaptchaAction)action
  45. completion:(nullable FIRAuthRecaptchaTokenCallback)completion;
  46. - (void)injectRecaptchaFields:(FIRIdentityToolkitRequest<FIRAuthRPCRequest> *)request
  47. provider:(FIRAuthRecaptchaProvider)provider
  48. action:(FIRAuthRecaptchaAction)action
  49. completion:(nullable FIRAuthInjectRequestCallback)completion;
  50. - (BOOL)enablementStatusForProvider:(FIRAuthRecaptchaProvider)provider;
  51. + (id)sharedRecaptchaVerifier:(nullable FIRAuth *)auth;
  52. @end
  53. NS_ASSUME_NONNULL_END
  54. #endif