@firebase/auth 1.3.0-canary.eff95304d → 1.3.0-canary.f002ef36a

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-bbdc1888.js → index-3d97c204.js} +133 -127
  4. package/dist/browser-cjs/index-3d97c204.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-f62a8012.js → popup_redirect-9281c39f.js} +183 -214
  14. package/dist/cordova/popup_redirect-9281c39f.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-2e980710.js → index-3000f55e.js} +133 -127
  20. package/dist/esm2017/index-3000f55e.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-ad762403.js → index-764f9bd9.js} +183 -214
  28. package/dist/esm5/index-764f9bd9.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-99dfc228.js → totp-359f3930.js} +179 -210
  44. package/dist/node/totp-359f3930.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-6a7976b7.js → totp-3e8532c1.js} +129 -123
  52. package/dist/node-esm/totp-3e8532c1.js.map +1 -0
  53. package/dist/rn/{index-1737b0ce.js → index-fef1349d.js} +183 -214
  54. package/dist/rn/index-fef1349d.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 +6 -6
  66. package/dist/browser-cjs/index-bbdc1888.js.map +0 -1
  67. package/dist/cordova/popup_redirect-f62a8012.js.map +0 -1
  68. package/dist/esm2017/index-2e980710.js.map +0 -1
  69. package/dist/esm5/index-ad762403.js.map +0 -1
  70. package/dist/node/totp-99dfc228.js.map +0 -1
  71. package/dist/node-esm/totp-6a7976b7.js.map +0 -1
  72. package/dist/rn/index-1737b0ce.js.map +0 -1
@@ -22,13 +22,13 @@ interface GetRecaptchaConfigRequest {
22
22
  clientType?: RecaptchaClientType;
23
23
  version?: RecaptchaVersion;
24
24
  }
