@firebase/auth 1.3.0-canary.60e4a07d2 → 1.3.0-canary.698eeb67d

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-9e6c4f37.js → index-6c320c88.js} +115 -127
  4. package/dist/browser-cjs/index-6c320c88.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-4758cdae.js → popup_redirect-96bd7835.js} +165 -214
  14. package/dist/cordova/popup_redirect-96bd7835.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-c088af8a.js → index-57aefb02.js} +115 -127
  20. package/dist/esm2017/index-57aefb02.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-f6b0662a.js → index-6728b711.js} +165 -214
  28. package/dist/esm5/index-6728b711.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-2cc6b74c.js → totp-8ef4e9a8.js} +161 -210
  44. package/dist/node/totp-8ef4e9a8.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-bfa3ee61.js → totp-19c74b23.js} +111 -123
  52. package/dist/node-esm/totp-19c74b23.js.map +1 -0
  53. package/dist/rn/{index-6ea1dd0a.js → index-95a9f1bd.js} +165 -214
  54. package/dist/rn/index-95a9f1bd.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-9e6c4f37.js.map +0 -1
  67. package/dist/cordova/popup_redirect-4758cdae.js.map +0 -1
  68. package/dist/esm2017/index-c088af8a.js.map +0 -1
  69. package/dist/esm5/index-f6b0662a.js.map +0 -1
  70. package/dist/node/totp-2cc6b74c.js.map +0 -1
  71. package/dist/node-esm/totp-bfa3ee61.js.map +0 -1
  72. package/dist/rn/index-6ea1dd0a.js.map +0 -1
@@ -1,4 +1,4 @@
1
- export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-f6b0662a.js';
1
+ export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-6728b711.js';
2
2
  import 'tslib';
3
3
  import '@firebase/util';
4
4
  import '@firebase/app';
@@ -1,5 +1,5 @@
1
- import { at as _isIOS, au as _isAndroid, av as _fail, aw as _getRedirectUrl, ax as debugAssert, ay as _getProjectConfig, az as _isIOS7Or8, aA as _assert, aB as _createError, aC as AuthEventManager, aD as _getInstance, b as browserLocalPersistence, aE as _persistenceKeyName, aF as _clearRedirectOutcomes, a as browserSessionPersistence, aG as _getRedirectResult, aH as _overrideRedirectResult, aI as _castAuth } from './index-f6b0662a.js';
2
- export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, aK as AuthImpl, aN as AuthPopup, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, aO as FetchProvider, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, aP as SAMLAuthCredential, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, aJ as UserImpl, aA as _assert, aI as _castAuth, av as _fail, aM as _generateEventId, aL as _getClientVersion, aD as _getInstance, aG as _getRedirectResult, aH as _overrideRedirectResult, aE as _persistenceKeyName, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-f6b0662a.js';
1
+ import { at as _isIOS, au as _isAndroid, av as _fail, aw as _getRedirectUrl, ax as debugAssert, ay as _getProjectConfig, az as _isIOS7Or8, aA as _assert, aB as _createError, aC as AuthEventManager, aD as _getInstance, b as browserLocalPersistence, aE as _persistenceKeyName, aF as _clearRedirectOutcomes, a as browserSessionPersistence, aG as _getRedirectResult, aH as _overrideRedirectResult, aI as _castAuth } from './index-6728b711.js';
2
+ export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, aK as AuthImpl, aN as AuthPopup, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, aO as FetchProvider, X as GithubAuthProvider, W as GoogleAuthProvider, M as OAuthCredential, Y as OAuthProvider, O as OperationType, N as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, p as ProviderId, R as RecaptchaVerifier, aP as SAMLAuthCredential, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, aJ as UserImpl, aA as _assert, aI as _castAuth, av as _fail, aM as _generateEventId, aL as _getClientVersion, aD as _getInstance, aG as _getRedirectResult, aH as _overrideRedirectResult, aE as _persistenceKeyName, a6 as applyActionCode, x as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a7 as checkActionCode, a5 as confirmPasswordReset, J as connectAuthEmulator, a9 as createUserWithEmailAndPassword, E as debugErrorMap, D as deleteUser, ae as fetchSignInMethodsForEmail, ap as getAdditionalUserInfo, o as getAuth, am as getIdToken, an as getIdTokenResult, ar as getMultiFactorResolver, j as getRedirectResult, Q as inMemoryPersistence, i as indexedDBLocalPersistence, I as initializeAuth, t as initializeRecaptchaConfig, ac as isSignInWithEmailLink, a1 as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, as as multiFactor, y as onAuthStateChanged, w as onIdTokenChanged, ai as parseActionCodeURL, G as prodErrorMap, a2 as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, aq as reload, af as sendEmailVerification, a4 as sendPasswordResetEmail, ab as sendSignInLinkToEmail, q as setPersistence, $ as signInAnonymously, a0 as signInWithCredential, a3 as signInWithCustomToken, aa as signInWithEmailAndPassword, ad as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, C as signOut, ao as unlink, B as updateCurrentUser, ak as updateEmail, al as updatePassword, u as updatePhoneNumber, aj as updateProfile, z as useDeviceLanguage, v as validatePassword, ag as verifyBeforeUpdateEmail, a8 as verifyPasswordResetCode } from './index-6728b711.js';
3
3
  import { __awaiter, __generator, __extends } from 'tslib';
