@firebase/auth 0.21.6 → 0.22.0-canary.1d6771eb3

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 (218) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +5 -0
  3. package/dist/auth-public.d.ts +59 -3
  4. package/dist/auth.d.ts +74 -13
  5. package/dist/browser-cjs/{index-39443020.js → index-7393ca6a.js} +593 -208
  6. package/dist/browser-cjs/index-7393ca6a.js.map +1 -0
  7. package/dist/browser-cjs/index.js +3 -2
  8. package/dist/browser-cjs/index.js.map +1 -1
  9. package/dist/browser-cjs/internal.js +3 -2
  10. package/dist/browser-cjs/internal.js.map +1 -1
  11. package/dist/browser-cjs/src/api/authentication/email_and_password.d.ts +9 -0
  12. package/dist/browser-cjs/src/api/authentication/recaptcha.d.ts +16 -0
  13. package/dist/browser-cjs/src/api/authentication/sign_up.d.ts +4 -0
  14. package/dist/browser-cjs/src/api/errors.d.ts +9 -1
  15. package/dist/browser-cjs/src/api/index.d.ts +17 -2
  16. package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +9 -1
  17. package/dist/browser-cjs/src/core/errors.d.ts +18 -1
  18. package/dist/browser-cjs/src/core/index.d.ts +27 -0
  19. package/dist/browser-cjs/src/core/util/handler.d.ts +1 -1
  20. package/dist/browser-cjs/src/core/util/log.d.ts +1 -0
  21. package/dist/browser-cjs/src/mfa/assertions/totp.d.ts +2 -2
  22. package/dist/browser-cjs/src/model/auth.d.ts +6 -0
  23. package/dist/browser-cjs/src/platform_browser/auth_window.d.ts +2 -2
  24. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  25. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  26. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  27. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  28. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  29. package/dist/browser-cjs/src/platform_browser/strategies/popup.d.ts +1 -1
  30. package/dist/browser-cjs/test/helpers/api/helper.d.ts +2 -0
  31. package/dist/browser-cjs/test/helpers/mock_auth.d.ts +5 -0
  32. package/dist/cordova/index.js +2 -2
  33. package/dist/cordova/internal.js +21 -77
  34. package/dist/cordova/internal.js.map +1 -1
  35. package/dist/cordova/{popup_redirect-8b388294.js → popup_redirect-eae95465.js} +781 -215
  36. package/dist/cordova/popup_redirect-eae95465.js.map +1 -0
  37. package/dist/cordova/src/api/authentication/email_and_password.d.ts +9 -0
  38. package/dist/cordova/src/api/authentication/recaptcha.d.ts +16 -0
  39. package/dist/cordova/src/api/authentication/sign_up.d.ts +4 -0
  40. package/dist/cordova/src/api/errors.d.ts +9 -1
  41. package/dist/cordova/src/api/index.d.ts +17 -2
  42. package/dist/cordova/src/core/auth/auth_impl.d.ts +9 -1
  43. package/dist/cordova/src/core/errors.d.ts +18 -1
  44. package/dist/cordova/src/core/index.d.ts +27 -0
  45. package/dist/cordova/src/core/util/handler.d.ts +1 -1
  46. package/dist/cordova/src/core/util/log.d.ts +1 -0
  47. package/dist/cordova/src/mfa/assertions/totp.d.ts +2 -2
  48. package/dist/cordova/src/model/auth.d.ts +6 -0
  49. package/dist/cordova/src/platform_browser/auth_window.d.ts +2 -2
  50. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  51. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  52. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  53. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  54. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  55. package/dist/cordova/src/platform_browser/strategies/popup.d.ts +1 -1
  56. package/dist/cordova/test/helpers/api/helper.d.ts +2 -0
  57. package/dist/cordova/test/helpers/mock_auth.d.ts +5 -0
  58. package/dist/esm2017/{index-2d01563f.js → index-1124980d.js} +594 -210
  59. package/dist/esm2017/index-1124980d.js.map +1 -0
  60. package/dist/esm2017/index.js +2 -2
  61. package/dist/esm2017/internal.js +3 -3
  62. package/dist/esm2017/src/api/authentication/email_and_password.d.ts +9 -0
  63. package/dist/esm2017/src/api/authentication/recaptcha.d.ts +16 -0
  64. package/dist/esm2017/src/api/authentication/sign_up.d.ts +4 -0
  65. package/dist/esm2017/src/api/errors.d.ts +9 -1
  66. package/dist/esm2017/src/api/index.d.ts +17 -2
  67. package/dist/esm2017/src/core/auth/auth_impl.d.ts +9 -1
  68. package/dist/esm2017/src/core/errors.d.ts +18 -1
  69. package/dist/esm2017/src/core/index.d.ts +27 -0
  70. package/dist/esm2017/src/core/util/handler.d.ts +1 -1
  71. package/dist/esm2017/src/core/util/log.d.ts +1 -0
  72. package/dist/esm2017/src/mfa/assertions/totp.d.ts +2 -2
  73. package/dist/esm2017/src/model/auth.d.ts +6 -0
  74. package/dist/esm2017/src/platform_browser/auth_window.d.ts +2 -2
  75. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  76. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  77. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  78. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  79. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  80. package/dist/esm2017/src/platform_browser/strategies/popup.d.ts +1 -1
  81. package/dist/esm2017/test/helpers/api/helper.d.ts +2 -0
  82. package/dist/esm2017/test/helpers/mock_auth.d.ts +5 -0
  83. package/dist/esm5/{index-44fc929c.js → index-169fb84f.js} +800 -290
  84. package/dist/esm5/index-169fb84f.js.map +1 -0
  85. package/dist/esm5/index.js +1 -1
  86. package/dist/esm5/internal.js +2 -2
  87. package/dist/esm5/src/api/authentication/email_and_password.d.ts +9 -0
  88. package/dist/esm5/src/api/authentication/recaptcha.d.ts +16 -0
  89. package/dist/esm5/src/api/authentication/sign_up.d.ts +4 -0
  90. package/dist/esm5/src/api/errors.d.ts +9 -1
  91. package/dist/esm5/src/api/index.d.ts +17 -2
  92. package/dist/esm5/src/core/auth/auth_impl.d.ts +9 -1
  93. package/dist/esm5/src/core/errors.d.ts +18 -1
  94. package/dist/esm5/src/core/index.d.ts +27 -0
  95. package/dist/esm5/src/core/util/handler.d.ts +1 -1
  96. package/dist/esm5/src/core/util/log.d.ts +1 -0
  97. package/dist/esm5/src/mfa/assertions/totp.d.ts +2 -2
  98. package/dist/esm5/src/model/auth.d.ts +6 -0
  99. package/dist/esm5/src/platform_browser/auth_window.d.ts +2 -2
  100. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  101. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  102. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  103. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  104. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  105. package/dist/esm5/src/platform_browser/strategies/popup.d.ts +1 -1
  106. package/dist/esm5/test/helpers/api/helper.d.ts +2 -0
  107. package/dist/esm5/test/helpers/mock_auth.d.ts +5 -0
  108. package/dist/index.webworker.esm5.js +605 -75
  109. package/dist/index.webworker.esm5.js.map +1 -1
  110. package/dist/node/index.js +2 -1
  111. package/dist/node/index.js.map +1 -1
  112. package/dist/node/internal.js +62 -42
  113. package/dist/node/internal.js.map +1 -1
  114. package/dist/node/src/api/authentication/email_and_password.d.ts +9 -0
  115. package/dist/node/src/api/authentication/recaptcha.d.ts +16 -0
  116. package/dist/node/src/api/authentication/sign_up.d.ts +4 -0
  117. package/dist/node/src/api/errors.d.ts +9 -1
  118. package/dist/node/src/api/index.d.ts +17 -2
  119. package/dist/node/src/core/auth/auth_impl.d.ts +9 -1
  120. package/dist/node/src/core/errors.d.ts +18 -1
  121. package/dist/node/src/core/index.d.ts +27 -0
  122. package/dist/node/src/core/util/handler.d.ts +1 -1
  123. package/dist/node/src/core/util/log.d.ts +1 -0
  124. package/dist/node/src/mfa/assertions/totp.d.ts +2 -2
  125. package/dist/node/src/model/auth.d.ts +6 -0
  126. package/dist/node/src/platform_browser/auth_window.d.ts +2 -2
  127. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  128. package/dist/node/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  129. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  130. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  131. package/dist/node/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  132. package/dist/node/src/platform_browser/strategies/popup.d.ts +1 -1
  133. package/dist/node/test/helpers/api/helper.d.ts +2 -0
  134. package/dist/node/test/helpers/mock_auth.d.ts +5 -0
  135. package/dist/node/{totp-5e73d8e7.js → totp-13fce87f.js} +703 -172
  136. package/dist/node/totp-13fce87f.js.map +1 -0
  137. package/dist/node-esm/index.js +1 -1
  138. package/dist/node-esm/internal.js +16 -4
  139. package/dist/node-esm/internal.js.map +1 -1
  140. package/dist/node-esm/src/api/authentication/email_and_password.d.ts +9 -0
  141. package/dist/node-esm/src/api/authentication/recaptcha.d.ts +16 -0
  142. package/dist/node-esm/src/api/authentication/sign_up.d.ts +4 -0
  143. package/dist/node-esm/src/api/errors.d.ts +9 -1
  144. package/dist/node-esm/src/api/index.d.ts +17 -2
  145. package/dist/node-esm/src/core/auth/auth_impl.d.ts +9 -1
  146. package/dist/node-esm/src/core/errors.d.ts +18 -1
  147. package/dist/node-esm/src/core/index.d.ts +27 -0
  148. package/dist/node-esm/src/core/util/handler.d.ts +1 -1
  149. package/dist/node-esm/src/core/util/log.d.ts +1 -0
  150. package/dist/node-esm/src/mfa/assertions/totp.d.ts +2 -2
  151. package/dist/node-esm/src/model/auth.d.ts +6 -0
  152. package/dist/node-esm/src/platform_browser/auth_window.d.ts +2 -2
  153. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  154. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  155. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  156. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  157. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  158. package/dist/node-esm/src/platform_browser/strategies/popup.d.ts +1 -1
  159. package/dist/node-esm/test/helpers/api/helper.d.ts +2 -0
  160. package/dist/node-esm/test/helpers/mock_auth.d.ts +5 -0
  161. package/dist/node-esm/{totp-7b645f19.js → totp-aee19ee4.js} +560 -141
  162. package/dist/node-esm/totp-aee19ee4.js.map +1 -0
  163. package/dist/rn/index.js +2 -1
  164. package/dist/rn/index.js.map +1 -1
  165. package/dist/rn/internal.js +79 -48
  166. package/dist/rn/internal.js.map +1 -1
  167. package/dist/rn/{phone-ec210006.js → phone-26700494.js} +741 -260
  168. package/dist/rn/phone-26700494.js.map +1 -0
  169. package/dist/rn/src/api/authentication/email_and_password.d.ts +9 -0
  170. package/dist/rn/src/api/authentication/recaptcha.d.ts +16 -0
  171. package/dist/rn/src/api/authentication/sign_up.d.ts +4 -0
  172. package/dist/rn/src/api/errors.d.ts +9 -1
  173. package/dist/rn/src/api/index.d.ts +17 -2
  174. package/dist/rn/src/core/auth/auth_impl.d.ts +9 -1
  175. package/dist/rn/src/core/errors.d.ts +18 -1
  176. package/dist/rn/src/core/index.d.ts +27 -0
  177. package/dist/rn/src/core/util/handler.d.ts +1 -1
  178. package/dist/rn/src/core/util/log.d.ts +1 -0
  179. package/dist/rn/src/mfa/assertions/totp.d.ts +2 -2
  180. package/dist/rn/src/model/auth.d.ts +6 -0
  181. package/dist/rn/src/platform_browser/auth_window.d.ts +2 -2
  182. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  183. package/dist/rn/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  184. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  185. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  186. package/dist/rn/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  187. package/dist/rn/src/platform_browser/strategies/popup.d.ts +1 -1
  188. package/dist/rn/test/helpers/api/helper.d.ts +2 -0
  189. package/dist/rn/test/helpers/mock_auth.d.ts +5 -0
  190. package/dist/src/api/authentication/email_and_password.d.ts +9 -0
  191. package/dist/src/api/authentication/recaptcha.d.ts +16 -0
  192. package/dist/src/api/authentication/sign_up.d.ts +4 -0
  193. package/dist/src/api/errors.d.ts +9 -1
  194. package/dist/src/api/index.d.ts +17 -2
  195. package/dist/src/core/auth/auth_impl.d.ts +9 -1
  196. package/dist/src/core/errors.d.ts +18 -1
  197. package/dist/src/core/index.d.ts +27 -0
  198. package/dist/src/core/util/handler.d.ts +1 -1
  199. package/dist/src/core/util/log.d.ts +1 -0
  200. package/dist/src/mfa/assertions/totp.d.ts +2 -2
  201. package/dist/src/model/auth.d.ts +6 -0
  202. package/dist/src/platform_browser/auth_window.d.ts +2 -2
  203. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  204. package/dist/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  205. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  206. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  207. package/dist/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  208. package/dist/src/platform_browser/strategies/popup.d.ts +1 -1
  209. package/dist/test/helpers/api/helper.d.ts +2 -0
  210. package/dist/test/helpers/mock_auth.d.ts +5 -0
  211. package/package.json +6 -6
  212. package/dist/browser-cjs/index-39443020.js.map +0 -1
  213. package/dist/cordova/popup_redirect-8b388294.js.map +0 -1
  214. package/dist/esm2017/index-2d01563f.js.map +0 -1
  215. package/dist/esm5/index-44fc929c.js.map +0 -1
  216. package/dist/node/totp-5e73d8e7.js.map +0 -1
  217. package/dist/node-esm/totp-7b645f19.js.map +0 -1
  218. package/dist/rn/phone-ec210006.js.map +0 -1
