@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
@@ -359,6 +359,34 @@ function _getWorkerGlobalScope() {
359
359
  return _isWorker() ? self : null;
360
360
  }
361
361
 
362
+ /**
363
+ * @license
364
+ * Copyright 2020 Google LLC
365
+ *
366
+ * Licensed under the Apache License, Version 2.0 (the "License");
367
+ * you may not use this file except in compliance with the License.
368
+ * You may obtain a copy of the License at
369
+ *
370
+ * http://www.apache.org/licenses/LICENSE-2.0
371
+ *
372
+ * Unless required by applicable law or agreed to in writing, software
373
+ * distributed under the License is distributed on an "AS IS" BASIS,
374
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
375
+ * See the License for the specific language governing permissions and
376
+ * limitations under the License.
377
+ */
378
+ const logClient = new Logger('@firebase/auth');
379
+ function _logWarn(msg, ...args) {
380
+ if (logClient.logLevel <= LogLevel.WARN) {
381
+ logClient.warn(`Auth (${SDK_VERSION}): ${msg}`, ...args);
382
+ }
383
+ }
384
+ function _logError(msg, ...args) {
385
+ if (logClient.logLevel <= LogLevel.ERROR) {
386
+ logClient.error(`Auth (${SDK_VERSION}): ${msg}`, ...args);
387
+ }
388
+ }
389
+
362
390
  /**
363
391
  * @license
364
392
  * Copyright 2019 Google LLC
@@ -461,6 +489,28 @@ function _deleteObject(db, key) {
461
489
  const _POLLING_INTERVAL_MS$1 = 800;
462
490
  const _TRANSACTION_RETRY_COUNT = 3;
463
491
  class IndexedDBLocalPersistence {
492
+ registerLifecycleListeners() {
493
+ if (typeof window !== 'undefined' &&
494
+ typeof window.addEventListener === 'function') {
495
+ window.addEventListener('pagehide', this.onPageHide);
496
+ window.addEventListener('pageshow', this.onPageShow);
497
+ }
498
+ if (typeof document !== 'undefined' &&
499
+ typeof document.addEventListener === 'function') {
500
+ document.addEventListener('visibilitychange', this.onVisibilityChange);
501
+ }
502
+ }
503
+ unregisterLifecycleListeners() {
504
+ if (typeof window !== 'undefined' &&
505
+ typeof window.removeEventListener === 'function') {
506
+ window.removeEventListener('pagehide', this.onPageHide);
507
+ window.removeEventListener('pageshow', this.onPageShow);
508
+ }
509
+ if (typeof document !== 'undefined' &&
510
+ typeof document.removeEventListener === 'function') {
511
+ document.removeEventListener('visibilitychange', this.onVisibilityChange);
512
+ }
513
+ }
464
514
  constructor() {
465
515
  this.type = "LOCAL" /* PersistenceType.LOCAL */;
466
516
  this.dbPromise = null;
@@ -470,16 +520,46 @@ class IndexedDBLocalPersistence {
470
520
  // setTimeout return value is platform specific
471
521
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
472
522
  this.pollTimer = null;
523
+ this.isHiding = false;
473
524
  this.pendingWrites = 0;
474
525
  this.receiver = null;
475
526
  this.sender = null;
476
527
  this.serviceWorkerReceiverAvailable = false;
477
528
  this.activeServiceWorker = null;
529
+ this.onPageHide = () => {
530
+ this.isHiding = true;
531
+ this.stopPolling();
532
+ if (this.dbPromise) {
533
+ this.dbPromise.then(db => db.close()).catch(() => { });
534
+ this.dbPromise = null;
535
+ }
536
+ };
537
+ this.onPageShow = () => {
538
+ if (this.isHiding) {
539
+ this.isHiding = false;
540
+ if (Object.keys(this.listeners).length > 0) {
541
+ this.startPolling();
542
+ }
543
+ }
544
+ };
545
+ this.onVisibilityChange = () => {
546
+ if (typeof document !== 'undefined') {
547
+ if (document.visibilityState === 'hidden') {
548
+ this.onPageHide();
549
+ }
550
+ else if (document.visibilityState === 'visible') {
551
+ this.onPageShow();
552
+ }
553
+ }
554
+ };
478
555
  // Fire & forget the service worker registration as it may never resolve
479
556
  this._workerInitializationPromise =
480
557
  this.initializeServiceWorkerMessaging().then(() => { }, () => { });
481
558
  }
