@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,4 +1,4 @@
|
|
|
1
|
-
import { ErrorFactory,
|
|
1
|
+
import { ErrorFactory, isBrowserExtension, isMobileCordova, isReactNative, FirebaseError, querystring, getModularInstance, base64Decode, getUA, isIE, createSubscribe, deepEqual, querystringDecode, extractQuerystring, getDefaultEmulatorHost } from '@firebase/util';
|
|
2
2
|
import { SDK_VERSION, _getProvider, _registerComponent, registerVersion, getApp } from '@firebase/app';
|
|
3
3
|
import { __rest } from 'tslib';
|
|
4
4
|
import { Component } from '@firebase/component';
|
|
@@ -266,7 +266,15 @@ function _debugErrorMap() {
|
|
|
266
266
|
["already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */]: 'initializeAuth() has already been called with ' +
|
|
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
|
-
' already initialized instance.'
|
|
269
|
+
' already initialized instance.',
|
|
270
|
+
["missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */]: 'The reCAPTCHA token is missing when sending request to the backend.',
|
|
271
|
+
["invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */]: 'The reCAPTCHA token is invalid when sending request to the backend.',
|
|
272
|
+
["invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */]: 'The reCAPTCHA action is invalid when sending request to the backend.',
|
|
273
|
+
["recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */]: 'reCAPTCHA Enterprise integration is not enabled for this project.',
|
|
274
|
+
["missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */]: 'The reCAPTCHA client type is missing when sending request to the backend.',
|
|
275
|
+
["missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */]: 'The reCAPTCHA version is missing when sending request to the backend.',
|
|
276
|
+
["invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */]: 'Invalid request parameters.',
|
|
277
|
+
["invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */]: 'The reCAPTCHA version is invalid when sending request to the backend.'
|
|
270
278
|
};
|
|
271
279
|
}
|
|
272
280
|
function _prodErrorMap() {
|
|
@@ -402,7 +410,15 @@ const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
|
|
|
402
410
|
USER_SIGNED_OUT: 'auth/user-signed-out',
|
|
403
411
|
WEAK_PASSWORD: 'auth/weak-password',
|
|
404
412
|
WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
|
|
405
|
-
ALREADY_INITIALIZED: 'auth/already-initialized'
|
|
413
|
+
ALREADY_INITIALIZED: 'auth/already-initialized',
|
|
414
|
+
RECAPTCHA_NOT_ENABLED: 'auth/recaptcha-not-enabled',
|
|
415
|
+
MISSING_RECAPTCHA_TOKEN: 'auth/missing-recaptcha-token',
|
|
416
|
+
INVALID_RECAPTCHA_TOKEN: 'auth/invalid-recaptcha-token',
|
|
417
|
+
INVALID_RECAPTCHA_ACTION: 'auth/invalid-recaptcha-action',
|
|
418
|
+
MISSING_CLIENT_TYPE: 'auth/missing-client-type',
|
|
419
|
+
MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version',
|
|
420
|
+
INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version',
|
|
421
|
+
INVALID_REQ_TYPE: 'auth/invalid-req-type'
|
|
406
422
|
};
|
|
407
423
|
|
|
408
424
|
/**
|
|
@@ -507,103 +523,6 @@ function debugAssert(assertion, message) {
|
|
|
507
523
|
}
|
|
508
524
|
}
|
|
509
525
|
|
|
510
|
-
/**
|
|
511
|
-
* @license
|
|
512
|
-
* Copyright 2020 Google LLC
|
|
513
|
-
*
|
|
514
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
515
|
-
* you may not use this file except in compliance with the License.
|
|
516
|
-
* You may obtain a copy of the License at
|
|
517
|
-
*
|
|
518
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
519
|
-
*
|
|
520
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
521
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
522
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
523
|
-
* See the License for the specific language governing permissions and
|
|
524
|
-
* limitations under the License.
|
|
525
|
-
*/
|
|
526
|
-
const instanceCache = new Map();
|
|
527
|
-
function _getInstance(cls) {
|
|
528
|
-
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
529
|
-
let instance = instanceCache.get(cls);
|
|
530
|
-
if (instance) {
|
|
531
|
-
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
532
|
-
return instance;
|
|
533
|
-
}
|
|
534
|
-
instance = new cls();
|
|
535
|
-
instanceCache.set(cls, instance);
|
|
536
|
-
return instance;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* @license
|
|
541
|
-
* Copyright 2020 Google LLC
|
|
542
|
-
*
|
|
543
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
544
|
-
* you may not use this file except in compliance with the License.
|
|
545
|
-
* You may obtain a copy of the License at
|
|
546
|
-
*
|
|
547
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
548
|
-
*
|
|
549
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
550
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
551
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
552
|
-
* See the License for the specific language governing permissions and
|
|
553
|
-
* limitations under the License.
|
|
554
|
-
*/
|
|
555
|
-
/**
|
|
556
|
-
* Initializes an {@link Auth} instance with fine-grained control over
|
|
557
|
-
* {@link Dependencies}.
|
|
558
|
-
*
|
|
559
|
-
* @remarks
|
|
560
|
-
*
|
|
561
|
-
* This function allows more control over the {@link Auth} instance than
|
|
562
|
-
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
563
|
-
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
564
|
-
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
565
|
-
* need control over which persistence layer is used, or to minimize bundle
|
|
566
|
-
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
567
|
-
*
|
|
568
|
-
* For example, if your app only uses anonymous accounts and you only want
|
|
569
|
-
* accounts saved for the current session, initialize `Auth` with:
|
|
570
|
-
*
|
|
571
|
-
* ```js
|
|
572
|
-
* const auth = initializeAuth(app, {
|
|
573
|
-
* persistence: browserSessionPersistence,
|
|
574
|
-
* popupRedirectResolver: undefined,
|
|
575
|
-
* });
|
|
576
|
-
* ```
|
|
577
|
-
*
|
|
578
|
-
* @public
|
|
579
|
-
*/
|
|
580
|
-
function initializeAuth(app, deps) {
|
|
581
|
-
const provider = _getProvider(app, 'auth');
|
|
582
|
-
if (provider.isInitialized()) {
|
|
583
|
-
const auth = provider.getImmediate();
|
|
584
|
-
const initialOptions = provider.getOptions();
|
|
585
|
-
if (deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
586
|
-
return auth;
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
_fail(auth, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
const auth = provider.initialize({ options: deps });
|
|
593
|
-
return auth;
|
|
594
|
-
}
|
|
595
|
-
function _initializeAuthInstance(auth, deps) {
|
|
596
|
-
const persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
597
|
-
const hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
598
|
-
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
599
|
-
auth._updateErrorMap(deps.errorMap);
|
|
600
|
-
}
|
|
601
|
-
// This promise is intended to float; auth initialization happens in the
|
|
602
|
-
// background, meanwhile the auth object may be used by the app.
|
|
603
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
604
|
-
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
526
|
/**
|
|
608
527
|
* @license
|
|
609
528
|
* Copyright 2020 Google LLC
|
|
@@ -882,7 +801,16 @@ const SERVER_ERROR_MAP = {
|
|
|
882
801
|
["SECOND_FACTOR_EXISTS" /* ServerError.SECOND_FACTOR_EXISTS */]: "second-factor-already-in-use" /* AuthErrorCode.SECOND_FACTOR_ALREADY_ENROLLED */,
|
|
883
802
|
["SECOND_FACTOR_LIMIT_EXCEEDED" /* ServerError.SECOND_FACTOR_LIMIT_EXCEEDED */]: "maximum-second-factor-count-exceeded" /* AuthErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED */,
|
|
884
803
|
// Blocking functions related errors.
|
|
885
|
-
["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */]: "internal-error" /* AuthErrorCode.INTERNAL_ERROR
|
|
804
|
+
["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */]: "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
|
|
805
|
+
// Recaptcha related errors.
|
|
806
|
+
["RECAPTCHA_NOT_ENABLED" /* ServerError.RECAPTCHA_NOT_ENABLED */]: "recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */,
|
|
807
|
+
["MISSING_RECAPTCHA_TOKEN" /* ServerError.MISSING_RECAPTCHA_TOKEN */]: "missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */,
|
|
808
|
+
["INVALID_RECAPTCHA_TOKEN" /* ServerError.INVALID_RECAPTCHA_TOKEN */]: "invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */,
|
|
809
|
+
["INVALID_RECAPTCHA_ACTION" /* ServerError.INVALID_RECAPTCHA_ACTION */]: "invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */,
|
|
810
|
+
["MISSING_CLIENT_TYPE" /* ServerError.MISSING_CLIENT_TYPE */]: "missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */,
|
|
811
|
+
["MISSING_RECAPTCHA_VERSION" /* ServerError.MISSING_RECAPTCHA_VERSION */]: "missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */,
|
|
812
|
+
["INVALID_RECAPTCHA_VERSION" /* ServerError.INVALID_RECAPTCHA_VERSION */]: "invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */,
|
|
813
|
+
["INVALID_REQ_TYPE" /* ServerError.INVALID_REQ_TYPE */]: "invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */
|
|
886
814
|
};
|
|
887
815
|
|
|
888
816
|
/**
|
|
@@ -1784,6 +1712,35 @@ class UserImpl {
|
|
|
1784
1712
|
}
|
|
1785
1713
|
}
|
|
1786
1714
|
|
|
1715
|
+
/**
|
|
1716
|
+
* @license
|
|
1717
|
+
* Copyright 2020 Google LLC
|
|
1718
|
+
*
|
|
1719
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1720
|
+
* you may not use this file except in compliance with the License.
|
|
1721
|
+
* You may obtain a copy of the License at
|
|
1722
|
+
*
|
|
1723
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1724
|
+
*
|
|
1725
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1726
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1727
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1728
|
+
* See the License for the specific language governing permissions and
|
|
1729
|
+
* limitations under the License.
|
|
1730
|
+
*/
|
|
1731
|
+
const instanceCache = new Map();
|
|
1732
|
+
function _getInstance(cls) {
|
|
1733
|
+
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
1734
|
+
let instance = instanceCache.get(cls);
|
|
1735
|
+
if (instance) {
|
|
1736
|
+
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
1737
|
+
return instance;
|
|
1738
|
+
}
|
|
1739
|
+
instance = new cls();
|
|
1740
|
+
instanceCache.set(cls, instance);
|
|
1741
|
+
return instance;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1787
1744
|
/**
|
|
1788
1745
|
* @license
|
|
1789
1746
|
* Copyright 2019 Google LLC
|
|
@@ -2121,6 +2078,232 @@ function _getClientVersion(clientPlatform, frameworks = []) {
|
|
|
2121
2078
|
return `${reportedPlatform}/${"JsCore" /* ClientImplementation.CORE */}/${SDK_VERSION}/${reportedFrameworks}`;
|
|
2122
2079
|
}
|
|
2123
2080
|
|
|
2081
|
+
/**
|
|
2082
|
+
* @license
|
|
2083
|
+
* Copyright 2020 Google LLC
|
|
2084
|
+
*
|
|
2085
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2086
|
+
* you may not use this file except in compliance with the License.
|
|
2087
|
+
* You may obtain a copy of the License at
|
|
2088
|
+
*
|
|
2089
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2090
|
+
*
|
|
2091
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2092
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2093
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2094
|
+
* See the License for the specific language governing permissions and
|
|
2095
|
+
* limitations under the License.
|
|
2096
|
+
*/
|
|
2097
|
+
async function getRecaptchaConfig(auth, request) {
|
|
2098
|
+
return _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request));
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
/**
|
|
2102
|
+
* @license
|
|
2103
|
+
* Copyright 2020 Google LLC
|
|
2104
|
+
*
|
|
2105
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2106
|
+
* you may not use this file except in compliance with the License.
|
|
2107
|
+
* You may obtain a copy of the License at
|
|
2108
|
+
*
|
|
2109
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2110
|
+
*
|
|
2111
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2112
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2113
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2114
|
+
* See the License for the specific language governing permissions and
|
|
2115
|
+
* limitations under the License.
|
|
2116
|
+
*/
|
|
2117
|
+
function isEnterprise(grecaptcha) {
|
|
2118
|
+
return (grecaptcha !== undefined &&
|
|
2119
|
+
grecaptcha.enterprise !== undefined);
|
|
2120
|
+
}
|
|
2121
|
+
class RecaptchaConfig {
|
|
2122
|
+
constructor(response) {
|
|
2123
|
+
/**
|
|
2124
|
+
* The reCAPTCHA site key.
|
|
2125
|
+
*/
|
|
2126
|
+
this.siteKey = '';
|
|
2127
|
+
/**
|
|
2128
|
+
* The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
|
|
2129
|
+
*/
|
|
2130
|
+
this.emailPasswordEnabled = false;
|
|
2131
|
+
if (response.recaptchaKey === undefined) {
|
|
2132
|
+
throw new Error('recaptchaKey undefined');
|
|
2133
|
+
}
|
|
2134
|
+
// Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
|
|
2135
|
+
this.siteKey = response.recaptchaKey.split('/')[3];
|
|
2136
|
+
this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
|
|
2137
|
+
enforcementState.enforcementState !== 'OFF');
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* @license
|
|
2143
|
+
* Copyright 2020 Google LLC
|
|
2144
|
+
*
|
|
2145
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2146
|
+
* you may not use this file except in compliance with the License.
|
|
2147
|
+
* You may obtain a copy of the License at
|
|
2148
|
+
*
|
|
2149
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2150
|
+
*
|
|
2151
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2152
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2153
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2154
|
+
* See the License for the specific language governing permissions and
|
|
2155
|
+
* limitations under the License.
|
|
2156
|
+
*/
|
|
2157
|
+
function getScriptParentElement() {
|
|
2158
|
+
var _a, _b;
|
|
2159
|
+
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
2160
|
+
}
|
|
2161
|
+
function _loadJS(url) {
|
|
2162
|
+
// TODO: consider adding timeout support & cancellation
|
|
2163
|
+
return new Promise((resolve, reject) => {
|
|
2164
|
+
const el = document.createElement('script');
|
|
2165
|
+
el.setAttribute('src', url);
|
|
2166
|
+
el.onload = resolve;
|
|
2167
|
+
el.onerror = e => {
|
|
2168
|
+
const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
2169
|
+
error.customData = e;
|
|
2170
|
+
reject(error);
|
|
2171
|
+
};
|
|
2172
|
+
el.type = 'text/javascript';
|
|
2173
|
+
el.charset = 'UTF-8';
|
|
2174
|
+
getScriptParentElement().appendChild(el);
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2179
|
+
const RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
|
|
2180
|
+
const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
|
|
2181
|
+
class RecaptchaEnterpriseVerifier {
|
|
2182
|
+
/**
|
|
2183
|
+
*
|
|
2184
|
+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
2185
|
+
*
|
|
2186
|
+
*/
|
|
2187
|
+
constructor(authExtern) {
|
|
2188
|
+
/**
|
|
2189
|
+
* Identifies the type of application verifier (e.g. "recaptcha-enterprise").
|
|
2190
|
+
*/
|
|
2191
|
+
this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
|
|
2192
|
+
this.auth = _castAuth(authExtern);
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Executes the verification process.
|
|
2196
|
+
*
|
|
2197
|
+
* @returns A Promise for a token that can be used to assert the validity of a request.
|
|
2198
|
+
*/
|
|
2199
|
+
async verify(action = 'verify', forceRefresh = false) {
|
|
2200
|
+
async function retrieveSiteKey(auth) {
|
|
2201
|
+
if (!forceRefresh) {
|
|
2202
|
+
if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
|
|
2203
|
+
return auth._agentRecaptchaConfig.siteKey;
|
|
2204
|
+
}
|
|
2205
|
+
if (auth.tenantId != null &&
|
|
2206
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
|
|
2207
|
+
return auth._tenantRecaptchaConfigs[auth.tenantId].siteKey;
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
return new Promise(async (resolve, reject) => {
|
|
2211
|
+
getRecaptchaConfig(auth, {
|
|
2212
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2213
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2214
|
+
})
|
|
2215
|
+
.then(response => {
|
|
2216
|
+
if (response.recaptchaKey === undefined) {
|
|
2217
|
+
reject(new Error('recaptcha Enterprise site key undefined'));
|
|
2218
|
+
}
|
|
2219
|
+
else {
|
|
2220
|
+
const config = new RecaptchaConfig(response);
|
|
2221
|
+
if (auth.tenantId == null) {
|
|
2222
|
+
auth._agentRecaptchaConfig = config;
|
|
2223
|
+
}
|
|
2224
|
+
else {
|
|
2225
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] = config;
|
|
2226
|
+
}
|
|
2227
|
+
return resolve(config.siteKey);
|
|
2228
|
+
}
|
|
2229
|
+
})
|
|
2230
|
+
.catch(error => {
|
|
2231
|
+
reject(error);
|
|
2232
|
+
});
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
function retrieveRecaptchaToken(siteKey, resolve, reject) {
|
|
2236
|
+
const grecaptcha = window.grecaptcha;
|
|
2237
|
+
if (isEnterprise(grecaptcha)) {
|
|
2238
|
+
grecaptcha.enterprise.ready(() => {
|
|
2239
|
+
try {
|
|
2240
|
+
grecaptcha.enterprise
|
|
2241
|
+
.execute(siteKey, { action })
|
|
2242
|
+
.then(token => {
|
|
2243
|
+
resolve(token);
|
|
2244
|
+
})
|
|
2245
|
+
.catch(error => {
|
|
2246
|
+
reject(error);
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2249
|
+
catch (error) {
|
|
2250
|
+
reject(error);
|
|
2251
|
+
}
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
else {
|
|
2255
|
+
reject(Error('No reCAPTCHA enterprise script loaded.'));
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
return new Promise((resolve, reject) => {
|
|
2259
|
+
retrieveSiteKey(this.auth)
|
|
2260
|
+
.then(siteKey => {
|
|
2261
|
+
if (!forceRefresh && isEnterprise(window.grecaptcha)) {
|
|
2262
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2263
|
+
}
|
|
2264
|
+
else {
|
|
2265
|
+
if (typeof window === 'undefined') {
|
|
2266
|
+
reject(new Error('RecaptchaVerifier is only supported in browser'));
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
_loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
|
|
2270
|
+
.then(() => {
|
|
2271
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2272
|
+
})
|
|
2273
|
+
.catch(error => {
|
|
2274
|
+
reject(error);
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
})
|
|
2278
|
+
.catch(error => {
|
|
2279
|
+
reject(error);
|
|
2280
|
+
});
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
async function injectRecaptchaFields(auth, request, action, captchaResp = false) {
|
|
2285
|
+
const verifier = new RecaptchaEnterpriseVerifier(auth);
|
|
2286
|
+
let captchaResponse;
|
|
2287
|
+
try {
|
|
2288
|
+
captchaResponse = await verifier.verify(action);
|
|
2289
|
+
}
|
|
2290
|
+
catch (error) {
|
|
2291
|
+
captchaResponse = await verifier.verify(action, true);
|
|
2292
|
+
}
|
|
2293
|
+
const newRequest = Object.assign({}, request);
|
|
2294
|
+
if (!captchaResp) {
|
|
2295
|
+
Object.assign(newRequest, { captchaResponse });
|
|
2296
|
+
}
|
|
2297
|
+
else {
|
|
2298
|
+
Object.assign(newRequest, { 'captchaResp': captchaResponse });
|
|
2299
|
+
}
|
|
2300
|
+
Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
|
|
2301
|
+
Object.assign(newRequest, {
|
|
2302
|
+
'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2303
|
+
});
|
|
2304
|
+
return newRequest;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2124
2307
|
/**
|
|
2125
2308
|
* @license
|
|
2126
2309
|
* Copyright 2022 Google LLC
|
|
@@ -2240,6 +2423,8 @@ class AuthImpl {
|
|
|
2240
2423
|
this._initializationPromise = null;
|
|
2241
2424
|
this._popupRedirectResolver = null;
|
|
2242
2425
|
this._errorFactory = _DEFAULT_AUTH_ERROR_FACTORY;
|
|
2426
|
+
this._agentRecaptchaConfig = null;
|
|
2427
|
+
this._tenantRecaptchaConfigs = {};
|
|
2243
2428
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2244
2429
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2245
2430
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2459,6 +2644,31 @@ class AuthImpl {
|
|
|
2459
2644
|
await this.assertedPersistence.setPersistence(_getInstance(persistence));
|
|
2460
2645
|
});
|
|
2461
2646
|
}
|
|
2647
|
+
async initializeRecaptchaConfig() {
|
|
2648
|
+
const response = await getRecaptchaConfig(this, {
|
|
2649
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2650
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2651
|
+
});
|
|
2652
|
+
const config = new RecaptchaConfig(response);
|
|
2653
|
+
if (this.tenantId == null) {
|
|
2654
|
+
this._agentRecaptchaConfig = config;
|
|
2655
|
+
}
|
|
2656
|
+
else {
|
|
2657
|
+
this._tenantRecaptchaConfigs[this.tenantId] = config;
|
|
2658
|
+
}
|
|
2659
|
+
if (config.emailPasswordEnabled) {
|
|
2660
|
+
const verifier = new RecaptchaEnterpriseVerifier(this);
|
|
2661
|
+
void verifier.verify();
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
_getRecaptchaConfig() {
|
|
2665
|
+
if (this.tenantId == null) {
|
|
2666
|
+
return this._agentRecaptchaConfig;
|
|
2667
|
+
}
|
|
2668
|
+
else {
|
|
2669
|
+
return this._tenantRecaptchaConfigs[this.tenantId];
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2462
2672
|
_getPersistence() {
|
|
2463
2673
|
return this.assertedPersistence.persistence.type;
|
|
2464
2674
|
}
|
|
@@ -2681,6 +2891,74 @@ class Subscription {
|
|
|
2681
2891
|
}
|
|
2682
2892
|
}
|
|
2683
2893
|
|
|
2894
|
+
/**
|
|
2895
|
+
* @license
|
|
2896
|
+
* Copyright 2020 Google LLC
|
|
2897
|
+
*
|
|
2898
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2899
|
+
* you may not use this file except in compliance with the License.
|
|
2900
|
+
* You may obtain a copy of the License at
|
|
2901
|
+
*
|
|
2902
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2903
|
+
*
|
|
2904
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2905
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2906
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2907
|
+
* See the License for the specific language governing permissions and
|
|
2908
|
+
* limitations under the License.
|
|
2909
|
+
*/
|
|
2910
|
+
/**
|
|
2911
|
+
* Initializes an {@link Auth} instance with fine-grained control over
|
|
2912
|
+
* {@link Dependencies}.
|
|
2913
|
+
*
|
|
2914
|
+
* @remarks
|
|
2915
|
+
*
|
|
2916
|
+
* This function allows more control over the {@link Auth} instance than
|
|
2917
|
+
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
2918
|
+
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
2919
|
+
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
2920
|
+
* need control over which persistence layer is used, or to minimize bundle
|
|
2921
|
+
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
2922
|
+
*
|
|
2923
|
+
* For example, if your app only uses anonymous accounts and you only want
|
|
2924
|
+
* accounts saved for the current session, initialize `Auth` with:
|
|
2925
|
+
*
|
|
2926
|
+
* ```js
|
|
2927
|
+
* const auth = initializeAuth(app, {
|
|
2928
|
+
* persistence: browserSessionPersistence,
|
|
2929
|
+
* popupRedirectResolver: undefined,
|
|
2930
|
+
* });
|
|
2931
|
+
* ```
|
|
2932
|
+
*
|
|
2933
|
+
* @public
|
|
2934
|
+
*/
|
|
2935
|
+
function initializeAuth(app, deps) {
|
|
2936
|
+
const provider = _getProvider(app, 'auth');
|
|
2937
|
+
if (provider.isInitialized()) {
|
|
2938
|
+
const auth = provider.getImmediate();
|
|
2939
|
+
const initialOptions = provider.getOptions();
|
|
2940
|
+
if (deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
2941
|
+
return auth;
|
|
2942
|
+
}
|
|
2943
|
+
else {
|
|
2944
|
+
_fail(auth, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
const auth = provider.initialize({ options: deps });
|
|
2948
|
+
return auth;
|
|
2949
|
+
}
|
|
2950
|
+
function _initializeAuthInstance(auth, deps) {
|
|
2951
|
+
const persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
2952
|
+
const hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
2953
|
+
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
2954
|
+
auth._updateErrorMap(deps.errorMap);
|
|
2955
|
+
}
|
|
2956
|
+
// This promise is intended to float; auth initialization happens in the
|
|
2957
|
+
// background, meanwhile the auth object may be used by the app.
|
|
2958
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2959
|
+
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2684
2962
|
/**
|
|
2685
2963
|
* Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
|
|
2686
2964
|
* Firebase Auth services.
|
|
@@ -3020,13 +3298,31 @@ class EmailAuthCredential extends AuthCredential {
|
|
|
3020
3298
|
}
|
|
3021
3299
|
/** @internal */
|
|
3022
3300
|
async _getIdTokenResponse(auth) {
|
|
3301
|
+
var _a;
|
|
3023
3302
|
switch (this.signInMethod) {
|
|
3024
3303
|
case "password" /* SignInMethod.EMAIL_PASSWORD */:
|
|
3025
|
-
|
|
3304
|
+
const request = {
|
|
3026
3305
|
returnSecureToken: true,
|
|
3027
3306
|
email: this._email,
|
|
3028
|
-
password: this._password
|
|
3029
|
-
|
|
3307
|
+
password: this._password,
|
|
3308
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
3309
|
+
};
|
|
3310
|
+
if ((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
3311
|
+
const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
|
|
3312
|
+
return signInWithPassword(auth, requestWithRecaptcha);
|
|
3313
|
+
}
|
|
3314
|
+
else {
|
|
3315
|
+
return signInWithPassword(auth, request).catch(async (error) => {
|
|
3316
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
3317
|
+
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.');
|
|
3318
|
+
const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
|
|
3319
|
+
return signInWithPassword(auth, requestWithRecaptcha);
|
|
3320
|
+
}
|
|
3321
|
+
else {
|
|
3322
|
+
return Promise.reject(error);
|
|
3323
|
+
}
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3030
3326
|
case "emailLink" /* SignInMethod.EMAIL_LINK */:
|
|
3031
3327
|
return signInWithEmailLink$1(auth, {
|
|
3032
3328
|
email: this._email,
|
|
@@ -4982,15 +5278,39 @@ function _setActionCodeSettingsOnRequest(auth, request, actionCodeSettings) {
|
|
|
4982
5278
|
* @public
|
|
4983
5279
|
*/
|
|
4984
5280
|
async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
|
|
4985
|
-
|
|
5281
|
+
var _a;
|
|
5282
|
+
const authInternal = _castAuth(auth);
|
|
4986
5283
|
const request = {
|
|
4987
5284
|
requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
|
|
4988
|
-
email
|
|
5285
|
+
email,
|
|
5286
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
4989
5287
|
};
|
|
4990
|
-
if (
|
|
4991
|
-
|
|
5288
|
+
if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
5289
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5290
|
+
if (actionCodeSettings) {
|
|
5291
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
5292
|
+
}
|
|
5293
|
+
await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
|
|
5294
|
+
}
|
|
5295
|
+
else {
|
|
5296
|
+
if (actionCodeSettings) {
|
|
5297
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
5298
|
+
}
|
|
5299
|
+
await sendPasswordResetEmail$1(authInternal, request)
|
|
5300
|
+
.catch(async (error) => {
|
|
5301
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
5302
|
+
console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
|
|
5303
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5304
|
+
if (actionCodeSettings) {
|
|
5305
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
5306
|
+
}
|
|
5307
|
+
await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
|
|
5308
|
+
}
|
|
5309
|
+
else {
|
|
5310
|
+
return Promise.reject(error);
|
|
5311
|
+
}
|
|
5312
|
+
});
|
|
4992
5313
|
}
|
|
4993
|
-
await sendPasswordResetEmail$1(authModular, request);
|
|
4994
5314
|
}
|
|
4995
5315
|
/**
|
|
4996
5316
|
* Completes the password reset process, given a confirmation code and new password.
|
|
@@ -5103,11 +5423,33 @@ async function verifyPasswordResetCode(auth, code) {
|
|
|
5103
5423
|
* @public
|
|
5104
5424
|
*/
|
|
5105
5425
|
async function createUserWithEmailAndPassword(auth, email, password) {
|
|
5426
|
+
var _a;
|
|
5106
5427
|
const authInternal = _castAuth(auth);
|
|
5107
|
-
const
|
|
5428
|
+
const request = {
|
|
5108
5429
|
returnSecureToken: true,
|
|
5109
5430
|
email,
|
|
5110
|
-
password
|
|
5431
|
+
password,
|
|
5432
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
5433
|
+
};
|
|
5434
|
+
let signUpResponse;
|
|
5435
|
+
if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
5436
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
|
|
5437
|
+
signUpResponse = signUp(authInternal, requestWithRecaptcha);
|
|
5438
|
+
}
|
|
5439
|
+
else {
|
|
5440
|
+
signUpResponse = signUp(authInternal, request).catch(async (error) => {
|
|
5441
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
5442
|
+
console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
|
|
5443
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
|
|
5444
|
+
return signUp(authInternal, requestWithRecaptcha);
|
|
5445
|
+
}
|
|
5446
|
+
else {
|
|
5447
|
+
return Promise.reject(error);
|
|
5448
|
+
}
|
|
5449
|
+
});
|
|
5450
|
+
}
|
|
5451
|
+
const response = await signUpResponse.catch(error => {
|
|
5452
|
+
return Promise.reject(error);
|
|
5111
5453
|
});
|
|
5112
5454
|
const userCredential = await UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response);
|
|
5113
5455
|
await authInternal._updateCurrentUser(userCredential.user);
|
|
@@ -5188,16 +5530,39 @@ function signInWithEmailAndPassword(auth, email, password) {
|
|
|
5188
5530
|
* @public
|
|
5189
5531
|
*/
|
|
5190
5532
|
async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
|
|
5191
|
-
|
|
5533
|
+
var _a;
|
|
5534
|
+
const authInternal = _castAuth(auth);
|
|
5192
5535
|
const request = {
|
|
5193
5536
|
requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
|
|
5194
|
-
email
|
|
5537
|
+
email,
|
|
5538
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
5195
5539
|
};
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5540
|
+
function setActionCodeSettings(request, actionCodeSettings) {
|
|
5541
|
+
_assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
5542
|
+
if (actionCodeSettings) {
|
|
5543
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
5547
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5548
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
5549
|
+
await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
|
|
5550
|
+
}
|
|
5551
|
+
else {
|
|
5552
|
+
setActionCodeSettings(request, actionCodeSettings);
|
|
5553
|
+
await sendSignInLinkToEmail$1(authInternal, request)
|
|
5554
|
+
.catch(async (error) => {
|
|
5555
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
5556
|
+
console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
|
|
5557
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5558
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
5559
|
+
await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
|
|
5560
|
+
}
|
|
5561
|
+
else {
|
|
5562
|
+
return Promise.reject(error);
|
|
5563
|
+
}
|
|
5564
|
+
});
|
|
5199
5565
|
}
|
|
5200
|
-
await sendSignInLinkToEmail$1(authModular, request);
|
|
5201
5566
|
}
|
|
5202
5567
|
/**
|
|
5203
5568
|
* Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
|
|
@@ -5692,6 +6057,35 @@ function getAdditionalUserInfo(userCredential) {
|
|
|
5692
6057
|
function setPersistence(auth, persistence) {
|
|
5693
6058
|
return getModularInstance(auth).setPersistence(persistence);
|
|
5694
6059
|
}
|
|
6060
|
+
/**
|
|
6061
|
+
* Loads the reCAPTCHA configuration into the `Auth` instance.
|
|
6062
|
+
*
|
|
6063
|
+
* @remarks
|
|
6064
|
+
* This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
|
|
6065
|
+
* verification flow should be triggered for each auth provider, into the
|
|
6066
|
+
* current Auth session.
|
|
6067
|
+
*
|
|
6068
|
+
* If initializeRecaptchaConfig() is not invoked, the auth flow will always start
|
|
6069
|
+
* without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
|
|
6070
|
+
* verification, the SDK will transparently load the reCAPTCHA config and restart the
|
|
6071
|
+
* auth flows.
|
|
6072
|
+
*
|
|
6073
|
+
* Thus, by calling this optional method, you will reduce the latency of future auth flows.
|
|
6074
|
+
* Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
|
|
6075
|
+
*
|
|
6076
|
+
* @example
|
|
6077
|
+
* ```javascript
|
|
6078
|
+
* initializeRecaptchaConfig(auth);
|
|
6079
|
+
* ```
|
|
6080
|
+
*
|
|
6081
|
+
* @param auth - The {@link Auth} instance.
|
|
6082
|
+
*
|
|
6083
|
+
* @public
|
|
6084
|
+
*/
|
|
6085
|
+
function initializeRecaptchaConfig(auth) {
|
|
6086
|
+
const authInternal = _castAuth(auth);
|
|
6087
|
+
return authInternal.initializeRecaptchaConfig();
|
|
6088
|
+
}
|
|
5695
6089
|
/**
|
|
5696
6090
|
* Adds an observer for changes to the signed-in user's ID token.
|
|
5697
6091
|
*
|
|
@@ -6005,7 +6399,7 @@ function multiFactor(user) {
|
|
|
6005
6399
|
}
|
|
6006
6400
|
|
|
6007
6401
|
var name = "@firebase/auth";
|
|
6008
|
-
var version = "0.22.0-canary.
|
|
6402
|
+
var version = "0.22.0-canary.ecb4454c3";
|
|
6009
6403
|
|
|
6010
6404
|
/**
|
|
6011
6405
|
* @license
|
|
@@ -6417,5 +6811,5 @@ function _isEmptyString(input) {
|
|
|
6417
6811
|
return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
|
|
6418
6812
|
}
|
|
6419
6813
|
|
|
6420
|
-
export {
|
|
6421
|
-
//# sourceMappingURL=totp-
|
|
6814
|
+
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, _persistenceKeyName as aA, _castAuth as aB, FederatedAuthProvider as aC, BaseOAuthProvider as aD, _emulatorUrl as aE, _performApiRequest as aF, _isIOS as aG, _isAndroid as aH, _isIOS7Or8 as aI, _createError as aJ, _isIframe as aK, _isMobileBrowser as aL, _isIE10 as aM, _isSafari as aN, UserImpl as aO, AuthImpl as aP, _getClientVersion as aQ, FetchProvider as aR, SAMLAuthCredential as aS, 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, _getInstance as as, _assert as at, _signInWithCredential as au, _reauthenticate as av, _link as aw, signInWithIdp as ax, _fail as ay, debugAssert 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 };
|
|
6815
|
+
//# sourceMappingURL=totp-501673f0.js.map
|