@firebase/auth 0.22.0-canary.ea3849fff → 0.22.0-canary.ecb4454c3

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 (175) hide show
  1. package/dist/auth-public.d.ts +57 -0
  2. package/dist/auth.d.ts +70 -1
  3. package/dist/browser-cjs/{index-a4932583.js → index-2a5c9cce.js} +526 -181
  4. package/dist/browser-cjs/index-2a5c9cce.js.map +1 -0
  5. package/dist/browser-cjs/index.js +3 -2
  6. package/dist/browser-cjs/index.js.map +1 -1
  7. package/dist/browser-cjs/internal.js +3 -2
  8. package/dist/browser-cjs/internal.js.map +1 -1
  9. package/dist/browser-cjs/src/api/authentication/email_and_password.d.ts +9 -0
  10. package/dist/browser-cjs/src/api/authentication/recaptcha.d.ts +16 -0
  11. package/dist/browser-cjs/src/api/authentication/sign_up.d.ts +4 -0
  12. package/dist/browser-cjs/src/api/errors.d.ts +9 -1
  13. package/dist/browser-cjs/src/api/index.d.ts +15 -1
  14. package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +5 -0
  15. package/dist/browser-cjs/src/core/errors.d.ts +17 -1
  16. package/dist/browser-cjs/src/core/index.d.ts +26 -0
  17. package/dist/browser-cjs/src/model/auth.d.ts +5 -0
  18. package/dist/browser-cjs/src/platform_browser/auth_window.d.ts +2 -2
  19. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  20. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  21. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  22. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  23. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  24. package/dist/browser-cjs/test/helpers/api/helper.d.ts +2 -0
  25. package/dist/cordova/index.js +2 -2
  26. package/dist/cordova/internal.js +4 -71
  27. package/dist/cordova/internal.js.map +1 -1
  28. package/dist/cordova/{popup_redirect-e2867f33.js → popup_redirect-710a0689.js} +660 -152
  29. package/dist/cordova/popup_redirect-710a0689.js.map +1 -0
  30. package/dist/cordova/src/api/authentication/email_and_password.d.ts +9 -0
  31. package/dist/cordova/src/api/authentication/recaptcha.d.ts +16 -0
  32. package/dist/cordova/src/api/authentication/sign_up.d.ts +4 -0
  33. package/dist/cordova/src/api/errors.d.ts +9 -1
  34. package/dist/cordova/src/api/index.d.ts +15 -1
  35. package/dist/cordova/src/core/auth/auth_impl.d.ts +5 -0
  36. package/dist/cordova/src/core/errors.d.ts +17 -1
  37. package/dist/cordova/src/core/index.d.ts +26 -0
  38. package/dist/cordova/src/model/auth.d.ts +5 -0
  39. package/dist/cordova/src/platform_browser/auth_window.d.ts +2 -2
  40. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  41. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  42. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  43. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  44. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  45. package/dist/cordova/test/helpers/api/helper.d.ts +2 -0
  46. package/dist/esm2017/{index-5eca8e8e.js → index-2dbc6285.js} +527 -183
  47. package/dist/esm2017/index-2dbc6285.js.map +1 -0
  48. package/dist/esm2017/index.js +2 -2
  49. package/dist/esm2017/internal.js +3 -3
  50. package/dist/esm2017/src/api/authentication/email_and_password.d.ts +9 -0
  51. package/dist/esm2017/src/api/authentication/recaptcha.d.ts +16 -0
  52. package/dist/esm2017/src/api/authentication/sign_up.d.ts +4 -0
  53. package/dist/esm2017/src/api/errors.d.ts +9 -1
  54. package/dist/esm2017/src/api/index.d.ts +15 -1
  55. package/dist/esm2017/src/core/auth/auth_impl.d.ts +5 -0
  56. package/dist/esm2017/src/core/errors.d.ts +17 -1
  57. package/dist/esm2017/src/core/index.d.ts +26 -0
  58. package/dist/esm2017/src/model/auth.d.ts +5 -0
  59. package/dist/esm2017/src/platform_browser/auth_window.d.ts +2 -2
  60. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  61. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  62. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  63. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  64. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  65. package/dist/esm2017/test/helpers/api/helper.d.ts +2 -0
  66. package/dist/esm5/{index-ea49ccf6.js → index-f764da84.js} +682 -241
  67. package/dist/esm5/index-f764da84.js.map +1 -0
  68. package/dist/esm5/index.js +1 -1
  69. package/dist/esm5/internal.js +2 -2
  70. package/dist/esm5/src/api/authentication/email_and_password.d.ts +9 -0
  71. package/dist/esm5/src/api/authentication/recaptcha.d.ts +16 -0
  72. package/dist/esm5/src/api/authentication/sign_up.d.ts +4 -0
  73. package/dist/esm5/src/api/errors.d.ts +9 -1
  74. package/dist/esm5/src/api/index.d.ts +15 -1
  75. package/dist/esm5/src/core/auth/auth_impl.d.ts +5 -0
  76. package/dist/esm5/src/core/errors.d.ts +17 -1
  77. package/dist/esm5/src/core/index.d.ts +26 -0
  78. package/dist/esm5/src/model/auth.d.ts +5 -0
  79. package/dist/esm5/src/platform_browser/auth_window.d.ts +2 -2
  80. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  81. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  82. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  83. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  84. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  85. package/dist/esm5/test/helpers/api/helper.d.ts +2 -0
  86. package/dist/index.webworker.esm5.js +544 -53
  87. package/dist/index.webworker.esm5.js.map +1 -1
  88. package/dist/node/index.js +2 -1
  89. package/dist/node/index.js.map +1 -1
  90. package/dist/node/internal.js +2 -1
  91. package/dist/node/internal.js.map +1 -1
  92. package/dist/node/src/api/authentication/email_and_password.d.ts +9 -0
  93. package/dist/node/src/api/authentication/recaptcha.d.ts +16 -0
  94. package/dist/node/src/api/authentication/sign_up.d.ts +4 -0
  95. package/dist/node/src/api/errors.d.ts +9 -1
  96. package/dist/node/src/api/index.d.ts +15 -1
  97. package/dist/node/src/core/auth/auth_impl.d.ts +5 -0
  98. package/dist/node/src/core/errors.d.ts +17 -1
  99. package/dist/node/src/core/index.d.ts +26 -0
  100. package/dist/node/src/model/auth.d.ts +5 -0
  101. package/dist/node/src/platform_browser/auth_window.d.ts +2 -2
  102. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  103. package/dist/node/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  104. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  105. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  106. package/dist/node/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  107. package/dist/node/test/helpers/api/helper.d.ts +2 -0
  108. package/dist/node/{totp-e4b57fc2.js → totp-b357b7fa.js} +642 -150
  109. package/dist/node/totp-b357b7fa.js.map +1 -0
  110. package/dist/node-esm/index.js +1 -1
  111. package/dist/node-esm/internal.js +2 -2
  112. package/dist/node-esm/src/api/authentication/email_and_password.d.ts +9 -0
  113. package/dist/node-esm/src/api/authentication/recaptcha.d.ts +16 -0
  114. package/dist/node-esm/src/api/authentication/sign_up.d.ts +4 -0
  115. package/dist/node-esm/src/api/errors.d.ts +9 -1
  116. package/dist/node-esm/src/api/index.d.ts +15 -1
  117. package/dist/node-esm/src/core/auth/auth_impl.d.ts +5 -0
  118. package/dist/node-esm/src/core/errors.d.ts +17 -1
  119. package/dist/node-esm/src/core/index.d.ts +26 -0
  120. package/dist/node-esm/src/model/auth.d.ts +5 -0
  121. package/dist/node-esm/src/platform_browser/auth_window.d.ts +2 -2
  122. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  123. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  124. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  125. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  126. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  127. package/dist/node-esm/test/helpers/api/helper.d.ts +2 -0
  128. package/dist/node-esm/{totp-3a67b88c.js → totp-501673f0.js} +514 -120
  129. package/dist/node-esm/totp-501673f0.js.map +1 -0
  130. package/dist/rn/index.js +2 -1
  131. package/dist/rn/index.js.map +1 -1
  132. package/dist/rn/internal.js +2 -1
  133. package/dist/rn/internal.js.map +1 -1
  134. package/dist/rn/{phone-6ea1b9dd.js → phone-7f3181c6.js} +681 -239
  135. package/dist/rn/phone-7f3181c6.js.map +1 -0
  136. package/dist/rn/src/api/authentication/email_and_password.d.ts +9 -0
  137. package/dist/rn/src/api/authentication/recaptcha.d.ts +16 -0
  138. package/dist/rn/src/api/authentication/sign_up.d.ts +4 -0
  139. package/dist/rn/src/api/errors.d.ts +9 -1
  140. package/dist/rn/src/api/index.d.ts +15 -1
  141. package/dist/rn/src/core/auth/auth_impl.d.ts +5 -0
  142. package/dist/rn/src/core/errors.d.ts +17 -1
  143. package/dist/rn/src/core/index.d.ts +26 -0
  144. package/dist/rn/src/model/auth.d.ts +5 -0
  145. package/dist/rn/src/platform_browser/auth_window.d.ts +2 -2
  146. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  147. package/dist/rn/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  148. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  149. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  150. package/dist/rn/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  151. package/dist/rn/test/helpers/api/helper.d.ts +2 -0
  152. package/dist/src/api/authentication/email_and_password.d.ts +9 -0
  153. package/dist/src/api/authentication/recaptcha.d.ts +16 -0
  154. package/dist/src/api/authentication/sign_up.d.ts +4 -0
  155. package/dist/src/api/errors.d.ts +9 -1
  156. package/dist/src/api/index.d.ts +15 -1
  157. package/dist/src/core/auth/auth_impl.d.ts +5 -0
  158. package/dist/src/core/errors.d.ts +17 -1
  159. package/dist/src/core/index.d.ts +26 -0
  160. package/dist/src/model/auth.d.ts +5 -0
  161. package/dist/src/platform_browser/auth_window.d.ts +2 -2
  162. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +33 -0
  163. package/dist/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  164. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +40 -0
  165. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  166. package/dist/src/platform_browser/recaptcha/recaptcha_mock.d.ts +16 -1
  167. package/dist/test/helpers/api/helper.d.ts +2 -0
  168. package/package.json +6 -6
  169. package/dist/browser-cjs/index-a4932583.js.map +0 -1
  170. package/dist/cordova/popup_redirect-e2867f33.js.map +0 -1
  171. package/dist/esm2017/index-5eca8e8e.js.map +0 -1
  172. package/dist/esm5/index-ea49ccf6.js.map +0 -1
  173. package/dist/node/totp-e4b57fc2.js.map +0 -1
  174. package/dist/node-esm/totp-3a67b88c.js.map +0 -1
  175. package/dist/rn/phone-6ea1b9dd.js.map +0 -1
