@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
@@ -1478,6 +1478,7 @@ function extractProviderData(providers) {
1478
1478
  * See the License for the specific language governing permissions and
1479
1479
  * limitations under the License.
1480
1480
  */
1481
+ /* eslint-disable camelcase */
1481
1482
  async function requestStsToken(auth, refreshToken) {
1482
1483
  const response = await _performFetchWithErrorHandling(auth, {}, async () => {
1483
1484
  const body = util.querystring({
@@ -3330,6 +3331,22 @@ function generateRandomAlphaNumericString(len) {
3330
3331
  }
3331
3332
 
3332
3333
  /* eslint-disable @typescript-eslint/no-require-imports */
3334
+ /**
3335
+ * @license
3336
+ * Copyright 2022 Google LLC
3337
+ *
3338
+ * Licensed under the Apache License, Version 2.0 (the "License");
3339
+ * you may not use this file except in compliance with the License.
3340
+ * You may obtain a copy of the License at
3341
+ *
3342
+ * http://www.apache.org/licenses/LICENSE-2.0
3343
+ *
3344
+ * Unless required by applicable law or agreed to in writing, software
3345
+ * distributed under the License is distributed on an "AS IS" BASIS,
3346
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3347
+ * See the License for the specific language governing permissions and
3348
+ * limitations under the License.
3349
+ */
3333
3350
  const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
3334
3351
  const FAKE_TOKEN = 'NO_RECAPTCHA';
3335
3352
  const RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME = 'onFirebaseAuthREInstanceReady';
@@ -5193,6 +5210,11 @@ GithubAuthProvider.PROVIDER_ID = "github.com" /* ProviderId.GITHUB */;
5193
5210
  * See the License for the specific language governing permissions and
5194
5211
  * limitations under the License.
5195
5212
  */
5213
+ /**
5214
+ * Represents the SAML credentials returned by an {@link SAMLAuthProvider}.
5215
+ *
5216
+ * @public
5217
+ */
5196
5218
  const IDP_REQUEST_URI = 'http://localhost';
5197
5219
  /**
5198
5220
  * @public
@@ -7710,6 +7732,28 @@ function _deleteObject(db, key) {
7710
7732
  const _POLLING_INTERVAL_MS = 800;
7711
7733
  const _TRANSACTION_RETRY_COUNT = 3;
7712
7734
  class IndexedDBLocalPersistence {
7735
+ registerLifecycleListeners() {
7736
+ if (typeof window !== 'undefined' &&
7737
+ typeof window.addEventListener === 'function') {
7738
+ window.addEventListener('pagehide', this.onPageHide);
7739
+ window.addEventListener('pageshow', this.onPageShow);
7740
+ }
7741
+ if (typeof document !== 'undefined' &&
7742
+ typeof document.addEventListener === 'function') {
7743
+ document.addEventListener('visibilitychange', this.onVisibilityChange);
7744
+ }
7745
+ }
7746
+ unregisterLifecycleListeners() {
7747
+ if (typeof window !== 'undefined' &&
7748
+ typeof window.removeEventListener === 'function') {
7749
+ window.removeEventListener('pagehide', this.onPageHide);
7750
+ window.removeEventListener('pageshow', this.onPageShow);
7751
+ }
7752
+ if (typeof document !== 'undefined' &&
7753
+ typeof document.removeEventListener === 'function') {
7754
+ document.removeEventListener('visibilitychange', this.onVisibilityChange);
7755
+ }
7756
+ }
7713
7757
  constructor() {
7714
7758
  this.type = "LOCAL" /* PersistenceType.LOCAL */;
7715
7759
  this.dbPromise = null;
@@ -7719,16 +7763,46 @@ class IndexedDBLocalPersistence {
7719
7763
  // setTimeout return value is platform specific
7720
7764
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7721
7765
  this.pollTimer = null;
7766
+ this.isHiding = false;
7722
7767
  this.pendingWrites = 0;
7723
7768
  this.receiver = null;
7724
7769
  this.sender = null;
7725
7770
  this.serviceWorkerReceiverAvailable = false;
7726
7771
  this.activeServiceWorker = null;
7772
+ this.onPageHide = () => {
7773
+ this.isHiding = true;
7774
+ this.stopPolling();
7775
+ if (this.dbPromise) {
7776
+ this.dbPromise.then(db => db.close()).catch(() => { });
7777
+ this.dbPromise = null;
7778
+ }
7779
+ };
7780
+ this.onPageShow = () => {
7781
+ if (this.isHiding) {
7782
+ this.isHiding = false;
7783
+ if (Object.keys(this.listeners).length > 0) {
7784
+ this.startPolling();
7785
+ }
7786
+ }
7787
+ };
7788
+ this.onVisibilityChange = () => {
7789
+ if (typeof document !== 'undefined') {
7790
+ if (document.visibilityState === 'hidden') {
7791
+ this.onPageHide();
7792
+ }
7793
+ else if (document.visibilityState === 'visible') {
7794
+ this.onPageShow();
7795
+ }
7796
+ }
7797
+ };
7727
7798
  // Fire & forget the service worker registration as it may never resolve
7728
7799
  this._workerInitializationPromise =
7729
7800
  this.initializeServiceWorkerMessaging().then(() => { }, () => { });
7730
7801
  }
7731
7802
  async _openDb() {
7803
+ if (this.isHiding) {
7804
+ throw new Error('Database is closing/hidden');
7805
+ }
7732
7806
  if (this.dbPromise) {
7733
7807
  return this.dbPromise;
7734
7808
  }
@@ -7746,6 +7820,9 @@ class IndexedDBLocalPersistence {
7746
7820
  return await op(db);
7747
7821
  }
7748
7822
  catch (e) {
7823
+ if (this.isHiding) {
7824
+ throw e;
7825
+ }
7749
7826
  if (numAttempts++ > _TRANSACTION_RETRY_COUNT) {
7750
7827
  throw e;
7751
7828
  }
@@ -7875,37 +7952,51 @@ class IndexedDBLocalPersistence {
7875
7952
  });
7876
7953
  }
7877
7954
  async _poll() {
7878
- // TODO: check if we need to fallback if getAll is not supported
7879
- const result = await this._withRetries((db) => {
7880
- const getAllRequest = getObjectStore(db, false).getAll();
7881
- return new DBPromise(getAllRequest).toPromise();
7882
- });
7883
- if (!result) {
7884
- return [];
7885
- }
7886
- // If we have pending writes in progress abort, we'll get picked up on the next poll
7887
- if (this.pendingWrites !== 0) {
7955
+ if (this.isHiding) {
7888
7956
  return [];
7889
7957
  }
7890
- const keys = [];
7891
- const keysInResult = new Set();
7892
- if (result.length !== 0) {
7893
- for (const { fbase_key: key, value } of result) {
7894
- keysInResult.add(key);
7895
- if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
7896
- this.notifyListeners(key, value);
7897
- keys.push(key);
7958
+ try {
7959
+ // TODO: check if we need to fallback if getAll is not supported
7960
+ const result = await this._withRetries((db) => {
7961
+ const getAllRequest = getObjectStore(db, false).getAll();
7962
+ return new DBPromise(getAllRequest).toPromise();
7963
+ });
7964
+ if (this.isHiding) {
7965
+ return [];
7966
+ }
7967
+ if (!result) {
7968
+ return [];
7969
+ }
7970
+ // If we have pending writes in progress abort, we'll get picked up on the next poll
7971
+ if (this.pendingWrites !== 0) {
7972
+ return [];
7973
+ }
7974
+ const keys = [];
7975
+ const keysInResult = new Set();
7976
+ if (result.length !== 0) {
7977
+ for (const { fbase_key: key, value } of result) {
7978
+ keysInResult.add(key);
7979
+ if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
7980
+ this.notifyListeners(key, value);
7981
+ keys.push(key);
7982
+ }
7983
+ }
7984
+ }
7985
+ for (const localKey of Object.keys(this.localCache)) {
7986
+ if (this.localCache[localKey] && !keysInResult.has(localKey)) {
7987
+ // Deleted
7988
+ this.notifyListeners(localKey, null);
7989
+ keys.push(localKey);
7898
7990
  }
7899
7991
  }
7992
+ return keys;
7900
7993
  }
7901
- for (const localKey of Object.keys(this.localCache)) {
7902
- if (this.localCache[localKey] && !keysInResult.has(localKey)) {
7903
- // Deleted
7904
- this.notifyListeners(localKey, null);
7905
- keys.push(localKey);
7994
+ catch (e) {
7995
+ if (!this.isHiding) {
7996
+ _logWarn(`Firebase Auth cross-tab polling failed with error: ${e}`);
7906
7997
  }
7998
+ return [];
7907
7999
  }
7908
- return keys;
7909
8000
  }
7910
8001
  notifyListeners(key, newValue) {
7911
8002
  this.localCache[key] = newValue;
@@ -7929,6 +8020,7 @@ class IndexedDBLocalPersistence {
7929
8020
  _addListener(key, listener) {
7930
8021
  if (Object.keys(this.listeners).length === 0) {
7931
8022
  this.startPolling();
8023
+ this.registerLifecycleListeners();
7932
8024
  }
7933
8025
  if (!this.listeners[key]) {
7934
8026
  this.listeners[key] = new Set();
@@ -7946,6 +8038,7 @@ class IndexedDBLocalPersistence {
7946
8038
  }
7947
8039
  if (Object.keys(this.listeners).length === 0) {
7948
8040
  this.stopPolling();
8041
+ this.unregisterLifecycleListeners();
7949
8042
  }
7950
8043
  }
7951
8044
  }
@@ -8147,7 +8240,7 @@ function _isEmptyString(input) {
8147
8240
  }
8148
8241
 
8149
8242
  var name = "@firebase/auth";
8150
- var version = "1.13.3";
8243
+ var version = "1.13.4-20260728185501";
8151
8244
 
8152
8245
  /**
8153
8246
  * @license
@@ -8411,4 +8504,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
8411
8504
  exports.validatePassword = validatePassword;
8412
8505
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
8413
8506
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
8414
- //# sourceMappingURL=register-1fdfc769.js.map
8507
+ //# sourceMappingURL=register-Bk5zU3vt.js.map