@firebase/auth 1.9.1 → 1.10.0-auth-redirect-credentials.82faa0828

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-d5da52c1.js} +215 -16
  4. package/dist/browser-cjs/index-d5da52c1.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-79d5de9a.js} +71 -17
  24. package/dist/cordova/popup_redirect-79d5de9a.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-fc6bc882.js} +216 -18
  33. package/dist/esm2017/index-fc6bc882.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 +70 -16
  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-88cb8aaf.js} +72 -16
  60. package/dist/node/totp-88cb8aaf.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-91f8ecc7.js} +73 -18
  73. package/dist/node-esm/totp-91f8ecc7.js.map +1 -0
  74. package/dist/rn/{index-ee081591.js → index-be8638d6.js} +70 -16
  75. package/dist/rn/index-be8638d6.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-878ee631.js} +70 -16
  99. package/dist/web-extension-cjs/register-878ee631.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-59e2f235.js} +71 -17
  114. package/dist/web-extension-esm2017/register-59e2f235.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 +8 -7
  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,10 @@ 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
+ if (auth.emulatorConfig && util.isCloudWorkstation(auth.emulatorConfig.host)) {
919
+ fetchArgs.credentials = 'include';
920
+ }
921
+ return FetchProvider.fetch()(await _getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
911
922
  });
912
923
  }
913
924
  async function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
@@ -972,12 +983,25 @@ async function _performSignInRequest(auth, method, path, request, customErrorMap
972
983
  }
973
984
  return serverResponse;
974
985
  }