@@ -2,8 +2,8 @@
2
2
 
3
3
  var util = require('@firebase/util');
4
4
  var app = require('@firebase/app');
5
- var logger = require('@firebase/logger');
6
5
  var tslib = require('tslib');
6
+ var logger = require('@firebase/logger');
7
7
  var component = require('@firebase/component');
8
8
 
9
9
  /**
@@ -214,6 +214,7 @@ function _debugErrorMap() {
214
214
  ["missing-or-invalid-nonce" /* AuthErrorCode.MISSING_OR_INVALID_NONCE */]: 'The request does not contain a valid nonce. This can occur if the ' +
215
215
  'SHA-256 hash of the provided raw nonce does not match the hashed nonce ' +
216
216
  'in the ID token payload.',
217
+ ["missing-password" /* AuthErrorCode.MISSING_PASSWORD */]: 'A non-empty password must be provided',
217
218
  ["missing-multi-factor-info" /* AuthErrorCode.MISSING_MFA_INFO */]: 'No second factor identifier is provided.',
218
219
  ["missing-multi-factor-session" /* AuthErrorCode.MISSING_MFA_SESSION */]: 'The request is missing proof of first factor successful sign-in.',
219
220
  ["missing-phone-number" /* AuthErrorCode.MISSING_PHONE_NUMBER */]: 'To send verification codes, provide a phone number for the recipient.',