@@ -290,6 +290,14 @@ function _debugErrorMap() {
290
290
  'different options. To avoid this error, call initializeAuth() with the ' +
291
291
  'same options as when it was originally called, or call getAuth() to return the' +
292
292
  ' already initialized instance.',
293
+ _a["missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is missing when sending request to the backend.',
294
+ _a["invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */] = 'The reCAPTCHA token is invalid when sending request to the backend.',
295
+ _a["invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */] = 'The reCAPTCHA action is invalid when sending request to the backend.',
296
+ _a["recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */] = 'reCAPTCHA Enterprise integration is not enabled for this project.',
297
+ _a["missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */] = 'The reCAPTCHA client type is missing when sending request to the backend.',
298
+ _a["missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is missing when sending request to the backend.',
299
+ _a["invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */] = 'Invalid request parameters.',
300
+ _a["invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */] = 'The reCAPTCHA version is invalid when sending request to the backend.',
293
301
  _a;
294
302
  }
295
303
  function _prodErrorMap() {
@@ -426,7 +434,15 @@ var AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
426
434
  USER_SIGNED_OUT: 'auth/user-signed-out',
427
435
  WEAK_PASSWORD: 'auth/weak-password',
428
436
  WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
429
- ALREADY_INITIALIZED: 'auth/already-initialized'
437
+ ALREADY_INITIALIZED: 'auth/already-initialized',
438
+ RECAPTCHA_NOT_ENABLED: 'auth/recaptcha-not-enabled',
439
+ MISSING_RECAPTCHA_TOKEN: 'auth/missing-recaptcha-token',
440
+ INVALID_RECAPTCHA_TOKEN: 'auth/invalid-recaptcha-token',
441
+ INVALID_RECAPTCHA_ACTION: 'auth/invalid-recaptcha-action',
442
+ MISSING_CLIENT_TYPE: 'auth/missing-client-type',
443
+ MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version',
444
+ INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version',
445
+ INVALID_REQ_TYPE: 'auth/invalid-req-type'
430
446
  };
431
447
 
432
448
  /**
@@ -557,103 +573,6 @@ function debugAssert(assertion, message) {
557
573
  }
558
574
  }
559
575
 
560
- /**
561
- * @license
562
- * Copyright 2020 Google LLC
563
- *
564
- * Licensed under the Apache License, Version 2.0 (the "License");
565
- * you may not use this file except in compliance with the License.
566
- * You may obtain a copy of the License at
567
- *
568
- * http://www.apache.org/licenses/LICENSE-2.0
569
- *
570
- * Unless required by applicable law or agreed to in writing, software
571
- * distributed under the License is distributed on an "AS IS" BASIS,
572
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
573
- * See the License for the specific language governing permissions and
574
- * limitations under the License.
575
- */
576
- var instanceCache = new Map();
577
- function _getInstance(cls) {
578
- debugAssert(cls instanceof Function, 'Expected a class definition');
579
- var instance = instanceCache.get(cls);
580
- if (instance) {
581
- debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
582
- return instance;
583
- }
584
- instance = new cls();
585
- instanceCache.set(cls, instance);
586
- return instance;
587
- }
588
-
589
- /**
590
- * @license
591
- * Copyright 2020 Google LLC
592
- *
593
- * Licensed under the Apache License, Version 2.0 (the "License");
594
- * you may not use this file except in compliance with the License.
595
- * You may obtain a copy of the License at
596
- *
597
- * http://www.apache.org/licenses/LICENSE-2.0
598
- *
599
- * Unless required by applicable law or agreed to in writing, software
600
- * distributed under the License is distributed on an "AS IS" BASIS,
601
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
602
- * See the License for the specific language governing permissions and
603
- * limitations under the License.
604
- */
605
- /**
606
- * Initializes an {@link Auth} instance with fine-grained control over
607
- * {@link Dependencies}.
608
- *
609
- * @remarks
610
- *
611
- * This function allows more control over the {@link Auth} instance than
612
- * {@link getAuth}. `getAuth` uses platform-specific defaults to supply
613
- * the {@link Dependencies}. In general, `getAuth` is the easiest way to
614
- * initialize Auth and works for most use cases. Use `initializeAuth` if you
615
- * need control over which persistence layer is used, or to minimize bundle
616
- * size if you're not using either `signInWithPopup` or `signInWithRedirect`.
617
- *
618
- * For example, if your app only uses anonymous accounts and you only want
619
- * accounts saved for the current session, initialize `Auth` with:
620
- *
621
- * ```js
622
- * const auth = initializeAuth(app, {
623
- * persistence: browserSessionPersistence,
624
- * popupRedirectResolver: undefined,
625
- * });
626
- * ```
627
- *
628
- * @public
629
- */
630
- function initializeAuth(app$1, deps) {
631
- var provider = app._getProvider(app$1, 'auth');
632
- if (provider.isInitialized()) {
633
- var auth_1 = provider.getImmediate();
634
- var initialOptions = provider.getOptions();
635
- if (util.deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
636
- return auth_1;
637
- }
638
- else {
639
- _fail(auth_1, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
640
- }
641
- }
642
- var auth = provider.initialize({ options: deps });
643
- return auth;
644
- }
645
- function _initializeAuthInstance(auth, deps) {
646
- var persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
647
- var hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
648
- if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
649
- auth._updateErrorMap(deps.errorMap);
650
- }
651
- // This promise is intended to float; auth initialization happens in the
652
- // background, meanwhile the auth object may be used by the app.
653
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
654
- auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
655
- }
656
-
657
576
  /**
658
577
  * @license
659
578
  * Copyright 2020 Google LLC
@@ -938,6 +857,15 @@ var SERVER_ERROR_MAP = (_a$1 = {},
938
857
  _a$1["SECOND_FACTOR_LIMIT_EXCEEDED" /* ServerError.SECOND_FACTOR_LIMIT_EXCEEDED */] = "maximum-second-factor-count-exceeded" /* AuthErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED */,
939
858
  // Blocking functions related errors.
940
859
  _a$1["BLOCKING_FUNCTION_ERROR_RESPONSE" /* ServerError.BLOCKING_FUNCTION_ERROR_RESPONSE */] = "internal-error" /* AuthErrorCode.INTERNAL_ERROR */,
860
+ // Recaptcha related errors.
861
+ _a$1["RECAPTCHA_NOT_ENABLED" /* ServerError.RECAPTCHA_NOT_ENABLED */] = "recaptcha-not-enabled" /* AuthErrorCode.RECAPTCHA_NOT_ENABLED */,
862
+ _a$1["MISSING_RECAPTCHA_TOKEN" /* ServerError.MISSING_RECAPTCHA_TOKEN */] = "missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */,
863
+ _a$1["INVALID_RECAPTCHA_TOKEN" /* ServerError.INVALID_RECAPTCHA_TOKEN */] = "invalid-recaptcha-token" /* AuthErrorCode.INVALID_RECAPTCHA_TOKEN */,
864
+ _a$1["INVALID_RECAPTCHA_ACTION" /* ServerError.INVALID_RECAPTCHA_ACTION */] = "invalid-recaptcha-action" /* AuthErrorCode.INVALID_RECAPTCHA_ACTION */,
865
+ _a$1["MISSING_CLIENT_TYPE" /* ServerError.MISSING_CLIENT_TYPE */] = "missing-client-type" /* AuthErrorCode.MISSING_CLIENT_TYPE */,
866
+ _a$1["MISSING_RECAPTCHA_VERSION" /* ServerError.MISSING_RECAPTCHA_VERSION */] = "missing-recaptcha-version" /* AuthErrorCode.MISSING_RECAPTCHA_VERSION */,
867
+ _a$1["INVALID_RECAPTCHA_VERSION" /* ServerError.INVALID_RECAPTCHA_VERSION */] = "invalid-recaptcha-version" /* AuthErrorCode.INVALID_RECAPTCHA_VERSION */,
868
+ _a$1["INVALID_REQ_TYPE" /* ServerError.INVALID_REQ_TYPE */] = "invalid-req-type" /* AuthErrorCode.INVALID_REQ_TYPE */,
941
869
  _a$1);
942
870
 
943
871
  /**
@@ -2059,6 +1987,35 @@ var UserImpl = /** @class */ (function () {
2059
1987
  return UserImpl;
2060
1988
  }());
2061
1989
 
1990
+ /**
1991
+ * @license
1992
+ * Copyright 2020 Google LLC
1993
+ *
1994
+ * Licensed under the Apache License, Version 2.0 (the "License");
1995
+ * you may not use this file except in compliance with the License.
1996
+ * You may obtain a copy of the License at
1997
+ *
1998
+ * http://www.apache.org/licenses/LICENSE-2.0
1999
+ *
2000
+ * Unless required by applicable law or agreed to in writing, software
2001
+ * distributed under the License is distributed on an "AS IS" BASIS,
2002
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2003
+ * See the License for the specific language governing permissions and
2004
+ * limitations under the License.
2005
+ */
2006
+ var instanceCache = new Map();
2007
+ function _getInstance(cls) {
2008
+ debugAssert(cls instanceof Function, 'Expected a class definition');
2009
+ var instance = instanceCache.get(cls);
2010
+ if (instance) {
2011
+ debugAssert(instance instanceof cls, 'Instance stored in cache mismatched with class');
2012
+ return instance;
2013
+ }
2014
+ instance = new cls();
2015
+ instanceCache.set(cls, instance);
2016
+ return instance;
2017
+ }
2018
+
2062
2019
  /**
2063
2020
  * @license
2064
2021
  * Copyright 2019 Google LLC
@@ -2492,6 +2449,271 @@ function _getClientVersion(clientPlatform, frameworks) {
2492
2449
  return "".concat(reportedPlatform, "/").concat("JsCore" /* ClientImplementation.CORE */, "/").concat(app.SDK_VERSION, "/").concat(reportedFrameworks);
2493
2450
  }
2494
2451
 
2452
+ /**
2453
+ * @license
2454
+ * Copyright 2020 Google LLC
2455
+ *
2456
+ * Licensed under the Apache License, Version 2.0 (the "License");
2457
+ * you may not use this file except in compliance with the License.
2458
+ * You may obtain a copy of the License at
2459
+ *
2460
+ * http://www.apache.org/licenses/LICENSE-2.0
2461
+ *
2462
+ * Unless required by applicable law or agreed to in writing, software
2463
+ * distributed under the License is distributed on an "AS IS" BASIS,
2464
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2465
+ * See the License for the specific language governing permissions and
2466
+ * limitations under the License.
2467
+ */
2468
+ function getRecaptchaConfig(auth, request) {
2469
+ return tslib.__awaiter(this, void 0, void 0, function () {
2470
+ return tslib.__generator(this, function (_a) {
2471
+ return [2 /*return*/, _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request))];
2472
+ });
2473
+ });
2474
+ }
2475
+
2476
+ /**
2477
+ * @license
2478
+ * Copyright 2020 Google LLC
2479
+ *
2480
+ * Licensed under the Apache License, Version 2.0 (the "License");
2481
+ * you may not use this file except in compliance with the License.
2482
+ * You may obtain a copy of the License at
2483
+ *
2484
+ * http://www.apache.org/licenses/LICENSE-2.0
2485
+ *
2486
+ * Unless required by applicable law or agreed to in writing, software
2487
+ * distributed under the License is distributed on an "AS IS" BASIS,
2488
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2489
+ * See the License for the specific language governing permissions and
2490
+ * limitations under the License.
2491
+ */
2492
+ function isEnterprise(grecaptcha) {
2493
+ return (grecaptcha !== undefined &&
2494
+ grecaptcha.enterprise !== undefined);
2495
+ }
2496
+ var RecaptchaConfig = /** @class */ (function () {
2497
+ function RecaptchaConfig(response) {
2498
+ /**
2499
+ * The reCAPTCHA site key.
2500
+ */
2501
+ this.siteKey = '';
2502
+ /**
2503
+ * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
2504
+ */
2505
+ this.emailPasswordEnabled = false;
2506
+ if (response.recaptchaKey === undefined) {
2507
+ throw new Error('recaptchaKey undefined');
2508
+ }
2509
+ // Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
2510
+ this.siteKey = response.recaptchaKey.split('/')[3];
2511
+ this.emailPasswordEnabled = response.recaptchaEnforcementState.some(function (enforcementState) {
2512
+ return enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
2513
+ enforcementState.enforcementState !== 'OFF';
2514
+ });
2515
+ }
2516
+ return RecaptchaConfig;
2517
+ }());
2518
+
2519
+ /**
2520
+ * @license
2521
+ * Copyright 2020 Google LLC
2522
+ *
2523
+ * Licensed under the Apache License, Version 2.0 (the "License");
2524
+ * you may not use this file except in compliance with the License.
2525
+ * You may obtain a copy of the License at
2526
+ *
2527
+ * http://www.apache.org/licenses/LICENSE-2.0
2528
+ *
2529
+ * Unless required by applicable law or agreed to in writing, software
2530
+ * distributed under the License is distributed on an "AS IS" BASIS,
2531
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2532
+ * See the License for the specific language governing permissions and
2533
+ * limitations under the License.
2534
+ */
2535
+ function getScriptParentElement() {
2536
+ var _a, _b;
2537
+ return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
2538
+ }
2539
+ function _loadJS(url) {
2540
+ // TODO: consider adding timeout support & cancellation
2541
+ return new Promise(function (resolve, reject) {
2542
+ var el = document.createElement('script');
2543
+ el.setAttribute('src', url);
2544
+ el.onload = resolve;
2545
+ el.onerror = function (e) {
2546
+ var error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2547
+ error.customData = e;
2548
+ reject(error);
2549
+ };
2550
+ el.type = 'text/javascript';
2551
+ el.charset = 'UTF-8';
2552
+ getScriptParentElement().appendChild(el);
2553
+ });
2554
+ }
2555
+
2556
+ /* eslint-disable @typescript-eslint/no-require-imports */
2557
+ var RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
2558
+ var RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
2559
+ var RecaptchaEnterpriseVerifier = /** @class */ (function () {
2560
+ /**
2561
+ *
2562
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
2563
+ *
2564
+ */
2565
+ function RecaptchaEnterpriseVerifier(authExtern) {
2566
+ /**
2567
+ * Identifies the type of application verifier (e.g. "recaptcha-enterprise").
2568
+ */
2569
+ this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
2570
+ this.auth = _castAuth(authExtern);
2571
+ }
2572
+ /**
2573
+ * Executes the verification process.
2574
+ *
2575
+ * @returns A Promise for a token that can be used to assert the validity of a request.
2576
+ */
2577
+ RecaptchaEnterpriseVerifier.prototype.verify = function (action, forceRefresh) {
2578
+ if (action === void 0) { action = 'verify'; }
2579
+ if (forceRefresh === void 0) { forceRefresh = false; }
2580
+ return tslib.__awaiter(this, void 0, void 0, function () {
2581
+ function retrieveSiteKey(auth) {
2582
+ return tslib.__awaiter(this, void 0, void 0, function () {
2583
+ var _this = this;
2584
+ return tslib.__generator(this, function (_a) {
2585
+ if (!forceRefresh) {
2586
+ if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
2587
+ return [2 /*return*/, auth._agentRecaptchaConfig.siteKey];
2588
+ }
2589
+ if (auth.tenantId != null &&
2590
+ auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
2591
+ return [2 /*return*/, auth._tenantRecaptchaConfigs[auth.tenantId].siteKey];
2592
+ }
2593
+ }
2594
+ return [2 /*return*/, new Promise(function (resolve, reject) { return tslib.__awaiter(_this, void 0, void 0, function () {
2595
+ return tslib.__generator(this, function (_a) {
2596
+ getRecaptchaConfig(auth, {
2597
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
2598
+ version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
2599
+ })
2600
+ .then(function (response) {
2601
+ if (response.recaptchaKey === undefined) {
2602
+ reject(new Error('recaptcha Enterprise site key undefined'));
2603
+ }
2604
+ else {
2605
+ var config = new RecaptchaConfig(response);
2606
+ if (auth.tenantId == null) {
2607
+ auth._agentRecaptchaConfig = config;
2608
+ }
2609
+ else {
2610
+ auth._tenantRecaptchaConfigs[auth.tenantId] = config;
2611
+ }
2612
+ return resolve(config.siteKey);
2613
+ }
2614
+ })
2615
+ .catch(function (error) {
2616
+ reject(error);
2617
+ });
2618
+ return [2 /*return*/];
2619
+ });
2620
+ }); })];
2621
+ });
2622
+ });
2623
+ }
2624
+ function retrieveRecaptchaToken(siteKey, resolve, reject) {
2625
+ var grecaptcha = window.grecaptcha;
2626
+ if (isEnterprise(grecaptcha)) {
2627
+ grecaptcha.enterprise.ready(function () {
2628
+ try {
2629
+ grecaptcha.enterprise
2630
+ .execute(siteKey, { action: action })
2631
+ .then(function (token) {
2632
+ resolve(token);
2633
+ })
2634
+ .catch(function (error) {
2635
+ reject(error);
2636
+ });
2637
+ }
2638
+ catch (error) {
2639
+ reject(error);
2640
+ }
2641
+ });
2642
+ }
2643
+ else {
2644
+ reject(Error('No reCAPTCHA enterprise script loaded.'));
2645
+ }
2646
+ }
2647
+ var _this = this;
2648
+ return tslib.__generator(this, function (_a) {
2649
+ return [2 /*return*/, new Promise(function (resolve, reject) {
2650
+ retrieveSiteKey(_this.auth)
2651
+ .then(function (siteKey) {
2652
+ if (!forceRefresh && isEnterprise(window.grecaptcha)) {
2653
+ retrieveRecaptchaToken(siteKey, resolve, reject);
2654
+ }
2655
+ else {
2656
+ if (typeof window === 'undefined') {
2657
+ reject(new Error('RecaptchaVerifier is only supported in browser'));
2658
+ return;
2659
+ }
2660
+ _loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
2661
+ .then(function () {
2662
+ retrieveRecaptchaToken(siteKey, resolve, reject);
2663
+ })
2664
+ .catch(function (error) {
2665
+ reject(error);
2666
+ });
2667
+ }
2668
+ })
2669
+ .catch(function (error) {
2670
+ reject(error);
2671
+ });
2672
+ })];
2673
+ });
2674
+ });
2675
+ };
2676
+ return RecaptchaEnterpriseVerifier;
2677
+ }());
2678
+ function injectRecaptchaFields(auth, request, action, captchaResp) {
2679
+ if (captchaResp === void 0) { captchaResp = false; }
2680
+ return tslib.__awaiter(this, void 0, void 0, function () {
2681
+ var verifier, captchaResponse, newRequest;
2682
+ return tslib.__generator(this, function (_a) {
2683
+ switch (_a.label) {
2684
+ case 0:
2685
+ verifier = new RecaptchaEnterpriseVerifier(auth);
2686
+ _a.label = 1;
2687
+ case 1:
2688
+ _a.trys.push([1, 3, , 5]);
2689
+ return [4 /*yield*/, verifier.verify(action)];
2690
+ case 2:
2691
+ captchaResponse = _a.sent();
2692
+ return [3 /*break*/, 5];
2693
+ case 3:
2694
+ _a.sent();
2695
+ return [4 /*yield*/, verifier.verify(action, true)];
2696
+ case 4:
2697
+ captchaResponse = _a.sent();
2698
+ return [3 /*break*/, 5];
2699
+ case 5:
2700
+ newRequest = tslib.__assign({}, request);
2701
+ if (!captchaResp) {
2702
+ Object.assign(newRequest, { captchaResponse: captchaResponse });
2703
+ }
2704
+ else {
2705
+ Object.assign(newRequest, { 'captchaResp': captchaResponse });
2706
+ }
2707
+ Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
2708
+ Object.assign(newRequest, {
2709
+ 'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
2710
+ });
2711
+ return [2 /*return*/, newRequest];
2712
+ }
2713
+ });
2714
+ });
2715
+ }
2716
+
2495
2717
  /**
2496
2718
  * @license
2497
2719
  * Copyright 2022 Google LLC
@@ -2634,6 +2856,8 @@ var AuthImpl = /** @class */ (function () {
2634
2856
  this._initializationPromise = null;
2635
2857
  this._popupRedirectResolver = null;
2636
2858
  this._errorFactory = _DEFAULT_AUTH_ERROR_FACTORY;
2859
+ this._agentRecaptchaConfig = null;
2860
+ this._tenantRecaptchaConfigs = {};
2637
2861
  // Tracks the last notified UID for state change listeners to prevent
2638
2862
  // repeated calls to the callbacks. Undefined means it's never been
2639
2863
  // called, whereas null means it's been called with a signed out user
@@ -2963,6 +3187,41 @@ var AuthImpl = /** @class */ (function () {
2963
3187
  });
2964
3188
  }); });
