@firebase/auth 1.13.9 → 1.13.10-20261111165442

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 (70) hide show
  1. package/dist/auth-public.d.ts +1 -0
  2. package/dist/auth.d.ts +1 -0
  3. package/dist/browser-cjs/{index-DTUcAMkM.js → index-3quNI-5T.js} +180 -62
  4. package/dist/browser-cjs/index-3quNI-5T.js.map +1 -0
  5. package/dist/browser-cjs/index.js +1 -1
  6. package/dist/browser-cjs/internal.js +1 -1
  7. package/dist/browser-cjs/src/core/persistence/index.d.ts +1 -0
  8. package/dist/browser-cjs/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  9. package/dist/cordova/auth-cordova-public.d.ts +1 -0
  10. package/dist/cordova/auth-cordova.d.ts +1 -0
  11. package/dist/cordova/index.js +2 -2
  12. package/dist/cordova/internal.js +2 -2
  13. package/dist/cordova/{popup_redirect-xyFFcAgj.js → popup_redirect-BfyV9XtN.js} +180 -62
  14. package/dist/cordova/popup_redirect-BfyV9XtN.js.map +1 -0
  15. package/dist/cordova/src/core/persistence/index.d.ts +1 -0
  16. package/dist/cordova/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  17. package/dist/esm/{index-Bz2J43nW.js → index-D7PwIQ8t.js} +180 -62
  18. package/dist/esm/index-D7PwIQ8t.js.map +1 -0
  19. package/dist/esm/index.js +1 -1
  20. package/dist/esm/internal.js +2 -2
  21. package/dist/esm/src/core/persistence/index.d.ts +1 -0
  22. package/dist/esm/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  23. package/dist/index.webworker.js +179 -61
  24. package/dist/index.webworker.js.map +1 -1
  25. package/dist/node/index.js +1 -1
  26. package/dist/node/internal.js +1 -1
  27. package/dist/node/internal.js.map +1 -1
  28. package/dist/node/src/core/persistence/index.d.ts +1 -0
  29. package/dist/node/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  30. package/dist/node/{totp-CMTC0AYP.js → totp-Cvunw6R9.js} +49 -30
  31. package/dist/node/totp-Cvunw6R9.js.map +1 -0
  32. package/dist/node-esm/index.js +1 -1
  33. package/dist/node-esm/internal.js +2 -2
  34. package/dist/node-esm/internal.js.map +1 -1
  35. package/dist/node-esm/src/core/persistence/index.d.ts +1 -0
  36. package/dist/node-esm/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  37. package/dist/node-esm/{totp-pe8Y0u5S.js → totp-BIzof36h.js} +49 -30
  38. package/dist/node-esm/totp-BIzof36h.js.map +1 -0
  39. package/dist/rn/{index-DzY9h3Kn.js → index-Cjrvemz_.js} +49 -30
  40. package/dist/rn/index-Cjrvemz_.js.map +1 -0
  41. package/dist/rn/index.js +1 -1
  42. package/dist/rn/internal.js +132 -33
  43. package/dist/rn/internal.js.map +1 -1
  44. package/dist/rn/src/core/persistence/index.d.ts +1 -0
  45. package/dist/rn/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  46. package/dist/src/core/persistence/index.d.ts +1 -0
  47. package/dist/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  48. package/dist/web-extension-cjs/index.js +1 -1
  49. package/dist/web-extension-cjs/internal.js +1 -1
  50. package/dist/web-extension-cjs/{register-CTiLN4Sf.js → register-Bj5RraXk.js} +180 -62
  51. package/dist/web-extension-cjs/register-Bj5RraXk.js.map +1 -0
  52. package/dist/web-extension-cjs/src/core/persistence/index.d.ts +1 -0
  53. package/dist/web-extension-cjs/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  54. package/dist/web-extension-esm/auth-web-extension-public.d.ts +1 -0
  55. package/dist/web-extension-esm/auth-web-extension.d.ts +1 -0
  56. package/dist/web-extension-esm/index.js +2 -2
  57. package/dist/web-extension-esm/internal.js +2 -2
  58. package/dist/web-extension-esm/{register-DBjcU-NC.js → register-B2Dp0WV3.js} +180 -62
  59. package/dist/web-extension-esm/register-B2Dp0WV3.js.map +1 -0
  60. package/dist/web-extension-esm/src/core/persistence/index.d.ts +1 -0
  61. package/dist/web-extension-esm/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  62. package/package.json +1 -1
  63. package/dist/browser-cjs/index-DTUcAMkM.js.map +0 -1
  64. package/dist/cordova/popup_redirect-xyFFcAgj.js.map +0 -1
  65. package/dist/esm/index-Bz2J43nW.js.map +0 -1
  66. package/dist/node/totp-CMTC0AYP.js.map +0 -1
  67. package/dist/node-esm/totp-pe8Y0u5S.js.map +0 -1
  68. package/dist/rn/index-DzY9h3Kn.js.map +0 -1
  69. package/dist/web-extension-cjs/register-CTiLN4Sf.js.map +0 -1
  70. package/dist/web-extension-esm/register-DBjcU-NC.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-DTUcAMkM.js');
5
+ var index = require('./index-3quNI-5T.js');
6
6
  require('@firebase/app');
7
7
  require('@firebase/util');
8
8
  require('@firebase/logger');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-DTUcAMkM.js');
5
+ var index = require('./index-3quNI-5T.js');
6
6
  var util = require('@firebase/util');
7
7
  require('@firebase/app');
8
8
  require('@firebase/logger');
