@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.
- package/dist/auth-public.d.ts +28 -1
- package/dist/auth.d.ts +40 -2
- package/dist/browser-cjs/{index-018c7ebd.js → index-eddc1dc3.js} +211 -15
- package/dist/browser-cjs/index-eddc1dc3.js.map +1 -0
- package/dist/browser-cjs/index.d.ts +2 -1
- package/dist/browser-cjs/index.js +2 -1
- package/dist/browser-cjs/index.js.map +1 -1
- package/dist/browser-cjs/internal.js +2 -1
- package/dist/browser-cjs/internal.js.map +1 -1
- package/dist/browser-cjs/src/api/index.d.ts +1 -1
- package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/browser-cjs/src/core/persistence/index.d.ts +2 -1
- package/dist/browser-cjs/src/model/auth.d.ts +4 -1
- package/dist/browser-cjs/src/model/public_types.d.ts +2 -1
- package/dist/browser-cjs/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/browser-cjs/src/platform_node/index.d.ts +1 -0
- package/dist/cordova/auth-cordova-public.d.ts +26 -1
- package/dist/cordova/auth-cordova.d.ts +29 -2
- package/dist/cordova/index.d.ts +2 -1
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal.js +147 -3
- package/dist/cordova/internal.js.map +1 -1
- package/dist/cordova/{popup_redirect-e795474a.js → popup_redirect-5323ec00.js} +66 -15
- package/dist/cordova/popup_redirect-5323ec00.js.map +1 -0
- package/dist/cordova/src/api/index.d.ts +1 -1
- package/dist/cordova/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/cordova/src/core/persistence/index.d.ts +2 -1
- package/dist/cordova/src/model/auth.d.ts +4 -1
- package/dist/cordova/src/model/public_types.d.ts +2 -1
- package/dist/cordova/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/cordova/src/platform_node/index.d.ts +1 -0
- package/dist/esm2017/{index-e84cf44d.js → index-c92d61ad.js} +211 -16
- package/dist/esm2017/index-c92d61ad.js.map +1 -0
- package/dist/esm2017/index.d.ts +2 -1
- package/dist/esm2017/index.js +1 -1
- package/dist/esm2017/internal.js +2 -2
- package/dist/esm2017/src/api/index.d.ts +1 -1
- package/dist/esm2017/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/esm2017/src/core/persistence/index.d.ts +2 -1
- package/dist/esm2017/src/model/auth.d.ts +4 -1
- package/dist/esm2017/src/model/public_types.d.ts +2 -1
- package/dist/esm2017/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/esm2017/src/platform_node/index.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.webworker.js +65 -14
- package/dist/index.webworker.js.map +1 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/internal.js +2 -1
- package/dist/node/internal.js.map +1 -1
- package/dist/node/src/api/index.d.ts +1 -1
- package/dist/node/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/node/src/core/persistence/index.d.ts +2 -1
- package/dist/node/src/model/auth.d.ts +4 -1
- package/dist/node/src/model/public_types.d.ts +2 -1
- package/dist/node/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/node/src/platform_node/index.d.ts +1 -0
- package/dist/node/{totp-06fa6909.js → totp-af329771.js} +68 -15
- package/dist/node/totp-af329771.js.map +1 -0
- package/dist/node-esm/index.d.ts +2 -1
- package/dist/node-esm/index.js +1 -1
- package/dist/node-esm/internal.js +2 -2
- package/dist/node-esm/internal.js.map +1 -1
- package/dist/node-esm/src/api/index.d.ts +1 -1
- package/dist/node-esm/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/node-esm/src/core/persistence/index.d.ts +2 -1
- package/dist/node-esm/src/model/auth.d.ts +4 -1
- package/dist/node-esm/src/model/public_types.d.ts +2 -1
- package/dist/node-esm/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/node-esm/src/platform_node/index.d.ts +1 -0
- package/dist/node-esm/{totp-d5ff2369.js → totp-7829abf2.js} +68 -16
- package/dist/node-esm/totp-7829abf2.js.map +1 -0
- package/dist/rn/{index-ee081591.js → index-e8d5e0fb.js} +66 -15
- package/dist/rn/index-e8d5e0fb.js.map +1 -0
- package/dist/rn/index.d.ts +2 -1
- package/dist/rn/index.js +1 -1
- package/dist/rn/internal.js +146 -1
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/src/api/index.d.ts +1 -1
- package/dist/rn/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/rn/src/core/persistence/index.d.ts +2 -1
- package/dist/rn/src/model/auth.d.ts +4 -1
- package/dist/rn/src/model/public_types.d.ts +2 -1
- package/dist/rn/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/rn/src/platform_node/index.d.ts +1 -0
- package/dist/src/api/index.d.ts +1 -1
- package/dist/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/src/core/persistence/index.d.ts +2 -1
- package/dist/src/model/auth.d.ts +4 -1
- package/dist/src/model/public_types.d.ts +2 -1
- package/dist/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/src/platform_node/index.d.ts +1 -0
- package/dist/web-extension-cjs/index.d.ts +2 -1
- package/dist/web-extension-cjs/index.js +1 -1
- package/dist/web-extension-cjs/internal.js +146 -1
- package/dist/web-extension-cjs/internal.js.map +1 -1
- package/dist/web-extension-cjs/{register-c2c7670d.js → register-b64ddc5e.js} +66 -15
- package/dist/web-extension-cjs/register-b64ddc5e.js.map +1 -0
- package/dist/web-extension-cjs/src/api/index.d.ts +1 -1
- package/dist/web-extension-cjs/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/web-extension-cjs/src/core/persistence/index.d.ts +2 -1
- package/dist/web-extension-cjs/src/model/auth.d.ts +4 -1
- package/dist/web-extension-cjs/src/model/public_types.d.ts +2 -1
- package/dist/web-extension-cjs/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/web-extension-cjs/src/platform_node/index.d.ts +1 -0
- package/dist/web-extension-esm2017/auth-web-extension-public.d.ts +26 -1
- package/dist/web-extension-esm2017/auth-web-extension.d.ts +29 -2
- package/dist/web-extension-esm2017/index.d.ts +2 -1
- package/dist/web-extension-esm2017/index.js +2 -2
- package/dist/web-extension-esm2017/internal.js +147 -3
- package/dist/web-extension-esm2017/internal.js.map +1 -1
- package/dist/web-extension-esm2017/{register-31c228e4.js → register-00522d81.js} +66 -15
- package/dist/web-extension-esm2017/register-00522d81.js.map +1 -0
- package/dist/web-extension-esm2017/src/api/index.d.ts +1 -1
- package/dist/web-extension-esm2017/src/core/auth/auth_impl.d.ts +4 -1
- package/dist/web-extension-esm2017/src/core/persistence/index.d.ts +2 -1
- package/dist/web-extension-esm2017/src/model/auth.d.ts +4 -1
- package/dist/web-extension-esm2017/src/model/public_types.d.ts +2 -1
- package/dist/web-extension-esm2017/src/platform_browser/persistence/cookie_storage.d.ts +40 -0
- package/dist/web-extension-esm2017/src/platform_node/index.d.ts +1 -0
- package/package.json +3 -2
- package/dist/browser-cjs/index-018c7ebd.js.map +0 -1
- package/dist/cordova/popup_redirect-e795474a.js.map +0 -1
- package/dist/esm2017/index-e84cf44d.js.map +0 -1
- package/dist/node/totp-06fa6909.js.map +0 -1
- package/dist/node-esm/totp-d5ff2369.js.map +0 -1
- package/dist/rn/index-ee081591.js.map +0 -1
- package/dist/web-extension-cjs/register-c2c7670d.js.map +0 -1
- package/dist/web-extension-esm2017/register-31c228e4.js.map +0 -1
|
@@ -91,7 +91,7 @@ export declare function _addTidIfNecessary<T extends {
|
|
|
91
91
|
export declare function _performApiRequest<T, V>(auth: Auth, method: HttpMethod, path: Endpoint, request?: T, customErrorMap?: Partial<ServerErrorMap<ServerError>>): Promise<V>;
|
|
92
92
|
export declare function _performFetchWithErrorHandling<V>(auth: Auth, customErrorMap: Partial<ServerErrorMap<ServerError>>, fetchFn: () => Promise<Response>): Promise<V>;
|
|
93
93
|
export declare function _performSignInRequest<T, V extends IdTokenResponse>(auth: Auth, method: HttpMethod, path: Endpoint, request?: T, customErrorMap?: Partial<ServerErrorMap<ServerError>>): Promise<V>;
|
|
94
|
-
export declare function _getFinalTarget(auth: Auth, host: string, path: string, query: string): string
|
|
94
|
+
export declare function _getFinalTarget(auth: Auth, host: string, path: string, query: string): Promise<string>;
|
|
95
95
|
export declare function _parseEnforcementState(enforcementStateStr: string): EnforcementState;
|
|
96
96
|
interface PotentialResponse extends IdTokenResponse {
|
|
97
97
|
email?: string;
|
|
@@ -57,6 +57,8 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
|
|
|
57
57
|
_tenantRecaptchaConfigs: Record<string, RecaptchaConfig>;
|
|
58
58
|
_projectPasswordPolicy: PasswordPolicyInternal | null;
|
|
59
59
|
_tenantPasswordPolicies: Record<string, PasswordPolicyInternal>;
|
|
60
|
+
_resolvePersistenceManagerAvailable: ((value: void | PromiseLike<void>) => void) | undefined;
|
|
61
|
+
_persistenceManagerAvailable: Promise<void>;
|
|
60
62
|
readonly name: string;
|
|
61
63
|
private lastNotifiedUid;
|
|
62
64
|
languageCode: string | null;
|
|
@@ -82,7 +84,8 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
|
|
|
82
84
|
validatePassword(password: string): Promise<PasswordValidationStatus>;
|
|
83
85
|
_getPasswordPolicyInternal(): PasswordPolicyInternal | null;
|
|
84
86
|
_updatePasswordPolicy(): Promise<void>;
|
|
85
|
-
|
|
87
|
+
_getPersistenceType(): string;
|
|
88
|
+
_getPersistence(): PersistenceInternal;
|
|
86
89
|
_updateErrorMap(errorMap: AuthErrorMap): void;
|
|
87
90
|
onAuthStateChanged(nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
|
|
88
91
|
beforeAuthStateChanged(callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
|
|
@@ -18,7 +18,8 @@ import { Persistence } from '../../model/public_types';
|
|
|
18
18
|
export declare const enum PersistenceType {
|
|
19
19
|
SESSION = "SESSION",
|
|
20
20
|
LOCAL = "LOCAL",
|
|
21
|
-
NONE = "NONE"
|
|
21
|
+
NONE = "NONE",
|
|
22
|
+
COOKIE = "COOKIE"
|
|
22
23
|
}
|
|
23
24
|
export type PersistedBlob = Record<string, unknown>;
|
|
24
25
|
export interface Instantiator<T> {
|
|
@@ -22,6 +22,7 @@ import { UserInternal } from './user';
|
|
|
22
22
|
import { ClientPlatform } from '../core/util/version';
|
|
23
23
|
import { RecaptchaConfig } from '../platform_browser/recaptcha/recaptcha';
|
|
24
24
|
import { PasswordPolicyInternal } from './password_policy';
|
|
25
|
+
import { PersistenceInternal } from '../core/persistence';
|
|
25
26
|
export type AppName = string;
|
|
26
27
|
export type ApiKey = string;
|
|
27
28
|
export type AuthDomain = string;
|
|
@@ -56,6 +57,7 @@ export interface AuthInternal extends Auth {
|
|
|
56
57
|
_canInitEmulator: boolean;
|
|
57
58
|
_isInitialized: boolean;
|
|
58
59
|
_initializationPromise: Promise<void> | null;
|
|
60
|
+
_persistenceManagerAvailable: Promise<void>;
|
|
59
61
|
_updateCurrentUser(user: UserInternal | null): Promise<void>;
|
|
60
62
|
_onStorageEvent(): void;
|
|
61
63
|
_notifyListenersIfCurrent(user: UserInternal): void;
|
|
@@ -66,7 +68,8 @@ export interface AuthInternal extends Auth {
|
|
|
66
68
|
_key(): string;
|
|
67
69
|
_startProactiveRefresh(): void;
|
|
68
70
|
_stopProactiveRefresh(): void;
|
|
69
|
-
|
|
71
|
+
_getPersistenceType(): string;
|
|
72
|
+
_getPersistence(): PersistenceInternal;
|
|
70
73
|
_getRecaptchaConfig(): RecaptchaConfig | null;
|
|
71
74
|
_getPasswordPolicyInternal(): PasswordPolicyInternal | null;
|
|
72
75
|
_updatePasswordPolicy(): Promise<void>;
|
|
@@ -305,8 +305,9 @@ export interface Persistence {
|
|
|
305
305
|
* - 'SESSION' is used for temporary persistence such as `sessionStorage`.
|
|
306
306
|
* - 'LOCAL' is used for long term persistence such as `localStorage` or `IndexedDB`.
|
|
307
307
|
* - 'NONE' is used for in-memory, or no persistence.
|
|
308
|
+
* - 'COOKIE' is used for cookie persistence, useful for server-side rendering.
|
|
308
309
|
*/
|
|
309
|
-
readonly type: 'SESSION' | 'LOCAL' | 'NONE';
|
|
310
|
+
readonly type: 'SESSION' | 'LOCAL' | 'NONE' | 'COOKIE';
|
|
310
311
|
}
|
|
311
312
|
/**
|
|
312
313
|
* Interface representing ID token result obtained from {@link User.getIdTokenResult}.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { Persistence } from '../../model/public_types';
|
|
18
|
+
import { PersistenceInternal, PersistenceType, PersistenceValue, StorageEventListener } from '../../core/persistence';
|
|
19
|
+
export declare class CookiePersistence implements PersistenceInternal {
|
|
20
|
+
static type: 'COOKIE';
|
|
21
|
+
readonly type = PersistenceType.COOKIE;
|
|
22
|
+
listenerUnsubscribes: Map<StorageEventListener, () => void>;
|
|
23
|
+
_getFinalTarget(originalUrl: string): URL | string;
|
|
24
|
+
_isAvailable(): Promise<boolean>;
|
|
25
|
+
_set(_key: string, _value: PersistenceValue): Promise<void>;
|
|
26
|
+
_get<T extends PersistenceValue>(key: string): Promise<T | null>;
|
|
27
|
+
_remove(key: string): Promise<void>;
|
|
28
|
+
_addListener(key: string, listener: StorageEventListener): void;
|
|
29
|
+
_removeListener(_key: string, listener: StorageEventListener): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* An implementation of {@link Persistence} of type `COOKIE`, for use on the client side in
|
|
33
|
+
* applications leveraging hybrid rendering and middleware.
|
|
34
|
+
*
|
|
35
|
+
* @remarks This persistence method requires companion middleware to function, such as that provided
|
|
36
|
+
* by {@link https://firebaseopensource.com/projects/firebaseextended/reactfire/ | ReactFire} for
|
|
37
|
+
* NextJS.
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
export declare const browserCookiePersistence: Persistence;
|
|
@@ -28,6 +28,7 @@ declare class FailClass {
|
|
|
28
28
|
}
|
|
29
29
|
export declare const browserLocalPersistence: import("../model/public_types").Persistence;
|
|
30
30
|
export declare const browserSessionPersistence: import("../model/public_types").Persistence;
|
|
31
|
+
export declare const browserCookiePersistence: import("../model/public_types").Persistence;
|
|
31
32
|
export declare const indexedDBLocalPersistence: import("../model/public_types").Persistence;
|
|
32
33
|
export declare const browserPopupRedirectResolver: import("@firebase/app").FirebaseError;
|
|
33
34
|
export declare const PhoneAuthProvider: typeof FailClass;
|
|
@@ -869,6 +869,14 @@ const SERVER_ERROR_MAP = {
|
|
|
869
869
|
* See the License for the specific language governing permissions and
|
|
870
870
|
* limitations under the License.
|
|
871
871
|
*/
|
|
872
|
+
const CookieAuthProxiedEndpoints = [
|
|
873
|
+
"/v1/accounts:signInWithCustomToken" /* Endpoint.SIGN_IN_WITH_CUSTOM_TOKEN */,
|
|
874
|
+
"/v1/accounts:signInWithEmailLink" /* Endpoint.SIGN_IN_WITH_EMAIL_LINK */,
|
|
875
|
+
"/v1/accounts:signInWithIdp" /* Endpoint.SIGN_IN_WITH_IDP */,
|
|
876
|
+
"/v1/accounts:signInWithPassword" /* Endpoint.SIGN_IN_WITH_PASSWORD */,
|
|
877
|
+
"/v1/accounts:signInWithPhoneNumber" /* Endpoint.SIGN_IN_WITH_PHONE_NUMBER */,
|
|
878
|
+
"/v1/token" /* Endpoint.TOKEN */
|
|
879
|
+
];
|
|
872
880
|
const DEFAULT_API_TIMEOUT_MS = new Delay(30000, 60000);
|
|
873
881
|
function _addTidIfNecessary(auth, request) {
|
|
874
882
|
if (auth.tenantId && !request.tenantId) {
|
|
@@ -905,7 +913,7 @@ async function _performApiRequest(auth, method, path, request, customErrorMap =
|
|
|
905
913
|
if (!isCloudflareWorker()) {
|
|
906
914
|
fetchArgs.referrerPolicy = 'no-referrer';
|
|
907
915
|
}
|
|
908
|
-
return FetchProvider.fetch()(_getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
|
|
916
|
+
return FetchProvider.fetch()(await _getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
|
|
909
917
|
});
|
|
910
918
|
}
|
|
911
919
|
async function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
|
|
@@ -970,12 +978,25 @@ async function _performSignInRequest(auth, method, path, request, customErrorMap
|
|
|
970
978
|
}
|
|
971
979
|
return serverResponse;
|
|
972
980
|
}
|
|
973
|
-
function _getFinalTarget(auth, host, path, query) {
|
|
981
|
+
async function _getFinalTarget(auth, host, path, query) {
|
|
974
982
|
const base = `${host}${path}?${query}`;
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
983
|
+
const authInternal = auth;
|
|
984
|
+
const finalTarget = authInternal.config.emulator
|
|
985
|
+
? _emulatorUrl(auth.config, base)
|
|
986
|
+
: `${auth.config.apiScheme}://${base}`;
|
|
987
|
+
// Cookie auth works by MiTMing the signIn and token endpoints from the developer's backend,
|
|
988
|
+
// saving the idToken and refreshToken into cookies, and then redacting the refreshToken
|
|
989
|
+
// from the response
|
|
990
|
+
if (CookieAuthProxiedEndpoints.includes(path)) {
|
|
991
|
+
// Persistence manager is async, we need to await it. We can't just wait for auth initialized
|
|
992
|
+
// here since auth initialization calls this function.
|
|
993
|
+
await authInternal._persistenceManagerAvailable;
|
|
994
|
+
if (authInternal._getPersistenceType() === "COOKIE" /* PersistenceType.COOKIE */) {
|
|
995
|
+
const cookiePersistence = authInternal._getPersistence();
|
|
996
|
+
return cookiePersistence._getFinalTarget(finalTarget).toString();
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return finalTarget;
|
|
979
1000
|
}
|
|
980
1001
|
function _parseEnforcementState(enforcementStateStr) {
|
|
981
1002
|
switch (enforcementStateStr) {
|
|
@@ -1551,7 +1572,7 @@ async function requestStsToken(auth, refreshToken) {
|
|
|
1551
1572
|
'refresh_token': refreshToken
|
|
1552
1573
|
}).slice(1);
|
|
1553
1574
|
const { tokenApiHost, apiKey } = auth.config;
|
|
1554
|
-
const url = _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
|
|
1575
|
+
const url = await _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
|
|
1555
1576
|
const headers = await auth._getAdditionalHeaders();
|
|
1556
1577
|
headers["Content-Type" /* HttpHeader.CONTENT_TYPE */] = 'application/x-www-form-urlencoded';
|
|
1557
1578
|
return FetchProvider.fetch()(url, {
|
|
@@ -2042,7 +2063,17 @@ class PersistenceUserManager {
|
|
|
2042
2063
|
}
|
|
2043
2064
|
async getCurrentUser() {
|
|
2044
2065
|
const blob = await this.persistence._get(this.fullUserKey);
|
|
2045
|
-
|
|
2066
|
+
if (!blob) {
|
|
2067
|
+
return null;
|
|
2068
|
+
}
|
|
2069
|
+
if (typeof blob === 'string') {
|
|
2070
|
+
const response = await getAccountInfo(this.auth, { idToken: blob }).catch(() => undefined);
|
|
2071
|
+
if (!response) {
|
|
2072
|
+
return null;
|
|
2073
|
+
}
|
|
2074
|
+
return UserImpl._fromGetAccountInfoResponse(this.auth, response, blob);
|
|
2075
|
+
}
|
|
2076
|
+
return UserImpl._fromJSON(this.auth, blob);
|
|
2046
2077
|
}
|
|
2047
2078
|
removeCurrentUser() {
|
|
2048
2079
|
return this.persistence._remove(this.fullUserKey);
|
|
@@ -2089,7 +2120,19 @@ class PersistenceUserManager {
|
|
|
2089
2120
|
try {
|
|
2090
2121
|
const blob = await persistence._get(key);
|
|
2091
2122
|
if (blob) {
|
|
2092
|
-
|
|
2123
|
+
let user;
|
|
2124
|
+
if (typeof blob === 'string') {
|
|
2125
|
+
const response = await getAccountInfo(auth, {
|
|
2126
|
+
idToken: blob
|
|
2127
|
+
}).catch(() => undefined);
|
|
2128
|
+
if (!response) {
|
|
2129
|
+
break;
|
|
2130
|
+
}
|
|
2131
|
+
user = await UserImpl._fromGetAccountInfoResponse(auth, response, blob);
|
|
2132
|
+
}
|
|
2133
|
+
else {
|
|
2134
|
+
user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
|
|
2135
|
+
}
|
|
2093
2136
|
if (persistence !== selectedPersistence) {
|
|
2094
2137
|
userToMigrate = user;
|
|
2095
2138
|
}
|
|
@@ -2587,6 +2630,7 @@ class AuthImpl {
|
|
|
2587
2630
|
this._tenantRecaptchaConfigs = {};
|
|
2588
2631
|
this._projectPasswordPolicy = null;
|
|
2589
2632
|
this._tenantPasswordPolicies = {};
|
|
2633
|
+
this._resolvePersistenceManagerAvailable = undefined;
|
|
2590
2634
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2591
2635
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2592
2636
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2597,6 +2641,9 @@ class AuthImpl {
|
|
|
2597
2641
|
this.frameworks = [];
|
|
2598
2642
|
this.name = app.name;
|
|
2599
2643
|
this.clientVersion = config.sdkClientVersion;
|
|
2644
|
+
// TODO(jamesdaniels) explore less hacky way to do this, cookie authentication needs
|
|
2645
|
+
// persistenceMananger to be available. see _getFinalTarget for more context
|
|
2646
|
+
this._persistenceManagerAvailable = new Promise(resolve => (this._resolvePersistenceManagerAvailable = resolve));
|
|
2600
2647
|
}
|
|
2601
2648
|
_initializeWithPersistence(persistenceHierarchy, popupRedirectResolver) {
|
|
2602
2649
|
if (popupRedirectResolver) {
|
|
@@ -2605,17 +2652,18 @@ class AuthImpl {
|
|
|
2605
2652
|
// Have to check for app deletion throughout initialization (after each
|
|
2606
2653
|
// promise resolution)
|
|
2607
2654
|
this._initializationPromise = this.queue(async () => {
|
|
2608
|
-
var _a, _b;
|
|
2655
|
+
var _a, _b, _c;
|
|
2609
2656
|
if (this._deleted) {
|
|
2610
2657
|
return;
|
|
2611
2658
|
}
|
|
2612
2659
|
this.persistenceManager = await PersistenceUserManager.create(this, persistenceHierarchy);
|
|
2660
|
+
(_a = this._resolvePersistenceManagerAvailable) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
2613
2661
|
if (this._deleted) {
|
|
2614
2662
|
return;
|
|
2615
2663
|
}
|
|
2616
2664
|
// Initialize the resolver early if necessary (only applicable to web:
|
|
2617
2665
|
// this will cause the iframe to load immediately in certain cases)
|
|
2618
|
-
if ((
|
|
2666
|
+
if ((_b = this._popupRedirectResolver) === null || _b === void 0 ? void 0 : _b._shouldInitProactively) {
|
|
2619
2667
|
// If this fails, don't halt auth loading
|
|
2620
2668
|
try {
|
|
2621
2669
|
await this._popupRedirectResolver._initialize(this);
|
|
@@ -2625,7 +2673,7 @@ class AuthImpl {
|
|
|
2625
2673
|
}
|
|
2626
2674
|
}
|
|
2627
2675
|
await this.initializeCurrentUser(popupRedirectResolver);
|
|
2628
|
-
this.lastNotifiedUid = ((
|
|
2676
|
+
this.lastNotifiedUid = ((_c = this.currentUser) === null || _c === void 0 ? void 0 : _c.uid) || null;
|
|
2629
2677
|
if (this._deleted) {
|
|
2630
2678
|
return;
|
|
2631
2679
|
}
|
|
@@ -2879,9 +2927,12 @@ class AuthImpl {
|
|
|
2879
2927
|
this._tenantPasswordPolicies[this.tenantId] = passwordPolicy;
|
|
2880
2928
|
}
|
|
2881
2929
|
}
|
|
2882
|
-
|
|
2930
|
+
_getPersistenceType() {
|
|
2883
2931
|
return this.assertedPersistence.persistence.type;
|
|
2884
2932
|
}
|
|
2933
|
+
_getPersistence() {
|
|
2934
|
+
return this.assertedPersistence.persistence;
|
|
2935
|
+
}
|
|
2885
2936
|
_updateErrorMap(errorMap) {
|
|
2886
2937
|
this._errorFactory = new ErrorFactory('auth', 'Firebase', errorMap());
|
|
2887
2938
|
}
|
|
@@ -7469,6 +7520,150 @@ BrowserLocalPersistence.type = 'LOCAL';
|
|
|
7469
7520
|
*/
|
|
7470
7521
|
const browserLocalPersistence = BrowserLocalPersistence;
|
|
7471
7522
|
|
|
7523
|
+
/**
|
|
7524
|
+
* @license
|
|
7525
|
+
* Copyright 2025 Google LLC
|
|
7526
|
+
*
|
|
7527
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7528
|
+
* you may not use this file except in compliance with the License.
|
|
7529
|
+
* You may obtain a copy of the License at
|
|
7530
|
+
*
|
|
7531
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7532
|
+
*
|
|
7533
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7534
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7535
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7536
|
+
* See the License for the specific language governing permissions and
|
|
7537
|
+
* limitations under the License.
|
|
7538
|
+
*/
|
|
7539
|
+
const POLLING_INTERVAL_MS = 1000;
|
|
7540
|
+
// Pull a cookie value from document.cookie
|
|
7541
|
+
function getDocumentCookie(name) {
|
|
7542
|
+
var _a, _b;
|
|
7543
|
+
const escapedName = name.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
|
|
7544
|
+
const matcher = RegExp(`${escapedName}=([^;]+)`);
|
|
7545
|
+
return (_b = (_a = document.cookie.match(matcher)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null;
|
|
7546
|
+
}
|
|
7547
|
+
// Produce a sanitized cookie name from the persistence key
|
|
7548
|
+
function getCookieName(key) {
|
|
7549
|
+
// __HOST- doesn't work in localhost https://issues.chromium.org/issues/40196122 but it has
|
|
7550
|
+
// desirable security properties, so lets use a different cookie name while in dev-mode.
|
|
7551
|
+
// Already checked isSecureContext in _isAvailable, so if it's http we're hitting local.
|
|
7552
|
+
const isDevMode = window.location.protocol === 'http:';
|
|
7553
|
+
return `${isDevMode ? '__dev_' : '__HOST-'}FIREBASE_${key.split(':')[3]}`;
|
|
7554
|
+
}
|
|
7555
|
+
class CookiePersistence {
|
|
7556
|
+
constructor() {
|
|
7557
|
+
this.type = "COOKIE" /* PersistenceType.COOKIE */;
|
|
7558
|
+
this.listenerUnsubscribes = new Map();
|
|
7559
|
+
}
|
|
7560
|
+
// used to get the URL to the backend to proxy to
|
|
7561
|
+
_getFinalTarget(originalUrl) {
|
|
7562
|
+
if (typeof window === undefined) {
|
|
7563
|
+
return originalUrl;
|
|
7564
|
+
}
|
|
7565
|
+
const url = new URL(`${window.location.origin}/__cookies__`);
|
|
7566
|
+
url.searchParams.set('finalTarget', originalUrl);
|
|
7567
|
+
return url;
|
|
7568
|
+
}
|
|
7569
|
+
// To be a usable persistence method in a chain browserCookiePersistence ensures that
|
|
7570
|
+
// prerequisites have been met, namely that we're in a secureContext, navigator and document are
|
|
7571
|
+
// available and cookies are enabled. Not all UAs support these method, so fallback accordingly.
|
|
7572
|
+
async _isAvailable() {
|
|
7573
|
+
var _a;
|
|
7574
|
+
if (typeof isSecureContext === 'boolean' && !isSecureContext) {
|
|
7575
|
+
return false;
|
|
7576
|
+
}
|
|
7577
|
+
if (typeof navigator === 'undefined' || typeof document === 'undefined') {
|
|
7578
|
+
return false;
|
|
7579
|
+
}
|
|
7580
|
+
return (_a = navigator.cookieEnabled) !== null && _a !== void 0 ? _a : true;
|
|
7581
|
+
}
|
|
7582
|
+
// Set should be a noop as we expect middleware to handle this
|
|
7583
|
+
async _set(_key, _value) {
|
|
7584
|
+
return;
|
|
7585
|
+
}
|
|
7586
|
+
// Attempt to get the cookie from cookieStore, fallback to document.cookie
|
|
7587
|
+
async _get(key) {
|
|
7588
|
+
if (!this._isAvailable()) {
|
|
7589
|
+
return null;
|
|
7590
|
+
}
|
|
7591
|
+
const name = getCookieName(key);
|
|
7592
|
+
if (window.cookieStore) {
|
|
7593
|
+
const cookie = await window.cookieStore.get(name);
|
|
7594
|
+
return cookie === null || cookie === void 0 ? void 0 : cookie.value;
|
|
7595
|
+
}
|
|
7596
|
+
return getDocumentCookie(name);
|
|
7597
|
+
}
|
|
7598
|
+
// Log out by overriding the idToken with a sentinel value of ""
|
|
7599
|
+
async _remove(key) {
|
|
7600
|
+
if (!this._isAvailable()) {
|
|
7601
|
+
return;
|
|
7602
|
+
}
|
|
7603
|
+
// To make sure we don't hit signout over and over again, only do this operation if we need to
|
|
7604
|
+
// with the logout sentinel value of "" this can cause race conditions. Unnecessary set-cookie
|
|
7605
|
+
// headers will reduce CDN hit rates too.
|
|
7606
|
+
const existingValue = await this._get(key);
|
|
7607
|
+
if (!existingValue) {
|
|
7608
|
+
return;
|
|
7609
|
+
}
|
|
7610
|
+
const name = getCookieName(key);
|
|
7611
|
+
document.cookie = `${name}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`;
|
|
7612
|
+
await fetch(`/__cookies__`, { method: 'DELETE' }).catch(() => undefined);
|
|
7613
|
+
}
|
|
7614
|
+
// Listen for cookie changes, both cookieStore and fallback to polling document.cookie
|
|
7615
|
+
_addListener(key, listener) {
|
|
7616
|
+
if (!this._isAvailable()) {
|
|
7617
|
+
return;
|
|
7618
|
+
}
|
|
7619
|
+
const name = getCookieName(key);
|
|
7620
|
+
if (window.cookieStore) {
|
|
7621
|
+
const cb = ((event) => {
|
|
7622
|
+
const changedCookie = event.changed.find(change => change.name === name);
|
|
7623
|
+
if (changedCookie) {
|
|
7624
|
+
listener(changedCookie.value);
|
|
7625
|
+
}
|
|
7626
|
+
const deletedCookie = event.deleted.find(change => change.name === name);
|
|
7627
|
+
if (deletedCookie) {
|
|
7628
|
+
listener(null);
|
|
7629
|
+
}
|
|
7630
|
+
});
|
|
7631
|
+
const unsubscribe = () => window.cookieStore.removeEventListener('change', cb);
|
|
7632
|
+
this.listenerUnsubscribes.set(listener, unsubscribe);
|
|
7633
|
+
return window.cookieStore.addEventListener('change', cb);
|
|
7634
|
+
}
|
|
7635
|
+
let lastValue = getDocumentCookie(name);
|
|
7636
|
+
const interval = setInterval(() => {
|
|
7637
|
+
const currentValue = getDocumentCookie(name);
|
|
7638
|
+
if (currentValue !== lastValue) {
|
|
7639
|
+
listener(currentValue);
|
|
7640
|
+
lastValue = currentValue;
|
|
7641
|
+
}
|
|
7642
|
+
}, POLLING_INTERVAL_MS);
|
|
7643
|
+
const unsubscribe = () => clearInterval(interval);
|
|
7644
|
+
this.listenerUnsubscribes.set(listener, unsubscribe);
|
|
7645
|
+
}
|
|
7646
|
+
_removeListener(_key, listener) {
|
|
7647
|
+
const unsubscribe = this.listenerUnsubscribes.get(listener);
|
|
7648
|
+
if (!unsubscribe) {
|
|
7649
|
+
return;
|
|
7650
|
+
}
|
|
7651
|
+
unsubscribe();
|
|
7652
|
+
this.listenerUnsubscribes.delete(listener);
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
CookiePersistence.type = 'COOKIE';
|
|
7656
|
+
/**
|
|
7657
|
+
* An implementation of {@link Persistence} of type `COOKIE`, for use on the client side in
|
|
7658
|
+
* applications leveraging hybrid rendering and middleware.
|
|
7659
|
+
*
|
|
7660
|
+
* @remarks This persistence method requires companion middleware to function, such as that provided
|
|
7661
|
+
* by {@link https://firebaseopensource.com/projects/firebaseextended/reactfire/ | ReactFire} for
|
|
7662
|
+
* NextJS.
|
|
7663
|
+
* @beta
|
|
7664
|
+
*/
|
|
7665
|
+
const browserCookiePersistence = CookiePersistence;
|
|
7666
|
+
|
|
7472
7667
|
/**
|
|
7473
7668
|
* @license
|
|
7474
7669
|
* Copyright 2020 Google LLC
|
|
@@ -10679,7 +10874,7 @@ function _isEmptyString(input) {
|
|
|
10679
10874
|
}
|
|
10680
10875
|
|
|
10681
10876
|
var name = "@firebase/auth";
|
|
10682
|
-
var version = "1.
|
|
10877
|
+
var version = "1.10.0";
|
|
10683
10878
|
|
|
10684
10879
|
/**
|
|
10685
10880
|
* @license
|
|
@@ -10933,5 +11128,5 @@ _setExternalJSProvider({
|
|
|
10933
11128
|
});
|
|
10934
11129
|
registerAuth("Browser" /* ClientPlatform.BROWSER */);
|
|
10935
11130
|
|
|
10936
|
-
export {
|
|
10937
|
-
//# sourceMappingURL=index-
|
|
11131
|
+
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 };
|
|
11132
|
+
//# sourceMappingURL=index-c92d61ad.js.map
|