@firebase/auth 1.9.1 → 1.10.0

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 (130) hide show
  1. package/dist/auth-public.d.ts +28 -1
  2. package/dist/auth.d.ts +40 -2
  3. package/dist/browser-cjs/{index-018c7ebd.js → index-eddc1dc3.js} +211 -15
  4. package/dist/browser-cjs/index-eddc1dc3.js.map +1 -0
  5. package/dist/browser-cjs/index.d.ts +2 -1
  6. package/dist/browser-cjs/index.js +2 -1
  7. package/dist/browser-cjs/index.js.map +1 -1
  8. package/dist/browser-cjs/internal.js +2 -1
  9. package/dist/browser-cjs/internal.js.map +1 -1
  10. package/dist/browser-cjs/src/api/index.d.ts +1 -1
  11. package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +4 -1
  12. package/dist/browser-cjs/src/core/persistence/index.d.ts +2 -1
  13. package/dist/browser-cjs/src/model/auth.d.ts +4 -1
  14. package/dist/browser-cjs/src/model/public_types.d.ts +2 -1
  15. package/dist/browser-cjs/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  16. package/dist/browser-cjs/src/platform_node/index.d.ts +1 -0
  17. package/dist/cordova/auth-cordova-public.d.ts +26 -1
  18. package/dist/cordova/auth-cordova.d.ts +29 -2
  19. package/dist/cordova/index.d.ts +2 -1
  20. package/dist/cordova/index.js +2 -2
  21. package/dist/cordova/internal.js +147 -3
  22. package/dist/cordova/internal.js.map +1 -1
  23. package/dist/cordova/{popup_redirect-e795474a.js → popup_redirect-5323ec00.js} +66 -15
  24. package/dist/cordova/popup_redirect-5323ec00.js.map +1 -0
  25. package/dist/cordova/src/api/index.d.ts +1 -1
  26. package/dist/cordova/src/core/auth/auth_impl.d.ts +4 -1
  27. package/dist/cordova/src/core/persistence/index.d.ts +2 -1
  28. package/dist/cordova/src/model/auth.d.ts +4 -1
  29. package/dist/cordova/src/model/public_types.d.ts +2 -1
  30. package/dist/cordova/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  31. package/dist/cordova/src/platform_node/index.d.ts +1 -0
  32. package/dist/esm2017/{index-e84cf44d.js → index-c92d61ad.js} +211 -16
  33. package/dist/esm2017/index-c92d61ad.js.map +1 -0
  34. package/dist/esm2017/index.d.ts +2 -1
  35. package/dist/esm2017/index.js +1 -1
  36. package/dist/esm2017/internal.js +2 -2
  37. package/dist/esm2017/src/api/index.d.ts +1 -1
  38. package/dist/esm2017/src/core/auth/auth_impl.d.ts +4 -1
  39. package/dist/esm2017/src/core/persistence/index.d.ts +2 -1
  40. package/dist/esm2017/src/model/auth.d.ts +4 -1
  41. package/dist/esm2017/src/model/public_types.d.ts +2 -1
  42. package/dist/esm2017/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  43. package/dist/esm2017/src/platform_node/index.d.ts +1 -0
  44. package/dist/index.d.ts +2 -1
  45. package/dist/index.webworker.js +65 -14
  46. package/dist/index.webworker.js.map +1 -1
  47. package/dist/node/index.d.ts +2 -1
  48. package/dist/node/index.js +2 -1
  49. package/dist/node/index.js.map +1 -1
  50. package/dist/node/internal.js +2 -1
  51. package/dist/node/internal.js.map +1 -1
  52. package/dist/node/src/api/index.d.ts +1 -1
  53. package/dist/node/src/core/auth/auth_impl.d.ts +4 -1
  54. package/dist/node/src/core/persistence/index.d.ts +2 -1
  55. package/dist/node/src/model/auth.d.ts +4 -1
  56. package/dist/node/src/model/public_types.d.ts +2 -1
  57. package/dist/node/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  58. package/dist/node/src/platform_node/index.d.ts +1 -0
  59. package/dist/node/{totp-06fa6909.js → totp-af329771.js} +68 -15
  60. package/dist/node/totp-af329771.js.map +1 -0
  61. package/dist/node-esm/index.d.ts +2 -1
  62. package/dist/node-esm/index.js +1 -1
  63. package/dist/node-esm/internal.js +2 -2
  64. package/dist/node-esm/internal.js.map +1 -1
  65. package/dist/node-esm/src/api/index.d.ts +1 -1
  66. package/dist/node-esm/src/core/auth/auth_impl.d.ts +4 -1
  67. package/dist/node-esm/src/core/persistence/index.d.ts +2 -1
  68. package/dist/node-esm/src/model/auth.d.ts +4 -1
  69. package/dist/node-esm/src/model/public_types.d.ts +2 -1
  70. package/dist/node-esm/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  71. package/dist/node-esm/src/platform_node/index.d.ts +1 -0
  72. package/dist/node-esm/{totp-d5ff2369.js → totp-7829abf2.js} +68 -16
  73. package/dist/node-esm/totp-7829abf2.js.map +1 -0
  74. package/dist/rn/{index-ee081591.js → index-e8d5e0fb.js} +66 -15
  75. package/dist/rn/index-e8d5e0fb.js.map +1 -0
  76. package/dist/rn/index.d.ts +2 -1
  77. package/dist/rn/index.js +1 -1
  78. package/dist/rn/internal.js +146 -1
  79. package/dist/rn/internal.js.map +1 -1
  80. package/dist/rn/src/api/index.d.ts +1 -1
  81. package/dist/rn/src/core/auth/auth_impl.d.ts +4 -1
  82. package/dist/rn/src/core/persistence/index.d.ts +2 -1
  83. package/dist/rn/src/model/auth.d.ts +4 -1
  84. package/dist/rn/src/model/public_types.d.ts +2 -1
  85. package/dist/rn/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  86. package/dist/rn/src/platform_node/index.d.ts +1 -0
  87. package/dist/src/api/index.d.ts +1 -1
  88. package/dist/src/core/auth/auth_impl.d.ts +4 -1
  89. package/dist/src/core/persistence/index.d.ts +2 -1
  90. package/dist/src/model/auth.d.ts +4 -1
  91. package/dist/src/model/public_types.d.ts +2 -1
  92. package/dist/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  93. package/dist/src/platform_node/index.d.ts +1 -0
  94. package/dist/web-extension-cjs/index.d.ts +2 -1
  95. package/dist/web-extension-cjs/index.js +1 -1
  96. package/dist/web-extension-cjs/internal.js +146 -1
  97. package/dist/web-extension-cjs/internal.js.map +1 -1
  98. package/dist/web-extension-cjs/{register-c2c7670d.js → register-b64ddc5e.js} +66 -15
  99. package/dist/web-extension-cjs/register-b64ddc5e.js.map +1 -0
  100. package/dist/web-extension-cjs/src/api/index.d.ts +1 -1
  101. package/dist/web-extension-cjs/src/core/auth/auth_impl.d.ts +4 -1
  102. package/dist/web-extension-cjs/src/core/persistence/index.d.ts +2 -1
  103. package/dist/web-extension-cjs/src/model/auth.d.ts +4 -1
  104. package/dist/web-extension-cjs/src/model/public_types.d.ts +2 -1
  105. package/dist/web-extension-cjs/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  106. package/dist/web-extension-cjs/src/platform_node/index.d.ts +1 -0
  107. package/dist/web-extension-esm2017/auth-web-extension-public.d.ts +26 -1
  108. package/dist/web-extension-esm2017/auth-web-extension.d.ts +29 -2
  109. package/dist/web-extension-esm2017/index.d.ts +2 -1
  110. package/dist/web-extension-esm2017/index.js +2 -2
  111. package/dist/web-extension-esm2017/internal.js +147 -3
  112. package/dist/web-extension-esm2017/internal.js.map +1 -1
  113. package/dist/web-extension-esm2017/{register-31c228e4.js → register-00522d81.js} +66 -15
  114. package/dist/web-extension-esm2017/register-00522d81.js.map +1 -0
  115. package/dist/web-extension-esm2017/src/api/index.d.ts +1 -1
  116. package/dist/web-extension-esm2017/src/core/auth/auth_impl.d.ts +4 -1
  117. package/dist/web-extension-esm2017/src/core/persistence/index.d.ts +2 -1
  118. package/dist/web-extension-esm2017/src/model/auth.d.ts +4 -1
  119. package/dist/web-extension-esm2017/src/model/public_types.d.ts +2 -1
  120. package/dist/web-extension-esm2017/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
  121. package/dist/web-extension-esm2017/src/platform_node/index.d.ts +1 -0
  122. package/package.json +3 -2
  123. package/dist/browser-cjs/index-018c7ebd.js.map +0 -1
  124. package/dist/cordova/popup_redirect-e795474a.js.map +0 -1
  125. package/dist/esm2017/index-e84cf44d.js.map +0 -1
  126. package/dist/node/totp-06fa6909.js.map +0 -1
  127. package/dist/node-esm/totp-d5ff2369.js.map +0 -1
  128. package/dist/rn/index-ee081591.js.map +0 -1
  129. package/dist/web-extension-cjs/register-c2c7670d.js.map +0 -1
  130. package/dist/web-extension-esm2017/register-31c228e4.js.map +0 -1
