@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
package/dist/esm2017/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './src/model/public_types';
|
|
|
23
23
|
export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps';
|
|
24
24
|
export * from './src';
|
|
25
25
|
import { browserLocalPersistence } from './src/platform_browser/persistence/local_storage';
|
|
26
|
+
import { browserCookiePersistence } from './src/platform_browser/persistence/cookie_storage';
|
|
26
27
|
import { browserSessionPersistence } from './src/platform_browser/persistence/session_storage';
|
|
27
28
|
import { indexedDBLocalPersistence } from './src/platform_browser/persistence/indexed_db';
|
|
28
29
|
import { PhoneAuthProvider } from './src/platform_browser/providers/phone';
|
|
@@ -34,4 +35,4 @@ import { browserPopupRedirectResolver } from './src/platform_browser/popup_redir
|
|
|
34
35
|
import { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
|
|
35
36
|
import { TotpMultiFactorGenerator, TotpSecret } from './src/mfa/assertions/totp';
|
|
36
37
|
import { getAuth } from './src/platform_browser';
|
|
37
|
-
export { browserLocalPersistence, browserSessionPersistence, indexedDBLocalPersistence, PhoneAuthProvider, signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber, signInWithPopup, linkWithPopup, reauthenticateWithPopup, signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect, getRedirectResult, RecaptchaVerifier, browserPopupRedirectResolver, PhoneMultiFactorGenerator, TotpMultiFactorGenerator, TotpSecret, getAuth };
|
|
38
|
+
export { browserLocalPersistence, browserCookiePersistence, browserSessionPersistence, indexedDBLocalPersistence, PhoneAuthProvider, signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber, signInWithPopup, linkWithPopup, reauthenticateWithPopup, signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect, getRedirectResult, RecaptchaVerifier, browserPopupRedirectResolver, PhoneMultiFactorGenerator, TotpMultiFactorGenerator, TotpSecret, getAuth };
|
package/dist/esm2017/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ActionCodeOperation,
|
|
1
|
+
export { A as ActionCodeOperation, aj as ActionCodeURL, M as AuthCredential, J as AuthErrorCodes, N as EmailAuthCredential, W as EmailAuthProvider, X as FacebookAuthProvider, F as FactorId, Z as GithubAuthProvider, Y as GoogleAuthProvider, Q as OAuthCredential, _ as OAuthProvider, O as OperationType, U as PhoneAuthCredential, P as PhoneAuthProvider, n as PhoneMultiFactorGenerator, q as ProviderId, R as RecaptchaVerifier, $ as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, o as TotpSecret, a0 as TwitterAuthProvider, a8 as applyActionCode, y as beforeAuthStateChanged, a as browserCookiePersistence, b as browserLocalPersistence, m as browserPopupRedirectResolver, c as browserSessionPersistence, a9 as checkActionCode, a7 as confirmPasswordReset, L as connectAuthEmulator, ab as createUserWithEmailAndPassword, H as debugErrorMap, G as deleteUser, ag as fetchSignInMethodsForEmail, ar as getAdditionalUserInfo, p as getAuth, ao as getIdToken, ap as getIdTokenResult, at as getMultiFactorResolver, k as getRedirectResult, V as inMemoryPersistence, i as indexedDBLocalPersistence, K as initializeAuth, v as initializeRecaptchaConfig, ae as isSignInWithEmailLink, a3 as linkWithCredential, l as linkWithPhoneNumber, e as linkWithPopup, h as linkWithRedirect, au as multiFactor, z as onAuthStateChanged, x as onIdTokenChanged, ak as parseActionCodeURL, I as prodErrorMap, a4 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, f as reauthenticateWithPopup, j as reauthenticateWithRedirect, as as reload, E as revokeAccessToken, ah as sendEmailVerification, a6 as sendPasswordResetEmail, ad as sendSignInLinkToEmail, t as setPersistence, a1 as signInAnonymously, a2 as signInWithCredential, a5 as signInWithCustomToken, ac as signInWithEmailAndPassword, af as signInWithEmailLink, s as signInWithPhoneNumber, d as signInWithPopup, g as signInWithRedirect, D as signOut, aq as unlink, C as updateCurrentUser, am as updateEmail, an as updatePassword, u as updatePhoneNumber, al as updateProfile, B as useDeviceLanguage, w as validatePassword, ai as verifyBeforeUpdateEmail, aa as verifyPasswordResetCode } from './index-c92d61ad.js';
|
|
2
2
|
import '@firebase/app';
|
|
3
3
|
import '@firebase/util';
|
|
4
4
|
import '@firebase/logger';
|
package/dist/esm2017/internal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as ActionCodeOperation,
|
|
1
|
+
import { av as debugAssert, aw as _isIOS, ax as _isAndroid, ay as _fail, az as _getRedirectUrl, aA as _getProjectConfig, aB as _isIOS7Or8, aC as _createError, aD as _assert, aE as AuthEventManager, aF as _getInstance, b as browserLocalPersistence, aG as _persistenceKeyName, c as browserSessionPersistence, aH as _getRedirectResult, aI as _overrideRedirectResult, aJ as _clearRedirectOutcomes, aK as _castAuth } from './index-c92d61ad.js';
|
|
2
|
+
export { A as ActionCodeOperation, aj as ActionCodeURL, M as AuthCredential, J as AuthErrorCodes, aM as AuthImpl, aP as AuthPopup, N as EmailAuthCredential, W as EmailAuthProvider, X as FacebookAuthProvider, F as FactorId, aQ as FetchProvider, Z as GithubAuthProvider, Y as GoogleAuthProvider, Q as OAuthCredential, _ as OAuthProvider, O as OperationType, U as PhoneAuthCredential, P as PhoneAuthProvider, n as PhoneMultiFactorGenerator, q as ProviderId, R as RecaptchaVerifier, aR as SAMLAuthCredential, $ as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, o as TotpSecret, a0 as TwitterAuthProvider, aL as UserImpl, aD as _assert, aK as _castAuth, ay as _fail, aO as _generateEventId, aN as _getClientVersion, aF as _getInstance, aH as _getRedirectResult, aI as _overrideRedirectResult, aG as _persistenceKeyName, a8 as applyActionCode, y as beforeAuthStateChanged, a as browserCookiePersistence, b as browserLocalPersistence, m as browserPopupRedirectResolver, c as browserSessionPersistence, a9 as checkActionCode, a7 as confirmPasswordReset, L as connectAuthEmulator, ab as createUserWithEmailAndPassword, H as debugErrorMap, G as deleteUser, ag as fetchSignInMethodsForEmail, ar as getAdditionalUserInfo, p as getAuth, ao as getIdToken, ap as getIdTokenResult, at as getMultiFactorResolver, k as getRedirectResult, V as inMemoryPersistence, i as indexedDBLocalPersistence, K as initializeAuth, v as initializeRecaptchaConfig, ae as isSignInWithEmailLink, a3 as linkWithCredential, l as linkWithPhoneNumber, e as linkWithPopup, h as linkWithRedirect, au as multiFactor, z as onAuthStateChanged, x as onIdTokenChanged, ak as parseActionCodeURL, I as prodErrorMap, a4 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, f as reauthenticateWithPopup, j as reauthenticateWithRedirect, as as reload, E as revokeAccessToken, ah as sendEmailVerification, a6 as sendPasswordResetEmail, ad as sendSignInLinkToEmail, t as setPersistence, a1 as signInAnonymously, a2 as signInWithCredential, a5 as signInWithCustomToken, ac as signInWithEmailAndPassword, af as signInWithEmailLink, s as signInWithPhoneNumber, d as signInWithPopup, g as signInWithRedirect, D as signOut, aq as unlink, C as updateCurrentUser, am as updateEmail, an as updatePassword, u as updatePhoneNumber, al as updateProfile, B as useDeviceLanguage, w as validatePassword, ai as verifyBeforeUpdateEmail, aa as verifyPasswordResetCode } from './index-c92d61ad.js';
|
|
3
3
|
import { querystringDecode } from '@firebase/util';
|
|
4
4
|
import '@firebase/app';
|
|
5
5
|
import '@firebase/logger';
|
|
@@ -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;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './src/model/public_types';
|
|
|
23
23
|
export { FactorId, ProviderId, SignInMethod, OperationType, ActionCodeOperation } from './src/model/enum_maps';
|
|
24
24
|
export * from './src';
|
|
25
25
|
import { browserLocalPersistence } from './src/platform_browser/persistence/local_storage';
|
|
26
|
+
import { browserCookiePersistence } from './src/platform_browser/persistence/cookie_storage';
|
|
26
27
|
import { browserSessionPersistence } from './src/platform_browser/persistence/session_storage';
|
|
27
28
|
import { indexedDBLocalPersistence } from './src/platform_browser/persistence/indexed_db';
|
|
28
29
|
import { PhoneAuthProvider } from './src/platform_browser/providers/phone';
|
|
@@ -34,4 +35,4 @@ import { browserPopupRedirectResolver } from './src/platform_browser/popup_redir
|
|
|
34
35
|
import { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
|
|
35
36
|
import { TotpMultiFactorGenerator, TotpSecret } from './src/mfa/assertions/totp';
|
|
36
37
|
import { getAuth } from './src/platform_browser';
|
|
37
|
-
export { browserLocalPersistence, browserSessionPersistence, indexedDBLocalPersistence, PhoneAuthProvider, signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber, signInWithPopup, linkWithPopup, reauthenticateWithPopup, signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect, getRedirectResult, RecaptchaVerifier, browserPopupRedirectResolver, PhoneMultiFactorGenerator, TotpMultiFactorGenerator, TotpSecret, getAuth };
|
|
38
|
+
export { browserLocalPersistence, browserCookiePersistence, browserSessionPersistence, indexedDBLocalPersistence, PhoneAuthProvider, signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber, signInWithPopup, linkWithPopup, reauthenticateWithPopup, signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect, getRedirectResult, RecaptchaVerifier, browserPopupRedirectResolver, PhoneMultiFactorGenerator, TotpMultiFactorGenerator, TotpSecret, getAuth };
|
package/dist/index.webworker.js
CHANGED
|
@@ -530,7 +530,7 @@ function _initializeAuthInstance(auth, deps) {
|
|
|
530
530
|
}
|
|
531
531
|
|
|
532
532
|
var name = "@firebase/auth";
|
|
533
|
-
var version = "1.
|
|
533
|
+
var version = "1.10.0";
|
|
534
534
|
|
|
535
535
|
/**
|
|
536
536
|
* @license
|
|
@@ -996,6 +996,14 @@ const SERVER_ERROR_MAP = {
|
|
|
996
996
|
* See the License for the specific language governing permissions and
|
|
997
997
|
* limitations under the License.
|
|
998
998
|
*/
|
|
999
|
+
const CookieAuthProxiedEndpoints = [
|
|
1000
|
+
"/v1/accounts:signInWithCustomToken" /* Endpoint.SIGN_IN_WITH_CUSTOM_TOKEN */,
|
|
1001
|
+
"/v1/accounts:signInWithEmailLink" /* Endpoint.SIGN_IN_WITH_EMAIL_LINK */,
|
|
1002
|
+
"/v1/accounts:signInWithIdp" /* Endpoint.SIGN_IN_WITH_IDP */,
|
|
1003
|
+
"/v1/accounts:signInWithPassword" /* Endpoint.SIGN_IN_WITH_PASSWORD */,
|
|
1004
|
+
"/v1/accounts:signInWithPhoneNumber" /* Endpoint.SIGN_IN_WITH_PHONE_NUMBER */,
|
|
1005
|
+
"/v1/token" /* Endpoint.TOKEN */
|
|
1006
|
+
];
|
|
999
1007
|
const DEFAULT_API_TIMEOUT_MS = new Delay(30000, 60000);
|
|
1000
1008
|
function _addTidIfNecessary(auth, request) {
|
|
1001
1009
|
if (auth.tenantId && !request.tenantId) {
|
|
@@ -1032,7 +1040,7 @@ async function _performApiRequest(auth, method, path, request, customErrorMap =
|
|
|
1032
1040
|
if (!isCloudflareWorker()) {
|
|
1033
1041
|
fetchArgs.referrerPolicy = 'no-referrer';
|
|
1034
1042
|
}
|
|
1035
|
-
return FetchProvider.fetch()(_getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
|
|
1043
|
+
return FetchProvider.fetch()(await _getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
|
|
1036
1044
|
});
|
|
1037
1045
|
}
|
|
1038
1046
|
async function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
|
|
@@ -1097,12 +1105,25 @@ async function _performSignInRequest(auth, method, path, request, customErrorMap
|
|
|
1097
1105
|
}
|
|
1098
1106
|
return serverResponse;
|
|
1099
1107
|
}
|
|
1100
|
-
function _getFinalTarget(auth, host, path, query) {
|
|
1108
|
+
async function _getFinalTarget(auth, host, path, query) {
|
|
1101
1109
|
const base = `${host}${path}?${query}`;
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1110
|
+
const authInternal = auth;
|
|
1111
|
+
const finalTarget = authInternal.config.emulator
|
|
1112
|
+
? _emulatorUrl(auth.config, base)
|
|
1113
|
+
: `${auth.config.apiScheme}://${base}`;
|
|
1114
|
+
// Cookie auth works by MiTMing the signIn and token endpoints from the developer's backend,
|
|
1115
|
+
// saving the idToken and refreshToken into cookies, and then redacting the refreshToken
|
|
1116
|
+
// from the response
|
|
1117
|
+
if (CookieAuthProxiedEndpoints.includes(path)) {
|
|
1118
|
+
// Persistence manager is async, we need to await it. We can't just wait for auth initialized
|
|
1119
|
+
// here since auth initialization calls this function.
|
|
1120
|
+
await authInternal._persistenceManagerAvailable;
|
|
1121
|
+
if (authInternal._getPersistenceType() === "COOKIE" /* PersistenceType.COOKIE */) {
|
|
1122
|
+
const cookiePersistence = authInternal._getPersistence();
|
|
1123
|
+
return cookiePersistence._getFinalTarget(finalTarget).toString();
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
return finalTarget;
|
|
1106
1127
|
}
|
|
1107
1128
|
function _parseEnforcementState(enforcementStateStr) {
|
|
1108
1129
|
switch (enforcementStateStr) {
|
|
@@ -1572,7 +1593,7 @@ async function requestStsToken(auth, refreshToken) {
|
|
|
1572
1593
|
'refresh_token': refreshToken
|
|
1573
1594
|
}).slice(1);
|
|
1574
1595
|
const { tokenApiHost, apiKey } = auth.config;
|
|
1575
|
-
const url = _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
|
|
1596
|
+
const url = await _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
|
|
1576
1597
|
const headers = await auth._getAdditionalHeaders();
|
|
1577
1598
|
headers["Content-Type" /* HttpHeader.CONTENT_TYPE */] = 'application/x-www-form-urlencoded';
|
|
1578
1599
|
return FetchProvider.fetch()(url, {
|
|
@@ -2034,7 +2055,17 @@ class PersistenceUserManager {
|
|
|
2034
2055
|
}
|
|
2035
2056
|
async getCurrentUser() {
|
|
2036
2057
|
const blob = await this.persistence._get(this.fullUserKey);
|
|
2037
|
-
|
|
2058
|
+
if (!blob) {
|
|
2059
|
+
return null;
|
|
2060
|
+
}
|
|
2061
|
+
if (typeof blob === 'string') {
|
|
2062
|
+
const response = await getAccountInfo(this.auth, { idToken: blob }).catch(() => undefined);
|
|
2063
|
+
if (!response) {
|
|
2064
|
+
return null;
|
|
2065
|
+
}
|
|
2066
|
+
return UserImpl._fromGetAccountInfoResponse(this.auth, response, blob);
|
|
2067
|
+
}
|
|
2068
|
+
return UserImpl._fromJSON(this.auth, blob);
|
|
2038
2069
|
}
|
|
2039
2070
|
removeCurrentUser() {
|
|
2040
2071
|
return this.persistence._remove(this.fullUserKey);
|
|
@@ -2081,7 +2112,19 @@ class PersistenceUserManager {
|
|
|
2081
2112
|
try {
|
|
2082
2113
|
const blob = await persistence._get(key);
|
|
2083
2114
|
if (blob) {
|
|
2084
|
-
|
|
2115
|
+
let user;
|
|
2116
|
+
if (typeof blob === 'string') {
|
|
2117
|
+
const response = await getAccountInfo(auth, {
|
|
2118
|
+
idToken: blob
|
|
2119
|
+
}).catch(() => undefined);
|
|
2120
|
+
if (!response) {
|
|
2121
|
+
break;
|
|
2122
|
+
}
|
|
2123
|
+
user = await UserImpl._fromGetAccountInfoResponse(auth, response, blob);
|
|
2124
|
+
}
|
|
2125
|
+
else {
|
|
2126
|
+
user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
|
|
2127
|
+
}
|
|
2085
2128
|
if (persistence !== selectedPersistence) {
|
|
2086
2129
|
userToMigrate = user;
|
|
2087
2130
|
}
|
|
@@ -2419,6 +2462,7 @@ class AuthImpl {
|
|
|
2419
2462
|
this._tenantRecaptchaConfigs = {};
|
|
2420
2463
|
this._projectPasswordPolicy = null;
|
|
2421
2464
|
this._tenantPasswordPolicies = {};
|
|
2465
|
+
this._resolvePersistenceManagerAvailable = undefined;
|
|
2422
2466
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2423
2467
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2424
2468
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2429,6 +2473,9 @@ class AuthImpl {
|
|
|
2429
2473
|
this.frameworks = [];
|
|
2430
2474
|
this.name = app.name;
|
|
2431
2475
|
this.clientVersion = config.sdkClientVersion;
|
|
2476
|
+
// TODO(jamesdaniels) explore less hacky way to do this, cookie authentication needs
|
|
2477
|
+
// persistenceMananger to be available. see _getFinalTarget for more context
|
|
2478
|
+
this._persistenceManagerAvailable = new Promise(resolve => (this._resolvePersistenceManagerAvailable = resolve));
|
|
2432
2479
|
}
|
|
2433
2480
|
_initializeWithPersistence(persistenceHierarchy, popupRedirectResolver) {
|
|
2434
2481
|
if (popupRedirectResolver) {
|
|
@@ -2437,17 +2484,18 @@ class AuthImpl {
|
|
|
2437
2484
|
// Have to check for app deletion throughout initialization (after each
|
|
2438
2485
|
// promise resolution)
|
|
2439
2486
|
this._initializationPromise = this.queue(async () => {
|
|
2440
|
-
var _a, _b;
|
|
2487
|
+
var _a, _b, _c;
|
|
2441
2488
|
if (this._deleted) {
|
|
2442
2489
|
return;
|
|
2443
2490
|
}
|
|
2444
2491
|
this.persistenceManager = await PersistenceUserManager.create(this, persistenceHierarchy);
|
|
2492
|
+
(_a = this._resolvePersistenceManagerAvailable) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
2445
2493
|
if (this._deleted) {
|
|
2446
2494
|
return;
|
|
2447
2495
|
}
|
|
2448
2496
|
// Initialize the resolver early if necessary (only applicable to web:
|
|
2449
2497
|
// this will cause the iframe to load immediately in certain cases)
|
|
2450
|
-
if ((
|
|
2498
|
+
if ((_b = this._popupRedirectResolver) === null || _b === void 0 ? void 0 : _b._shouldInitProactively) {
|
|
2451
2499
|
// If this fails, don't halt auth loading
|
|
2452
2500
|
try {
|
|
2453
2501
|
await this._popupRedirectResolver._initialize(this);
|
|
@@ -2457,7 +2505,7 @@ class AuthImpl {
|
|
|
2457
2505
|
}
|
|
2458
2506
|
}
|
|
2459
2507
|
await this.initializeCurrentUser(popupRedirectResolver);
|
|
2460
|
-
this.lastNotifiedUid = ((
|
|
2508
|
+
this.lastNotifiedUid = ((_c = this.currentUser) === null || _c === void 0 ? void 0 : _c.uid) || null;
|
|
2461
2509
|
if (this._deleted) {
|
|
2462
2510
|
return;
|
|
2463
2511
|
}
|
|
@@ -2711,9 +2759,12 @@ class AuthImpl {
|
|
|
2711
2759
|
this._tenantPasswordPolicies[this.tenantId] = passwordPolicy;
|
|
2712
2760
|
}
|
|
2713
2761
|
}
|
|
2714
|
-
|
|
2762
|
+
_getPersistenceType() {
|
|
2715
2763
|
return this.assertedPersistence.persistence.type;
|
|
2716
2764
|
}
|
|
2765
|
+
_getPersistence() {
|
|
2766
|
+
return this.assertedPersistence.persistence;
|
|
2767
|
+
}
|
|
2717
2768
|
_updateErrorMap(errorMap) {
|
|
2718
2769
|
this._errorFactory = new ErrorFactory('auth', 'Firebase', errorMap());
|
|
2719
2770
|
}
|