@firebase/auth 1.13.9 → 1.13.10-20261110194028

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 (70) hide show
  1. package/dist/auth-public.d.ts +1 -0
  2. package/dist/auth.d.ts +1 -0
  3. package/dist/browser-cjs/{index-DTUcAMkM.js → index-CWK8eckO.js} +180 -62
  4. package/dist/browser-cjs/index-CWK8eckO.js.map +1 -0
  5. package/dist/browser-cjs/index.js +1 -1
  6. package/dist/browser-cjs/internal.js +1 -1
  7. package/dist/browser-cjs/src/core/persistence/index.d.ts +1 -0
  8. package/dist/browser-cjs/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  9. package/dist/cordova/auth-cordova-public.d.ts +1 -0
  10. package/dist/cordova/auth-cordova.d.ts +1 -0
  11. package/dist/cordova/index.js +2 -2
  12. package/dist/cordova/internal.js +2 -2
  13. package/dist/cordova/{popup_redirect-xyFFcAgj.js → popup_redirect-_-tO-o8H.js} +180 -62
  14. package/dist/cordova/popup_redirect-_-tO-o8H.js.map +1 -0
  15. package/dist/cordova/src/core/persistence/index.d.ts +1 -0
  16. package/dist/cordova/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  17. package/dist/esm/{index-Bz2J43nW.js → index-CGm68jO1.js} +180 -62
  18. package/dist/esm/index-CGm68jO1.js.map +1 -0
  19. package/dist/esm/index.js +1 -1
  20. package/dist/esm/internal.js +2 -2
  21. package/dist/esm/src/core/persistence/index.d.ts +1 -0
  22. package/dist/esm/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  23. package/dist/index.webworker.js +179 -61
  24. package/dist/index.webworker.js.map +1 -1
  25. package/dist/node/index.js +1 -1
  26. package/dist/node/internal.js +1 -1
  27. package/dist/node/internal.js.map +1 -1
  28. package/dist/node/src/core/persistence/index.d.ts +1 -0
  29. package/dist/node/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  30. package/dist/node/{totp-CMTC0AYP.js → totp-CMj0kbMN.js} +49 -30
  31. package/dist/node/totp-CMj0kbMN.js.map +1 -0
  32. package/dist/node-esm/index.js +1 -1
  33. package/dist/node-esm/internal.js +2 -2
  34. package/dist/node-esm/internal.js.map +1 -1
  35. package/dist/node-esm/src/core/persistence/index.d.ts +1 -0
  36. package/dist/node-esm/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  37. package/dist/node-esm/{totp-pe8Y0u5S.js → totp-C1gXPzeQ.js} +49 -30
  38. package/dist/node-esm/totp-C1gXPzeQ.js.map +1 -0
  39. package/dist/rn/{index-DzY9h3Kn.js → index-CkEQlRgG.js} +49 -30
  40. package/dist/rn/index-CkEQlRgG.js.map +1 -0
  41. package/dist/rn/index.js +1 -1
  42. package/dist/rn/internal.js +132 -33
  43. package/dist/rn/internal.js.map +1 -1
  44. package/dist/rn/src/core/persistence/index.d.ts +1 -0
  45. package/dist/rn/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  46. package/dist/src/core/persistence/index.d.ts +1 -0
  47. package/dist/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  48. package/dist/web-extension-cjs/index.js +1 -1
  49. package/dist/web-extension-cjs/internal.js +1 -1
  50. package/dist/web-extension-cjs/{register-CTiLN4Sf.js → register-DDH4JTxZ.js} +180 -62
  51. package/dist/web-extension-cjs/register-DDH4JTxZ.js.map +1 -0
  52. package/dist/web-extension-cjs/src/core/persistence/index.d.ts +1 -0
  53. package/dist/web-extension-cjs/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  54. package/dist/web-extension-esm/auth-web-extension-public.d.ts +1 -0
  55. package/dist/web-extension-esm/auth-web-extension.d.ts +1 -0
  56. package/dist/web-extension-esm/index.js +2 -2
  57. package/dist/web-extension-esm/internal.js +2 -2
  58. package/dist/web-extension-esm/{register-DBjcU-NC.js → register-BjPfSC3G.js} +180 -62
  59. package/dist/web-extension-esm/register-BjPfSC3G.js.map +1 -0
  60. package/dist/web-extension-esm/src/core/persistence/index.d.ts +1 -0
  61. package/dist/web-extension-esm/src/platform_browser/persistence/indexed_db.d.ts +18 -4
  62. package/package.json +1 -1
  63. package/dist/browser-cjs/index-DTUcAMkM.js.map +0 -1
  64. package/dist/cordova/popup_redirect-xyFFcAgj.js.map +0 -1
  65. package/dist/esm/index-Bz2J43nW.js.map +0 -1
  66. package/dist/node/totp-CMTC0AYP.js.map +0 -1
  67. package/dist/node-esm/totp-pe8Y0u5S.js.map +0 -1
  68. package/dist/rn/index-DzY9h3Kn.js.map +0 -1
  69. package/dist/web-extension-cjs/register-CTiLN4Sf.js.map +0 -1
  70. package/dist/web-extension-esm/register-DBjcU-NC.js.map +0 -1