@@ -737,6 +737,8 @@ declare abstract class BaseOAuthProvider extends FederatedAuthProvider implement
737
737
  */
738
738
  export declare function beforeAuthStateChanged(auth: Auth, callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
739
739
 
740
+ /* Excluded from this release type: browserCookiePersistence */
741
+
740
742
  /**
741
743
  * An implementation of {@link Persistence} of type `LOCAL` using `localStorage`
742
744
  * for the underlying storage.
@@ -2390,10 +2392,31 @@ export declare interface Persistence {
2390
2392
  * - 'SESSION' is used for temporary persistence such as `sessionStorage`.
2391
2393
  * - 'LOCAL' is used for long term persistence such as `localStorage` or `IndexedDB`.
2392
2394
  * - 'NONE' is used for in-memory, or no persistence.
2395
+ * - 'COOKIE' is used for cookie persistence, useful for server-side rendering.
2393
2396
  */
2394
- readonly type: 'SESSION' | 'LOCAL' | 'NONE';
2397
+ readonly type: 'SESSION' | 'LOCAL' | 'NONE' | 'COOKIE';
2398
+ }
2399
+
2400
+ declare interface PersistenceInternal extends Persistence {
2401
+ type: PersistenceType;
2402
+ _isAvailable(): Promise<boolean>;
2403
+ _set(key: string, value: PersistenceValue): Promise<void>;
2404
+ _get<T extends PersistenceValue>(key: string): Promise<T | null>;
2405
+ _remove(key: string): Promise<void>;
2406
+ _addListener(key: string, listener: StorageEventListener): void;
2407
+ _removeListener(key: string, listener: StorageEventListener): void;
2408
+ _shouldAllowMigration?: boolean;
2409
+ }
2410
+
2411
+ declare const enum PersistenceType {
2412
+ SESSION = "SESSION",
2413
+ LOCAL = "LOCAL",
2414
+ NONE = "NONE",
2415
+ COOKIE = "COOKIE"
2395
2416
  }
