@firebase/auth 0.22.0 → 0.23.0-20230413163153

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 (201) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/auth-public.d.ts +57 -0
  3. package/dist/auth.d.ts +71 -1
  4. package/dist/browser-cjs/{index-5859881d.js → index-11e51d65.js} +586 -205
  5. package/dist/browser-cjs/index-11e51d65.js.map +1 -0
  6. package/dist/browser-cjs/index.js +3 -2
  7. package/dist/browser-cjs/index.js.map +1 -1
  8. package/dist/browser-cjs/internal.js +3 -2
  9. package/dist/browser-cjs/internal.js.map +1 -1
  10. package/dist/browser-cjs/src/api/authentication/email_and_password.d.ts +9 -0
  11. package/dist/browser-cjs/src/api/authentication/recaptcha.d.ts +16 -0
  12. package/dist/browser-cjs/src/api/authentication/sign_up.d.ts +4 -0
  13. package/dist/browser-cjs/src/api/errors.d.ts +9 -1
  14. package/dist/browser-cjs/src/api/index.d.ts +17 -2
  15. package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +9 -1
  16. package/dist/browser-cjs/src/core/errors.d.ts +17 -1
  17. package/dist/browser-cjs/src/core/index.d.ts +26 -0
  18. package/dist/browser-cjs/src/core/util/handler.d.ts +1 -1
  19. package/dist/browser-cjs/src/core/util/log.d.ts +1 -0
  20. package/dist/browser-cjs/src/model/auth.d.ts +6 -0
  21. package/dist/browser-cjs/src/platform_browser/auth_window.d.ts +2 -2
  22. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  23. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  24. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  25. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  26. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  27. package/dist/browser-cjs/test/helpers/api/helper.d.ts +2 -0
  28. package/dist/browser-cjs/test/helpers/mock_auth.d.ts +5 -0
  29. package/dist/cordova/index.js +2 -2
  30. package/dist/cordova/internal.js +17 -75
  31. package/dist/cordova/internal.js.map +1 -1
  32. package/dist/cordova/{popup_redirect-3519667a.js → popup_redirect-fcd471f9.js} +778 -214
  33. package/dist/cordova/popup_redirect-fcd471f9.js.map +1 -0
  34. package/dist/cordova/src/api/authentication/email_and_password.d.ts +9 -0
  35. package/dist/cordova/src/api/authentication/recaptcha.d.ts +16 -0
  36. package/dist/cordova/src/api/authentication/sign_up.d.ts +4 -0
  37. package/dist/cordova/src/api/errors.d.ts +9 -1
  38. package/dist/cordova/src/api/index.d.ts +17 -2
  39. package/dist/cordova/src/core/auth/auth_impl.d.ts +9 -1
  40. package/dist/cordova/src/core/errors.d.ts +17 -1
  41. package/dist/cordova/src/core/index.d.ts +26 -0
  42. package/dist/cordova/src/core/util/handler.d.ts +1 -1
  43. package/dist/cordova/src/core/util/log.d.ts +1 -0
  44. package/dist/cordova/src/model/auth.d.ts +6 -0
  45. package/dist/cordova/src/platform_browser/auth_window.d.ts +2 -2
  46. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  47. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  48. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  49. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  50. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  51. package/dist/cordova/test/helpers/api/helper.d.ts +2 -0
  52. package/dist/cordova/test/helpers/mock_auth.d.ts +5 -0
  53. package/dist/esm2017/{index-680e2b70.js → index-999a48c4.js} +587 -207
  54. package/dist/esm2017/index-999a48c4.js.map +1 -0
  55. package/dist/esm2017/index.js +2 -2
  56. package/dist/esm2017/internal.js +3 -3
  57. package/dist/esm2017/src/api/authentication/email_and_password.d.ts +9 -0
  58. package/dist/esm2017/src/api/authentication/recaptcha.d.ts +16 -0
  59. package/dist/esm2017/src/api/authentication/sign_up.d.ts +4 -0
  60. package/dist/esm2017/src/api/errors.d.ts +9 -1
  61. package/dist/esm2017/src/api/index.d.ts +17 -2
  62. package/dist/esm2017/src/core/auth/auth_impl.d.ts +9 -1
  63. package/dist/esm2017/src/core/errors.d.ts +17 -1
  64. package/dist/esm2017/src/core/index.d.ts +26 -0
  65. package/dist/esm2017/src/core/util/handler.d.ts +1 -1
  66. package/dist/esm2017/src/core/util/log.d.ts +1 -0
  67. package/dist/esm2017/src/model/auth.d.ts +6 -0
  68. package/dist/esm2017/src/platform_browser/auth_window.d.ts +2 -2
  69. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  70. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  71. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  72. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  73. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  74. package/dist/esm2017/test/helpers/api/helper.d.ts +2 -0
  75. package/dist/esm2017/test/helpers/mock_auth.d.ts +5 -0
  76. package/dist/esm5/{index-714e827f.js → index-35460fdd.js} +793 -287
  77. package/dist/esm5/index-35460fdd.js.map +1 -0
  78. package/dist/esm5/index.js +1 -1
  79. package/dist/esm5/internal.js +2 -2
  80. package/dist/esm5/src/api/authentication/email_and_password.d.ts +9 -0
  81. package/dist/esm5/src/api/authentication/recaptcha.d.ts +16 -0
  82. package/dist/esm5/src/api/authentication/sign_up.d.ts +4 -0
  83. package/dist/esm5/src/api/errors.d.ts +9 -1
  84. package/dist/esm5/src/api/index.d.ts +17 -2
  85. package/dist/esm5/src/core/auth/auth_impl.d.ts +9 -1
  86. package/dist/esm5/src/core/errors.d.ts +17 -1
  87. package/dist/esm5/src/core/index.d.ts +26 -0
  88. package/dist/esm5/src/core/util/handler.d.ts +1 -1
  89. package/dist/esm5/src/core/util/log.d.ts +1 -0
  90. package/dist/esm5/src/model/auth.d.ts +6 -0
  91. package/dist/esm5/src/platform_browser/auth_window.d.ts +2 -2
  92. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  93. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  94. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  95. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  96. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  97. package/dist/esm5/test/helpers/api/helper.d.ts +2 -0
  98. package/dist/esm5/test/helpers/mock_auth.d.ts +5 -0
  99. package/dist/index.webworker.esm5.js +602 -74
  100. package/dist/index.webworker.esm5.js.map +1 -1
  101. package/dist/node/index.js +2 -1
  102. package/dist/node/index.js.map +1 -1
  103. package/dist/node/internal.js +62 -42
  104. package/dist/node/internal.js.map +1 -1
  105. package/dist/node/src/api/authentication/email_and_password.d.ts +9 -0
  106. package/dist/node/src/api/authentication/recaptcha.d.ts +16 -0
  107. package/dist/node/src/api/authentication/sign_up.d.ts +4 -0
  108. package/dist/node/src/api/errors.d.ts +9 -1
  109. package/dist/node/src/api/index.d.ts +17 -2
  110. package/dist/node/src/core/auth/auth_impl.d.ts +9 -1
  111. package/dist/node/src/core/errors.d.ts +17 -1
  112. package/dist/node/src/core/index.d.ts +26 -0
  113. package/dist/node/src/core/util/handler.d.ts +1 -1
  114. package/dist/node/src/core/util/log.d.ts +1 -0
  115. package/dist/node/src/model/auth.d.ts +6 -0
  116. package/dist/node/src/platform_browser/auth_window.d.ts +2 -2
  117. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  118. package/dist/node/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  119. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  120. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  121. package/dist/node/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  122. package/dist/node/test/helpers/api/helper.d.ts +2 -0
  123. package/dist/node/test/helpers/mock_auth.d.ts +5 -0
  124. package/dist/node/{totp-416a2adc.js → totp-ba4e50e7.js} +700 -171
  125. package/dist/node/totp-ba4e50e7.js.map +1 -0
  126. package/dist/node-esm/index.js +1 -1
  127. package/dist/node-esm/internal.js +16 -4
  128. package/dist/node-esm/internal.js.map +1 -1
  129. package/dist/node-esm/src/api/authentication/email_and_password.d.ts +9 -0
  130. package/dist/node-esm/src/api/authentication/recaptcha.d.ts +16 -0
  131. package/dist/node-esm/src/api/authentication/sign_up.d.ts +4 -0
  132. package/dist/node-esm/src/api/errors.d.ts +9 -1
  133. package/dist/node-esm/src/api/index.d.ts +17 -2
  134. package/dist/node-esm/src/core/auth/auth_impl.d.ts +9 -1
  135. package/dist/node-esm/src/core/errors.d.ts +17 -1
  136. package/dist/node-esm/src/core/index.d.ts +26 -0
  137. package/dist/node-esm/src/core/util/handler.d.ts +1 -1
  138. package/dist/node-esm/src/core/util/log.d.ts +1 -0
  139. package/dist/node-esm/src/model/auth.d.ts +6 -0
  140. package/dist/node-esm/src/platform_browser/auth_window.d.ts +2 -2
  141. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  142. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  143. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  144. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  145. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  146. package/dist/node-esm/test/helpers/api/helper.d.ts +2 -0
  147. package/dist/node-esm/test/helpers/mock_auth.d.ts +5 -0
  148. package/dist/node-esm/{totp-c3bf2a20.js → totp-9cd89fc6.js} +557 -140
  149. package/dist/node-esm/totp-9cd89fc6.js.map +1 -0
  150. package/dist/rn/index.js +2 -1
  151. package/dist/rn/index.js.map +1 -1
  152. package/dist/rn/internal.js +75 -46
  153. package/dist/rn/internal.js.map +1 -1
  154. package/dist/rn/{phone-2ec1815d.js → phone-b58141c1.js} +738 -259
  155. package/dist/rn/phone-b58141c1.js.map +1 -0
  156. package/dist/rn/src/api/authentication/email_and_password.d.ts +9 -0
  157. package/dist/rn/src/api/authentication/recaptcha.d.ts +16 -0
  158. package/dist/rn/src/api/authentication/sign_up.d.ts +4 -0
  159. package/dist/rn/src/api/errors.d.ts +9 -1
  160. package/dist/rn/src/api/index.d.ts +17 -2
  161. package/dist/rn/src/core/auth/auth_impl.d.ts +9 -1
  162. package/dist/rn/src/core/errors.d.ts +17 -1
  163. package/dist/rn/src/core/index.d.ts +26 -0
  164. package/dist/rn/src/core/util/handler.d.ts +1 -1
  165. package/dist/rn/src/core/util/log.d.ts +1 -0
  166. package/dist/rn/src/model/auth.d.ts +6 -0
  167. package/dist/rn/src/platform_browser/auth_window.d.ts +2 -2
  168. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  169. package/dist/rn/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  170. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  171. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  172. package/dist/rn/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  173. package/dist/rn/test/helpers/api/helper.d.ts +2 -0
  174. package/dist/rn/test/helpers/mock_auth.d.ts +5 -0
  175. package/dist/src/api/authentication/email_and_password.d.ts +9 -0
  176. package/dist/src/api/authentication/recaptcha.d.ts +16 -0
  177. package/dist/src/api/authentication/sign_up.d.ts +4 -0
  178. package/dist/src/api/errors.d.ts +9 -1
  179. package/dist/src/api/index.d.ts +17 -2
  180. package/dist/src/core/auth/auth_impl.d.ts +9 -1
  181. package/dist/src/core/errors.d.ts +17 -1
  182. package/dist/src/core/index.d.ts +26 -0
  183. package/dist/src/core/util/handler.d.ts +1 -1
  184. package/dist/src/core/util/log.d.ts +1 -0
  185. package/dist/src/model/auth.d.ts +6 -0
  186. package/dist/src/platform_browser/auth_window.d.ts +2 -2
  187. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  188. package/dist/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  189. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  190. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  191. package/dist/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  192. package/dist/test/helpers/api/helper.d.ts +2 -0
  193. package/dist/test/helpers/mock_auth.d.ts +5 -0
  194. package/package.json +1 -1
  195. package/dist/browser-cjs/index-5859881d.js.map +0 -1
  196. package/dist/cordova/popup_redirect-3519667a.js.map +0 -1
  197. package/dist/esm2017/index-680e2b70.js.map +0 -1
  198. package/dist/esm5/index-714e827f.js.map +0 -1
  199. package/dist/node/totp-416a2adc.js.map +0 -1
  200. package/dist/node-esm/totp-c3bf2a20.js.map +0 -1
  201. package/dist/rn/phone-2ec1815d.js.map +0 -1
