@firebase/auth 1.13.1 → 1.13.2-eap-crashlytics.558ee841d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/browser-cjs/{index-58b444b9.js → index-223cb6d8.js} +55 -15
  2. package/dist/browser-cjs/index-223cb6d8.js.map +1 -0
  3. package/dist/browser-cjs/index.js +1 -1
  4. package/dist/browser-cjs/internal.js +1 -1
  5. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  6. package/dist/browser-cjs/test/helpers/mock_loadjs.d.ts +17 -0
  7. package/dist/cordova/index.js +2 -2
  8. package/dist/cordova/internal.js +2 -2
  9. package/dist/cordova/{popup_redirect-e90e6597.js → popup_redirect-8f954bab.js} +56 -16
  10. package/dist/cordova/popup_redirect-8f954bab.js.map +1 -0
  11. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  12. package/dist/cordova/test/helpers/mock_loadjs.d.ts +17 -0
  13. package/dist/esm/{index-907e9a1a.js → index-42b2f63a.js} +56 -16
  14. package/dist/esm/index-42b2f63a.js.map +1 -0
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/internal.js +2 -2
  17. package/dist/esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  18. package/dist/esm/test/helpers/mock_loadjs.d.ts +17 -0
  19. package/dist/index.webworker.js +55 -15
  20. package/dist/index.webworker.js.map +1 -1
  21. package/dist/node/index.js +1 -1
  22. package/dist/node/internal.js +1 -1
  23. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  24. package/dist/node/test/helpers/mock_loadjs.d.ts +17 -0
  25. package/dist/node/{totp-ec1dc837.js → totp-1de3d98e.js} +39 -5
  26. package/dist/node/totp-1de3d98e.js.map +1 -0
  27. package/dist/node-esm/index.js +1 -1
  28. package/dist/node-esm/internal.js +2 -2
  29. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  30. package/dist/node-esm/test/helpers/mock_loadjs.d.ts +17 -0
  31. package/dist/node-esm/{totp-97daafa8.js → totp-16b08ec9.js} +40 -6
  32. package/dist/node-esm/totp-16b08ec9.js.map +1 -0
  33. package/dist/rn/{index-ec5272bc.js → index-3c01bc90.js} +39 -5
  34. package/dist/rn/index-3c01bc90.js.map +1 -0
  35. package/dist/rn/index.js +1 -1
  36. package/dist/rn/internal.js +18 -12
  37. package/dist/rn/internal.js.map +1 -1
  38. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  39. package/dist/rn/test/helpers/mock_loadjs.d.ts +17 -0
  40. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  41. package/dist/test/helpers/mock_loadjs.d.ts +17 -0
  42. package/dist/web-extension-cjs/index.js +1 -1
  43. package/dist/web-extension-cjs/internal.js +1 -1
  44. package/dist/web-extension-cjs/{register-410eef86.js → register-6a93d6fa.js} +55 -15
  45. package/dist/web-extension-cjs/register-6a93d6fa.js.map +1 -0
  46. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  47. package/dist/web-extension-cjs/test/helpers/mock_loadjs.d.ts +17 -0
  48. package/dist/web-extension-esm/index.js +2 -2
  49. package/dist/web-extension-esm/internal.js +2 -2
  50. package/dist/web-extension-esm/{register-4207f7c7.js → register-6e13f5d2.js} +56 -16
  51. package/dist/web-extension-esm/register-6e13f5d2.js.map +1 -0
  52. package/dist/web-extension-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +18 -0
  53. package/dist/web-extension-esm/test/helpers/mock_loadjs.d.ts +17 -0
  54. package/package.json +6 -6
  55. package/dist/browser-cjs/index-58b444b9.js.map +0 -1
  56. package/dist/cordova/popup_redirect-e90e6597.js.map +0 -1
  57. package/dist/esm/index-907e9a1a.js.map +0 -1
  58. package/dist/node/totp-ec1dc837.js.map +0 -1
  59. package/dist/node-esm/totp-97daafa8.js.map +0 -1
  60. package/dist/rn/index-ec5272bc.js.map +0 -1
  61. package/dist/web-extension-cjs/register-410eef86.js.map +0 -1
  62. package/dist/web-extension-esm/register-4207f7c7.js.map +0 -1
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { A as ActionCodeOperation, aj as ActionCodeURL, M as AuthCredential, J as AuthErrorCodes, N as EmailAuthCredential, W as EmailAuthProvider, X as FacebookAuthProvider, F as FactorId, Z as GithubAuthProvider, Y as GoogleAuthProvider, Q as OAuthCredential, _ as OAuthProvider, O as OperationType, U as PhoneAuthCredential, P as PhoneAuthProvider, n as PhoneMultiFactorGenerator, q as ProviderId, R as RecaptchaVerifier, $ as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, o as TotpSecret, a0 as TwitterAuthProvider, a8 as applyActionCode, y as beforeAuthStateChanged, a as browserCookiePersistence, b as browserLocalPersistence, m as browserPopupRedirectResolver, c as browserSessionPersistence, a9 as checkActionCode, a7 as confirmPasswordReset, L as connectAuthEmulator, ab as createUserWithEmailAndPassword, H as debugErrorMap, G as deleteUser, ag as fetchSignInMethodsForEmail, ar as getAdditionalUserInfo, p as getAuth, ao as getIdToken, ap as getIdTokenResult, at as getMultiFactorResolver, k as getRedirectResult, V as inMemoryPersistence, i as indexedDBLocalPersistence, K as initializeAuth, v as initializeRecaptchaConfig, ae as isSignInWithEmailLink, a3 as linkWithCredential, l as linkWithPhoneNumber, e as linkWithPopup, h as linkWithRedirect, au as multiFactor, z as onAuthStateChanged, x as onIdTokenChanged, ak as parseActionCodeURL, I as prodErrorMap, a4 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, f as reauthenticateWithPopup, j as reauthenticateWithRedirect, as as reload, E as revokeAccessToken, ah as sendEmailVerification, a6 as sendPasswordResetEmail, ad as sendSignInLinkToEmail, t as setPersistence, a1 as signInAnonymously, a2 as signInWithCredential, a5 as signInWithCustomToken, ac as signInWithEmailAndPassword, af as signInWithEmailLink, s as signInWithPhoneNumber, d as signInWithPopup, g as signInWithRedirect, D as signOut, aq as unlink, C as updateCurrentUser, am as updateEmail, an as updatePassword, u as updatePhoneNumber, al as updateProfile, B as useDeviceLanguage, w as validatePassword, ai as verifyBeforeUpdateEmail, aa as verifyPasswordResetCode } from './index-907e9a1a.js';
1
+ export { A as ActionCodeOperation, aj as ActionCodeURL, M as AuthCredential, J as AuthErrorCodes, N as EmailAuthCredential, W as EmailAuthProvider, X as FacebookAuthProvider, F as FactorId, Z as GithubAuthProvider, Y as GoogleAuthProvider, Q as OAuthCredential, _ as OAuthProvider, O as OperationType, U as PhoneAuthCredential, P as PhoneAuthProvider, n as PhoneMultiFactorGenerator, q as ProviderId, R as RecaptchaVerifier, $ as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, o as TotpSecret, a0 as TwitterAuthProvider, a8 as applyActionCode, y as beforeAuthStateChanged, a as browserCookiePersistence, b as browserLocalPersistence, m as browserPopupRedirectResolver, c as browserSessionPersistence, a9 as checkActionCode, a7 as confirmPasswordReset, L as connectAuthEmulator, ab as createUserWithEmailAndPassword, H as debugErrorMap, G as deleteUser, ag as fetchSignInMethodsForEmail, ar as getAdditionalUserInfo, p as getAuth, ao as getIdToken, ap as getIdTokenResult, at as getMultiFactorResolver, k as getRedirectResult, V as inMemoryPersistence, i as indexedDBLocalPersistence, K as initializeAuth, v as initializeRecaptchaConfig, ae as isSignInWithEmailLink, a3 as linkWithCredential, l as linkWithPhoneNumber, e as linkWithPopup, h as linkWithRedirect, au as multiFactor, z as onAuthStateChanged, x as onIdTokenChanged, ak as parseActionCodeURL, I as prodErrorMap, a4 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, f as reauthenticateWithPopup, j as reauthenticateWithRedirect, as as reload, E as revokeAccessToken, ah as sendEmailVerification, a6 as sendPasswordResetEmail, ad as sendSignInLinkToEmail, t as setPersistence, a1 as signInAnonymously, a2 as signInWithCredential, a5 as signInWithCustomToken, ac as signInWithEmailAndPassword, af as signInWithEmailLink, s as signInWithPhoneNumber, d as signInWithPopup, g as signInWithRedirect, D as signOut, aq as unlink, C as updateCurrentUser, am as updateEmail, an as updatePassword, u as updatePhoneNumber, al as updateProfile, B as useDeviceLanguage, w as validatePassword, ai as verifyBeforeUpdateEmail, aa as verifyPasswordResetCode } from './index-42b2f63a.js';
2
2
  import '@firebase/app';
