Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e193c14
WIP: feat(appcheck): Implement initial reCAPTCHA Enterprise provider
hiteshmaurya56 Jul 8, 2025
5288e7c
WIP: feat(appcheck-recaptcha-enterprise): Add token exchange models a…
hiteshmaurya56 Jul 8, 2025
c25340b
WIP: feat(appcheck-network): Extend NetworkClient for reCAPTCHA Enter…
hiteshmaurya56 Jul 8, 2025
86c3bbb
WIP: feat(appcheck-network): Extend NetworkClient for reCAPTCHA Enter…
hiteshmaurya56 Jul 8, 2025
68ac173
WIP: feat(appcheck-recaptcha-enterprise): Implement RecaptchaEnterpri…
hiteshmaurya56 Jul 8, 2025
014dc4a
WIP: chore(appcheck-recaptcha-enterprise): Integrate module into buil…
hiteshmaurya56 Jul 8, 2025
2d2b96d
test(appcheck-recaptcha-enterprise): Add unit tests for reCAPTCHA Ent…
hiteshmaurya56 Jul 9, 2025
7a99c47
Resolves comments
hiteshmaurya56 Jul 11, 2025
c8e295b
Resolves comments
hiteshmaurya56 Jul 11, 2025
5f925b4
feat: Add new library versions
hiteshmaurya56 Jul 14, 2025
9c34a6e
Resolves build errors
hiteshmaurya56 Jul 14, 2025
290a9fb
Fix: Apply Spotless formatting to appcheck-recaptchaenterprise module
hiteshmaurya56 Jul 14, 2025
b6dea8d
Fix: Apply Spotless formatting to appcheck-recaptchaenterprise module
hiteshmaurya56 Jul 14, 2025
ff30974
Fix: Add api.txt file
hiteshmaurya56 Jul 14, 2025
874ef41
Resolves comments
hiteshmaurya56 Jul 16, 2025
f30a68e
Resolves comments
hiteshmaurya56 Jul 17, 2025
24056ce
Resolves comments
hiteshmaurya56 Jul 17, 2025
4027c4d
Resolves comments
hiteshmaurya56 Jul 18, 2025
97fc25d
Corrects Formatting
hiteshmaurya56 Jul 18, 2025
1f56a6a
Resolves Comments
hiteshmaurya56 Jul 22, 2025
8d0f5ee
Removes Map from RecaptchaEnterpriseAppCheckProviderFactory
hiteshmaurya56 Jul 23, 2025
beac8e3
Resolves Spotless formatting issue
hiteshmaurya56 Jul 24, 2025
b99b2fa
Merge branch 'main' into android-recaptchaenterprise
hiteshmaurya56 Jul 24, 2025
4160a2a
Adds existing_api.txt file
hiteshmaurya56 Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ android {
}

