@firebase/auth 1.3.0 → 1.3.1-20231025123451

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 (72) hide show
  1. package/dist/auth-public.d.ts +25 -4
  2. package/dist/auth.d.ts +25 -4
  3. package/dist/browser-cjs/{index-68b50c51.js → index-1a200980.js} +133 -127
  4. package/dist/browser-cjs/index-1a200980.js.map +1 -0
  5. package/dist/browser-cjs/index.js +1 -1
  6. package/dist/browser-cjs/internal.js +1 -1
  7. package/dist/browser-cjs/src/api/authentication/recaptcha.d.ts +2 -2
  8. package/dist/browser-cjs/src/api/index.d.ts +10 -0
  9. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  10. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  11. package/dist/cordova/index.js +2 -2
  12. package/dist/cordova/internal.js +2 -2
  13. package/dist/cordova/{popup_redirect-0a78e29a.js → popup_redirect-293c87d4.js} +183 -214
  14. package/dist/cordova/popup_redirect-293c87d4.js.map +1 -0
  15. package/dist/cordova/src/api/authentication/recaptcha.d.ts +2 -2
  16. package/dist/cordova/src/api/index.d.ts +10 -0
  17. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  18. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  19. package/dist/esm2017/{index-9a76d29a.js → index-e91d1134.js} +133 -127
  20. package/dist/esm2017/index-e91d1134.js.map +1 -0
  21. package/dist/esm2017/index.js +1 -1
  22. package/dist/esm2017/internal.js +2 -2
  23. package/dist/esm2017/src/api/authentication/recaptcha.d.ts +2 -2
  24. package/dist/esm2017/src/api/index.d.ts +10 -0
  25. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  26. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  27. package/dist/esm5/{index-3f0ee8ce.js → index-11c5d6af.js} +183 -214
  28. package/dist/esm5/index-11c5d6af.js.map +1 -0
  29. package/dist/esm5/index.js +1 -1
  30. package/dist/esm5/internal.js +2 -2
  31. package/dist/esm5/src/api/authentication/recaptcha.d.ts +2 -2
  32. package/dist/esm5/src/api/index.d.ts +10 -0
  33. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  34. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  35. package/dist/index.webworker.esm5.js +141 -172
  36. package/dist/index.webworker.esm5.js.map +1 -1
  37. package/dist/node/index.js +1 -1
  38. package/dist/node/internal.js +1 -1
  39. package/dist/node/src/api/authentication/recaptcha.d.ts +2 -2
  40. package/dist/node/src/api/index.d.ts +10 -0
  41. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  42. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  43. package/dist/node/{totp-cceb0d01.js → totp-65485935.js} +179 -210
  44. package/dist/node/totp-65485935.js.map +1 -0
  45. package/dist/node-esm/index.js +1 -1
  46. package/dist/node-esm/internal.js +2 -2
  47. package/dist/node-esm/src/api/authentication/recaptcha.d.ts +2 -2
  48. package/dist/node-esm/src/api/index.d.ts +10 -0
  49. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  50. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  51. package/dist/node-esm/{totp-64a935f2.js → totp-6f437332.js} +129 -123
  52. package/dist/node-esm/totp-6f437332.js.map +1 -0
  53. package/dist/rn/{index-1dd41d18.js → index-134d3a30.js} +183 -214
  54. package/dist/rn/index-134d3a30.js.map +1 -0
  55. package/dist/rn/index.js +1 -1
  56. package/dist/rn/internal.js +1 -1
  57. package/dist/rn/src/api/authentication/recaptcha.d.ts +2 -2
  58. package/dist/rn/src/api/index.d.ts +10 -0
  59. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  60. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  61. package/dist/src/api/authentication/recaptcha.d.ts +2 -2
  62. package/dist/src/api/index.d.ts +10 -0
  63. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  64. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  65. package/package.json +8 -8
  66. package/dist/browser-cjs/index-68b50c51.js.map +0 -1
  67. package/dist/cordova/popup_redirect-0a78e29a.js.map +0 -1
  68. package/dist/esm2017/index-9a76d29a.js.map +0 -1
  69. package/dist/esm5/index-3f0ee8ce.js.map +0 -1
  70. package/dist/node/totp-cceb0d01.js.map +0 -1
  71. package/dist/node-esm/totp-64a935f2.js.map +0 -1
  72. package/dist/rn/index-1dd41d18.js.map +0 -1
