@firebase/auth 1.7.9-canary.aa6db78eb → 1.7.9-canary.b942e9e6e

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 (148) hide show
  1. package/README.md +32 -1
  2. package/dist/auth-public.d.ts +22 -10
  3. package/dist/auth.d.ts +22 -10
  4. package/dist/browser-cjs/{index-8c4960c5.js → index-c1e3d4f9.js} +392 -175
  5. package/dist/browser-cjs/index-c1e3d4f9.js.map +1 -0
  6. package/dist/browser-cjs/index.js +1 -1
  7. package/dist/browser-cjs/internal.js +1 -1
  8. package/dist/browser-cjs/src/api/account_management/mfa.d.ts +5 -1
  9. package/dist/browser-cjs/src/api/authentication/mfa.d.ts +5 -1
  10. package/dist/browser-cjs/src/api/authentication/sms.d.ts +5 -1
  11. package/dist/browser-cjs/src/api/index.d.ts +7 -3
  12. package/dist/browser-cjs/src/platform_browser/providers/phone.d.ts +7 -5
  13. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  14. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  15. package/dist/browser-cjs/src/platform_browser/strategies/phone.d.ts +10 -6
  16. package/dist/browser-cjs/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  17. package/dist/cordova/auth-cordova-public.d.ts +7 -0
  18. package/dist/cordova/auth-cordova.d.ts +7 -0
  19. package/dist/cordova/index.js +2 -2
  20. package/dist/cordova/internal.js +168 -177
  21. package/dist/cordova/internal.js.map +1 -1
  22. package/dist/cordova/{popup_redirect-1e109c2a.js → popup_redirect-63b3580d.js} +285 -21
  23. package/dist/cordova/popup_redirect-63b3580d.js.map +1 -0
  24. package/dist/cordova/src/api/account_management/mfa.d.ts +5 -1
  25. package/dist/cordova/src/api/authentication/mfa.d.ts +5 -1
  26. package/dist/cordova/src/api/authentication/sms.d.ts +5 -1
  27. package/dist/cordova/src/api/index.d.ts +7 -3
  28. package/dist/cordova/src/platform_browser/providers/phone.d.ts +7 -5
  29. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  30. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  31. package/dist/cordova/src/platform_browser/strategies/phone.d.ts +10 -6
  32. package/dist/cordova/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  33. package/dist/esm2017/{index-6cb7b51a.js → index-c8d513e3.js} +392 -175
  34. package/dist/esm2017/index-c8d513e3.js.map +1 -0
  35. package/dist/esm2017/index.js +1 -1
  36. package/dist/esm2017/internal.js +2 -2
  37. package/dist/esm2017/src/api/account_management/mfa.d.ts +5 -1
  38. package/dist/esm2017/src/api/authentication/mfa.d.ts +5 -1
  39. package/dist/esm2017/src/api/authentication/sms.d.ts +5 -1
  40. package/dist/esm2017/src/api/index.d.ts +7 -3
  41. package/dist/esm2017/src/platform_browser/providers/phone.d.ts +7 -5
  42. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  43. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  44. package/dist/esm2017/src/platform_browser/strategies/phone.d.ts +10 -6
  45. package/dist/esm2017/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  46. package/dist/esm5/{index-262b3f24.js → index-82b3e33f.js} +450 -195
  47. package/dist/esm5/index-82b3e33f.js.map +1 -0
  48. package/dist/esm5/index.js +1 -1
  49. package/dist/esm5/internal.js +2 -2
  50. package/dist/esm5/src/api/account_management/mfa.d.ts +5 -1
  51. package/dist/esm5/src/api/authentication/mfa.d.ts +5 -1
  52. package/dist/esm5/src/api/authentication/sms.d.ts +5 -1
  53. package/dist/esm5/src/api/index.d.ts +7 -3
  54. package/dist/esm5/src/platform_browser/providers/phone.d.ts +7 -5
  55. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  56. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  57. package/dist/esm5/src/platform_browser/strategies/phone.d.ts +10 -6
  58. package/dist/esm5/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  59. package/dist/index.webworker.esm5.js +163 -19
  60. package/dist/index.webworker.esm5.js.map +1 -1
  61. package/dist/node/index.js +1 -1
  62. package/dist/node/internal.js +1 -1
  63. package/dist/node/src/api/account_management/mfa.d.ts +5 -1
  64. package/dist/node/src/api/authentication/mfa.d.ts +5 -1
  65. package/dist/node/src/api/authentication/sms.d.ts +5 -1
  66. package/dist/node/src/api/index.d.ts +7 -3
  67. package/dist/node/src/platform_browser/providers/phone.d.ts +7 -5
  68. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  69. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  70. package/dist/node/src/platform_browser/strategies/phone.d.ts +10 -6
  71. package/dist/node/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  72. package/dist/node/{totp-617e4db6.js → totp-c9a669c7.js} +164 -20
  73. package/dist/node/totp-c9a669c7.js.map +1 -0
  74. package/dist/node-esm/index.js +1 -1
  75. package/dist/node-esm/internal.js +2 -2
  76. package/dist/node-esm/src/api/account_management/mfa.d.ts +5 -1
  77. package/dist/node-esm/src/api/authentication/mfa.d.ts +5 -1
  78. package/dist/node-esm/src/api/authentication/sms.d.ts +5 -1
  79. package/dist/node-esm/src/api/index.d.ts +7 -3
  80. package/dist/node-esm/src/platform_browser/providers/phone.d.ts +7 -5
  81. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  82. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  83. package/dist/node-esm/src/platform_browser/strategies/phone.d.ts +10 -6
  84. package/dist/node-esm/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  85. package/dist/node-esm/{totp-98ba6f1f.js → totp-9698d31a.js} +168 -30
  86. package/dist/node-esm/totp-9698d31a.js.map +1 -0
  87. package/dist/rn/{index-198b1e87.js → index-dd6cc9b0.js} +450 -195
  88. package/dist/rn/index-dd6cc9b0.js.map +1 -0
  89. package/dist/rn/index.js +1 -1
  90. package/dist/rn/internal.js +1 -1
  91. package/dist/rn/src/api/account_management/mfa.d.ts +5 -1
  92. package/dist/rn/src/api/authentication/mfa.d.ts +5 -1
  93. package/dist/rn/src/api/authentication/sms.d.ts +5 -1
  94. package/dist/rn/src/api/index.d.ts +7 -3
  95. package/dist/rn/src/platform_browser/providers/phone.d.ts +7 -5
  96. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  97. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  98. package/dist/rn/src/platform_browser/strategies/phone.d.ts +10 -6
  99. package/dist/rn/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  100. package/dist/src/api/account_management/mfa.d.ts +5 -1
  101. package/dist/src/api/authentication/mfa.d.ts +5 -1
  102. package/dist/src/api/authentication/sms.d.ts +5 -1
  103. package/dist/src/api/index.d.ts +7 -3
  104. package/dist/src/platform_browser/providers/phone.d.ts +7 -5
  105. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  106. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  107. package/dist/src/platform_browser/strategies/phone.d.ts +10 -6
  108. package/dist/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  109. package/dist/web-extension-cjs/index.js +1 -1
  110. package/dist/web-extension-cjs/internal.js +115 -147
  111. package/dist/web-extension-cjs/internal.js.map +1 -1
  112. package/dist/web-extension-cjs/{register-0aa8e295.js → register-1a706c5a.js} +283 -30
  113. package/dist/web-extension-cjs/register-1a706c5a.js.map +1 -0
  114. package/dist/web-extension-cjs/src/api/account_management/mfa.d.ts +5 -1
  115. package/dist/web-extension-cjs/src/api/authentication/mfa.d.ts +5 -1
  116. package/dist/web-extension-cjs/src/api/authentication/sms.d.ts +5 -1
  117. package/dist/web-extension-cjs/src/api/index.d.ts +7 -3
  118. package/dist/web-extension-cjs/src/platform_browser/providers/phone.d.ts +7 -5
  119. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  120. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  121. package/dist/web-extension-cjs/src/platform_browser/strategies/phone.d.ts +10 -6
  122. package/dist/web-extension-cjs/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  123. package/dist/web-extension-esm2017/auth-web-extension-public.d.ts +7 -0
  124. package/dist/web-extension-esm2017/auth-web-extension.d.ts +7 -0
  125. package/dist/web-extension-esm2017/index.js +2 -2
  126. package/dist/web-extension-esm2017/internal.js +115 -147
  127. package/dist/web-extension-esm2017/internal.js.map +1 -1
  128. package/dist/web-extension-esm2017/{register-68ef89ff.js → register-3c017834.js} +280 -31
  129. package/dist/web-extension-esm2017/register-3c017834.js.map +1 -0
  130. package/dist/web-extension-esm2017/src/api/account_management/mfa.d.ts +5 -1
  131. package/dist/web-extension-esm2017/src/api/authentication/mfa.d.ts +5 -1
  132. package/dist/web-extension-esm2017/src/api/authentication/sms.d.ts +5 -1
  133. package/dist/web-extension-esm2017/src/api/index.d.ts +7 -3
  134. package/dist/web-extension-esm2017/src/platform_browser/providers/phone.d.ts +7 -5
  135. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  136. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  137. package/dist/web-extension-esm2017/src/platform_browser/strategies/phone.d.ts +10 -6
  138. package/dist/web-extension-esm2017/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  139. package/package.json +6 -6
  140. package/dist/browser-cjs/index-8c4960c5.js.map +0 -1
  141. package/dist/cordova/popup_redirect-1e109c2a.js.map +0 -1
  142. package/dist/esm2017/index-6cb7b51a.js.map +0 -1
  143. package/dist/esm5/index-262b3f24.js.map +0 -1
  144. package/dist/node/totp-617e4db6.js.map +0 -1
  145. package/dist/node-esm/totp-98ba6f1f.js.map +0 -1
  146. package/dist/rn/index-198b1e87.js.map +0 -1
  147. package/dist/web-extension-cjs/register-0aa8e295.js.map +0 -1
  148. package/dist/web-extension-esm2017/register-68ef89ff.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var totp = require('./totp-617e4db6.js');