@@ -266,7 +267,15 @@ function _debugErrorMap() {
266
267
  ["already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */]: 'initializeAuth() has already been called with ' +
267
268
  'different options. To avoid this error, call initializeAuth() with the ' +
268
269
  'same options as when it was originally called, or call getAuth() to return the' +
269
- ' already initialized instance.'
270
+ ' already initialized instance.',
271
+ ["missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */]: 'The reCAPTCHA token is missing when sending request to the backend.',
272
+ ["invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */]: 'The reCAPTCHA token is invalid when sending request to the backend.',
273
+ ["invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */]: 'The reCAPTCHA action is invalid when sending request to the backend.',
274
+ ["recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */]: 'reCAPTCHA Enterprise integration is not enabled for this project.',
275
+ ["missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */]: 'The reCAPTCHA client type is missing when sending request to the backend.',
276
+ ["missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */]: 'The reCAPTCHA version is missing when sending request to the backend.',
277
+ ["invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */]: 'Invalid request parameters.',
278
+ ["invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */]: 'The reCAPTCHA version is invalid when sending request to the backend.'
270
279
  };
271
280
  }
272
281
  function _prodErrorMap() {
@@ -402,7 +411,15 @@ const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
402
411
  USER_SIGNED_OUT: 'auth/user-signed-out',
403
412
  WEAK_PASSWORD: 'auth/weak-password',
404
413
  WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
405
- ALREADY_INITIALIZED: 'auth/already-initialized'
414
+ ALREADY_INITIALIZED: 'auth/already-initialized',
415
+ RECAPTCHA_NOT_ENABLED: 'auth/recaptcha-not-enabled',
416
+ MISSING_RECAPTCHA_TOKEN: 'auth/missing-recaptcha-token',
417
+ INVALID_RECAPTCHA_TOKEN: 'auth/invalid-recaptcha-token',
418
+ INVALID_RECAPTCHA_ACTION: 'auth/invalid-recaptcha-action',
419
+ MISSING_CLIENT_TYPE: 'auth/missing-client-type',
420
+ MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version',
421
+ INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version',
422
+ INVALID_REQ_TYPE: 'auth/invalid-req-type'
406
423
  };
407
424
 
408
425
  /**
@@ -422,6 +439,11 @@ const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
422
439
  * limitations under the License.
423
440
  */
424
441
  const logClient = new logger.Logger('@firebase/auth');
442
+ function _logWarn(msg, ...args) {
443
+ if (logClient.logLevel <= logger.LogLevel.WARN) {
444
+ logClient.warn(`Auth (${app.SDK_VERSION}): ${msg}`, ...args);
445
+ }
446
+ }
425
447
  function _logError(msg, ...args) {
426
448
  if (logClient.logLevel <= logger.LogLevel.ERROR) {
427
449
  logClient.error(`Auth (${app.SDK_VERSION}): ${msg}`, ...args);
@@ -512,103 +534,6 @@ function debugAssert(assertion, message) {
512
534
  }
513
535
  }
514
536
 
515
- /**
516
- * @license
517
- * Copyright 2020 Google LLC
518
- *
519
- * Licensed under the Apache License, Version 2.0 (the "License");
520
- * you may not use this file except in compliance with the License.
521
- * You may obtain a copy of the License at
522
- *
523
- * http://www.apache.org/licenses/LICENSE-2.0
524
- *
525
- * Unless required by applicable law or agreed to in writing, software
526
- * distributed under the License is distributed on an "AS IS" BASIS,
527
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
528
- * See the License for the specific language governing permissions and
529
- * limitations under the License.
530
- */
531
- const instanceCache = new Map();
532
- function _getInstance(cls) {
533
- debugAssert(cls instanceof Function, 'Expected a class definition');
534
- let instance = instanceCache.get(cls);
535
- if (instance) {
536
- debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
537
- return instance;
538
- }
539
- instance = new cls();
540
- instanceCache.set(cls, instance);
541
- return instance;
542
- }
543
-
544
- /**
545
- * @license
546
- * Copyright 2020 Google LLC
547
- *
548
- * Licensed under the Apache License, Version 2.0 (the "License");
549
- * you may not use this file except in compliance with the License.
550
- * You may obtain a copy of the License at
551
- *
552
- * http://www.apache.org/licenses/LICENSE-2.0
553
- *
554
- * Unless required by applicable law or agreed to in writing, software
555
- * distributed under the License is distributed on an "AS IS" BASIS,
556
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
557
- * See the License for the specific language governing permissions and
558
- * limitations under the License.
559
- */
560
- /**
561
- * Initializes an {@link Auth} instance with fine-grained control over
562
- * {@link Dependencies}.
563
- *
564
- * @remarks
565
- *
566
- * This function allows more control over the {@link Auth} instance than
567
- * {@link getAuth}. `getAuth` uses platform-specific defaults to supply
568
- * the {@link Dependencies}. In general, `getAuth` is the easiest way to
569
- * initialize Auth and works for most use cases. Use `initializeAuth` if you
570
- * need control over which persistence layer is used, or to minimize bundle
571
- * size if you're not using either `signInWithPopup` or `signInWithRedirect`.
572
- *
573
- * For example, if your app only uses anonymous accounts and you only want
574
- * accounts saved for the current session, initialize `Auth` with:
575
- *
576
- * ```js
577
- * const auth = initializeAuth(app, {
578
- * persistence: browserSessionPersistence,
579
- * popupRedirectResolver: undefined,
580
- * });
581
- * ```
582
- *
583
- * @public
584
- */
585
- function initializeAuth(app$1, deps) {
586
- const provider = app._getProvider(app$1, 'auth');
587
- if (provider.isInitialized()) {
588
- const auth = provider.getImmediate();
589
- const initialOptions = provider.getOptions();
590
- if (util.deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
591
- return auth;
592
- }
593
- else {
594
- _fail(auth, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
595
- }
596
- }
597
- const auth = provider.initialize({ options: deps });
598
- return auth;
599
- }
600
- function _initializeAuthInstance(auth, deps) {
601
- const persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
602
- const hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
603
- if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
604
- auth._updateErrorMap(deps.errorMap);
605
- }
606
- // This promise is intended to float; auth initialization happens in the
607
- // background, meanwhile the auth object may be used by the app.
608
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
609
- auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
610
- }
611
-
612
537
  /**
613
538
  * @license
614
539
  * Copyright 2020 Google LLC
@@ -840,7 +765,7 @@ const SERVER_ERROR_MAP = {
840
765
  // Sign in with email and password errors (some apply to sign up too).
841
766
  ["INVALID_PASSWORD" /* ServerError.INVALID_PASSWORD */]: "wrong-password" /* AuthErrorCode.INVALID_PASSWORD */,
842
767
  // This can only happen if the SDK sends a bad request.
843
- ["MISSING_PASSWORD" /* ServerError.MISSING_PASSWORD */]: "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
768
+ ["MISSING_PASSWORD" /* ServerError.MISSING_PASSWORD */]: "missing-password" /* AuthErrorCode.MISSING_PASSWORD */,
844
769
  // Sign up with email and password errors.
845
770
  ["EMAIL_EXISTS" /* ServerError.EMAIL_EXISTS */]: "email-already-in-use" /* AuthErrorCode.EMAIL_EXISTS */,
846
771
  ["PASSWORD_LOGIN_DISABLED" /* ServerError.PASSWORD_LOGIN_DISABLED */]: "operation-not-allowed" /* AuthErrorCode.OPERATION_NOT_ALLOWED */,
@@ -887,7 +812,16 @@ const SERVER_ERROR_MAP = {
887
812
  ["SECOND_FACTOR_EXISTS" /* ServerError.SECOND_FACTOR_EXISTS */]: "second-factor-already-in-use" /* AuthErrorCode.SECOND_FACTOR_ALREADY_ENROLLED */,
888
813
  ["SECOND_FACTOR_LIMIT_EXCEEDED" /* ServerError.SECOND_FACTOR_LIMIT_EXCEEDED */]: "maximum-second-factor-count-exceeded" /* AuthErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED */,
889
814
  // Blocking functions related errors.
890
- ["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */]: "internal-error" /* AuthErrorCode.INTERNAL_ERROR */
815
+ ["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */]: "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
816
+ // Recaptcha related errors.
817
+ ["RECAPTCHA_NOT_ENABLED" /* ServerError.RECAPTCHA_NOT_ENABLED */]: "recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */,
818
+ ["MISSING_RECAPTCHA_TOKEN" /* ServerError.MISSING_RECAPTCHA_TOKEN */]: "missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */,
819
+ ["INVALID_RECAPTCHA_TOKEN" /* ServerError.INVALID_RECAPTCHA_TOKEN */]: "invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */,
820
+ ["INVALID_RECAPTCHA_ACTION" /* ServerError.INVALID_RECAPTCHA_ACTION */]: "invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */,
821
+ ["MISSING_CLIENT_TYPE" /* ServerError.MISSING_CLIENT_TYPE */]: "missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */,
822
+ ["MISSING_RECAPTCHA_VERSION" /* ServerError.MISSING_RECAPTCHA_VERSION */]: "missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */,
823
+ ["INVALID_RECAPTCHA_VERSION" /* ServerError.INVALID_RECAPTCHA_VERSION */]: "invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */,
824
+ ["INVALID_REQ_TYPE" /* ServerError.INVALID_REQ_TYPE */]: "invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */
891
825
  };
892
826
 
893
827
  /**
@@ -1789,6 +1723,35 @@ class UserImpl {
1789
1723
  }
1790
1724
  }
1791
1725
 
1726
+ /**
1727
+ * @license
1728
+ * Copyright 2020 Google LLC
1729
+ *
1730
+ * Licensed under the Apache License, Version 2.0 (the "License");
1731
+ * you may not use this file except in compliance with the License.
1732
+ * You may obtain a copy of the License at
1733
+ *
1734
+ * http://www.apache.org/licenses/LICENSE-2.0
1735
+ *
1736
+ * Unless required by applicable law or agreed to in writing, software
1737
+ * distributed under the License is distributed on an "AS IS" BASIS,
1738
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1739
+ * See the License for the specific language governing permissions and
1740
+ * limitations under the License.
1741
+ */
1742
+ const instanceCache = new Map();
1743
+ function _getInstance(cls) {
1744
+ debugAssert(cls instanceof Function, 'Expected a class definition');
1745
+ let instance = instanceCache.get(cls);
1746
+ if (instance) {
1747
+ debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
1748
+ return instance;
1749
+ }
1750
+ instance = new cls();
1751
+ instanceCache.set(cls, instance);
1752
+ return instance;
1753
+ }
1754
+
1792
1755
  /**
1793
1756
  * @license
1794
1757
  * Copyright 2019 Google LLC
@@ -2130,6 +2093,242 @@ function _getClientVersion(clientPlatform, frameworks = []) {
2130
2093
  return `${reportedPlatform}/${"JsCore" /* ClientImplementation.CORE */}/${app.SDK_VERSION}/${reportedFrameworks}`;
2131
2094
  }
2132
2095
 
2096
+ /**
2097
+ * @license
2098
+ * Copyright 2020 Google LLC
2099
+ *
2100
+ * Licensed under the Apache License, Version 2.0 (the "License");
2101
+ * you may not use this file except in compliance with the License.
2102
+ * You may obtain a copy of the License at
2103
+ *
2104
+ * http://www.apache.org/licenses/LICENSE-2.0
2105
+ *
2106
+ * Unless required by applicable law or agreed to in writing, software
2107
+ * distributed under the License is distributed on an "AS IS" BASIS,
2108
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2109
+ * See the License for the specific language governing permissions and
2110
+ * limitations under the License.
2111
+ */
2112
+ async function getRecaptchaParams(auth) {
2113
+ return ((await _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)).recaptchaSiteKey || '');
2114
+ }
2115
+ async function getRecaptchaConfig(auth, request) {
2116
+ return _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request));
2117
+ }
2118
+
2119
+ /**
2120
+ * @license
2121
+ * Copyright 2020 Google LLC
2122
+ *
2123
+ * Licensed under the Apache License, Version 2.0 (the "License");
2124
+ * you may not use this file except in compliance with the License.
2125
+ * You may obtain a copy of the License at
2126
+ *
2127
+ * http://www.apache.org/licenses/LICENSE-2.0
2128
+ *
2129
+ * Unless required by applicable law or agreed to in writing, software
2130
+ * distributed under the License is distributed on an "AS IS" BASIS,
2131
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2132
+ * See the License for the specific language governing permissions and
2133
+ * limitations under the License.
2134
+ */
2135
+ function isV2(grecaptcha) {
2136
+ return (grecaptcha !== undefined &&
2137
+ grecaptcha.getResponse !== undefined);
2138
+ }
2139
+ function isEnterprise(grecaptcha) {
2140
+ return (grecaptcha !== undefined &&
2141
+ grecaptcha.enterprise !== undefined);
2142
+ }
2143
+ class RecaptchaConfig {
2144
+ constructor(response) {
2145
+ /**
2146
+ * The reCAPTCHA site key.
2147
+ */
2148
+ this.siteKey = '';
2149
+ /**
2150
+ * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
2151
+ */
2152
+ this.emailPasswordEnabled = false;
2153
+ if (response.recaptchaKey === undefined) {
2154
+ throw new Error('recaptchaKey undefined');
2155
+ }
2156
+ // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
2157
+ this.siteKey = response.recaptchaKey.split('/')[3];
2158
+ this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
2159
+ enforcementState.enforcementState !== 'OFF');
2160
+ }
2161
+ }
2162
+
2163
+ /**
2164
+ * @license
2165
+ * Copyright 2020 Google LLC
2166
+ *
2167
+ * Licensed under the Apache License, Version 2.0 (the "License");
2168
+ * you may not use this file except in compliance with the License.
2169
+ * You may obtain a copy of the License at
2170
+ *
2171
+ * http://www.apache.org/licenses/LICENSE-2.0
2172
+ *
2173
+ * Unless required by applicable law or agreed to in writing, software
2174
+ * distributed under the License is distributed on an "AS IS" BASIS,
2175
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2176
+ * See the License for the specific language governing permissions and
2177
+ * limitations under the License.
2178
+ */
2179
+ function getScriptParentElement() {
2180
+ var _a, _b;
2181
+ return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
2182
+ }
2183
+ function _loadJS(url) {
2184
+ // TODO: consider adding timeout support & cancellation
2185
+ return new Promise((resolve, reject) => {
2186
+ const el = document.createElement('script');
2187
+ el.setAttribute('src', url);
2188
+ el.onload = resolve;
2189
+ el.onerror = e => {
2190
+ const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2191
+ error.customData = e;
2192
+ reject(error);
2193
+ };
2194
+ el.type = 'text/javascript';
2195
+ el.charset = 'UTF-8';
2196
+ getScriptParentElement().appendChild(el);
2197
+ });
2198
+ }
2199
+ function _generateCallbackName(prefix) {
2200
+ return `__${prefix}${Math.floor(Math.random() * 1000000)}`;
2201
+ }
2202
+
2203
+ /* eslint-disable @typescript-eslint/no-require-imports */
2204
+ const RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
2205
+ const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
2206
+ class RecaptchaEnterpriseVerifier {
2207
+ /**
2208
+ *
2209
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
2210
+ *
2211
+ */
2212
+ constructor(authExtern) {
2213
+ /**
2214
+ * Identifies the type of application verifier (e.g. "recaptcha-enterprise").
2215
+ */
2216
+ this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
2217
+ this.auth = _castAuth(authExtern);
2218
+ }
2219
+ /**
2220
+ * Executes the verification process.
2221
+ *
2222
+ * @returns A Promise for a token that can be used to assert the validity of a request.
2223
+ */
2224
+ async verify(action = 'verify', forceRefresh = false) {
2225
+ async function retrieveSiteKey(auth) {
2226
+ if (!forceRefresh) {
2227
+ if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
2228
+ return auth._agentRecaptchaConfig.siteKey;
2229
+ }
2230
+ if (auth.tenantId != null &&
2231
+ auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
2232
+ return auth._tenantRecaptchaConfigs[auth.tenantId].siteKey;
2233
+ }
2234
+ }
2235
+ return new Promise(async (resolve, reject) => {
2236
+ getRecaptchaConfig(auth, {
2237
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
2238
+ version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
2239
+ })
2240
+ .then(response => {
2241
+ if (response.recaptchaKey === undefined) {
2242
+ reject(new Error('recaptcha Enterprise site key undefined'));
2243
+ }
2244
+ else {
2245
+ const config = new RecaptchaConfig(response);
2246
+ if (auth.tenantId == null) {
2247
+ auth._agentRecaptchaConfig = config;
2248
+ }
2249
+ else {
2250
+ auth._tenantRecaptchaConfigs[auth.tenantId] = config;
2251
+ }
2252
+ return resolve(config.siteKey);
2253
+ }
2254
+ })
2255
+ .catch(error => {
2256
+ reject(error);
2257
+ });
2258
+ });
2259
+ }
2260
+ function retrieveRecaptchaToken(siteKey, resolve, reject) {
2261
+ const grecaptcha = window.grecaptcha;
2262
+ if (isEnterprise(grecaptcha)) {
2263
+ grecaptcha.enterprise.ready(() => {
2264
+ try {
2265
+ grecaptcha.enterprise
2266
+ .execute(siteKey, { action })
2267
+ .then(token => {
2268
+ resolve(token);
2269
+ })
2270
+ .catch(error => {
2271
+ reject(error);
2272
+ });
2273
+ }
2274
+ catch (error) {
2275
+ reject(error);
2276
+ }
2277
+ });
2278
+ }
2279
+ else {
2280
+ reject(Error('No reCAPTCHA enterprise script loaded.'));
2281
+ }
2282
+ }
2283
+ return new Promise((resolve, reject) => {
2284
+ retrieveSiteKey(this.auth)
2285
+ .then(siteKey => {
2286
+ if (!forceRefresh && isEnterprise(window.grecaptcha)) {
2287
+ retrieveRecaptchaToken(siteKey, resolve, reject);
2288
+ }
2289
+ else {
2290
+ if (typeof window === 'undefined') {
2291
+ reject(new Error('RecaptchaVerifier is only supported in browser'));
2292
+ return;
2293
+ }
2294
+ _loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
2295
+ .then(() => {
2296
+ retrieveRecaptchaToken(siteKey, resolve, reject);
2297
+ })
2298
+ .catch(error => {
2299
+ reject(error);
2300
+ });
2301
+ }
2302
+ })
2303
+ .catch(error => {
2304
+ reject(error);
2305
+ });
2306
+ });
2307
+ }
2308
+ }
2309
+ async function injectRecaptchaFields(auth, request, action, captchaResp = false) {
2310
+ const verifier = new RecaptchaEnterpriseVerifier(auth);
2311
+ let captchaResponse;
2312
+ try {
2313
+ captchaResponse = await verifier.verify(action);
2314
+ }
2315
+ catch (error) {
2316
+ captchaResponse = await verifier.verify(action, true);
2317
+ }
2318
+ const newRequest = Object.assign({}, request);
2319
+ if (!captchaResp) {
2320
+ Object.assign(newRequest, { captchaResponse });
2321
+ }
2322
+ else {
2323
+ Object.assign(newRequest, { 'captchaResp': captchaResponse });
2324
+ }
2325
+ Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
2326
+ Object.assign(newRequest, {
2327
+ 'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
2328
+ });
2329
+ return newRequest;
2330
+ }
2331
+
2133
2332
  /**
2134
2333
  * @license
2135
2334
  * Copyright 2022 Google LLC
@@ -2228,9 +2427,10 @@ class AuthMiddlewareQueue {
2228
2427
  * limitations under the License.
2229
2428
  */
2230
2429
  class AuthImpl {
2231
- constructor(app, heartbeatServiceProvider, config) {
2430
+ constructor(app, heartbeatServiceProvider, appCheckServiceProvider, config) {
2232
2431
  this.app = app;
2233
2432
  this.heartbeatServiceProvider = heartbeatServiceProvider;
2433
+ this.appCheckServiceProvider = appCheckServiceProvider;
2234
2434
  this.config = config;
2235
2435
  this.currentUser = null;
2236
2436
  this.emulatorConfig = null;
@@ -2248,6 +2448,8 @@ class AuthImpl {
2248
2448
  this._initializationPromise = null;
2249
2449
  this._popupRedirectResolver = null;
2250
2450
  this._errorFactory = _DEFAULT_AUTH_ERROR_FACTORY;
2451
+ this._agentRecaptchaConfig = null;
2452
+ this._tenantRecaptchaConfigs = {};
2251
2453
  // Tracks the last notified UID for state change listeners to prevent
2252
2454
  // repeated calls to the callbacks. Undefined means it's never been
2253
2455
  // called, whereas null means it's been called with a signed out user
@@ -2467,6 +2669,31 @@ class AuthImpl {
2467
2669
  await this.assertedPersistence.setPersistence(_getInstance(persistence));
2468
2670
  });
2469
2671
  }
2672
+ async initializeRecaptchaConfig() {
2673
+ const response = await getRecaptchaConfig(this, {
2674
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
2675
+ version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
2676
+ });
2677
+ const config = new RecaptchaConfig(response);
2678
+ if (this.tenantId == null) {
2679
+ this._agentRecaptchaConfig = config;
2680
+ }
2681
+ else {
2682
+ this._tenantRecaptchaConfigs[this.tenantId] = config;
2683
+ }
2684
+ if (config.emailPasswordEnabled) {
2685
+ const verifier = new RecaptchaEnterpriseVerifier(this);
2686
+ void verifier.verify();
2687
+ }
2688
+ }
2689
+ _getRecaptchaConfig() {
2690
+ if (this.tenantId == null) {
2691
+ return this._agentRecaptchaConfig;
2692
+ }
2693
+ else {
2694
+ return this._tenantRecaptchaConfigs[this.tenantId];
2695
+ }
2696
+ }
2470
2697
  _getPersistence() {
2471
2698
  return this.assertedPersistence.persistence.type;
2472
2699
  }
@@ -2646,8 +2873,26 @@ class AuthImpl {
2646
2873
  if (heartbeatsHeader) {
2647
2874
  headers["X-Firebase-Client" /* HttpHeader.X_FIREBASE_CLIENT */] = heartbeatsHeader;
2648
2875
  }
2876
+ // If the App Check service exists, add the App Check token in the headers
2877
+ const appCheckToken = await this._getAppCheckToken();
2878
+ if (appCheckToken) {
2879
+ headers["X-Firebase-AppCheck" /* HttpHeader.X_FIREBASE_APP_CHECK */] = appCheckToken;
2880
+ }
2649
2881
  return headers;
2650
2882
  }
2883
+ async _getAppCheckToken() {
2884
+ var _a;
2885
+ const appCheckTokenResult = await ((_a = this.appCheckServiceProvider
2886
+ .getImmediate({ optional: true })) === null || _a === void 0 ? void 0 : _a.getToken());
2887
+ if (appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.error) {
2888
+ // Context: appCheck.getToken() will never throw even if an error happened.
2889
+ // In the error case, a dummy token will be returned along with an error field describing
2890
+ // the error. In general, we shouldn't care about the error condition and just use
2891
+ // the token (actual or dummy) to send requests.
2892
+ _logWarn(`Error while retrieving App Check token: ${appCheckTokenResult.error}`);
2893
+ }
2894
+ return appCheckTokenResult === null || appCheckTokenResult === void 0 ? void 0 : appCheckTokenResult.token;
2895
+ }
2651
2896
  }
2652
2897
  /**
2653
2898
  * Method to be used to cast down to our private implmentation of Auth.
@@ -2671,6 +2916,74 @@ class Subscription {
2671
2916
  }
2672
2917
  }
2673
2918
 
2919
+ /**
2920
+ * @license
2921
+ * Copyright 2020 Google LLC
2922
+ *
2923
+ * Licensed under the Apache License, Version 2.0 (the "License");
2924
+ * you may not use this file except in compliance with the License.
2925
+ * You may obtain a copy of the License at
2926
+ *
2927
+ * http://www.apache.org/licenses/LICENSE-2.0
2928
+ *
2929
+ * Unless required by applicable law or agreed to in writing, software
2930
+ * distributed under the License is distributed on an "AS IS" BASIS,
2931
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2932
+ * See the License for the specific language governing permissions and
2933
+ * limitations under the License.
2934
+ */
2935
+ /**
2936
+ * Initializes an {@link Auth} instance with fine-grained control over
2937
+ * {@link Dependencies}.
2938
+ *
2939
+ * @remarks
2940
+ *
2941
+ * This function allows more control over the {@link Auth} instance than
2942
+ * {@link getAuth}. `getAuth` uses platform-specific defaults to supply
2943
+ * the {@link Dependencies}. In general, `getAuth` is the easiest way to
2944
+ * initialize Auth and works for most use cases. Use `initializeAuth` if you
2945
+ * need control over which persistence layer is used, or to minimize bundle
2946
+ * size if you're not using either `signInWithPopup` or `signInWithRedirect`.
2947
+ *
2948
+ * For example, if your app only uses anonymous accounts and you only want
2949
+ * accounts saved for the current session, initialize `Auth` with:
2950
+ *
2951
+ * ```js
2952
+ * const auth = initializeAuth(app, {
2953
+ * persistence: browserSessionPersistence,
2954
+ * popupRedirectResolver: undefined,
2955
+ * });
2956
+ * ```
2957
+ *
2958
+ * @public
2959
+ */
2960
+ function initializeAuth(app$1, deps) {
2961
+ const provider = app._getProvider(app$1, 'auth');
2962
+ if (provider.isInitialized()) {
2963
+ const auth = provider.getImmediate();
2964
+ const initialOptions = provider.getOptions();
2965
+ if (util.deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
2966
+ return auth;
2967
+ }
2968
+ else {
2969
+ _fail(auth, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
2970
+ }
2971
+ }
2972
+ const auth = provider.initialize({ options: deps });
2973
+ return auth;
2974
+ }
2975
+ function _initializeAuthInstance(auth, deps) {
2976
+ const persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
2977
+ const hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
2978
+ if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
2979
+ auth._updateErrorMap(deps.errorMap);
2980
+ }
2981
+ // This promise is intended to float; auth initialization happens in the
2982
+ // background, meanwhile the auth object may be used by the app.
2983
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
2984
+ auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
2985
+ }
2986
+
2674
2987
  /**
2675
2988
  * Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
2676
2989
  * Firebase Auth services.
@@ -3010,13 +3323,31 @@ class EmailAuthCredential extends AuthCredential {
3010
3323
  }
3011
3324
  /** @internal */
3012
3325
  async _getIdTokenResponse(auth) {
3326
+ var _a;
3013
3327
  switch (this.signInMethod) {
3014
3328
  case "password" /* SignInMethod.EMAIL_PASSWORD */:
3015
- return signInWithPassword(auth, {
3329
+ const request = {
3016
3330
  returnSecureToken: true,
3017
3331
  email: this._email,
3018
- password: this._password
3019
- });
3332
+ password: this._password,
3333
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
3334
+ };
3335
+ if ((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
3336
+ const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3337
+ return signInWithPassword(auth, requestWithRecaptcha);
3338
+ }
3339
+ else {
3340
+ return signInWithPassword(auth, request).catch(async (error) => {
3341
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
3342
+ 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.');
3343
+ const requestWithRecaptcha = await injectRecaptchaFields(auth, request, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */);
3344
+ return signInWithPassword(auth, requestWithRecaptcha);
3345
+ }
3346
+ else {
3347
+ return Promise.reject(error);
3348
+ }
3349
+ });
3350
+ }
3020
3351
  case "emailLink" /* SignInMethod.EMAIL_LINK */:
3021
3352
  return signInWithEmailLink$1(auth, {
3022
3353
  email: this._email,
@@ -4975,15 +5306,39 @@ function _setActionCodeSettingsOnRequest(auth, request, actionCodeSettings) {
4975
5306
  * @public
4976
5307
  */
4977
5308
  async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
4978
- const authModular = util.getModularInstance(auth);
5309
+ var _a;
5310
+ const authInternal = _castAuth(auth);
4979
5311
  const request = {
4980
5312
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
4981
- email
5313
+ email,
5314
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
4982
5315
  };
4983
- if (actionCodeSettings) {
4984
- _setActionCodeSettingsOnRequest(authModular, request, actionCodeSettings);
5316
+ if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5317
+ const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5318
+ if (actionCodeSettings) {
5319
+ _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5320
+ }
5321
+ await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5322
+ }
5323
+ else {
5324
+ if (actionCodeSettings) {
5325
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5326
+ }
5327
+ await sendPasswordResetEmail$1(authInternal, request)
5328
+ .catch(async (error) => {
5329
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5330
+ console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
5331
+ const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5332
+ if (actionCodeSettings) {
5333
+ _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5334
+ }
5335
+ await sendPasswordResetEmail$1(authInternal, requestWithRecaptcha);
5336
+ }
5337
+ else {
5338
+ return Promise.reject(error);
5339
+ }
5340
+ });
4985
5341
  }
4986
- await sendPasswordResetEmail$1(authModular, request);
4987
5342
  }
4988
5343
  /**
4989
5344
  * Completes the password reset process, given a confirmation code and new password.
@@ -5096,11 +5451,33 @@ async function verifyPasswordResetCode(auth, code) {
5096
5451
  * @public
5097
5452
  */
5098
5453
  async function createUserWithEmailAndPassword(auth, email, password) {
5454
+ var _a;
5099
5455
  const authInternal = _castAuth(auth);
5100
- const response = await signUp(authInternal, {
5456
+ const request = {
5101
5457
  returnSecureToken: true,
5102
5458
  email,
5103
- password
5459
+ password,
5460
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5461
+ };
5462
+ let signUpResponse;
5463
+ if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5464
+ const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5465
+ signUpResponse = signUp(authInternal, requestWithRecaptcha);
5466
+ }
5467
+ else {
5468
+ signUpResponse = signUp(authInternal, request).catch(async (error) => {
5469
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5470
+ console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
5471
+ const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */);
5472
+ return signUp(authInternal, requestWithRecaptcha);
5473
+ }
5474
+ else {
5475
+ return Promise.reject(error);
5476
+ }
5477
+ });
5478
+ }
5479
+ const response = await signUpResponse.catch(error => {
5480
+ return Promise.reject(error);
5104
5481
  });
5105
5482
  const userCredential = await UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response);
5106
5483
  await authInternal._updateCurrentUser(userCredential.user);
@@ -5181,16 +5558,39 @@ function signInWithEmailAndPassword(auth, email, password) {
5181
5558
  * @public
5182
5559
  */
5183
5560
  async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
5184
- const authModular = util.getModularInstance(auth);
5561
+ var _a;
5562
+ const authInternal = _castAuth(auth);
5185
5563
  const request = {
5186
5564
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
5187
- email
5565
+ email,
5566
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5188
5567
  };
5189
- _assert(actionCodeSettings.handleCodeInApp, authModular, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
5190
- if (actionCodeSettings) {
5191
- _setActionCodeSettingsOnRequest(authModular, request, actionCodeSettings);
5568
+ function setActionCodeSettings(request, actionCodeSettings) {
5569
+ _assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
5570
+ if (actionCodeSettings) {
5571
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
5572
+ }
5573
+ }
5574
+ if ((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled) {
5575
+ const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5576
+ setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5577
+ await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5578
+ }
5579
+ else {
5580
+ setActionCodeSettings(request, actionCodeSettings);
5581
+ await sendSignInLinkToEmail$1(authInternal, request)
5582
+ .catch(async (error) => {
5583
+ if (error.code === `auth/${"missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */}`) {
5584
+ console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
5585
+ const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true);
5586
+ setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
5587
+ await sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha);
5588
+ }
5589
+ else {
5590
+ return Promise.reject(error);
5591
+ }
5592
+ });
5192
5593
  }
5193
- await sendSignInLinkToEmail$1(authModular, request);
5194
5594
  }
5195
5595
  /**
5196
5596
  * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
@@ -5685,11 +6085,41 @@ function getAdditionalUserInfo(userCredential) {
5685
6085
  function setPersistence(auth, persistence) {
5686
6086
  return util.getModularInstance(auth).setPersistence(persistence);
5687
6087
  }
6088
+ /**
6089
+ * Loads the reCAPTCHA configuration into the `Auth` instance.
6090
+ *
6091
+ * @remarks
6092
+ * This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
6093
+ * verification flow should be triggered for each auth provider, into the
6094
+ * current Auth session.
6095
+ *
6096
+ * If initializeRecaptchaConfig() is not invoked, the auth flow will always start
6097
+ * without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
6098
+ * verification, the SDK will transparently load the reCAPTCHA config and restart the
6099
+ * auth flows.
6100
+ *
6101
+ * Thus, by calling this optional method, you will reduce the latency of future auth flows.
6102
+ * Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
6103
+ *
6104
+ * @example
6105
+ * ```javascript
6106
+ * initializeRecaptchaConfig(auth);
6107
+ * ```
6108
+ *
6109
+ * @param auth - The {@link Auth} instance.
6110
+ *
6111
+ * @public
6112
+ */
6113
+ function initializeRecaptchaConfig(auth) {
6114
+ const authInternal = _castAuth(auth);
6115
+ return authInternal.initializeRecaptchaConfig();
6116
+ }
5688
6117
  /**
5689
6118
  * Adds an observer for changes to the signed-in user's ID token.
5690
6119
  *
5691
6120
  * @remarks
5692
6121
  * This includes sign-in, sign-out, and token refresh events.
6122
+ * This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
5693
6123
  *
5694
6124
  * @param auth - The {@link Auth} instance.
5695
6125
  * @param nextOrObserver - callback triggered on change.
@@ -7029,66 +7459,6 @@ function finalizeSignInTotpMfa(auth, request) {
7029
7459
  return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
7030
7460
  }
7031
7461
 
7032
- /**
7033
- * @license
7034
- * Copyright 2020 Google LLC
7035
- *
7036
- * Licensed under the Apache License, Version 2.0 (the "License");
7037
- * you may not use this file except in compliance with the License.
7038
- * You may obtain a copy of the License at
7039
- *
7040
- * http://www.apache.org/licenses/LICENSE-2.0
7041
- *
7042
- * Unless required by applicable law or agreed to in writing, software
7043
- * distributed under the License is distributed on an "AS IS" BASIS,
7044
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7045
- * See the License for the specific language governing permissions and
7046
- * limitations under the License.
7047
- */
7048
- async function getRecaptchaParams(auth) {
7049
- return ((await _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)).recaptchaSiteKey || '');
7050
- }
7051
-
7052
- /**
7053
- * @license
7054
- * Copyright 2020 Google LLC
7055
- *
7056
- * Licensed under the Apache License, Version 2.0 (the "License");
7057
- * you may not use this file except in compliance with the License.
7058
- * You may obtain a copy of the License at
7059
- *
7060
- * http://www.apache.org/licenses/LICENSE-2.0
7061
- *
7062
- * Unless required by applicable law or agreed to in writing, software
7063
- * distributed under the License is distributed on an "AS IS" BASIS,
7064
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7065
- * See the License for the specific language governing permissions and
7066
- * limitations under the License.
7067
- */
7068
- function getScriptParentElement() {
7069
- var _a, _b;
7070
- return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
7071
- }
7072
- function _loadJS(url) {
7073
- // TODO: consider adding timeout support & cancellation
7074
- return new Promise((resolve, reject) => {
7075
- const el = document.createElement('script');
7076
- el.setAttribute('src', url);
7077
- el.onload = resolve;
7078
- el.onerror = e => {
7079
- const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
7080
- error.customData = e;
7081
- reject(error);
7082
- };
7083
- el.type = 'text/javascript';
7084
- el.charset = 'UTF-8';
7085
- getScriptParentElement().appendChild(el);
7086
- });
7087
- }
7088
- function _generateCallbackName(prefix) {
7089
- return `__${prefix}${Math.floor(Math.random() * 1000000)}`;
7090
- }
7091
-
7092
7462
  /**
7093
7463
  * @license
7094
7464
  * Copyright 2020 Google LLC
@@ -7255,7 +7625,7 @@ class ReCaptchaLoaderImpl {
7255
7625
  }
7256
7626
  load(auth, hl = '') {
7257
7627
  _assert(isHostLanguageValid(hl), auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
7258
- if (this.shouldResolveImmediately(hl)) {
7628
+ if (this.shouldResolveImmediately(hl) && isV2(_window().grecaptcha)) {
7259
7629
  return Promise.resolve(_window().grecaptcha);
7260
7630
  }
7261
7631
  return new Promise((resolve, reject) => {
@@ -7266,7 +7636,7 @@ class ReCaptchaLoaderImpl {
7266
7636
  _window().clearTimeout(networkTimeout);
7267
7637
  delete _window()[_JSLOAD_CALLBACK];
7268
7638
  const recaptcha = _window().grecaptcha;
7269
- if (!recaptcha) {
7639
+ if (!recaptcha || !isV2(recaptcha)) {
7270
7640
  reject(_createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
7271
7641
  return;
7272
7642
  }
@@ -8250,11 +8620,13 @@ class PopupOperation extends AbstractPopupRedirectOperation {
8250
8620
  if ((_b = (_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.window) === null || _b === void 0 ? void 0 : _b.closed) {
8251
8621
  // Make sure that there is sufficient time for whatever action to
8252
8622
  // complete. The window could have closed but the sign in network
8253
- // call could still be in flight.
8623
+ // call could still be in flight. This is specifically true for
8624
+ // Firefox or if the opener is in an iframe, in which case the oauth
8625
+ // helper closes the popup.
8254
8626
  this.pollId = window.setTimeout(() => {
8255
8627
  this.pollId = null;
8256
8628
  this.reject(_createError(this.auth, "popup-closed-by-user" /* AuthErrorCode.POPUP_CLOSED_BY_USER */));