@@ -1087,6 +1087,13 @@ export declare interface EmulatorConfig {
1087
1087
  readonly disableWarnings: boolean;
1088
1088
  };
1089
1089
  }
1090
+
1091
+ declare const enum EnforcementState {
1092
+ ENFORCE = "ENFORCE",
1093
+ AUDIT = "AUDIT",
1094
+ OFF = "OFF",
1095
+ ENFORCEMENT_STATE_UNSPECIFIED = "ENFORCEMENT_STATE_UNSPECIFIED"
1096
+ }
1090
1097
  export { ErrorFn }
1091
1098
 
1092
1099
  /* Excluded from this release type: EventManager */
@@ -1300,7 +1307,7 @@ export declare function getMultiFactorResolver(auth: Auth, error: MultiFactorErr
1300
1307
 
1301
1308
  declare interface GetRecaptchaConfigResponse {
1302
1309
  recaptchaKey: string;
1303
- recaptchaEnforcementState: RecaptchaEnforcementState[];
1310
+ recaptchaEnforcementState: RecaptchaEnforcementProviderState[];
1304
1311
  }
1305
1312
 
1306
1313
  /**
@@ -2812,13 +2819,27 @@ declare class RecaptchaConfig {
2812
2819
  */
2813
2820
  siteKey: string;
2814
2821
  /**
2815
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
2822
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
2816
2823
  */
2817
- emailPasswordEnabled: boolean;
2824
+ recaptchaEnforcementState: RecaptchaEnforcementProviderState[];
2818
2825
  constructor(response: GetRecaptchaConfigResponse);
2826
+ /**
2827
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
2828
+ *
2829
+ * @param providerStr - The provider whose enforcement state is to be returned.
2830
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
2831
+ */
2832
+ getProviderEnforcementState(providerStr: string): EnforcementState | null;
2833
+ /**
2834
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
2835
+ *
2836
+ * @param providerStr - The provider whose enablement state is to be returned.
2837
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
2838
+ */
2839
+ isProviderEnabled(providerStr: string): boolean;
2819
2840
  }
2820
2841
 
2821
- declare interface RecaptchaEnforcementState {
2842
+ declare interface RecaptchaEnforcementProviderState {
2822
2843
  provider: string;
2823
2844
  enforcementState: string;
2824
2845
  }
package/dist/auth.d.ts CHANGED
@@ -1367,6 +1367,13 @@ export declare interface EmulatorConfig {
1367
1367
  readonly disableWarnings: boolean;
1368
1368
  };
1369
1369
  }
1370
+
1371
+ declare const enum EnforcementState {
1372
+ ENFORCE = "ENFORCE",
1373
+ AUDIT = "AUDIT",
1374
+ OFF = "OFF",
1375
+ ENFORCEMENT_STATE_UNSPECIFIED = "ENFORCEMENT_STATE_UNSPECIFIED"
1376
+ }
1370
1377
  export { ErrorFn }
1371
1378
 
1372
1379
  /**
@@ -1598,7 +1605,7 @@ export declare function getMultiFactorResolver(auth: Auth, error: MultiFactorErr
1598
1605
 
1599
1606
  declare interface GetRecaptchaConfigResponse {
1600
1607
  recaptchaKey: string;
1601
- recaptchaEnforcementState: RecaptchaEnforcementState[];
1608
+ recaptchaEnforcementState: RecaptchaEnforcementProviderState[];
1602
1609
  }
1603
1610
 
1604
1611
  /**
@@ -3273,13 +3280,27 @@ declare class RecaptchaConfig {
3273
3280
  */
3274
3281
  siteKey: string;
3275
3282
  /**
3276
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
3283
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
3277
3284
  */
3278
- emailPasswordEnabled: boolean;
3285
+ recaptchaEnforcementState: RecaptchaEnforcementProviderState[];
3279
3286
  constructor(response: GetRecaptchaConfigResponse);