5
+ var totp = require('./totp-c9a669c7.js');
6
6
  require('tslib');
7
7
  require('@firebase/app');
8
8
  require('@firebase/util');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var totp = require('./totp-617e4db6.js');
5
+ var totp = require('./totp-c9a669c7.js');
6
6
  var tslib = require('tslib');
7
7
  var util = require('@firebase/util');
8
8
  var app = require('@firebase/app');
@@ -14,6 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { RecaptchaClientType, RecaptchaVersion } from '../index';
17
18
  import { SignInWithPhoneNumberRequest } from '../authentication/sms';
18
19
  import { FinalizeMfaResponse } from '../authentication/mfa';
19
20
  import { AuthInternal } from '../../model/auth';
@@ -44,7 +45,10 @@ export interface StartPhoneMfaEnrollmentRequest {
44
45
  idToken: string;
45
46
  phoneEnrollmentInfo: {
46
47
  phoneNumber: string;
47
- recaptchaToken: string;
48
+ recaptchaToken?: string;
49
+ captchaResponse?: string;
50
+ clientType?: RecaptchaClientType;
51
+ recaptchaVersion?: RecaptchaVersion;
48
52
  };
49
53
  tenantId?: string;
50
54
  }
@@ -14,6 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { RecaptchaClientType, RecaptchaVersion } from '../index';
17
18
  import { Auth } from '../../model/public_types';