482
559
  async _openDb() {
560
+ if (this.isHiding) {
561
+ throw new Error('Database is closing/hidden');
562
+ }
483
563
  if (this.dbPromise) {
484
564
  return this.dbPromise;
485
565
  }
@@ -497,6 +577,9 @@ class IndexedDBLocalPersistence {
497
577
  return await op(db);
498
578
  }
499
579
  catch (e) {
580
+ if (this.isHiding) {
581
+ throw e;
582
+ }
500
583
  if (numAttempts++ > _TRANSACTION_RETRY_COUNT) {
501
584
  throw e;
502
585
  }
@@ -626,37 +709,51 @@ class IndexedDBLocalPersistence {
626
709
  });
627
710
  }
628
711
  async _poll() {
629
- // TODO: check if we need to fallback if getAll is not supported
630
- const result = await this._withRetries((db) => {
631
- const getAllRequest = getObjectStore(db, false).getAll();
632
- return new DBPromise(getAllRequest).toPromise();
633
- });
634
- if (!result) {
712
+ if (this.isHiding) {
635
713
  return [];
636
714
  }
637
- // If we have pending writes in progress abort, we'll get picked up on the next poll
638
- if (this.pendingWrites !== 0) {
639
- return [];
640
- }
641
- const keys = [];
642
- const keysInResult = new Set();
643
- if (result.length !== 0) {
644
- for (const { fbase_key: key, value } of result) {
645
- keysInResult.add(key);
646
- if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
647
- this.notifyListeners(key, value);
648
- keys.push(key);
715
+ try {
716
+ // TODO: check if we need to fallback if getAll is not supported
717
+ const result = await this._withRetries((db) => {
718
+ const getAllRequest = getObjectStore(db, false).getAll();
719
+ return new DBPromise(getAllRequest).toPromise();
720
+ });
721
+ if (this.isHiding) {
722
+ return [];
723
+ }
724
+ if (!result) {
725
+ return [];
726
+ }
727
+ // If we have pending writes in progress abort, we'll get picked up on the next poll
728
+ if (this.pendingWrites !== 0) {
729
+ return [];
730
+ }
731
+ const keys = [];
732
+ const keysInResult = new Set();
733
+ if (result.length !== 0) {
734
+ for (const { fbase_key: key, value } of result) {
735
+ keysInResult.add(key);
736
+ if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
737
+ this.notifyListeners(key, value);
738
+ keys.push(key);
739
+ }
740
+ }
741
+ }
742
+ for (const localKey of Object.keys(this.localCache)) {
743
+ if (this.localCache[localKey] && !keysInResult.has(localKey)) {
744
+ // Deleted
745
+ this.notifyListeners(localKey, null);
746
+ keys.push(localKey);
649
747
  }
650
748
  }
749
+ return keys;
651
750
  }
652
- for (const localKey of Object.keys(this.localCache)) {
653
- if (this.localCache[localKey] && !keysInResult.has(localKey)) {
654
- // Deleted
655
- this.notifyListeners(localKey, null);
656
- keys.push(localKey);
751
+ catch (e) {
752
+ if (!this.isHiding) {
753
+ _logWarn(`Firebase Auth cross-tab polling failed with error: ${e}`);
657
754
  }
755
+ return [];
658
756
  }
659
- return keys;
660
757
  }
661
758
  notifyListeners(key, newValue) {
662
759
  this.localCache[key] = newValue;
@@ -680,6 +777,7 @@ class IndexedDBLocalPersistence {
680
777
  _addListener(key, listener) {
681
778
  if (Object.keys(this.listeners).length === 0) {
682
779
  this.startPolling();
780
+ this.registerLifecycleListeners();
683
781
  }
684
782
  if (!this.listeners[key]) {
685
783
  this.listeners[key] = new Set();
@@ -697,6 +795,7 @@ class IndexedDBLocalPersistence {
697
795
  }
698
796
  if (Object.keys(this.listeners).length === 0) {
699
797
  this.stopPolling();
798
+ this.unregisterLifecycleListeners();
700
799
  }
701
800
  }
702
801
  }
@@ -1033,34 +1132,6 @@ const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
1033
1132
  INVALID_HOSTING_LINK_DOMAIN: 'auth/invalid-hosting-link-domain'
1034
1133
  };
1035
1134
 
1036
- /**
1037
- * @license
1038
- * Copyright 2020 Google LLC
1039
- *
1040
- * Licensed under the Apache License, Version 2.0 (the "License");
1041
- * you may not use this file except in compliance with the License.
1042
- * You may obtain a copy of the License at
1043
- *
1044
- * http://www.apache.org/licenses/LICENSE-2.0
1045
- *
1046
- * Unless required by applicable law or agreed to in writing, software
1047
- * distributed under the License is distributed on an "AS IS" BASIS,
1048
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1049
- * See the License for the specific language governing permissions and
1050
- * limitations under the License.
1051
- */
1052
- const logClient = new Logger('@firebase/auth');
1053
- function _logWarn(msg, ...args) {
1054
- if (logClient.logLevel <= LogLevel.WARN) {
1055
- logClient.warn(`Auth (${SDK_VERSION}): ${msg}`, ...args);
1056
- }
1057
- }
1058
- function _logError(msg, ...args) {
1059
- if (logClient.logLevel <= LogLevel.ERROR) {
1060
- logClient.error(`Auth (${SDK_VERSION}): ${msg}`, ...args);
1061
- }
1062
- }
1063
-
1064
1135
  /**
1065
1136
  * @license
1066
1137
  * Copyright 2020 Google LLC
@@ -2182,6 +2253,7 @@ function extractProviderData(providers) {
2182
2253
  * See the License for the specific language governing permissions and
2183
2254
  * limitations under the License.
2184
2255
  */
2256
+ /* eslint-disable camelcase */
2185
2257
  async function requestStsToken(auth, refreshToken) {
2186
2258
  const response = await _performFetchWithErrorHandling(auth, {}, async () => {
2187
2259
  const body = querystring({
@@ -4034,6 +4106,22 @@ function generateRandomAlphaNumericString(len) {
4034
4106
  }
4035
4107
 
4036
4108
  /* eslint-disable @typescript-eslint/no-require-imports */
4109
+ /**
4110
+ * @license
4111
+ * Copyright 2022 Google LLC
4112
+ *
4113
+ * Licensed under the Apache License, Version 2.0 (the "License");
4114
+ * you may not use this file except in compliance with the License.
4115
+ * You may obtain a copy of the License at
4116
+ *
4117
+ * http://www.apache.org/licenses/LICENSE-2.0
4118
+ *
4119
+ * Unless required by applicable law or agreed to in writing, software
4120
+ * distributed under the License is distributed on an "AS IS" BASIS,
4121
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4122
+ * See the License for the specific language governing permissions and
4123
+ * limitations under the License.
4124
+ */
4037
4125
  const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
4038
4126
  const FAKE_TOKEN = 'NO_RECAPTCHA';
4039
4127
  const RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME = 'onFirebaseAuthREInstanceReady';
@@ -5897,6 +5985,11 @@ GithubAuthProvider.PROVIDER_ID = "github.com" /* ProviderId.GITHUB */;
5897
5985
  * See the License for the specific language governing permissions and
5898
5986
  * limitations under the License.
5899
5987
  */
5988
+ /**
5989
+ * Represents the SAML credentials returned by an {@link SAMLAuthProvider}.
5990
+ *
5991
+ * @public
5992
+ */
5900
5993
  const IDP_REQUEST_URI = 'http://localhost';
5901
5994
  /**
5902
5995
  * @public
@@ -7957,7 +8050,7 @@ function multiFactor(user) {
7957
8050
  }
7958
8051
 
7959
8052
  var name = "@firebase/auth";
7960
- var version = "1.13.3";
8053
+ var version = "1.13.4-20260728185501";
7961
8054
 
7962
8055
  /**
7963
8056
  * @license
@@ -9770,5 +9863,5 @@ function generateNoEvent() {
9770
9863
  };
9771
9864
  }
9772
9865
 
9773
- export { signInWithEmailAndPassword as $, ActionCodeOperation as A, PhoneAuthCredential as B, inMemoryPersistence as C, EmailAuthProvider as D, EmailAuthCredential as E, FactorId as F, FacebookAuthProvider as G, GoogleAuthProvider as H, GithubAuthProvider as I, OAuthProvider as J, SAMLAuthProvider as K, signInAnonymously as L, signInWithCredential as M, linkWithCredential as N, OperationType as O, ProviderId as P, reauthenticateWithCredential as Q, signInWithCustomToken as R, SignInMethod as S, TwitterAuthProvider as T, sendPasswordResetEmail as U, confirmPasswordReset as V, applyActionCode as W, checkActionCode as X, verifyPasswordResetCode as Y, createUserWithEmailAndPassword as Z, _signInWithRedirect as _, _reauthenticateWithRedirect as a, debugFail as a$, sendSignInLinkToEmail as a0, isSignInWithEmailLink as a1, signInWithEmailLink as a2, fetchSignInMethodsForEmail as a3, sendEmailVerification as a4, verifyBeforeUpdateEmail as a5, ActionCodeURL as a6, parseActionCodeURL as a7, updateProfile as a8, updateEmail as a9, FAKE_TOKEN as aA, startEnrollPhoneMfa as aB, handleRecaptchaFlow as aC, sendPhoneVerificationCode as aD, _link$1 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, _isMobileBrowser as aX, _isSafari as aY, _isIOS as aZ, AuthEventManager as a_, updatePassword as aa, getIdToken as ab, getIdTokenResult as ac, unlink as ad, getAdditionalUserInfo as ae, reload as af, getMultiFactorResolver as ag, multiFactor as ah, _performApiRequest as ai, _addTidIfNecessary as aj, Delay as ak, _window as al, _assert as am, isV2 as an, _createError as ao, _recaptchaV2ScriptUrl as ap, _loadJS as aq, MockReCaptcha as ar, _generateCallbackName as as, _castAuth as at, _isHttpOrHttps as au, _isWorker as av, getRecaptchaParams as aw, _serverAppCurrentUserOperationNotSupportedError as ax, _assertLinkedStatus as ay, _initializeRecaptchaConfig as az, _linkWithRedirect as b, finalizeEnrollPhoneMfa as b0, startEnrollTotpMfa as b1, finalizeEnrollTotpMfa as b2, _setExternalJSProvider as b3, _persistenceKeyName as b4, UserImpl as b5, _getInstance as b6, AuthImpl as b7, _getClientVersion as b8, FetchProvider as b9, SAMLAuthCredential as ba, signInWithRedirect as bb, linkWithRedirect as bc, reauthenticateWithRedirect as bd, indexedDBLocalPersistence as c, cordovaPopupRedirectResolver as d, browserLocalPersistence as e, browserSessionPersistence as f, getRedirectResult as g, initializeRecaptchaConfig as h, initializeAuth as i, beforeAuthStateChanged as j, onAuthStateChanged as k, updateCurrentUser as l, signOut as m, revokeAccessToken as n, onIdTokenChanged as o, deleteUser as p, debugErrorMap as q, registerAuth as r, setPersistence as s, prodErrorMap as t, useDeviceLanguage as u, validatePassword as v, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as w, connectAuthEmulator as x, AuthCredential as y, OAuthCredential as z };
9774
- //# sourceMappingURL=popup_redirect-167cbb8f.js.map
9866
+ 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 };
9867
+ //# sourceMappingURL=popup_redirect-Be0Melsy.js.map