@firebase/auth 1.13.3-eap-crashlytics.659b578fb → 1.13.4-20260728185501

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 (37) hide show
  1. package/dist/browser-cjs/{index-DLAcLH17.js → index-TiyvRZm6.js} +97 -26
  2. package/dist/{esm/index-DIozsb1n.js.map → browser-cjs/index-TiyvRZm6.js.map} +1 -1
  3. package/dist/browser-cjs/index.js +1 -1
  4. package/dist/browser-cjs/internal.js +1 -1
  5. package/dist/cordova/index.js +2 -2
  6. package/dist/cordova/internal.js +2 -2
  7. package/dist/cordova/{popup_redirect-DU-rQFxl.js → popup_redirect-Be0Melsy.js} +125 -54
  8. package/dist/cordova/popup_redirect-Be0Melsy.js.map +1 -0
  9. package/dist/esm/{index-DIozsb1n.js → index-DqtyKhzu.js} +97 -26
  10. package/dist/{browser-cjs/index-DLAcLH17.js.map → esm/index-DqtyKhzu.js.map} +1 -1
  11. package/dist/esm/index.js +1 -1
  12. package/dist/esm/internal.js +2 -2
  13. package/dist/index.webworker.js +96 -25
  14. package/dist/index.webworker.js.map +1 -1
  15. package/dist/node/index.js +1 -1
  16. package/dist/node/internal.js +1 -1
  17. package/dist/node/{totp-BwsckFdy.js → totp-D8cjDKiH.js} +2 -2
  18. package/dist/node/{totp-BwsckFdy.js.map → totp-D8cjDKiH.js.map} +1 -1
  19. package/dist/node-esm/index.js +1 -1
  20. package/dist/node-esm/internal.js +2 -2
  21. package/dist/node-esm/{totp-BqsE7qvo.js → totp-BkwAJFrn.js} +2 -2
  22. package/dist/node-esm/{totp-BqsE7qvo.js.map → totp-BkwAJFrn.js.map} +1 -1
  23. package/dist/rn/{index-96z01bxX.js → index-BzcHGbdh.js} +2 -2
  24. package/dist/rn/{index-96z01bxX.js.map → index-BzcHGbdh.js.map} +1 -1
  25. package/dist/rn/index.js +1 -1
  26. package/dist/rn/internal.js +96 -25
  27. package/dist/rn/internal.js.map +1 -1
  28. package/dist/web-extension-cjs/index.js +1 -1
  29. package/dist/web-extension-cjs/internal.js +1 -1
  30. package/dist/web-extension-cjs/{register-B1PXHVFP.js → register-Bk5zU3vt.js} +97 -26
  31. package/dist/{web-extension-esm/register-B7zfGmPU.js.map → web-extension-cjs/register-Bk5zU3vt.js.map} +1 -1
  32. package/dist/web-extension-esm/index.js +2 -2
  33. package/dist/web-extension-esm/internal.js +2 -2
  34. package/dist/web-extension-esm/{register-B7zfGmPU.js → register-CGKCII54.js} +97 -26
  35. package/dist/{web-extension-cjs/register-B1PXHVFP.js.map → web-extension-esm/register-CGKCII54.js.map} +1 -1
  36. package/package.json +6 -6
  37. package/dist/cordova/popup_redirect-DU-rQFxl.js.map +0 -1