18
19
  import { IdTokenResponse } from '../../model/id_token';
19
20
  import { MfaEnrollment } from '../account_management/mfa';
@@ -34,7 +35,10 @@ export interface StartPhoneMfaSignInRequest {
34
35
  mfaPendingCredential: string;
35
36
  mfaEnrollmentId: string;
36
37
  phoneSignInInfo: {
37
- recaptchaToken: string;
38
+ recaptchaToken?: string;
39
+ captchaResponse?: string;
40
+ clientType?: RecaptchaClientType;
41
+ recaptchaVersion?: RecaptchaVersion;
38
42
  };
39
43
  tenantId?: string;
40
44
  }
@@ -14,12 +14,16 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { RecaptchaClientType, RecaptchaVersion } from '../index';
17
18
  import { IdTokenResponse } from '../../model/id_token';
18
19
  import { Auth } from '../../model/public_types';
19
20
  export interface SendPhoneVerificationCodeRequest {
20
21
  phoneNumber: string;
21
- recaptchaToken: string;
22
+ recaptchaToken?: string;
22
23
  tenantId?: string;
24
+ captchaResponse?: string;
25
+ clientType?: RecaptchaClientType;
26
+ recaptchaVersion?: RecaptchaVersion;
23
27
  }
24
28
  export interface SendPhoneVerificationCodeResponse {
25
29
  sessionInfo: string;
@@ -69,7 +69,10 @@ export declare const enum RecaptchaVersion {
69
69
  export declare const enum RecaptchaActionName {
70
70
  SIGN_IN_WITH_PASSWORD = "signInWithPassword",
71
71
  GET_OOB_CODE = "getOobCode",
72
- SIGN_UP_PASSWORD = "signUpPassword"
72
+ SIGN_UP_PASSWORD = "signUpPassword",
73
+ SEND_VERIFICATION_CODE = "sendVerificationCode",
74
+ MFA_SMS_ENROLLMENT = "mfaSmsEnrollment",
75
+ MFA_SMS_SIGNIN = "mfaSmsSignIn"
73
76
  }
74
77
  export declare const enum EnforcementState {
75
78
  ENFORCE = "ENFORCE",
@@ -77,8 +80,9 @@ export declare const enum EnforcementState {
77
80
  OFF = "OFF",
78
81
  ENFORCEMENT_STATE_UNSPECIFIED = "ENFORCEMENT_STATE_UNSPECIFIED"
79
82
  }
80
- export declare const enum RecaptchaProvider {
81
- EMAIL_PASSWORD_PROVIDER = "EMAIL_PASSWORD_PROVIDER"
83
+ export declare const enum RecaptchaAuthProvider {
84
+ EMAIL_PASSWORD_PROVIDER = "EMAIL_PASSWORD_PROVIDER",
85
+ PHONE_PROVIDER = "PHONE_PROVIDER"
82
86
  }
83
87
  export declare const DEFAULT_API_TIMEOUT_MS: Delay;
84
88
  export declare function _addTidIfNecessary<T extends {
@@ -74,14 +74,16 @@ export declare class PhoneAuthProvider {
74
74
  *
75
75
  * @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
76
76
  * E.164 format (e.g. +16505550101).
77
- * @param applicationVerifier - For abuse prevention, this method also requires a
78
- * {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
79
- * {@link RecaptchaVerifier}.
77
+ * @param applicationVerifier - An {@link ApplicationVerifier}, which prevents
78
+ * requests from unauthorized clients. This SDK includes an implementation
79
+ * based on reCAPTCHA v2, {@link RecaptchaVerifier}. If you've enabled
80
+ * reCAPTCHA Enterprise bot protection in Enforce mode, this parameter is
81
+ * optional; in all other configurations, the parameter is required.
80
82
  *
81
83
  * @returns A Promise for a verification ID that can be passed to
82
- * {@link PhoneAuthProvider.credential} to identify this flow..
84
+ * {@link PhoneAuthProvider.credential} to identify this flow.
83
85
  */
84
- verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier: ApplicationVerifier): Promise<string>;
86
+ verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier?: ApplicationVerifier): Promise<string>;
85
87
  /**
86
88
  * Creates a phone auth credential, given the verification ID from
87
89
  * {@link PhoneAuthProvider.verifyPhoneNumber} and the code that was sent to the user's
@@ -68,4 +68,11 @@ export declare class RecaptchaConfig {
68
68
  * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
69
69
  */
70
70
  isProviderEnabled(providerStr: string): boolean;
71
+ /**
72
+ * Returns true if reCAPTCHA Enterprise protection is enabled in at least one provider, otherwise
73
+ * returns false.
74
+ *
75
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for at least one provider.
76
+ */
77
+ isAnyProviderEnabled(): boolean;
71
78
  }
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { RecaptchaActionName } from '../../api';
17
+ import { RecaptchaActionName, RecaptchaAuthProvider } from '../../api';
18
18
  import { Auth } from '../../model/public_types';
19
19
  import { AuthInternal } from '../../model/auth';
20
20
  export declare const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = "recaptcha-enterprise";
@@ -38,8 +38,8 @@ export declare class RecaptchaEnterpriseVerifier {
38
38
  */
39
39
  verify(action?: string, forceRefresh?: boolean): Promise<string>;
40
40
  }
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>;
41
+ export declare function injectRecaptchaFields<T>(auth: AuthInternal, request: T, action: RecaptchaActionName, isCaptchaResp?: boolean, isFakeToken?: boolean): Promise<T>;
42
+ declare type ActionMethod<TRequest, TResponse> = (auth: AuthInternal, request: TRequest) => Promise<TResponse>;
43
+ export declare function handleRecaptchaFlow<TRequest, TResponse>(authInstance: AuthInternal, request: TRequest, actionName: RecaptchaActionName, actionMethod: ActionMethod<TRequest, TResponse>, recaptchaAuthProvider: RecaptchaAuthProvider): Promise<TResponse>;
44
44
  export declare function _initializeRecaptchaConfig(auth: Auth): Promise<void>;
45
45
  export {};
@@ -27,12 +27,15 @@ import { AuthInternal } from '../../model/auth';
27
27
  * provides the code sent to their phone, call {@link ConfirmationResult.confirm}
28
28
  * with the code to sign the user in.
29
29
  *
30
- * For abuse prevention, this method also requires a {@link ApplicationVerifier}.
31
- * This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
30
+ * For abuse prevention, this method requires a {@link ApplicationVerifier}.
31
+ * This SDK includes an implementation based on reCAPTCHA v2, {@link RecaptchaVerifier}.
32
32
  * This function can work on other platforms that do not support the
33
33
  * {@link RecaptchaVerifier} (like React Native), but you need to use a
34
34
  * third-party {@link ApplicationVerifier} implementation.
35
35
  *
36
+ * If you've enabled project-level reCAPTCHA Enterprise bot protection in
37
+ * Enforce mode, you can omit the {@link ApplicationVerifier}.
38
+ *
36
39
  * This method does not work in a Node.js environment or with {@link Auth} instances created with a
37
40
  * {@link @firebase/app#FirebaseServerApp}.
38
41
  *
@@ -51,7 +54,7 @@ import { AuthInternal } from '../../model/auth';
51
54
  *
52
55
  * @public
53
56
  */
54
- export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
57
+ export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
55
58
  /**
56
59
  * Links the user account with the given phone number.
57
60
  *
@@ -64,7 +67,7 @@ export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, a
64
67
  *
65
68
  * @public
66
69
  */
67
- export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
70
+ export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
68
71
  /**
69
72
  * Re-authenticates a user using a fresh phone credential.
70
73
  *
@@ -80,12 +83,12 @@ export declare function linkWithPhoneNumber(user: User, phoneNumber: string, app
80
83
  *
81
84
  * @public
82
85
  */
83
- export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
86
+ export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
84
87
  /**
85
88
  * Returns a verification ID to be used in conjunction with the SMS code that is sent.
86
89
  *
87
90
  */
88
- export declare function _verifyPhoneNumber(auth: AuthInternal, options: PhoneInfoOptions | string, verifier: ApplicationVerifierInternal): Promise<string>;
91
+ export declare function _verifyPhoneNumber(auth: AuthInternal, options: PhoneInfoOptions | string, verifier?: ApplicationVerifierInternal): Promise<string>;
89
92
  /**
90
93
  * Updates the user's phone number.
91
94
  *
@@ -110,3 +113,4 @@ export declare function _verifyPhoneNumber(auth: AuthInternal, options: PhoneInf
110
113
  * @public
111
114
  */
112
115
  export declare function updatePhoneNumber(user: User, credential: PhoneAuthCredential): Promise<void>;
116
+ export declare function injectRecaptchaV2Token<T>(auth: AuthInternal, request: T, recaptchaV2Verifier: ApplicationVerifierInternal): Promise<T>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};
@@ -1154,6 +1154,16 @@ var RecaptchaConfig = /** @class */ (function () {
1154
1154
  "ENFORCE" /* EnforcementState.ENFORCE */ ||
1155
1155
  this.getProviderEnforcementState(providerStr) === "AUDIT" /* EnforcementState.AUDIT */);
1156
1156
  };
1157
+ /**
1158
+ * Returns true if reCAPTCHA Enterprise protection is enabled in at least one provider, otherwise
1159
+ * returns false.
1160
+ *
1161
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for at least one provider.
1162
+ */
1163
+ RecaptchaConfig.prototype.isAnyProviderEnabled = function () {
1164
+ return (this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */) ||
1165
+ this.isProviderEnabled("PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */));
1166
+ };
1157
1167
  return RecaptchaConfig;
1158
1168
  }());
1159
1169
 
@@ -3796,6 +3806,60 @@ function _recaptchaEnterpriseScriptUrl() {
3796
3806
  return externalJSProvider.recaptchaEnterpriseScript;
3797
3807
  }
3798
3808
 
3809
+ /**
3810
+ * @license
3811
+ * Copyright 2020 Google LLC
3812
+ *
3813
+ * Licensed under the Apache License, Version 2.0 (the "License");
3814
+ * you may not use this file except in compliance with the License.
3815
+ * You may obtain a copy of the License at
3816
+ *
3817
+ * http://www.apache.org/licenses/LICENSE-2.0
3818
+ *
3819
+ * Unless required by applicable law or agreed to in writing, software
3820
+ * distributed under the License is distributed on an "AS IS" BASIS,
3821
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3822
+ * See the License for the specific language governing permissions and
3823
+ * limitations under the License.
3824
+ */
3825
+ var MockGreCAPTCHATopLevel = /** @class */ (function () {
3826
+ function MockGreCAPTCHATopLevel() {
3827
+ this.enterprise = new MockGreCAPTCHA();
3828
+ }
3829
+ MockGreCAPTCHATopLevel.prototype.ready = function (callback) {
3830
+ callback();
3831
+ };
3832
+ MockGreCAPTCHATopLevel.prototype.execute = function (
3833
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3834
+ _siteKey, _options) {
3835
+ return Promise.resolve('token');
3836
+ };
3837
+ MockGreCAPTCHATopLevel.prototype.render = function (
3838
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3839
+ _container, _parameters) {
3840
+ return '';
3841
+ };
3842
+ return MockGreCAPTCHATopLevel;
3843
+ }());
3844
+ var MockGreCAPTCHA = /** @class */ (function () {
3845
+ function MockGreCAPTCHA() {
3846
+ }
3847
+ MockGreCAPTCHA.prototype.ready = function (callback) {
3848
+ callback();
3849
+ };
3850
+ MockGreCAPTCHA.prototype.execute = function (
3851
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3852
+ _siteKey, _options) {
3853
+ return Promise.resolve('token');
3854
+ };
3855
+ MockGreCAPTCHA.prototype.render = function (
3856
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3857
+ _container, _parameters) {
3858
+ return '';
3859
+ };
3860
+ return MockGreCAPTCHA;
3861
+ }());
3862
+
3799
3863
  /* eslint-disable @typescript-eslint/no-require-imports */
3800
3864
  var RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
3801
3865
  var FAKE_TOKEN = 'NO_RECAPTCHA';
@@ -3882,8 +3946,14 @@ var RecaptchaEnterpriseVerifier = /** @class */ (function () {
3882
3946
  reject(Error('No reCAPTCHA enterprise script loaded.'));
3883
3947
  }
3884
3948
  }
3949
+ var mockRecaptcha;
3885
3950
  var _this = this;
3886
3951
  return tslib.__generator(this, function (_a) {
3952
+ // Returns Promise for a mock token when appVerificationDisabledForTesting is true.
3953
+ if (this.auth.settings.appVerificationDisabledForTesting) {
3954
+ mockRecaptcha = new MockGreCAPTCHATopLevel();
3955
+ return [2 /*return*/, mockRecaptcha.execute('siteKey', { action: 'verify' })];
3956
+ }
3887
3957
  return [2 /*return*/, new Promise(function (resolve, reject) {
3888
3958
  retrieveSiteKey(_this.auth)
3889
3959
  .then(function (siteKey) {
@@ -3917,15 +3987,18 @@ var RecaptchaEnterpriseVerifier = /** @class */ (function () {
3917
3987
  };
3918
3988
  return RecaptchaEnterpriseVerifier;
3919
3989
  }());
3920
- function injectRecaptchaFields(auth, request, action, captchaResp) {
3921
- if (captchaResp === void 0) { captchaResp = false; }
3990
+ function injectRecaptchaFields(auth, request, action, isCaptchaResp, isFakeToken) {
3991
+ if (isCaptchaResp === void 0) { isCaptchaResp = false; }
3992
+ if (isFakeToken === void 0) { isFakeToken = false; }
3922
3993
  return tslib.__awaiter(this, void 0, void 0, function () {
3923
- var verifier, captchaResponse, newRequest;
3994
+ var verifier, captchaResponse, newRequest, phoneNumber, recaptchaToken, recaptchaToken;
3924
3995
  return tslib.__generator(this, function (_a) {
3925
3996
  switch (_a.label) {
3926
3997
  case 0:
3927
3998
  verifier = new RecaptchaEnterpriseVerifier(auth);
3928
- _a.label = 1;
3999
+ if (!isFakeToken) return [3 /*break*/, 1];
4000
+ captchaResponse = FAKE_TOKEN;
4001
+ return [3 /*break*/, 5];
3929
4002
  case 1:
3930
4003
  _a.trys.push([1, 3, , 5]);
3931
4004
  return [4 /*yield*/, verifier.verify(action)];
@@ -3940,7 +4013,35 @@ function injectRecaptchaFields(auth, request, action, captchaResp) {
3940
4013
  return [3 /*break*/, 5];
3941
4014
  case 5:
3942
4015
  newRequest = tslib.__assign({}, request);
3943
- if (!captchaResp) {
4016
+ if (action === "mfaSmsEnrollment" /* RecaptchaActionName.MFA_SMS_ENROLLMENT */ ||
4017
+ action === "mfaSmsSignIn" /* RecaptchaActionName.MFA_SMS_SIGNIN */) {
4018
+ if ('phoneEnrollmentInfo' in newRequest) {
4019
+ phoneNumber = newRequest.phoneEnrollmentInfo.phoneNumber;
4020
+ recaptchaToken = newRequest.phoneEnrollmentInfo.recaptchaToken;
4021
+ Object.assign(newRequest, {
4022
+ 'phoneEnrollmentInfo': {
4023
+ phoneNumber: phoneNumber,
4024
+ recaptchaToken: recaptchaToken,
4025
+ captchaResponse: captchaResponse,
4026
+ 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
4027
+ 'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
4028
+ }
4029
+ });
4030
+ }
4031
+ else if ('phoneSignInInfo' in newRequest) {
4032
+ recaptchaToken = newRequest.phoneSignInInfo.recaptchaToken;
4033
+ Object.assign(newRequest, {
4034
+ 'phoneSignInInfo': {
4035
+ recaptchaToken: recaptchaToken,
4036
+ captchaResponse: captchaResponse,
4037
+ 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
4038
+ 'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
4039
+ }
4040
+ });
4041
+ }
4042
+ return [2 /*return*/, newRequest];
4043
+ }
4044
+ if (!isCaptchaResp) {
3944
4045
  Object.assign(newRequest, { captchaResponse: captchaResponse });
3945
4046
  }
3946
4047
  else {
@@ -3955,19 +4056,20 @@ function injectRecaptchaFields(auth, request, action, captchaResp) {
3955
4056
  });
3956
4057
  });
3957
4058
  }
3958
- function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3959
- var _a;
4059
+ function handleRecaptchaFlow(authInstance, request, actionName, actionMethod, recaptchaAuthProvider) {
4060
+ var _a, _b;
3960
4061
  return tslib.__awaiter(this, void 0, void 0, function () {
3961
- var requestWithRecaptcha;
4062
+ var requestWithRecaptcha, requestWithRecaptcha, requestWithRecaptchaFields;
3962
4063
  var _this = this;
3963
- return tslib.__generator(this, function (_b) {
3964
- switch (_b.label) {
4064
+ return tslib.__generator(this, function (_c) {
4065
+ switch (_c.label) {
3965
4066
  case 0:
4067
+ if (!(recaptchaAuthProvider === "EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */)) return [3 /*break*/, 4];
3966
4068
  if (!((_a = authInstance
3967
- ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */))) return [3 /*break*/, 2];
4069
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */))) return [3 /*break*/, 2];
3968
4070
  return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, actionName === "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */)];
3969
4071
  case 1:
3970
- requestWithRecaptcha = _b.sent();
4072
+ requestWithRecaptcha = _c.sent();
3971
4073
  return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha)];
3972
4074
  case 2: return [2 /*return*/, actionMethod(authInstance, request).catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
3973
4075
  var requestWithRecaptcha;
@@ -3984,6 +4086,48 @@ function handleRecaptchaFlow(authInstance, request, actionName, actionMethod) {
3984
4086
  }
3985
4087
  });
3986
4088
  }); })];
4089
+ case 3: return [3 /*break*/, 10];
4090
+ case 4:
4091
+ if (!(recaptchaAuthProvider === "PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */)) return [3 /*break*/, 9];
4092
+ if (!((_b = authInstance
4093
+ ._getRecaptchaConfig()) === null || _b === void 0 ? void 0 : _b.isProviderEnabled("PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */))) return [3 /*break*/, 6];
4094
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName)];
4095
+ case 5:
4096
+ requestWithRecaptcha = _c.sent();
4097
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptcha).catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
4098
+ var requestWithRecaptchaFields;
4099
+ var _a;
4100
+ return tslib.__generator(this, function (_b) {
4101
+ switch (_b.label) {
4102
+ case 0:
4103
+ if (!(((_a = authInstance
4104
+ ._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.getProviderEnforcementState("PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */)) === "AUDIT" /* EnforcementState.AUDIT */)) return [3 /*break*/, 2];
4105
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */) ||
4106
+ error.code === "auth/".concat("invalid-app-credential" /* AuthErrorCode.INVALID_APP_CREDENTIAL */))) return [3 /*break*/, 2];
4107
+ console.log("Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ".concat(actionName, " flow."));
4108
+ return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, false, // isCaptchaResp
4109
+ true // isFakeToken
4110
+ )];
4111
+ case 1:
4112
+ requestWithRecaptchaFields = _b.sent();
4113
+ // This will call the PhoneApiCaller to fetch and inject reCAPTCHA v2 token.
4114
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptchaFields)];
4115
+ case 2:
4116
+ // ENFORCE mode or AUDIT mode with any other error.
4117
+ return [2 /*return*/, Promise.reject(error)];
4118
+ }
4119
+ });
4120
+ }); })];
4121
+ case 6: return [4 /*yield*/, injectRecaptchaFields(authInstance, request, actionName, false, // isCaptchaResp
4122
+ true // isFakeToken
4123
+ )];
4124
+ case 7:
4125
+ requestWithRecaptchaFields = _c.sent();
4126
+ // This will call the PhoneApiCaller to fetch and inject v2 token.
4127
+ return [2 /*return*/, actionMethod(authInstance, requestWithRecaptchaFields)];
4128
+ case 8: return [3 /*break*/, 10];
4129
+ case 9: return [2 /*return*/, Promise.reject(recaptchaAuthProvider + ' provider is not supported.')];
4130
+ case 10: return [2 /*return*/];
3987
4131
  }
3988
4132
  });
3989
4133
  });
@@ -4008,7 +4152,7 @@ function _initializeRecaptchaConfig(auth) {
4008
4152
  else {
4009
4153
  authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
4010
4154
  }
4011
- if (config.isProviderEnabled("EMAIL_PASSWORD_PROVIDER" /* RecaptchaProvider.EMAIL_PASSWORD_PROVIDER */)) {
4155
+ if (config.isAnyProviderEnabled()) {
4012
4156
  verifier = new RecaptchaEnterpriseVerifier(authInternal);
4013
4157
  void verifier.verify();
4014
4158
  }
@@ -4494,7 +4638,7 @@ var EmailAuthCredential = /** @class */ (function (_super) {
4494
4638
  password: this._password,
4495
4639
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
4496
4640
  };
4497
- return [2 /*return*/, handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword)];
4641
+ return [2 /*return*/, handleRecaptchaFlow(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */, signInWithPassword, "EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */)];
4498
4642
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
4499
4643
  return [2 /*return*/, signInWithEmailLink$1(auth, {
4500
4644
  email: this._email,
@@ -4521,7 +4665,7 @@ var EmailAuthCredential = /** @class */ (function (_super) {
4521
4665
  password: this._password,
4522
4666
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
4523
4667
  };
4524
- return [2 /*return*/, handleRecaptchaFlow(auth, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, linkEmailPassword)];
4668
+ return [2 /*return*/, handleRecaptchaFlow(auth, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, linkEmailPassword, "EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */)];
4525
4669
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
4526
4670
  return [2 /*return*/, signInWithEmailLinkForLinking(auth, {
4527
4671
  idToken: idToken,
@@ -6757,7 +6901,7 @@ function sendPasswordResetEmail(auth, email, actionCodeSettings) {
6757
6901
  if (actionCodeSettings) {
6758
6902
  _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
6759
6903
  }
6760
- return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1)];
6904
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendPasswordResetEmail$1, "EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */)];
6761
6905
  case 1:
6762
6906
  _a.sent();
6763
6907
  return [2 /*return*/];
@@ -6933,7 +7077,7 @@ function createUserWithEmailAndPassword(auth, email, password) {
6933
7077
  password: password,
6934
7078
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
6935
7079
  };
6936
- signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp);
7080
+ signUpResponse = handleRecaptchaFlow(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */, signUp, "EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */);
6937
7081
  return [4 /*yield*/, signUpResponse.catch(function (error) {
6938
7082
  if (error.code === "auth/".concat("password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */)) {
6939
7083
  void recachePasswordPolicy(auth);
@@ -7064,7 +7208,7 @@ function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
7064
7208
  clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
7065
7209
  };
7066
7210
  setActionCodeSettings(request, actionCodeSettings);
7067
- return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1)];
7211
+ return [4 /*yield*/, handleRecaptchaFlow(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, sendSignInLinkToEmail$1, "EMAIL_PASSWORD_PROVIDER" /* RecaptchaAuthProvider.EMAIL_PASSWORD_PROVIDER */)];
7068
7212
  case 1:
7069
7213
  _a.sent();
7070
7214
  return [2 /*return*/];
@@ -8186,7 +8330,7 @@ function multiFactor(user) {
8186
8330
  }
8187
8331
 
8188
8332
  var name = "@firebase/auth";
8189
- var version = "1.7.9-canary.aa6db78eb";
8333
+ var version = "1.7.9-canary.b942e9e6e";
8190
8334
 
8191
8335
  /**
8192
8336
  * @license
@@ -8759,4 +8903,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
8759
8903
  exports.validatePassword = validatePassword;
8760
8904
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
8761
8905
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
8762
- //# sourceMappingURL=totp-617e4db6.js.map
8906
+ //# sourceMappingURL=totp-c9a669c7.js.map