File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
packages/auth/src/platform_browser Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ describe('platform_browser/providers/phone', () => {
6464 context ( '#verifyPhoneNumber' , ( ) => {
6565 it ( 'calls verify on the appVerifier and then calls the server when recaptcha enterprise is disabled' , async ( ) => {
6666 const recaptchaConfigResponseOff = {
67- recaptchaKey : 'foo/bar/to/site- key' ,
67+ // no recaptcha key if no rCE provider is enabled
6868 recaptchaEnforcementState : [
6969 {
7070 provider : RecaptchaAuthProvider . PHONE_PROVIDER ,
@@ -111,7 +111,7 @@ describe('platform_browser/providers/phone', () => {
111111
112112 it ( 'throws an error if verify without appVerifier when recaptcha enterprise is disabled' , async ( ) => {
113113 const recaptchaConfigResponseOff = {
114- recaptchaKey : 'foo/bar/to/site- key' ,
114+ // no recaptcha key if no rCE provider is enabled
115115 recaptchaEnforcementState : [
116116 {
117117 provider : RecaptchaAuthProvider . PHONE_PROVIDER ,
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ const recaptchaConfigResponseAudit = {
8383 ]
8484} ;
8585const recaptchaConfigResponseOff = {
86- recaptchaKey : 'foo/bar/to/site- key' ,
86+ // no recaptcha key if no rCE provider is enabled
8787 recaptchaEnforcementState : [
8888 {
8989 provider : RecaptchaAuthProvider . PHONE_PROVIDER ,
Original file line number Diff line number Diff line change @@ -68,9 +68,9 @@ import { _castAuth } from '../../core/auth/auth_impl';
6868import { getModularInstance } from '@firebase/util' ;
6969import { ProviderId } from '../../model/enums' ;
7070import {
71- RecaptchaEnterpriseVerifier ,
7271 FAKE_TOKEN ,
73- handleRecaptchaFlow
72+ handleRecaptchaFlow ,
73+ _initializeRecaptchaConfig
7474} from '../recaptcha/recaptcha_enterprise_verifier' ;
7575import { _isFirebaseServerApp } from '@firebase/app' ;
7676
@@ -227,8 +227,17 @@ export async function _verifyPhoneNumber(
227227 verifier ?: ApplicationVerifierInternal
228228) : Promise < string > {
229229 if ( ! auth . _getRecaptchaConfig ( ) ) {
230- const enterpriseVerifier = new RecaptchaEnterpriseVerifier ( auth ) ;
231- await enterpriseVerifier . verify ( ) ;
230+ try {
231+ await _initializeRecaptchaConfig ( auth ) ;
232+ } catch ( error ) {
233+ // If an error occurs while fetching the config, there is no way to know the enablement state
234+ // of Phone provider, so we proceed with recaptcha V2 verification.
235+ // The error is likely "recaptchaKey undefined", as reCAPTCHA Enterprise is not
236+ // enabled for any provider.
237+ console . log (
238+ 'Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.'
239+ ) ;
240+ }
232241 }
233242
234243 try {
You can’t perform that action at this time.
0 commit comments