8257
- }, 2000 /* _Timeout.AUTH_EVENT */);
8629
+ }, 8000 /* _Timeout.AUTH_EVENT */);
8258
8630
  return;
8259
8631
  }
8260
8632
  this.pollId = window.setTimeout(poll, _POLL_WINDOW_CLOSE_TIMEOUT.get());
@@ -9112,7 +9484,13 @@ const WIDGET_PATH = '__/auth/handler';
9112
9484
  * @internal
9113
9485
  */
9114
9486
  const EMULATOR_WIDGET_PATH = 'emulator/auth/handler';
9115
- function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additionalParams) {
9487
+ /**
9488
+ * Fragment name for the App Check token that gets passed to the widget
9489
+ *
9490
+ * @internal
9491
+ */
9492
+ const FIREBASE_APP_CHECK_FRAGMENT_ID = encodeURIComponent('fac');
9493
+ async function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additionalParams) {
9116
9494
  _assert(auth.config.authDomain, auth, "auth-domain-config-required" /* AuthErrorCode.MISSING_AUTH_DOMAIN */);
9117
9495
  _assert(auth.config.apiKey, auth, "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */);
9118
9496
  const params = {
@@ -9151,7 +9529,13 @@ function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additio
9151
9529
  delete paramsDict[key];
9152
9530
  }
9153
9531
  }
9154
- return `${getHandlerBase(auth)}?${util.querystring(paramsDict).slice(1)}`;
9532
+ // Sets the App Check token to pass to the widget
9533
+ const appCheckToken = await auth._getAppCheckToken();
9534
+ const appCheckTokenFragment = appCheckToken
9535
+ ? `#${FIREBASE_APP_CHECK_FRAGMENT_ID}=${encodeURIComponent(appCheckToken)}`
9536
+ : '';
9537
+ // Start at index 1 to skip the leading '&' in the query string
9538
+ return `${getHandlerBase(auth)}?${util.querystring(paramsDict).slice(1)}${appCheckTokenFragment}`;
9155
9539
  }