2965
3189
  };
3190
+ AuthImpl.prototype.initializeRecaptchaConfig = function () {
3191
+ return tslib.__awaiter(this, void 0, void 0, function () {
3192
+ var response, config, verifier;
3193
+ return tslib.__generator(this, function (_a) {
3194
+ switch (_a.label) {
3195
+ case 0: return [4 /*yield*/, getRecaptchaConfig(this, {
3196
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
3197
+ version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
3198
+ })];
3199
+ case 1:
3200
+ response = _a.sent();
3201
+ config = new RecaptchaConfig(response);
3202
+ if (this.tenantId == null) {
3203
+ this._agentRecaptchaConfig = config;
3204
+ }
3205
+ else {
3206
+ this._tenantRecaptchaConfigs[this.tenantId] = config;
3207
+ }
3208
+ if (config.emailPasswordEnabled) {
3209
+ verifier = new RecaptchaEnterpriseVerifier(this);
3210
+ void verifier.verify();
3211
+ }
3212
+ return [2 /*return*/];
3213
+ }
3214
+ });
3215
+ });
3216
+ };
3217
+ AuthImpl.prototype._getRecaptchaConfig = function () {
3218
+ if (this.tenantId == null) {
3219
+ return this._agentRecaptchaConfig;
3220
+ }
3221
+ else {
3222
+ return this._tenantRecaptchaConfigs[this.tenantId];
3223
+ }
3224
+ };
2966
3225
  AuthImpl.prototype._getPersistence = function () {
2967
3226
  return this.assertedPersistence.persistence.type;
2968
3227
  };
