@firebase/auth 1.13.3 → 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 (48) hide show
  1. package/dist/browser-cjs/{index-80e3689c.js → index-TiyvRZm6.js} +119 -26
  2. package/dist/browser-cjs/{index-80e3689c.js.map → 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/browser-cjs/internal.js.map +1 -1
  6. package/dist/cordova/index.js +9 -3
  7. package/dist/cordova/index.js.map +1 -1
  8. package/dist/cordova/internal.js +3 -3
  9. package/dist/cordova/internal.js.map +1 -1
  10. package/dist/cordova/{popup_redirect-167cbb8f.js → popup_redirect-Be0Melsy.js} +148 -55
  11. package/dist/cordova/popup_redirect-Be0Melsy.js.map +1 -0
  12. package/dist/esm/{index-d90d2ee5.js → index-DqtyKhzu.js} +120 -27
  13. package/dist/esm/{index-d90d2ee5.js.map → index-DqtyKhzu.js.map} +1 -1
  14. package/dist/esm/index.js +1 -1
  15. package/dist/esm/internal.js +3 -3
  16. package/dist/esm/internal.js.map +1 -1
  17. package/dist/index.webworker.js +124 -70
  18. package/dist/index.webworker.js.map +1 -1
  19. package/dist/node/index.js +1 -1
  20. package/dist/node/internal.js +1 -1
  21. package/dist/node/internal.js.map +1 -1
  22. package/dist/node/{totp-9e84e53d.js → totp-D8cjDKiH.js} +30 -47
  23. package/dist/node/{totp-9e84e53d.js.map → totp-D8cjDKiH.js.map} +1 -1
  24. package/dist/node-esm/index.js +1 -1
  25. package/dist/node-esm/internal.js +3 -3
  26. package/dist/node-esm/internal.js.map +1 -1
  27. package/dist/node-esm/{totp-65577477.js → totp-BkwAJFrn.js} +31 -48
  28. package/dist/node-esm/{totp-65577477.js.map → totp-BkwAJFrn.js.map} +1 -1
  29. package/dist/rn/{index-7d302f10.js → index-BzcHGbdh.js} +24 -2
  30. package/dist/rn/{index-7d302f10.js.map → index-BzcHGbdh.js.map} +1 -1
  31. package/dist/rn/index.js +7 -1
  32. package/dist/rn/index.js.map +1 -1
  33. package/dist/rn/internal.js +96 -25
  34. package/dist/rn/internal.js.map +1 -1
  35. package/dist/web-extension-cjs/index.js +2 -1
  36. package/dist/web-extension-cjs/index.js.map +1 -1
  37. package/dist/web-extension-cjs/internal.js +1 -1
  38. package/dist/web-extension-cjs/internal.js.map +1 -1
  39. package/dist/web-extension-cjs/{register-1fdfc769.js → register-Bk5zU3vt.js} +119 -26
  40. package/dist/{web-extension-esm/register-293ebff1.js.map → web-extension-cjs/register-Bk5zU3vt.js.map} +1 -1
  41. package/dist/web-extension-esm/index.js +4 -3
  42. package/dist/web-extension-esm/index.js.map +1 -1
  43. package/dist/web-extension-esm/internal.js +3 -3
  44. package/dist/web-extension-esm/internal.js.map +1 -1
  45. package/dist/web-extension-esm/{register-293ebff1.js → register-CGKCII54.js} +120 -27
  46. package/dist/{web-extension-cjs/register-1fdfc769.js.map → web-extension-esm/register-CGKCII54.js.map} +1 -1
  47. package/package.json +13 -12
  48. package/dist/cordova/popup_redirect-167cbb8f.js.map +0 -1
@@ -1577,6 +1577,7 @@ function extractProviderData(providers) {
1577
1577
  * See the License for the specific language governing permissions and
1578
1578
  * limitations under the License.
1579
1579
  */
1580
+ /* eslint-disable camelcase */
1580
1581
  async function requestStsToken(auth, refreshToken) {
1581
1582
  const response = await _performFetchWithErrorHandling(auth, {}, async () => {
1582
1583
  const body = util.querystring({
@@ -3429,6 +3430,22 @@ function generateRandomAlphaNumericString(len) {
3429
3430
  }
3430
3431
 
3431
3432
  /* eslint-disable @typescript-eslint/no-require-imports */
3433
+ /**
3434
+ * @license
3435
+ * Copyright 2022 Google LLC
3436
+ *
3437
+ * Licensed under the Apache License, Version 2.0 (the "License");
3438
+ * you may not use this file except in compliance with the License.
3439
+ * You may obtain a copy of the License at
3440
+ *
3441
+ * http://www.apache.org/licenses/LICENSE-2.0
3442
+ *
3443
+ * Unless required by applicable law or agreed to in writing, software
3444
+ * distributed under the License is distributed on an "AS IS" BASIS,
3445
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3446
+ * See the License for the specific language governing permissions and
3447
+ * limitations under the License.
3448
+ */
3432
3449
  const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
3433
3450
  const FAKE_TOKEN = 'NO_RECAPTCHA';
3434
3451
  const RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME = 'onFirebaseAuthREInstanceReady';
@@ -5292,6 +5309,11 @@ GithubAuthProvider.PROVIDER_ID = "github.com" /* ProviderId.GITHUB */;
5292
5309
  * See the License for the specific language governing permissions and
5293
5310
  * limitations under the License.
5294
5311
  */
5312
+ /**
5313
+ * Represents the SAML credentials returned by an {@link SAMLAuthProvider}.
5314
+ *
5315
+ * @public
5316
+ */
5295
5317
  const IDP_REQUEST_URI = 'http://localhost';
5296
5318
  /**
5297
5319
  * @public
@@ -8225,6 +8247,28 @@ function _deleteObject(db, key) {
8225
8247
  const _POLLING_INTERVAL_MS = 800;
8226
8248
  const _TRANSACTION_RETRY_COUNT = 3;
8227
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
+ }
8228
8272
  constructor() {
8229
8273
  this.type = "LOCAL" /* PersistenceType.LOCAL */;
8230
8274
  this.dbPromise = null;
@@ -8234,16 +8278,46 @@ class IndexedDBLocalPersistence {
8234
8278
  // setTimeout return value is platform specific
8235
8279
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8236
8280
  this.pollTimer = null;
8281
+ this.isHiding = false;
8237
8282
  this.pendingWrites = 0;
8238
8283
  this.receiver = null;
8239
8284
  this.sender = null;
8240
8285
  this.serviceWorkerReceiverAvailable = false;
8241
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
+ };
8242
8313
  // Fire & forget the service worker registration as it may never resolve
8243
8314
  this._workerInitializationPromise =
8244
8315
  this.initializeServiceWorkerMessaging().then(() => { }, () => { });
8245
8316
  }
8246
8317
  async _openDb() {
8318
+ if (this.isHiding) {
8319
+ throw new Error('Database is closing/hidden');
8320
+ }
8247
8321
  if (this.dbPromise) {
8248
8322
  return this.dbPromise;
8249
8323
  }
@@ -8261,6 +8335,9 @@ class IndexedDBLocalPersistence {
8261
8335
  return await op(db);
8262
8336
  }
8263
8337
  catch (e) {
8338
+ if (this.isHiding) {
8339
+ throw e;
8340
+ }
8264
8341
  if (numAttempts++ > _TRANSACTION_RETRY_COUNT) {
8265
8342
  throw e;
8266
8343
  }
@@ -8390,37 +8467,51 @@ class IndexedDBLocalPersistence {
8390
8467
  });
8391
8468
  }
8392
8469
  async _poll() {
8393
- // TODO: check if we need to fallback if getAll is not supported
8394
- const result = await this._withRetries((db) => {
8395
- const getAllRequest = getObjectStore(db, false).getAll();
8396
- return new DBPromise(getAllRequest).toPromise();
8397
- });
8398
- if (!result) {
8399
- return [];
8400
- }
8401
- // If we have pending writes in progress abort, we'll get picked up on the next poll
8402
- if (this.pendingWrites !== 0) {
8470
+ if (this.isHiding) {
8403
8471
  return [];
8404
8472
  }
8405
- const keys = [];
8406
- const keysInResult = new Set();
8407
- if (result.length !== 0) {
8408
- for (const { fbase_key: key, value } of result) {
8409
- keysInResult.add(key);
8410
- if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
8411
- this.notifyListeners(key, value);
8412
- 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
+ }
8498
+ }
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);
8413
8505
  }
8414
8506
  }
8507
+ return keys;
8415
8508
  }
8416
- for (const localKey of Object.keys(this.localCache)) {
8417
- if (this.localCache[localKey] && !keysInResult.has(localKey)) {
8418
- // Deleted
8419
- this.notifyListeners(localKey, null);
8420
- keys.push(localKey);
8509
+ catch (e) {
8510
+ if (!this.isHiding) {
8511
+ _logWarn(`Firebase Auth cross-tab polling failed with error: ${e}`);
8421
8512
  }
8513
+ return [];
8422
8514
  }
8423
- return keys;
8424
8515
  }
8425
8516
  notifyListeners(key, newValue) {
8426
8517
  this.localCache[key] = newValue;
@@ -8444,6 +8535,7 @@ class IndexedDBLocalPersistence {
8444
8535
  _addListener(key, listener) {
8445
8536
  if (Object.keys(this.listeners).length === 0) {
8446
8537
  this.startPolling();
8538
+ this.registerLifecycleListeners();
8447
8539
  }
8448
8540
  if (!this.listeners[key]) {
8449
8541
  this.listeners[key] = new Set();
@@ -8461,6 +8553,7 @@ class IndexedDBLocalPersistence {
8461
8553
  }
8462
8554
  if (Object.keys(this.listeners).length === 0) {
8463
8555
  this.stopPolling();
8556
+ this.unregisterLifecycleListeners();
8464
8557
  }
8465
8558
  }
8466
8559
  }
@@ -10941,7 +11034,7 @@ function _isEmptyString(input) {
10941
11034
  }
10942
11035
 
10943
11036
  var name = "@firebase/auth";
10944
- var version = "1.13.3";
11037
+ var version = "1.13.4-20260728185501";
10945
11038
 
10946
11039
  /**
10947
11040
  * @license
@@ -11301,4 +11394,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
11301
11394
  exports.validatePassword = validatePassword;
11302
11395
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
11303
11396
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
11304
- //# sourceMappingURL=index-80e3689c.js.map
11397
+ //# sourceMappingURL=index-TiyvRZm6.js.map