@firebase/auth 1.7.9 → 1.8.0

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 (435) hide show
  1. package/README.md +32 -1
  2. package/dist/auth-public.d.ts +22 -10
  3. package/dist/auth.d.ts +22 -10
  4. package/dist/browser-cjs/{index-e2e765e6.js → index-b60d3212.js} +393 -176
  5. package/dist/browser-cjs/index-b60d3212.js.map +1 -0
  6. package/dist/browser-cjs/index.js +1 -1
  7. package/dist/browser-cjs/internal.js +1 -1
  8. package/dist/browser-cjs/src/api/account_management/mfa.d.ts +5 -1
  9. package/dist/browser-cjs/src/api/authentication/mfa.d.ts +5 -1
  10. package/dist/browser-cjs/src/api/authentication/sms.d.ts +5 -1
  11. package/dist/browser-cjs/src/api/index.d.ts +7 -3
  12. package/dist/browser-cjs/src/platform_browser/providers/phone.d.ts +7 -5
  13. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  14. package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  15. package/dist/browser-cjs/src/platform_browser/strategies/phone.d.ts +10 -6
  16. package/dist/cordova/auth-cordova-public.d.ts +7 -0
  17. package/dist/cordova/auth-cordova.d.ts +7 -0
  18. package/dist/cordova/index.js +6 -7
  19. package/dist/cordova/index.js.map +1 -1
  20. package/dist/cordova/internal.js +660 -985
  21. package/dist/cordova/internal.js.map +1 -1
  22. package/dist/cordova/popup_redirect-6fcd583a.js +9635 -0
  23. package/dist/cordova/popup_redirect-6fcd583a.js.map +1 -0
  24. package/dist/cordova/src/api/account_management/mfa.d.ts +5 -1
  25. package/dist/cordova/src/api/authentication/mfa.d.ts +5 -1
  26. package/dist/cordova/src/api/authentication/sms.d.ts +5 -1
  27. package/dist/cordova/src/api/index.d.ts +7 -3
  28. package/dist/cordova/src/platform_browser/providers/phone.d.ts +7 -5
  29. package/dist/cordova/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  30. package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  31. package/dist/cordova/src/platform_browser/strategies/phone.d.ts +10 -6
  32. package/dist/{esm5/src/api/account_management/mfa.test.d.ts → cordova/test/integration/flows/recaptcha_enterprise.test.d.ts} +1 -1
  33. package/dist/esm2017/{index-68602d24.js → index-a7d5cfcc.js} +393 -176
  34. package/dist/esm2017/index-a7d5cfcc.js.map +1 -0
  35. package/dist/esm2017/index.js +1 -1
  36. package/dist/esm2017/internal.js +2 -2
  37. package/dist/esm2017/src/api/account_management/mfa.d.ts +5 -1
  38. package/dist/esm2017/src/api/authentication/mfa.d.ts +5 -1
  39. package/dist/esm2017/src/api/authentication/sms.d.ts +5 -1
  40. package/dist/esm2017/src/api/index.d.ts +7 -3
  41. package/dist/esm2017/src/platform_browser/providers/phone.d.ts +7 -5
  42. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  43. package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  44. package/dist/esm2017/src/platform_browser/strategies/phone.d.ts +10 -6
  45. package/dist/{esm5/src/api/account_management/email_and_password.test.d.ts → esm2017/test/integration/flows/recaptcha_enterprise.test.d.ts} +1 -1
  46. package/dist/index.webworker.js +7912 -0
  47. package/dist/index.webworker.js.map +1 -0
  48. package/dist/node/index.js +2 -3
  49. package/dist/node/index.js.map +1 -1
  50. package/dist/node/internal.js +555 -844
  51. package/dist/node/internal.js.map +1 -1
  52. package/dist/node/src/api/account_management/mfa.d.ts +5 -1
  53. package/dist/node/src/api/authentication/mfa.d.ts +5 -1
  54. package/dist/node/src/api/authentication/sms.d.ts +5 -1
  55. package/dist/node/src/api/index.d.ts +7 -3
  56. package/dist/node/src/platform_browser/providers/phone.d.ts +7 -5
  57. package/dist/node/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  58. package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  59. package/dist/node/src/platform_browser/strategies/phone.d.ts +10 -6
  60. package/dist/node/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  61. package/dist/node/totp-ab108bed.js +7582 -0
  62. package/dist/node/totp-ab108bed.js.map +1 -0
  63. package/dist/node-esm/index.js +1 -2
  64. package/dist/node-esm/index.js.map +1 -1
  65. package/dist/node-esm/internal.js +2 -3
  66. package/dist/node-esm/internal.js.map +1 -1
  67. package/dist/node-esm/src/api/account_management/mfa.d.ts +5 -1
  68. package/dist/node-esm/src/api/authentication/mfa.d.ts +5 -1
  69. package/dist/node-esm/src/api/authentication/sms.d.ts +5 -1
  70. package/dist/node-esm/src/api/index.d.ts +7 -3
  71. package/dist/node-esm/src/platform_browser/providers/phone.d.ts +7 -5
  72. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  73. package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  74. package/dist/node-esm/src/platform_browser/strategies/phone.d.ts +10 -6
  75. package/dist/{esm5/scripts/run_node_tests.d.ts → node-esm/test/integration/flows/recaptcha_enterprise.test.d.ts} +1 -1
  76. package/dist/node-esm/{totp-219bb96f.js → totp-f311e20a.js} +170 -33
  77. package/dist/node-esm/totp-f311e20a.js.map +1 -0
  78. package/dist/rn/index-4d73adbf.js +8575 -0
  79. package/dist/rn/index-4d73adbf.js.map +1 -0
  80. package/dist/rn/index.js +45 -55
  81. package/dist/rn/index.js.map +1 -1
  82. package/dist/rn/internal.js +1195 -1890
  83. package/dist/rn/internal.js.map +1 -1
  84. package/dist/rn/src/api/account_management/mfa.d.ts +5 -1
  85. package/dist/rn/src/api/authentication/mfa.d.ts +5 -1
  86. package/dist/rn/src/api/authentication/sms.d.ts +5 -1
  87. package/dist/rn/src/api/index.d.ts +7 -3
  88. package/dist/rn/src/platform_browser/providers/phone.d.ts +7 -5
  89. package/dist/rn/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  90. package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  91. package/dist/rn/src/platform_browser/strategies/phone.d.ts +10 -6
  92. package/dist/rn/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  93. package/dist/src/api/account_management/mfa.d.ts +5 -1
  94. package/dist/src/api/authentication/mfa.d.ts +5 -1
  95. package/dist/src/api/authentication/sms.d.ts +5 -1
  96. package/dist/src/api/index.d.ts +7 -3
  97. package/dist/src/platform_browser/providers/phone.d.ts +7 -5
  98. package/dist/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  99. package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  100. package/dist/src/platform_browser/strategies/phone.d.ts +10 -6
  101. package/dist/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  102. package/dist/web-extension-cjs/index.js +1 -1
  103. package/dist/web-extension-cjs/internal.js +115 -147
  104. package/dist/web-extension-cjs/internal.js.map +1 -1
  105. package/dist/web-extension-cjs/{register-674a8250.js → register-17c71bd5.js} +284 -31
  106. package/dist/web-extension-cjs/register-17c71bd5.js.map +1 -0
  107. package/dist/web-extension-cjs/src/api/account_management/mfa.d.ts +5 -1
  108. package/dist/web-extension-cjs/src/api/authentication/mfa.d.ts +5 -1
  109. package/dist/web-extension-cjs/src/api/authentication/sms.d.ts +5 -1
  110. package/dist/web-extension-cjs/src/api/index.d.ts +7 -3
  111. package/dist/web-extension-cjs/src/platform_browser/providers/phone.d.ts +7 -5
  112. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  113. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  114. package/dist/web-extension-cjs/src/platform_browser/strategies/phone.d.ts +10 -6
  115. package/dist/web-extension-cjs/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  116. package/dist/web-extension-esm2017/auth-web-extension-public.d.ts +7 -0
  117. package/dist/web-extension-esm2017/auth-web-extension.d.ts +7 -0
  118. package/dist/web-extension-esm2017/index.js +2 -2
  119. package/dist/web-extension-esm2017/internal.js +115 -147
  120. package/dist/web-extension-esm2017/internal.js.map +1 -1
  121. package/dist/web-extension-esm2017/{register-428f8789.js → register-77f1d56a.js} +281 -32
  122. package/dist/web-extension-esm2017/register-77f1d56a.js.map +1 -0
  123. package/dist/web-extension-esm2017/src/api/account_management/mfa.d.ts +5 -1
  124. package/dist/web-extension-esm2017/src/api/authentication/mfa.d.ts +5 -1
  125. package/dist/web-extension-esm2017/src/api/authentication/sms.d.ts +5 -1
  126. package/dist/web-extension-esm2017/src/api/index.d.ts +7 -3
  127. package/dist/web-extension-esm2017/src/platform_browser/providers/phone.d.ts +7 -5
  128. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +7 -0
  129. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +4 -4
  130. package/dist/web-extension-esm2017/src/platform_browser/strategies/phone.d.ts +10 -6
  131. package/dist/web-extension-esm2017/test/integration/flows/recaptcha_enterprise.test.d.ts +17 -0
  132. package/internal/package.json +5 -3
  133. package/package.json +10 -11
  134. package/dist/browser-cjs/index-e2e765e6.js.map +0 -1
  135. package/dist/cordova/popup_redirect-abcbab4c.js +0 -11249
  136. package/dist/cordova/popup_redirect-abcbab4c.js.map +0 -1
  137. package/dist/esm2017/index-68602d24.js.map +0 -1
  138. package/dist/esm5/index-c0803b14.js +0 -12741
  139. package/dist/esm5/index-c0803b14.js.map +0 -1
  140. package/dist/esm5/index.cordova.d.ts +0 -32
  141. package/dist/esm5/index.d.ts +0 -37
  142. package/dist/esm5/index.doc.d.ts +0 -24
  143. package/dist/esm5/index.js +0 -7
  144. package/dist/esm5/index.js.map +0 -1
  145. package/dist/esm5/index.node.d.ts +0 -17
  146. package/dist/esm5/index.rn.d.ts +0 -40
  147. package/dist/esm5/index.shared.d.ts +0 -19
  148. package/dist/esm5/index.web-extension.d.ts +0 -31
  149. package/dist/esm5/index.webworker.d.ts +0 -21
  150. package/dist/esm5/internal/index.d.ts +0 -42
  151. package/dist/esm5/internal.js +0 -682
  152. package/dist/esm5/internal.js.map +0 -1
  153. package/dist/esm5/src/api/account_management/account.d.ts +0 -59
  154. package/dist/esm5/src/api/account_management/account.test.d.ts +0 -17
  155. package/dist/esm5/src/api/account_management/email_and_password.d.ts +0 -49
  156. package/dist/esm5/src/api/account_management/mfa.d.ts +0 -103
  157. package/dist/esm5/src/api/account_management/profile.d.ts +0 -29
  158. package/dist/esm5/src/api/account_management/profile.test.d.ts +0 -17
  159. package/dist/esm5/src/api/authentication/create_auth_uri.d.ts +0 -26
  160. package/dist/esm5/src/api/authentication/create_auth_uri.test.d.ts +0 -17
  161. package/dist/esm5/src/api/authentication/custom_token.d.ts +0 -26
  162. package/dist/esm5/src/api/authentication/custom_token.test.d.ts +0 -17
  163. package/dist/esm5/src/api/authentication/email_and_password.d.ts +0 -85
  164. package/dist/esm5/src/api/authentication/email_and_password.test.d.ts +0 -17
  165. package/dist/esm5/src/api/authentication/email_link.d.ts +0 -32
  166. package/dist/esm5/src/api/authentication/email_link.test.d.ts +0 -17
  167. package/dist/esm5/src/api/authentication/idp.d.ts +0 -40
  168. package/dist/esm5/src/api/authentication/idp.test.d.ts +0 -17
  169. package/dist/esm5/src/api/authentication/mfa.d.ts +0 -69
  170. package/dist/esm5/src/api/authentication/mfa.test.d.ts +0 -17
  171. package/dist/esm5/src/api/authentication/recaptcha.d.ts +0 -34
  172. package/dist/esm5/src/api/authentication/recaptcha.test.d.ts +0 -17
  173. package/dist/esm5/src/api/authentication/sign_up.d.ts +0 -34
  174. package/dist/esm5/src/api/authentication/sign_up.test.d.ts +0 -17
  175. package/dist/esm5/src/api/authentication/sms.d.ts +0 -50
  176. package/dist/esm5/src/api/authentication/sms.test.d.ts +0 -17
  177. package/dist/esm5/src/api/authentication/token.d.ts +0 -37
  178. package/dist/esm5/src/api/authentication/token.test.d.ts +0 -17
  179. package/dist/esm5/src/api/errors.d.ts +0 -128
  180. package/dist/esm5/src/api/index.d.ts +0 -97
  181. package/dist/esm5/src/api/index.test.d.ts +0 -17
  182. package/dist/esm5/src/api/password_policy/get_password_policy.d.ts +0 -48
  183. package/dist/esm5/src/api/password_policy/get_password_policy.test.d.ts +0 -17
  184. package/dist/esm5/src/api/project_config/get_project_config.d.ts +0 -25
  185. package/dist/esm5/src/api/project_config/get_project_config.test.d.ts +0 -17
  186. package/dist/esm5/src/core/action_code_url.d.ts +0 -73
  187. package/dist/esm5/src/core/action_code_url.test.d.ts +0 -17
  188. package/dist/esm5/src/core/auth/auth_event_manager.d.ts +0 -34
  189. package/dist/esm5/src/core/auth/auth_event_manager.test.d.ts +0 -17
  190. package/dist/esm5/src/core/auth/auth_impl.d.ts +0 -130
  191. package/dist/esm5/src/core/auth/auth_impl.test.d.ts +0 -17
  192. package/dist/esm5/src/core/auth/emulator.d.ts +0 -42
  193. package/dist/esm5/src/core/auth/emulator.test.d.ts +0 -17
  194. package/dist/esm5/src/core/auth/firebase_internal.d.ts +0 -35
  195. package/dist/esm5/src/core/auth/firebase_internal.test.d.ts +0 -17
  196. package/dist/esm5/src/core/auth/initialize.d.ts +0 -46
  197. package/dist/esm5/src/core/auth/initialize.test.d.ts +0 -17
  198. package/dist/esm5/src/core/auth/middleware.d.ts +0 -25
  199. package/dist/esm5/src/core/auth/middleware.test.d.ts +0 -17
  200. package/dist/esm5/src/core/auth/password_policy_impl.d.ts +0 -59
  201. package/dist/esm5/src/core/auth/password_policy_impl.test.d.ts +0 -17
  202. package/dist/esm5/src/core/auth/register.d.ts +0 -23
  203. package/dist/esm5/src/core/credentials/auth_credential.d.ts +0 -75
  204. package/dist/esm5/src/core/credentials/email.d.ts +0 -60
  205. package/dist/esm5/src/core/credentials/email.test.d.ts +0 -17
  206. package/dist/esm5/src/core/credentials/index.d.ts +0 -23
  207. package/dist/esm5/src/core/credentials/oauth.d.ts +0 -81
  208. package/dist/esm5/src/core/credentials/oauth.test.d.ts +0 -17
  209. package/dist/esm5/src/core/credentials/phone.d.ts +0 -52
  210. package/dist/esm5/src/core/credentials/phone.test.d.ts +0 -17
  211. package/dist/esm5/src/core/credentials/saml.d.ts +0 -52
  212. package/dist/esm5/src/core/credentials/saml.test.d.ts +0 -17
  213. package/dist/esm5/src/core/errors.d.ts +0 -325
  214. package/dist/esm5/src/core/errors.test.d.ts +0 -17
  215. package/dist/esm5/src/core/index.d.ts +0 -230
  216. package/dist/esm5/src/core/persistence/in_memory.d.ts +0 -35
  217. package/dist/esm5/src/core/persistence/in_memory.test.d.ts +0 -17
  218. package/dist/esm5/src/core/persistence/index.d.ts +0 -41
  219. package/dist/esm5/src/core/persistence/persistence_user_manager.d.ts +0 -45
  220. package/dist/esm5/src/core/persistence/persistence_user_manager.test.d.ts +0 -17
  221. package/dist/esm5/src/core/providers/email.d.ts +0 -83
  222. package/dist/esm5/src/core/providers/email.test.d.ts +0 -17
  223. package/dist/esm5/src/core/providers/facebook.d.ts +0 -93
  224. package/dist/esm5/src/core/providers/facebook.test.d.ts +0 -17
  225. package/dist/esm5/src/core/providers/federated.d.ts +0 -64
  226. package/dist/esm5/src/core/providers/federated.test.d.ts +0 -17
  227. package/dist/esm5/src/core/providers/github.d.ts +0 -89
  228. package/dist/esm5/src/core/providers/github.test.d.ts +0 -17
  229. package/dist/esm5/src/core/providers/google.d.ts +0 -96
  230. package/dist/esm5/src/core/providers/google.test.d.ts +0 -17
  231. package/dist/esm5/src/core/providers/oauth.d.ts +0 -151
  232. package/dist/esm5/src/core/providers/oauth.test.d.ts +0 -17
  233. package/dist/esm5/src/core/providers/saml.d.ts +0 -62
  234. package/dist/esm5/src/core/providers/saml.test.d.ts +0 -17
  235. package/dist/esm5/src/core/providers/twitter.d.ts +0 -103
  236. package/dist/esm5/src/core/providers/twitter.test.d.ts +0 -17
  237. package/dist/esm5/src/core/strategies/abstract_popup_redirect_operation.d.ts +0 -44
  238. package/dist/esm5/src/core/strategies/abstract_popup_redirect_operation.test.d.ts +0 -17
  239. package/dist/esm5/src/core/strategies/action_code_settings.d.ts +0 -19
  240. package/dist/esm5/src/core/strategies/action_code_settings.test.d.ts +0 -17
  241. package/dist/esm5/src/core/strategies/anonymous.d.ts +0 -32
  242. package/dist/esm5/src/core/strategies/anonymous.test.d.ts +0 -17
  243. package/dist/esm5/src/core/strategies/credential.d.ts +0 -64
  244. package/dist/esm5/src/core/strategies/credential.test.d.ts +0 -17
  245. package/dist/esm5/src/core/strategies/custom_token.d.ts +0 -37
  246. package/dist/esm5/src/core/strategies/custom_token.test.d.ts +0 -17
  247. package/dist/esm5/src/core/strategies/email.d.ts +0 -104
  248. package/dist/esm5/src/core/strategies/email.test.d.ts +0 -17
  249. package/dist/esm5/src/core/strategies/email_and_password.d.ts +0 -139
  250. package/dist/esm5/src/core/strategies/email_and_password.test.d.ts +0 -17
  251. package/dist/esm5/src/core/strategies/email_link.d.ts +0 -107
  252. package/dist/esm5/src/core/strategies/email_link.test.d.ts +0 -17
  253. package/dist/esm5/src/core/strategies/idp.d.ts +0 -32
  254. package/dist/esm5/src/core/strategies/idp.test.d.ts +0 -17
  255. package/dist/esm5/src/core/strategies/redirect.d.ts +0 -36
  256. package/dist/esm5/src/core/strategies/redirect.test.d.ts +0 -17
  257. package/dist/esm5/src/core/user/account_info.d.ts +0 -68
  258. package/dist/esm5/src/core/user/account_info.test.d.ts +0 -17
  259. package/dist/esm5/src/core/user/additional_user_info.d.ts +0 -31
  260. package/dist/esm5/src/core/user/additional_user_info.test.d.ts +0 -17
  261. package/dist/esm5/src/core/user/id_token_result.d.ts +0 -48
  262. package/dist/esm5/src/core/user/id_token_result.test.d.ts +0 -17
  263. package/dist/esm5/src/core/user/invalidation.d.ts +0 -18
  264. package/dist/esm5/src/core/user/invalidation.test.d.ts +0 -17
  265. package/dist/esm5/src/core/user/link_unlink.d.ts +0 -30
  266. package/dist/esm5/src/core/user/link_unlink.test.d.ts +0 -17
  267. package/dist/esm5/src/core/user/proactive_refresh.d.ts +0 -34
  268. package/dist/esm5/src/core/user/proactive_refresh.test.d.ts +0 -17
  269. package/dist/esm5/src/core/user/reauthenticate.d.ts +0 -20
  270. package/dist/esm5/src/core/user/reauthenticate.test.d.ts +0 -17
  271. package/dist/esm5/src/core/user/reload.d.ts +0 -29
  272. package/dist/esm5/src/core/user/reload.test.d.ts +0 -17
  273. package/dist/esm5/src/core/user/token_manager.d.ts +0 -50
  274. package/dist/esm5/src/core/user/token_manager.test.d.ts +0 -17
  275. package/dist/esm5/src/core/user/user_credential_impl.d.ts +0 -37
  276. package/dist/esm5/src/core/user/user_credential_impl.test.d.ts +0 -17
  277. package/dist/esm5/src/core/user/user_impl.d.ts +0 -74
  278. package/dist/esm5/src/core/user/user_impl.test.d.ts +0 -17
  279. package/dist/esm5/src/core/user/user_metadata.d.ts +0 -27
  280. package/dist/esm5/src/core/util/assert.d.ts +0 -94
  281. package/dist/esm5/src/core/util/assert.test.d.ts +0 -17
  282. package/dist/esm5/src/core/util/browser.d.ts +0 -50
  283. package/dist/esm5/src/core/util/browser.test.d.ts +0 -17
  284. package/dist/esm5/src/core/util/delay.d.ts +0 -31
  285. package/dist/esm5/src/core/util/delay.test.d.ts +0 -17
  286. package/dist/esm5/src/core/util/emulator.d.ts +0 -18
  287. package/dist/esm5/src/core/util/emulator.test.d.ts +0 -17
  288. package/dist/esm5/src/core/util/event_id.d.ts +0 -17
  289. package/dist/esm5/src/core/util/event_id.test.d.ts +0 -17
  290. package/dist/esm5/src/core/util/fetch_provider.d.ts +0 -25
  291. package/dist/esm5/src/core/util/handler.d.ts +0 -20
  292. package/dist/esm5/src/core/util/instantiator.d.ts +0 -28
  293. package/dist/esm5/src/core/util/instantiator.test.d.ts +0 -17
  294. package/dist/esm5/src/core/util/location.d.ts +0 -19
  295. package/dist/esm5/src/core/util/log.d.ts +0 -23
  296. package/dist/esm5/src/core/util/navigator.d.ts +0 -21
  297. package/dist/esm5/src/core/util/providers.d.ts +0 -23
  298. package/dist/esm5/src/core/util/resolver.d.ts +0 -25
  299. package/dist/esm5/src/core/util/time.d.ts +0 -17
  300. package/dist/esm5/src/core/util/validate_origin.d.ts +0 -18
  301. package/dist/esm5/src/core/util/validate_origin.test.d.ts +0 -17
  302. package/dist/esm5/src/core/util/version.d.ts +0 -31
  303. package/dist/esm5/src/core/util/version.test.d.ts +0 -17
  304. package/dist/esm5/src/index.d.ts +0 -18
  305. package/dist/esm5/src/mfa/assertions/totp.d.ts +0 -124
  306. package/dist/esm5/src/mfa/assertions/totp.test.d.ts +0 -17
  307. package/dist/esm5/src/mfa/index.d.ts +0 -18
  308. package/dist/esm5/src/mfa/mfa_assertion.d.ts +0 -27
  309. package/dist/esm5/src/mfa/mfa_error.d.ts +0 -35
  310. package/dist/esm5/src/mfa/mfa_info.d.ts +0 -36
  311. package/dist/esm5/src/mfa/mfa_info.test.d.ts +0 -17
  312. package/dist/esm5/src/mfa/mfa_resolver.d.ts +0 -41
  313. package/dist/esm5/src/mfa/mfa_resolver.test.d.ts +0 -17
  314. package/dist/esm5/src/mfa/mfa_session.d.ts +0 -39
  315. package/dist/esm5/src/mfa/mfa_session.test.d.ts +0 -17
  316. package/dist/esm5/src/mfa/mfa_user.d.ts +0 -38
  317. package/dist/esm5/src/mfa/mfa_user.test.d.ts +0 -17
  318. package/dist/esm5/src/model/application_verifier.d.ts +0 -23
  319. package/dist/esm5/src/model/auth.d.ts +0 -87
  320. package/dist/esm5/src/model/enum_maps.d.ts +0 -98
  321. package/dist/esm5/src/model/enums.d.ts +0 -74
  322. package/dist/esm5/src/model/id_token.d.ts +0 -87
  323. package/dist/esm5/src/model/password_policy.d.ts +0 -111
  324. package/dist/esm5/src/model/popup_redirect.d.ts +0 -94
  325. package/dist/esm5/src/model/public_types.d.ts +0 -1285
  326. package/dist/esm5/src/model/user.d.ts +0 -83
  327. package/dist/esm5/src/platform_browser/auth.test.d.ts +0 -17
  328. package/dist/esm5/src/platform_browser/auth_window.d.ts +0 -37
  329. package/dist/esm5/src/platform_browser/iframe/gapi.d.ts +0 -19
  330. package/dist/esm5/src/platform_browser/iframe/gapi.iframes.d.ts +0 -47
  331. package/dist/esm5/src/platform_browser/iframe/gapi.test.d.ts +0 -17
  332. package/dist/esm5/src/platform_browser/iframe/iframe.d.ts +0 -18
  333. package/dist/esm5/src/platform_browser/iframe/iframe.test.d.ts +0 -17
  334. package/dist/esm5/src/platform_browser/index.d.ts +0 -27
  335. package/dist/esm5/src/platform_browser/load_js.d.ts +0 -29
  336. package/dist/esm5/src/platform_browser/load_js.test.d.ts +0 -17
  337. package/dist/esm5/src/platform_browser/messagechannel/index.d.ts +0 -87
  338. package/dist/esm5/src/platform_browser/messagechannel/promise.d.ts +0 -33
  339. package/dist/esm5/src/platform_browser/messagechannel/promise.test.d.ts +0 -17
  340. package/dist/esm5/src/platform_browser/messagechannel/receiver.d.ts +0 -63
  341. package/dist/esm5/src/platform_browser/messagechannel/receiver.test.d.ts +0 -17
  342. package/dist/esm5/src/platform_browser/messagechannel/sender.d.ts +0 -46
  343. package/dist/esm5/src/platform_browser/messagechannel/sender.test.d.ts +0 -17
  344. package/dist/esm5/src/platform_browser/mfa/assertions/phone.d.ts +0 -59
  345. package/dist/esm5/src/platform_browser/mfa/assertions/phone.test.d.ts +0 -17
  346. package/dist/esm5/src/platform_browser/persistence/browser.d.ts +0 -27
  347. package/dist/esm5/src/platform_browser/persistence/browser.test.d.ts +0 -17
  348. package/dist/esm5/src/platform_browser/persistence/indexed_db.d.ts +0 -33
  349. package/dist/esm5/src/platform_browser/persistence/indexed_db.test.d.ts +0 -17
  350. package/dist/esm5/src/platform_browser/persistence/local_storage.d.ts +0 -25
  351. package/dist/esm5/src/platform_browser/persistence/local_storage.test.d.ts +0 -17
  352. package/dist/esm5/src/platform_browser/persistence/session_storage.d.ts +0 -24
  353. package/dist/esm5/src/platform_browser/persistence/session_storage.test.d.ts +0 -17
  354. package/dist/esm5/src/platform_browser/popup_redirect.d.ts +0 -27
  355. package/dist/esm5/src/platform_browser/popup_redirect.test.d.ts +0 -17
  356. package/dist/esm5/src/platform_browser/providers/phone.d.ts +0 -152
  357. package/dist/esm5/src/platform_browser/providers/phone.test.d.ts +0 -17
  358. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.d.ts +0 -71
  359. package/dist/esm5/src/platform_browser/recaptcha/recaptcha.test.d.ts +0 -17
  360. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +0 -45
  361. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +0 -17
  362. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_loader.d.ts +0 -49
  363. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_loader.test.d.ts +0 -17
  364. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_mock.d.ts +0 -66
  365. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_mock.test.d.ts +0 -17
  366. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_verifier.d.ts +0 -92
  367. package/dist/esm5/src/platform_browser/recaptcha/recaptcha_verifier.test.d.ts +0 -17
  368. package/dist/esm5/src/platform_browser/strategies/phone.d.ts +0 -112
  369. package/dist/esm5/src/platform_browser/strategies/phone.test.d.ts +0 -17
  370. package/dist/esm5/src/platform_browser/strategies/popup.d.ts +0 -109
  371. package/dist/esm5/src/platform_browser/strategies/popup.test.d.ts +0 -17
  372. package/dist/esm5/src/platform_browser/strategies/redirect.d.ts +0 -176
  373. package/dist/esm5/src/platform_browser/strategies/redirect.test.d.ts +0 -17
  374. package/dist/esm5/src/platform_browser/util/popup.d.ts +0 -24
  375. package/dist/esm5/src/platform_browser/util/popup.test.d.ts +0 -17
  376. package/dist/esm5/src/platform_browser/util/worker.d.ts +0 -20
  377. package/dist/esm5/src/platform_cordova/plugins.d.ts +0 -42
  378. package/dist/esm5/src/platform_cordova/popup_redirect/events.d.ts +0 -39
  379. package/dist/esm5/src/platform_cordova/popup_redirect/events.test.d.ts +0 -17
  380. package/dist/esm5/src/platform_cordova/popup_redirect/popup_redirect.d.ts +0 -24
  381. package/dist/esm5/src/platform_cordova/popup_redirect/popup_redirect.test.d.ts +0 -17
  382. package/dist/esm5/src/platform_cordova/popup_redirect/utils.d.ts +0 -47
  383. package/dist/esm5/src/platform_cordova/popup_redirect/utils.test.d.ts +0 -17
  384. package/dist/esm5/src/platform_cordova/strategies/redirect.d.ts +0 -20
  385. package/dist/esm5/src/platform_node/index.d.ts +0 -50
  386. package/dist/esm5/src/platform_react_native/persistence/react_native.d.ts +0 -25
  387. package/dist/esm5/src/platform_react_native/persistence/react_native.test.d.ts +0 -17
  388. package/dist/esm5/test/helpers/api/helper.d.ts +0 -22
  389. package/dist/esm5/test/helpers/delay.d.ts +0 -20
  390. package/dist/esm5/test/helpers/erroring_unavailable_persistence.d.ts +0 -36
  391. package/dist/esm5/test/helpers/fake_service_worker.d.ts +0 -22
  392. package/dist/esm5/test/helpers/id_token_response.d.ts +0 -18
  393. package/dist/esm5/test/helpers/iframe_event.d.ts +0 -19
  394. package/dist/esm5/test/helpers/integration/emulator_rest_helpers.d.ts +0 -35
  395. package/dist/esm5/test/helpers/integration/helpers.d.ts +0 -32
  396. package/dist/esm5/test/helpers/integration/settings.d.ts +0 -23
  397. package/dist/esm5/test/helpers/jwt.d.ts +0 -17
  398. package/dist/esm5/test/helpers/mock_auth.d.ts +0 -47
  399. package/dist/esm5/test/helpers/mock_auth_credential.d.ts +0 -31
  400. package/dist/esm5/test/helpers/mock_fetch.d.ts +0 -30
  401. package/dist/esm5/test/helpers/mock_fetch.test.d.ts +0 -17
  402. package/dist/esm5/test/helpers/mock_popup_redirect_resolver.d.ts +0 -24
  403. package/dist/esm5/test/helpers/redirect_persistence.d.ts +0 -24
  404. package/dist/esm5/test/helpers/timeout_stub.d.ts +0 -34
  405. package/dist/esm5/test/integration/flows/anonymous.test.d.ts +0 -17
  406. package/dist/esm5/test/integration/flows/custom.local.test.d.ts +0 -17
  407. package/dist/esm5/test/integration/flows/email.test.d.ts +0 -17
  408. package/dist/esm5/test/integration/flows/idp.local.test.d.ts +0 -17
  409. package/dist/esm5/test/integration/flows/middleware_test_generator.d.ts +0 -18
  410. package/dist/esm5/test/integration/flows/oob.local.test.d.ts +0 -17
  411. package/dist/esm5/test/integration/flows/password_policy.test.d.ts +0 -17
  412. package/dist/esm5/test/integration/flows/phone.test.d.ts +0 -17
  413. package/dist/esm5/test/integration/flows/totp.test.d.ts +0 -17
  414. package/dist/esm5/test/integration/webdriver/anonymous.test.d.ts +0 -17
  415. package/dist/esm5/test/integration/webdriver/compat/firebaseui.test.d.ts +0 -17
  416. package/dist/esm5/test/integration/webdriver/persistence.test.d.ts +0 -17
  417. package/dist/esm5/test/integration/webdriver/popup.test.d.ts +0 -17
  418. package/dist/esm5/test/integration/webdriver/redirect.test.d.ts +0 -17
  419. package/dist/esm5/test/integration/webdriver/util/auth_driver.d.ts +0 -46
  420. package/dist/esm5/test/integration/webdriver/util/functions.d.ts +0 -81
  421. package/dist/esm5/test/integration/webdriver/util/idp_page.d.ts +0 -31
  422. package/dist/esm5/test/integration/webdriver/util/js_load_condition.d.ts +0 -25
  423. package/dist/esm5/test/integration/webdriver/util/test_runner.d.ts +0 -19
  424. package/dist/esm5/test/integration/webdriver/util/test_server.d.ts +0 -27
  425. package/dist/esm5/test/integration/webdriver/util/ui_page.d.ts +0 -33
  426. package/dist/index.webworker.esm5.js +0 -9265
  427. package/dist/index.webworker.esm5.js.map +0 -1
  428. package/dist/node/totp-259483a2.js +0 -8762
  429. package/dist/node/totp-259483a2.js.map +0 -1
  430. package/dist/node-esm/totp-219bb96f.js.map +0 -1
  431. package/dist/rn/index-2f66320e.js +0 -9819
  432. package/dist/rn/index-2f66320e.js.map +0 -1
  433. package/dist/web-extension-cjs/register-674a8250.js.map +0 -1
  434. package/dist/web-extension-esm2017/register-428f8789.js.map +0 -1
  435. /package/dist/{esm5/test/integration/flows/firebaseserverapp.test.d.ts → browser-cjs/test/integration/flows/recaptcha_enterprise.test.d.ts} +0 -0