@@ -39,4 +39,5 @@ export interface PersistenceInternal extends Persistence {
39
39
  _addListener(key: string, listener: StorageEventListener): void;
40
40
  _removeListener(key: string, listener: StorageEventListener): void;
41
41
  _shouldAllowMigration?: boolean;
42
+ _lastProbeTimedOut?: boolean;
42
43
  }
@@ -17,13 +17,27 @@
17
17
  import { Persistence } from '../../model/public_types';
18
18
  import { PersistenceValue } from '../../core/persistence/';
19
19
  export declare const DB_NAME = "firebaseLocalStorageDb";
20
+ export declare const _POLLING_INTERVAL_MS = 800;
21
+ export declare const _TRANSACTION_RETRY_COUNT = 3;
22
+ /**
23
+ * Short timeout scoped to the `readwrite` availability probe in `_isAvailable()`.
24
+ * Matches `_POLLING_INTERVAL_MS` so that if a background tab is suspended while
25
+ * holding a `readonly` poll transaction that blocks `readwrite` transactions
26
+ * (#10540), the startup probe fails fast and aborts its queued transaction in
27
+ * under a second without blocking fallback or user loading.
28
+ */
29
+ export declare const _DB_PROBE_TIMEOUT_MS = 800;
30
+ /**
31
+ * Timeout for opening the database and regular IndexedDB read/write requests.
32
+ * Kept at multiple seconds to accommodate cold `indexedDB.open()` or slow disk
33
+ * I/O on low-end devices without premature timeouts.
34
+ */
35
+ export declare const _DB_TIMEOUT_MS = 2500;
20
36
  export declare function _clearDatabase(db: IDBDatabase): Promise<void>;
21
37
  export declare function _deleteDatabase(): Promise<void>;
22
38
  export declare function _openDatabase(): Promise<IDBDatabase>;