@@ -39,4 +39,5 @@ export interface PersistenceInternal extends Persistence {
39
39
  _addListener(key: string, listener: StorageEventListener): void;
40
40
  _removeListener(key: string, listener: StorageEventListener): void;
41
41
  _shouldAllowMigration?: boolean;
42
+ _lastProbeTimedOut?: boolean;
42
43
  }
@@ -17,13 +17,27 @@
17
17
  import { Persistence } from '../../model/public_types';
18
18
  import { PersistenceValue } from '../../core/persistence/';
19
19
  export declare const DB_NAME = "firebaseLocalStorageDb";
20
+ export declare const _POLLING_INTERVAL_MS = 800;
21
+ export declare const _TRANSACTION_RETRY_COUNT = 3;
22
+ /**
23
+ * Short timeout scoped to the `readwrite` availability probe in `_isAvailable()`.
24
+ * Matches `_POLLING_INTERVAL_MS` so that if a background tab is suspended while
25
+ * holding a `readonly` poll transaction that blocks `readwrite` transactions
26
+ * (#10540), the startup probe fails fast and aborts its queued transaction in
27
+ * under a second without blocking fallback or user loading.
28
+ */
29
+ export declare const _DB_PROBE_TIMEOUT_MS = 800;
30
+ /**
31
+ * Timeout for opening the database and regular IndexedDB read/write requests.
32
+ * Kept at multiple seconds to accommodate cold `indexedDB.open()` or slow disk
33
+ * I/O on low-end devices without premature timeouts.
34
+ */
35
+ export declare const _DB_TIMEOUT_MS = 2500;
20
36
  export declare function _clearDatabase(db: IDBDatabase): Promise<void>;
21
37
  export declare function _deleteDatabase(): Promise<void>;
22
38
  export declare function _openDatabase(): Promise<IDBDatabase>;