25
- interface RecaptchaEnforcementState {
25
+ export interface RecaptchaEnforcementProviderState {
26
26
  provider: string;
27
27
  enforcementState: string;
28
28
  }
29
29
  export interface GetRecaptchaConfigResponse {
30
30
  recaptchaKey: string;
31
- recaptchaEnforcementState: RecaptchaEnforcementState[];
31
+ recaptchaEnforcementState: RecaptchaEnforcementProviderState[];
32
32
  }
33
33
  export declare function getRecaptchaConfig(auth: Auth, request: GetRecaptchaConfigRequest): Promise<GetRecaptchaConfigResponse>;
34
34
  export {};
@@ -69,6 +69,15 @@ export declare const enum RecaptchaActionName {
69
69
  GET_OOB_CODE = "getOobCode",
70
70
  SIGN_UP_PASSWORD = "signUpPassword"
71
71
  }
72
+ export declare const enum EnforcementState {
73
+ ENFORCE = "ENFORCE",
74
+ AUDIT = "AUDIT",
75
+ OFF = "OFF",
76
+ ENFORCEMENT_STATE_UNSPECIFIED = "ENFORCEMENT_STATE_UNSPECIFIED"
77
+ }
78
+ export declare const enum RecaptchaProvider {
79
+ EMAIL_PASSWORD_PROVIDER = "EMAIL_PASSWORD_PROVIDER"
80
+ }
72
81
  export declare const DEFAULT_API_TIMEOUT_MS: Delay;
73
82
  export declare function _addTidIfNecessary<T extends {
74
83
  tenantId?: string;
@@ -77,6 +86,7 @@ export declare function _performApiRequest<T, V>(auth: Auth, method: HttpMethod,
77
86
  export declare function _performFetchWithErrorHandling<V>(auth: Auth, customErrorMap: Partial<ServerErrorMap<ServerError>>, fetchFn: () => Promise<Response>): Promise<V>;
78
87
  export declare function _performSignInRequest<T, V extends IdTokenResponse>(auth: Auth, method: HttpMethod, path: Endpoint, request?: T, customErrorMap?: Partial<ServerErrorMap<ServerError>>): Promise<V>;
79
88
  export declare function _getFinalTarget(auth: Auth, host: string, path: string, query: string): string;
89
+ export declare function _parseEnforcementState(enforcementStateStr: string): EnforcementState;
80
90
  interface PotentialResponse extends IdTokenResponse {
81
91
  email?: string;
82
92
  phoneNumber?: string;
@@ -15,7 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { RecaptchaParameters } from '../../model/public_types';
18
- import { GetRecaptchaConfigResponse } from '../../api/authentication/recaptcha';
18
+ import { GetRecaptchaConfigResponse, RecaptchaEnforcementProviderState } from '../../api/authentication/recaptcha';
19
+ import { EnforcementState } from '../../api/index';
19
20
  export interface Recaptcha {
20
21
  render: (container: HTMLElement, parameters: RecaptchaParameters) => number;
21
22
  getResponse: (id: number) => string;
@@ -49,8 +50,22 @@ export declare class RecaptchaConfig {
49
50
  */
50
51
  siteKey: string;
51
52
  /**
52
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
53
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
53
54
  */
54
- emailPasswordEnabled: boolean;
55
+ recaptchaEnforcementState: RecaptchaEnforcementProviderState[];
55
56
  constructor(response: GetRecaptchaConfigResponse);
57
+ /**
58
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
59
+ *
60
+ * @param providerStr - The provider whose enforcement state is to be returned.
61
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
62
+ */
63
+ getProviderEnforcementState(providerStr: string): EnforcementState | null;
64
+ /**
65
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
66
+ *
67
+ * @param providerStr - The provider whose enablement state is to be returned.
68
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
69
+ */
70
+ isProviderEnabled(providerStr: string): boolean;
56
71
  }
@@ -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 {};
@@ -103,50 +103,6 @@ const ActionCodeOperation = {
103
103
  VERIFY_EMAIL: 'VERIFY_EMAIL'
104
104
  };
105
105
 
106
- /**
107
- * @license
108
- * Copyright 2020 Google LLC
109
- *
110
- * Licensed under the Apache License, Version 2.0 (the "License");
111
- * you may not use this file except in compliance with the License.
112
- * You may obtain a copy of the License at
113
- *
114
- * http://www.apache.org/licenses/LICENSE-2.0
115
- *
116
- * Unless required by applicable law or agreed to in writing, software
117
- * distributed under the License is distributed on an "AS IS" BASIS,
118
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119
- * See the License for the specific language governing permissions and
120
- * limitations under the License.
121
- */
122
- function isV2(grecaptcha) {
123
- return (grecaptcha !== undefined &&
124
- grecaptcha.getResponse !== undefined);
125
- }
126
- function isEnterprise(grecaptcha) {
127
- return (grecaptcha !== undefined &&
128
- grecaptcha.enterprise !== undefined);
129
- }
130
- class RecaptchaConfig {
131
- constructor(response) {
132
- /**
133
- * The reCAPTCHA site key.
134
- */
135
- this.siteKey = '';
136
- /**
137
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
138
- */
139
- this.emailPasswordEnabled = false;
140
- if (response.recaptchaKey === undefined) {
141
- throw new Error('recaptchaKey undefined');
142
- }
143
- // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
144
- this.siteKey = response.recaptchaKey.split('/')[3];
145
- this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
146
- enforcementState.enforcementState !== 'OFF');
147
- }
148
- }
149
-
150
106
  /**
151
107
  * @license
152
108
  * Copyright 2020 Google LLC
@@ -756,6 +712,12 @@ class FetchProvider {
756
712
  if (typeof self !== 'undefined' && 'fetch' in self) {
757
713
  return self.fetch;
758
714
  }
715
+ if (typeof globalThis !== 'undefined' && globalThis.fetch) {
716
+ return globalThis.fetch;
717
+ }
718
+ if (typeof fetch !== 'undefined') {
719
+ return fetch;
720
+ }
759
721
  debugFail('Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
760
722
  }
761
723
  static headers() {
@@ -765,6 +727,12 @@ class FetchProvider {
765
727
  if (typeof self !== 'undefined' && 'Headers' in self) {
766
728
  return self.Headers;
767
729
  }
730
+ if (typeof globalThis !== 'undefined' && globalThis.Headers) {
731
+ return globalThis.Headers;
732
+ }
733
+ if (typeof Headers !== 'undefined') {
734
+ return Headers;
735
+ }
768
736
  debugFail('Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
769
737
  }
770
738
  static response() {
@@ -774,6 +742,12 @@ class FetchProvider {
774
742
  if (typeof self !== 'undefined' && 'Response' in self) {
775
743
  return self.Response;
776
744
  }
745
+ if (typeof globalThis !== 'undefined' && globalThis.Response) {
746
+ return globalThis.Response;
747
+ }
748
+ if (typeof Response !== 'undefined') {
749
+ return Response;
750
+ }
777
751
  debugFail('Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
778
752
  }
779
753
  }
@@ -985,6 +959,18 @@ function _getFinalTarget(auth, host, path, query) {
985
959
  }
986
960
  return _emulatorUrl(auth.config, base);
987
961
  }
962
+ function _parseEnforcementState(enforcementStateStr) {
963
+ switch (enforcementStateStr) {
964
+ case 'ENFORCE':
965
+ return "ENFORCE" /* EnforcementState.ENFORCE */;
966
+ case 'AUDIT':
967
+ return "AUDIT" /* EnforcementState.AUDIT */;
968
+ case 'OFF':
969
+ return "OFF" /* EnforcementState.OFF */;
970
+ default:
971
+ return "ENFORCEMENT_STATE_UNSPECIFIED" /* EnforcementState.ENFORCEMENT_STATE_UNSPECIFIED */;
972
+ }
973
+ }
988
974
  class NetworkTimeout {
989
975
  constructor(auth) {
990
976
  this.auth = auth;
@@ -1018,6 +1004,79 @@ function _makeTaggedError(auth, code, response) {
1018
1004
  return error;
1019
1005
  }
1020
1006
 
1007
+ /**
1008
+ * @license
1009
+ * Copyright 2020 Google LLC
1010
+ *
1011
+ * Licensed under the Apache License, Version 2.0 (the "License");
1012
+ * you may not use this file except in compliance with the License.
1013
+ * You may obtain a copy of the License at
1014
+ *
1015
+ * http://www.apache.org/licenses/LICENSE-2.0
1016
+ *
1017
+ * Unless required by applicable law or agreed to in writing, software
1018
+ * distributed under the License is distributed on an "AS IS" BASIS,
1019
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1020
+ * See the License for the specific language governing permissions and
1021
+ * limitations under the License.
1022
+ */
1023
+ function isV2(grecaptcha) {
1024
+ return (grecaptcha !== undefined &&
1025
+ grecaptcha.getResponse !== undefined);
1026
+ }
1027
+ function isEnterprise(grecaptcha) {
1028
+ return (grecaptcha !== undefined &&
1029
+ grecaptcha.enterprise !== undefined);
1030
+ }
1031
+ class RecaptchaConfig {
1032
+ constructor(response) {
1033
+ /**
1034
+ * The reCAPTCHA site key.
1035
+ */
1036
+ this.siteKey = '';
1037
+ /**
1038
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
1039
+ */
1040
+ this.recaptchaEnforcementState = [];
1041
+ if (response.recaptchaKey === undefined) {
1042
+ throw new Error('recaptchaKey undefined');
1043
+ }
1044
+ // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
1045
+ this.siteKey = response.recaptchaKey.split('/')[3];
1046
+ this.recaptchaEnforcementState = response.recaptchaEnforcementState;
1047
+ }
1048
+ /**
1049
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
1050
+ *
1051
+ * @param providerStr - The provider whose enforcement state is to be returned.
1052
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
1053
+ */
1054
+ getProviderEnforcementState(providerStr) {
1055
+ if (!this.recaptchaEnforcementState ||
1056
+ this.recaptchaEnforcementState.length === 0) {
1057
+ return null;
1058
+ }
1059
+ for (const recaptchaEnforcementState of this.recaptchaEnforcementState) {
1060
+ if (recaptchaEnforcementState.provider &&
1061
+ recaptchaEnforcementState.provider === providerStr) {
1062
+ return _parseEnforcementState(recaptchaEnforcementState.enforcementState);
1063
+ }
1064
+ }
1065
+ return null;
1066
+ }
1067
+ /**
1068
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
1069
+ *
1070
+ * @param providerStr - The provider whose enablement state is to be returned.
1071
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
1072
+ */
1073
+ isProviderEnabled(providerStr) {
1074
+ return (this.getProviderEnforcementState(providerStr) ===
1075
+ "ENFORCE" /* EnforcementState.ENFORCE */ ||
1076
+ this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
1077
+ }
1078
+ }
1079
+
1021
1080
  /**
1022
1081
  * @license
1023
1082
  * Copyright 2020 Google LLC
@@ -3133,6 +3192,26 @@ async function injectRecaptchaFields(auth, request, action, captchaResp = false)
3133
3192
  });
3134
3193
  return newRequest;
3135
3194
  }
3195
+ async function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3196
+ var _a;
3197
+ if ((_a = authInstance
3198
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3199
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3200
+ return actionMethod(authInstance, requestWithRecaptcha);
3201
+ }
3202
+ else {
3203
+ return actionMethod(authInstance, request).catch(async (error) => {
3204
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3205
+ console.log(`${actionName} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);
3206
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3207
+ return actionMethod(authInstance, requestWithRecaptcha);
3208
+ }
3209
+ else {
3210
+ return Promise.reject(error);
3211
+ }
3212
+ });
3213
+ }
3214
+ }
3136
3215
  async function _initializeRecaptchaConfig(auth) {
3137
3216
  const authInternal = _castAuth(auth);
3138
3217
  const response = await getRecaptchaConfig(authInternal, {
@@ -3146,7 +3225,7 @@ async function _initializeRecaptchaConfig(auth) {
3146
3225
  else {
3147
3226
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
3148
3227
  }
3149
- if (config.emailPasswordEnabled) {
3228
+ if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3150
3229
  const verifier = new RecaptchaEnterpriseVerifier(authInternal);
3151
3230
  void verifier.verify();
3152
3231
  }
@@ -3559,7 +3638,6 @@ class EmailAuthCredential extends AuthCredential {
3559
3638
  }
3560
3639
  /** @internal */
3561
3640
  async _getIdTokenResponse(auth) {
3562
- var _a;
3563
3641
  switch (this.signInMethod) {
3564
3642
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3565
3643
  const request = {
@@ -3568,22 +3646,7 @@ class EmailAuthCredential extends AuthCredential {
3568
3646
  password: this._password,
3569
3647
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3570
3648
  };
3571
- if ((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
3572
- const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3573
- return signInWithPassword(auth, requestWithRecaptcha);
3574
- }
3575
- else {
3576
- return signInWithPassword(auth, request).catch(async (error) => {
3577
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3578
- 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.');
3579
- const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3580
- return signInWithPassword(auth, requestWithRecaptcha);
3581
- }
3582
- else {
3583
- return Promise.reject(error);
3584
- }
3585
- });
3586
- }
3649
+ return handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword);
3587
3650
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3588
3651
  return signInWithEmailLink$1(auth, {
3589
3652
  email: this._email,
@@ -5561,39 +5624,16 @@ async function recachePasswordPolicy(auth) {
5561
5624
  * @public
5562
5625
  */
5563
5626
  async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
5564
- var _a;
5565
5627
  const authInternal = _castAuth(auth);
5566
5628
  const request = {
5567
5629
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
5568
5630
  email,
5569
5631
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5570
5632
  };
5571
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5572
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5573
- if (actionCodeSettings) {
5574
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5575
- }
5576
- await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5577
- }
5578
- else {
5579
- if (actionCodeSettings) {
5580
- _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5581
- }
5582
- await sendPasswordResetEmail$1(authInternal, request)
5583
- .catch(async (error) => {
5584
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5585
- console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
5586
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5587
- if (actionCodeSettings) {
5588
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5589
- }
5590
- await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5591
- }
5592
- else {
5593
- return Promise.reject(error);
5594
- }
5595
- });
5633
+ if (actionCodeSettings) {
5634
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5596
5635
  }
5636
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1);
5597
5637
  }
5598
5638
  /**
5599
5639
  * Completes the password reset process, given a confirmation code and new password.
@@ -5713,7 +5753,6 @@ async function verifyPasswordResetCode(auth, code) {
5713
5753
  * @public
5714
5754
  */
5715
5755
  async function createUserWithEmailAndPassword(auth, email, password) {
5716
- var _a;
5717
5756
  const authInternal = _castAuth(auth);
5718
5757
  const request = {
5719
5758
  returnSecureToken: true,
@@ -5721,21 +5760,7 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5721
5760
  password,
5722
5761
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5723
5762
  };
5724
- let signUpResponse;
5725
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5726
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5727
- signUpResponse = signUp(authInternal, requestWithRecaptcha);
5728
- }
5729
- else {
5730
- signUpResponse = signUp(authInternal, request).catch(async (error) => {
5731
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5732
- console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
5733
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5734
- return signUp(authInternal, requestWithRecaptcha);
5735
- }
5736
- throw error;
5737
- });
5738
- }
5763
+ const signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
5739
5764
  const response = await signUpResponse.catch(error => {
5740
5765
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5741
5766
  void recachePasswordPolicy(auth);
@@ -5826,7 +5851,6 @@ function signInWithEmailAndPassword(auth, email, password) {
5826
5851
  * @public
5827
5852
  */
5828
5853
  async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5829
- var _a;
5830
5854
  const authInternal = _castAuth(auth);
5831
5855
  const request = {
5832
5856
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
@@ -5839,26 +5863,8 @@ async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5839
5863
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5840
5864
  }
5841
5865
  }
5842
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5843
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5844
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5845
- await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5846
- }
5847
- else {
5848
- setActionCodeSettings(request, actionCodeSettings);
5849
- await sendSignInLinkToEmail$1(authInternal, request)
5850
- .catch(async (error) => {
5851
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5852
- console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
5853
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5854
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5855
- await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5856
- }
5857
- else {
5858
- return Promise.reject(error);
5859
- }
5860
- });
5861
- }
5866
+ setActionCodeSettings(request, actionCodeSettings);
5867
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1);
5862
5868
  }
5863
5869
  /**
5864
5870
  * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
@@ -10218,7 +10224,7 @@ function _isEmptyString(input) {
10218
10224
  }
10219
10225
 
10220
10226
  var name = "@firebase/auth";
10221
- var version = "1.3.0-canary.eff95304d";
10227
+ var version = "1.3.0-canary.f002ef36a";
10222
10228
 
10223
10229
  /**
10224
10230
  * @license
@@ -10439,4 +10445,4 @@ function getAuth(app = getApp()) {
10439
10445
  registerAuth("Browser" /* ClientPlatform.BROWSER */);
10440
10446
 
10441
10447
  export { signInAnonymously as $, ActionCodeOperation as A, updateCurrentUser as B, signOut as C, deleteUser as D, debugErrorMap as E, FactorId as F, prodErrorMap as G, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as H, initializeAuth as I, connectAuthEmulator as J, AuthCredential as K, EmailAuthCredential as L, OAuthCredential as M, PhoneAuthCredential as N, OperationType as O, PhoneAuthProvider as P, inMemoryPersistence as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, EmailAuthProvider as U, FacebookAuthProvider as V, GoogleAuthProvider as W, GithubAuthProvider as X, OAuthProvider as Y, SAMLAuthProvider as Z, TwitterAuthProvider as _, browserSessionPersistence as a, signInWithCredential as a0, linkWithCredential as a1, reauthenticateWithCredential as a2, signInWithCustomToken as a3, sendPasswordResetEmail as a4, confirmPasswordReset as a5, applyActionCode as a6, checkActionCode as a7, verifyPasswordResetCode as a8, createUserWithEmailAndPassword as a9, _createError as aA, _assert as aB, AuthEventManager as aC, _getInstance as aD, _persistenceKeyName as aE, _getRedirectResult as aF, _overrideRedirectResult as aG, _clearRedirectOutcomes as aH, _castAuth as aI, UserImpl as aJ, AuthImpl as aK, _getClientVersion as aL, _generateEventId as aM, AuthPopup as aN, FetchProvider as aO, SAMLAuthCredential as aP, signInWithEmailAndPassword as aa, sendSignInLinkToEmail as ab, isSignInWithEmailLink as ac, signInWithEmailLink as ad, fetchSignInMethodsForEmail as ae, sendEmailVerification as af, verifyBeforeUpdateEmail as ag, ActionCodeURL as ah, parseActionCodeURL as ai, updateProfile as aj, updateEmail as ak, updatePassword as al, getIdToken as am, getIdTokenResult as an, unlink as ao, getAdditionalUserInfo as ap, reload as aq, getMultiFactorResolver as ar, multiFactor as as, debugAssert as at, _isIOS as au, _isAndroid as av, _fail as aw, _getRedirectUrl as ax, _getProjectConfig as ay, _isIOS7Or8 as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, initializeRecaptchaConfig as t, updatePhoneNumber as u, validatePassword as v, onIdTokenChanged as w, beforeAuthStateChanged as x, onAuthStateChanged as y, useDeviceLanguage as z };
10442
- //# sourceMappingURL=index-2e980710.js.map
10448
+ //# sourceMappingURL=index-3000f55e.js.map