@@ -1,8 +1,8 @@
1
- import { ai as _performApiRequest, aj as _addTidIfNecessary, ak as _assert, al as Delay, am as _window, an as isV2, ao as _createError, ap as _recaptchaV2ScriptUrl, aq as _loadJS, ar as _generateCallbackName, as as getRecaptchaParams, at as _isHttpOrHttps, au as _isWorker, av as _castAuth, M as signInWithCredential, aw as _serverAppCurrentUserOperationNotSupportedError, N as linkWithCredential, ax as _assertLinkedStatus, Q as reauthenticateWithCredential, ay as sendPhoneVerificationCode, az as startEnrollPhoneMfa, aA as _link, B as PhoneAuthCredential, aB as debugAssert, aC as _generateEventId, aD as AbstractPopupRedirectOperation, aE as _assertInstanceOf, aF as _withDefaultResolver, aG as FederatedAuthProvider, aH as _fail, aI as _getProjectConfig, aJ as _getCurrentUrl, aK as _gapiScriptUrl, aL as _emulatorUrl, aM as _isChromeIOS, aN as _isFirefox, aO as _isIOSStandalone, aP as _getRedirectUrl, aQ as _setWindowLocation, aR as _isMobileBrowser, aS as _isSafari, aT as _isIOS, f as browserSessionPersistence, aU as _getRedirectResult, aV as _overrideRedirectResult, aW as AuthEventManager, aX as debugFail, aY as finalizeEnrollPhoneMfa, aZ as finalizeEnrollTotpMfa, a_ as startEnrollTotpMfa, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, e as browserLocalPersistence, j as beforeAuthStateChanged, o as onIdTokenChanged, x as connectAuthEmulator, a$ as _setExternalJSProvider } from './popup_redirect-abcbab4c.js';
2
- export { A as ActionCodeOperation, a6 as ActionCodeURL, y as AuthCredential, w as AuthErrorCodes, b3 as AuthImpl, E as EmailAuthCredential, D as EmailAuthProvider, G as FacebookAuthProvider, F as FactorId, b5 as FetchProvider, I as GithubAuthProvider, H as GoogleAuthProvider, z as OAuthCredential, J as OAuthProvider, O as OperationType, B as PhoneAuthCredential, P as ProviderId, b6 as SAMLAuthCredential, K as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, b1 as UserImpl, ak as _assert, av as _castAuth, aH as _fail, aC as _generateEventId, b4 as _getClientVersion, b2 as _getInstance, aU as _getRedirectResult, aV as _overrideRedirectResult, b0 as _persistenceKeyName, W as applyActionCode, j as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, X as checkActionCode, V as confirmPasswordReset, x as connectAuthEmulator, d as cordovaPopupRedirectResolver, Z as createUserWithEmailAndPassword, q as debugErrorMap, p as deleteUser, a3 as fetchSignInMethodsForEmail, ae as getAdditionalUserInfo, ab as getIdToken, ac as getIdTokenResult, ag as getMultiFactorResolver, g as getRedirectResult, C as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, h as initializeRecaptchaConfig, a1 as isSignInWithEmailLink, N as linkWithCredential, b8 as linkWithRedirect, ah as multiFactor, k as onAuthStateChanged, o as onIdTokenChanged, a7 as parseActionCodeURL, t as prodErrorMap, Q as reauthenticateWithCredential, b9 as reauthenticateWithRedirect, af as reload, n as revokeAccessToken, a4 as sendEmailVerification, U as sendPasswordResetEmail, a0 as sendSignInLinkToEmail, s as setPersistence, L as signInAnonymously, M as signInWithCredential, R as signInWithCustomToken, $ as signInWithEmailAndPassword, a2 as signInWithEmailLink, b7 as signInWithRedirect, m as signOut, ad as unlink, l as updateCurrentUser, a9 as updateEmail, aa as updatePassword, a8 as updateProfile, u as useDeviceLanguage, v as validatePassword, a5 as verifyBeforeUpdateEmail, Y as verifyPasswordResetCode } from './popup_redirect-abcbab4c.js';
3
- import { __awaiter, __generator, __assign, __extends, __spreadArray } from 'tslib';
1
+ import { ai as _performApiRequest, aj as _addTidIfNecessary, ak as Delay, al as _window, am as _assert, an as isV2, ao as _createError, ap as _recaptchaV2ScriptUrl, aq as _loadJS, ar as MockReCaptcha, as as _generateCallbackName, at as _castAuth, au as _isHttpOrHttps, av as _isWorker, aw as getRecaptchaParams, ax as _serverAppCurrentUserOperationNotSupportedError, M as signInWithCredential, ay as _assertLinkedStatus, N as linkWithCredential, Q as reauthenticateWithCredential, az as _initializeRecaptchaConfig, aA as FAKE_TOKEN, aB as startEnrollPhoneMfa, aC as handleRecaptchaFlow, aD as sendPhoneVerificationCode, aE as _link, B as PhoneAuthCredential, aF as _assertInstanceOf, aG as _withDefaultResolver, aH as AbstractPopupRedirectOperation, aI as debugAssert, aJ as _generateEventId, aK as FederatedAuthProvider, aL as _getProjectConfig, aM as _fail, aN as _getCurrentUrl, aO as _gapiScriptUrl, aP as _emulatorUrl, aQ as _isChromeIOS, aR as _isFirefox, aS as _isIOSStandalone, f as browserSessionPersistence, aT as _getRedirectResult, aU as _overrideRedirectResult, aV as _getRedirectUrl, aW as _setWindowLocation, aX as _isMobileBrowser, aY as _isSafari, aZ as _isIOS, a_ as AuthEventManager, a$ as debugFail, b0 as finalizeEnrollPhoneMfa, b1 as startEnrollTotpMfa, b2 as finalizeEnrollTotpMfa, r as registerAuth, i as initializeAuth, c as indexedDBLocalPersistence, e as browserLocalPersistence, j as beforeAuthStateChanged, o as onIdTokenChanged, x as connectAuthEmulator, b3 as _setExternalJSProvider } from './popup_redirect-6fcd583a.js';
2
+ export { A as ActionCodeOperation, a6 as ActionCodeURL, y as AuthCredential, w as AuthErrorCodes, b7 as AuthImpl, E as EmailAuthCredential, D as EmailAuthProvider, G as FacebookAuthProvider, F as FactorId, b9 as FetchProvider, I as GithubAuthProvider, H as GoogleAuthProvider, z as OAuthCredential, J as OAuthProvider, O as OperationType, B as PhoneAuthCredential, P as ProviderId, ba as SAMLAuthCredential, K as SAMLAuthProvider, S as SignInMethod, T as TwitterAuthProvider, b5 as UserImpl, am as _assert, at as _castAuth, aM as _fail, aJ as _generateEventId, b8 as _getClientVersion, b6 as _getInstance, aT as _getRedirectResult, aU as _overrideRedirectResult, b4 as _persistenceKeyName, W as applyActionCode, j as beforeAuthStateChanged, e as browserLocalPersistence, f as browserSessionPersistence, X as checkActionCode, V as confirmPasswordReset, x as connectAuthEmulator, d as cordovaPopupRedirectResolver, Z as createUserWithEmailAndPassword, q as debugErrorMap, p as deleteUser, a3 as fetchSignInMethodsForEmail, ae as getAdditionalUserInfo, ab as getIdToken, ac as getIdTokenResult, ag as getMultiFactorResolver, g as getRedirectResult, C as inMemoryPersistence, c as indexedDBLocalPersistence, i as initializeAuth, h as initializeRecaptchaConfig, a1 as isSignInWithEmailLink, N as linkWithCredential, bc as linkWithRedirect, ah as multiFactor, k as onAuthStateChanged, o as onIdTokenChanged, a7 as parseActionCodeURL, t as prodErrorMap, Q as reauthenticateWithCredential, bd as reauthenticateWithRedirect, af as reload, n as revokeAccessToken, a4 as sendEmailVerification, U as sendPasswordResetEmail, a0 as sendSignInLinkToEmail, s as setPersistence, L as signInAnonymously, M as signInWithCredential, R as signInWithCustomToken, $ as signInWithEmailAndPassword, a2 as signInWithEmailLink, bb as signInWithRedirect, m as signOut, ad as unlink, l as updateCurrentUser, a9 as updateEmail, aa as updatePassword, a8 as updateProfile, u as useDeviceLanguage, v as validatePassword, a5 as verifyBeforeUpdateEmail, Y as verifyPasswordResetCode } from './popup_redirect-6fcd583a.js';
4
3
  import { querystring, getModularInstance, getUA, getExperimentalSetting, getDefaultEmulatorHost } from '@firebase/util';
