@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
|
@@ -103,6 +103,7 @@ function _debugErrorMap() {
|
|
|
103
103
|
'Please fix by going to the Auth email templates section in the Firebase Console.',
|
|
104
104
|
_a["invalid-verification-id" /* INVALID_SESSION_INFO */] = 'The verification ID used to create the phone auth credential is invalid.',
|
|
105
105
|
_a["invalid-tenant-id" /* INVALID_TENANT_ID */] = "The Auth instance's tenant ID is invalid.",
|
|
106
|
+
_a["login-blocked" /* LOGIN_BLOCKED */] = "Login blocked by user-provided method: {$originalMessage}",
|
|
106
107
|
_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.',
|
|
107
108
|
_a["auth-domain-config-required" /* MISSING_AUTH_DOMAIN */] = 'Be sure to include authDomain when calling firebase.initializeApp(), ' +
|
|
108
109
|
'by following the instructions in the Firebase console.',
|
|
@@ -2367,6 +2368,104 @@ function _getClientVersion(clientPlatform, frameworks) {
|
|
|
2367
2368
|
return reportedPlatform + "/" + "JsCore" /* CORE */ + "/" + app.SDK_VERSION + "/" + reportedFrameworks;
|
|
2368
2369
|
}
|
|
2369
2370
|
|
|
2371
|
+
/**
|
|
2372
|
+
* @license
|
|
2373
|
+
* Copyright 2022 Google LLC
|
|
2374
|
+
*
|
|
2375
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2376
|
+
* you may not use this file except in compliance with the License.
|
|
2377
|
+
* You may obtain a copy of the License at
|
|
2378
|
+
*
|
|
2379
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2380
|
+
*
|
|
2381
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2382
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2383
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2384
|
+
* See the License for the specific language governing permissions and
|
|
2385
|
+
* limitations under the License.
|
|
2386
|
+
*/
|
|
2387
|
+
var AuthMiddlewareQueue = /** @class */ (function () {
|
|
2388
|
+
function AuthMiddlewareQueue(auth) {
|
|
2389
|
+
this.auth = auth;
|
|
2390
|
+
this.queue = [];
|
|
2391
|
+
}
|
|
2392
|
+
AuthMiddlewareQueue.prototype.pushCallback = function (callback, onAbort) {
|
|
2393
|
+
var _this = this;
|
|
2394
|
+
// The callback could be sync or async. Wrap it into a
|
|
2395
|
+
// function that is always async.
|
|
2396
|
+
var wrappedCallback = function (user) { return new Promise(function (resolve, reject) {
|
|
2397
|
+
try {
|
|
2398
|
+
var result = callback(user);
|
|
2399
|
+
// Either resolve with existing promise or wrap a non-promise
|
|
2400
|
+
// return value into a promise.
|
|
2401
|
+
resolve(result);
|
|
2402
|
+
}
|
|
2403
|
+
catch (e) {
|
|
2404
|
+
// Sync callback throws.
|
|
2405
|
+
reject(e);
|
|
2406
|
+
}
|
|
2407
|
+
}); };
|
|
2408
|
+
// Attach the onAbort if present
|
|
2409
|
+
wrappedCallback.onAbort = onAbort;
|
|
2410
|
+
this.queue.push(wrappedCallback);
|
|
2411
|
+
var index = this.queue.length - 1;
|
|
2412
|
+
return function () {
|
|
2413
|
+
// Unsubscribe. Replace with no-op. Do not remove from array, or it will disturb
|
|
2414
|
+
// indexing of other elements.
|
|
2415
|
+
_this.queue[index] = function () { return Promise.resolve(); };
|
|
2416
|
+
};
|
|
2417
|
+
};
|
|
2418
|
+
AuthMiddlewareQueue.prototype.runMiddleware = function (nextUser) {
|
|
2419
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2420
|
+
var onAbortStack, _i, _a, beforeStateCallback, e_1, _b, onAbortStack_1, onAbort;
|
|
2421
|
+
return tslib.__generator(this, function (_c) {
|
|
2422
|
+
switch (_c.label) {
|
|
2423
|
+
case 0:
|
|
2424
|
+
if (this.auth.currentUser === nextUser) {
|
|
2425
|
+
return [2 /*return*/];
|
|
2426
|
+
}
|
|
2427
|
+
onAbortStack = [];
|
|
2428
|
+
_c.label = 1;
|
|
2429
|
+
case 1:
|
|
2430
|
+
_c.trys.push([1, 6, , 7]);
|
|
2431
|
+
_i = 0, _a = this.queue;
|
|
2432
|
+
_c.label = 2;
|
|
2433
|
+
case 2:
|
|
2434
|
+
if (!(_i < _a.length)) return [3 /*break*/, 5];
|
|
2435
|
+
beforeStateCallback = _a[_i];
|
|
2436
|
+
return [4 /*yield*/, beforeStateCallback(nextUser)];
|
|
2437
|
+
case 3:
|
|
2438
|
+
_c.sent();
|
|
2439
|
+
// Only push the onAbort if the callback succeeds
|
|
2440
|
+
if (beforeStateCallback.onAbort) {
|
|
2441
|
+
onAbortStack.push(beforeStateCallback.onAbort);
|
|
2442
|
+
}
|
|
2443
|
+
_c.label = 4;
|
|
2444
|
+
case 4:
|
|
2445
|
+
_i++;
|
|
2446
|
+
return [3 /*break*/, 2];
|
|
2447
|
+
case 5: return [3 /*break*/, 7];
|
|
2448
|
+
case 6:
|
|
2449
|
+
e_1 = _c.sent();
|
|
2450
|
+
// Run all onAbort, with separate try/catch to ignore any errors and
|
|
2451
|
+
// continue
|
|
2452
|
+
onAbortStack.reverse();
|
|
2453
|
+
for (_b = 0, onAbortStack_1 = onAbortStack; _b < onAbortStack_1.length; _b++) {
|
|
2454
|
+
onAbort = onAbortStack_1[_b];
|
|
2455
|
+
try {
|
|
2456
|
+
onAbort();
|
|
2457
|
+
}
|
|
2458
|
+
catch (_) { /* swallow error */ }
|
|
2459
|
+
}
|
|
2460
|
+
throw this.auth._errorFactory.create("login-blocked" /* LOGIN_BLOCKED */, { originalMessage: e_1.message });
|
|
2461
|
+
case 7: return [2 /*return*/];
|
|
2462
|
+
}
|
|
2463
|
+
});
|
|
2464
|
+
});
|
|
2465
|
+
};
|
|
2466
|
+
return AuthMiddlewareQueue;
|
|
2467
|
+
}());
|
|
2468
|
+
|
|
2370
2469
|
/**
|
|
2371
2470
|
* @license
|
|
2372
2471
|
* Copyright 2020 Google LLC
|
|
@@ -2393,6 +2492,7 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2393
2492
|
this.operations = Promise.resolve();
|
|
2394
2493
|
this.authStateSubscription = new Subscription(this);
|
|
2395
2494
|
this.idTokenSubscription = new Subscription(this);
|
|
2495
|
+
this.beforeStateQueue = new AuthMiddlewareQueue(this);
|
|
2396
2496
|
this.redirectUser = null;
|
|
2397
2497
|
this.isProactiveRefreshEnabled = false;
|
|
2398
2498
|
// Any network calls will set this to true and prevent subsequent emulator
|
|
@@ -2494,9 +2594,11 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2494
2594
|
return [2 /*return*/];
|
|
2495
2595
|
case 3:
|
|
2496
2596
|
// Update current Auth state. Either a new login or logout.
|
|
2497
|
-
|
|
2597
|
+
// Skip blocking callbacks, they should not apply to a change in another tab.
|
|
2598
|
+
return [4 /*yield*/, this._updateCurrentUser(user, /* skipBeforeStateCallbacks */ true)];
|
|
2498
2599
|
case 4:
|
|
2499
2600
|
// Update current Auth state. Either a new login or logout.
|
|
2601
|
+
// Skip blocking callbacks, they should not apply to a change in another tab.
|
|
2500
2602
|
_a.sent();
|
|
2501
2603
|
return [2 /*return*/];
|
|
2502
2604
|
}
|
|
@@ -2506,18 +2608,20 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2506
2608
|
AuthImpl.prototype.initializeCurrentUser = function (popupRedirectResolver) {
|
|
2507
2609
|
var _a;
|
|
2508
2610
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2509
|
-
var
|
|
2611
|
+
var previouslyStoredUser, futureCurrentUser, needsTocheckMiddleware, redirectUserEventId, storedUserEventId, result, e_2;
|
|
2510
2612
|
return tslib.__generator(this, function (_b) {
|
|
2511
2613
|
switch (_b.label) {
|
|
2512
2614
|
case 0: return [4 /*yield*/, this.assertedPersistence.getCurrentUser()];
|
|
2513
2615
|
case 1:
|
|
2514
|
-
|
|
2616
|
+
previouslyStoredUser = (_b.sent());
|
|
2617
|
+
futureCurrentUser = previouslyStoredUser;
|
|
2618
|
+
needsTocheckMiddleware = false;
|
|
2515
2619
|
if (!(popupRedirectResolver && this.config.authDomain)) return [3 /*break*/, 4];
|
|
2516
2620
|
return [4 /*yield*/, this.getOrInitRedirectPersistenceManager()];
|
|
2517
2621
|
case 2:
|
|
2518
2622
|
_b.sent();
|
|
2519
2623
|
redirectUserEventId = (_a = this.redirectUser) === null || _a === void 0 ? void 0 : _a._redirectEventId;
|
|
2520
|
-
storedUserEventId =
|
|
2624
|
+
storedUserEventId = futureCurrentUser === null || futureCurrentUser === void 0 ? void 0 : futureCurrentUser._redirectEventId;
|
|
2521
2625
|
return [4 /*yield*/, this.tryRedirectSignIn(popupRedirectResolver)];
|
|
2522
2626
|
case 3:
|
|
2523
2627
|
result = _b.sent();
|
|
@@ -2527,32 +2631,51 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2527
2631
|
// TODO(samgho): More thoroughly test all of this
|
|
2528
2632
|
if ((!redirectUserEventId || redirectUserEventId === storedUserEventId) &&
|
|
2529
2633
|
(result === null || result === void 0 ? void 0 : result.user)) {
|
|
2530
|
-
|
|
2634
|
+
futureCurrentUser = result.user;
|
|
2635
|
+
needsTocheckMiddleware = true;
|
|
2531
2636
|
}
|
|
2532
2637
|
_b.label = 4;
|
|
2533
2638
|
case 4:
|
|
2534
2639
|
// If no user in persistence, there is no current user. Set to null.
|
|
2535
|
-
if (!
|
|
2640
|
+
if (!futureCurrentUser) {
|
|
2536
2641
|
return [2 /*return*/, this.directlySetCurrentUser(null)];
|
|
2537
2642
|
}
|
|
2538
|
-
if (
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2643
|
+
if (!!futureCurrentUser._redirectEventId) return [3 /*break*/, 9];
|
|
2644
|
+
if (!needsTocheckMiddleware) return [3 /*break*/, 8];
|
|
2645
|
+
_b.label = 5;
|
|
2646
|
+
case 5:
|
|
2647
|
+
_b.trys.push([5, 7, , 8]);
|
|
2648
|
+
return [4 /*yield*/, this.beforeStateQueue.runMiddleware(futureCurrentUser)];
|
|
2649
|
+
case 6:
|
|
2650
|
+
_b.sent();
|
|
2651
|
+
return [3 /*break*/, 8];
|
|
2652
|
+
case 7:
|
|
2653
|
+
e_2 = _b.sent();
|
|
2654
|
+
futureCurrentUser = previouslyStoredUser;
|
|
2655
|
+
// We know this is available since the bit is only set when the
|
|
2656
|
+
// resolver is available
|
|
2657
|
+
this._popupRedirectResolver._overrideRedirectResult(this, function () { return Promise.reject(e_2); });
|
|
2658
|
+
return [3 /*break*/, 8];
|
|
2659
|
+
case 8:
|
|
2660
|
+
if (futureCurrentUser) {
|
|
2661
|
+
return [2 /*return*/, this.reloadAndSetCurrentUserOrClear(futureCurrentUser)];
|
|
2662
|
+
}
|
|
2663
|
+
else {
|
|
2664
|
+
return [2 /*return*/, this.directlySetCurrentUser(null)];
|
|
2543
2665
|
}
|
|
2666
|
+
case 9:
|
|
2544
2667
|
_assert(this._popupRedirectResolver, this, "argument-error" /* ARGUMENT_ERROR */);
|
|
2545
2668
|
return [4 /*yield*/, this.getOrInitRedirectPersistenceManager()];
|
|
2546
|
-
case
|
|
2669
|
+
case 10:
|
|
2547
2670
|
_b.sent();
|
|
2548
2671
|
// If the redirect user's event ID matches the current user's event ID,
|
|
2549
2672
|
// DO NOT reload the current user, otherwise they'll be cleared from storage.
|
|
2550
2673
|
// This is important for the reauthenticateWithRedirect() flow.
|
|
2551
2674
|
if (this.redirectUser &&
|
|
2552
|
-
this.redirectUser._redirectEventId ===
|
|
2553
|
-
return [2 /*return*/, this.directlySetCurrentUser(
|
|
2675
|
+
this.redirectUser._redirectEventId === futureCurrentUser._redirectEventId) {
|
|
2676
|
+
return [2 /*return*/, this.directlySetCurrentUser(futureCurrentUser)];
|
|
2554
2677
|
}
|
|
2555
|
-
return [2 /*return*/, this.reloadAndSetCurrentUserOrClear(
|
|
2678
|
+
return [2 /*return*/, this.reloadAndSetCurrentUserOrClear(futureCurrentUser)];
|
|
2556
2679
|
}
|
|
2557
2680
|
});
|
|
2558
2681
|
});
|
|
@@ -2590,7 +2713,7 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2590
2713
|
};
|
|
2591
2714
|
AuthImpl.prototype.reloadAndSetCurrentUserOrClear = function (user) {
|
|
2592
2715
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2593
|
-
var
|
|
2716
|
+
var e_4;
|
|
2594
2717
|
return tslib.__generator(this, function (_a) {
|
|
2595
2718
|
switch (_a.label) {
|
|
2596
2719
|
case 0:
|
|
@@ -2600,8 +2723,8 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2600
2723
|
_a.sent();
|
|
2601
2724
|
return [3 /*break*/, 3];
|
|
2602
2725
|
case 2:
|
|
2603
|
-
|
|
2604
|
-
if (
|
|
2726
|
+
e_4 = _a.sent();
|
|
2727
|
+
if (e_4.code !== "auth/" + "network-request-failed" /* NETWORK_REQUEST_FAILED */) {
|
|
2605
2728
|
// Something's wrong with the user's token. Log them out and remove
|
|
2606
2729
|
// them from storage
|
|
2607
2730
|
return [2 /*return*/, this.directlySetCurrentUser(null)];
|
|
@@ -2637,27 +2760,36 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2637
2760
|
});
|
|
2638
2761
|
});
|
|
2639
2762
|
};
|
|
2640
|
-
AuthImpl.prototype._updateCurrentUser = function (user) {
|
|
2763
|
+
AuthImpl.prototype._updateCurrentUser = function (user, skipBeforeStateCallbacks) {
|
|
2764
|
+
if (skipBeforeStateCallbacks === void 0) { skipBeforeStateCallbacks = false; }
|
|
2641
2765
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2642
2766
|
var _this = this;
|
|
2643
2767
|
return tslib.__generator(this, function (_a) {
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2768
|
+
switch (_a.label) {
|
|
2769
|
+
case 0:
|
|
2770
|
+
if (this._deleted) {
|
|
2771
|
+
return [2 /*return*/];
|
|
2772
|
+
}
|
|
2773
|
+
if (user) {
|
|
2774
|
+
_assert(this.tenantId === user.tenantId, this, "tenant-id-mismatch" /* TENANT_ID_MISMATCH */);
|
|
2775
|
+
}
|
|
2776
|
+
if (!!skipBeforeStateCallbacks) return [3 /*break*/, 2];
|
|
2777
|
+
return [4 /*yield*/, this.beforeStateQueue.runMiddleware(user)];
|
|
2778
|
+
case 1:
|
|
2779
|
+
_a.sent();
|
|
2780
|
+
_a.label = 2;
|
|
2781
|
+
case 2: return [2 /*return*/, this.queue(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
2782
|
+
return tslib.__generator(this, function (_a) {
|
|
2783
|
+
switch (_a.label) {
|
|
2784
|
+
case 0: return [4 /*yield*/, this.directlySetCurrentUser(user)];
|
|
2785
|
+
case 1:
|
|
2786
|
+
_a.sent();
|
|
2787
|
+
this.notifyAuthListeners();
|
|
2788
|
+
return [2 /*return*/];
|
|
2789
|
+
}
|
|
2790
|
+
});
|
|
2791
|
+
}); })];
|
|
2649
2792
|
}
|
|
2650
|
-
return [2 /*return*/, this.queue(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
2651
|
-
return tslib.__generator(this, function (_a) {
|
|
2652
|
-
switch (_a.label) {
|
|
2653
|
-
case 0: return [4 /*yield*/, this.directlySetCurrentUser(user)];
|
|
2654
|
-
case 1:
|
|
2655
|
-
_a.sent();
|
|
2656
|
-
this.notifyAuthListeners();
|
|
2657
|
-
return [2 /*return*/];
|
|
2658
|
-
}
|
|
2659
|
-
});
|
|
2660
|
-
}); })];
|
|
2661
2793
|
});
|
|
2662
2794
|
});
|
|
2663
2795
|
};
|
|
@@ -2665,13 +2797,21 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2665
2797
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2666
2798
|
return tslib.__generator(this, function (_a) {
|
|
2667
2799
|
switch (_a.label) {
|
|
2668
|
-
case 0:
|
|
2669
|
-
|
|
2670
|
-
|
|
2800
|
+
case 0:
|
|
2801
|
+
// Run first, to block _setRedirectUser() if any callbacks fail.
|
|
2802
|
+
return [4 /*yield*/, this.beforeStateQueue.runMiddleware(null)];
|
|
2671
2803
|
case 1:
|
|
2804
|
+
// Run first, to block _setRedirectUser() if any callbacks fail.
|
|
2672
2805
|
_a.sent();
|
|
2673
|
-
|
|
2674
|
-
|
|
2806
|
+
if (!(this.redirectPersistenceManager || this._popupRedirectResolver)) return [3 /*break*/, 3];
|
|
2807
|
+
return [4 /*yield*/, this._setRedirectUser(null)];
|
|
2808
|
+
case 2:
|
|
2809
|
+
_a.sent();
|
|
2810
|
+
_a.label = 3;
|
|
2811
|
+
case 3:
|
|
2812
|
+
// Prevent callbacks from being called again in _updateCurrentUser, as
|
|
2813
|
+
// they were already called in the first line.
|
|
2814
|
+
return [2 /*return*/, this._updateCurrentUser(null, /* skipBeforeStateCallbacks */ true)];
|
|
2675
2815
|
}
|
|
2676
2816
|
});
|
|
2677
2817
|
});
|
|
@@ -2698,6 +2838,9 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2698
2838
|
AuthImpl.prototype.onAuthStateChanged = function (nextOrObserver, error, completed) {
|
|
2699
2839
|
return this.registerStateListener(this.authStateSubscription, nextOrObserver, error, completed);
|
|
2700
2840
|
};
|
|
2841
|
+
AuthImpl.prototype.beforeAuthStateChanged = function (callback, onAbort) {
|
|
2842
|
+
return this.beforeStateQueue.pushCallback(callback, onAbort);
|
|
2843
|
+
};
|
|
2701
2844
|
AuthImpl.prototype.onIdTokenChanged = function (nextOrObserver, error, completed) {
|
|
2702
2845
|
return this.registerStateListener(this.idTokenSubscription, nextOrObserver, error, completed);
|
|
2703
2846
|
};
|
|
@@ -6433,6 +6576,19 @@ function setPersistence(auth, persistence) {
|
|
|
6433
6576
|
function onIdTokenChanged(auth, nextOrObserver, error, completed) {
|
|
6434
6577
|
return util.getModularInstance(auth).onIdTokenChanged(nextOrObserver, error, completed);
|
|
6435
6578
|
}
|
|
6579
|
+
/**
|
|
6580
|
+
* Adds a blocking callback that runs before an auth state change
|
|
6581
|
+
* sets a new user.
|
|
6582
|
+
*
|
|
6583
|
+
* @param auth - The {@link Auth} instance.
|
|
6584
|
+
* @param callback - callback triggered before new user value is set.
|
|
6585
|
+
* If this throws, it blocks the user from being set.
|
|
6586
|
+
* @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
|
|
6587
|
+
* callback throws, allowing you to undo any side effects.
|
|
6588
|
+
*/
|
|
6589
|
+
function beforeAuthStateChanged(auth, callback, onAbort) {
|
|
6590
|
+
return util.getModularInstance(auth).beforeAuthStateChanged(callback, onAbort);
|
|
6591
|
+
}
|
|
6436
6592
|
/**
|
|
6437
6593
|
* Adds an observer for changes to the user's sign-in state.
|
|
6438
6594
|
*
|
|
@@ -6799,7 +6955,7 @@ function multiFactor(user) {
|
|
|
6799
6955
|
}
|
|
6800
6956
|
|
|
6801
6957
|
var name = "@firebase/auth";
|
|
6802
|
-
var version = "0.
|
|
6958
|
+
var version = "0.20.0";
|
|
6803
6959
|
|
|
6804
6960
|
/**
|
|
6805
6961
|
* @license
|
|
@@ -8276,6 +8432,7 @@ exports._setWindowLocation = _setWindowLocation;
|
|
|
8276
8432
|
exports._signInWithCredential = _signInWithCredential;
|
|
8277
8433
|
exports._window = _window;
|
|
8278
8434
|
exports.applyActionCode = applyActionCode;
|
|
8435
|
+
exports.beforeAuthStateChanged = beforeAuthStateChanged;
|
|
8279
8436
|
exports.checkActionCode = checkActionCode;
|
|
8280
8437
|
exports.confirmPasswordReset = confirmPasswordReset;
|
|
8281
8438
|
exports.connectAuthEmulator = connectAuthEmulator;
|
|
@@ -8323,4 +8480,4 @@ exports.updateProfile = updateProfile;
|
|
|
8323
8480
|
exports.useDeviceLanguage = useDeviceLanguage;
|
|
8324
8481
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
8325
8482
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
8326
|
-
//# sourceMappingURL=phone-
|
|
8483
|
+
//# sourceMappingURL=phone-ae029e3c.js.map
|