@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
|
@@ -772,6 +772,14 @@ const SERVER_ERROR_MAP = {
|
|
|
772
772
|
* See the License for the specific language governing permissions and
|
|
773
773
|
* limitations under the License.
|
|
774
774
|
*/
|
|
775
|
+
const CookieAuthProxiedEndpoints = [
|
|
776
|
+
"/v1/accounts:signInWithCustomToken" /* Endpoint.SIGN_IN_WITH_CUSTOM_TOKEN */,
|
|
777
|
+
"/v1/accounts:signInWithEmailLink" /* Endpoint.SIGN_IN_WITH_EMAIL_LINK */,
|
|
778
|
+
"/v1/accounts:signInWithIdp" /* Endpoint.SIGN_IN_WITH_IDP */,
|
|
779
|
+
"/v1/accounts:signInWithPassword" /* Endpoint.SIGN_IN_WITH_PASSWORD */,
|
|
780
|
+
"/v1/accounts:signInWithPhoneNumber" /* Endpoint.SIGN_IN_WITH_PHONE_NUMBER */,
|
|
781
|
+
"/v1/token" /* Endpoint.TOKEN */
|
|
782
|
+
];
|
|
775
783
|
const DEFAULT_API_TIMEOUT_MS = new Delay(30000, 60000);
|
|
776
784
|
function _addTidIfNecessary(auth, request) {
|
|
777
785
|
if (auth.tenantId && !request.tenantId) {
|
|
@@ -808,7 +816,7 @@ async function _performApiRequest(auth, method, path, request, customErrorMap =
|
|
|
808
816
|
if (!util.isCloudflareWorker()) {
|
|
809
817
|
fetchArgs.referrerPolicy = 'no-referrer';
|
|
810
818
|
}
|
|
811
|
-
return FetchProvider.fetch()(_getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
|
|
819
|
+
return FetchProvider.fetch()(await _getFinalTarget(auth, auth.config.apiHost, path, query), fetchArgs);
|
|
812
820
|
});
|
|
813
821
|
}
|
|
814
822
|
async function _performFetchWithErrorHandling(auth, customErrorMap, fetchFn) {
|
|
@@ -873,12 +881,25 @@ async function _performSignInRequest(auth, method, path, request, customErrorMap
|
|
|
873
881
|
}
|
|
874
882
|
return serverResponse;
|
|
875
883
|
}
|
|
876
|
-
function _getFinalTarget(auth, host, path, query) {
|
|
884
|
+
async function _getFinalTarget(auth, host, path, query) {
|
|
877
885
|
const base = `${host}${path}?${query}`;
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
886
|
+
const authInternal = auth;
|
|
887
|
+
const finalTarget = authInternal.config.emulator
|
|
888
|
+
? _emulatorUrl(auth.config, base)
|
|
889
|
+
: `${auth.config.apiScheme}://${base}`;
|
|
890
|
+
// Cookie auth works by MiTMing the signIn and token endpoints from the developer's backend,
|
|
891
|
+
// saving the idToken and refreshToken into cookies, and then redacting the refreshToken
|
|
892
|
+
// from the response
|
|
893
|
+
if (CookieAuthProxiedEndpoints.includes(path)) {
|
|
894
|
+
// Persistence manager is async, we need to await it. We can't just wait for auth initialized
|
|
895
|
+
// here since auth initialization calls this function.
|
|
896
|
+
await authInternal._persistenceManagerAvailable;
|
|
897
|
+
if (authInternal._getPersistenceType() === "COOKIE" /* PersistenceType.COOKIE */) {
|
|
898
|
+
const cookiePersistence = authInternal._getPersistence();
|
|
899
|
+
return cookiePersistence._getFinalTarget(finalTarget).toString();
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return finalTarget;
|
|
882
903
|
}
|
|
883
904
|
function _parseEnforcementState(enforcementStateStr) {
|
|
884
905
|
switch (enforcementStateStr) {
|
|
@@ -1454,7 +1475,7 @@ async function requestStsToken(auth, refreshToken) {
|
|
|
1454
1475
|
'refresh_token': refreshToken
|
|
1455
1476
|
}).slice(1);
|
|
1456
1477
|
const { tokenApiHost, apiKey } = auth.config;
|
|
1457
|
-
const url = _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
|
|
1478
|
+
const url = await _getFinalTarget(auth, tokenApiHost, "/v1/token" /* Endpoint.TOKEN */, `key=${apiKey}`);
|
|
1458
1479
|
const headers = await auth._getAdditionalHeaders();
|
|
1459
1480
|
headers["Content-Type" /* HttpHeader.CONTENT_TYPE */] = 'application/x-www-form-urlencoded';
|
|
1460
1481
|
return FetchProvider.fetch()(url, {
|
|
@@ -1945,7 +1966,17 @@ class PersistenceUserManager {
|
|
|
1945
1966
|
}
|
|
1946
1967
|
async getCurrentUser() {
|
|
1947
1968
|
const blob = await this.persistence._get(this.fullUserKey);
|
|
1948
|
-
|
|
1969
|
+
if (!blob) {
|
|
1970
|
+
return null;
|
|
1971
|
+
}
|
|
1972
|
+
if (typeof blob === 'string') {
|
|
1973
|
+
const response = await getAccountInfo(this.auth, { idToken: blob }).catch(() => undefined);
|
|
1974
|
+
if (!response) {
|
|
1975
|
+
return null;
|
|
1976
|
+
}
|
|
1977
|
+
return UserImpl._fromGetAccountInfoResponse(this.auth, response, blob);
|
|
1978
|
+
}
|
|
1979
|
+
return UserImpl._fromJSON(this.auth, blob);
|
|
1949
1980
|
}
|
|
1950
1981
|
removeCurrentUser() {
|
|
1951
1982
|
return this.persistence._remove(this.fullUserKey);
|
|
@@ -1992,7 +2023,19 @@ class PersistenceUserManager {
|
|
|
1992
2023
|
try {
|
|
1993
2024
|
const blob = await persistence._get(key);
|
|
1994
2025
|
if (blob) {
|
|
1995
|
-
|
|
2026
|
+
let user;
|
|
2027
|
+
if (typeof blob === 'string') {
|
|
2028
|
+
const response = await getAccountInfo(auth, {
|
|
2029
|
+
idToken: blob
|
|
2030
|
+
}).catch(() => undefined);
|
|
2031
|
+
if (!response) {
|
|
2032
|
+
break;
|
|
2033
|
+
}
|
|
2034
|
+
user = await UserImpl._fromGetAccountInfoResponse(auth, response, blob);
|
|
2035
|
+
}
|
|
2036
|
+
else {
|
|
2037
|
+
user = UserImpl._fromJSON(auth, blob); // throws for unparsable blob (wrong format)
|
|
2038
|
+
}
|
|
1996
2039
|
if (persistence !== selectedPersistence) {
|
|
1997
2040
|
userToMigrate = user;
|
|
1998
2041
|
}
|
|
@@ -2490,6 +2533,7 @@ class AuthImpl {
|
|
|
2490
2533
|
this._tenantRecaptchaConfigs = {};
|
|
2491
2534
|
this._projectPasswordPolicy = null;
|
|
2492
2535
|
this._tenantPasswordPolicies = {};
|
|
2536
|
+
this._resolvePersistenceManagerAvailable = undefined;
|
|
2493
2537
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2494
2538
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2495
2539
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2500,6 +2544,9 @@ class AuthImpl {
|
|
|
2500
2544
|
this.frameworks = [];
|
|
2501
2545
|
this.name = app.name;
|
|
2502
2546
|
this.clientVersion = config.sdkClientVersion;
|
|
2547
|
+
// TODO(jamesdaniels) explore less hacky way to do this, cookie authentication needs
|
|
2548
|
+
// persistenceMananger to be available. see _getFinalTarget for more context
|
|
2549
|
+
this._persistenceManagerAvailable = new Promise(resolve => (this._resolvePersistenceManagerAvailable = resolve));
|
|
2503
2550
|
}
|
|
2504
2551
|
_initializeWithPersistence(persistenceHierarchy, popupRedirectResolver) {
|
|
2505
2552
|
if (popupRedirectResolver) {
|
|
@@ -2508,17 +2555,18 @@ class AuthImpl {
|
|
|
2508
2555
|
// Have to check for app deletion throughout initialization (after each
|
|
2509
2556
|
// promise resolution)
|
|
2510
2557
|
this._initializationPromise = this.queue(async () => {
|
|
2511
|
-
var _a, _b;
|
|
2558
|
+
var _a, _b, _c;
|
|
2512
2559
|
if (this._deleted) {
|
|
2513
2560
|
return;
|
|
2514
2561
|
}
|
|
2515
2562
|
this.persistenceManager = await PersistenceUserManager.create(this, persistenceHierarchy);
|
|
2563
|
+
(_a = this._resolvePersistenceManagerAvailable) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
2516
2564
|
if (this._deleted) {
|
|
2517
2565
|
return;
|
|
2518
2566
|
}
|
|
2519
2567
|
// Initialize the resolver early if necessary (only applicable to web:
|
|
2520
2568
|
// this will cause the iframe to load immediately in certain cases)
|
|
2521
|
-
if ((
|
|
2569
|
+
if ((_b = this._popupRedirectResolver) === null || _b === void 0 ? void 0 : _b._shouldInitProactively) {
|
|
2522
2570
|
// If this fails, don't halt auth loading
|
|
2523
2571
|
try {
|
|
2524
2572
|
await this._popupRedirectResolver._initialize(this);
|
|
@@ -2528,7 +2576,7 @@ class AuthImpl {
|
|
|
2528
2576
|
}
|
|
2529
2577
|
}
|
|
2530
2578
|
await this.initializeCurrentUser(popupRedirectResolver);
|
|
2531
|
-
this.lastNotifiedUid = ((
|
|
2579
|
+
this.lastNotifiedUid = ((_c = this.currentUser) === null || _c === void 0 ? void 0 : _c.uid) || null;
|
|
2532
2580
|
if (this._deleted) {
|
|
2533
2581
|
return;
|
|
2534
2582
|
}
|
|
@@ -2782,9 +2830,12 @@ class AuthImpl {
|
|
|
2782
2830
|
this._tenantPasswordPolicies[this.tenantId] = passwordPolicy;
|
|
2783
2831
|
}
|
|
2784
2832
|
}
|
|
2785
|
-
|
|
2833
|
+
_getPersistenceType() {
|
|
2786
2834
|
return this.assertedPersistence.persistence.type;
|
|
2787
2835
|
}
|
|
2836
|
+
_getPersistence() {
|
|
2837
|
+
return this.assertedPersistence.persistence;
|
|
2838
|
+
}
|
|
2788
2839
|
_updateErrorMap(errorMap) {
|
|
2789
2840
|
this._errorFactory = new util.ErrorFactory('auth', 'Firebase', errorMap());
|
|
2790
2841
|
}
|
|
@@ -8027,7 +8078,7 @@ function _isEmptyString(input) {
|
|
|
8027
8078
|
}
|
|
8028
8079
|
|
|
8029
8080
|
var name = "@firebase/auth";
|
|
8030
|
-
var version = "1.
|
|
8081
|
+
var version = "1.10.0";
|
|
8031
8082
|
|
|
8032
8083
|
/**
|
|
8033
8084
|
* @license
|
|
@@ -8292,4 +8343,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
|
|
|
8292
8343
|
exports.validatePassword = validatePassword;
|
|
8293
8344
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
8294
8345
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
8295
|
-
//# sourceMappingURL=register-
|
|
8346
|
+
//# sourceMappingURL=register-b64ddc5e.js.map
|