3
3
  import '@firebase/util';
4
4
  import '@firebase/logger';
@@ -1,5 +1,5 @@
1
- import { av as debugAssert, aw as _isIOS, ax as _isAndroid, ay as _fail, az as _getRedirectUrl, aA as _getProjectConfig, aB as _isIOS7Or8, aC as _createError, aD as _assert, aE as AuthEventManager, aF as _getInstance, b as browserLocalPersistence, aG as _persistenceKeyName, c as browserSessionPersistence, aH as _getRedirectResult, aI as _overrideRedirectResult, aJ as _clearRedirectOutcomes, aK as _castAuth } from './index-907e9a1a.js';
2
- export { A as ActionCodeOperation, aj as ActionCodeURL, M as AuthCredential, J as AuthErrorCodes, aM as AuthImpl, aP as AuthPopup, N as EmailAuthCredential, W as EmailAuthProvider, X as FacebookAuthProvider, F as FactorId, aQ as FetchProvider, Z as GithubAuthProvider, Y as GoogleAuthProvider, Q as OAuthCredential, _ as OAuthProvider, O as OperationType, U as PhoneAuthCredential, P as PhoneAuthProvider, n as PhoneMultiFactorGenerator, q as ProviderId, R as RecaptchaVerifier, aR as SAMLAuthCredential, $ as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, o as TotpSecret, a0 as TwitterAuthProvider, aL as UserImpl, aD as _assert, aK as _castAuth, ay as _fail, aO as _generateEventId, aN as _getClientVersion, aF as _getInstance, aH as _getRedirectResult, aI as _overrideRedirectResult, aG as _persistenceKeyName, a8 as applyActionCode, y as beforeAuthStateChanged, a as browserCookiePersistence, b as browserLocalPersistence, m as browserPopupRedirectResolver, c as browserSessionPersistence, a9 as checkActionCode, a7 as confirmPasswordReset, L as connectAuthEmulator, ab as createUserWithEmailAndPassword, H as debugErrorMap, G as deleteUser, ag as fetchSignInMethodsForEmail, ar as getAdditionalUserInfo, p as getAuth, ao as getIdToken, ap as getIdTokenResult, at as getMultiFactorResolver, k as getRedirectResult, V as inMemoryPersistence, i as indexedDBLocalPersistence, K as initializeAuth, v as initializeRecaptchaConfig, ae as isSignInWithEmailLink, a3 as linkWithCredential, l as linkWithPhoneNumber, e as linkWithPopup, h as linkWithRedirect, au as multiFactor, z as onAuthStateChanged, x as onIdTokenChanged, ak as parseActionCodeURL, I as prodErrorMap, a4 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, f as reauthenticateWithPopup, j as reauthenticateWithRedirect, as as reload, E as revokeAccessToken, ah as sendEmailVerification, a6 as sendPasswordResetEmail, ad as sendSignInLinkToEmail, t as setPersistence, a1 as signInAnonymously, a2 as signInWithCredential, a5 as signInWithCustomToken, ac as signInWithEmailAndPassword, af as signInWithEmailLink, s as signInWithPhoneNumber, d as signInWithPopup, g as signInWithRedirect, D as signOut, aq as unlink, C as updateCurrentUser, am as updateEmail, an as updatePassword, u as updatePhoneNumber, al as updateProfile, B as useDeviceLanguage, w as validatePassword, ai as verifyBeforeUpdateEmail, aa as verifyPasswordResetCode } from './index-907e9a1a.js';
1
+ import { av as debugAssert, aw as _isIOS, ax as _isAndroid, ay as _fail, az as _getRedirectUrl, aA as _getProjectConfig, aB as _isIOS7Or8, aC as _createError, aD as _assert, aE as AuthEventManager, aF as _getInstance, b as browserLocalPersistence, aG as _persistenceKeyName, c as browserSessionPersistence, aH as _getRedirectResult, aI as _overrideRedirectResult, aJ as _clearRedirectOutcomes, aK as _castAuth } from './index-42b2f63a.js';
2
+ export { A as ActionCodeOperation, aj as ActionCodeURL, M as AuthCredential, J as AuthErrorCodes, aM as AuthImpl, aP as AuthPopup, N as EmailAuthCredential, W as EmailAuthProvider, X as FacebookAuthProvider, F as FactorId, aQ as FetchProvider, Z as GithubAuthProvider, Y as GoogleAuthProvider, Q as OAuthCredential, _ as OAuthProvider, O as OperationType, U as PhoneAuthCredential, P as PhoneAuthProvider, n as PhoneMultiFactorGenerator, q as ProviderId, R as RecaptchaVerifier, aR as SAMLAuthCredential, $ as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, o as TotpSecret, a0 as TwitterAuthProvider, aL as UserImpl, aD as _assert, aK as _castAuth, ay as _fail, aO as _generateEventId, aN as _getClientVersion, aF as _getInstance, aH as _getRedirectResult, aI as _overrideRedirectResult, aG as _persistenceKeyName, a8 as applyActionCode, y as beforeAuthStateChanged, a as browserCookiePersistence, b as browserLocalPersistence, m as browserPopupRedirectResolver, c as browserSessionPersistence, a9 as checkActionCode, a7 as confirmPasswordReset, L as connectAuthEmulator, ab as createUserWithEmailAndPassword, H as debugErrorMap, G as deleteUser, ag as fetchSignInMethodsForEmail, ar as getAdditionalUserInfo, p as getAuth, ao as getIdToken, ap as getIdTokenResult, at as getMultiFactorResolver, k as getRedirectResult, V as inMemoryPersistence, i as indexedDBLocalPersistence, K as initializeAuth, v as initializeRecaptchaConfig, ae as isSignInWithEmailLink, a3 as linkWithCredential, l as linkWithPhoneNumber, e as linkWithPopup, h as linkWithRedirect, au as multiFactor, z as onAuthStateChanged, x as onIdTokenChanged, ak as parseActionCodeURL, I as prodErrorMap, a4 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, f as reauthenticateWithPopup, j as reauthenticateWithRedirect, as as reload, E as revokeAccessToken, ah as sendEmailVerification, a6 as sendPasswordResetEmail, ad as sendSignInLinkToEmail, t as setPersistence, a1 as signInAnonymously, a2 as signInWithCredential, a5 as signInWithCustomToken, ac as signInWithEmailAndPassword, af as signInWithEmailLink, s as signInWithPhoneNumber, d as signInWithPopup, g as signInWithRedirect, D as signOut, aq as unlink, C as updateCurrentUser, am as updateEmail, an as updatePassword, u as updatePhoneNumber, al as updateProfile, B as useDeviceLanguage, w as validatePassword, ai as verifyBeforeUpdateEmail, aa as verifyPasswordResetCode } from './index-42b2f63a.js';
3
3
  import { querystringDecode } from '@firebase/util';