@@ -3273,6 +3532,74 @@ var Subscription = /** @class */ (function () {
3273
3532
  return Subscription;
3274
3533
  }());
3275
3534
 
3535
+ /**
3536
+ * @license
3537
+ * Copyright 2020 Google LLC
3538
+ *
3539
+ * Licensed under the Apache License, Version 2.0 (the "License");
3540
+ * you may not use this file except in compliance with the License.
3541
+ * You may obtain a copy of the License at
3542
+ *
3543
+ * http://www.apache.org/licenses/LICENSE-2.0
3544
+ *
3545
+ * Unless required by applicable law or agreed to in writing, software
3546
+ * distributed under the License is distributed on an "AS IS" BASIS,
3547
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3548
+ * See the License for the specific language governing permissions and
3549
+ * limitations under the License.
3550
+ */
3551
+ /**
3552
+ * Initializes an {@link Auth} instance with fine-grained control over
3553
+ * {@link Dependencies}.
3554
+ *
3555
+ * @remarks
3556
+ *
3557
+ * This function allows more control over the {@link Auth} instance than
3558
+ * {@link getAuth}. `getAuth` uses platform-specific defaults to supply
3559
+ * the {@link Dependencies}. In general, `getAuth` is the easiest way to
3560
+ * initialize Auth and works for most use cases. Use `initializeAuth` if you
3561
+ * need control over which persistence layer is used, or to minimize bundle
3562
+ * size if you're not using either `signInWithPopup` or `signInWithRedirect`.
3563
+ *
3564
+ * For example, if your app only uses anonymous accounts and you only want
3565
+ * accounts saved for the current session, initialize `Auth` with:
3566
+ *
3567
+ * ```js
3568
+ * const auth = initializeAuth(app, {
3569
+ * persistence: browserSessionPersistence,
3570
+ * popupRedirectResolver: undefined,
3571
+ * });
3572
+ * ```
3573
+ *
3574
+ * @public
3575
+ */
3576
+ function initializeAuth(app$1, deps) {
3577
+ var provider = app._getProvider(app$1, 'auth');
3578
+ if (provider.isInitialized()) {
3579
+ var auth_1 = provider.getImmediate();
3580
+ var initialOptions = provider.getOptions();
3581
+ if (util.deepEqual(initialOptions, deps !== null && deps !== void 0 ? deps : {})) {
3582
+ return auth_1;
3583
+ }
3584
+ else {
3585
+ _fail(auth_1, "already-initialized" /* AuthErrorCode.ALREADY_INITIALIZED */);
3586
+ }
3587
+ }
3588
+ var auth = provider.initialize({ options: deps });
3589
+ return auth;
3590
+ }
3591
+ function _initializeAuthInstance(auth, deps) {
3592
+ var persistence = (deps === null || deps === void 0 ? void 0 : deps.persistence) || [];
3593
+ var hierarchy = (Array.isArray(persistence) ? persistence : [persistence]).map(_getInstance);
3594
+ if (deps === null || deps === void 0 ? void 0 : deps.errorMap) {
3595
+ auth._updateErrorMap(deps.errorMap);
3596
+ }
3597
+ // This promise is intended to float; auth initialization happens in the
3598
+ // background, meanwhile the auth object may be used by the app.
3599
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
3600
+ auth._initializeWithPersistence(hierarchy, deps === null || deps === void 0 ? void 0 : deps.popupRedirectResolver);
3601
+ }
3602
+
3276
3603
  /**
3277
3604
  * Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
3278
3605
  * Firebase Auth services.
@@ -3661,24 +3988,55 @@ var EmailAuthCredential = /** @class */ (function (_super) {
3661
3988
  };
3662
3989
  /** @internal */
3663
3990
  EmailAuthCredential.prototype._getIdTokenResponse = function (auth) {
3991
+ var _a;
3664
3992
  return tslib.__awaiter(this, void 0, void 0, function () {
3665
- return tslib.__generator(this, function (_a) {
3666
- switch (this.signInMethod) {
3667
- case "password" /* SignInMethod.EMAIL_PASSWORD */:
3668
- return [2 /*return*/, signInWithPassword(auth, {
3669
- returnSecureToken: true,
3670
- email: this._email,
3671
- password: this._password
3672
- })];
3673
- case "emailLink" /* SignInMethod.EMAIL_LINK */:
3674
- return [2 /*return*/, signInWithEmailLink$1(auth, {
3675
- email: this._email,
3676
- oobCode: this._password
3677
- })];
3678
- default:
3993
+ var _b, request_1, requestWithRecaptcha;
3994
+ var _this = this;
3995
+ return tslib.__generator(this, function (_c) {
3996
+ switch (_c.label) {
3997
+ case 0:
3998
+ _b = this.signInMethod;
3999
+ switch (_b) {
4000
+ case "password" /* SignInMethod.EMAIL_PASSWORD */: return [3 /*break*/, 1];
4001
+ case "emailLink" /* SignInMethod.EMAIL_LINK */: return [3 /*break*/, 4];
4002
+ }
4003
+ return [3 /*break*/, 5];
4004
+ case 1:
4005
+ request_1 = {
4006
+ returnSecureToken: true,
4007
+ email: this._email,
4008
+ password: this._password,
4009
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
4010
+ };
4011
+ if (!((_a = auth._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
4012
+ return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
4013
+ case 2:
4014
+ requestWithRecaptcha = _c.sent();
4015
+ return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
4016
+ case 3: return [2 /*return*/, signInWithPassword(auth, request_1).catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
4017
+ var requestWithRecaptcha;
4018
+ return tslib.__generator(this, function (_a) {
4019
+ switch (_a.label) {
4020
+ case 0:
4021
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
4022
+ 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.');
4023
+ return [4 /*yield*/, injectRecaptchaFields(auth, request_1, "signInWithPassword" /* RecaptchaActionName.SIGN_IN_WITH_PASSWORD */)];
4024
+ case 1:
4025
+ requestWithRecaptcha = _a.sent();
4026
+ return [2 /*return*/, signInWithPassword(auth, requestWithRecaptcha)];
4027
+ case 2: return [2 /*return*/, Promise.reject(error)];
4028
+ }
4029
+ });
4030
+ }); })];
4031
+ case 4: return [2 /*return*/, signInWithEmailLink$1(auth, {
4032
+ email: this._email,
4033
+ oobCode: this._password
4034
+ })];
4035
+ case 5:
3679
4036
  _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
4037
+ _c.label = 6;
4038
+ case 6: return [2 /*return*/];
3680
4039
  }
3681
- return [2 /*return*/];
3682
4040
  });
3683
4041
  });
3684
4042
  };
@@ -5858,23 +6216,61 @@ function _setActionCodeSettingsOnRequest(auth, request, actionCodeSettings) {
5858
6216
  * @public
5859
6217
  */
5860
6218
  function sendPasswordResetEmail(auth, email, actionCodeSettings) {
6219
+ var _a;
5861
6220
  return tslib.__awaiter(this, void 0, void 0, function () {
5862
- var authModular, request;
5863
- return tslib.__generator(this, function (_a) {
5864
- switch (_a.label) {
6221
+ var authInternal, request, requestWithRecaptcha;
6222
+ var _this = this;
6223
+ return tslib.__generator(this, function (_b) {
6224
+ switch (_b.label) {
5865
6225
  case 0:
5866
- authModular = util.getModularInstance(auth);
6226
+ authInternal = _castAuth(auth);
5867
6227
  request = {
5868
6228
  requestType: "PASSWORD_RESET" /* ActionCodeOperation.PASSWORD_RESET */,
5869
- email: email
6229
+ email: email,
6230
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
5870
6231
  };
6232
+ if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
6233
+ return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
6234
+ case 1:
6235
+ requestWithRecaptcha = _b.sent();
5871
6236
  if (actionCodeSettings) {
5872
- _setActionCodeSettingsOnRequest(authModular, request, actionCodeSettings);
6237
+ _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
5873
6238
  }
5874
- return [4 /*yield*/, sendPasswordResetEmail$1(authModular, request)];
5875
- case 1:
5876
- _a.sent();
5877
- return [2 /*return*/];
6239
+ return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
6240
+ case 2:
6241
+ _b.sent();
6242
+ return [3 /*break*/, 5];
6243
+ case 3:
6244
+ if (actionCodeSettings) {
6245
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
6246
+ }
6247
+ return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, request)
6248
+ .catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
6249
+ var requestWithRecaptcha;
6250
+ return tslib.__generator(this, function (_a) {
6251
+ switch (_a.label) {
6252
+ case 0:
6253
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
6254
+ console.log('Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.');
6255
+ return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
6256
+ case 1:
6257
+ requestWithRecaptcha = _a.sent();
6258
+ if (actionCodeSettings) {
6259
+ _setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
6260
+ }
6261
+ return [4 /*yield*/, sendPasswordResetEmail$1(authInternal, requestWithRecaptcha)];
6262
+ case 2:
6263
+ _a.sent();
6264
+ return [3 /*break*/, 4];
6265
+ case 3: return [2 /*return*/, Promise.reject(error)];
6266
+ case 4: return [2 /*return*/];
6267
+ }
6268
+ });
6269
+ }); })];
6270
+ case 4:
6271
+ _b.sent();
6272
+ _b.label = 5;
6273
+ case 5: return [2 /*return*/];
5878
6274
  }
5879
6275
  });
5880
6276
  });
@@ -6019,25 +6415,54 @@ function verifyPasswordResetCode(auth, code) {
6019
6415
  * @public
6020
6416
  */
6021
6417
  function createUserWithEmailAndPassword(auth, email, password) {
6418
+ var _a;
6022
6419
  return tslib.__awaiter(this, void 0, void 0, function () {
6023
- var authInternal, response, userCredential;
6024
- return tslib.__generator(this, function (_a) {
6025
- switch (_a.label) {
6420
+ var authInternal, request, signUpResponse, requestWithRecaptcha, response, userCredential;
6421
+ var _this = this;
6422
+ return tslib.__generator(this, function (_b) {
6423
+ switch (_b.label) {
6026
6424
  case 0:
6027
6425
  authInternal = _castAuth(auth);
6028
- return [4 /*yield*/, signUp(authInternal, {
6029
- returnSecureToken: true,
6030
- email: email,
6031
- password: password
6032
- })];
6426
+ request = {
6427
+ returnSecureToken: true,
6428
+ email: email,
6429
+ password: password,
6430
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
6431
+ };
6432
+ if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 2];
6433
+ return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
6033
6434
  case 1:
6034
- response = _a.sent();
6035
- return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
6435
+ requestWithRecaptcha = _b.sent();
6436
+ signUpResponse = signUp(authInternal, requestWithRecaptcha);
6437
+ return [3 /*break*/, 3];
6036
6438
  case 2:
6037
- userCredential = _a.sent();
6439
+ signUpResponse = signUp(authInternal, request).catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
6440
+ var requestWithRecaptcha;
6441
+ return tslib.__generator(this, function (_a) {
6442
+ switch (_a.label) {
6443
+ case 0:
6444
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 2];
6445
+ console.log('Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.');
6446
+ return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "signUpPassword" /* RecaptchaActionName.SIGN_UP_PASSWORD */)];
6447
+ case 1:
6448
+ requestWithRecaptcha = _a.sent();
6449
+ return [2 /*return*/, signUp(authInternal, requestWithRecaptcha)];
6450
+ case 2: return [2 /*return*/, Promise.reject(error)];
6451
+ }
6452
+ });
6453
+ }); });
6454
+ _b.label = 3;
6455
+ case 3: return [4 /*yield*/, signUpResponse.catch(function (error) {
6456
+ return Promise.reject(error);
6457
+ })];
6458
+ case 4:
6459
+ response = _b.sent();
6460
+ return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, "signIn" /* OperationType.SIGN_IN */, response)];
6461
+ case 5:
6462
+ userCredential = _b.sent();
6038
6463
  return [4 /*yield*/, authInternal._updateCurrentUser(userCredential.user)];
6039
- case 3:
6040
- _a.sent();
6464
+ case 6:
6465
+ _b.sent();
6041
6466
  return [2 /*return*/, userCredential];
6042
6467
  }
6043
6468
  });
