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', () => {
64
64
context ( '#verifyPhoneNumber' , ( ) => {
65
65
it ( 'calls verify on the appVerifier and then calls the server when recaptcha enterprise is disabled' , async ( ) => {
66
66
const recaptchaConfigResponseOff = {
67
- recaptchaKey : 'foo/bar/to/site- key' ,
67
+ // no recaptcha key if no rCE provider is enabled
68
68
recaptchaEnforcementState : [
69
69
{
70
70
provider : RecaptchaAuthProvider . PHONE_PROVIDER ,
@@ -111,7 +111,7 @@ describe('platform_browser/providers/phone', () => {
111
111
112
112
it ( 'throws an error if verify without appVerifier when recaptcha enterprise is disabled' , async ( ) => {
113
113
const recaptchaConfigResponseOff = {
114
- recaptchaKey : 'foo/bar/to/site- key' ,
114
+ // no recaptcha key if no rCE provider is enabled
115
115
recaptchaEnforcementState : [
116
116
{
117
117
provider : RecaptchaAuthProvider . PHONE_PROVIDER ,
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ const recaptchaConfigResponseAudit = {
83
83
]
84
84
} ;
85
85
const recaptchaConfigResponseOff = {
86
- recaptchaKey : 'foo/bar/to/site- key' ,
86
+ // no recaptcha key if no rCE provider is enabled
87
87
recaptchaEnforcementState : [
88
88
{
89
89
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';
68
68
import { getModularInstance } from '@firebase/util' ;
69
69
import { ProviderId } from '../../model/enums' ;
70
70
import {
71
- RecaptchaEnterpriseVerifier ,
72
71
FAKE_TOKEN ,
73
- handleRecaptchaFlow
72
+ handleRecaptchaFlow ,
73
+ _initializeRecaptchaConfig
74
74
} from '../recaptcha/recaptcha_enterprise_verifier' ;
75
75
import { _isFirebaseServerApp } from '@firebase/app' ;
76
76
@@ -227,8 +227,17 @@ export async function _verifyPhoneNumber(
227
227
verifier ?: ApplicationVerifierInternal
228
228
) : Promise < string > {
229
229
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
+ }
232
241
}
233
242
234
243
try {
You can’t perform that action at this time.
0 commit comments