@firebase/auth 1.3.0 → 1.3.1-canary.6e4e475f6

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 (82) hide show
  1. package/dist/auth-public.d.ts +25 -4
  2. package/dist/auth.d.ts +25 -4
  3. package/dist/browser-cjs/{index-68b50c51.js → index-e3e2566b.js} +133 -127
  4. package/dist/browser-cjs/index-e3e2566b.js.map +1 -0
  5. package/dist/browser-cjs/index.js +1 -1
  6. package/dist/browser-cjs/index.rn.d.ts +1 -0
  7. package/dist/browser-cjs/internal.js +1 -1
  8. package/dist/browser-cjs/src/api/authentication/recaptcha.d.ts +2 -2
  9. package/dist/browser-cjs/src/api/index.d.ts +10 -0
  10. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  11. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  12. package/dist/cordova/index.js +2 -2
  13. package/dist/cordova/index.rn.d.ts +1 -0
  14. package/dist/cordova/internal.js +2 -2
  15. package/dist/cordova/{popup_redirect-0a78e29a.js → popup_redirect-9973210d.js} +183 -214
  16. package/dist/cordova/popup_redirect-9973210d.js.map +1 -0
  17. package/dist/cordova/src/api/authentication/recaptcha.d.ts +2 -2
  18. package/dist/cordova/src/api/index.d.ts +10 -0
  19. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  20. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  21. package/dist/esm2017/{index-9a76d29a.js → index-aaffd0fc.js} +133 -127
  22. package/dist/esm2017/index-aaffd0fc.js.map +1 -0
  23. package/dist/esm2017/index.js +1 -1
  24. package/dist/esm2017/index.rn.d.ts +1 -0
  25. package/dist/esm2017/internal.js +2 -2
  26. package/dist/esm2017/src/api/authentication/recaptcha.d.ts +2 -2
  27. package/dist/esm2017/src/api/index.d.ts +10 -0
  28. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  29. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  30. package/dist/esm5/{index-3f0ee8ce.js → index-044bfa44.js} +183 -214
  31. package/dist/esm5/index-044bfa44.js.map +1 -0
  32. package/dist/esm5/index.js +1 -1
  33. package/dist/esm5/index.rn.d.ts +1 -0
  34. package/dist/esm5/internal.js +2 -2
  35. package/dist/esm5/src/api/authentication/recaptcha.d.ts +2 -2
  36. package/dist/esm5/src/api/index.d.ts +10 -0
  37. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  38. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  39. package/dist/index.rn.d.ts +1 -0
  40. package/dist/index.webworker.esm5.js +141 -172
  41. package/dist/index.webworker.esm5.js.map +1 -1
  42. package/dist/node/index.js +1 -1
  43. package/dist/node/index.rn.d.ts +1 -0
  44. package/dist/node/internal.js +1 -1
  45. package/dist/node/src/api/authentication/recaptcha.d.ts +2 -2
  46. package/dist/node/src/api/index.d.ts +10 -0
  47. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  48. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  49. package/dist/node/{totp-cceb0d01.js → totp-c47e7a9e.js} +179 -210
  50. package/dist/node/totp-c47e7a9e.js.map +1 -0
  51. package/dist/node-esm/index.js +1 -1
  52. package/dist/node-esm/index.rn.d.ts +1 -0
  53. package/dist/node-esm/internal.js +2 -2
  54. package/dist/node-esm/src/api/authentication/recaptcha.d.ts +2 -2
  55. package/dist/node-esm/src/api/index.d.ts +10 -0
  56. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  57. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  58. package/dist/node-esm/{totp-64a935f2.js → totp-898d4014.js} +129 -123
  59. package/dist/node-esm/totp-898d4014.js.map +1 -0
  60. package/dist/rn/{index-1dd41d18.js → index-9dc6fdd2.js} +359 -218
  61. package/dist/rn/index-9dc6fdd2.js.map +1 -0
  62. package/dist/rn/index.js +3 -1
  63. package/dist/rn/index.js.map +1 -1
  64. package/dist/rn/index.rn.d.ts +1 -0
  65. package/dist/rn/internal.js +3 -177
  66. package/dist/rn/internal.js.map +1 -1
  67. package/dist/rn/src/api/authentication/recaptcha.d.ts +2 -2
  68. package/dist/rn/src/api/index.d.ts +10 -0
  69. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  70. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  71. package/dist/src/api/authentication/recaptcha.d.ts +2 -2
  72. package/dist/src/api/index.d.ts +10 -0
  73. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +18 -3
  74. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +3 -0
  75. package/package.json +12 -12
  76. package/dist/browser-cjs/index-68b50c51.js.map +0 -1
  77. package/dist/cordova/popup_redirect-0a78e29a.js.map +0 -1
  78. package/dist/esm2017/index-9a76d29a.js.map +0 -1
  79. package/dist/esm5/index-3f0ee8ce.js.map +0 -1
  80. package/dist/node/totp-cceb0d01.js.map +0 -1
  81. package/dist/node-esm/totp-64a935f2.js.map +0 -1
  82. package/dist/rn/index-1dd41d18.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 './totp-64a935f2.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 './totp-898d4014.js';
