Does app check check work with firebase phone auth?

Viewed 120

I'm new to web development in general. started learning Javascript last year.

I created a website for testing. Before implementing app check, phone auth worked fine.

I'm using reCaptcha enterprise for app check.

I get this error: Uncaught (in promise) TypeError: recaptchaVerifier.render is not a function

implementing app check:

const { initializeAppCheck, ReCaptchaEnterpriseProvider } = require("firebase/app-check");

const appCheck = initializeAppCheck(firebaseApp, {
    provider: new ReCaptchaEnterpriseProvider('**********************************'),
    isTokenAutoRefreshEnabled: true // Set to true to allow auto-refresh.
});

My javascript code for implementing phone auth:

$('#phone-method').click(function() {

 window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {}, auth);
 // Sign in with phone flow
})
2 Answers

Same problem to me, but this thread in Github help me:

https://github.com/firebase/firebase-js-sdk/issues/6133

Here you have a nice sample inside.

It seems that appCheck only works great with ReCaptchaV3Provider. You will just have to change:

initializeAppCheck(app, {
    provider: new ReCaptchaEnterpriseProvider(*****),
    isTokenAutoRefreshEnabled: true
})

to:

initializeAppCheck(app, {
    provider: new ReCaptchaV3Provider(*****),
    isTokenAutoRefreshEnabled: true
})

And I recommend to change the way to initialize captcha, set to invisible like this:

 window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', 
 { 'size': 'invisible' },
 auth);
Related