@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
@@ -1575,6 +1575,7 @@ function extractProviderData(providers) {
1575
1575
  * See the License for the specific language governing permissions and
1576
1576
  * limitations under the License.
1577
1577
  */
1578
+ /* eslint-disable camelcase */
1578
1579
  async function requestStsToken(auth, refreshToken) {
1579
1580
  const response = await _performFetchWithErrorHandling(auth, {}, async () => {
1580
1581
  const body = querystring({
@@ -3427,6 +3428,22 @@ function generateRandomAlphaNumericString(len) {
3427
3428
  }
3428
3429
 
3429
3430
  /* eslint-disable @typescript-eslint/no-require-imports */
3431
+ /**
3432
+ * @license
3433
+ * Copyright 2022 Google LLC
3434
+ *
3435
+ * Licensed under the Apache License, Version 2.0 (the "License");
3436
+ * you may not use this file except in compliance with the License.
3437
+ * You may obtain a copy of the License at
3438
+ *
3439
+ * http://www.apache.org/licenses/LICENSE-2.0
3440
+ *
3441
+ * Unless required by applicable law or agreed to in writing, software
3442
+ * distributed under the License is distributed on an "AS IS" BASIS,
3443
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3444
+ * See the License for the specific language governing permissions and
3445
+ * limitations under the License.
3446
+ */
3430
3447
  const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
3431
3448
  const FAKE_TOKEN = 'NO_RECAPTCHA';
3432
3449
  const RECAPTCHA_ENTERPRISE_ONLOAD_CALLBACK_NAME = 'onFirebaseAuthREInstanceReady';
@@ -5290,6 +5307,11 @@ GithubAuthProvider.PROVIDER_ID = "github.com" /* ProviderId.GITHUB */;
5290
5307
  * See the License for the specific language governing permissions and
5291
5308
  * limitations under the License.
5292
5309
  */
5310
+ /**
5311
+ * Represents the SAML credentials returned by an {@link SAMLAuthProvider}.
5312
+ *
5313
+ * @public
5314
+ */
5293
5315
  const IDP_REQUEST_URI = 'http://localhost';
5294
5316
  /**
5295
5317
  * @public
@@ -8223,6 +8245,28 @@ function _deleteObject(db, key) {
8223
8245
  const _POLLING_INTERVAL_MS = 800;
8224
8246
  const _TRANSACTION_RETRY_COUNT = 3;
8225
8247
  class IndexedDBLocalPersistence {
8248
+ registerLifecycleListeners() {
8249
+ if (typeof window !== 'undefined' &&
8250
+ typeof window.addEventListener === 'function') {
8251
+ window.addEventListener('pagehide', this.onPageHide);
8252
+ window.addEventListener('pageshow', this.onPageShow);
8253
+ }
8254
+ if (typeof document !== 'undefined' &&
8255
+ typeof document.addEventListener === 'function') {
8256
+ document.addEventListener('visibilitychange', this.onVisibilityChange);
8257
+ }
8258
+ }
8259
+ unregisterLifecycleListeners() {
8260
+ if (typeof window !== 'undefined' &&
8261
+ typeof window.removeEventListener === 'function') {
8262
+ window.removeEventListener('pagehide', this.onPageHide);
8263
+ window.removeEventListener('pageshow', this.onPageShow);
8264
+ }
8265
+ if (typeof document !== 'undefined' &&
8266
+ typeof document.removeEventListener === 'function') {
8267
+ document.removeEventListener('visibilitychange', this.onVisibilityChange);
8268
+ }
8269
+ }
8226
8270
  constructor() {
8227
8271
  this.type = "LOCAL" /* PersistenceType.LOCAL */;
8228
8272
  this.dbPromise = null;
@@ -8232,16 +8276,46 @@ class IndexedDBLocalPersistence {
8232
8276
  // setTimeout return value is platform specific
8233
8277
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8234
8278
  this.pollTimer = null;
8279
+ this.isHiding = false;
8235
8280
  this.pendingWrites = 0;
8236
8281
  this.receiver = null;
8237
8282
  this.sender = null;
8238
8283
  this.serviceWorkerReceiverAvailable = false;
8239
8284
  this.activeServiceWorker = null;
8285
+ this.onPageHide = () => {
8286
+ this.isHiding = true;
8287
+ this.stopPolling();
8288
+ if (this.dbPromise) {
8289
+ this.dbPromise.then(db => db.close()).catch(() => { });
8290
+ this.dbPromise = null;
8291
+ }
8292
+ };
8293
+ this.onPageShow = () => {
8294
+ if (this.isHiding) {
8295
+ this.isHiding = false;
8296
+ if (Object.keys(this.listeners).length > 0) {
8297
+ this.startPolling();
8298
+ }
8299
+ }
8300
+ };
8301
+ this.onVisibilityChange = () => {
8302
+ if (typeof document !== 'undefined') {
8303
+ if (document.visibilityState === 'hidden') {
8304
+ this.onPageHide();
8305
+ }
8306
+ else if (document.visibilityState === 'visible') {
8307
+ this.onPageShow();
8308
+ }
8309
+ }
8310
+ };
8240
8311
  // Fire & forget the service worker registration as it may never resolve
8241
8312
  this._workerInitializationPromise =
8242
8313
  this.initializeServiceWorkerMessaging().then(() => { }, () => { });
8243
8314
  }
8244
8315
  async _openDb() {
8316
+ if (this.isHiding) {
8317
+ throw new Error('Database is closing/hidden');
8318
+ }
8245
8319
  if (this.dbPromise) {
8246
8320
  return this.dbPromise;
8247
8321
  }
@@ -8259,6 +8333,9 @@ class IndexedDBLocalPersistence {
8259
8333
  return await op(db);
8260
8334
  }
8261
8335
  catch (e) {
8336
+ if (this.isHiding) {
8337
+ throw e;
8338
+ }
8262
8339
  if (numAttempts++ > _TRANSACTION_RETRY_COUNT) {
8263
8340
  throw e;
8264
8341
  }
@@ -8388,37 +8465,51 @@ class IndexedDBLocalPersistence {
8388
8465
  });
8389
8466
  }
8390
8467
  async _poll() {
8391
- // TODO: check if we need to fallback if getAll is not supported
8392
- const result = await this._withRetries((db) => {
8393
- const getAllRequest = getObjectStore(db, false).getAll();
8394
- return new DBPromise(getAllRequest).toPromise();
8395
- });
8396
- if (!result) {
8397
- return [];
8398
- }
8399
- // If we have pending writes in progress abort, we'll get picked up on the next poll
8400
- if (this.pendingWrites !== 0) {
8468
+ if (this.isHiding) {
8401
8469
  return [];
8402
8470
  }
8403
- const keys = [];
8404
- const keysInResult = new Set();
8405
- if (result.length !== 0) {
8406
- for (const { fbase_key: key, value } of result) {
8407
- keysInResult.add(key);
8408
- if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
8409
- this.notifyListeners(key, value);
8410
- keys.push(key);
8471
+ try {
8472
+ // TODO: check if we need to fallback if getAll is not supported
8473
+ const result = await this._withRetries((db) => {
8474
+ const getAllRequest = getObjectStore(db, false).getAll();
8475
+ return new DBPromise(getAllRequest).toPromise();
8476
+ });
8477
+ if (this.isHiding) {
8478
+ return [];
8479
+ }
8480
+ if (!result) {
8481
+ return [];
8482
+ }
8483
+ // If we have pending writes in progress abort, we'll get picked up on the next poll
8484
+ if (this.pendingWrites !== 0) {
8485
+ return [];
8486
+ }
8487
+ const keys = [];
8488
+ const keysInResult = new Set();
8489
+ if (result.length !== 0) {
8490
+ for (const { fbase_key: key, value } of result) {
8491
+ keysInResult.add(key);
8492
+ if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
8493
+ this.notifyListeners(key, value);
8494
+ keys.push(key);
8495
+ }
8496
+ }
8497
+ }
8498
+ for (const localKey of Object.keys(this.localCache)) {
8499
+ if (this.localCache[localKey] && !keysInResult.has(localKey)) {
8500
+ // Deleted
8501
+ this.notifyListeners(localKey, null);
8502
+ keys.push(localKey);
8411
8503
  }
8412
8504
  }
8505
+ return keys;
8413
8506
  }
8414
- for (const localKey of Object.keys(this.localCache)) {
8415
- if (this.localCache[localKey] && !keysInResult.has(localKey)) {
8416
- // Deleted
8417
- this.notifyListeners(localKey, null);
8418
- keys.push(localKey);
8507
+ catch (e) {
8508
+ if (!this.isHiding) {
8509
+ _logWarn(`Firebase Auth cross-tab polling failed with error: ${e}`);
8419
8510
  }
8511
+ return [];
8420
8512
  }
8421
- return keys;
8422
8513
  }
8423
8514
  notifyListeners(key, newValue) {
8424
8515
  this.localCache[key] = newValue;
@@ -8442,6 +8533,7 @@ class IndexedDBLocalPersistence {
8442
8533
  _addListener(key, listener) {
8443
8534
  if (Object.keys(this.listeners).length === 0) {
8444
8535
  this.startPolling();
8536
+ this.registerLifecycleListeners();
8445
8537
  }
8446
8538
  if (!this.listeners[key]) {
8447
8539
  this.listeners[key] = new Set();
@@ -8459,6 +8551,7 @@ class IndexedDBLocalPersistence {
8459
8551
  }
8460
8552
  if (Object.keys(this.listeners).length === 0) {
8461
8553
  this.stopPolling();
8554
+ this.unregisterLifecycleListeners();
8462
8555
  }
8463
8556
  }
8464
8557
  }
@@ -10939,7 +11032,7 @@ function _isEmptyString(input) {
10939
11032
  }
10940
11033
 
10941
11034
  var name = "@firebase/auth";
10942
- var version = "1.13.3";
11035
+ var version = "1.13.4-20260728185501";
10943
11036
 
10944
11037
  /**
10945
11038
  * @license
@@ -11191,5 +11284,5 @@ _setExternalJSProvider({
11191
11284
  });
11192
11285
  registerAuth("Browser" /* ClientPlatform.BROWSER */);
11193
11286
 
11194
- export { SAMLAuthProvider as $, ActionCodeOperation as A, useDeviceLanguage as B, updateCurrentUser as C, signOut as D, revokeAccessToken as E, FactorId as F, deleteUser as G, debugErrorMap as H, prodErrorMap as I, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as J, initializeAuth as K, connectAuthEmulator as L, AuthCredential as M, EmailAuthCredential as N, OperationType as O, PhoneAuthProvider as P, OAuthCredential as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, PhoneAuthCredential as U, inMemoryPersistence as V, EmailAuthProvider as W, FacebookAuthProvider as X, GoogleAuthProvider as Y, GithubAuthProvider as Z, OAuthProvider as _, browserCookiePersistence as a, TwitterAuthProvider as a0, signInAnonymously as a1, signInWithCredential as a2, linkWithCredential as a3, reauthenticateWithCredential as a4, signInWithCustomToken as a5, sendPasswordResetEmail as a6, confirmPasswordReset as a7, applyActionCode as a8, checkActionCode as a9, _getProjectConfig as aA, _isIOS7Or8 as aB, _createError as aC, _assert as aD, AuthEventManager as aE, _getInstance as aF, _persistenceKeyName as aG, _getRedirectResult as aH, _overrideRedirectResult as aI, _clearRedirectOutcomes as aJ, _castAuth as aK, UserImpl as aL, AuthImpl as aM, _getClientVersion as aN, _generateEventId as aO, AuthPopup as aP, FetchProvider as aQ, SAMLAuthCredential as aR, verifyPasswordResetCode as aa, createUserWithEmailAndPassword as ab, signInWithEmailAndPassword as ac, sendSignInLinkToEmail as ad, isSignInWithEmailLink as ae, signInWithEmailLink as af, fetchSignInMethodsForEmail as ag, sendEmailVerification as ah, verifyBeforeUpdateEmail as ai, ActionCodeURL as aj, parseActionCodeURL as ak, updateProfile as al, updateEmail as am, updatePassword as an, getIdToken as ao, getIdTokenResult as ap, unlink as aq, getAdditionalUserInfo as ar, reload as as, getMultiFactorResolver as at, multiFactor as au, debugAssert as av, _isIOS as aw, _isAndroid as ax, _fail as ay, _getRedirectUrl as az, browserLocalPersistence as b, browserSessionPersistence as c, signInWithPopup as d, linkWithPopup as e, reauthenticateWithPopup as f, signInWithRedirect as g, linkWithRedirect as h, indexedDBLocalPersistence as i, reauthenticateWithRedirect as j, getRedirectResult as k, linkWithPhoneNumber as l, browserPopupRedirectResolver as m, PhoneMultiFactorGenerator as n, TotpSecret as o, getAuth as p, ProviderId as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, setPersistence as t, updatePhoneNumber as u, initializeRecaptchaConfig as v, validatePassword as w, onIdTokenChanged as x, beforeAuthStateChanged as y, onAuthStateChanged as z };
11195
- //# sourceMappingURL=index-d90d2ee5.js.map
11287
+ export { onIdTokenChanged as $, ActionCodeOperation as A, fetchSignInMethodsForEmail as B, getAdditionalUserInfo as C, getAuth as D, EmailAuthCredential as E, FacebookAuthProvider as F, GithubAuthProvider as G, getIdToken as H, getIdTokenResult as I, getMultiFactorResolver as J, getRedirectResult as K, inMemoryPersistence as L, indexedDBLocalPersistence as M, initializeAuth as N, OAuthCredential as O, PhoneAuthCredential as P, initializeRecaptchaConfig as Q, RecaptchaVerifier as R, SAMLAuthProvider as S, TotpMultiFactorGenerator as T, isSignInWithEmailLink as U, linkWithCredential as V, linkWithPhoneNumber as W, linkWithPopup as X, linkWithRedirect as Y, multiFactor as Z, onAuthStateChanged as _, ActionCodeURL as a, parseActionCodeURL as a0, prodErrorMap as a1, reauthenticateWithCredential as a2, reauthenticateWithPhoneNumber as a3, reauthenticateWithPopup as a4, reauthenticateWithRedirect as a5, reload as a6, revokeAccessToken as a7, sendEmailVerification as a8, sendPasswordResetEmail as a9, _getRedirectUrl as aA, _isIOS7Or8 as aB, _createError as aC, _getProjectConfig as aD, AuthEventManager as aE, _getInstance as aF, _persistenceKeyName as aG, _getRedirectResult as aH, _overrideRedirectResult as aI, _clearRedirectOutcomes as aJ, _castAuth as aK, AuthImpl as aL, AuthPopup as aM, FetchProvider as aN, SAMLAuthCredential as aO, UserImpl as aP, _generateEventId as aQ, _getClientVersion as aR, sendSignInLinkToEmail as aa, setPersistence as ab, signInAnonymously as ac, signInWithCredential as ad, signInWithCustomToken as ae, signInWithEmailAndPassword as af, signInWithEmailLink as ag, signInWithPhoneNumber as ah, signInWithPopup as ai, signInWithRedirect as aj, signOut as ak, unlink as al, updateCurrentUser as am, updateEmail as an, updatePassword as ao, updatePhoneNumber as ap, updateProfile as aq, useDeviceLanguage as ar, validatePassword as as, verifyBeforeUpdateEmail as at, verifyPasswordResetCode as au, _assert as av, debugAssert as aw, _isIOS as ax, _isAndroid as ay, _fail as az, AuthCredential as b, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as c, EmailAuthProvider as d, FactorId as e, GoogleAuthProvider as f, OAuthProvider as g, OperationType as h, PhoneAuthProvider as i, PhoneMultiFactorGenerator as j, ProviderId as k, SignInMethod as l, TotpSecret as m, TwitterAuthProvider as n, applyActionCode as o, beforeAuthStateChanged as p, browserCookiePersistence as q, browserLocalPersistence as r, browserPopupRedirectResolver as s, browserSessionPersistence as t, checkActionCode as u, confirmPasswordReset as v, connectAuthEmulator as w, createUserWithEmailAndPassword as x, debugErrorMap as y, deleteUser as z };
11288
+ //# sourceMappingURL=index-DqtyKhzu.js.map