2396
2417
 
2418
+ declare type PersistenceValue = PersistedBlob | string;
2419
+
2397
2420
  /**
2398
2421
  * Represents the credentials returned by {@link PhoneAuthProvider}.
2399
2422
  *
@@ -3456,6 +3479,10 @@ declare interface StartTotpMfaEnrollmentResponse {
3456
3479
  };
3457
3480
  }
3458
3481
 
3482
+ declare interface StorageEventListener {
3483
+ (value: PersistenceValue | null): void;
3484
+ }
3485
+
3459
3486
  /* Excluded from this release type: StsTokenManager */
3460
3487
 
3461
3488
  /* Excluded from this release type: TaggedWithTokenResponse */
package/dist/auth.d.ts CHANGED
@@ -873,6 +873,7 @@ declare interface AuthInternal extends Auth {
873
873
  _canInitEmulator: boolean;
874
874
  _isInitialized: boolean;
875
875
  _initializationPromise: Promise<void> | null;
876
+ _persistenceManagerAvailable: Promise<void>;
876
877
  _updateCurrentUser(user: UserInternal | null): Promise<void>;
877
878
  _onStorageEvent(): void;
878
879
  _notifyListenersIfCurrent(user: UserInternal): void;
@@ -883,7 +884,8 @@ declare interface AuthInternal extends Auth {
883
884
  _key(): string;
884
885
  _startProactiveRefresh(): void;
885
886
  _stopProactiveRefresh(): void;
886
- _getPersistence(): string;
887
+ _getPersistenceType(): string;
888
+ _getPersistence(): PersistenceInternal;
887
889
  _getRecaptchaConfig(): RecaptchaConfig | null;
888
890
  _getPasswordPolicyInternal(): PasswordPolicyInternal | null;
889
891
  _updatePasswordPolicy(): Promise<void>;
@@ -987,6 +989,17 @@ declare abstract class BaseOAuthProvider extends FederatedAuthProvider implement
987
989
  */
988
990
  export declare function beforeAuthStateChanged(auth: Auth, callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
989
991
 
992
+ /**
993
+ * An implementation of {@link Persistence} of type `COOKIE`, for use on the client side in
994
+ * applications leveraging hybrid rendering and middleware.
995
+ *
996
+ * @remarks This persistence method requires companion middleware to function, such as that provided
997
+ * by {@link https://firebaseopensource.com/projects/firebaseextended/reactfire/ | ReactFire} for
998
+ * NextJS.
999
+ * @beta
1000
+ */
1001
+ export declare const browserCookiePersistence: Persistence;
1002
+
990
1003
  /**
991
1004
  * An implementation of {@link Persistence} of type `LOCAL` using `localStorage`
992
1005
  * for the underlying storage.
@@ -2790,10 +2803,31 @@ export declare interface Persistence {
2790
2803
  * - 'SESSION' is used for temporary persistence such as `sessionStorage`.
2791
2804
  * - 'LOCAL' is used for long term persistence such as `localStorage` or `IndexedDB`.
2792
2805
  * - 'NONE' is used for in-memory, or no persistence.
2806
+ * - 'COOKIE' is used for cookie persistence, useful for server-side rendering.
2793
2807
  */
2794
- readonly type: 'SESSION' | 'LOCAL' | 'NONE';
2808
+ readonly type: 'SESSION' | 'LOCAL' | 'NONE' | 'COOKIE';
2809
+ }
2810
+
2811
+ declare interface PersistenceInternal extends Persistence {
2812
+ type: PersistenceType;
2813
+ _isAvailable(): Promise<boolean>;
2814
+ _set(key: string, value: PersistenceValue): Promise<void>;
2815
+ _get<T extends PersistenceValue>(key: string): Promise<T | null>;
2816
+ _remove(key: string): Promise<void>;
2817
+ _addListener(key: string, listener: StorageEventListener): void;
2818
+ _removeListener(key: string, listener: StorageEventListener): void;
2819
+ _shouldAllowMigration?: boolean;
2795
2820
  }
2796
2821
 
2822
+ declare const enum PersistenceType {
2823
+ SESSION = "SESSION",
2824
+ LOCAL = "LOCAL",
2825
+ NONE = "NONE",
2826
+ COOKIE = "COOKIE"
2827
+ }
2828
+
2829
+ declare type PersistenceValue = PersistedBlob | string;
2830
+
2797
2831
  /**
2798
2832
  * Represents the credentials returned by {@link PhoneAuthProvider}.
2799
2833
  *
@@ -3955,6 +3989,10 @@ declare interface StartTotpMfaEnrollmentResponse {
3955
3989
  };
3956
3990
  }
3957
3991
 
3992
+ declare interface StorageEventListener {
3993
+ (value: PersistenceValue | null): void;
3994
+ }
3995
+
3958
3996
  /**
3959
3997
  * We need to mark this class as internal explicitly to exclude it in the public typings, because
3960
3998
  * it references AuthInternal which has a circular dependency with UserInternal.
@@ -871,6 +871,14 @@ const SERVER_ERROR_MAP = {
871
871
  * See the License for the specific language governing permissions and
872
872
  * limitations under the License.
873
873
  */
874
+ const CookieAuthProxiedEndpoints = [
875
+ "/v1/accounts:signInWithCustomToken" /* Endpoint.SIGN_IN_WITH_CUSTOM_TOKEN */,
876
+ "/v1/accounts:signInWithEmailLink" /* Endpoint.SIGN_IN_WITH_EMAIL_LINK */,
877
+ "/v1/accounts:signInWithIdp" /* Endpoint.SIGN_IN_WITH_IDP */,
878
+ "/v1/accounts:signInWithPassword" /* Endpoint.SIGN_IN_WITH_PASSWORD */,
879
+ "/v1/accounts:signInWithPhoneNumber" /* Endpoint.SIGN_IN_WITH_PHONE_NUMBER */,
880
+ "/v1/token" /* Endpoint.TOKEN */
881
+ ];
874
882
  const DEFAULT_API_TIMEOUT_MS = new Delay(30000, 60000);
875
883
  function _addTidIfNecessary(auth, request) {
876
884
  if (auth.tenantId && !request.tenantId) {
@@ -907,7 +915,7 @@ async function _performApiRequest(auth, method, path, request, customErrorMap =
907
915
  if (!util.isCloudflareWorker()) {
908
916
  fetchArgs.referrerPolicy = 'no-referrer';
909
917
  }
910
- return FetchProvider.fetch()(_getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
918
+ return FetchProvider.fetch()(await _getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
911
919
  });
912
920
  }
913
921
  async function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
@@ -972,12 +980,25 @@ async function _performSignInRequest(auth, method, path, request, customErrorMap
972
980
  }
973
981
  return serverResponse;
974
982
  }
975
- function _getFinalTarget(auth, host, path, query) {
983
+ async function _getFinalTarget(auth, host, path, query) {
976
984
  const base = `${host}${path}?${query}`;
977
- if (!auth.config.emulator) {
978
- return `${auth.config.apiScheme}://${base}`;
979
- }
980
- return _emulatorUrl(auth.config, base);
985
+ const authInternal = auth;
986
+ const finalTarget = authInternal.config.emulator
987
+ ? _emulatorUrl(auth.config, base)
988
+ : `${auth.config.apiScheme}://${base}`;
989
+ // Cookie auth works by MiTMing the signIn and token endpoints from the developer's backend,
990
+ // saving the idToken and refreshToken into cookies, and then redacting the refreshToken
991
+ // from the response
992
+ if (CookieAuthProxiedEndpoints.includes(path)) {
993
+ // Persistence manager is async, we need to await it. We can't just wait for auth initialized
994
+ // here since auth initialization calls this function.
995
+ await authInternal._persistenceManagerAvailable;
996
+ if (authInternal._getPersistenceType() === "COOKIE" /* PersistenceType.COOKIE */) {
997
+ const cookiePersistence = authInternal._getPersistence();
998
+ return cookiePersistence._getFinalTarget(finalTarget).toString();
999
+ }
1000
+ }
1001
+ return finalTarget;
981
1002
  }
982
1003
  function _parseEnforcementState(enforcementStateStr) {
983
1004
  switch (enforcementStateStr) {
@@ -1553,7 +1574,7 @@ async function requestStsToken(auth, refreshToken) {
1553
1574
  'refresh_token': refreshToken
1554
1575
  }).slice(1);
1555
1576
  const { tokenApiHost, apiKey } = auth.config;
1556
- const url = _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
1577
+ const url = await _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
1557
1578
  const headers = await auth._getAdditionalHeaders();
1558
1579
  headers["Content-Type" /* HttpHeader.CONTENT_TYPE */] = 'application/x-www-form-urlencoded';
1559
1580
  return FetchProvider.fetch()(url, {
@@ -2044,7 +2065,17 @@ class PersistenceUserManager {
2044
2065
  }
2045
2066
  async getCurrentUser() {
2046
2067
  const blob = await this.persistence._get(this.fullUserKey);
2047
- return blob ? UserImpl._fromJSON(this.auth, blob) : null;
2068
+ if (!blob) {
2069
+ return null;
2070
+ }
2071
+ if (typeof blob === 'string') {
2072
+ const response = await getAccountInfo(this.auth, { idToken: blob }).catch(() => undefined);
2073
+ if (!response) {
2074
+ return null;
2075
+ }
2076
+ return UserImpl._fromGetAccountInfoResponse(this.auth, response, blob);
2077
+ }
2078
+ return UserImpl._fromJSON(this.auth, blob);
2048
2079
  }
2049
2080
  removeCurrentUser() {
2050
2081
  return this.persistence._remove(this.fullUserKey);
@@ -2091,7 +2122,19 @@ class PersistenceUserManager {
2091
2122
  try {
2092
2123
  const blob = await persistence._get(key);
2093
2124
  if (blob) {
2094
- const user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
2125
+ let user;
2126
+ if (typeof blob === 'string') {
2127
+ const response = await getAccountInfo(auth, {
2128
+ idToken: blob
2129
+ }).catch(() => undefined);
2130
+ if (!response) {
2131
+ break;
2132
+ }
2133
+ user = await UserImpl._fromGetAccountInfoResponse(auth, response, blob);
2134
+ }
2135
+ else {
2136
+ user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
2137
+ }
2095
2138
  if (persistence !== selectedPersistence) {
2096
2139
  userToMigrate = user;
2097
2140
  }
@@ -2589,6 +2632,7 @@ class AuthImpl {
2589
2632
  this._tenantRecaptchaConfigs = {};
2590
2633
  this._projectPasswordPolicy = null;
2591
2634
  this._tenantPasswordPolicies = {};
2635
+ this._resolvePersistenceManagerAvailable = undefined;
2592
2636
  // Tracks the last notified UID for state change listeners to prevent
2593
2637
  // repeated calls to the callbacks. Undefined means it's never been
2594
2638
  // called, whereas null means it's been called with a signed out user
@@ -2599,6 +2643,9 @@ class AuthImpl {
2599
2643
  this.frameworks = [];
2600
2644
  this.name = app.name;
2601
2645
  this.clientVersion = config.sdkClientVersion;
2646
+ // TODO(jamesdaniels) explore less hacky way to do this, cookie authentication needs
2647
+ // persistenceMananger to be available. see _getFinalTarget for more context
2648
+ this._persistenceManagerAvailable = new Promise(resolve => (this._resolvePersistenceManagerAvailable = resolve));
2602
2649
  }
2603
2650
  _initializeWithPersistence(persistenceHierarchy, popupRedirectResolver) {
2604
2651
  if (popupRedirectResolver) {
@@ -2607,17 +2654,18 @@ class AuthImpl {
2607
2654
  // Have to check for app deletion throughout initialization (after each
2608
2655
  // promise resolution)
2609
2656
  this._initializationPromise = this.queue(async () => {
2610
- var _a, _b;
2657
+ var _a, _b, _c;
2611
2658
  if (this._deleted) {
2612
2659
  return;
2613
2660
  }
2614
2661
  this.persistenceManager = await PersistenceUserManager.create(this, persistenceHierarchy);
2662
+ (_a = this._resolvePersistenceManagerAvailable) === null || _a === void 0 ? void 0 : _a.call(this);
2615
2663
  if (this._deleted) {
2616
2664
  return;
2617
2665
  }
2618
2666
  // Initialize the resolver early if necessary (only applicable to web:
2619
2667
  // this will cause the iframe to load immediately in certain cases)
2620
- if ((_a = this._popupRedirectResolver) === null || _a === void 0 ? void 0 : _a._shouldInitProactively) {
2668
+ if ((_b = this._popupRedirectResolver) === null || _b === void 0 ? void 0 : _b._shouldInitProactively) {
2621
2669
  // If this fails, don't halt auth loading
2622
2670
  try {
2623
2671
  await this._popupRedirectResolver._initialize(this);
@@ -2627,7 +2675,7 @@ class AuthImpl {
2627
2675
  }
2628
2676
  }
2629
2677
  await this.initializeCurrentUser(popupRedirectResolver);
2630
- this.lastNotifiedUid = ((_b = this.currentUser) === null || _b === void 0 ? void 0 : _b.uid) || null;
2678
+ this.lastNotifiedUid = ((_c = this.currentUser) === null || _c === void 0 ? void 0 : _c.uid) || null;
2631
2679
  if (this._deleted) {
2632
2680
  return;
2633
2681
  }
@@ -2881,9 +2929,12 @@ class AuthImpl {
2881
2929
  this._tenantPasswordPolicies[this.tenantId] = passwordPolicy;
2882
2930
  }
2883
2931
  }
2884
- _getPersistence() {
2932
+ _getPersistenceType() {
2885
2933
  return this.assertedPersistence.persistence.type;
2886
2934
  }
2935
+ _getPersistence() {
2936
+ return this.assertedPersistence.persistence;
2937
+ }
2887
2938
  _updateErrorMap(errorMap) {
2888
2939
  this._errorFactory = new util.ErrorFactory('auth', 'Firebase', errorMap());
2889
2940
  }
@@ -7471,6 +7522,150 @@ BrowserLocalPersistence.type = 'LOCAL';
7471
7522
  */
7472
7523
  const browserLocalPersistence = BrowserLocalPersistence;
7473
7524
 
7525
+ /**
7526
+ * @license
7527
+ * Copyright 2025 Google LLC
7528
+ *
7529
+ * Licensed under the Apache License, Version 2.0 (the "License");
7530
+ * you may not use this file except in compliance with the License.
7531
+ * You may obtain a copy of the License at
7532
+ *
7533
+ * http://www.apache.org/licenses/LICENSE-2.0
7534
+ *
7535
+ * Unless required by applicable law or agreed to in writing, software
7536
+ * distributed under the License is distributed on an "AS IS" BASIS,
7537
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7538
+ * See the License for the specific language governing permissions and
7539
+ * limitations under the License.
7540
+ */
7541
+ const POLLING_INTERVAL_MS = 1000;
7542
+ // Pull a cookie value from document.cookie
7543
+ function getDocumentCookie(name) {
7544
+ var _a, _b;
7545
+ const escapedName = name.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
7546
+ const matcher = RegExp(`${escapedName}=([^;]+)`);
7547
+ return (_b = (_a = document.cookie.match(matcher)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null;
7548
+ }
7549
+ // Produce a sanitized cookie name from the persistence key
7550
+ function getCookieName(key) {
7551
+ // __HOST- doesn't work in localhost https://issues.chromium.org/issues/40196122 but it has
7552
+ // desirable security properties, so lets use a different cookie name while in dev-mode.
7553
+ // Already checked isSecureContext in _isAvailable, so if it's http we're hitting local.
7554
+ const isDevMode = window.location.protocol === 'http:';
7555
+ return `${isDevMode ? '__dev_' : '__HOST-'}FIREBASE_${key.split(':')[3]}`;
7556
+ }
7557
+ class CookiePersistence {
7558
+ constructor() {
7559
+ this.type = "COOKIE" /* PersistenceType.COOKIE */;
7560
+ this.listenerUnsubscribes = new Map();
7561
+ }
7562
+ // used to get the URL to the backend to proxy to
7563
+ _getFinalTarget(originalUrl) {
7564
+ if (typeof window === undefined) {
7565
+ return originalUrl;
7566
+ }
7567
+ const url = new URL(`${window.location.origin}/__cookies__`);
7568
+ url.searchParams.set('finalTarget', originalUrl);
7569
+ return url;
7570
+ }
7571
+ // To be a usable persistence method in a chain browserCookiePersistence ensures that
7572
+ // prerequisites have been met, namely that we're in a secureContext, navigator and document are
7573
+ // available and cookies are enabled. Not all UAs support these method, so fallback accordingly.
7574
+ async _isAvailable() {
7575
+ var _a;
7576
+ if (typeof isSecureContext === 'boolean' && !isSecureContext) {
7577
+ return false;
7578
+ }
7579
+ if (typeof navigator === 'undefined' || typeof document === 'undefined') {
7580
+ return false;
7581
+ }
7582
+ return (_a = navigator.cookieEnabled) !== null && _a !== void 0 ? _a : true;
7583
+ }
7584
+ // Set should be a noop as we expect middleware to handle this
7585
+ async _set(_key, _value) {
7586
+ return;
7587
+ }
7588
+ // Attempt to get the cookie from cookieStore, fallback to document.cookie
7589
+ async _get(key) {
7590
+ if (!this._isAvailable()) {
7591
+ return null;
7592
+ }
7593
+ const name = getCookieName(key);
7594
+ if (window.cookieStore) {
7595
+ const cookie = await window.cookieStore.get(name);
7596
+ return cookie === null || cookie === void 0 ? void 0 : cookie.value;
7597
+ }
7598
+ return getDocumentCookie(name);
7599
+ }
7600
+ // Log out by overriding the idToken with a sentinel value of ""
7601
+ async _remove(key) {
7602
+ if (!this._isAvailable()) {
7603
+ return;
7604
+ }
7605
+ // To make sure we don't hit signout over and over again, only do this operation if we need to
7606
+ // with the logout sentinel value of "" this can cause race conditions. Unnecessary set-cookie
7607
+ // headers will reduce CDN hit rates too.
7608
+ const existingValue = await this._get(key);
7609
+ if (!existingValue) {
7610
+ return;
7611
+ }
7612
+ const name = getCookieName(key);
7613
+ document.cookie = `${name}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`;
7614
+ await fetch(`/__cookies__`, { method: 'DELETE' }).catch(() => undefined);
7615
+ }
7616
+ // Listen for cookie changes, both cookieStore and fallback to polling document.cookie
7617
+ _addListener(key, listener) {
7618
+ if (!this._isAvailable()) {
7619
+ return;
7620
+ }
7621
+ const name = getCookieName(key);
7622
+ if (window.cookieStore) {
7623
+ const cb = ((event) => {
7624
+ const changedCookie = event.changed.find(change => change.name === name);
7625
+ if (changedCookie) {
7626
+ listener(changedCookie.value);
7627
+ }
7628
+ const deletedCookie = event.deleted.find(change => change.name === name);
7629
+ if (deletedCookie) {
7630
+ listener(null);
7631
+ }
7632
+ });
7633
+ const unsubscribe = () => window.cookieStore.removeEventListener('change', cb);
7634
+ this.listenerUnsubscribes.set(listener, unsubscribe);
7635
+ return window.cookieStore.addEventListener('change', cb);
7636
+ }
7637
+ let lastValue = getDocumentCookie(name);
7638
+ const interval = setInterval(() => {
7639
+ const currentValue = getDocumentCookie(name);
7640
+ if (currentValue !== lastValue) {
7641
+ listener(currentValue);
7642
+ lastValue = currentValue;
7643
+ }
7644
+ }, POLLING_INTERVAL_MS);
7645
+ const unsubscribe = () => clearInterval(interval);
7646
+ this.listenerUnsubscribes.set(listener, unsubscribe);
7647
+ }
7648
+ _removeListener(_key, listener) {
7649
+ const unsubscribe = this.listenerUnsubscribes.get(listener);
7650
+ if (!unsubscribe) {
7651
+ return;
7652
+ }
7653
+ unsubscribe();
7654
+ this.listenerUnsubscribes.delete(listener);
7655
+ }
7656
+ }
7657
+ CookiePersistence.type = 'COOKIE';
7658
+ /**
7659
+ * An implementation of {@link Persistence} of type `COOKIE`, for use on the client side in
7660
+ * applications leveraging hybrid rendering and middleware.
7661
+ *
7662
+ * @remarks This persistence method requires companion middleware to function, such as that provided
7663
+ * by {@link https://firebaseopensource.com/projects/firebaseextended/reactfire/ | ReactFire} for
7664
+ * NextJS.
7665
+ * @beta
7666
+ */
7667
+ const browserCookiePersistence = CookiePersistence;
7668
+
7474
7669
  /**
7475
7670
  * @license
7476
7671
  * Copyright 2020 Google LLC
@@ -10681,7 +10876,7 @@ function _isEmptyString(input) {
10681
10876
  }
10682
10877
 
10683
10878
  var name = "@firebase/auth";
10684
- var version = "1.9.1";
10879
+ var version = "1.10.0";
10685
10880
 
10686
10881
  /**
10687
10882
  * @license
@@ -10982,6 +11177,7 @@ exports._overrideRedirectResult = _overrideRedirectResult;
10982
11177
  exports._persistenceKeyName = _persistenceKeyName;
10983
11178
  exports.applyActionCode = applyActionCode;
10984
11179
  exports.beforeAuthStateChanged = beforeAuthStateChanged;
11180
+ exports.browserCookiePersistence = browserCookiePersistence;
10985
11181
  exports.browserLocalPersistence = browserLocalPersistence;
10986
11182
  exports.browserPopupRedirectResolver = browserPopupRedirectResolver;
10987
11183
  exports.browserSessionPersistence = browserSessionPersistence;
@@ -11042,4 +11238,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
11042
11238
  exports.validatePassword = validatePassword;
11043
11239
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
11044
11240
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
11045
- //# sourceMappingURL=index-018c7ebd.js.map
11241
+ //# sourceMappingURL=index-eddc1dc3.js.map