23
- export declare function _putObject(db: IDBDatabase, key: string, value: PersistenceValue | string): Promise<void>;
24
- export declare function _deleteObject(db: IDBDatabase, key: string): Promise<void>;
25
- export declare const _POLLING_INTERVAL_MS = 800;
26
- export declare const _TRANSACTION_RETRY_COUNT = 3;
39
+ export declare function _putObject(db: IDBDatabase, key: string, value: PersistenceValue | string, timeoutMs?: number): Promise<void>;
40
+ export declare function _deleteObject(db: IDBDatabase, key: string, timeoutMs?: number): Promise<void>;
27
41
  /**
28
42
  * An implementation of {@link Persistence} of type `LOCAL` using `indexedDB`
29
43
  * for the underlying storage.
@@ -2128,31 +2128,25 @@ class PersistenceUserManager {
2128
2128
  if (!persistenceHierarchy.length) {
2129
2129
  return new PersistenceUserManager(_getInstance(inMemoryPersistence), auth, userKey);
2130
2130
  }
2131
- // Eliminate any persistences that are not available
2132
- const availablePersistences = (await Promise.all(persistenceHierarchy.map(async (persistence) => {
2131
+ const key = _persistenceKeyName(userKey, auth.config.apiKey, auth.name);
2132
+ // Search for an existing user across all persistences before running `_isAvailable()`.
2133
+ // `_get` only opens a `readonly` transaction in IndexedDB, whereas `_isAvailable()` opens
2134
+ // a `readwrite` transaction; if another tab is suspended holding a `readonly` transaction
2135
+ // (#10540), queuing a `readwrite` transaction first blocks subsequent `readonly` transactions
2136
+ // in the browser's IndexedDB lock manager.
2137
+ let foundUser = null;
2138
+ let foundPersistence = null;
2139
+ const unreadablePersistences = new Set();
2140
+ for (const persistence of persistenceHierarchy) {
2141
+ let blob = null;
2133
2142
  try {
2134
- if (await persistence._isAvailable()) {
2135
- return persistence;
2136
- }
2143
+ blob = await persistence._get(key);
2137
2144
  }
2138
2145
  catch {
2139
- return undefined;
2146
+ unreadablePersistences.add(persistence);
2147
+ continue;
2140
2148
  }
2141
- return undefined;
2142
- }))).filter(persistence => persistence);
2143
- // Fall back to the first persistence listed, or in memory if none available
2144
- let selectedPersistence = availablePersistences[0] ||
2145
- _getInstance(inMemoryPersistence);
2146
- const key = _persistenceKeyName(userKey, auth.config.apiKey, auth.name);
2147
- // Pull out the existing user, setting the chosen persistence to that
2148
- // persistence if the user exists.
2149
- let userToMigrate = null;
2150
- // Note, here we check for a user in _all_ persistences, not just the
2151
- // ones deemed available. If we can migrate a user out of a broken
2152
- // persistence, we will (but only if that persistence supports migration).
2153
- for (const persistence of persistenceHierarchy) {
2154
2149
  try {
2155
- const blob = await persistence._get(key);
2156
2150
  if (blob) {
2157
2151
  let user;
2158
2152
  if (typeof blob === 'string') {
@@ -2167,15 +2161,38 @@ class PersistenceUserManager {
2167
2161
  else {
2168
2162
  user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
2169
2163
  }
2170
- if (persistence !== selectedPersistence) {
2171
- userToMigrate = user;
2172
- }
2173
- selectedPersistence = persistence;
2164
+ foundUser = user;
2165
+ foundPersistence = persistence;
2174
2166
  break;
2175
2167
  }
2176
2168
  }
2177
2169
  catch { }
2178
2170
  }
2171
+ // Eliminate any persistences that are not available
2172
+ const availablePersistences = (await Promise.all(persistenceHierarchy.map(async (persistence) => {
2173
+ try {
2174
+ if (await persistence._isAvailable()) {
2175
+ return persistence;
2176
+ }
2177
+ if (persistence._lastProbeTimedOut) {
2178
+ unreadablePersistences.add(persistence);
2179
+ }
2180
+ }
2181
+ catch {
2182
+ return undefined;
2183
+ }
2184
+ return undefined;
2185
+ }))).filter(persistence => persistence);
2186
+ // Fall back to the first persistence listed, or in memory if none available
2187
+ let selectedPersistence = availablePersistences[0] ||
2188
+ _getInstance(inMemoryPersistence);
2189
+ let userToMigrate = null;
2190
+ if (foundPersistence && foundUser) {
2191
+ if (foundPersistence !== selectedPersistence) {
2192
+ userToMigrate = foundUser;
2193
+ }
2194
+ selectedPersistence = foundPersistence;
2195
+ }
2179
2196
  // If we find the user in a persistence that does support migration, use
2180
2197
  // that migration path (of only persistences that support migration)
2181
2198
  const migrationHierarchy = availablePersistences.filter(p => p._shouldAllowMigration);
@@ -2190,10 +2207,13 @@ class PersistenceUserManager {
2190
2207
  // we'll just let it bubble to surface the error.
2191
2208
  await selectedPersistence._set(key, userToMigrate.toJSON());
2192
2209
  }
2193
- // Attempt to clear the key in other persistences but ignore errors. This helps prevent issues
2194
- // such as users getting stuck with a previous account after signing out and refreshing the tab.
2210
+ // Attempt to clear the key in other persistences (except those whose _get threw or whose
2211
+ // _isAvailable() probe timed out, so we never delete from a store we couldn't read or that
2212
+ // is blocked by another tab) and ignore errors. This helps prevent issues such as users
2213
+ // getting stuck with a previous account after signing out and refreshing the tab.
2195
2214
  await Promise.all(persistenceHierarchy.map(async (persistence) => {
2196
- if (persistence !== selectedPersistence) {
2215
+ if (persistence !== selectedPersistence &&
2216
+ !unreadablePersistences.has(persistence)) {
2197
2217
  try {
2198
2218
  await persistence._remove(key);
2199
2219
  }
@@ -2712,7 +2732,6 @@ class AuthImpl {
2712
2732
  }
2713
2733
  catch (e) {
2714
2734
  _logWarn(`Failed to initialize current user: ${e}`);
2715
- await this.directlySetCurrentUser(null).catch(() => { });
2716
2735
  }
2717
2736
  this.lastNotifiedUid = this.currentUser?.uid || null;
2718
2737
  if (this._deleted) {
@@ -7241,7 +7260,7 @@ function multiFactor(user) {
7241
7260
  }
7242
7261
 
7243
7262
  var name = "@firebase/auth";
7244
- var version = "1.13.9";
7263
+ var version = "1.13.10-20261110194028";
7245
7264
 
7246
7265
  /**
7247
7266
  * @license
@@ -7761,4 +7780,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
7761
7780
  exports.validatePassword = validatePassword;
7762
7781
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
7763
7782
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
7764
- //# sourceMappingURL=totp-CMTC0AYP.js.map
7783
+ //# sourceMappingURL=totp-CMj0kbMN.js.map