975
- function _getFinalTarget(auth, host, path, query) {
986
+ async function _getFinalTarget(auth, host, path, query) {
976
987
  const base = `${host}${path}?${query}`;
977
- if (!auth.config.emulator) {
978
- return `${auth.config.apiScheme}://${base}`;
979
- }
980
- return _emulatorUrl(auth.config, base);
988
+ const authInternal = auth;
989
+ const finalTarget = authInternal.config.emulator
990
+ ? _emulatorUrl(auth.config, base)
991
+ : `${auth.config.apiScheme}://${base}`;
992
+ // Cookie auth works by MiTMing the signIn and token endpoints from the developer's backend,
993
+ // saving the idToken and refreshToken into cookies, and then redacting the refreshToken
994
+ // from the response
995
+ if (CookieAuthProxiedEndpoints.includes(path)) {
996
+ // Persistence manager is async, we need to await it. We can't just wait for auth initialized
997
+ // here since auth initialization calls this function.
998
+ await authInternal._persistenceManagerAvailable;
999
+ if (authInternal._getPersistenceType() === "COOKIE" /* PersistenceType.COOKIE */) {
1000
+ const cookiePersistence = authInternal._getPersistence();
1001
+ return cookiePersistence._getFinalTarget(finalTarget).toString();
1002
+ }
1003
+ }
1004
+ return finalTarget;
981
1005
  }
982
1006
  function _parseEnforcementState(enforcementStateStr) {
983
1007
  switch (enforcementStateStr) {
@@ -1553,7 +1577,7 @@ async function requestStsToken(auth, refreshToken) {
1553
1577
  'refresh_token': refreshToken
1554
1578
  }).slice(1);
1555
1579
  const { tokenApiHost, apiKey } = auth.config;
1556
- const url = _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
1580
+ const url = await _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
1557
1581
  const headers = await auth._getAdditionalHeaders();
1558
1582
  headers["Content-Type" /* HttpHeader.CONTENT_TYPE */] = 'application/x-www-form-urlencoded';
1559
1583
  return FetchProvider.fetch()(url, {
@@ -2044,7 +2068,17 @@ class PersistenceUserManager {
2044
2068
  }
2045
2069
  async getCurrentUser() {
2046
2070
  const blob = await this.persistence._get(this.fullUserKey);
2047
- return blob ? UserImpl._fromJSON(this.auth, blob) : null;
2071
+ if (!blob) {
2072
+ return null;
2073
+ }
2074
+ if (typeof blob === 'string') {
2075
+ const response = await getAccountInfo(this.auth, { idToken: blob }).catch(() => undefined);
2076
+ if (!response) {
2077
+ return null;
2078
+ }
2079
+ return UserImpl._fromGetAccountInfoResponse(this.auth, response, blob);
2080
+ }
2081
+ return UserImpl._fromJSON(this.auth, blob);
2048
2082
  }
2049
2083
  removeCurrentUser() {
2050
2084
  return this.persistence._remove(this.fullUserKey);
@@ -2091,7 +2125,19 @@ class PersistenceUserManager {
2091
2125
  try {
2092
2126
  const blob = await persistence._get(key);
2093
2127
  if (blob) {
2094
- const user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
2128
+ let user;
2129
+ if (typeof blob === 'string') {
2130
+ const response = await getAccountInfo(auth, {
2131
+ idToken: blob
2132
+ }).catch(() => undefined);
2133
+ if (!response) {
2134
+ break;
2135
+ }
2136
+ user = await UserImpl._fromGetAccountInfoResponse(auth, response, blob);
2137
+ }
2138
+ else {
2139
+ user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
2140
+ }
2095
2141
  if (persistence !== selectedPersistence) {
2096
2142
  userToMigrate = user;
2097
2143
  }
@@ -2589,6 +2635,7 @@ class AuthImpl {
2589
2635
  this._tenantRecaptchaConfigs = {};
2590
2636
  this._projectPasswordPolicy = null;
2591
2637
  this._tenantPasswordPolicies = {};
2638
+ this._resolvePersistenceManagerAvailable = undefined;
2592
2639
  // Tracks the last notified UID for state change listeners to prevent
2593
2640
  // repeated calls to the callbacks. Undefined means it's never been
2594
2641
  // called, whereas null means it's been called with a signed out user
@@ -2599,6 +2646,9 @@ class AuthImpl {
2599
2646
  this.frameworks = [];
2600
2647
  this.name = app.name;
2601
2648
  this.clientVersion = config.sdkClientVersion;
2649
+ // TODO(jamesdaniels) explore less hacky way to do this, cookie authentication needs
2650
+ // persistenceMananger to be available. see _getFinalTarget for more context
2651
+ this._persistenceManagerAvailable = new Promise(resolve => (this._resolvePersistenceManagerAvailable = resolve));
2602
2652
  }
2603
2653
  _initializeWithPersistence(persistenceHierarchy, popupRedirectResolver) {
2604
2654
  if (popupRedirectResolver) {
@@ -2607,17 +2657,18 @@ class AuthImpl {
2607
2657
  // Have to check for app deletion throughout initialization (after each
2608
2658
  // promise resolution)
2609
2659
  this._initializationPromise = this.queue(async () => {
2610
- var _a, _b;
2660
+ var _a, _b, _c;
2611
2661
  if (this._deleted) {
2612
2662
  return;
2613
2663
  }
2614
2664
  this.persistenceManager = await PersistenceUserManager.create(this, persistenceHierarchy);
2665
+ (_a = this._resolvePersistenceManagerAvailable) === null || _a === void 0 ? void 0 : _a.call(this);
2615
2666
  if (this._deleted) {
2616
2667
  return;
2617
2668
  }
2618
2669
  // Initialize the resolver early if necessary (only applicable to web:
2619
2670
  // this will cause the iframe to load immediately in certain cases)
2620
- if ((_a = this._popupRedirectResolver) === null || _a === void 0 ? void 0 : _a._shouldInitProactively) {
2671
+ if ((_b = this._popupRedirectResolver) === null || _b === void 0 ? void 0 : _b._shouldInitProactively) {
2621
2672
  // If this fails, don't halt auth loading
2622
2673
  try {
2623
2674
  await this._popupRedirectResolver._initialize(this);
@@ -2627,7 +2678,7 @@ class AuthImpl {
2627
2678
  }
2628
2679
  }
2629
2680
  await this.initializeCurrentUser(popupRedirectResolver);
2630
- this.lastNotifiedUid = ((_b = this.currentUser) === null || _b === void 0 ? void 0 : _b.uid) || null;
2681
+ this.lastNotifiedUid = ((_c = this.currentUser) === null || _c === void 0 ? void 0 : _c.uid) || null;
2631
2682
  if (this._deleted) {
2632
2683
  return;
2633
2684
  }
@@ -2881,9 +2932,12 @@ class AuthImpl {
2881
2932
  this._tenantPasswordPolicies[this.tenantId] = passwordPolicy;
2882
2933
  }
2883
2934
  }
2884
- _getPersistence() {
2935
+ _getPersistenceType() {
2885
2936
  return this.assertedPersistence.persistence.type;
2886
2937
  }
2938
+ _getPersistence() {
2939
+ return this.assertedPersistence.persistence;
2940
+ }
2887
2941
  _updateErrorMap(errorMap) {
2888
2942
  this._errorFactory = new util.ErrorFactory('auth', 'Firebase', errorMap());
2889
2943
  }
@@ -4448,7 +4502,7 @@ class ActionCodeURL {
4448
4502
  this.operation = operation;
4449
4503
  this.code = code;
4450
4504
  this.continueUrl = (_d = searchParams["continueUrl" /* QueryField.CONTINUE_URL */]) !== null && _d !== void 0 ? _d : null;
4451
- this.languageCode = (_e = searchParams["languageCode" /* QueryField.LANGUAGE_CODE */]) !== null && _e !== void 0 ? _e : null;
4505
+ this.languageCode = (_e = searchParams["lang" /* QueryField.LANGUAGE_CODE */]) !== null && _e !== void 0 ? _e : null;
4452
4506
  this.tenantId = (_f = searchParams["tenantId" /* QueryField.TENANT_ID */]) !== null && _f !== void 0 ? _f : null;
4453
4507
  }
4454
4508
  /**
@@ -7471,6 +7525,150 @@ BrowserLocalPersistence.type = 'LOCAL';
7471
7525
  */
7472
7526
  const browserLocalPersistence = BrowserLocalPersistence;
7473
7527
 
7528
+ /**
7529
+ * @license
7530
+ * Copyright 2025 Google LLC
7531
+ *
7532
+ * Licensed under the Apache License, Version 2.0 (the "License");
7533
+ * you may not use this file except in compliance with the License.
7534
+ * You may obtain a copy of the License at
7535
+ *
7536
+ * http://www.apache.org/licenses/LICENSE-2.0
7537
+ *
7538
+ * Unless required by applicable law or agreed to in writing, software
7539
+ * distributed under the License is distributed on an "AS IS" BASIS,
7540
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7541
+ * See the License for the specific language governing permissions and
7542
+ * limitations under the License.
7543
+ */
7544
+ const POLLING_INTERVAL_MS = 1000;
7545
+ // Pull a cookie value from document.cookie
7546
+ function getDocumentCookie(name) {
7547
+ var _a, _b;
7548
+ const escapedName = name.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
7549
+ const matcher = RegExp(`${escapedName}=([^;]+)`);
7550
+ return (_b = (_a = document.cookie.match(matcher)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null;
7551
+ }
7552
+ // Produce a sanitized cookie name from the persistence key
7553
+ function getCookieName(key) {
7554
+ // __HOST- doesn't work in localhost https://issues.chromium.org/issues/40196122 but it has
7555
+ // desirable security properties, so lets use a different cookie name while in dev-mode.
7556
+ // Already checked isSecureContext in _isAvailable, so if it's http we're hitting local.
7557
+ const isDevMode = window.location.protocol === 'http:';
7558
+ return `${isDevMode ? '__dev_' : '__HOST-'}FIREBASE_${key.split(':')[3]}`;
7559
+ }
7560
+ class CookiePersistence {
7561
+ constructor() {
7562
+ this.type = "COOKIE" /* PersistenceType.COOKIE */;
7563
+ this.listenerUnsubscribes = new Map();
7564
+ }
7565
+ // used to get the URL to the backend to proxy to
7566
+ _getFinalTarget(originalUrl) {
7567
+ if (typeof window === undefined) {
7568
+ return originalUrl;
7569
+ }
7570
+ const url = new URL(`${window.location.origin}/__cookies__`);
7571
+ url.searchParams.set('finalTarget', originalUrl);
7572
+ return url;
7573
+ }
7574
+ // To be a usable persistence method in a chain browserCookiePersistence ensures that
7575
+ // prerequisites have been met, namely that we're in a secureContext, navigator and document are
7576
+ // available and cookies are enabled. Not all UAs support these method, so fallback accordingly.
7577
+ async _isAvailable() {
7578
+ var _a;
7579
+ if (typeof isSecureContext === 'boolean' && !isSecureContext) {
7580
+ return false;
7581
+ }
7582
+ if (typeof navigator === 'undefined' || typeof document === 'undefined') {
7583
+ return false;
7584
+ }
7585
+ return (_a = navigator.cookieEnabled) !== null && _a !== void 0 ? _a : true;
7586
+ }
7587
+ // Set should be a noop as we expect middleware to handle this
7588
+ async _set(_key, _value) {
7589
+ return;
7590
+ }
7591
+ // Attempt to get the cookie from cookieStore, fallback to document.cookie
7592
+ async _get(key) {
7593
+ if (!this._isAvailable()) {
7594
+ return null;
7595
+ }
7596
+ const name = getCookieName(key);
7597
+ if (window.cookieStore) {
7598
+ const cookie = await window.cookieStore.get(name);
7599
+ return cookie === null || cookie === void 0 ? void 0 : cookie.value;
7600
+ }
7601
+ return getDocumentCookie(name);
7602
+ }
7603
+ // Log out by overriding the idToken with a sentinel value of ""
7604
+ async _remove(key) {
7605
+ if (!this._isAvailable()) {
7606
+ return;
7607
+ }
7608
+ // To make sure we don't hit signout over and over again, only do this operation if we need to
7609
+ // with the logout sentinel value of "" this can cause race conditions. Unnecessary set-cookie
7610
+ // headers will reduce CDN hit rates too.
7611
+ const existingValue = await this._get(key);
7612
+ if (!existingValue) {
7613
+ return;
7614
+ }
7615
+ const name = getCookieName(key);
7616
+ document.cookie = `${name}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`;
7617
+ await fetch(`/__cookies__`, { method: 'DELETE' }).catch(() => undefined);
7618
+ }
7619
+ // Listen for cookie changes, both cookieStore and fallback to polling document.cookie
7620
+ _addListener(key, listener) {
7621
+ if (!this._isAvailable()) {
7622
+ return;
7623
+ }
7624
+ const name = getCookieName(key);
7625
+ if (window.cookieStore) {
7626
+ const cb = ((event) => {
7627
+ const changedCookie = event.changed.find(change => change.name === name);
7628
+ if (changedCookie) {
7629
+ listener(changedCookie.value);
7630
+ }
7631
+ const deletedCookie = event.deleted.find(change => change.name === name);
7632
+ if (deletedCookie) {
7633
+ listener(null);
7634
+ }
7635
+ });
7636
+ const unsubscribe = () => window.cookieStore.removeEventListener('change', cb);
7637
+ this.listenerUnsubscribes.set(listener, unsubscribe);
7638
+ return window.cookieStore.addEventListener('change', cb);
7639
+ }
7640
+ let lastValue = getDocumentCookie(name);
7641
+ const interval = setInterval(() => {
7642
+ const currentValue = getDocumentCookie(name);
7643
+ if (currentValue !== lastValue) {
7644
+ listener(currentValue);
7645
+ lastValue = currentValue;
7646
+ }
7647
+ }, POLLING_INTERVAL_MS);
7648
+ const unsubscribe = () => clearInterval(interval);
7649
+ this.listenerUnsubscribes.set(listener, unsubscribe);
7650
+ }
7651
+ _removeListener(_key, listener) {
7652
+ const unsubscribe = this.listenerUnsubscribes.get(listener);
7653
+ if (!unsubscribe) {
7654
+ return;
7655
+ }
7656
+ unsubscribe();
7657
+ this.listenerUnsubscribes.delete(listener);
7658
+ }
7659
+ }
7660
+ CookiePersistence.type = 'COOKIE';
7661
+ /**
7662
+ * An implementation of {@link Persistence} of type `COOKIE`, for use on the client side in
7663
+ * applications leveraging hybrid rendering and middleware.
7664
+ *
7665
+ * @remarks This persistence method requires companion middleware to function, such as that provided
7666
+ * by {@link https://firebaseopensource.com/projects/firebaseextended/reactfire/ | ReactFire} for
7667
+ * NextJS.
7668
+ * @beta
7669
+ */
7670
+ const browserCookiePersistence = CookiePersistence;
7671
+
7474
7672
  /**
7475
7673
  * @license
7476
7674
  * Copyright 2020 Google LLC
@@ -10681,7 +10879,7 @@ function _isEmptyString(input) {
10681
10879
  }
10682
10880
 
10683
10881
  var name = "@firebase/auth";
10684
- var version = "1.9.1";
10882
+ var version = "1.10.0-auth-redirect-credentials.82faa0828";
10685
10883
 
10686
10884
  /**
10687
10885
  * @license
@@ -10982,6 +11180,7 @@ exports._overrideRedirectResult = _overrideRedirectResult;
10982
11180
  exports._persistenceKeyName = _persistenceKeyName;
10983
11181
  exports.applyActionCode = applyActionCode;
10984
11182
  exports.beforeAuthStateChanged = beforeAuthStateChanged;
11183
+ exports.browserCookiePersistence = browserCookiePersistence;
10985
11184
  exports.browserLocalPersistence = browserLocalPersistence;
10986
11185
  exports.browserPopupRedirectResolver = browserPopupRedirectResolver;
10987
11186
  exports.browserSessionPersistence = browserSessionPersistence;
@@ -11042,4 +11241,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
11042
11241
  exports.validatePassword = validatePassword;
11043
11242
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
11044
11243
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
11045
- //# sourceMappingURL=index-018c7ebd.js.map
11244
+ //# sourceMappingURL=index-d5da52c1.js.map