@@ -8247,6 +8247,28 @@ function _deleteObject(db, key) {
8247
8247
  const _POLLING_INTERVAL_MS = 800;
8248
8248
  const _TRANSACTION_RETRY_COUNT = 3;
8249
8249
  class IndexedDBLocalPersistence {
8250
+ registerLifecycleListeners() {
8251
+ if (typeof window !== 'undefined' &&
8252
+ typeof window.addEventListener === 'function') {
8253
+ window.addEventListener('pagehide', this.onPageHide);
8254
+ window.addEventListener('pageshow', this.onPageShow);
8255
+ }
8256
+ if (typeof document !== 'undefined' &&
8257
+ typeof document.addEventListener === 'function') {
8258
+ document.addEventListener('visibilitychange', this.onVisibilityChange);
8259
+ }
8260
+ }
8261
+ unregisterLifecycleListeners() {
8262
+ if (typeof window !== 'undefined' &&
8263
+ typeof window.removeEventListener === 'function') {
8264
+ window.removeEventListener('pagehide', this.onPageHide);
8265
+ window.removeEventListener('pageshow', this.onPageShow);
8266
+ }
8267
+ if (typeof document !== 'undefined' &&
8268
+ typeof document.removeEventListener === 'function') {
8269
+ document.removeEventListener('visibilitychange', this.onVisibilityChange);
8270
+ }
8271
+ }
8250
8272
  constructor() {
8251
8273
  this.type = "LOCAL" /* PersistenceType.LOCAL */;
8252
8274
  this.dbPromise = null;
@@ -8256,16 +8278,46 @@ class IndexedDBLocalPersistence {
8256
8278
  // setTimeout return value is platform specific
8257
8279
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8258
8280
  this.pollTimer = null;
8281
+ this.isHiding = false;
8259
8282
  this.pendingWrites = 0;
8260
8283
  this.receiver = null;
8261
8284
  this.sender = null;
8262
8285
  this.serviceWorkerReceiverAvailable = false;
8263
8286
  this.activeServiceWorker = null;
8287
+ this.onPageHide = () => {
8288
+ this.isHiding = true;
8289
+ this.stopPolling();
8290
+ if (this.dbPromise) {
8291
+ this.dbPromise.then(db => db.close()).catch(() => { });
8292
+ this.dbPromise = null;
8293
+ }
8294
+ };
8295
+ this.onPageShow = () => {
8296
+ if (this.isHiding) {
8297
+ this.isHiding = false;
8298
+ if (Object.keys(this.listeners).length > 0) {
8299
+ this.startPolling();
8300
+ }
8301
+ }
8302
+ };
8303
+ this.onVisibilityChange = () => {
8304
+ if (typeof document !== 'undefined') {
8305
+ if (document.visibilityState === 'hidden') {
8306
+ this.onPageHide();
8307
+ }
8308
+ else if (document.visibilityState === 'visible') {
8309
+ this.onPageShow();
8310
+ }
8311
+ }
8312
+ };
8264
8313
  // Fire & forget the service worker registration as it may never resolve
8265
8314
  this._workerInitializationPromise =
8266
8315
  this.initializeServiceWorkerMessaging().then(() => { }, () => { });
8267
8316
  }
8268
8317
  async _openDb() {
8318
+ if (this.isHiding) {
8319
+ throw new Error('Database is closing/hidden');
8320
+ }
8269
8321
  if (this.dbPromise) {
8270
8322
  return this.dbPromise;
8271
8323
  }
@@ -8283,6 +8335,9 @@ class IndexedDBLocalPersistence {
8283
8335
  return await op(db);
8284
8336
  }
8285
8337
  catch (e) {
8338
+ if (this.isHiding) {
8339
+ throw e;
8340
+ }
8286
8341
  if (numAttempts++ > _TRANSACTION_RETRY_COUNT) {
8287
8342
  throw e;
8288
8343
  }
@@ -8412,37 +8467,51 @@ class IndexedDBLocalPersistence {
8412
8467
  });
8413
8468
  }
8414
8469
  async _poll() {
8415
- // TODO: check if we need to fallback if getAll is not supported
8416
- const result = await this._withRetries((db) => {
8417
- const getAllRequest = getObjectStore(db, false).getAll();
8418
- return new DBPromise(getAllRequest).toPromise();
8419
- });
8420
- if (!result) {
8470
+ if (this.isHiding) {
8421
8471
  return [];
8422
8472
  }
8423
- // If we have pending writes in progress abort, we'll get picked up on the next poll
8424
- if (this.pendingWrites !== 0) {
8425
- return [];
8426
- }
8427
- const keys = [];
8428
- const keysInResult = new Set();
8429
- if (result.length !== 0) {
8430
- for (const { fbase_key: key, value } of result) {
8431
- keysInResult.add(key);
8432
- if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
8433
- this.notifyListeners(key, value);
8434
- keys.push(key);
8473
+ try {
8474
+ // TODO: check if we need to fallback if getAll is not supported
8475
+ const result = await this._withRetries((db) => {
8476
+ const getAllRequest = getObjectStore(db, false).getAll();
8477
+ return new DBPromise(getAllRequest).toPromise();
8478
+ });
8479
+ if (this.isHiding) {
8480
+ return [];
8481
+ }
8482
+ if (!result) {
8483
+ return [];
8484
+ }
8485
+ // If we have pending writes in progress abort, we'll get picked up on the next poll
8486
+ if (this.pendingWrites !== 0) {
8487
+ return [];
8488
+ }
8489
+ const keys = [];
8490
+ const keysInResult = new Set();
8491
+ if (result.length !== 0) {
8492
+ for (const { fbase_key: key, value } of result) {
8493
+ keysInResult.add(key);
8494
+ if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
8495
+ this.notifyListeners(key, value);
8496
+ keys.push(key);
8497
+ }
8435
8498
  }
8436
8499
  }
8500
+ for (const localKey of Object.keys(this.localCache)) {
8501
+ if (this.localCache[localKey] && !keysInResult.has(localKey)) {
8502
+ // Deleted
8503
+ this.notifyListeners(localKey, null);
8504
+ keys.push(localKey);
8505
+ }
8506
+ }
8507
+ return keys;
8437
8508
  }
8438
- for (const localKey of Object.keys(this.localCache)) {
8439
- if (this.localCache[localKey] && !keysInResult.has(localKey)) {
8440
- // Deleted
8441
- this.notifyListeners(localKey, null);
8442
- keys.push(localKey);
8509
+ catch (e) {
8510
+ if (!this.isHiding) {
8511
+ _logWarn(`Firebase Auth cross-tab polling failed with error: ${e}`);
8443
8512
  }
8513
+ return [];
8444
8514
  }
8445
- return keys;
8446
8515
  }
8447
8516
  notifyListeners(key, newValue) {
8448
8517
  this.localCache[key] = newValue;
@@ -8466,6 +8535,7 @@ class IndexedDBLocalPersistence {
8466
8535
  _addListener(key, listener) {
8467
8536
  if (Object.keys(this.listeners).length === 0) {
8468
8537
  this.startPolling();
8538
+ this.registerLifecycleListeners();
8469
8539
  }
8470
8540
  if (!this.listeners[key]) {
8471
8541
  this.listeners[key] = new Set();
@@ -8483,6 +8553,7 @@ class IndexedDBLocalPersistence {
8483
8553
  }
8484
8554
  if (Object.keys(this.listeners).length === 0) {
8485
8555
  this.stopPolling();
8556
+ this.unregisterLifecycleListeners();
8486
8557
  }
8487
8558
  }
8488
8559
  }
@@ -10963,7 +11034,7 @@ function _isEmptyString(input) {
10963
11034
  }
10964
11035
 
10965
11036
  var name = "@firebase/auth";
10966
- var version = "1.13.3-eap-crashlytics.659b578fb";
11037
+ var version = "1.13.4-20260728185501";
10967
11038
 
10968
11039
  /**
10969
11040
  * @license
@@ -11323,4 +11394,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
11323
11394
  exports.validatePassword = validatePassword;
11324
11395
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
11325
11396
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
11326
- //# sourceMappingURL=index-DLAcLH17.js.map
11397
+ //# sourceMappingURL=index-TiyvRZm6.js.map