@firebase/auth-compat 0.5.15 → 0.5.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-compat/index.d.ts +50 -50
- package/dist/auth-compat/index.node.d.ts +24 -24
- package/dist/auth-compat/scripts/run_node_tests.d.ts +17 -17
- package/dist/auth-compat/src/auth.d.ts +72 -72
- package/dist/auth-compat/src/auth.test.d.ts +17 -17
- package/dist/auth-compat/src/persistence.d.ts +29 -29
- package/dist/auth-compat/src/phone_auth_provider.d.ts +29 -29
- package/dist/auth-compat/src/platform.d.ts +39 -39
- package/dist/auth-compat/src/popup_redirect.d.ts +34 -34
- package/dist/auth-compat/src/popup_redirect.test.d.ts +17 -17
- package/dist/auth-compat/src/recaptcha_verifier.d.ts +28 -28
- package/dist/auth-compat/src/user.d.ts +64 -64
- package/dist/auth-compat/src/user_credential.d.ts +20 -20
- package/dist/auth-compat/src/wrap.d.ts +26 -26
- package/dist/auth-compat/test/helpers/helpers.d.ts +24 -24
- package/dist/auth-compat/test/integration/flows/anonymous.test.d.ts +17 -17
- package/dist/auth-compat/test/integration/flows/custom.test.d.ts +17 -17
- package/dist/auth-compat/test/integration/flows/email.test.d.ts +17 -17
- package/dist/auth-compat/test/integration/flows/idp.test.d.ts +17 -17
- package/dist/auth-compat/test/integration/flows/oob.test.d.ts +17 -17
- package/dist/auth-compat/test/integration/flows/phone.test.d.ts +17 -17
- package/dist/esm/auth-compat/index.d.ts +50 -50
- package/dist/esm/auth-compat/index.node.d.ts +24 -24
- package/dist/esm/auth-compat/scripts/run_node_tests.d.ts +17 -17
- package/dist/esm/auth-compat/src/auth.d.ts +72 -72
- package/dist/esm/auth-compat/src/auth.test.d.ts +17 -17
- package/dist/esm/auth-compat/src/persistence.d.ts +29 -29
- package/dist/esm/auth-compat/src/phone_auth_provider.d.ts +29 -29
- package/dist/esm/auth-compat/src/platform.d.ts +39 -39
- package/dist/esm/auth-compat/src/popup_redirect.d.ts +34 -34
- package/dist/esm/auth-compat/src/popup_redirect.test.d.ts +17 -17
- package/dist/esm/auth-compat/src/recaptcha_verifier.d.ts +28 -28
- package/dist/esm/auth-compat/src/user.d.ts +64 -64
- package/dist/esm/auth-compat/src/user_credential.d.ts +20 -20
- package/dist/esm/auth-compat/src/wrap.d.ts +26 -26
- package/dist/esm/auth-compat/test/helpers/helpers.d.ts +24 -24
- package/dist/esm/auth-compat/test/integration/flows/anonymous.test.d.ts +17 -17
- package/dist/esm/auth-compat/test/integration/flows/custom.test.d.ts +17 -17
- package/dist/esm/auth-compat/test/integration/flows/email.test.d.ts +17 -17
- package/dist/esm/auth-compat/test/integration/flows/idp.test.d.ts +17 -17
- package/dist/esm/auth-compat/test/integration/flows/oob.test.d.ts +17 -17
- package/dist/esm/auth-compat/test/integration/flows/phone.test.d.ts +17 -17
- package/dist/esm/index.node.esm.js +993 -993
- package/dist/esm/index.node.esm.js.map +1 -1
- package/dist/firebase-auth.js +1 -1
- package/dist/firebase-auth.js.map +1 -1
- package/dist/index.cjs.js +977 -977
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +977 -977
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +993 -993
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs.js
CHANGED
|
@@ -29,1001 +29,1001 @@ var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
|
|
29
29
|
var exp__namespace = /*#__PURE__*/_interopNamespace(exp);
|
|
30
30
|
|
|
31
31
|
var name = "@firebase/auth-compat";
|
|
32
|
-
var version = "0.5.
|
|
32
|
+
var version = "0.5.16";
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* @license
|
|
36
|
-
* Copyright 2020 Google LLC
|
|
37
|
-
*
|
|
38
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
39
|
-
* you may not use this file except in compliance with the License.
|
|
40
|
-
* You may obtain a copy of the License at
|
|
41
|
-
*
|
|
42
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
43
|
-
*
|
|
44
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
45
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
46
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
47
|
-
* See the License for the specific language governing permissions and
|
|
48
|
-
* limitations under the License.
|
|
49
|
-
*/
|
|
50
|
-
const CORDOVA_ONDEVICEREADY_TIMEOUT_MS = 1000;
|
|
51
|
-
function _getCurrentScheme() {
|
|
52
|
-
var _a;
|
|
53
|
-
return ((_a = self === null || self === void 0 ? void 0 : self.location) === null || _a === void 0 ? void 0 : _a.protocol) || null;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @return {boolean} Whether the current environment is http or https.
|
|
57
|
-
*/
|
|
58
|
-
function _isHttpOrHttps() {
|
|
59
|
-
return _getCurrentScheme() === 'http:' || _getCurrentScheme() === 'https:';
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @param {?string=} ua The user agent.
|
|
63
|
-
* @return {boolean} Whether the app is rendered in a mobile iOS or Android
|
|
64
|
-
* Cordova environment.
|
|
65
|
-
*/
|
|
66
|
-
function _isAndroidOrIosCordovaScheme(ua = util.getUA()) {
|
|
67
|
-
return !!((_getCurrentScheme() === 'file:' ||
|
|
68
|
-
_getCurrentScheme() === 'ionic:' ||
|
|
69
|
-
_getCurrentScheme() === 'capacitor:') &&
|
|
70
|
-
ua.toLowerCase().match(/iphone|ipad|ipod|android/));
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @return {boolean} Whether the environment is a native environment, where
|
|
74
|
-
* CORS checks do not apply.
|
|
75
|
-
*/
|
|
76
|
-
function _isNativeEnvironment() {
|
|
77
|
-
return util.isReactNative() || util.isNode();
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Checks whether the user agent is IE11.
|
|
81
|
-
* @return {boolean} True if it is IE11.
|
|
82
|
-
*/
|
|
83
|
-
function _isIe11() {
|
|
84
|
-
return util.isIE() && (document === null || document === void 0 ? void 0 : document.documentMode) === 11;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Checks whether the user agent is Edge.
|
|
88
|
-
* @param {string} userAgent The browser user agent string.
|
|
89
|
-
* @return {boolean} True if it is Edge.
|
|
90
|
-
*/
|
|
91
|
-
function _isEdge(ua = util.getUA()) {
|
|
92
|
-
return /Edge\/\d+/.test(ua);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* @param {?string=} opt_userAgent The navigator user agent.
|
|
96
|
-
* @return {boolean} Whether local storage is not synchronized between an iframe
|
|
97
|
-
* and a popup of the same domain.
|
|
98
|
-
*/
|
|
99
|
-
function _isLocalStorageNotSynchronized(ua = util.getUA()) {
|
|
100
|
-
return _isIe11() || _isEdge(ua);
|
|
101
|
-
}
|
|
102
|
-
/** @return {boolean} Whether web storage is supported. */
|
|
103
|
-
function _isWebStorageSupported() {
|
|
104
|
-
try {
|
|
105
|
-
const storage = self.localStorage;
|
|
106
|
-
const key = exp__namespace._generateEventId();
|
|
107
|
-
if (storage) {
|
|
108
|
-
// setItem will throw an exception if we cannot access WebStorage (e.g.,
|
|
109
|
-
// Safari in private mode).
|
|
110
|
-
storage['setItem'](key, '1');
|
|
111
|
-
storage['removeItem'](key);
|
|
112
|
-
// For browsers where iframe web storage does not synchronize with a popup
|
|
113
|
-
// of the same domain, indexedDB is used for persistent storage. These
|
|
114
|
-
// browsers include IE11 and Edge.
|
|
115
|
-
// Make sure it is supported (IE11 and Edge private mode does not support
|
|
116
|
-
// that).
|
|
117
|
-
if (_isLocalStorageNotSynchronized()) {
|
|
118
|
-
// In such browsers, if indexedDB is not supported, an iframe cannot be
|
|
119
|
-
// notified of the popup sign in result.
|
|
120
|
-
return util.isIndexedDBAvailable();
|
|
121
|
-
}
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
// localStorage is not available from a worker. Test availability of
|
|
127
|
-
// indexedDB.
|
|
128
|
-
return _isWorker() && util.isIndexedDBAvailable();
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* @param {?Object=} global The optional global scope.
|
|
134
|
-
* @return {boolean} Whether current environment is a worker.
|
|
135
|
-
*/
|
|
136
|
-
function _isWorker() {
|
|
137
|
-
// WorkerGlobalScope only defined in worker environment.
|
|
138
|
-
return (typeof global !== 'undefined' &&
|
|
139
|
-
'WorkerGlobalScope' in global &&
|
|
140
|
-
'importScripts' in global);
|
|
141
|
-
}
|
|
142
|
-
function _isPopupRedirectSupported() {
|
|
143
|
-
return ((_isHttpOrHttps() ||
|
|
144
|
-
util.isBrowserExtension() ||
|
|
145
|
-
_isAndroidOrIosCordovaScheme()) &&
|
|
146
|
-
// React Native with remote debugging reports its location.protocol as
|
|
147
|
-
// http.
|
|
148
|
-
!_isNativeEnvironment() &&
|
|
149
|
-
// Local storage has to be supported for browser popup and redirect
|
|
150
|
-
// operations to work.
|
|
151
|
-
_isWebStorageSupported() &&
|
|
152
|
-
// DOM, popups and redirects are not supported within a worker.
|
|
153
|
-
!_isWorker());
|
|
154
|
-
}
|
|
155
|
-
/** Quick check that indicates the platform *may* be Cordova */
|
|
156
|
-
function _isLikelyCordova() {
|
|
157
|
-
return _isAndroidOrIosCordovaScheme() && typeof document !== 'undefined';
|
|
158
|
-
}
|
|
159
|
-
async function _isCordova() {
|
|
160
|
-
if (!_isLikelyCordova()) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
return new Promise(resolve => {
|
|
164
|
-
const timeoutId = setTimeout(() => {
|
|
165
|
-
// We've waited long enough; the telltale Cordova event didn't happen
|
|
166
|
-
resolve(false);
|
|
167
|
-
}, CORDOVA_ONDEVICEREADY_TIMEOUT_MS);
|
|
168
|
-
document.addEventListener('deviceready', () => {
|
|
169
|
-
clearTimeout(timeoutId);
|
|
170
|
-
resolve(true);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
function _getSelfWindow() {
|
|
175
|
-
return typeof window !== 'undefined' ? window : null;
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2020 Google LLC
|
|
37
|
+
*
|
|
38
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
39
|
+
* you may not use this file except in compliance with the License.
|
|
40
|
+
* You may obtain a copy of the License at
|
|
41
|
+
*
|
|
42
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
43
|
+
*
|
|
44
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
45
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
46
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
47
|
+
* See the License for the specific language governing permissions and
|
|
48
|
+
* limitations under the License.
|
|
49
|
+
*/
|
|
50
|
+
const CORDOVA_ONDEVICEREADY_TIMEOUT_MS = 1000;
|
|
51
|
+
function _getCurrentScheme() {
|
|
52
|
+
var _a;
|
|
53
|
+
return ((_a = self === null || self === void 0 ? void 0 : self.location) === null || _a === void 0 ? void 0 : _a.protocol) || null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @return {boolean} Whether the current environment is http or https.
|
|
57
|
+
*/
|
|
58
|
+
function _isHttpOrHttps() {
|
|
59
|
+
return _getCurrentScheme() === 'http:' || _getCurrentScheme() === 'https:';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @param {?string=} ua The user agent.
|
|
63
|
+
* @return {boolean} Whether the app is rendered in a mobile iOS or Android
|
|
64
|
+
* Cordova environment.
|
|
65
|
+
*/
|
|
66
|
+
function _isAndroidOrIosCordovaScheme(ua = util.getUA()) {
|
|
67
|
+
return !!((_getCurrentScheme() === 'file:' ||
|
|
68
|
+
_getCurrentScheme() === 'ionic:' ||
|
|
69
|
+
_getCurrentScheme() === 'capacitor:') &&
|
|
70
|
+
ua.toLowerCase().match(/iphone|ipad|ipod|android/));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @return {boolean} Whether the environment is a native environment, where
|
|
74
|
+
* CORS checks do not apply.
|
|
75
|
+
*/
|
|
76
|
+
function _isNativeEnvironment() {
|
|
77
|
+
return util.isReactNative() || util.isNode();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Checks whether the user agent is IE11.
|
|
81
|
+
* @return {boolean} True if it is IE11.
|
|
82
|
+
*/
|
|
83
|
+
function _isIe11() {
|
|
84
|
+
return util.isIE() && (document === null || document === void 0 ? void 0 : document.documentMode) === 11;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks whether the user agent is Edge.
|
|
88
|
+
* @param {string} userAgent The browser user agent string.
|
|
89
|
+
* @return {boolean} True if it is Edge.
|
|
90
|
+
*/
|
|
91
|
+
function _isEdge(ua = util.getUA()) {
|
|
92
|
+
return /Edge\/\d+/.test(ua);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @param {?string=} opt_userAgent The navigator user agent.
|
|
96
|
+
* @return {boolean} Whether local storage is not synchronized between an iframe
|
|
97
|
+
* and a popup of the same domain.
|
|
98
|
+
*/
|
|
99
|
+
function _isLocalStorageNotSynchronized(ua = util.getUA()) {
|
|
100
|
+
return _isIe11() || _isEdge(ua);
|
|
101
|
+
}
|
|
102
|
+
/** @return {boolean} Whether web storage is supported. */
|
|
103
|
+
function _isWebStorageSupported() {
|
|
104
|
+
try {
|
|
105
|
+
const storage = self.localStorage;
|
|
106
|
+
const key = exp__namespace._generateEventId();
|
|
107
|
+
if (storage) {
|
|
108
|
+
// setItem will throw an exception if we cannot access WebStorage (e.g.,
|
|
109
|
+
// Safari in private mode).
|
|
110
|
+
storage['setItem'](key, '1');
|
|
111
|
+
storage['removeItem'](key);
|
|
112
|
+
// For browsers where iframe web storage does not synchronize with a popup
|
|
113
|
+
// of the same domain, indexedDB is used for persistent storage. These
|
|
114
|
+
// browsers include IE11 and Edge.
|
|
115
|
+
// Make sure it is supported (IE11 and Edge private mode does not support
|
|
116
|
+
// that).
|
|
117
|
+
if (_isLocalStorageNotSynchronized()) {
|
|
118
|
+
// In such browsers, if indexedDB is not supported, an iframe cannot be
|
|
119
|
+
// notified of the popup sign in result.
|
|
120
|
+
return util.isIndexedDBAvailable();
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
// localStorage is not available from a worker. Test availability of
|
|
127
|
+
// indexedDB.
|
|
128
|
+
return _isWorker() && util.isIndexedDBAvailable();
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @param {?Object=} global The optional global scope.
|
|
134
|
+
* @return {boolean} Whether current environment is a worker.
|
|
135
|
+
*/
|
|
136
|
+
function _isWorker() {
|
|
137
|
+
// WorkerGlobalScope only defined in worker environment.
|
|
138
|
+
return (typeof global !== 'undefined' &&
|
|
139
|
+
'WorkerGlobalScope' in global &&
|
|
140
|
+
'importScripts' in global);
|
|
141
|
+
}
|
|
142
|
+
function _isPopupRedirectSupported() {
|
|
143
|
+
return ((_isHttpOrHttps() ||
|
|
144
|
+
util.isBrowserExtension() ||
|
|
145
|
+
_isAndroidOrIosCordovaScheme()) &&
|
|
146
|
+
// React Native with remote debugging reports its location.protocol as
|
|
147
|
+
// http.
|
|
148
|
+
!_isNativeEnvironment() &&
|
|
149
|
+
// Local storage has to be supported for browser popup and redirect
|
|
150
|
+
// operations to work.
|
|
151
|
+
_isWebStorageSupported() &&
|
|
152
|
+
// DOM, popups and redirects are not supported within a worker.
|
|
153
|
+
!_isWorker());
|
|
154
|
+
}
|
|
155
|
+
/** Quick check that indicates the platform *may* be Cordova */
|
|
156
|
+
function _isLikelyCordova() {
|
|
157
|
+
return _isAndroidOrIosCordovaScheme() && typeof document !== 'undefined';
|
|
158
|
+
}
|
|
159
|
+
async function _isCordova() {
|
|
160
|
+
if (!_isLikelyCordova()) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return new Promise(resolve => {
|
|
164
|
+
const timeoutId = setTimeout(() => {
|
|
165
|
+
// We've waited long enough; the telltale Cordova event didn't happen
|
|
166
|
+
resolve(false);
|
|
167
|
+
}, CORDOVA_ONDEVICEREADY_TIMEOUT_MS);
|
|
168
|
+
document.addEventListener('deviceready', () => {
|
|
169
|
+
clearTimeout(timeoutId);
|
|
170
|
+
resolve(true);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function _getSelfWindow() {
|
|
175
|
+
return typeof window !== 'undefined' ? window : null;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
/**
|
|
179
|
-
* @license
|
|
180
|
-
* Copyright 2020 Google LLC
|
|
181
|
-
*
|
|
182
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
183
|
-
* you may not use this file except in compliance with the License.
|
|
184
|
-
* You may obtain a copy of the License at
|
|
185
|
-
*
|
|
186
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
187
|
-
*
|
|
188
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
189
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
190
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
191
|
-
* See the License for the specific language governing permissions and
|
|
192
|
-
* limitations under the License.
|
|
193
|
-
*/
|
|
194
|
-
const Persistence = {
|
|
195
|
-
LOCAL: 'local',
|
|
196
|
-
NONE: 'none',
|
|
197
|
-
SESSION: 'session'
|
|
198
|
-
};
|
|
199
|
-
const _assert$3 = exp__namespace._assert;
|
|
200
|
-
const PERSISTENCE_KEY = 'persistence';
|
|
201
|
-
/**
|
|
202
|
-
* Validates that an argument is a valid persistence value. If an invalid type
|
|
203
|
-
* is specified, an error is thrown synchronously.
|
|
204
|
-
*/
|
|
205
|
-
function _validatePersistenceArgument(auth, persistence) {
|
|
206
|
-
_assert$3(Object.values(Persistence).includes(persistence), auth, "invalid-persistence-type" /* exp.AuthErrorCode.INVALID_PERSISTENCE */);
|
|
207
|
-
// Validate if the specified type is supported in the current environment.
|
|
208
|
-
if (util.isReactNative()) {
|
|
209
|
-
// This is only supported in a browser.
|
|
210
|
-
_assert$3(persistence !== Persistence.SESSION, auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (util.isNode()) {
|
|
214
|
-
// Only none is supported in Node.js.
|
|
215
|
-
_assert$3(persistence === Persistence.NONE, auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (_isWorker()) {
|
|
219
|
-
// In a worker environment, either LOCAL or NONE are supported.
|
|
220
|
-
// If indexedDB not supported and LOCAL provided, throw an error
|
|
221
|
-
_assert$3(persistence === Persistence.NONE ||
|
|
222
|
-
(persistence === Persistence.LOCAL && util.isIndexedDBAvailable()), auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
// This is restricted by what the browser supports.
|
|
226
|
-
_assert$3(persistence === Persistence.NONE || _isWebStorageSupported(), auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
227
|
-
}
|
|
228
|
-
async function _savePersistenceForRedirect(auth) {
|
|
229
|
-
await auth._initializationPromise;
|
|
230
|
-
const session = getSessionStorageIfAvailable();
|
|
231
|
-
const key = exp__namespace._persistenceKeyName(PERSISTENCE_KEY, auth.config.apiKey, auth.name);
|
|
232
|
-
if (session) {
|
|
233
|
-
session.setItem(key, auth._getPersistence());
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
function _getPersistencesFromRedirect(apiKey, appName) {
|
|
237
|
-
const session = getSessionStorageIfAvailable();
|
|
238
|
-
if (!session) {
|
|
239
|
-
return [];
|
|
240
|
-
}
|
|
241
|
-
const key = exp__namespace._persistenceKeyName(PERSISTENCE_KEY, apiKey, appName);
|
|
242
|
-
const persistence = session.getItem(key);
|
|
243
|
-
switch (persistence) {
|
|
244
|
-
case Persistence.NONE:
|
|
245
|
-
return [exp__namespace.inMemoryPersistence];
|
|
246
|
-
case Persistence.LOCAL:
|
|
247
|
-
return [exp__namespace.indexedDBLocalPersistence, exp__namespace.browserSessionPersistence];
|
|
248
|
-
case Persistence.SESSION:
|
|
249
|
-
return [exp__namespace.browserSessionPersistence];
|
|
250
|
-
default:
|
|
251
|
-
return [];
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/** Returns session storage, or null if the property access errors */
|
|
255
|
-
function getSessionStorageIfAvailable() {
|
|
256
|
-
var _a;
|
|
257
|
-
try {
|
|
258
|
-
return ((_a = _getSelfWindow()) === null || _a === void 0 ? void 0 : _a.sessionStorage) || null;
|
|
259
|
-
}
|
|
260
|
-
catch (e) {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
178
|
+
/**
|
|
179
|
+
* @license
|
|
180
|
+
* Copyright 2020 Google LLC
|
|
181
|
+
*
|
|
182
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
183
|
+
* you may not use this file except in compliance with the License.
|
|
184
|
+
* You may obtain a copy of the License at
|
|
185
|
+
*
|
|
186
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
187
|
+
*
|
|
188
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
189
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
190
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
191
|
+
* See the License for the specific language governing permissions and
|
|
192
|
+
* limitations under the License.
|
|
193
|
+
*/
|
|
194
|
+
const Persistence = {
|
|
195
|
+
LOCAL: 'local',
|
|
196
|
+
NONE: 'none',
|
|
197
|
+
SESSION: 'session'
|
|
198
|
+
};
|
|
199
|
+
const _assert$3 = exp__namespace._assert;
|
|
200
|
+
const PERSISTENCE_KEY = 'persistence';
|
|
201
|
+
/**
|
|
202
|
+
* Validates that an argument is a valid persistence value. If an invalid type
|
|
203
|
+
* is specified, an error is thrown synchronously.
|
|
204
|
+
*/
|
|
205
|
+
function _validatePersistenceArgument(auth, persistence) {
|
|
206
|
+
_assert$3(Object.values(Persistence).includes(persistence), auth, "invalid-persistence-type" /* exp.AuthErrorCode.INVALID_PERSISTENCE */);
|
|
207
|
+
// Validate if the specified type is supported in the current environment.
|
|
208
|
+
if (util.isReactNative()) {
|
|
209
|
+
// This is only supported in a browser.
|
|
210
|
+
_assert$3(persistence !== Persistence.SESSION, auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (util.isNode()) {
|
|
214
|
+
// Only none is supported in Node.js.
|
|
215
|
+
_assert$3(persistence === Persistence.NONE, auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (_isWorker()) {
|
|
219
|
+
// In a worker environment, either LOCAL or NONE are supported.
|
|
220
|
+
// If indexedDB not supported and LOCAL provided, throw an error
|
|
221
|
+
_assert$3(persistence === Persistence.NONE ||
|
|
222
|
+
(persistence === Persistence.LOCAL && util.isIndexedDBAvailable()), auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
// This is restricted by what the browser supports.
|
|
226
|
+
_assert$3(persistence === Persistence.NONE || _isWebStorageSupported(), auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
227
|
+
}
|
|
228
|
+
async function _savePersistenceForRedirect(auth) {
|
|
229
|
+
await auth._initializationPromise;
|
|
230
|
+
const session = getSessionStorageIfAvailable();
|
|
231
|
+
const key = exp__namespace._persistenceKeyName(PERSISTENCE_KEY, auth.config.apiKey, auth.name);
|
|
232
|
+
if (session) {
|
|
233
|
+
session.setItem(key, auth._getPersistence());
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function _getPersistencesFromRedirect(apiKey, appName) {
|
|
237
|
+
const session = getSessionStorageIfAvailable();
|
|
238
|
+
if (!session) {
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
const key = exp__namespace._persistenceKeyName(PERSISTENCE_KEY, apiKey, appName);
|
|
242
|
+
const persistence = session.getItem(key);
|
|
243
|
+
switch (persistence) {
|
|
244
|
+
case Persistence.NONE:
|
|
245
|
+
return [exp__namespace.inMemoryPersistence];
|
|
246
|
+
case Persistence.LOCAL:
|
|
247
|
+
return [exp__namespace.indexedDBLocalPersistence, exp__namespace.browserSessionPersistence];
|
|
248
|
+
case Persistence.SESSION:
|
|
249
|
+
return [exp__namespace.browserSessionPersistence];
|
|
250
|
+
default:
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** Returns session storage, or null if the property access errors */
|
|
255
|
+
function getSessionStorageIfAvailable() {
|
|
256
|
+
var _a;
|
|
257
|
+
try {
|
|
258
|
+
return ((_a = _getSelfWindow()) === null || _a === void 0 ? void 0 : _a.sessionStorage) || null;
|
|
259
|
+
}
|
|
260
|
+
catch (e) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
/**
|
|
266
|
-
* @license
|
|
267
|
-
* Copyright 2020 Google LLC
|
|
268
|
-
*
|
|
269
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
270
|
-
* you may not use this file except in compliance with the License.
|
|
271
|
-
* You may obtain a copy of the License at
|
|
272
|
-
*
|
|
273
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
274
|
-
*
|
|
275
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
276
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
277
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
278
|
-
* See the License for the specific language governing permissions and
|
|
279
|
-
* limitations under the License.
|
|
280
|
-
*/
|
|
281
|
-
const _assert$2 = exp__namespace._assert;
|
|
282
|
-
/** Platform-agnostic popup-redirect resolver */
|
|
283
|
-
class CompatPopupRedirectResolver {
|
|
284
|
-
constructor() {
|
|
285
|
-
// Create both resolvers for dynamic resolution later
|
|
286
|
-
this.browserResolver = exp__namespace._getInstance(exp__namespace.browserPopupRedirectResolver);
|
|
287
|
-
this.cordovaResolver = exp__namespace._getInstance(exp__namespace.cordovaPopupRedirectResolver);
|
|
288
|
-
// The actual resolver in use: either browserResolver or cordovaResolver.
|
|
289
|
-
this.underlyingResolver = null;
|
|
290
|
-
this._redirectPersistence = exp__namespace.browserSessionPersistence;
|
|
291
|
-
this._completeRedirectFn = exp__namespace._getRedirectResult;
|
|
292
|
-
this._overrideRedirectResult = exp__namespace._overrideRedirectResult;
|
|
293
|
-
}
|
|
294
|
-
async _initialize(auth) {
|
|
295
|
-
await this.selectUnderlyingResolver();
|
|
296
|
-
return this.assertedUnderlyingResolver._initialize(auth);
|
|
297
|
-
}
|
|
298
|
-
async _openPopup(auth, provider, authType, eventId) {
|
|
299
|
-
await this.selectUnderlyingResolver();
|
|
300
|
-
return this.assertedUnderlyingResolver._openPopup(auth, provider, authType, eventId);
|
|
301
|
-
}
|
|
302
|
-
async _openRedirect(auth, provider, authType, eventId) {
|
|
303
|
-
await this.selectUnderlyingResolver();
|
|
304
|
-
return this.assertedUnderlyingResolver._openRedirect(auth, provider, authType, eventId);
|
|
305
|
-
}
|
|
306
|
-
_isIframeWebStorageSupported(auth, cb) {
|
|
307
|
-
this.assertedUnderlyingResolver._isIframeWebStorageSupported(auth, cb);
|
|
308
|
-
}
|
|
309
|
-
_originValidation(auth) {
|
|
310
|
-
return this.assertedUnderlyingResolver._originValidation(auth);
|
|
311
|
-
}
|
|
312
|
-
get _shouldInitProactively() {
|
|
313
|
-
return _isLikelyCordova() || this.browserResolver._shouldInitProactively;
|
|
314
|
-
}
|
|
315
|
-
get assertedUnderlyingResolver() {
|
|
316
|
-
_assert$2(this.underlyingResolver, "internal-error" /* exp.AuthErrorCode.INTERNAL_ERROR */);
|
|
317
|
-
return this.underlyingResolver;
|
|
318
|
-
}
|
|
319
|
-
async selectUnderlyingResolver() {
|
|
320
|
-
if (this.underlyingResolver) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
// We haven't yet determined whether or not we're in Cordova; go ahead
|
|
324
|
-
// and determine that state now.
|
|
325
|
-
const isCordova = await _isCordova();
|
|
326
|
-
this.underlyingResolver = isCordova
|
|
327
|
-
? this.cordovaResolver
|
|
328
|
-
: this.browserResolver;
|
|
329
|
-
}
|
|
265
|
+
/**
|
|
266
|
+
* @license
|
|
267
|
+
* Copyright 2020 Google LLC
|
|
268
|
+
*
|
|
269
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
270
|
+
* you may not use this file except in compliance with the License.
|
|
271
|
+
* You may obtain a copy of the License at
|
|
272
|
+
*
|
|
273
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
274
|
+
*
|
|
275
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
276
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
277
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
278
|
+
* See the License for the specific language governing permissions and
|
|
279
|
+
* limitations under the License.
|
|
280
|
+
*/
|
|
281
|
+
const _assert$2 = exp__namespace._assert;
|
|
282
|
+
/** Platform-agnostic popup-redirect resolver */
|
|
283
|
+
class CompatPopupRedirectResolver {
|
|
284
|
+
constructor() {
|
|
285
|
+
// Create both resolvers for dynamic resolution later
|
|
286
|
+
this.browserResolver = exp__namespace._getInstance(exp__namespace.browserPopupRedirectResolver);
|
|
287
|
+
this.cordovaResolver = exp__namespace._getInstance(exp__namespace.cordovaPopupRedirectResolver);
|
|
288
|
+
// The actual resolver in use: either browserResolver or cordovaResolver.
|
|
289
|
+
this.underlyingResolver = null;
|
|
290
|
+
this._redirectPersistence = exp__namespace.browserSessionPersistence;
|
|
291
|
+
this._completeRedirectFn = exp__namespace._getRedirectResult;
|
|
292
|
+
this._overrideRedirectResult = exp__namespace._overrideRedirectResult;
|
|
293
|
+
}
|
|
294
|
+
async _initialize(auth) {
|
|
295
|
+
await this.selectUnderlyingResolver();
|
|
296
|
+
return this.assertedUnderlyingResolver._initialize(auth);
|
|
297
|
+
}
|
|
298
|
+
async _openPopup(auth, provider, authType, eventId) {
|
|
299
|
+
await this.selectUnderlyingResolver();
|
|
300
|
+
return this.assertedUnderlyingResolver._openPopup(auth, provider, authType, eventId);
|
|
301
|
+
}
|
|
302
|
+
async _openRedirect(auth, provider, authType, eventId) {
|
|
303
|
+
await this.selectUnderlyingResolver();
|
|
304
|
+
return this.assertedUnderlyingResolver._openRedirect(auth, provider, authType, eventId);
|
|
305
|
+
}
|
|
306
|
+
_isIframeWebStorageSupported(auth, cb) {
|
|
307
|
+
this.assertedUnderlyingResolver._isIframeWebStorageSupported(auth, cb);
|
|
308
|
+
}
|
|
309
|
+
_originValidation(auth) {
|
|
310
|
+
return this.assertedUnderlyingResolver._originValidation(auth);
|
|
311
|
+
}
|
|
312
|
+
get _shouldInitProactively() {
|
|
313
|
+
return _isLikelyCordova() || this.browserResolver._shouldInitProactively;
|
|
314
|
+
}
|
|
315
|
+
get assertedUnderlyingResolver() {
|
|
316
|
+
_assert$2(this.underlyingResolver, "internal-error" /* exp.AuthErrorCode.INTERNAL_ERROR */);
|
|
317
|
+
return this.underlyingResolver;
|
|
318
|
+
}
|
|
319
|
+
async selectUnderlyingResolver() {
|
|
320
|
+
if (this.underlyingResolver) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
// We haven't yet determined whether or not we're in Cordova; go ahead
|
|
324
|
+
// and determine that state now.
|
|
325
|
+
const isCordova = await _isCordova();
|
|
326
|
+
this.underlyingResolver = isCordova
|
|
327
|
+
? this.cordovaResolver
|
|
328
|
+
: this.browserResolver;
|
|
329
|
+
}
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
/**
|
|
333
|
-
* @license
|
|
334
|
-
* Copyright 2020 Google LLC
|
|
335
|
-
*
|
|
336
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
337
|
-
* you may not use this file except in compliance with the License.
|
|
338
|
-
* You may obtain a copy of the License at
|
|
339
|
-
*
|
|
340
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
341
|
-
*
|
|
342
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
343
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
344
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
345
|
-
* See the License for the specific language governing permissions and
|
|
346
|
-
* limitations under the License.
|
|
347
|
-
*/
|
|
348
|
-
function unwrap(object) {
|
|
349
|
-
return object.unwrap();
|
|
350
|
-
}
|
|
351
|
-
function wrapped(object) {
|
|
352
|
-
return object.wrapped();
|
|
332
|
+
/**
|
|
333
|
+
* @license
|
|
334
|
+
* Copyright 2020 Google LLC
|
|
335
|
+
*
|
|
336
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
337
|
+
* you may not use this file except in compliance with the License.
|
|
338
|
+
* You may obtain a copy of the License at
|
|
339
|
+
*
|
|
340
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
341
|
+
*
|
|
342
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
343
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
344
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
345
|
+
* See the License for the specific language governing permissions and
|
|
346
|
+
* limitations under the License.
|
|
347
|
+
*/
|
|
348
|
+
function unwrap(object) {
|
|
349
|
+
return object.unwrap();
|
|
350
|
+
}
|
|
351
|
+
function wrapped(object) {
|
|
352
|
+
return object.wrapped();
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
/**
|
|
356
|
-
* @license
|
|
357
|
-
* Copyright 2020 Google LLC
|
|
358
|
-
*
|
|
359
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
360
|
-
* you may not use this file except in compliance with the License.
|
|
361
|
-
* You may obtain a copy of the License at
|
|
362
|
-
*
|
|
363
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
364
|
-
*
|
|
365
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
366
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
367
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
368
|
-
* See the License for the specific language governing permissions and
|
|
369
|
-
* limitations under the License.
|
|
370
|
-
*/
|
|
371
|
-
function credentialFromResponse(userCredential) {
|
|
372
|
-
return credentialFromObject(userCredential);
|
|
373
|
-
}
|
|
374
|
-
function attachExtraErrorFields(auth, e) {
|
|
375
|
-
var _a;
|
|
376
|
-
// The response contains all fields from the server which may or may not
|
|
377
|
-
// actually match the underlying type
|
|
378
|
-
const response = (_a = e.customData) === null || _a === void 0 ? void 0 : _a._tokenResponse;
|
|
379
|
-
if ((e === null || e === void 0 ? void 0 : e.code) === 'auth/multi-factor-auth-required') {
|
|
380
|
-
const mfaErr = e;
|
|
381
|
-
mfaErr.resolver = new MultiFactorResolver(auth, exp__namespace.getMultiFactorResolver(auth, e));
|
|
382
|
-
}
|
|
383
|
-
else if (response) {
|
|
384
|
-
const credential = credentialFromObject(e);
|
|
385
|
-
const credErr = e;
|
|
386
|
-
if (credential) {
|
|
387
|
-
credErr.credential = credential;
|
|
388
|
-
credErr.tenantId = response.tenantId || undefined;
|
|
389
|
-
credErr.email = response.email || undefined;
|
|
390
|
-
credErr.phoneNumber = response.phoneNumber || undefined;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
function credentialFromObject(object) {
|
|
395
|
-
const { _tokenResponse } = (object instanceof util.FirebaseError ? object.customData : object);
|
|
396
|
-
if (!_tokenResponse) {
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
399
|
-
// Handle phone Auth credential responses, as they have a different format
|
|
400
|
-
// from other backend responses (i.e. no providerId). This is also only the
|
|
401
|
-
// case for user credentials (does not work for errors).
|
|
402
|
-
if (!(object instanceof util.FirebaseError)) {
|
|
403
|
-
if ('temporaryProof' in _tokenResponse && 'phoneNumber' in _tokenResponse) {
|
|
404
|
-
return exp__namespace.PhoneAuthProvider.credentialFromResult(object);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
const providerId = _tokenResponse.providerId;
|
|
408
|
-
// Email and password is not supported as there is no situation where the
|
|
409
|
-
// server would return the password to the client.
|
|
410
|
-
if (!providerId || providerId === exp__namespace.ProviderId.PASSWORD) {
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
let provider;
|
|
414
|
-
switch (providerId) {
|
|
415
|
-
case exp__namespace.ProviderId.GOOGLE:
|
|
416
|
-
provider = exp__namespace.GoogleAuthProvider;
|
|
417
|
-
break;
|
|
418
|
-
case exp__namespace.ProviderId.FACEBOOK:
|
|
419
|
-
provider = exp__namespace.FacebookAuthProvider;
|
|
420
|
-
break;
|
|
421
|
-
case exp__namespace.ProviderId.GITHUB:
|
|
422
|
-
provider = exp__namespace.GithubAuthProvider;
|
|
423
|
-
break;
|
|
424
|
-
case exp__namespace.ProviderId.TWITTER:
|
|
425
|
-
provider = exp__namespace.TwitterAuthProvider;
|
|
426
|
-
break;
|
|
427
|
-
default:
|
|
428
|
-
const { oauthIdToken, oauthAccessToken, oauthTokenSecret, pendingToken, nonce } = _tokenResponse;
|
|
429
|
-
if (!oauthAccessToken &&
|
|
430
|
-
!oauthTokenSecret &&
|
|
431
|
-
!oauthIdToken &&
|
|
432
|
-
!pendingToken) {
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
// TODO(avolkovi): uncomment this and get it working with SAML & OIDC
|
|
436
|
-
if (pendingToken) {
|
|
437
|
-
if (providerId.startsWith('saml.')) {
|
|
438
|
-
return exp__namespace.SAMLAuthCredential._create(providerId, pendingToken);
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
// OIDC and non-default providers excluding Twitter.
|
|
442
|
-
return exp__namespace.OAuthCredential._fromParams({
|
|
443
|
-
providerId,
|
|
444
|
-
signInMethod: providerId,
|
|
445
|
-
pendingToken,
|
|
446
|
-
idToken: oauthIdToken,
|
|
447
|
-
accessToken: oauthAccessToken
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
return new exp__namespace.OAuthProvider(providerId).credential({
|
|
452
|
-
idToken: oauthIdToken,
|
|
453
|
-
accessToken: oauthAccessToken,
|
|
454
|
-
rawNonce: nonce
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
return object instanceof util.FirebaseError
|
|
458
|
-
? provider.credentialFromError(object)
|
|
459
|
-
: provider.credentialFromResult(object);
|
|
460
|
-
}
|
|
461
|
-
function convertCredential(auth, credentialPromise) {
|
|
462
|
-
return credentialPromise
|
|
463
|
-
.catch(e => {
|
|
464
|
-
if (e instanceof util.FirebaseError) {
|
|
465
|
-
attachExtraErrorFields(auth, e);
|
|
466
|
-
}
|
|
467
|
-
throw e;
|
|
468
|
-
})
|
|
469
|
-
.then(credential => {
|
|
470
|
-
const operationType = credential.operationType;
|
|
471
|
-
const user = credential.user;
|
|
472
|
-
return {
|
|
473
|
-
operationType,
|
|
474
|
-
credential: credentialFromResponse(credential),
|
|
475
|
-
additionalUserInfo: exp__namespace.getAdditionalUserInfo(credential),
|
|
476
|
-
user: User.getOrCreate(user)
|
|
477
|
-
};
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
async function convertConfirmationResult(auth, confirmationResultPromise) {
|
|
481
|
-
const confirmationResultExp = await confirmationResultPromise;
|
|
482
|
-
return {
|
|
483
|
-
verificationId: confirmationResultExp.verificationId,
|
|
484
|
-
confirm: (verificationCode) => convertCredential(auth, confirmationResultExp.confirm(verificationCode))
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
class MultiFactorResolver {
|
|
488
|
-
constructor(auth, resolver) {
|
|
489
|
-
this.resolver = resolver;
|
|
490
|
-
this.auth = wrapped(auth);
|
|
491
|
-
}
|
|
492
|
-
get session() {
|
|
493
|
-
return this.resolver.session;
|
|
494
|
-
}
|
|
495
|
-
get hints() {
|
|
496
|
-
return this.resolver.hints;
|
|
497
|
-
}
|
|
498
|
-
resolveSignIn(assertion) {
|
|
499
|
-
return convertCredential(unwrap(this.auth), this.resolver.resolveSignIn(assertion));
|
|
500
|
-
}
|
|
355
|
+
/**
|
|
356
|
+
* @license
|
|
357
|
+
* Copyright 2020 Google LLC
|
|
358
|
+
*
|
|
359
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
360
|
+
* you may not use this file except in compliance with the License.
|
|
361
|
+
* You may obtain a copy of the License at
|
|
362
|
+
*
|
|
363
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
364
|
+
*
|
|
365
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
366
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
367
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
368
|
+
* See the License for the specific language governing permissions and
|
|
369
|
+
* limitations under the License.
|
|
370
|
+
*/
|
|
371
|
+
function credentialFromResponse(userCredential) {
|
|
372
|
+
return credentialFromObject(userCredential);
|
|
373
|
+
}
|
|
374
|
+
function attachExtraErrorFields(auth, e) {
|
|
375
|
+
var _a;
|
|
376
|
+
// The response contains all fields from the server which may or may not
|
|
377
|
+
// actually match the underlying type
|
|
378
|
+
const response = (_a = e.customData) === null || _a === void 0 ? void 0 : _a._tokenResponse;
|
|
379
|
+
if ((e === null || e === void 0 ? void 0 : e.code) === 'auth/multi-factor-auth-required') {
|
|
380
|
+
const mfaErr = e;
|
|
381
|
+
mfaErr.resolver = new MultiFactorResolver(auth, exp__namespace.getMultiFactorResolver(auth, e));
|
|
382
|
+
}
|
|
383
|
+
else if (response) {
|
|
384
|
+
const credential = credentialFromObject(e);
|
|
385
|
+
const credErr = e;
|
|
386
|
+
if (credential) {
|
|
387
|
+
credErr.credential = credential;
|
|
388
|
+
credErr.tenantId = response.tenantId || undefined;
|
|
389
|
+
credErr.email = response.email || undefined;
|
|
390
|
+
credErr.phoneNumber = response.phoneNumber || undefined;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function credentialFromObject(object) {
|
|
395
|
+
const { _tokenResponse } = (object instanceof util.FirebaseError ? object.customData : object);
|
|
396
|
+
if (!_tokenResponse) {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
// Handle phone Auth credential responses, as they have a different format
|
|
400
|
+
// from other backend responses (i.e. no providerId). This is also only the
|
|
401
|
+
// case for user credentials (does not work for errors).
|
|
402
|
+
if (!(object instanceof util.FirebaseError)) {
|
|
403
|
+
if ('temporaryProof' in _tokenResponse && 'phoneNumber' in _tokenResponse) {
|
|
404
|
+
return exp__namespace.PhoneAuthProvider.credentialFromResult(object);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const providerId = _tokenResponse.providerId;
|
|
408
|
+
// Email and password is not supported as there is no situation where the
|
|
409
|
+
// server would return the password to the client.
|
|
410
|
+
if (!providerId || providerId === exp__namespace.ProviderId.PASSWORD) {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
let provider;
|
|
414
|
+
switch (providerId) {
|
|
415
|
+
case exp__namespace.ProviderId.GOOGLE:
|
|
416
|
+
provider = exp__namespace.GoogleAuthProvider;
|
|
417
|
+
break;
|
|
418
|
+
case exp__namespace.ProviderId.FACEBOOK:
|
|
419
|
+
provider = exp__namespace.FacebookAuthProvider;
|
|
420
|
+
break;
|
|
421
|
+
case exp__namespace.ProviderId.GITHUB:
|
|
422
|
+
provider = exp__namespace.GithubAuthProvider;
|
|
423
|
+
break;
|
|
424
|
+
case exp__namespace.ProviderId.TWITTER:
|
|
425
|
+
provider = exp__namespace.TwitterAuthProvider;
|
|
426
|
+
break;
|
|
427
|
+
default:
|
|
428
|
+
const { oauthIdToken, oauthAccessToken, oauthTokenSecret, pendingToken, nonce } = _tokenResponse;
|
|
429
|
+
if (!oauthAccessToken &&
|
|
430
|
+
!oauthTokenSecret &&
|
|
431
|
+
!oauthIdToken &&
|
|
432
|
+
!pendingToken) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
// TODO(avolkovi): uncomment this and get it working with SAML & OIDC
|
|
436
|
+
if (pendingToken) {
|
|
437
|
+
if (providerId.startsWith('saml.')) {
|
|
438
|
+
return exp__namespace.SAMLAuthCredential._create(providerId, pendingToken);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
// OIDC and non-default providers excluding Twitter.
|
|
442
|
+
return exp__namespace.OAuthCredential._fromParams({
|
|
443
|
+
providerId,
|
|
444
|
+
signInMethod: providerId,
|
|
445
|
+
pendingToken,
|
|
446
|
+
idToken: oauthIdToken,
|
|
447
|
+
accessToken: oauthAccessToken
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return new exp__namespace.OAuthProvider(providerId).credential({
|
|
452
|
+
idToken: oauthIdToken,
|
|
453
|
+
accessToken: oauthAccessToken,
|
|
454
|
+
rawNonce: nonce
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
return object instanceof util.FirebaseError
|
|
458
|
+
? provider.credentialFromError(object)
|
|
459
|
+
: provider.credentialFromResult(object);
|
|
460
|
+
}
|
|
461
|
+
function convertCredential(auth, credentialPromise) {
|
|
462
|
+
return credentialPromise
|
|
463
|
+
.catch(e => {
|
|
464
|
+
if (e instanceof util.FirebaseError) {
|
|
465
|
+
attachExtraErrorFields(auth, e);
|
|
466
|
+
}
|
|
467
|
+
throw e;
|
|
468
|
+
})
|
|
469
|
+
.then(credential => {
|
|
470
|
+
const operationType = credential.operationType;
|
|
471
|
+
const user = credential.user;
|
|
472
|
+
return {
|
|
473
|
+
operationType,
|
|
474
|
+
credential: credentialFromResponse(credential),
|
|
475
|
+
additionalUserInfo: exp__namespace.getAdditionalUserInfo(credential),
|
|
476
|
+
user: User.getOrCreate(user)
|
|
477
|
+
};
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
async function convertConfirmationResult(auth, confirmationResultPromise) {
|
|
481
|
+
const confirmationResultExp = await confirmationResultPromise;
|
|
482
|
+
return {
|
|
483
|
+
verificationId: confirmationResultExp.verificationId,
|
|
484
|
+
confirm: (verificationCode) => convertCredential(auth, confirmationResultExp.confirm(verificationCode))
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
class MultiFactorResolver {
|
|
488
|
+
constructor(auth, resolver) {
|
|
489
|
+
this.resolver = resolver;
|
|
490
|
+
this.auth = wrapped(auth);
|
|
491
|
+
}
|
|
492
|
+
get session() {
|
|
493
|
+
return this.resolver.session;
|
|
494
|
+
}
|
|
495
|
+
get hints() {
|
|
496
|
+
return this.resolver.hints;
|
|
497
|
+
}
|
|
498
|
+
resolveSignIn(assertion) {
|
|
499
|
+
return convertCredential(unwrap(this.auth), this.resolver.resolveSignIn(assertion));
|
|
500
|
+
}
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
/**
|
|
504
|
-
* @license
|
|
505
|
-
* Copyright 2020 Google LLC
|
|
506
|
-
*
|
|
507
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
508
|
-
* you may not use this file except in compliance with the License.
|
|
509
|
-
* You may obtain a copy of the License at
|
|
510
|
-
*
|
|
511
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
512
|
-
*
|
|
513
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
514
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
515
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
516
|
-
* See the License for the specific language governing permissions and
|
|
517
|
-
* limitations under the License.
|
|
518
|
-
*/
|
|
519
|
-
class User {
|
|
520
|
-
constructor(_delegate) {
|
|
521
|
-
this._delegate = _delegate;
|
|
522
|
-
this.multiFactor = exp__namespace.multiFactor(_delegate);
|
|
523
|
-
}
|
|
524
|
-
static getOrCreate(user) {
|
|
525
|
-
if (!User.USER_MAP.has(user)) {
|
|
526
|
-
User.USER_MAP.set(user, new User(user));
|
|
527
|
-
}
|
|
528
|
-
return User.USER_MAP.get(user);
|
|
529
|
-
}
|
|
530
|
-
delete() {
|
|
531
|
-
return this._delegate.delete();
|
|
532
|
-
}
|
|
533
|
-
reload() {
|
|
534
|
-
return this._delegate.reload();
|
|
535
|
-
}
|
|
536
|
-
toJSON() {
|
|
537
|
-
return this._delegate.toJSON();
|
|
538
|
-
}
|
|
539
|
-
getIdTokenResult(forceRefresh) {
|
|
540
|
-
return this._delegate.getIdTokenResult(forceRefresh);
|
|
541
|
-
}
|
|
542
|
-
getIdToken(forceRefresh) {
|
|
543
|
-
return this._delegate.getIdToken(forceRefresh);
|
|
544
|
-
}
|
|
545
|
-
linkAndRetrieveDataWithCredential(credential) {
|
|
546
|
-
return this.linkWithCredential(credential);
|
|
547
|
-
}
|
|
548
|
-
async linkWithCredential(credential) {
|
|
549
|
-
return convertCredential(this.auth, exp__namespace.linkWithCredential(this._delegate, credential));
|
|
550
|
-
}
|
|
551
|
-
async linkWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
552
|
-
return convertConfirmationResult(this.auth, exp__namespace.linkWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
553
|
-
}
|
|
554
|
-
async linkWithPopup(provider) {
|
|
555
|
-
return convertCredential(this.auth, exp__namespace.linkWithPopup(this._delegate, provider, CompatPopupRedirectResolver));
|
|
556
|
-
}
|
|
557
|
-
async linkWithRedirect(provider) {
|
|
558
|
-
await _savePersistenceForRedirect(exp__namespace._castAuth(this.auth));
|
|
559
|
-
return exp__namespace.linkWithRedirect(this._delegate, provider, CompatPopupRedirectResolver);
|
|
560
|
-
}
|
|
561
|
-
reauthenticateAndRetrieveDataWithCredential(credential) {
|
|
562
|
-
return this.reauthenticateWithCredential(credential);
|
|
563
|
-
}
|
|
564
|
-
async reauthenticateWithCredential(credential) {
|
|
565
|
-
return convertCredential(this.auth, exp__namespace.reauthenticateWithCredential(this._delegate, credential));
|
|
566
|
-
}
|
|
567
|
-
reauthenticateWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
568
|
-
return convertConfirmationResult(this.auth, exp__namespace.reauthenticateWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
569
|
-
}
|
|
570
|
-
reauthenticateWithPopup(provider) {
|
|
571
|
-
return convertCredential(this.auth, exp__namespace.reauthenticateWithPopup(this._delegate, provider, CompatPopupRedirectResolver));
|
|
572
|
-
}
|
|
573
|
-
async reauthenticateWithRedirect(provider) {
|
|
574
|
-
await _savePersistenceForRedirect(exp__namespace._castAuth(this.auth));
|
|
575
|
-
return exp__namespace.reauthenticateWithRedirect(this._delegate, provider, CompatPopupRedirectResolver);
|
|
576
|
-
}
|
|
577
|
-
sendEmailVerification(actionCodeSettings) {
|
|
578
|
-
return exp__namespace.sendEmailVerification(this._delegate, actionCodeSettings);
|
|
579
|
-
}
|
|
580
|
-
async unlink(providerId) {
|
|
581
|
-
await exp__namespace.unlink(this._delegate, providerId);
|
|
582
|
-
return this;
|
|
583
|
-
}
|
|
584
|
-
updateEmail(newEmail) {
|
|
585
|
-
return exp__namespace.updateEmail(this._delegate, newEmail);
|
|
586
|
-
}
|
|
587
|
-
updatePassword(newPassword) {
|
|
588
|
-
return exp__namespace.updatePassword(this._delegate, newPassword);
|
|
589
|
-
}
|
|
590
|
-
updatePhoneNumber(phoneCredential) {
|
|
591
|
-
return exp__namespace.updatePhoneNumber(this._delegate, phoneCredential);
|
|
592
|
-
}
|
|
593
|
-
updateProfile(profile) {
|
|
594
|
-
return exp__namespace.updateProfile(this._delegate, profile);
|
|
595
|
-
}
|
|
596
|
-
verifyBeforeUpdateEmail(newEmail, actionCodeSettings) {
|
|
597
|
-
return exp__namespace.verifyBeforeUpdateEmail(this._delegate, newEmail, actionCodeSettings);
|
|
598
|
-
}
|
|
599
|
-
get emailVerified() {
|
|
600
|
-
return this._delegate.emailVerified;
|
|
601
|
-
}
|
|
602
|
-
get isAnonymous() {
|
|
603
|
-
return this._delegate.isAnonymous;
|
|
604
|
-
}
|
|
605
|
-
get metadata() {
|
|
606
|
-
return this._delegate.metadata;
|
|
607
|
-
}
|
|
608
|
-
get phoneNumber() {
|
|
609
|
-
return this._delegate.phoneNumber;
|
|
610
|
-
}
|
|
611
|
-
get providerData() {
|
|
612
|
-
return this._delegate.providerData;
|
|
613
|
-
}
|
|
614
|
-
get refreshToken() {
|
|
615
|
-
return this._delegate.refreshToken;
|
|
616
|
-
}
|
|
617
|
-
get tenantId() {
|
|
618
|
-
return this._delegate.tenantId;
|
|
619
|
-
}
|
|
620
|
-
get displayName() {
|
|
621
|
-
return this._delegate.displayName;
|
|
622
|
-
}
|
|
623
|
-
get email() {
|
|
624
|
-
return this._delegate.email;
|
|
625
|
-
}
|
|
626
|
-
get photoURL() {
|
|
627
|
-
return this._delegate.photoURL;
|
|
628
|
-
}
|
|
629
|
-
get providerId() {
|
|
630
|
-
return this._delegate.providerId;
|
|
631
|
-
}
|
|
632
|
-
get uid() {
|
|
633
|
-
return this._delegate.uid;
|
|
634
|
-
}
|
|
635
|
-
get auth() {
|
|
636
|
-
return this._delegate.auth;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
// Maintain a map so that there's always a 1:1 mapping between new User and
|
|
640
|
-
// legacy compat users
|
|
503
|
+
/**
|
|
504
|
+
* @license
|
|
505
|
+
* Copyright 2020 Google LLC
|
|
506
|
+
*
|
|
507
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
508
|
+
* you may not use this file except in compliance with the License.
|
|
509
|
+
* You may obtain a copy of the License at
|
|
510
|
+
*
|
|
511
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
512
|
+
*
|
|
513
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
514
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
515
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
516
|
+
* See the License for the specific language governing permissions and
|
|
517
|
+
* limitations under the License.
|
|
518
|
+
*/
|
|
519
|
+
class User {
|
|
520
|
+
constructor(_delegate) {
|
|
521
|
+
this._delegate = _delegate;
|
|
522
|
+
this.multiFactor = exp__namespace.multiFactor(_delegate);
|
|
523
|
+
}
|
|
524
|
+
static getOrCreate(user) {
|
|
525
|
+
if (!User.USER_MAP.has(user)) {
|
|
526
|
+
User.USER_MAP.set(user, new User(user));
|
|
527
|
+
}
|
|
528
|
+
return User.USER_MAP.get(user);
|
|
529
|
+
}
|
|
530
|
+
delete() {
|
|
531
|
+
return this._delegate.delete();
|
|
532
|
+
}
|
|
533
|
+
reload() {
|
|
534
|
+
return this._delegate.reload();
|
|
535
|
+
}
|
|
536
|
+
toJSON() {
|
|
537
|
+
return this._delegate.toJSON();
|
|
538
|
+
}
|
|
539
|
+
getIdTokenResult(forceRefresh) {
|
|
540
|
+
return this._delegate.getIdTokenResult(forceRefresh);
|
|
541
|
+
}
|
|
542
|
+
getIdToken(forceRefresh) {
|
|
543
|
+
return this._delegate.getIdToken(forceRefresh);
|
|
544
|
+
}
|
|
545
|
+
linkAndRetrieveDataWithCredential(credential) {
|
|
546
|
+
return this.linkWithCredential(credential);
|
|
547
|
+
}
|
|
548
|
+
async linkWithCredential(credential) {
|
|
549
|
+
return convertCredential(this.auth, exp__namespace.linkWithCredential(this._delegate, credential));
|
|
550
|
+
}
|
|
551
|
+
async linkWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
552
|
+
return convertConfirmationResult(this.auth, exp__namespace.linkWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
553
|
+
}
|
|
554
|
+
async linkWithPopup(provider) {
|
|
555
|
+
return convertCredential(this.auth, exp__namespace.linkWithPopup(this._delegate, provider, CompatPopupRedirectResolver));
|
|
556
|
+
}
|
|
557
|
+
async linkWithRedirect(provider) {
|
|
558
|
+
await _savePersistenceForRedirect(exp__namespace._castAuth(this.auth));
|
|
559
|
+
return exp__namespace.linkWithRedirect(this._delegate, provider, CompatPopupRedirectResolver);
|
|
560
|
+
}
|
|
561
|
+
reauthenticateAndRetrieveDataWithCredential(credential) {
|
|
562
|
+
return this.reauthenticateWithCredential(credential);
|
|
563
|
+
}
|
|
564
|
+
async reauthenticateWithCredential(credential) {
|
|
565
|
+
return convertCredential(this.auth, exp__namespace.reauthenticateWithCredential(this._delegate, credential));
|
|
566
|
+
}
|
|
567
|
+
reauthenticateWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
568
|
+
return convertConfirmationResult(this.auth, exp__namespace.reauthenticateWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
569
|
+
}
|
|
570
|
+
reauthenticateWithPopup(provider) {
|
|
571
|
+
return convertCredential(this.auth, exp__namespace.reauthenticateWithPopup(this._delegate, provider, CompatPopupRedirectResolver));
|
|
572
|
+
}
|
|
573
|
+
async reauthenticateWithRedirect(provider) {
|
|
574
|
+
await _savePersistenceForRedirect(exp__namespace._castAuth(this.auth));
|
|
575
|
+
return exp__namespace.reauthenticateWithRedirect(this._delegate, provider, CompatPopupRedirectResolver);
|
|
576
|
+
}
|
|
577
|
+
sendEmailVerification(actionCodeSettings) {
|
|
578
|
+
return exp__namespace.sendEmailVerification(this._delegate, actionCodeSettings);
|
|
579
|
+
}
|
|
580
|
+
async unlink(providerId) {
|
|
581
|
+
await exp__namespace.unlink(this._delegate, providerId);
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
updateEmail(newEmail) {
|
|
585
|
+
return exp__namespace.updateEmail(this._delegate, newEmail);
|
|
586
|
+
}
|
|
587
|
+
updatePassword(newPassword) {
|
|
588
|
+
return exp__namespace.updatePassword(this._delegate, newPassword);
|
|
589
|
+
}
|
|
590
|
+
updatePhoneNumber(phoneCredential) {
|
|
591
|
+
return exp__namespace.updatePhoneNumber(this._delegate, phoneCredential);
|
|
592
|
+
}
|
|
593
|
+
updateProfile(profile) {
|
|
594
|
+
return exp__namespace.updateProfile(this._delegate, profile);
|
|
595
|
+
}
|
|
596
|
+
verifyBeforeUpdateEmail(newEmail, actionCodeSettings) {
|
|
597
|
+
return exp__namespace.verifyBeforeUpdateEmail(this._delegate, newEmail, actionCodeSettings);
|
|
598
|
+
}
|
|
599
|
+
get emailVerified() {
|
|
600
|
+
return this._delegate.emailVerified;
|
|
601
|
+
}
|
|
602
|
+
get isAnonymous() {
|
|
603
|
+
return this._delegate.isAnonymous;
|
|
604
|
+
}
|
|
605
|
+
get metadata() {
|
|
606
|
+
return this._delegate.metadata;
|
|
607
|
+
}
|
|
608
|
+
get phoneNumber() {
|
|
609
|
+
return this._delegate.phoneNumber;
|
|
610
|
+
}
|
|
611
|
+
get providerData() {
|
|
612
|
+
return this._delegate.providerData;
|
|
613
|
+
}
|
|
614
|
+
get refreshToken() {
|
|
615
|
+
return this._delegate.refreshToken;
|
|
616
|
+
}
|
|
617
|
+
get tenantId() {
|
|
618
|
+
return this._delegate.tenantId;
|
|
619
|
+
}
|
|
620
|
+
get displayName() {
|
|
621
|
+
return this._delegate.displayName;
|
|
622
|
+
}
|
|
623
|
+
get email() {
|
|
624
|
+
return this._delegate.email;
|
|
625
|
+
}
|
|
626
|
+
get photoURL() {
|
|
627
|
+
return this._delegate.photoURL;
|
|
628
|
+
}
|
|
629
|
+
get providerId() {
|
|
630
|
+
return this._delegate.providerId;
|
|
631
|
+
}
|
|
632
|
+
get uid() {
|
|
633
|
+
return this._delegate.uid;
|
|
634
|
+
}
|
|
635
|
+
get auth() {
|
|
636
|
+
return this._delegate.auth;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
// Maintain a map so that there's always a 1:1 mapping between new User and
|
|
640
|
+
// legacy compat users
|
|
641
641
|
User.USER_MAP = new WeakMap();
|
|
642
642
|
|
|
643
|
-
/**
|
|
644
|
-
* @license
|
|
645
|
-
* Copyright 2020 Google LLC
|
|
646
|
-
*
|
|
647
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
648
|
-
* you may not use this file except in compliance with the License.
|
|
649
|
-
* You may obtain a copy of the License at
|
|
650
|
-
*
|
|
651
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
652
|
-
*
|
|
653
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
654
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
655
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
656
|
-
* See the License for the specific language governing permissions and
|
|
657
|
-
* limitations under the License.
|
|
658
|
-
*/
|
|
659
|
-
const _assert$1 = exp__namespace._assert;
|
|
660
|
-
class Auth {
|
|
661
|
-
constructor(app, provider) {
|
|
662
|
-
this.app = app;
|
|
663
|
-
if (provider.isInitialized()) {
|
|
664
|
-
this._delegate = provider.getImmediate();
|
|
665
|
-
this.linkUnderlyingAuth();
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
const { apiKey } = app.options;
|
|
669
|
-
// TODO: platform needs to be determined using heuristics
|
|
670
|
-
_assert$1(apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
671
|
-
appName: app.name
|
|
672
|
-
});
|
|
673
|
-
// TODO: platform needs to be determined using heuristics
|
|
674
|
-
_assert$1(apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
675
|
-
appName: app.name
|
|
676
|
-
});
|
|
677
|
-
// Only use a popup/redirect resolver in browser environments
|
|
678
|
-
const resolver = typeof window !== 'undefined' ? CompatPopupRedirectResolver : undefined;
|
|
679
|
-
this._delegate = provider.initialize({
|
|
680
|
-
options: {
|
|
681
|
-
persistence: buildPersistenceHierarchy(apiKey, app.name),
|
|
682
|
-
popupRedirectResolver: resolver
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
this._delegate._updateErrorMap(exp__namespace.debugErrorMap);
|
|
686
|
-
this.linkUnderlyingAuth();
|
|
687
|
-
}
|
|
688
|
-
get emulatorConfig() {
|
|
689
|
-
return this._delegate.emulatorConfig;
|
|
690
|
-
}
|
|
691
|
-
get currentUser() {
|
|
692
|
-
if (!this._delegate.currentUser) {
|
|
693
|
-
return null;
|
|
694
|
-
}
|
|
695
|
-
return User.getOrCreate(this._delegate.currentUser);
|
|
696
|
-
}
|
|
697
|
-
get languageCode() {
|
|
698
|
-
return this._delegate.languageCode;
|
|
699
|
-
}
|
|
700
|
-
set languageCode(languageCode) {
|
|
701
|
-
this._delegate.languageCode = languageCode;
|
|
702
|
-
}
|
|
703
|
-
get settings() {
|
|
704
|
-
return this._delegate.settings;
|
|
705
|
-
}
|
|
706
|
-
get tenantId() {
|
|
707
|
-
return this._delegate.tenantId;
|
|
708
|
-
}
|
|
709
|
-
set tenantId(tid) {
|
|
710
|
-
this._delegate.tenantId = tid;
|
|
711
|
-
}
|
|
712
|
-
useDeviceLanguage() {
|
|
713
|
-
this._delegate.useDeviceLanguage();
|
|
714
|
-
}
|
|
715
|
-
signOut() {
|
|
716
|
-
return this._delegate.signOut();
|
|
717
|
-
}
|
|
718
|
-
useEmulator(url, options) {
|
|
719
|
-
exp__namespace.connectAuthEmulator(this._delegate, url, options);
|
|
720
|
-
}
|
|
721
|
-
applyActionCode(code) {
|
|
722
|
-
return exp__namespace.applyActionCode(this._delegate, code);
|
|
723
|
-
}
|
|
724
|
-
checkActionCode(code) {
|
|
725
|
-
return exp__namespace.checkActionCode(this._delegate, code);
|
|
726
|
-
}
|
|
727
|
-
confirmPasswordReset(code, newPassword) {
|
|
728
|
-
return exp__namespace.confirmPasswordReset(this._delegate, code, newPassword);
|
|
729
|
-
}
|
|
730
|
-
async createUserWithEmailAndPassword(email, password) {
|
|
731
|
-
return convertCredential(this._delegate, exp__namespace.createUserWithEmailAndPassword(this._delegate, email, password));
|
|
732
|
-
}
|
|
733
|
-
fetchProvidersForEmail(email) {
|
|
734
|
-
return this.fetchSignInMethodsForEmail(email);
|
|
735
|
-
}
|
|
736
|
-
fetchSignInMethodsForEmail(email) {
|
|
737
|
-
return exp__namespace.fetchSignInMethodsForEmail(this._delegate, email);
|
|
738
|
-
}
|
|
739
|
-
isSignInWithEmailLink(emailLink) {
|
|
740
|
-
return exp__namespace.isSignInWithEmailLink(this._delegate, emailLink);
|
|
741
|
-
}
|
|
742
|
-
async getRedirectResult() {
|
|
743
|
-
_assert$1(_isPopupRedirectSupported(), this._delegate, "operation-not-supported-in-this-environment" /* exp.AuthErrorCode.OPERATION_NOT_SUPPORTED */);
|
|
744
|
-
const credential = await exp__namespace.getRedirectResult(this._delegate, CompatPopupRedirectResolver);
|
|
745
|
-
if (!credential) {
|
|
746
|
-
return {
|
|
747
|
-
credential: null,
|
|
748
|
-
user: null
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
return convertCredential(this._delegate, Promise.resolve(credential));
|
|
752
|
-
}
|
|
753
|
-
// This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
|
|
754
|
-
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it
|
|
755
|
-
// out of autogenerated documentation pages to reduce accidental misuse.
|
|
756
|
-
addFrameworkForLogging(framework) {
|
|
757
|
-
exp__namespace.addFrameworkForLogging(this._delegate, framework);
|
|
758
|
-
}
|
|
759
|
-
onAuthStateChanged(nextOrObserver, errorFn, completed) {
|
|
760
|
-
const { next, error, complete } = wrapObservers(nextOrObserver, errorFn, completed);
|
|
761
|
-
return this._delegate.onAuthStateChanged(next, error, complete);
|
|
762
|
-
}
|
|
763
|
-
onIdTokenChanged(nextOrObserver, errorFn, completed) {
|
|
764
|
-
const { next, error, complete } = wrapObservers(nextOrObserver, errorFn, completed);
|
|
765
|
-
return this._delegate.onIdTokenChanged(next, error, complete);
|
|
766
|
-
}
|
|
767
|
-
sendSignInLinkToEmail(email, actionCodeSettings) {
|
|
768
|
-
return exp__namespace.sendSignInLinkToEmail(this._delegate, email, actionCodeSettings);
|
|
769
|
-
}
|
|
770
|
-
sendPasswordResetEmail(email, actionCodeSettings) {
|
|
771
|
-
return exp__namespace.sendPasswordResetEmail(this._delegate, email, actionCodeSettings || undefined);
|
|
772
|
-
}
|
|
773
|
-
async setPersistence(persistence) {
|
|
774
|
-
_validatePersistenceArgument(this._delegate, persistence);
|
|
775
|
-
let converted;
|
|
776
|
-
switch (persistence) {
|
|
777
|
-
case Persistence.SESSION:
|
|
778
|
-
converted = exp__namespace.browserSessionPersistence;
|
|
779
|
-
break;
|
|
780
|
-
case Persistence.LOCAL:
|
|
781
|
-
// Not using isIndexedDBAvailable() since it only checks if indexedDB is defined.
|
|
782
|
-
const isIndexedDBFullySupported = await exp__namespace
|
|
783
|
-
._getInstance(exp__namespace.indexedDBLocalPersistence)
|
|
784
|
-
._isAvailable();
|
|
785
|
-
converted = isIndexedDBFullySupported
|
|
786
|
-
? exp__namespace.indexedDBLocalPersistence
|
|
787
|
-
: exp__namespace.browserLocalPersistence;
|
|
788
|
-
break;
|
|
789
|
-
case Persistence.NONE:
|
|
790
|
-
converted = exp__namespace.inMemoryPersistence;
|
|
791
|
-
break;
|
|
792
|
-
default:
|
|
793
|
-
return exp__namespace._fail("argument-error" /* exp.AuthErrorCode.ARGUMENT_ERROR */, {
|
|
794
|
-
appName: this._delegate.name
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
return this._delegate.setPersistence(converted);
|
|
798
|
-
}
|
|
799
|
-
signInAndRetrieveDataWithCredential(credential) {
|
|
800
|
-
return this.signInWithCredential(credential);
|
|
801
|
-
}
|
|
802
|
-
signInAnonymously() {
|
|
803
|
-
return convertCredential(this._delegate, exp__namespace.signInAnonymously(this._delegate));
|
|
804
|
-
}
|
|
805
|
-
signInWithCredential(credential) {
|
|
806
|
-
return convertCredential(this._delegate, exp__namespace.signInWithCredential(this._delegate, credential));
|
|
807
|
-
}
|
|
808
|
-
signInWithCustomToken(token) {
|
|
809
|
-
return convertCredential(this._delegate, exp__namespace.signInWithCustomToken(this._delegate, token));
|
|
810
|
-
}
|
|
811
|
-
signInWithEmailAndPassword(email, password) {
|
|
812
|
-
return convertCredential(this._delegate, exp__namespace.signInWithEmailAndPassword(this._delegate, email, password));
|
|
813
|
-
}
|
|
814
|
-
signInWithEmailLink(email, emailLink) {
|
|
815
|
-
return convertCredential(this._delegate, exp__namespace.signInWithEmailLink(this._delegate, email, emailLink));
|
|
816
|
-
}
|
|
817
|
-
signInWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
818
|
-
return convertConfirmationResult(this._delegate, exp__namespace.signInWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
819
|
-
}
|
|
820
|
-
async signInWithPopup(provider) {
|
|
821
|
-
_assert$1(_isPopupRedirectSupported(), this._delegate, "operation-not-supported-in-this-environment" /* exp.AuthErrorCode.OPERATION_NOT_SUPPORTED */);
|
|
822
|
-
return convertCredential(this._delegate, exp__namespace.signInWithPopup(this._delegate, provider, CompatPopupRedirectResolver));
|
|
823
|
-
}
|
|
824
|
-
async signInWithRedirect(provider) {
|
|
825
|
-
_assert$1(_isPopupRedirectSupported(), this._delegate, "operation-not-supported-in-this-environment" /* exp.AuthErrorCode.OPERATION_NOT_SUPPORTED */);
|
|
826
|
-
await _savePersistenceForRedirect(this._delegate);
|
|
827
|
-
return exp__namespace.signInWithRedirect(this._delegate, provider, CompatPopupRedirectResolver);
|
|
828
|
-
}
|
|
829
|
-
updateCurrentUser(user) {
|
|
830
|
-
// remove ts-ignore once overloads are defined for exp functions to accept compat objects
|
|
831
|
-
// @ts-ignore
|
|
832
|
-
return this._delegate.updateCurrentUser(user);
|
|
833
|
-
}
|
|
834
|
-
verifyPasswordResetCode(code) {
|
|
835
|
-
return exp__namespace.verifyPasswordResetCode(this._delegate, code);
|
|
836
|
-
}
|
|
837
|
-
unwrap() {
|
|
838
|
-
return this._delegate;
|
|
839
|
-
}
|
|
840
|
-
_delete() {
|
|
841
|
-
return this._delegate._delete();
|
|
842
|
-
}
|
|
843
|
-
linkUnderlyingAuth() {
|
|
844
|
-
this._delegate.wrapped = () => this;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
Auth.Persistence = Persistence;
|
|
848
|
-
function wrapObservers(nextOrObserver, error, complete) {
|
|
849
|
-
let next = nextOrObserver;
|
|
850
|
-
if (typeof nextOrObserver !== 'function') {
|
|
851
|
-
({ next, error, complete } = nextOrObserver);
|
|
852
|
-
}
|
|
853
|
-
// We know 'next' is now a function
|
|
854
|
-
const oldNext = next;
|
|
855
|
-
const newNext = (user) => oldNext(user && User.getOrCreate(user));
|
|
856
|
-
return {
|
|
857
|
-
next: newNext,
|
|
858
|
-
error: error,
|
|
859
|
-
complete
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
function buildPersistenceHierarchy(apiKey, appName) {
|
|
863
|
-
// Note this is slightly different behavior: in this case, the stored
|
|
864
|
-
// persistence is checked *first* rather than last. This is because we want
|
|
865
|
-
// to prefer stored persistence type in the hierarchy. This is an empty
|
|
866
|
-
// array if window is not available or there is no pending redirect
|
|
867
|
-
const persistences = _getPersistencesFromRedirect(apiKey, appName);
|
|
868
|
-
// If "self" is available, add indexedDB
|
|
869
|
-
if (typeof self !== 'undefined' &&
|
|
870
|
-
!persistences.includes(exp__namespace.indexedDBLocalPersistence)) {
|
|
871
|
-
persistences.push(exp__namespace.indexedDBLocalPersistence);
|
|
872
|
-
}
|
|
873
|
-
// If "window" is available, add HTML Storage persistences
|
|
874
|
-
if (typeof window !== 'undefined') {
|
|
875
|
-
for (const persistence of [
|
|
876
|
-
exp__namespace.browserLocalPersistence,
|
|
877
|
-
exp__namespace.browserSessionPersistence
|
|
878
|
-
]) {
|
|
879
|
-
if (!persistences.includes(persistence)) {
|
|
880
|
-
persistences.push(persistence);
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
// Add in-memory as a final fallback
|
|
885
|
-
if (!persistences.includes(exp__namespace.inMemoryPersistence)) {
|
|
886
|
-
persistences.push(exp__namespace.inMemoryPersistence);
|
|
887
|
-
}
|
|
888
|
-
return persistences;
|
|
643
|
+
/**
|
|
644
|
+
* @license
|
|
645
|
+
* Copyright 2020 Google LLC
|
|
646
|
+
*
|
|
647
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
648
|
+
* you may not use this file except in compliance with the License.
|
|
649
|
+
* You may obtain a copy of the License at
|
|
650
|
+
*
|
|
651
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
652
|
+
*
|
|
653
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
654
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
655
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
656
|
+
* See the License for the specific language governing permissions and
|
|
657
|
+
* limitations under the License.
|
|
658
|
+
*/
|
|
659
|
+
const _assert$1 = exp__namespace._assert;
|
|
660
|
+
class Auth {
|
|
661
|
+
constructor(app, provider) {
|
|
662
|
+
this.app = app;
|
|
663
|
+
if (provider.isInitialized()) {
|
|
664
|
+
this._delegate = provider.getImmediate();
|
|
665
|
+
this.linkUnderlyingAuth();
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
const { apiKey } = app.options;
|
|
669
|
+
// TODO: platform needs to be determined using heuristics
|
|
670
|
+
_assert$1(apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
671
|
+
appName: app.name
|
|
672
|
+
});
|
|
673
|
+
// TODO: platform needs to be determined using heuristics
|
|
674
|
+
_assert$1(apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
675
|
+
appName: app.name
|
|
676
|
+
});
|
|
677
|
+
// Only use a popup/redirect resolver in browser environments
|
|
678
|
+
const resolver = typeof window !== 'undefined' ? CompatPopupRedirectResolver : undefined;
|
|
679
|
+
this._delegate = provider.initialize({
|
|
680
|
+
options: {
|
|
681
|
+
persistence: buildPersistenceHierarchy(apiKey, app.name),
|
|
682
|
+
popupRedirectResolver: resolver
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
this._delegate._updateErrorMap(exp__namespace.debugErrorMap);
|
|
686
|
+
this.linkUnderlyingAuth();
|
|
687
|
+
}
|
|
688
|
+
get emulatorConfig() {
|
|
689
|
+
return this._delegate.emulatorConfig;
|
|
690
|
+
}
|
|
691
|
+
get currentUser() {
|
|
692
|
+
if (!this._delegate.currentUser) {
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
return User.getOrCreate(this._delegate.currentUser);
|
|
696
|
+
}
|
|
697
|
+
get languageCode() {
|
|
698
|
+
return this._delegate.languageCode;
|
|
699
|
+
}
|
|
700
|
+
set languageCode(languageCode) {
|
|
701
|
+
this._delegate.languageCode = languageCode;
|
|
702
|
+
}
|
|
703
|
+
get settings() {
|
|
704
|
+
return this._delegate.settings;
|
|
705
|
+
}
|
|
706
|
+
get tenantId() {
|
|
707
|
+
return this._delegate.tenantId;
|
|
708
|
+
}
|
|
709
|
+
set tenantId(tid) {
|
|
710
|
+
this._delegate.tenantId = tid;
|
|
711
|
+
}
|
|
712
|
+
useDeviceLanguage() {
|
|
713
|
+
this._delegate.useDeviceLanguage();
|
|
714
|
+
}
|
|
715
|
+
signOut() {
|
|
716
|
+
return this._delegate.signOut();
|
|
717
|
+
}
|
|
718
|
+
useEmulator(url, options) {
|
|
719
|
+
exp__namespace.connectAuthEmulator(this._delegate, url, options);
|
|
720
|
+
}
|
|
721
|
+
applyActionCode(code) {
|
|
722
|
+
return exp__namespace.applyActionCode(this._delegate, code);
|
|
723
|
+
}
|
|
724
|
+
checkActionCode(code) {
|
|
725
|
+
return exp__namespace.checkActionCode(this._delegate, code);
|
|
726
|
+
}
|
|
727
|
+
confirmPasswordReset(code, newPassword) {
|
|
728
|
+
return exp__namespace.confirmPasswordReset(this._delegate, code, newPassword);
|
|
729
|
+
}
|
|
730
|
+
async createUserWithEmailAndPassword(email, password) {
|
|
731
|
+
return convertCredential(this._delegate, exp__namespace.createUserWithEmailAndPassword(this._delegate, email, password));
|
|
732
|
+
}
|
|
733
|
+
fetchProvidersForEmail(email) {
|
|
734
|
+
return this.fetchSignInMethodsForEmail(email);
|
|
735
|
+
}
|
|
736
|
+
fetchSignInMethodsForEmail(email) {
|
|
737
|
+
return exp__namespace.fetchSignInMethodsForEmail(this._delegate, email);
|
|
738
|
+
}
|
|
739
|
+
isSignInWithEmailLink(emailLink) {
|
|
740
|
+
return exp__namespace.isSignInWithEmailLink(this._delegate, emailLink);
|
|
741
|
+
}
|
|
742
|
+
async getRedirectResult() {
|
|
743
|
+
_assert$1(_isPopupRedirectSupported(), this._delegate, "operation-not-supported-in-this-environment" /* exp.AuthErrorCode.OPERATION_NOT_SUPPORTED */);
|
|
744
|
+
const credential = await exp__namespace.getRedirectResult(this._delegate, CompatPopupRedirectResolver);
|
|
745
|
+
if (!credential) {
|
|
746
|
+
return {
|
|
747
|
+
credential: null,
|
|
748
|
+
user: null
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
return convertCredential(this._delegate, Promise.resolve(credential));
|
|
752
|
+
}
|
|
753
|
+
// This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
|
|
754
|
+
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it
|
|
755
|
+
// out of autogenerated documentation pages to reduce accidental misuse.
|
|
756
|
+
addFrameworkForLogging(framework) {
|
|
757
|
+
exp__namespace.addFrameworkForLogging(this._delegate, framework);
|
|
758
|
+
}
|
|
759
|
+
onAuthStateChanged(nextOrObserver, errorFn, completed) {
|
|
760
|
+
const { next, error, complete } = wrapObservers(nextOrObserver, errorFn, completed);
|
|
761
|
+
return this._delegate.onAuthStateChanged(next, error, complete);
|
|
762
|
+
}
|
|
763
|
+
onIdTokenChanged(nextOrObserver, errorFn, completed) {
|
|
764
|
+
const { next, error, complete } = wrapObservers(nextOrObserver, errorFn, completed);
|
|
765
|
+
return this._delegate.onIdTokenChanged(next, error, complete);
|
|
766
|
+
}
|
|
767
|
+
sendSignInLinkToEmail(email, actionCodeSettings) {
|
|
768
|
+
return exp__namespace.sendSignInLinkToEmail(this._delegate, email, actionCodeSettings);
|
|
769
|
+
}
|
|
770
|
+
sendPasswordResetEmail(email, actionCodeSettings) {
|
|
771
|
+
return exp__namespace.sendPasswordResetEmail(this._delegate, email, actionCodeSettings || undefined);
|
|
772
|
+
}
|
|
773
|
+
async setPersistence(persistence) {
|
|
774
|
+
_validatePersistenceArgument(this._delegate, persistence);
|
|
775
|
+
let converted;
|
|
776
|
+
switch (persistence) {
|
|
777
|
+
case Persistence.SESSION:
|
|
778
|
+
converted = exp__namespace.browserSessionPersistence;
|
|
779
|
+
break;
|
|
780
|
+
case Persistence.LOCAL:
|
|
781
|
+
// Not using isIndexedDBAvailable() since it only checks if indexedDB is defined.
|
|
782
|
+
const isIndexedDBFullySupported = await exp__namespace
|
|
783
|
+
._getInstance(exp__namespace.indexedDBLocalPersistence)
|
|
784
|
+
._isAvailable();
|
|
785
|
+
converted = isIndexedDBFullySupported
|
|
786
|
+
? exp__namespace.indexedDBLocalPersistence
|
|
787
|
+
: exp__namespace.browserLocalPersistence;
|
|
788
|
+
break;
|
|
789
|
+
case Persistence.NONE:
|
|
790
|
+
converted = exp__namespace.inMemoryPersistence;
|
|
791
|
+
break;
|
|
792
|
+
default:
|
|
793
|
+
return exp__namespace._fail("argument-error" /* exp.AuthErrorCode.ARGUMENT_ERROR */, {
|
|
794
|
+
appName: this._delegate.name
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
return this._delegate.setPersistence(converted);
|
|
798
|
+
}
|
|
799
|
+
signInAndRetrieveDataWithCredential(credential) {
|
|
800
|
+
return this.signInWithCredential(credential);
|
|
801
|
+
}
|
|
802
|
+
signInAnonymously() {
|
|
803
|
+
return convertCredential(this._delegate, exp__namespace.signInAnonymously(this._delegate));
|
|
804
|
+
}
|
|
805
|
+
signInWithCredential(credential) {
|
|
806
|
+
return convertCredential(this._delegate, exp__namespace.signInWithCredential(this._delegate, credential));
|
|
807
|
+
}
|
|
808
|
+
signInWithCustomToken(token) {
|
|
809
|
+
return convertCredential(this._delegate, exp__namespace.signInWithCustomToken(this._delegate, token));
|
|
810
|
+
}
|
|
811
|
+
signInWithEmailAndPassword(email, password) {
|
|
812
|
+
return convertCredential(this._delegate, exp__namespace.signInWithEmailAndPassword(this._delegate, email, password));
|
|
813
|
+
}
|
|
814
|
+
signInWithEmailLink(email, emailLink) {
|
|
815
|
+
return convertCredential(this._delegate, exp__namespace.signInWithEmailLink(this._delegate, email, emailLink));
|
|
816
|
+
}
|
|
817
|
+
signInWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
818
|
+
return convertConfirmationResult(this._delegate, exp__namespace.signInWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
819
|
+
}
|
|
820
|
+
async signInWithPopup(provider) {
|
|
821
|
+
_assert$1(_isPopupRedirectSupported(), this._delegate, "operation-not-supported-in-this-environment" /* exp.AuthErrorCode.OPERATION_NOT_SUPPORTED */);
|
|
822
|
+
return convertCredential(this._delegate, exp__namespace.signInWithPopup(this._delegate, provider, CompatPopupRedirectResolver));
|
|
823
|
+
}
|
|
824
|
+
async signInWithRedirect(provider) {
|
|
825
|
+
_assert$1(_isPopupRedirectSupported(), this._delegate, "operation-not-supported-in-this-environment" /* exp.AuthErrorCode.OPERATION_NOT_SUPPORTED */);
|
|
826
|
+
await _savePersistenceForRedirect(this._delegate);
|
|
827
|
+
return exp__namespace.signInWithRedirect(this._delegate, provider, CompatPopupRedirectResolver);
|
|
828
|
+
}
|
|
829
|
+
updateCurrentUser(user) {
|
|
830
|
+
// remove ts-ignore once overloads are defined for exp functions to accept compat objects
|
|
831
|
+
// @ts-ignore
|
|
832
|
+
return this._delegate.updateCurrentUser(user);
|
|
833
|
+
}
|
|
834
|
+
verifyPasswordResetCode(code) {
|
|
835
|
+
return exp__namespace.verifyPasswordResetCode(this._delegate, code);
|
|
836
|
+
}
|
|
837
|
+
unwrap() {
|
|
838
|
+
return this._delegate;
|
|
839
|
+
}
|
|
840
|
+
_delete() {
|
|
841
|
+
return this._delegate._delete();
|
|
842
|
+
}
|
|
843
|
+
linkUnderlyingAuth() {
|
|
844
|
+
this._delegate.wrapped = () => this;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
Auth.Persistence = Persistence;
|
|
848
|
+
function wrapObservers(nextOrObserver, error, complete) {
|
|
849
|
+
let next = nextOrObserver;
|
|
850
|
+
if (typeof nextOrObserver !== 'function') {
|
|
851
|
+
({ next, error, complete } = nextOrObserver);
|
|
852
|
+
}
|
|
853
|
+
// We know 'next' is now a function
|
|
854
|
+
const oldNext = next;
|
|
855
|
+
const newNext = (user) => oldNext(user && User.getOrCreate(user));
|
|
856
|
+
return {
|
|
857
|
+
next: newNext,
|
|
858
|
+
error: error,
|
|
859
|
+
complete
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
function buildPersistenceHierarchy(apiKey, appName) {
|
|
863
|
+
// Note this is slightly different behavior: in this case, the stored
|
|
864
|
+
// persistence is checked *first* rather than last. This is because we want
|
|
865
|
+
// to prefer stored persistence type in the hierarchy. This is an empty
|
|
866
|
+
// array if window is not available or there is no pending redirect
|
|
867
|
+
const persistences = _getPersistencesFromRedirect(apiKey, appName);
|
|
868
|
+
// If "self" is available, add indexedDB
|
|
869
|
+
if (typeof self !== 'undefined' &&
|
|
870
|
+
!persistences.includes(exp__namespace.indexedDBLocalPersistence)) {
|
|
871
|
+
persistences.push(exp__namespace.indexedDBLocalPersistence);
|
|
872
|
+
}
|
|
873
|
+
// If "window" is available, add HTML Storage persistences
|
|
874
|
+
if (typeof window !== 'undefined') {
|
|
875
|
+
for (const persistence of [
|
|
876
|
+
exp__namespace.browserLocalPersistence,
|
|
877
|
+
exp__namespace.browserSessionPersistence
|
|
878
|
+
]) {
|
|
879
|
+
if (!persistences.includes(persistence)) {
|
|
880
|
+
persistences.push(persistence);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
// Add in-memory as a final fallback
|
|
885
|
+
if (!persistences.includes(exp__namespace.inMemoryPersistence)) {
|
|
886
|
+
persistences.push(exp__namespace.inMemoryPersistence);
|
|
887
|
+
}
|
|
888
|
+
return persistences;
|
|
889
889
|
}
|
|
890
890
|
|
|
891
|
-
/**
|
|
892
|
-
* @license
|
|
893
|
-
* Copyright 2020 Google LLC
|
|
894
|
-
*
|
|
895
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
896
|
-
* you may not use this file except in compliance with the License.
|
|
897
|
-
* You may obtain a copy of the License at
|
|
898
|
-
*
|
|
899
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
900
|
-
*
|
|
901
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
902
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
903
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
904
|
-
* See the License for the specific language governing permissions and
|
|
905
|
-
* limitations under the License.
|
|
906
|
-
*/
|
|
907
|
-
class PhoneAuthProvider {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
this.
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
}
|
|
917
|
-
verifyPhoneNumber(phoneInfoOptions, applicationVerifier) {
|
|
918
|
-
return this._delegate.verifyPhoneNumber(
|
|
919
|
-
// The implementation matches but the types are subtly incompatible
|
|
920
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
921
|
-
phoneInfoOptions, applicationVerifier);
|
|
922
|
-
}
|
|
923
|
-
unwrap() {
|
|
924
|
-
return this._delegate;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
PhoneAuthProvider.PHONE_SIGN_IN_METHOD = exp__namespace.PhoneAuthProvider.PHONE_SIGN_IN_METHOD;
|
|
891
|
+
/**
|
|
892
|
+
* @license
|
|
893
|
+
* Copyright 2020 Google LLC
|
|
894
|
+
*
|
|
895
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
896
|
+
* you may not use this file except in compliance with the License.
|
|
897
|
+
* You may obtain a copy of the License at
|
|
898
|
+
*
|
|
899
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
900
|
+
*
|
|
901
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
902
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
903
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
904
|
+
* See the License for the specific language governing permissions and
|
|
905
|
+
* limitations under the License.
|
|
906
|
+
*/
|
|
907
|
+
class PhoneAuthProvider {
|
|
908
|
+
static credential(verificationId, verificationCode) {
|
|
909
|
+
return exp__namespace.PhoneAuthProvider.credential(verificationId, verificationCode);
|
|
910
|
+
}
|
|
911
|
+
constructor() {
|
|
912
|
+
this.providerId = 'phone';
|
|
913
|
+
// TODO: remove ts-ignore when moving types from auth-types to auth-compat
|
|
914
|
+
// @ts-ignore
|
|
915
|
+
this._delegate = new exp__namespace.PhoneAuthProvider(unwrap(firebase__default["default"].auth()));
|
|
916
|
+
}
|
|
917
|
+
verifyPhoneNumber(phoneInfoOptions, applicationVerifier) {
|
|
918
|
+
return this._delegate.verifyPhoneNumber(
|
|
919
|
+
// The implementation matches but the types are subtly incompatible
|
|
920
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
921
|
+
phoneInfoOptions, applicationVerifier);
|
|
922
|
+
}
|
|
923
|
+
unwrap() {
|
|
924
|
+
return this._delegate;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
PhoneAuthProvider.PHONE_SIGN_IN_METHOD = exp__namespace.PhoneAuthProvider.PHONE_SIGN_IN_METHOD;
|
|
928
928
|
PhoneAuthProvider.PROVIDER_ID = exp__namespace.PhoneAuthProvider.PROVIDER_ID;
|
|
929
929
|
|
|
930
|
-
/**
|
|
931
|
-
* @license
|
|
932
|
-
* Copyright 2020 Google LLC
|
|
933
|
-
*
|
|
934
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
935
|
-
* you may not use this file except in compliance with the License.
|
|
936
|
-
* You may obtain a copy of the License at
|
|
937
|
-
*
|
|
938
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
939
|
-
*
|
|
940
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
941
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
942
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
943
|
-
* See the License for the specific language governing permissions and
|
|
944
|
-
* limitations under the License.
|
|
945
|
-
*/
|
|
946
|
-
const _assert = exp__namespace._assert;
|
|
947
|
-
class RecaptchaVerifier {
|
|
948
|
-
constructor(container, parameters, app = firebase__default["default"].app()) {
|
|
949
|
-
var _a;
|
|
950
|
-
// API key is required for web client RPC calls.
|
|
951
|
-
_assert((_a = app.options) === null || _a === void 0 ? void 0 : _a.apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
952
|
-
appName: app.name
|
|
953
|
-
});
|
|
954
|
-
this._delegate = new exp__namespace.RecaptchaVerifier(
|
|
955
|
-
// TODO: remove ts-ignore when moving types from auth-types to auth-compat
|
|
956
|
-
// @ts-ignore
|
|
957
|
-
app.auth(), container,
|
|
958
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
959
|
-
parameters);
|
|
960
|
-
this.type = this._delegate.type;
|
|
961
|
-
}
|
|
962
|
-
clear() {
|
|
963
|
-
this._delegate.clear();
|
|
964
|
-
}
|
|
965
|
-
render() {
|
|
966
|
-
return this._delegate.render();
|
|
967
|
-
}
|
|
968
|
-
verify() {
|
|
969
|
-
return this._delegate.verify();
|
|
970
|
-
}
|
|
930
|
+
/**
|
|
931
|
+
* @license
|
|
932
|
+
* Copyright 2020 Google LLC
|
|
933
|
+
*
|
|
934
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
935
|
+
* you may not use this file except in compliance with the License.
|
|
936
|
+
* You may obtain a copy of the License at
|
|
937
|
+
*
|
|
938
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
939
|
+
*
|
|
940
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
941
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
942
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
943
|
+
* See the License for the specific language governing permissions and
|
|
944
|
+
* limitations under the License.
|
|
945
|
+
*/
|
|
946
|
+
const _assert = exp__namespace._assert;
|
|
947
|
+
class RecaptchaVerifier {
|
|
948
|
+
constructor(container, parameters, app = firebase__default["default"].app()) {
|
|
949
|
+
var _a;
|
|
950
|
+
// API key is required for web client RPC calls.
|
|
951
|
+
_assert((_a = app.options) === null || _a === void 0 ? void 0 : _a.apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
952
|
+
appName: app.name
|
|
953
|
+
});
|
|
954
|
+
this._delegate = new exp__namespace.RecaptchaVerifier(
|
|
955
|
+
// TODO: remove ts-ignore when moving types from auth-types to auth-compat
|
|
956
|
+
// @ts-ignore
|
|
957
|
+
app.auth(), container,
|
|
958
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
959
|
+
parameters);
|
|
960
|
+
this.type = this._delegate.type;
|
|
961
|
+
}
|
|
962
|
+
clear() {
|
|
963
|
+
this._delegate.clear();
|
|
964
|
+
}
|
|
965
|
+
render() {
|
|
966
|
+
return this._delegate.render();
|
|
967
|
+
}
|
|
968
|
+
verify() {
|
|
969
|
+
return this._delegate.verify();
|
|
970
|
+
}
|
|
971
971
|
}
|
|
972
972
|
|
|
973
|
-
/**
|
|
974
|
-
* @license
|
|
975
|
-
* Copyright 2020 Google LLC
|
|
976
|
-
*
|
|
977
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
978
|
-
* you may not use this file except in compliance with the License.
|
|
979
|
-
* You may obtain a copy of the License at
|
|
980
|
-
*
|
|
981
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
982
|
-
*
|
|
983
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
984
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
985
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
986
|
-
* See the License for the specific language governing permissions and
|
|
987
|
-
* limitations under the License.
|
|
988
|
-
*/
|
|
989
|
-
const AUTH_TYPE = 'auth-compat';
|
|
990
|
-
// Create auth components to register with firebase.
|
|
991
|
-
// Provides Auth public APIs.
|
|
992
|
-
function registerAuthCompat(instance) {
|
|
993
|
-
instance.INTERNAL.registerComponent(new component.Component(AUTH_TYPE, container => {
|
|
994
|
-
// getImmediate for FirebaseApp will always succeed
|
|
995
|
-
const app = container.getProvider('app-compat').getImmediate();
|
|
996
|
-
const authProvider = container.getProvider('auth');
|
|
997
|
-
return new Auth(app, authProvider);
|
|
998
|
-
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
|
999
|
-
.setServiceProps({
|
|
1000
|
-
ActionCodeInfo: {
|
|
1001
|
-
Operation: {
|
|
1002
|
-
EMAIL_SIGNIN: exp__namespace.ActionCodeOperation.EMAIL_SIGNIN,
|
|
1003
|
-
PASSWORD_RESET: exp__namespace.ActionCodeOperation.PASSWORD_RESET,
|
|
1004
|
-
RECOVER_EMAIL: exp__namespace.ActionCodeOperation.RECOVER_EMAIL,
|
|
1005
|
-
REVERT_SECOND_FACTOR_ADDITION: exp__namespace.ActionCodeOperation.REVERT_SECOND_FACTOR_ADDITION,
|
|
1006
|
-
VERIFY_AND_CHANGE_EMAIL: exp__namespace.ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL,
|
|
1007
|
-
VERIFY_EMAIL: exp__namespace.ActionCodeOperation.VERIFY_EMAIL
|
|
1008
|
-
}
|
|
1009
|
-
},
|
|
1010
|
-
EmailAuthProvider: exp__namespace.EmailAuthProvider,
|
|
1011
|
-
FacebookAuthProvider: exp__namespace.FacebookAuthProvider,
|
|
1012
|
-
GithubAuthProvider: exp__namespace.GithubAuthProvider,
|
|
1013
|
-
GoogleAuthProvider: exp__namespace.GoogleAuthProvider,
|
|
1014
|
-
OAuthProvider: exp__namespace.OAuthProvider,
|
|
1015
|
-
SAMLAuthProvider: exp__namespace.SAMLAuthProvider,
|
|
1016
|
-
PhoneAuthProvider: PhoneAuthProvider,
|
|
1017
|
-
PhoneMultiFactorGenerator: exp__namespace.PhoneMultiFactorGenerator,
|
|
1018
|
-
RecaptchaVerifier: RecaptchaVerifier,
|
|
1019
|
-
TwitterAuthProvider: exp__namespace.TwitterAuthProvider,
|
|
1020
|
-
Auth,
|
|
1021
|
-
AuthCredential: exp__namespace.AuthCredential,
|
|
1022
|
-
Error: util.FirebaseError
|
|
1023
|
-
})
|
|
1024
|
-
.setInstantiationMode("LAZY" /* InstantiationMode.LAZY */)
|
|
1025
|
-
.setMultipleInstances(false));
|
|
1026
|
-
instance.registerVersion(name, version);
|
|
1027
|
-
}
|
|
973
|
+
/**
|
|
974
|
+
* @license
|
|
975
|
+
* Copyright 2020 Google LLC
|
|
976
|
+
*
|
|
977
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
978
|
+
* you may not use this file except in compliance with the License.
|
|
979
|
+
* You may obtain a copy of the License at
|
|
980
|
+
*
|
|
981
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
982
|
+
*
|
|
983
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
984
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
985
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
986
|
+
* See the License for the specific language governing permissions and
|
|
987
|
+
* limitations under the License.
|
|
988
|
+
*/
|
|
989
|
+
const AUTH_TYPE = 'auth-compat';
|
|
990
|
+
// Create auth components to register with firebase.
|
|
991
|
+
// Provides Auth public APIs.
|
|
992
|
+
function registerAuthCompat(instance) {
|
|
993
|
+
instance.INTERNAL.registerComponent(new component.Component(AUTH_TYPE, container => {
|
|
994
|
+
// getImmediate for FirebaseApp will always succeed
|
|
995
|
+
const app = container.getProvider('app-compat').getImmediate();
|
|
996
|
+
const authProvider = container.getProvider('auth');
|
|
997
|
+
return new Auth(app, authProvider);
|
|
998
|
+
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
|
999
|
+
.setServiceProps({
|
|
1000
|
+
ActionCodeInfo: {
|
|
1001
|
+
Operation: {
|
|
1002
|
+
EMAIL_SIGNIN: exp__namespace.ActionCodeOperation.EMAIL_SIGNIN,
|
|
1003
|
+
PASSWORD_RESET: exp__namespace.ActionCodeOperation.PASSWORD_RESET,
|
|
1004
|
+
RECOVER_EMAIL: exp__namespace.ActionCodeOperation.RECOVER_EMAIL,
|
|
1005
|
+
REVERT_SECOND_FACTOR_ADDITION: exp__namespace.ActionCodeOperation.REVERT_SECOND_FACTOR_ADDITION,
|
|
1006
|
+
VERIFY_AND_CHANGE_EMAIL: exp__namespace.ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL,
|
|
1007
|
+
VERIFY_EMAIL: exp__namespace.ActionCodeOperation.VERIFY_EMAIL
|
|
1008
|
+
}
|
|
1009
|
+
},
|
|
1010
|
+
EmailAuthProvider: exp__namespace.EmailAuthProvider,
|
|
1011
|
+
FacebookAuthProvider: exp__namespace.FacebookAuthProvider,
|
|
1012
|
+
GithubAuthProvider: exp__namespace.GithubAuthProvider,
|
|
1013
|
+
GoogleAuthProvider: exp__namespace.GoogleAuthProvider,
|
|
1014
|
+
OAuthProvider: exp__namespace.OAuthProvider,
|
|
1015
|
+
SAMLAuthProvider: exp__namespace.SAMLAuthProvider,
|
|
1016
|
+
PhoneAuthProvider: PhoneAuthProvider,
|
|
1017
|
+
PhoneMultiFactorGenerator: exp__namespace.PhoneMultiFactorGenerator,
|
|
1018
|
+
RecaptchaVerifier: RecaptchaVerifier,
|
|
1019
|
+
TwitterAuthProvider: exp__namespace.TwitterAuthProvider,
|
|
1020
|
+
Auth,
|
|
1021
|
+
AuthCredential: exp__namespace.AuthCredential,
|
|
1022
|
+
Error: util.FirebaseError
|
|
1023
|
+
})
|
|
1024
|
+
.setInstantiationMode("LAZY" /* InstantiationMode.LAZY */)
|
|
1025
|
+
.setMultipleInstances(false));
|
|
1026
|
+
instance.registerVersion(name, version);
|
|
1027
|
+
}
|
|
1028
1028
|
registerAuthCompat(firebase__default["default"]);
|
|
1029
1029
|
//# sourceMappingURL=index.cjs.js.map
|