feat: implement reCAPTCHA Enterprise#9066
Conversation
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| if ( | ||
| context.platformOS === 'android' || | ||
| context.platformOS === 'ios' || | ||
| context.platformOS === 'macos' | ||
| ) { | ||
| return { providerName: 'recaptcha' }; | ||
| } |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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'.
| if (context.platformOS === 'ios' || context.platformOS === 'macos') { | |
| if (context.platformOS === 'ios') { |
| export function assertNativeRecaptchaSiteKeyConsistency( | ||
| appOptions: Pick<ReactNativeFirebase.FirebaseAppOptions, 'recaptchaSiteKey'>, | ||
| constructorSiteKey: string, | ||
| ): void { | ||
| const configSiteKey = appOptions.recaptchaSiteKey; |
There was a problem hiding this comment.
To prevent potential runtime TypeErrors if appOptions is null or undefined (for example, in testing or custom environments), use optional chaining when accessing recaptchaSiteKey.
| 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; |
| app: { options: { recaptchaSiteKey?: string } }, | ||
| options: WebInitializeAppCheckOptions, | ||
| ): JsAppCheckOptions { | ||
| const { provider, isTokenAutoRefreshEnabled } = options; | ||
|
|
||
| if (!provider) { | ||
| const recaptchaSiteKey = app.options.recaptchaSiteKey; |
There was a problem hiding this comment.
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.
| 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; |
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.
dbc4276 to
2d9964b
Compare
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
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/\*\*/e2ejesttests added or updated inpackages/\*\*/__tests__Test Plan
A great deal of unit and type and e2e and documentation tests
Think
react-native-firebaseis great? Please consider supporting the project with any of the below:React Native FirebaseandInvertaseon Twitter