@firebase/auth 1.3.0-canary.0ae010ef2 → 1.3.0-canary.12f25592c

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.
Files changed (46) hide show
  1. package/dist/browser-cjs/{index-77c7acd1.js → index-b8d969af.js} +28 -82
  2. package/dist/browser-cjs/index-b8d969af.js.map +1 -0
  3. package/dist/browser-cjs/index.js +1 -1
  4. package/dist/browser-cjs/internal.js +1 -1
  5. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  6. package/dist/cordova/index.js +2 -2
  7. package/dist/cordova/internal.js +2 -2
  8. package/dist/cordova/{popup_redirect-378dee5d.js → popup_redirect-5e5f5325.js} +76 -166
  9. package/dist/cordova/popup_redirect-5e5f5325.js.map +1 -0
  10. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  11. package/dist/esm2017/{index-8ae48e33.js → index-d416518f.js} +28 -82
  12. package/dist/esm2017/index-d416518f.js.map +1 -0
  13. package/dist/esm2017/index.js +1 -1
  14. package/dist/esm2017/internal.js +2 -2
  15. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  16. package/dist/esm5/{index-24e45e55.js → index-3f5e864f.js} +76 -166
  17. package/dist/esm5/index-3f5e864f.js.map +1 -0
  18. package/dist/esm5/index.js +1 -1
  19. package/dist/esm5/internal.js +2 -2
  20. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  21. package/dist/index.webworker.esm5.js +75 -165
  22. package/dist/index.webworker.esm5.js.map +1 -1
  23. package/dist/node/index.js +1 -1
  24. package/dist/node/internal.js +1 -1
  25. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  26. package/dist/node/{totp-55649440.js → totp-1d922ce9.js} +76 -166
  27. package/dist/node/totp-1d922ce9.js.map +1 -0
  28. package/dist/node-esm/index.js +1 -1
  29. package/dist/node-esm/internal.js +2 -2
  30. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  31. package/dist/node-esm/{totp-4aedda59.js → totp-ab4fe73d.js} +28 -82
  32. package/dist/node-esm/totp-ab4fe73d.js.map +1 -0
  33. package/dist/rn/{index-dad0301e.js → index-81668c87.js} +76 -166
  34. package/dist/rn/index-81668c87.js.map +1 -0
  35. package/dist/rn/index.js +1 -1
  36. package/dist/rn/internal.js +1 -1
  37. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  38. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  39. package/package.json +6 -6
  40. package/dist/browser-cjs/index-77c7acd1.js.map +0 -1
  41. package/dist/cordova/popup_redirect-378dee5d.js.map +0 -1
  42. package/dist/esm2017/index-8ae48e33.js.map +0 -1
  43. package/dist/esm5/index-24e45e55.js.map +0 -1
  44. package/dist/node/totp-55649440.js.map +0 -1
  45. package/dist/node-esm/totp-4aedda59.js.map +0 -1
  46. package/dist/rn/index-dad0301e.js.map +0 -1
@@ -1,4 +1,4 @@
1
- export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-24e45e55.js';
1
+ export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-3f5e864f.js';
2
2
  import 'tslib';
3
3
  import '@firebase/util';
4
4
  import '@firebase/app';
@@ -1,5 +1,5 @@
1
- import { at as _isIOS, au as _isAndroid, av as _fail, aw as _getRedirectUrl, ax as debugAssert, ay as _getProjectConfig, az as _isIOS7Or8, aA as _assert, aB as _createError, aC as AuthEventManager, aD as _getInstance, b as browserLocalPersistence, aE as _persistenceKeyName, aF as _clearRedirectOutcomes, a as browserSessionPersistence, aG as _getRedirectResult, aH as _overrideRedirectResult, aI as _castAuth } from './index-24e45e55.js';
2
- export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, aK as AuthImpl, aN as AuthPopup, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, aO as FetchProvider, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, aP as SAMLAuthCredential, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, aJ as UserImpl, aA as _assert, aI as _castAuth, av as _fail, aM as _generateEventId, aL as _getClientVersion, aD as _getInstance, aG as _getRedirectResult, aH as _overrideRedirectResult, aE as _persistenceKeyName, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-24e45e55.js';
1
+ import { at as _isIOS, au as _isAndroid, av as _fail, aw as _getRedirectUrl, ax as debugAssert, ay as _getProjectConfig, az as _isIOS7Or8, aA as _assert, aB as _createError, aC as AuthEventManager, aD as _getInstance, b as browserLocalPersistence, aE as _persistenceKeyName, aF as _clearRedirectOutcomes, a as browserSessionPersistence, aG as _getRedirectResult, aH as _overrideRedirectResult, aI as _castAuth } from './index-3f5e864f.js';
2
+ export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, aK as AuthImpl, aN as AuthPopup, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, aO as FetchProvider, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, aP as SAMLAuthCredential, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, aJ as UserImpl, aA as _assert, aI as _castAuth, av as _fail, aM as _generateEventId, aL as _getClientVersion, aD as _getInstance, aG as _getRedirectResult, aH as _overrideRedirectResult, aE as _persistenceKeyName, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-3f5e864f.js';
3
3
  import { __awaiter, __generator, __extends } from 'tslib';
