Skip to content

Commit 927d06b

Browse files
committed
Check for non-Enterprise recaptcha object
1 parent a6dc377 commit 927d06b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/auth/src/platform_browser/recaptcha/recaptcha_loader.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export interface ReCaptchaLoader {
4949
export class ReCaptchaLoaderImpl implements ReCaptchaLoader {
5050
private hostLanguage = '';
5151
private counter = 0;
52-
private readonly librarySeparatelyLoaded = !!_window().grecaptcha;
52+
/**
53+
* Check for `render()` method. `window.grecaptcha` will exist if the Enterprise
54+
* version of the ReCAPTCHA script was loaded by someone else (e.g. App Check) but
55+
* `window.grecaptcha.render()` will not. Another load will add it.
56+
*/
57+
private readonly librarySeparatelyLoaded = !!_window().grecaptcha?.render;
5358

5459
load(auth: AuthInternal, hl = ''): Promise<Recaptcha> {
5560
_assert(isHostLanguageValid(hl), auth, AuthErrorCode.ARGUMENT_ERROR);
@@ -112,7 +117,7 @@ export class ReCaptchaLoaderImpl implements ReCaptchaLoader {
112117
// In cases (2) and (3), we _can't_ reload as it would break the recaptchas
113118
// that are already in the page
114119
return (
115-
!!_window().grecaptcha &&
120+
!!_window().grecaptcha?.render &&
116121
(hl === this.hostLanguage ||
117122
this.counter > 0 ||
118123
this.librarySeparatelyLoaded)

0 commit comments

Comments
 (0)