@firebase/auth 1.3.0-canary.12221ddb4 → 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-2b0bafb8.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-4298bbc1.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-b610f09f.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-774f1e02.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-77407f01.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-160ed11d.js → totp-ab4fe73d.js} +28 -82
  32. package/dist/node-esm/totp-ab4fe73d.js.map +1 -0
  33. package/dist/rn/{index-d3bc086e.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 +12 -12
  40. package/dist/browser-cjs/index-2b0bafb8.js.map +0 -1
  41. package/dist/cordova/popup_redirect-4298bbc1.js.map +0 -1
  42. package/dist/esm2017/index-b610f09f.js.map +0 -1
  43. package/dist/esm5/index-774f1e02.js.map +0 -1
  44. package/dist/node/totp-77407f01.js.map +0 -1
  45. package/dist/node-esm/totp-160ed11d.js.map +0 -1
  46. package/dist/rn/index-d3bc086e.js.map +0 -1
@@ -3135,6 +3135,25 @@ async function injectRecaptchaFields(auth, request, action, captchaResp = false)
3135
3135
  });
3136
3136
  return newRequest;
3137
3137
  }
3138
+ async function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3139
+ var _a;
3140
+ if ((_a = authInstance._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
3141
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3142
+ return actionMethod(authInstance, requestWithRecaptcha);
3143
+ }
3144
+ else {
3145
+ return actionMethod(authInstance, request).catch(async (error) => {
3146
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3147
+ console.log(`${actionName} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);
3148
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3149
+ return actionMethod(authInstance, requestWithRecaptcha);
3150
+ }
3151
+ else {
3152
+ return Promise.reject(error);
3153
+ }
3154
+ });
3155
+ }
3156
+ }
3138
3157
  async function _initializeRecaptchaConfig(auth) {
3139
3158
  const authInternal = _castAuth(auth);
3140
3159
  const response = await getRecaptchaConfig(authInternal, {
@@ -3561,7 +3580,6 @@ class EmailAuthCredential extends AuthCredential {
3561
3580
  }
3562
3581
  /** @internal */
3563
3582
  async _getIdTokenResponse(auth) {
3564
- var _a;
3565
3583
  switch (this.signInMethod) {
3566
3584
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3567
3585
  const request = {
@@ -3570,22 +3588,7 @@ class EmailAuthCredential extends AuthCredential {
3570
3588
  password: this._password,
3571
3589
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3572
3590
  };
3573
- if ((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
3574
- const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3575
- return signInWithPassword(auth, requestWithRecaptcha);
3576
- }
3577
- else {
3578
- return signInWithPassword(auth, request).catch(async (error) => {
3579
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3580
- 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.');
3581
- const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3582
- return signInWithPassword(auth, requestWithRecaptcha);
3583
- }
3584
- else {
3585
- return Promise.reject(error);
3586
- }
3587
- });
3588
- }
3591
+ return handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword);
3589
3592
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3590
3593
  return signInWithEmailLink$1(auth, {
3591
3594
  email: this._email,
@@ -5563,39 +5566,16 @@ async function recachePasswordPolicy(auth) {
5563
5566
  * @public
5564
5567
  */
5565
5568
  async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
5566
- var _a;
5567
5569
  const authInternal = _castAuth(auth);
5568
5570
  const request = {
5569
5571
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
5570
5572
  email,
5571
5573
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5572
5574
  };
5573
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5574
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5575
- if (actionCodeSettings) {
5576
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5577
- }
5578
- await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5579
- }
5580
- else {
5581
- if (actionCodeSettings) {
5582
- _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5583
- }
5584
- await sendPasswordResetEmail$1(authInternal, request)
5585
- .catch(async (error) => {
5586
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5587
- console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
5588
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5589
- if (actionCodeSettings) {
5590
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5591
- }
5592
- await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5593
- }
5594
- else {
5595
- return Promise.reject(error);
5596
- }
5597
- });
5575
+ if (actionCodeSettings) {
5576
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5598
5577
  }
5578
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1);
5599
5579
  }
5600
5580
  /**
5601
5581
  * Completes the password reset process, given a confirmation code and new password.
@@ -5715,7 +5695,6 @@ async function verifyPasswordResetCode(auth, code) {
5715
5695
  * @public
5716
5696
  */
5717
5697
  async function createUserWithEmailAndPassword(auth, email, password) {
5718
- var _a;
5719
5698
  const authInternal = _castAuth(auth);
5720
5699
  const request = {
5721
5700
  returnSecureToken: true,
@@ -5723,21 +5702,7 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5723
5702
  password,
5724
5703
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5725
5704
  };
5726
- let signUpResponse;
5727
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5728
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5729
- signUpResponse = signUp(authInternal, requestWithRecaptcha);
5730
- }
5731
- else {
5732
- signUpResponse = signUp(authInternal, request).catch(async (error) => {
5733
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5734
- console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
5735
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5736
- return signUp(authInternal, requestWithRecaptcha);
5737
- }
5738
- throw error;
5739
- });
5740
- }
5705
+ const signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
5741
5706
  const response = await signUpResponse.catch(error => {
5742
5707
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5743
5708
  void recachePasswordPolicy(auth);
@@ -5828,7 +5793,6 @@ function signInWithEmailAndPassword(auth, email, password) {
5828
5793
  * @public
5829
5794
  */
5830
5795
  async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5831
- var _a;
5832
5796
  const authInternal = _castAuth(auth);
5833
5797
  const request = {
5834
5798
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
@@ -5841,26 +5805,8 @@ async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5841
5805
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5842
5806
  }
5843
5807
  }
5844
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5845
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5846
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5847
- await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5848
- }
5849
- else {
5850
- setActionCodeSettings(request, actionCodeSettings);
5851
- await sendSignInLinkToEmail$1(authInternal, request)
5852
- .catch(async (error) => {
5853
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5854
- console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
5855
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5856
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5857
- await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5858
- }
5859
- else {
5860
- return Promise.reject(error);
5861
- }
5862
- });
5863
- }
5808
+ setActionCodeSettings(request, actionCodeSettings);
5809
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1);
5864
5810
  }
5865
5811
  /**
5866
5812
  * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
@@ -10220,7 +10166,7 @@ function _isEmptyString(input) {
10220
10166
  }
10221
10167
 
10222
10168
  var name = "@firebase/auth";
10223
- var version = "1.3.0-canary.12221ddb4";
10169
+ var version = "1.3.0-canary.12f25592c";
10224
10170
 
10225
10171
  /**
10226
10172
  * @license
@@ -10546,4 +10492,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
10546
10492
  exports.validatePassword = validatePassword;
10547
10493
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
10548
10494
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
10549
- //# sourceMappingURL=index-2b0bafb8.js.map
10495
+ //# sourceMappingURL=index-b8d969af.js.map