4
4
  import '@firebase/app';
5
5
  import '@firebase/logger';
@@ -19,12 +19,30 @@ import { Auth } from '../../model/public_types';
19
19
  import { AuthInternal } from '../../model/auth';
20
20
  export declare const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = "recaptcha-enterprise";
21
21
  export declare const FAKE_TOKEN = "NO_RECAPTCHA";
22
+ export declare const RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME = "onFirebaseAuthREInstanceReady";
23
+ declare global {
24
+ interface Window {
25
+ [RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME]: () => void;
26
+ }
27
+ }
22
28
  export declare class RecaptchaEnterpriseVerifier {
23
29
  /**
24
30
  * Identifies the type of application verifier (e.g. "recaptcha-enterprise").
25
31
  */
26
32
  readonly type = "recaptcha-enterprise";
27
33
  private readonly auth;
34
+ /**
35
+ * Deferred that resolves when script tag has been injected onto the page
36
+ * and the script is ready (grecaptcha.ready() and script.onload are not
37
+ * reliable indicators, so this resolves when the global
38
+ * `window[RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME]()` callback provided to the recaptcha url param "onload"
39
+ * is triggered).
40
+ * As a static variable this is applied to all instances of the class.
41
+ * This will cause an error if users try to create multiple RecaptchaVerifiers
42
+ * with different Recaptcha Enterprise sitekeys, which should be an
43
+ * unuspported use case.
44
+ */
45
+ private static scriptInjectionDeferred;
28
46
  /**
29
47
  *
30
48
  * @param authExtern - The corresponding Firebase {@link Auth} instance.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare const mockLoadJS: () => Promise<Event>;
@@ -1,5 +1,5 @@
1
1
  import { SDK_VERSION, _getProvider, _isFirebaseServerApp, _registerComponent, registerVersion, getApp } from '@firebase/app';
2
- import { ErrorFactory, deepEqual, getUA, isBrowserExtension, isMobileCordova, isReactNative, FirebaseError, querystring, isCloudflareWorker, isCloudWorkstation, getModularInstance, base64Decode, createSubscribe, pingServer, querystringDecode, extractQuerystring } from '@firebase/util';
2
+ import { ErrorFactory, deepEqual, getUA, isBrowserExtension, isMobileCordova, isReactNative, FirebaseError, querystring, isCloudflareWorker, isCloudWorkstation, getModularInstance, base64Decode, createSubscribe, Deferred, pingServer, querystringDecode, extractQuerystring } from '@firebase/util';
3
3
  import { Logger, LogLevel } from '@firebase/logger';
4
4
  import { Component } from '@firebase/component';
5
5
 
@@ -533,7 +533,7 @@ function _initializeAuthInstance(auth, deps) {
533
533
  }
534
534
 
535
535
  var name = "@firebase/auth";
536
- var version = "1.13.1";
536
+ var version = "1.13.2-eap-crashlytics.558ee841d";
537
537
 
538
538
  /**
539
539
  * @license
@@ -3658,6 +3658,7 @@ const _TRANSACTION_RETRY_COUNT = 3;
3658
3658
  class IndexedDBLocalPersistence {
3659
3659
  constructor() {
3660
3660
  this.type = "LOCAL" /* PersistenceType.LOCAL */;
3661
+ this.dbPromise = null;
3661
3662
  this._shouldAllowMigration = true;
3662
3663
  this.listeners = {};
3663
3664
  this.localCache = {};
@@ -3674,11 +3675,14 @@ class IndexedDBLocalPersistence {
3674
3675
  this.initializeServiceWorkerMessaging().then(() => { }, () => { });
3675
3676
  }
3676
3677
  async _openDb() {
3677
- if (this.db) {
3678
- return this.db;
3678
+ if (this.dbPromise) {
3679
+ return this.dbPromise;
3679
3680
  }
3680
- this.db = await _openDatabase();
3681
- return this.db;
3681
+ this.dbPromise = _openDatabase();
3682
+ this.dbPromise.catch(() => {
3683
+ this.dbPromise = null;
3684
+ });
3685
+ return this.dbPromise;
3682
3686
  }
3683
3687
  async _withRetries(op) {
3684
3688
  let numAttempts = 0;
@@ -3691,9 +3695,10 @@ class IndexedDBLocalPersistence {
3691
3695
  if (numAttempts++ > _TRANSACTION_RETRY_COUNT) {
3692
3696
  throw e;
3693
3697
  }
3694
- if (this.db) {
3695
- this.db.close();
3696
- this.db = undefined;
3698
+ if (this.dbPromise) {
3699
+ const db = await this.dbPromise;
3700
+ db.close();
3701
+ this.dbPromise = null;
3697
3702
  }
3698
3703
  // TODO: consider adding exponential backoff
3699
3704
  }
@@ -3778,9 +3783,10 @@ class IndexedDBLocalPersistence {
3778
3783
  if (!indexedDB) {
3779
3784
  return false;
3780
3785
  }
3781
- const db = await _openDatabase();
3782
- await _putObject(db, STORAGE_AVAILABLE_KEY, '1');
3783
- await _deleteObject(db, STORAGE_AVAILABLE_KEY);
3786
+ await this._withRetries(async (db) => {
3787
+ await _putObject(db, STORAGE_AVAILABLE_KEY, '1');
3788
+ await _deleteObject(db, STORAGE_AVAILABLE_KEY);
3789
+ });
3784
3790
  return true;
3785
3791
  }
3786
3792
  catch { }
@@ -4180,6 +4186,7 @@ class MockGreCAPTCHA {
4180
4186
  /* eslint-disable @typescript-eslint/no-require-imports */
4181
4187
  const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
4182
4188
  const FAKE_TOKEN = 'NO_RECAPTCHA';
4189
+ const RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME = 'onFirebaseAuthREInstanceReady';
4183
4190
  class RecaptchaEnterpriseVerifier {
4184
4191
  /**
4185
4192
  *
@@ -4259,8 +4266,13 @@ class RecaptchaEnterpriseVerifier {
4259
4266
  }
4260
4267
  return new Promise((resolve, reject) => {
4261
4268
  retrieveSiteKey(this.auth)
4262
- .then(siteKey => {
4263
- if (!forceRefresh && isEnterprise(window.grecaptcha)) {
4269
+ .then(async (siteKey) => {
4270
+ if (!forceRefresh &&
4271
+ isEnterprise(window.grecaptcha) &&
4272
+ // If download has already been initiated, do not trigger another
4273
+ // download, await the promise here.
4274
+ RecaptchaEnterpriseVerifier.scriptInjectionDeferred) {
4275
+ await RecaptchaEnterpriseVerifier.scriptInjectionDeferred.promise;
4264
4276
  retrieveRecaptchaToken(siteKey, resolve, reject);
4265
4277
  }
4266
4278
  else {
@@ -4270,9 +4282,25 @@ class RecaptchaEnterpriseVerifier {
4270
4282
  }
4271
4283
  let url = _recaptchaEnterpriseScriptUrl();
4272
4284
  if (url.length !== 0) {
4273
- url += siteKey;
4285
+ url +=
4286
+ siteKey +
4287
+ `&onload=${RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME}`;
4274
4288
  }
4289
+ // Existence of deferred indicates download has been initiated.
4290
+ RecaptchaEnterpriseVerifier.scriptInjectionDeferred =
4291
+ new Deferred();
4292
+ /**
4293
+ * Script attached to global window object that will be called
4294
+ * when the ReCAPTCHA Enterprise instance is ready.
4295
+ * grecaptcha.ready() is not reliable when there are multiple
4296
+ * scripts on the page, and script.onload only indicates the
4297
+ * script has downloaded, not that it has initialized.
4298
+ */
4299
+ window[RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME] = () => {
4300
+ RecaptchaEnterpriseVerifier.scriptInjectionDeferred?.resolve();
4301
+ };
4275
4302
  _loadJS(url)
4303
+ .then(() => RecaptchaEnterpriseVerifier.scriptInjectionDeferred?.promise)
4276
4304
  .then(() => {
4277
4305
  retrieveRecaptchaToken(siteKey, resolve, reject);
4278
4306
  })
@@ -4287,6 +4315,18 @@ class RecaptchaEnterpriseVerifier {
4287
4315
  });
4288
4316
  }
4289
4317
  }
4318
+ /**
4319
+ * Deferred that resolves when script tag has been injected onto the page
4320
+ * and the script is ready (grecaptcha.ready() and script.onload are not
4321
+ * reliable indicators, so this resolves when the global
4322
+ * `window[RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME]()` callback provided to the recaptcha url param "onload"
4323
+ * is triggered).
4324
+ * As a static variable this is applied to all instances of the class.
4325
+ * This will cause an error if users try to create multiple RecaptchaVerifiers
4326
+ * with different Recaptcha Enterprise sitekeys, which should be an
4327
+ * unuspported use case.
4328
+ */
4329
+ RecaptchaEnterpriseVerifier.scriptInjectionDeferred = null;
4290
4330
  async function injectRecaptchaFields(auth, request, action, isCaptchaResp = false, isFakeToken = false) {
4291
4331
  const verifier = new RecaptchaEnterpriseVerifier(auth);
4292
4332
  let captchaResponse;