@@ -15,12 +15,16 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { ActionCodeOperation, Auth } from '../../model/public_types';
18
+ import { RecaptchaClientType, RecaptchaVersion } from '../index';
18
19
  import { IdToken, IdTokenResponse } from '../../model/id_token';
19
20
  export interface SignInWithPasswordRequest {
20
21
  returnSecureToken?: boolean;
21
22
  email: string;
22
23
  password: string;
23
24
  tenantId?: string;
25
+ captchaResponse?: string;
26
+ clientType?: RecaptchaClientType;
27
+ recaptchaVersion?: RecaptchaVersion;
24
28
  }
25
29
  export interface SignInWithPasswordResponse extends IdTokenResponse {
26
30
  email: string;
@@ -48,10 +52,15 @@ export interface PasswordResetRequest extends GetOobCodeRequest {
48
52
  requestType: ActionCodeOperation.PASSWORD_RESET;
49
53
  email: string;
50
54
  captchaResp?: string;
55
+ clientType?: RecaptchaClientType;
56
+ recaptchaVersion?: RecaptchaVersion;
51
57
  }
52
58
  export interface EmailSignInRequest extends GetOobCodeRequest {
53
59
  requestType: ActionCodeOperation.EMAIL_SIGNIN;
54
60
  email: string;
61
+ captchaResp?: string;
62
+ clientType?: RecaptchaClientType;
63
+ recaptchaVersion?: RecaptchaVersion;
55
64
  }
56
65
  export interface VerifyAndChangeEmailRequest extends GetOobCodeRequest {
57
66
  requestType: ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL;
@@ -14,5 +14,21 @@
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
  export declare function getRecaptchaParams(auth: Auth): Promise<string>;
20
+ interface GetRecaptchaConfigRequest {
21
+ tenantId?: string;
22
+ clientType?: RecaptchaClientType;
23
+ version?: RecaptchaVersion;
24
+ }
25
+ interface RecaptchaEnforcementState {
26
+ provider: string;
27
+ enforcementState: string;
28
+ }
29
+ export interface GetRecaptchaConfigResponse {
30
+ recaptchaKey: string;
31
+ recaptchaEnforcementState: RecaptchaEnforcementState[];
32
+ }
33
+ export declare function getRecaptchaConfig(auth: Auth, request: GetRecaptchaConfigRequest): Promise<GetRecaptchaConfigResponse>;
34
+ export {};
@@ -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 { IdTokenResponse } from '../../model/id_token';
18
19
  import { Auth } from '../../model/public_types';
19
20
  export interface SignUpRequest {
@@ -21,6 +22,9 @@ export interface SignUpRequest {
21
22
  email?: string;
22
23
  password?: string;
23
24
  tenantId?: string;
25
+ captchaResponse?: string;
26
+ clientType?: RecaptchaClientType;
27
+ recaptchaVersion?: RecaptchaVersion;
24
28
  }
25
29
  export interface SignUpResponse extends IdTokenResponse {
26
30
  displayName?: string;
@@ -88,7 +88,15 @@ export declare const enum ServerError {
88
88
  USER_CANCELLED = "USER_CANCELLED",
89
89
  USER_DISABLED = "USER_DISABLED",
90
90
  USER_NOT_FOUND = "USER_NOT_FOUND",
91
- WEAK_PASSWORD = "WEAK_PASSWORD"
91
+ WEAK_PASSWORD = "WEAK_PASSWORD",
92
+ RECAPTCHA_NOT_ENABLED = "RECAPTCHA_NOT_ENABLED",
93
+ MISSING_RECAPTCHA_TOKEN = "MISSING_RECAPTCHA_TOKEN",
94
+ INVALID_RECAPTCHA_TOKEN = "INVALID_RECAPTCHA_TOKEN",
95
+ INVALID_RECAPTCHA_ACTION = "INVALID_RECAPTCHA_ACTION",
96
+ MISSING_CLIENT_TYPE = "MISSING_CLIENT_TYPE",
97
+ MISSING_RECAPTCHA_VERSION = "MISSING_RECAPTCHA_VERSION",
98
+ INVALID_RECAPTCHA_VERSION = "INVALID_RECAPTCHA_VERSION",
99
+ INVALID_REQ_TYPE = "INVALID_REQ_TYPE"
92
100
  }
93
101
  /**
94
102
  * API Response in the event of an error
@@ -29,7 +29,8 @@ export declare const enum HttpHeader {
29
29
  X_FIREBASE_LOCALE = "X-Firebase-Locale",
30
30
  X_CLIENT_VERSION = "X-Client-Version",
31
31
  X_FIREBASE_GMPID = "X-Firebase-gmpid",
32
- X_FIREBASE_CLIENT = "X-Firebase-Client"
32
+ X_FIREBASE_CLIENT = "X-Firebase-Client",
33
+ X_FIREBASE_APP_CHECK = "X-Firebase-AppCheck"
33
34
  }
34
35
  export declare const enum Endpoint {
35
36
  CREATE_AUTH_URI = "/v1/accounts:createAuthUri",
@@ -51,7 +52,21 @@ export declare const enum Endpoint {
51
52
  START_MFA_SIGN_IN = "/v2/accounts/mfaSignIn:start",
52
53
  FINALIZE_MFA_SIGN_IN = "/v2/accounts/mfaSignIn:finalize",
53
54
  WITHDRAW_MFA = "/v2/accounts/mfaEnrollment:withdraw",
54
- GET_PROJECT_CONFIG = "/v1/projects"
55
+ GET_PROJECT_CONFIG = "/v1/projects",
56
+ GET_RECAPTCHA_CONFIG = "/v2/recaptchaConfig"
57
+ }
58
+ export declare const enum RecaptchaClientType {
59
+ WEB = "CLIENT_TYPE_WEB",
60
+ ANDROID = "CLIENT_TYPE_ANDROID",
61
+ IOS = "CLIENT_TYPE_IOS"
62
+ }
63
+ export declare const enum RecaptchaVersion {
64
+ ENTERPRISE = "RECAPTCHA_ENTERPRISE"
65
+ }
66
+ export declare const enum RecaptchaActionName {
67
+ SIGN_IN_WITH_PASSWORD = "signInWithPassword",
68
+ GET_OOB_CODE = "getOobCode",
69
+ SIGN_UP_PASSWORD = "signUpPassword"
55
70
  }
56
71
  export declare const DEFAULT_API_TIMEOUT_MS: Delay;
57
72
  export declare function _addTidIfNecessary<T extends {
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { _FirebaseService, FirebaseApp } from '@firebase/app';
18
18
  import { Provider } from '@firebase/component';
19
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
19
20
  import { Auth, AuthErrorMap, AuthSettings, EmulatorConfig, NextOrObserver, Persistence, PopupRedirectResolver, User, CompleteFn, ErrorFn, Unsubscribe } from '../../model/public_types';
20
21
  import { ErrorFactory } from '@firebase/util';
21
22
  import { AuthInternal, ConfigInternal } from '../../model/auth';
@@ -23,6 +24,7 @@ import { PopupRedirectResolverInternal } from '../../model/popup_redirect';
23
24
  import { UserInternal } from '../../model/user';
24
25
  import { AuthErrorCode, AuthErrorParams } from '../errors';
25
26
  import { PersistenceInternal } from '../persistence';
27
+ import { RecaptchaConfig } from '../../platform_browser/recaptcha/recaptcha';
26
28
  export declare const enum DefaultConfig {
27
29
  TOKEN_API_HOST = "securetoken.googleapis.com",
28
30
  API_HOST = "identitytoolkit.googleapis.com",
@@ -31,6 +33,7 @@ export declare const enum DefaultConfig {
31
33
  export declare class AuthImpl implements AuthInternal, _FirebaseService {
32
34
  readonly app: FirebaseApp;
33
35
  private readonly heartbeatServiceProvider;
36
+ private readonly appCheckServiceProvider;
34
37
  readonly config: ConfigInternal;
35
38
  currentUser: User | null;
36
39
  emulatorConfig: EmulatorConfig | null;
@@ -48,12 +51,14 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
48
51
  _initializationPromise: Promise<void> | null;
49
52
  _popupRedirectResolver: PopupRedirectResolverInternal | null;
50
53
  _errorFactory: ErrorFactory<AuthErrorCode, AuthErrorParams>;
54
+ _agentRecaptchaConfig: RecaptchaConfig | null;
55
+ _tenantRecaptchaConfigs: Record<string, RecaptchaConfig>;
51
56
  readonly name: string;
52
57
  private lastNotifiedUid;
53
58
  languageCode: string | null;
54
59
  tenantId: string | null;
55
60
  settings: AuthSettings;
56
- constructor(app: FirebaseApp, heartbeatServiceProvider: Provider<'heartbeat'>, config: ConfigInternal);
61
+ constructor(app: FirebaseApp, heartbeatServiceProvider: Provider<'heartbeat'>, appCheckServiceProvider: Provider<AppCheckInternalComponentName>, config: ConfigInternal);
57
62
  _initializeWithPersistence(persistenceHierarchy: PersistenceInternal[], popupRedirectResolver?: PopupRedirectResolver): Promise<void>;
58
63
  /**
59
64
  * If the persistence is changed in another window, the user manager will let us know
@@ -68,6 +73,8 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
68
73
  _updateCurrentUser(user: User | null, skipBeforeStateCallbacks?: boolean): Promise<void>;
69
74
  signOut(): Promise<void>;
70
75
  setPersistence(persistence: Persistence): Promise<void>;
76
+ initializeRecaptchaConfig(): Promise<void>;
77
+ _getRecaptchaConfig(): RecaptchaConfig | null;
71
78
  _getPersistence(): string;
72
79
  _updateErrorMap(errorMap: AuthErrorMap): void;
73
80
  onAuthStateChanged(nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
@@ -100,6 +107,7 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
100
107
  _logFramework(framework: string): void;
101
108
  _getFrameworks(): readonly string[];
102
109
  _getAdditionalHeaders(): Promise<Record<string, string>>;
110
+ _getAppCheckToken(): Promise<string | undefined>;
103
111
  }
104
112
  /**
105
113
  * Method to be used to cast down to our private implmentation of Auth.
@@ -121,7 +121,15 @@ export declare const enum AuthErrorCode {
121
121
  USER_SIGNED_OUT = "user-signed-out",
122
122
  WEAK_PASSWORD = "weak-password",
123
123
  WEB_STORAGE_UNSUPPORTED = "web-storage-unsupported",
124
- ALREADY_INITIALIZED = "already-initialized"
124
+ ALREADY_INITIALIZED = "already-initialized",
125
+ RECAPTCHA_NOT_ENABLED = "recaptcha-not-enabled",
126
+ MISSING_RECAPTCHA_TOKEN = "missing-recaptcha-token",
127
+ INVALID_RECAPTCHA_TOKEN = "invalid-recaptcha-token",
128
+ INVALID_RECAPTCHA_ACTION = "invalid-recaptcha-action",
129
+ MISSING_CLIENT_TYPE = "missing-client-type",
130
+ MISSING_RECAPTCHA_VERSION = "missing-recaptcha-version",
131
+ INVALID_RECAPTCHA_VERSION = "invalid-recaptcha-version",
132
+ INVALID_REQ_TYPE = "invalid-req-type"
125
133
  }
126
134
  export interface ErrorMapRetriever extends AuthErrorMap {
127
135
  (): ErrorMap<AuthErrorCode>;
@@ -302,5 +310,13 @@ export declare const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY: {
302
310
  readonly WEAK_PASSWORD: "auth/weak-password";
303
311
  readonly WEB_STORAGE_UNSUPPORTED: "auth/web-storage-unsupported";
304
312
  readonly ALREADY_INITIALIZED: "auth/already-initialized";
313
+ readonly RECAPTCHA_NOT_ENABLED: "auth/recaptcha-not-enabled";
314
+ readonly MISSING_RECAPTCHA_TOKEN: "auth/missing-recaptcha-token";
315
+ readonly INVALID_RECAPTCHA_TOKEN: "auth/invalid-recaptcha-token";
316
+ readonly INVALID_RECAPTCHA_ACTION: "auth/invalid-recaptcha-action";
317
+ readonly MISSING_CLIENT_TYPE: "auth/missing-client-type";
318
+ readonly MISSING_RECAPTCHA_VERSION: "auth/missing-recaptcha-version";
319
+ readonly INVALID_RECAPTCHA_VERSION: "auth/invalid-recaptcha-version";
320
+ readonly INVALID_REQ_TYPE: "auth/invalid-req-type";
305
321
  };
306
322
  export {};
@@ -38,6 +38,32 @@ export { debugErrorMap, prodErrorMap, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY
38
38
  * @public
39
39
  */
40
40
  export declare function setPersistence(auth: Auth, persistence: Persistence): Promise<void>;
41
+ /**
42
+ * Loads the reCAPTCHA configuration into the `Auth` instance.
43
+ *
44
+ * @remarks
45
+ * This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
46
+ * verification flow should be triggered for each auth provider, into the
47
+ * current Auth session.
48
+ *
49
+ * If initializeRecaptchaConfig() is not invoked, the auth flow will always start
50
+ * without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
51
+ * verification, the SDK will transparently load the reCAPTCHA config and restart the
52
+ * auth flows.
53
+ *
54
+ * Thus, by calling this optional method, you will reduce the latency of future auth flows.
55
+ * Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
56
+ *
57
+ * @example
58
+ * ```javascript
59
+ * initializeRecaptchaConfig(auth);
60
+ * ```
61
+ *
62
+ * @param auth - The {@link Auth} instance.
63
+ *
64
+ * @public
65
+ */
66
+ export declare function initializeRecaptchaConfig(auth: Auth): Promise<void>;
41
67
  /**
42
68
  * Adds an observer for changes to the signed-in user's ID token.
43
69
  *
@@ -17,4 +17,4 @@
17
17
  import { AuthProvider } from '../../model/public_types';
18
18
  import { AuthInternal } from '../../model/auth';
19
19
  import { AuthEventType } from '../../model/popup_redirect';
20
- export declare function _getRedirectUrl(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, redirectUrl?: string, eventId?: string, additionalParams?: Record<string, string>): string;
20
+ export declare function _getRedirectUrl(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, redirectUrl?: string, eventId?: string, additionalParams?: Record<string, string>): Promise<string>;
@@ -19,4 +19,5 @@ export { LogLevel };
19
19
  export declare function _getLogLevel(): LogLevel;
20
20
  export declare function _setLogLevel(newLevel: LogLevel): void;
21
21
  export declare function _logDebug(msg: string, ...args: string[]): void;
22
+ export declare function _logWarn(msg: string, ...args: string[]): void;
22
23
  export declare function _logError(msg: string, ...args: string[]): void;
@@ -20,6 +20,7 @@ import { AuthErrorCode, AuthErrorParams } from '../core/errors';
20
20
  import { PopupRedirectResolverInternal } from './popup_redirect';
21
21
  import { UserInternal } from './user';
22
22
  import { ClientPlatform } from '../core/util/version';
23
+ import { RecaptchaConfig } from '../platform_browser/recaptcha/recaptcha';
23
24
  export declare type AppName = string;
24
25
  export declare type ApiKey = string;
25
26
  export declare type AuthDomain = string;
@@ -47,6 +48,8 @@ export interface ConfigInternal extends Config {
47
48
  export interface AuthInternal extends Auth {
48
49
  currentUser: User | null;
49
50
  emulatorConfig: EmulatorConfig | null;
51
+ _agentRecaptchaConfig: RecaptchaConfig | null;
52
+ _tenantRecaptchaConfigs: Record<string, RecaptchaConfig>;
50
53
  _canInitEmulator: boolean;
51
54
  _isInitialized: boolean;
52
55
  _initializationPromise: Promise<void> | null;
@@ -61,9 +64,11 @@ export interface AuthInternal extends Auth {
61
64
  _startProactiveRefresh(): void;
62
65
  _stopProactiveRefresh(): void;
63
66
  _getPersistence(): string;
67
+ _getRecaptchaConfig(): RecaptchaConfig | null;
64
68
  _logFramework(framework: string): void;
65
69
  _getFrameworks(): readonly string[];
66
70
  _getAdditionalHeaders(): Promise<Record<string, string>>;
71
+ _getAppCheckToken(): Promise<string | undefined>;
67
72
  readonly name: AppName;
68
73
  readonly config: ConfigInternal;
69
74
  languageCode: string | null;
@@ -72,4 +77,5 @@ export interface AuthInternal extends Auth {
72
77
  _errorFactory: ErrorFactory<AuthErrorCode, AuthErrorParams>;
73
78
  useDeviceLanguage(): void;
74
79
  signOut(): Promise<void>;
80
+ initializeRecaptchaConfig(): Promise<void>;
75
81
  }
@@ -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 { Recaptcha } from './recaptcha/recaptcha';
17
+ import { Recaptcha, GreCAPTCHATopLevel } from './recaptcha/recaptcha';
18
18
  /**
19
19
  * A specialized window type that melds the normal window type plus the
20
20
  * various bits we need. The three different blocks that are &'d together
@@ -23,7 +23,7 @@ import { Recaptcha } from './recaptcha/recaptcha';
23
23
  export declare type AuthWindow = {
24
24
  [T in keyof Window]: Window[T];
25
25
  } & {
26
- grecaptcha?: Recaptcha;
26
+ grecaptcha?: Recaptcha | GreCAPTCHATopLevel;
27
27
  ___jsl?: Record<string, any>;
28
28
  gapi?: typeof gapi;
29
29
  } & {
@@ -15,9 +15,42 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { RecaptchaParameters } from '../../model/public_types';
18
+ import { GetRecaptchaConfigResponse } from '../../api/authentication/recaptcha';
18
19
  export interface Recaptcha {
19
20
  render: (container: HTMLElement, parameters: RecaptchaParameters) => number;
20
21
  getResponse: (id: number) => string;
21
22
  execute: (id: number) => unknown;
22
23
  reset: (id: number) => unknown;
23
24
  }
25
+ export declare function isV2(grecaptcha: Recaptcha | GreCAPTCHA | undefined): grecaptcha is Recaptcha;
26
+ export interface GreCAPTCHATopLevel extends GreCAPTCHA {
27
+ enterprise: GreCAPTCHA;
28
+ }
29
+ export interface GreCAPTCHA {
30
+ ready: (callback: () => void) => void;
31
+ execute: (siteKey: string, options: {
32
+ action: string;
33
+ }) => Promise<string>;
34
+ render: (container: string | HTMLElement, parameters: GreCAPTCHARenderOption) => string;
35
+ }
36
+ export interface GreCAPTCHARenderOption {
37
+ sitekey: string;
38
+ size: 'invisible';
39
+ }
40
+ export declare function isEnterprise(grecaptcha: Recaptcha | GreCAPTCHA | undefined): grecaptcha is GreCAPTCHATopLevel;
41
+ declare global {
42
+ interface Window {
43
+ grecaptcha?: Recaptcha | GreCAPTCHATopLevel;
44
+ }
45
+ }
46
+ export declare class RecaptchaConfig {
47
+ /**
48
+ * The reCAPTCHA site key.
49
+ */
50
+ siteKey: string;
51
+ /**
52
+ * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
53
+ */
54
+ emailPasswordEnabled: boolean;
55
+ constructor(response: GetRecaptchaConfigResponse);
56
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 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 {};
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 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
+ import { RecaptchaActionName } from '../../api';
18
+ import { Auth } from '../../model/public_types';
19
+ import { AuthInternal } from '../../model/auth';
20
+ export declare const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = "recaptcha-enterprise";
21
+ export declare class RecaptchaEnterpriseVerifier {
22
+ /**
23
+ * Identifies the type of application verifier (e.g. "recaptcha-enterprise").
24
+ */
25
+ readonly type = "recaptcha-enterprise";
26
+ private readonly auth;
27
+ /**
28
+ *
29
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
30
+ *
31
+ */
32
+ constructor(authExtern: Auth);
33
+ /**
34
+ * Executes the verification process.
35
+ *
36
+ * @returns A Promise for a token that can be used to assert the validity of a request.
37
+ */
38
+ verify(action?: string, forceRefresh?: boolean): Promise<string>;
39
+ }
40
+ export declare function injectRecaptchaFields<T>(auth: AuthInternal, request: T, action: RecaptchaActionName, captchaResp?: boolean): Promise<T>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 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 {};
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import { AuthInternal } from '../../model/auth';
18
18
  import { RecaptchaParameters } from '../../model/public_types';
19
- import { Recaptcha } from './recaptcha';
19
+ import { Recaptcha, GreCAPTCHATopLevel, GreCAPTCHARenderOption, GreCAPTCHA } from './recaptcha';
20
20
  export declare const _SOLVE_TIME_MS = 500;
21
21
  export declare const _EXPIRATION_TIME_MS = 60000;
22
22
  export declare const _WIDGET_ID_START = 1000000000000;
@@ -35,6 +35,21 @@ export declare class MockReCaptcha implements Recaptcha {
35
35
  getResponse(optWidgetId?: number): string;
36
36
  execute(optWidgetId?: number | string): Promise<string>;
37
37
  }
38
+ export declare class MockGreCAPTCHATopLevel implements GreCAPTCHATopLevel {
39
+ enterprise: GreCAPTCHA;
40
+ ready(callback: () => void): void;
41
+ execute(_siteKey: string, _options: {
42
+ action: string;
43
+ }): Promise<string>;
44
+ render(_container: string | HTMLElement, _parameters: GreCAPTCHARenderOption): string;
45
+ }
46
+ export declare class MockGreCAPTCHA implements GreCAPTCHA {
47
+ ready(callback: () => void): void;
48
+ execute(_siteKey: string, _options: {
49
+ action: string;
50
+ }): Promise<string>;
51
+ render(_container: string | HTMLElement, _parameters: GreCAPTCHARenderOption): string;
52
+ }
38
53
  export declare class MockWidget {
39
54
  private readonly params;
40
55
  private readonly container;
@@ -17,4 +17,6 @@
17
17
  import { Endpoint } from '../../../src/api';
18
18
  import { Route } from '../mock_fetch';
19
19
  export declare function endpointUrl(endpoint: Endpoint): string;
20
+ export declare function endpointUrlWithParams(endpoint: Endpoint, params: Record<string, any>): string;
20
21
  export declare function mockEndpoint(endpoint: Endpoint, response: object, status?: number): Route;
22
+ export declare function mockEndpointWithParams(endpoint: Endpoint, params: Record<string, any>, response: object, status?: number): Route;
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { Provider } from '@firebase/component';
18
+ import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
18
19
  import { PopupRedirectResolver } from '../../src/model/public_types';
19
20
  import { AuthImpl } from '../../src/core/auth/auth_impl';
20
21
  import { PersistedBlob } from '../../src/core/persistence';
@@ -33,6 +34,10 @@ export declare const FAKE_HEARTBEAT_CONTROLLER: {
33
34
  getHeartbeatsHeader: () => Promise<string>;
34
35
  };
35
36
  export declare const FAKE_HEARTBEAT_CONTROLLER_PROVIDER: Provider<'heartbeat'>;
37
+ export declare const FAKE_APP_CHECK_CONTROLLER: {
38
+ getToken: () => Promise<AppCheckTokenResult>;
39
+ };
40
+ export declare const FAKE_APP_CHECK_CONTROLLER_PROVIDER: Provider<'app-check-internal'>;
36
41
  export declare class MockPersistenceLayer extends InMemoryPersistence {
37
42
  lastObjectSet: PersistedBlob | null;
38
43
  _set(key: string, object: PersistedBlob): Promise<void>;