@firebase/auth 1.3.0-canary.e5b96d77c → 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-23160221.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-c751978d.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-3fbffe07.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-fad8f63a.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-21765a38.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-0edda768.js → totp-3e8532c1.js} +129 -123
  52. package/dist/node-esm/totp-3e8532c1.js.map +1 -0
  53. package/dist/rn/{index-7891a42a.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 +12 -12
  66. package/dist/browser-cjs/index-23160221.js.map +0 -1
  67. package/dist/cordova/popup_redirect-c751978d.js.map +0 -1
  68. package/dist/esm2017/index-3fbffe07.js.map +0 -1
  69. package/dist/esm5/index-fad8f63a.js.map +0 -1
  70. package/dist/node/totp-21765a38.js.map +0 -1
  71. package/dist/node-esm/totp-0edda768.js.map +0 -1
  72. package/dist/rn/index-7891a42a.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-fad8f63a.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-764f9bd9.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-fad8f63a.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-fad8f63a.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-764f9bd9.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-764f9bd9.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.e5b96d77c";
554
+ var version = "1.3.0-canary.f002ef36a";
555
555
 
556
556
  /**
557
557
  * @license
@@ -878,6 +878,12 @@ var FetchProvider = /** @class */ (function () {
878
878
  if (typeof self !== 'undefined' && 'fetch' in self) {
879
879
  return self.fetch;
880
880
  }
881
+ if (typeof globalThis !== 'undefined' && globalThis.fetch) {
882
+ return globalThis.fetch;
883
+ }
884
+ if (typeof fetch !== 'undefined') {
885
+ return fetch;
886
+ }
881
887
  debugFail('Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
882
888
  };
883
889
  FetchProvider.headers = function () {
@@ -887,6 +893,12 @@ var FetchProvider = /** @class */ (function () {
887
893
  if (typeof self !== 'undefined' && 'Headers' in self) {
888
894
  return self.Headers;
889
895
  }
896
+ if (typeof globalThis !== 'undefined' && globalThis.Headers) {
897
+ return globalThis.Headers;
898
+ }
899
+ if (typeof Headers !== 'undefined') {
900
+ return Headers;
901
+ }
890
902
  debugFail('Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
891
903
  };
892
904
  FetchProvider.response = function () {
@@ -896,6 +908,12 @@ var FetchProvider = /** @class */ (function () {
896
908
  if (typeof self !== 'undefined' && 'Response' in self) {
897
909
  return self.Response;
898
910
  }
911
+ if (typeof globalThis !== 'undefined' && globalThis.Response) {
912
+ return globalThis.Response;
913
+ }
914
+ if (typeof Response !== 'undefined') {
915
+ return Response;
916
+ }
899
917
  debugFail('Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
900
918
  };
901
919
  return FetchProvider;
@@ -1148,6 +1166,18 @@ function _getFinalTarget(auth, host, path, query) {
1148
1166
  }
1149
1167
  return _emulatorUrl(auth.config, base);
1150
1168
  }
1169
+ function _parseEnforcementState(enforcementStateStr) {
1170
+ switch (enforcementStateStr) {
1171
+ case 'ENFORCE':
1172
+ return "ENFORCE" /* EnforcementState.ENFORCE */;
1173
+ case 'AUDIT':
1174
+ return "AUDIT" /* EnforcementState.AUDIT */;
1175
+ case 'OFF':
1176
+ return "OFF" /* EnforcementState.OFF */;
1177
+ default:
1178
+ return "ENFORCEMENT_STATE_UNSPECIFIED" /* EnforcementState.ENFORCEMENT_STATE_UNSPECIFIED */;
1179
+ }
1180
+ }
1151
1181
  var NetworkTimeout = /** @class */ (function () {
1152
1182
  function NetworkTimeout(auth) {
1153
1183
  var _this = this;
@@ -4617,19 +4647,47 @@ var RecaptchaConfig = /** @class */ (function () {
4617
4647
  */
4618
4648
  this.siteKey = '';
4619
4649
  /**
4620
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
4650
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
4621
4651
  */
4622
- this.emailPasswordEnabled = false;
4652
+ this.recaptchaEnforcementState = [];
4623
4653
  if (response.recaptchaKey === undefined) {
4624
4654
  throw new Error('recaptchaKey undefined');
4625
4655
  }
4626
4656
  // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
4627
4657
  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
- });
4658
+ this.recaptchaEnforcementState = response.recaptchaEnforcementState;
4632
4659
  }
4660
+ /**
4661
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
4662
+ *
4663
+ * @param providerStr - The provider whose enforcement state is to be returned.
4664
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
4665
+ */
4666
+ RecaptchaConfig.prototype.getProviderEnforcementState = function (providerStr) {
4667
+ if (!this.recaptchaEnforcementState ||
4668
+ this.recaptchaEnforcementState.length === 0) {
4669
+ return null;
4670
+ }
4671
+ for (var _i = 0, _a = this.recaptchaEnforcementState; _i < _a.length; _i++) {
4672
+ var recaptchaEnforcementState = _a[_i];
4673
+ if (recaptchaEnforcementState.provider &&
4674
+ recaptchaEnforcementState.provider === providerStr) {
4675
+ return _parseEnforcementState(recaptchaEnforcementState.enforcementState);
4676
+ }
4677
+ }
4678
+ return null;
4679
+ };
4680
+ /**
4681
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
4682
+ *
4683
+ * @param providerStr - The provider whose enablement state is to be returned.
4684
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
4685
+ */
4686
+ RecaptchaConfig.prototype.isProviderEnabled = function (providerStr) {
4687
+ return (this.getProviderEnforcementState(providerStr) ===
4688
+ "ENFORCE" /* EnforcementState.ENFORCE */ ||
4689
+ this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
4690
+ };
4633
4691
  return RecaptchaConfig;
4634
4692
  }());
4635
4693
 
@@ -4850,6 +4908,39 @@ function injectRecaptchaFields(auth, request, action, captchaResp) {
4850
4908
  });
4851
4909
  });
4852
4910
  }
4911
+ function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
4912
+ var _a;
4913
+ return __awaiter(this, void 0, void 0, function () {
4914
+ var requestWithRecaptcha;
4915
+ var _this = this;
4916
+ return __generator(this, function (_b) {
4917
+ switch (_b.label) {
4918
+ case 0:
4919
+ if (!((_a = authInstance
4920
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */))) return [3 /*break*/, 2];
4921
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */)];
4922
+ case 1:
4923
+ requestWithRecaptcha = _b.sent();
4924
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha)];
4925
+ case 2: return [2 /*return*/, actionMethod(authInstance, request).catch(function (error) { return __awaiter(_this, void 0, void 0, function () {
4926
+ var requestWithRecaptcha;
4927
+ return __generator(this, function (_a) {
4928
+ switch (_a.label) {
4929
+ case 0:
4930
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
4931
+ console.log("".concat(actionName, " is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow."));
4932
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */)];
4933
+ case 1:
4934
+ requestWithRecaptcha = _a.sent();
4935
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha)];
4936
+ case 2: return [2 /*return*/, Promise.reject(error)];
4937
+ }
4938
+ });
4939
+ }); })];
4940
+ }
4941
+ });
4942
+ });
4943
+ }
4853
4944
  function _initializeRecaptchaConfig(auth) {
4854
4945
  return __awaiter(this, void 0, void 0, function () {
4855
4946
  var authInternal, response, config, verifier;
@@ -4870,7 +4961,7 @@ function _initializeRecaptchaConfig(auth) {
4870
4961
  else {
4871
4962
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
4872
4963
  }
4873
- if (config.emailPasswordEnabled) {
4964
+ if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
4874
4965
  verifier = new RecaptchaEnterpriseVerifier(authInternal);
4875
4966
  void verifier.verify();
4876
4967
  }
@@ -5268,55 +5359,27 @@ var EmailAuthCredential = /** @class */ (function (_super) {
5268
5359
  };
5269
5360
  /** @internal */
5270
5361
  EmailAuthCredential.prototype._getIdTokenResponse = function (auth) {
5271
- var _a;
5272
5362
  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 = {
5363
+ var request;
5364
+ return __generator(this, function (_a) {
5365
+ switch (this.signInMethod) {
5366
+ case "password" /* SignInMethod.EMAIL_PASSWORD */:
5367
+ request = {
5286
5368
  returnSecureToken: true,
5287
5369
  email: this._email,
5288
5370
  password: this._password,
5289
5371
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5290
5372
  };
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:
5373
+ return [2 /*return*/, handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword)];
5374
+ case "emailLink" /* SignInMethod.EMAIL_LINK */:
5375
+ return [2 /*return*/, signInWithEmailLink$1(auth, {
5376
+ email: this._email,
5377
+ oobCode: this._password
5378
+ })];
5379
+ default:
5316
5380
  _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
5317
- _c.label = 6;
5318
- case 6: return [2 /*return*/];
5319
5381
  }
5382
+ return [2 /*return*/];
5320
5383
  });
5321
5384
  });
5322
5385
  };
@@ -7526,12 +7589,10 @@ function recachePasswordPolicy(auth) {
7526
7589
  * @public
7527
7590
  */
7528
7591
  function sendPasswordResetEmail(auth, email, actionCodeSettings) {
7529
- var _a;
7530
7592
  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) {
7593
+ var authInternal, request;
7594
+ return __generator(this, function (_a) {
7595
+ switch (_a.label) {
7535
7596
  case 0:
7536
7597
  authInternal = _castAuth(auth);
7537
7598
  request = {
@@ -7539,48 +7600,13 @@ function sendPasswordResetEmail(auth, email, actionCodeSettings) {
7539
7600
  email: email,
7540
7601
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7541
7602
  };
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
7603
  if (actionCodeSettings) {
7555
7604
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
7556
7605
  }
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*/];
7606
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1)];
7607
+ case 1:
7608
+ _a.sent();
7609
+ return [2 /*return*/];
7584
7610
  }
7585
7611
  });
7586
7612
  });
@@ -7735,12 +7761,10 @@ function verifyPasswordResetCode(auth, code) {
7735
7761
  * @public
7736
7762
  */
7737
7763
  function createUserWithEmailAndPassword(auth, email, password) {
7738
- var _a;
7739
7764
  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) {
7765
+ var authInternal, request, signUpResponse, response, userCredential;
7766
+ return __generator(this, function (_a) {
7767
+ switch (_a.label) {
7744
7768
  case 0:
7745
7769
  authInternal = _castAuth(auth);
7746
7770
  request = {
@@ -7749,43 +7773,21 @@ function createUserWithEmailAndPassword(auth, email, password) {
7749
7773
  password: password,
7750
7774
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7751
7775
  };
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;
7776
+ signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
7777
+ return [4 /*yield*/, signUpResponse.catch(function (error) {
7778
+ if (error.code === "auth/".concat("password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */)) {
7779
+ void recachePasswordPolicy(auth);
7771
7780
  }
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();
7781
+ throw error;
7782
+ })];
7783
+ case 1:
7784
+ response = _a.sent();
7783
7785
  return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
7784
- case 5:
7785
- userCredential = _b.sent();
7786
+ case 2:
7787
+ userCredential = _a.sent();
7786
7788
  return [4 /*yield*/, authInternal._updateCurrentUser(userCredential.user)];
7787
- case 6:
7788
- _b.sent();
7789
+ case 3:
7790
+ _a.sent();
7789
7791
  return [2 /*return*/, userCredential];
7790
7792
  }
7791
7793
  });
@@ -7874,7 +7876,6 @@ function signInWithEmailAndPassword(auth, email, password) {
7874
7876
  * @public
7875
7877
  */
7876
7878
  function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7877
- var _a;
7878
7879
  return __awaiter(this, void 0, void 0, function () {
7879
7880
  function setActionCodeSettings(request, actionCodeSettings) {
7880
7881
  _assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
@@ -7882,10 +7883,9 @@ function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7882
7883
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
7883
7884
  }
7884
7885
  }
7885
- var authInternal, request, requestWithRecaptcha;
7886
- var _this = this;
7887
- return __generator(this, function (_b) {
7888
- switch (_b.label) {
7886
+ var authInternal, request;
7887
+ return __generator(this, function (_a) {
7888
+ switch (_a.label) {
7889
7889
  case 0:
7890
7890
  authInternal = _castAuth(auth);
7891
7891
  request = {
@@ -7893,42 +7893,11 @@ function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7893
7893
  email: email,
7894
7894
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7895
7895
  };
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
7896
  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*/];
7897
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1)];
7898
+ case 1:
7899
+ _a.sent();
7900
+ return [2 /*return*/];
7932
7901
  }
7933
7902
  });
7934
7903
  });