5
- import { _isFirebaseServerApp, SDK_VERSION, getApp, _getProvider } from '@firebase/app';
4
+ import { _isFirebaseServerApp, SDK_VERSION, _getProvider, getApp } from '@firebase/app';
5
+ import 'tslib';
6
6
  import '@firebase/component';
7
7
  import '@firebase/logger';
8
8
 
@@ -32,143 +32,6 @@ function finalizeSignInTotpMfa(auth, request) {
32
32
  return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
33
33
  }
34
34
 
35
- /**
36
- * @license
37
- * Copyright 2020 Google LLC
38
- *
39
- * Licensed under the Apache License, Version 2.0 (the "License");
40
- * you may not use this file except in compliance with the License.
41
- * You may obtain a copy of the License at
42
- *
43
- * http://www.apache.org/licenses/LICENSE-2.0
44
- *
45
- * Unless required by applicable law or agreed to in writing, software
46
- * distributed under the License is distributed on an "AS IS" BASIS,
47
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
- * See the License for the specific language governing permissions and
49
- * limitations under the License.
50
- */
51
- var _SOLVE_TIME_MS = 500;
52
- var _EXPIRATION_TIME_MS = 60000;
53
- var _WIDGET_ID_START = 1000000000000;
54
- var MockReCaptcha = /** @class */ (function () {
55
- function MockReCaptcha(auth) {
56
- this.auth = auth;
57
- this.counter = _WIDGET_ID_START;
58
- this._widgets = new Map();
59
- }
60
- MockReCaptcha.prototype.render = function (container, parameters) {
61
- var id = this.counter;
62
- this._widgets.set(id, new MockWidget(container, this.auth.name, parameters || {}));
63
- this.counter++;
64
- return id;
65
- };
66
- MockReCaptcha.prototype.reset = function (optWidgetId) {
67
- var _a;
68
- var id = optWidgetId || _WIDGET_ID_START;
69
- void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.delete());
70
- this._widgets.delete(id);
71
- };
72
- MockReCaptcha.prototype.getResponse = function (optWidgetId) {
73
- var _a;
74
- var id = optWidgetId || _WIDGET_ID_START;
75
- return ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.getResponse()) || '';
76
- };
77
- MockReCaptcha.prototype.execute = function (optWidgetId) {
78
- var _a;
79
- return __awaiter(this, void 0, void 0, function () {
80
- var id;
81
- return __generator(this, function (_b) {
82
- id = optWidgetId || _WIDGET_ID_START;
83
- void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.execute());
84
- return [2 /*return*/, ''];
85
- });
86
- });
87
- };
88
- return MockReCaptcha;
89
- }());
90
- var MockWidget = /** @class */ (function () {
91
- function MockWidget(containerOrId, appName, params) {
92
- var _this = this;
93
- this.params = params;
94
- this.timerId = null;
95
- this.deleted = false;
96
- this.responseToken = null;
97
- this.clickHandler = function () {
98
- _this.execute();
99
- };
100
- var container = typeof containerOrId === 'string'
101
- ? document.getElementById(containerOrId)
102
- : containerOrId;
103
- _assert(container, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, { appName: appName });
104
- this.container = container;
105
- this.isVisible = this.params.size !== 'invisible';
106
- if (this.isVisible) {
107
- this.execute();
108
- }
109
- else {
110
- this.container.addEventListener('click', this.clickHandler);
111
- }
112
- }
113
- MockWidget.prototype.getResponse = function () {
114
- this.checkIfDeleted();
115
- return this.responseToken;
116
- };
117
- MockWidget.prototype.delete = function () {
118
- this.checkIfDeleted();
119
- this.deleted = true;
120
- if (this.timerId) {
121
- clearTimeout(this.timerId);
122
- this.timerId = null;
123
- }
124
- this.container.removeEventListener('click', this.clickHandler);
125
- };
126
- MockWidget.prototype.execute = function () {
127
- var _this = this;
128
- this.checkIfDeleted();
129
- if (this.timerId) {
130
- return;
131
- }
132
- this.timerId = window.setTimeout(function () {
133
- _this.responseToken = generateRandomAlphaNumericString(50);
134
- var _a = _this.params, callback = _a.callback, expiredCallback = _a["expired-callback"];
135
- if (callback) {
136
- try {
137
- callback(_this.responseToken);
138
- }
139
- catch (e) { }
140
- }
141
- _this.timerId = window.setTimeout(function () {
142
- _this.timerId = null;
143
- _this.responseToken = null;
144
- if (expiredCallback) {
145
- try {
146
- expiredCallback();
147
- }
148
- catch (e) { }
149
- }
150
- if (_this.isVisible) {
151
- _this.execute();
152
- }
153
- }, _EXPIRATION_TIME_MS);
154
- }, _SOLVE_TIME_MS);
155
- };
156
- MockWidget.prototype.checkIfDeleted = function () {
157
- if (this.deleted) {
158
- throw new Error('reCAPTCHA mock was already deleted!');
159
- }
160
- };
161
- return MockWidget;
162
- }());
163
- function generateRandomAlphaNumericString(len) {
164
- var chars = [];
165
- var allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
166
- for (var i = 0; i < len; i++) {
167
- chars.push(allowedChars.charAt(Math.floor(Math.random() * allowedChars.length)));
168
- }
169
- return chars.join('');
170
- }
171
-
172
35
  /**
173
36
  * @license
174
37
  * Copyright 2020 Google LLC
@@ -187,13 +50,13 @@ function generateRandomAlphaNumericString(len) {
187
50
  */
188
51
  // ReCaptcha will load using the same callback, so the callback function needs
189
52
  // to be kept around
190
- var _JSLOAD_CALLBACK = _generateCallbackName('rcb');
191
- var NETWORK_TIMEOUT_DELAY = new Delay(30000, 60000);
53
+ const _JSLOAD_CALLBACK = _generateCallbackName('rcb');
54
+ const NETWORK_TIMEOUT_DELAY = new Delay(30000, 60000);
192
55
  /**
193
56
  * Loader for the GReCaptcha library. There should only ever be one of this.
194
57
  */
