@firebase/auth 0.22.0 → 0.23.0-canary.0a27d2fbf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/auth-public.d.ts +57 -0
- package/dist/auth.d.ts +71 -1
- package/dist/browser-cjs/{index-5859881d.js → index-5df83e84.js} +590 -207
- package/dist/browser-cjs/index-5df83e84.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 +17 -2
- package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +9 -1
- 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/core/util/handler.d.ts +1 -1
- package/dist/browser-cjs/src/core/util/log.d.ts +1 -0
- package/dist/browser-cjs/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/browser-cjs/test/helpers/api/helper.d.ts +2 -0
- package/dist/browser-cjs/test/helpers/mock_auth.d.ts +5 -0
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal.js +21 -77
- package/dist/cordova/internal.js.map +1 -1
- package/dist/cordova/{popup_redirect-3519667a.js → popup_redirect-b3f8e40c.js} +778 -214
- package/dist/cordova/popup_redirect-b3f8e40c.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 +17 -2
- package/dist/cordova/src/core/auth/auth_impl.d.ts +9 -1
- package/dist/cordova/src/core/errors.d.ts +17 -1
- package/dist/cordova/src/core/index.d.ts +26 -0
- package/dist/cordova/src/core/util/handler.d.ts +1 -1
- package/dist/cordova/src/core/util/log.d.ts +1 -0
- package/dist/cordova/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/cordova/test/helpers/api/helper.d.ts +2 -0
- package/dist/cordova/test/helpers/mock_auth.d.ts +5 -0
- package/dist/esm2017/{index-680e2b70.js → index-6cb4f120.js} +591 -209
- package/dist/esm2017/index-6cb4f120.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 +17 -2
- package/dist/esm2017/src/core/auth/auth_impl.d.ts +9 -1
- package/dist/esm2017/src/core/errors.d.ts +17 -1
- package/dist/esm2017/src/core/index.d.ts +26 -0
- package/dist/esm2017/src/core/util/handler.d.ts +1 -1
- package/dist/esm2017/src/core/util/log.d.ts +1 -0
- package/dist/esm2017/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/esm2017/test/helpers/api/helper.d.ts +2 -0
- package/dist/esm2017/test/helpers/mock_auth.d.ts +5 -0
- package/dist/esm5/{index-714e827f.js → index-4dc6213a.js} +797 -289
- package/dist/esm5/index-4dc6213a.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 +17 -2
- package/dist/esm5/src/core/auth/auth_impl.d.ts +9 -1
- package/dist/esm5/src/core/errors.d.ts +17 -1
- package/dist/esm5/src/core/index.d.ts +26 -0
- package/dist/esm5/src/core/util/handler.d.ts +1 -1
- package/dist/esm5/src/core/util/log.d.ts +1 -0
- package/dist/esm5/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/esm5/test/helpers/api/helper.d.ts +2 -0
- package/dist/esm5/test/helpers/mock_auth.d.ts +5 -0
- package/dist/index.webworker.esm5.js +602 -74
- 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 +62 -42
- 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 +17 -2
- package/dist/node/src/core/auth/auth_impl.d.ts +9 -1
- package/dist/node/src/core/errors.d.ts +17 -1
- package/dist/node/src/core/index.d.ts +26 -0
- package/dist/node/src/core/util/handler.d.ts +1 -1
- package/dist/node/src/core/util/log.d.ts +1 -0
- package/dist/node/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/node/test/helpers/api/helper.d.ts +2 -0
- package/dist/node/test/helpers/mock_auth.d.ts +5 -0
- package/dist/node/{totp-416a2adc.js → totp-c1b55906.js} +700 -171
- package/dist/node/totp-c1b55906.js.map +1 -0
- package/dist/node-esm/index.js +1 -1
- package/dist/node-esm/internal.js +16 -4
- package/dist/node-esm/internal.js.map +1 -1
- 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 +17 -2
- package/dist/node-esm/src/core/auth/auth_impl.d.ts +9 -1
- 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/core/util/handler.d.ts +1 -1
- package/dist/node-esm/src/core/util/log.d.ts +1 -0
- package/dist/node-esm/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/node-esm/test/helpers/api/helper.d.ts +2 -0
- package/dist/node-esm/test/helpers/mock_auth.d.ts +5 -0
- package/dist/node-esm/{totp-c3bf2a20.js → totp-5cad7b9f.js} +557 -140
- package/dist/node-esm/totp-5cad7b9f.js.map +1 -0
- package/dist/rn/index.js +2 -1
- package/dist/rn/index.js.map +1 -1
- package/dist/rn/internal.js +79 -48
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/{phone-2ec1815d.js → phone-5059d9ba.js} +738 -259
- package/dist/rn/phone-5059d9ba.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 +17 -2
- package/dist/rn/src/core/auth/auth_impl.d.ts +9 -1
- package/dist/rn/src/core/errors.d.ts +17 -1
- package/dist/rn/src/core/index.d.ts +26 -0
- package/dist/rn/src/core/util/handler.d.ts +1 -1
- package/dist/rn/src/core/util/log.d.ts +1 -0
- package/dist/rn/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/rn/test/helpers/api/helper.d.ts +2 -0
- package/dist/rn/test/helpers/mock_auth.d.ts +5 -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 +17 -2
- package/dist/src/core/auth/auth_impl.d.ts +9 -1
- package/dist/src/core/errors.d.ts +17 -1
- package/dist/src/core/index.d.ts +26 -0
- package/dist/src/core/util/handler.d.ts +1 -1
- package/dist/src/core/util/log.d.ts +1 -0
- package/dist/src/model/auth.d.ts +6 -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/src/platform_browser/strategies/popup.d.ts +1 -1
- package/dist/test/helpers/api/helper.d.ts +2 -0
- package/dist/test/helpers/mock_auth.d.ts +5 -0
- package/package.json +6 -6
- package/dist/browser-cjs/index-5859881d.js.map +0 -1
- package/dist/cordova/popup_redirect-3519667a.js.map +0 -1
- package/dist/esm2017/index-680e2b70.js.map +0 -1
- package/dist/esm5/index-714e827f.js.map +0 -1
- package/dist/node/totp-416a2adc.js.map +0 -1
- package/dist/node-esm/totp-c3bf2a20.js.map +0 -1
- package/dist/rn/phone-2ec1815d.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ErrorFactory,
|
|
1
|
+
import { ErrorFactory, isBrowserExtension, isMobileCordova, isReactNative, FirebaseError, querystring, getModularInstance, base64Decode, getUA, isIE, createSubscribe, deepEqual, querystringDecode, extractQuerystring, isEmpty, getExperimentalSetting, getDefaultEmulatorHost } from '@firebase/util';
|
|
2
2
|
import { SDK_VERSION, _getProvider, _registerComponent, registerVersion, getApp } from '@firebase/app';
|
|
3
|
-
import { Logger, LogLevel } from '@firebase/logger';
|
|
4
3
|
import { __rest } from 'tslib';
|
|
4
|
+
import { Logger, LogLevel } from '@firebase/logger';
|
|
5
5
|
import { Component } from '@firebase/component';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -265,7 +265,15 @@ function _debugErrorMap() {
|
|
|
265
265
|
["already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */]: 'initializeAuth() has already been called with ' +
|
|
266
266
|
'different options. To avoid this error, call initializeAuth() with the ' +
|
|
267
267
|
'same options as when it was originally called, or call getAuth() to return the' +
|
|
268
|
-
' already initialized instance.'
|
|
268
|
+
' already initialized instance.',
|
|
269
|
+
["missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */]: 'The reCAPTCHA token is missing when sending request to the backend.',
|
|
270
|
+
["invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */]: 'The reCAPTCHA token is invalid when sending request to the backend.',
|
|
271
|
+
["invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */]: 'The reCAPTCHA action is invalid when sending request to the backend.',
|
|
272
|
+
["recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */]: 'reCAPTCHA Enterprise integration is not enabled for this project.',
|
|
273
|
+
["missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */]: 'The reCAPTCHA client type is missing when sending request to the backend.',
|
|
274
|
+
["missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */]: 'The reCAPTCHA version is missing when sending request to the backend.',
|
|
275
|
+
["invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */]: 'Invalid request parameters.',
|
|
276
|
+
["invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */]: 'The reCAPTCHA version is invalid when sending request to the backend.'
|
|
269
277
|
};
|
|
270
278
|
}
|
|
271
279
|
function _prodErrorMap() {
|
|
@@ -401,7 +409,15 @@ const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
|
|
|
401
409
|
USER_SIGNED_OUT: 'auth/user-signed-out',
|
|
402
410
|
WEAK_PASSWORD: 'auth/weak-password',
|
|
403
411
|
WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
|
|
404
|
-
ALREADY_INITIALIZED: 'auth/already-initialized'
|
|
412
|
+
ALREADY_INITIALIZED: 'auth/already-initialized',
|
|
413
|
+
RECAPTCHA_NOT_ENABLED: 'auth/recaptcha-not-enabled',
|
|
414
|
+
MISSING_RECAPTCHA_TOKEN: 'auth/missing-recaptcha-token',
|
|
415
|
+
INVALID_RECAPTCHA_TOKEN: 'auth/invalid-recaptcha-token',
|
|
416
|
+
INVALID_RECAPTCHA_ACTION: 'auth/invalid-recaptcha-action',
|
|
417
|
+
MISSING_CLIENT_TYPE: 'auth/missing-client-type',
|
|
418
|
+
MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version',
|
|
419
|
+
INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version',
|
|
420
|
+
INVALID_REQ_TYPE: 'auth/invalid-req-type'
|
|
405
421
|
};
|
|
406
422
|
|
|
407
423
|
/**
|
|
@@ -421,6 +437,11 @@ const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
|
|
|
421
437
|
* limitations under the License.
|
|
422
438
|
*/
|
|
423
439
|
const logClient = new Logger('@firebase/auth');
|
|
440
|
+
function _logWarn(msg, ...args) {
|
|
441
|
+
if (logClient.logLevel <= LogLevel.WARN) {
|
|
442
|
+
logClient.warn(`Auth (${SDK_VERSION}): ${msg}`, ...args);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
424
445
|
function _logError(msg, ...args) {
|
|
425
446
|
if (logClient.logLevel <= LogLevel.ERROR) {
|
|
426
447
|
logClient.error(`Auth (${SDK_VERSION}): ${msg}`, ...args);
|
|
@@ -511,103 +532,6 @@ function debugAssert(assertion, message) {
|
|
|
511
532
|
}
|
|
512
533
|
}
|
|
513
534
|
|
|
514
|
-
/**
|
|
515
|
-
* @license
|
|
516
|
-
* Copyright 2020 Google LLC
|
|
517
|
-
*
|
|
518
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
519
|
-
* you may not use this file except in compliance with the License.
|
|
520
|
-
* You may obtain a copy of the License at
|
|
521
|
-
*
|
|
522
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
523
|
-
*
|
|
524
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
525
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
526
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
527
|
-
* See the License for the specific language governing permissions and
|
|
528
|
-
* limitations under the License.
|
|
529
|
-
*/
|
|
530
|
-
const instanceCache = new Map();
|
|
531
|
-
function _getInstance(cls) {
|
|
532
|
-
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
533
|
-
let instance = instanceCache.get(cls);
|
|
534
|
-
if (instance) {
|
|
535
|
-
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
536
|
-
return instance;
|
|
537
|
-
}
|
|
538
|
-
instance = new cls();
|
|
539
|
-
instanceCache.set(cls, instance);
|
|
540
|
-
return instance;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* @license
|
|
545
|
-
* Copyright 2020 Google LLC
|
|
546
|
-
*
|
|
547
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
548
|
-
* you may not use this file except in compliance with the License.
|
|
549
|
-
* You may obtain a copy of the License at
|
|
550
|
-
*
|
|
551
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
552
|
-
*
|
|
553
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
554
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
555
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
556
|
-
* See the License for the specific language governing permissions and
|
|
557
|
-
* limitations under the License.
|
|
558
|
-
*/
|
|
559
|
-
/**
|
|
560
|
-
* Initializes an {@link Auth} instance with fine-grained control over
|
|
561
|
-
* {@link Dependencies}.
|
|
562
|
-
*
|
|
563
|
-
* @remarks
|
|
564
|
-
*
|
|
565
|
-
* This function allows more control over the {@link Auth} instance than
|
|
566
|
-
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
567
|
-
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
568
|
-
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
569
|
-
* need control over which persistence layer is used, or to minimize bundle
|
|
570
|
-
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
571
|
-
*
|
|
572
|
-
* For example, if your app only uses anonymous accounts and you only want
|
|
573
|
-
* accounts saved for the current session, initialize `Auth` with:
|
|
574
|
-
*
|
|
575
|
-
* ```js
|
|
576
|
-
* const auth = initializeAuth(app, {
|
|
577
|
-
* persistence: browserSessionPersistence,
|
|
578
|
-
* popupRedirectResolver: undefined,
|
|
579
|
-
* });
|
|
580
|
-
* ```
|
|
581
|
-
*
|
|
582
|
-
* @public
|
|
583
|
-
*/
|
|
584
|
-
function initializeAuth(app, deps) {
|
|
585
|
-
const provider = _getProvider(app, 'auth');
|
|
586
|
-
if (provider.isInitialized()) {
|
|
587
|
-
const auth = provider.getImmediate();
|
|
588
|
-
const initialOptions = provider.getOptions();
|
|
589
|
-
if (deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
590
|
-
return auth;
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
_fail(auth, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
const auth = provider.initialize({ options: deps });
|
|
597
|
-
return auth;
|
|
598
|
-
}
|
|
599
|
-
function _initializeAuthInstance(auth, deps) {
|
|
600
|
-
const persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
601
|
-
const hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
602
|
-
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
603
|
-
auth._updateErrorMap(deps.errorMap);
|
|
604
|
-
}
|
|
605
|
-
// This promise is intended to float; auth initialization happens in the
|
|
606
|
-
// background, meanwhile the auth object may be used by the app.
|
|
607
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
608
|
-
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
535
|
/**
|
|
612
536
|
* @license
|
|
613
537
|
* Copyright 2020 Google LLC
|
|
@@ -886,7 +810,16 @@ const SERVER_ERROR_MAP = {
|
|
|
886
810
|
["SECOND_FACTOR_EXISTS" /* ServerError.SECOND_FACTOR_EXISTS */]: "second-factor-already-in-use" /* AuthErrorCode.SECOND_FACTOR_ALREADY_ENROLLED */,
|
|
887
811
|
["SECOND_FACTOR_LIMIT_EXCEEDED" /* ServerError.SECOND_FACTOR_LIMIT_EXCEEDED */]: "maximum-second-factor-count-exceeded" /* AuthErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED */,
|
|
888
812
|
// Blocking functions related errors.
|
|
889
|
-
["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */]: "internal-error" /* AuthErrorCode.INTERNAL_ERROR
|
|
813
|
+
["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */]: "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
|
|
814
|
+
// Recaptcha related errors.
|
|
815
|
+
["RECAPTCHA_NOT_ENABLED" /* ServerError.RECAPTCHA_NOT_ENABLED */]: "recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */,
|
|
816
|
+
["MISSING_RECAPTCHA_TOKEN" /* ServerError.MISSING_RECAPTCHA_TOKEN */]: "missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */,
|
|
817
|
+
["INVALID_RECAPTCHA_TOKEN" /* ServerError.INVALID_RECAPTCHA_TOKEN */]: "invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */,
|
|
818
|
+
["INVALID_RECAPTCHA_ACTION" /* ServerError.INVALID_RECAPTCHA_ACTION */]: "invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */,
|
|
819
|
+
["MISSING_CLIENT_TYPE" /* ServerError.MISSING_CLIENT_TYPE */]: "missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */,
|
|
820
|
+
["MISSING_RECAPTCHA_VERSION" /* ServerError.MISSING_RECAPTCHA_VERSION */]: "missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */,
|
|
821
|
+
["INVALID_RECAPTCHA_VERSION" /* ServerError.INVALID_RECAPTCHA_VERSION */]: "invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */,
|
|
822
|
+
["INVALID_REQ_TYPE" /* ServerError.INVALID_REQ_TYPE */]: "invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */
|
|
890
823
|
};
|
|
891
824
|
|
|
892
825
|
/**
|
|
@@ -1788,6 +1721,35 @@ class UserImpl {
|
|
|
1788
1721
|
}
|
|
1789
1722
|
}
|
|
1790
1723
|
|
|
1724
|
+
/**
|
|
1725
|
+
* @license
|
|
1726
|
+
* Copyright 2020 Google LLC
|
|
1727
|
+
*
|
|
1728
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1729
|
+
* you may not use this file except in compliance with the License.
|
|
1730
|
+
* You may obtain a copy of the License at
|
|
1731
|
+
*
|
|
1732
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1733
|
+
*
|
|
1734
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1735
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1736
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1737
|
+
* See the License for the specific language governing permissions and
|
|
1738
|
+
* limitations under the License.
|
|
1739
|
+
*/
|
|
1740
|
+
const instanceCache = new Map();
|
|
1741
|
+
function _getInstance(cls) {
|
|
1742
|
+
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
1743
|
+
let instance = instanceCache.get(cls);
|
|
1744
|
+
if (instance) {
|
|
1745
|
+
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
1746
|
+
return instance;
|
|
1747
|
+
}
|
|
1748
|
+
instance = new cls();
|
|
1749
|
+
instanceCache.set(cls, instance);
|
|
1750
|
+
return instance;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1791
1753
|
/**
|
|
1792
1754
|
* @license
|
|
1793
1755
|
* Copyright 2019 Google LLC
|
|
@@ -2129,6 +2091,242 @@ function _getClientVersion(clientPlatform, frameworks = []) {
|
|
|
2129
2091
|
return `${reportedPlatform}/${"JsCore" /* ClientImplementation.CORE */}/${SDK_VERSION}/${reportedFrameworks}`;
|
|
2130
2092
|
}
|
|
2131
2093
|
|
|
2094
|
+
/**
|
|
2095
|
+
* @license
|
|
2096
|
+
* Copyright 2020 Google LLC
|
|
2097
|
+
*
|
|
2098
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2099
|
+
* you may not use this file except in compliance with the License.
|
|
2100
|
+
* You may obtain a copy of the License at
|
|
2101
|
+
*
|
|
2102
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2103
|
+
*
|
|
2104
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2105
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2106
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2107
|
+
* See the License for the specific language governing permissions and
|
|
2108
|
+
* limitations under the License.
|
|
2109
|
+
*/
|
|
2110
|
+
async function getRecaptchaParams(auth) {
|
|
2111
|
+
return ((await _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)).recaptchaSiteKey || '');
|
|
2112
|
+
}
|
|
2113
|
+
async function getRecaptchaConfig(auth, request) {
|
|
2114
|
+
return _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request));
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
/**
|
|
2118
|
+
* @license
|
|
2119
|
+
* Copyright 2020 Google LLC
|
|
2120
|
+
*
|
|
2121
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2122
|
+
* you may not use this file except in compliance with the License.
|
|
2123
|
+
* You may obtain a copy of the License at
|
|
2124
|
+
*
|
|
2125
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2126
|
+
*
|
|
2127
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2128
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2129
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2130
|
+
* See the License for the specific language governing permissions and
|
|
2131
|
+
* limitations under the License.
|
|
2132
|
+
*/
|
|
2133
|
+
function isV2(grecaptcha) {
|
|
2134
|
+
return (grecaptcha !== undefined &&
|
|
2135
|
+
grecaptcha.getResponse !== undefined);
|
|
2136
|
+
}
|
|
2137
|
+
function isEnterprise(grecaptcha) {
|
|
2138
|
+
return (grecaptcha !== undefined &&
|
|
2139
|
+
grecaptcha.enterprise !== undefined);
|
|
2140
|
+
}
|
|
2141
|
+
class RecaptchaConfig {
|
|
2142
|
+
constructor(response) {
|
|
2143
|
+
/**
|
|
2144
|
+
* The reCAPTCHA site key.
|
|
2145
|
+
*/
|
|
2146
|
+
this.siteKey = '';
|
|
2147
|
+
/**
|
|
2148
|
+
* The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
|
|
2149
|
+
*/
|
|
2150
|
+
this.emailPasswordEnabled = false;
|
|
2151
|
+
if (response.recaptchaKey === undefined) {
|
|
2152
|
+
throw new Error('recaptchaKey undefined');
|
|
2153
|
+
}
|
|
2154
|
+
// Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
|
|
2155
|
+
this.siteKey = response.recaptchaKey.split('/')[3];
|
|
2156
|
+
this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
|
|
2157
|
+
enforcementState.enforcementState !== 'OFF');
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
/**
|
|
2162
|
+
* @license
|
|
2163
|
+
* Copyright 2020 Google LLC
|
|
2164
|
+
*
|
|
2165
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2166
|
+
* you may not use this file except in compliance with the License.
|
|
2167
|
+
* You may obtain a copy of the License at
|
|
2168
|
+
*
|
|
2169
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2170
|
+
*
|
|
2171
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2172
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2173
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2174
|
+
* See the License for the specific language governing permissions and
|
|
2175
|
+
* limitations under the License.
|
|
2176
|
+
*/
|
|
2177
|
+
function getScriptParentElement() {
|
|
2178
|
+
var _a, _b;
|
|
2179
|
+
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
2180
|
+
}
|
|
2181
|
+
function _loadJS(url) {
|
|
2182
|
+
// TODO: consider adding timeout support & cancellation
|
|
2183
|
+
return new Promise((resolve, reject) => {
|
|
2184
|
+
const el = document.createElement('script');
|
|
2185
|
+
el.setAttribute('src', url);
|
|
2186
|
+
el.onload = resolve;
|
|
2187
|
+
el.onerror = e => {
|
|
2188
|
+
const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
2189
|
+
error.customData = e;
|
|
2190
|
+
reject(error);
|
|
2191
|
+
};
|
|
2192
|
+
el.type = 'text/javascript';
|
|
2193
|
+
el.charset = 'UTF-8';
|
|
2194
|
+
getScriptParentElement().appendChild(el);
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
function _generateCallbackName(prefix) {
|
|
2198
|
+
return `__${prefix}${Math.floor(Math.random() * 1000000)}`;
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2202
|
+
const RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
|
|
2203
|
+
const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
|
|
2204
|
+
class RecaptchaEnterpriseVerifier {
|
|
2205
|
+
/**
|
|
2206
|
+
*
|
|
2207
|
+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
2208
|
+
*
|
|
2209
|
+
*/
|
|
2210
|
+
constructor(authExtern) {
|
|
2211
|
+
/**
|
|
2212
|
+
* Identifies the type of application verifier (e.g. "recaptcha-enterprise").
|
|
2213
|
+
*/
|
|
2214
|
+
this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
|
|
2215
|
+
this.auth = _castAuth(authExtern);
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Executes the verification process.
|
|
2219
|
+
*
|
|
2220
|
+
* @returns A Promise for a token that can be used to assert the validity of a request.
|
|
2221
|
+
*/
|
|
2222
|
+
async verify(action = 'verify', forceRefresh = false) {
|
|
2223
|
+
async function retrieveSiteKey(auth) {
|
|
2224
|
+
if (!forceRefresh) {
|
|
2225
|
+
if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
|
|
2226
|
+
return auth._agentRecaptchaConfig.siteKey;
|
|
2227
|
+
}
|
|
2228
|
+
if (auth.tenantId != null &&
|
|
2229
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
|
|
2230
|
+
return auth._tenantRecaptchaConfigs[auth.tenantId].siteKey;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
return new Promise(async (resolve, reject) => {
|
|
2234
|
+
getRecaptchaConfig(auth, {
|
|
2235
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2236
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2237
|
+
})
|
|
2238
|
+
.then(response => {
|
|
2239
|
+
if (response.recaptchaKey === undefined) {
|
|
2240
|
+
reject(new Error('recaptcha Enterprise site key undefined'));
|
|
2241
|
+
}
|
|
2242
|
+
else {
|
|
2243
|
+
const config = new RecaptchaConfig(response);
|
|
2244
|
+
if (auth.tenantId == null) {
|
|
2245
|
+
auth._agentRecaptchaConfig = config;
|
|
2246
|
+
}
|
|
2247
|
+
else {
|
|
2248
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] = config;
|
|
2249
|
+
}
|
|
2250
|
+
return resolve(config.siteKey);
|
|
2251
|
+
}
|
|
2252
|
+
})
|
|
2253
|
+
.catch(error => {
|
|
2254
|
+
reject(error);
|
|
2255
|
+
});
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
function retrieveRecaptchaToken(siteKey, resolve, reject) {
|
|
2259
|
+
const grecaptcha = window.grecaptcha;
|
|
2260
|
+
if (isEnterprise(grecaptcha)) {
|
|
2261
|
+
grecaptcha.enterprise.ready(() => {
|
|
2262
|
+
try {
|
|
2263
|
+
grecaptcha.enterprise
|
|
2264
|
+
.execute(siteKey, { action })
|
|
2265
|
+
.then(token => {
|
|
2266
|
+
resolve(token);
|
|
2267
|
+
})
|
|
2268
|
+
.catch(error => {
|
|
2269
|
+
reject(error);
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
catch (error) {
|
|
2273
|
+
reject(error);
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
else {
|
|
2278
|
+
reject(Error('No reCAPTCHA enterprise script loaded.'));
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
return new Promise((resolve, reject) => {
|
|
2282
|
+
retrieveSiteKey(this.auth)
|
|
2283
|
+
.then(siteKey => {
|
|
2284
|
+
if (!forceRefresh && isEnterprise(window.grecaptcha)) {
|
|
2285
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2286
|
+
}
|
|
2287
|
+
else {
|
|
2288
|
+
if (typeof window === 'undefined') {
|
|
2289
|
+
reject(new Error('RecaptchaVerifier is only supported in browser'));
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
_loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
|
|
2293
|
+
.then(() => {
|
|
2294
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2295
|
+
})
|
|
2296
|
+
.catch(error => {
|
|
2297
|
+
reject(error);
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
})
|
|
2301
|
+
.catch(error => {
|
|
2302
|
+
reject(error);
|
|
2303
|
+
});
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
async function injectRecaptchaFields(auth, request, action, captchaResp = false) {
|
|
2308
|
+
const verifier = new RecaptchaEnterpriseVerifier(auth);
|
|
2309
|
+
let captchaResponse;
|
|
2310
|
+
try {
|
|
2311
|
+
captchaResponse = await verifier.verify(action);
|
|
2312
|
+
}
|
|
2313
|
+
catch (error) {
|
|
2314
|
+
captchaResponse = await verifier.verify(action, true);
|
|
2315
|
+
}
|
|
2316
|
+
const newRequest = Object.assign({}, request);
|
|
2317
|
+
if (!captchaResp) {
|
|
2318
|
+
Object.assign(newRequest, { captchaResponse });
|
|
2319
|
+
}
|
|
2320
|
+
else {
|
|
2321
|
+
Object.assign(newRequest, { 'captchaResp': captchaResponse });
|
|
2322
|
+
}
|
|
2323
|
+
Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
|
|
2324
|
+
Object.assign(newRequest, {
|
|
2325
|
+
'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2326
|
+
});
|
|
2327
|
+
return newRequest;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2132
2330
|
/**
|
|
2133
2331
|
* @license
|
|
2134
2332
|
* Copyright 2022 Google LLC
|
|
@@ -2227,9 +2425,10 @@ class AuthMiddlewareQueue {
|
|
|
2227
2425
|
* limitations under the License.
|
|
2228
2426
|
*/
|
|
2229
2427
|
class AuthImpl {
|
|
2230
|
-
constructor(app, heartbeatServiceProvider, config) {
|
|
2428
|
+
constructor(app, heartbeatServiceProvider, appCheckServiceProvider, config) {
|
|
2231
2429
|
this.app = app;
|
|
2232
2430
|
this.heartbeatServiceProvider = heartbeatServiceProvider;
|
|
2431
|
+
this.appCheckServiceProvider = appCheckServiceProvider;
|
|
2233
2432
|
this.config = config;
|
|
2234
2433
|
this.currentUser = null;
|
|
2235
2434
|
this.emulatorConfig = null;
|
|
@@ -2247,6 +2446,8 @@ class AuthImpl {
|
|
|
2247
2446
|
this._initializationPromise = null;
|
|
2248
2447
|
this._popupRedirectResolver = null;
|
|
2249
2448
|
this._errorFactory = _DEFAULT_AUTH_ERROR_FACTORY;
|
|
2449
|
+
this._agentRecaptchaConfig = null;
|
|
2450
|
+
this._tenantRecaptchaConfigs = {};
|
|
2250
2451
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2251
2452
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2252
2453
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2466,6 +2667,31 @@ class AuthImpl {
|
|
|
2466
2667
|
await this.assertedPersistence.setPersistence(_getInstance(persistence));
|
|
2467
2668
|
});
|
|
2468
2669
|
}
|
|
2670
|
+
async initializeRecaptchaConfig() {
|
|
2671
|
+
const response = await getRecaptchaConfig(this, {
|
|
2672
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2673
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2674
|
+
});
|
|
2675
|
+
const config = new RecaptchaConfig(response);
|
|
2676
|
+
if (this.tenantId == null) {
|
|
2677
|
+
this._agentRecaptchaConfig = config;
|
|
2678
|
+
}
|
|
2679
|
+
else {
|
|
2680
|
+
this._tenantRecaptchaConfigs[this.tenantId] = config;
|
|
2681
|
+
}
|
|
2682
|
+
if (config.emailPasswordEnabled) {
|
|
2683
|
+
const verifier = new RecaptchaEnterpriseVerifier(this);
|
|
2684
|
+
void verifier.verify();
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
_getRecaptchaConfig() {
|
|
2688
|
+
if (this.tenantId == null) {
|
|
2689
|
+
return this._agentRecaptchaConfig;
|
|
2690
|
+
}
|
|
2691
|
+
else {
|
|
2692
|
+
return this._tenantRecaptchaConfigs[this.tenantId];
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2469
2695
|
_getPersistence() {
|
|
2470
2696
|
return this.assertedPersistence.persistence.type;
|
|
2471
2697
|
}
|
|
@@ -2645,8 +2871,26 @@ class AuthImpl {
|
|
|
2645
2871
|
if (heartbeatsHeader) {
|
|
2646
2872
|
headers["X-Firebase-Client" /* HttpHeader.X_FIREBASE_CLIENT */] = heartbeatsHeader;
|
|
2647
2873
|
}
|
|
2874
|
+
// If the App Check service exists, add the App Check token in the headers
|
|
2875
|
+
const appCheckToken = await this._getAppCheckToken();
|
|
2876
|
+
if (appCheckToken) {
|
|
2877
|
+
headers["X-Firebase-AppCheck" /* HttpHeader.X_FIREBASE_APP_CHECK */] = appCheckToken;
|
|
2878
|
+
}
|
|
2648
2879
|
return headers;
|
|
2649
2880
|
}
|
|
2881
|
+
async _getAppCheckToken() {
|
|
2882
|
+
var _a;
|
|
2883
|
+
const appCheckTokenResult = await ((_a = this.appCheckServiceProvider
|
|
2884
|
+
.getImmediate({ optional: true })) === null || _a === void 0 ? void 0 : _a.getToken());
|
|
2885
|
+
if (appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.error) {
|
|
2886
|
+
// Context: appCheck.getToken() will never throw even if an error happened.
|
|
2887
|
+
// In the error case, a dummy token will be returned along with an error field describing
|
|
2888
|
+
// the error. In general, we shouldn't care about the error condition and just use
|
|
2889
|
+
// the token (actual or dummy) to send requests.
|
|
2890
|
+
_logWarn(`Error while retrieving App Check token: ${appCheckTokenResult.error}`);
|
|
2891
|
+
}
|
|
2892
|
+
return appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.token;
|
|
2893
|
+
}
|
|
2650
2894
|
}
|
|
2651
2895
|
/**
|
|
2652
2896
|
* Method to be used to cast down to our private implmentation of Auth.
|
|
@@ -2670,6 +2914,74 @@ class Subscription {
|
|
|
2670
2914
|
}
|
|
2671
2915
|
}
|
|
2672
2916
|
|
|
2917
|
+
/**
|
|
2918
|
+
* @license
|
|
2919
|
+
* Copyright 2020 Google LLC
|
|
2920
|
+
*
|
|
2921
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2922
|
+
* you may not use this file except in compliance with the License.
|
|
2923
|
+
* You may obtain a copy of the License at
|
|
2924
|
+
*
|
|
2925
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2926
|
+
*
|
|
2927
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2928
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2929
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2930
|
+
* See the License for the specific language governing permissions and
|
|
2931
|
+
* limitations under the License.
|
|
2932
|
+
*/
|
|
2933
|
+
/**
|
|
2934
|
+
* Initializes an {@link Auth} instance with fine-grained control over
|
|
2935
|
+
* {@link Dependencies}.
|
|
2936
|
+
*
|
|
2937
|
+
* @remarks
|
|
2938
|
+
*
|
|
2939
|
+
* This function allows more control over the {@link Auth} instance than
|
|
2940
|
+
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
2941
|
+
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
2942
|
+
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
2943
|
+
* need control over which persistence layer is used, or to minimize bundle
|
|
2944
|
+
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
2945
|
+
*
|
|
2946
|
+
* For example, if your app only uses anonymous accounts and you only want
|
|
2947
|
+
* accounts saved for the current session, initialize `Auth` with:
|
|
2948
|
+
*
|
|
2949
|
+
* ```js
|
|
2950
|
+
* const auth = initializeAuth(app, {
|
|
2951
|
+
* persistence: browserSessionPersistence,
|
|
2952
|
+
* popupRedirectResolver: undefined,
|
|
2953
|
+
* });
|
|
2954
|
+
* ```
|
|
2955
|
+
*
|
|
2956
|
+
* @public
|
|
2957
|
+
*/
|
|
2958
|
+
function initializeAuth(app, deps) {
|
|
2959
|
+
const provider = _getProvider(app, 'auth');
|
|
2960
|
+
if (provider.isInitialized()) {
|
|
2961
|
+
const auth = provider.getImmediate();
|
|
2962
|
+
const initialOptions = provider.getOptions();
|
|
2963
|
+
if (deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
2964
|
+
return auth;
|
|
2965
|
+
}
|
|
2966
|
+
else {
|
|
2967
|
+
_fail(auth, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
const auth = provider.initialize({ options: deps });
|
|
2971
|
+
return auth;
|
|
2972
|
+
}
|
|
2973
|
+
function _initializeAuthInstance(auth, deps) {
|
|
2974
|
+
const persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
2975
|
+
const hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
2976
|
+
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
2977
|
+
auth._updateErrorMap(deps.errorMap);
|
|
2978
|
+
}
|
|
2979
|
+
// This promise is intended to float; auth initialization happens in the
|
|
2980
|
+
// background, meanwhile the auth object may be used by the app.
|
|
2981
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2982
|
+
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2673
2985
|
/**
|
|
2674
2986
|
* Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
|
|
2675
2987
|
* Firebase Auth services.
|
|
@@ -3009,13 +3321,31 @@ class EmailAuthCredential extends AuthCredential {
|
|
|
3009
3321
|
}
|
|
3010
3322
|
/** @internal */
|
|
3011
3323
|
async _getIdTokenResponse(auth) {
|
|
3324
|
+
var _a;
|
|
3012
3325
|
switch (this.signInMethod) {
|
|
3013
3326
|
case "password" /* SignInMethod.EMAIL_PASSWORD */:
|
|
3014
|
-
|
|
3327
|
+
const request = {
|
|
3015
3328
|
returnSecureToken: true,
|
|
3016
3329
|
email: this._email,
|
|
3017
|
-
password: this._password
|
|
3018
|
-
|
|
3330
|
+
password: this._password,
|
|
3331
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
3332
|
+
};
|
|
3333
|
+
if ((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
3334
|
+
const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
|
|
3335
|
+
return signInWithPassword(auth, requestWithRecaptcha);
|
|
3336
|
+
}
|
|
3337
|
+
else {
|
|
3338
|
+
return signInWithPassword(auth, request).catch(async (error) => {
|
|
3339
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
3340
|
+
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.');
|
|
3341
|
+
const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
|
|
3342
|
+
return signInWithPassword(auth, requestWithRecaptcha);
|
|
3343
|
+
}
|
|
3344
|
+
else {
|
|
3345
|
+
return Promise.reject(error);
|
|
3346
|
+
}
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3019
3349
|
case "emailLink" /* SignInMethod.EMAIL_LINK */:
|
|
3020
3350
|
return signInWithEmailLink$1(auth, {
|
|
3021
3351
|
email: this._email,
|
|
@@ -4974,15 +5304,39 @@ function _setActionCodeSettingsOnRequest(auth, request, actionCodeSettings) {
|
|
|
4974
5304
|
* @public
|
|
4975
5305
|
*/
|
|
4976
5306
|
async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
|
|
4977
|
-
|
|
5307
|
+
var _a;
|
|
5308
|
+
const authInternal = _castAuth(auth);
|
|
4978
5309
|
const request = {
|
|
4979
5310
|
requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
|
|
4980
|
-
email
|
|
5311
|
+
email,
|
|
5312
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
4981
5313
|
};
|
|
4982
|
-
if (
|
|
4983
|
-
|
|
5314
|
+
if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
5315
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5316
|
+
if (actionCodeSettings) {
|
|
5317
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
5318
|
+
}
|
|
5319
|
+
await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
|
|
5320
|
+
}
|
|
5321
|
+
else {
|
|
5322
|
+
if (actionCodeSettings) {
|
|
5323
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
5324
|
+
}
|
|
5325
|
+
await sendPasswordResetEmail$1(authInternal, request)
|
|
5326
|
+
.catch(async (error) => {
|
|
5327
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
5328
|
+
console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
|
|
5329
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5330
|
+
if (actionCodeSettings) {
|
|
5331
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
5332
|
+
}
|
|
5333
|
+
await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
|
|
5334
|
+
}
|
|
5335
|
+
else {
|
|
5336
|
+
return Promise.reject(error);
|
|
5337
|
+
}
|
|
5338
|
+
});
|
|
4984
5339
|
}
|
|
4985
|
-
await sendPasswordResetEmail$1(authModular, request);
|
|
4986
5340
|
}
|
|
4987
5341
|
/**
|
|
4988
5342
|
* Completes the password reset process, given a confirmation code and new password.
|
|
@@ -5095,11 +5449,33 @@ async function verifyPasswordResetCode(auth, code) {
|
|
|
5095
5449
|
* @public
|
|
5096
5450
|
*/
|
|
5097
5451
|
async function createUserWithEmailAndPassword(auth, email, password) {
|
|
5452
|
+
var _a;
|
|
5098
5453
|
const authInternal = _castAuth(auth);
|
|
5099
|
-
const
|
|
5454
|
+
const request = {
|
|
5100
5455
|
returnSecureToken: true,
|
|
5101
5456
|
email,
|
|
5102
|
-
password
|
|
5457
|
+
password,
|
|
5458
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
5459
|
+
};
|
|
5460
|
+
let signUpResponse;
|
|
5461
|
+
if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
5462
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
|
|
5463
|
+
signUpResponse = signUp(authInternal, requestWithRecaptcha);
|
|
5464
|
+
}
|
|
5465
|
+
else {
|
|
5466
|
+
signUpResponse = signUp(authInternal, request).catch(async (error) => {
|
|
5467
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
5468
|
+
console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
|
|
5469
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
|
|
5470
|
+
return signUp(authInternal, requestWithRecaptcha);
|
|
5471
|
+
}
|
|
5472
|
+
else {
|
|
5473
|
+
return Promise.reject(error);
|
|
5474
|
+
}
|
|
5475
|
+
});
|
|
5476
|
+
}
|
|
5477
|
+
const response = await signUpResponse.catch(error => {
|
|
5478
|
+
return Promise.reject(error);
|
|
5103
5479
|
});
|
|
5104
5480
|
const userCredential = await UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response);
|
|
5105
5481
|
await authInternal._updateCurrentUser(userCredential.user);
|
|
@@ -5180,16 +5556,39 @@ function signInWithEmailAndPassword(auth, email, password) {
|
|
|
5180
5556
|
* @public
|
|
5181
5557
|
*/
|
|
5182
5558
|
async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
|
|
5183
|
-
|
|
5559
|
+
var _a;
|
|
5560
|
+
const authInternal = _castAuth(auth);
|
|
5184
5561
|
const request = {
|
|
5185
5562
|
requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
|
|
5186
|
-
email
|
|
5563
|
+
email,
|
|
5564
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
5187
5565
|
};
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5566
|
+
function setActionCodeSettings(request, actionCodeSettings) {
|
|
5567
|
+
_assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
5568
|
+
if (actionCodeSettings) {
|
|
5569
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5572
|
+
if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
|
|
5573
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5574
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
5575
|
+
await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
|
|
5576
|
+
}
|
|
5577
|
+
else {
|
|
5578
|
+
setActionCodeSettings(request, actionCodeSettings);
|
|
5579
|
+
await sendSignInLinkToEmail$1(authInternal, request)
|
|
5580
|
+
.catch(async (error) => {
|
|
5581
|
+
if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
|
|
5582
|
+
console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
|
|
5583
|
+
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
|
|
5584
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
5585
|
+
await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
|
|
5586
|
+
}
|
|
5587
|
+
else {
|
|
5588
|
+
return Promise.reject(error);
|
|
5589
|
+
}
|
|
5590
|
+
});
|
|
5191
5591
|
}
|
|
5192
|
-
await sendSignInLinkToEmail$1(authModular, request);
|
|
5193
5592
|
}
|
|
5194
5593
|
/**
|
|
5195
5594
|
* Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
|
|
@@ -5684,6 +6083,35 @@ function getAdditionalUserInfo(userCredential) {
|
|
|
5684
6083
|
function setPersistence(auth, persistence) {
|
|
5685
6084
|
return getModularInstance(auth).setPersistence(persistence);
|
|
5686
6085
|
}
|
|
6086
|
+
/**
|
|
6087
|
+
* Loads the reCAPTCHA configuration into the `Auth` instance.
|
|
6088
|
+
*
|
|
6089
|
+
* @remarks
|
|
6090
|
+
* This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
|
|
6091
|
+
* verification flow should be triggered for each auth provider, into the
|
|
6092
|
+
* current Auth session.
|
|
6093
|
+
*
|
|
6094
|
+
* If initializeRecaptchaConfig() is not invoked, the auth flow will always start
|
|
6095
|
+
* without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
|
|
6096
|
+
* verification, the SDK will transparently load the reCAPTCHA config and restart the
|
|
6097
|
+
* auth flows.
|
|
6098
|
+
*
|
|
6099
|
+
* Thus, by calling this optional method, you will reduce the latency of future auth flows.
|
|
6100
|
+
* Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
|
|
6101
|
+
*
|
|
6102
|
+
* @example
|
|
6103
|
+
* ```javascript
|
|
6104
|
+
* initializeRecaptchaConfig(auth);
|
|
6105
|
+
* ```
|
|
6106
|
+
*
|
|
6107
|
+
* @param auth - The {@link Auth} instance.
|
|
6108
|
+
*
|
|
6109
|
+
* @public
|
|
6110
|
+
*/
|
|
6111
|
+
function initializeRecaptchaConfig(auth) {
|
|
6112
|
+
const authInternal = _castAuth(auth);
|
|
6113
|
+
return authInternal.initializeRecaptchaConfig();
|
|
6114
|
+
}
|
|
5687
6115
|
/**
|
|
5688
6116
|
* Adds an observer for changes to the signed-in user's ID token.
|
|
5689
6117
|
*
|
|
@@ -7029,66 +7457,6 @@ function finalizeSignInTotpMfa(auth, request) {
|
|
|
7029
7457
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
7030
7458
|
}
|
|
7031
7459
|
|
|
7032
|
-
/**
|
|
7033
|
-
* @license
|
|
7034
|
-
* Copyright 2020 Google LLC
|
|
7035
|
-
*
|
|
7036
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7037
|
-
* you may not use this file except in compliance with the License.
|
|
7038
|
-
* You may obtain a copy of the License at
|
|
7039
|
-
*
|
|
7040
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7041
|
-
*
|
|
7042
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7043
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7044
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7045
|
-
* See the License for the specific language governing permissions and
|
|
7046
|
-
* limitations under the License.
|
|
7047
|
-
*/
|
|
7048
|
-
async function getRecaptchaParams(auth) {
|
|
7049
|
-
return ((await _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)).recaptchaSiteKey || '');
|
|
7050
|
-
}
|
|
7051
|
-
|
|
7052
|
-
/**
|
|
7053
|
-
* @license
|
|
7054
|
-
* Copyright 2020 Google LLC
|
|
7055
|
-
*
|
|
7056
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7057
|
-
* you may not use this file except in compliance with the License.
|
|
7058
|
-
* You may obtain a copy of the License at
|
|
7059
|
-
*
|
|
7060
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7061
|
-
*
|
|
7062
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7063
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7064
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7065
|
-
* See the License for the specific language governing permissions and
|
|
7066
|
-
* limitations under the License.
|
|
7067
|
-
*/
|
|
7068
|
-
function getScriptParentElement() {
|
|
7069
|
-
var _a, _b;
|
|
7070
|
-
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
7071
|
-
}
|
|
7072
|
-
function _loadJS(url) {
|
|
7073
|
-
// TODO: consider adding timeout support & cancellation
|
|
7074
|
-
return new Promise((resolve, reject) => {
|
|
7075
|
-
const el = document.createElement('script');
|
|
7076
|
-
el.setAttribute('src', url);
|
|
7077
|
-
el.onload = resolve;
|
|
7078
|
-
el.onerror = e => {
|
|
7079
|
-
const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
7080
|
-
error.customData = e;
|
|
7081
|
-
reject(error);
|
|
7082
|
-
};
|
|
7083
|
-
el.type = 'text/javascript';
|
|
7084
|
-
el.charset = 'UTF-8';
|
|
7085
|
-
getScriptParentElement().appendChild(el);
|
|
7086
|
-
});
|
|
7087
|
-
}
|
|
7088
|
-
function _generateCallbackName(prefix) {
|
|
7089
|
-
return `__${prefix}${Math.floor(Math.random() * 1000000)}`;
|
|
7090
|
-
}
|
|
7091
|
-
|
|
7092
7460
|
/**
|
|
7093
7461
|
* @license
|
|
7094
7462
|
* Copyright 2020 Google LLC
|
|
@@ -7255,7 +7623,7 @@ class ReCaptchaLoaderImpl {
|
|
|
7255
7623
|
}
|
|
7256
7624
|
load(auth, hl = '') {
|
|
7257
7625
|
_assert(isHostLanguageValid(hl), auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
7258
|
-
if (this.shouldResolveImmediately(hl)) {
|
|
7626
|
+
if (this.shouldResolveImmediately(hl) && isV2(_window().grecaptcha)) {
|
|
7259
7627
|
return Promise.resolve(_window().grecaptcha);
|
|
7260
7628
|
}
|
|
7261
7629
|
return new Promise((resolve, reject) => {
|
|
@@ -7266,7 +7634,7 @@ class ReCaptchaLoaderImpl {
|
|
|
7266
7634
|
_window().clearTimeout(networkTimeout);
|
|
7267
7635
|
delete _window()[_JSLOAD_CALLBACK];
|
|
7268
7636
|
const recaptcha = _window().grecaptcha;
|
|
7269
|
-
if (!recaptcha) {
|
|
7637
|
+
if (!recaptcha || !isV2(recaptcha)) {
|
|
7270
7638
|
reject(_createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
|
|
7271
7639
|
return;
|
|
7272
7640
|
}
|
|
@@ -8250,11 +8618,13 @@ class PopupOperation extends AbstractPopupRedirectOperation {
|
|
|
8250
8618
|
if ((_b = (_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.window) === null || _b === void 0 ? void 0 : _b.closed) {
|
|
8251
8619
|
// Make sure that there is sufficient time for whatever action to
|
|
8252
8620
|
// complete. The window could have closed but the sign in network
|
|
8253
|
-
// call could still be in flight.
|
|
8621
|
+
// call could still be in flight. This is specifically true for
|
|
8622
|
+
// Firefox or if the opener is in an iframe, in which case the oauth
|
|
8623
|
+
// helper closes the popup.
|
|
8254
8624
|
this.pollId = window.setTimeout(() => {
|
|
8255
8625
|
this.pollId = null;
|
|
8256
8626
|
this.reject(_createError(this.auth, "popup-closed-by-user" /* AuthErrorCode.POPUP_CLOSED_BY_USER */));
|
|
8257
|
-
},
|
|
8627
|
+
}, 8000 /* _Timeout.AUTH_EVENT */);
|
|
8258
8628
|
return;
|
|
8259
8629
|
}
|
|
8260
8630
|
this.pollId = window.setTimeout(poll, _POLL_WINDOW_CLOSE_TIMEOUT.get());
|
|
@@ -9112,7 +9482,13 @@ const WIDGET_PATH = '__/auth/handler';
|
|
|
9112
9482
|
* @internal
|
|
9113
9483
|
*/
|
|
9114
9484
|
const EMULATOR_WIDGET_PATH = 'emulator/auth/handler';
|
|
9115
|
-
|
|
9485
|
+
/**
|
|
9486
|
+
* Fragment name for the App Check token that gets passed to the widget
|
|
9487
|
+
*
|
|
9488
|
+
* @internal
|
|
9489
|
+
*/
|
|
9490
|
+
const FIREBASE_APP_CHECK_FRAGMENT_ID = encodeURIComponent('fac');
|
|
9491
|
+
async function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additionalParams) {
|
|
9116
9492
|
_assert(auth.config.authDomain, auth, "auth-domain-config-required" /* AuthErrorCode.MISSING_AUTH_DOMAIN */);
|
|
9117
9493
|
_assert(auth.config.apiKey, auth, "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */);
|
|
9118
9494
|
const params = {
|
|
@@ -9151,7 +9527,13 @@ function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additio
|
|
|
9151
9527
|
delete paramsDict[key];
|
|
9152
9528
|
}
|
|
9153
9529
|
}
|
|
9154
|
-
|
|
9530
|
+
// Sets the App Check token to pass to the widget
|
|
9531
|
+
const appCheckToken = await auth._getAppCheckToken();
|
|
9532
|
+
const appCheckTokenFragment = appCheckToken
|
|
9533
|
+
? `#${FIREBASE_APP_CHECK_FRAGMENT_ID}=${encodeURIComponent(appCheckToken)}`
|
|
9534
|
+
: '';
|
|
9535
|
+
// Start at index 1 to skip the leading '&' in the query string
|
|
9536
|
+
return `${getHandlerBase(auth)}?${querystring(paramsDict).slice(1)}${appCheckTokenFragment}`;
|
|
9155
9537
|
}
|
|
9156
9538
|
function getHandlerBase({ config }) {
|
|
9157
9539
|
if (!config.emulator) {
|
|
@@ -9195,12 +9577,13 @@ class BrowserPopupRedirectResolver {
|
|
|
9195
9577
|
async _openPopup(auth, provider, authType, eventId) {
|
|
9196
9578
|
var _a;
|
|
9197
9579
|
debugAssert((_a = this.eventManagers[auth._key()]) === null || _a === void 0 ? void 0 : _a.manager, '_initialize() not called before _openPopup()');
|
|
9198
|
-
const url = _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
|
|
9580
|
+
const url = await _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
|
|
9199
9581
|
return _open(auth, url, _generateEventId());
|
|
9200
9582
|
}
|
|
9201
9583
|
async _openRedirect(auth, provider, authType, eventId) {
|
|
9202
9584
|
await this._originValidation(auth);
|
|
9203
|
-
|
|
9585
|
+
const url = await _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
|
|
9586
|
+
_setWindowLocation(url);
|
|
9204
9587
|
return new Promise(() => { });
|
|
9205
9588
|
}
|
|
9206
9589
|
_initialize(auth) {
|
|
@@ -9485,7 +9868,7 @@ function _isEmptyString(input) {
|
|
|
9485
9868
|
}
|
|
9486
9869
|
|
|
9487
9870
|
var name = "@firebase/auth";
|
|
9488
|
-
var version = "0.
|
|
9871
|
+
var version = "0.23.0-canary.0a27d2fbf";
|
|
9489
9872
|
|
|
9490
9873
|
/**
|
|
9491
9874
|
* @license
|
|
@@ -9591,26 +9974,25 @@ function registerAuth(clientPlatform) {
|
|
|
9591
9974
|
_registerComponent(new Component("auth" /* _ComponentName.AUTH */, (container, { options: deps }) => {
|
|
9592
9975
|
const app = container.getProvider('app').getImmediate();
|
|
9593
9976
|
const heartbeatServiceProvider = container.getProvider('heartbeat');
|
|
9977
|
+
const appCheckServiceProvider = container.getProvider('app-check-internal');
|
|
9594
9978
|
const { apiKey, authDomain } = app.options;
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
return authInstance;
|
|
9613
|
-
})(app, heartbeatServiceProvider);
|
|
9979
|
+
_assert(apiKey && !apiKey.includes(':'), "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */, { appName: app.name });
|
|
9980
|
+
// Auth domain is optional if IdP sign in isn't being used
|
|
9981
|
+
_assert(!(authDomain === null || authDomain === void 0 ? void 0 : authDomain.includes(':')), "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, {
|
|
9982
|
+
appName: app.name
|
|
9983
|
+
});
|
|
9984
|
+
const config = {
|
|
9985
|
+
apiKey,
|
|
9986
|
+
authDomain,
|
|
9987
|
+
clientPlatform,
|
|
9988
|
+
apiHost: "identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */,
|
|
9989
|
+
tokenApiHost: "securetoken.googleapis.com" /* DefaultConfig.TOKEN_API_HOST */,
|
|
9990
|
+
apiScheme: "https" /* DefaultConfig.API_SCHEME */,
|
|
9991
|
+
sdkClientVersion: _getClientVersion(clientPlatform)
|
|
9992
|
+
};
|
|
9993
|
+
const authInstance = new AuthImpl(app, heartbeatServiceProvider, appCheckServiceProvider, config);
|
|
9994
|
+
_initializeAuthInstance(authInstance, deps);
|
|
9995
|
+
return authInstance;
|
|
9614
9996
|
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
|
9615
9997
|
/**
|
|
9616
9998
|
* Auth can only be initialized by explicitly calling getAuth() or initializeAuth()
|
|
@@ -9710,5 +10092,5 @@ function getAuth(app = getApp()) {
|
|
|
9710
10092
|
}
|
|
9711
10093
|
registerAuth("Browser" /* ClientPlatform.BROWSER */);
|
|
9712
10094
|
|
|
9713
|
-
export {
|
|
9714
|
-
//# sourceMappingURL=index-
|
|
10095
|
+
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, _assert as aA, AuthEventManager as aB, _getInstance as aC, _persistenceKeyName as aD, _getRedirectResult as aE, _overrideRedirectResult as aF, _clearRedirectOutcomes 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, debugAssert as as, _isIOS as at, _isAndroid as au, _fail as av, _getRedirectUrl as aw, _getProjectConfig as ax, _isIOS7Or8 as ay, _createError 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 };
|
|
10096
|
+
//# sourceMappingURL=index-6cb4f120.js.map
|