@firebase/auth 1.3.0-canary.b2f6084ef → 1.3.0-canary.bd073b26a

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-6dea9e71.js → index-579a938f.js} +115 -127
  4. package/dist/browser-cjs/index-579a938f.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-26919902.js → popup_redirect-400d4165.js} +165 -214
  14. package/dist/cordova/popup_redirect-400d4165.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-8d700a94.js → index-5030de23.js} +115 -127
  20. package/dist/esm2017/index-5030de23.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-2f338edd.js → index-eeff7a7d.js} +165 -214
  28. package/dist/esm5/index-eeff7a7d.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 +123 -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-4fce07b4.js → totp-a4fded14.js} +161 -210
  44. package/dist/node/totp-a4fded14.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-4eb6ee99.js → totp-1609c8f4.js} +111 -123
  52. package/dist/node-esm/totp-1609c8f4.js.map +1 -0
  53. package/dist/rn/{index-e781fb23.js → index-44789ad9.js} +165 -214
  54. package/dist/rn/index-44789ad9.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 +12 -12
  66. package/dist/browser-cjs/index-6dea9e71.js.map +0 -1
  67. package/dist/cordova/popup_redirect-26919902.js.map +0 -1
  68. package/dist/esm2017/index-8d700a94.js.map +0 -1
  69. package/dist/esm5/index-2f338edd.js.map +0 -1
  70. package/dist/node/totp-4fce07b4.js.map +0 -1
  71. package/dist/node-esm/totp-4eb6ee99.js.map +0 -1
  72. package/dist/rn/index-e781fb23.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
@@ -985,6 +941,18 @@ function _getFinalTarget(auth, host, path, query) {
985
941
  }
986
942
  return _emulatorUrl(auth.config, base);
987
943
  }