@@ -6118,24 +6543,61 @@ function signInWithEmailAndPassword(auth, email, password) {
6118
6543
  * @public
6119
6544
  */
6120
6545
  function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
6546
+ var _a;
6121
6547
  return tslib.__awaiter(this, void 0, void 0, function () {
6122
- var authModular, request;
6123
- return tslib.__generator(this, function (_a) {
6124
- switch (_a.label) {
6548
+ function setActionCodeSettings(request, actionCodeSettings) {
6549
+ _assert(actionCodeSettings.handleCodeInApp, authInternal, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
6550
+ if (actionCodeSettings) {
6551
+ _setActionCodeSettingsOnRequest(authInternal, request, actionCodeSettings);
6552
+ }
6553
+ }
6554
+ var authInternal, request, requestWithRecaptcha;
6555
+ var _this = this;
6556
+ return tslib.__generator(this, function (_b) {
6557
+ switch (_b.label) {
6125
6558
  case 0:
6126
- authModular = util.getModularInstance(auth);
6559
+ authInternal = _castAuth(auth);
6127
6560
  request = {
6128
6561
  requestType: "EMAIL_SIGNIN" /* ActionCodeOperation.EMAIL_SIGNIN */,
6129
- email: email
6562
+ email: email,
6563
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
6130
6564
  };
6131
- _assert(actionCodeSettings.handleCodeInApp, authModular, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
6132
- if (actionCodeSettings) {
6133
- _setActionCodeSettingsOnRequest(authModular, request, actionCodeSettings);
6134
- }
6135
- return [4 /*yield*/, sendSignInLinkToEmail$1(authModular, request)];
6565
+ if (!((_a = authInternal._getRecaptchaConfig()) === null || _a === void 0 ? void 0 : _a.emailPasswordEnabled)) return [3 /*break*/, 3];
6566
+ return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
6136
6567
  case 1:
6137
- _a.sent();
6138
- return [2 /*return*/];
6568
+ requestWithRecaptcha = _b.sent();
6569
+ setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
6570
+ return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
6571
+ case 2:
6572
+ _b.sent();
6573
+ return [3 /*break*/, 5];
6574
+ case 3:
6575
+ setActionCodeSettings(request, actionCodeSettings);
6576
+ return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, request)
6577
+ .catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
6578
+ var requestWithRecaptcha;
6579
+ return tslib.__generator(this, function (_a) {
6580
+ switch (_a.label) {
6581
+ case 0:
6582
+ if (!(error.code === "auth/".concat("missing-recaptcha-token" /* AuthErrorCode.MISSING_RECAPTCHA_TOKEN */))) return [3 /*break*/, 3];
6583
+ console.log('Email link sign-in is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-in flow.');
6584
+ return [4 /*yield*/, injectRecaptchaFields(authInternal, request, "getOobCode" /* RecaptchaActionName.GET_OOB_CODE */, true)];
6585
+ case 1:
6586
+ requestWithRecaptcha = _a.sent();
6587
+ setActionCodeSettings(requestWithRecaptcha, actionCodeSettings);
6588
+ return [4 /*yield*/, sendSignInLinkToEmail$1(authInternal, requestWithRecaptcha)];
6589
+ case 2:
6590
+ _a.sent();
6591
+ return [3 /*break*/, 4];
6592
+ case 3: return [2 /*return*/, Promise.reject(error)];
6593
+ case 4: return [2 /*return*/];
6594
+ }
6595
+ });
6596
+ }); })];
6597
+ case 4:
6598
+ _b.sent();
6599
+ _b.label = 5;
6600
+ case 5: return [2 /*return*/];
6139
6601
  }
6140
6602
  });
6141
6603
  });