dependencies {
implementation(libs.dagger.dagger)

api project(':appcheck:firebase-appcheck')
api 'com.google.firebase:firebase-common'
api 'com.google.firebase:firebase-components'
api 'com.google.android.recaptcha:recaptcha:18.7.1'

annotationProcessor(libs.dagger.compiler)

testImplementation(project(":integ-testing")) {
exclude group: 'com.google.firebase', module: 'firebase-common'
exclude group: 'com.google.firebase', module: 'firebase-components'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
package com.google.firebase.appcheck.recaptchaenterprise;

import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.firebase.FirebaseApp;
import com.google.firebase.annotations.concurrent.Blocking;
import com.google.firebase.annotations.concurrent.Lightweight;
import com.google.firebase.appcheck.recaptchaenterprise.internal.FirebaseExecutors;
import com.google.firebase.appcheck.recaptchaenterprise.internal.DaggerProviderComponent;
import com.google.firebase.appcheck.recaptchaenterprise.internal.ProviderMultiResourceComponent;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentRegistrar;
import com.google.firebase.components.Dependency;
Expand All @@ -43,14 +45,19 @@ public List<Component<?>> getComponents() {
Qualified<Executor> blockingExecutor = Qualified.qualified(Blocking.class, Executor.class);

return Arrays.asList(
Component.builder(FirebaseExecutors.class)
Component.builder(ProviderMultiResourceComponent.class)
.name(LIBRARY_NAME)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.required(liteExecutor))
.add(Dependency.required(blockingExecutor))
.factory(
container ->
new FirebaseExecutors(
container.get(liteExecutor), container.get(blockingExecutor)))
DaggerProviderComponent.builder()
.setFirebaseApp(container.get(FirebaseApp.class))
.setLiteExecutor(container.get(liteExecutor))
.setBlockingExecutor(container.get(blockingExecutor))
.build()
.getMultiResourceComponent())
.build(),
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@

package com.google.firebase.appcheck.recaptchaenterprise;

import android.app.Application;
import androidx.annotation.NonNull;
import com.google.firebase.FirebaseApp;
import com.google.firebase.appcheck.AppCheckProvider;
import com.google.firebase.appcheck.AppCheckProviderFactory;
import com.google.firebase.appcheck.FirebaseAppCheck;
import com.google.firebase.appcheck.recaptchaenterprise.internal.FirebaseExecutors;
import com.google.firebase.appcheck.recaptchaenterprise.internal.ProviderMultiResourceComponent;
import com.google.firebase.appcheck.recaptchaenterprise.internal.RecaptchaEnterpriseAppCheckProvider;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -31,7 +30,6 @@
*/
public class RecaptchaEnterpriseAppCheckProviderFactory implements AppCheckProviderFactory {

private static FirebaseExecutors firebaseExecutors;
private static final Map<String, RecaptchaEnterpriseAppCheckProviderFactory> factoryInstances =
new ConcurrentHashMap<>();
private final String siteKey;
Expand All @@ -55,18 +53,9 @@ public AppCheckProvider create(@NonNull FirebaseApp firebaseApp) {
if (provider == null) {
synchronized (this) {
if (provider == null) {
if (RecaptchaEnterpriseAppCheckProviderFactory.firebaseExecutors == null) {
firebaseExecutors = firebaseApp.get(FirebaseExecutors.class);
}
Application application = (Application) firebaseApp.getApplicationContext();

provider =
new RecaptchaEnterpriseAppCheckProvider(
firebaseApp,
application,
siteKey,
firebaseExecutors.getLiteExecutor(),
firebaseExecutors.getBlockingExecutor());
ProviderMultiResourceComponent component =
firebaseApp.get(ProviderMultiResourceComponent.class);
provider = component.get(siteKey);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,34 @@

package com.google.firebase.appcheck.recaptchaenterprise.internal;

import com.google.firebase.FirebaseApp;
import com.google.firebase.annotations.concurrent.Blocking;
import com.google.firebase.annotations.concurrent.Lightweight;
import dagger.BindsInstance;
import dagger.Component;
import dagger.Module;
import java.util.concurrent.Executor;
import javax.inject.Singleton;

/**
* This class encapsulates a {@link com.google.firebase.annotations.concurrent.Lightweight} executor
* and a {@link com.google.firebase.annotations.concurrent.Blocking} executor, making them available
* for various asynchronous operations related to reCAPTCHA Enterprise App Check.
*/
public class FirebaseExecutors {
private final Executor liteExecutor;
private final Executor blockingExecutor;

public FirebaseExecutors(
@Lightweight Executor liteExecutor, @Blocking Executor blockingExecutor) {
this.liteExecutor = liteExecutor;
this.blockingExecutor = blockingExecutor;
}
@Singleton
@Component(modules = ProviderComponent.MainModule.class)
public interface ProviderComponent {
ProviderMultiResourceComponent getMultiResourceComponent();

public Executor getLiteExecutor() {
return liteExecutor;
}
@Component.Builder
interface Builder {
@BindsInstance
Builder setFirebaseApp(FirebaseApp firebaseApp);

@BindsInstance
Builder setLiteExecutor(@Lightweight Executor liteExecutor);

public Executor getBlockingExecutor() {
return blockingExecutor;
@BindsInstance
Builder setBlockingExecutor(@Blocking Executor blockingExecutor);

ProviderComponent build();
}

@Module
abstract class MainModule {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.appcheck.recaptchaenterprise.internal;

import androidx.annotation.NonNull;
import dagger.assisted.Assisted;
import dagger.assisted.AssistedFactory;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
import javax.inject.Singleton;

/** Multi-resource container for RecaptchaEnterpriseAppCheckProvider */
@Singleton
public final class ProviderMultiResourceComponent {
private final RecaptchaEnterpriseAppCheckProviderFactory providerFactory;

private final Map<String, RecaptchaEnterpriseAppCheckProvider> instances =
new ConcurrentHashMap<>();

@Inject
ProviderMultiResourceComponent(RecaptchaEnterpriseAppCheckProviderFactory providerFactory) {
this.providerFactory = providerFactory;
}

@NonNull
public RecaptchaEnterpriseAppCheckProvider get(@NonNull String siteKey) {
return instances.computeIfAbsent(siteKey, providerFactory::create);
}

@AssistedFactory
interface RecaptchaEnterpriseAppCheckProviderFactory {
RecaptchaEnterpriseAppCheckProvider create(@Assisted String siteKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.google.firebase.appcheck.internal.DefaultAppCheckToken;
import com.google.firebase.appcheck.internal.NetworkClient;
import com.google.firebase.appcheck.internal.RetryManager;
import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.concurrent.Executor;
Expand Down Expand Up @@ -59,13 +61,13 @@ public class RecaptchaEnterpriseAppCheckProvider implements AppCheckProvider {
private Application application;
private static final String TAG = "rCEAppCheckProvider";

@AssistedInject
public RecaptchaEnterpriseAppCheckProvider(
@NonNull FirebaseApp firebaseApp,
@NonNull Application application,
@NonNull String siteKey,
@Assisted @NonNull String siteKey,
@Lightweight Executor liteExecutor,
@Blocking Executor blockingExecutor) {
this.application = application;
this.application = (Application) firebaseApp.getApplicationContext();
this.siteKey = siteKey;
this.liteExecutor = liteExecutor;
this.blockingExecutor = blockingExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.Application;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.android.recaptcha.RecaptchaAction;
Expand Down Expand Up @@ -62,7 +61,6 @@ public class RecaptchaEnterpriseAppCheckProviderTest {
private final String siteKey = "siteKey";

@Mock private NetworkClient mockNetworkClient;
@Mock private Application mockApplication;
@Mock FirebaseApp mockFirebaseApp;
@Mock RecaptchaTasksClient mockRecaptchaTasksClient;
@Mock RetryManager mockRetryManager;
Expand All @@ -81,11 +79,7 @@ public void testPublicConstructor_nullFirebaseApp_expectThrows() {
NullPointerException.class,
() ->
new RecaptchaEnterpriseAppCheckProvider(
null,
mockApplication,
siteKey,
TestOnlyExecutors.lite(),
TestOnlyExecutors.blocking()));
null, siteKey, TestOnlyExecutors.lite(), TestOnlyExecutors.blocking()));
}

@Test
Expand All @@ -94,11 +88,7 @@ public void testPublicConstructor_nullSiteKey_expectThrows() {
NullPointerException.class,
() ->
new RecaptchaEnterpriseAppCheckProvider(
mockFirebaseApp,
mockApplication,
null,
TestOnlyExecutors.lite(),
TestOnlyExecutors.blocking()));
mockFirebaseApp, null, TestOnlyExecutors.lite(), TestOnlyExecutors.blocking()));
}

@Test
Expand Down
Loading