@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
|
@@ -168,6 +168,14 @@ function _debugErrorMap() {
|
|
|
168
168
|
'different options. To avoid this error, call initializeAuth() with the ' +
|
|
169
169
|
'same options as when it was originally called, or call getAuth() to return the' +
|
|
170
170
|
' already initialized instance.',
|
|
171
|
+
_a["missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is missing when sending request to the backend.',
|
|
172
|
+
_a["invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is invalid when sending request to the backend.',
|
|
173
|
+
_a["invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */] = 'The reCAPTCHA action is invalid when sending request to the backend.',
|
|
174
|
+
_a["recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */] = 'reCAPTCHA Enterprise integration is not enabled for this project.',
|
|
175
|
+
_a["missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */] = 'The reCAPTCHA client type is missing when sending request to the backend.',
|
|
176
|
+
_a["missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is missing when sending request to the backend.',
|
|
177
|
+
_a["invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */] = 'Invalid request parameters.',
|
|
178
|
+
_a["invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is invalid when sending request to the backend.',
|
|
171
179
|
_a;
|
|
172
180
|
}
|
|
173
181
|
function _prodErrorMap() {
|
|
@@ -304,7 +312,15 @@ var AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
|
|
|
304
312
|
USER_SIGNED_OUT: 'auth/user-signed-out',
|
|
305
313
|
WEAK_PASSWORD: 'auth/weak-password',
|
|
306
314
|
WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
|
|
307
|
-
ALREADY_INITIALIZED: 'auth/already-initialized'
|
|
315
|
+
ALREADY_INITIALIZED: 'auth/already-initialized',
|
|
316
|
+
RECAPTCHA_NOT_ENABLED: 'auth/recaptcha-not-enabled',
|
|
317
|
+
MISSING_RECAPTCHA_TOKEN: 'auth/missing-recaptcha-token',
|
|
318
|
+
INVALID_RECAPTCHA_TOKEN: 'auth/invalid-recaptcha-token',
|
|
319
|
+
INVALID_RECAPTCHA_ACTION: 'auth/invalid-recaptcha-action',
|
|
320
|
+
MISSING_CLIENT_TYPE: 'auth/missing-client-type',
|
|
321
|
+
MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version',
|
|
322
|
+
INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version',
|
|
323
|
+
INVALID_REQ_TYPE: 'auth/invalid-req-type'
|
|
308
324
|
};
|
|
309
325
|
|
|
310
326
|
/**
|
|
@@ -533,7 +549,7 @@ function _initializeAuthInstance(auth, deps) {
|
|
|
533
549
|
}
|
|
534
550
|
|
|
535
551
|
var name = "@firebase/auth";
|
|
536
|
-
var version = "0.22.0-canary.
|
|
552
|
+
var version = "0.22.0-canary.ecb4454c3";
|
|
537
553
|
|
|
538
554
|
/**
|
|
539
555
|
* @license
|
|
@@ -963,6 +979,15 @@ var SERVER_ERROR_MAP = (_a$1 = {},
|
|
|
963
979
|
_a$1["SECOND_FACTOR_LIMIT_EXCEEDED" /* ServerError.SECOND_FACTOR_LIMIT_EXCEEDED */] = "maximum-second-factor-count-exceeded" /* AuthErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED */,
|
|
964
980
|
// Blocking functions related errors.
|
|
965
981
|
_a$1["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */] = "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
|
|
982
|
+
// Recaptcha related errors.
|
|
983
|
+
_a$1["RECAPTCHA_NOT_ENABLED" /* ServerError.RECAPTCHA_NOT_ENABLED */] = "recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */,
|
|
984
|
+
_a$1["MISSING_RECAPTCHA_TOKEN" /* ServerError.MISSING_RECAPTCHA_TOKEN */] = "missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */,
|
|
985
|
+
_a$1["INVALID_RECAPTCHA_TOKEN" /* ServerError.INVALID_RECAPTCHA_TOKEN */] = "invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */,
|
|
986
|
+
_a$1["INVALID_RECAPTCHA_ACTION" /* ServerError.INVALID_RECAPTCHA_ACTION */] = "invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */,
|
|
987
|
+
_a$1["MISSING_CLIENT_TYPE" /* ServerError.MISSING_CLIENT_TYPE */] = "missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */,
|
|
988
|
+
_a$1["MISSING_RECAPTCHA_VERSION" /* ServerError.MISSING_RECAPTCHA_VERSION */] = "missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */,
|
|
989
|
+
_a$1["INVALID_RECAPTCHA_VERSION" /* ServerError.INVALID_RECAPTCHA_VERSION */] = "invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */,
|
|
990
|
+
_a$1["INVALID_REQ_TYPE" /* ServerError.INVALID_REQ_TYPE */] = "invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */,
|
|
966
991
|
_a$1);
|
|
967
992
|
|
|
968
993
|
/**
|
|
@@ -2340,6 +2365,271 @@ var PersistenceUserManager = /** @class */ (function () {
|
|
|
2340
2365
|
return PersistenceUserManager;
|
|
2341
2366
|
}());
|
|
2342
2367
|
|
|
2368
|
+
/**
|
|
2369
|
+
* @license
|
|
2370
|
+
* Copyright 2020 Google LLC
|
|
2371
|
+
*
|
|
2372
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2373
|
+
* you may not use this file except in compliance with the License.
|
|
2374
|
+
* You may obtain a copy of the License at
|
|
2375
|
+
*
|
|
2376
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2377
|
+
*
|
|
2378
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2379
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2380
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2381
|
+
* See the License for the specific language governing permissions and
|
|
2382
|
+
* limitations under the License.
|
|
2383
|
+
*/
|
|
2384
|
+
function getRecaptchaConfig(auth, request) {
|
|
2385
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2386
|
+
return __generator(this, function (_a) {
|
|
2387
|
+
return [2 /*return*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request))];
|
|
2388
|
+
});
|
|
2389
|
+
});
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* @license
|
|
2394
|
+
* Copyright 2020 Google LLC
|
|
2395
|
+
*
|
|
2396
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2397
|
+
* you may not use this file except in compliance with the License.
|
|
2398
|
+
* You may obtain a copy of the License at
|
|
2399
|
+
*
|
|
2400
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2401
|
+
*
|
|
2402
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2403
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2404
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2405
|
+
* See the License for the specific language governing permissions and
|
|
2406
|
+
* limitations under the License.
|
|
2407
|
+
*/
|
|
2408
|
+
function isEnterprise(grecaptcha) {
|
|
2409
|
+
return (grecaptcha !== undefined &&
|
|
2410
|
+
grecaptcha.enterprise !== undefined);
|
|
2411
|
+
}
|
|
2412
|
+
var RecaptchaConfig = /** @class */ (function () {
|
|
2413
|
+
function RecaptchaConfig(response) {
|
|
2414
|
+
/**
|
|
2415
|
+
* The reCAPTCHA site key.
|
|
2416
|
+
*/
|
|
2417
|
+
this.siteKey = '';
|
|
2418
|
+
/**
|
|
2419
|
+
* The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
|
|
2420
|
+
*/
|
|
2421
|
+
this.emailPasswordEnabled = false;
|
|
2422
|
+
if (response.recaptchaKey === undefined) {
|
|
2423
|
+
throw new Error('recaptchaKey undefined');
|
|
2424
|
+
}
|
|
2425
|
+
// Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
|
|
2426
|
+
this.siteKey = response.recaptchaKey.split('/')[3];
|
|
2427
|
+
this.emailPasswordEnabled = response.recaptchaEnforcementState.some(function (enforcementState) {
|
|
2428
|
+
return enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
|
|
2429
|
+
enforcementState.enforcementState !== 'OFF';
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
return RecaptchaConfig;
|
|
2433
|
+
}());
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* @license
|
|
2437
|
+
* Copyright 2020 Google LLC
|
|
2438
|
+
*
|
|
2439
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2440
|
+
* you may not use this file except in compliance with the License.
|
|
2441
|
+
* You may obtain a copy of the License at
|
|
2442
|
+
*
|
|
2443
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2444
|
+
*
|
|
2445
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2446
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2447
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2448
|
+
* See the License for the specific language governing permissions and
|
|
2449
|
+
* limitations under the License.
|
|
2450
|
+
*/
|
|
2451
|
+
function getScriptParentElement() {
|
|
2452
|
+
var _a, _b;
|
|
2453
|
+
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
2454
|
+
}
|
|
2455
|
+
function _loadJS(url) {
|
|
2456
|
+
// TODO: consider adding timeout support & cancellation
|
|
2457
|
+
return new Promise(function (resolve, reject) {
|
|
2458
|
+
var el = document.createElement('script');
|
|
2459
|
+
el.setAttribute('src', url);
|
|
2460
|
+
el.onload = resolve;
|
|
2461
|
+
el.onerror = function (e) {
|
|
2462
|
+
var error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
2463
|
+
error.customData = e;
|
|
2464
|
+
reject(error);
|
|
2465
|
+
};
|
|
2466
|
+
el.type = 'text/javascript';
|
|
2467
|
+
el.charset = 'UTF-8';
|
|
2468
|
+
getScriptParentElement().appendChild(el);
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2473
|
+
var RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
|
|
2474
|
+
var RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
|
|
2475
|
+
var RecaptchaEnterpriseVerifier = /** @class */ (function () {
|
|
2476
|
+
/**
|
|
2477
|
+
*
|
|
2478
|
+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
2479
|
+
*
|
|
2480
|
+
*/
|
|
2481
|
+
function RecaptchaEnterpriseVerifier(authExtern) {
|
|
2482
|
+
/**
|
|
2483
|
+
* Identifies the type of application verifier (e.g. "recaptcha-enterprise").
|
|
2484
|
+
*/
|
|
2485
|
+
this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
|
|
2486
|
+
this.auth = _castAuth(authExtern);
|
|
2487
|
+
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Executes the verification process.
|
|
2490
|
+
*
|
|
2491
|
+
* @returns A Promise for a token that can be used to assert the validity of a request.
|
|
2492
|
+
*/
|
|
2493
|
+
RecaptchaEnterpriseVerifier.prototype.verify = function (action, forceRefresh) {
|
|
2494
|
+
if (action === void 0) { action = 'verify'; }
|
|
2495
|
+
if (forceRefresh === void 0) { forceRefresh = false; }
|
|
2496
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2497
|
+
function retrieveSiteKey(auth) {
|
|
2498
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2499
|
+
var _this = this;
|
|
2500
|
+
return __generator(this, function (_a) {
|
|
2501
|
+
if (!forceRefresh) {
|
|
2502
|
+
if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
|
|
2503
|
+
return [2 /*return*/, auth._agentRecaptchaConfig.siteKey];
|
|
2504
|
+
}
|
|
2505
|
+
if (auth.tenantId != null &&
|
|
2506
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
|
|
2507
|
+
return [2 /*return*/, auth._tenantRecaptchaConfigs[auth.tenantId].siteKey];
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
2511
|
+
return __generator(this, function (_a) {
|
|
2512
|
+
getRecaptchaConfig(auth, {
|
|
2513
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2514
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2515
|
+
})
|
|
2516
|
+
.then(function (response) {
|
|
2517
|
+
if (response.recaptchaKey === undefined) {
|
|
2518
|
+
reject(new Error('recaptcha Enterprise site key undefined'));
|
|
2519
|
+
}
|
|
2520
|
+
else {
|
|
2521
|
+
var config = new RecaptchaConfig(response);
|
|
2522
|
+
if (auth.tenantId == null) {
|
|
2523
|
+
auth._agentRecaptchaConfig = config;
|
|
2524
|
+
}
|
|
2525
|
+
else {
|
|
2526
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] = config;
|
|
2527
|
+
}
|
|
2528
|
+
return resolve(config.siteKey);
|
|
2529
|
+
}
|
|
2530
|
+
})
|
|
2531
|
+
.catch(function (error) {
|
|
2532
|
+
reject(error);
|
|
2533
|
+
});
|
|
2534
|
+
return [2 /*return*/];
|
|
2535
|
+
});
|
|
2536
|
+
}); })];
|
|
2537
|
+
});
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
function retrieveRecaptchaToken(siteKey, resolve, reject) {
|
|
2541
|
+
var grecaptcha = window.grecaptcha;
|
|
2542
|
+
if (isEnterprise(grecaptcha)) {
|
|
2543
|
+
grecaptcha.enterprise.ready(function () {
|
|
2544
|
+
try {
|
|
2545
|
+
grecaptcha.enterprise
|
|
2546
|
+
.execute(siteKey, { action: action })
|
|
2547
|
+
.then(function (token) {
|
|
2548
|
+
resolve(token);
|
|
2549
|
+
})
|
|
2550
|
+
.catch(function (error) {
|
|
2551
|
+
reject(error);
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
catch (error) {
|
|
2555
|
+
reject(error);
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2558
|
+
}
|
|
2559
|
+
else {
|
|
2560
|
+
reject(Error('No reCAPTCHA enterprise script loaded.'));
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
var _this = this;
|
|
2564
|
+
return __generator(this, function (_a) {
|
|
2565
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
2566
|
+
retrieveSiteKey(_this.auth)
|
|
2567
|
+
.then(function (siteKey) {
|
|
2568
|
+
if (!forceRefresh && isEnterprise(window.grecaptcha)) {
|
|
2569
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2570
|
+
}
|
|
2571
|
+
else {
|
|
2572
|
+
if (typeof window === 'undefined') {
|
|
2573
|
+
reject(new Error('RecaptchaVerifier is only supported in browser'));
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
_loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
|
|
2577
|
+
.then(function () {
|
|
2578
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2579
|
+
})
|
|
2580
|
+
.catch(function (error) {
|
|
2581
|
+
reject(error);
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
})
|
|
2585
|
+
.catch(function (error) {
|
|
2586
|
+
reject(error);
|
|
2587
|
+
});
|
|
2588
|
+
})];
|
|
2589
|
+
});
|
|
2590
|
+
});
|
|
2591
|
+
};
|
|
2592
|
+
return RecaptchaEnterpriseVerifier;
|
|
2593
|
+
}());
|
|
2594
|
+
function injectRecaptchaFields(auth, request, action, captchaResp) {
|
|
2595
|
+
if (captchaResp === void 0) { captchaResp = false; }
|
|
2596
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2597
|
+
var verifier, captchaResponse, newRequest;
|
|
2598
|
+
return __generator(this, function (_a) {
|
|
2599
|
+
switch (_a.label) {
|
|
2600
|
+
case 0:
|
|
2601
|
+
verifier = new RecaptchaEnterpriseVerifier(auth);
|
|
2602
|
+
_a.label = 1;
|
|
2603
|
+
case 1:
|
|
2604
|
+
_a.trys.push([1, 3, , 5]);
|
|
2605
|
+
return [4 /*yield*/, verifier.verify(action)];
|
|
2606
|
+
case 2:
|
|
2607
|
+
captchaResponse = _a.sent();
|
|
2608
|
+
return [3 /*break*/, 5];
|
|
2609
|
+
case 3:
|
|
2610
|
+
_a.sent();
|
|
2611
|
+
return [4 /*yield*/, verifier.verify(action, true)];
|
|
2612
|
+
case 4:
|
|
2613
|
+
captchaResponse = _a.sent();
|
|
2614
|
+
return [3 /*break*/, 5];
|
|
2615
|
+
case 5:
|
|
2616
|
+
newRequest = __assign({}, request);
|
|
2617
|
+
if (!captchaResp) {
|
|
2618
|
+
Object.assign(newRequest, { captchaResponse: captchaResponse });
|
|
2619
|
+
}
|
|
2620
|
+
else {
|
|
2621
|
+
Object.assign(newRequest, { 'captchaResp': captchaResponse });
|
|
2622
|
+
}
|
|
2623
|
+
Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
|
|
2624
|
+
Object.assign(newRequest, {
|
|
2625
|
+
'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2626
|
+
});
|
|
2627
|
+
return [2 /*return*/, newRequest];
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2343
2633
|
/**
|
|
2344
2634
|
* @license
|
|
2345
2635
|
* Copyright 2022 Google LLC
|
|
@@ -2482,6 +2772,8 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2482
2772
|
this._initializationPromise = null;
|
|
2483
2773
|
this._popupRedirectResolver = null;
|
|
2484
2774
|
this._errorFactory = _DEFAULT_AUTH_ERROR_FACTORY;
|
|
2775
|
+
this._agentRecaptchaConfig = null;
|
|
2776
|
+
this._tenantRecaptchaConfigs = {};
|
|
2485
2777
|
// Tracks the last notified UID for state change listeners to prevent
|
|
2486
2778
|
// repeated calls to the callbacks. Undefined means it's never been
|
|
2487
2779
|
// called, whereas null means it's been called with a signed out user
|
|
@@ -2811,6 +3103,41 @@ var AuthImpl = /** @class */ (function () {
|
|
|
2811
3103
|
});
|
|
2812
3104
|
}); });
|
|
2813
3105
|
};
|
|
3106
|
+
AuthImpl.prototype.initializeRecaptchaConfig = function () {
|
|
3107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3108
|
+
var response, config, verifier;
|
|
3109
|
+
return __generator(this, function (_a) {
|
|
3110
|
+
switch (_a.label) {
|
|
3111
|
+
case 0: return [4 /*yield*/, getRecaptchaConfig(this, {
|
|
3112
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
3113
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
3114
|
+
})];
|
|
3115
|
+
case 1:
|
|
3116
|
+
response = _a.sent();
|
|
3117
|
+
config = new RecaptchaConfig(response);
|
|
3118
|
+
if (this.tenantId == null) {
|
|
3119
|
+
this._agentRecaptchaConfig = config;
|
|
3120
|
+
}
|
|
3121
|
+
else {
|
|
3122
|
+
this._tenantRecaptchaConfigs[this.tenantId] = config;
|
|
3123
|
+
}
|
|
3124
|
+
if (config.emailPasswordEnabled) {
|
|
3125
|
+
verifier = new RecaptchaEnterpriseVerifier(this);
|
|
3126
|
+
void verifier.verify();
|
|
3127
|
+
}
|
|
3128
|
+
return [2 /*return*/];
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3131
|
+
});
|
|
3132
|
+
};
|
|
3133
|
+
AuthImpl.prototype._getRecaptchaConfig = function () {
|
|
3134
|
+
if (this.tenantId == null) {
|
|
3135
|
+
return this._agentRecaptchaConfig;
|
|
3136
|
+
}
|
|
3137
|
+
else {
|
|
3138
|
+
return this._tenantRecaptchaConfigs[this.tenantId];
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
2814
3141
|
AuthImpl.prototype._getPersistence = function () {
|
|
2815
3142
|
return this.assertedPersistence.persistence.type;
|
|
2816
3143
|
};
|
|
@@ -4679,24 +5006,55 @@ var EmailAuthCredential = /** @class */ (function (_super) {
|
|
|
4679
5006
|
};
|
|
4680
5007
|
/** @internal */
|
|
4681
5008
|
EmailAuthCredential.prototype._getIdTokenResponse = function (auth) {
|
|
5009
|
+
var _a;
|
|
4682
5010
|
return __awaiter(this, void 0, void 0, function () {
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
5011
|
+
var _b, request_1, requestWithRecaptcha;
|
|
5012
|
+
var _this = this;
|
|
5013
|
+
return __generator(this, function (_c) {
|
|
5014
|
+
switch (_c.label) {
|
|
5015
|
+
case 0:
|
|
5016
|
+
_b = this.signInMethod;
|
|
5017
|
+
switch (_b) {
|
|
5018
|
+
case "password" /* SignInMethod.EMAIL_PASSWORD */: return [3 /*break*/, 1];
|
|
5019
|
+
case "emailLink" /* SignInMethod.EMAIL_LINK */: return [3 /*break*/, 4];
|
|
5020
|
+
}
|
|
5021
|
+
return [3 /*break*/, 5];
|
|
5022
|
+
case 1:
|
|
5023
|
+
request_1 = {
|
|
5024
|
+
returnSecureToken: true,
|
|
5025
|
+
email: this._email,
|
|
5026
|
+
password: this._password,
|
|
5027
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
5028
|
+
};
|
|
5029
|
+
if (!((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
5030
|
+
return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
|
|
5031
|
+
case 2:
|
|
5032
|
+
requestWithRecaptcha = _c.sent();
|
|
5033
|
+
return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
|
|
5034
|
+
case 3: return [2 /*return*/, signInWithPassword(auth, request_1).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
5035
|
+
var requestWithRecaptcha;
|
|
5036
|
+
return __generator(this, function (_a) {
|
|
5037
|
+
switch (_a.label) {
|
|
5038
|
+
case 0:
|
|
5039
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
|
|
5040
|
+
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.');
|
|
5041
|
+
return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
|
|
5042
|
+
case 1:
|
|
5043
|
+
requestWithRecaptcha = _a.sent();
|
|
5044
|
+
return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
|
|
5045
|
+
case 2: return [2 /*return*/, Promise.reject(error)];
|
|
5046
|
+
}
|
|
5047
|
+
});
|
|
5048
|
+
}); })];
|
|
5049
|
+
case 4: return [2 /*return*/, signInWithEmailLink$1(auth, {
|
|
5050
|
+
email: this._email,
|
|
5051
|
+
oobCode: this._password
|
|
5052
|
+
})];
|
|
5053
|
+
case 5:
|
|
4697
5054
|
_fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
5055
|
+
_c.label = 6;
|
|
5056
|
+
case 6: return [2 /*return*/];
|
|
4698
5057
|
}
|
|
4699
|
-
return [2 /*return*/];
|
|
4700
5058
|
});
|
|
4701
5059
|
});
|
|
4702
5060
|
};
|
|
@@ -6876,23 +7234,61 @@ function _setActionCodeSettingsOnRequest(auth, request, actionCodeSettings) {
|
|
|
6876
7234
|
* @public
|
|
6877
7235
|
*/
|
|
6878
7236
|
function sendPasswordResetEmail(auth, email, actionCodeSettings) {
|
|
7237
|
+
var _a;
|
|
6879
7238
|
return __awaiter(this, void 0, void 0, function () {
|
|
6880
|
-
var
|
|
6881
|
-
|
|
6882
|
-
|
|
7239
|
+
var authInternal, request, requestWithRecaptcha;
|
|
7240
|
+
var _this = this;
|
|
7241
|
+
return __generator(this, function (_b) {
|
|
7242
|
+
switch (_b.label) {
|
|
6883
7243
|
case 0:
|
|
6884
|
-
|
|
7244
|
+
authInternal = _castAuth(auth);
|
|
6885
7245
|
request = {
|
|
6886
7246
|
requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
|
|
6887
|
-
email: email
|
|
7247
|
+
email: email,
|
|
7248
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
6888
7249
|
};
|
|
7250
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
7251
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
7252
|
+
case 1:
|
|
7253
|
+
requestWithRecaptcha = _b.sent();
|
|
6889
7254
|
if (actionCodeSettings) {
|
|
6890
|
-
_setActionCodeSettingsOnRequest(
|
|
7255
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
6891
7256
|
}
|
|
6892
|
-
return [4 /*yield*/, sendPasswordResetEmail$1(
|
|
6893
|
-
case
|
|
6894
|
-
|
|
6895
|
-
return [
|
|
7257
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
|
|
7258
|
+
case 2:
|
|
7259
|
+
_b.sent();
|
|
7260
|
+
return [3 /*break*/, 5];
|
|
7261
|
+
case 3:
|
|
7262
|
+
if (actionCodeSettings) {
|
|
7263
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
7264
|
+
}
|
|
7265
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, request)
|
|
7266
|
+
.catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
7267
|
+
var requestWithRecaptcha;
|
|
7268
|
+
return __generator(this, function (_a) {
|
|
7269
|
+
switch (_a.label) {
|
|
7270
|
+
case 0:
|
|
7271
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
|
|
7272
|
+
console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
|
|
7273
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
7274
|
+
case 1:
|
|
7275
|
+
requestWithRecaptcha = _a.sent();
|
|
7276
|
+
if (actionCodeSettings) {
|
|
7277
|
+
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
|
|
7278
|
+
}
|
|
7279
|
+
return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
|
|
7280
|
+
case 2:
|
|
7281
|
+
_a.sent();
|
|
7282
|
+
return [3 /*break*/, 4];
|
|
7283
|
+
case 3: return [2 /*return*/, Promise.reject(error)];
|
|
7284
|
+
case 4: return [2 /*return*/];
|
|
7285
|
+
}
|
|
7286
|
+
});
|
|
7287
|
+
}); })];
|
|
7288
|
+
case 4:
|
|
7289
|
+
_b.sent();
|
|
7290
|
+
_b.label = 5;
|
|
7291
|
+
case 5: return [2 /*return*/];
|
|
6896
7292
|
}
|
|
6897
7293
|
});
|
|
6898
7294
|
});
|
|
@@ -7037,25 +7433,54 @@ function verifyPasswordResetCode(auth, code) {
|
|
|
7037
7433
|
* @public
|
|
7038
7434
|
*/
|
|
7039
7435
|
function createUserWithEmailAndPassword(auth, email, password) {
|
|
7436
|
+
var _a;
|
|
7040
7437
|
return __awaiter(this, void 0, void 0, function () {
|
|
7041
|
-
var authInternal, response, userCredential;
|
|
7042
|
-
|
|
7043
|
-
|
|
7438
|
+
var authInternal, request, signUpResponse, requestWithRecaptcha, response, userCredential;
|
|
7439
|
+
var _this = this;
|
|
7440
|
+
return __generator(this, function (_b) {
|
|
7441
|
+
switch (_b.label) {
|
|
7044
7442
|
case 0:
|
|
7045
7443
|
authInternal = _castAuth(auth);
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7444
|
+
request = {
|
|
7445
|
+
returnSecureToken: true,
|
|
7446
|
+
email: email,
|
|
7447
|
+
password: password,
|
|
7448
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
7449
|
+
};
|
|
7450
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 2];
|
|
7451
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
|
|
7051
7452
|
case 1:
|
|
7052
|
-
|
|
7053
|
-
|
|
7453
|
+
requestWithRecaptcha = _b.sent();
|
|
7454
|
+
signUpResponse = signUp(authInternal, requestWithRecaptcha);
|
|
7455
|
+
return [3 /*break*/, 3];
|
|
7054
7456
|
case 2:
|
|
7055
|
-
|
|
7457
|
+
signUpResponse = signUp(authInternal, request).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
7458
|
+
var requestWithRecaptcha;
|
|
7459
|
+
return __generator(this, function (_a) {
|
|
7460
|
+
switch (_a.label) {
|
|
7461
|
+
case 0:
|
|
7462
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
|
|
7463
|
+
console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
|
|
7464
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
|
|
7465
|
+
case 1:
|
|
7466
|
+
requestWithRecaptcha = _a.sent();
|
|
7467
|
+
return [2 /*return*/, signUp(authInternal, requestWithRecaptcha)];
|
|
7468
|
+
case 2: return [2 /*return*/, Promise.reject(error)];
|
|
7469
|
+
}
|
|
7470
|
+
});
|
|
7471
|
+
}); });
|
|
7472
|
+
_b.label = 3;
|
|
7473
|
+
case 3: return [4 /*yield*/, signUpResponse.catch(function (error) {
|
|
7474
|
+
return Promise.reject(error);
|
|
7475
|
+
})];
|
|
7476
|
+
case 4:
|
|
7477
|
+
response = _b.sent();
|
|
7478
|
+
return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
|
|
7479
|
+
case 5:
|
|
7480
|
+
userCredential = _b.sent();
|
|
7056
7481
|
return [4 /*yield*/, authInternal._updateCurrentUser(userCredential.user)];
|
|
7057
|
-
case
|
|
7058
|
-
|
|
7482
|
+
case 6:
|
|
7483
|
+
_b.sent();
|
|
7059
7484
|
return [2 /*return*/, userCredential];
|
|
7060
7485
|
}
|
|
7061
7486
|
});
|
|
@@ -7136,24 +7561,61 @@ function signInWithEmailAndPassword(auth, email, password) {
|
|
|
7136
7561
|
* @public
|
|
7137
7562
|
*/
|
|
7138
7563
|
function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
|
|
7564
|
+
var _a;
|
|
7139
7565
|
return __awaiter(this, void 0, void 0, function () {
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7566
|
+
function setActionCodeSettings(request, actionCodeSettings) {
|
|
7567
|
+
_assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
7568
|
+
if (actionCodeSettings) {
|
|
7569
|
+
_setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
|
|
7570
|
+
}
|
|
7571
|
+
}
|
|
7572
|
+
var authInternal, request, requestWithRecaptcha;
|
|
7573
|
+
var _this = this;
|
|
7574
|
+
return __generator(this, function (_b) {
|
|
7575
|
+
switch (_b.label) {
|
|
7143
7576
|
case 0:
|
|
7144
|
-
|
|
7577
|
+
authInternal = _castAuth(auth);
|
|
7145
7578
|
request = {
|
|
7146
7579
|
requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
|
|
7147
|
-
email: email
|
|
7580
|
+
email: email,
|
|
7581
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
|
|
7148
7582
|
};
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
_setActionCodeSettingsOnRequest(authModular, request, actionCodeSettings);
|
|
7152
|
-
}
|
|
7153
|
-
return [4 /*yield*/, sendSignInLinkToEmail$1(authModular, request)];
|
|
7583
|
+
if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
|
|
7584
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
7154
7585
|
case 1:
|
|
7155
|
-
|
|
7156
|
-
|
|
7586
|
+
requestWithRecaptcha = _b.sent();
|
|
7587
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
7588
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
|
|
7589
|
+
case 2:
|
|
7590
|
+
_b.sent();
|
|
7591
|
+
return [3 /*break*/, 5];
|
|
7592
|
+
case 3:
|
|
7593
|
+
setActionCodeSettings(request, actionCodeSettings);
|
|
7594
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, request)
|
|
7595
|
+
.catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
|
|
7596
|
+
var requestWithRecaptcha;
|
|
7597
|
+
return __generator(this, function (_a) {
|
|
7598
|
+
switch (_a.label) {
|
|
7599
|
+
case 0:
|
|
7600
|
+
if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
|
|
7601
|
+
console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
|
|
7602
|
+
return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
|
|
7603
|
+
case 1:
|
|
7604
|
+
requestWithRecaptcha = _a.sent();
|
|
7605
|
+
setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
|
|
7606
|
+
return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
|
|
7607
|
+
case 2:
|
|
7608
|
+
_a.sent();
|
|
7609
|
+
return [3 /*break*/, 4];
|
|
7610
|
+
case 3: return [2 /*return*/, Promise.reject(error)];
|
|
7611
|
+
case 4: return [2 /*return*/];
|
|
7612
|
+
}
|
|
7613
|
+
});
|
|
7614
|
+
}); })];
|
|
7615
|
+
case 4:
|
|
7616
|
+
_b.sent();
|
|
7617
|
+
_b.label = 5;
|
|
7618
|
+
case 5: return [2 /*return*/];
|
|
7157
7619
|
}
|
|
7158
7620
|
});
|
|
7159
7621
|
});
|
|
@@ -7749,6 +8211,35 @@ function getAdditionalUserInfo(userCredential) {
|
|
|
7749
8211
|
function setPersistence(auth, persistence) {
|
|
7750
8212
|
return getModularInstance(auth).setPersistence(persistence);
|
|
7751
8213
|
}
|
|
8214
|
+
/**
|
|
8215
|
+
* Loads the reCAPTCHA configuration into the `Auth` instance.
|
|
8216
|
+
*
|
|
8217
|
+
* @remarks
|
|
8218
|
+
* This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
|
|
8219
|
+
* verification flow should be triggered for each auth provider, into the
|
|
8220
|
+
* current Auth session.
|
|
8221
|
+
*
|
|
8222
|
+
* If initializeRecaptchaConfig() is not invoked, the auth flow will always start
|
|
8223
|
+
* without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
|
|
8224
|
+
* verification, the SDK will transparently load the reCAPTCHA config and restart the
|
|
8225
|
+
* auth flows.
|
|
8226
|
+
*
|
|
8227
|
+
* Thus, by calling this optional method, you will reduce the latency of future auth flows.
|
|
8228
|
+
* Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
|
|
8229
|
+
*
|
|
8230
|
+
* @example
|
|
8231
|
+
* ```javascript
|
|
8232
|
+
* initializeRecaptchaConfig(auth);
|
|
8233
|
+
* ```
|
|
8234
|
+
*
|
|
8235
|
+
* @param auth - The {@link Auth} instance.
|
|
8236
|
+
*
|
|
8237
|
+
* @public
|
|
8238
|
+
*/
|
|
8239
|
+
function initializeRecaptchaConfig(auth) {
|
|
8240
|
+
var authInternal = _castAuth(auth);
|
|
8241
|
+
return authInternal.initializeRecaptchaConfig();
|
|
8242
|
+
}
|
|
7752
8243
|
/**
|
|
7753
8244
|
* Adds an observer for changes to the signed-in user's ID token.
|
|
7754
8245
|
*
|
|
@@ -8174,5 +8665,5 @@ function getAuth(app) {
|
|
|
8174
8665
|
return auth;
|
|
8175
8666
|
}
|
|
8176
8667
|
|
|
8177
|
-
export { ActionCodeOperation, ActionCodeURL, AuthCredential, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as AuthErrorCodes, EmailAuthCredential, EmailAuthProvider, FacebookAuthProvider, FactorId, GithubAuthProvider, GoogleAuthProvider, OAuthCredential, OAuthProvider, OperationType, PhoneAuthCredential, ProviderId, SAMLAuthProvider, SignInMethod, TwitterAuthProvider, applyActionCode, beforeAuthStateChanged, checkActionCode, confirmPasswordReset, connectAuthEmulator, createUserWithEmailAndPassword, debugErrorMap, deleteUser, fetchSignInMethodsForEmail, getAdditionalUserInfo, getAuth, getIdToken, getIdTokenResult, getMultiFactorResolver, inMemoryPersistence, indexedDBLocalPersistence, initializeAuth, isSignInWithEmailLink, linkWithCredential, multiFactor, onAuthStateChanged, onIdTokenChanged, parseActionCodeURL, prodErrorMap, reauthenticateWithCredential, reload, sendEmailVerification, sendPasswordResetEmail, sendSignInLinkToEmail, setPersistence, signInAnonymously, signInWithCredential, signInWithCustomToken, signInWithEmailAndPassword, signInWithEmailLink, signOut, unlink, updateCurrentUser, updateEmail, updatePassword, updateProfile, useDeviceLanguage, verifyBeforeUpdateEmail, verifyPasswordResetCode };
|
|
8668
|
+
export { ActionCodeOperation, ActionCodeURL, AuthCredential, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as AuthErrorCodes, EmailAuthCredential, EmailAuthProvider, FacebookAuthProvider, FactorId, GithubAuthProvider, GoogleAuthProvider, OAuthCredential, OAuthProvider, OperationType, PhoneAuthCredential, ProviderId, SAMLAuthProvider, SignInMethod, TwitterAuthProvider, applyActionCode, beforeAuthStateChanged, checkActionCode, confirmPasswordReset, connectAuthEmulator, createUserWithEmailAndPassword, debugErrorMap, deleteUser, fetchSignInMethodsForEmail, getAdditionalUserInfo, getAuth, getIdToken, getIdTokenResult, getMultiFactorResolver, inMemoryPersistence, indexedDBLocalPersistence, initializeAuth, initializeRecaptchaConfig, isSignInWithEmailLink, linkWithCredential, multiFactor, onAuthStateChanged, onIdTokenChanged, parseActionCodeURL, prodErrorMap, reauthenticateWithCredential, reload, sendEmailVerification, sendPasswordResetEmail, sendSignInLinkToEmail, setPersistence, signInAnonymously, signInWithCredential, signInWithCustomToken, signInWithEmailAndPassword, signInWithEmailLink, signOut, unlink, updateCurrentUser, updateEmail, updatePassword, updateProfile, useDeviceLanguage, verifyBeforeUpdateEmail, verifyPasswordResetCode };
|
|
8178
8669
|
//# sourceMappingURL=index.webworker.esm5.js.map
|