23
- export declare function _putObject(db: IDBDatabase, key: string, value: PersistenceValue | string): Promise<void>;
24
- export declare function _deleteObject(db: IDBDatabase, key: string): Promise<void>;
25
- export declare const _POLLING_INTERVAL_MS = 800;
26
- export declare const _TRANSACTION_RETRY_COUNT = 3;
39
+ export declare function _putObject(db: IDBDatabase, key: string, value: PersistenceValue | string, timeoutMs?: number): Promise<void>;
40
+ export declare function _deleteObject(db: IDBDatabase, key: string, timeoutMs?: number): Promise<void>;
27
41
  /**
28
42
  * An implementation of {@link Persistence} of type `LOCAL` using `indexedDB`
29
43
  * for the underlying storage.
@@ -2314,6 +2314,7 @@ declare interface PersistenceInternal extends Persistence {
2314
2314
  _addListener(key: string, listener: StorageEventListener): void;
2315
2315
  _removeListener(key: string, listener: StorageEventListener): void;
2316
2316
  _shouldAllowMigration?: boolean;
2317
+ _lastProbeTimedOut?: boolean;
2317
2318
  }
2318
2319
 
2319
2320
  declare const enum PersistenceType {
@@ -2714,6 +2714,7 @@ declare interface PersistenceInternal extends Persistence {
2714
2714
  _addListener(key: string, listener: StorageEventListener): void;
2715
2715
  _removeListener(key: string, listener: StorageEventListener): void;
2716
2716
  _shouldAllowMigration?: boolean;
2717
+ _lastProbeTimedOut?: boolean;
2717
2718
  }
2718
2719
 
2719
2720
  declare const enum PersistenceType {
@@ -1,6 +1,6 @@
1
1
  import { _getProvider, getApp } from '@firebase/app';
2
- import { _ as _linkWithRedirect, a as _reauthenticateWithRedirect, b as _signInWithRedirect, r as registerAuth, i as initializeAuth, c as cordovaPopupRedirectResolver, d as indexedDBLocalPersistence } from './popup_redirect-xyFFcAgj.js';
3
- export { A as ActionCodeOperation, e as ActionCodeURL, f as AuthCredential, g as AuthErrorCodes, E as EmailAuthCredential, h as EmailAuthProvider, F as FacebookAuthProvider, j as FactorId, G as GithubAuthProvider, k as GoogleAuthProvider, O as OAuthCredential, l as OAuthProvider, m as OperationType, P as PhoneAuthCredential, n as ProviderId, S as SAMLAuthProvider, o as SignInMethod, T as TwitterAuthProvider, p as applyActionCode, q as beforeAuthStateChanged, s as browserLocalPersistence, t as browserSessionPersistence, u as checkActionCode, v as confirmPasswordReset, w as connectAuthEmulator, x as createUserWithEmailAndPassword, y as debugErrorMap, z as deleteUser, B as fetchSignInMethodsForEmail, C as getAdditionalUserInfo, D as getIdToken, H as getIdTokenResult, I as getMultiFactorResolver, J as getRedirectResult, K as inMemoryPersistence, L as initializeRecaptchaConfig, M as isSignInWithEmailLink, N as linkWithCredential, Q as multiFactor, R as onAuthStateChanged, U as onIdTokenChanged, V as parseActionCodeURL, W as prodErrorMap, X as reauthenticateWithCredential, Y as reload, Z as revokeAccessToken, $ as sendEmailVerification, a0 as sendPasswordResetEmail, a1 as sendSignInLinkToEmail, a2 as setPersistence, a3 as signInAnonymously, a4 as signInWithCredential, a5 as signInWithCustomToken, a6 as signInWithEmailAndPassword, a7 as signInWithEmailLink, a8 as signOut, a9 as unlink, aa as updateCurrentUser, ab as updateEmail, ac as updatePassword, ad as updateProfile, ae as useDeviceLanguage, af as validatePassword, ag as verifyBeforeUpdateEmail, ah as verifyPasswordResetCode } from './popup_redirect-xyFFcAgj.js';
2
+ import { _ as _linkWithRedirect, a as _reauthenticateWithRedirect, b as _signInWithRedirect, r as registerAuth, i as initializeAuth, c as cordovaPopupRedirectResolver, d as indexedDBLocalPersistence } from './popup_redirect-BfyV9XtN.js';
3
+ export { A as ActionCodeOperation, e as ActionCodeURL, f as AuthCredential, g as AuthErrorCodes, E as EmailAuthCredential, h as EmailAuthProvider, F as FacebookAuthProvider, j as FactorId, G as GithubAuthProvider, k as GoogleAuthProvider, O as OAuthCredential, l as OAuthProvider, m as OperationType, P as PhoneAuthCredential, n as ProviderId, S as SAMLAuthProvider, o as SignInMethod, T as TwitterAuthProvider, p as applyActionCode, q as beforeAuthStateChanged, s as browserLocalPersistence, t as browserSessionPersistence, u as checkActionCode, v as confirmPasswordReset, w as connectAuthEmulator, x as createUserWithEmailAndPassword, y as debugErrorMap, z as deleteUser, B as fetchSignInMethodsForEmail, C as getAdditionalUserInfo, D as getIdToken, H as getIdTokenResult, I as getMultiFactorResolver, J as getRedirectResult, K as inMemoryPersistence, L as initializeRecaptchaConfig, M as isSignInWithEmailLink, N as linkWithCredential, Q as multiFactor, R as onAuthStateChanged, U as onIdTokenChanged, V as parseActionCodeURL, W as prodErrorMap, X as reauthenticateWithCredential, Y as reload, Z as revokeAccessToken, $ as sendEmailVerification, a0 as sendPasswordResetEmail, a1 as sendSignInLinkToEmail, a2 as setPersistence, a3 as signInAnonymously, a4 as signInWithCredential, a5 as signInWithCustomToken, a6 as signInWithEmailAndPassword, a7 as signInWithEmailLink, a8 as signOut, a9 as unlink, aa as updateCurrentUser, ab as updateEmail, ac as updatePassword, ad as updateProfile, ae as useDeviceLanguage, af as validatePassword, ag as verifyBeforeUpdateEmail, ah as verifyPasswordResetCode } from './popup_redirect-BfyV9XtN.js';
4
4
  import '@firebase/util';
5
5
  import '@firebase/component';
6
6
  import '@firebase/logger';
@@ -1,5 +1,5 @@
1
- import { ai as _performApiRequest, aj as _addTidIfNecessary, ak as Delay, al as MockReCaptcha, am as _window, an as _assert, ao as isV2, ap as _createError, aq as _recaptchaV2ScriptUrl, ar as _loadJS, as as _generateCallbackName, at as _castAuth, au as _isHttpOrHttps, av as _isWorker, aw as getRecaptchaParams, ax as _assertLinkedStatus, N as linkWithCredential, ay as _serverAppCurrentUserOperationNotSupportedError, X as reauthenticateWithCredential, a4 as signInWithCredential, az as _link, aA as _initializeRecaptchaConfig, aB as FAKE_TOKEN, aC as startEnrollPhoneMfa, aD as handleRecaptchaFlow, aE as sendPhoneVerificationCode, P as PhoneAuthCredential, aF as _assertInstanceOf, aG as _withDefaultResolver, aH as AbstractPopupRedirectOperation, aI as debugAssert, aJ as _generateEventId, aK as FederatedAuthProvider, aL as _getProjectConfig, aM as _fail, aN as _getCurrentUrl, aO as _gapiScriptUrl, aP as _emulatorUrl, aQ as _isChromeIOS, aR as _isFirefox, aS as _isIOSStandalone, t as browserSessionPersistence, aT as _getRedirectResult, aU as _overrideRedirectResult, aV as _getRedirectUrl, aW as _setWindowLocation, aX as AuthEventManager, aY as _isMobileBrowser, aZ as _isSafari, a_ as _isIOS, a$ as debugFail, b0 as finalizeEnrollPhoneMfa, b1 as startEnrollTotpMfa, b2 as finalizeEnrollTotpMfa, r as registerAuth, i as initializeAuth, d as indexedDBLocalPersistence, s as browserLocalPersistence, q as beforeAuthStateChanged, U as onIdTokenChanged, w as connectAuthEmulator, b3 as _setExternalJSProvider } from './popup_redirect-xyFFcAgj.js';
2
- export { A as ActionCodeOperation, e as ActionCodeURL, f as AuthCredential, g as AuthErrorCodes, b4 as AuthImpl, E as EmailAuthCredential, h as EmailAuthProvider, F as FacebookAuthProvider, j as FactorId, b5 as FetchProvider, G as GithubAuthProvider, k as GoogleAuthProvider, O as OAuthCredential, l as OAuthProvider, m as OperationType, n as ProviderId, b6 as SAMLAuthCredential, S as SAMLAuthProvider, o as SignInMethod, T as TwitterAuthProvider, b7 as UserImpl, b8 as _getClientVersion, b9 as _getInstance, ba as _persistenceKeyName, p as applyActionCode, u as checkActionCode, v as confirmPasswordReset, c as cordovaPopupRedirectResolver, x as createUserWithEmailAndPassword, y as debugErrorMap, z as deleteUser, B as fetchSignInMethodsForEmail, C as getAdditionalUserInfo, D as getIdToken, H as getIdTokenResult, I as getMultiFactorResolver, J as getRedirectResult, K as inMemoryPersistence, L as initializeRecaptchaConfig, M as isSignInWithEmailLink, bb as linkWithRedirect, Q as multiFactor, R as onAuthStateChanged, V as parseActionCodeURL, W as prodErrorMap, bc as reauthenticateWithRedirect, Y as reload, Z as revokeAccessToken, $ as sendEmailVerification, a0 as sendPasswordResetEmail, a1 as sendSignInLinkToEmail, a2 as setPersistence, a3 as signInAnonymously, a5 as signInWithCustomToken, a6 as signInWithEmailAndPassword, a7 as signInWithEmailLink, bd as signInWithRedirect, a8 as signOut, a9 as unlink, aa as updateCurrentUser, ab as updateEmail, ac as updatePassword, ad as updateProfile, ae as useDeviceLanguage, af as validatePassword, ag as verifyBeforeUpdateEmail, ah as verifyPasswordResetCode } from './popup_redirect-xyFFcAgj.js';
1
+ import { ai as _performApiRequest, aj as _addTidIfNecessary, ak as Delay, al as MockReCaptcha, am as _window, an as _assert, ao as isV2, ap as _createError, aq as _recaptchaV2ScriptUrl, ar as _loadJS, as as _generateCallbackName, at as _castAuth, au as _isHttpOrHttps, av as _isWorker, aw as getRecaptchaParams, ax as _assertLinkedStatus, N as linkWithCredential, ay as _serverAppCurrentUserOperationNotSupportedError, X as reauthenticateWithCredential, a4 as signInWithCredential, az as _link, aA as _initializeRecaptchaConfig, aB as FAKE_TOKEN, aC as startEnrollPhoneMfa, aD as handleRecaptchaFlow, aE as sendPhoneVerificationCode, P as PhoneAuthCredential, aF as _assertInstanceOf, aG as _withDefaultResolver, aH as AbstractPopupRedirectOperation, aI as debugAssert, aJ as _generateEventId, aK as FederatedAuthProvider, aL as _getProjectConfig, aM as _fail, aN as _getCurrentUrl, aO as _gapiScriptUrl, aP as _emulatorUrl, aQ as _isChromeIOS, aR as _isFirefox, aS as _isIOSStandalone, t as browserSessionPersistence, aT as _getRedirectResult, aU as _overrideRedirectResult, aV as _getRedirectUrl, aW as _setWindowLocation, aX as AuthEventManager, aY as _isMobileBrowser, aZ as _isSafari, a_ as _isIOS, a$ as debugFail, b0 as finalizeEnrollPhoneMfa, b1 as startEnrollTotpMfa, b2 as finalizeEnrollTotpMfa, r as registerAuth, i as initializeAuth, d as indexedDBLocalPersistence, s as browserLocalPersistence, q as beforeAuthStateChanged, U as onIdTokenChanged, w as connectAuthEmulator, b3 as _setExternalJSProvider } from './popup_redirect-BfyV9XtN.js';
2
+ export { A as ActionCodeOperation, e as ActionCodeURL, f as AuthCredential, g as AuthErrorCodes, b4 as AuthImpl, E as EmailAuthCredential, h as EmailAuthProvider, F as FacebookAuthProvider, j as FactorId, b5 as FetchProvider, G as GithubAuthProvider, k as GoogleAuthProvider, O as OAuthCredential, l as OAuthProvider, m as OperationType, n as ProviderId, b6 as SAMLAuthCredential, S as SAMLAuthProvider, o as SignInMethod, T as TwitterAuthProvider, b7 as UserImpl, b8 as _getClientVersion, b9 as _getInstance, ba as _persistenceKeyName, p as applyActionCode, u as checkActionCode, v as confirmPasswordReset, c as cordovaPopupRedirectResolver, x as createUserWithEmailAndPassword, y as debugErrorMap, z as deleteUser, B as fetchSignInMethodsForEmail, C as getAdditionalUserInfo, D as getIdToken, H as getIdTokenResult, I as getMultiFactorResolver, J as getRedirectResult, K as inMemoryPersistence, L as initializeRecaptchaConfig, M as isSignInWithEmailLink, bb as linkWithRedirect, Q as multiFactor, R as onAuthStateChanged, V as parseActionCodeURL, W as prodErrorMap, bc as reauthenticateWithRedirect, Y as reload, Z as revokeAccessToken, $ as sendEmailVerification, a0 as sendPasswordResetEmail, a1 as sendSignInLinkToEmail, a2 as setPersistence, a3 as signInAnonymously, a5 as signInWithCustomToken, a6 as signInWithEmailAndPassword, a7 as signInWithEmailLink, bd as signInWithRedirect, a8 as signOut, a9 as unlink, aa as updateCurrentUser, ab as updateEmail, ac as updatePassword, ad as updateProfile, ae as useDeviceLanguage, af as validatePassword, ag as verifyBeforeUpdateEmail, ah as verifyPasswordResetCode } from './popup_redirect-BfyV9XtN.js';
3
3
  import { querystring, getModularInstance, getUA, getExperimentalSetting, getDefaultEmulatorHost } from '@firebase/util';
4
4
  import { _isFirebaseServerApp, SDK_VERSION, _getProvider, getApp } from '@firebase/app';
5
5
  import '@firebase/component';
@@ -407,6 +407,23 @@ const DB_NAME = 'firebaseLocalStorageDb';
407
407
  const DB_VERSION = 1;
408
408
  const DB_OBJECTSTORE_NAME = 'firebaseLocalStorage';
409
409
  const DB_DATA_KEYPATH = 'fbase_key';
410
+ const _POLLING_INTERVAL_MS$1 = 800;
411
+ const _TRANSACTION_RETRY_COUNT = 3;
412
+ /**
413
+ * Short timeout scoped to the `readwrite` availability probe in `_isAvailable()`.
414
+ * Matches `_POLLING_INTERVAL_MS` so that if a background tab is suspended while
415
+ * holding a `readonly` poll transaction that blocks `readwrite` transactions
416
+ * (#10540), the startup probe fails fast and aborts its queued transaction in
417
+ * under a second without blocking fallback or user loading.
418
+ */
419
+ const _DB_PROBE_TIMEOUT_MS = 800;
420
+ /**
421
+ * Timeout for opening the database and regular IndexedDB read/write requests.
422
+ * Kept at multiple seconds to accommodate cold `indexedDB.open()` or slow disk
423
+ * I/O on low-end devices without premature timeouts.
424
+ */
425
+ const _DB_TIMEOUT_MS = 2500;
426
+ const DB_TIMEOUT_ERROR = 'DB_TIMEOUT';
410
427
  /**
411
428
  * Promise wrapper for IDBRequest
412
429
  *
@@ -417,13 +434,32 @@ class DBPromise {
417
434
  constructor(request) {
418
435
  this.request = request;
419
436
  }
420
- toPromise() {
437
+ toPromise(timeoutMs = _DB_TIMEOUT_MS) {
421
438
  return new Promise((resolve, reject) => {
439
+ let settled = false;
440
+ const timer = setTimeout(() => {
441
+ if (!settled) {
442
+ settled = true;
443
+ try {
444
+ this.request.transaction?.abort();
445
+ }
446
+ catch { }
447
+ reject(new Error(DB_TIMEOUT_ERROR));
448
+ }
449
+ }, timeoutMs);
422
450
  this.request.addEventListener('success', () => {
423
- resolve(this.request.result);
451
+ if (!settled) {
452
+ settled = true;
453
+ clearTimeout(timer);
454
+ resolve(this.request.result);
455
+ }
424
456
  });
425
457
  this.request.addEventListener('error', () => {
426
- reject(this.request.error);
458
+ if (!settled) {
459
+ settled = true;
460
+ clearTimeout(timer);
461
+ reject(this.request.error);
462
+ }
427
463
  });
428
464
  });
429
465
  }
@@ -440,8 +476,19 @@ function _deleteDatabase() {
440
476
  function _openDatabase() {
441
477
  const request = indexedDB.open(DB_NAME, DB_VERSION);
442
478
  return new Promise((resolve, reject) => {
479
+ let settled = false;
480
+ const timer = setTimeout(() => {
481
+ if (!settled) {
482
+ settled = true;
483
+ reject(new Error(DB_TIMEOUT_ERROR));
484
+ }
485
+ }, _DB_TIMEOUT_MS);
443
486
  request.addEventListener('error', () => {
444
- reject(request.error);
487
+ if (!settled) {
488
+ settled = true;
489
+ clearTimeout(timer);
490
+ reject(request.error);
491
+ }
445
492
  });
446
493
  request.addEventListener('upgradeneeded', () => {
447
494
  const db = request.result;
@@ -449,11 +496,20 @@ function _openDatabase() {
449
496
  db.createObjectStore(DB_OBJECTSTORE_NAME, { keyPath: DB_DATA_KEYPATH });
450
497
  }
451
498
  catch (e) {
452
- reject(e);
499
+ if (!settled) {
500
+ settled = true;
501
+ clearTimeout(timer);
502
+ reject(e);
503
+ }
453
504
  }
454
505
  });
455
506
  request.addEventListener('success', async () => {
456
507
  const db = request.result;
508
+ if (settled) {
509
+ db.close();
510
+ return;
511
+ }
512
+ clearTimeout(timer);
457
513
  // Strange bug that occurs in Firefox when multiple tabs are opened at the
458
514
  // same time. The only way to recover seems to be deleting the database
459
515
  // and re-initializing it.
@@ -461,33 +517,45 @@ function _openDatabase() {
461
517
  if (!db.objectStoreNames.contains(DB_OBJECTSTORE_NAME)) {
462
518
  // Need to close the database or else you get a `blocked` event
463
519
  db.close();
464
- await _deleteDatabase();
465
- resolve(await _openDatabase());
520
+ try {
521
+ // Note: if `deleteDatabase` is `blocked` by another tab's open connection and
522
+ // times out (`DB_TIMEOUT_ERROR`), `request.transaction` is null so the browser
523
+ // keeps the delete request queued until all blocking connections close.
524
+ await _deleteDatabase();
525
+ const reopenedDb = await _openDatabase();
526
+ settled = true;
527
+ resolve(reopenedDb);
528
+ }
529
+ catch (e) {
530
+ if (!settled) {
531
+ settled = true;
532
+ reject(e);
533
+ }
534
+ }
466
535
  }
467
536
  else {
537
+ settled = true;
468
538
  resolve(db);
469
539
  }
470
540
  });
471
541
  });
472
542
  }
473
- async function _putObject(db, key, value) {
543
+ async function _putObject(db, key, value, timeoutMs = _DB_TIMEOUT_MS) {
474
544
  const request = getObjectStore(db, true).put({
475
545
  [DB_DATA_KEYPATH]: key,
476
546
  value
477
547
  });
478
- return new DBPromise(request).toPromise();
548
+ return new DBPromise(request).toPromise(timeoutMs);
479
549
  }
480
550
  async function getObject(db, key) {
481
551
  const request = getObjectStore(db, false).get(key);
482
552
  const data = await new DBPromise(request).toPromise();
483
553
  return data === undefined ? null : data.value;
484
554
  }
485
- function _deleteObject(db, key) {
555
+ function _deleteObject(db, key, timeoutMs = _DB_TIMEOUT_MS) {
486
556
  const request = getObjectStore(db, true).delete(key);
487
- return new DBPromise(request).toPromise();
557
+ return new DBPromise(request).toPromise(timeoutMs);
488
558
  }
489
- const _POLLING_INTERVAL_MS$1 = 800;
490
- const _TRANSACTION_RETRY_COUNT = 3;
491
559
  class IndexedDBLocalPersistence {
492
560
  registerLifecycleListeners() {
493
561
  if (typeof window !== 'undefined' &&
@@ -514,6 +582,7 @@ class IndexedDBLocalPersistence {
514
582
  this.pollTimer = null;
515
583
  this.isClosing = false;
516
584
  this.pendingWrites = 0;
585
+ this._lastProbeTimedOut = false;
517
586
  this.receiver = null;
518
587
  this.sender = null;
519
588
  this.serviceWorkerReceiverAvailable = false;
@@ -542,32 +611,46 @@ class IndexedDBLocalPersistence {
542
611
  if (this.dbPromise) {
543
612
  return this.dbPromise;
544
613
  }
545
- this.dbPromise = _openDatabase();
546
- this.dbPromise.catch(() => {
547
- this.dbPromise = null;
614
+ const dbPromise = _openDatabase();
615
+ this.dbPromise = dbPromise;
616
+ dbPromise.catch(() => {
617
+ if (this.dbPromise === dbPromise) {
618
+ this.dbPromise = null;
619
+ }
548
620
  });
549
- return this.dbPromise;
621
+ return dbPromise;
550
622
  }
551
623
  async _withRetries(op) {
552
624
  let numAttempts = 0;
553
625
  while (true) {
626
+ let db;
627
+ let dbPromiseBeforeOp = null;
554
628
  try {
555
- const db = await this._openDb();
629
+ const openPromise = this._openDb();
630
+ dbPromiseBeforeOp = this.dbPromise;
631
+ db = await openPromise;
556
632
  return await op(db);
557
633
  }
558
634
  catch (e) {
559
- if (numAttempts++ > _TRANSACTION_RETRY_COUNT) {
560
- throw e;
635
+ if (db) {
636
+ db.close();
637
+ if (dbPromiseBeforeOp && this.dbPromise === dbPromiseBeforeOp) {
638
+ this.dbPromise = null;
639
+ }
561
640
  }
562
- if (this.dbPromise) {
563
- const dbPromise = this.dbPromise;
641
+ else if (this.dbPromise && this.dbPromise === dbPromiseBeforeOp) {
642
+ const currentDbPromise = this.dbPromise;
564
643
  this.dbPromise = null;
565
644
  try {
566
- const db = await dbPromise;
567
- db.close();
645
+ const openedDb = await currentDbPromise;
646
+ openedDb.close();
568
647
  }
569
648
  catch { }
570
649
  }
650
+ const isTimeout = e instanceof Error && e.message === DB_TIMEOUT_ERROR;
651
+ if (isTimeout || numAttempts++ > _TRANSACTION_RETRY_COUNT) {
652
+ throw e;
653
+ }
571
654
  // TODO: consider adding exponential backoff
572
655
  }
573
656
  }
@@ -647,17 +730,21 @@ class IndexedDBLocalPersistence {
647
730
  }
648
731
  }
649
732
  async _isAvailable() {
733
+ this._lastProbeTimedOut = false;
650
734
  try {
651
735
  if (!indexedDB) {
652
736
  return false;
653
737
  }
654
738
  await this._withRetries(async (db) => {
655
- await _putObject(db, STORAGE_AVAILABLE_KEY, '1');
656
- await _deleteObject(db, STORAGE_AVAILABLE_KEY);
739
+ await _putObject(db, STORAGE_AVAILABLE_KEY, '1', _DB_PROBE_TIMEOUT_MS);
740
+ await _deleteObject(db, STORAGE_AVAILABLE_KEY, _DB_PROBE_TIMEOUT_MS);
657
741
  });
658
742
  return true;
659
743
  }
660
- catch { }
744
+ catch (e) {
745
+ this._lastProbeTimedOut =
746
+ e instanceof Error && e.message === DB_TIMEOUT_ERROR;
747
+ }
661
748
  return false;
662
749
  }
663
750
  async _withPendingWrite(write) {
@@ -677,9 +764,19 @@ class IndexedDBLocalPersistence {
677
764
  });
678
765
  }
679
766
  async _get(key) {
680
- const obj = (await this._withRetries((db) => getObject(db, key)));
681
- this.localCache[key] = obj;
682
- return obj;
767
+ try {
768
+ const obj = (await this._withRetries((db) => getObject(db, key)));
769
+ this.localCache[key] = obj;
770
+ return obj;
771
+ }
772
+ catch (e) {
773
+ if (e instanceof Error &&
774
+ e.message === DB_TIMEOUT_ERROR &&
775
+ this.localCache[key] != null) {
776
+ return this.localCache[key];
777
+ }
778
+ throw e;
779
+ }
683
780
  }
684
781
  async _remove(key) {
685
782
  return this._withPendingWrite(async () => {
@@ -761,8 +858,10 @@ class IndexedDBLocalPersistence {
761
858
  }
762
859
  if (!this.listeners[key]) {
763
860
  this.listeners[key] = new Set();
764
- // Populate the cache to avoid spuriously triggering on first poll.
765
- void this._get(key).catch(() => { }); // This can happen in the background async and we can return immediately.
861
+ if (!(key in this.localCache)) {
862
+ // Populate the cache to avoid spuriously triggering on first poll.
863
+ void this._get(key).catch(() => { }); // This can happen in the background async and we can return immediately.
864
+ }
766
865
  }
767
866
  this.listeners[key].add(listener);
768
867
  }
@@ -2801,31 +2900,25 @@ class PersistenceUserManager {
2801
2900
  if (!persistenceHierarchy.length) {
2802
2901
  return new PersistenceUserManager(_getInstance(inMemoryPersistence), auth, userKey);
2803
2902
  }
2804
- // Eliminate any persistences that are not available
2805
- const availablePersistences = (await Promise.all(persistenceHierarchy.map(async (persistence) => {
2903
+ const key = _persistenceKeyName(userKey, auth.config.apiKey, auth.name);
2904
+ // Search for an existing user across all persistences before running `_isAvailable()`.
2905
+ // `_get` only opens a `readonly` transaction in IndexedDB, whereas `_isAvailable()` opens
2906
+ // a `readwrite` transaction; if another tab is suspended holding a `readonly` transaction
2907
+ // (#10540), queuing a `readwrite` transaction first blocks subsequent `readonly` transactions
2908
+ // in the browser's IndexedDB lock manager.
2909
+ let foundUser = null;
2910
+ let foundPersistence = null;
2911
+ const unreadablePersistences = new Set();
2912
+ for (const persistence of persistenceHierarchy) {
2913
+ let blob = null;
2806
2914
  try {
2807
- if (await persistence._isAvailable()) {
2808
- return persistence;
2809
- }
2915
+ blob = await persistence._get(key);
2810
2916
  }
2811
2917
  catch {
2812
- return undefined;
2918
+ unreadablePersistences.add(persistence);
2919
+ continue;
2813
2920
  }
2814
- return undefined;
2815
- }))).filter(persistence => persistence);
2816
- // Fall back to the first persistence listed, or in memory if none available
2817
- let selectedPersistence = availablePersistences[0] ||
2818
- _getInstance(inMemoryPersistence);
2819
- const key = _persistenceKeyName(userKey, auth.config.apiKey, auth.name);
2820
- // Pull out the existing user, setting the chosen persistence to that
2821
- // persistence if the user exists.
2822
- let userToMigrate = null;
2823
- // Note, here we check for a user in _all_ persistences, not just the
2824
- // ones deemed available. If we can migrate a user out of a broken
2825
- // persistence, we will (but only if that persistence supports migration).
2826
- for (const persistence of persistenceHierarchy) {
2827
2921
  try {
2828
- const blob = await persistence._get(key);
2829
2922
  if (blob) {
2830
2923
  let user;
2831
2924
  if (typeof blob === 'string') {
@@ -2840,15 +2933,38 @@ class PersistenceUserManager {
2840
2933
  else {
2841
2934
  user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
2842
2935
  }
2843
- if (persistence !== selectedPersistence) {
2844
- userToMigrate = user;
2845
- }
2846
- selectedPersistence = persistence;
2936
+ foundUser = user;
2937
+ foundPersistence = persistence;
2847
2938
  break;
2848
2939
  }
2849
2940
  }
2850
2941
  catch { }
2851
2942
  }
2943
+ // Eliminate any persistences that are not available
2944
+ const availablePersistences = (await Promise.all(persistenceHierarchy.map(async (persistence) => {
2945
+ try {
2946
+ if (await persistence._isAvailable()) {
2947
+ return persistence;
2948
+ }
2949
+ if (persistence._lastProbeTimedOut) {
2950
+ unreadablePersistences.add(persistence);
2951
+ }
2952
+ }
2953
+ catch {
2954
+ return undefined;
2955
+ }
2956
+ return undefined;
2957
+ }))).filter(persistence => persistence);
2958
+ // Fall back to the first persistence listed, or in memory if none available
2959
+ let selectedPersistence = availablePersistences[0] ||
2960
+ _getInstance(inMemoryPersistence);
2961
+ let userToMigrate = null;
2962
+ if (foundPersistence && foundUser) {
2963
+ if (foundPersistence !== selectedPersistence) {
2964
+ userToMigrate = foundUser;
2965
+ }
2966
+ selectedPersistence = foundPersistence;
2967
+ }
2852
2968
  // If we find the user in a persistence that does support migration, use
2853
2969
  // that migration path (of only persistences that support migration)
2854
2970
  const migrationHierarchy = availablePersistences.filter(p => p._shouldAllowMigration);
@@ -2863,10 +2979,13 @@ class PersistenceUserManager {
2863
2979
  // we'll just let it bubble to surface the error.
2864
2980
  await selectedPersistence._set(key, userToMigrate.toJSON());
2865
2981
  }
2866
- // Attempt to clear the key in other persistences but ignore errors. This helps prevent issues
2867
- // such as users getting stuck with a previous account after signing out and refreshing the tab.
2982
+ // Attempt to clear the key in other persistences (except those whose _get threw or whose
2983
+ // _isAvailable() probe timed out, so we never delete from a store we couldn't read or that
2984
+ // is blocked by another tab) and ignore errors. This helps prevent issues such as users
2985
+ // getting stuck with a previous account after signing out and refreshing the tab.
2868
2986
  await Promise.all(persistenceHierarchy.map(async (persistence) => {
2869
- if (persistence !== selectedPersistence) {
2987
+ if (persistence !== selectedPersistence &&
2988
+ !unreadablePersistences.has(persistence)) {
2870
2989
  try {
2871
2990
  await persistence._remove(key);
2872
2991
  }
@@ -3388,7 +3507,6 @@ class AuthImpl {
3388
3507
  }
3389
3508
  catch (e) {
3390
3509
  _logWarn(`Failed to initialize current user: ${e}`);
3391
- await this.directlySetCurrentUser(null).catch(() => { });
3392
3510
  }
3393
3511
  this.lastNotifiedUid = this.currentUser?.uid || null;
3394
3512
  if (this._deleted) {
@@ -8085,7 +8203,7 @@ function multiFactor(user) {
8085
8203
  }
8086
8204
 
8087
8205
  var name = "@firebase/auth";
8088
- var version = "1.13.9";
8206
+ var version = "1.13.10-20261111165442";
8089
8207
 
8090
8208
  /**
8091
8209
  * @license
@@ -9910,4 +10028,4 @@ function generateNoEvent() {
9910
10028
  }
9911
10029
 
9912
10030
  export { sendEmailVerification as $, ActionCodeOperation as A, fetchSignInMethodsForEmail as B, getAdditionalUserInfo as C, getIdToken as D, EmailAuthCredential as E, FacebookAuthProvider as F, GithubAuthProvider as G, getIdTokenResult as H, getMultiFactorResolver as I, getRedirectResult as J, inMemoryPersistence as K, initializeRecaptchaConfig as L, isSignInWithEmailLink as M, linkWithCredential as N, OAuthCredential as O, PhoneAuthCredential as P, multiFactor as Q, onAuthStateChanged as R, SAMLAuthProvider as S, TwitterAuthProvider as T, onIdTokenChanged as U, parseActionCodeURL as V, prodErrorMap as W, reauthenticateWithCredential as X, reload as Y, revokeAccessToken as Z, _linkWithRedirect as _, _reauthenticateWithRedirect as a, debugFail as a$, sendPasswordResetEmail as a0, sendSignInLinkToEmail as a1, setPersistence as a2, signInAnonymously as a3, signInWithCredential as a4, signInWithCustomToken as a5, signInWithEmailAndPassword as a6, signInWithEmailLink as a7, signOut as a8, unlink as a9, _initializeRecaptchaConfig as aA, FAKE_TOKEN as aB, startEnrollPhoneMfa as aC, handleRecaptchaFlow as aD, sendPhoneVerificationCode as aE, _assertInstanceOf as aF, _withDefaultResolver as aG, AbstractPopupRedirectOperation as aH, debugAssert as aI, _generateEventId as aJ, FederatedAuthProvider as aK, _getProjectConfig as aL, _fail as aM, _getCurrentUrl as aN, _gapiScriptUrl as aO, _emulatorUrl as aP, _isChromeIOS as aQ, _isFirefox as aR, _isIOSStandalone as aS, _getRedirectResult as aT, _overrideRedirectResult as aU, _getRedirectUrl as aV, _setWindowLocation as aW, AuthEventManager as aX, _isMobileBrowser as aY, _isSafari as aZ, _isIOS as a_, updateCurrentUser as aa, updateEmail as ab, updatePassword as ac, updateProfile as ad, useDeviceLanguage as ae, validatePassword as af, verifyBeforeUpdateEmail as ag, verifyPasswordResetCode as ah, _performApiRequest as ai, _addTidIfNecessary as aj, Delay as ak, MockReCaptcha as al, _window as am, _assert as an, isV2 as ao, _createError as ap, _recaptchaV2ScriptUrl as aq, _loadJS as ar, _generateCallbackName as as, _castAuth as at, _isHttpOrHttps as au, _isWorker as av, getRecaptchaParams as aw, _assertLinkedStatus as ax, _serverAppCurrentUserOperationNotSupportedError as ay, _link$1 as az, _signInWithRedirect as b, finalizeEnrollPhoneMfa as b0, startEnrollTotpMfa as b1, finalizeEnrollTotpMfa as b2, _setExternalJSProvider as b3, AuthImpl as b4, FetchProvider as b5, SAMLAuthCredential as b6, UserImpl as b7, _getClientVersion as b8, _getInstance as b9, _persistenceKeyName as ba, linkWithRedirect as bb, reauthenticateWithRedirect as bc, signInWithRedirect as bd, cordovaPopupRedirectResolver as c, indexedDBLocalPersistence as d, ActionCodeURL as e, AuthCredential as f, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as g, EmailAuthProvider as h, initializeAuth as i, FactorId as j, GoogleAuthProvider as k, OAuthProvider as l, OperationType as m, ProviderId as n, SignInMethod as o, applyActionCode as p, beforeAuthStateChanged as q, registerAuth as r, browserLocalPersistence as s, browserSessionPersistence as t, checkActionCode as u, confirmPasswordReset as v, connectAuthEmulator as w, createUserWithEmailAndPassword as x, debugErrorMap as y, deleteUser as z };
9913
- //# sourceMappingURL=popup_redirect-xyFFcAgj.js.map
10031
+ //# sourceMappingURL=popup_redirect-BfyV9XtN.js.map