4
4
  import { querystringDecode } from '@firebase/util';
5
5
  import '@firebase/app';
@@ -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 {};
@@ -551,7 +551,7 @@ function _initializeAuthInstance(auth, deps) {
551
551
  }
552
552
 
553
553
  var name = "@firebase/auth";
554
- var version = "1.3.0-canary.60e4a07d2";
554
+ var version = "1.3.0-canary.698eeb67d";
555
555
 
556
556
  /**
557
557
  * @license
@@ -1148,6 +1148,18 @@ function _getFinalTarget(auth, host, path, query) {
1148
1148
  }
1149
1149
  return _emulatorUrl(auth.config, base);
1150
1150
  }
1151
+ function _parseEnforcementState(enforcementStateStr) {
1152
+ switch (enforcementStateStr) {
1153
+ case 'ENFORCE':
1154
+ return "ENFORCE" /* EnforcementState.ENFORCE */;
1155
+ case 'AUDIT':
1156
+ return "AUDIT" /* EnforcementState.AUDIT */;
1157
+ case 'OFF':
1158
+ return "OFF" /* EnforcementState.OFF */;
1159
+ default:
1160
+ return "ENFORCEMENT_STATE_UNSPECIFIED" /* EnforcementState.ENFORCEMENT_STATE_UNSPECIFIED */;
1161
+ }
1162
+ }
1151
1163
  var NetworkTimeout = /** @class */ (function () {
1152
1164
  function NetworkTimeout(auth) {
1153
1165
  var _this = this;
@@ -4617,19 +4629,47 @@ var RecaptchaConfig = /** @class */ (function () {
4617
4629
  */
4618
4630
  this.siteKey = '';
4619
4631
  /**
4620
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
4632
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
4621
4633
  */
4622
- this.emailPasswordEnabled = false;
4634
+ this.recaptchaEnforcementState = [];
4623
4635
  if (response.recaptchaKey === undefined) {
4624
4636
  throw new Error('recaptchaKey undefined');
4625
4637
  }
4626
4638
  // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
4627
4639
  this.siteKey = response.recaptchaKey.split('/')[3];
4628
- this.emailPasswordEnabled = response.recaptchaEnforcementState.some(function (enforcementState) {
4629
- return enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
4630
- enforcementState.enforcementState !== 'OFF';
4631
- });
4640
+ this.recaptchaEnforcementState = response.recaptchaEnforcementState;
4632
4641
  }
4642
+ /**
4643
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
4644
+ *
4645
+ * @param providerStr - The provider whose enforcement state is to be returned.
4646
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
4647
+ */
4648
+ RecaptchaConfig.prototype.getProviderEnforcementState = function (providerStr) {
4649
+ if (!this.recaptchaEnforcementState ||
4650
+ this.recaptchaEnforcementState.length === 0) {
4651
+ return null;
4652
+ }
4653
+ for (var _i = 0, _a = this.recaptchaEnforcementState; _i < _a.length; _i++) {
4654
+ var recaptchaEnforcementState = _a[_i];
4655
+ if (recaptchaEnforcementState.provider &&
4656
+ recaptchaEnforcementState.provider === providerStr) {
4657
+ return _parseEnforcementState(recaptchaEnforcementState.enforcementState);
4658
+ }
4659
+ }
4660
+ return null;
4661
+ };
4662
+ /**
4663
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
4664
+ *
4665
+ * @param providerStr - The provider whose enablement state is to be returned.
4666
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
4667
+ */
4668
+ RecaptchaConfig.prototype.isProviderEnabled = function (providerStr) {
4669
+ return (this.getProviderEnforcementState(providerStr) ===
4670
+ "ENFORCE" /* EnforcementState.ENFORCE */ ||
4671
+ this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
4672
+ };
4633
4673
  return RecaptchaConfig;
4634
4674
  }());
4635
4675
 
@@ -4850,6 +4890,39 @@ function injectRecaptchaFields(auth, request, action, captchaResp) {
4850
4890
  });
4851
4891
  });