9156
9540
  function getHandlerBase({ config }) {
9157
9541
  if (!config.emulator) {
@@ -9195,12 +9579,13 @@ class BrowserPopupRedirectResolver {
9195
9579
  async _openPopup(auth, provider, authType, eventId) {
9196
9580
  var _a;
9197
9581
  debugAssert((_a = this.eventManagers[auth._key()]) === null || _a === void 0 ? void 0 : _a.manager, '_initialize() not called before _openPopup()');
9198
- const url = _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
9582
+ const url = await _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
9199
9583
  return _open(auth, url, _generateEventId());
9200
9584
  }
9201
9585
  async _openRedirect(auth, provider, authType, eventId) {
9202
9586
  await this._originValidation(auth);
9203
- _setWindowLocation(_getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId));
9587
+ const url = await _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
9588
+ _setWindowLocation(url);
9204
9589
  return new Promise(() => { });
9205
9590
  }
9206
9591
  _initialize(auth) {
@@ -9485,7 +9870,7 @@ function _isEmptyString(input) {
9485
9870
  }
9486
9871
 
9487
9872
  var name = "@firebase/auth";
9488
- var version = "0.21.6";
9873
+ var version = "0.22.0-canary.1d6771eb3";
9489
9874
 
9490
9875
  /**
9491
9876
  * @license
@@ -9591,26 +9976,25 @@ function registerAuth(clientPlatform) {
9591
9976
  app._registerComponent(new component.Component("auth" /* _ComponentName.AUTH */, (container, { options: deps }) => {
9592
9977
  const app = container.getProvider('app').getImmediate();
9593
9978
  const heartbeatServiceProvider = container.getProvider('heartbeat');
9979
+ const appCheckServiceProvider = container.getProvider('app-check-internal');
9594
9980
  const { apiKey, authDomain } = app.options;
9595
- return ((app, heartbeatServiceProvider) => {
9596
- _assert(apiKey && !apiKey.includes(':'), "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */, { appName: app.name });
9597
- // Auth domain is optional if IdP sign in isn't being used
9598
- _assert(!(authDomain === null || authDomain === void 0 ? void 0 : authDomain.includes(':')), "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, {
9599
- appName: app.name
9600
- });
9601
- const config = {
9602
- apiKey,
9603
- authDomain,
9604
- clientPlatform,
9605
- apiHost: "identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */,
9606
- tokenApiHost: "securetoken.googleapis.com" /* DefaultConfig.TOKEN_API_HOST */,
9607
- apiScheme: "https" /* DefaultConfig.API_SCHEME */,
9608
- sdkClientVersion: _getClientVersion(clientPlatform)
9609
- };
9610
- const authInstance = new AuthImpl(app, heartbeatServiceProvider, config);
9611
- _initializeAuthInstance(authInstance, deps);
9612
- return authInstance;
9613
- })(app, heartbeatServiceProvider);
9981
+ _assert(apiKey && !apiKey.includes(':'), "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */, { appName: app.name });
9982
+ // Auth domain is optional if IdP sign in isn't being used
9983
+ _assert(!(authDomain === null || authDomain === void 0 ? void 0 : authDomain.includes(':')), "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, {
9984
+ appName: app.name
9985
+ });
9986
+ const config = {
9987
+ apiKey,
9988
+ authDomain,
9989
+ clientPlatform,
9990
+ apiHost: "identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */,
9991
+ tokenApiHost: "securetoken.googleapis.com" /* DefaultConfig.TOKEN_API_HOST */,
9992
+ apiScheme: "https" /* DefaultConfig.API_SCHEME */,
9993
+ sdkClientVersion: _getClientVersion(clientPlatform)
9994
+ };
9995
+ const authInstance = new AuthImpl(app, heartbeatServiceProvider, appCheckServiceProvider, config);
9996
+ _initializeAuthInstance(authInstance, deps);
9997
+ return authInstance;
9614
9998
  }, "PUBLIC" /* ComponentType.PUBLIC */)
9615
9999
  /**
9616
10000
  * Auth can only be initialized by explicitly calling getAuth() or initializeAuth()
@@ -9777,6 +10161,7 @@ exports.getRedirectResult = getRedirectResult;
9777
10161
  exports.inMemoryPersistence = inMemoryPersistence;
9778
10162
  exports.indexedDBLocalPersistence = indexedDBLocalPersistence;
9779
10163
  exports.initializeAuth = initializeAuth;
10164
+ exports.initializeRecaptchaConfig = initializeRecaptchaConfig;
9780
10165
  exports.isSignInWithEmailLink = isSignInWithEmailLink;
9781
10166
  exports.linkWithCredential = linkWithCredential;
9782
10167
  exports.linkWithPhoneNumber = linkWithPhoneNumber;
@@ -9814,4 +10199,4 @@ exports.updateProfile = updateProfile;
9814
10199
  exports.useDeviceLanguage = useDeviceLanguage;
9815
10200
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
9816
10201
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
9817
- //# sourceMappingURL=index-39443020.js.map
10202
+ //# sourceMappingURL=index-7393ca6a.js.map