@@ -6731,6 +7193,35 @@ function getAdditionalUserInfo(userCredential) {
6731
7193
  function setPersistence(auth, persistence) {
6732
7194
  return util.getModularInstance(auth).setPersistence(persistence);
6733
7195
  }
7196
+ /**
7197
+ * Loads the reCAPTCHA configuration into the `Auth` instance.
7198
+ *
7199
+ * @remarks
7200
+ * This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
7201
+ * verification flow should be triggered for each auth provider, into the
7202
+ * current Auth session.
7203
+ *
7204
+ * If initializeRecaptchaConfig() is not invoked, the auth flow will always start
7205
+ * without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
7206
+ * verification, the SDK will transparently load the reCAPTCHA config and restart the
7207
+ * auth flows.
7208
+ *
7209
+ * Thus, by calling this optional method, you will reduce the latency of future auth flows.
7210
+ * Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
7211
+ *
7212
+ * @example
7213
+ * ```javascript
7214
+ * initializeRecaptchaConfig(auth);
7215
+ * ```
7216
+ *
7217
+ * @param auth - The {@link Auth} instance.
7218
+ *
7219
+ * @public
7220
+ */
7221
+ function initializeRecaptchaConfig(auth) {
7222
+ var authInternal = _castAuth(auth);
7223
+ return authInternal.initializeRecaptchaConfig();
7224
+ }
6734
7225
  /**
6735
7226
  * Adds an observer for changes to the signed-in user's ID token.
6736
7227
  *
@@ -7129,7 +7620,7 @@ function multiFactor(user) {
7129
7620
  }
7130
7621
 
7131
7622
  var name = "@firebase/auth";
7132
- var version = "0.22.0-canary.ea3849fff";
7623
+ var version = "0.22.0-canary.ecb4454c3";
7133
7624
 
7134
7625
  /**
7135
7626
  * @license
@@ -7663,6 +8154,7 @@ exports.getRedirectResult = getRedirectResult;
7663
8154
  exports.inMemoryPersistence = inMemoryPersistence;
7664
8155
  exports.indexedDBLocalPersistence = indexedDBLocalPersistence;
7665
8156
  exports.initializeAuth = initializeAuth;
8157
+ exports.initializeRecaptchaConfig = initializeRecaptchaConfig;
7666
8158
  exports.isSignInWithEmailLink = isSignInWithEmailLink;
7667
8159
  exports.linkWithCredential = linkWithCredential;
7668
8160
  exports.linkWithPhoneNumber = linkWithPhoneNumber;
@@ -7701,4 +8193,4 @@ exports.updateProfile = updateProfile;
7701
8193
  exports.useDeviceLanguage = useDeviceLanguage;
7702
8194
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
7703
8195
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
7704
- //# sourceMappingURL=totp-e4b57fc2.js.map
8196
+ //# sourceMappingURL=totp-b357b7fa.js.map