@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 './totp-bfa3ee61.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-19c74b23.js';
2
2
  import '@firebase/util';
3
3
  import '@firebase/app';
4
4
  import 'tslib';
@@ -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-bfa3ee61.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-bfa3ee61.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-19c74b23.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-19c74b23.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
@@ -972,6 +932,18 @@ function _getFinalTarget(auth, host, path, query) {
972
932
  }
973
933
  return _emulatorUrl(auth.config, base);
974
934
  }
935
+ function _parseEnforcementState(enforcementStateStr) {
936
+ switch (enforcementStateStr) {
937
+ case 'ENFORCE':
938
+ return "ENFORCE" /* EnforcementState.ENFORCE */;
939
+ case 'AUDIT':
940
+ return "AUDIT" /* EnforcementState.AUDIT */;
941
+ case 'OFF':
942
+ return "OFF" /* EnforcementState.OFF */;
943
+ default:
944
+ return "ENFORCEMENT_STATE_UNSPECIFIED" /* EnforcementState.ENFORCEMENT_STATE_UNSPECIFIED */;
945
+ }
946
+ }
975
947
  class NetworkTimeout {
976
948
  constructor(auth) {
977
949
  this.auth = auth;
@@ -1005,6 +977,75 @@ function _makeTaggedError(auth, code, response) {
1005
977
  return error;
1006
978
  }
1007
979
 
980
+ /**
981
+ * @license
982
+ * Copyright 2020 Google LLC
983
+ *
984
+ * Licensed under the Apache License, Version 2.0 (the "License");
985
+ * you may not use this file except in compliance with the License.
986
+ * You may obtain a copy of the License at
987
+ *
988
+ * http://www.apache.org/licenses/LICENSE-2.0
989
+ *
990
+ * Unless required by applicable law or agreed to in writing, software
991
+ * distributed under the License is distributed on an "AS IS" BASIS,
992
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
993
+ * See the License for the specific language governing permissions and
994
+ * limitations under the License.
995
+ */
996
+ function isEnterprise(grecaptcha) {
997
+ return (grecaptcha !== undefined &&
998
+ grecaptcha.enterprise !== undefined);
999
+ }
1000
+ class RecaptchaConfig {
1001
+ constructor(response) {
1002
+ /**
1003
+ * The reCAPTCHA site key.
1004
+ */
1005
+ this.siteKey = '';
1006
+ /**
1007
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
1008
+ */
1009
+ this.recaptchaEnforcementState = [];
1010
+ if (response.recaptchaKey === undefined) {
1011
+ throw new Error('recaptchaKey undefined');
1012
+ }
1013
+ // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
1014
+ this.siteKey = response.recaptchaKey.split('/')[3];
1015
+ this.recaptchaEnforcementState = response.recaptchaEnforcementState;
1016
+ }
1017
+ /**
1018
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
1019
+ *
1020
+ * @param providerStr - The provider whose enforcement state is to be returned.
1021
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
1022
+ */
1023
+ getProviderEnforcementState(providerStr) {
1024
+ if (!this.recaptchaEnforcementState ||
1025
+ this.recaptchaEnforcementState.length === 0) {
1026
+ return null;
1027
+ }
1028
+ for (const recaptchaEnforcementState of this.recaptchaEnforcementState) {
1029
+ if (recaptchaEnforcementState.provider &&
1030
+ recaptchaEnforcementState.provider === providerStr) {
1031
+ return _parseEnforcementState(recaptchaEnforcementState.enforcementState);
1032
+ }
1033
+ }
1034
+ return null;
1035
+ }
1036
+ /**
1037
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
1038
+ *
1039
+ * @param providerStr - The provider whose enablement state is to be returned.
1040
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
1041
+ */
1042
+ isProviderEnabled(providerStr) {
1043
+ return (this.getProviderEnforcementState(providerStr) ===
1044
+ "ENFORCE" /* EnforcementState.ENFORCE */ ||
1045
+ this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
1046
+ }
1047
+ }
1048
+
1008
1049
  /**
1009
1050
  * @license
1010
1051
  * Copyright 2020 Google LLC
@@ -3110,6 +3151,26 @@ async function injectRecaptchaFields(auth, request, action, captchaResp = false)
3110
3151
  });
3111
3152
  return newRequest;
3112
3153
  }
3154
+ async function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3155
+ var _a;
3156
+ if ((_a = authInstance
3157
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3158
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3159
+ return actionMethod(authInstance, requestWithRecaptcha);
3160
+ }
3161
+ else {
3162
+ return actionMethod(authInstance, request).catch(async (error) => {
3163
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3164
+ console.log(`${actionName} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);
3165
+ const requestWithRecaptcha = await injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */);
3166
+ return actionMethod(authInstance, requestWithRecaptcha);
3167
+ }
3168
+ else {
3169
+ return Promise.reject(error);
3170
+ }
3171
+ });
3172
+ }
3173
+ }
3113
3174
  async function _initializeRecaptchaConfig(auth) {
3114
3175
  const authInternal = _castAuth(auth);
3115
3176
  const response = await getRecaptchaConfig(authInternal, {
@@ -3123,7 +3184,7 @@ async function _initializeRecaptchaConfig(auth) {
3123
3184
  else {
3124
3185
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
3125
3186
  }
3126
- if (config.emailPasswordEnabled) {
3187
+ if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
3127
3188
  const verifier = new RecaptchaEnterpriseVerifier(authInternal);
3128
3189
  void verifier.verify();
3129
3190
  }
@@ -3536,7 +3597,6 @@ class EmailAuthCredential extends AuthCredential {
3536
3597
  }
3537
3598
  /** @internal */
3538
3599
  async _getIdTokenResponse(auth) {
3539
- var _a;
3540
3600
  switch (this.signInMethod) {
3541
3601
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3542
3602
  const request = {
@@ -3545,22 +3605,7 @@ class EmailAuthCredential extends AuthCredential {
3545
3605
  password: this._password,
3546
3606
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3547
3607
  };
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
- }
3608
+ return handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword);
3564
3609
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3565
3610
  return signInWithEmailLink$1(auth, {
3566
3611
  email: this._email,
@@ -5535,39 +5580,16 @@ async function recachePasswordPolicy(auth) {
5535
5580
  * @public
5536
5581
  */
5537
5582
  async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
5538
- var _a;
5539
5583
  const authInternal = _castAuth(auth);
5540
5584
  const request = {
5541
5585
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
5542
5586
  email,
5543
5587
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5544
5588
  };
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
- });
5589
+ if (actionCodeSettings) {
5590
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5570
5591
  }
5592
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1);
5571
5593
  }
5572
5594
  /**
5573
5595
  * Completes the password reset process, given a confirmation code and new password.
@@ -5687,7 +5709,6 @@ async function verifyPasswordResetCode(auth, code) {
5687
5709
  * @public
5688
5710
  */
5689
5711
  async function createUserWithEmailAndPassword(auth, email, password) {
5690
- var _a;
5691
5712
  const authInternal = _castAuth(auth);
5692
5713
  const request = {
5693
5714
  returnSecureToken: true,
@@ -5695,21 +5716,7 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5695
5716
  password,
5696
5717
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5697
5718
  };
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
- }
5719
+ const signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
5713
5720
  const response = await signUpResponse.catch(error => {
5714
5721
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5715
5722
  void recachePasswordPolicy(auth);
@@ -5800,7 +5807,6 @@ function signInWithEmailAndPassword(auth, email, password) {
5800
5807
  * @public
5801
5808
  */
5802
5809
  async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5803
- var _a;
5804
5810
  const authInternal = _castAuth(auth);
5805
5811
  const request = {
5806
5812
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
@@ -5813,26 +5819,8 @@ async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5813
5819
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5814
5820
  }
5815
5821
  }
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
- }
5822
+ setActionCodeSettings(request, actionCodeSettings);
5823
+ await handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1);
5836
5824
  }
5837
5825
  /**
5838
5826
  * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
@@ -6715,7 +6703,7 @@ function multiFactor(user) {
6715
6703
  }
6716
6704
 
6717
6705
  var name = "@firebase/auth";
6718
- var version = "1.3.0-canary.60e4a07d2";
6706
+ var version = "1.3.0-canary.698eeb67d";
6719
6707
 
6720
6708
  /**
6721
6709
  * @license
@@ -7125,4 +7113,4 @@ function _isEmptyString(input) {
7125
7113
  }
7126
7114
 
7127
7115
  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-bfa3ee61.js.map
7116
+ //# sourceMappingURL=totp-19c74b23.js.map