944
+ function _parseEnforcementState(enforcementStateStr) {
945
+ switch (enforcementStateStr) {
946
+ case 'ENFORCE':
947
+ return "ENFORCE" /* EnforcementState.ENFORCE */;
948
+ case 'AUDIT':
949
+ return "AUDIT" /* EnforcementState.AUDIT */;
950
+ case 'OFF':
951
+ return "OFF" /* EnforcementState.OFF */;
952
+ default:
953
+ return "ENFORCEMENT_STATE_UNSPECIFIED" /* EnforcementState.ENFORCEMENT_STATE_UNSPECIFIED */;
954
+ }
955
+ }
988
956
  class NetworkTimeout {
989
957
  constructor(auth) {
990
958
  this.auth = auth;
@@ -1018,6 +986,79 @@ function _makeTaggedError(auth, code, response) {
1018
986
  return error;
1019
987
  }
1020
988
 
989
+ /**
990
+ * @license
991
+ * Copyright 2020 Google LLC
992
+ *
993
+ * Licensed under the Apache License, Version 2.0 (the "License");
994
+ * you may not use this file except in compliance with the License.
995
+ * You may obtain a copy of the License at
996
+ *
997
+ * http://www.apache.org/licenses/LICENSE-2.0
998
+ *
999
+ * Unless required by applicable law or agreed to in writing, software
1000
+ * distributed under the License is distributed on an "AS IS" BASIS,
1001
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1002
+ * See the License for the specific language governing permissions and
1003
+ * limitations under the License.
1004
+ */
1005
+ function isV2(grecaptcha) {
1006
+ return (grecaptcha !== undefined &&
1007
+ grecaptcha.getResponse !== undefined);
1008
+ }
1009
+ function isEnterprise(grecaptcha) {
1010
+ return (grecaptcha !== undefined &&
1011
+ grecaptcha.enterprise !== undefined);
1012
+ }
1013
+ class RecaptchaConfig {
1014
+ constructor(response) {
1015
+ /**
1016
+ * The reCAPTCHA site key.
1017
+ */
1018
+ this.siteKey = '';
1019
+ /**
1020
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
1021
+ */
1022
+ this.recaptchaEnforcementState = [];
1023
+ if (response.recaptchaKey === undefined) {
1024
+ throw new Error('recaptchaKey undefined');
1025
+ }
1026
+ // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
1027
+ this.siteKey = response.recaptchaKey.split('/')[3];
1028
+ this.recaptchaEnforcementState = response.recaptchaEnforcementState;
1029
+ }
1030
+ /**
1031
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
1032
+ *
1033
+ * @param providerStr - The provider whose enforcement state is to be returned.
1034
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
1035
+ */
1036
+ getProviderEnforcementState(providerStr) {
1037
+ if (!this.recaptchaEnforcementState ||
1038
+ this.recaptchaEnforcementState.length === 0) {
1039
+ return null;
1040
+ }
1041
+ for (const recaptchaEnforcementState of this.recaptchaEnforcementState) {
1042
+ if (recaptchaEnforcementState.provider &&
1043
+ recaptchaEnforcementState.provider === providerStr) {
1044
+ return _parseEnforcementState(recaptchaEnforcementState.enforcementState);
1045
+ }
1046
+ }
1047
+ return null;
1048
+ }
1049
+ /**
1050
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
1051
+ *
1052
+ * @param providerStr - The provider whose enablement state is to be returned.
1053
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
1054
+ */
1055
+ isProviderEnabled(providerStr) {
1056
+ return (this.getProviderEnforcementState(providerStr) ===
1057
+ "ENFORCE" /* EnforcementState.ENFORCE */ ||
1058
+ this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
1059
+ }
1060
+ }
1061
+
1021
1062
  /**
1022
1063
  * @license
1023
1064
  * Copyright 2020 Google LLC
@@ -3133,6 +3174,26 @@ async function injectRecaptchaFields(auth, request, action, captchaResp = false)
3133
3174
  });
3134
3175
  return newRequest;
3135
3176
  }
3177
+ async function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3178
+ var _a;
3179
+ if ((_a = authInstance
3180
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3181
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3182
+ return actionMethod(authInstance, requestWithRecaptcha);
3183
+ }
3184
+ else {
3185
+ return actionMethod(authInstance, request).catch(async (error) => {
3186
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3187
+ console.log(`${actionName} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);
3188
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3189
+ return actionMethod(authInstance, requestWithRecaptcha);
3190
+ }
3191
+ else {
3192
+ return Promise.reject(error);
3193
+ }
3194
+ });
3195
+ }
3196
+ }
3136
3197
  async function _initializeRecaptchaConfig(auth) {
3137
3198
  const authInternal = _castAuth(auth);
3138
3199
  const response = await getRecaptchaConfig(authInternal, {
@@ -3146,7 +3207,7 @@ async function _initializeRecaptchaConfig(auth) {
3146
3207
  else {
3147
3208
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
3148
3209
  }
3149
- if (config.emailPasswordEnabled) {
3210
+ if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3150
3211
  const verifier = new RecaptchaEnterpriseVerifier(authInternal);
3151
3212
  void verifier.verify();
3152
3213
  }
@@ -3559,7 +3620,6 @@ class EmailAuthCredential extends AuthCredential {
3559
3620
  }
3560
3621
  /** @internal */
3561
3622
  async _getIdTokenResponse(auth) {
3562
- var _a;
3563
3623
  switch (this.signInMethod) {
3564
3624
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3565
3625
  const request = {
@@ -3568,22 +3628,7 @@ class EmailAuthCredential extends AuthCredential {
3568
3628
  password: this._password,
3569
3629
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3570
3630
  };
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
- }
3631
+ return handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword);
3587
3632
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3588
3633
  return signInWithEmailLink$1(auth, {
3589
3634
  email: this._email,
@@ -5561,39 +5606,16 @@ async function recachePasswordPolicy(auth) {
5561
5606
  * @public
5562
5607
  */
5563
5608
  async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
5564
- var _a;
5565
5609
  const authInternal = _castAuth(auth);
5566
5610
  const request = {
5567
5611
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
5568
5612
  email,
5569
5613
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5570
5614
  };
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
- });
5615
+ if (actionCodeSettings) {
5616
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5596
5617
  }
5618
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1);
5597
5619
  }
5598
5620
  /**
5599
5621
  * Completes the password reset process, given a confirmation code and new password.
@@ -5713,7 +5735,6 @@ async function verifyPasswordResetCode(auth, code) {
5713
5735
  * @public
5714
5736
  */
5715
5737
  async function createUserWithEmailAndPassword(auth, email, password) {
5716
- var _a;
5717
5738
  const authInternal = _castAuth(auth);
5718
5739
  const request = {
5719
5740
  returnSecureToken: true,
@@ -5721,21 +5742,7 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5721
5742
  password,
5722
5743
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5723
5744
  };
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
- }
5745
+ const signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
5739
5746
  const response = await signUpResponse.catch(error => {
5740
5747
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5741
5748
  void recachePasswordPolicy(auth);
@@ -5826,7 +5833,6 @@ function signInWithEmailAndPassword(auth, email, password) {
5826
5833
  * @public
5827
5834
  */
5828
5835
  async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5829
- var _a;
5830
5836
  const authInternal = _castAuth(auth);
5831
5837
  const request = {
5832
5838
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
@@ -5839,26 +5845,8 @@ async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5839
5845
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5840
5846
  }
5841
5847
  }
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
- }
5848
+ setActionCodeSettings(request, actionCodeSettings);
5849
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1);
5862
5850
  }
5863
5851
  /**
5864
5852
  * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
@@ -10218,7 +10206,7 @@ function _isEmptyString(input) {
10218
10206
  }
10219
10207
 
10220
10208
  var name = "@firebase/auth";
10221
- var version = "1.3.0-canary.b2f6084ef";
10209
+ var version = "1.3.0-canary.bd073b26a";
10222
10210
 
10223
10211
  /**
10224
10212
  * @license
@@ -10439,4 +10427,4 @@ function getAuth(app = getApp()) {
10439
10427
  registerAuth("Browser" /* ClientPlatform.BROWSER */);
10440
10428
 
10441
10429
  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-8d700a94.js.map
10430
+ //# sourceMappingURL=index-5030de23.js.map