@firebase/auth 0.22.0-canary.ea3849fff → 0.22.0-canary.ecb4454c3
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-public.d.ts +57 -0
- package/dist/auth.d.ts +70 -1
- package/dist/browser-cjs/{index-a4932583.js → index-2a5c9cce.js} +526 -181
- package/dist/browser-cjs/index-2a5c9cce.js.map +1 -0
- package/dist/browser-cjs/index.js +3 -2
- package/dist/browser-cjs/index.js.map +1 -1
- package/dist/browser-cjs/internal.js +3 -2
- package/dist/browser-cjs/internal.js.map +1 -1
- package/dist/browser-cjs/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/browser-cjs/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/browser-cjs/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/browser-cjs/src/api/errors.d.ts +9 -1
- package/dist/browser-cjs/src/api/index.d.ts +15 -1
- package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/browser-cjs/src/core/errors.d.ts +17 -1
- package/dist/browser-cjs/src/core/index.d.ts +26 -0
- package/dist/browser-cjs/src/model/auth.d.ts +5 -0
- package/dist/browser-cjs/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/browser-cjs/test/helpers/api/helper.d.ts +2 -0
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal.js +4 -71
- package/dist/cordova/internal.js.map +1 -1
- package/dist/cordova/{popup_redirect-e2867f33.js → popup_redirect-710a0689.js} +660 -152
- package/dist/cordova/popup_redirect-710a0689.js.map +1 -0
- package/dist/cordova/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/cordova/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/cordova/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/cordova/src/api/errors.d.ts +9 -1
- package/dist/cordova/src/api/index.d.ts +15 -1
- package/dist/cordova/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/cordova/src/core/errors.d.ts +17 -1
- package/dist/cordova/src/core/index.d.ts +26 -0
- package/dist/cordova/src/model/auth.d.ts +5 -0
- package/dist/cordova/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/cordova/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/cordova/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/cordova/test/helpers/api/helper.d.ts +2 -0
- package/dist/esm2017/{index-5eca8e8e.js → index-2dbc6285.js} +527 -183
- package/dist/esm2017/index-2dbc6285.js.map +1 -0
- package/dist/esm2017/index.js +2 -2
- package/dist/esm2017/internal.js +3 -3
- package/dist/esm2017/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/esm2017/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/esm2017/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/esm2017/src/api/errors.d.ts +9 -1
- package/dist/esm2017/src/api/index.d.ts +15 -1
- package/dist/esm2017/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/esm2017/src/core/errors.d.ts +17 -1
- package/dist/esm2017/src/core/index.d.ts +26 -0
- package/dist/esm2017/src/model/auth.d.ts +5 -0
- package/dist/esm2017/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/esm2017/test/helpers/api/helper.d.ts +2 -0
- package/dist/esm5/{index-ea49ccf6.js → index-f764da84.js} +682 -241
- package/dist/esm5/index-f764da84.js.map +1 -0
- package/dist/esm5/index.js +1 -1
- package/dist/esm5/internal.js +2 -2
- package/dist/esm5/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/esm5/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/esm5/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/esm5/src/api/errors.d.ts +9 -1
- package/dist/esm5/src/api/index.d.ts +15 -1
- package/dist/esm5/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/esm5/src/core/errors.d.ts +17 -1
- package/dist/esm5/src/core/index.d.ts +26 -0
- package/dist/esm5/src/model/auth.d.ts +5 -0
- package/dist/esm5/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/esm5/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/esm5/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/esm5/test/helpers/api/helper.d.ts +2 -0
- package/dist/index.webworker.esm5.js +544 -53
- package/dist/index.webworker.esm5.js.map +1 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/internal.js +2 -1
- package/dist/node/internal.js.map +1 -1
- package/dist/node/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/node/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/node/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/node/src/api/errors.d.ts +9 -1
- package/dist/node/src/api/index.d.ts +15 -1
- package/dist/node/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/node/src/core/errors.d.ts +17 -1
- package/dist/node/src/core/index.d.ts +26 -0
- package/dist/node/src/model/auth.d.ts +5 -0
- package/dist/node/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/node/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/node/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/node/test/helpers/api/helper.d.ts +2 -0
- package/dist/node/{totp-e4b57fc2.js → totp-b357b7fa.js} +642 -150
- package/dist/node/totp-b357b7fa.js.map +1 -0
- package/dist/node-esm/index.js +1 -1
- package/dist/node-esm/internal.js +2 -2
- package/dist/node-esm/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/node-esm/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/node-esm/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/node-esm/src/api/errors.d.ts +9 -1
- package/dist/node-esm/src/api/index.d.ts +15 -1
- package/dist/node-esm/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/node-esm/src/core/errors.d.ts +17 -1
- package/dist/node-esm/src/core/index.d.ts +26 -0
- package/dist/node-esm/src/model/auth.d.ts +5 -0
- package/dist/node-esm/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/node-esm/test/helpers/api/helper.d.ts +2 -0
- package/dist/node-esm/{totp-3a67b88c.js → totp-501673f0.js} +514 -120
- package/dist/node-esm/totp-501673f0.js.map +1 -0
- package/dist/rn/index.js +2 -1
- package/dist/rn/index.js.map +1 -1
- package/dist/rn/internal.js +2 -1
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/{phone-6ea1b9dd.js → phone-7f3181c6.js} +681 -239
- package/dist/rn/phone-7f3181c6.js.map +1 -0
- package/dist/rn/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/rn/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/rn/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/rn/src/api/errors.d.ts +9 -1
- package/dist/rn/src/api/index.d.ts +15 -1
- package/dist/rn/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/rn/src/core/errors.d.ts +17 -1
- package/dist/rn/src/core/index.d.ts +26 -0
- package/dist/rn/src/model/auth.d.ts +5 -0
- package/dist/rn/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/rn/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/rn/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/rn/test/helpers/api/helper.d.ts +2 -0
- package/dist/src/api/authentication/email_and_password.d.ts +9 -0
- package/dist/src/api/authentication/recaptcha.d.ts +16 -0
- package/dist/src/api/authentication/sign_up.d.ts +4 -0
- package/dist/src/api/errors.d.ts +9 -1
- package/dist/src/api/index.d.ts +15 -1
- package/dist/src/core/auth/auth_impl.d.ts +5 -0
- package/dist/src/core/errors.d.ts +17 -1
- package/dist/src/core/index.d.ts +26 -0
- package/dist/src/model/auth.d.ts +5 -0
- package/dist/src/platform_browser/auth_window.d.ts +2 -2
- package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
- package/dist/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
- package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
- package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
- package/dist/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
- package/dist/test/helpers/api/helper.d.ts +2 -0
- package/package.json +6 -6
- package/dist/browser-cjs/index-a4932583.js.map +0 -1
- package/dist/cordova/popup_redirect-e2867f33.js.map +0 -1
- package/dist/esm2017/index-5eca8e8e.js.map +0 -1
- package/dist/esm5/index-ea49ccf6.js.map +0 -1
- package/dist/node/totp-e4b57fc2.js.map +0 -1
- package/dist/node-esm/totp-3a67b88c.js.map +0 -1
- package/dist/rn/phone-6ea1b9dd.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __spreadArray, __assign, __awaiter, __generator, __rest, __extends } from 'tslib';
|
|
2
|
-
import { ErrorFactory,
|
|
2
|
+
import { ErrorFactory, isBrowserExtension, isMobileCordova, isReactNative, FirebaseError, querystring, getModularInstance, base64Decode, isIE, getUA, createSubscribe, deepEqual, querystringDecode, extractQuerystring, isEmpty, getExperimentalSetting, getDefaultEmulatorHost } from '@firebase/util';
|
|
3
3
|
import { SDK_VERSION, _getProvider, _registerComponent, registerVersion, getApp } from '@firebase/app';
|
|
4
4
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
5
5
|
import { Component } from '@firebase/component';
|
|
@@ -267,6 +267,14 @@ function _debugErrorMap() {
|
|
|
267
267
|
'different options. To avoid this error, call initializeAuth() with the ' +
|
|
268
268
|
'same options as when it was originally called, or call getAuth() to return the' +
|
|
269
269
|
' already initialized instance.',
|
|
270
|
+
_a["missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is missing when sending request to the backend.',
|
|
271
|
+
_a["invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is invalid when sending request to the backend.',
|
|
272
|
+
_a["invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */] = 'The reCAPTCHA action is invalid when sending request to the backend.',
|
|
273
|
+
_a["recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */] = 'reCAPTCHA Enterprise integration is not enabled for this project.',
|
|
274
|
+
_a["missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */] = 'The reCAPTCHA client type is missing when sending request to the backend.',
|
|
275
|
+
_a["missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is missing when sending request to the backend.',
|
|
276
|
+
_a["invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */] = 'Invalid request parameters.',
|
|
277
|
+
_a["invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is invalid when sending request to the backend.',
|
|
270
278
|
_a;
|
|
271
279
|
}
|
|
272
280
|
function _prodErrorMap() {
|
|
@@ -403,7 +411,15 @@ var AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
|
|
|
403
411
|
USER_SIGNED_OUT: 'auth/user-signed-out',
|
|
404
412
|
WEAK_PASSWORD: 'auth/weak-password',
|
|
405
413
|
WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
|
|
406
|
-
ALREADY_INITIALIZED: 'auth/already-initialized'
|
|
414
|
+
ALREADY_INITIALIZED: 'auth/already-initialized',
|
|
415
|
+
RECAPTCHA_NOT_ENABLED: 'auth/recaptcha-not-enabled',
|
|
416
|
+
MISSING_RECAPTCHA_TOKEN: 'auth/missing-recaptcha-token',
|
|
417
|
+
INVALID_RECAPTCHA_TOKEN: 'auth/invalid-recaptcha-token',
|
|
418
|
+
INVALID_RECAPTCHA_ACTION: 'auth/invalid-recaptcha-action',
|
|
419
|
+
MISSING_CLIENT_TYPE: 'auth/missing-client-type',
|
|
420
|
+
MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version',
|
|
421
|
+
INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version',
|
|
422
|
+
INVALID_REQ_TYPE: 'auth/invalid-req-type'
|
|
407
423
|
};
|
|
408
424
|
|
|
409
425
|
/**
|
|
@@ -544,103 +560,6 @@ function debugAssert(assertion, message) {
|
|
|
544
560
|
}
|
|
545
561
|
}
|
|
546
562
|
|
|
547
|
-
/**
|
|
548
|
-
* @license
|
|
549
|
-
* Copyright 2020 Google LLC
|
|
550
|
-
*
|
|
551
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
552
|
-
* you may not use this file except in compliance with the License.
|
|
553
|
-
* You may obtain a copy of the License at
|
|
554
|
-
*
|
|
555
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
556
|
-
*
|
|
557
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
558
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
559
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
560
|
-
* See the License for the specific language governing permissions and
|
|
561
|
-
* limitations under the License.
|
|
562
|
-
*/
|
|
563
|
-
var instanceCache = new Map();
|
|
564
|
-
function _getInstance(cls) {
|
|
565
|
-
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
566
|
-
var instance = instanceCache.get(cls);
|
|
567
|
-
if (instance) {
|
|
568
|
-
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
569
|
-
return instance;
|
|
570
|
-
}
|
|
571
|
-
instance = new cls();
|
|
572
|
-
instanceCache.set(cls, instance);
|
|
573
|
-
return instance;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* @license
|
|
578
|
-
* Copyright 2020 Google LLC
|
|
579
|
-
*
|
|
580
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
581
|
-
* you may not use this file except in compliance with the License.
|
|
582
|
-
* You may obtain a copy of the License at
|
|
583
|
-
*
|
|
584
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
585
|
-
*
|
|
586
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
587
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
588
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
589
|
-
* See the License for the specific language governing permissions and
|
|
590
|
-
* limitations under the License.
|
|
591
|
-
*/
|
|
592
|
-
/**
|
|
593
|
-
* Initializes an {@link Auth} instance with fine-grained control over
|
|
594
|
-
* {@link Dependencies}.
|
|
595
|
-
*
|
|
596
|
-
* @remarks
|
|
597
|
-
*
|
|
598
|
-
* This function allows more control over the {@link Auth} instance than
|
|
599
|
-
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
600
|
-
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
601
|
-
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
602
|
-
* need control over which persistence layer is used, or to minimize bundle
|
|
603
|
-
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
604
|
-
*
|
|
605
|
-
* For example, if your app only uses anonymous accounts and you only want
|
|
606
|
-
* accounts saved for the current session, initialize `Auth` with:
|
|
607
|
-
*
|
|
608
|
-
* ```js
|
|
609
|
-
* const auth = initializeAuth(app, {
|
|
610
|
-
* persistence: browserSessionPersistence,
|
|
611
|
-
* popupRedirectResolver: undefined,
|
|
612
|
-
* });
|
|
613
|
-
* ```
|
|
614
|
-
*
|
|
615
|
-
* @public
|
|
616
|
-
*/
|
|
617
|
-
function initializeAuth(app, deps) {
|
|
618
|
-
var provider = _getProvider(app, 'auth');
|
|
619
|
-
if (provider.isInitialized()) {
|
|
620
|
-
var auth_1 = provider.getImmediate();
|
|
621
|
-
var initialOptions = provider.getOptions();
|
|
622
|
-
if (deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
623
|
-
return auth_1;
|
|
624
|
-
}
|
|
625
|
-
else {
|
|
626
|
-
_fail(auth_1, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
var auth = provider.initialize({ options: deps });
|
|
630
|
-
return auth;
|
|
631
|
-
}
|
|
632
|
-
function _initializeAuthInstance(auth, deps) {
|
|
633
|
-
var persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
634
|
-
var hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
635
|
-
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
636
|
-
auth._updateErrorMap(deps.errorMap);
|
|
637
|
-
}
|
|
638
|
-
// This promise is intended to float; auth initialization happens in the
|
|
639
|
-
// background, meanwhile the auth object may be used by the app.
|
|
640
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
641
|
-
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
642
|
-
}
|
|
643
|
-
|
|
644
563
|
/**
|
|
645
564
|
* @license
|
|
646
565
|
* Copyright 2020 Google LLC
|
|
@@ -925,6 +844,15 @@ var SERVER_ERROR_MAP = (_a$1 = {},
|
|
|
925
844
|
_a$1["SECOND_FACTOR_LIMIT_EXCEEDED" /* ServerError.SECOND_FACTOR_LIMIT_EXCEEDED */] = "maximum-second-factor-count-exceeded" /* AuthErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED */,
|
|
926
845
|
// Blocking functions related errors.
|
|
927
846
|
_a$1["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */] = "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
|
|
847
|
+
// Recaptcha related errors.
|
|
848
|
+
_a$1["RECAPTCHA_NOT_ENABLED" /* ServerError.RECAPTCHA_NOT_ENABLED */] = "recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */,
|
|
849
|
+
_a$1["MISSING_RECAPTCHA_TOKEN" /* ServerError.MISSING_RECAPTCHA_TOKEN */] = "missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */,
|
|
850
|
+
_a$1["INVALID_RECAPTCHA_TOKEN" /* ServerError.INVALID_RECAPTCHA_TOKEN */] = "invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */,
|
|
851
|
+
_a$1["INVALID_RECAPTCHA_ACTION" /* ServerError.INVALID_RECAPTCHA_ACTION */] = "invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */,
|
|
852
|
+
_a$1["MISSING_CLIENT_TYPE" /* ServerError.MISSING_CLIENT_TYPE */] = "missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */,
|
|
853
|
+
_a$1["MISSING_RECAPTCHA_VERSION" /* ServerError.MISSING_RECAPTCHA_VERSION */] = "missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */,
|
|
854
|
+
_a$1["INVALID_RECAPTCHA_VERSION" /* ServerError.INVALID_RECAPTCHA_VERSION */] = "invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */,
|
|
855
|
+
_a$1["INVALID_REQ_TYPE" /* ServerError.INVALID_REQ_TYPE */] = "invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */,
|
|
928
856
|
_a$1);
|
|
929
857
|
|
|
930
858
|
/**
|
|
@@ -2046,6 +1974,35 @@ var UserImpl = /** @class */ (function () {
|
|
|
2046
1974
|
return UserImpl;
|
|
2047
1975
|
}());
|
|
2048
1976
|
|
|
1977
|
+
/**
|
|
1978
|
+
* @license
|
|
1979
|
+
* Copyright 2020 Google LLC
|
|
1980
|
+
*
|
|
1981
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1982
|
+
* you may not use this file except in compliance with the License.
|
|
1983
|
+
* You may obtain a copy of the License at
|
|
1984
|
+
*
|
|
1985
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1986
|
+
*
|
|
1987
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1988
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1989
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1990
|
+
* See the License for the specific language governing permissions and
|
|
1991
|
+
* limitations under the License.
|
|
1992
|
+
*/
|
|
1993
|
+
var instanceCache = new Map();
|
|
1994
|
+
function _getInstance(cls) {
|
|
1995
|
+
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
1996
|
+
var instance = instanceCache.get(cls);
|
|
1997
|
+
if (instance) {
|
|
1998
|
+
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
1999
|
+
return instance;
|
|
2000
|
+
}
|
|
2001
|
+
instance = new cls();
|
|
2002
|
+
instanceCache.set(cls, instance);
|
|
2003
|
+
return instance;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2049
2006
|
/**
|
|
2050
2007
|
* @license
|
|
2051
2008
|
* Copyright 2019 Google LLC
|
|
@@ -2484,6 +2441,288 @@ function _getClientVersion(clientPlatform, frameworks) {
|
|
|
2484
2441
|
return "".concat(reportedPlatform, "/").concat("JsCore" /* ClientImplementation.CORE */, "/").concat(SDK_VERSION, "/").concat(reportedFrameworks);
|
|
2485
2442
|
}
|
|
2486
2443
|
|
|
2444
|
+
/**
|
|
2445
|
+
* @license
|
|
2446
|
+
* Copyright 2020 Google LLC
|
|
2447
|
+
*
|
|
2448
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2449
|
+
* you may not use this file except in compliance with the License.
|
|
2450
|
+
* You may obtain a copy of the License at
|
|
2451
|
+
*
|
|
2452
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2453
|
+
*
|
|
2454
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2455
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2456
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2457
|
+
* See the License for the specific language governing permissions and
|
|
2458
|
+
* limitations under the License.
|
|
2459
|
+
*/
|
|
2460
|
+
function getRecaptchaParams(auth) {
|
|
2461
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2462
|
+
return __generator(this, function (_a) {
|
|
2463
|
+
switch (_a.label) {
|
|
2464
|
+
case 0: return [4 /*yield*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)];
|
|
2465
|
+
case 1: return [2 /*return*/, ((_a.sent()).recaptchaSiteKey || '')];
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2468
|
+
});
|
|
2469
|
+
}
|
|
2470
|
+
function getRecaptchaConfig(auth, request) {
|
|
2471
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2472
|
+
return __generator(this, function (_a) {
|
|
2473
|
+
return [2 /*return*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request))];
|
|
2474
|
+
});
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
/**
|
|
2479
|
+
* @license
|
|
2480
|
+
* Copyright 2020 Google LLC
|
|
2481
|
+
*
|
|
2482
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2483
|
+
* you may not use this file except in compliance with the License.
|
|
2484
|
+
* You may obtain a copy of the License at
|
|
2485
|
+
*
|
|
2486
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2487
|
+
*
|
|
2488
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2489
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2490
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2491
|
+
* See the License for the specific language governing permissions and
|
|
2492
|
+
* limitations under the License.
|
|
2493
|
+
*/
|
|
2494
|
+
function isV2(grecaptcha) {
|
|
2495
|
+
return (grecaptcha !== undefined &&
|
|
2496
|
+
grecaptcha.getResponse !== undefined);
|
|
2497
|
+
}
|
|
2498
|
+
function isEnterprise(grecaptcha) {
|
|
2499
|
+
return (grecaptcha !== undefined &&
|
|
2500
|
+
grecaptcha.enterprise !== undefined);
|
|
2501
|
+
}
|
|
2502
|
+
var RecaptchaConfig = /** @class */ (function () {
|
|
2503
|
+
function RecaptchaConfig(response) {
|
|
2504
|
+
/**
|
|
2505
|
+
* The reCAPTCHA site key.
|
|
2506
|
+
*/
|
|
2507
|
+
this.siteKey = '';
|
|
2508
|
+
/**
|
|
2509
|
+
* The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
|
|
2510
|
+
*/
|
|
2511
|
+
this.emailPasswordEnabled = false;
|
|
2512
|
+
if (response.recaptchaKey === undefined) {
|
|
2513
|
+
throw new Error('recaptchaKey undefined');
|
|
2514
|
+
}
|
|
2515
|
+
// Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
|
|
2516
|
+
this.siteKey = response.recaptchaKey.split('/')[3];
|
|
2517
|
+
this.emailPasswordEnabled = response.recaptchaEnforcementState.some(function (enforcementState) {
|
|
2518
|
+
return enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
|
|
2519
|
+
enforcementState.enforcementState !== 'OFF';
|
|
2520
|
+
});
|
|
2521
|
+
}
|
|
2522
|
+
return RecaptchaConfig;
|
|
2523
|
+
}());
|
|
2524
|
+
|
|
2525
|
+
/**
|
|
2526
|
+
* @license
|
|
2527
|
+
* Copyright 2020 Google LLC
|
|
2528
|
+
*
|
|
2529
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2530
|
+
* you may not use this file except in compliance with the License.
|
|
2531
|
+
* You may obtain a copy of the License at
|
|
2532
|
+
*
|
|
2533
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2534
|
+
*
|
|
2535
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2536
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2537
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2538
|
+
* See the License for the specific language governing permissions and
|
|
2539
|
+
* limitations under the License.
|
|
2540
|
+
*/
|
|
2541
|
+
function getScriptParentElement() {
|
|
2542
|
+
var _a, _b;
|
|
2543
|
+
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
2544
|
+
}
|
|
2545
|
+
function _loadJS(url) {
|
|
2546
|
+
// TODO: consider adding timeout support & cancellation
|
|
2547
|
+
return new Promise(function (resolve, reject) {
|
|
2548
|
+
var el = document.createElement('script');
|
|
2549
|
+
el.setAttribute('src', url);
|
|
2550
|
+
el.onload = resolve;
|
|
2551
|
+
el.onerror = function (e) {
|
|
2552
|
+
var error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
2553
|
+
error.customData = e;
|
|
2554
|
+
reject(error);
|
|
2555
|
+
};
|
|
2556
|
+
el.type = 'text/javascript';
|
|
2557
|
+
el.charset = 'UTF-8';
|
|
2558
|
+
getScriptParentElement().appendChild(el);
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
function _generateCallbackName(prefix) {
|
|
2562
|
+
return "__".concat(prefix).concat(Math.floor(Math.random() * 1000000));
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2566
|
+
var RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
|
|
2567
|
+
var RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
|
|
2568
|
+
var RecaptchaEnterpriseVerifier = /** @class */ (function () {
|
|
2569
|
+
/**
|
|
2570
|
+
*
|
|
2571
|
+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
2572
|
+
*
|
|
2573
|
+
*/
|
|
2574
|
+
function RecaptchaEnterpriseVerifier(authExtern) {
|
|
2575
|
+
/**
|
|
2576
|
+
* Identifies the type of application verifier (e.g. "recaptcha-enterprise").
|
|
2577
|
+
*/
|
|
2578
|
+
this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
|
|
2579
|
+
this.auth = _castAuth(authExtern);
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Executes the verification process.
|
|
2583
|
+
*
|
|
2584
|
+
* @returns A Promise for a token that can be used to assert the validity of a request.
|
|
2585
|
+
*/
|
|
2586
|
+
RecaptchaEnterpriseVerifier.prototype.verify = function (action, forceRefresh) {
|
|
2587
|
+
if (action === void 0) { action = 'verify'; }
|
|
2588
|
+
if (forceRefresh === void 0) { forceRefresh = false; }
|
|
2589
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2590
|
+
function retrieveSiteKey(auth) {
|
|
2591
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2592
|
+
var _this = this;
|
|
2593
|
+
return __generator(this, function (_a) {
|
|
2594
|
+
if (!forceRefresh) {
|
|
2595
|
+
if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
|
|
2596
|
+
return [2 /*return*/, auth._agentRecaptchaConfig.siteKey];
|
|
2597
|
+
}
|
|
2598
|
+
if (auth.tenantId != null &&
|
|
2599
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
|
|
2600
|
+
return [2 /*return*/, auth._tenantRecaptchaConfigs[auth.tenantId].siteKey];
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
2604
|
+
return __generator(this, function (_a) {
|
|
2605
|
+
getRecaptchaConfig(auth, {
|
|
2606
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2607
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2608
|
+
})
|
|
2609
|
+
.then(function (response) {
|
|
2610
|
+
if (response.recaptchaKey === undefined) {
|
|
2611
|
+
reject(new Error('recaptcha Enterprise site key undefined'));
|
|
2612
|
+
}
|
|
2613
|
+
else {
|
|
2614
|
+
var config = new RecaptchaConfig(response);
|
|
2615
|
+
if (auth.tenantId == null) {
|
|
2616
|
+
auth._agentRecaptchaConfig = config;
|
|
2617
|
+
}
|
|
2618
|
+
else {
|
|
2619
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] = config;
|
|
2620
|
+
}
|
|
2621
|
+
return resolve(config.siteKey);
|
|
2622
|
+
}
|
|
2623
|
+
})
|
|
2624
|
+
.catch(function (error) {
|
|
2625
|
+
reject(error);
|
|
2626
|
+
});
|
|
2627
|
+
return [2 /*return*/];
|
|
2628
|
+
});
|
|
2629
|
+
}); })];
|
|
2630
|
+
});
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
function retrieveRecaptchaToken(siteKey, resolve, reject) {
|
|
2634
|
+
var grecaptcha = window.grecaptcha;
|
|
2635
|
+
if (isEnterprise(grecaptcha)) {
|
|
2636
|
+
grecaptcha.enterprise.ready(function () {
|
|
2637
|
+
try {
|
|
2638
|
+
grecaptcha.enterprise
|
|
2639
|
+
.execute(siteKey, { action: action })
|
|
2640
|
+
.then(function (token) {
|
|
2641
|
+
resolve(token);
|
|
2642
|
+
})
|
|
2643
|
+
.catch(function (error) {
|
|
2644
|
+
reject(error);
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
catch (error) {
|
|
2648
|
+
reject(error);
|
|
2649
|
+
}
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
else {
|
|
2653
|
+
reject(Error('No reCAPTCHA enterprise script loaded.'));
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
var _this = this;
|
|
2657
|
+
return __generator(this, function (_a) {
|
|
2658
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
2659
|
+
retrieveSiteKey(_this.auth)
|
|
2660
|
+
.then(function (siteKey) {
|
|
2661
|
+
if (!forceRefresh && isEnterprise(window.grecaptcha)) {
|
|
2662
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2663
|
+
}
|
|
2664
|
+
else {
|
|
2665
|
+
if (typeof window === 'undefined') {
|
|
2666
|
+
reject(new Error('RecaptchaVerifier is only supported in browser'));
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
_loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
|
|
2670
|
+
.then(function () {
|
|
2671
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2672
|
+
})
|
|
2673
|
+
.catch(function (error) {
|
|
2674
|
+
reject(error);
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
})
|
|
2678
|
+
.catch(function (error) {
|
|
2679
|
+
reject(error);
|
|
2680
|
+
});
|
|
2681
|
+
})];
|
|
2682
|
+
});
|
|
2683
|
+
});
|
|
2684
|
+
};
|
|
2685
|
+
return RecaptchaEnterpriseVerifier;
|
|
2686
|
+
}());
|
|
2687
|
+
function injectRecaptchaFields(auth, request, action, captchaResp) {
|
|
2688
|
+
if (captchaResp === void 0) { captchaResp = false; }
|
|
2689
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2690
|
+
var verifier, captchaResponse, newRequest;
|
|
2691
|
+
return __generator(this, function (_a) {
|
|
2692
|
+
switch (_a.label) {
|
|
2693
|
+
case 0:
|
|
2694
|
+
verifier = new RecaptchaEnterpriseVerifier(auth);
|
|
2695
|
+
_a.label = 1;
|
|
2696
|
+
case 1:
|
|
2697
|
+
_a.trys.push([1, 3, , 5]);
|
|
2698
|
+
return [4 /*yield*/, verifier.verify(action)];
|
|
2699
|
+
case 2:
|
|
2700
|
+
captchaResponse = _a.sent();
|
|
2701
|
+
return [3 /*break*/, 5];
|
|
2702
|
+
case 3:
|
|
2703
|
+
_a.sent();
|
|
2704
|
+
return [4 /*yield*/, verifier.verify(action, true)];
|
|
2705
|
+
case 4:
|
|
2706
|
+
captchaResponse = _a.sent();
|
|
2707
|
+
return [3 /*break*/, 5];
|
|
2708
|
+
case 5:
|
|
2709
|
+
newRequest = __assign({}, request);
|
|
2710
|
+
if (!captchaResp) {
|
|
2711
|
+
Object.assign(newRequest, { captchaResponse: captchaResponse });
|
|
2712
|
+
}
|
|
2713
|
+
else {
|
|
2714
|
+
Object.assign(newRequest, { 'captchaResp': captchaResponse });
|
|
2715
|
+
}
|
|
2716
|
+
Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
|
|
2717
|
+
Object.assign(newRequest, {
|
|
2718
|
+
'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2719
|
+
});
|
|
2720
|
+
return [2 /*return*/, newRequest];
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2487
2726
|
/**
|
|
2488
2727
|
* @license
|
|
2489
2728
|
* Copyright 2022 Google LLC
|
|
@@ -2626,6 +2865,8 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2626
2865
|
this._initializationPromise = null;
|
|
2627
2866
|
this._popupRedirectResolver = null;
|
|
2628
2867
|
this._errorFactory = _DEFAULT_AUTH_ERROR_FACTORY;
|
|
2868
|
+
this._agentRecaptchaConfig = null;
|
|
2869
|
+
this._tenantRecaptchaConfigs = {};
|
|
2629
2870
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2630
2871
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2631
2872
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2955,6 +3196,41 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2955
3196
|
});
|
|
2956
3197
|
}); });
|
|
2957
3198
|
};
|
|
3199
|
+
AuthImpl.prototype.initializeRecaptchaConfig = function () {
|
|
3200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3201
|
+
var response, config, verifier;
|
|
3202
|
+
return __generator(this, function (_a) {
|
|
3203
|
+
switch (_a.label) {
|
|
3204
|
+
case 0: return [4 /*yield*/, getRecaptchaConfig(this, {
|
|
3205
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
3206
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
3207
|
+
})];
|
|
3208
|
+
case 1:
|
|
3209
|
+
response = _a.sent();
|
|
3210
|
+
config = new RecaptchaConfig(response);
|
|
3211
|
+
if (this.tenantId == null) {
|
|
3212
|
+
this._agentRecaptchaConfig = config;
|
|
3213
|
+
}
|
|
3214
|
+
else {
|
|
3215
|
+
this._tenantRecaptchaConfigs[this.tenantId] = config;
|
|
3216
|
+
}
|
|
3217
|
+
if (config.emailPasswordEnabled) {
|
|
3218
|
+
verifier = new RecaptchaEnterpriseVerifier(this);
|
|
3219
|
+
void verifier.verify();
|
|
3220
|
+
}
|
|
3221
|
+
return [2 /*return*/];
|
|
3222
|
+
}
|
|
3223
|
+
});
|
|
3224
|
+
});
|
|
3225
|
+
};
|
|
3226
|
+
AuthImpl.prototype._getRecaptchaConfig = function () {
|
|
3227
|
+
if (this.tenantId == null) {
|
|
3228
|
+
return this._agentRecaptchaConfig;
|
|
3229
|
+
}
|
|
3230
|
+
else {
|
|
3231
|
+
return this._tenantRecaptchaConfigs[this.tenantId];
|
|
3232
|
+
}
|
|
3233
|
+
};
|
|
2958
3234
|
AuthImpl.prototype._getPersistence = function () {
|
|
2959
3235
|
return this.assertedPersistence.persistence.type;
|
|
2960
3236
|
};
|
|
@@ -3241,29 +3517,97 @@ var AuthImpl = /** @class */ (function () {
|
|
|
3241
3517
|
* Method to be used to cast down to our private implmentation of Auth.
|
|
3242
3518
|
* It will also handle unwrapping from the compat type if necessary
|
|
3243
3519
|
*
|
|
3244
|
-
* @param auth Auth object passed in from developer
|
|
3520
|
+
* @param auth Auth object passed in from developer
|
|
3521
|
+
*/
|
|
3522
|
+
function _castAuth(auth) {
|
|
3523
|
+
return getModularInstance(auth);
|
|
3524
|
+
}
|
|
3525
|
+
/** Helper class to wrap subscriber logic */
|
|
3526
|
+
var Subscription = /** @class */ (function () {
|
|
3527
|
+
function Subscription(auth) {
|
|
3528
|
+
var _this = this;
|
|
3529
|
+
this.auth = auth;
|
|
3530
|
+
this.observer = null;
|
|
3531
|
+
this.addObserver = createSubscribe(function (observer) { return (_this.observer = observer); });
|
|
3532
|
+
}
|
|
3533
|
+
Object.defineProperty(Subscription.prototype, "next", {
|
|
3534
|
+
get: function () {
|
|
3535
|
+
_assert(this.observer, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
3536
|
+
return this.observer.next.bind(this.observer);
|
|
3537
|
+
},
|
|
3538
|
+
enumerable: false,
|
|
3539
|
+
configurable: true
|
|
3540
|
+
});
|
|
3541
|
+
return Subscription;
|
|
3542
|
+
}());
|
|
3543
|
+
|
|
3544
|
+
/**
|
|
3545
|
+
* @license
|
|
3546
|
+
* Copyright 2020 Google LLC
|
|
3547
|
+
*
|
|
3548
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3549
|
+
* you may not use this file except in compliance with the License.
|
|
3550
|
+
* You may obtain a copy of the License at
|
|
3551
|
+
*
|
|
3552
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3553
|
+
*
|
|
3554
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3555
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3556
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3557
|
+
* See the License for the specific language governing permissions and
|
|
3558
|
+
* limitations under the License.
|
|
3559
|
+
*/
|
|
3560
|
+
/**
|
|
3561
|
+
* Initializes an {@link Auth} instance with fine-grained control over
|
|
3562
|
+
* {@link Dependencies}.
|
|
3563
|
+
*
|
|
3564
|
+
* @remarks
|
|
3565
|
+
*
|
|
3566
|
+
* This function allows more control over the {@link Auth} instance than
|
|
3567
|
+
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
3568
|
+
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
3569
|
+
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
3570
|
+
* need control over which persistence layer is used, or to minimize bundle
|
|
3571
|
+
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
3572
|
+
*
|
|
3573
|
+
* For example, if your app only uses anonymous accounts and you only want
|
|
3574
|
+
* accounts saved for the current session, initialize `Auth` with:
|
|
3575
|
+
*
|
|
3576
|
+
* ```js
|
|
3577
|
+
* const auth = initializeAuth(app, {
|
|
3578
|
+
* persistence: browserSessionPersistence,
|
|
3579
|
+
* popupRedirectResolver: undefined,
|
|
3580
|
+
* });
|
|
3581
|
+
* ```
|
|
3582
|
+
*
|
|
3583
|
+
* @public
|
|
3245
3584
|
*/
|
|
3246
|
-
function
|
|
3247
|
-
|
|
3585
|
+
function initializeAuth(app, deps) {
|
|
3586
|
+
var provider = _getProvider(app, 'auth');
|
|
3587
|
+
if (provider.isInitialized()) {
|
|
3588
|
+
var auth_1 = provider.getImmediate();
|
|
3589
|
+
var initialOptions = provider.getOptions();
|
|
3590
|
+
if (deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
3591
|
+
return auth_1;
|
|
3592
|
+
}
|
|
3593
|
+
else {
|
|
3594
|
+
_fail(auth_1, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
var auth = provider.initialize({ options: deps });
|
|
3598
|
+
return auth;
|
|
3248
3599
|
}
|
|
3249
|
-
|
|
3250
|
-
var
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
this.observer = null;
|
|
3255
|
-
this.addObserver = createSubscribe(function (observer) { return (_this.observer = observer); });
|
|
3600
|
+
function _initializeAuthInstance(auth, deps) {
|
|
3601
|
+
var persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
3602
|
+
var hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
3603
|
+
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
3604
|
+
auth._updateErrorMap(deps.errorMap);
|
|
3256
3605
|
}
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
enumerable: false,
|
|
3263
|
-
configurable: true
|
|
3264
|
-
});
|
|
3265
|
-
return Subscription;
|
|
3266
|
-
}());
|
|
3606
|
+
// This promise is intended to float; auth initialization happens in the
|
|
3607
|
+
// background, meanwhile the auth object may be used by the app.
|
|
3608
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
3609
|
+
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
3610
|
+
}
|
|
3267
3611
|
|
|
3268
3612
|
/**
|
|
3269
3613
|
* Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
|
|
@@ -3653,24 +3997,55 @@ var EmailAuthCredential = /** @class */ (function (_super) {
|
|
|
3653
3997
|
};
|
|
3654
3998
|
/** @internal */
|
|
3655
3999
|
EmailAuthCredential.prototype._getIdTokenResponse = function (auth) {
|
|
4000
|
+
var _a;
|
|
3656
4001
|
return __awaiter(this, void 0, void 0, function () {
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
4002
|
+
var _b, request_1, requestWithRecaptcha;
|
|
4003
|
+
var _this = this;
|
|
4004
|
+
return __generator(this, function (_c) {
|
|
4005
|
+
switch (_c.label) {
|
|
4006
|
+
case 0:
|
|
4007
|
+
_b = this.signInMethod;
|
|
4008
|
+
switch (_b) {
|
|
4009
|
+
case "password" /* SignInMethod.EMAIL_PASSWORD */: return [3 /*break*/, 1];
|
|
4010
|
+
case "emailLink" /* SignInMethod.EMAIL_LINK */: return [3 /*break*/, 4];
|
|
4011
|
+
}
|
|
4012
|
+
return [3 /*break*/, 5];
|
|
4013
|
+
case 1:
|
|
4014
|
+
request_1 = {
|
|
4015
|
+
returnSecureToken: true,
|
|
4016
|
+
email: this._email,
|
|
4017
|
+
password: this._password,
|
|
4018
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
4019
|
+
};
|
|
4020
|
+
if (!((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
4021
|
+
return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
|
|
4022
|
+
case 2:
|
|
4023
|
+
requestWithRecaptcha = _c.sent();
|
|
4024
|
+
return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
|
|
4025
|
+
case 3: return [2 /*return*/, signInWithPassword(auth, request_1).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
4026
|
+
var requestWithRecaptcha;
|
|
4027
|
+
return __generator(this, function (_a) {
|
|
4028
|
+
switch (_a.label) {
|
|
4029
|
+
case 0:
|
|
4030
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
|
|
4031
|
+
console.log('Sign-in with email address and password is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
|
|
4032
|
+
return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
|
|
4033
|
+
case 1:
|
|
4034
|
+
requestWithRecaptcha = _a.sent();
|
|
4035
|
+
return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
|
|
4036
|
+
case 2: return [2 /*return*/, Promise.reject(error)];
|
|
4037
|
+
}
|
|
4038
|
+
});
|
|
4039
|
+
}); })];
|
|
4040
|
+
case 4: return [2 /*return*/, signInWithEmailLink$1(auth, {
|
|
4041
|
+
email: this._email,
|
|
4042
|
+
oobCode: this._password
|
|
4043
|
+
})];
|
|
4044
|
+
case 5:
|
|
3671
4045
|
_fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
4046
|
+
_c.label = 6;
|
|
4047
|
+
case 6: return [2 /*return*/];
|
|
3672
4048
|
}
|
|
3673
|
-
return [2 /*return*/];
|
|
3674
4049
|
});
|
|
3675
4050
|
});
|
|
3676
4051
|
};
|
|
@@ -5857,23 +6232,61 @@ function _setActionCodeSettingsOnRequest(auth, request, actionCodeSettings) {
|
|
|
5857
6232
|
* @public
|
|
5858
6233
|
*/
|
|
5859
6234
|
function sendPasswordResetEmail(auth, email, actionCodeSettings) {
|
|
6235
|
+
var _a;
|
|
5860
6236
|
return __awaiter(this, void 0, void 0, function () {
|
|
5861
|
-
var
|
|
5862
|
-
|
|
5863
|
-
|
|
6237
|
+
var authInternal, request, requestWithRecaptcha;
|
|
6238
|
+
var _this = this;
|
|
6239
|
+
return __generator(this, function (_b) {
|
|
6240
|
+
switch (_b.label) {
|
|
5864
6241
|
case 0:
|
|
5865
|
-
|
|
6242
|
+
authInternal = _castAuth(auth);
|
|
5866
6243
|
request = {
|
|
5867
6244
|
requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
|
|
5868
|
-
email: email
|
|
6245
|
+
email: email,
|
|
6246
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
5869
6247
|
};
|
|
6248
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
6249
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6250
|
+
case 1:
|
|
6251
|
+
requestWithRecaptcha = _b.sent();
|
|
5870
6252
|
if (actionCodeSettings) {
|
|
5871
|
-
_setActionCodeSettingsOnRequest(
|
|
6253
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
5872
6254
|
}
|
|
5873
|
-
return [4 /*yield*/, sendPasswordResetEmail$1(
|
|
5874
|
-
case
|
|
5875
|
-
|
|
5876
|
-
return [
|
|
6255
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
|
|
6256
|
+
case 2:
|
|
6257
|
+
_b.sent();
|
|
6258
|
+
return [3 /*break*/, 5];
|
|
6259
|
+
case 3:
|
|
6260
|
+
if (actionCodeSettings) {
|
|
6261
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
6262
|
+
}
|
|
6263
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, request)
|
|
6264
|
+
.catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
6265
|
+
var requestWithRecaptcha;
|
|
6266
|
+
return __generator(this, function (_a) {
|
|
6267
|
+
switch (_a.label) {
|
|
6268
|
+
case 0:
|
|
6269
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
|
|
6270
|
+
console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
|
|
6271
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6272
|
+
case 1:
|
|
6273
|
+
requestWithRecaptcha = _a.sent();
|
|
6274
|
+
if (actionCodeSettings) {
|
|
6275
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
6276
|
+
}
|
|
6277
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
|
|
6278
|
+
case 2:
|
|
6279
|
+
_a.sent();
|
|
6280
|
+
return [3 /*break*/, 4];
|
|
6281
|
+
case 3: return [2 /*return*/, Promise.reject(error)];
|
|
6282
|
+
case 4: return [2 /*return*/];
|
|
6283
|
+
}
|
|
6284
|
+
});
|
|
6285
|
+
}); })];
|
|
6286
|
+
case 4:
|
|
6287
|
+
_b.sent();
|
|
6288
|
+
_b.label = 5;
|
|
6289
|
+
case 5: return [2 /*return*/];
|
|
5877
6290
|
}
|
|
5878
6291
|
});
|
|
5879
6292
|
});
|
|
@@ -6018,25 +6431,54 @@ function verifyPasswordResetCode(auth, code) {
|
|
|
6018
6431
|
* @public
|
|
6019
6432
|
*/
|
|
6020
6433
|
function createUserWithEmailAndPassword(auth, email, password) {
|
|
6434
|
+
var _a;
|
|
6021
6435
|
return __awaiter(this, void 0, void 0, function () {
|
|
6022
|
-
var authInternal, response, userCredential;
|
|
6023
|
-
|
|
6024
|
-
|
|
6436
|
+
var authInternal, request, signUpResponse, requestWithRecaptcha, response, userCredential;
|
|
6437
|
+
var _this = this;
|
|
6438
|
+
return __generator(this, function (_b) {
|
|
6439
|
+
switch (_b.label) {
|
|
6025
6440
|
case 0:
|
|
6026
6441
|
authInternal = _castAuth(auth);
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6442
|
+
request = {
|
|
6443
|
+
returnSecureToken: true,
|
|
6444
|
+
email: email,
|
|
6445
|
+
password: password,
|
|
6446
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
6447
|
+
};
|
|
6448
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 2];
|
|
6449
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
|
|
6032
6450
|
case 1:
|
|
6033
|
-
|
|
6034
|
-
|
|
6451
|
+
requestWithRecaptcha = _b.sent();
|
|
6452
|
+
signUpResponse = signUp(authInternal, requestWithRecaptcha);
|
|
6453
|
+
return [3 /*break*/, 3];
|
|
6035
6454
|
case 2:
|
|
6036
|
-
|
|
6455
|
+
signUpResponse = signUp(authInternal, request).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
6456
|
+
var requestWithRecaptcha;
|
|
6457
|
+
return __generator(this, function (_a) {
|
|
6458
|
+
switch (_a.label) {
|
|
6459
|
+
case 0:
|
|
6460
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
|
|
6461
|
+
console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
|
|
6462
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
|
|
6463
|
+
case 1:
|
|
6464
|
+
requestWithRecaptcha = _a.sent();
|
|
6465
|
+
return [2 /*return*/, signUp(authInternal, requestWithRecaptcha)];
|
|
6466
|
+
case 2: return [2 /*return*/, Promise.reject(error)];
|
|
6467
|
+
}
|
|
6468
|
+
});
|
|
6469
|
+
}); });
|
|
6470
|
+
_b.label = 3;
|
|
6471
|
+
case 3: return [4 /*yield*/, signUpResponse.catch(function (error) {
|
|
6472
|
+
return Promise.reject(error);
|
|
6473
|
+
})];
|
|
6474
|
+
case 4:
|
|
6475
|
+
response = _b.sent();
|
|
6476
|
+
return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
|
|
6477
|
+
case 5:
|
|
6478
|
+
userCredential = _b.sent();
|
|
6037
6479
|
return [4 /*yield*/, authInternal._updateCurrentUser(userCredential.user)];
|
|
6038
|
-
case
|
|
6039
|
-
|
|
6480
|
+
case 6:
|
|
6481
|
+
_b.sent();
|
|
6040
6482
|
return [2 /*return*/, userCredential];
|
|
6041
6483
|
}
|
|
6042
6484
|
});
|
|
@@ -6117,24 +6559,61 @@ function signInWithEmailAndPassword(auth, email, password) {
|
|
|
6117
6559
|
* @public
|
|
6118
6560
|
*/
|
|
6119
6561
|
function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
|
|
6562
|
+
var _a;
|
|
6120
6563
|
return __awaiter(this, void 0, void 0, function () {
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6564
|
+
function setActionCodeSettings(request, actionCodeSettings) {
|
|
6565
|
+
_assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
6566
|
+
if (actionCodeSettings) {
|
|
6567
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
6568
|
+
}
|
|
6569
|
+
}
|
|
6570
|
+
var authInternal, request, requestWithRecaptcha;
|
|
6571
|
+
var _this = this;
|
|
6572
|
+
return __generator(this, function (_b) {
|
|
6573
|
+
switch (_b.label) {
|
|
6124
6574
|
case 0:
|
|
6125
|
-
|
|
6575
|
+
authInternal = _castAuth(auth);
|
|
6126
6576
|
request = {
|
|
6127
6577
|
requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
|
|
6128
|
-
email: email
|
|
6578
|
+
email: email,
|
|
6579
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
6129
6580
|
};
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
_setActionCodeSettingsOnRequest(authModular, request, actionCodeSettings);
|
|
6133
|
-
}
|
|
6134
|
-
return [4 /*yield*/, sendSignInLinkToEmail$1(authModular, request)];
|
|
6581
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
6582
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6135
6583
|
case 1:
|
|
6136
|
-
|
|
6137
|
-
|
|
6584
|
+
requestWithRecaptcha = _b.sent();
|
|
6585
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
6586
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
|
|
6587
|
+
case 2:
|
|
6588
|
+
_b.sent();
|
|
6589
|
+
return [3 /*break*/, 5];
|
|
6590
|
+
case 3:
|
|
6591
|
+
setActionCodeSettings(request, actionCodeSettings);
|
|
6592
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, request)
|
|
6593
|
+
.catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
6594
|
+
var requestWithRecaptcha;
|
|
6595
|
+
return __generator(this, function (_a) {
|
|
6596
|
+
switch (_a.label) {
|
|
6597
|
+
case 0:
|
|
6598
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
|
|
6599
|
+
console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
|
|
6600
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6601
|
+
case 1:
|
|
6602
|
+
requestWithRecaptcha = _a.sent();
|
|
6603
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
6604
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
|
|
6605
|
+
case 2:
|
|
6606
|
+
_a.sent();
|
|
6607
|
+
return [3 /*break*/, 4];
|
|
6608
|
+
case 3: return [2 /*return*/, Promise.reject(error)];
|
|
6609
|
+
case 4: return [2 /*return*/];
|
|
6610
|
+
}
|
|
6611
|
+
});
|
|
6612
|
+
}); })];
|
|
6613
|
+
case 4:
|
|
6614
|
+
_b.sent();
|
|
6615
|
+
_b.label = 5;
|
|
6616
|
+
case 5: return [2 /*return*/];
|
|
6138
6617
|
}
|
|
6139
6618
|
});
|
|
6140
6619
|
});
|
|
@@ -6730,6 +7209,35 @@ function getAdditionalUserInfo(userCredential) {
|
|
|
6730
7209
|
function setPersistence(auth, persistence) {
|
|
6731
7210
|
return getModularInstance(auth).setPersistence(persistence);
|
|
6732
7211
|
}
|
|
7212
|
+
/**
|
|
7213
|
+
* Loads the reCAPTCHA configuration into the `Auth` instance.
|
|
7214
|
+
*
|
|
7215
|
+
* @remarks
|
|
7216
|
+
* This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
|
|
7217
|
+
* verification flow should be triggered for each auth provider, into the
|
|
7218
|
+
* current Auth session.
|
|
7219
|
+
*
|
|
7220
|
+
* If initializeRecaptchaConfig() is not invoked, the auth flow will always start
|
|
7221
|
+
* without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
|
|
7222
|
+
* verification, the SDK will transparently load the reCAPTCHA config and restart the
|
|
7223
|
+
* auth flows.
|
|
7224
|
+
*
|
|
7225
|
+
* Thus, by calling this optional method, you will reduce the latency of future auth flows.
|
|
7226
|
+
* Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
|
|
7227
|
+
*
|
|
7228
|
+
* @example
|
|
7229
|
+
* ```javascript
|
|
7230
|
+
* initializeRecaptchaConfig(auth);
|
|
7231
|
+
* ```
|
|
7232
|
+
*
|
|
7233
|
+
* @param auth - The {@link Auth} instance.
|
|
7234
|
+
*
|
|
7235
|
+
* @public
|
|
7236
|
+
*/
|
|
7237
|
+
function initializeRecaptchaConfig(auth) {
|
|
7238
|
+
var authInternal = _castAuth(auth);
|
|
7239
|
+
return authInternal.initializeRecaptchaConfig();
|
|
7240
|
+
}
|
|
6733
7241
|
/**
|
|
6734
7242
|
* Adds an observer for changes to the signed-in user's ID token.
|
|
6735
7243
|
*
|
|
@@ -8416,73 +8924,6 @@ function finalizeSignInTotpMfa(auth, request) {
|
|
|
8416
8924
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
8417
8925
|
}
|
|
8418
8926
|
|
|
8419
|
-
/**
|
|
8420
|
-
* @license
|
|
8421
|
-
* Copyright 2020 Google LLC
|
|
8422
|
-
*
|
|
8423
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8424
|
-
* you may not use this file except in compliance with the License.
|
|
8425
|
-
* You may obtain a copy of the License at
|
|
8426
|
-
*
|
|
8427
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8428
|
-
*
|
|
8429
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8430
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8431
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8432
|
-
* See the License for the specific language governing permissions and
|
|
8433
|
-
* limitations under the License.
|
|
8434
|
-
*/
|
|
8435
|
-
function getRecaptchaParams(auth) {
|
|
8436
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
8437
|
-
return __generator(this, function (_a) {
|
|
8438
|
-
switch (_a.label) {
|
|
8439
|
-
case 0: return [4 /*yield*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)];
|
|
8440
|
-
case 1: return [2 /*return*/, ((_a.sent()).recaptchaSiteKey || '')];
|
|
8441
|
-
}
|
|
8442
|
-
});
|
|
8443
|
-
});
|
|
8444
|
-
}
|
|
8445
|
-
|
|
8446
|
-
/**
|
|
8447
|
-
* @license
|
|
8448
|
-
* Copyright 2020 Google LLC
|
|
8449
|
-
*
|
|
8450
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8451
|
-
* you may not use this file except in compliance with the License.
|
|
8452
|
-
* You may obtain a copy of the License at
|
|
8453
|
-
*
|
|
8454
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8455
|
-
*
|
|
8456
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8457
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8458
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8459
|
-
* See the License for the specific language governing permissions and
|
|
8460
|
-
* limitations under the License.
|
|
8461
|
-
*/
|
|
8462
|
-
function getScriptParentElement() {
|
|
8463
|
-
var _a, _b;
|
|
8464
|
-
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
8465
|
-
}
|
|
8466
|
-
function _loadJS(url) {
|
|
8467
|
-
// TODO: consider adding timeout support & cancellation
|
|
8468
|
-
return new Promise(function (resolve, reject) {
|
|
8469
|
-
var el = document.createElement('script');
|
|
8470
|
-
el.setAttribute('src', url);
|
|
8471
|
-
el.onload = resolve;
|
|
8472
|
-
el.onerror = function (e) {
|
|
8473
|
-
var error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
8474
|
-
error.customData = e;
|
|
8475
|
-
reject(error);
|
|
8476
|
-
};
|
|
8477
|
-
el.type = 'text/javascript';
|
|
8478
|
-
el.charset = 'UTF-8';
|
|
8479
|
-
getScriptParentElement().appendChild(el);
|
|
8480
|
-
});
|
|
8481
|
-
}
|
|
8482
|
-
function _generateCallbackName(prefix) {
|
|
8483
|
-
return "__".concat(prefix).concat(Math.floor(Math.random() * 1000000));
|
|
8484
|
-
}
|
|
8485
|
-
|
|
8486
8927
|
/**
|
|
8487
8928
|
* @license
|
|
8488
8929
|
* Copyright 2020 Google LLC
|
|
@@ -8660,7 +9101,7 @@ var ReCaptchaLoaderImpl = /** @class */ (function () {
|
|
|
8660
9101
|
var _this = this;
|
|
8661
9102
|
if (hl === void 0) { hl = ''; }
|
|
8662
9103
|
_assert(isHostLanguageValid(hl), auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
8663
|
-
if (this.shouldResolveImmediately(hl)) {
|
|
9104
|
+
if (this.shouldResolveImmediately(hl) && isV2(_window().grecaptcha)) {
|
|
8664
9105
|
return Promise.resolve(_window().grecaptcha);
|
|
8665
9106
|
}
|
|
8666
9107
|
return new Promise(function (resolve, reject) {
|
|
@@ -8671,7 +9112,7 @@ var ReCaptchaLoaderImpl = /** @class */ (function () {
|
|
|
8671
9112
|
_window().clearTimeout(networkTimeout);
|
|
8672
9113
|
delete _window()[_JSLOAD_CALLBACK];
|
|
8673
9114
|
var recaptcha = _window().grecaptcha;
|
|
8674
|
-
if (!recaptcha) {
|
|
9115
|
+
if (!recaptcha || !isV2(recaptcha)) {
|
|
8675
9116
|
reject(_createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
|
|
8676
9117
|
return;
|
|
8677
9118
|
}
|
|
@@ -11369,7 +11810,7 @@ function _isEmptyString(input) {
|
|
|
11369
11810
|
}
|
|
11370
11811
|
|
|
11371
11812
|
var name = "@firebase/auth";
|
|
11372
|
-
var version = "0.22.0-canary.
|
|
11813
|
+
var version = "0.22.0-canary.ecb4454c3";
|
|
11373
11814
|
|
|
11374
11815
|
/**
|
|
11375
11816
|
* @license
|
|
@@ -11625,5 +12066,5 @@ function getAuth(app) {
|
|
|
11625
12066
|
}
|
|
11626
12067
|
registerAuth("Browser" /* ClientPlatform.BROWSER */);
|
|
11627
12068
|
|
|
11628
|
-
export {
|
|
11629
|
-
//# sourceMappingURL=index-
|
|
12069
|
+
export { signInWithCredential as $, ActionCodeOperation as A, signOut as B, deleteUser as C, debugErrorMap as D, prodErrorMap as E, FactorId as F, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as G, initializeAuth as H, connectAuthEmulator as I, AuthCredential as J, EmailAuthCredential as K, OAuthCredential as L, PhoneAuthCredential as M, inMemoryPersistence as N, OperationType as O, PhoneAuthProvider as P, EmailAuthProvider as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, FacebookAuthProvider as U, GoogleAuthProvider as V, GithubAuthProvider as W, OAuthProvider as X, SAMLAuthProvider as Y, TwitterAuthProvider as Z, signInAnonymously as _, browserSessionPersistence as a, linkWithCredential as a0, reauthenticateWithCredential as a1, signInWithCustomToken as a2, sendPasswordResetEmail as a3, confirmPasswordReset as a4, applyActionCode as a5, checkActionCode as a6, verifyPasswordResetCode as a7, createUserWithEmailAndPassword as a8, signInWithEmailAndPassword as a9, _createError as aA, AuthEventManager as aB, _getInstance as aC, _persistenceKeyName as aD, _clearRedirectOutcomes as aE, _getRedirectResult as aF, _overrideRedirectResult as aG, _castAuth as aH, UserImpl as aI, AuthImpl as aJ, _getClientVersion as aK, _generateEventId as aL, AuthPopup as aM, FetchProvider as aN, SAMLAuthCredential as aO, sendSignInLinkToEmail as aa, isSignInWithEmailLink as ab, signInWithEmailLink as ac, fetchSignInMethodsForEmail as ad, sendEmailVerification as ae, verifyBeforeUpdateEmail as af, ActionCodeURL as ag, parseActionCodeURL as ah, updateProfile as ai, updateEmail as aj, updatePassword as ak, getIdToken as al, getIdTokenResult as am, unlink as an, getAdditionalUserInfo as ao, reload as ap, getMultiFactorResolver as aq, multiFactor as ar, _isIOS as as, _isAndroid as at, _fail as au, _getRedirectUrl as av, debugAssert as aw, _getProjectConfig as ax, _isIOS7Or8 as ay, _assert as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, initializeRecaptchaConfig as t, updatePhoneNumber as u, onIdTokenChanged as v, beforeAuthStateChanged as w, onAuthStateChanged as x, useDeviceLanguage as y, updateCurrentUser as z };
|
|
12070
|
+
//# sourceMappingURL=index-f764da84.js.map
|