@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
|
@@ -170,6 +170,14 @@ function _debugErrorMap() {
|
|
|
170
170
|
'different options. To avoid this error, call initializeAuth() with the ' +
|
|
171
171
|
'same options as when it was originally called, or call getAuth() to return the' +
|
|
172
172
|
' already initialized instance.',
|
|
173
|
+
_a["missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is missing when sending request to the backend.',
|
|
174
|
+
_a["invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is invalid when sending request to the backend.',
|
|
175
|
+
_a["invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */] = 'The reCAPTCHA action is invalid when sending request to the backend.',
|
|
176
|
+
_a["recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */] = 'reCAPTCHA Enterprise integration is not enabled for this project.',
|
|
177
|
+
_a["missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */] = 'The reCAPTCHA client type is missing when sending request to the backend.',
|
|
178
|
+
_a["missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is missing when sending request to the backend.',
|
|
179
|
+
_a["invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */] = 'Invalid request parameters.',
|
|
180
|
+
_a["invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is invalid when sending request to the backend.',
|
|
173
181
|
_a;
|
|
174
182
|
}
|
|
175
183
|
function _prodErrorMap() {
|
|
@@ -306,7 +314,15 @@ var AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
|
|
|
306
314
|
USER_SIGNED_OUT: 'auth/user-signed-out',
|
|
307
315
|
WEAK_PASSWORD: 'auth/weak-password',
|
|
308
316
|
WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
|
|
309
|
-
ALREADY_INITIALIZED: 'auth/already-initialized'
|
|
317
|
+
ALREADY_INITIALIZED: 'auth/already-initialized',
|
|
318
|
+
RECAPTCHA_NOT_ENABLED: 'auth/recaptcha-not-enabled',
|
|
319
|
+
MISSING_RECAPTCHA_TOKEN: 'auth/missing-recaptcha-token',
|
|
320
|
+
INVALID_RECAPTCHA_TOKEN: 'auth/invalid-recaptcha-token',
|
|
321
|
+
INVALID_RECAPTCHA_ACTION: 'auth/invalid-recaptcha-action',
|
|
322
|
+
MISSING_CLIENT_TYPE: 'auth/missing-client-type',
|
|
323
|
+
MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version',
|
|
324
|
+
INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version',
|
|
325
|
+
INVALID_REQ_TYPE: 'auth/invalid-req-type'
|
|
310
326
|
};
|
|
311
327
|
|
|
312
328
|
/**
|
|
@@ -447,103 +463,6 @@ function debugAssert(assertion, message) {
|
|
|
447
463
|
}
|
|
448
464
|
}
|
|
449
465
|
|
|
450
|
-
/**
|
|
451
|
-
* @license
|
|
452
|
-
* Copyright 2020 Google LLC
|
|
453
|
-
*
|
|
454
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
455
|
-
* you may not use this file except in compliance with the License.
|
|
456
|
-
* You may obtain a copy of the License at
|
|
457
|
-
*
|
|
458
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
459
|
-
*
|
|
460
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
461
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
462
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
463
|
-
* See the License for the specific language governing permissions and
|
|
464
|
-
* limitations under the License.
|
|
465
|
-
*/
|
|
466
|
-
var instanceCache = new Map();
|
|
467
|
-
function _getInstance(cls) {
|
|
468
|
-
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
469
|
-
var instance = instanceCache.get(cls);
|
|
470
|
-
if (instance) {
|
|
471
|
-
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
472
|
-
return instance;
|
|
473
|
-
}
|
|
474
|
-
instance = new cls();
|
|
475
|
-
instanceCache.set(cls, instance);
|
|
476
|
-
return instance;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* @license
|
|
481
|
-
* Copyright 2020 Google LLC
|
|
482
|
-
*
|
|
483
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
484
|
-
* you may not use this file except in compliance with the License.
|
|
485
|
-
* You may obtain a copy of the License at
|
|
486
|
-
*
|
|
487
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
488
|
-
*
|
|
489
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
490
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
491
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
492
|
-
* See the License for the specific language governing permissions and
|
|
493
|
-
* limitations under the License.
|
|
494
|
-
*/
|
|
495
|
-
/**
|
|
496
|
-
* Initializes an {@link Auth} instance with fine-grained control over
|
|
497
|
-
* {@link Dependencies}.
|
|
498
|
-
*
|
|
499
|
-
* @remarks
|
|
500
|
-
*
|
|
501
|
-
* This function allows more control over the {@link Auth} instance than
|
|
502
|
-
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
503
|
-
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
504
|
-
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
505
|
-
* need control over which persistence layer is used, or to minimize bundle
|
|
506
|
-
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
507
|
-
*
|
|
508
|
-
* For example, if your app only uses anonymous accounts and you only want
|
|
509
|
-
* accounts saved for the current session, initialize `Auth` with:
|
|
510
|
-
*
|
|
511
|
-
* ```js
|
|
512
|
-
* const auth = initializeAuth(app, {
|
|
513
|
-
* persistence: browserSessionPersistence,
|
|
514
|
-
* popupRedirectResolver: undefined,
|
|
515
|
-
* });
|
|
516
|
-
* ```
|
|
517
|
-
*
|
|
518
|
-
* @public
|
|
519
|
-
*/
|
|
520
|
-
function initializeAuth(app$1, deps) {
|
|
521
|
-
var provider = app._getProvider(app$1, 'auth');
|
|
522
|
-
if (provider.isInitialized()) {
|
|
523
|
-
var auth_1 = provider.getImmediate();
|
|
524
|
-
var initialOptions = provider.getOptions();
|
|
525
|
-
if (util.deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
526
|
-
return auth_1;
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
_fail(auth_1, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
var auth = provider.initialize({ options: deps });
|
|
533
|
-
return auth;
|
|
534
|
-
}
|
|
535
|
-
function _initializeAuthInstance(auth, deps) {
|
|
536
|
-
var persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
537
|
-
var hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
538
|
-
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
539
|
-
auth._updateErrorMap(deps.errorMap);
|
|
540
|
-
}
|
|
541
|
-
// This promise is intended to float; auth initialization happens in the
|
|
542
|
-
// background, meanwhile the auth object may be used by the app.
|
|
543
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
544
|
-
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
466
|
/**
|
|
548
467
|
* @license
|
|
549
468
|
* Copyright 2020 Google LLC
|
|
@@ -828,6 +747,15 @@ var SERVER_ERROR_MAP = (_a$1 = {},
|
|
|
828
747
|
_a$1["SECOND_FACTOR_LIMIT_EXCEEDED" /* ServerError.SECOND_FACTOR_LIMIT_EXCEEDED */] = "maximum-second-factor-count-exceeded" /* AuthErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED */,
|
|
829
748
|
// Blocking functions related errors.
|
|
830
749
|
_a$1["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */] = "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
|
|
750
|
+
// Recaptcha related errors.
|
|
751
|
+
_a$1["RECAPTCHA_NOT_ENABLED" /* ServerError.RECAPTCHA_NOT_ENABLED */] = "recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */,
|
|
752
|
+
_a$1["MISSING_RECAPTCHA_TOKEN" /* ServerError.MISSING_RECAPTCHA_TOKEN */] = "missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */,
|
|
753
|
+
_a$1["INVALID_RECAPTCHA_TOKEN" /* ServerError.INVALID_RECAPTCHA_TOKEN */] = "invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */,
|
|
754
|
+
_a$1["INVALID_RECAPTCHA_ACTION" /* ServerError.INVALID_RECAPTCHA_ACTION */] = "invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */,
|
|
755
|
+
_a$1["MISSING_CLIENT_TYPE" /* ServerError.MISSING_CLIENT_TYPE */] = "missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */,
|
|
756
|
+
_a$1["MISSING_RECAPTCHA_VERSION" /* ServerError.MISSING_RECAPTCHA_VERSION */] = "missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */,
|
|
757
|
+
_a$1["INVALID_RECAPTCHA_VERSION" /* ServerError.INVALID_RECAPTCHA_VERSION */] = "invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */,
|
|
758
|
+
_a$1["INVALID_REQ_TYPE" /* ServerError.INVALID_REQ_TYPE */] = "invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */,
|
|
831
759
|
_a$1);
|
|
832
760
|
|
|
833
761
|
/**
|
|
@@ -1949,6 +1877,35 @@ var UserImpl = /** @class */ (function () {
|
|
|
1949
1877
|
return UserImpl;
|
|
1950
1878
|
}());
|
|
1951
1879
|
|
|
1880
|
+
/**
|
|
1881
|
+
* @license
|
|
1882
|
+
* Copyright 2020 Google LLC
|
|
1883
|
+
*
|
|
1884
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1885
|
+
* you may not use this file except in compliance with the License.
|
|
1886
|
+
* You may obtain a copy of the License at
|
|
1887
|
+
*
|
|
1888
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1889
|
+
*
|
|
1890
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1891
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1892
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1893
|
+
* See the License for the specific language governing permissions and
|
|
1894
|
+
* limitations under the License.
|
|
1895
|
+
*/
|
|
1896
|
+
var instanceCache = new Map();
|
|
1897
|
+
function _getInstance(cls) {
|
|
1898
|
+
debugAssert(cls instanceof Function, 'Expected a class definition');
|
|
1899
|
+
var instance = instanceCache.get(cls);
|
|
1900
|
+
if (instance) {
|
|
1901
|
+
debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
|
|
1902
|
+
return instance;
|
|
1903
|
+
}
|
|
1904
|
+
instance = new cls();
|
|
1905
|
+
instanceCache.set(cls, instance);
|
|
1906
|
+
return instance;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1952
1909
|
/**
|
|
1953
1910
|
* @license
|
|
1954
1911
|
* Copyright 2019 Google LLC
|
|
@@ -2387,6 +2344,288 @@ function _getClientVersion(clientPlatform, frameworks) {
|
|
|
2387
2344
|
return "".concat(reportedPlatform, "/").concat("JsCore" /* ClientImplementation.CORE */, "/").concat(app.SDK_VERSION, "/").concat(reportedFrameworks);
|
|
2388
2345
|
}
|
|
2389
2346
|
|
|
2347
|
+
/**
|
|
2348
|
+
* @license
|
|
2349
|
+
* Copyright 2020 Google LLC
|
|
2350
|
+
*
|
|
2351
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2352
|
+
* you may not use this file except in compliance with the License.
|
|
2353
|
+
* You may obtain a copy of the License at
|
|
2354
|
+
*
|
|
2355
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2356
|
+
*
|
|
2357
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2358
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2359
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2360
|
+
* See the License for the specific language governing permissions and
|
|
2361
|
+
* limitations under the License.
|
|
2362
|
+
*/
|
|
2363
|
+
function getRecaptchaParams(auth) {
|
|
2364
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2365
|
+
return tslib.__generator(this, function (_a) {
|
|
2366
|
+
switch (_a.label) {
|
|
2367
|
+
case 0: return [4 /*yield*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)];
|
|
2368
|
+
case 1: return [2 /*return*/, ((_a.sent()).recaptchaSiteKey || '')];
|
|
2369
|
+
}
|
|
2370
|
+
});
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
function getRecaptchaConfig(auth, request) {
|
|
2374
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2375
|
+
return tslib.__generator(this, function (_a) {
|
|
2376
|
+
return [2 /*return*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request))];
|
|
2377
|
+
});
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* @license
|
|
2383
|
+
* Copyright 2020 Google LLC
|
|
2384
|
+
*
|
|
2385
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2386
|
+
* you may not use this file except in compliance with the License.
|
|
2387
|
+
* You may obtain a copy of the License at
|
|
2388
|
+
*
|
|
2389
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2390
|
+
*
|
|
2391
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2392
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2393
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2394
|
+
* See the License for the specific language governing permissions and
|
|
2395
|
+
* limitations under the License.
|
|
2396
|
+
*/
|
|
2397
|
+
function isV2(grecaptcha) {
|
|
2398
|
+
return (grecaptcha !== undefined &&
|
|
2399
|
+
grecaptcha.getResponse !== undefined);
|
|
2400
|
+
}
|
|
2401
|
+
function isEnterprise(grecaptcha) {
|
|
2402
|
+
return (grecaptcha !== undefined &&
|
|
2403
|
+
grecaptcha.enterprise !== undefined);
|
|
2404
|
+
}
|
|
2405
|
+
var RecaptchaConfig = /** @class */ (function () {
|
|
2406
|
+
function RecaptchaConfig(response) {
|
|
2407
|
+
/**
|
|
2408
|
+
* The reCAPTCHA site key.
|
|
2409
|
+
*/
|
|
2410
|
+
this.siteKey = '';
|
|
2411
|
+
/**
|
|
2412
|
+
* The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
|
|
2413
|
+
*/
|
|
2414
|
+
this.emailPasswordEnabled = false;
|
|
2415
|
+
if (response.recaptchaKey === undefined) {
|
|
2416
|
+
throw new Error('recaptchaKey undefined');
|
|
2417
|
+
}
|
|
2418
|
+
// Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
|
|
2419
|
+
this.siteKey = response.recaptchaKey.split('/')[3];
|
|
2420
|
+
this.emailPasswordEnabled = response.recaptchaEnforcementState.some(function (enforcementState) {
|
|
2421
|
+
return enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
|
|
2422
|
+
enforcementState.enforcementState !== 'OFF';
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
return RecaptchaConfig;
|
|
2426
|
+
}());
|
|
2427
|
+
|
|
2428
|
+
/**
|
|
2429
|
+
* @license
|
|
2430
|
+
* Copyright 2020 Google LLC
|
|
2431
|
+
*
|
|
2432
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2433
|
+
* you may not use this file except in compliance with the License.
|
|
2434
|
+
* You may obtain a copy of the License at
|
|
2435
|
+
*
|
|
2436
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2437
|
+
*
|
|
2438
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2439
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2440
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2441
|
+
* See the License for the specific language governing permissions and
|
|
2442
|
+
* limitations under the License.
|
|
2443
|
+
*/
|
|
2444
|
+
function getScriptParentElement() {
|
|
2445
|
+
var _a, _b;
|
|
2446
|
+
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
2447
|
+
}
|
|
2448
|
+
function _loadJS(url) {
|
|
2449
|
+
// TODO: consider adding timeout support & cancellation
|
|
2450
|
+
return new Promise(function (resolve, reject) {
|
|
2451
|
+
var el = document.createElement('script');
|
|
2452
|
+
el.setAttribute('src', url);
|
|
2453
|
+
el.onload = resolve;
|
|
2454
|
+
el.onerror = function (e) {
|
|
2455
|
+
var error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
2456
|
+
error.customData = e;
|
|
2457
|
+
reject(error);
|
|
2458
|
+
};
|
|
2459
|
+
el.type = 'text/javascript';
|
|
2460
|
+
el.charset = 'UTF-8';
|
|
2461
|
+
getScriptParentElement().appendChild(el);
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
function _generateCallbackName(prefix) {
|
|
2465
|
+
return "__".concat(prefix).concat(Math.floor(Math.random() * 1000000));
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2469
|
+
var RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
|
|
2470
|
+
var RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
|
|
2471
|
+
var RecaptchaEnterpriseVerifier = /** @class */ (function () {
|
|
2472
|
+
/**
|
|
2473
|
+
*
|
|
2474
|
+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
2475
|
+
*
|
|
2476
|
+
*/
|
|
2477
|
+
function RecaptchaEnterpriseVerifier(authExtern) {
|
|
2478
|
+
/**
|
|
2479
|
+
* Identifies the type of application verifier (e.g. "recaptcha-enterprise").
|
|
2480
|
+
*/
|
|
2481
|
+
this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
|
|
2482
|
+
this.auth = _castAuth(authExtern);
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Executes the verification process.
|
|
2486
|
+
*
|
|
2487
|
+
* @returns A Promise for a token that can be used to assert the validity of a request.
|
|
2488
|
+
*/
|
|
2489
|
+
RecaptchaEnterpriseVerifier.prototype.verify = function (action, forceRefresh) {
|
|
2490
|
+
if (action === void 0) { action = 'verify'; }
|
|
2491
|
+
if (forceRefresh === void 0) { forceRefresh = false; }
|
|
2492
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2493
|
+
function retrieveSiteKey(auth) {
|
|
2494
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2495
|
+
var _this = this;
|
|
2496
|
+
return tslib.__generator(this, function (_a) {
|
|
2497
|
+
if (!forceRefresh) {
|
|
2498
|
+
if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
|
|
2499
|
+
return [2 /*return*/, auth._agentRecaptchaConfig.siteKey];
|
|
2500
|
+
}
|
|
2501
|
+
if (auth.tenantId != null &&
|
|
2502
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
|
|
2503
|
+
return [2 /*return*/, auth._tenantRecaptchaConfigs[auth.tenantId].siteKey];
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
2507
|
+
return tslib.__generator(this, function (_a) {
|
|
2508
|
+
getRecaptchaConfig(auth, {
|
|
2509
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2510
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2511
|
+
})
|
|
2512
|
+
.then(function (response) {
|
|
2513
|
+
if (response.recaptchaKey === undefined) {
|
|
2514
|
+
reject(new Error('recaptcha Enterprise site key undefined'));
|
|
2515
|
+
}
|
|
2516
|
+
else {
|
|
2517
|
+
var config = new RecaptchaConfig(response);
|
|
2518
|
+
if (auth.tenantId == null) {
|
|
2519
|
+
auth._agentRecaptchaConfig = config;
|
|
2520
|
+
}
|
|
2521
|
+
else {
|
|
2522
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] = config;
|
|
2523
|
+
}
|
|
2524
|
+
return resolve(config.siteKey);
|
|
2525
|
+
}
|
|
2526
|
+
})
|
|
2527
|
+
.catch(function (error) {
|
|
2528
|
+
reject(error);
|
|
2529
|
+
});
|
|
2530
|
+
return [2 /*return*/];
|
|
2531
|
+
});
|
|
2532
|
+
}); })];
|
|
2533
|
+
});
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
function retrieveRecaptchaToken(siteKey, resolve, reject) {
|
|
2537
|
+
var grecaptcha = window.grecaptcha;
|
|
2538
|
+
if (isEnterprise(grecaptcha)) {
|
|
2539
|
+
grecaptcha.enterprise.ready(function () {
|
|
2540
|
+
try {
|
|
2541
|
+
grecaptcha.enterprise
|
|
2542
|
+
.execute(siteKey, { action: action })
|
|
2543
|
+
.then(function (token) {
|
|
2544
|
+
resolve(token);
|
|
2545
|
+
})
|
|
2546
|
+
.catch(function (error) {
|
|
2547
|
+
reject(error);
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
catch (error) {
|
|
2551
|
+
reject(error);
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
else {
|
|
2556
|
+
reject(Error('No reCAPTCHA enterprise script loaded.'));
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
var _this = this;
|
|
2560
|
+
return tslib.__generator(this, function (_a) {
|
|
2561
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
2562
|
+
retrieveSiteKey(_this.auth)
|
|
2563
|
+
.then(function (siteKey) {
|
|
2564
|
+
if (!forceRefresh && isEnterprise(window.grecaptcha)) {
|
|
2565
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2566
|
+
}
|
|
2567
|
+
else {
|
|
2568
|
+
if (typeof window === 'undefined') {
|
|
2569
|
+
reject(new Error('RecaptchaVerifier is only supported in browser'));
|
|
2570
|
+
return;
|
|
2571
|
+
}
|
|
2572
|
+
_loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
|
|
2573
|
+
.then(function () {
|
|
2574
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2575
|
+
})
|
|
2576
|
+
.catch(function (error) {
|
|
2577
|
+
reject(error);
|
|
2578
|
+
});
|
|
2579
|
+
}
|
|
2580
|
+
})
|
|
2581
|
+
.catch(function (error) {
|
|
2582
|
+
reject(error);
|
|
2583
|
+
});
|
|
2584
|
+
})];
|
|
2585
|
+
});
|
|
2586
|
+
});
|
|
2587
|
+
};
|
|
2588
|
+
return RecaptchaEnterpriseVerifier;
|
|
2589
|
+
}());
|
|
2590
|
+
function injectRecaptchaFields(auth, request, action, captchaResp) {
|
|
2591
|
+
if (captchaResp === void 0) { captchaResp = false; }
|
|
2592
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2593
|
+
var verifier, captchaResponse, newRequest;
|
|
2594
|
+
return tslib.__generator(this, function (_a) {
|
|
2595
|
+
switch (_a.label) {
|
|
2596
|
+
case 0:
|
|
2597
|
+
verifier = new RecaptchaEnterpriseVerifier(auth);
|
|
2598
|
+
_a.label = 1;
|
|
2599
|
+
case 1:
|
|
2600
|
+
_a.trys.push([1, 3, , 5]);
|
|
2601
|
+
return [4 /*yield*/, verifier.verify(action)];
|
|
2602
|
+
case 2:
|
|
2603
|
+
captchaResponse = _a.sent();
|
|
2604
|
+
return [3 /*break*/, 5];
|
|
2605
|
+
case 3:
|
|
2606
|
+
_a.sent();
|
|
2607
|
+
return [4 /*yield*/, verifier.verify(action, true)];
|
|
2608
|
+
case 4:
|
|
2609
|
+
captchaResponse = _a.sent();
|
|
2610
|
+
return [3 /*break*/, 5];
|
|
2611
|
+
case 5:
|
|
2612
|
+
newRequest = tslib.__assign({}, request);
|
|
2613
|
+
if (!captchaResp) {
|
|
2614
|
+
Object.assign(newRequest, { captchaResponse: captchaResponse });
|
|
2615
|
+
}
|
|
2616
|
+
else {
|
|
2617
|
+
Object.assign(newRequest, { 'captchaResp': captchaResponse });
|
|
2618
|
+
}
|
|
2619
|
+
Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
|
|
2620
|
+
Object.assign(newRequest, {
|
|
2621
|
+
'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2622
|
+
});
|
|
2623
|
+
return [2 /*return*/, newRequest];
|
|
2624
|
+
}
|
|
2625
|
+
});
|
|
2626
|
+
});
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2390
2629
|
/**
|
|
2391
2630
|
* @license
|
|
2392
2631
|
* Copyright 2022 Google LLC
|
|
@@ -2529,6 +2768,8 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2529
2768
|
this._initializationPromise = null;
|
|
2530
2769
|
this._popupRedirectResolver = null;
|
|
2531
2770
|
this._errorFactory = _DEFAULT_AUTH_ERROR_FACTORY;
|
|
2771
|
+
this._agentRecaptchaConfig = null;
|
|
2772
|
+
this._tenantRecaptchaConfigs = {};
|
|
2532
2773
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2533
2774
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2534
2775
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2858,6 +3099,41 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2858
3099
|
});
|
|
2859
3100
|
}); });
|
|
2860
3101
|
};
|
|
3102
|
+
AuthImpl.prototype.initializeRecaptchaConfig = function () {
|
|
3103
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
3104
|
+
var response, config, verifier;
|
|
3105
|
+
return tslib.__generator(this, function (_a) {
|
|
3106
|
+
switch (_a.label) {
|
|
3107
|
+
case 0: return [4 /*yield*/, getRecaptchaConfig(this, {
|
|
3108
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
3109
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
3110
|
+
})];
|
|
3111
|
+
case 1:
|
|
3112
|
+
response = _a.sent();
|
|
3113
|
+
config = new RecaptchaConfig(response);
|
|
3114
|
+
if (this.tenantId == null) {
|
|
3115
|
+
this._agentRecaptchaConfig = config;
|
|
3116
|
+
}
|
|
3117
|
+
else {
|
|
3118
|
+
this._tenantRecaptchaConfigs[this.tenantId] = config;
|
|
3119
|
+
}
|
|
3120
|
+
if (config.emailPasswordEnabled) {
|
|
3121
|
+
verifier = new RecaptchaEnterpriseVerifier(this);
|
|
3122
|
+
void verifier.verify();
|
|
3123
|
+
}
|
|
3124
|
+
return [2 /*return*/];
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
});
|
|
3128
|
+
};
|
|
3129
|
+
AuthImpl.prototype._getRecaptchaConfig = function () {
|
|
3130
|
+
if (this.tenantId == null) {
|
|
3131
|
+
return this._agentRecaptchaConfig;
|
|
3132
|
+
}
|
|
3133
|
+
else {
|
|
3134
|
+
return this._tenantRecaptchaConfigs[this.tenantId];
|
|
3135
|
+
}
|
|
3136
|
+
};
|
|
2861
3137
|
AuthImpl.prototype._getPersistence = function () {
|
|
2862
3138
|
return this.assertedPersistence.persistence.type;
|
|
2863
3139
|
};
|
|
@@ -3144,29 +3420,97 @@ var AuthImpl = /** @class */ (function () {
|
|
|
3144
3420
|
* Method to be used to cast down to our private implmentation of Auth.
|
|
3145
3421
|
* It will also handle unwrapping from the compat type if necessary
|
|
3146
3422
|
*
|
|
3147
|
-
* @param auth Auth object passed in from developer
|
|
3423
|
+
* @param auth Auth object passed in from developer
|
|
3424
|
+
*/
|
|
3425
|
+
function _castAuth(auth) {
|
|
3426
|
+
return util.getModularInstance(auth);
|
|
3427
|
+
}
|
|
3428
|
+
/** Helper class to wrap subscriber logic */
|
|
3429
|
+
var Subscription = /** @class */ (function () {
|
|
3430
|
+
function Subscription(auth) {
|
|
3431
|
+
var _this = this;
|
|
3432
|
+
this.auth = auth;
|
|
3433
|
+
this.observer = null;
|
|
3434
|
+
this.addObserver = util.createSubscribe(function (observer) { return (_this.observer = observer); });
|
|
3435
|
+
}
|
|
3436
|
+
Object.defineProperty(Subscription.prototype, "next", {
|
|
3437
|
+
get: function () {
|
|
3438
|
+
_assert(this.observer, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
3439
|
+
return this.observer.next.bind(this.observer);
|
|
3440
|
+
},
|
|
3441
|
+
enumerable: false,
|
|
3442
|
+
configurable: true
|
|
3443
|
+
});
|
|
3444
|
+
return Subscription;
|
|
3445
|
+
}());
|
|
3446
|
+
|
|
3447
|
+
/**
|
|
3448
|
+
* @license
|
|
3449
|
+
* Copyright 2020 Google LLC
|
|
3450
|
+
*
|
|
3451
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3452
|
+
* you may not use this file except in compliance with the License.
|
|
3453
|
+
* You may obtain a copy of the License at
|
|
3454
|
+
*
|
|
3455
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3456
|
+
*
|
|
3457
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3458
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3459
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3460
|
+
* See the License for the specific language governing permissions and
|
|
3461
|
+
* limitations under the License.
|
|
3462
|
+
*/
|
|
3463
|
+
/**
|
|
3464
|
+
* Initializes an {@link Auth} instance with fine-grained control over
|
|
3465
|
+
* {@link Dependencies}.
|
|
3466
|
+
*
|
|
3467
|
+
* @remarks
|
|
3468
|
+
*
|
|
3469
|
+
* This function allows more control over the {@link Auth} instance than
|
|
3470
|
+
* {@link getAuth}. `getAuth` uses platform-specific defaults to supply
|
|
3471
|
+
* the {@link Dependencies}. In general, `getAuth` is the easiest way to
|
|
3472
|
+
* initialize Auth and works for most use cases. Use `initializeAuth` if you
|
|
3473
|
+
* need control over which persistence layer is used, or to minimize bundle
|
|
3474
|
+
* size if you're not using either `signInWithPopup` or `signInWithRedirect`.
|
|
3475
|
+
*
|
|
3476
|
+
* For example, if your app only uses anonymous accounts and you only want
|
|
3477
|
+
* accounts saved for the current session, initialize `Auth` with:
|
|
3478
|
+
*
|
|
3479
|
+
* ```js
|
|
3480
|
+
* const auth = initializeAuth(app, {
|
|
3481
|
+
* persistence: browserSessionPersistence,
|
|
3482
|
+
* popupRedirectResolver: undefined,
|
|
3483
|
+
* });
|
|
3484
|
+
* ```
|
|
3485
|
+
*
|
|
3486
|
+
* @public
|
|
3148
3487
|
*/
|
|
3149
|
-
function
|
|
3150
|
-
|
|
3488
|
+
function initializeAuth(app$1, deps) {
|
|
3489
|
+
var provider = app._getProvider(app$1, 'auth');
|
|
3490
|
+
if (provider.isInitialized()) {
|
|
3491
|
+
var auth_1 = provider.getImmediate();
|
|
3492
|
+
var initialOptions = provider.getOptions();
|
|
3493
|
+
if (util.deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
|
|
3494
|
+
return auth_1;
|
|
3495
|
+
}
|
|
3496
|
+
else {
|
|
3497
|
+
_fail(auth_1, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
var auth = provider.initialize({ options: deps });
|
|
3501
|
+
return auth;
|
|
3151
3502
|
}
|
|
3152
|
-
|
|
3153
|
-
var
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
this.observer = null;
|
|
3158
|
-
this.addObserver = util.createSubscribe(function (observer) { return (_this.observer = observer); });
|
|
3503
|
+
function _initializeAuthInstance(auth, deps) {
|
|
3504
|
+
var persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
|
|
3505
|
+
var hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
|
|
3506
|
+
if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
|
|
3507
|
+
auth._updateErrorMap(deps.errorMap);
|
|
3159
3508
|
}
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
enumerable: false,
|
|
3166
|
-
configurable: true
|
|
3167
|
-
});
|
|
3168
|
-
return Subscription;
|
|
3169
|
-
}());
|
|
3509
|
+
// This promise is intended to float; auth initialization happens in the
|
|
3510
|
+
// background, meanwhile the auth object may be used by the app.
|
|
3511
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
3512
|
+
auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
|
|
3513
|
+
}
|
|
3170
3514
|
|
|
3171
3515
|
/**
|
|
3172
3516
|
* Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
|
|
@@ -3556,24 +3900,55 @@ var EmailAuthCredential = /** @class */ (function (_super) {
|
|
|
3556
3900
|
};
|
|
3557
3901
|
/** @internal */
|
|
3558
3902
|
EmailAuthCredential.prototype._getIdTokenResponse = function (auth) {
|
|
3903
|
+
var _a;
|
|
3559
3904
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3905
|
+
var _b, request_1, requestWithRecaptcha;
|
|
3906
|
+
var _this = this;
|
|
3907
|
+
return tslib.__generator(this, function (_c) {
|
|
3908
|
+
switch (_c.label) {
|
|
3909
|
+
case 0:
|
|
3910
|
+
_b = this.signInMethod;
|
|
3911
|
+
switch (_b) {
|
|
3912
|
+
case "password" /* SignInMethod.EMAIL_PASSWORD */: return [3 /*break*/, 1];
|
|
3913
|
+
case "emailLink" /* SignInMethod.EMAIL_LINK */: return [3 /*break*/, 4];
|
|
3914
|
+
}
|
|
3915
|
+
return [3 /*break*/, 5];
|
|
3916
|
+
case 1:
|
|
3917
|
+
request_1 = {
|
|
3918
|
+
returnSecureToken: true,
|
|
3919
|
+
email: this._email,
|
|
3920
|
+
password: this._password,
|
|
3921
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
3922
|
+
};
|
|
3923
|
+
if (!((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
3924
|
+
return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
|
|
3925
|
+
case 2:
|
|
3926
|
+
requestWithRecaptcha = _c.sent();
|
|
3927
|
+
return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
|
|
3928
|
+
case 3: return [2 /*return*/, signInWithPassword(auth, request_1).catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
3929
|
+
var requestWithRecaptcha;
|
|
3930
|
+
return tslib.__generator(this, function (_a) {
|
|
3931
|
+
switch (_a.label) {
|
|
3932
|
+
case 0:
|
|
3933
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
|
|
3934
|
+
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.');
|
|
3935
|
+
return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
|
|
3936
|
+
case 1:
|
|
3937
|
+
requestWithRecaptcha = _a.sent();
|
|
3938
|
+
return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
|
|
3939
|
+
case 2: return [2 /*return*/, Promise.reject(error)];
|
|
3940
|
+
}
|
|
3941
|
+
});
|
|
3942
|
+
}); })];
|
|
3943
|
+
case 4: return [2 /*return*/, signInWithEmailLink$1(auth, {
|
|
3944
|
+
email: this._email,
|
|
3945
|
+
oobCode: this._password
|
|
3946
|
+
})];
|
|
3947
|
+
case 5:
|
|
3574
3948
|
_fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
3949
|
+
_c.label = 6;
|
|
3950
|
+
case 6: return [2 /*return*/];
|
|
3575
3951
|
}
|
|
3576
|
-
return [2 /*return*/];
|
|
3577
3952
|
});
|
|
3578
3953
|
});
|
|
3579
3954
|
};
|
|
@@ -5760,23 +6135,61 @@ function _setActionCodeSettingsOnRequest(auth, request, actionCodeSettings) {
|
|
|
5760
6135
|
* @public
|
|
5761
6136
|
*/
|
|
5762
6137
|
function sendPasswordResetEmail(auth, email, actionCodeSettings) {
|
|
6138
|
+
var _a;
|
|
5763
6139
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
5764
|
-
var
|
|
5765
|
-
|
|
5766
|
-
|
|
6140
|
+
var authInternal, request, requestWithRecaptcha;
|
|
6141
|
+
var _this = this;
|
|
6142
|
+
return tslib.__generator(this, function (_b) {
|
|
6143
|
+
switch (_b.label) {
|
|
5767
6144
|
case 0:
|
|
5768
|
-
|
|
6145
|
+
authInternal = _castAuth(auth);
|
|
5769
6146
|
request = {
|
|
5770
6147
|
requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
|
|
5771
|
-
email: email
|
|
6148
|
+
email: email,
|
|
6149
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
5772
6150
|
};
|
|
6151
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
6152
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6153
|
+
case 1:
|
|
6154
|
+
requestWithRecaptcha = _b.sent();
|
|
5773
6155
|
if (actionCodeSettings) {
|
|
5774
|
-
_setActionCodeSettingsOnRequest(
|
|
6156
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
5775
6157
|
}
|
|
5776
|
-
return [4 /*yield*/, sendPasswordResetEmail$1(
|
|
5777
|
-
case
|
|
5778
|
-
|
|
5779
|
-
return [
|
|
6158
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
|
|
6159
|
+
case 2:
|
|
6160
|
+
_b.sent();
|
|
6161
|
+
return [3 /*break*/, 5];
|
|
6162
|
+
case 3:
|
|
6163
|
+
if (actionCodeSettings) {
|
|
6164
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
6165
|
+
}
|
|
6166
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, request)
|
|
6167
|
+
.catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
6168
|
+
var requestWithRecaptcha;
|
|
6169
|
+
return tslib.__generator(this, function (_a) {
|
|
6170
|
+
switch (_a.label) {
|
|
6171
|
+
case 0:
|
|
6172
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
|
|
6173
|
+
console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
|
|
6174
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6175
|
+
case 1:
|
|
6176
|
+
requestWithRecaptcha = _a.sent();
|
|
6177
|
+
if (actionCodeSettings) {
|
|
6178
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
6179
|
+
}
|
|
6180
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
|
|
6181
|
+
case 2:
|
|
6182
|
+
_a.sent();
|
|
6183
|
+
return [3 /*break*/, 4];
|
|
6184
|
+
case 3: return [2 /*return*/, Promise.reject(error)];
|
|
6185
|
+
case 4: return [2 /*return*/];
|
|
6186
|
+
}
|
|
6187
|
+
});
|
|
6188
|
+
}); })];
|
|
6189
|
+
case 4:
|
|
6190
|
+
_b.sent();
|
|
6191
|
+
_b.label = 5;
|
|
6192
|
+
case 5: return [2 /*return*/];
|
|
5780
6193
|
}
|
|
5781
6194
|
});
|
|
5782
6195
|
});
|
|
@@ -5921,25 +6334,54 @@ function verifyPasswordResetCode(auth, code) {
|
|
|
5921
6334
|
* @public
|
|
5922
6335
|
*/
|
|
5923
6336
|
function createUserWithEmailAndPassword(auth, email, password) {
|
|
6337
|
+
var _a;
|
|
5924
6338
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
5925
|
-
var authInternal, response, userCredential;
|
|
5926
|
-
|
|
5927
|
-
|
|
6339
|
+
var authInternal, request, signUpResponse, requestWithRecaptcha, response, userCredential;
|
|
6340
|
+
var _this = this;
|
|
6341
|
+
return tslib.__generator(this, function (_b) {
|
|
6342
|
+
switch (_b.label) {
|
|
5928
6343
|
case 0:
|
|
5929
6344
|
authInternal = _castAuth(auth);
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
6345
|
+
request = {
|
|
6346
|
+
returnSecureToken: true,
|
|
6347
|
+
email: email,
|
|
6348
|
+
password: password,
|
|
6349
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
6350
|
+
};
|
|
6351
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 2];
|
|
6352
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
|
|
5935
6353
|
case 1:
|
|
5936
|
-
|
|
5937
|
-
|
|
6354
|
+
requestWithRecaptcha = _b.sent();
|
|
6355
|
+
signUpResponse = signUp(authInternal, requestWithRecaptcha);
|
|
6356
|
+
return [3 /*break*/, 3];
|
|
5938
6357
|
case 2:
|
|
5939
|
-
|
|
6358
|
+
signUpResponse = signUp(authInternal, request).catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
6359
|
+
var requestWithRecaptcha;
|
|
6360
|
+
return tslib.__generator(this, function (_a) {
|
|
6361
|
+
switch (_a.label) {
|
|
6362
|
+
case 0:
|
|
6363
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
|
|
6364
|
+
console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
|
|
6365
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
|
|
6366
|
+
case 1:
|
|
6367
|
+
requestWithRecaptcha = _a.sent();
|
|
6368
|
+
return [2 /*return*/, signUp(authInternal, requestWithRecaptcha)];
|
|
6369
|
+
case 2: return [2 /*return*/, Promise.reject(error)];
|
|
6370
|
+
}
|
|
6371
|
+
});
|
|
6372
|
+
}); });
|
|
6373
|
+
_b.label = 3;
|
|
6374
|
+
case 3: return [4 /*yield*/, signUpResponse.catch(function (error) {
|
|
6375
|
+
return Promise.reject(error);
|
|
6376
|
+
})];
|
|
6377
|
+
case 4:
|
|
6378
|
+
response = _b.sent();
|
|
6379
|
+
return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
|
|
6380
|
+
case 5:
|
|
6381
|
+
userCredential = _b.sent();
|
|
5940
6382
|
return [4 /*yield*/, authInternal._updateCurrentUser(userCredential.user)];
|
|
5941
|
-
case
|
|
5942
|
-
|
|
6383
|
+
case 6:
|
|
6384
|
+
_b.sent();
|
|
5943
6385
|
return [2 /*return*/, userCredential];
|
|
5944
6386
|
}
|
|
5945
6387
|
});
|
|
@@ -6020,24 +6462,61 @@ function signInWithEmailAndPassword(auth, email, password) {
|
|
|
6020
6462
|
* @public
|
|
6021
6463
|
*/
|
|
6022
6464
|
function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
|
|
6465
|
+
var _a;
|
|
6023
6466
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6467
|
+
function setActionCodeSettings(request, actionCodeSettings) {
|
|
6468
|
+
_assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
6469
|
+
if (actionCodeSettings) {
|
|
6470
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
6471
|
+
}
|
|
6472
|
+
}
|
|
6473
|
+
var authInternal, request, requestWithRecaptcha;
|
|
6474
|
+
var _this = this;
|
|
6475
|
+
return tslib.__generator(this, function (_b) {
|
|
6476
|
+
switch (_b.label) {
|
|
6027
6477
|
case 0:
|
|
6028
|
-
|
|
6478
|
+
authInternal = _castAuth(auth);
|
|
6029
6479
|
request = {
|
|
6030
6480
|
requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
|
|
6031
|
-
email: email
|
|
6481
|
+
email: email,
|
|
6482
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
6032
6483
|
};
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
_setActionCodeSettingsOnRequest(authModular, request, actionCodeSettings);
|
|
6036
|
-
}
|
|
6037
|
-
return [4 /*yield*/, sendSignInLinkToEmail$1(authModular, request)];
|
|
6484
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
6485
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6038
6486
|
case 1:
|
|
6039
|
-
|
|
6040
|
-
|
|
6487
|
+
requestWithRecaptcha = _b.sent();
|
|
6488
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
6489
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
|
|
6490
|
+
case 2:
|
|
6491
|
+
_b.sent();
|
|
6492
|
+
return [3 /*break*/, 5];
|
|
6493
|
+
case 3:
|
|
6494
|
+
setActionCodeSettings(request, actionCodeSettings);
|
|
6495
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, request)
|
|
6496
|
+
.catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
6497
|
+
var requestWithRecaptcha;
|
|
6498
|
+
return tslib.__generator(this, function (_a) {
|
|
6499
|
+
switch (_a.label) {
|
|
6500
|
+
case 0:
|
|
6501
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
|
|
6502
|
+
console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
|
|
6503
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
6504
|
+
case 1:
|
|
6505
|
+
requestWithRecaptcha = _a.sent();
|
|
6506
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
6507
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
|
|
6508
|
+
case 2:
|
|
6509
|
+
_a.sent();
|
|
6510
|
+
return [3 /*break*/, 4];
|
|
6511
|
+
case 3: return [2 /*return*/, Promise.reject(error)];
|
|
6512
|
+
case 4: return [2 /*return*/];
|
|
6513
|
+
}
|
|
6514
|
+
});
|
|
6515
|
+
}); })];
|
|
6516
|
+
case 4:
|
|
6517
|
+
_b.sent();
|
|
6518
|
+
_b.label = 5;
|
|
6519
|
+
case 5: return [2 /*return*/];
|
|
6041
6520
|
}
|
|
6042
6521
|
});
|
|
6043
6522
|
});
|
|
@@ -6633,6 +7112,35 @@ function getAdditionalUserInfo(userCredential) {
|
|
|
6633
7112
|
function setPersistence(auth, persistence) {
|
|
6634
7113
|
return util.getModularInstance(auth).setPersistence(persistence);
|
|
6635
7114
|
}
|
|
7115
|
+
/**
|
|
7116
|
+
* Loads the reCAPTCHA configuration into the `Auth` instance.
|
|
7117
|
+
*
|
|
7118
|
+
* @remarks
|
|
7119
|
+
* This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
|
|
7120
|
+
* verification flow should be triggered for each auth provider, into the
|
|
7121
|
+
* current Auth session.
|
|
7122
|
+
*
|
|
7123
|
+
* If initializeRecaptchaConfig() is not invoked, the auth flow will always start
|
|
7124
|
+
* without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
|
|
7125
|
+
* verification, the SDK will transparently load the reCAPTCHA config and restart the
|
|
7126
|
+
* auth flows.
|
|
7127
|
+
*
|
|
7128
|
+
* Thus, by calling this optional method, you will reduce the latency of future auth flows.
|
|
7129
|
+
* Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
|
|
7130
|
+
*
|
|
7131
|
+
* @example
|
|
7132
|
+
* ```javascript
|
|
7133
|
+
* initializeRecaptchaConfig(auth);
|
|
7134
|
+
* ```
|
|
7135
|
+
*
|
|
7136
|
+
* @param auth - The {@link Auth} instance.
|
|
7137
|
+
*
|
|
7138
|
+
* @public
|
|
7139
|
+
*/
|
|
7140
|
+
function initializeRecaptchaConfig(auth) {
|
|
7141
|
+
var authInternal = _castAuth(auth);
|
|
7142
|
+
return authInternal.initializeRecaptchaConfig();
|
|
7143
|
+
}
|
|
6636
7144
|
/**
|
|
6637
7145
|
* Adds an observer for changes to the signed-in user's ID token.
|
|
6638
7146
|
*
|
|
@@ -7037,7 +7545,7 @@ function multiFactor(user) {
|
|
|
7037
7545
|
}
|
|
7038
7546
|
|
|
7039
7547
|
var name = "@firebase/auth";
|
|
7040
|
-
var version = "0.22.0-canary.
|
|
7548
|
+
var version = "0.22.0-canary.ecb4454c3";
|
|
7041
7549
|
|
|
7042
7550
|
/**
|
|
7043
7551
|
* @license
|
|
@@ -7326,33 +7834,6 @@ function finalizeSignInTotpMfa(auth, request) {
|
|
|
7326
7834
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
7327
7835
|
}
|
|
7328
7836
|
|
|
7329
|
-
/**
|
|
7330
|
-
* @license
|
|
7331
|
-
* Copyright 2020 Google LLC
|
|
7332
|
-
*
|
|
7333
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7334
|
-
* you may not use this file except in compliance with the License.
|
|
7335
|
-
* You may obtain a copy of the License at
|
|
7336
|
-
*
|
|
7337
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7338
|
-
*
|
|
7339
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7340
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7341
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7342
|
-
* See the License for the specific language governing permissions and
|
|
7343
|
-
* limitations under the License.
|
|
7344
|
-
*/
|
|
7345
|
-
function getRecaptchaParams(auth) {
|
|
7346
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7347
|
-
return tslib.__generator(this, function (_a) {
|
|
7348
|
-
switch (_a.label) {
|
|
7349
|
-
case 0: return [4 /*yield*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)];
|
|
7350
|
-
case 1: return [2 /*return*/, ((_a.sent()).recaptchaSiteKey || '')];
|
|
7351
|
-
}
|
|
7352
|
-
});
|
|
7353
|
-
});
|
|
7354
|
-
}
|
|
7355
|
-
|
|
7356
7837
|
/**
|
|
7357
7838
|
* @license
|
|
7358
7839
|
* Copyright 2020 Google LLC
|
|
@@ -7432,46 +7913,6 @@ function _getWorkerGlobalScope() {
|
|
|
7432
7913
|
return _isWorker() ? self : null;
|
|
7433
7914
|
}
|
|
7434
7915
|
|
|
7435
|
-
/**
|
|
7436
|
-
* @license
|
|
7437
|
-
* Copyright 2020 Google LLC
|
|
7438
|
-
*
|
|
7439
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7440
|
-
* you may not use this file except in compliance with the License.
|
|
7441
|
-
* You may obtain a copy of the License at
|
|
7442
|
-
*
|
|
7443
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7444
|
-
*
|
|
7445
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7446
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7447
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7448
|
-
* See the License for the specific language governing permissions and
|
|
7449
|
-
* limitations under the License.
|
|
7450
|
-
*/
|
|
7451
|
-
function getScriptParentElement() {
|
|
7452
|
-
var _a, _b;
|
|
7453
|
-
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
7454
|
-
}
|
|
7455
|
-
function _loadJS(url) {
|
|
7456
|
-
// TODO: consider adding timeout support & cancellation
|
|
7457
|
-
return new Promise(function (resolve, reject) {
|
|
7458
|
-
var el = document.createElement('script');
|
|
7459
|
-
el.setAttribute('src', url);
|
|
7460
|
-
el.onload = resolve;
|
|
7461
|
-
el.onerror = function (e) {
|
|
7462
|
-
var error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
7463
|
-
error.customData = e;
|
|
7464
|
-
reject(error);
|
|
7465
|
-
};
|
|
7466
|
-
el.type = 'text/javascript';
|
|
7467
|
-
el.charset = 'UTF-8';
|
|
7468
|
-
getScriptParentElement().appendChild(el);
|
|
7469
|
-
});
|
|
7470
|
-
}
|
|
7471
|
-
function _generateCallbackName(prefix) {
|
|
7472
|
-
return "__".concat(prefix).concat(Math.floor(Math.random() * 1000000));
|
|
7473
|
-
}
|
|
7474
|
-
|
|
7475
7916
|
/**
|
|
7476
7917
|
* @license
|
|
7477
7918
|
* Copyright 2020 Google LLC
|
|
@@ -7649,7 +8090,7 @@ var ReCaptchaLoaderImpl = /** @class */ (function () {
|
|
|
7649
8090
|
var _this = this;
|
|
7650
8091
|
if (hl === void 0) { hl = ''; }
|
|
7651
8092
|
_assert(isHostLanguageValid(hl), auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
7652
|
-
if (this.shouldResolveImmediately(hl)) {
|
|
8093
|
+
if (this.shouldResolveImmediately(hl) && isV2(_window().grecaptcha)) {
|
|
7653
8094
|
return Promise.resolve(_window().grecaptcha);
|
|
7654
8095
|
}
|
|
7655
8096
|
return new Promise(function (resolve, reject) {
|
|
@@ -7660,7 +8101,7 @@ var ReCaptchaLoaderImpl = /** @class */ (function () {
|
|
|
7660
8101
|
_window().clearTimeout(networkTimeout);
|
|
7661
8102
|
delete _window()[_JSLOAD_CALLBACK];
|
|
7662
8103
|
var recaptcha = _window().grecaptcha;
|
|
7663
|
-
if (!recaptcha) {
|
|
8104
|
+
if (!recaptcha || !isV2(recaptcha)) {
|
|
7664
8105
|
reject(_createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
|
|
7665
8106
|
return;
|
|
7666
8107
|
}
|
|
@@ -8537,6 +8978,7 @@ exports.getIdTokenResult = getIdTokenResult;
|
|
|
8537
8978
|
exports.getMultiFactorResolver = getMultiFactorResolver;
|
|
8538
8979
|
exports.inMemoryPersistence = inMemoryPersistence;
|
|
8539
8980
|
exports.initializeAuth = initializeAuth;
|
|
8981
|
+
exports.initializeRecaptchaConfig = initializeRecaptchaConfig;
|
|
8540
8982
|
exports.isSignInWithEmailLink = isSignInWithEmailLink;
|
|
8541
8983
|
exports.linkWithCredential = linkWithCredential;
|
|
8542
8984
|
exports.linkWithPhoneNumber = linkWithPhoneNumber;
|
|
@@ -8571,4 +9013,4 @@ exports.updateProfile = updateProfile;
|
|
|
8571
9013
|
exports.useDeviceLanguage = useDeviceLanguage;
|
|
8572
9014
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
8573
9015
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
8574
|
-
//# sourceMappingURL=phone-
|
|
9016
|
+
//# sourceMappingURL=phone-7f3181c6.js.map
|