@firebase/auth 0.19.12 → 0.20.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/CHANGELOG.md +13 -0
- package/dist/auth-public.d.ts +30 -0
- package/dist/auth.d.ts +38 -1
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal/index.d.ts +1 -0
- package/dist/cordova/internal.js +3 -2
- package/dist/cordova/internal.js.map +1 -1
- package/dist/cordova/{popup_redirect-fd81f644.js → popup_redirect-1228b67a.js} +203 -43
- package/dist/cordova/popup_redirect-1228b67a.js.map +1 -0
- package/dist/cordova/src/core/auth/auth_impl.d.ts +3 -1
- package/dist/cordova/src/core/auth/middleware.d.ts +25 -0
- package/dist/cordova/src/core/auth/middleware.test.d.ts +17 -0
- package/dist/cordova/src/core/errors.d.ts +7 -1
- package/dist/cordova/src/core/index.d.ts +11 -0
- package/dist/cordova/src/core/strategies/redirect.d.ts +1 -0
- package/dist/cordova/src/model/popup_redirect.d.ts +2 -0
- package/dist/cordova/src/model/public_types.d.ts +10 -0
- package/dist/cordova/test/integration/flows/middleware_test_generator.d.ts +18 -0
- package/dist/cordova/test/integration/webdriver/util/functions.d.ts +4 -0
- package/dist/esm2017/{index-7078a255.js → index-815f1b87.js} +143 -18
- package/dist/esm2017/index-815f1b87.js.map +1 -0
- package/dist/esm2017/index.js +1 -1
- package/dist/esm2017/internal/index.d.ts +1 -0
- package/dist/esm2017/internal.js +3 -2
- package/dist/esm2017/internal.js.map +1 -1
- package/dist/esm2017/src/core/auth/auth_impl.d.ts +3 -1
- package/dist/esm2017/src/core/auth/middleware.d.ts +25 -0
- package/dist/esm2017/src/core/auth/middleware.test.d.ts +17 -0
- package/dist/esm2017/src/core/errors.d.ts +7 -1
- package/dist/esm2017/src/core/index.d.ts +11 -0
- package/dist/esm2017/src/core/strategies/redirect.d.ts +1 -0
- package/dist/esm2017/src/model/popup_redirect.d.ts +2 -0
- package/dist/esm2017/src/model/public_types.d.ts +10 -0
- package/dist/esm2017/test/integration/flows/middleware_test_generator.d.ts +18 -0
- package/dist/esm2017/test/integration/webdriver/util/functions.d.ts +4 -0
- package/dist/esm5/{index-7a476dcd.js → index-dc27d95e.js} +203 -43
- package/dist/esm5/index-dc27d95e.js.map +1 -0
- package/dist/esm5/index.js +1 -1
- package/dist/esm5/internal/index.d.ts +1 -0
- package/dist/esm5/internal.js +3 -2
- package/dist/esm5/internal.js.map +1 -1
- package/dist/esm5/src/core/auth/auth_impl.d.ts +3 -1
- package/dist/esm5/src/core/auth/middleware.d.ts +25 -0
- package/dist/esm5/src/core/auth/middleware.test.d.ts +17 -0
- package/dist/esm5/src/core/errors.d.ts +7 -1
- package/dist/esm5/src/core/index.d.ts +11 -0
- package/dist/esm5/src/core/strategies/redirect.d.ts +1 -0
- package/dist/esm5/src/model/popup_redirect.d.ts +2 -0
- package/dist/esm5/src/model/public_types.d.ts +10 -0
- package/dist/esm5/test/integration/flows/middleware_test_generator.d.ts +18 -0
- package/dist/esm5/test/integration/webdriver/util/functions.d.ts +4 -0
- package/dist/index.webworker.esm5.js +198 -42
- package/dist/index.webworker.esm5.js.map +1 -1
- package/dist/internal/index.d.ts +1 -0
- package/dist/node/{index-eabd3e6c.js → index-ec34877a.js} +199 -42
- package/dist/node/index-ec34877a.js.map +1 -0
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/internal/index.d.ts +1 -0
- package/dist/node/internal.js +7 -1
- package/dist/node/internal.js.map +1 -1
- package/dist/node/src/core/auth/auth_impl.d.ts +3 -1
- package/dist/node/src/core/auth/middleware.d.ts +25 -0
- package/dist/node/src/core/auth/middleware.test.d.ts +17 -0
- package/dist/node/src/core/errors.d.ts +7 -1
- package/dist/node/src/core/index.d.ts +11 -0
- package/dist/node/src/core/strategies/redirect.d.ts +1 -0
- package/dist/node/src/model/popup_redirect.d.ts +2 -0
- package/dist/node/src/model/public_types.d.ts +10 -0
- package/dist/node/test/integration/flows/middleware_test_generator.d.ts +18 -0
- package/dist/node/test/integration/webdriver/util/functions.d.ts +4 -0
- package/dist/node-esm/{index-d709908a.js → index-c85cf380.js} +139 -18
- package/dist/node-esm/index-c85cf380.js.map +1 -0
- package/dist/node-esm/index.js +1 -1
- package/dist/node-esm/internal/index.d.ts +1 -0
- package/dist/node-esm/internal.js +7 -3
- package/dist/node-esm/internal.js.map +1 -1
- package/dist/node-esm/src/core/auth/auth_impl.d.ts +3 -1
- package/dist/node-esm/src/core/auth/middleware.d.ts +25 -0
- package/dist/node-esm/src/core/auth/middleware.test.d.ts +17 -0
- package/dist/node-esm/src/core/errors.d.ts +7 -1
- package/dist/node-esm/src/core/index.d.ts +11 -0
- package/dist/node-esm/src/core/strategies/redirect.d.ts +1 -0
- package/dist/node-esm/src/model/popup_redirect.d.ts +2 -0
- package/dist/node-esm/src/model/public_types.d.ts +10 -0
- package/dist/node-esm/test/integration/flows/middleware_test_generator.d.ts +18 -0
- package/dist/node-esm/test/integration/webdriver/util/functions.d.ts +4 -0
- package/dist/rn/index.js +2 -1
- package/dist/rn/index.js.map +1 -1
- package/dist/rn/internal/index.d.ts +1 -0
- package/dist/rn/internal.js +8 -1
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/{phone-eec7f987.js → phone-ae029e3c.js} +199 -42
- package/dist/rn/phone-ae029e3c.js.map +1 -0
- package/dist/rn/src/core/auth/auth_impl.d.ts +3 -1
- package/dist/rn/src/core/auth/middleware.d.ts +25 -0
- package/dist/rn/src/core/auth/middleware.test.d.ts +17 -0
- package/dist/rn/src/core/errors.d.ts +7 -1
- package/dist/rn/src/core/index.d.ts +11 -0
- package/dist/rn/src/core/strategies/redirect.d.ts +1 -0
- package/dist/rn/src/model/popup_redirect.d.ts +2 -0
- package/dist/rn/src/model/public_types.d.ts +10 -0
- package/dist/rn/test/integration/flows/middleware_test_generator.d.ts +18 -0
- package/dist/rn/test/integration/webdriver/util/functions.d.ts +4 -0
- package/dist/src/core/auth/auth_impl.d.ts +3 -1
- package/dist/src/core/auth/middleware.d.ts +25 -0
- package/dist/src/core/auth/middleware.test.d.ts +17 -0
- package/dist/src/core/errors.d.ts +7 -1
- package/dist/src/core/index.d.ts +11 -0
- package/dist/src/core/strategies/redirect.d.ts +1 -0
- package/dist/src/model/popup_redirect.d.ts +2 -0
- package/dist/src/model/public_types.d.ts +10 -0
- package/dist/test/integration/flows/middleware_test_generator.d.ts +18 -0
- package/dist/test/integration/webdriver/util/functions.d.ts +4 -0
- package/package.json +6 -6
- package/dist/cordova/popup_redirect-fd81f644.js.map +0 -1
- package/dist/esm2017/index-7078a255.js.map +0 -1
- package/dist/esm5/index-7a476dcd.js.map +0 -1
- package/dist/node/index-eabd3e6c.js.map +0 -1
- package/dist/node-esm/index-d709908a.js.map +0 -1
- package/dist/rn/phone-eec7f987.js.map +0 -1
package/dist/internal/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { TaggedWithTokenResponse } from '../src/model/id_token';
|
|
|
35
35
|
export { _fail, _assert } from '../src/core/util/assert';
|
|
36
36
|
export { AuthPopup } from '../src/platform_browser/util/popup';
|
|
37
37
|
export { _getRedirectResult } from '../src/platform_browser/strategies/redirect';
|
|
38
|
+
export { _overrideRedirectResult } from '../src/core/strategies/redirect';
|
|
38
39
|
export { cordovaPopupRedirectResolver } from '../src/platform_cordova/popup_redirect/popup_redirect';
|
|
39
40
|
export { FetchProvider } from '../src/core/util/fetch_provider';
|
|
40
41
|
export { SAMLAuthCredential } from '../src/core/credentials/saml';
|
|
@@ -222,6 +222,7 @@ function _debugErrorMap() {
|
|
|
222
222
|
'Please fix by going to the Auth email templates section in the Firebase Console.',
|
|
223
223
|
_a["invalid-verification-id" /* INVALID_SESSION_INFO */] = 'The verification ID used to create the phone auth credential is invalid.',
|
|
224
224
|
_a["invalid-tenant-id" /* INVALID_TENANT_ID */] = "The Auth instance's tenant ID is invalid.",
|
|
225
|
+
_a["login-blocked" /* LOGIN_BLOCKED */] = "Login blocked by user-provided method: {$originalMessage}",
|
|
225
226
|
_a["missing-android-pkg-name" /* MISSING_ANDROID_PACKAGE_NAME */] = 'An Android Package Name must be provided if the Android App is required to be installed.',
|
|
226
227
|
_a["auth-domain-config-required" /* MISSING_AUTH_DOMAIN */] = 'Be sure to include authDomain when calling firebase.initializeApp(), ' +
|
|
227
228
|
'by following the instructions in the Firebase console.',
|
|
@@ -2471,6 +2472,104 @@ function _getClientVersion(clientPlatform, frameworks) {
|
|
|
2471
2472
|
return reportedPlatform + "/" + "JsCore" /* CORE */ + "/" + app.SDK_VERSION + "/" + reportedFrameworks;
|
|
2472
2473
|
}
|
|
2473
2474
|
|
|
2475
|
+
/**
|
|
2476
|
+
* @license
|
|
2477
|
+
* Copyright 2022 Google LLC
|
|
2478
|
+
*
|
|
2479
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2480
|
+
* you may not use this file except in compliance with the License.
|
|
2481
|
+
* You may obtain a copy of the License at
|
|
2482
|
+
*
|
|
2483
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2484
|
+
*
|
|
2485
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2486
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2487
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2488
|
+
* See the License for the specific language governing permissions and
|
|
2489
|
+
* limitations under the License.
|
|
2490
|
+
*/
|
|
2491
|
+
var AuthMiddlewareQueue = /** @class */ (function () {
|
|
2492
|
+
function AuthMiddlewareQueue(auth) {
|
|
2493
|
+
this.auth = auth;
|
|
2494
|
+
this.queue = [];
|
|
2495
|
+
}
|
|
2496
|
+
AuthMiddlewareQueue.prototype.pushCallback = function (callback, onAbort) {
|
|
2497
|
+
var _this = this;
|
|
2498
|
+
// The callback could be sync or async. Wrap it into a
|
|
2499
|
+
// function that is always async.
|
|
2500
|
+
var wrappedCallback = function (user) { return new Promise(function (resolve, reject) {
|
|
2501
|
+
try {
|
|
2502
|
+
var result = callback(user);
|
|
2503
|
+
// Either resolve with existing promise or wrap a non-promise
|
|
2504
|
+
// return value into a promise.
|
|
2505
|
+
resolve(result);
|
|
2506
|
+
}
|
|
2507
|
+
catch (e) {
|
|
2508
|
+
// Sync callback throws.
|
|
2509
|
+
reject(e);
|
|
2510
|
+
}
|
|
2511
|
+
}); };
|
|
2512
|
+
// Attach the onAbort if present
|
|
2513
|
+
wrappedCallback.onAbort = onAbort;
|
|
2514
|
+
this.queue.push(wrappedCallback);
|
|
2515
|
+
var index = this.queue.length - 1;
|
|
2516
|
+
return function () {
|
|
2517
|
+
// Unsubscribe. Replace with no-op. Do not remove from array, or it will disturb
|
|
2518
|
+
// indexing of other elements.
|
|
2519
|
+
_this.queue[index] = function () { return Promise.resolve(); };
|
|
2520
|
+
};
|
|
2521
|
+
};
|
|
2522
|
+
AuthMiddlewareQueue.prototype.runMiddleware = function (nextUser) {
|
|
2523
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2524
|
+
var onAbortStack, _i, _a, beforeStateCallback, e_1, _b, onAbortStack_1, onAbort;
|
|
2525
|
+
return tslib.__generator(this, function (_c) {
|
|
2526
|
+
switch (_c.label) {
|
|
2527
|
+
case 0:
|
|
2528
|
+
if (this.auth.currentUser === nextUser) {
|
|
2529
|
+
return [2 /*return*/];
|
|
2530
|
+
}
|
|
2531
|
+
onAbortStack = [];
|
|
2532
|
+
_c.label = 1;
|
|
2533
|
+
case 1:
|
|
2534
|
+
_c.trys.push([1, 6, , 7]);
|
|
2535
|
+
_i = 0, _a = this.queue;
|
|
2536
|
+
_c.label = 2;
|
|
2537
|
+
case 2:
|
|
2538
|
+
if (!(_i < _a.length)) return [3 /*break*/, 5];
|
|
2539
|
+
beforeStateCallback = _a[_i];
|
|
2540
|
+
return [4 /*yield*/, beforeStateCallback(nextUser)];
|
|
2541
|
+
case 3:
|
|
2542
|
+
_c.sent();
|
|
2543
|
+
// Only push the onAbort if the callback succeeds
|
|
2544
|
+
if (beforeStateCallback.onAbort) {
|
|
2545
|
+
onAbortStack.push(beforeStateCallback.onAbort);
|
|
2546
|
+
}
|
|
2547
|
+
_c.label = 4;
|
|
2548
|
+
case 4:
|
|
2549
|
+
_i++;
|
|
2550
|
+
return [3 /*break*/, 2];
|
|
2551
|
+
case 5: return [3 /*break*/, 7];
|
|
2552
|
+
case 6:
|
|
2553
|
+
e_1 = _c.sent();
|
|
2554
|
+
// Run all onAbort, with separate try/catch to ignore any errors and
|
|
2555
|
+
// continue
|
|
2556
|
+
onAbortStack.reverse();
|
|
2557
|
+
for (_b = 0, onAbortStack_1 = onAbortStack; _b < onAbortStack_1.length; _b++) {
|
|
2558
|
+
onAbort = onAbortStack_1[_b];
|
|
2559
|
+
try {
|
|
2560
|
+
onAbort();
|
|
2561
|
+
}
|
|
2562
|
+
catch (_) { /* swallow error */ }
|
|
2563
|
+
}
|
|
2564
|
+
throw this.auth._errorFactory.create("login-blocked" /* LOGIN_BLOCKED */, { originalMessage: e_1.message });
|
|
2565
|
+
case 7: return [2 /*return*/];
|
|
2566
|
+
}
|
|
2567
|
+
});
|
|
2568
|
+
});
|
|
2569
|
+
};
|
|
2570
|
+
return AuthMiddlewareQueue;
|
|
2571
|
+
}());
|
|
2572
|
+
|
|
2474
2573
|
/**
|
|
2475
2574
|
* @license
|
|
2476
2575
|
* Copyright 2020 Google LLC
|
|
@@ -2497,6 +2596,7 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2497
2596
|
this.operations = Promise.resolve();
|
|
2498
2597
|
this.authStateSubscription = new Subscription(this);
|
|
2499
2598
|
this.idTokenSubscription = new Subscription(this);
|
|
2599
|
+
this.beforeStateQueue = new AuthMiddlewareQueue(this);
|
|
2500
2600
|
this.redirectUser = null;
|
|
2501
2601
|
this.isProactiveRefreshEnabled = false;
|
|
2502
2602
|
// Any network calls will set this to true and prevent subsequent emulator
|
|
@@ -2598,9 +2698,11 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2598
2698
|
return [2 /*return*/];
|
|
2599
2699
|
case 3:
|
|
2600
2700
|
// Update current Auth state. Either a new login or logout.
|
|
2601
|
-
|
|
2701
|
+
// Skip blocking callbacks, they should not apply to a change in another tab.
|
|
2702
|
+
return [4 /*yield*/, this._updateCurrentUser(user, /* skipBeforeStateCallbacks */ true)];
|
|
2602
2703
|
case 4:
|
|
2603
2704
|
// Update current Auth state. Either a new login or logout.
|
|
2705
|
+
// Skip blocking callbacks, they should not apply to a change in another tab.
|
|
2604
2706
|
_a.sent();
|
|
2605
2707
|
return [2 /*return*/];
|
|
2606
2708
|
}
|
|
@@ -2610,18 +2712,20 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2610
2712
|
AuthImpl.prototype.initializeCurrentUser = function (popupRedirectResolver) {
|
|
2611
2713
|
var _a;
|
|
2612
2714
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2613
|
-
var
|
|
2715
|
+
var previouslyStoredUser, futureCurrentUser, needsTocheckMiddleware, redirectUserEventId, storedUserEventId, result, e_2;
|
|
2614
2716
|
return tslib.__generator(this, function (_b) {
|
|
2615
2717
|
switch (_b.label) {
|
|
2616
2718
|
case 0: return [4 /*yield*/, this.assertedPersistence.getCurrentUser()];
|
|
2617
2719
|
case 1:
|
|
2618
|
-
|
|
2720
|
+
previouslyStoredUser = (_b.sent());
|
|
2721
|
+
futureCurrentUser = previouslyStoredUser;
|
|
2722
|
+
needsTocheckMiddleware = false;
|
|
2619
2723
|
if (!(popupRedirectResolver && this.config.authDomain)) return [3 /*break*/, 4];
|
|
2620
2724
|
return [4 /*yield*/, this.getOrInitRedirectPersistenceManager()];
|
|
2621
2725
|
case 2:
|
|
2622
2726
|
_b.sent();
|
|
2623
2727
|
redirectUserEventId = (_a = this.redirectUser) === null || _a === void 0 ? void 0 : _a._redirectEventId;
|
|
2624
|
-
storedUserEventId =
|
|
2728
|
+
storedUserEventId = futureCurrentUser === null || futureCurrentUser === void 0 ? void 0 : futureCurrentUser._redirectEventId;
|
|
2625
2729
|
return [4 /*yield*/, this.tryRedirectSignIn(popupRedirectResolver)];
|
|
2626
2730
|
case 3:
|
|
2627
2731
|
result = _b.sent();
|
|
@@ -2631,32 +2735,51 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2631
2735
|
// TODO(samgho): More thoroughly test all of this
|
|
2632
2736
|
if ((!redirectUserEventId || redirectUserEventId === storedUserEventId) &&
|
|
2633
2737
|
(result === null || result === void 0 ? void 0 : result.user)) {
|
|
2634
|
-
|
|
2738
|
+
futureCurrentUser = result.user;
|
|
2739
|
+
needsTocheckMiddleware = true;
|
|
2635
2740
|
}
|
|
2636
2741
|
_b.label = 4;
|
|
2637
2742
|
case 4:
|
|
2638
2743
|
// If no user in persistence, there is no current user. Set to null.
|
|
2639
|
-
if (!
|
|
2744
|
+
if (!futureCurrentUser) {
|
|
2640
2745
|
return [2 /*return*/, this.directlySetCurrentUser(null)];
|
|
2641
2746
|
}
|
|
2642
|
-
if (
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2747
|
+
if (!!futureCurrentUser._redirectEventId) return [3 /*break*/, 9];
|
|
2748
|
+
if (!needsTocheckMiddleware) return [3 /*break*/, 8];
|
|
2749
|
+
_b.label = 5;
|
|
2750
|
+
case 5:
|
|
2751
|
+
_b.trys.push([5, 7, , 8]);
|
|
2752
|
+
return [4 /*yield*/, this.beforeStateQueue.runMiddleware(futureCurrentUser)];
|
|
2753
|
+
case 6:
|
|
2754
|
+
_b.sent();
|
|
2755
|
+
return [3 /*break*/, 8];
|
|
2756
|
+
case 7:
|
|
2757
|
+
e_2 = _b.sent();
|
|
2758
|
+
futureCurrentUser = previouslyStoredUser;
|
|
2759
|
+
// We know this is available since the bit is only set when the
|
|
2760
|
+
// resolver is available
|
|
2761
|
+
this._popupRedirectResolver._overrideRedirectResult(this, function () { return Promise.reject(e_2); });
|
|
2762
|
+
return [3 /*break*/, 8];
|
|
2763
|
+
case 8:
|
|
2764
|
+
if (futureCurrentUser) {
|
|
2765
|
+
return [2 /*return*/, this.reloadAndSetCurrentUserOrClear(futureCurrentUser)];
|
|
2766
|
+
}
|
|
2767
|
+
else {
|
|
2768
|
+
return [2 /*return*/, this.directlySetCurrentUser(null)];
|
|
2647
2769
|
}
|
|
2770
|
+
case 9:
|
|
2648
2771
|
_assert(this._popupRedirectResolver, this, "argument-error" /* ARGUMENT_ERROR */);
|
|
2649
2772
|
return [4 /*yield*/, this.getOrInitRedirectPersistenceManager()];
|
|
2650
|
-
case
|
|
2773
|
+
case 10:
|
|
2651
2774
|
_b.sent();
|
|
2652
2775
|
// If the redirect user's event ID matches the current user's event ID,
|
|
2653
2776
|
// DO NOT reload the current user, otherwise they'll be cleared from storage.
|
|
2654
2777
|
// This is important for the reauthenticateWithRedirect() flow.
|
|
2655
2778
|
if (this.redirectUser &&
|
|
2656
|
-
this.redirectUser._redirectEventId ===
|
|
2657
|
-
return [2 /*return*/, this.directlySetCurrentUser(
|
|
2779
|
+
this.redirectUser._redirectEventId === futureCurrentUser._redirectEventId) {
|
|
2780
|
+
return [2 /*return*/, this.directlySetCurrentUser(futureCurrentUser)];
|
|
2658
2781
|
}
|
|
2659
|
-
return [2 /*return*/, this.reloadAndSetCurrentUserOrClear(
|
|
2782
|
+
return [2 /*return*/, this.reloadAndSetCurrentUserOrClear(futureCurrentUser)];
|
|
2660
2783
|
}
|
|
2661
2784
|
});
|
|
2662
2785
|
});
|
|
@@ -2694,7 +2817,7 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2694
2817
|
};
|
|
2695
2818
|
AuthImpl.prototype.reloadAndSetCurrentUserOrClear = function (user) {
|
|
2696
2819
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2697
|
-
var
|
|
2820
|
+
var e_4;
|
|
2698
2821
|
return tslib.__generator(this, function (_a) {
|
|
2699
2822
|
switch (_a.label) {
|
|
2700
2823
|
case 0:
|
|
@@ -2704,8 +2827,8 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2704
2827
|
_a.sent();
|
|
2705
2828
|
return [3 /*break*/, 3];
|
|
2706
2829
|
case 2:
|
|
2707
|
-
|
|
2708
|
-
if (
|
|
2830
|
+
e_4 = _a.sent();
|
|
2831
|
+
if (e_4.code !== "auth/" + "network-request-failed" /* NETWORK_REQUEST_FAILED */) {
|
|
2709
2832
|
// Something's wrong with the user's token. Log them out and remove
|
|
2710
2833
|
// them from storage
|
|
2711
2834
|
return [2 /*return*/, this.directlySetCurrentUser(null)];
|
|
@@ -2741,27 +2864,36 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2741
2864
|
});
|
|
2742
2865
|
});
|
|
2743
2866
|
};
|
|
2744
|
-
AuthImpl.prototype._updateCurrentUser = function (user) {
|
|
2867
|
+
AuthImpl.prototype._updateCurrentUser = function (user, skipBeforeStateCallbacks) {
|
|
2868
|
+
if (skipBeforeStateCallbacks === void 0) { skipBeforeStateCallbacks = false; }
|
|
2745
2869
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2746
2870
|
var _this = this;
|
|
2747
2871
|
return tslib.__generator(this, function (_a) {
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2872
|
+
switch (_a.label) {
|
|
2873
|
+
case 0:
|
|
2874
|
+
if (this._deleted) {
|
|
2875
|
+
return [2 /*return*/];
|
|
2876
|
+
}
|
|
2877
|
+
if (user) {
|
|
2878
|
+
_assert(this.tenantId === user.tenantId, this, "tenant-id-mismatch" /* TENANT_ID_MISMATCH */);
|
|
2879
|
+
}
|
|
2880
|
+
if (!!skipBeforeStateCallbacks) return [3 /*break*/, 2];
|
|
2881
|
+
return [4 /*yield*/, this.beforeStateQueue.runMiddleware(user)];
|
|
2882
|
+
case 1:
|
|
2883
|
+
_a.sent();
|
|
2884
|
+
_a.label = 2;
|
|
2885
|
+
case 2: return [2 /*return*/, this.queue(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
2886
|
+
return tslib.__generator(this, function (_a) {
|
|
2887
|
+
switch (_a.label) {
|
|
2888
|
+
case 0: return [4 /*yield*/, this.directlySetCurrentUser(user)];
|
|
2889
|
+
case 1:
|
|
2890
|
+
_a.sent();
|
|
2891
|
+
this.notifyAuthListeners();
|
|
2892
|
+
return [2 /*return*/];
|
|
2893
|
+
}
|
|
2894
|
+
});
|
|
2895
|
+
}); })];
|
|
2753
2896
|
}
|
|
2754
|
-
return [2 /*return*/, this.queue(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
2755
|
-
return tslib.__generator(this, function (_a) {
|
|
2756
|
-
switch (_a.label) {
|
|
2757
|
-
case 0: return [4 /*yield*/, this.directlySetCurrentUser(user)];
|
|
2758
|
-
case 1:
|
|
2759
|
-
_a.sent();
|
|
2760
|
-
this.notifyAuthListeners();
|
|
2761
|
-
return [2 /*return*/];
|
|
2762
|
-
}
|
|
2763
|
-
});
|
|
2764
|
-
}); })];
|
|
2765
2897
|
});
|
|
2766
2898
|
});
|
|
2767
2899
|
};
|
|
@@ -2769,13 +2901,21 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2769
2901
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2770
2902
|
return tslib.__generator(this, function (_a) {
|
|
2771
2903
|
switch (_a.label) {
|
|
2772
|
-
case 0:
|
|
2773
|
-
|
|
2774
|
-
|
|
2904
|
+
case 0:
|
|
2905
|
+
// Run first, to block _setRedirectUser() if any callbacks fail.
|
|
2906
|
+
return [4 /*yield*/, this.beforeStateQueue.runMiddleware(null)];
|
|
2775
2907
|
case 1:
|
|
2908
|
+
// Run first, to block _setRedirectUser() if any callbacks fail.
|
|
2776
2909
|
_a.sent();
|
|
2777
|
-
|
|
2778
|
-
|
|
2910
|
+
if (!(this.redirectPersistenceManager || this._popupRedirectResolver)) return [3 /*break*/, 3];
|
|
2911
|
+
return [4 /*yield*/, this._setRedirectUser(null)];
|
|
2912
|
+
case 2:
|
|
2913
|
+
_a.sent();
|
|
2914
|
+
_a.label = 3;
|
|
2915
|
+
case 3:
|
|
2916
|
+
// Prevent callbacks from being called again in _updateCurrentUser, as
|
|
2917
|
+
// they were already called in the first line.
|
|
2918
|
+
return [2 /*return*/, this._updateCurrentUser(null, /* skipBeforeStateCallbacks */ true)];
|
|
2779
2919
|
}
|
|
2780
2920
|
});
|
|
2781
2921
|
});
|
|
@@ -2802,6 +2942,9 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2802
2942
|
AuthImpl.prototype.onAuthStateChanged = function (nextOrObserver, error, completed) {
|
|
2803
2943
|
return this.registerStateListener(this.authStateSubscription, nextOrObserver, error, completed);
|
|
2804
2944
|
};
|
|
2945
|
+
AuthImpl.prototype.beforeAuthStateChanged = function (callback, onAbort) {
|
|
2946
|
+
return this.beforeStateQueue.pushCallback(callback, onAbort);
|
|
2947
|
+
};
|
|
2805
2948
|
AuthImpl.prototype.onIdTokenChanged = function (nextOrObserver, error, completed) {
|
|
2806
2949
|
return this.registerStateListener(this.idTokenSubscription, nextOrObserver, error, completed);
|
|
2807
2950
|
};
|
|
@@ -6530,6 +6673,19 @@ function setPersistence(auth, persistence) {
|
|
|
6530
6673
|
function onIdTokenChanged(auth, nextOrObserver, error, completed) {
|
|
6531
6674
|
return util.getModularInstance(auth).onIdTokenChanged(nextOrObserver, error, completed);
|
|
6532
6675
|
}
|
|
6676
|
+
/**
|
|
6677
|
+
* Adds a blocking callback that runs before an auth state change
|
|
6678
|
+
* sets a new user.
|
|
6679
|
+
*
|
|
6680
|
+
* @param auth - The {@link Auth} instance.
|
|
6681
|
+
* @param callback - callback triggered before new user value is set.
|
|
6682
|
+
* If this throws, it blocks the user from being set.
|
|
6683
|
+
* @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
|
|
6684
|
+
* callback throws, allowing you to undo any side effects.
|
|
6685
|
+
*/
|
|
6686
|
+
function beforeAuthStateChanged(auth, callback, onAbort) {
|
|
6687
|
+
return util.getModularInstance(auth).beforeAuthStateChanged(callback, onAbort);
|
|
6688
|
+
}
|
|
6533
6689
|
/**
|
|
6534
6690
|
* Adds an observer for changes to the user's sign-in state.
|
|
6535
6691
|
*
|
|
@@ -6890,7 +7046,7 @@ function multiFactor(user) {
|
|
|
6890
7046
|
}
|
|
6891
7047
|
|
|
6892
7048
|
var name = "@firebase/auth";
|
|
6893
|
-
var version = "0.
|
|
7049
|
+
var version = "0.20.0";
|
|
6894
7050
|
|
|
6895
7051
|
/**
|
|
6896
7052
|
* @license
|
|
@@ -7188,6 +7344,7 @@ exports._persistenceKeyName = _persistenceKeyName;
|
|
|
7188
7344
|
exports._reauthenticate = _reauthenticate;
|
|
7189
7345
|
exports._signInWithCredential = _signInWithCredential;
|
|
7190
7346
|
exports.applyActionCode = applyActionCode;
|
|
7347
|
+
exports.beforeAuthStateChanged = beforeAuthStateChanged;
|
|
7191
7348
|
exports.browserLocalPersistence = browserLocalPersistence;
|
|
7192
7349
|
exports.browserPopupRedirectResolver = browserPopupRedirectResolver;
|
|
7193
7350
|
exports.browserSessionPersistence = browserSessionPersistence;
|
|
@@ -7246,4 +7403,4 @@ exports.updateProfile = updateProfile;
|
|
|
7246
7403
|
exports.useDeviceLanguage = useDeviceLanguage;
|
|
7247
7404
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
7248
7405
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
7249
|
-
//# sourceMappingURL=index-
|
|
7406
|
+
//# sourceMappingURL=index-ec34877a.js.map
|