4
4
  import { querystringDecode } from '@firebase/util';
5
5
  import '@firebase/app';
@@ -39,4 +39,7 @@ export declare class RecaptchaEnterpriseVerifier {
39
39
  verify(action?: string, forceRefresh?: boolean): Promise<string>;
40
40
  }
41
41
  export declare function injectRecaptchaFields<T>(auth: AuthInternal, request: T, action: RecaptchaActionName, captchaResp?: boolean): Promise<T>;
42
+ declare type ActionMethod<TRequest, TResponse> = (auth: Auth, request: TRequest) => Promise<TResponse>;
43
+ export declare function handleRecaptchaFlow<TRequest, TResponse>(authInstance: AuthInternal, request: TRequest, actionName: RecaptchaActionName, actionMethod: ActionMethod<TRequest, TResponse>): Promise<TResponse>;
42
44
  export declare function _initializeRecaptchaConfig(auth: Auth): Promise<void>;
45
+ export {};
@@ -551,7 +551,7 @@ function _initializeAuthInstance(auth, deps) {
551
551
  }
552
552
 
553
553
  var name = "@firebase/auth";
554
- var version = "1.3.0-canary.0ae010ef2";
554
+ var version = "1.3.0-canary.12f25592c";
555
555
 
556
556
  /**
557
557
  * @license
@@ -4850,6 +4850,38 @@ function injectRecaptchaFields(auth, request, action, captchaResp) {
4850
4850
  });
4851
4851
  });
4852
4852
  }
4853
+ function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
4854
+ var _a;
4855
+ return __awaiter(this, void 0, void 0, function () {
4856
+ var requestWithRecaptcha;
4857
+ var _this = this;
4858
+ return __generator(this, function (_b) {
4859
+ switch (_b.label) {
4860
+ case 0:
4861
+ if (!((_a = authInstance._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 2];
4862
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */)];
4863
+ case 1:
4864
+ requestWithRecaptcha = _b.sent();
4865
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha)];
4866
+ case 2: return [2 /*return*/, actionMethod(authInstance, request).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
4867
+ var requestWithRecaptcha;
4868
+ return __generator(this, function (_a) {
4869
+ switch (_a.label) {
4870
+ case 0:
4871
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
4872
+ console.log("".concat(actionName, " is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow."));
4873
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */)];
4874
+ case 1:
4875
+ requestWithRecaptcha = _a.sent();
4876
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha)];
4877
+ case 2: return [2 /*return*/, Promise.reject(error)];
4878
+ }
4879
+ });
4880
+ }); })];
4881
+ }
4882
+ });
4883
+ });
4884
+ }
4853
4885
  function _initializeRecaptchaConfig(auth) {
4854
4886
  return __awaiter(this, void 0, void 0, function () {
4855
4887
  var authInternal, response, config, verifier;
@@ -5268,55 +5300,27 @@ var EmailAuthCredential = /** @class */ (function (_super) {
5268
5300
  };
5269
5301
  /** @internal */
5270
5302
  EmailAuthCredential.prototype._getIdTokenResponse = function (auth) {
5271
- var _a;
5272
5303
  return __awaiter(this, void 0, void 0, function () {
5273
- var _b, request_1, requestWithRecaptcha;
5274
- var _this = this;
5275
- return __generator(this, function (_c) {
5276
- switch (_c.label) {
5277
- case 0:
5278
- _b = this.signInMethod;
5279
- switch (_b) {
5280
- case "password" /* SignInMethod.EMAIL_PASSWORD */: return [3 /*break*/, 1];
5281
- case "emailLink" /* SignInMethod.EMAIL_LINK */: return [3 /*break*/, 4];
5282
- }
5283
- return [3 /*break*/, 5];
5284
- case 1:
5285
- request_1 = {
5304
+ var request;
5305
+ return __generator(this, function (_a) {
5306
+ switch (this.signInMethod) {
5307
+ case "password" /* SignInMethod.EMAIL_PASSWORD */:
5308
+ request = {
5286
5309
  returnSecureToken: true,
5287
5310
  email: this._email,
5288
5311
  password: this._password,
5289
5312
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5290
5313
  };
5291
- if (!((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
5292
- return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
5293
- case 2:
5294
- requestWithRecaptcha = _c.sent();
5295
- return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
5296
- case 3: return [2 /*return*/, signInWithPassword(auth, request_1).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
5297
- var requestWithRecaptcha;
5298
- return __generator(this, function (_a) {
5299
- switch (_a.label) {
5300
- case 0:
5301
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
5302
- 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.');
5303
- return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
5304
- case 1:
5305
- requestWithRecaptcha = _a.sent();
5306
- return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
5307
- case 2: return [2 /*return*/, Promise.reject(error)];
5308
- }
5309
- });
5310
- }); })];
5311
- case 4: return [2 /*return*/, signInWithEmailLink$1(auth, {
5312
- email: this._email,
5313
- oobCode: this._password
5314
- })];
5315
- case 5:
5314
+ return [2 /*return*/, handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword)];
5315
+ case "emailLink" /* SignInMethod.EMAIL_LINK */:
5316
+ return [2 /*return*/, signInWithEmailLink$1(auth, {
5317
+ email: this._email,
5318
+ oobCode: this._password
5319
+ })];
5320
+ default:
5316
5321
  _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
5317
- _c.label = 6;
5318
- case 6: return [2 /*return*/];
5319
5322
  }
5323
+ return [2 /*return*/];
5320
5324
  });
5321
5325
  });
5322
5326
  };
@@ -7526,12 +7530,10 @@ function recachePasswordPolicy(auth) {
7526
7530
  * @public
7527
7531
  */
7528
7532
  function sendPasswordResetEmail(auth, email, actionCodeSettings) {
7529
- var _a;
7530
7533
  return __awaiter(this, void 0, void 0, function () {
7531
- var authInternal, request, requestWithRecaptcha;
7532
- var _this = this;
7533
- return __generator(this, function (_b) {
7534
- switch (_b.label) {
7534
+ var authInternal, request;
7535
+ return __generator(this, function (_a) {
7536
+ switch (_a.label) {
7535
7537
  case 0:
7536
7538
  authInternal = _castAuth(auth);
7537
7539
  request = {
@@ -7539,48 +7541,13 @@ function sendPasswordResetEmail(auth, email, actionCodeSettings) {
7539
7541
  email: email,
7540
7542
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7541
7543
  };
7542
- if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
7543
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7544
- case 1:
7545
- requestWithRecaptcha = _b.sent();
7546
- if (actionCodeSettings) {
7547
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
7548
- }
7549
- return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
7550
- case 2:
7551
- _b.sent();
7552
- return [3 /*break*/, 5];
7553
- case 3:
7554
7544
  if (actionCodeSettings) {
7555
7545
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
7556
7546
  }
7557
- return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, request)
7558
- .catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
7559
- var requestWithRecaptcha;
7560
- return __generator(this, function (_a) {
7561
- switch (_a.label) {
7562
- case 0:
7563
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
7564
- console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
7565
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7566
- case 1:
7567
- requestWithRecaptcha = _a.sent();
7568
- if (actionCodeSettings) {
7569
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
7570
- }
7571
- return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
7572
- case 2:
7573
- _a.sent();
7574
- return [3 /*break*/, 4];
7575
- case 3: return [2 /*return*/, Promise.reject(error)];
7576
- case 4: return [2 /*return*/];
7577
- }
7578
- });
7579
- }); })];
7580
- case 4:
7581
- _b.sent();
7582
- _b.label = 5;
7583
- case 5: return [2 /*return*/];
7547
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1)];
7548
+ case 1:
7549
+ _a.sent();
7550
+ return [2 /*return*/];
7584
7551
  }
7585
7552
  });
7586
7553
  });
@@ -7735,12 +7702,10 @@ function verifyPasswordResetCode(auth, code) {
7735
7702
  * @public
7736
7703
  */
7737
7704
  function createUserWithEmailAndPassword(auth, email, password) {
7738
- var _a;
7739
7705
  return __awaiter(this, void 0, void 0, function () {
7740
- var authInternal, request, signUpResponse, requestWithRecaptcha, response, userCredential;
7741
- var _this = this;
7742
- return __generator(this, function (_b) {
7743
- switch (_b.label) {
7706
+ var authInternal, request, signUpResponse, response, userCredential;
7707
+ return __generator(this, function (_a) {
7708
+ switch (_a.label) {
7744
7709
  case 0:
7745
7710
  authInternal = _castAuth(auth);
7746
7711
  request = {
@@ -7749,43 +7714,21 @@ function createUserWithEmailAndPassword(auth, email, password) {
7749
7714
  password: password,
7750
7715
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7751
7716
  };
7752
- if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 2];
7753
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
7754
- case 1:
7755
- requestWithRecaptcha = _b.sent();
7756
- signUpResponse = signUp(authInternal, requestWithRecaptcha);
7757
- return [3 /*break*/, 3];
7758
- case 2:
7759
- signUpResponse = signUp(authInternal, request).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
7760
- var requestWithRecaptcha;
7761
- return __generator(this, function (_a) {
7762
- switch (_a.label) {
7763
- case 0:
7764
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
7765
- console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
7766
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
7767
- case 1:
7768
- requestWithRecaptcha = _a.sent();
7769
- return [2 /*return*/, signUp(authInternal, requestWithRecaptcha)];
7770
- case 2: throw error;
7717
+ signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
7718
+ return [4 /*yield*/, signUpResponse.catch(function (error) {
7719
+ if (error.code === "auth/".concat("password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */)) {
7720
+ void recachePasswordPolicy(auth);
7771
7721
  }
7772
- });
7773
- }); });
7774
- _b.label = 3;
7775
- case 3: return [4 /*yield*/, signUpResponse.catch(function (error) {
7776
- if (error.code === "auth/".concat("password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */)) {
7777
- void recachePasswordPolicy(auth);
7778
- }
7779
- throw error;
7780
- })];
7781
- case 4:
7782
- response = _b.sent();
7722
+ throw error;
7723
+ })];
7724
+ case 1:
7725
+ response = _a.sent();
7783
7726
  return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
7784
- case 5:
7785
- userCredential = _b.sent();
7727
+ case 2:
7728
+ userCredential = _a.sent();
7786
7729
  return [4 /*yield*/, authInternal._updateCurrentUser(userCredential.user)];
7787
- case 6:
7788
- _b.sent();
7730
+ case 3:
7731
+ _a.sent();
7789
7732
  return [2 /*return*/, userCredential];
7790
7733
  }
7791
7734
  });
@@ -7874,7 +7817,6 @@ function signInWithEmailAndPassword(auth, email, password) {
7874
7817
  * @public
7875
7818
  */
7876
7819
  function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7877
- var _a;
7878
7820
  return __awaiter(this, void 0, void 0, function () {
7879
7821
  function setActionCodeSettings(request, actionCodeSettings) {
7880
7822
  _assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
@@ -7882,10 +7824,9 @@ function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7882
7824
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
7883
7825
  }
7884
7826
  }
7885
- var authInternal, request, requestWithRecaptcha;
7886
- var _this = this;
7887
- return __generator(this, function (_b) {
7888
- switch (_b.label) {
7827
+ var authInternal, request;
7828
+ return __generator(this, function (_a) {
7829
+ switch (_a.label) {
7889
7830
  case 0:
7890
7831
  authInternal = _castAuth(auth);
7891
7832
  request = {
@@ -7893,42 +7834,11 @@ function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7893
7834
  email: email,
7894
7835
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7895
7836
  };
7896
- if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
7897
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7898
- case 1:
7899
- requestWithRecaptcha = _b.sent();
7900
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
7901
- return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
7902
- case 2:
7903
- _b.sent();
7904
- return [3 /*break*/, 5];
7905
- case 3:
7906
7837
  setActionCodeSettings(request, actionCodeSettings);
7907
- return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, request)
7908
- .catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
7909
- var requestWithRecaptcha;
7910
- return __generator(this, function (_a) {
7911
- switch (_a.label) {
7912
- case 0:
7913
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
7914
- console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
7915
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7916
- case 1:
7917
- requestWithRecaptcha = _a.sent();
7918
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
7919
- return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
7920
- case 2:
7921
- _a.sent();
7922
- return [3 /*break*/, 4];
7923
- case 3: return [2 /*return*/, Promise.reject(error)];
7924
- case 4: return [2 /*return*/];
7925
- }
7926
- });
7927
- }); })];
7928
- case 4:
7929
- _b.sent();
7930
- _b.label = 5;
7931
- case 5: return [2 /*return*/];
7838
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1)];
7839
+ case 1:
7840
+ _a.sent();
7841
+ return [2 /*return*/];
7932
7842
  }
7933
7843
  });
7934
7844
  });