2
2
  import '@firebase/util';
3
3
  import '@firebase/app';
4
4
  import 'tslib';
@@ -26,6 +26,7 @@ export * from './index.shared';
26
26
  export { PhoneAuthProvider } from './src/platform_browser/providers/phone';
27
27
  export { signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber } from './src/platform_browser/strategies/phone';
28
28
  export { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
29
+ export { TotpMultiFactorGenerator, TotpSecret } from './src/mfa/assertions/totp';
29
30
  export { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';
30
31
  export declare function getAuth(app?: FirebaseApp): Auth;
31
32
  /**
@@ -1,5 +1,5 @@
1
- import { at as _getInstance, au as _assert, av as _signInWithCredential, aw as _reauthenticate, ax as _link$1, K as AuthCredential, ay as signInWithIdp, az as _fail, aA as debugAssert, aB as _persistenceKeyName, aC as _castAuth, aD as FederatedAuthProvider, aE as BaseOAuthProvider, aF as _emulatorUrl, aG as _performApiRequest, aH as _isIOS, aI as _isAndroid, aJ as _isIOS7Or8, aK as _createError, aL as _isIframe, aM as _isMobileBrowser, aN as _isIE10, aO as _isSafari } from './totp-64a935f2.js';
2
- export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, aQ as AuthImpl, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, aS 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, aT as SAMLAuthCredential, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, aP as UserImpl, au as _assert, aC as _castAuth, az as _fail, aR as _getClientVersion, at as _getInstance, aB 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 './totp-64a935f2.js';
1
+ import { at as _getInstance, au as _assert, av as _signInWithCredential, aw as _reauthenticate, ax as _link$1, K as AuthCredential, ay as signInWithIdp, az as _fail, aA as debugAssert, aB as _persistenceKeyName, aC as _castAuth, aD as FederatedAuthProvider, aE as BaseOAuthProvider, aF as _emulatorUrl, aG as _performApiRequest, aH as _isIOS, aI as _isAndroid, aJ as _isIOS7Or8, aK as _createError, aL as _isIframe, aM as _isMobileBrowser, aN as _isIE10, aO as _isSafari } from './totp-898d4014.js';
2
+ export { A as ActionCodeOperation, ah as ActionCodeURL, K as AuthCredential, H as AuthErrorCodes, aQ as AuthImpl, L as EmailAuthCredential, U as EmailAuthProvider, V as FacebookAuthProvider, F as FactorId, aS 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, aT as SAMLAuthCredential, Z as SAMLAuthProvider, S as SignInMethod, T as TotpMultiFactorGenerator, n as TotpSecret, _ as TwitterAuthProvider, aP as UserImpl, au as _assert, aC as _castAuth, az as _fail, aR as _getClientVersion, at as _getInstance, aB 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 './totp-898d4014.js';
3
3
  import { isEmpty, querystring, getUA, querystringDecode } from '@firebase/util';
4
4
  import 'tslib';
5
5
  import { SDK_VERSION } from '@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 {};
@@ -104,46 +104,6 @@ const ActionCodeOperation = {
104
104
  VERIFY_EMAIL: 'VERIFY_EMAIL'
105
105
  };
106
106
 
107
- /**
108
- * @license
109
- * Copyright 2020 Google LLC
110
- *
111
- * Licensed under the Apache License, Version 2.0 (the "License");
112
- * you may not use this file except in compliance with the License.
113
- * You may obtain a copy of the License at
114
- *
115
- * http://www.apache.org/licenses/LICENSE-2.0
116
- *
117
- * Unless required by applicable law or agreed to in writing, software
118
- * distributed under the License is distributed on an "AS IS" BASIS,
119
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120
- * See the License for the specific language governing permissions and
121
- * limitations under the License.
122
- */
123
- function isEnterprise(grecaptcha) {
124
- return (grecaptcha !== undefined &&
125
- grecaptcha.enterprise !== undefined);
126
- }
127
- class RecaptchaConfig {
128
- constructor(response) {
129
- /**
130
- * The reCAPTCHA site key.
131
- */
132
- this.siteKey = '';
133
- /**
134
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
135
- */
136
- this.emailPasswordEnabled = false;
137
- if (response.recaptchaKey === undefined) {
138
- throw new Error('recaptchaKey undefined');
139
- }
140
- // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
141
- this.siteKey = response.recaptchaKey.split('/')[3];
142
- this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
143
- enforcementState.enforcementState !== 'OFF');
144
- }
145
- }
146
-
147
107
  /**
148
108
  * @license
149
109
  * Copyright 2020 Google LLC
@@ -743,6 +703,12 @@ class FetchProvider {
743
703
  if (typeof self !== 'undefined' && 'fetch' in self) {
744
704
  return self.fetch;
745
705
  }
706
+ if (typeof globalThis !== 'undefined' && globalThis.fetch) {
707
+ return globalThis.fetch;
708
+ }
709
+ if (typeof fetch !== 'undefined') {
710
+ return fetch;
711
+ }
746
712
  debugFail('Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
747
713
  }
748
714
  static headers() {
@@ -752,6 +718,12 @@ class FetchProvider {
752
718
  if (typeof self !== 'undefined' && 'Headers' in self) {
753
719
  return self.Headers;
754
720
  }
721
+ if (typeof globalThis !== 'undefined' && globalThis.Headers) {
722
+ return globalThis.Headers;
723
+ }
724
+ if (typeof Headers !== 'undefined') {
725
+ return Headers;
726
+ }
755
727
  debugFail('Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
756
728
  }
757
729
  static response() {
@@ -761,6 +733,12 @@ class FetchProvider {
761
733
  if (typeof self !== 'undefined' && 'Response' in self) {
762
734
  return self.Response;
763
735
  }
736
+ if (typeof globalThis !== 'undefined' && globalThis.Response) {
737
+ return globalThis.Response;
738
+ }
739
+ if (typeof Response !== 'undefined') {
740
+ return Response;
741
+ }
764
742
  debugFail('Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill');
765
743
  }
766
744
  }
@@ -972,6 +950,18 @@ function _getFinalTarget(auth, host, path, query) {
972
950
  }
973
951
  return _emulatorUrl(auth.config, base);
974
952
  }
953
+ function _parseEnforcementState(enforcementStateStr) {
954
+ switch (enforcementStateStr) {
955
+ case 'ENFORCE':
956
+ return "ENFORCE" /* EnforcementState.ENFORCE */;
957
+ case 'AUDIT':
958
+ return "AUDIT" /* EnforcementState.AUDIT */;
959
+ case 'OFF':
960
+ return "OFF" /* EnforcementState.OFF */;
961
+ default:
962
+ return "ENFORCEMENT_STATE_UNSPECIFIED" /* EnforcementState.ENFORCEMENT_STATE_UNSPECIFIED */;
963
+ }
964
+ }
975
965
  class NetworkTimeout {
976
966
  constructor(auth) {
977
967
  this.auth = auth;
@@ -1005,6 +995,75 @@ function _makeTaggedError(auth, code, response) {
1005
995
  return error;
1006
996
  }
1007
997
 
998
+ /**
999
+ * @license
1000
+ * Copyright 2020 Google LLC
1001
+ *
1002
+ * Licensed under the Apache License, Version 2.0 (the "License");
1003
+ * you may not use this file except in compliance with the License.
1004
+ * You may obtain a copy of the License at
1005
+ *
1006
+ * http://www.apache.org/licenses/LICENSE-2.0
1007
+ *
1008
+ * Unless required by applicable law or agreed to in writing, software
1009
+ * distributed under the License is distributed on an "AS IS" BASIS,
1010
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1011
+ * See the License for the specific language governing permissions and
1012
+ * limitations under the License.
1013
+ */
1014
+ function isEnterprise(grecaptcha) {
1015
+ return (grecaptcha !== undefined &&
1016
+ grecaptcha.enterprise !== undefined);
1017
+ }
1018
+ class RecaptchaConfig {
1019
+ constructor(response) {
1020
+ /**
1021
+ * The reCAPTCHA site key.
1022
+ */
1023
+ this.siteKey = '';
1024
+ /**
1025
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
1026
+ */
1027
+ this.recaptchaEnforcementState = [];
1028
+ if (response.recaptchaKey === undefined) {
1029
+ throw new Error('recaptchaKey undefined');
1030
+ }
1031
+ // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
1032
+ this.siteKey = response.recaptchaKey.split('/')[3];
1033
+ this.recaptchaEnforcementState = response.recaptchaEnforcementState;
1034
+ }
1035
+ /**
1036
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
1037
+ *
1038
+ * @param providerStr - The provider whose enforcement state is to be returned.
1039
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
1040
+ */
1041
+ getProviderEnforcementState(providerStr) {
1042
+ if (!this.recaptchaEnforcementState ||
1043
+ this.recaptchaEnforcementState.length === 0) {
1044
+ return null;
1045
+ }
1046
+ for (const recaptchaEnforcementState of this.recaptchaEnforcementState) {
1047
+ if (recaptchaEnforcementState.provider &&
1048
+ recaptchaEnforcementState.provider === providerStr) {
1049
+ return _parseEnforcementState(recaptchaEnforcementState.enforcementState);
1050
+ }
1051
+ }
1052
+ return null;
1053
+ }
1054
+ /**
1055
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
1056
+ *
1057
+ * @param providerStr - The provider whose enablement state is to be returned.
1058
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
1059
+ */
1060
+ isProviderEnabled(providerStr) {
1061
+ return (this.getProviderEnforcementState(providerStr) ===
1062
+ "ENFORCE" /* EnforcementState.ENFORCE */ ||
1063
+ this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
1064
+ }
1065
+ }
1066
+
1008
1067
  /**
1009
1068
  * @license
1010
1069
  * Copyright 2020 Google LLC
@@ -3110,6 +3169,26 @@ async function injectRecaptchaFields(auth, request, action, captchaResp = false)
3110
3169
  });
3111
3170
  return newRequest;
3112
3171
  }
3172
+ async function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3173
+ var _a;
3174
+ if ((_a = authInstance
3175
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3176
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3177
+ return actionMethod(authInstance, requestWithRecaptcha);
3178
+ }
3179
+ else {
3180
+ return actionMethod(authInstance, request).catch(async (error) => {
3181
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3182
+ console.log(`${actionName} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);
3183
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3184
+ return actionMethod(authInstance, requestWithRecaptcha);
3185
+ }
3186
+ else {
3187
+ return Promise.reject(error);
3188
+ }
3189
+ });
3190
+ }
3191
+ }
3113
3192
  async function _initializeRecaptchaConfig(auth) {
3114
3193
  const authInternal = _castAuth(auth);
3115
3194
  const response = await getRecaptchaConfig(authInternal, {
@@ -3123,7 +3202,7 @@ async function _initializeRecaptchaConfig(auth) {
3123
3202
  else {
3124
3203
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
3125
3204
  }
3126
- if (config.emailPasswordEnabled) {
3205
+ if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3127
3206
  const verifier = new RecaptchaEnterpriseVerifier(authInternal);
3128
3207
  void verifier.verify();
3129
3208
  }
@@ -3536,7 +3615,6 @@ class EmailAuthCredential extends AuthCredential {
3536
3615
  }
3537
3616
  /** @internal */
3538
3617
  async _getIdTokenResponse(auth) {
3539
- var _a;
3540
3618
  switch (this.signInMethod) {
3541
3619
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3542
3620
  const request = {
@@ -3545,22 +3623,7 @@ class EmailAuthCredential extends AuthCredential {
3545
3623
  password: this._password,
3546
3624
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3547
3625
  };
3548
- if ((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
3549
- const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3550
- return signInWithPassword(auth, requestWithRecaptcha);
3551
- }
3552
- else {
3553
- return signInWithPassword(auth, request).catch(async (error) => {
3554
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3555
- 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.');
3556
- const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3557
- return signInWithPassword(auth, requestWithRecaptcha);
3558
- }
3559
- else {
3560
- return Promise.reject(error);
3561
- }
3562
- });
3563
- }
3626
+ return handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword);
3564
3627
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3565
3628
  return signInWithEmailLink$1(auth, {
3566
3629
  email: this._email,
@@ -5535,39 +5598,16 @@ async function recachePasswordPolicy(auth) {
5535
5598
  * @public
5536
5599
  */
5537
5600
  async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
5538
- var _a;
5539
5601
  const authInternal = _castAuth(auth);
5540
5602
  const request = {
5541
5603
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
5542
5604
  email,
5543
5605
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5544
5606
  };
5545
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5546
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5547
- if (actionCodeSettings) {
5548
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5549
- }
5550
- await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5551
- }
5552
- else {
5553
- if (actionCodeSettings) {
5554
- _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5555
- }
5556
- await sendPasswordResetEmail$1(authInternal, request)
5557
- .catch(async (error) => {
5558
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5559
- console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
5560
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5561
- if (actionCodeSettings) {
5562
- _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5563
- }
5564
- await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5565
- }
5566
- else {
5567
- return Promise.reject(error);
5568
- }
5569
- });
5607
+ if (actionCodeSettings) {
5608
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5570
5609
  }
5610
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1);
5571
5611
  }
5572
5612
  /**
5573
5613
  * Completes the password reset process, given a confirmation code and new password.
@@ -5687,7 +5727,6 @@ async function verifyPasswordResetCode(auth, code) {
5687
5727
  * @public
5688
5728
  */
5689
5729
  async function createUserWithEmailAndPassword(auth, email, password) {
5690
- var _a;
5691
5730
  const authInternal = _castAuth(auth);
5692
5731
  const request = {
5693
5732
  returnSecureToken: true,
@@ -5695,21 +5734,7 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5695
5734
  password,
5696
5735
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5697
5736
  };
5698
- let signUpResponse;
5699
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5700
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5701
- signUpResponse = signUp(authInternal, requestWithRecaptcha);
5702
- }
5703
- else {
5704
- signUpResponse = signUp(authInternal, request).catch(async (error) => {
5705
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5706
- console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
5707
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5708
- return signUp(authInternal, requestWithRecaptcha);
5709
- }
5710
- throw error;
5711
- });
5712
- }
5737
+ const signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
5713
5738
  const response = await signUpResponse.catch(error => {
5714
5739
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5715
5740
  void recachePasswordPolicy(auth);
@@ -5800,7 +5825,6 @@ function signInWithEmailAndPassword(auth, email, password) {
5800
5825
  * @public
5801
5826
  */
5802
5827
  async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5803
- var _a;
5804
5828
  const authInternal = _castAuth(auth);
5805
5829
  const request = {
5806
5830
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
@@ -5813,26 +5837,8 @@ async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5813
5837
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5814
5838
  }
5815
5839
  }
5816
- if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5817
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5818
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5819
- await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5820
- }
5821
- else {
5822
- setActionCodeSettings(request, actionCodeSettings);
5823
- await sendSignInLinkToEmail$1(authInternal, request)
5824
- .catch(async (error) => {
5825
- if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5826
- console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
5827
- const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5828
- setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5829
- await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5830
- }
5831
- else {
5832
- return Promise.reject(error);
5833
- }
5834
- });
5835
- }
5840
+ setActionCodeSettings(request, actionCodeSettings);
5841
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1);
5836
5842
  }
5837
5843
  /**
5838
5844
  * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
@@ -6715,7 +6721,7 @@ function multiFactor(user) {
6715
6721
  }
6716
6722
 
6717
6723
  var name = "@firebase/auth";
6718
- var version = "1.3.0";
6724
+ var version = "1.3.1-canary.6e4e475f6";
6719
6725
 
6720
6726
  /**
6721
6727
  * @license
@@ -7125,4 +7131,4 @@ function _isEmptyString(input) {
7125
7131
  }
7126
7132
 
7127
7133
  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, debugAssert as aA, _persistenceKeyName as aB, _castAuth as aC, FederatedAuthProvider as aD, BaseOAuthProvider as aE, _emulatorUrl as aF, _performApiRequest as aG, _isIOS as aH, _isAndroid as aI, _isIOS7Or8 as aJ, _createError as aK, _isIframe as aL, _isMobileBrowser as aM, _isIE10 as aN, _isSafari as aO, UserImpl as aP, AuthImpl as aQ, _getClientVersion as aR, FetchProvider as aS, SAMLAuthCredential as aT, 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, _getInstance as at, _assert as au, _signInWithCredential as av, _reauthenticate as aw, _link as ax, signInWithIdp as ay, _fail 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 };
7128
- //# sourceMappingURL=totp-64a935f2.js.map
7134
+ //# sourceMappingURL=totp-898d4014.js.map