195
- var ReCaptchaLoaderImpl = /** @class */ (function () {
196
- function ReCaptchaLoaderImpl() {
58
+ class ReCaptchaLoaderImpl {
59
+ constructor() {
197
60
  var _a;
198
61
  this.hostLanguage = '';
199
62
  this.counter = 0;
@@ -204,51 +67,49 @@ var ReCaptchaLoaderImpl = /** @class */ (function () {
204
67
  */
205
68
  this.librarySeparatelyLoaded = !!((_a = _window().grecaptcha) === null || _a === void 0 ? void 0 : _a.render);
206
69
  }
207
- ReCaptchaLoaderImpl.prototype.load = function (auth, hl) {
208
- var _this = this;
209
- if (hl === void 0) { hl = ''; }
70
+ load(auth, hl = '') {
210
71
  _assert(isHostLanguageValid(hl), auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
211
72
  if (this.shouldResolveImmediately(hl) && isV2(_window().grecaptcha)) {
212
73
  return Promise.resolve(_window().grecaptcha);
213
74
  }
214
- return new Promise(function (resolve, reject) {
215
- var networkTimeout = _window().setTimeout(function () {
75
+ return new Promise((resolve, reject) => {
76
+ const networkTimeout = _window().setTimeout(() => {
216
77
  reject(_createError(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */));
217
78
  }, NETWORK_TIMEOUT_DELAY.get());
218
- _window()[_JSLOAD_CALLBACK] = function () {
79
+ _window()[_JSLOAD_CALLBACK] = () => {
219
80
  _window().clearTimeout(networkTimeout);
220
81
  delete _window()[_JSLOAD_CALLBACK];
221
- var recaptcha = _window().grecaptcha;
82
+ const recaptcha = _window().grecaptcha;
222
83
  if (!recaptcha || !isV2(recaptcha)) {
223
84
  reject(_createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
224
85
  return;
225
86
  }
226
87
  // Wrap the recaptcha render function so that we know if the developer has
227
88
  // called it separately
228
- var render = recaptcha.render;
229
- recaptcha.render = function (container, params) {
230
- var widgetId = render(container, params);
231
- _this.counter++;
89
+ const render = recaptcha.render;
90
+ recaptcha.render = (container, params) => {
91
+ const widgetId = render(container, params);
92
+ this.counter++;
232
93
  return widgetId;
233
94
  };
234
- _this.hostLanguage = hl;
95
+ this.hostLanguage = hl;
235
96
  resolve(recaptcha);
236
97
  };
237
- var url = "".concat(_recaptchaV2ScriptUrl(), "?").concat(querystring({
98
+ const url = `${_recaptchaV2ScriptUrl()}?${querystring({
238
99
  onload: _JSLOAD_CALLBACK,
239
100
  render: 'explicit',
240
- hl: hl
241
- }));
242
- _loadJS(url).catch(function () {
101
+ hl
102
+ })}`;
103
+ _loadJS(url).catch(() => {
243
104
  clearTimeout(networkTimeout);
244
105
  reject(_createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
245
106
  });
246
107
  });
247
- };
248
- ReCaptchaLoaderImpl.prototype.clearedOneInstance = function () {
108
+ }
109
+ clearedOneInstance() {
249
110
  this.counter--;
250
- };
251
- ReCaptchaLoaderImpl.prototype.shouldResolveImmediately = function (hl) {
111
+ }
112
+ shouldResolveImmediately(hl) {
252
113
  var _a;
253
114
  // We can resolve immediately if:
254
115
  // • grecaptcha is already defined AND (
@@ -261,25 +122,17 @@ var ReCaptchaLoaderImpl = /** @class */ (function () {
261
122
  (hl === this.hostLanguage ||
262
123
  this.counter > 0 ||
263
124
  this.librarySeparatelyLoaded));
264
- };
265
- return ReCaptchaLoaderImpl;
266
- }());
125
+ }
126
+ }
267
127
  function isHostLanguageValid(hl) {
268
128
  return hl.length <= 6 && /^\s*[a-zA-Z0-9\-]*\s*$/.test(hl);
269
129
  }
270
- var MockReCaptchaLoaderImpl = /** @class */ (function () {
271
- function MockReCaptchaLoaderImpl() {
130
+ class MockReCaptchaLoaderImpl {
131
+ async load(auth) {
132
+ return new MockReCaptcha(auth);
272
133
  }
273
- MockReCaptchaLoaderImpl.prototype.load = function (auth) {
274
- return __awaiter(this, void 0, void 0, function () {
275
- return __generator(this, function (_a) {
276
- return [2 /*return*/, new MockReCaptcha(auth)];
277
- });
278
- });
279
- };
280
- MockReCaptchaLoaderImpl.prototype.clearedOneInstance = function () { };
281
- return MockReCaptchaLoaderImpl;
282
- }());
134
+ clearedOneInstance() { }
135
+ }
283
136
 
284
137
  /**
285
138
  * @license
@@ -297,8 +150,8 @@ var MockReCaptchaLoaderImpl = /** @class */ (function () {
297
150
  * See the License for the specific language governing permissions and
298
151
  * limitations under the License.
299
152
  */
300
- var RECAPTCHA_VERIFIER_TYPE = 'recaptcha';
301
- var DEFAULT_PARAMS = {
153
+ const RECAPTCHA_VERIFIER_TYPE = 'recaptcha';
154
+ const DEFAULT_PARAMS = {
302
155
  theme: 'light',
303
156
  type: 'image'
304
157
  };
@@ -310,7 +163,7 @@ var DEFAULT_PARAMS = {
310
163
  *
311
164
  * @public
312
165
  */
313
- var RecaptchaVerifier = /** @class */ (function () {
166
+ class RecaptchaVerifier {
314
167
  /**
315
168
  * @param authExtern - The corresponding Firebase {@link Auth} instance.
316
169
  *
@@ -330,8 +183,7 @@ var RecaptchaVerifier = /** @class */ (function () {
330
183
  * configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
331
184
  * 'invisible'.
332
185
  */
333
- function RecaptchaVerifier(authExtern, containerOrId, parameters) {
334
- if (parameters === void 0) { parameters = __assign({}, DEFAULT_PARAMS); }
186
+ constructor(authExtern, containerOrId, parameters = Object.assign({}, DEFAULT_PARAMS)) {
335
187
  this.parameters = parameters;
336
188
  /**
337
189
  * The application verifier type.
@@ -348,7 +200,7 @@ var RecaptchaVerifier = /** @class */ (function () {
348
200
  this.auth = _castAuth(authExtern);
349
201
  this.isInvisible = this.parameters.size === 'invisible';
350
202
  _assert(typeof document !== 'undefined', this.auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
351
- var container = typeof containerOrId === 'string'
203
+ const container = typeof containerOrId === 'string'
352
204
  ? document.getElementById(containerOrId)
353
205
  : containerOrId;
354
206
  _assert(container, this.auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
@@ -365,46 +217,34 @@ var RecaptchaVerifier = /** @class */ (function () {
365
217
  *
366
218
  * @returns A Promise for the reCAPTCHA token.
367
219
  */
368
- RecaptchaVerifier.prototype.verify = function () {
369
- return __awaiter(this, void 0, void 0, function () {
370
- var id, recaptcha, response;
371
- var _this = this;
372
- return __generator(this, function (_a) {
373
- switch (_a.label) {
374
- case 0:
375
- this.assertNotDestroyed();
376
- return [4 /*yield*/, this.render()];
377
- case 1:
378
- id = _a.sent();
379
- recaptcha = this.getAssertedRecaptcha();
380
- response = recaptcha.getResponse(id);
381
- if (response) {
382
- return [2 /*return*/, response];
383
- }
384
- return [2 /*return*/, new Promise(function (resolve) {
385
- var tokenChange = function (token) {
386
- if (!token) {
387
- return; // Ignore token expirations.
388
- }
389
- _this.tokenChangeListeners.delete(tokenChange);
390
- resolve(token);
391
- };
392
- _this.tokenChangeListeners.add(tokenChange);
393
- if (_this.isInvisible) {
394
- recaptcha.execute(id);
395
- }
396
- })];
220
+ async verify() {
221
+ this.assertNotDestroyed();
222
+ const id = await this.render();
223
+ const recaptcha = this.getAssertedRecaptcha();
224
+ const response = recaptcha.getResponse(id);
225
+ if (response) {
226
+ return response;
227
+ }
228
+ return new Promise(resolve => {
229
+ const tokenChange = (token) => {
230
+ if (!token) {
231
+ return; // Ignore token expirations.
397
232
  }
398
- });
233
+ this.tokenChangeListeners.delete(tokenChange);
234
+ resolve(token);
235
+ };
236
+ this.tokenChangeListeners.add(tokenChange);
237
+ if (this.isInvisible) {
238
+ recaptcha.execute(id);
239
+ }
399
240
  });
400
- };
241
+ }
401
242
  /**
402
243
  * Renders the reCAPTCHA widget on the page.
403
244
  *
404
245
  * @returns A Promise that resolves with the reCAPTCHA widget ID.
405
246
  */
406
- RecaptchaVerifier.prototype.render = function () {
407
- var _this = this;
247
+ render() {
408
248
  try {
409
249
  this.assertNotDestroyed();
410
250
  }
@@ -417,111 +257,83 @@ var RecaptchaVerifier = /** @class */ (function () {
417
257
  if (this.renderPromise) {
418
258
  return this.renderPromise;
419
259
  }
420
- this.renderPromise = this.makeRenderPromise().catch(function (e) {
421
- _this.renderPromise = null;
260
+ this.renderPromise = this.makeRenderPromise().catch(e => {
261
+ this.renderPromise = null;
422
262
  throw e;
423
263
  });
424
264
  return this.renderPromise;
425
- };
265
+ }
426
266
  /** @internal */
427
- RecaptchaVerifier.prototype._reset = function () {
267
+ _reset() {
428
268
  this.assertNotDestroyed();
429
269
  if (this.widgetId !== null) {
430
270
  this.getAssertedRecaptcha().reset(this.widgetId);
431
271
  }
432
- };
272
+ }
433
273
  /**
434
274
  * Clears the reCAPTCHA widget from the page and destroys the instance.
435
275
  */
436
- RecaptchaVerifier.prototype.clear = function () {
437
- var _this = this;
276
+ clear() {
438
277
  this.assertNotDestroyed();
439
278
  this.destroyed = true;
440
279
  this._recaptchaLoader.clearedOneInstance();
441
280
  if (!this.isInvisible) {
442
- this.container.childNodes.forEach(function (node) {
443
- _this.container.removeChild(node);
281
+ this.container.childNodes.forEach(node => {
282
+ this.container.removeChild(node);
444
283
  });
445
284
  }
446
- };
447
- RecaptchaVerifier.prototype.validateStartingState = function () {
285
+ }
286
+ validateStartingState() {
448
287
  _assert(!this.parameters.sitekey, this.auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
449
288
  _assert(this.isInvisible || !this.container.hasChildNodes(), this.auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
450
289
  _assert(typeof document !== 'undefined', this.auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
451
- };
452
- RecaptchaVerifier.prototype.makeTokenCallback = function (existing) {
453
- var _this = this;
454
- return function (token) {
455
- _this.tokenChangeListeners.forEach(function (listener) { return listener(token); });
290
+ }
291
+ makeTokenCallback(existing) {
292
+ return token => {
293
+ this.tokenChangeListeners.forEach(listener => listener(token));
456
294
  if (typeof existing === 'function') {
457
295
  existing(token);
458
296
  }
459
297
  else if (typeof existing === 'string') {
460
- var globalFunc = _window()[existing];
298
+ const globalFunc = _window()[existing];
461
299
  if (typeof globalFunc === 'function') {
462
300
  globalFunc(token);
463
301
  }
464
302
  }
465
303
  };
466
- };
467
- RecaptchaVerifier.prototype.assertNotDestroyed = function () {
304
+ }
305
+ assertNotDestroyed() {
468
306
  _assert(!this.destroyed, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
469
- };
470
- RecaptchaVerifier.prototype.makeRenderPromise = function () {
471
- return __awaiter(this, void 0, void 0, function () {
472
- var container, guaranteedEmpty;
473
- return __generator(this, function (_a) {
474
- switch (_a.label) {
475
- case 0: return [4 /*yield*/, this.init()];
476
- case 1:
477
- _a.sent();
478
- if (!this.widgetId) {
479
- container = this.container;
480
- if (!this.isInvisible) {
481
- guaranteedEmpty = document.createElement('div');
482
- container.appendChild(guaranteedEmpty);
483
- container = guaranteedEmpty;
484
- }
485
- this.widgetId = this.getAssertedRecaptcha().render(container, this.parameters);
486
- }
487
- return [2 /*return*/, this.widgetId];
488
- }
489
- });
490
- });
491
- };
492
- RecaptchaVerifier.prototype.init = function () {
493
- return __awaiter(this, void 0, void 0, function () {
494
- var _a, siteKey;
495
- return __generator(this, function (_b) {
496
- switch (_b.label) {
497
- case 0:
498
- _assert(_isHttpOrHttps() && !_isWorker(), this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
499
- return [4 /*yield*/, domReady()];
500
- case 1:
501
- _b.sent();
502
- _a = this;
503
- return [4 /*yield*/, this._recaptchaLoader.load(this.auth, this.auth.languageCode || undefined)];
504
- case 2:
505
- _a.recaptcha = _b.sent();
506
- return [4 /*yield*/, getRecaptchaParams(this.auth)];
507
- case 3:
508
- siteKey = _b.sent();
509
- _assert(siteKey, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
510
- this.parameters.sitekey = siteKey;
511
- return [2 /*return*/];
512
- }
513
- });
514
- });
515
- };
516
- RecaptchaVerifier.prototype.getAssertedRecaptcha = function () {
307
+ }
308
+ async makeRenderPromise() {
309
+ await this.init();
310
+ if (!this.widgetId) {
311
+ let container = this.container;
312
+ if (!this.isInvisible) {
313
+ const guaranteedEmpty = document.createElement('div');
314
+ container.appendChild(guaranteedEmpty);
315
+ container = guaranteedEmpty;
316
+ }
317
+ this.widgetId = this.getAssertedRecaptcha().render(container, this.parameters);
318
+ }
319
+ return this.widgetId;
320
+ }
321
+ async init() {
322
+ _assert(_isHttpOrHttps() && !_isWorker(), this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
323
+ await domReady();
324
+ this.recaptcha = await this._recaptchaLoader.load(this.auth, this.auth.languageCode || undefined);
325
+ const siteKey = await getRecaptchaParams(this.auth);
326
+ _assert(siteKey, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
327
+ this.parameters.sitekey = siteKey;
328
+ }
329
+ getAssertedRecaptcha() {
517
330
  _assert(this.recaptcha, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
518
331
  return this.recaptcha;
519
- };
520
- return RecaptchaVerifier;
521
- }());
332
+ }
333
+ }
522
334
  function domReady() {
523
- var resolver = null;
524
- return new Promise(function (resolve) {
335
+ let resolver = null;
336
+ return new Promise(resolve => {
525
337
  if (document.readyState === 'complete') {
526
338
  resolve();
527
339
  return;
@@ -529,9 +341,9 @@ function domReady() {
529
341
  // Document not ready, wait for load before resolving.
530
342
  // Save resolver, so we can remove listener in case it was externally
531
343
  // cancelled.
532
- resolver = function () { return resolve(); };
344
+ resolver = () => resolve();
533
345
  window.addEventListener('load', resolver);
534
- }).catch(function (e) {
346
+ }).catch(e => {
535
347
  if (resolver) {
536
348
  window.removeEventListener('load', resolver);
537
349
  }
@@ -555,17 +367,16 @@ function domReady() {
555
367
  * See the License for the specific language governing permissions and
556
368
  * limitations under the License.
557
369
  */
558
- var ConfirmationResultImpl = /** @class */ (function () {
559
- function ConfirmationResultImpl(verificationId, onConfirmation) {
370
+ class ConfirmationResultImpl {
371
+ constructor(verificationId, onConfirmation) {
560
372
  this.verificationId = verificationId;
561
373
  this.onConfirmation = onConfirmation;
562
374
  }
563
- ConfirmationResultImpl.prototype.confirm = function (verificationCode) {
564
- var authCredential = PhoneAuthCredential._fromVerification(this.verificationId, verificationCode);
375
+ confirm(verificationCode) {
376
+ const authCredential = PhoneAuthCredential._fromVerification(this.verificationId, verificationCode);
565
377
  return this.onConfirmation(authCredential);
566
- };
567
- return ConfirmationResultImpl;
568
- }());
378
+ }
379
+ }
569
380
  /**
570
381
  * Asynchronously signs in using a phone number.
571
382
  *
@@ -575,12 +386,15 @@ var ConfirmationResultImpl = /** @class */ (function () {
575
386
  * provides the code sent to their phone, call {@link ConfirmationResult.confirm}
576
387
  * with the code to sign the user in.
577
388
  *
578
- * For abuse prevention, this method also requires a {@link ApplicationVerifier}.
579
- * This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
389
+ * For abuse prevention, this method requires a {@link ApplicationVerifier}.
390
+ * This SDK includes an implementation based on reCAPTCHA v2, {@link RecaptchaVerifier}.
580
391
  * This function can work on other platforms that do not support the
581
392
  * {@link RecaptchaVerifier} (like React Native), but you need to use a
582
393
  * third-party {@link ApplicationVerifier} implementation.
583
394
  *
395
+ * If you've enabled project-level reCAPTCHA Enterprise bot protection in
396
+ * Enforce mode, you can omit the {@link ApplicationVerifier}.
397
+ *
584
398
  * This method does not work in a Node.js environment or with {@link Auth} instances created with a
585
399
  * {@link @firebase/app#FirebaseServerApp}.
586
400
  *
@@ -599,25 +413,13 @@ var ConfirmationResultImpl = /** @class */ (function () {
599
413
  *
600
414
  * @public
601
415
  */
602
- function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
603
- return __awaiter(this, void 0, void 0, function () {
604
- var authInternal, verificationId;
605
- return __generator(this, function (_a) {
606
- switch (_a.label) {
607
- case 0:
608
- if (_isFirebaseServerApp(auth.app)) {
609
- return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
610
- }
611
- authInternal = _castAuth(auth);
612
- return [4 /*yield*/, _verifyPhoneNumber(authInternal, phoneNumber, getModularInstance(appVerifier))];
613
- case 1:
614
- verificationId = _a.sent();
615
- return [2 /*return*/, new ConfirmationResultImpl(verificationId, function (cred) {
616
- return signInWithCredential(authInternal, cred);
617
- })];
618
- }
619
- });
620
- });
416
+ async function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
417
+ if (_isFirebaseServerApp(auth.app)) {
418
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
419
+ }
420
+ const authInternal = _castAuth(auth);
421
+ const verificationId = await _verifyPhoneNumber(authInternal, phoneNumber, getModularInstance(appVerifier));
422
+ return new ConfirmationResultImpl(verificationId, cred => signInWithCredential(authInternal, cred));
621
423
  }
622
424
  /**
623
425
  * Links the user account with the given phone number.
@@ -631,25 +433,11 @@ function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
631
433
  *
632
434
  * @public
633
435
  */
634
- function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
635
- return __awaiter(this, void 0, void 0, function () {
636
- var userInternal, verificationId;
637
- return __generator(this, function (_a) {
638
- switch (_a.label) {
639
- case 0:
640
- userInternal = getModularInstance(user);
641
- return [4 /*yield*/, _assertLinkedStatus(false, userInternal, "phone" /* ProviderId.PHONE */)];
642
- case 1:
643
- _a.sent();
644
- return [4 /*yield*/, _verifyPhoneNumber(userInternal.auth, phoneNumber, getModularInstance(appVerifier))];
645
- case 2:
646
- verificationId = _a.sent();
647
- return [2 /*return*/, new ConfirmationResultImpl(verificationId, function (cred) {
648
- return linkWithCredential(userInternal, cred);
649
- })];
650
- }
651
- });
652
- });
436
+ async function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
437
+ const userInternal = getModularInstance(user);
438
+ await _assertLinkedStatus(false, userInternal, "phone" /* ProviderId.PHONE */);
439
+ const verificationId = await _verifyPhoneNumber(userInternal.auth, phoneNumber, getModularInstance(appVerifier));
440
+ return new ConfirmationResultImpl(verificationId, cred => linkWithCredential(userInternal, cred));
653
441
  }
654
442
  /**
655
443
  * Re-authenticates a user using a fresh phone credential.
@@ -666,98 +454,120 @@ function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
666
454
  *
667
455
  * @public
668
456
  */
669
- function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
670
- return __awaiter(this, void 0, void 0, function () {
671
- var userInternal, verificationId;
672
- return __generator(this, function (_a) {
673
- switch (_a.label) {
674
- case 0:
675
- userInternal = getModularInstance(user);
676
- if (_isFirebaseServerApp(userInternal.auth.app)) {
677
- return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth))];
678
- }
679
- return [4 /*yield*/, _verifyPhoneNumber(userInternal.auth, phoneNumber, getModularInstance(appVerifier))];
680
- case 1:
681
- verificationId = _a.sent();
682
- return [2 /*return*/, new ConfirmationResultImpl(verificationId, function (cred) {
683
- return reauthenticateWithCredential(userInternal, cred);
684
- })];
685
- }
686
- });
687
- });
457
+ async function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
458
+ const userInternal = getModularInstance(user);
459
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
460
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
461
+ }
462
+ const verificationId = await _verifyPhoneNumber(userInternal.auth, phoneNumber, getModularInstance(appVerifier));
463
+ return new ConfirmationResultImpl(verificationId, cred => reauthenticateWithCredential(userInternal, cred));
688
464
  }
689
465
  /**
690
466
  * Returns a verification ID to be used in conjunction with the SMS code that is sent.
691
467
  *
692
468
  */
693
- function _verifyPhoneNumber(auth, options, verifier) {
469
+ async function _verifyPhoneNumber(auth, options, verifier) {
694
470
  var _a;
695
- return __awaiter(this, void 0, void 0, function () {
696
- var recaptchaToken, phoneInfoOptions, session, response, mfaEnrollmentId, response, sessionInfo;
697
- return __generator(this, function (_b) {
698
- switch (_b.label) {
699
- case 0: return [4 /*yield*/, verifier.verify()];
700
- case 1:
701
- recaptchaToken = _b.sent();
702
- _b.label = 2;
703
- case 2:
704
- _b.trys.push([2, , 10, 11]);
705
- _assert(typeof recaptchaToken === 'string', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
706
- _assert(verifier.type === RECAPTCHA_VERIFIER_TYPE, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
707
- phoneInfoOptions = void 0;
708
- if (typeof options === 'string') {
709
- phoneInfoOptions = {
710
- phoneNumber: options
711
- };
471
+ if (!auth._getRecaptchaConfig()) {
472
+ try {
473
+ await _initializeRecaptchaConfig(auth);
474
+ }
475
+ catch (error) {
476
+ // If an error occurs while fetching the config, there is no way to know the enablement state
477
+ // of Phone provider, so we proceed with recaptcha V2 verification.
478
+ // The error is likely "recaptchaKey undefined", as reCAPTCHA Enterprise is not
479
+ // enabled for any provider.
480
+ console.log('Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.');
481
+ }
482
+ }
483
+ try {
484
+ let phoneInfoOptions;
485
+ if (typeof options === 'string') {
486
+ phoneInfoOptions = {
487
+ phoneNumber: options
488
+ };
489
+ }
490
+ else {
491
+ phoneInfoOptions = options;
492
+ }
493
+ if ('session' in phoneInfoOptions) {
494
+ const session = phoneInfoOptions.session;
495
+ if ('phoneNumber' in phoneInfoOptions) {
496
+ _assert(session.type === "enroll" /* MultiFactorSessionType.ENROLL */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
497
+ const startPhoneMfaEnrollmentRequest = {
498
+ idToken: session.credential,
499
+ phoneEnrollmentInfo: {
500
+ phoneNumber: phoneInfoOptions.phoneNumber,
501
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
712
502
  }
713
- else {
714
- phoneInfoOptions = options;
503
+ };
504
+ const startEnrollPhoneMfaActionCallback = async (authInstance, request) => {
505
+ // If reCAPTCHA Enterprise token is FAKE_TOKEN, fetch reCAPTCHA v2 token and inject into request.
506
+ if (request.phoneEnrollmentInfo.captchaResponse === FAKE_TOKEN) {
507
+ _assert((verifier === null || verifier === void 0 ? void 0 : verifier.type) === RECAPTCHA_VERIFIER_TYPE, authInstance, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
508
+ const requestWithRecaptchaV2 = await injectRecaptchaV2Token(authInstance, request, verifier);
509
+ return startEnrollPhoneMfa(authInstance, requestWithRecaptchaV2);
715
510
  }
716
- if (!('session' in phoneInfoOptions)) return [3 /*break*/, 7];
717
- session = phoneInfoOptions.session;
718
- if (!('phoneNumber' in phoneInfoOptions)) return [3 /*break*/, 4];
719
- _assert(session.type === "enroll" /* MultiFactorSessionType.ENROLL */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
720
- return [4 /*yield*/, startEnrollPhoneMfa(auth, {
721
- idToken: session.credential,
722
- phoneEnrollmentInfo: {
723
- phoneNumber: phoneInfoOptions.phoneNumber,
724
- recaptchaToken: recaptchaToken
725
- }
726
- })];
727
- case 3:
728
- response = _b.sent();
729
- return [2 /*return*/, response.phoneSessionInfo.sessionInfo];
730
- case 4:
731
- _assert(session.type === "signin" /* MultiFactorSessionType.SIGN_IN */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
732
- mfaEnrollmentId = ((_a = phoneInfoOptions.multiFactorHint) === null || _a === void 0 ? void 0 : _a.uid) ||
733
- phoneInfoOptions.multiFactorUid;
734
- _assert(mfaEnrollmentId, auth, "missing-multi-factor-info" /* AuthErrorCode.MISSING_MFA_INFO */);
735
- return [4 /*yield*/, startSignInPhoneMfa(auth, {
736
- mfaPendingCredential: session.credential,
737
- mfaEnrollmentId: mfaEnrollmentId,
738
- phoneSignInInfo: {
739
- recaptchaToken: recaptchaToken
740
- }
741
- })];
742
- case 5:
743
- response = _b.sent();
744
- return [2 /*return*/, response.phoneResponseInfo.sessionInfo];
745
- case 6: return [3 /*break*/, 9];
746
- case 7: return [4 /*yield*/, sendPhoneVerificationCode(auth, {
747
- phoneNumber: phoneInfoOptions.phoneNumber,
748
- recaptchaToken: recaptchaToken
749
- })];
750
- case 8:
751
- sessionInfo = (_b.sent()).sessionInfo;
752
- return [2 /*return*/, sessionInfo];
753
- case 9: return [3 /*break*/, 11];
754
- case 10:
755
- verifier._reset();
756
- return [7 /*endfinally*/];
757
- case 11: return [2 /*return*/];
511
+ return startEnrollPhoneMfa(authInstance, request);
512
+ };
513
+ const startPhoneMfaEnrollmentResponse = handleRecaptchaFlow(auth, startPhoneMfaEnrollmentRequest, "mfaSmsEnrollment" /* RecaptchaActionName.MFA_SMS_ENROLLMENT */, startEnrollPhoneMfaActionCallback, "PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */);
514
+ const response = await startPhoneMfaEnrollmentResponse.catch(error => {
515
+ return Promise.reject(error);
516
+ });
517
+ return response.phoneSessionInfo.sessionInfo;
758
518
  }
759
- });
760
- });
519
+ else {
520
+ _assert(session.type === "signin" /* MultiFactorSessionType.SIGN_IN */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
521
+ const mfaEnrollmentId = ((_a = phoneInfoOptions.multiFactorHint) === null || _a === void 0 ? void 0 : _a.uid) ||
522
+ phoneInfoOptions.multiFactorUid;
523
+ _assert(mfaEnrollmentId, auth, "missing-multi-factor-info" /* AuthErrorCode.MISSING_MFA_INFO */);
524
+ const startPhoneMfaSignInRequest = {
525
+ mfaPendingCredential: session.credential,
526
+ mfaEnrollmentId,
527
+ phoneSignInInfo: {
528
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
529
+ }
530
+ };
531
+ const startSignInPhoneMfaActionCallback = async (authInstance, request) => {
532
+ // If reCAPTCHA Enterprise token is FAKE_TOKEN, fetch reCAPTCHA v2 token and inject into request.
533
+ if (request.phoneSignInInfo.captchaResponse === FAKE_TOKEN) {
534
+ _assert((verifier === null || verifier === void 0 ? void 0 : verifier.type) === RECAPTCHA_VERIFIER_TYPE, authInstance, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
535
+ const requestWithRecaptchaV2 = await injectRecaptchaV2Token(authInstance, request, verifier);
536
+ return startSignInPhoneMfa(authInstance, requestWithRecaptchaV2);
537
+ }
538
+ return startSignInPhoneMfa(authInstance, request);
539
+ };
540
+ const startPhoneMfaSignInResponse = handleRecaptchaFlow(auth, startPhoneMfaSignInRequest, "mfaSmsSignIn" /* RecaptchaActionName.MFA_SMS_SIGNIN */, startSignInPhoneMfaActionCallback, "PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */);
541
+ const response = await startPhoneMfaSignInResponse.catch(error => {
542
+ return Promise.reject(error);
543
+ });
544
+ return response.phoneResponseInfo.sessionInfo;
545
+ }
546
+ }
547
+ else {
548
+ const sendPhoneVerificationCodeRequest = {
549
+ phoneNumber: phoneInfoOptions.phoneNumber,
550
+ clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */
551
+ };
552
+ const sendPhoneVerificationCodeActionCallback = async (authInstance, request) => {
553
+ // If reCAPTCHA Enterprise token is FAKE_TOKEN, fetch reCAPTCHA v2 token and inject into request.
554
+ if (request.captchaResponse === FAKE_TOKEN) {
555
+ _assert((verifier === null || verifier === void 0 ? void 0 : verifier.type) === RECAPTCHA_VERIFIER_TYPE, authInstance, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
556
+ const requestWithRecaptchaV2 = await injectRecaptchaV2Token(authInstance, request, verifier);
557
+ return sendPhoneVerificationCode(authInstance, requestWithRecaptchaV2);
558
+ }
559
+ return sendPhoneVerificationCode(authInstance, request);
560
+ };
561
+ const sendPhoneVerificationCodeResponse = handleRecaptchaFlow(auth, sendPhoneVerificationCodeRequest, "sendVerificationCode" /* RecaptchaActionName.SEND_VERIFICATION_CODE */, sendPhoneVerificationCodeActionCallback, "PHONE_PROVIDER" /* RecaptchaAuthProvider.PHONE_PROVIDER */);
562
+ const response = await sendPhoneVerificationCodeResponse.catch(error => {
563
+ return Promise.reject(error);
564
+ });
565
+ return response.sessionInfo;
566
+ }
567
+ }
568
+ finally {
569
+ verifier === null || verifier === void 0 ? void 0 : verifier._reset();
570
+ }
761
571
  }
762
572
  /**
763
573
  * Updates the user's phone number.
@@ -782,23 +592,55 @@ function _verifyPhoneNumber(auth, options, verifier) {
782
592
  *
783
593
  * @public
784
594
  */
785
- function updatePhoneNumber(user, credential) {
786
- return __awaiter(this, void 0, void 0, function () {
787
- var userInternal;
788
- return __generator(this, function (_a) {
789
- switch (_a.label) {
790
- case 0:
791
- userInternal = getModularInstance(user);
792
- if (_isFirebaseServerApp(userInternal.auth.app)) {
793
- return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth))];
794
- }
795
- return [4 /*yield*/, _link(userInternal, credential)];
796
- case 1:
797
- _a.sent();
798
- return [2 /*return*/];
595
+ async function updatePhoneNumber(user, credential) {
596
+ const userInternal = getModularInstance(user);
597
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
598
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
599
+ }
600
+ await _link(userInternal, credential);
601
+ }
602
+ // Helper function that fetches and injects a reCAPTCHA v2 token into the request.
603
+ async function injectRecaptchaV2Token(auth, request, recaptchaV2Verifier) {
604
+ _assert(recaptchaV2Verifier.type === RECAPTCHA_VERIFIER_TYPE, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
605
+ const recaptchaV2Token = await recaptchaV2Verifier.verify();
606
+ _assert(typeof recaptchaV2Token === 'string', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
607
+ const newRequest = Object.assign({}, request);
608
+ if ('phoneEnrollmentInfo' in newRequest) {
609
+ const phoneNumber = newRequest.phoneEnrollmentInfo.phoneNumber;
610
+ const captchaResponse = newRequest.phoneEnrollmentInfo.captchaResponse;
611
+ const clientType = newRequest
612
+ .phoneEnrollmentInfo.clientType;
613
+ const recaptchaVersion = newRequest.phoneEnrollmentInfo.recaptchaVersion;
614
+ Object.assign(newRequest, {
615
+ 'phoneEnrollmentInfo': {
616
+ phoneNumber,
617
+ recaptchaToken: recaptchaV2Token,
618
+ captchaResponse,
619
+ clientType,
620
+ recaptchaVersion
799
621
  }
800
622
  });
801
- });
623
+ return newRequest;
624
+ }
625
+ else if ('phoneSignInInfo' in newRequest) {
626
+ const captchaResponse = newRequest.phoneSignInInfo.captchaResponse;
627
+ const clientType = newRequest
628
+ .phoneSignInInfo.clientType;
629
+ const recaptchaVersion = newRequest.phoneSignInInfo.recaptchaVersion;
630
+ Object.assign(newRequest, {
631
+ 'phoneSignInInfo': {
632
+ recaptchaToken: recaptchaV2Token,
633
+ captchaResponse,
634
+ clientType,
635
+ recaptchaVersion
636
+ }
637
+ });
638
+ return newRequest;
639
+ }
640
+ else {
641
+ Object.assign(newRequest, { 'recaptchaToken': recaptchaV2Token });
642
+ return newRequest;
643
+ }
802
644
  }
803
645
 
804
646
  /**
@@ -836,12 +678,12 @@ function updatePhoneNumber(user, credential) {
836
678
  *
837
679
  * @public
838
680
  */
839
- var PhoneAuthProvider = /** @class */ (function () {
681
+ class PhoneAuthProvider {
840
682
  /**
841
683
  * @param auth - The Firebase {@link Auth} instance in which sign-ins should occur.
842
684
  *
843
685
  */
844
- function PhoneAuthProvider(auth) {
686
+ constructor(auth) {
845
687
  /** Always set to {@link ProviderId}.PHONE. */
846
688
  this.providerId = PhoneAuthProvider.PROVIDER_ID;
847
689
  this.auth = _castAuth(auth);
@@ -870,16 +712,18 @@ var PhoneAuthProvider = /** @class */ (function () {
870
712
  *
871
713
  * @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
872
714
  * E.164 format (e.g. +16505550101).
873
- * @param applicationVerifier - For abuse prevention, this method also requires a
874
- * {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
875
- * {@link RecaptchaVerifier}.
715
+ * @param applicationVerifier - An {@link ApplicationVerifier}, which prevents
716
+ * requests from unauthorized clients. This SDK includes an implementation
717
+ * based on reCAPTCHA v2, {@link RecaptchaVerifier}. If you've enabled
718
+ * reCAPTCHA Enterprise bot protection in Enforce mode, this parameter is
719
+ * optional; in all other configurations, the parameter is required.
876
720
  *
877
721
  * @returns A Promise for a verification ID that can be passed to
878
- * {@link PhoneAuthProvider.credential} to identify this flow..
722
+ * {@link PhoneAuthProvider.credential} to identify this flow.
879
723
  */
880
- PhoneAuthProvider.prototype.verifyPhoneNumber = function (phoneOptions, applicationVerifier) {
724
+ verifyPhoneNumber(phoneOptions, applicationVerifier) {
881
725
  return _verifyPhoneNumber(this.auth, phoneOptions, getModularInstance(applicationVerifier));
882
- };
726
+ }
883
727
  /**
884
728
  * Creates a phone auth credential, given the verification ID from
885
729
  * {@link PhoneAuthProvider.verifyPhoneNumber} and the code that was sent to the user's
@@ -907,17 +751,17 @@ var PhoneAuthProvider = /** @class */ (function () {
907
751
  *
908
752
  * @returns The auth provider credential.
909
753
  */
910
- PhoneAuthProvider.credential = function (verificationId, verificationCode) {
754
+ static credential(verificationId, verificationCode) {
911
755
  return PhoneAuthCredential._fromVerification(verificationId, verificationCode);
912
- };
756
+ }
913
757
  /**
914
758
  * Generates an {@link AuthCredential} from a {@link UserCredential}.
915
759
  * @param userCredential - The user credential.
916
760
  */
917
- PhoneAuthProvider.credentialFromResult = function (userCredential) {
918
- var credential = userCredential;
761
+ static credentialFromResult(userCredential) {
762
+ const credential = userCredential;
919
763
  return PhoneAuthProvider.credentialFromTaggedObject(credential);
920
- };
764
+ }
921
765
  /**
922
766
  * Returns an {@link AuthCredential} when passed an error.
923
767
  *
@@ -950,26 +794,24 @@ var PhoneAuthProvider = /** @class */ (function () {
950
794
  *
951
795
  * @param error - The error to generate a credential from.
952
796
  */
953
- PhoneAuthProvider.credentialFromError = function (error) {
797
+ static credentialFromError(error) {
954
798
  return PhoneAuthProvider.credentialFromTaggedObject((error.customData || {}));
955
- };
956
- PhoneAuthProvider.credentialFromTaggedObject = function (_a) {
957
- var tokenResponse = _a._tokenResponse;
799
+ }
800
+ static credentialFromTaggedObject({ _tokenResponse: tokenResponse }) {
958
801
  if (!tokenResponse) {
959
802
  return null;
960
803
  }
961
- var _b = tokenResponse, phoneNumber = _b.phoneNumber, temporaryProof = _b.temporaryProof;
804
+ const { phoneNumber, temporaryProof } = tokenResponse;
962
805
  if (phoneNumber && temporaryProof) {
963
806
  return PhoneAuthCredential._fromTokenResponse(phoneNumber, temporaryProof);
964
807
  }
965
808
  return null;
966
- };
967
- /** Always set to {@link ProviderId}.PHONE. */
968
- PhoneAuthProvider.PROVIDER_ID = "phone" /* ProviderId.PHONE */;
969
- /** Always set to {@link SignInMethod}.PHONE. */
970
- PhoneAuthProvider.PHONE_SIGN_IN_METHOD = "phone" /* SignInMethod.PHONE */;
971
- return PhoneAuthProvider;
972
- }());
809
+ }
810
+ }
811
+ /** Always set to {@link ProviderId}.PHONE. */
812
+ PhoneAuthProvider.PROVIDER_ID = "phone" /* ProviderId.PHONE */;
813
+ /** Always set to {@link SignInMethod}.PHONE. */
814
+ PhoneAuthProvider.PHONE_SIGN_IN_METHOD = "phone" /* SignInMethod.PHONE */;
973
815
 
974
816
  /**
975
817
  * @license
@@ -987,7 +829,7 @@ var PhoneAuthProvider = /** @class */ (function () {
987
829
  * See the License for the specific language governing permissions and
988
830
  * limitations under the License.
989
831
  */
990
- var _POLL_WINDOW_CLOSE_TIMEOUT = new Delay(2000, 10000);
832
+ const _POLL_WINDOW_CLOSE_TIMEOUT = new Delay(2000, 10000);
991
833
  /**
992
834
  * Authenticates a Firebase client using a popup-based OAuth authentication flow.
993
835
  *
@@ -1019,20 +861,15 @@ var _POLL_WINDOW_CLOSE_TIMEOUT = new Delay(2000, 10000);
1019
861
  *
1020
862
  * @public
1021
863
  */
1022
- function signInWithPopup(auth, provider, resolver) {
1023
- return __awaiter(this, void 0, void 0, function () {
1024
- var authInternal, resolverInternal, action;
1025
- return __generator(this, function (_a) {
1026
- if (_isFirebaseServerApp(auth.app)) {
1027
- return [2 /*return*/, Promise.reject(_createError(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */))];
1028
- }
1029
- authInternal = _castAuth(auth);
1030
- _assertInstanceOf(auth, provider, FederatedAuthProvider);
1031
- resolverInternal = _withDefaultResolver(authInternal, resolver);
1032
- action = new PopupOperation(authInternal, "signInViaPopup" /* AuthEventType.SIGN_IN_VIA_POPUP */, provider, resolverInternal);
1033
- return [2 /*return*/, action.executeNotNull()];
1034
- });
1035
- });
864
+ async function signInWithPopup(auth, provider, resolver) {
865
+ if (_isFirebaseServerApp(auth.app)) {
866
+ return Promise.reject(_createError(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */));
867
+ }
868
+ const authInternal = _castAuth(auth);
869
+ _assertInstanceOf(auth, provider, FederatedAuthProvider);
870
+ const resolverInternal = _withDefaultResolver(authInternal, resolver);
871
+ const action = new PopupOperation(authInternal, "signInViaPopup" /* AuthEventType.SIGN_IN_VIA_POPUP */, provider, resolverInternal);
872
+ return action.executeNotNull();
1036
873
  }
1037
874
  /**
1038
875
  * Reauthenticates the current user with the specified {@link OAuthProvider} using a pop-up based
@@ -1062,20 +899,15 @@ function signInWithPopup(auth, provider, resolver) {
1062
899
  *
1063
900
  * @public
1064
901
  */
1065
- function reauthenticateWithPopup(user, provider, resolver) {
1066
- return __awaiter(this, void 0, void 0, function () {
1067
- var userInternal, resolverInternal, action;
1068
- return __generator(this, function (_a) {
1069
- userInternal = getModularInstance(user);
1070
- if (_isFirebaseServerApp(userInternal.auth.app)) {
1071
- return [2 /*return*/, Promise.reject(_createError(userInternal.auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */))];
1072
- }
1073
- _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
1074
- resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1075
- action = new PopupOperation(userInternal.auth, "reauthViaPopup" /* AuthEventType.REAUTH_VIA_POPUP */, provider, resolverInternal, userInternal);
1076
- return [2 /*return*/, action.executeNotNull()];
1077
- });
1078
- });
902
+ async function reauthenticateWithPopup(user, provider, resolver) {
903
+ const userInternal = getModularInstance(user);
904
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
905
+ return Promise.reject(_createError(userInternal.auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */));
906
+ }
907
+ _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
908
+ const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
909
+ const action = new PopupOperation(userInternal.auth, "reauthViaPopup" /* AuthEventType.REAUTH_VIA_POPUP */, provider, resolverInternal, userInternal);
910
+ return action.executeNotNull();
1079
911
  }
1080
912
  /**
1081
913
  * Links the authenticated provider to the user account using a pop-up based OAuth flow.
@@ -1102,99 +934,66 @@ function reauthenticateWithPopup(user, provider, resolver) {
1102
934
  *
1103
935
  * @public
1104
936
  */
1105
- function linkWithPopup(user, provider, resolver) {
1106
- return __awaiter(this, void 0, void 0, function () {
1107
- var userInternal, resolverInternal, action;
1108
- return __generator(this, function (_a) {
1109
- userInternal = getModularInstance(user);
1110
- _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
1111
- resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1112
- action = new PopupOperation(userInternal.auth, "linkViaPopup" /* AuthEventType.LINK_VIA_POPUP */, provider, resolverInternal, userInternal);
1113
- return [2 /*return*/, action.executeNotNull()];
1114
- });
1115
- });
937
+ async function linkWithPopup(user, provider, resolver) {
938
+ const userInternal = getModularInstance(user);
939
+ _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
940
+ const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
941
+ const action = new PopupOperation(userInternal.auth, "linkViaPopup" /* AuthEventType.LINK_VIA_POPUP */, provider, resolverInternal, userInternal);
942
+ return action.executeNotNull();
1116
943
  }
1117
944
  /**
1118
945
  * Popup event manager. Handles the popup's entire lifecycle; listens to auth
1119
946
  * events
1120
947
  *
1121
948
  */
1122
- var PopupOperation = /** @class */ (function (_super) {
1123
- __extends(PopupOperation, _super);
1124
- function PopupOperation(auth, filter, provider, resolver, user) {
1125
- var _this = _super.call(this, auth, filter, resolver, user) || this;
1126
- _this.provider = provider;
1127
- _this.authWindow = null;
1128
- _this.pollId = null;
949
+ class PopupOperation extends AbstractPopupRedirectOperation {
950
+ constructor(auth, filter, provider, resolver, user) {
951
+ super(auth, filter, resolver, user);
952
+ this.provider = provider;
953
+ this.authWindow = null;
954
+ this.pollId = null;
1129
955
  if (PopupOperation.currentPopupAction) {
1130
956
  PopupOperation.currentPopupAction.cancel();
1131
957
  }
1132
- PopupOperation.currentPopupAction = _this;
1133
- return _this;
1134
- }
1135
- PopupOperation.prototype.executeNotNull = function () {
1136
- return __awaiter(this, void 0, void 0, function () {
1137
- var result;
1138
- return __generator(this, function (_a) {
1139
- switch (_a.label) {
1140
- case 0: return [4 /*yield*/, this.execute()];
1141
- case 1:
1142
- result = _a.sent();
1143
- _assert(result, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1144
- return [2 /*return*/, result];
1145
- }
1146
- });
958
+ PopupOperation.currentPopupAction = this;
959
+ }
960
+ async executeNotNull() {
961
+ const result = await this.execute();
962
+ _assert(result, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
963
+ return result;
964
+ }
965
+ async onExecution() {
966
+ debugAssert(this.filter.length === 1, 'Popup operations only handle one event');
967
+ const eventId = _generateEventId();
968
+ this.authWindow = await this.resolver._openPopup(this.auth, this.provider, this.filter[0], // There's always one, see constructor
969
+ eventId);
970
+ this.authWindow.associatedEvent = eventId;
971
+ // Check for web storage support and origin validation _after_ the popup is
972
+ // loaded. These operations are slow (~1 second or so) Rather than
973
+ // waiting on them before opening the window, optimistically open the popup
974
+ // and check for storage support at the same time. If storage support is
975
+ // not available, this will cause the whole thing to reject properly. It
976
+ // will also close the popup, but since the promise has already rejected,
977
+ // the popup closed by user poll will reject into the void.
978
+ this.resolver._originValidation(this.auth).catch(e => {
979
+ this.reject(e);
1147
980
  });
1148
- };
1149
- PopupOperation.prototype.onExecution = function () {
1150
- return __awaiter(this, void 0, void 0, function () {
1151
- var eventId, _a;
1152
- var _this = this;
1153
- return __generator(this, function (_b) {
1154
- switch (_b.label) {
1155
- case 0:
1156
- debugAssert(this.filter.length === 1, 'Popup operations only handle one event');
1157
- eventId = _generateEventId();
1158
- _a = this;
1159
- return [4 /*yield*/, this.resolver._openPopup(this.auth, this.provider, this.filter[0], // There's always one, see constructor
1160
- eventId)];
1161
- case 1:
1162
- _a.authWindow = _b.sent();
1163
- this.authWindow.associatedEvent = eventId;
1164
- // Check for web storage support and origin validation _after_ the popup is
1165
- // loaded. These operations are slow (~1 second or so) Rather than
1166
- // waiting on them before opening the window, optimistically open the popup
1167
- // and check for storage support at the same time. If storage support is
1168
- // not available, this will cause the whole thing to reject properly. It
1169
- // will also close the popup, but since the promise has already rejected,
1170
- // the popup closed by user poll will reject into the void.
1171
- this.resolver._originValidation(this.auth).catch(function (e) {
1172
- _this.reject(e);
1173
- });
1174
- this.resolver._isIframeWebStorageSupported(this.auth, function (isSupported) {
1175
- if (!isSupported) {
1176
- _this.reject(_createError(_this.auth, "web-storage-unsupported" /* AuthErrorCode.WEB_STORAGE_UNSUPPORTED */));
1177
- }
1178
- });
1179
- // Handle user closure. Notice this does *not* use await
1180
- this.pollUserCancellation();
1181
- return [2 /*return*/];
1182
- }
1183
- });
981
+ this.resolver._isIframeWebStorageSupported(this.auth, isSupported => {
982
+ if (!isSupported) {
983
+ this.reject(_createError(this.auth, "web-storage-unsupported" /* AuthErrorCode.WEB_STORAGE_UNSUPPORTED */));
984
+ }
1184
985
  });
1185
- };
1186
- Object.defineProperty(PopupOperation.prototype, "eventId", {
1187
- get: function () {
1188
- var _a;
1189
- return ((_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.associatedEvent) || null;
1190
- },
1191
- enumerable: false,
1192
- configurable: true
1193
- });
1194
- PopupOperation.prototype.cancel = function () {
986
+ // Handle user closure. Notice this does *not* use await
987
+ this.pollUserCancellation();
988
+ }
989
+ get eventId() {
990
+ var _a;
991
+ return ((_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.associatedEvent) || null;
992
+ }
993
+ cancel() {
1195
994
  this.reject(_createError(this.auth, "cancelled-popup-request" /* AuthErrorCode.EXPIRED_POPUP_REQUEST */));
1196
- };
1197
- PopupOperation.prototype.cleanUp = function () {
995
+ }
996
+ cleanUp() {
1198
997
  if (this.authWindow) {
1199
998
  this.authWindow.close();
1200
999
  }
@@ -1204,32 +1003,30 @@ var PopupOperation = /** @class */ (function (_super) {
1204
1003
  this.authWindow = null;
1205
1004
  this.pollId = null;
1206
1005
  PopupOperation.currentPopupAction = null;
1207
- };
1208
- PopupOperation.prototype.pollUserCancellation = function () {
1209
- var _this = this;
1210
- var poll = function () {
1006
+ }
1007
+ pollUserCancellation() {
1008
+ const poll = () => {
1211
1009
  var _a, _b;
1212
- if ((_b = (_a = _this.authWindow) === null || _a === void 0 ? void 0 : _a.window) === null || _b === void 0 ? void 0 : _b.closed) {
1010
+ if ((_b = (_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.window) === null || _b === void 0 ? void 0 : _b.closed) {
1213
1011
  // Make sure that there is sufficient time for whatever action to
1214
1012
  // complete. The window could have closed but the sign in network
1215
1013
  // call could still be in flight. This is specifically true for
1216
1014
  // Firefox or if the opener is in an iframe, in which case the oauth
1217
1015
  // helper closes the popup.
1218
- _this.pollId = window.setTimeout(function () {
1219
- _this.pollId = null;
1220
- _this.reject(_createError(_this.auth, "popup-closed-by-user" /* AuthErrorCode.POPUP_CLOSED_BY_USER */));
1016
+ this.pollId = window.setTimeout(() => {
1017
+ this.pollId = null;
1018
+ this.reject(_createError(this.auth, "popup-closed-by-user" /* AuthErrorCode.POPUP_CLOSED_BY_USER */));
1221
1019
  }, 8000 /* _Timeout.AUTH_EVENT */);
1222
1020
  return;
1223
1021
  }
1224
- _this.pollId = window.setTimeout(poll, _POLL_WINDOW_CLOSE_TIMEOUT.get());
1022
+ this.pollId = window.setTimeout(poll, _POLL_WINDOW_CLOSE_TIMEOUT.get());
1225
1023
  };
1226
1024
  poll();
1227
- };
1228
- // Only one popup is ever shown at once. The lifecycle of the current popup
1229
- // can be managed / cancelled by the constructor.
1230
- PopupOperation.currentPopupAction = null;
1231
- return PopupOperation;
1232
- }(AbstractPopupRedirectOperation));
1025
+ }
1026
+ }
1027
+ // Only one popup is ever shown at once. The lifecycle of the current popup
1028
+ // can be managed / cancelled by the constructor.
1029
+ PopupOperation.currentPopupAction = null;
1233
1030
 
1234
1031
  /**
1235
1032
  * @license
@@ -1247,44 +1044,32 @@ var PopupOperation = /** @class */ (function (_super) {
1247
1044
  * See the License for the specific language governing permissions and
1248
1045
  * limitations under the License.
1249
1046
  */
1250
- var IP_ADDRESS_REGEX = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
1251
- var HTTP_REGEX = /^https?/;
1252
- function _validateOrigin(auth) {
1253
- return __awaiter(this, void 0, void 0, function () {
1254
- var authorizedDomains, _i, authorizedDomains_1, domain;
1255
- return __generator(this, function (_a) {
1256
- switch (_a.label) {
1257
- case 0:
1258
- // Skip origin validation if we are in an emulated environment
1259
- if (auth.config.emulator) {
1260
- return [2 /*return*/];
1261
- }
1262
- return [4 /*yield*/, _getProjectConfig(auth)];
1263
- case 1:
1264
- authorizedDomains = (_a.sent()).authorizedDomains;
1265
- for (_i = 0, authorizedDomains_1 = authorizedDomains; _i < authorizedDomains_1.length; _i++) {
1266
- domain = authorizedDomains_1[_i];
1267
- try {
1268
- if (matchDomain(domain)) {
1269
- return [2 /*return*/];
1270
- }
1271
- }
1272
- catch (_b) {
1273
- // Do nothing if there's a URL error; just continue searching
1274
- }
1275
- }
1276
- // In the old SDK, this error also provides helpful messages.
1277
- _fail(auth, "unauthorized-domain" /* AuthErrorCode.INVALID_ORIGIN */);
1278
- return [2 /*return*/];
1047
+ const IP_ADDRESS_REGEX = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
1048
+ const HTTP_REGEX = /^https?/;
1049
+ async function _validateOrigin(auth) {
1050
+ // Skip origin validation if we are in an emulated environment
1051
+ if (auth.config.emulator) {
1052
+ return;
1053
+ }
1054
+ const { authorizedDomains } = await _getProjectConfig(auth);
1055
+ for (const domain of authorizedDomains) {
1056
+ try {
1057
+ if (matchDomain(domain)) {
1058
+ return;
1279
1059
  }
1280
- });
1281
- });
1060
+ }
1061
+ catch (_a) {
1062
+ // Do nothing if there's a URL error; just continue searching
1063
+ }
1064
+ }
1065
+ // In the old SDK, this error also provides helpful messages.
1066
+ _fail(auth, "unauthorized-domain" /* AuthErrorCode.INVALID_ORIGIN */);
1282
1067
  }
1283
1068
  function matchDomain(expected) {
1284
- var currentUrl = _getCurrentUrl();
1285
- var _a = new URL(currentUrl), protocol = _a.protocol, hostname = _a.hostname;
1069
+ const currentUrl = _getCurrentUrl();
1070
+ const { protocol, hostname } = new URL(currentUrl);
1286
1071
  if (expected.startsWith('chrome-extension://')) {
1287
- var ceUrl = new URL(expected);
1072
+ const ceUrl = new URL(expected);
1288
1073
  if (ceUrl.hostname === '' && hostname === '') {
1289
1074
  // For some reason we're not parsing chrome URLs properly
1290
1075
  return (protocol === 'chrome-extension:' &&
@@ -1302,10 +1087,10 @@ function matchDomain(expected) {
1302
1087
  return hostname === expected;
1303
1088
  }
1304
1089
  // Dots in pattern should be escaped.
1305
- var escapedDomainPattern = expected.replace(/\./g, '\\.');
1090
+ const escapedDomainPattern = expected.replace(/\./g, '\\.');
1306
1091
  // Non ip address domains.
1307
1092
  // domain.com = *.domain.com OR domain.com
1308
- var re = new RegExp('^(.+\\.' + escapedDomainPattern + '|' + escapedDomainPattern + ')$', 'i');
1093
+ const re = new RegExp('^(.+\\.' + escapedDomainPattern + '|' + escapedDomainPattern + ')$', 'i');
1309
1094
  return re.test(hostname);
1310
1095
  }
1311
1096
 
@@ -1325,7 +1110,7 @@ function matchDomain(expected) {
1325
1110
  * See the License for the specific language governing permissions and
1326
1111
  * limitations under the License.
1327
1112
  */
1328
- var NETWORK_TIMEOUT = new Delay(30000, 60000);
1113
+ const NETWORK_TIMEOUT = new Delay(30000, 60000);
1329
1114
  /**
1330
1115
  * Reset unloaded GApi modules. If gapi.load fails due to a network error,
1331
1116
  * it will stop working after a retrial. This is a hack to fix this issue.
@@ -1334,21 +1119,20 @@ function resetUnloadedGapiModules() {
1334
1119
  // Clear last failed gapi.load state to force next gapi.load to first
1335
1120
  // load the failed gapi.iframes module.
1336
1121
  // Get gapix.beacon context.
1337
- var beacon = _window().___jsl;
1122
+ const beacon = _window().___jsl;
1338
1123
  // Get current hint.
1339
1124
  if (beacon === null || beacon === void 0 ? void 0 : beacon.H) {
1340
1125
  // Get gapi hint.
1341
- for (var _i = 0, _a = Object.keys(beacon.H); _i < _a.length; _i++) {
1342
- var hint = _a[_i];
1126
+ for (const hint of Object.keys(beacon.H)) {
1343
1127
  // Requested modules.
1344
1128
  beacon.H[hint].r = beacon.H[hint].r || [];
1345
1129
  // Loaded modules.
1346
1130
  beacon.H[hint].L = beacon.H[hint].L || [];
1347
1131
  // Set requested modules to a copy of the loaded modules.
1348
- beacon.H[hint].r = __spreadArray([], beacon.H[hint].L, true);
1132
+ beacon.H[hint].r = [...beacon.H[hint].L];
1349
1133
  // Clear pending callbacks.
1350
1134
  if (beacon.CP) {
1351
- for (var i = 0; i < beacon.CP.length; i++) {
1135
+ for (let i = 0; i < beacon.CP.length; i++) {
1352
1136
  // Remove all failed pending callbacks.
1353
1137
  beacon.CP[i] = null;
1354
1138
  }
@@ -1357,7 +1141,7 @@ function resetUnloadedGapiModules() {
1357
1141
  }
1358
1142
  }
1359
1143
  function loadGapi(auth) {
1360
- return new Promise(function (resolve, reject) {
1144
+ return new Promise((resolve, reject) => {
1361
1145
  var _a, _b, _c;
1362
1146
  // Function to run when gapi.load is ready.
1363
1147
  function loadGapiIframe() {
@@ -1365,10 +1149,10 @@ function loadGapi(auth) {
1365
1149
  // Run this to fix that.
1366
1150
  resetUnloadedGapiModules();
1367
1151
  gapi.load('gapi.iframes', {
1368
- callback: function () {
1152
+ callback: () => {
1369
1153
  resolve(gapi.iframes.getContext());
1370
1154
  },
1371
- ontimeout: function () {
1155
+ ontimeout: () => {
1372
1156
  // The above reset may be sufficient, but having this reset after
1373
1157
  // failure ensures that if the developer calls gapi.load after the
1374
1158
  // connection is re-established and before another attempt to embed
@@ -1395,9 +1179,9 @@ function loadGapi(auth) {
1395
1179
  // multiple times in parallel and could result in the later callback
1396
1180
  // overwriting the previous one. This would end up with a iframe
1397
1181
  // timeout.
1398
- var cbName = _generateCallbackName('iframefcb');
1182
+ const cbName = _generateCallbackName('iframefcb');
1399
1183
  // GApi loader not available, dynamically load platform.js.
1400
- _window()[cbName] = function () {
1184
+ _window()[cbName] = () => {
1401
1185
  // GApi loader should be ready.
1402
1186
  if (!!gapi.load) {
1403
1187
  loadGapiIframe();
@@ -1408,16 +1192,16 @@ function loadGapi(auth) {
1408
1192
  }
1409
1193
  };
1410
1194
  // Load GApi loader.
1411
- return _loadJS("".concat(_gapiScriptUrl(), "?onload=").concat(cbName))
1412
- .catch(function (e) { return reject(e); });
1195
+ return _loadJS(`${_gapiScriptUrl()}?onload=${cbName}`)
1196
+ .catch(e => reject(e));
1413
1197
  }
1414
- }).catch(function (error) {
1198
+ }).catch(error => {
1415
1199
  // Reset cached promise to allow for retrial.
1416
1200
  cachedGApiLoader = null;
1417
1201
  throw error;
1418
1202
  });
1419
1203
  }
1420
- var cachedGApiLoader = null;
1204
+ let cachedGApiLoader = null;
1421
1205
  function _loadGapi(auth) {
1422
1206
  cachedGApiLoader = cachedGApiLoader || loadGapi(auth);
1423
1207
  return cachedGApiLoader;
@@ -1439,10 +1223,10 @@ function _loadGapi(auth) {
1439
1223
  * See the License for the specific language governing permissions and
1440
1224
  * limitations under the License.
1441
1225
  */
1442
- var PING_TIMEOUT = new Delay(5000, 15000);
1443
- var IFRAME_PATH = '__/auth/iframe';
1444
- var EMULATED_IFRAME_PATH = 'emulator/auth/iframe';
1445
- var IFRAME_ATTRIBUTES = {
1226
+ const PING_TIMEOUT = new Delay(5000, 15000);
1227
+ const IFRAME_PATH = '__/auth/iframe';
1228
+ const EMULATED_IFRAME_PATH = 'emulator/auth/iframe';
1229
+ const IFRAME_ATTRIBUTES = {
1446
1230
  style: {
1447
1231
  position: 'absolute',
1448
1232
  top: '-100px',
@@ -1454,82 +1238,64 @@ var IFRAME_ATTRIBUTES = {
1454
1238
  };
1455
1239
  // Map from apiHost to endpoint ID for passing into iframe. In current SDK, apiHost can be set to
1456
1240
  // anything (not from a list of endpoints with IDs as in legacy), so this is the closest we can get.
1457
- var EID_FROM_APIHOST = new Map([
1241
+ const EID_FROM_APIHOST = new Map([
1458
1242
  ["identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */, 'p'],
1459
1243
  ['staging-identitytoolkit.sandbox.googleapis.com', 's'],
1460
1244
  ['test-identitytoolkit.sandbox.googleapis.com', 't'] // test
1461
1245
  ]);
1462
1246
  function getIframeUrl(auth) {
1463
- var config = auth.config;
1247
+ const config = auth.config;
1464
1248
  _assert(config.authDomain, auth, "auth-domain-config-required" /* AuthErrorCode.MISSING_AUTH_DOMAIN */);
1465
- var url = config.emulator
1249
+ const url = config.emulator
1466
1250
  ? _emulatorUrl(config, EMULATED_IFRAME_PATH)
1467
- : "https://".concat(auth.config.authDomain, "/").concat(IFRAME_PATH);
1468
- var params = {
1251
+ : `https://${auth.config.authDomain}/${IFRAME_PATH}`;
1252
+ const params = {
1469
1253
  apiKey: config.apiKey,
1470
1254
  appName: auth.name,
1471
1255
  v: SDK_VERSION
1472
1256
  };
1473
- var eid = EID_FROM_APIHOST.get(auth.config.apiHost);
1257
+ const eid = EID_FROM_APIHOST.get(auth.config.apiHost);
1474
1258
  if (eid) {
1475
1259
  params.eid = eid;
1476
1260
  }
1477
- var frameworks = auth._getFrameworks();
1261
+ const frameworks = auth._getFrameworks();
1478
1262
  if (frameworks.length) {
1479
1263
  params.fw = frameworks.join(',');
1480
1264
  }
1481
- return "".concat(url, "?").concat(querystring(params).slice(1));
1265
+ return `${url}?${querystring(params).slice(1)}`;
1482
1266
  }
1483
- function _openIframe(auth) {
1484
- return __awaiter(this, void 0, void 0, function () {
1485
- var context, gapi;
1486
- var _this = this;
1487
- return __generator(this, function (_a) {
1488
- switch (_a.label) {
1489
- case 0: return [4 /*yield*/, _loadGapi(auth)];
1490
- case 1:
1491
- context = _a.sent();
1492
- gapi = _window().gapi;
1493
- _assert(gapi, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1494
- return [2 /*return*/, context.open({
1495
- where: document.body,
1496
- url: getIframeUrl(auth),
1497
- messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
1498
- attributes: IFRAME_ATTRIBUTES,
1499
- dontclear: true
1500
- }, function (iframe) {
1501
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1502
- // Clear timer and resolve pending iframe ready promise.
1503
- function clearTimerAndResolve() {
1504
- _window().clearTimeout(networkErrorTimer);
1505
- resolve(iframe);
1506
- }
1507
- var networkError, networkErrorTimer;
1508
- return __generator(this, function (_a) {
1509
- switch (_a.label) {
1510
- case 0: return [4 /*yield*/, iframe.restyle({
1511
- // Prevent iframe from closing on mouse out.
1512
- setHideOnLeave: false
1513
- })];
1514
- case 1:
1515
- _a.sent();
1516
- networkError = _createError(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */);
1517
- networkErrorTimer = _window().setTimeout(function () {
1518
- reject(networkError);
1519
- }, PING_TIMEOUT.get());
1520
- // This returns an IThenable. However the reject part does not call
1521
- // when the iframe is not loaded.
1522
- iframe.ping(clearTimerAndResolve).then(clearTimerAndResolve, function () {
1523
- reject(networkError);
1524
- });
1525
- return [2 /*return*/];
1526
- }
1527
- });
1528
- }); });
1529
- })];
1530
- }
1267
+ async function _openIframe(auth) {
1268
+ const context = await _loadGapi(auth);
1269
+ const gapi = _window().gapi;
1270
+ _assert(gapi, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1271
+ return context.open({
1272
+ where: document.body,
1273
+ url: getIframeUrl(auth),
1274
+ messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
1275
+ attributes: IFRAME_ATTRIBUTES,
1276
+ dontclear: true
1277
+ }, (iframe) => new Promise(async (resolve, reject) => {
1278
+ await iframe.restyle({
1279
+ // Prevent iframe from closing on mouse out.
1280
+ setHideOnLeave: false
1531
1281
  });
1532
- });
1282
+ const networkError = _createError(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */);
1283
+ // Confirm iframe is correctly loaded.
1284
+ // To fallback on failure, set a timeout.
1285
+ const networkErrorTimer = _window().setTimeout(() => {
1286
+ reject(networkError);
1287
+ }, PING_TIMEOUT.get());
1288
+ // Clear timer and resolve pending iframe ready promise.
1289
+ function clearTimerAndResolve() {
1290
+ _window().clearTimeout(networkErrorTimer);
1291
+ resolve(iframe);
1292
+ }
1293
+ // This returns an IThenable. However the reject part does not call
1294
+ // when the iframe is not loaded.
1295
+ iframe.ping(clearTimerAndResolve).then(clearTimerAndResolve, () => {
1296
+ reject(networkError);
1297
+ });
1298
+ }));
1533
1299
  }
1534
1300
 
1535
1301
  /**
@@ -1548,41 +1314,39 @@ function _openIframe(auth) {
1548
1314
  * See the License for the specific language governing permissions and
1549
1315
  * limitations under the License.
1550
1316
  */
1551
- var BASE_POPUP_OPTIONS = {
1317
+ const BASE_POPUP_OPTIONS = {
1552
1318
  location: 'yes',
1553
1319
  resizable: 'yes',
1554
1320
  statusbar: 'yes',
1555
1321
  toolbar: 'no'
1556
1322
  };
1557
- var DEFAULT_WIDTH = 500;
1558
- var DEFAULT_HEIGHT = 600;
1559
- var TARGET_BLANK = '_blank';
1560
- var FIREFOX_EMPTY_URL = 'http://localhost';
1561
- var AuthPopup = /** @class */ (function () {
1562
- function AuthPopup(window) {
1323
+ const DEFAULT_WIDTH = 500;
1324
+ const DEFAULT_HEIGHT = 600;
1325
+ const TARGET_BLANK = '_blank';
1326
+ const FIREFOX_EMPTY_URL = 'http://localhost';
1327
+ class AuthPopup {
1328
+ constructor(window) {
1563
1329
  this.window = window;
1564
1330
  this.associatedEvent = null;
1565
1331
  }
1566
- AuthPopup.prototype.close = function () {
1332
+ close() {
1567
1333
  if (this.window) {
1568
1334
  try {
1569
1335
  this.window.close();
1570
1336
  }
1571
1337
  catch (e) { }
1572
1338
  }
1573
- };
1574
- return AuthPopup;
1575
- }());
1576
- function _open(auth, url, name, width, height) {
1577
- if (width === void 0) { width = DEFAULT_WIDTH; }
1578
- if (height === void 0) { height = DEFAULT_HEIGHT; }
1579
- var top = Math.max((window.screen.availHeight - height) / 2, 0).toString();
1580
- var left = Math.max((window.screen.availWidth - width) / 2, 0).toString();
1581
- var target = '';
1582
- var options = __assign(__assign({}, BASE_POPUP_OPTIONS), { width: width.toString(), height: height.toString(), top: top, left: left });
1339
+ }
1340
+ }
1341
+ function _open(auth, url, name, width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT) {
1342
+ const top = Math.max((window.screen.availHeight - height) / 2, 0).toString();
1343
+ const left = Math.max((window.screen.availWidth - width) / 2, 0).toString();
1344
+ let target = '';
1345
+ const options = Object.assign(Object.assign({}, BASE_POPUP_OPTIONS), { width: width.toString(), height: height.toString(), top,
1346
+ left });
1583
1347
  // Chrome iOS 7 and 8 is returning an undefined popup win when target is
1584
1348
  // specified, even though the popup is not necessarily blocked.
1585
- var ua = getUA().toLowerCase();
1349
+ const ua = getUA().toLowerCase();
1586
1350
  if (name) {
1587
1351
  target = _isChromeIOS(ua) ? TARGET_BLANK : name;
1588
1352
  }
@@ -1593,17 +1357,14 @@ function _open(auth, url, name, width, height) {
1593
1357
  // issues when the user has many Google accounts, for instance.
1594
1358
  options.scrollbars = 'yes';
1595
1359
  }
1596
- var optionsString = Object.entries(options).reduce(function (accum, _a) {
1597
- var key = _a[0], value = _a[1];
1598
- return "".concat(accum).concat(key, "=").concat(value, ",");
1599
- }, '');
1360
+ const optionsString = Object.entries(options).reduce((accum, [key, value]) => `${accum}${key}=${value},`, '');
1600
1361
  if (_isIOSStandalone(ua) && target !== '_self') {
1601
1362
  openAsNewWindowIOS(url || '', target);
1602
1363
  return new AuthPopup(null);
1603
1364
  }
1604
1365
  // about:blank getting sanitized causing browsers like IE/Edge to display
1605
1366
  // brief error message before redirecting to handler.
1606
- var newWin = window.open(url || '', target, optionsString);
1367
+ const newWin = window.open(url || '', target, optionsString);
1607
1368
  _assert(newWin, auth, "popup-blocked" /* AuthErrorCode.POPUP_BLOCKED */);
1608
1369
  // Flaky on IE edge, encapsulate with a try and catch.
1609
1370
  try {
@@ -1613,10 +1374,10 @@ function _open(auth, url, name, width, height) {
1613
1374
  return new AuthPopup(newWin);
1614
1375
  }
1615
1376
  function openAsNewWindowIOS(url, target) {
1616
- var el = document.createElement('a');
1377
+ const el = document.createElement('a');
1617
1378
  el.href = url;
1618
1379
  el.target = target;
1619
- var click = document.createEvent('MouseEvent');
1380
+ const click = document.createEvent('MouseEvent');
1620
1381
  click.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 1, null);
1621
1382
  el.dispatchEvent(click);
1622
1383
  }
@@ -1641,9 +1402,9 @@ function openAsNewWindowIOS(url, target) {
1641
1402
  * The special web storage event
1642
1403
  *
1643
1404
  */
1644
- var WEB_STORAGE_SUPPORT_KEY = 'webStorageSupport';
1645
- var BrowserPopupRedirectResolver = /** @class */ (function () {
1646
- function BrowserPopupRedirectResolver() {
1405
+ const WEB_STORAGE_SUPPORT_KEY = 'webStorageSupport';
1406
+ class BrowserPopupRedirectResolver {
1407
+ constructor() {
1647
1408
  this.eventManagers = {};
1648
1409
  this.iframes = {};
1649
1410
  this.originValidationPromises = {};
@@ -1653,111 +1414,75 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
1653
1414
  }
1654
1415
  // Wrapping in async even though we don't await anywhere in order
1655
1416
  // to make sure errors are raised as promise rejections
1656
- BrowserPopupRedirectResolver.prototype._openPopup = function (auth, provider, authType, eventId) {
1417
+ async _openPopup(auth, provider, authType, eventId) {
1657
1418
  var _a;
1658
- return __awaiter(this, void 0, void 0, function () {
1659
- var url;
1660
- return __generator(this, function (_b) {
1661
- switch (_b.label) {
1662
- case 0:
1663
- debugAssert((_a = this.eventManagers[auth._key()]) === null || _a === void 0 ? void 0 : _a.manager, '_initialize() not called before _openPopup()');
1664
- return [4 /*yield*/, _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId)];
1665
- case 1:
1666
- url = _b.sent();
1667
- return [2 /*return*/, _open(auth, url, _generateEventId())];
1668
- }
1669
- });
1670
- });
1671
- };
1672
- BrowserPopupRedirectResolver.prototype._openRedirect = function (auth, provider, authType, eventId) {
1673
- return __awaiter(this, void 0, void 0, function () {
1674
- var url;
1675
- return __generator(this, function (_a) {
1676
- switch (_a.label) {
1677
- case 0: return [4 /*yield*/, this._originValidation(auth)];
1678
- case 1:
1679
- _a.sent();
1680
- return [4 /*yield*/, _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId)];
1681
- case 2:
1682
- url = _a.sent();
1683
- _setWindowLocation(url);
1684
- return [2 /*return*/, new Promise(function () { })];
1685
- }
1686
- });
1687
- });
1688
- };
1689
- BrowserPopupRedirectResolver.prototype._initialize = function (auth) {
1690
- var _this = this;
1691
- var key = auth._key();
1419
+ debugAssert((_a = this.eventManagers[auth._key()]) === null || _a === void 0 ? void 0 : _a.manager, '_initialize() not called before _openPopup()');
1420
+ const url = await _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
1421
+ return _open(auth, url, _generateEventId());
1422
+ }
1423
+ async _openRedirect(auth, provider, authType, eventId) {
1424
+ await this._originValidation(auth);
1425
+ const url = await _getRedirectUrl(auth, provider, authType, _getCurrentUrl(), eventId);
1426
+ _setWindowLocation(url);
1427
+ return new Promise(() => { });
1428
+ }
1429
+ _initialize(auth) {
1430
+ const key = auth._key();
1692
1431
  if (this.eventManagers[key]) {
1693
- var _a = this.eventManagers[key], manager = _a.manager, promise_1 = _a.promise;
1432
+ const { manager, promise } = this.eventManagers[key];
1694
1433
  if (manager) {
1695
1434
  return Promise.resolve(manager);
1696
1435
  }
1697
1436
  else {
1698
- debugAssert(promise_1, 'If manager is not set, promise should be');
1699
- return promise_1;
1437
+ debugAssert(promise, 'If manager is not set, promise should be');
1438
+ return promise;
1700
1439
  }
1701
1440
  }
1702
- var promise = this.initAndGetManager(auth);
1703
- this.eventManagers[key] = { promise: promise };
1441
+ const promise = this.initAndGetManager(auth);
1442
+ this.eventManagers[key] = { promise };
1704
1443
  // If the promise is rejected, the key should be removed so that the
1705
1444
  // operation can be retried later.
1706
- promise.catch(function () {
1707
- delete _this.eventManagers[key];
1445
+ promise.catch(() => {
1446
+ delete this.eventManagers[key];
1708
1447
  });
1709
1448
  return promise;
1710
- };
1711
- BrowserPopupRedirectResolver.prototype.initAndGetManager = function (auth) {
1712
- return __awaiter(this, void 0, void 0, function () {
1713
- var iframe, manager;
1714
- return __generator(this, function (_a) {
1715
- switch (_a.label) {
1716
- case 0: return [4 /*yield*/, _openIframe(auth)];
1717
- case 1:
1718
- iframe = _a.sent();
1719
- manager = new AuthEventManager(auth);
1720
- iframe.register('authEvent', function (iframeEvent) {
1721
- _assert(iframeEvent === null || iframeEvent === void 0 ? void 0 : iframeEvent.authEvent, auth, "invalid-auth-event" /* AuthErrorCode.INVALID_AUTH_EVENT */);
1722
- // TODO: Consider splitting redirect and popup events earlier on
1723
- var handled = manager.onEvent(iframeEvent.authEvent);
1724
- return { status: handled ? "ACK" /* GapiOutcome.ACK */ : "ERROR" /* GapiOutcome.ERROR */ };
1725
- }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
1726
- this.eventManagers[auth._key()] = { manager: manager };
1727
- this.iframes[auth._key()] = iframe;
1728
- return [2 /*return*/, manager];
1729
- }
1730
- });
1731
- });
1732
- };
1733
- BrowserPopupRedirectResolver.prototype._isIframeWebStorageSupported = function (auth, cb) {
1734
- var iframe = this.iframes[auth._key()];
1735
- iframe.send(WEB_STORAGE_SUPPORT_KEY, { type: WEB_STORAGE_SUPPORT_KEY }, function (result) {
1449
+ }
1450
+ async initAndGetManager(auth) {
1451
+ const iframe = await _openIframe(auth);
1452
+ const manager = new AuthEventManager(auth);
1453
+ iframe.register('authEvent', (iframeEvent) => {
1454
+ _assert(iframeEvent === null || iframeEvent === void 0 ? void 0 : iframeEvent.authEvent, auth, "invalid-auth-event" /* AuthErrorCode.INVALID_AUTH_EVENT */);
1455
+ // TODO: Consider splitting redirect and popup events earlier on
1456
+ const handled = manager.onEvent(iframeEvent.authEvent);
1457
+ return { status: handled ? "ACK" /* GapiOutcome.ACK */ : "ERROR" /* GapiOutcome.ERROR */ };
1458
+ }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
1459
+ this.eventManagers[auth._key()] = { manager };
1460
+ this.iframes[auth._key()] = iframe;
1461
+ return manager;
1462
+ }
1463
+ _isIframeWebStorageSupported(auth, cb) {
1464
+ const iframe = this.iframes[auth._key()];
1465
+ iframe.send(WEB_STORAGE_SUPPORT_KEY, { type: WEB_STORAGE_SUPPORT_KEY }, result => {
1736
1466
  var _a;
1737
- var isSupported = (_a = result === null || result === void 0 ? void 0 : result[0]) === null || _a === void 0 ? void 0 : _a[WEB_STORAGE_SUPPORT_KEY];
1467
+ const isSupported = (_a = result === null || result === void 0 ? void 0 : result[0]) === null || _a === void 0 ? void 0 : _a[WEB_STORAGE_SUPPORT_KEY];
1738
1468
  if (isSupported !== undefined) {
1739
1469
  cb(!!isSupported);
1740
1470
  }
1741
1471
  _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1742
1472
  }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
1743
- };
1744
- BrowserPopupRedirectResolver.prototype._originValidation = function (auth) {
1745
- var key = auth._key();
1473
+ }
1474
+ _originValidation(auth) {
1475
+ const key = auth._key();
1746
1476
  if (!this.originValidationPromises[key]) {
1747
1477
  this.originValidationPromises[key] = _validateOrigin(auth);
1748
1478
  }
1749
1479
  return this.originValidationPromises[key];
1750
- };
1751
- Object.defineProperty(BrowserPopupRedirectResolver.prototype, "_shouldInitProactively", {
1752
- get: function () {
1753
- // Mobile browsers and Safari need to optimistically initialize
1754
- return _isMobileBrowser() || _isSafari() || _isIOS();
1755
- },
1756
- enumerable: false,
1757
- configurable: true
1758
- });
1759
- return BrowserPopupRedirectResolver;
1760
- }());
1480
+ }
1481
+ get _shouldInitProactively() {
1482
+ // Mobile browsers and Safari need to optimistically initialize
1483
+ return _isMobileBrowser() || _isSafari() || _isIOS();
1484
+ }
1485
+ }
1761
1486
  /**
1762
1487
  * An implementation of {@link PopupRedirectResolver} suitable for browser
1763
1488
  * based applications.
@@ -1767,13 +1492,13 @@ var BrowserPopupRedirectResolver = /** @class */ (function () {
1767
1492
  *
1768
1493
  * @public
1769
1494
  */
1770
- var browserPopupRedirectResolver = BrowserPopupRedirectResolver;
1495
+ const browserPopupRedirectResolver = BrowserPopupRedirectResolver;
1771
1496
 
1772
- var MultiFactorAssertionImpl = /** @class */ (function () {
1773
- function MultiFactorAssertionImpl(factorId) {
1497
+ class MultiFactorAssertionImpl {
1498
+ constructor(factorId) {
1774
1499
  this.factorId = factorId;
1775
1500
  }
1776
- MultiFactorAssertionImpl.prototype._process = function (auth, session, displayName) {
1501
+ _process(auth, session, displayName) {
1777
1502
  switch (session.type) {
1778
1503
  case "enroll" /* MultiFactorSessionType.ENROLL */:
1779
1504
  return this._finalizeEnroll(auth, session.credential, displayName);
@@ -1782,51 +1507,46 @@ var MultiFactorAssertionImpl = /** @class */ (function () {
1782
1507
  default:
1783
1508
  return debugFail('unexpected MultiFactorSessionType');
1784
1509
  }
1785
- };
1786
- return MultiFactorAssertionImpl;
1787
- }());
1510
+ }
1511
+ }
1788
1512
 
1789
1513
  /**
1790
1514
  * {@inheritdoc PhoneMultiFactorAssertion}
1791
1515
  *
1792
1516
  * @public
1793
1517
  */
1794
- var PhoneMultiFactorAssertionImpl = /** @class */ (function (_super) {
1795
- __extends(PhoneMultiFactorAssertionImpl, _super);
1796
- function PhoneMultiFactorAssertionImpl(credential) {
1797
- var _this = _super.call(this, "phone" /* FactorId.PHONE */) || this;
1798
- _this.credential = credential;
1799
- return _this;
1518
+ class PhoneMultiFactorAssertionImpl extends MultiFactorAssertionImpl {
1519
+ constructor(credential) {
1520
+ super("phone" /* FactorId.PHONE */);
1521
+ this.credential = credential;
1800
1522
  }
1801
1523
  /** @internal */
1802
- PhoneMultiFactorAssertionImpl._fromCredential = function (credential) {
1524
+ static _fromCredential(credential) {
1803
1525
  return new PhoneMultiFactorAssertionImpl(credential);
1804
- };
1526
+ }
1805
1527
  /** @internal */
1806
- PhoneMultiFactorAssertionImpl.prototype._finalizeEnroll = function (auth, idToken, displayName) {
1528
+ _finalizeEnroll(auth, idToken, displayName) {
1807
1529
  return finalizeEnrollPhoneMfa(auth, {
1808
- idToken: idToken,
1809
- displayName: displayName,
1530
+ idToken,
1531
+ displayName,
1810
1532
  phoneVerificationInfo: this.credential._makeVerificationRequest()
1811
1533
  });
1812
- };
1534
+ }
1813
1535
  /** @internal */
1814
- PhoneMultiFactorAssertionImpl.prototype._finalizeSignIn = function (auth, mfaPendingCredential) {
1536
+ _finalizeSignIn(auth, mfaPendingCredential) {
1815
1537
  return finalizeSignInPhoneMfa(auth, {
1816
- mfaPendingCredential: mfaPendingCredential,
1538
+ mfaPendingCredential,
1817
1539
  phoneVerificationInfo: this.credential._makeVerificationRequest()
1818
1540
  });
1819
- };
1820
- return PhoneMultiFactorAssertionImpl;
1821
- }(MultiFactorAssertionImpl));
1541
+ }
1542
+ }
1822
1543
  /**
1823
1544
  * Provider for generating a {@link PhoneMultiFactorAssertion}.
1824
1545
  *
1825
1546
  * @public
1826
1547
  */
1827
- var PhoneMultiFactorGenerator = /** @class */ (function () {
1828
- function PhoneMultiFactorGenerator() {
1829
- }
1548
+ class PhoneMultiFactorGenerator {
1549
+ constructor() { }
1830
1550
  /**
1831
1551
  * Provides a {@link PhoneMultiFactorAssertion} to confirm ownership of the phone second factor.
1832
1552
  *
@@ -1837,24 +1557,21 @@ var PhoneMultiFactorGenerator = /** @class */ (function () {
1837
1557
  * @returns A {@link PhoneMultiFactorAssertion} which can be used with
1838
1558
  * {@link MultiFactorResolver.resolveSignIn}
1839
1559
  */
1840
- PhoneMultiFactorGenerator.assertion = function (credential) {
1560
+ static assertion(credential) {
1841
1561
  return PhoneMultiFactorAssertionImpl._fromCredential(credential);
1842
- };
1843
- /**
1844
- * The identifier of the phone second factor: `phone`.
1845
- */
1846
- PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
1847
- return PhoneMultiFactorGenerator;
1848
- }());
1562
+ }
1563
+ }
1564
+ /**
1565
+ * The identifier of the phone second factor: `phone`.
1566
+ */
1567
+ PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
1849
1568
 
1850
1569
  /**
1851
1570
  * Provider for generating a {@link TotpMultiFactorAssertion}.
1852
1571
  *
1853
1572
  * @public
1854
1573
  */
1855
- var TotpMultiFactorGenerator = /** @class */ (function () {
1856
- function TotpMultiFactorGenerator() {
1857
- }
1574
+ class TotpMultiFactorGenerator {
1858
1575
  /**
1859
1576
  * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
1860
1577
  * the TOTP (time-based one-time password) second factor.
@@ -1865,9 +1582,9 @@ var TotpMultiFactorGenerator = /** @class */ (function () {
1865
1582
  * @returns A {@link TotpMultiFactorAssertion} which can be used with
1866
1583
  * {@link MultiFactorUser.enroll}.
1867
1584
  */
1868
- TotpMultiFactorGenerator.assertionForEnrollment = function (secret, oneTimePassword) {
1585
+ static assertionForEnrollment(secret, oneTimePassword) {
1869
1586
  return TotpMultiFactorAssertionImpl._fromSecret(secret, oneTimePassword);
1870
- };
1587
+ }
1871
1588
  /**
1872
1589
  * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
1873
1590
  * This assertion is used to complete signIn with TOTP as the second factor.
@@ -1877,9 +1594,9 @@ var TotpMultiFactorGenerator = /** @class */ (function () {
1877
1594
  * @returns A {@link TotpMultiFactorAssertion} which can be used with
1878
1595
  * {@link MultiFactorResolver.resolveSignIn}.
1879
1596
  */
1880
- TotpMultiFactorGenerator.assertionForSignIn = function (enrollmentId, oneTimePassword) {
1597
+ static assertionForSignIn(enrollmentId, oneTimePassword) {
1881
1598
  return TotpMultiFactorAssertionImpl._fromEnrollmentId(enrollmentId, oneTimePassword);
1882
- };
1599
+ }
1883
1600
  /**
1884
1601
  * Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
1885
1602
  * Creates a TOTP secret as part of enrolling a TOTP second factor.
@@ -1889,79 +1606,56 @@ var TotpMultiFactorGenerator = /** @class */ (function () {
1889
1606
  * @param session The {@link MultiFactorSession} that the user is part of.
1890
1607
  * @returns A promise to {@link TotpSecret}.
1891
1608
  */
1892
- TotpMultiFactorGenerator.generateSecret = function (session) {
1609
+ static async generateSecret(session) {
1893
1610
  var _a;
1894
- return __awaiter(this, void 0, void 0, function () {
1895
- var mfaSession, response;
1896
- return __generator(this, function (_b) {
1897
- switch (_b.label) {
1898
- case 0:
1899
- mfaSession = session;
1900
- _assert(typeof ((_a = mfaSession.user) === null || _a === void 0 ? void 0 : _a.auth) !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1901
- return [4 /*yield*/, startEnrollTotpMfa(mfaSession.user.auth, {
1902
- idToken: mfaSession.credential,
1903
- totpEnrollmentInfo: {}
1904
- })];
1905
- case 1:
1906
- response = _b.sent();
1907
- return [2 /*return*/, TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.user.auth)];
1908
- }
1909
- });
1611
+ const mfaSession = session;
1612
+ _assert(typeof ((_a = mfaSession.user) === null || _a === void 0 ? void 0 : _a.auth) !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1613
+ const response = await startEnrollTotpMfa(mfaSession.user.auth, {
1614
+ idToken: mfaSession.credential,
1615
+ totpEnrollmentInfo: {}
1910
1616
  });
1911
- };
1912
- /**
1913
- * The identifier of the TOTP second factor: `totp`.
1914
- */
1915
- TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
1916
- return TotpMultiFactorGenerator;
1917
- }());
1918
- var TotpMultiFactorAssertionImpl = /** @class */ (function (_super) {
1919
- __extends(TotpMultiFactorAssertionImpl, _super);
1920
- function TotpMultiFactorAssertionImpl(otp, enrollmentId, secret) {
1921
- var _this = _super.call(this, "totp" /* FactorId.TOTP */) || this;
1922
- _this.otp = otp;
1923
- _this.enrollmentId = enrollmentId;
1924
- _this.secret = secret;
1925
- return _this;
1617
+ return TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.user.auth);
1618
+ }
1619
+ }
1620
+ /**
1621
+ * The identifier of the TOTP second factor: `totp`.
1622
+ */
1623
+ TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
1624
+ class TotpMultiFactorAssertionImpl extends MultiFactorAssertionImpl {
1625
+ constructor(otp, enrollmentId, secret) {
1626
+ super("totp" /* FactorId.TOTP */);
1627
+ this.otp = otp;
1628
+ this.enrollmentId = enrollmentId;
1629
+ this.secret = secret;
1926
1630
  }
1927
1631
  /** @internal */
1928
- TotpMultiFactorAssertionImpl._fromSecret = function (secret, otp) {
1632
+ static _fromSecret(secret, otp) {
1929
1633
  return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
1930
- };
1634
+ }
1931
1635
  /** @internal */
1932
- TotpMultiFactorAssertionImpl._fromEnrollmentId = function (enrollmentId, otp) {
1636
+ static _fromEnrollmentId(enrollmentId, otp) {
1933
1637
  return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
1934
- };
1638
+ }
1935
1639
  /** @internal */
1936
- TotpMultiFactorAssertionImpl.prototype._finalizeEnroll = function (auth, idToken, displayName) {
1937
- return __awaiter(this, void 0, void 0, function () {
1938
- return __generator(this, function (_a) {
1939
- _assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
1940
- return [2 /*return*/, finalizeEnrollTotpMfa(auth, {
1941
- idToken: idToken,
1942
- displayName: displayName,
1943
- totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
1944
- })];
1945
- });
1640
+ async _finalizeEnroll(auth, idToken, displayName) {
1641
+ _assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
1642
+ return finalizeEnrollTotpMfa(auth, {
1643
+ idToken,
1644
+ displayName,
1645
+ totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
1946
1646
  });
1947
- };
1647
+ }
1948
1648
  /** @internal */
1949
- TotpMultiFactorAssertionImpl.prototype._finalizeSignIn = function (auth, mfaPendingCredential) {
1950
- return __awaiter(this, void 0, void 0, function () {
1951
- var totpVerificationInfo;
1952
- return __generator(this, function (_a) {
1953
- _assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
1954
- totpVerificationInfo = { verificationCode: this.otp };
1955
- return [2 /*return*/, finalizeSignInTotpMfa(auth, {
1956
- mfaPendingCredential: mfaPendingCredential,
1957
- mfaEnrollmentId: this.enrollmentId,
1958
- totpVerificationInfo: totpVerificationInfo
1959
- })];
1960
- });
1649
+ async _finalizeSignIn(auth, mfaPendingCredential) {
1650
+ _assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
1651
+ const totpVerificationInfo = { verificationCode: this.otp };
1652
+ return finalizeSignInTotpMfa(auth, {
1653
+ mfaPendingCredential,
1654
+ mfaEnrollmentId: this.enrollmentId,
1655
+ totpVerificationInfo
1961
1656
  });
1962
- };
1963
- return TotpMultiFactorAssertionImpl;
1964
- }(MultiFactorAssertionImpl));
1657
+ }
1658
+ }
1965
1659
  /**
1966
1660
  * Provider for generating a {@link TotpMultiFactorAssertion}.
1967
1661
  *
@@ -1969,9 +1663,9 @@ var TotpMultiFactorAssertionImpl = /** @class */ (function (_super) {
1969
1663
  * Implements methods to retrieve the shared secret key and generate a QR code URL.
1970
1664
  * @public
1971
1665
  */
1972
- var TotpSecret = /** @class */ (function () {
1666
+ class TotpSecret {
1973
1667
  // The public members are declared outside the constructor so the docs can be generated.
1974
- function TotpSecret(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
1668
+ constructor(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
1975
1669
  this.sessionInfo = sessionInfo;
1976
1670
  this.auth = auth;
1977
1671
  this.secretKey = secretKey;
@@ -1981,13 +1675,13 @@ var TotpSecret = /** @class */ (function () {
1981
1675
  this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
1982
1676
  }
1983
1677
  /** @internal */
1984
- TotpSecret._fromStartTotpMfaEnrollmentResponse = function (response, auth) {
1678
+ static _fromStartTotpMfaEnrollmentResponse(response, auth) {
1985
1679
  return new TotpSecret(response.totpSessionInfo.sharedSecretKey, response.totpSessionInfo.hashingAlgorithm, response.totpSessionInfo.verificationCodeLength, response.totpSessionInfo.periodSec, new Date(response.totpSessionInfo.finalizeEnrollmentTime).toUTCString(), response.totpSessionInfo.sessionInfo, auth);
1986
- };
1680
+ }
1987
1681
  /** @internal */
1988
- TotpSecret.prototype._makeTotpVerificationInfo = function (otp) {
1682
+ _makeTotpVerificationInfo(otp) {
1989
1683
  return { sessionInfo: this.sessionInfo, verificationCode: otp };
1990
- };
1684
+ }
1991
1685
  /**
1992
1686
  * Returns a QR code URL as described in
1993
1687
  * https://github.com/google/google-authenticator/wiki/Key-Uri-Format
@@ -1998,9 +1692,9 @@ var TotpSecret = /** @class */ (function () {
1998
1692
  * @param issuer issuer of the TOTP (likely the app name).
1999
1693
  * @returns A QR code URL string.
2000
1694
  */
2001
- TotpSecret.prototype.generateQrCodeUrl = function (accountName, issuer) {
1695
+ generateQrCodeUrl(accountName, issuer) {
2002
1696
  var _a;
2003
- var useDefaults = false;
1697
+ let useDefaults = false;
2004
1698
  if (_isEmptyString(accountName) || _isEmptyString(issuer)) {
2005
1699
  useDefaults = true;
2006
1700
  }
@@ -2012,10 +1706,9 @@ var TotpSecret = /** @class */ (function () {
2012
1706
  issuer = this.auth.name;
2013
1707
  }
2014
1708
  }
2015
- return "otpauth://totp/".concat(issuer, ":").concat(accountName, "?secret=").concat(this.secretKey, "&issuer=").concat(issuer, "&algorithm=").concat(this.hashingAlgorithm, "&digits=").concat(this.codeLength);
2016
- };
2017
- return TotpSecret;
2018
- }());
1709
+ return `otpauth://totp/${issuer}:${accountName}?secret=${this.secretKey}&issuer=${issuer}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`;
1710
+ }
1711
+ }
2019
1712
  /** @internal */
2020
1713
  function _isEmptyString(input) {
2021
1714
  return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
@@ -2037,46 +1730,31 @@ function _isEmptyString(input) {
2037
1730
  * See the License for the specific language governing permissions and
2038
1731
  * limitations under the License.
2039
1732
  */
2040
- var DEFAULT_ID_TOKEN_MAX_AGE = 5 * 60;
2041
- var authIdTokenMaxAge = getExperimentalSetting('authIdTokenMaxAge') || DEFAULT_ID_TOKEN_MAX_AGE;
2042
- var lastPostedIdToken = null;
2043
- var mintCookieFactory = function (url) { return function (user) { return __awaiter(void 0, void 0, void 0, function () {
2044
- var idTokenResult, _a, idTokenAge, idToken;
2045
- return __generator(this, function (_b) {
2046
- switch (_b.label) {
2047
- case 0:
2048
- _a = user;
2049
- if (!_a) return [3 /*break*/, 2];
2050
- return [4 /*yield*/, user.getIdTokenResult()];
2051
- case 1:
2052
- _a = (_b.sent());
2053
- _b.label = 2;
2054
- case 2:
2055
- idTokenResult = _a;
2056
- idTokenAge = idTokenResult &&
2057
- (new Date().getTime() - Date.parse(idTokenResult.issuedAtTime)) / 1000;
2058
- if (idTokenAge && idTokenAge > authIdTokenMaxAge) {
2059
- return [2 /*return*/];
2060
- }
2061
- idToken = idTokenResult === null || idTokenResult === void 0 ? void 0 : idTokenResult.token;
2062
- if (lastPostedIdToken === idToken) {
2063
- return [2 /*return*/];
2064
- }
2065
- lastPostedIdToken = idToken;
2066
- return [4 /*yield*/, fetch(url, {
2067
- method: idToken ? 'POST' : 'DELETE',
2068
- headers: idToken
2069
- ? {
2070
- 'Authorization': "Bearer ".concat(idToken)
2071
- }
2072
- : {}
2073
- })];
2074
- case 3:
2075
- _b.sent();
2076
- return [2 /*return*/];
2077
- }
1733
+ const DEFAULT_ID_TOKEN_MAX_AGE = 5 * 60;
1734
+ const authIdTokenMaxAge = getExperimentalSetting('authIdTokenMaxAge') || DEFAULT_ID_TOKEN_MAX_AGE;
1735
+ let lastPostedIdToken = null;
1736
+ const mintCookieFactory = (url) => async (user) => {
1737
+ const idTokenResult = user && (await user.getIdTokenResult());
1738
+ const idTokenAge = idTokenResult &&
1739
+ (new Date().getTime() - Date.parse(idTokenResult.issuedAtTime)) / 1000;
1740
+ if (idTokenAge && idTokenAge > authIdTokenMaxAge) {
1741
+ return;
1742
+ }
1743
+ // Specifically trip null => undefined when logged out, to delete any existing cookie
1744
+ const idToken = idTokenResult === null || idTokenResult === void 0 ? void 0 : idTokenResult.token;
1745
+ if (lastPostedIdToken === idToken) {
1746
+ return;
1747
+ }
1748
+ lastPostedIdToken = idToken;
1749
+ await fetch(url, {
1750
+ method: idToken ? 'POST' : 'DELETE',
1751
+ headers: idToken
1752
+ ? {
1753
+ 'Authorization': `Bearer ${idToken}`
1754
+ }
1755
+ : {}
2078
1756
  });
2079
- }); }; };
1757
+ };
2080
1758
  /**
2081
1759
  * Returns the Auth instance associated with the provided {@link @firebase/app#FirebaseApp}.
2082
1760
  * If no instance exists, initializes an Auth instance with platform-specific default dependencies.
@@ -2085,13 +1763,12 @@ var mintCookieFactory = function (url) { return function (user) { return __await
2085
1763
  *
2086
1764
  * @public
2087
1765
  */
2088
- function getAuth(app) {
2089
- if (app === void 0) { app = getApp(); }
2090
- var provider = _getProvider(app, 'auth');
1766
+ function getAuth(app = getApp()) {
1767
+ const provider = _getProvider(app, 'auth');
2091
1768
  if (provider.isInitialized()) {
2092
1769
  return provider.getImmediate();
2093
1770
  }
2094
- var auth = initializeAuth(app, {
1771
+ const auth = initializeAuth(app, {
2095
1772
  popupRedirectResolver: browserPopupRedirectResolver,
2096
1773
  persistence: [
2097
1774
  indexedDBLocalPersistence,
@@ -2099,24 +1776,22 @@ function getAuth(app) {
2099
1776
  browserSessionPersistence
2100
1777
  ]
2101
1778
  });
2102
- var authTokenSyncPath = getExperimentalSetting('authTokenSyncURL');
1779
+ const authTokenSyncPath = getExperimentalSetting('authTokenSyncURL');
2103
1780
  // Only do the Cookie exchange in a secure context
2104
1781
  if (authTokenSyncPath &&
2105
1782
  typeof isSecureContext === 'boolean' &&
2106
1783
  isSecureContext) {
2107
1784
  // Don't allow urls (XSS possibility), only paths on the same domain
2108
- var authTokenSyncUrl = new URL(authTokenSyncPath, location.origin);
1785
+ const authTokenSyncUrl = new URL(authTokenSyncPath, location.origin);
2109
1786
  if (location.origin === authTokenSyncUrl.origin) {
2110
- var mintCookie_1 = mintCookieFactory(authTokenSyncUrl.toString());
2111
- beforeAuthStateChanged(auth, mintCookie_1, function () {
2112
- return mintCookie_1(auth.currentUser);
2113
- });
2114
- onIdTokenChanged(auth, function (user) { return mintCookie_1(user); });
1787
+ const mintCookie = mintCookieFactory(authTokenSyncUrl.toString());
1788
+ beforeAuthStateChanged(auth, mintCookie, () => mintCookie(auth.currentUser));
1789
+ onIdTokenChanged(auth, user => mintCookie(user));
2115
1790
  }
2116
1791
  }
2117
- var authEmulatorHost = getDefaultEmulatorHost('auth');
1792
+ const authEmulatorHost = getDefaultEmulatorHost('auth');
2118
1793
  if (authEmulatorHost) {
2119
- connectAuthEmulator(auth, "http://".concat(authEmulatorHost));
1794
+ connectAuthEmulator(auth, `http://${authEmulatorHost}`);
2120
1795
  }
2121
1796
  return auth;
2122
1797
  }
@@ -2125,14 +1800,14 @@ function getScriptParentElement() {
2125
1800
  return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
2126
1801
  }
2127
1802
  _setExternalJSProvider({
2128
- loadJS: function (url) {
1803
+ loadJS(url) {
2129
1804
  // TODO: consider adding timeout support & cancellation
2130
- return new Promise(function (resolve, reject) {
2131
- var el = document.createElement('script');
1805
+ return new Promise((resolve, reject) => {
1806
+ const el = document.createElement('script');
2132
1807
  el.setAttribute('src', url);
2133
1808
  el.onload = resolve;
2134
- el.onerror = function (e) {
2135
- var error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1809
+ el.onerror = e => {
1810
+ const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2136
1811
  error.customData = e;
2137
1812
  reject(error);
2138
1813
  };