3287
+ /**
3288
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
3289
+ *
3290
+ * @param providerStr - The provider whose enforcement state is to be returned.
3291
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
3292
+ */
3293
+ getProviderEnforcementState(providerStr: string): EnforcementState | null;
3294
+ /**
3295
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
3296
+ *
3297
+ * @param providerStr - The provider whose enablement state is to be returned.
3298
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
3299
+ */
3300
+ isProviderEnabled(providerStr: string): boolean;
3280
3301
  }
3281
3302
 
3282
- declare interface RecaptchaEnforcementState {
3303
+ declare interface RecaptchaEnforcementProviderState {
3283
3304
  provider: string;
3284
3305
  enforcementState: string;
3285
3306
  }
@@ -105,50 +105,6 @@ const ActionCodeOperation = {
105
105
  VERIFY_EMAIL: 'VERIFY_EMAIL'
106
106
  };
107
107
 
108
- /**
109
- * @license
110
- * Copyright 2020 Google LLC
111
- *
112
- * Licensed under the Apache License, Version 2.0 (the "License");
113
- * you may not use this file except in compliance with the License.
114
- * You may obtain a copy of the License at
115
- *
116
- * http://www.apache.org/licenses/LICENSE-2.0
117
- *
118
- * Unless required by applicable law or agreed to in writing, software
119
- * distributed under the License is distributed on an "AS IS" BASIS,
120
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121
- * See the License for the specific language governing permissions and
122
- * limitations under the License.
123
- */
124
- function isV2(grecaptcha) {
125
- return (grecaptcha !== undefined &&
126
- grecaptcha.getResponse !== undefined);
127
- }
128
- function isEnterprise(grecaptcha) {
129
- return (grecaptcha !== undefined &&
130
- grecaptcha.enterprise !== undefined);
131
- }
132
- class RecaptchaConfig {
133
- constructor(response) {
134
- /**
135
- * The reCAPTCHA site key.
136
- */
137
- this.siteKey = '';
138
- /**
139
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
140
- */
141
- this.emailPasswordEnabled = false;
142
- if (response.recaptchaKey === undefined) {
143
- throw new Error('recaptchaKey undefined');
144
- }
145
- // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
146
- this.siteKey = response.recaptchaKey.split('/')[3];
147
- this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
148
- enforcementState.enforcementState !== 'OFF');
149
- }
150
- }
151
-
152
108
  /**
153
109
  * @license
154
110
  * Copyright 2020 Google LLC
@@ -758,6 +714,12 @@ class FetchProvider {
758
714
  if (typeof self !== 'undefined' && 'fetch' in self) {
759
715
  return self.fetch;
760
716
  }
717
+ if (typeof globalThis !== 'undefined' && globalThis.fetch) {
718
+ return globalThis.fetch;
719
+ }
720
+ if (typeof fetch !== 'undefined') {
721
+ return fetch;
722
+ }
761
723
  debugFail('Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
762
724
  }
763
725
  static headers() {
@@ -767,6 +729,12 @@ class FetchProvider {
767
729
  if (typeof self !== 'undefined' && 'Headers' in self) {
768
730
  return self.Headers;
769
731
  }
732
+ if (typeof globalThis !== 'undefined' && globalThis.Headers) {
733
+ return globalThis.Headers;
734
+ }
735
+ if (typeof Headers !== 'undefined') {
736
+ return Headers;
737
+ }
770
738
  debugFail('Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
771
739
  }
772
740
  static response() {
@@ -776,6 +744,12 @@ class FetchProvider {
776
744
  if (typeof self !== 'undefined' && 'Response' in self) {
777
745
  return self.Response;
778
746
  }
747
+ if (typeof globalThis !== 'undefined' && globalThis.Response) {
748
+ return globalThis.Response;
749
+ }
750
+ if (typeof Response !== 'undefined') {
751
+ return Response;
752
+ }
779
753
  debugFail('Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
780
754
  }
781
755
  }
@@ -987,6 +961,18 @@ function _getFinalTarget(auth, host, path, query) {
987
961
  }
988
962
  return _emulatorUrl(auth.config, base);
989
963
  }
964
+ function _parseEnforcementState(enforcementStateStr) {
965
+ switch (enforcementStateStr) {
966
+ case 'ENFORCE':
967
+ return "ENFORCE" /* EnforcementState.ENFORCE */;
968
+ case 'AUDIT':
969
+ return "AUDIT" /* EnforcementState.AUDIT */;
970
+ case 'OFF':
971
+ return "OFF" /* EnforcementState.OFF */;
972
+ default:
973
+ return "ENFORCEMENT_STATE_UNSPECIFIED" /* EnforcementState.ENFORCEMENT_STATE_UNSPECIFIED */;
974
+ }
975
+ }
990
976
  class NetworkTimeout {
991
977
  constructor(auth) {
992
978
  this.auth = auth;
@@ -1020,6 +1006,79 @@ function _makeTaggedError(auth, code, response) {
1020
1006
  return error;
1021
1007
  }
1022
1008
 
1009
+ /**
1010
+ * @license
1011
+ * Copyright 2020 Google LLC
1012
+ *
1013
+ * Licensed under the Apache License, Version 2.0 (the "License");
1014
+ * you may not use this file except in compliance with the License.
1015
+ * You may obtain a copy of the License at
1016
+ *
1017
+ * http://www.apache.org/licenses/LICENSE-2.0
1018
+ *
1019
+ * Unless required by applicable law or agreed to in writing, software
1020
+ * distributed under the License is distributed on an "AS IS" BASIS,
1021
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1022
+ * See the License for the specific language governing permissions and
1023
+ * limitations under the License.
1024
+ */
1025
+ function isV2(grecaptcha) {
1026
+ return (grecaptcha !== undefined &&
1027
+ grecaptcha.getResponse !== undefined);
1028
+ }
1029
+ function isEnterprise(grecaptcha) {
1030
+ return (grecaptcha !== undefined &&
1031
+ grecaptcha.enterprise !== undefined);
1032
+ }
1033
+ class RecaptchaConfig {
1034
+ constructor(response) {
1035
+ /**
1036
+ * The reCAPTCHA site key.
1037
+ */
1038
+ this.siteKey = '';
1039
+ /**
1040
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
1041
+ */
1042
+ this.recaptchaEnforcementState = [];
1043
+ if (response.recaptchaKey === undefined) {
1044
+ throw new Error('recaptchaKey undefined');
1045
+ }
1046
+ // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
1047
+ this.siteKey = response.recaptchaKey.split('/')[3];
1048
+ this.recaptchaEnforcementState = response.recaptchaEnforcementState;
1049
+ }
1050
+ /**
1051
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
1052
+ *
1053
+ * @param providerStr - The provider whose enforcement state is to be returned.
1054
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
1055
+ */
1056
+ getProviderEnforcementState(providerStr) {
1057
+ if (!this.recaptchaEnforcementState ||
1058
+ this.recaptchaEnforcementState.length === 0) {
1059
+ return null;
1060
+ }
1061
+ for (const recaptchaEnforcementState of this.recaptchaEnforcementState) {
1062
+ if (recaptchaEnforcementState.provider &&
1063
+ recaptchaEnforcementState.provider === providerStr) {
1064
+ return _parseEnforcementState(recaptchaEnforcementState.enforcementState);
1065
+ }
1066
+ }
1067
+ return null;
1068
+ }
1069
+ /**
1070
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
1071
+ *
1072
+ * @param providerStr - The provider whose enablement state is to be returned.
1073
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
1074
+ */
1075
+ isProviderEnabled(providerStr) {
1076
+ return (this.getProviderEnforcementState(providerStr) ===
1077
+ "ENFORCE" /* EnforcementState.ENFORCE */ ||
1078
+ this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
1079
+ }
1080
+ }
1081
+
1023
1082
  /**
1024
1083
  * @license
1025
1084
  * Copyright 2020 Google LLC
@@ -3135,6 +3194,26 @@ async function injectRecaptchaFields(auth, request, action, captchaResp = false)
3135
3194
  });
3136
3195
  return newRequest;
3137
3196
  }
3197
+ async function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3198
+ var _a;
3199
+ if ((_a = authInstance
3200
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3201
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3202
+ return actionMethod(authInstance, requestWithRecaptcha);
3203
+ }
3204
+ else {
3205
+ return actionMethod(authInstance, request).catch(async (error) => {
3206
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3207
+ console.log(`${actionName} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);
3208
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3209
+ return actionMethod(authInstance, requestWithRecaptcha);
3210
+ }
3211
+ else {
3212
+ return Promise.reject(error);
3213
+ }
3214
+ });
3215
+ }
3216
+ }
3138
3217
  async function _initializeRecaptchaConfig(auth) {
3139
3218
  const authInternal = _castAuth(auth);
3140
3219
  const response = await getRecaptchaConfig(authInternal, {
@@ -3148,7 +3227,7 @@ async function _initializeRecaptchaConfig(auth) {
3148
3227
  else {
3149
3228
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
3150
3229
  }
3151
- if (config.emailPasswordEnabled) {
3230
+ if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3152
3231
  const verifier = new RecaptchaEnterpriseVerifier(authInternal);
3153
3232
  void verifier.verify();
3154
3233
  }
@@ -3561,7 +3640,6 @@ class EmailAuthCredential extends AuthCredential {
3561
3640
  }
3562
3641
  /** @internal */
3563
3642
  async _getIdTokenResponse(auth) {
3564
- var _a;
3565
3643
  switch (this.signInMethod) {
3566
3644
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3567
3645
  const request = {
@@ -3570,22 +3648,7 @@ class EmailAuthCredential extends AuthCredential {
3570
3648
  password: this._password,
3571
3649
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3572
3650
  };
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
- }
3651
+ return handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword);
3589
3652
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3590
3653
  return signInWithEmailLink$1(auth, {
3591
3654
  email: this._email,
@@ -5563,39 +5626,16 @@ async function recachePasswordPolicy(auth) {
5563
5626
  * @public
5564
5627
  */
5565
5628
  async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
5566
- var _a;
5567
5629
  const authInternal = _castAuth(auth);
5568
5630
  const request = {
5569
5631
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
5570
5632
  email,
5571
5633
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5572
5634
  };
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
- });
5635
+ if (actionCodeSettings) {
5636
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5598
5637
  }
5638
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1);
5599
5639
  }
5600
5640
  /**
5601
5641
  * Completes the password reset process, given a confirmation code and new password.
@@ -5715,7 +5755,6 @@ async function verifyPasswordResetCode(auth, code) {
5715
5755
  * @public
5716
5756
  */
5717
5757
  async function createUserWithEmailAndPassword(auth, email, password) {
5718
- var _a;
5719
5758
  const authInternal = _castAuth(auth);
5720
5759
  const request = {
5721
5760
  returnSecureToken: true,
@@ -5723,21 +5762,7 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5723
5762
  password,
5724
5763
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5725
5764
  };
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
- }
5765
+ const signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
5741
5766
  const response = await signUpResponse.catch(error => {
5742
5767
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5743
5768
  void recachePasswordPolicy(auth);
@@ -5828,7 +5853,6 @@ function signInWithEmailAndPassword(auth, email, password) {
5828
5853
  * @public
5829
5854
  */
5830
5855
  async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5831
- var _a;
5832
5856
  const authInternal = _castAuth(auth);
5833
5857
  const request = {
5834
5858
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
@@ -5841,26 +5865,8 @@ async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5841
5865
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5842
5866
  }
5843
5867
  }
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
- }
5868
+ setActionCodeSettings(request, actionCodeSettings);
5869
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1);
5864
5870
  }
5865
5871
  /**
5866
5872
  * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
@@ -10220,7 +10226,7 @@ function _isEmptyString(input) {
10220
10226
  }
10221
10227
 
10222
10228
  var name = "@firebase/auth";
10223
- var version = "1.3.0";
10229
+ var version = "1.3.1-20231025123451";
10224
10230
 
10225
10231
  /**
10226
10232
  * @license
@@ -10546,4 +10552,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
10546
10552
  exports.validatePassword = validatePassword;
10547
10553
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
10548
10554
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
10549
- //# sourceMappingURL=index-68b50c51.js.map
10555
+ //# sourceMappingURL=index-1a200980.js.map