@firebase/auth-compat 0.5.14 → 0.5.15
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 +3 -3
- package/dist/esm/index.node.esm.js +1 -2
- 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 +1 -1
- package/dist/index.esm2017.js +1 -1
- package/dist/index.node.cjs.js +373 -613
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +8 -8
- package/dist/index.esm.js +0 -1243
- package/dist/index.esm.js.map +0 -1
package/dist/index.node.cjs.js
CHANGED
|
@@ -4,8 +4,6 @@ var firebase = require('@firebase/app-compat');
|
|
|
4
4
|
var exp = require('@firebase/auth/internal');
|
|
5
5
|
var component = require('@firebase/component');
|
|
6
6
|
var util = require('@firebase/util');
|
|
7
|
-
var tslib = require('tslib');
|
|
8
|
-
var undici = require('undici');
|
|
9
7
|
|
|
10
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
9
|
|
|
@@ -31,7 +29,7 @@ var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
|
|
31
29
|
var exp__namespace = /*#__PURE__*/_interopNamespace(exp);
|
|
32
30
|
|
|
33
31
|
var name = "@firebase/auth-compat";
|
|
34
|
-
var version = "0.5.
|
|
32
|
+
var version = "0.5.15";
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* @license
|
|
@@ -49,7 +47,7 @@ var version = "0.5.14";
|
|
|
49
47
|
* See the License for the specific language governing permissions and
|
|
50
48
|
* limitations under the License.
|
|
51
49
|
*/
|
|
52
|
-
|
|
50
|
+
const CORDOVA_ONDEVICEREADY_TIMEOUT_MS = 1000;
|
|
53
51
|
function _getCurrentScheme() {
|
|
54
52
|
var _a;
|
|
55
53
|
return ((_a = self === null || self === void 0 ? void 0 : self.location) === null || _a === void 0 ? void 0 : _a.protocol) || null;
|
|
@@ -65,8 +63,7 @@ function _isHttpOrHttps() {
|
|
|
65
63
|
* @return {boolean} Whether the app is rendered in a mobile iOS or Android
|
|
66
64
|
* Cordova environment.
|
|
67
65
|
*/
|
|
68
|
-
function _isAndroidOrIosCordovaScheme(ua) {
|
|
69
|
-
if (ua === void 0) { ua = util.getUA(); }
|
|
66
|
+
function _isAndroidOrIosCordovaScheme(ua = util.getUA()) {
|
|
70
67
|
return !!((_getCurrentScheme() === 'file:' ||
|
|
71
68
|
_getCurrentScheme() === 'ionic:' ||
|
|
72
69
|
_getCurrentScheme() === 'capacitor:') &&
|
|
@@ -91,8 +88,7 @@ function _isIe11() {
|
|
|
91
88
|
* @param {string} userAgent The browser user agent string.
|
|
92
89
|
* @return {boolean} True if it is Edge.
|
|
93
90
|
*/
|
|
94
|
-
function _isEdge(ua) {
|
|
95
|
-
if (ua === void 0) { ua = util.getUA(); }
|
|
91
|
+
function _isEdge(ua = util.getUA()) {
|
|
96
92
|
return /Edge\/\d+/.test(ua);
|
|
97
93
|
}
|
|
98
94
|
/**
|
|
@@ -100,15 +96,14 @@ function _isEdge(ua) {
|
|
|
100
96
|
* @return {boolean} Whether local storage is not synchronized between an iframe
|
|
101
97
|
* and a popup of the same domain.
|
|
102
98
|
*/
|
|
103
|
-
function _isLocalStorageNotSynchronized(ua) {
|
|
104
|
-
if (ua === void 0) { ua = util.getUA(); }
|
|
99
|
+
function _isLocalStorageNotSynchronized(ua = util.getUA()) {
|
|
105
100
|
return _isIe11() || _isEdge(ua);
|
|
106
101
|
}
|
|
107
102
|
/** @return {boolean} Whether web storage is supported. */
|
|
108
103
|
function _isWebStorageSupported() {
|
|
109
104
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
const storage = self.localStorage;
|
|
106
|
+
const key = exp__namespace._generateEventId();
|
|
112
107
|
if (storage) {
|
|
113
108
|
// setItem will throw an exception if we cannot access WebStorage (e.g.,
|
|
114
109
|
// Safari in private mode).
|
|
@@ -161,22 +156,18 @@ function _isPopupRedirectSupported() {
|
|
|
161
156
|
function _isLikelyCordova() {
|
|
162
157
|
return _isAndroidOrIosCordovaScheme() && typeof document !== 'undefined';
|
|
163
158
|
}
|
|
164
|
-
function _isCordova() {
|
|
165
|
-
|
|
166
|
-
return
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
clearTimeout(timeoutId);
|
|
177
|
-
resolve(true);
|
|
178
|
-
});
|
|
179
|
-
})];
|
|
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);
|
|
180
171
|
});
|
|
181
172
|
});
|
|
182
173
|
}
|
|
@@ -200,13 +191,13 @@ function _getSelfWindow() {
|
|
|
200
191
|
* See the License for the specific language governing permissions and
|
|
201
192
|
* limitations under the License.
|
|
202
193
|
*/
|
|
203
|
-
|
|
194
|
+
const Persistence = {
|
|
204
195
|
LOCAL: 'local',
|
|
205
196
|
NONE: 'none',
|
|
206
197
|
SESSION: 'session'
|
|
207
198
|
};
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
const _assert$3 = exp__namespace._assert;
|
|
200
|
+
const PERSISTENCE_KEY = 'persistence';
|
|
210
201
|
/**
|
|
211
202
|
* Validates that an argument is a valid persistence value. If an invalid type
|
|
212
203
|
* is specified, an error is thrown synchronously.
|
|
@@ -234,31 +225,21 @@ function _validatePersistenceArgument(auth, persistence) {
|
|
|
234
225
|
// This is restricted by what the browser supports.
|
|
235
226
|
_assert$3(persistence === Persistence.NONE || _isWebStorageSupported(), auth, "unsupported-persistence-type" /* exp.AuthErrorCode.UNSUPPORTED_PERSISTENCE */);
|
|
236
227
|
}
|
|
237
|
-
function _savePersistenceForRedirect(auth) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
_a.sent();
|
|
245
|
-
session = getSessionStorageIfAvailable();
|
|
246
|
-
key = exp__namespace._persistenceKeyName(PERSISTENCE_KEY, auth.config.apiKey, auth.name);
|
|
247
|
-
if (session) {
|
|
248
|
-
session.setItem(key, auth._getPersistence());
|
|
249
|
-
}
|
|
250
|
-
return [2 /*return*/];
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
});
|
|
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
|
+
}
|
|
254
235
|
}
|
|
255
236
|
function _getPersistencesFromRedirect(apiKey, appName) {
|
|
256
|
-
|
|
237
|
+
const session = getSessionStorageIfAvailable();
|
|
257
238
|
if (!session) {
|
|
258
239
|
return [];
|
|
259
240
|
}
|
|
260
|
-
|
|
261
|
-
|
|
241
|
+
const key = exp__namespace._persistenceKeyName(PERSISTENCE_KEY, apiKey, appName);
|
|
242
|
+
const persistence = session.getItem(key);
|
|
262
243
|
switch (persistence) {
|
|
263
244
|
case Persistence.NONE:
|
|
264
245
|
return [exp__namespace.inMemoryPersistence];
|
|
@@ -297,10 +278,10 @@ function getSessionStorageIfAvailable() {
|
|
|
297
278
|
* See the License for the specific language governing permissions and
|
|
298
279
|
* limitations under the License.
|
|
299
280
|
*/
|
|
300
|
-
|
|
281
|
+
const _assert$2 = exp__namespace._assert;
|
|
301
282
|
/** Platform-agnostic popup-redirect resolver */
|
|
302
|
-
|
|
303
|
-
|
|
283
|
+
class CompatPopupRedirectResolver {
|
|
284
|
+
constructor() {
|
|
304
285
|
// Create both resolvers for dynamic resolution later
|
|
305
286
|
this.browserResolver = exp__namespace._getInstance(exp__namespace.browserPopupRedirectResolver);
|
|
306
287
|
this.cordovaResolver = exp__namespace._getInstance(exp__namespace.cordovaPopupRedirectResolver);
|
|
@@ -310,85 +291,43 @@ var CompatPopupRedirectResolver = /** @class */ (function () {
|
|
|
310
291
|
this._completeRedirectFn = exp__namespace._getRedirectResult;
|
|
311
292
|
this._overrideRedirectResult = exp__namespace._overrideRedirectResult;
|
|
312
293
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
327
|
-
return tslib.__generator(this, function (_a) {
|
|
328
|
-
switch (_a.label) {
|
|
329
|
-
case 0: return [4 /*yield*/, this.selectUnderlyingResolver()];
|
|
330
|
-
case 1:
|
|
331
|
-
_a.sent();
|
|
332
|
-
return [2 /*return*/, this.assertedUnderlyingResolver._openPopup(auth, provider, authType, eventId)];
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
CompatPopupRedirectResolver.prototype._openRedirect = function (auth, provider, authType, eventId) {
|
|
338
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
339
|
-
return tslib.__generator(this, function (_a) {
|
|
340
|
-
switch (_a.label) {
|
|
341
|
-
case 0: return [4 /*yield*/, this.selectUnderlyingResolver()];
|
|
342
|
-
case 1:
|
|
343
|
-
_a.sent();
|
|
344
|
-
return [2 /*return*/, this.assertedUnderlyingResolver._openRedirect(auth, provider, authType, eventId)];
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
CompatPopupRedirectResolver.prototype._isIframeWebStorageSupported = function (auth, cb) {
|
|
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) {
|
|
350
307
|
this.assertedUnderlyingResolver._isIframeWebStorageSupported(auth, cb);
|
|
351
|
-
}
|
|
352
|
-
|
|
308
|
+
}
|
|
309
|
+
_originValidation(auth) {
|
|
353
310
|
return this.assertedUnderlyingResolver._originValidation(auth);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
switch (_a.label) {
|
|
375
|
-
case 0:
|
|
376
|
-
if (this.underlyingResolver) {
|
|
377
|
-
return [2 /*return*/];
|
|
378
|
-
}
|
|
379
|
-
return [4 /*yield*/, _isCordova()];
|
|
380
|
-
case 1:
|
|
381
|
-
isCordova = _a.sent();
|
|
382
|
-
this.underlyingResolver = isCordova
|
|
383
|
-
? this.cordovaResolver
|
|
384
|
-
: this.browserResolver;
|
|
385
|
-
return [2 /*return*/];
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
};
|
|
390
|
-
return CompatPopupRedirectResolver;
|
|
391
|
-
}());
|
|
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
|
+
}
|
|
392
331
|
|
|
393
332
|
/**
|
|
394
333
|
* @license
|
|
@@ -436,14 +375,14 @@ function attachExtraErrorFields(auth, e) {
|
|
|
436
375
|
var _a;
|
|
437
376
|
// The response contains all fields from the server which may or may not
|
|
438
377
|
// actually match the underlying type
|
|
439
|
-
|
|
378
|
+
const response = (_a = e.customData) === null || _a === void 0 ? void 0 : _a._tokenResponse;
|
|
440
379
|
if ((e === null || e === void 0 ? void 0 : e.code) === 'auth/multi-factor-auth-required') {
|
|
441
|
-
|
|
380
|
+
const mfaErr = e;
|
|
442
381
|
mfaErr.resolver = new MultiFactorResolver(auth, exp__namespace.getMultiFactorResolver(auth, e));
|
|
443
382
|
}
|
|
444
383
|
else if (response) {
|
|
445
|
-
|
|
446
|
-
|
|
384
|
+
const credential = credentialFromObject(e);
|
|
385
|
+
const credErr = e;
|
|
447
386
|
if (credential) {
|
|
448
387
|
credErr.credential = credential;
|
|
449
388
|
credErr.tenantId = response.tenantId || undefined;
|
|
@@ -453,7 +392,7 @@ function attachExtraErrorFields(auth, e) {
|
|
|
453
392
|
}
|
|
454
393
|
}
|
|
455
394
|
function credentialFromObject(object) {
|
|
456
|
-
|
|
395
|
+
const { _tokenResponse } = (object instanceof util.FirebaseError ? object.customData : object);
|
|
457
396
|
if (!_tokenResponse) {
|
|
458
397
|
return null;
|
|
459
398
|
}
|
|
@@ -465,13 +404,13 @@ function credentialFromObject(object) {
|
|
|
465
404
|
return exp__namespace.PhoneAuthProvider.credentialFromResult(object);
|
|
466
405
|
}
|
|
467
406
|
}
|
|
468
|
-
|
|
407
|
+
const providerId = _tokenResponse.providerId;
|
|
469
408
|
// Email and password is not supported as there is no situation where the
|
|
470
409
|
// server would return the password to the client.
|
|
471
410
|
if (!providerId || providerId === exp__namespace.ProviderId.PASSWORD) {
|
|
472
411
|
return null;
|
|
473
412
|
}
|
|
474
|
-
|
|
413
|
+
let provider;
|
|
475
414
|
switch (providerId) {
|
|
476
415
|
case exp__namespace.ProviderId.GOOGLE:
|
|
477
416
|
provider = exp__namespace.GoogleAuthProvider;
|
|
@@ -486,7 +425,7 @@ function credentialFromObject(object) {
|
|
|
486
425
|
provider = exp__namespace.TwitterAuthProvider;
|
|
487
426
|
break;
|
|
488
427
|
default:
|
|
489
|
-
|
|
428
|
+
const { oauthIdToken, oauthAccessToken, oauthTokenSecret, pendingToken, nonce } = _tokenResponse;
|
|
490
429
|
if (!oauthAccessToken &&
|
|
491
430
|
!oauthTokenSecret &&
|
|
492
431
|
!oauthIdToken &&
|
|
@@ -501,9 +440,9 @@ function credentialFromObject(object) {
|
|
|
501
440
|
else {
|
|
502
441
|
// OIDC and non-default providers excluding Twitter.
|
|
503
442
|
return exp__namespace.OAuthCredential._fromParams({
|
|
504
|
-
providerId
|
|
443
|
+
providerId,
|
|
505
444
|
signInMethod: providerId,
|
|
506
|
-
pendingToken
|
|
445
|
+
pendingToken,
|
|
507
446
|
idToken: oauthIdToken,
|
|
508
447
|
accessToken: oauthAccessToken
|
|
509
448
|
});
|
|
@@ -521,65 +460,45 @@ function credentialFromObject(object) {
|
|
|
521
460
|
}
|
|
522
461
|
function convertCredential(auth, credentialPromise) {
|
|
523
462
|
return credentialPromise
|
|
524
|
-
.catch(
|
|
463
|
+
.catch(e => {
|
|
525
464
|
if (e instanceof util.FirebaseError) {
|
|
526
465
|
attachExtraErrorFields(auth, e);
|
|
527
466
|
}
|
|
528
467
|
throw e;
|
|
529
468
|
})
|
|
530
|
-
.then(
|
|
531
|
-
|
|
532
|
-
|
|
469
|
+
.then(credential => {
|
|
470
|
+
const operationType = credential.operationType;
|
|
471
|
+
const user = credential.user;
|
|
533
472
|
return {
|
|
534
|
-
operationType
|
|
473
|
+
operationType,
|
|
535
474
|
credential: credentialFromResponse(credential),
|
|
536
475
|
additionalUserInfo: exp__namespace.getAdditionalUserInfo(credential),
|
|
537
476
|
user: User.getOrCreate(user)
|
|
538
477
|
};
|
|
539
478
|
});
|
|
540
479
|
}
|
|
541
|
-
function convertConfirmationResult(auth, confirmationResultPromise) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
case 1:
|
|
548
|
-
confirmationResultExp = _a.sent();
|
|
549
|
-
return [2 /*return*/, {
|
|
550
|
-
verificationId: confirmationResultExp.verificationId,
|
|
551
|
-
confirm: function (verificationCode) {
|
|
552
|
-
return convertCredential(auth, confirmationResultExp.confirm(verificationCode));
|
|
553
|
-
}
|
|
554
|
-
}];
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
});
|
|
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
|
+
};
|
|
558
486
|
}
|
|
559
|
-
|
|
560
|
-
|
|
487
|
+
class MultiFactorResolver {
|
|
488
|
+
constructor(auth, resolver) {
|
|
561
489
|
this.resolver = resolver;
|
|
562
490
|
this.auth = wrapped(auth);
|
|
563
491
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
Object.defineProperty(MultiFactorResolver.prototype, "hints", {
|
|
572
|
-
get: function () {
|
|
573
|
-
return this.resolver.hints;
|
|
574
|
-
},
|
|
575
|
-
enumerable: false,
|
|
576
|
-
configurable: true
|
|
577
|
-
});
|
|
578
|
-
MultiFactorResolver.prototype.resolveSignIn = function (assertion) {
|
|
492
|
+
get session() {
|
|
493
|
+
return this.resolver.session;
|
|
494
|
+
}
|
|
495
|
+
get hints() {
|
|
496
|
+
return this.resolver.hints;
|
|
497
|
+
}
|
|
498
|
+
resolveSignIn(assertion) {
|
|
579
499
|
return convertCredential(unwrap(this.auth), this.resolver.resolveSignIn(assertion));
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
}());
|
|
500
|
+
}
|
|
501
|
+
}
|
|
583
502
|
|
|
584
503
|
/**
|
|
585
504
|
* @license
|
|
@@ -597,222 +516,129 @@ var MultiFactorResolver = /** @class */ (function () {
|
|
|
597
516
|
* See the License for the specific language governing permissions and
|
|
598
517
|
* limitations under the License.
|
|
599
518
|
*/
|
|
600
|
-
|
|
601
|
-
|
|
519
|
+
class User {
|
|
520
|
+
constructor(_delegate) {
|
|
602
521
|
this._delegate = _delegate;
|
|
603
522
|
this.multiFactor = exp__namespace.multiFactor(_delegate);
|
|
604
523
|
}
|
|
605
|
-
|
|
524
|
+
static getOrCreate(user) {
|
|
606
525
|
if (!User.USER_MAP.has(user)) {
|
|
607
526
|
User.USER_MAP.set(user, new User(user));
|
|
608
527
|
}
|
|
609
528
|
return User.USER_MAP.get(user);
|
|
610
|
-
}
|
|
611
|
-
|
|
529
|
+
}
|
|
530
|
+
delete() {
|
|
612
531
|
return this._delegate.delete();
|
|
613
|
-
}
|
|
614
|
-
|
|
532
|
+
}
|
|
533
|
+
reload() {
|
|
615
534
|
return this._delegate.reload();
|
|
616
|
-
}
|
|
617
|
-
|
|
535
|
+
}
|
|
536
|
+
toJSON() {
|
|
618
537
|
return this._delegate.toJSON();
|
|
619
|
-
}
|
|
620
|
-
|
|
538
|
+
}
|
|
539
|
+
getIdTokenResult(forceRefresh) {
|
|
621
540
|
return this._delegate.getIdTokenResult(forceRefresh);
|
|
622
|
-
}
|
|
623
|
-
|
|
541
|
+
}
|
|
542
|
+
getIdToken(forceRefresh) {
|
|
624
543
|
return this._delegate.getIdToken(forceRefresh);
|
|
625
|
-
}
|
|
626
|
-
|
|
544
|
+
}
|
|
545
|
+
linkAndRetrieveDataWithCredential(credential) {
|
|
627
546
|
return this.linkWithCredential(credential);
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
return
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
User.prototype.linkWithPopup = function (provider) {
|
|
644
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
645
|
-
return tslib.__generator(this, function (_a) {
|
|
646
|
-
return [2 /*return*/, convertCredential(this.auth, exp__namespace.linkWithPopup(this._delegate, provider, CompatPopupRedirectResolver))];
|
|
647
|
-
});
|
|
648
|
-
});
|
|
649
|
-
};
|
|
650
|
-
User.prototype.linkWithRedirect = function (provider) {
|
|
651
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
652
|
-
return tslib.__generator(this, function (_a) {
|
|
653
|
-
switch (_a.label) {
|
|
654
|
-
case 0: return [4 /*yield*/, _savePersistenceForRedirect(exp__namespace._castAuth(this.auth))];
|
|
655
|
-
case 1:
|
|
656
|
-
_a.sent();
|
|
657
|
-
return [2 /*return*/, exp__namespace.linkWithRedirect(this._delegate, provider, CompatPopupRedirectResolver)];
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
|
-
};
|
|
662
|
-
User.prototype.reauthenticateAndRetrieveDataWithCredential = function (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) {
|
|
663
562
|
return this.reauthenticateWithCredential(credential);
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
return
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
});
|
|
670
|
-
});
|
|
671
|
-
};
|
|
672
|
-
User.prototype.reauthenticateWithPhoneNumber = function (phoneNumber, applicationVerifier) {
|
|
563
|
+
}
|
|
564
|
+
async reauthenticateWithCredential(credential) {
|
|
565
|
+
return convertCredential(this.auth, exp__namespace.reauthenticateWithCredential(this._delegate, credential));
|
|
566
|
+
}
|
|
567
|
+
reauthenticateWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
673
568
|
return convertConfirmationResult(this.auth, exp__namespace.reauthenticateWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
674
|
-
}
|
|
675
|
-
|
|
569
|
+
}
|
|
570
|
+
reauthenticateWithPopup(provider) {
|
|
676
571
|
return convertCredential(this.auth, exp__namespace.reauthenticateWithPopup(this._delegate, provider, CompatPopupRedirectResolver));
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
case 1:
|
|
684
|
-
_a.sent();
|
|
685
|
-
return [2 /*return*/, exp__namespace.reauthenticateWithRedirect(this._delegate, provider, CompatPopupRedirectResolver)];
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
};
|
|
690
|
-
User.prototype.sendEmailVerification = function (actionCodeSettings) {
|
|
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) {
|
|
691
578
|
return exp__namespace.sendEmailVerification(this._delegate, actionCodeSettings);
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
case 1:
|
|
699
|
-
_a.sent();
|
|
700
|
-
return [2 /*return*/, this];
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
};
|
|
705
|
-
User.prototype.updateEmail = function (newEmail) {
|
|
579
|
+
}
|
|
580
|
+
async unlink(providerId) {
|
|
581
|
+
await exp__namespace.unlink(this._delegate, providerId);
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
updateEmail(newEmail) {
|
|
706
585
|
return exp__namespace.updateEmail(this._delegate, newEmail);
|
|
707
|
-
}
|
|
708
|
-
|
|
586
|
+
}
|
|
587
|
+
updatePassword(newPassword) {
|
|
709
588
|
return exp__namespace.updatePassword(this._delegate, newPassword);
|
|
710
|
-
}
|
|
711
|
-
|
|
589
|
+
}
|
|
590
|
+
updatePhoneNumber(phoneCredential) {
|
|
712
591
|
return exp__namespace.updatePhoneNumber(this._delegate, phoneCredential);
|
|
713
|
-
}
|
|
714
|
-
|
|
592
|
+
}
|
|
593
|
+
updateProfile(profile) {
|
|
715
594
|
return exp__namespace.updateProfile(this._delegate, profile);
|
|
716
|
-
}
|
|
717
|
-
|
|
595
|
+
}
|
|
596
|
+
verifyBeforeUpdateEmail(newEmail, actionCodeSettings) {
|
|
718
597
|
return exp__namespace.verifyBeforeUpdateEmail(this._delegate, newEmail, actionCodeSettings);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
get: function () {
|
|
764
|
-
return this._delegate.tenantId;
|
|
765
|
-
},
|
|
766
|
-
enumerable: false,
|
|
767
|
-
configurable: true
|
|
768
|
-
});
|
|
769
|
-
Object.defineProperty(User.prototype, "displayName", {
|
|
770
|
-
get: function () {
|
|
771
|
-
return this._delegate.displayName;
|
|
772
|
-
},
|
|
773
|
-
enumerable: false,
|
|
774
|
-
configurable: true
|
|
775
|
-
});
|
|
776
|
-
Object.defineProperty(User.prototype, "email", {
|
|
777
|
-
get: function () {
|
|
778
|
-
return this._delegate.email;
|
|
779
|
-
},
|
|
780
|
-
enumerable: false,
|
|
781
|
-
configurable: true
|
|
782
|
-
});
|
|
783
|
-
Object.defineProperty(User.prototype, "photoURL", {
|
|
784
|
-
get: function () {
|
|
785
|
-
return this._delegate.photoURL;
|
|
786
|
-
},
|
|
787
|
-
enumerable: false,
|
|
788
|
-
configurable: true
|
|
789
|
-
});
|
|
790
|
-
Object.defineProperty(User.prototype, "providerId", {
|
|
791
|
-
get: function () {
|
|
792
|
-
return this._delegate.providerId;
|
|
793
|
-
},
|
|
794
|
-
enumerable: false,
|
|
795
|
-
configurable: true
|
|
796
|
-
});
|
|
797
|
-
Object.defineProperty(User.prototype, "uid", {
|
|
798
|
-
get: function () {
|
|
799
|
-
return this._delegate.uid;
|
|
800
|
-
},
|
|
801
|
-
enumerable: false,
|
|
802
|
-
configurable: true
|
|
803
|
-
});
|
|
804
|
-
Object.defineProperty(User.prototype, "auth", {
|
|
805
|
-
get: function () {
|
|
806
|
-
return this._delegate.auth;
|
|
807
|
-
},
|
|
808
|
-
enumerable: false,
|
|
809
|
-
configurable: true
|
|
810
|
-
});
|
|
811
|
-
// Maintain a map so that there's always a 1:1 mapping between new User and
|
|
812
|
-
// legacy compat users
|
|
813
|
-
User.USER_MAP = new WeakMap();
|
|
814
|
-
return User;
|
|
815
|
-
}());
|
|
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
|
+
User.USER_MAP = new WeakMap();
|
|
816
642
|
|
|
817
643
|
/**
|
|
818
644
|
* @license
|
|
@@ -830,16 +656,16 @@ var User = /** @class */ (function () {
|
|
|
830
656
|
* See the License for the specific language governing permissions and
|
|
831
657
|
* limitations under the License.
|
|
832
658
|
*/
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
659
|
+
const _assert$1 = exp__namespace._assert;
|
|
660
|
+
class Auth {
|
|
661
|
+
constructor(app, provider) {
|
|
836
662
|
this.app = app;
|
|
837
663
|
if (provider.isInitialized()) {
|
|
838
664
|
this._delegate = provider.getImmediate();
|
|
839
665
|
this.linkUnderlyingAuth();
|
|
840
666
|
return;
|
|
841
667
|
}
|
|
842
|
-
|
|
668
|
+
const { apiKey } = app.options;
|
|
843
669
|
// TODO: platform needs to be determined using heuristics
|
|
844
670
|
_assert$1(apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
845
671
|
appName: app.name
|
|
@@ -849,7 +675,7 @@ var Auth = /** @class */ (function () {
|
|
|
849
675
|
appName: app.name
|
|
850
676
|
});
|
|
851
677
|
// Only use a popup/redirect resolver in browser environments
|
|
852
|
-
|
|
678
|
+
const resolver = typeof window !== 'undefined' ? CompatPopupRedirectResolver : undefined;
|
|
853
679
|
this._delegate = provider.initialize({
|
|
854
680
|
options: {
|
|
855
681
|
persistence: buildPersistenceHierarchy(apiKey, app.name),
|
|
@@ -859,240 +685,178 @@ var Auth = /** @class */ (function () {
|
|
|
859
685
|
this._delegate._updateErrorMap(exp__namespace.debugErrorMap);
|
|
860
686
|
this.linkUnderlyingAuth();
|
|
861
687
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
configurable: true
|
|
888
|
-
});
|
|
889
|
-
Object.defineProperty(Auth.prototype, "settings", {
|
|
890
|
-
get: function () {
|
|
891
|
-
return this._delegate.settings;
|
|
892
|
-
},
|
|
893
|
-
enumerable: false,
|
|
894
|
-
configurable: true
|
|
895
|
-
});
|
|
896
|
-
Object.defineProperty(Auth.prototype, "tenantId", {
|
|
897
|
-
get: function () {
|
|
898
|
-
return this._delegate.tenantId;
|
|
899
|
-
},
|
|
900
|
-
set: function (tid) {
|
|
901
|
-
this._delegate.tenantId = tid;
|
|
902
|
-
},
|
|
903
|
-
enumerable: false,
|
|
904
|
-
configurable: true
|
|
905
|
-
});
|
|
906
|
-
Auth.prototype.useDeviceLanguage = function () {
|
|
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() {
|
|
907
713
|
this._delegate.useDeviceLanguage();
|
|
908
|
-
}
|
|
909
|
-
|
|
714
|
+
}
|
|
715
|
+
signOut() {
|
|
910
716
|
return this._delegate.signOut();
|
|
911
|
-
}
|
|
912
|
-
|
|
717
|
+
}
|
|
718
|
+
useEmulator(url, options) {
|
|
913
719
|
exp__namespace.connectAuthEmulator(this._delegate, url, options);
|
|
914
|
-
}
|
|
915
|
-
|
|
720
|
+
}
|
|
721
|
+
applyActionCode(code) {
|
|
916
722
|
return exp__namespace.applyActionCode(this._delegate, code);
|
|
917
|
-
}
|
|
918
|
-
|
|
723
|
+
}
|
|
724
|
+
checkActionCode(code) {
|
|
919
725
|
return exp__namespace.checkActionCode(this._delegate, code);
|
|
920
|
-
}
|
|
921
|
-
|
|
726
|
+
}
|
|
727
|
+
confirmPasswordReset(code, newPassword) {
|
|
922
728
|
return exp__namespace.confirmPasswordReset(this._delegate, code, newPassword);
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
return
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
});
|
|
929
|
-
});
|
|
930
|
-
};
|
|
931
|
-
Auth.prototype.fetchProvidersForEmail = function (email) {
|
|
729
|
+
}
|
|
730
|
+
async createUserWithEmailAndPassword(email, password) {
|
|
731
|
+
return convertCredential(this._delegate, exp__namespace.createUserWithEmailAndPassword(this._delegate, email, password));
|
|
732
|
+
}
|
|
733
|
+
fetchProvidersForEmail(email) {
|
|
932
734
|
return this.fetchSignInMethodsForEmail(email);
|
|
933
|
-
}
|
|
934
|
-
|
|
735
|
+
}
|
|
736
|
+
fetchSignInMethodsForEmail(email) {
|
|
935
737
|
return exp__namespace.fetchSignInMethodsForEmail(this._delegate, email);
|
|
936
|
-
}
|
|
937
|
-
|
|
738
|
+
}
|
|
739
|
+
isSignInWithEmailLink(emailLink) {
|
|
938
740
|
return exp__namespace.isSignInWithEmailLink(this._delegate, emailLink);
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
return [2 /*return*/, {
|
|
952
|
-
credential: null,
|
|
953
|
-
user: null
|
|
954
|
-
}];
|
|
955
|
-
}
|
|
956
|
-
return [2 /*return*/, convertCredential(this._delegate, Promise.resolve(credential))];
|
|
957
|
-
}
|
|
958
|
-
});
|
|
959
|
-
});
|
|
960
|
-
};
|
|
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
|
+
}
|
|
961
753
|
// This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
|
|
962
754
|
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it
|
|
963
755
|
// out of autogenerated documentation pages to reduce accidental misuse.
|
|
964
|
-
|
|
756
|
+
addFrameworkForLogging(framework) {
|
|
965
757
|
exp__namespace.addFrameworkForLogging(this._delegate, framework);
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
|
|
758
|
+
}
|
|
759
|
+
onAuthStateChanged(nextOrObserver, errorFn, completed) {
|
|
760
|
+
const { next, error, complete } = wrapObservers(nextOrObserver, errorFn, completed);
|
|
969
761
|
return this._delegate.onAuthStateChanged(next, error, complete);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
|
|
762
|
+
}
|
|
763
|
+
onIdTokenChanged(nextOrObserver, errorFn, completed) {
|
|
764
|
+
const { next, error, complete } = wrapObservers(nextOrObserver, errorFn, completed);
|
|
973
765
|
return this._delegate.onIdTokenChanged(next, error, complete);
|
|
974
|
-
}
|
|
975
|
-
|
|
766
|
+
}
|
|
767
|
+
sendSignInLinkToEmail(email, actionCodeSettings) {
|
|
976
768
|
return exp__namespace.sendSignInLinkToEmail(this._delegate, email, actionCodeSettings);
|
|
977
|
-
}
|
|
978
|
-
|
|
769
|
+
}
|
|
770
|
+
sendPasswordResetEmail(email, actionCodeSettings) {
|
|
979
771
|
return exp__namespace.sendPasswordResetEmail(this._delegate, email, actionCodeSettings || undefined);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
converted = exp__namespace.inMemoryPersistence;
|
|
1009
|
-
return [3 /*break*/, 6];
|
|
1010
|
-
case 5: return [2 /*return*/, exp__namespace._fail("argument-error" /* exp.AuthErrorCode.ARGUMENT_ERROR */, {
|
|
1011
|
-
appName: this._delegate.name
|
|
1012
|
-
})];
|
|
1013
|
-
case 6: return [2 /*return*/, this._delegate.setPersistence(converted)];
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
1016
|
-
});
|
|
1017
|
-
};
|
|
1018
|
-
Auth.prototype.signInAndRetrieveDataWithCredential = function (credential) {
|
|
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) {
|
|
1019
800
|
return this.signInWithCredential(credential);
|
|
1020
|
-
}
|
|
1021
|
-
|
|
801
|
+
}
|
|
802
|
+
signInAnonymously() {
|
|
1022
803
|
return convertCredential(this._delegate, exp__namespace.signInAnonymously(this._delegate));
|
|
1023
|
-
}
|
|
1024
|
-
|
|
804
|
+
}
|
|
805
|
+
signInWithCredential(credential) {
|
|
1025
806
|
return convertCredential(this._delegate, exp__namespace.signInWithCredential(this._delegate, credential));
|
|
1026
|
-
}
|
|
1027
|
-
|
|
807
|
+
}
|
|
808
|
+
signInWithCustomToken(token) {
|
|
1028
809
|
return convertCredential(this._delegate, exp__namespace.signInWithCustomToken(this._delegate, token));
|
|
1029
|
-
}
|
|
1030
|
-
|
|
810
|
+
}
|
|
811
|
+
signInWithEmailAndPassword(email, password) {
|
|
1031
812
|
return convertCredential(this._delegate, exp__namespace.signInWithEmailAndPassword(this._delegate, email, password));
|
|
1032
|
-
}
|
|
1033
|
-
|
|
813
|
+
}
|
|
814
|
+
signInWithEmailLink(email, emailLink) {
|
|
1034
815
|
return convertCredential(this._delegate, exp__namespace.signInWithEmailLink(this._delegate, email, emailLink));
|
|
1035
|
-
}
|
|
1036
|
-
|
|
816
|
+
}
|
|
817
|
+
signInWithPhoneNumber(phoneNumber, applicationVerifier) {
|
|
1037
818
|
return convertConfirmationResult(this._delegate, exp__namespace.signInWithPhoneNumber(this._delegate, phoneNumber, applicationVerifier));
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
return tslib.__generator(this, function (_a) {
|
|
1050
|
-
switch (_a.label) {
|
|
1051
|
-
case 0:
|
|
1052
|
-
_assert$1(_isPopupRedirectSupported(), this._delegate, "operation-not-supported-in-this-environment" /* exp.AuthErrorCode.OPERATION_NOT_SUPPORTED */);
|
|
1053
|
-
return [4 /*yield*/, _savePersistenceForRedirect(this._delegate)];
|
|
1054
|
-
case 1:
|
|
1055
|
-
_a.sent();
|
|
1056
|
-
return [2 /*return*/, exp__namespace.signInWithRedirect(this._delegate, provider, CompatPopupRedirectResolver)];
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
});
|
|
1060
|
-
};
|
|
1061
|
-
Auth.prototype.updateCurrentUser = function (user) {
|
|
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) {
|
|
1062
830
|
// remove ts-ignore once overloads are defined for exp functions to accept compat objects
|
|
1063
831
|
// @ts-ignore
|
|
1064
832
|
return this._delegate.updateCurrentUser(user);
|
|
1065
|
-
}
|
|
1066
|
-
|
|
833
|
+
}
|
|
834
|
+
verifyPasswordResetCode(code) {
|
|
1067
835
|
return exp__namespace.verifyPasswordResetCode(this._delegate, code);
|
|
1068
|
-
}
|
|
1069
|
-
|
|
836
|
+
}
|
|
837
|
+
unwrap() {
|
|
1070
838
|
return this._delegate;
|
|
1071
|
-
}
|
|
1072
|
-
|
|
839
|
+
}
|
|
840
|
+
_delete() {
|
|
1073
841
|
return this._delegate._delete();
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
return Auth;
|
|
1081
|
-
}());
|
|
842
|
+
}
|
|
843
|
+
linkUnderlyingAuth() {
|
|
844
|
+
this._delegate.wrapped = () => this;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
Auth.Persistence = Persistence;
|
|
1082
848
|
function wrapObservers(nextOrObserver, error, complete) {
|
|
1083
|
-
|
|
849
|
+
let next = nextOrObserver;
|
|
1084
850
|
if (typeof nextOrObserver !== 'function') {
|
|
1085
|
-
(
|
|
851
|
+
({ next, error, complete } = nextOrObserver);
|
|
1086
852
|
}
|
|
1087
853
|
// We know 'next' is now a function
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
return oldNext(user && User.getOrCreate(user));
|
|
1091
|
-
};
|
|
854
|
+
const oldNext = next;
|
|
855
|
+
const newNext = (user) => oldNext(user && User.getOrCreate(user));
|
|
1092
856
|
return {
|
|
1093
857
|
next: newNext,
|
|
1094
858
|
error: error,
|
|
1095
|
-
complete
|
|
859
|
+
complete
|
|
1096
860
|
};
|
|
1097
861
|
}
|
|
1098
862
|
function buildPersistenceHierarchy(apiKey, appName) {
|
|
@@ -1100,7 +864,7 @@ function buildPersistenceHierarchy(apiKey, appName) {
|
|
|
1100
864
|
// persistence is checked *first* rather than last. This is because we want
|
|
1101
865
|
// to prefer stored persistence type in the hierarchy. This is an empty
|
|
1102
866
|
// array if window is not available or there is no pending redirect
|
|
1103
|
-
|
|
867
|
+
const persistences = _getPersistencesFromRedirect(apiKey, appName);
|
|
1104
868
|
// If "self" is available, add indexedDB
|
|
1105
869
|
if (typeof self !== 'undefined' &&
|
|
1106
870
|
!persistences.includes(exp__namespace.indexedDBLocalPersistence)) {
|
|
@@ -1108,11 +872,10 @@ function buildPersistenceHierarchy(apiKey, appName) {
|
|
|
1108
872
|
}
|
|
1109
873
|
// If "window" is available, add HTML Storage persistences
|
|
1110
874
|
if (typeof window !== 'undefined') {
|
|
1111
|
-
for (
|
|
875
|
+
for (const persistence of [
|
|
1112
876
|
exp__namespace.browserLocalPersistence,
|
|
1113
877
|
exp__namespace.browserSessionPersistence
|
|
1114
|
-
]
|
|
1115
|
-
var persistence = _a[_i];
|
|
878
|
+
]) {
|
|
1116
879
|
if (!persistences.includes(persistence)) {
|
|
1117
880
|
persistences.push(persistence);
|
|
1118
881
|
}
|
|
@@ -1141,29 +904,28 @@ function buildPersistenceHierarchy(apiKey, appName) {
|
|
|
1141
904
|
* See the License for the specific language governing permissions and
|
|
1142
905
|
* limitations under the License.
|
|
1143
906
|
*/
|
|
1144
|
-
|
|
1145
|
-
|
|
907
|
+
class PhoneAuthProvider {
|
|
908
|
+
constructor() {
|
|
1146
909
|
this.providerId = 'phone';
|
|
1147
910
|
// TODO: remove ts-ignore when moving types from auth-types to auth-compat
|
|
1148
911
|
// @ts-ignore
|
|
1149
912
|
this._delegate = new exp__namespace.PhoneAuthProvider(unwrap(firebase__default["default"].auth()));
|
|
1150
913
|
}
|
|
1151
|
-
|
|
914
|
+
static credential(verificationId, verificationCode) {
|
|
1152
915
|
return exp__namespace.PhoneAuthProvider.credential(verificationId, verificationCode);
|
|
1153
|
-
}
|
|
1154
|
-
|
|
916
|
+
}
|
|
917
|
+
verifyPhoneNumber(phoneInfoOptions, applicationVerifier) {
|
|
1155
918
|
return this._delegate.verifyPhoneNumber(
|
|
1156
919
|
// The implementation matches but the types are subtly incompatible
|
|
1157
920
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1158
921
|
phoneInfoOptions, applicationVerifier);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
922
|
+
}
|
|
923
|
+
unwrap() {
|
|
1161
924
|
return this._delegate;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
}());
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
PhoneAuthProvider.PHONE_SIGN_IN_METHOD = exp__namespace.PhoneAuthProvider.PHONE_SIGN_IN_METHOD;
|
|
928
|
+
PhoneAuthProvider.PROVIDER_ID = exp__namespace.PhoneAuthProvider.PROVIDER_ID;
|
|
1167
929
|
|
|
1168
930
|
/**
|
|
1169
931
|
* @license
|
|
@@ -1181,10 +943,9 @@ var PhoneAuthProvider = /** @class */ (function () {
|
|
|
1181
943
|
* See the License for the specific language governing permissions and
|
|
1182
944
|
* limitations under the License.
|
|
1183
945
|
*/
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
if (app === void 0) { app = firebase__default["default"].app(); }
|
|
946
|
+
const _assert = exp__namespace._assert;
|
|
947
|
+
class RecaptchaVerifier {
|
|
948
|
+
constructor(container, parameters, app = firebase__default["default"].app()) {
|
|
1188
949
|
var _a;
|
|
1189
950
|
// API key is required for web client RPC calls.
|
|
1190
951
|
_assert((_a = app.options) === null || _a === void 0 ? void 0 : _a.apiKey, "invalid-api-key" /* exp.AuthErrorCode.INVALID_API_KEY */, {
|
|
@@ -1198,17 +959,16 @@ var RecaptchaVerifier = /** @class */ (function () {
|
|
|
1198
959
|
parameters);
|
|
1199
960
|
this.type = this._delegate.type;
|
|
1200
961
|
}
|
|
1201
|
-
|
|
962
|
+
clear() {
|
|
1202
963
|
this._delegate.clear();
|
|
1203
|
-
}
|
|
1204
|
-
|
|
964
|
+
}
|
|
965
|
+
render() {
|
|
1205
966
|
return this._delegate.render();
|
|
1206
|
-
}
|
|
1207
|
-
|
|
967
|
+
}
|
|
968
|
+
verify() {
|
|
1208
969
|
return this._delegate.verify();
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
}());
|
|
970
|
+
}
|
|
971
|
+
}
|
|
1212
972
|
|
|
1213
973
|
/**
|
|
1214
974
|
* @license
|
|
@@ -1226,14 +986,14 @@ var RecaptchaVerifier = /** @class */ (function () {
|
|
|
1226
986
|
* See the License for the specific language governing permissions and
|
|
1227
987
|
* limitations under the License.
|
|
1228
988
|
*/
|
|
1229
|
-
|
|
989
|
+
const AUTH_TYPE = 'auth-compat';
|
|
1230
990
|
// Create auth components to register with firebase.
|
|
1231
991
|
// Provides Auth public APIs.
|
|
1232
992
|
function registerAuthCompat(instance) {
|
|
1233
|
-
instance.INTERNAL.registerComponent(new component.Component(AUTH_TYPE,
|
|
993
|
+
instance.INTERNAL.registerComponent(new component.Component(AUTH_TYPE, container => {
|
|
1234
994
|
// getImmediate for FirebaseApp will always succeed
|
|
1235
|
-
|
|
1236
|
-
|
|
995
|
+
const app = container.getProvider('app-compat').getImmediate();
|
|
996
|
+
const authProvider = container.getProvider('auth');
|
|
1237
997
|
return new Auth(app, authProvider);
|
|
1238
998
|
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
|
1239
999
|
.setServiceProps({
|
|
@@ -1257,7 +1017,7 @@ function registerAuthCompat(instance) {
|
|
|
1257
1017
|
PhoneMultiFactorGenerator: exp__namespace.PhoneMultiFactorGenerator,
|
|
1258
1018
|
RecaptchaVerifier: RecaptchaVerifier,
|
|
1259
1019
|
TwitterAuthProvider: exp__namespace.TwitterAuthProvider,
|
|
1260
|
-
Auth
|
|
1020
|
+
Auth,
|
|
1261
1021
|
AuthCredential: exp__namespace.AuthCredential,
|
|
1262
1022
|
Error: util.FirebaseError
|
|
1263
1023
|
})
|
|
@@ -1283,5 +1043,5 @@ registerAuthCompat(firebase__default["default"]);
|
|
|
1283
1043
|
* See the License for the specific language governing permissions and
|
|
1284
1044
|
* limitations under the License.
|
|
1285
1045
|
*/
|
|
1286
|
-
exp.FetchProvider.initialize(
|
|
1046
|
+
exp.FetchProvider.initialize(fetch, Headers, Response);
|
|
1287
1047
|
//# sourceMappingURL=index.node.cjs.js.map
|