4852
4892
  }
4893
+ function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
4894
+ var _a;
4895
+ return __awaiter(this, void 0, void 0, function () {
4896
+ var requestWithRecaptcha;
4897
+ var _this = this;
4898
+ return __generator(this, function (_b) {
4899
+ switch (_b.label) {
4900
+ case 0:
4901
+ if (!((_a = authInstance
4902
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */))) return [3 /*break*/, 2];
4903
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */)];
4904
+ case 1:
4905
+ requestWithRecaptcha = _b.sent();
4906
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha)];
4907
+ case 2: return [2 /*return*/, actionMethod(authInstance, request).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
4908
+ var requestWithRecaptcha;
4909
+ return __generator(this, function (_a) {
4910
+ switch (_a.label) {
4911
+ case 0:
4912
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
4913
+ console.log("".concat(actionName, " is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow."));
4914
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */)];
4915
+ case 1:
4916
+ requestWithRecaptcha = _a.sent();
4917
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha)];
4918
+ case 2: return [2 /*return*/, Promise.reject(error)];
4919
+ }
4920
+ });
4921
+ }); })];
4922
+ }
4923
+ });
4924
+ });
4925
+ }
4853
4926
  function _initializeRecaptchaConfig(auth) {
4854
4927
  return __awaiter(this, void 0, void 0, function () {
4855
4928
  var authInternal, response, config, verifier;
@@ -4870,7 +4943,7 @@ function _initializeRecaptchaConfig(auth) {
4870
4943
  else {
4871
4944
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
4872
4945
  }
4873
- if (config.emailPasswordEnabled) {
4946
+ if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
4874
4947
  verifier = new RecaptchaEnterpriseVerifier(authInternal);
4875
4948
  void verifier.verify();
4876
4949
  }
@@ -5268,55 +5341,27 @@ var EmailAuthCredential = /** @class */ (function (_super) {
5268
5341
  };
5269
5342
  /** @internal */
5270
5343
  EmailAuthCredential.prototype._getIdTokenResponse = function (auth) {
5271
- var _a;
5272
5344
  return __awaiter(this, void 0, void 0, function () {
5273
- var _b, request_1, requestWithRecaptcha;
5274
- var _this = this;
5275
- return __generator(this, function (_c) {
5276
- switch (_c.label) {
5277
- case 0:
5278
- _b = this.signInMethod;
5279
- switch (_b) {
5280
- case "password" /* SignInMethod.EMAIL_PASSWORD */: return [3 /*break*/, 1];
5281
- case "emailLink" /* SignInMethod.EMAIL_LINK */: return [3 /*break*/, 4];
5282
- }
5283
- return [3 /*break*/, 5];
5284
- case 1:
5285
- request_1 = {
5345
+ var request;
5346
+ return __generator(this, function (_a) {
5347
+ switch (this.signInMethod) {
5348
+ case "password" /* SignInMethod.EMAIL_PASSWORD */:
5349
+ request = {
5286
5350
  returnSecureToken: true,
5287
5351
  email: this._email,
5288
5352
  password: this._password,
5289
5353
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5290
5354
  };
5291
- if (!((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
5292
- return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
5293
- case 2:
5294
- requestWithRecaptcha = _c.sent();
5295
- return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
5296
- case 3: return [2 /*return*/, signInWithPassword(auth, request_1).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
5297
- var requestWithRecaptcha;
5298
- return __generator(this, function (_a) {
5299
- switch (_a.label) {
5300
- case 0:
5301
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
5302
- console.log('Sign-in with email address and password is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
5303
- return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
5304
- case 1:
5305
- requestWithRecaptcha = _a.sent();
5306
- return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
5307
- case 2: return [2 /*return*/, Promise.reject(error)];
5308
- }
5309
- });
5310
- }); })];
5311
- case 4: return [2 /*return*/, signInWithEmailLink$1(auth, {
5312
- email: this._email,
5313
- oobCode: this._password
5314
- })];
5315
- case 5:
5355
+ return [2 /*return*/, handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword)];
5356
+ case "emailLink" /* SignInMethod.EMAIL_LINK */:
5357
+ return [2 /*return*/, signInWithEmailLink$1(auth, {
5358
+ email: this._email,
5359
+ oobCode: this._password
5360
+ })];
5361
+ default:
5316
5362
  _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
5317
- _c.label = 6;
5318
- case 6: return [2 /*return*/];
5319
5363
  }
5364
+ return [2 /*return*/];
5320
5365
  });
5321
5366
  });
5322
5367
  };
@@ -7526,12 +7571,10 @@ function recachePasswordPolicy(auth) {
7526
7571
  * @public
7527
7572
  */
7528
7573
  function sendPasswordResetEmail(auth, email, actionCodeSettings) {
7529
- var _a;
7530
7574
  return __awaiter(this, void 0, void 0, function () {
7531
- var authInternal, request, requestWithRecaptcha;
7532
- var _this = this;
7533
- return __generator(this, function (_b) {
7534
- switch (_b.label) {
7575
+ var authInternal, request;
7576
+ return __generator(this, function (_a) {
7577
+ switch (_a.label) {
7535
7578
  case 0:
7536
7579
  authInternal = _castAuth(auth);
7537
7580
  request = {
@@ -7539,48 +7582,13 @@ function sendPasswordResetEmail(auth, email, actionCodeSettings) {
7539
7582
  email: email,
7540
7583
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7541
7584
  };
7542
- if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
7543
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7544
- case 1:
7545
- requestWithRecaptcha = _b.sent();
7546
- if (actionCodeSettings) {
7547
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
7548
- }
7549
- return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
7550
- case 2:
7551
- _b.sent();
7552
- return [3 /*break*/, 5];
7553
- case 3:
7554
7585
  if (actionCodeSettings) {
7555
7586
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
7556
7587
  }
7557
- return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, request)
7558
- .catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
7559
- var requestWithRecaptcha;
7560
- return __generator(this, function (_a) {
7561
- switch (_a.label) {
7562
- case 0:
7563
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
7564
- console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
7565
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7566
- case 1:
7567
- requestWithRecaptcha = _a.sent();
7568
- if (actionCodeSettings) {
7569
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
7570
- }
7571
- return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
7572
- case 2:
7573
- _a.sent();
7574
- return [3 /*break*/, 4];
7575
- case 3: return [2 /*return*/, Promise.reject(error)];
7576
- case 4: return [2 /*return*/];
7577
- }
7578
- });
7579
- }); })];
7580
- case 4:
7581
- _b.sent();
7582
- _b.label = 5;
7583
- case 5: return [2 /*return*/];
7588
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1)];
7589
+ case 1:
7590
+ _a.sent();
7591
+ return [2 /*return*/];
7584
7592
  }
7585
7593
  });
7586
7594
  });
@@ -7735,12 +7743,10 @@ function verifyPasswordResetCode(auth, code) {
7735
7743
  * @public
7736
7744
  */
7737
7745
  function createUserWithEmailAndPassword(auth, email, password) {
7738
- var _a;
7739
7746
  return __awaiter(this, void 0, void 0, function () {
7740
- var authInternal, request, signUpResponse, requestWithRecaptcha, response, userCredential;
7741
- var _this = this;
7742
- return __generator(this, function (_b) {
7743
- switch (_b.label) {
7747
+ var authInternal, request, signUpResponse, response, userCredential;
7748
+ return __generator(this, function (_a) {
7749
+ switch (_a.label) {
7744
7750
  case 0:
7745
7751
  authInternal = _castAuth(auth);
7746
7752
  request = {
@@ -7749,43 +7755,21 @@ function createUserWithEmailAndPassword(auth, email, password) {
7749
7755
  password: password,
7750
7756
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7751
7757
  };
7752
- if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 2];
7753
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
7754
- case 1:
7755
- requestWithRecaptcha = _b.sent();
7756
- signUpResponse = signUp(authInternal, requestWithRecaptcha);
7757
- return [3 /*break*/, 3];
7758
- case 2:
7759
- signUpResponse = signUp(authInternal, request).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
7760
- var requestWithRecaptcha;
7761
- return __generator(this, function (_a) {
7762
- switch (_a.label) {
7763
- case 0:
7764
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
7765
- console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
7766
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
7767
- case 1:
7768
- requestWithRecaptcha = _a.sent();
7769
- return [2 /*return*/, signUp(authInternal, requestWithRecaptcha)];
7770
- case 2: throw error;
7758
+ signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
7759
+ return [4 /*yield*/, signUpResponse.catch(function (error) {
7760
+ if (error.code === "auth/".concat("password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */)) {
7761
+ void recachePasswordPolicy(auth);
7771
7762
  }
7772
- });
7773
- }); });
7774
- _b.label = 3;
7775
- case 3: return [4 /*yield*/, signUpResponse.catch(function (error) {
7776
- if (error.code === "auth/".concat("password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */)) {
7777
- void recachePasswordPolicy(auth);
7778
- }
7779
- throw error;
7780
- })];
7781
- case 4:
7782
- response = _b.sent();
7763
+ throw error;
7764
+ })];
7765
+ case 1:
7766
+ response = _a.sent();
7783
7767
  return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
7784
- case 5:
7785
- userCredential = _b.sent();
7768
+ case 2:
7769
+ userCredential = _a.sent();
7786
7770
  return [4 /*yield*/, authInternal._updateCurrentUser(userCredential.user)];
7787
- case 6:
7788
- _b.sent();
7771
+ case 3:
7772
+ _a.sent();
7789
7773
  return [2 /*return*/, userCredential];
7790
7774
  }
7791
7775
  });
@@ -7874,7 +7858,6 @@ function signInWithEmailAndPassword(auth, email, password) {
7874
7858
  * @public
7875
7859
  */
7876
7860
  function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7877
- var _a;
7878
7861
  return __awaiter(this, void 0, void 0, function () {
7879
7862
  function setActionCodeSettings(request, actionCodeSettings) {
7880
7863
  _assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
@@ -7882,10 +7865,9 @@ function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7882
7865
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
7883
7866
  }
7884
7867
  }
7885
- var authInternal, request, requestWithRecaptcha;
7886
- var _this = this;
7887
- return __generator(this, function (_b) {
7888
- switch (_b.label) {
7868
+ var authInternal, request;
7869
+ return __generator(this, function (_a) {
7870
+ switch (_a.label) {
7889
7871
  case 0:
7890
7872
  authInternal = _castAuth(auth);
7891
7873
  request = {
@@ -7893,42 +7875,11 @@ function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7893
7875
  email: email,
7894
7876
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7895
7877
  };
7896
- if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
7897
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7898
- case 1:
7899
- requestWithRecaptcha = _b.sent();
7900
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
7901
- return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
7902
- case 2:
7903
- _b.sent();
7904
- return [3 /*break*/, 5];
7905
- case 3:
7906
7878
  setActionCodeSettings(request, actionCodeSettings);
7907
- return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, request)
7908
- .catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
7909
- var requestWithRecaptcha;
7910
- return __generator(this, function (_a) {
7911
- switch (_a.label) {
7912
- case 0:
7913
- if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
7914
- console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
7915
- return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
7916
- case 1:
7917
- requestWithRecaptcha = _a.sent();
7918
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
7919
- return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
7920
- case 2:
7921
- _a.sent();
7922
- return [3 /*break*/, 4];
7923
- case 3: return [2 /*return*/, Promise.reject(error)];
7924
- case 4: return [2 /*return*/];
7925
- }
7926
- });
7927
- }); })];
7928
- case 4:
7929
- _b.sent();
7930
- _b.label = 5;
7931
- case 5: return [2 /*return*/];
7879
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1)];
7880
+ case 1:
7881
+ _a.sent();
7882
+ return [2 /*return*/];
7932
7883
  }
7933
7884
  });
7934
7885
  });