Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recaptcha integration master pr #11231

Merged
merged 15 commits into from
Jul 25, 2023
2 changes: 1 addition & 1 deletion FirebaseAuth.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ supports email and password accounts, as well as several 3rd party authenticatio
s.dependency 'GoogleUtilities/AppDelegateSwizzler', '~> 7.8'
s.dependency 'GoogleUtilities/Environment', '~> 7.8'
s.dependency 'GTMSessionFetcher/Core', '>= 2.1', '< 4.0'

s.ios.dependency 'RecaptchaInterop', '~> 18.2.0'
renkelvin marked this conversation as resolved.
Show resolved Hide resolved
s.test_spec 'unit' do |unit_tests|
unit_tests.scheme = { :code_coverage => true }
# Unit tests can't run on watchOS.
Expand Down
301 changes: 291 additions & 10 deletions FirebaseAuth/Sources/Auth/FIRAuth.m

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions FirebaseAuth/Sources/Backend/FIRAuthBackend+MultiFactor.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @implementation FIRAuthBackend (MultiFactor)
+ (void)startMultiFactorEnrollment:(FIRStartMFAEnrollmentRequest *)request
callback:(FIRStartMFAEnrollmentResponseCallback)callback {
FIRStartMFAEnrollmentResponse *response = [[FIRStartMFAEnrollmentResponse alloc] init];
[[self implementation] postWithRequest:request
[[self implementation] callWithRequest:request
response:response
callback:^(NSError *error) {
if (error) {
Expand All @@ -38,7 +38,7 @@ + (void)startMultiFactorEnrollment:(FIRStartMFAEnrollmentRequest *)request
+ (void)finalizeMultiFactorEnrollment:(FIRFinalizeMFAEnrollmentRequest *)request
callback:(FIRFinalizeMFAEnrollmentResponseCallback)callback {
FIRFinalizeMFAEnrollmentResponse *response = [[FIRFinalizeMFAEnrollmentResponse alloc] init];
[[self implementation] postWithRequest:request
[[self implementation] callWithRequest:request
response:response
callback:^(NSError *error) {
if (error) {
Expand All @@ -52,7 +52,7 @@ + (void)finalizeMultiFactorEnrollment:(FIRFinalizeMFAEnrollmentRequest *)request
+ (void)startMultiFactorSignIn:(FIRStartMFASignInRequest *)request
callback:(FIRStartMFASignInResponseCallback)callback {
FIRStartMFASignInResponse *response = [[FIRStartMFASignInResponse alloc] init];
[[self implementation] postWithRequest:request
[[self implementation] callWithRequest:request
response:response
callback:^(NSError *error) {
if (error) {
Expand All @@ -66,7 +66,7 @@ + (void)startMultiFactorSignIn:(FIRStartMFASignInRequest *)request
+ (void)finalizeMultiFactorSignIn:(FIRFinalizeMFASignInRequest *)request
callback:(FIRFinalizeMFASignInResponseCallback)callback {
FIRFinalizeMFASignInResponse *response = [[FIRFinalizeMFASignInResponse alloc] init];
[[self implementation] postWithRequest:request
[[self implementation] callWithRequest:request
response:response
callback:^(NSError *error) {
if (error) {
Expand All @@ -80,7 +80,7 @@ + (void)finalizeMultiFactorSignIn:(FIRFinalizeMFASignInRequest *)request
+ (void)withdrawMultiFactor:(FIRWithdrawMFARequest *)request
callback:(FIRWithdrawMFAResponseCallback)callback {
FIRWithdrawMFAResponse *response = [[FIRWithdrawMFAResponse alloc] init];
[[self implementation] postWithRequest:request
[[self implementation] callWithRequest:request
response:response
callback:^(NSError *error) {
if (error) {
Expand Down
43 changes: 36 additions & 7 deletions FirebaseAuth/Sources/Backend/FIRAuthBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
@class FIRSignUpNewUserResponse;
@class FIRRevokeTokenRequest;
@class FIRRevokeTokenResponse;
@class FIRGetRecaptchaConfigRequest;
@class FIRGetRecaptchaConfigResponse;

@protocol FIRAuthBackendImplementation;
@protocol FIRAuthBackendRPCIssuer;
Expand Down Expand Up @@ -241,6 +243,15 @@ typedef void (^FIRRevokeTokenResponseCallback)(FIRRevokeTokenResponse *_Nullable
typedef void (^FIRSignInWithGameCenterResponseCallback)(
FIRSignInWithGameCenterResponse *_Nullable response, NSError *_Nullable error);

/** @typedef FIRGetRecaptchaConfigResponseCallback
@brief The type of block used to return the result of a call to the getRecaptchaConfig endpoint.
@param response The received response, if any.
@param error The error which occurred, if any.
@remarks One of response or error will be non-nil.
*/
typedef void (^FIRGetRecaptchaConfigResponseCallback)(
FIRGetRecaptchaConfigResponse *_Nullable response, NSError *_Nullable error);

/** @class FIRAuthBackend
@brief Simple static class with methods representing the backend RPCs.
@remarks All callback blocks passed as method parameters are invoked asynchronously on the
Expand Down Expand Up @@ -398,6 +409,15 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
+ (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
callback:(FIRSignInWithGameCenterResponseCallback)callback;

/** @fn getRecaptchaConfig:callback:
@brief Calls the getRecaptchaConfig endpoint, which is responsible for retrieving the recaptcha
configs including site key, provider enablement status.
@param request The request parameters.
@param callback The callback.
*/
+ (void)getRecaptchaConfig:(FIRGetRecaptchaConfigRequest *)request
callback:(FIRGetRecaptchaConfigResponseCallback)callback;

#if TARGET_OS_IOS
/** @fn sendVerificationCode:callback:
@brief Calls the sendVerificationCode endpoint, which is responsible for sending the
Expand Down Expand Up @@ -444,16 +464,16 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
*/
@protocol FIRAuthBackendRPCIssuer <NSObject>

/** @fn asyncPostToURLWithRequestConfiguration:URL:body:contentType:completionHandler:
@brief Asynchronously seXnds a POST request.
/** @fn asyncCallToURLWithRequestConfiguration:URL:body:contentType:completionHandler:
@brief Asynchronously sends a HTTP request.
@param requestConfiguration The request to be made.
@param URL The request URL.
@param body Request body.
@param contentType Content type of the body.
@param handler provided that handles POST response. Invoked asynchronously on the auth global
@param handler provided that handles HTTP response. Invoked asynchronously on the auth global
work queue in the future.
*/
- (void)asyncPostToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
- (void)asyncCallToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
URL:(NSURL *)URL
body:(nullable NSData *)body
contentType:(NSString *)contentType
Expand Down Expand Up @@ -620,6 +640,15 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
- (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
callback:(FIRSignInWithGameCenterResponseCallback)callback;

/** @fn getRecaptchaConfig:callback:
@brief Calls the getRecaptchaConfig endpoint, which is responsible for retrieving the recaptcha
configs including site key, provider enablement status.
@param request The request parameters.
@param callback The callback.
*/
- (void)getRecaptchaConfig:(FIRGetRecaptchaConfigRequest *)request
callback:(FIRGetRecaptchaConfigResponseCallback)callback;

/** @fn resetPassword:callback
@brief Calls the resetPassword endpoint, which is responsible for resetting a user's password
given an OOB code and new password.
Expand All @@ -629,8 +658,8 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
- (void)resetPassword:(FIRResetPasswordRequest *)request
callback:(FIRResetPasswordCallback)callback;

/** @fn postWithRequest:response:callback:
@brief Calls the RPC using HTTP POST.
/** @fn callWithRequest:response:callback:
@brief Calls the RPC using HTTP request.
@remarks Possible error responses:
@see FIRAuthInternalErrorCodeRPCRequestEncodingError
@see FIRAuthInternalErrorCodeJSONSerializationError
Expand All @@ -642,7 +671,7 @@ typedef void (^FIRSignInWithGameCenterResponseCallback)(
@param response The empty response to be filled.
@param callback The callback for both success and failure.
*/
- (void)postWithRequest:(id<FIRAuthRPCRequest>)request
- (void)callWithRequest:(id<FIRAuthRPCRequest>)request
response:(id<FIRAuthRPCResponse>)response
callback:(void (^)(NSError *_Nullable error))callback;

Expand Down