@firebase/auth 0.18.3 → 0.19.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 +16 -0
- package/dist/auth-public.d.ts +28 -19
- package/dist/auth.d.ts +29 -20
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/index.rn.d.ts +3 -0
- package/dist/cordova/internal.js +7 -3
- package/dist/cordova/internal.js.map +1 -1
- package/dist/cordova/{popup_redirect-f608cd47.js → popup_redirect-c65b3459.js} +46 -26
- package/dist/cordova/popup_redirect-c65b3459.js.map +1 -0
- package/dist/cordova/src/core/errors.d.ts +2 -2
- package/dist/cordova/src/core/strategies/abstract_popup_redirect_operation.d.ts +1 -1
- package/dist/cordova/src/mfa/mfa_error.d.ts +4 -5
- package/dist/cordova/src/model/public_types.d.ts +25 -19
- package/dist/cordova/src/platform_browser/persistence/browser.d.ts +4 -3
- package/dist/cordova/src/platform_browser/persistence/browser.test.d.ts +17 -0
- package/dist/cordova/src/platform_browser/strategies/phone.d.ts +3 -0
- package/dist/cordova/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
- package/dist/esm2017/{index-f41a0691.js → index-238d6fa9.js} +41 -24
- package/dist/esm2017/index-238d6fa9.js.map +1 -0
- package/dist/esm2017/index.js +1 -1
- package/dist/esm2017/index.rn.d.ts +3 -0
- package/dist/esm2017/internal.js +2 -2
- package/dist/esm2017/src/core/errors.d.ts +2 -2
- package/dist/esm2017/src/core/strategies/abstract_popup_redirect_operation.d.ts +1 -1
- package/dist/esm2017/src/mfa/mfa_error.d.ts +4 -5
- package/dist/esm2017/src/model/public_types.d.ts +25 -19
- package/dist/esm2017/src/platform_browser/persistence/browser.d.ts +4 -3
- package/dist/esm2017/src/platform_browser/persistence/browser.test.d.ts +17 -0
- package/dist/esm2017/src/platform_browser/strategies/phone.d.ts +3 -0
- package/dist/esm2017/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
- package/dist/esm5/{index-fd8b7af5.js → index-47dd1018.js} +51 -27
- package/dist/esm5/index-47dd1018.js.map +1 -0
- package/dist/esm5/index.js +1 -1
- package/dist/esm5/index.rn.d.ts +3 -0
- package/dist/esm5/internal.js +2 -2
- package/dist/esm5/src/core/errors.d.ts +2 -2
- package/dist/esm5/src/core/strategies/abstract_popup_redirect_operation.d.ts +1 -1
- package/dist/esm5/src/mfa/mfa_error.d.ts +4 -5
- package/dist/esm5/src/model/public_types.d.ts +25 -19
- package/dist/esm5/src/platform_browser/persistence/browser.d.ts +4 -3
- package/dist/esm5/src/platform_browser/persistence/browser.test.d.ts +17 -0
- package/dist/esm5/src/platform_browser/strategies/phone.d.ts +3 -0
- package/dist/esm5/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
- package/dist/index.rn.d.ts +3 -0
- package/dist/index.webworker.esm5.js +17 -16
- package/dist/index.webworker.esm5.js.map +1 -1
- package/dist/node/{index-358613ec.js → index-da4673cf.js} +18 -17
- package/dist/node/index-da4673cf.js.map +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.rn.d.ts +3 -0
- package/dist/node/internal.js +29 -10
- package/dist/node/internal.js.map +1 -1
- package/dist/node/src/core/errors.d.ts +2 -2
- package/dist/node/src/core/strategies/abstract_popup_redirect_operation.d.ts +1 -1
- package/dist/node/src/mfa/mfa_error.d.ts +4 -5
- package/dist/node/src/model/public_types.d.ts +25 -19
- package/dist/node/src/platform_browser/persistence/browser.d.ts +4 -3
- package/dist/node/src/platform_browser/persistence/browser.test.d.ts +17 -0
- package/dist/node/src/platform_browser/strategies/phone.d.ts +3 -0
- package/dist/node/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
- package/dist/rn/index.js +70 -64
- package/dist/rn/index.js.map +1 -1
- package/dist/rn/index.rn.d.ts +3 -0
- package/dist/rn/internal.js +338 -1465
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/{enum_maps-81db3ff6.js → phone-e3d3bcce.js} +1187 -27
- package/dist/rn/phone-e3d3bcce.js.map +1 -0
- package/dist/rn/src/core/errors.d.ts +2 -2
- package/dist/rn/src/core/strategies/abstract_popup_redirect_operation.d.ts +1 -1
- package/dist/rn/src/mfa/mfa_error.d.ts +4 -5
- package/dist/rn/src/model/public_types.d.ts +25 -19
- package/dist/rn/src/platform_browser/persistence/browser.d.ts +4 -3
- package/dist/rn/src/platform_browser/persistence/browser.test.d.ts +17 -0
- package/dist/rn/src/platform_browser/strategies/phone.d.ts +3 -0
- package/dist/rn/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
- package/dist/src/core/errors.d.ts +2 -2
- package/dist/src/core/strategies/abstract_popup_redirect_operation.d.ts +1 -1
- package/dist/src/mfa/mfa_error.d.ts +4 -5
- package/dist/src/model/public_types.d.ts +25 -19
- package/dist/src/platform_browser/persistence/browser.d.ts +4 -3
- package/dist/src/platform_browser/persistence/browser.test.d.ts +17 -0
- package/dist/src/platform_browser/strategies/phone.d.ts +3 -0
- package/dist/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
- package/package.json +2 -2
- package/dist/cordova/popup_redirect-f608cd47.js.map +0 -1
- package/dist/esm2017/index-f41a0691.js.map +0 -1
- package/dist/esm5/index-fd8b7af5.js.map +0 -1
- package/dist/node/index-358613ec.js.map +0 -1
- package/dist/rn/enum_maps-81db3ff6.js.map +0 -1
package/dist/rn/internal.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var phone = require('./phone-e3d3bcce.js');
|
|
6
6
|
var tslib = require('tslib');
|
|
7
7
|
var util = require('@firebase/util');
|
|
8
8
|
var app = require('@firebase/app');
|
|
@@ -29,8 +29,8 @@ require('@firebase/logger');
|
|
|
29
29
|
// Both have the same implementation but use a different underlying storage
|
|
30
30
|
// object.
|
|
31
31
|
var BrowserPersistenceClass = /** @class */ (function () {
|
|
32
|
-
function BrowserPersistenceClass(
|
|
33
|
-
this.
|
|
32
|
+
function BrowserPersistenceClass(storageRetriever, type) {
|
|
33
|
+
this.storageRetriever = storageRetriever;
|
|
34
34
|
this.type = type;
|
|
35
35
|
}
|
|
36
36
|
BrowserPersistenceClass.prototype._isAvailable = function () {
|
|
@@ -38,8 +38,8 @@ var BrowserPersistenceClass = /** @class */ (function () {
|
|
|
38
38
|
if (!this.storage) {
|
|
39
39
|
return Promise.resolve(false);
|
|
40
40
|
}
|
|
41
|
-
this.storage.setItem(
|
|
42
|
-
this.storage.removeItem(
|
|
41
|
+
this.storage.setItem(phone.STORAGE_AVAILABLE_KEY, '1');
|
|
42
|
+
this.storage.removeItem(phone.STORAGE_AVAILABLE_KEY);
|
|
43
43
|
return Promise.resolve(true);
|
|
44
44
|
}
|
|
45
45
|
catch (_a) {
|
|
@@ -58,6 +58,13 @@ var BrowserPersistenceClass = /** @class */ (function () {
|
|
|
58
58
|
this.storage.removeItem(key);
|
|
59
59
|
return Promise.resolve();
|
|
60
60
|
};
|
|
61
|
+
Object.defineProperty(BrowserPersistenceClass.prototype, "storage", {
|
|
62
|
+
get: function () {
|
|
63
|
+
return this.storageRetriever();
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
61
68
|
return BrowserPersistenceClass;
|
|
62
69
|
}());
|
|
63
70
|
|
|
@@ -79,7 +86,7 @@ var BrowserPersistenceClass = /** @class */ (function () {
|
|
|
79
86
|
*/
|
|
80
87
|
function _iframeCannotSyncWebStorage() {
|
|
81
88
|
var ua = util.getUA();
|
|
82
|
-
return
|
|
89
|
+
return phone._isSafari(ua) || phone._isIOS(ua);
|
|
83
90
|
}
|
|
84
91
|
// The polling period in case events are not supported
|
|
85
92
|
var _POLLING_INTERVAL_MS$1 = 1000;
|
|
@@ -88,7 +95,7 @@ var IE10_LOCAL_STORAGE_SYNC_DELAY = 10;
|
|
|
88
95
|
var BrowserLocalPersistence = /** @class */ (function (_super) {
|
|
89
96
|
tslib.__extends(BrowserLocalPersistence, _super);
|
|
90
97
|
function BrowserLocalPersistence() {
|
|
91
|
-
var _this = _super.call(this, window.localStorage, "LOCAL" /* LOCAL */) || this;
|
|
98
|
+
var _this = _super.call(this, function () { return window.localStorage; }, "LOCAL" /* LOCAL */) || this;
|
|
92
99
|
_this.boundEventHandler = function (event, poll) { return _this.onStorageEvent(event, poll); };
|
|
93
100
|
_this.listeners = {};
|
|
94
101
|
_this.localCache = {};
|
|
@@ -96,9 +103,9 @@ var BrowserLocalPersistence = /** @class */ (function (_super) {
|
|
|
96
103
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
104
|
_this.pollTimer = null;
|
|
98
105
|
// Safari or iOS browser and embedded in an iframe.
|
|
99
|
-
_this.safariLocalStorageNotSynced = _iframeCannotSyncWebStorage() &&
|
|
106
|
+
_this.safariLocalStorageNotSynced = _iframeCannotSyncWebStorage() && phone._isIframe();
|
|
100
107
|
// Whether to use polling instead of depending on window events
|
|
101
|
-
_this.fallbackToPolling =
|
|
108
|
+
_this.fallbackToPolling = phone._isMobileBrowser();
|
|
102
109
|
_this._shouldAllowMigration = true;
|
|
103
110
|
return _this;
|
|
104
111
|
}
|
|
@@ -172,7 +179,7 @@ var BrowserLocalPersistence = /** @class */ (function (_super) {
|
|
|
172
179
|
_this.notifyListeners(key, storedValue);
|
|
173
180
|
};
|
|
174
181
|
var storedValue = this.storage.getItem(key);
|
|
175
|
-
if (
|
|
182
|
+
if (phone._isIE10() &&
|
|
176
183
|
storedValue !== event.newValue &&
|
|
177
184
|
event.newValue !== event.oldValue) {
|
|
178
185
|
// IE 10 has this weird bug where a storage event would trigger with the
|
|
@@ -324,7 +331,7 @@ var browserLocalPersistence = BrowserLocalPersistence;
|
|
|
324
331
|
var BrowserSessionPersistence = /** @class */ (function (_super) {
|
|
325
332
|
tslib.__extends(BrowserSessionPersistence, _super);
|
|
326
333
|
function BrowserSessionPersistence() {
|
|
327
|
-
return _super.call(this, window.sessionStorage, "SESSION" /* SESSION */) || this;
|
|
334
|
+
return _super.call(this, function () { return window.sessionStorage; }, "SESSION" /* SESSION */) || this;
|
|
328
335
|
}
|
|
329
336
|
BrowserSessionPersistence.prototype._addListener = function (_key, _listener) {
|
|
330
337
|
// Listeners are not supported for session storage since it cannot be shared across windows
|
|
@@ -663,85 +670,6 @@ var Sender = /** @class */ (function () {
|
|
|
663
670
|
return Sender;
|
|
664
671
|
}());
|
|
665
672
|
|
|
666
|
-
/**
|
|
667
|
-
* @license
|
|
668
|
-
* Copyright 2020 Google LLC
|
|
669
|
-
*
|
|
670
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
671
|
-
* you may not use this file except in compliance with the License.
|
|
672
|
-
* You may obtain a copy of the License at
|
|
673
|
-
*
|
|
674
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
675
|
-
*
|
|
676
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
677
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
678
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
679
|
-
* See the License for the specific language governing permissions and
|
|
680
|
-
* limitations under the License.
|
|
681
|
-
*/
|
|
682
|
-
/**
|
|
683
|
-
* Lazy accessor for window, since the compat layer won't tree shake this out,
|
|
684
|
-
* we need to make sure not to mess with window unless we have to
|
|
685
|
-
*/
|
|
686
|
-
function _window() {
|
|
687
|
-
return window;
|
|
688
|
-
}
|
|
689
|
-
function _setWindowLocation(url) {
|
|
690
|
-
_window().location.href = url;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* @license
|
|
695
|
-
* Copyright 2020 Google LLC.
|
|
696
|
-
*
|
|
697
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
698
|
-
* you may not use this file except in compliance with the License.
|
|
699
|
-
* You may obtain a copy of the License at
|
|
700
|
-
*
|
|
701
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
702
|
-
*
|
|
703
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
704
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
705
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
706
|
-
* See the License for the specific language governing permissions and
|
|
707
|
-
* limitations under the License.
|
|
708
|
-
*/
|
|
709
|
-
function _isWorker() {
|
|
710
|
-
return (typeof _window()['WorkerGlobalScope'] !== 'undefined' &&
|
|
711
|
-
typeof _window()['importScripts'] === 'function');
|
|
712
|
-
}
|
|
713
|
-
function _getActiveServiceWorker() {
|
|
714
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
715
|
-
var registration;
|
|
716
|
-
return tslib.__generator(this, function (_b) {
|
|
717
|
-
switch (_b.label) {
|
|
718
|
-
case 0:
|
|
719
|
-
if (!(navigator === null || navigator === void 0 ? void 0 : navigator.serviceWorker)) {
|
|
720
|
-
return [2 /*return*/, null];
|
|
721
|
-
}
|
|
722
|
-
_b.label = 1;
|
|
723
|
-
case 1:
|
|
724
|
-
_b.trys.push([1, 3, , 4]);
|
|
725
|
-
return [4 /*yield*/, navigator.serviceWorker.ready];
|
|
726
|
-
case 2:
|
|
727
|
-
registration = _b.sent();
|
|
728
|
-
return [2 /*return*/, registration.active];
|
|
729
|
-
case 3:
|
|
730
|
-
_b.sent();
|
|
731
|
-
return [2 /*return*/, null];
|
|
732
|
-
case 4: return [2 /*return*/];
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
function _getServiceWorkerController() {
|
|
738
|
-
var _a;
|
|
739
|
-
return ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.serviceWorker) === null || _a === void 0 ? void 0 : _a.controller) || null;
|
|
740
|
-
}
|
|
741
|
-
function _getWorkerGlobalScope() {
|
|
742
|
-
return _isWorker() ? self : null;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
673
|
/**
|
|
746
674
|
* @license
|
|
747
675
|
* Copyright 2019 Google LLC
|
|
@@ -946,7 +874,7 @@ var IndexedDBLocalPersistence = /** @class */ (function () {
|
|
|
946
874
|
IndexedDBLocalPersistence.prototype.initializeServiceWorkerMessaging = function () {
|
|
947
875
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
948
876
|
return tslib.__generator(this, function (_a) {
|
|
949
|
-
return [2 /*return*/, _isWorker() ? this.initializeReceiver() : this.initializeSender()];
|
|
877
|
+
return [2 /*return*/, phone._isWorker() ? this.initializeReceiver() : this.initializeSender()];
|
|
950
878
|
});
|
|
951
879
|
});
|
|
952
880
|
};
|
|
@@ -957,7 +885,7 @@ var IndexedDBLocalPersistence = /** @class */ (function () {
|
|
|
957
885
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
958
886
|
var _this = this;
|
|
959
887
|
return tslib.__generator(this, function (_a) {
|
|
960
|
-
this.receiver = Receiver._getInstance(_getWorkerGlobalScope());
|
|
888
|
+
this.receiver = Receiver._getInstance(phone._getWorkerGlobalScope());
|
|
961
889
|
// Refresh from persistence if we receive a KeyChanged message.
|
|
962
890
|
this.receiver._subscribe("keyChanged" /* KEY_CHANGED */, function (_origin, data) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
963
891
|
var keys;
|
|
@@ -998,7 +926,7 @@ var IndexedDBLocalPersistence = /** @class */ (function () {
|
|
|
998
926
|
case 0:
|
|
999
927
|
// Check to see if there's an active service worker.
|
|
1000
928
|
_c = this;
|
|
1001
|
-
return [4 /*yield*/, _getActiveServiceWorker()];
|
|
929
|
+
return [4 /*yield*/, phone._getActiveServiceWorker()];
|
|
1002
930
|
case 1:
|
|
1003
931
|
// Check to see if there's an active service worker.
|
|
1004
932
|
_c.activeServiceWorker = _d.sent();
|
|
@@ -1037,7 +965,7 @@ var IndexedDBLocalPersistence = /** @class */ (function () {
|
|
|
1037
965
|
case 0:
|
|
1038
966
|
if (!this.sender ||
|
|
1039
967
|
!this.activeServiceWorker ||
|
|
1040
|
-
_getServiceWorkerController() !== this.activeServiceWorker) {
|
|
968
|
+
phone._getServiceWorkerController() !== this.activeServiceWorker) {
|
|
1041
969
|
return [2 /*return*/];
|
|
1042
970
|
}
|
|
1043
971
|
_b.label = 1;
|
|
@@ -1072,10 +1000,10 @@ var IndexedDBLocalPersistence = /** @class */ (function () {
|
|
|
1072
1000
|
return [4 /*yield*/, _openDatabase()];
|
|
1073
1001
|
case 1:
|
|
1074
1002
|
db = _b.sent();
|
|
1075
|
-
return [4 /*yield*/, _putObject(db,
|
|
1003
|
+
return [4 /*yield*/, _putObject(db, phone.STORAGE_AVAILABLE_KEY, '1')];
|
|
1076
1004
|
case 2:
|
|
1077
1005
|
_b.sent();
|
|
1078
|
-
return [4 /*yield*/, _deleteObject(db,
|
|
1006
|
+
return [4 /*yield*/, _deleteObject(db, phone.STORAGE_AVAILABLE_KEY)];
|
|
1079
1007
|
case 3:
|
|
1080
1008
|
_b.sent();
|
|
1081
1009
|
return [2 /*return*/, true];
|
|
@@ -1118,1137 +1046,144 @@ var IndexedDBLocalPersistence = /** @class */ (function () {
|
|
|
1118
1046
|
case 0: return [4 /*yield*/, this._withRetries(function (db) { return _putObject(db, key, value); })];
|
|
1119
1047
|
case 1:
|
|
1120
1048
|
_a.sent();
|
|
1121
|
-
this.localCache[key] = value;
|
|
1122
|
-
return [2 /*return*/, this.notifyServiceWorker(key)];
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
}); })];
|
|
1126
|
-
});
|
|
1127
|
-
});
|
|
1128
|
-
};
|
|
1129
|
-
IndexedDBLocalPersistence.prototype._get = function (key) {
|
|
1130
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1131
|
-
var obj;
|
|
1132
|
-
return tslib.__generator(this, function (_a) {
|
|
1133
|
-
switch (_a.label) {
|
|
1134
|
-
case 0: return [4 /*yield*/, this._withRetries(function (db) {
|
|
1135
|
-
return getObject(db, key);
|
|
1136
|
-
})];
|
|
1137
|
-
case 1:
|
|
1138
|
-
obj = (_a.sent());
|
|
1139
|
-
this.localCache[key] = obj;
|
|
1140
|
-
return [2 /*return*/, obj];
|
|
1141
|
-
}
|
|
1142
|
-
});
|
|
1143
|
-
});
|
|
1144
|
-
};
|
|
1145
|
-
IndexedDBLocalPersistence.prototype._remove = function (key) {
|
|
1146
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1147
|
-
var _this = this;
|
|
1148
|
-
return tslib.__generator(this, function (_a) {
|
|
1149
|
-
return [2 /*return*/, this._withPendingWrite(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
1150
|
-
return tslib.__generator(this, function (_a) {
|
|
1151
|
-
switch (_a.label) {
|
|
1152
|
-
case 0: return [4 /*yield*/, this._withRetries(function (db) { return _deleteObject(db, key); })];
|
|
1153
|
-
case 1:
|
|
1154
|
-
_a.sent();
|
|
1155
|
-
delete this.localCache[key];
|
|
1156
|
-
return [2 /*return*/, this.notifyServiceWorker(key)];
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
}); })];
|
|
1160
|
-
});
|
|
1161
|
-
});
|
|
1162
|
-
};
|
|
1163
|
-
IndexedDBLocalPersistence.prototype._poll = function () {
|
|
1164
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1165
|
-
var result, keys, keysInResult, _i, result_1, _a, key, value, _b, _c, localKey;
|
|
1166
|
-
return tslib.__generator(this, function (_d) {
|
|
1167
|
-
switch (_d.label) {
|
|
1168
|
-
case 0: return [4 /*yield*/, this._withRetries(function (db) {
|
|
1169
|
-
var getAllRequest = getObjectStore(db, false).getAll();
|
|
1170
|
-
return new DBPromise(getAllRequest).toPromise();
|
|
1171
|
-
})];
|
|
1172
|
-
case 1:
|
|
1173
|
-
result = _d.sent();
|
|
1174
|
-
if (!result) {
|
|
1175
|
-
return [2 /*return*/, []];
|
|
1176
|
-
}
|
|
1177
|
-
// If we have pending writes in progress abort, we'll get picked up on the next poll
|
|
1178
|
-
if (this.pendingWrites !== 0) {
|
|
1179
|
-
return [2 /*return*/, []];
|
|
1180
|
-
}
|
|
1181
|
-
keys = [];
|
|
1182
|
-
keysInResult = new Set();
|
|
1183
|
-
for (_i = 0, result_1 = result; _i < result_1.length; _i++) {
|
|
1184
|
-
_a = result_1[_i], key = _a.fbase_key, value = _a.value;
|
|
1185
|
-
keysInResult.add(key);
|
|
1186
|
-
if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
|
|
1187
|
-
this.notifyListeners(key, value);
|
|
1188
|
-
keys.push(key);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
for (_b = 0, _c = Object.keys(this.localCache); _b < _c.length; _b++) {
|
|
1192
|
-
localKey = _c[_b];
|
|
1193
|
-
if (this.localCache[localKey] && !keysInResult.has(localKey)) {
|
|
1194
|
-
// Deleted
|
|
1195
|
-
this.notifyListeners(localKey, null);
|
|
1196
|
-
keys.push(localKey);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
return [2 /*return*/, keys];
|
|
1200
|
-
}
|
|
1201
|
-
});
|
|
1202
|
-
});
|
|
1203
|
-
};
|
|
1204
|
-
IndexedDBLocalPersistence.prototype.notifyListeners = function (key, newValue) {
|
|
1205
|
-
this.localCache[key] = newValue;
|
|
1206
|
-
var listeners = this.listeners[key];
|
|
1207
|
-
if (listeners) {
|
|
1208
|
-
for (var _i = 0, _a = Array.from(listeners); _i < _a.length; _i++) {
|
|
1209
|
-
var listener = _a[_i];
|
|
1210
|
-
listener(newValue);
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
IndexedDBLocalPersistence.prototype.startPolling = function () {
|
|
1215
|
-
var _this = this;
|
|
1216
|
-
this.stopPolling();
|
|
1217
|
-
this.pollTimer = setInterval(function () { return tslib.__awaiter(_this, void 0, void 0, function () { return tslib.__generator(this, function (_a) {
|
|
1218
|
-
return [2 /*return*/, this._poll()];
|
|
1219
|
-
}); }); }, _POLLING_INTERVAL_MS);
|
|
1220
|
-
};
|
|
1221
|
-
IndexedDBLocalPersistence.prototype.stopPolling = function () {
|
|
1222
|
-
if (this.pollTimer) {
|
|
1223
|
-
clearInterval(this.pollTimer);
|
|
1224
|
-
this.pollTimer = null;
|
|
1225
|
-
}
|
|
1226
|
-
};
|
|
1227
|
-
IndexedDBLocalPersistence.prototype._addListener = function (key, listener) {
|
|
1228
|
-
if (Object.keys(this.listeners).length === 0) {
|
|
1229
|
-
this.startPolling();
|
|
1230
|
-
}
|
|
1231
|
-
if (!this.listeners[key]) {
|
|
1232
|
-
this.listeners[key] = new Set();
|
|
1233
|
-
// Populate the cache to avoid spuriously triggering on first poll.
|
|
1234
|
-
void this._get(key); // This can happen in the background async and we can return immediately.
|
|
1235
|
-
}
|
|
1236
|
-
this.listeners[key].add(listener);
|
|
1237
|
-
};
|
|
1238
|
-
IndexedDBLocalPersistence.prototype._removeListener = function (key, listener) {
|
|
1239
|
-
if (this.listeners[key]) {
|
|
1240
|
-
this.listeners[key].delete(listener);
|
|
1241
|
-
if (this.listeners[key].size === 0) {
|
|
1242
|
-
delete this.listeners[key];
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
if (Object.keys(this.listeners).length === 0) {
|
|
1246
|
-
this.stopPolling();
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
IndexedDBLocalPersistence.type = 'LOCAL';
|
|
1250
|
-
return IndexedDBLocalPersistence;
|
|
1251
|
-
}());
|
|
1252
|
-
/**
|
|
1253
|
-
* An implementation of {@link Persistence} of type `LOCAL` using `indexedDB`
|
|
1254
|
-
* for the underlying storage.
|
|
1255
|
-
*
|
|
1256
|
-
* @public
|
|
1257
|
-
*/
|
|
1258
|
-
var indexedDBLocalPersistence = IndexedDBLocalPersistence;
|
|
1259
|
-
|
|
1260
|
-
/**
|
|
1261
|
-
* @license
|
|
1262
|
-
* Copyright 2020 Google LLC
|
|
1263
|
-
*
|
|
1264
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1265
|
-
* you may not use this file except in compliance with the License.
|
|
1266
|
-
* You may obtain a copy of the License at
|
|
1267
|
-
*
|
|
1268
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1269
|
-
*
|
|
1270
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1271
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1272
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1273
|
-
* See the License for the specific language governing permissions and
|
|
1274
|
-
* limitations under the License.
|
|
1275
|
-
*/
|
|
1276
|
-
function startSignInPhoneMfa(auth, request) {
|
|
1277
|
-
return enum_maps._performApiRequest(auth, "POST" /* POST */, "/v2/accounts/mfaSignIn:start" /* START_PHONE_MFA_SIGN_IN */, enum_maps._addTidIfNecessary(auth, request));
|
|
1278
|
-
}
|
|
1279
|
-
function finalizeSignInPhoneMfa(auth, request) {
|
|
1280
|
-
return enum_maps._performApiRequest(auth, "POST" /* POST */, "/v2/accounts/mfaSignIn:finalize" /* FINALIZE_PHONE_MFA_SIGN_IN */, enum_maps._addTidIfNecessary(auth, request));
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
* @license
|
|
1285
|
-
* Copyright 2020 Google LLC
|
|
1286
|
-
*
|
|
1287
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1288
|
-
* you may not use this file except in compliance with the License.
|
|
1289
|
-
* You may obtain a copy of the License at
|
|
1290
|
-
*
|
|
1291
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1292
|
-
*
|
|
1293
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1294
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1295
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1296
|
-
* See the License for the specific language governing permissions and
|
|
1297
|
-
* limitations under the License.
|
|
1298
|
-
*/
|
|
1299
|
-
function getRecaptchaParams(auth) {
|
|
1300
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1301
|
-
return tslib.__generator(this, function (_a) {
|
|
1302
|
-
switch (_a.label) {
|
|
1303
|
-
case 0: return [4 /*yield*/, enum_maps._performApiRequest(auth, "GET" /* GET */, "/v1/recaptchaParams" /* GET_RECAPTCHA_PARAM */)];
|
|
1304
|
-
case 1: return [2 /*return*/, ((_a.sent()).recaptchaSiteKey || '')];
|
|
1305
|
-
}
|
|
1306
|
-
});
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
/**
|
|
1311
|
-
* @license
|
|
1312
|
-
* Copyright 2020 Google LLC
|
|
1313
|
-
*
|
|
1314
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1315
|
-
* you may not use this file except in compliance with the License.
|
|
1316
|
-
* You may obtain a copy of the License at
|
|
1317
|
-
*
|
|
1318
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1319
|
-
*
|
|
1320
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1321
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1322
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1323
|
-
* See the License for the specific language governing permissions and
|
|
1324
|
-
* limitations under the License.
|
|
1325
|
-
*/
|
|
1326
|
-
function getScriptParentElement() {
|
|
1327
|
-
var _a, _b;
|
|
1328
|
-
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
1329
|
-
}
|
|
1330
|
-
function _loadJS(url) {
|
|
1331
|
-
// TODO: consider adding timeout support & cancellation
|
|
1332
|
-
return new Promise(function (resolve, reject) {
|
|
1333
|
-
var el = document.createElement('script');
|
|
1334
|
-
el.setAttribute('src', url);
|
|
1335
|
-
el.onload = resolve;
|
|
1336
|
-
el.onerror = function (e) {
|
|
1337
|
-
var error = enum_maps._createError("internal-error" /* INTERNAL_ERROR */);
|
|
1338
|
-
error.customData = e;
|
|
1339
|
-
reject(error);
|
|
1340
|
-
};
|
|
1341
|
-
el.type = 'text/javascript';
|
|
1342
|
-
el.charset = 'UTF-8';
|
|
1343
|
-
getScriptParentElement().appendChild(el);
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
function _generateCallbackName(prefix) {
|
|
1347
|
-
return "__" + prefix + Math.floor(Math.random() * 1000000);
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
/**
|
|
1351
|
-
* @license
|
|
1352
|
-
* Copyright 2020 Google LLC
|
|
1353
|
-
*
|
|
1354
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1355
|
-
* you may not use this file except in compliance with the License.
|
|
1356
|
-
* You may obtain a copy of the License at
|
|
1357
|
-
*
|
|
1358
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1359
|
-
*
|
|
1360
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1361
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1362
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1363
|
-
* See the License for the specific language governing permissions and
|
|
1364
|
-
* limitations under the License.
|
|
1365
|
-
*/
|
|
1366
|
-
var _SOLVE_TIME_MS = 500;
|
|
1367
|
-
var _EXPIRATION_TIME_MS = 60000;
|
|
1368
|
-
var _WIDGET_ID_START = 1000000000000;
|
|
1369
|
-
var MockReCaptcha = /** @class */ (function () {
|
|
1370
|
-
function MockReCaptcha(auth) {
|
|
1371
|
-
this.auth = auth;
|
|
1372
|
-
this.counter = _WIDGET_ID_START;
|
|
1373
|
-
this._widgets = new Map();
|
|
1374
|
-
}
|
|
1375
|
-
MockReCaptcha.prototype.render = function (container, parameters) {
|
|
1376
|
-
var id = this.counter;
|
|
1377
|
-
this._widgets.set(id, new MockWidget(container, this.auth.name, parameters || {}));
|
|
1378
|
-
this.counter++;
|
|
1379
|
-
return id;
|
|
1380
|
-
};
|
|
1381
|
-
MockReCaptcha.prototype.reset = function (optWidgetId) {
|
|
1382
|
-
var _a;
|
|
1383
|
-
var id = optWidgetId || _WIDGET_ID_START;
|
|
1384
|
-
void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.delete());
|
|
1385
|
-
this._widgets.delete(id);
|
|
1386
|
-
};
|
|
1387
|
-
MockReCaptcha.prototype.getResponse = function (optWidgetId) {
|
|
1388
|
-
var _a;
|
|
1389
|
-
var id = optWidgetId || _WIDGET_ID_START;
|
|
1390
|
-
return ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.getResponse()) || '';
|
|
1391
|
-
};
|
|
1392
|
-
MockReCaptcha.prototype.execute = function (optWidgetId) {
|
|
1393
|
-
var _a;
|
|
1394
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1395
|
-
var id;
|
|
1396
|
-
return tslib.__generator(this, function (_b) {
|
|
1397
|
-
id = optWidgetId || _WIDGET_ID_START;
|
|
1398
|
-
void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.execute());
|
|
1399
|
-
return [2 /*return*/, ''];
|
|
1400
|
-
});
|
|
1401
|
-
});
|
|
1402
|
-
};
|
|
1403
|
-
return MockReCaptcha;
|
|
1404
|
-
}());
|
|
1405
|
-
var MockWidget = /** @class */ (function () {
|
|
1406
|
-
function MockWidget(containerOrId, appName, params) {
|
|
1407
|
-
var _this = this;
|
|
1408
|
-
this.params = params;
|
|
1409
|
-
this.timerId = null;
|
|
1410
|
-
this.deleted = false;
|
|
1411
|
-
this.responseToken = null;
|
|
1412
|
-
this.clickHandler = function () {
|
|
1413
|
-
_this.execute();
|
|
1414
|
-
};
|
|
1415
|
-
var container = typeof containerOrId === 'string'
|
|
1416
|
-
? document.getElementById(containerOrId)
|
|
1417
|
-
: containerOrId;
|
|
1418
|
-
enum_maps._assert(container, "argument-error" /* ARGUMENT_ERROR */, { appName: appName });
|
|
1419
|
-
this.container = container;
|
|
1420
|
-
this.isVisible = this.params.size !== 'invisible';
|
|
1421
|
-
if (this.isVisible) {
|
|
1422
|
-
this.execute();
|
|
1423
|
-
}
|
|
1424
|
-
else {
|
|
1425
|
-
this.container.addEventListener('click', this.clickHandler);
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
MockWidget.prototype.getResponse = function () {
|
|
1429
|
-
this.checkIfDeleted();
|
|
1430
|
-
return this.responseToken;
|
|
1431
|
-
};
|
|
1432
|
-
MockWidget.prototype.delete = function () {
|
|
1433
|
-
this.checkIfDeleted();
|
|
1434
|
-
this.deleted = true;
|
|
1435
|
-
if (this.timerId) {
|
|
1436
|
-
clearTimeout(this.timerId);
|
|
1437
|
-
this.timerId = null;
|
|
1438
|
-
}
|
|
1439
|
-
this.container.removeEventListener('click', this.clickHandler);
|
|
1440
|
-
};
|
|
1441
|
-
MockWidget.prototype.execute = function () {
|
|
1442
|
-
var _this = this;
|
|
1443
|
-
this.checkIfDeleted();
|
|
1444
|
-
if (this.timerId) {
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
this.timerId = window.setTimeout(function () {
|
|
1448
|
-
_this.responseToken = generateRandomAlphaNumericString(50);
|
|
1449
|
-
var _a = _this.params, callback = _a.callback, expiredCallback = _a["expired-callback"];
|
|
1450
|
-
if (callback) {
|
|
1451
|
-
try {
|
|
1452
|
-
callback(_this.responseToken);
|
|
1453
|
-
}
|
|
1454
|
-
catch (e) { }
|
|
1455
|
-
}
|
|
1456
|
-
_this.timerId = window.setTimeout(function () {
|
|
1457
|
-
_this.timerId = null;
|
|
1458
|
-
_this.responseToken = null;
|
|
1459
|
-
if (expiredCallback) {
|
|
1460
|
-
try {
|
|
1461
|
-
expiredCallback();
|
|
1462
|
-
}
|
|
1463
|
-
catch (e) { }
|
|
1464
|
-
}
|
|
1465
|
-
if (_this.isVisible) {
|
|
1466
|
-
_this.execute();
|
|
1467
|
-
}
|
|
1468
|
-
}, _EXPIRATION_TIME_MS);
|
|
1469
|
-
}, _SOLVE_TIME_MS);
|
|
1470
|
-
};
|
|
1471
|
-
MockWidget.prototype.checkIfDeleted = function () {
|
|
1472
|
-
if (this.deleted) {
|
|
1473
|
-
throw new Error('reCAPTCHA mock was already deleted!');
|
|
1474
|
-
}
|
|
1475
|
-
};
|
|
1476
|
-
return MockWidget;
|
|
1477
|
-
}());
|
|
1478
|
-
function generateRandomAlphaNumericString(len) {
|
|
1479
|
-
var chars = [];
|
|
1480
|
-
var allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
1481
|
-
for (var i = 0; i < len; i++) {
|
|
1482
|
-
chars.push(allowedChars.charAt(Math.floor(Math.random() * allowedChars.length)));
|
|
1483
|
-
}
|
|
1484
|
-
return chars.join('');
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
/**
|
|
1488
|
-
* @license
|
|
1489
|
-
* Copyright 2020 Google LLC
|
|
1490
|
-
*
|
|
1491
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1492
|
-
* you may not use this file except in compliance with the License.
|
|
1493
|
-
* You may obtain a copy of the License at
|
|
1494
|
-
*
|
|
1495
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1496
|
-
*
|
|
1497
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1498
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1499
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1500
|
-
* See the License for the specific language governing permissions and
|
|
1501
|
-
* limitations under the License.
|
|
1502
|
-
*/
|
|
1503
|
-
// ReCaptcha will load using the same callback, so the callback function needs
|
|
1504
|
-
// to be kept around
|
|
1505
|
-
var _JSLOAD_CALLBACK = _generateCallbackName('rcb');
|
|
1506
|
-
var NETWORK_TIMEOUT_DELAY = new enum_maps.Delay(30000, 60000);
|
|
1507
|
-
var RECAPTCHA_BASE = 'https://www.google.com/recaptcha/api.js?';
|
|
1508
|
-
/**
|
|
1509
|
-
* Loader for the GReCaptcha library. There should only ever be one of this.
|
|
1510
|
-
*/
|
|
1511
|
-
var ReCaptchaLoaderImpl = /** @class */ (function () {
|
|
1512
|
-
function ReCaptchaLoaderImpl() {
|
|
1513
|
-
this.hostLanguage = '';
|
|
1514
|
-
this.counter = 0;
|
|
1515
|
-
this.librarySeparatelyLoaded = !!_window().grecaptcha;
|
|
1516
|
-
}
|
|
1517
|
-
ReCaptchaLoaderImpl.prototype.load = function (auth, hl) {
|
|
1518
|
-
var _this = this;
|
|
1519
|
-
if (hl === void 0) { hl = ''; }
|
|
1520
|
-
enum_maps._assert(isHostLanguageValid(hl), auth, "argument-error" /* ARGUMENT_ERROR */);
|
|
1521
|
-
if (this.shouldResolveImmediately(hl)) {
|
|
1522
|
-
return Promise.resolve(_window().grecaptcha);
|
|
1523
|
-
}
|
|
1524
|
-
return new Promise(function (resolve, reject) {
|
|
1525
|
-
var networkTimeout = _window().setTimeout(function () {
|
|
1526
|
-
reject(enum_maps._createError(auth, "network-request-failed" /* NETWORK_REQUEST_FAILED */));
|
|
1527
|
-
}, NETWORK_TIMEOUT_DELAY.get());
|
|
1528
|
-
_window()[_JSLOAD_CALLBACK] = function () {
|
|
1529
|
-
_window().clearTimeout(networkTimeout);
|
|
1530
|
-
delete _window()[_JSLOAD_CALLBACK];
|
|
1531
|
-
var recaptcha = _window().grecaptcha;
|
|
1532
|
-
if (!recaptcha) {
|
|
1533
|
-
reject(enum_maps._createError(auth, "internal-error" /* INTERNAL_ERROR */));
|
|
1534
|
-
return;
|
|
1535
|
-
}
|
|
1536
|
-
// Wrap the greptcha render function so that we know if the developer has
|
|
1537
|
-
// called it separately
|
|
1538
|
-
var render = recaptcha.render;
|
|
1539
|
-
recaptcha.render = function (container, params) {
|
|
1540
|
-
var widgetId = render(container, params);
|
|
1541
|
-
_this.counter++;
|
|
1542
|
-
return widgetId;
|
|
1543
|
-
};
|
|
1544
|
-
_this.hostLanguage = hl;
|
|
1545
|
-
resolve(recaptcha);
|
|
1546
|
-
};
|
|
1547
|
-
var url = RECAPTCHA_BASE + "?" + util.querystring({
|
|
1548
|
-
onload: _JSLOAD_CALLBACK,
|
|
1549
|
-
render: 'explicit',
|
|
1550
|
-
hl: hl
|
|
1551
|
-
});
|
|
1552
|
-
_loadJS(url).catch(function () {
|
|
1553
|
-
clearTimeout(networkTimeout);
|
|
1554
|
-
reject(enum_maps._createError(auth, "internal-error" /* INTERNAL_ERROR */));
|
|
1555
|
-
});
|
|
1556
|
-
});
|
|
1557
|
-
};
|
|
1558
|
-
ReCaptchaLoaderImpl.prototype.clearedOneInstance = function () {
|
|
1559
|
-
this.counter--;
|
|
1560
|
-
};
|
|
1561
|
-
ReCaptchaLoaderImpl.prototype.shouldResolveImmediately = function (hl) {
|
|
1562
|
-
// We can resolve immediately if:
|
|
1563
|
-
// • grecaptcha is already defined AND (
|
|
1564
|
-
// 1. the requested language codes are the same OR
|
|
1565
|
-
// 2. there exists already a ReCaptcha on the page
|
|
1566
|
-
// 3. the library was already loaded by the app
|
|
1567
|
-
// In cases (2) and (3), we _can't_ reload as it would break the recaptchas
|
|
1568
|
-
// that are already in the page
|
|
1569
|
-
return (!!_window().grecaptcha &&
|
|
1570
|
-
(hl === this.hostLanguage ||
|
|
1571
|
-
this.counter > 0 ||
|
|
1572
|
-
this.librarySeparatelyLoaded));
|
|
1573
|
-
};
|
|
1574
|
-
return ReCaptchaLoaderImpl;
|
|
1575
|
-
}());
|
|
1576
|
-
function isHostLanguageValid(hl) {
|
|
1577
|
-
return hl.length <= 6 && /^\s*[a-zA-Z0-9\-]*\s*$/.test(hl);
|
|
1578
|
-
}
|
|
1579
|
-
var MockReCaptchaLoaderImpl = /** @class */ (function () {
|
|
1580
|
-
function MockReCaptchaLoaderImpl() {
|
|
1581
|
-
}
|
|
1582
|
-
MockReCaptchaLoaderImpl.prototype.load = function (auth) {
|
|
1583
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1584
|
-
return tslib.__generator(this, function (_a) {
|
|
1585
|
-
return [2 /*return*/, new MockReCaptcha(auth)];
|
|
1586
|
-
});
|
|
1587
|
-
});
|
|
1588
|
-
};
|
|
1589
|
-
MockReCaptchaLoaderImpl.prototype.clearedOneInstance = function () { };
|
|
1590
|
-
return MockReCaptchaLoaderImpl;
|
|
1591
|
-
}());
|
|
1592
|
-
|
|
1593
|
-
/**
|
|
1594
|
-
* @license
|
|
1595
|
-
* Copyright 2020 Google LLC
|
|
1596
|
-
*
|
|
1597
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1598
|
-
* you may not use this file except in compliance with the License.
|
|
1599
|
-
* You may obtain a copy of the License at
|
|
1600
|
-
*
|
|
1601
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1602
|
-
*
|
|
1603
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1604
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1605
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1606
|
-
* See the License for the specific language governing permissions and
|
|
1607
|
-
* limitations under the License.
|
|
1608
|
-
*/
|
|
1609
|
-
var RECAPTCHA_VERIFIER_TYPE = 'recaptcha';
|
|
1610
|
-
var DEFAULT_PARAMS = {
|
|
1611
|
-
theme: 'light',
|
|
1612
|
-
type: 'image'
|
|
1613
|
-
};
|
|
1614
|
-
/**
|
|
1615
|
-
* An {@link https://www.google.com/recaptcha/ | reCAPTCHA}-based application verifier.
|
|
1616
|
-
*
|
|
1617
|
-
* @public
|
|
1618
|
-
*/
|
|
1619
|
-
var RecaptchaVerifier = /** @class */ (function () {
|
|
1620
|
-
/**
|
|
1621
|
-
*
|
|
1622
|
-
* @param containerOrId - The reCAPTCHA container parameter.
|
|
1623
|
-
*
|
|
1624
|
-
* @remarks
|
|
1625
|
-
* This has different meaning depending on whether the reCAPTCHA is hidden or visible. For a
|
|
1626
|
-
* visible reCAPTCHA the container must be empty. If a string is used, it has to correspond to
|
|
1627
|
-
* an element ID. The corresponding element must also must be in the DOM at the time of
|
|
1628
|
-
* initialization.
|
|
1629
|
-
*
|
|
1630
|
-
* @param parameters - The optional reCAPTCHA parameters.
|
|
1631
|
-
*
|
|
1632
|
-
* @remarks
|
|
1633
|
-
* Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted except for
|
|
1634
|
-
* the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
|
|
1635
|
-
* configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
|
|
1636
|
-
* 'invisible'.
|
|
1637
|
-
*
|
|
1638
|
-
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
1639
|
-
*
|
|
1640
|
-
* @remarks
|
|
1641
|
-
* If none is provided, the default Firebase {@link Auth} instance is used. A Firebase {@link Auth} instance
|
|
1642
|
-
* must be initialized with an API key, otherwise an error will be thrown.
|
|
1643
|
-
*/
|
|
1644
|
-
function RecaptchaVerifier(containerOrId, parameters, authExtern) {
|
|
1645
|
-
if (parameters === void 0) { parameters = tslib.__assign({}, DEFAULT_PARAMS); }
|
|
1646
|
-
this.parameters = parameters;
|
|
1647
|
-
/**
|
|
1648
|
-
* The application verifier type.
|
|
1649
|
-
*
|
|
1650
|
-
* @remarks
|
|
1651
|
-
* For a reCAPTCHA verifier, this is 'recaptcha'.
|
|
1652
|
-
*/
|
|
1653
|
-
this.type = RECAPTCHA_VERIFIER_TYPE;
|
|
1654
|
-
this.destroyed = false;
|
|
1655
|
-
this.widgetId = null;
|
|
1656
|
-
this.tokenChangeListeners = new Set();
|
|
1657
|
-
this.renderPromise = null;
|
|
1658
|
-
this.recaptcha = null;
|
|
1659
|
-
this.auth = enum_maps._castAuth(authExtern);
|
|
1660
|
-
this.isInvisible = this.parameters.size === 'invisible';
|
|
1661
|
-
enum_maps._assert(typeof document !== 'undefined', this.auth, "operation-not-supported-in-this-environment" /* OPERATION_NOT_SUPPORTED */);
|
|
1662
|
-
var container = typeof containerOrId === 'string'
|
|
1663
|
-
? document.getElementById(containerOrId)
|
|
1664
|
-
: containerOrId;
|
|
1665
|
-
enum_maps._assert(container, this.auth, "argument-error" /* ARGUMENT_ERROR */);
|
|
1666
|
-
this.container = container;
|
|
1667
|
-
this.parameters.callback = this.makeTokenCallback(this.parameters.callback);
|
|
1668
|
-
this._recaptchaLoader = this.auth.settings.appVerificationDisabledForTesting
|
|
1669
|
-
? new MockReCaptchaLoaderImpl()
|
|
1670
|
-
: new ReCaptchaLoaderImpl();
|
|
1671
|
-
this.validateStartingState();
|
|
1672
|
-
// TODO: Figure out if sdk version is needed
|
|
1673
|
-
}
|
|
1674
|
-
/**
|
|
1675
|
-
* Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA token.
|
|
1676
|
-
*
|
|
1677
|
-
* @returns A Promise for the reCAPTCHA token.
|
|
1678
|
-
*/
|
|
1679
|
-
RecaptchaVerifier.prototype.verify = function () {
|
|
1680
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1681
|
-
var id, recaptcha, response;
|
|
1682
|
-
var _this = this;
|
|
1683
|
-
return tslib.__generator(this, function (_a) {
|
|
1684
|
-
switch (_a.label) {
|
|
1685
|
-
case 0:
|
|
1686
|
-
this.assertNotDestroyed();
|
|
1687
|
-
return [4 /*yield*/, this.render()];
|
|
1688
|
-
case 1:
|
|
1689
|
-
id = _a.sent();
|
|
1690
|
-
recaptcha = this.getAssertedRecaptcha();
|
|
1691
|
-
response = recaptcha.getResponse(id);
|
|
1692
|
-
if (response) {
|
|
1693
|
-
return [2 /*return*/, response];
|
|
1694
|
-
}
|
|
1695
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
1696
|
-
var tokenChange = function (token) {
|
|
1697
|
-
if (!token) {
|
|
1698
|
-
return; // Ignore token expirations.
|
|
1699
|
-
}
|
|
1700
|
-
_this.tokenChangeListeners.delete(tokenChange);
|
|
1701
|
-
resolve(token);
|
|
1702
|
-
};
|
|
1703
|
-
_this.tokenChangeListeners.add(tokenChange);
|
|
1704
|
-
if (_this.isInvisible) {
|
|
1705
|
-
recaptcha.execute(id);
|
|
1706
|
-
}
|
|
1707
|
-
})];
|
|
1708
|
-
}
|
|
1709
|
-
});
|
|
1710
|
-
});
|
|
1711
|
-
};
|
|
1712
|
-
/**
|
|
1713
|
-
* Renders the reCAPTCHA widget on the page.
|
|
1714
|
-
*
|
|
1715
|
-
* @returns A Promise that resolves with the reCAPTCHA widget ID.
|
|
1716
|
-
*/
|
|
1717
|
-
RecaptchaVerifier.prototype.render = function () {
|
|
1718
|
-
var _this = this;
|
|
1719
|
-
try {
|
|
1720
|
-
this.assertNotDestroyed();
|
|
1721
|
-
}
|
|
1722
|
-
catch (e) {
|
|
1723
|
-
// This method returns a promise. Since it's not async (we want to return the
|
|
1724
|
-
// _same_ promise if rendering is still occurring), the API surface should
|
|
1725
|
-
// reject with the error rather than just throw
|
|
1726
|
-
return Promise.reject(e);
|
|
1727
|
-
}
|
|
1728
|
-
if (this.renderPromise) {
|
|
1729
|
-
return this.renderPromise;
|
|
1730
|
-
}
|
|
1731
|
-
this.renderPromise = this.makeRenderPromise().catch(function (e) {
|
|
1732
|
-
_this.renderPromise = null;
|
|
1733
|
-
throw e;
|
|
1734
|
-
});
|
|
1735
|
-
return this.renderPromise;
|
|
1736
|
-
};
|
|
1737
|
-
/** @internal */
|
|
1738
|
-
RecaptchaVerifier.prototype._reset = function () {
|
|
1739
|
-
this.assertNotDestroyed();
|
|
1740
|
-
if (this.widgetId !== null) {
|
|
1741
|
-
this.getAssertedRecaptcha().reset(this.widgetId);
|
|
1742
|
-
}
|
|
1743
|
-
};
|
|
1744
|
-
/**
|
|
1745
|
-
* Clears the reCAPTCHA widget from the page and destroys the instance.
|
|
1746
|
-
*/
|
|
1747
|
-
RecaptchaVerifier.prototype.clear = function () {
|
|
1748
|
-
var _this = this;
|
|
1749
|
-
this.assertNotDestroyed();
|
|
1750
|
-
this.destroyed = true;
|
|
1751
|
-
this._recaptchaLoader.clearedOneInstance();
|
|
1752
|
-
if (!this.isInvisible) {
|
|
1753
|
-
this.container.childNodes.forEach(function (node) {
|
|
1754
|
-
_this.container.removeChild(node);
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1757
|
-
};
|
|
1758
|
-
RecaptchaVerifier.prototype.validateStartingState = function () {
|
|
1759
|
-
enum_maps._assert(!this.parameters.sitekey, this.auth, "argument-error" /* ARGUMENT_ERROR */);
|
|
1760
|
-
enum_maps._assert(this.isInvisible || !this.container.hasChildNodes(), this.auth, "argument-error" /* ARGUMENT_ERROR */);
|
|
1761
|
-
enum_maps._assert(typeof document !== 'undefined', this.auth, "operation-not-supported-in-this-environment" /* OPERATION_NOT_SUPPORTED */);
|
|
1762
|
-
};
|
|
1763
|
-
RecaptchaVerifier.prototype.makeTokenCallback = function (existing) {
|
|
1764
|
-
var _this = this;
|
|
1765
|
-
return function (token) {
|
|
1766
|
-
_this.tokenChangeListeners.forEach(function (listener) { return listener(token); });
|
|
1767
|
-
if (typeof existing === 'function') {
|
|
1768
|
-
existing(token);
|
|
1769
|
-
}
|
|
1770
|
-
else if (typeof existing === 'string') {
|
|
1771
|
-
var globalFunc = _window()[existing];
|
|
1772
|
-
if (typeof globalFunc === 'function') {
|
|
1773
|
-
globalFunc(token);
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
};
|
|
1777
|
-
};
|
|
1778
|
-
RecaptchaVerifier.prototype.assertNotDestroyed = function () {
|
|
1779
|
-
enum_maps._assert(!this.destroyed, this.auth, "internal-error" /* INTERNAL_ERROR */);
|
|
1780
|
-
};
|
|
1781
|
-
RecaptchaVerifier.prototype.makeRenderPromise = function () {
|
|
1782
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1783
|
-
var container, guaranteedEmpty;
|
|
1784
|
-
return tslib.__generator(this, function (_a) {
|
|
1785
|
-
switch (_a.label) {
|
|
1786
|
-
case 0: return [4 /*yield*/, this.init()];
|
|
1787
|
-
case 1:
|
|
1788
|
-
_a.sent();
|
|
1789
|
-
if (!this.widgetId) {
|
|
1790
|
-
container = this.container;
|
|
1791
|
-
if (!this.isInvisible) {
|
|
1792
|
-
guaranteedEmpty = document.createElement('div');
|
|
1793
|
-
container.appendChild(guaranteedEmpty);
|
|
1794
|
-
container = guaranteedEmpty;
|
|
1795
|
-
}
|
|
1796
|
-
this.widgetId = this.getAssertedRecaptcha().render(container, this.parameters);
|
|
1797
|
-
}
|
|
1798
|
-
return [2 /*return*/, this.widgetId];
|
|
1799
|
-
}
|
|
1800
|
-
});
|
|
1801
|
-
});
|
|
1802
|
-
};
|
|
1803
|
-
RecaptchaVerifier.prototype.init = function () {
|
|
1804
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1805
|
-
var _a, siteKey;
|
|
1806
|
-
return tslib.__generator(this, function (_b) {
|
|
1807
|
-
switch (_b.label) {
|
|
1808
|
-
case 0:
|
|
1809
|
-
enum_maps._assert(enum_maps._isHttpOrHttps() && !_isWorker(), this.auth, "internal-error" /* INTERNAL_ERROR */);
|
|
1810
|
-
return [4 /*yield*/, domReady()];
|
|
1811
|
-
case 1:
|
|
1812
|
-
_b.sent();
|
|
1813
|
-
_a = this;
|
|
1814
|
-
return [4 /*yield*/, this._recaptchaLoader.load(this.auth, this.auth.languageCode || undefined)];
|
|
1815
|
-
case 2:
|
|
1816
|
-
_a.recaptcha = _b.sent();
|
|
1817
|
-
return [4 /*yield*/, getRecaptchaParams(this.auth)];
|
|
1818
|
-
case 3:
|
|
1819
|
-
siteKey = _b.sent();
|
|
1820
|
-
enum_maps._assert(siteKey, this.auth, "internal-error" /* INTERNAL_ERROR */);
|
|
1821
|
-
this.parameters.sitekey = siteKey;
|
|
1822
|
-
return [2 /*return*/];
|
|
1823
|
-
}
|
|
1824
|
-
});
|
|
1825
|
-
});
|
|
1826
|
-
};
|
|
1827
|
-
RecaptchaVerifier.prototype.getAssertedRecaptcha = function () {
|
|
1828
|
-
enum_maps._assert(this.recaptcha, this.auth, "internal-error" /* INTERNAL_ERROR */);
|
|
1829
|
-
return this.recaptcha;
|
|
1830
|
-
};
|
|
1831
|
-
return RecaptchaVerifier;
|
|
1832
|
-
}());
|
|
1833
|
-
function domReady() {
|
|
1834
|
-
var resolver = null;
|
|
1835
|
-
return new Promise(function (resolve) {
|
|
1836
|
-
if (document.readyState === 'complete') {
|
|
1837
|
-
resolve();
|
|
1838
|
-
return;
|
|
1839
|
-
}
|
|
1840
|
-
// Document not ready, wait for load before resolving.
|
|
1841
|
-
// Save resolver, so we can remove listener in case it was externally
|
|
1842
|
-
// cancelled.
|
|
1843
|
-
resolver = function () { return resolve(); };
|
|
1844
|
-
window.addEventListener('load', resolver);
|
|
1845
|
-
}).catch(function (e) {
|
|
1846
|
-
if (resolver) {
|
|
1847
|
-
window.removeEventListener('load', resolver);
|
|
1848
|
-
}
|
|
1849
|
-
throw e;
|
|
1850
|
-
});
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
/**
|
|
1854
|
-
* @license
|
|
1855
|
-
* Copyright 2020 Google LLC
|
|
1856
|
-
*
|
|
1857
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1858
|
-
* you may not use this file except in compliance with the License.
|
|
1859
|
-
* You may obtain a copy of the License at
|
|
1860
|
-
*
|
|
1861
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1862
|
-
*
|
|
1863
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1864
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1865
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1866
|
-
* See the License for the specific language governing permissions and
|
|
1867
|
-
* limitations under the License.
|
|
1868
|
-
*/
|
|
1869
|
-
var ConfirmationResultImpl = /** @class */ (function () {
|
|
1870
|
-
function ConfirmationResultImpl(verificationId, onConfirmation) {
|
|
1871
|
-
this.verificationId = verificationId;
|
|
1872
|
-
this.onConfirmation = onConfirmation;
|
|
1873
|
-
}
|
|
1874
|
-
ConfirmationResultImpl.prototype.confirm = function (verificationCode) {
|
|
1875
|
-
var authCredential = enum_maps.PhoneAuthCredential._fromVerification(this.verificationId, verificationCode);
|
|
1876
|
-
return this.onConfirmation(authCredential);
|
|
1877
|
-
};
|
|
1878
|
-
return ConfirmationResultImpl;
|
|
1879
|
-
}());
|
|
1880
|
-
/**
|
|
1881
|
-
* Asynchronously signs in using a phone number.
|
|
1882
|
-
*
|
|
1883
|
-
* @remarks
|
|
1884
|
-
* This method sends a code via SMS to the given
|
|
1885
|
-
* phone number, and returns a {@link ConfirmationResult}. After the user
|
|
1886
|
-
* provides the code sent to their phone, call {@link ConfirmationResult.confirm}
|
|
1887
|
-
* with the code to sign the user in.
|
|
1888
|
-
*
|
|
1889
|
-
* For abuse prevention, this method also requires a {@link ApplicationVerifier}.
|
|
1890
|
-
* This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
|
|
1891
|
-
*
|
|
1892
|
-
* @example
|
|
1893
|
-
* ```javascript
|
|
1894
|
-
* // 'recaptcha-container' is the ID of an element in the DOM.
|
|
1895
|
-
* const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
|
|
1896
|
-
* const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
|
|
1897
|
-
* // Obtain a verificationCode from the user.
|
|
1898
|
-
* const credential = await confirmationResult.confirm(verificationCode);
|
|
1899
|
-
* ```
|
|
1900
|
-
*
|
|
1901
|
-
* @param auth - The {@link Auth} instance.
|
|
1902
|
-
* @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
|
|
1903
|
-
* @param appVerifier - The {@link ApplicationVerifier}.
|
|
1904
|
-
*
|
|
1905
|
-
* @public
|
|
1906
|
-
*/
|
|
1907
|
-
function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
|
|
1908
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1909
|
-
var authInternal, verificationId;
|
|
1910
|
-
return tslib.__generator(this, function (_a) {
|
|
1911
|
-
switch (_a.label) {
|
|
1912
|
-
case 0:
|
|
1913
|
-
authInternal = enum_maps._castAuth(auth);
|
|
1914
|
-
return [4 /*yield*/, _verifyPhoneNumber(authInternal, phoneNumber, util.getModularInstance(appVerifier))];
|
|
1915
|
-
case 1:
|
|
1916
|
-
verificationId = _a.sent();
|
|
1917
|
-
return [2 /*return*/, new ConfirmationResultImpl(verificationId, function (cred) {
|
|
1918
|
-
return enum_maps.signInWithCredential(authInternal, cred);
|
|
1919
|
-
})];
|
|
1920
|
-
}
|
|
1921
|
-
});
|
|
1922
|
-
});
|
|
1923
|
-
}
|
|
1924
|
-
/**
|
|
1925
|
-
* Links the user account with the given phone number.
|
|
1926
|
-
*
|
|
1927
|
-
* @param user - The user.
|
|
1928
|
-
* @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
|
|
1929
|
-
* @param appVerifier - The {@link ApplicationVerifier}.
|
|
1930
|
-
*
|
|
1931
|
-
* @public
|
|
1932
|
-
*/
|
|
1933
|
-
function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
|
|
1934
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1935
|
-
var userInternal, verificationId;
|
|
1936
|
-
return tslib.__generator(this, function (_a) {
|
|
1937
|
-
switch (_a.label) {
|
|
1938
|
-
case 0:
|
|
1939
|
-
userInternal = util.getModularInstance(user);
|
|
1940
|
-
return [4 /*yield*/, enum_maps._assertLinkedStatus(false, userInternal, "phone" /* PHONE */)];
|
|
1941
|
-
case 1:
|
|
1942
|
-
_a.sent();
|
|
1943
|
-
return [4 /*yield*/, _verifyPhoneNumber(userInternal.auth, phoneNumber, util.getModularInstance(appVerifier))];
|
|
1944
|
-
case 2:
|
|
1945
|
-
verificationId = _a.sent();
|
|
1946
|
-
return [2 /*return*/, new ConfirmationResultImpl(verificationId, function (cred) {
|
|
1947
|
-
return enum_maps.linkWithCredential(userInternal, cred);
|
|
1948
|
-
})];
|
|
1949
|
-
}
|
|
1950
|
-
});
|
|
1951
|
-
});
|
|
1952
|
-
}
|
|
1953
|
-
/**
|
|
1954
|
-
* Re-authenticates a user using a fresh phone credential.
|
|
1955
|
-
*
|
|
1956
|
-
* @remarks Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
|
|
1957
|
-
*
|
|
1958
|
-
* @param user - The user.
|
|
1959
|
-
* @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
|
|
1960
|
-
* @param appVerifier - The {@link ApplicationVerifier}.
|
|
1961
|
-
*
|
|
1962
|
-
* @public
|
|
1963
|
-
*/
|
|
1964
|
-
function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
|
|
1965
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1966
|
-
var userInternal, verificationId;
|
|
1967
|
-
return tslib.__generator(this, function (_a) {
|
|
1968
|
-
switch (_a.label) {
|
|
1969
|
-
case 0:
|
|
1970
|
-
userInternal = util.getModularInstance(user);
|
|
1971
|
-
return [4 /*yield*/, _verifyPhoneNumber(userInternal.auth, phoneNumber, util.getModularInstance(appVerifier))];
|
|
1972
|
-
case 1:
|
|
1973
|
-
verificationId = _a.sent();
|
|
1974
|
-
return [2 /*return*/, new ConfirmationResultImpl(verificationId, function (cred) {
|
|
1975
|
-
return enum_maps.reauthenticateWithCredential(userInternal, cred);
|
|
1049
|
+
this.localCache[key] = value;
|
|
1050
|
+
return [2 /*return*/, this.notifyServiceWorker(key)];
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}); })];
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
IndexedDBLocalPersistence.prototype._get = function (key) {
|
|
1058
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1059
|
+
var obj;
|
|
1060
|
+
return tslib.__generator(this, function (_a) {
|
|
1061
|
+
switch (_a.label) {
|
|
1062
|
+
case 0: return [4 /*yield*/, this._withRetries(function (db) {
|
|
1063
|
+
return getObject(db, key);
|
|
1976
1064
|
})];
|
|
1977
|
-
|
|
1065
|
+
case 1:
|
|
1066
|
+
obj = (_a.sent());
|
|
1067
|
+
this.localCache[key] = obj;
|
|
1068
|
+
return [2 /*return*/, obj];
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1978
1071
|
});
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
case 1:
|
|
1993
|
-
recaptchaToken = _b.sent();
|
|
1994
|
-
_b.label = 2;
|
|
1995
|
-
case 2:
|
|
1996
|
-
_b.trys.push([2, , 10, 11]);
|
|
1997
|
-
enum_maps._assert(typeof recaptchaToken === 'string', auth, "argument-error" /* ARGUMENT_ERROR */);
|
|
1998
|
-
enum_maps._assert(verifier.type === RECAPTCHA_VERIFIER_TYPE, auth, "argument-error" /* ARGUMENT_ERROR */);
|
|
1999
|
-
phoneInfoOptions = void 0;
|
|
2000
|
-
if (typeof options === 'string') {
|
|
2001
|
-
phoneInfoOptions = {
|
|
2002
|
-
phoneNumber: options
|
|
2003
|
-
};
|
|
2004
|
-
}
|
|
2005
|
-
else {
|
|
2006
|
-
phoneInfoOptions = options;
|
|
2007
|
-
}
|
|
2008
|
-
if (!('session' in phoneInfoOptions)) return [3 /*break*/, 7];
|
|
2009
|
-
session = phoneInfoOptions.session;
|
|
2010
|
-
if (!('phoneNumber' in phoneInfoOptions)) return [3 /*break*/, 4];
|
|
2011
|
-
enum_maps._assert(session.type === "enroll" /* ENROLL */, auth, "internal-error" /* INTERNAL_ERROR */);
|
|
2012
|
-
return [4 /*yield*/, enum_maps.startEnrollPhoneMfa(auth, {
|
|
2013
|
-
idToken: session.credential,
|
|
2014
|
-
phoneEnrollmentInfo: {
|
|
2015
|
-
phoneNumber: phoneInfoOptions.phoneNumber,
|
|
2016
|
-
recaptchaToken: recaptchaToken
|
|
1072
|
+
};
|
|
1073
|
+
IndexedDBLocalPersistence.prototype._remove = function (key) {
|
|
1074
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1075
|
+
var _this = this;
|
|
1076
|
+
return tslib.__generator(this, function (_a) {
|
|
1077
|
+
return [2 /*return*/, this._withPendingWrite(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
1078
|
+
return tslib.__generator(this, function (_a) {
|
|
1079
|
+
switch (_a.label) {
|
|
1080
|
+
case 0: return [4 /*yield*/, this._withRetries(function (db) { return _deleteObject(db, key); })];
|
|
1081
|
+
case 1:
|
|
1082
|
+
_a.sent();
|
|
1083
|
+
delete this.localCache[key];
|
|
1084
|
+
return [2 /*return*/, this.notifyServiceWorker(key)];
|
|
2017
1085
|
}
|
|
1086
|
+
});
|
|
1087
|
+
}); })];
|
|
1088
|
+
});
|
|
1089
|
+
});
|
|
1090
|
+
};
|
|
1091
|
+
IndexedDBLocalPersistence.prototype._poll = function () {
|
|
1092
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1093
|
+
var result, keys, keysInResult, _i, result_1, _a, key, value, _b, _c, localKey;
|
|
1094
|
+
return tslib.__generator(this, function (_d) {
|
|
1095
|
+
switch (_d.label) {
|
|
1096
|
+
case 0: return [4 /*yield*/, this._withRetries(function (db) {
|
|
1097
|
+
var getAllRequest = getObjectStore(db, false).getAll();
|
|
1098
|
+
return new DBPromise(getAllRequest).toPromise();
|
|
2018
1099
|
})];
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
1100
|
+
case 1:
|
|
1101
|
+
result = _d.sent();
|
|
1102
|
+
if (!result) {
|
|
1103
|
+
return [2 /*return*/, []];
|
|
1104
|
+
}
|
|
1105
|
+
// If we have pending writes in progress abort, we'll get picked up on the next poll
|
|
1106
|
+
if (this.pendingWrites !== 0) {
|
|
1107
|
+
return [2 /*return*/, []];
|
|
1108
|
+
}
|
|
1109
|
+
keys = [];
|
|
1110
|
+
keysInResult = new Set();
|
|
1111
|
+
for (_i = 0, result_1 = result; _i < result_1.length; _i++) {
|
|
1112
|
+
_a = result_1[_i], key = _a.fbase_key, value = _a.value;
|
|
1113
|
+
keysInResult.add(key);
|
|
1114
|
+
if (JSON.stringify(this.localCache[key]) !== JSON.stringify(value)) {
|
|
1115
|
+
this.notifyListeners(key, value);
|
|
1116
|
+
keys.push(key);
|
|
2032
1117
|
}
|
|
2033
|
-
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
case 9: return [3 /*break*/, 11];
|
|
2046
|
-
case 10:
|
|
2047
|
-
verifier._reset();
|
|
2048
|
-
return [7 /*endfinally*/];
|
|
2049
|
-
case 11: return [2 /*return*/];
|
|
2050
|
-
}
|
|
1118
|
+
}
|
|
1119
|
+
for (_b = 0, _c = Object.keys(this.localCache); _b < _c.length; _b++) {
|
|
1120
|
+
localKey = _c[_b];
|
|
1121
|
+
if (this.localCache[localKey] && !keysInResult.has(localKey)) {
|
|
1122
|
+
// Deleted
|
|
1123
|
+
this.notifyListeners(localKey, null);
|
|
1124
|
+
keys.push(localKey);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
return [2 /*return*/, keys];
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
2051
1130
|
});
|
|
2052
|
-
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
* const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
|
|
2061
|
-
* const provider = new PhoneAuthProvider(auth);
|
|
2062
|
-
* const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
|
|
2063
|
-
* // Obtain the verificationCode from the user.
|
|
2064
|
-
* const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
|
|
2065
|
-
* await updatePhoneNumber(user, phoneCredential);
|
|
2066
|
-
* ```
|
|
2067
|
-
*
|
|
2068
|
-
* @param user - The user.
|
|
2069
|
-
* @param credential - A credential authenticating the new phone number.
|
|
2070
|
-
*
|
|
2071
|
-
* @public
|
|
2072
|
-
*/
|
|
2073
|
-
function updatePhoneNumber(user, credential) {
|
|
2074
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2075
|
-
return tslib.__generator(this, function (_a) {
|
|
2076
|
-
switch (_a.label) {
|
|
2077
|
-
case 0: return [4 /*yield*/, enum_maps._link(util.getModularInstance(user), credential)];
|
|
2078
|
-
case 1:
|
|
2079
|
-
_a.sent();
|
|
2080
|
-
return [2 /*return*/];
|
|
1131
|
+
};
|
|
1132
|
+
IndexedDBLocalPersistence.prototype.notifyListeners = function (key, newValue) {
|
|
1133
|
+
this.localCache[key] = newValue;
|
|
1134
|
+
var listeners = this.listeners[key];
|
|
1135
|
+
if (listeners) {
|
|
1136
|
+
for (var _i = 0, _a = Array.from(listeners); _i < _a.length; _i++) {
|
|
1137
|
+
var listener = _a[_i];
|
|
1138
|
+
listener(newValue);
|
|
2081
1139
|
}
|
|
2082
|
-
}
|
|
2083
|
-
});
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
/**
|
|
2087
|
-
* @license
|
|
2088
|
-
* Copyright 2020 Google LLC
|
|
2089
|
-
*
|
|
2090
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2091
|
-
* you may not use this file except in compliance with the License.
|
|
2092
|
-
* You may obtain a copy of the License at
|
|
2093
|
-
*
|
|
2094
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2095
|
-
*
|
|
2096
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2097
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2098
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2099
|
-
* See the License for the specific language governing permissions and
|
|
2100
|
-
* limitations under the License.
|
|
2101
|
-
*/
|
|
2102
|
-
/**
|
|
2103
|
-
* Provider for generating an {@link PhoneAuthCredential}.
|
|
2104
|
-
*
|
|
2105
|
-
* @example
|
|
2106
|
-
* ```javascript
|
|
2107
|
-
* // 'recaptcha-container' is the ID of an element in the DOM.
|
|
2108
|
-
* const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
|
|
2109
|
-
* const provider = new PhoneAuthProvider(auth);
|
|
2110
|
-
* const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
|
|
2111
|
-
* // Obtain the verificationCode from the user.
|
|
2112
|
-
* const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
|
|
2113
|
-
* const userCredential = await signInWithCredential(auth, phoneCredential);
|
|
2114
|
-
* ```
|
|
2115
|
-
*
|
|
2116
|
-
* @public
|
|
2117
|
-
*/
|
|
2118
|
-
var PhoneAuthProvider = /** @class */ (function () {
|
|
2119
|
-
/**
|
|
2120
|
-
* @param auth - The Firebase {@link Auth} instance in which sign-ins should occur.
|
|
2121
|
-
*
|
|
2122
|
-
*/
|
|
2123
|
-
function PhoneAuthProvider(auth) {
|
|
2124
|
-
/** Always set to {@link ProviderId}.PHONE. */
|
|
2125
|
-
this.providerId = PhoneAuthProvider.PROVIDER_ID;
|
|
2126
|
-
this.auth = enum_maps._castAuth(auth);
|
|
2127
|
-
}
|
|
2128
|
-
/**
|
|
2129
|
-
*
|
|
2130
|
-
* Starts a phone number authentication flow by sending a verification code to the given phone
|
|
2131
|
-
* number.
|
|
2132
|
-
*
|
|
2133
|
-
* @example
|
|
2134
|
-
* ```javascript
|
|
2135
|
-
* const provider = new PhoneAuthProvider(auth);
|
|
2136
|
-
* const verificationId = await provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
|
|
2137
|
-
* // Obtain verificationCode from the user.
|
|
2138
|
-
* const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
|
|
2139
|
-
* const userCredential = await signInWithCredential(auth, authCredential);
|
|
2140
|
-
* ```
|
|
2141
|
-
*
|
|
2142
|
-
* @example
|
|
2143
|
-
* An alternative flow is provided using the `signInWithPhoneNumber` method.
|
|
2144
|
-
* ```javascript
|
|
2145
|
-
* const confirmationResult = signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
|
|
2146
|
-
* // Obtain verificationCode from the user.
|
|
2147
|
-
* const userCredential = confirmationResult.confirm(verificationCode);
|
|
2148
|
-
* ```
|
|
2149
|
-
*
|
|
2150
|
-
* @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
|
|
2151
|
-
* E.164 format (e.g. +16505550101).
|
|
2152
|
-
* @param applicationVerifier - For abuse prevention, this method also requires a
|
|
2153
|
-
* {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
|
|
2154
|
-
* {@link RecaptchaVerifier}.
|
|
2155
|
-
*
|
|
2156
|
-
* @returns A Promise for a verification ID that can be passed to
|
|
2157
|
-
* {@link PhoneAuthProvider.credential} to identify this flow..
|
|
2158
|
-
*/
|
|
2159
|
-
PhoneAuthProvider.prototype.verifyPhoneNumber = function (phoneOptions, applicationVerifier) {
|
|
2160
|
-
return _verifyPhoneNumber(this.auth, phoneOptions, util.getModularInstance(applicationVerifier));
|
|
1140
|
+
}
|
|
2161
1141
|
};
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
* ```javascript
|
|
2169
|
-
* const provider = new PhoneAuthProvider(auth);
|
|
2170
|
-
* const verificationId = provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
|
|
2171
|
-
* // Obtain verificationCode from the user.
|
|
2172
|
-
* const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
|
|
2173
|
-
* const userCredential = signInWithCredential(auth, authCredential);
|
|
2174
|
-
* ```
|
|
2175
|
-
*
|
|
2176
|
-
* @example
|
|
2177
|
-
* An alternative flow is provided using the `signInWithPhoneNumber` method.
|
|
2178
|
-
* ```javascript
|
|
2179
|
-
* const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
|
|
2180
|
-
* // Obtain verificationCode from the user.
|
|
2181
|
-
* const userCredential = await confirmationResult.confirm(verificationCode);
|
|
2182
|
-
* ```
|
|
2183
|
-
*
|
|
2184
|
-
* @param verificationId - The verification ID returned from {@link PhoneAuthProvider.verifyPhoneNumber}.
|
|
2185
|
-
* @param verificationCode - The verification code sent to the user's mobile device.
|
|
2186
|
-
*
|
|
2187
|
-
* @returns The auth provider credential.
|
|
2188
|
-
*/
|
|
2189
|
-
PhoneAuthProvider.credential = function (verificationId, verificationCode) {
|
|
2190
|
-
return enum_maps.PhoneAuthCredential._fromVerification(verificationId, verificationCode);
|
|
1142
|
+
IndexedDBLocalPersistence.prototype.startPolling = function () {
|
|
1143
|
+
var _this = this;
|
|
1144
|
+
this.stopPolling();
|
|
1145
|
+
this.pollTimer = setInterval(function () { return tslib.__awaiter(_this, void 0, void 0, function () { return tslib.__generator(this, function (_a) {
|
|
1146
|
+
return [2 /*return*/, this._poll()];
|
|
1147
|
+
}); }); }, _POLLING_INTERVAL_MS);
|
|
2191
1148
|
};
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
var credential = userCredential;
|
|
2198
|
-
return PhoneAuthProvider.credentialFromTaggedObject(credential);
|
|
1149
|
+
IndexedDBLocalPersistence.prototype.stopPolling = function () {
|
|
1150
|
+
if (this.pollTimer) {
|
|
1151
|
+
clearInterval(this.pollTimer);
|
|
1152
|
+
this.pollTimer = null;
|
|
1153
|
+
}
|
|
2199
1154
|
};
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
* fails, links the user with the account associated with that number:
|
|
2211
|
-
*
|
|
2212
|
-
* ```js
|
|
2213
|
-
* const provider = new PhoneAuthProvider(auth);
|
|
2214
|
-
* const verificationId = await provider.verifyPhoneNumber(number, verifier);
|
|
2215
|
-
* try {
|
|
2216
|
-
* const code = ''; // Prompt the user for the verification code
|
|
2217
|
-
* await updatePhoneNumber(
|
|
2218
|
-
* auth.currentUser,
|
|
2219
|
-
* PhoneAuthProvider.credential(verificationId, code));
|
|
2220
|
-
* } catch (e) {
|
|
2221
|
-
* if (e.code === 'auth/account-exists-with-different-credential') {
|
|
2222
|
-
* const cred = PhoneAuthProvider.credentialFromError(e);
|
|
2223
|
-
* await linkWithCredential(auth.currentUser, cred);
|
|
2224
|
-
* }
|
|
2225
|
-
* }
|
|
2226
|
-
*
|
|
2227
|
-
* // At this point, auth.currentUser.phoneNumber === number.
|
|
2228
|
-
* ```
|
|
2229
|
-
*
|
|
2230
|
-
* @param error - The error to generate a credential from.
|
|
2231
|
-
*/
|
|
2232
|
-
PhoneAuthProvider.credentialFromError = function (error) {
|
|
2233
|
-
return PhoneAuthProvider.credentialFromTaggedObject((error.customData || {}));
|
|
1155
|
+
IndexedDBLocalPersistence.prototype._addListener = function (key, listener) {
|
|
1156
|
+
if (Object.keys(this.listeners).length === 0) {
|
|
1157
|
+
this.startPolling();
|
|
1158
|
+
}
|
|
1159
|
+
if (!this.listeners[key]) {
|
|
1160
|
+
this.listeners[key] = new Set();
|
|
1161
|
+
// Populate the cache to avoid spuriously triggering on first poll.
|
|
1162
|
+
void this._get(key); // This can happen in the background async and we can return immediately.
|
|
1163
|
+
}
|
|
1164
|
+
this.listeners[key].add(listener);
|
|
2234
1165
|
};
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
1166
|
+
IndexedDBLocalPersistence.prototype._removeListener = function (key, listener) {
|
|
1167
|
+
if (this.listeners[key]) {
|
|
1168
|
+
this.listeners[key].delete(listener);
|
|
1169
|
+
if (this.listeners[key].size === 0) {
|
|
1170
|
+
delete this.listeners[key];
|
|
1171
|
+
}
|
|
2239
1172
|
}
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
return enum_maps.PhoneAuthCredential._fromTokenResponse(phoneNumber, temporaryProof);
|
|
1173
|
+
if (Object.keys(this.listeners).length === 0) {
|
|
1174
|
+
this.stopPolling();
|
|
2243
1175
|
}
|
|
2244
|
-
return null;
|
|
2245
1176
|
};
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
1177
|
+
IndexedDBLocalPersistence.type = 'LOCAL';
|
|
1178
|
+
return IndexedDBLocalPersistence;
|
|
1179
|
+
}());
|
|
1180
|
+
/**
|
|
1181
|
+
* An implementation of {@link Persistence} of type `LOCAL` using `indexedDB`
|
|
1182
|
+
* for the underlying storage.
|
|
1183
|
+
*
|
|
1184
|
+
* @public
|
|
1185
|
+
*/
|
|
1186
|
+
var indexedDBLocalPersistence = IndexedDBLocalPersistence;
|
|
2252
1187
|
|
|
2253
1188
|
/**
|
|
2254
1189
|
* @license
|
|
@@ -2273,9 +1208,9 @@ var PhoneAuthProvider = /** @class */ (function () {
|
|
|
2273
1208
|
*/
|
|
2274
1209
|
function _withDefaultResolver(auth, resolverOverride) {
|
|
2275
1210
|
if (resolverOverride) {
|
|
2276
|
-
return
|
|
1211
|
+
return phone._getInstance(resolverOverride);
|
|
2277
1212
|
}
|
|
2278
|
-
|
|
1213
|
+
phone._assert(auth._popupRedirectResolver, auth, "argument-error" /* ARGUMENT_ERROR */);
|
|
2279
1214
|
return auth._popupRedirectResolver;
|
|
2280
1215
|
}
|
|
2281
1216
|
|
|
@@ -2303,13 +1238,13 @@ var IdpCredential = /** @class */ (function (_super) {
|
|
|
2303
1238
|
return _this;
|
|
2304
1239
|
}
|
|
2305
1240
|
IdpCredential.prototype._getIdTokenResponse = function (auth) {
|
|
2306
|
-
return
|
|
1241
|
+
return phone.signInWithIdp(auth, this._buildIdpRequest());
|
|
2307
1242
|
};
|
|
2308
1243
|
IdpCredential.prototype._linkToIdToken = function (auth, idToken) {
|
|
2309
|
-
return
|
|
1244
|
+
return phone.signInWithIdp(auth, this._buildIdpRequest(idToken));
|
|
2310
1245
|
};
|
|
2311
1246
|
IdpCredential.prototype._getReauthenticationResolver = function (auth) {
|
|
2312
|
-
return
|
|
1247
|
+
return phone.signInWithIdp(auth, this._buildIdpRequest());
|
|
2313
1248
|
};
|
|
2314
1249
|
IdpCredential.prototype._buildIdpRequest = function (idToken) {
|
|
2315
1250
|
var request = {
|
|
@@ -2327,22 +1262,22 @@ var IdpCredential = /** @class */ (function (_super) {
|
|
|
2327
1262
|
return request;
|
|
2328
1263
|
};
|
|
2329
1264
|
return IdpCredential;
|
|
2330
|
-
}(
|
|
1265
|
+
}(phone.AuthCredential));
|
|
2331
1266
|
function _signIn(params) {
|
|
2332
|
-
return
|
|
1267
|
+
return phone._signInWithCredential(params.auth, new IdpCredential(params), params.bypassAuthState);
|
|
2333
1268
|
}
|
|
2334
1269
|
function _reauth(params) {
|
|
2335
1270
|
var auth = params.auth, user = params.user;
|
|
2336
|
-
|
|
2337
|
-
return
|
|
1271
|
+
phone._assert(user, auth, "internal-error" /* INTERNAL_ERROR */);
|
|
1272
|
+
return phone._reauthenticate(user, new IdpCredential(params), params.bypassAuthState);
|
|
2338
1273
|
}
|
|
2339
1274
|
function _link(params) {
|
|
2340
1275
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2341
1276
|
var auth, user;
|
|
2342
1277
|
return tslib.__generator(this, function (_a) {
|
|
2343
1278
|
auth = params.auth, user = params.user;
|
|
2344
|
-
|
|
2345
|
-
return [2 /*return*/,
|
|
1279
|
+
phone._assert(user, auth, "internal-error" /* INTERNAL_ERROR */);
|
|
1280
|
+
return [2 /*return*/, phone._link(user, new IdpCredential(params), params.bypassAuthState)];
|
|
2346
1281
|
});
|
|
2347
1282
|
});
|
|
2348
1283
|
}
|
|
@@ -2459,16 +1394,16 @@ var AbstractPopupRedirectOperation = /** @class */ (function () {
|
|
|
2459
1394
|
case "reauthViaRedirect" /* REAUTH_VIA_REDIRECT */:
|
|
2460
1395
|
return _reauth;
|
|
2461
1396
|
default:
|
|
2462
|
-
|
|
1397
|
+
phone._fail(this.auth, "internal-error" /* INTERNAL_ERROR */);
|
|
2463
1398
|
}
|
|
2464
1399
|
};
|
|
2465
1400
|
AbstractPopupRedirectOperation.prototype.resolve = function (cred) {
|
|
2466
|
-
|
|
1401
|
+
phone.debugAssert(this.pendingPromise, 'Pending promise was never set');
|
|
2467
1402
|
this.pendingPromise.resolve(cred);
|
|
2468
1403
|
this.unregisterAndCleanUp();
|
|
2469
1404
|
};
|
|
2470
1405
|
AbstractPopupRedirectOperation.prototype.reject = function (error) {
|
|
2471
|
-
|
|
1406
|
+
phone.debugAssert(this.pendingPromise, 'Pending promise was never set');
|
|
2472
1407
|
this.pendingPromise.reject(error);
|
|
2473
1408
|
this.unregisterAndCleanUp();
|
|
2474
1409
|
};
|
|
@@ -2498,7 +1433,7 @@ var AbstractPopupRedirectOperation = /** @class */ (function () {
|
|
|
2498
1433
|
* See the License for the specific language governing permissions and
|
|
2499
1434
|
* limitations under the License.
|
|
2500
1435
|
*/
|
|
2501
|
-
var _POLL_WINDOW_CLOSE_TIMEOUT = new
|
|
1436
|
+
var _POLL_WINDOW_CLOSE_TIMEOUT = new phone.Delay(2000, 10000);
|
|
2502
1437
|
/**
|
|
2503
1438
|
* Authenticates a Firebase client using a popup-based OAuth authentication flow.
|
|
2504
1439
|
*
|
|
@@ -2532,8 +1467,8 @@ function signInWithPopup(auth, provider, resolver) {
|
|
|
2532
1467
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2533
1468
|
var authInternal, resolverInternal, action;
|
|
2534
1469
|
return tslib.__generator(this, function (_a) {
|
|
2535
|
-
authInternal =
|
|
2536
|
-
|
|
1470
|
+
authInternal = phone._castAuth(auth);
|
|
1471
|
+
phone._assertInstanceOf(auth, provider, phone.FederatedAuthProvider);
|
|
2537
1472
|
resolverInternal = _withDefaultResolver(authInternal, resolver);
|
|
2538
1473
|
action = new PopupOperation(authInternal, "signInViaPopup" /* SIGN_IN_VIA_POPUP */, provider, resolverInternal);
|
|
2539
1474
|
return [2 /*return*/, action.executeNotNull()];
|
|
@@ -2570,7 +1505,7 @@ function reauthenticateWithPopup(user, provider, resolver) {
|
|
|
2570
1505
|
var userInternal, resolverInternal, action;
|
|
2571
1506
|
return tslib.__generator(this, function (_a) {
|
|
2572
1507
|
userInternal = util.getModularInstance(user);
|
|
2573
|
-
|
|
1508
|
+
phone._assertInstanceOf(userInternal.auth, provider, phone.FederatedAuthProvider);
|
|
2574
1509
|
resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
|
|
2575
1510
|
action = new PopupOperation(userInternal.auth, "reauthViaPopup" /* REAUTH_VIA_POPUP */, provider, resolverInternal, userInternal);
|
|
2576
1511
|
return [2 /*return*/, action.executeNotNull()];
|
|
@@ -2606,7 +1541,7 @@ function linkWithPopup(user, provider, resolver) {
|
|
|
2606
1541
|
var userInternal, resolverInternal, action;
|
|
2607
1542
|
return tslib.__generator(this, function (_a) {
|
|
2608
1543
|
userInternal = util.getModularInstance(user);
|
|
2609
|
-
|
|
1544
|
+
phone._assertInstanceOf(userInternal.auth, provider, phone.FederatedAuthProvider);
|
|
2610
1545
|
resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
|
|
2611
1546
|
action = new PopupOperation(userInternal.auth, "linkViaPopup" /* LINK_VIA_POPUP */, provider, resolverInternal, userInternal);
|
|
2612
1547
|
return [2 /*return*/, action.executeNotNull()];
|
|
@@ -2639,7 +1574,7 @@ var PopupOperation = /** @class */ (function (_super) {
|
|
|
2639
1574
|
case 0: return [4 /*yield*/, this.execute()];
|
|
2640
1575
|
case 1:
|
|
2641
1576
|
result = _a.sent();
|
|
2642
|
-
|
|
1577
|
+
phone._assert(result, this.auth, "internal-error" /* INTERNAL_ERROR */);
|
|
2643
1578
|
return [2 /*return*/, result];
|
|
2644
1579
|
}
|
|
2645
1580
|
});
|
|
@@ -2652,7 +1587,7 @@ var PopupOperation = /** @class */ (function (_super) {
|
|
|
2652
1587
|
return tslib.__generator(this, function (_b) {
|
|
2653
1588
|
switch (_b.label) {
|
|
2654
1589
|
case 0:
|
|
2655
|
-
|
|
1590
|
+
phone.debugAssert(this.filter.length === 1, 'Popup operations only handle one event');
|
|
2656
1591
|
eventId = _generateEventId();
|
|
2657
1592
|
_a = this;
|
|
2658
1593
|
return [4 /*yield*/, this.resolver._openPopup(this.auth, this.provider, this.filter[0], // There's always one, see constructor
|
|
@@ -2672,7 +1607,7 @@ var PopupOperation = /** @class */ (function (_super) {
|
|
|
2672
1607
|
});
|
|
2673
1608
|
this.resolver._isIframeWebStorageSupported(this.auth, function (isSupported) {
|
|
2674
1609
|
if (!isSupported) {
|
|
2675
|
-
_this.reject(
|
|
1610
|
+
_this.reject(phone._createError(_this.auth, "web-storage-unsupported" /* WEB_STORAGE_UNSUPPORTED */));
|
|
2676
1611
|
}
|
|
2677
1612
|
});
|
|
2678
1613
|
// Handle user closure. Notice this does *not* use await
|
|
@@ -2691,7 +1626,7 @@ var PopupOperation = /** @class */ (function (_super) {
|
|
|
2691
1626
|
configurable: true
|
|
2692
1627
|
});
|
|
2693
1628
|
PopupOperation.prototype.cancel = function () {
|
|
2694
|
-
this.reject(
|
|
1629
|
+
this.reject(phone._createError(this.auth, "cancelled-popup-request" /* EXPIRED_POPUP_REQUEST */));
|
|
2695
1630
|
};
|
|
2696
1631
|
PopupOperation.prototype.cleanUp = function () {
|
|
2697
1632
|
if (this.authWindow) {
|
|
@@ -2714,7 +1649,7 @@ var PopupOperation = /** @class */ (function (_super) {
|
|
|
2714
1649
|
// call could still be in flight.
|
|
2715
1650
|
_this.pollId = window.setTimeout(function () {
|
|
2716
1651
|
_this.pollId = null;
|
|
2717
|
-
_this.reject(
|
|
1652
|
+
_this.reject(phone._createError(_this.auth, "popup-closed-by-user" /* POPUP_CLOSED_BY_USER */));
|
|
2718
1653
|
}, 2000 /* AUTH_EVENT */);
|
|
2719
1654
|
return;
|
|
2720
1655
|
}
|
|
@@ -2798,7 +1733,13 @@ var RedirectAction = /** @class */ (function (_super) {
|
|
|
2798
1733
|
case 7:
|
|
2799
1734
|
redirectOutcomeMap.set(this.auth._key(), readyOutcome);
|
|
2800
1735
|
_b.label = 8;
|
|
2801
|
-
case 8:
|
|
1736
|
+
case 8:
|
|
1737
|
+
// If we're not bypassing auth state, the ready outcome should be set to
|
|
1738
|
+
// null.
|
|
1739
|
+
if (!this.bypassAuthState) {
|
|
1740
|
+
redirectOutcomeMap.set(this.auth._key(), function () { return Promise.resolve(null); });
|
|
1741
|
+
}
|
|
1742
|
+
return [2 /*return*/, readyOutcome()];
|
|
2802
1743
|
}
|
|
2803
1744
|
});
|
|
2804
1745
|
});
|
|
@@ -2844,16 +1785,22 @@ var RedirectAction = /** @class */ (function (_super) {
|
|
|
2844
1785
|
}(AbstractPopupRedirectOperation));
|
|
2845
1786
|
function _getAndClearPendingRedirectStatus(resolver, auth) {
|
|
2846
1787
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2847
|
-
var key, hasPendingRedirect;
|
|
1788
|
+
var key, persistence, hasPendingRedirect;
|
|
2848
1789
|
return tslib.__generator(this, function (_a) {
|
|
2849
1790
|
switch (_a.label) {
|
|
2850
1791
|
case 0:
|
|
2851
1792
|
key = pendingRedirectKey(auth);
|
|
2852
|
-
|
|
1793
|
+
persistence = resolverPersistence(resolver);
|
|
1794
|
+
return [4 /*yield*/, persistence._isAvailable()];
|
|
2853
1795
|
case 1:
|
|
2854
|
-
|
|
2855
|
-
|
|
1796
|
+
if (!(_a.sent())) {
|
|
1797
|
+
return [2 /*return*/, false];
|
|
1798
|
+
}
|
|
1799
|
+
return [4 /*yield*/, persistence._get(key)];
|
|
2856
1800
|
case 2:
|
|
1801
|
+
hasPendingRedirect = (_a.sent()) === 'true';
|
|
1802
|
+
return [4 /*yield*/, persistence._remove(key)];
|
|
1803
|
+
case 3:
|
|
2857
1804
|
_a.sent();
|
|
2858
1805
|
return [2 /*return*/, hasPendingRedirect];
|
|
2859
1806
|
}
|
|
@@ -2871,10 +1818,10 @@ function _clearRedirectOutcomes() {
|
|
|
2871
1818
|
redirectOutcomeMap.clear();
|
|
2872
1819
|
}
|
|
2873
1820
|
function resolverPersistence(resolver) {
|
|
2874
|
-
return
|
|
1821
|
+
return phone._getInstance(resolver._redirectPersistence);
|
|
2875
1822
|
}
|
|
2876
1823
|
function pendingRedirectKey(auth) {
|
|
2877
|
-
return
|
|
1824
|
+
return phone._persistenceKeyName(PENDING_REDIRECT_KEY, auth.config.apiKey, auth.name);
|
|
2878
1825
|
}
|
|
2879
1826
|
|
|
2880
1827
|
/**
|
|
@@ -2941,8 +1888,8 @@ function _signInWithRedirect(auth, provider, resolver) {
|
|
|
2941
1888
|
return tslib.__generator(this, function (_a) {
|
|
2942
1889
|
switch (_a.label) {
|
|
2943
1890
|
case 0:
|
|
2944
|
-
authInternal =
|
|
2945
|
-
|
|
1891
|
+
authInternal = phone._castAuth(auth);
|
|
1892
|
+
phone._assertInstanceOf(auth, provider, phone.FederatedAuthProvider);
|
|
2946
1893
|
resolverInternal = _withDefaultResolver(authInternal, resolver);
|
|
2947
1894
|
return [4 /*yield*/, _setPendingRedirectStatus(resolverInternal, authInternal)];
|
|
2948
1895
|
case 1:
|
|
@@ -2990,7 +1937,7 @@ function _reauthenticateWithRedirect(user, provider, resolver) {
|
|
|
2990
1937
|
switch (_a.label) {
|
|
2991
1938
|
case 0:
|
|
2992
1939
|
userInternal = util.getModularInstance(user);
|
|
2993
|
-
|
|
1940
|
+
phone._assertInstanceOf(userInternal.auth, provider, phone.FederatedAuthProvider);
|
|
2994
1941
|
resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
|
|
2995
1942
|
return [4 /*yield*/, _setPendingRedirectStatus(resolverInternal, userInternal.auth)];
|
|
2996
1943
|
case 1:
|
|
@@ -3038,9 +1985,9 @@ function _linkWithRedirect(user, provider, resolver) {
|
|
|
3038
1985
|
switch (_a.label) {
|
|
3039
1986
|
case 0:
|
|
3040
1987
|
userInternal = util.getModularInstance(user);
|
|
3041
|
-
|
|
1988
|
+
phone._assertInstanceOf(userInternal.auth, provider, phone.FederatedAuthProvider);
|
|
3042
1989
|
resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
|
|
3043
|
-
return [4 /*yield*/,
|
|
1990
|
+
return [4 /*yield*/, phone._assertLinkedStatus(false, userInternal, provider.providerId)];
|
|
3044
1991
|
case 1:
|
|
3045
1992
|
_a.sent();
|
|
3046
1993
|
return [4 /*yield*/, _setPendingRedirectStatus(resolverInternal, userInternal.auth)];
|
|
@@ -3097,7 +2044,7 @@ function getRedirectResult(auth, resolver) {
|
|
|
3097
2044
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
3098
2045
|
return tslib.__generator(this, function (_a) {
|
|
3099
2046
|
switch (_a.label) {
|
|
3100
|
-
case 0: return [4 /*yield*/,
|
|
2047
|
+
case 0: return [4 /*yield*/, phone._castAuth(auth)._initializationPromise];
|
|
3101
2048
|
case 1:
|
|
3102
2049
|
_a.sent();
|
|
3103
2050
|
return [2 /*return*/, _getRedirectResult(auth, resolver, false)];
|
|
@@ -3112,7 +2059,7 @@ function _getRedirectResult(auth, resolverExtern, bypassAuthState) {
|
|
|
3112
2059
|
return tslib.__generator(this, function (_a) {
|
|
3113
2060
|
switch (_a.label) {
|
|
3114
2061
|
case 0:
|
|
3115
|
-
authInternal =
|
|
2062
|
+
authInternal = phone._castAuth(auth);
|
|
3116
2063
|
resolver = _withDefaultResolver(authInternal, resolverExtern);
|
|
3117
2064
|
action = new RedirectAction(authInternal, resolver, bypassAuthState);
|
|
3118
2065
|
return [4 /*yield*/, action.execute()];
|
|
@@ -3224,7 +2171,7 @@ var AuthEventManager = /** @class */ (function () {
|
|
|
3224
2171
|
if (event.error && !isNullRedirectEvent(event)) {
|
|
3225
2172
|
var code = ((_a = event.error.code) === null || _a === void 0 ? void 0 : _a.split('auth/')[1]) ||
|
|
3226
2173
|
"internal-error" /* INTERNAL_ERROR */;
|
|
3227
|
-
consumer.onError(
|
|
2174
|
+
consumer.onError(phone._createError(this.auth, code));
|
|
3228
2175
|
}
|
|
3229
2176
|
else {
|
|
3230
2177
|
consumer.onAuthEvent(event);
|
|
@@ -3289,7 +2236,7 @@ function _getProjectConfig(auth, request) {
|
|
|
3289
2236
|
if (request === void 0) { request = {}; }
|
|
3290
2237
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
3291
2238
|
return tslib.__generator(this, function (_a) {
|
|
3292
|
-
return [2 /*return*/,
|
|
2239
|
+
return [2 /*return*/, phone._performApiRequest(auth, "GET" /* GET */, "/v1/projects" /* GET_PROJECT_CONFIG */, request)];
|
|
3293
2240
|
});
|
|
3294
2241
|
});
|
|
3295
2242
|
}
|
|
@@ -3337,14 +2284,14 @@ function _validateOrigin$1(auth) {
|
|
|
3337
2284
|
}
|
|
3338
2285
|
}
|
|
3339
2286
|
// In the old SDK, this error also provides helpful messages.
|
|
3340
|
-
|
|
2287
|
+
phone._fail(auth, "unauthorized-domain" /* INVALID_ORIGIN */);
|
|
3341
2288
|
return [2 /*return*/];
|
|
3342
2289
|
}
|
|
3343
2290
|
});
|
|
3344
2291
|
});
|
|
3345
2292
|
}
|
|
3346
2293
|
function matchDomain(expected) {
|
|
3347
|
-
var currentUrl =
|
|
2294
|
+
var currentUrl = phone._getCurrentUrl();
|
|
3348
2295
|
var _a = new URL(currentUrl), protocol = _a.protocol, hostname = _a.hostname;
|
|
3349
2296
|
if (expected.startsWith('chrome-extension://')) {
|
|
3350
2297
|
var ceUrl = new URL(expected);
|
|
@@ -3388,7 +2335,7 @@ function matchDomain(expected) {
|
|
|
3388
2335
|
* See the License for the specific language governing permissions and
|
|
3389
2336
|
* limitations under the License.
|
|
3390
2337
|
*/
|
|
3391
|
-
var NETWORK_TIMEOUT = new
|
|
2338
|
+
var NETWORK_TIMEOUT = new phone.Delay(30000, 60000);
|
|
3392
2339
|
/**
|
|
3393
2340
|
* Reset unlaoded GApi modules. If gapi.load fails due to a network error,
|
|
3394
2341
|
* it will stop working after a retrial. This is a hack to fix this issue.
|
|
@@ -3397,7 +2344,7 @@ function resetUnloadedGapiModules() {
|
|
|
3397
2344
|
// Clear last failed gapi.load state to force next gapi.load to first
|
|
3398
2345
|
// load the failed gapi.iframes module.
|
|
3399
2346
|
// Get gapix.beacon context.
|
|
3400
|
-
var beacon = _window().___jsl;
|
|
2347
|
+
var beacon = phone._window().___jsl;
|
|
3401
2348
|
// Get current hint.
|
|
3402
2349
|
if (beacon === null || beacon === void 0 ? void 0 : beacon.H) {
|
|
3403
2350
|
// Get gapi hint.
|
|
@@ -3439,16 +2386,16 @@ function loadGapi(auth) {
|
|
|
3439
2386
|
// failed attempt.
|
|
3440
2387
|
// Timeout when gapi.iframes.Iframe not loaded.
|
|
3441
2388
|
resetUnloadedGapiModules();
|
|
3442
|
-
reject(
|
|
2389
|
+
reject(phone._createError(auth, "network-request-failed" /* NETWORK_REQUEST_FAILED */));
|
|
3443
2390
|
},
|
|
3444
2391
|
timeout: NETWORK_TIMEOUT.get()
|
|
3445
2392
|
});
|
|
3446
2393
|
}
|
|
3447
|
-
if ((_b = (_a = _window().gapi) === null || _a === void 0 ? void 0 : _a.iframes) === null || _b === void 0 ? void 0 : _b.Iframe) {
|
|
2394
|
+
if ((_b = (_a = phone._window().gapi) === null || _a === void 0 ? void 0 : _a.iframes) === null || _b === void 0 ? void 0 : _b.Iframe) {
|
|
3448
2395
|
// If gapi.iframes.Iframe available, resolve.
|
|
3449
2396
|
resolve(gapi.iframes.getContext());
|
|
3450
2397
|
}
|
|
3451
|
-
else if (!!((_c = _window().gapi) === null || _c === void 0 ? void 0 : _c.load)) {
|
|
2398
|
+
else if (!!((_c = phone._window().gapi) === null || _c === void 0 ? void 0 : _c.load)) {
|
|
3452
2399
|
// Gapi loader ready, load gapi.iframes.
|
|
3453
2400
|
loadGapiIframe();
|
|
3454
2401
|
}
|
|
@@ -3458,20 +2405,20 @@ function loadGapi(auth) {
|
|
|
3458
2405
|
// multiple times in parallel and could result in the later callback
|
|
3459
2406
|
// overwriting the previous one. This would end up with a iframe
|
|
3460
2407
|
// timeout.
|
|
3461
|
-
var cbName = _generateCallbackName('iframefcb');
|
|
2408
|
+
var cbName = phone._generateCallbackName('iframefcb');
|
|
3462
2409
|
// GApi loader not available, dynamically load platform.js.
|
|
3463
|
-
_window()[cbName] = function () {
|
|
2410
|
+
phone._window()[cbName] = function () {
|
|
3464
2411
|
// GApi loader should be ready.
|
|
3465
2412
|
if (!!gapi.load) {
|
|
3466
2413
|
loadGapiIframe();
|
|
3467
2414
|
}
|
|
3468
2415
|
else {
|
|
3469
2416
|
// Gapi loader failed, throw error.
|
|
3470
|
-
reject(
|
|
2417
|
+
reject(phone._createError(auth, "network-request-failed" /* NETWORK_REQUEST_FAILED */));
|
|
3471
2418
|
}
|
|
3472
2419
|
};
|
|
3473
2420
|
// Load GApi loader.
|
|
3474
|
-
return _loadJS("https://apis.google.com/js/api.js?onload=" + cbName);
|
|
2421
|
+
return phone._loadJS("https://apis.google.com/js/api.js?onload=" + cbName);
|
|
3475
2422
|
}
|
|
3476
2423
|
}).catch(function (error) {
|
|
3477
2424
|
// Reset cached promise to allow for retrial.
|
|
@@ -3501,7 +2448,7 @@ function _loadGapi(auth) {
|
|
|
3501
2448
|
* See the License for the specific language governing permissions and
|
|
3502
2449
|
* limitations under the License.
|
|
3503
2450
|
*/
|
|
3504
|
-
var PING_TIMEOUT = new
|
|
2451
|
+
var PING_TIMEOUT = new phone.Delay(5000, 15000);
|
|
3505
2452
|
var IFRAME_PATH = '__/auth/iframe';
|
|
3506
2453
|
var EMULATED_IFRAME_PATH = 'emulator/auth/iframe';
|
|
3507
2454
|
var IFRAME_ATTRIBUTES = {
|
|
@@ -3510,7 +2457,8 @@ var IFRAME_ATTRIBUTES = {
|
|
|
3510
2457
|
top: '-100px',
|
|
3511
2458
|
width: '1px',
|
|
3512
2459
|
height: '1px'
|
|
3513
|
-
}
|
|
2460
|
+
},
|
|
2461
|
+
'aria-hidden': 'true'
|
|
3514
2462
|
};
|
|
3515
2463
|
// Map from apiHost to endpoint ID for passing into iframe. In current SDK, apiHost can be set to
|
|
3516
2464
|
// anything (not from a list of endpoints with IDs as in legacy), so this is the closest we can get.
|
|
@@ -3521,9 +2469,9 @@ var EID_FROM_APIHOST = new Map([
|
|
|
3521
2469
|
]);
|
|
3522
2470
|
function getIframeUrl(auth) {
|
|
3523
2471
|
var config = auth.config;
|
|
3524
|
-
|
|
2472
|
+
phone._assert(config.authDomain, auth, "auth-domain-config-required" /* MISSING_AUTH_DOMAIN */);
|
|
3525
2473
|
var url = config.emulator
|
|
3526
|
-
?
|
|
2474
|
+
? phone._emulatorUrl(config, EMULATED_IFRAME_PATH)
|
|
3527
2475
|
: "https://" + auth.config.authDomain + "/" + IFRAME_PATH;
|
|
3528
2476
|
var params = {
|
|
3529
2477
|
apiKey: config.apiKey,
|
|
@@ -3549,8 +2497,8 @@ function _openIframe(auth) {
|
|
|
3549
2497
|
case 0: return [4 /*yield*/, _loadGapi(auth)];
|
|
3550
2498
|
case 1:
|
|
3551
2499
|
context = _a.sent();
|
|
3552
|
-
gapi = _window().gapi;
|
|
3553
|
-
|
|
2500
|
+
gapi = phone._window().gapi;
|
|
2501
|
+
phone._assert(gapi, auth, "internal-error" /* INTERNAL_ERROR */);
|
|
3554
2502
|
return [2 /*return*/, context.open({
|
|
3555
2503
|
where: document.body,
|
|
3556
2504
|
url: getIframeUrl(auth),
|
|
@@ -3561,7 +2509,7 @@ function _openIframe(auth) {
|
|
|
3561
2509
|
return new Promise(function (resolve, reject) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
3562
2510
|
// Clear timer and resolve pending iframe ready promise.
|
|
3563
2511
|
function clearTimerAndResolve() {
|
|
3564
|
-
_window().clearTimeout(networkErrorTimer);
|
|
2512
|
+
phone._window().clearTimeout(networkErrorTimer);
|
|
3565
2513
|
resolve(iframe);
|
|
3566
2514
|
}
|
|
3567
2515
|
var networkError, networkErrorTimer;
|
|
@@ -3573,8 +2521,8 @@ function _openIframe(auth) {
|
|
|
3573
2521
|
})];
|
|
3574
2522
|
case 1:
|
|
3575
2523
|
_a.sent();
|
|
3576
|
-
networkError =
|
|
3577
|
-
networkErrorTimer = _window().setTimeout(function () {
|
|
2524
|
+
networkError = phone._createError(auth, "network-request-failed" /* NETWORK_REQUEST_FAILED */);
|
|
2525
|
+
networkErrorTimer = phone._window().setTimeout(function () {
|
|
3578
2526
|
reject(networkError);
|
|
3579
2527
|
}, PING_TIMEOUT.get());
|
|
3580
2528
|
// This returns an IThenable. However the reject part does not call
|
|
@@ -3645,9 +2593,9 @@ function _open(auth, url, name, width, height) {
|
|
|
3645
2593
|
// specified, even though the popup is not necessarily blocked.
|
|
3646
2594
|
var ua = util.getUA().toLowerCase();
|
|
3647
2595
|
if (name) {
|
|
3648
|
-
target =
|
|
2596
|
+
target = phone._isChromeIOS(ua) ? TARGET_BLANK : name;
|
|
3649
2597
|
}
|
|
3650
|
-
if (
|
|
2598
|
+
if (phone._isFirefox(ua)) {
|
|
3651
2599
|
// Firefox complains when invalid URLs are popped out. Hacky way to bypass.
|
|
3652
2600
|
url = url || FIREFOX_EMPTY_URL;
|
|
3653
2601
|
// Firefox disables by default scrolling on popup windows, which can create
|
|
@@ -3658,14 +2606,14 @@ function _open(auth, url, name, width, height) {
|
|
|
3658
2606
|
var key = _a[0], value = _a[1];
|
|
3659
2607
|
return "" + accum + key + "=" + value + ",";
|
|
3660
2608
|
}, '');
|
|
3661
|
-
if (
|
|
2609
|
+
if (phone._isIOSStandalone(ua) && target !== '_self') {
|
|
3662
2610
|
openAsNewWindowIOS(url || '', target);
|
|
3663
2611
|
return new AuthPopup(null);
|
|
3664
2612
|
}
|
|
3665
2613
|
// about:blank getting sanitized causing browsers like IE/Edge to display
|
|
3666
2614
|
// brief error message before redirecting to handler.
|
|
3667
2615
|
var newWin = window.open(url || '', target, optionsString);
|
|
3668
|
-
|
|
2616
|
+
phone._assert(newWin, auth, "popup-blocked" /* POPUP_BLOCKED */);
|
|
3669
2617
|
// Flaky on IE edge, encapsulate with a try and catch.
|
|
3670
2618
|
try {
|
|
3671
2619
|
newWin.focus();
|
|
@@ -3711,8 +2659,8 @@ var WIDGET_PATH = '__/auth/handler';
|
|
|
3711
2659
|
*/
|
|
3712
2660
|
var EMULATOR_WIDGET_PATH = 'emulator/auth/handler';
|
|
3713
2661
|
function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additionalParams) {
|
|
3714
|
-
|
|
3715
|
-
|
|
2662
|
+
phone._assert(auth.config.authDomain, auth, "auth-domain-config-required" /* MISSING_AUTH_DOMAIN */);
|
|
2663
|
+
phone._assert(auth.config.apiKey, auth, "invalid-api-key" /* INVALID_API_KEY */);
|
|
3716
2664
|
var params = {
|
|
3717
2665
|
apiKey: auth.config.apiKey,
|
|
3718
2666
|
appName: auth.name,
|
|
@@ -3721,7 +2669,7 @@ function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additio
|
|
|
3721
2669
|
v: app.SDK_VERSION,
|
|
3722
2670
|
eventId: eventId
|
|
3723
2671
|
};
|
|
3724
|
-
if (provider instanceof
|
|
2672
|
+
if (provider instanceof phone.FederatedAuthProvider) {
|
|
3725
2673
|
provider.setDefaultLanguage(auth.languageCode);
|
|
3726
2674
|
params.providerId = provider.providerId || '';
|
|
3727
2675
|
if (!util.isEmpty(provider.getCustomParameters())) {
|
|
@@ -3733,7 +2681,7 @@ function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additio
|
|
|
3733
2681
|
params[key] = value;
|
|
3734
2682
|
}
|
|
3735
2683
|
}
|
|
3736
|
-
if (provider instanceof
|
|
2684
|
+
if (provider instanceof phone.BaseOAuthProvider) {
|
|
3737
2685
|
var scopes = provider.getScopes().filter(function (scope) { return scope !== ''; });
|
|
3738
2686
|
if (scopes.length > 0) {
|
|
3739
2687
|
params.scopes = scopes.join(',');
|
|
@@ -3758,7 +2706,7 @@ function getHandlerBase(_a) {
|
|
|
3758
2706
|
if (!config.emulator) {
|
|
3759
2707
|
return "https://" + config.authDomain + "/" + WIDGET_PATH;
|
|
3760
2708
|
}
|
|
3761
|
-
return
|
|
2709
|
+
return phone._emulatorUrl(config, EMULATOR_WIDGET_PATH);
|
|
3762
2710
|
}
|
|
3763
2711
|
|
|
3764
2712
|
/**
|
|
@@ -3797,8 +2745,8 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
|
|
|
3797
2745
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
3798
2746
|
var url;
|
|
3799
2747
|
return tslib.__generator(this, function (_b) {
|
|
3800
|
-
|
|
3801
|
-
url = _getRedirectUrl(auth, provider, authType,
|
|
2748
|
+
phone.debugAssert((_a = this.eventManagers[auth._key()]) === null || _a === void 0 ? void 0 : _a.manager, '_initialize() not called before _openPopup()');
|
|
2749
|
+
url = _getRedirectUrl(auth, provider, authType, phone._getCurrentUrl(), eventId);
|
|
3802
2750
|
return [2 /*return*/, _open(auth, url, _generateEventId())];
|
|
3803
2751
|
});
|
|
3804
2752
|
});
|
|
@@ -3810,7 +2758,7 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
|
|
|
3810
2758
|
case 0: return [4 /*yield*/, this._originValidation(auth)];
|
|
3811
2759
|
case 1:
|
|
3812
2760
|
_a.sent();
|
|
3813
|
-
_setWindowLocation(_getRedirectUrl(auth, provider, authType,
|
|
2761
|
+
phone._setWindowLocation(_getRedirectUrl(auth, provider, authType, phone._getCurrentUrl(), eventId));
|
|
3814
2762
|
return [2 /*return*/, new Promise(function () { })];
|
|
3815
2763
|
}
|
|
3816
2764
|
});
|
|
@@ -3824,7 +2772,7 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
|
|
|
3824
2772
|
return Promise.resolve(manager);
|
|
3825
2773
|
}
|
|
3826
2774
|
else {
|
|
3827
|
-
|
|
2775
|
+
phone.debugAssert(promise_1, 'If manager is not set, promise should be');
|
|
3828
2776
|
return promise_1;
|
|
3829
2777
|
}
|
|
3830
2778
|
}
|
|
@@ -3842,7 +2790,7 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
|
|
|
3842
2790
|
iframe = _a.sent();
|
|
3843
2791
|
manager = new AuthEventManager(auth);
|
|
3844
2792
|
iframe.register('authEvent', function (iframeEvent) {
|
|
3845
|
-
|
|
2793
|
+
phone._assert(iframeEvent === null || iframeEvent === void 0 ? void 0 : iframeEvent.authEvent, auth, "invalid-auth-event" /* INVALID_AUTH_EVENT */);
|
|
3846
2794
|
// TODO: Consider splitting redirect and popup events earlier on
|
|
3847
2795
|
var handled = manager.onEvent(iframeEvent.authEvent);
|
|
3848
2796
|
return { status: handled ? "ACK" /* ACK */ : "ERROR" /* ERROR */ };
|
|
@@ -3862,7 +2810,7 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
|
|
|
3862
2810
|
if (isSupported !== undefined) {
|
|
3863
2811
|
cb(!!isSupported);
|
|
3864
2812
|
}
|
|
3865
|
-
|
|
2813
|
+
phone._fail(auth, "internal-error" /* INTERNAL_ERROR */);
|
|
3866
2814
|
}, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
|
|
3867
2815
|
};
|
|
3868
2816
|
BrowserPopupRedirectResolver.prototype._originValidation = function (auth) {
|
|
@@ -3875,7 +2823,7 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
|
|
|
3875
2823
|
Object.defineProperty(BrowserPopupRedirectResolver.prototype, "_shouldInitProactively", {
|
|
3876
2824
|
get: function () {
|
|
3877
2825
|
// Mobile browsers and Safari need to optimistically initialize
|
|
3878
|
-
return
|
|
2826
|
+
return phone._isMobileBrowser() || phone._isSafari() || phone._isIOS();
|
|
3879
2827
|
},
|
|
3880
2828
|
enumerable: false,
|
|
3881
2829
|
configurable: true
|
|
@@ -3890,81 +2838,6 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
|
|
|
3890
2838
|
*/
|
|
3891
2839
|
var browserPopupRedirectResolver = BrowserPopupRedirectResolver;
|
|
3892
2840
|
|
|
3893
|
-
var MultiFactorAssertionImpl = /** @class */ (function () {
|
|
3894
|
-
function MultiFactorAssertionImpl(factorId) {
|
|
3895
|
-
this.factorId = factorId;
|
|
3896
|
-
}
|
|
3897
|
-
MultiFactorAssertionImpl.prototype._process = function (auth, session, displayName) {
|
|
3898
|
-
switch (session.type) {
|
|
3899
|
-
case "enroll" /* ENROLL */:
|
|
3900
|
-
return this._finalizeEnroll(auth, session.credential, displayName);
|
|
3901
|
-
case "signin" /* SIGN_IN */:
|
|
3902
|
-
return this._finalizeSignIn(auth, session.credential);
|
|
3903
|
-
default:
|
|
3904
|
-
return enum_maps.debugFail('unexpected MultiFactorSessionType');
|
|
3905
|
-
}
|
|
3906
|
-
};
|
|
3907
|
-
return MultiFactorAssertionImpl;
|
|
3908
|
-
}());
|
|
3909
|
-
|
|
3910
|
-
/**
|
|
3911
|
-
* {@inheritdoc PhoneMultiFactorAssertion}
|
|
3912
|
-
*
|
|
3913
|
-
* @public
|
|
3914
|
-
*/
|
|
3915
|
-
var PhoneMultiFactorAssertionImpl = /** @class */ (function (_super) {
|
|
3916
|
-
tslib.__extends(PhoneMultiFactorAssertionImpl, _super);
|
|
3917
|
-
function PhoneMultiFactorAssertionImpl(credential) {
|
|
3918
|
-
var _this = _super.call(this, "phone" /* PHONE */) || this;
|
|
3919
|
-
_this.credential = credential;
|
|
3920
|
-
return _this;
|
|
3921
|
-
}
|
|
3922
|
-
/** @internal */
|
|
3923
|
-
PhoneMultiFactorAssertionImpl._fromCredential = function (credential) {
|
|
3924
|
-
return new PhoneMultiFactorAssertionImpl(credential);
|
|
3925
|
-
};
|
|
3926
|
-
/** @internal */
|
|
3927
|
-
PhoneMultiFactorAssertionImpl.prototype._finalizeEnroll = function (auth, idToken, displayName) {
|
|
3928
|
-
return enum_maps.finalizeEnrollPhoneMfa(auth, {
|
|
3929
|
-
idToken: idToken,
|
|
3930
|
-
displayName: displayName,
|
|
3931
|
-
phoneVerificationInfo: this.credential._makeVerificationRequest()
|
|
3932
|
-
});
|
|
3933
|
-
};
|
|
3934
|
-
/** @internal */
|
|
3935
|
-
PhoneMultiFactorAssertionImpl.prototype._finalizeSignIn = function (auth, mfaPendingCredential) {
|
|
3936
|
-
return finalizeSignInPhoneMfa(auth, {
|
|
3937
|
-
mfaPendingCredential: mfaPendingCredential,
|
|
3938
|
-
phoneVerificationInfo: this.credential._makeVerificationRequest()
|
|
3939
|
-
});
|
|
3940
|
-
};
|
|
3941
|
-
return PhoneMultiFactorAssertionImpl;
|
|
3942
|
-
}(MultiFactorAssertionImpl));
|
|
3943
|
-
/**
|
|
3944
|
-
* Provider for generating a {@link PhoneMultiFactorAssertion}.
|
|
3945
|
-
*
|
|
3946
|
-
* @public
|
|
3947
|
-
*/
|
|
3948
|
-
var PhoneMultiFactorGenerator = /** @class */ (function () {
|
|
3949
|
-
function PhoneMultiFactorGenerator() {
|
|
3950
|
-
}
|
|
3951
|
-
/**
|
|
3952
|
-
* Provides a {@link PhoneMultiFactorAssertion} to confirm ownership of the phone second factor.
|
|
3953
|
-
*
|
|
3954
|
-
* @param phoneAuthCredential - A credential provided by {@link PhoneAuthProvider.credential}.
|
|
3955
|
-
* @returns A {@link PhoneMultiFactorAssertion} which can be used with
|
|
3956
|
-
* {@link MultiFactorResolver.resolveSignIn}
|
|
3957
|
-
*/
|
|
3958
|
-
PhoneMultiFactorGenerator.assertion = function (credential) {
|
|
3959
|
-
return PhoneMultiFactorAssertionImpl._fromCredential(credential);
|
|
3960
|
-
};
|
|
3961
|
-
/**
|
|
3962
|
-
* The identifier of the phone second factor: `phone`.
|
|
3963
|
-
*/
|
|
3964
|
-
PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
|
|
3965
|
-
return PhoneMultiFactorGenerator;
|
|
3966
|
-
}());
|
|
3967
|
-
|
|
3968
2841
|
/**
|
|
3969
2842
|
* @license
|
|
3970
2843
|
* Copyright 2021 Google LLC
|
|
@@ -3995,7 +2868,7 @@ function getAuth(app$1) {
|
|
|
3995
2868
|
if (provider.isInitialized()) {
|
|
3996
2869
|
return provider.getImmediate();
|
|
3997
2870
|
}
|
|
3998
|
-
return
|
|
2871
|
+
return phone.initializeAuth(app$1, {
|
|
3999
2872
|
popupRedirectResolver: browserPopupRedirectResolver,
|
|
4000
2873
|
persistence: [
|
|
4001
2874
|
indexedDBLocalPersistence,
|
|
@@ -4004,7 +2877,7 @@ function getAuth(app$1) {
|
|
|
4004
2877
|
]
|
|
4005
2878
|
});
|
|
4006
2879
|
}
|
|
4007
|
-
|
|
2880
|
+
phone.registerAuth("Browser" /* BROWSER */);
|
|
4008
2881
|
|
|
4009
2882
|
/**
|
|
4010
2883
|
* @license
|
|
@@ -4058,21 +2931,21 @@ function _generateHandlerUrl(auth, event, provider) {
|
|
|
4058
2931
|
switch (_b.label) {
|
|
4059
2932
|
case 0:
|
|
4060
2933
|
BuildInfo = _cordovaWindow().BuildInfo;
|
|
4061
|
-
|
|
2934
|
+
phone.debugAssert(event.sessionId, 'AuthEvent did not contain a session ID');
|
|
4062
2935
|
return [4 /*yield*/, computeSha256(event.sessionId)];
|
|
4063
2936
|
case 1:
|
|
4064
2937
|
sessionDigest = _b.sent();
|
|
4065
2938
|
additionalParams = {};
|
|
4066
|
-
if (
|
|
2939
|
+
if (phone._isIOS()) {
|
|
4067
2940
|
// iOS app identifier
|
|
4068
2941
|
additionalParams['ibi'] = BuildInfo.packageName;
|
|
4069
2942
|
}
|
|
4070
|
-
else if (
|
|
2943
|
+
else if (phone._isAndroid()) {
|
|
4071
2944
|
// Android app identifier
|
|
4072
2945
|
additionalParams['apn'] = BuildInfo.packageName;
|
|
4073
2946
|
}
|
|
4074
2947
|
else {
|
|
4075
|
-
|
|
2948
|
+
phone._fail(auth, "operation-not-supported-in-this-environment" /* OPERATION_NOT_SUPPORTED */);
|
|
4076
2949
|
}
|
|
4077
2950
|
// Add the display name if available
|
|
4078
2951
|
if (BuildInfo.displayName) {
|
|
@@ -4096,14 +2969,14 @@ function _validateOrigin(auth) {
|
|
|
4096
2969
|
case 0:
|
|
4097
2970
|
BuildInfo = _cordovaWindow().BuildInfo;
|
|
4098
2971
|
request = {};
|
|
4099
|
-
if (
|
|
2972
|
+
if (phone._isIOS()) {
|
|
4100
2973
|
request.iosBundleId = BuildInfo.packageName;
|
|
4101
2974
|
}
|
|
4102
|
-
else if (
|
|
2975
|
+
else if (phone._isAndroid()) {
|
|
4103
2976
|
request.androidPackageName = BuildInfo.packageName;
|
|
4104
2977
|
}
|
|
4105
2978
|
else {
|
|
4106
|
-
|
|
2979
|
+
phone._fail(auth, "operation-not-supported-in-this-environment" /* OPERATION_NOT_SUPPORTED */);
|
|
4107
2980
|
}
|
|
4108
2981
|
// Will fail automatically if package name is not authorized
|
|
4109
2982
|
return [4 /*yield*/, _getProjectConfig(auth, request)];
|
|
@@ -4126,7 +2999,7 @@ function _performRedirect(handlerUrl) {
|
|
|
4126
2999
|
}
|
|
4127
3000
|
else {
|
|
4128
3001
|
// TODO: Return the inappbrowser ref that's returned from the open call
|
|
4129
|
-
iabRef = cordova.InAppBrowser.open(handlerUrl,
|
|
3002
|
+
iabRef = cordova.InAppBrowser.open(handlerUrl, phone._isIOS7Or8() ? '_blank' : '_system', 'location=yes');
|
|
4130
3003
|
}
|
|
4131
3004
|
resolve(iabRef);
|
|
4132
3005
|
});
|
|
@@ -4174,7 +3047,7 @@ function _waitForAppResume(auth, eventListener, iabRef) {
|
|
|
4174
3047
|
}
|
|
4175
3048
|
onCloseTimer = window.setTimeout(function () {
|
|
4176
3049
|
// Wait two seeconds after resume then reject.
|
|
4177
|
-
reject(
|
|
3050
|
+
reject(phone._createError(auth, "redirect-cancelled-by-user" /* REDIRECT_CANCELLED_BY_USER */));
|
|
4178
3051
|
}, REDIRECT_TIMEOUT_MS);
|
|
4179
3052
|
}
|
|
4180
3053
|
function visibilityChanged() {
|
|
@@ -4187,7 +3060,7 @@ function _waitForAppResume(auth, eventListener, iabRef) {
|
|
|
4187
3060
|
eventListener.addPassiveListener(authEventSeen);
|
|
4188
3061
|
// Listen for resume and visibility events
|
|
4189
3062
|
document.addEventListener('resume', resumed, false);
|
|
4190
|
-
if (
|
|
3063
|
+
if (phone._isAndroid()) {
|
|
4191
3064
|
document.addEventListener('visibilitychange', visibilityChanged, false);
|
|
4192
3065
|
}
|
|
4193
3066
|
// SETUP THE CLEANUP FUNCTION =====
|
|
@@ -4224,22 +3097,22 @@ function _checkCordovaConfiguration(auth) {
|
|
|
4224
3097
|
// Note that cordova-universal-links-plugin has been abandoned.
|
|
4225
3098
|
// A fork with latest fixes is available at:
|
|
4226
3099
|
// https://www.npmjs.com/package/cordova-universal-links-plugin-fix
|
|
4227
|
-
|
|
3100
|
+
phone._assert(typeof ((_a = win === null || win === void 0 ? void 0 : win.universalLinks) === null || _a === void 0 ? void 0 : _a.subscribe) === 'function', auth, "invalid-cordova-configuration" /* INVALID_CORDOVA_CONFIGURATION */, {
|
|
4228
3101
|
missingPlugin: 'cordova-universal-links-plugin-fix'
|
|
4229
3102
|
});
|
|
4230
3103
|
// https://www.npmjs.com/package/cordova-plugin-buildinfo
|
|
4231
|
-
|
|
3104
|
+
phone._assert(typeof ((_b = win === null || win === void 0 ? void 0 : win.BuildInfo) === null || _b === void 0 ? void 0 : _b.packageName) !== 'undefined', auth, "invalid-cordova-configuration" /* INVALID_CORDOVA_CONFIGURATION */, {
|
|
4232
3105
|
missingPlugin: 'cordova-plugin-buildInfo'
|
|
4233
3106
|
});
|
|
4234
3107
|
// https://github.com/google/cordova-plugin-browsertab
|
|
4235
|
-
|
|
3108
|
+
phone._assert(typeof ((_e = (_d = (_c = win === null || win === void 0 ? void 0 : win.cordova) === null || _c === void 0 ? void 0 : _c.plugins) === null || _d === void 0 ? void 0 : _d.browsertab) === null || _e === void 0 ? void 0 : _e.openUrl) === 'function', auth, "invalid-cordova-configuration" /* INVALID_CORDOVA_CONFIGURATION */, {
|
|
4236
3109
|
missingPlugin: 'cordova-plugin-browsertab'
|
|
4237
3110
|
});
|
|
4238
|
-
|
|
3111
|
+
phone._assert(typeof ((_h = (_g = (_f = win === null || win === void 0 ? void 0 : win.cordova) === null || _f === void 0 ? void 0 : _f.plugins) === null || _g === void 0 ? void 0 : _g.browsertab) === null || _h === void 0 ? void 0 : _h.isAvailable) === 'function', auth, "invalid-cordova-configuration" /* INVALID_CORDOVA_CONFIGURATION */, {
|
|
4239
3112
|
missingPlugin: 'cordova-plugin-browsertab'
|
|
4240
3113
|
});
|
|
4241
3114
|
// https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/
|
|
4242
|
-
|
|
3115
|
+
phone._assert(typeof ((_k = (_j = win === null || win === void 0 ? void 0 : win.cordova) === null || _j === void 0 ? void 0 : _j.InAppBrowser) === null || _k === void 0 ? void 0 : _k.open) === 'function', auth, "invalid-cordova-configuration" /* INVALID_CORDOVA_CONFIGURATION */, {
|
|
4243
3116
|
missingPlugin: 'cordova-plugin-inappbrowser'
|
|
4244
3117
|
});
|
|
4245
3118
|
}
|
|
@@ -4267,7 +3140,7 @@ function computeSha256(sessionId) {
|
|
|
4267
3140
|
function stringToArrayBuffer(str) {
|
|
4268
3141
|
// This function is only meant to deal with an ASCII charset and makes
|
|
4269
3142
|
// certain simplifying assumptions.
|
|
4270
|
-
|
|
3143
|
+
phone.debugAssert(/[0-9a-zA-Z]+/.test(str), 'Can only convert alpha-numeric strings');
|
|
4271
3144
|
if (typeof TextEncoder !== 'undefined') {
|
|
4272
3145
|
return new TextEncoder().encode(str);
|
|
4273
3146
|
}
|
|
@@ -4351,7 +3224,7 @@ function _generateNewEvent(auth, type, eventId) {
|
|
|
4351
3224
|
sessionId: generateSessionId(),
|
|
4352
3225
|
postBody: null,
|
|
4353
3226
|
tenantId: auth.tenantId,
|
|
4354
|
-
error:
|
|
3227
|
+
error: phone._createError(auth, "no-auth-event" /* NO_AUTH_EVENT */)
|
|
4355
3228
|
};
|
|
4356
3229
|
}
|
|
4357
3230
|
function _savePartialEvent(auth, event) {
|
|
@@ -4394,7 +3267,7 @@ function _eventFromPartialAndUrl(partialEvent, url) {
|
|
|
4394
3267
|
? parseJsonOrNull(decodeURIComponent(params['firebaseError']))
|
|
4395
3268
|
: null;
|
|
4396
3269
|
var code = (_b = (_a = errorObject === null || errorObject === void 0 ? void 0 : errorObject['code']) === null || _a === void 0 ? void 0 : _a.split('auth/')) === null || _b === void 0 ? void 0 : _b[1];
|
|
4397
|
-
var error = code ?
|
|
3270
|
+
var error = code ? phone._createError(code) : null;
|
|
4398
3271
|
if (error) {
|
|
4399
3272
|
return {
|
|
4400
3273
|
type: partialEvent.type,
|
|
@@ -4429,10 +3302,10 @@ function generateSessionId() {
|
|
|
4429
3302
|
return chars.join('');
|
|
4430
3303
|
}
|
|
4431
3304
|
function storage() {
|
|
4432
|
-
return
|
|
3305
|
+
return phone._getInstance(browserLocalPersistence);
|
|
4433
3306
|
}
|
|
4434
3307
|
function persistenceKey(auth) {
|
|
4435
|
-
return
|
|
3308
|
+
return phone._persistenceKeyName("authEvent" /* AUTH_EVENT */, auth.config.apiKey, auth.name);
|
|
4436
3309
|
}
|
|
4437
3310
|
function parseJsonOrNull(json) {
|
|
4438
3311
|
try {
|
|
@@ -4512,7 +3385,7 @@ var CordovaPopupRedirectResolver = /** @class */ (function () {
|
|
|
4512
3385
|
});
|
|
4513
3386
|
};
|
|
4514
3387
|
CordovaPopupRedirectResolver.prototype._openPopup = function (auth) {
|
|
4515
|
-
|
|
3388
|
+
phone._fail(auth, "operation-not-supported-in-this-environment" /* OPERATION_NOT_SUPPORTED */);
|
|
4516
3389
|
};
|
|
4517
3390
|
CordovaPopupRedirectResolver.prototype._openRedirect = function (auth, provider, authType, eventId) {
|
|
4518
3391
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
@@ -4650,7 +3523,7 @@ function generateNoEvent() {
|
|
|
4650
3523
|
urlResponse: null,
|
|
4651
3524
|
postBody: null,
|
|
4652
3525
|
tenantId: null,
|
|
4653
|
-
error:
|
|
3526
|
+
error: phone._createError("no-auth-event" /* NO_AUTH_EVENT */)
|
|
4654
3527
|
};
|
|
4655
3528
|
}
|
|
4656
3529
|
|
|
@@ -4674,82 +3547,86 @@ function generateNoEvent() {
|
|
|
4674
3547
|
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it out
|
|
4675
3548
|
// of autogenerated documentation pages to reduce accidental misuse.
|
|
4676
3549
|
function addFrameworkForLogging(auth, framework) {
|
|
4677
|
-
|
|
3550
|
+
phone._castAuth(auth)._logFramework(framework);
|
|
4678
3551
|
}
|
|
4679
3552
|
|
|
4680
|
-
exports.ActionCodeOperation =
|
|
4681
|
-
exports.ActionCodeURL =
|
|
4682
|
-
exports.AuthCredential =
|
|
4683
|
-
exports.AuthErrorCodes =
|
|
4684
|
-
exports.AuthImpl =
|
|
4685
|
-
exports.EmailAuthCredential =
|
|
4686
|
-
exports.EmailAuthProvider =
|
|
4687
|
-
exports.FacebookAuthProvider =
|
|
4688
|
-
exports.FactorId =
|
|
4689
|
-
exports.FetchProvider =
|
|
4690
|
-
exports.GithubAuthProvider =
|
|
4691
|
-
exports.GoogleAuthProvider =
|
|
4692
|
-
exports.OAuthCredential =
|
|
4693
|
-
exports.OAuthProvider =
|
|
4694
|
-
exports.OperationType =
|
|
4695
|
-
exports.PhoneAuthCredential =
|
|
4696
|
-
exports.
|
|
4697
|
-
exports.
|
|
4698
|
-
exports.
|
|
4699
|
-
exports.
|
|
4700
|
-
exports.
|
|
4701
|
-
exports.
|
|
4702
|
-
exports.
|
|
4703
|
-
exports.
|
|
4704
|
-
exports.
|
|
4705
|
-
exports.
|
|
4706
|
-
exports.
|
|
4707
|
-
exports.
|
|
4708
|
-
exports.
|
|
4709
|
-
exports.
|
|
4710
|
-
exports.
|
|
4711
|
-
exports.
|
|
4712
|
-
exports.
|
|
4713
|
-
exports.
|
|
4714
|
-
exports.
|
|
4715
|
-
exports.
|
|
4716
|
-
exports.
|
|
4717
|
-
exports.
|
|
4718
|
-
exports.
|
|
4719
|
-
exports.
|
|
4720
|
-
exports.
|
|
4721
|
-
exports.
|
|
4722
|
-
exports.
|
|
4723
|
-
exports.
|
|
4724
|
-
exports.
|
|
4725
|
-
exports.
|
|
4726
|
-
exports.
|
|
4727
|
-
exports.
|
|
4728
|
-
exports.
|
|
4729
|
-
exports.
|
|
4730
|
-
exports.
|
|
4731
|
-
exports.
|
|
4732
|
-
exports.
|
|
4733
|
-
exports.
|
|
4734
|
-
exports.
|
|
4735
|
-
exports.
|
|
4736
|
-
exports.
|
|
4737
|
-
exports.
|
|
4738
|
-
exports.
|
|
4739
|
-
exports.
|
|
4740
|
-
exports.
|
|
4741
|
-
exports.
|
|
4742
|
-
exports.
|
|
4743
|
-
exports.
|
|
4744
|
-
exports.
|
|
4745
|
-
exports.
|
|
4746
|
-
exports.
|
|
4747
|
-
exports.
|
|
4748
|
-
exports.
|
|
3553
|
+
exports.ActionCodeOperation = phone.ActionCodeOperation;
|
|
3554
|
+
exports.ActionCodeURL = phone.ActionCodeURL;
|
|
3555
|
+
exports.AuthCredential = phone.AuthCredential;
|
|
3556
|
+
exports.AuthErrorCodes = phone.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY;
|
|
3557
|
+
exports.AuthImpl = phone.AuthImpl;
|
|
3558
|
+
exports.EmailAuthCredential = phone.EmailAuthCredential;
|
|
3559
|
+
exports.EmailAuthProvider = phone.EmailAuthProvider;
|
|
3560
|
+
exports.FacebookAuthProvider = phone.FacebookAuthProvider;
|
|
3561
|
+
exports.FactorId = phone.FactorId;
|
|
3562
|
+
exports.FetchProvider = phone.FetchProvider;
|
|
3563
|
+
exports.GithubAuthProvider = phone.GithubAuthProvider;
|
|
3564
|
+
exports.GoogleAuthProvider = phone.GoogleAuthProvider;
|
|
3565
|
+
exports.OAuthCredential = phone.OAuthCredential;
|
|
3566
|
+
exports.OAuthProvider = phone.OAuthProvider;
|
|
3567
|
+
exports.OperationType = phone.OperationType;
|
|
3568
|
+
exports.PhoneAuthCredential = phone.PhoneAuthCredential;
|
|
3569
|
+
exports.PhoneAuthProvider = phone.PhoneAuthProvider;
|
|
3570
|
+
exports.PhoneMultiFactorGenerator = phone.PhoneMultiFactorGenerator;
|
|
3571
|
+
exports.ProviderId = phone.ProviderId;
|
|
3572
|
+
exports.RecaptchaVerifier = phone.RecaptchaVerifier;
|
|
3573
|
+
exports.SAMLAuthCredential = phone.SAMLAuthCredential;
|
|
3574
|
+
exports.SAMLAuthProvider = phone.SAMLAuthProvider;
|
|
3575
|
+
exports.SignInMethod = phone.SignInMethod;
|
|
3576
|
+
exports.TwitterAuthProvider = phone.TwitterAuthProvider;
|
|
3577
|
+
exports.UserImpl = phone.UserImpl;
|
|
3578
|
+
exports._assert = phone._assert;
|
|
3579
|
+
exports._castAuth = phone._castAuth;
|
|
3580
|
+
exports._fail = phone._fail;
|
|
3581
|
+
exports._getClientVersion = phone._getClientVersion;
|
|
3582
|
+
exports._getInstance = phone._getInstance;
|
|
3583
|
+
exports._persistenceKeyName = phone._persistenceKeyName;
|
|
3584
|
+
exports.applyActionCode = phone.applyActionCode;
|
|
3585
|
+
exports.checkActionCode = phone.checkActionCode;
|
|
3586
|
+
exports.confirmPasswordReset = phone.confirmPasswordReset;
|
|
3587
|
+
exports.connectAuthEmulator = phone.connectAuthEmulator;
|
|
3588
|
+
exports.createUserWithEmailAndPassword = phone.createUserWithEmailAndPassword;
|
|
3589
|
+
exports.debugErrorMap = phone.debugErrorMap;
|
|
3590
|
+
exports.deleteUser = phone.deleteUser;
|
|
3591
|
+
exports.fetchSignInMethodsForEmail = phone.fetchSignInMethodsForEmail;
|
|
3592
|
+
exports.getAdditionalUserInfo = phone.getAdditionalUserInfo;
|
|
3593
|
+
exports.getIdToken = phone.getIdToken;
|
|
3594
|
+
exports.getIdTokenResult = phone.getIdTokenResult;
|
|
3595
|
+
exports.getMultiFactorResolver = phone.getMultiFactorResolver;
|
|
3596
|
+
exports.inMemoryPersistence = phone.inMemoryPersistence;
|
|
3597
|
+
exports.initializeAuth = phone.initializeAuth;
|
|
3598
|
+
exports.isSignInWithEmailLink = phone.isSignInWithEmailLink;
|
|
3599
|
+
exports.linkWithCredential = phone.linkWithCredential;
|
|
3600
|
+
exports.linkWithPhoneNumber = phone.linkWithPhoneNumber;
|
|
3601
|
+
exports.multiFactor = phone.multiFactor;
|
|
3602
|
+
exports.onAuthStateChanged = phone.onAuthStateChanged;
|
|
3603
|
+
exports.onIdTokenChanged = phone.onIdTokenChanged;
|
|
3604
|
+
exports.parseActionCodeURL = phone.parseActionCodeURL;
|
|
3605
|
+
exports.prodErrorMap = phone.prodErrorMap;
|
|
3606
|
+
exports.reauthenticateWithCredential = phone.reauthenticateWithCredential;
|
|
3607
|
+
exports.reauthenticateWithPhoneNumber = phone.reauthenticateWithPhoneNumber;
|
|
3608
|
+
exports.reload = phone.reload;
|
|
3609
|
+
exports.sendEmailVerification = phone.sendEmailVerification;
|
|
3610
|
+
exports.sendPasswordResetEmail = phone.sendPasswordResetEmail;
|
|
3611
|
+
exports.sendSignInLinkToEmail = phone.sendSignInLinkToEmail;
|
|
3612
|
+
exports.setPersistence = phone.setPersistence;
|
|
3613
|
+
exports.signInAnonymously = phone.signInAnonymously;
|
|
3614
|
+
exports.signInWithCredential = phone.signInWithCredential;
|
|
3615
|
+
exports.signInWithCustomToken = phone.signInWithCustomToken;
|
|
3616
|
+
exports.signInWithEmailAndPassword = phone.signInWithEmailAndPassword;
|
|
3617
|
+
exports.signInWithEmailLink = phone.signInWithEmailLink;
|
|
3618
|
+
exports.signInWithPhoneNumber = phone.signInWithPhoneNumber;
|
|
3619
|
+
exports.signOut = phone.signOut;
|
|
3620
|
+
exports.unlink = phone.unlink;
|
|
3621
|
+
exports.updateCurrentUser = phone.updateCurrentUser;
|
|
3622
|
+
exports.updateEmail = phone.updateEmail;
|
|
3623
|
+
exports.updatePassword = phone.updatePassword;
|
|
3624
|
+
exports.updatePhoneNumber = phone.updatePhoneNumber;
|
|
3625
|
+
exports.updateProfile = phone.updateProfile;
|
|
3626
|
+
exports.useDeviceLanguage = phone.useDeviceLanguage;
|
|
3627
|
+
exports.verifyBeforeUpdateEmail = phone.verifyBeforeUpdateEmail;
|
|
3628
|
+
exports.verifyPasswordResetCode = phone.verifyPasswordResetCode;
|
|
4749
3629
|
exports.AuthPopup = AuthPopup;
|
|
4750
|
-
exports.PhoneAuthProvider = PhoneAuthProvider;
|
|
4751
|
-
exports.PhoneMultiFactorGenerator = PhoneMultiFactorGenerator;
|
|
4752
|
-
exports.RecaptchaVerifier = RecaptchaVerifier;
|
|
4753
3630
|
exports._generateEventId = _generateEventId;
|
|
4754
3631
|
exports._getRedirectResult = _getRedirectResult;
|
|
4755
3632
|
exports.addFrameworkForLogging = addFrameworkForLogging;
|
|
@@ -4760,14 +3637,10 @@ exports.cordovaPopupRedirectResolver = cordovaPopupRedirectResolver;
|
|
|
4760
3637
|
exports.getAuth = getAuth;
|
|
4761
3638
|
exports.getRedirectResult = getRedirectResult;
|
|
4762
3639
|
exports.indexedDBLocalPersistence = indexedDBLocalPersistence;
|
|
4763
|
-
exports.linkWithPhoneNumber = linkWithPhoneNumber;
|
|
4764
3640
|
exports.linkWithPopup = linkWithPopup;
|
|
4765
3641
|
exports.linkWithRedirect = linkWithRedirect;
|
|
4766
|
-
exports.reauthenticateWithPhoneNumber = reauthenticateWithPhoneNumber;
|
|
4767
3642
|
exports.reauthenticateWithPopup = reauthenticateWithPopup;
|
|
4768
3643
|
exports.reauthenticateWithRedirect = reauthenticateWithRedirect;
|
|
4769
|
-
exports.signInWithPhoneNumber = signInWithPhoneNumber;
|
|
4770
3644
|
exports.signInWithPopup = signInWithPopup;
|
|
4771
3645
|
exports.signInWithRedirect = signInWithRedirect;
|
|
4772
|
-
exports.updatePhoneNumber = updatePhoneNumber;
|
|
4773
3646
|
//# sourceMappingURL=internal.js.map
|