From 927d06b2224d85e06946e8568d2bb95eb552ad9e Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 7 Jul 2022 11:29:31 -0700 Subject: [PATCH 1/2] Check for non-Enterprise recaptcha object --- .../src/platform_browser/recaptcha/recaptcha_loader.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.ts b/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.ts index 212c81b0d1f..a75e889398f 100644 --- a/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.ts +++ b/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.ts @@ -49,7 +49,12 @@ export interface ReCaptchaLoader { export class ReCaptchaLoaderImpl implements ReCaptchaLoader { private hostLanguage = ''; private counter = 0; - private readonly librarySeparatelyLoaded = !!_window().grecaptcha; + /** + * Check for `render()` method. `window.grecaptcha` will exist if the Enterprise + * version of the ReCAPTCHA script was loaded by someone else (e.g. App Check) but + * `window.grecaptcha.render()` will not. Another load will add it. + */ + private readonly librarySeparatelyLoaded = !!_window().grecaptcha?.render; load(auth: AuthInternal, hl = ''): Promise { _assert(isHostLanguageValid(hl), auth, AuthErrorCode.ARGUMENT_ERROR); @@ -112,7 +117,7 @@ export class ReCaptchaLoaderImpl implements ReCaptchaLoader { // In cases (2) and (3), we _can't_ reload as it would break the recaptchas // that are already in the page return ( - !!_window().grecaptcha && + !!_window().grecaptcha?.render && (hl === this.hostLanguage || this.counter > 0 || this.librarySeparatelyLoaded) From 3c1aa2ee19456df07f9c40c5295a855684543ed5 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 7 Jul 2022 12:08:25 -0700 Subject: [PATCH 2/2] Add changeset --- .changeset/smooth-readers-cough.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/smooth-readers-cough.md diff --git a/.changeset/smooth-readers-cough.md b/.changeset/smooth-readers-cough.md new file mode 100644 index 00000000000..4ef624b647d --- /dev/null +++ b/.changeset/smooth-readers-cough.md @@ -0,0 +1,5 @@ +--- +'@firebase/auth': patch +--- + +Fix a bug causing ReCAPTCHA conflicts between Auth and App Check.