Skip to content

feat: implement reCAPTCHA Enterprise#9066

Open
mikehardy wants to merge 15 commits into
mainfrom
recaptcha-enterprise
Open

feat: implement reCAPTCHA Enterprise#9066
mikehardy wants to merge 15 commits into
mainfrom
recaptcha-enterprise

Conversation

@mikehardy

Copy link
Copy Markdown
Collaborator

Description

More documentation to come - this is in progress at this moment, pushing for visibility only

Related issues

Can link upstream and FlutterFire sister repo PR

Release Summary

Will be conventional commits for an automated semantic release

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

A great deal of unit and type and e2e and documentation tests


Think react-native-firebase is great? Please consider supporting the project with any of the below:

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for reCAPTCHA Enterprise in react-native-firebase, enabling enhanced bot protection for App Check and Auth. The changes include the addition of new provider classes, native dependency updates for Android, and comprehensive configuration plumbing to propagate site keys across platforms. The implementation follows a modular approach, ensuring type parity with the Firebase JS SDK while providing platform-specific runtime behavior.

Highlights

  • reCAPTCHA Enterprise Support: Implemented reCAPTCHA Enterprise for App Check and Auth, including new provider classes and native integration.
  • Configuration Plumbing: Added recaptchaSiteKey support to FirebaseAppOptions to enable cross-platform configuration.
  • Platform-Specific Routing: Introduced robust routing logic to handle reCAPTCHA providers across iOS, Android, and Web contexts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements Phase 0 and Phase 1 of the reCAPTCHA Enterprise design plan, adding recaptchaSiteKey plumbing to the core app options and introducing ReCaptchaV3Provider and ReCaptchaEnterpriseProvider to the App Check package. It updates the Web bridge to support real JS SDK providers and provider-less initialization, extends native provider configurations, and adds comprehensive unit and type tests. The review feedback focuses on simplifying the platform routing logic by removing dead code for macOS (which is already handled under the isOther path) and improving runtime robustness by using optional chaining when accessing app options.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +82 to +88
if (
context.platformOS === 'android' ||
context.platformOS === 'ios' ||
context.platformOS === 'macos'
) {
return { providerName: 'recaptcha' };
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since RNFBCommon.isOther is true when Platform.OS is 'macos', the initializeAppCheck method in namespaced.ts will always return early on macOS and never call resolveNativeInitializeAppCheckRoute. Therefore, checking for 'macos' inside resolveNativeInitializeAppCheckRoute is dead code and can be safely removed to simplify the platform routing logic.

    if (
      context.platformOS === 'android' ||
      context.platformOS === 'ios'
    ) {
      return { providerName: 'recaptcha' };
    }

};
}

if (context.platformOS === 'ios' || context.platformOS === 'macos') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As macOS is handled under the isOther path, context.platformOS will never be 'macos' when executing resolveNativeInitializeAppCheckRoute. You can safely simplify this check to only check for 'ios'.

Suggested change
if (context.platformOS === 'ios' || context.platformOS === 'macos') {
if (context.platformOS === 'ios') {

Comment on lines +31 to +35
export function assertNativeRecaptchaSiteKeyConsistency(
appOptions: Pick<ReactNativeFirebase.FirebaseAppOptions, 'recaptchaSiteKey'>,
constructorSiteKey: string,
): void {
const configSiteKey = appOptions.recaptchaSiteKey;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

To prevent potential runtime TypeErrors if appOptions is null or undefined (for example, in testing or custom environments), use optional chaining when accessing recaptchaSiteKey.

Suggested change
export function assertNativeRecaptchaSiteKeyConsistency(
appOptions: Pick<ReactNativeFirebase.FirebaseAppOptions, 'recaptchaSiteKey'>,
constructorSiteKey: string,
): void {
const configSiteKey = appOptions.recaptchaSiteKey;
export function assertNativeRecaptchaSiteKeyConsistency(
appOptions: Pick<ReactNativeFirebase.FirebaseAppOptions, 'recaptchaSiteKey'>,
constructorSiteKey: string,
): void {
const configSiteKey = appOptions?.recaptchaSiteKey;

Comment on lines +85 to +91
app: { options: { recaptchaSiteKey?: string } },
options: WebInitializeAppCheckOptions,
): JsAppCheckOptions {
const { provider, isTokenAutoRefreshEnabled } = options;

if (!provider) {
const recaptchaSiteKey = app.options.recaptchaSiteKey;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

To prevent potential runtime errors if app or app.options is undefined or null (e.g., in custom environments or unit tests), use optional chaining when retrieving recaptchaSiteKey.

Suggested change
app: { options: { recaptchaSiteKey?: string } },
options: WebInitializeAppCheckOptions,
): JsAppCheckOptions {
const { provider, isTokenAutoRefreshEnabled } = options;
if (!provider) {
const recaptchaSiteKey = app.options.recaptchaSiteKey;
app: { options: { recaptchaSiteKey?: string } },
options: WebInitializeAppCheckOptions,
): JsAppCheckOptions {
const { provider, isTokenAutoRefreshEnabled } = options;
if (!provider) {
const recaptchaSiteKey = app?.options?.recaptchaSiteKey;

mikehardy added 15 commits June 22, 2026 21:43
Add first-class recaptchaSiteKey on FirebaseAppOptions with native
FirebaseOptions/FIROptions wiring on Android and iOS, Other/Web passthrough,
tests, and Phase 0 design doc progress.
Runtime helpers for distinguishing Other/Web from Other/Hermes targets,
with unit tests and design doc Phase 1.5 progress.
Export js-sdk-matching ReCaptchaV3Provider and ReCaptchaEnterpriseProvider
stubs, extend native provider unions with recaptcha, and add tests.
Refactor the Other/Web bridge to use real js-sdk providers, support
provider-less init when recaptchaSiteKey is set, and add routing tests.
Add namespaced routing for native recaptcha, web provider-less init,
Hermes throws, and Enterprise site-key consistency checks with tests.
Document exported ReCaptcha provider classes and narrowed AppCheckOptions
drift reasons per Phase 1.6.
Cover js-sdk provider classes, native recaptcha configure options, and
provider-less initializeAppCheck when recaptchaSiteKey is set.
Link firebase-appcheck-recaptcha and route the recaptcha provider to
RecaptchaAppCheckProviderFactory using native FirebaseOptions site key.
…errors

Implement FIRRecaptchaProvider on iOS, link RecaptchaEnterprise pod,
reject configure failures, block macOS recaptcha routing in JS, and add tests.
Wire native Android/iOS bridges, Other/Web js-sdk delegation, Hermes
no-op with warning, reCAPTCHA SDK deps, compare-types, and tests.
Document provider routing tables, initializeRecaptchaConfig, recaptchaSiteKey
config, and platform behaviour across app-check, auth, and migration guides.
Link reCAPTCHA design from okf-bundle index, add app-check provider matrix,
update auth compare-types triage for initializeRecaptchaConfig, document
native coverage paths, and mark Phase 7 tests verified.
Add App Check recaptcha and Auth initializeRecaptchaConfig e2e tests,
align namespaced Hermes behaviour with modular no-op, and mark validation
phases complete with platform e2e skip notes.
Document that config plugins copy native Firebase files verbatim and
users must redownload google-services files after enabling App Check reCAPTCHA.
@mikehardy mikehardy force-pushed the recaptcha-enterprise branch from dbc4276 to 2d9964b Compare June 23, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant