@firebase/auth 1.5.1 → 1.6.0-20240131233318

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 (657) hide show
  1. package/dist/auth-public.d.ts +1 -1
  2. package/dist/auth.d.ts +3 -2
  3. package/dist/browser-cjs/{index-21814063.js → index-ef98d5d0.js} +57 -25
  4. package/dist/browser-cjs/index-ef98d5d0.js.map +1 -0
  5. package/dist/browser-cjs/index.js +1 -1
  6. package/dist/browser-cjs/index.web-extension.d.ts +31 -0
  7. package/dist/browser-cjs/internal.js +1 -1
  8. package/dist/browser-cjs/src/core/providers/google.d.ts +1 -1
  9. package/dist/browser-cjs/src/core/util/version.d.ts +2 -1
  10. package/dist/browser-cjs/src/platform_browser/load_js.d.ts +11 -0
  11. package/dist/cordova/index.js +2 -2
  12. package/dist/cordova/index.web-extension.d.ts +31 -0
  13. package/dist/cordova/internal.js +29 -5
  14. package/dist/cordova/internal.js.map +1 -1
  15. package/dist/cordova/{popup_redirect-106f885f.js → popup_redirect-35ee3740.js} +35 -23
  16. package/dist/cordova/popup_redirect-35ee3740.js.map +1 -0
  17. package/dist/cordova/src/core/providers/google.d.ts +1 -1
  18. package/dist/cordova/src/core/util/version.d.ts +2 -1
  19. package/dist/cordova/src/platform_browser/load_js.d.ts +11 -0
  20. package/dist/esm2017/{index-dd468b12.js → index-a8a90353.js} +57 -25
  21. package/dist/esm2017/index-a8a90353.js.map +1 -0
  22. package/dist/esm2017/index.js +1 -1
  23. package/dist/esm2017/index.web-extension.d.ts +31 -0
  24. package/dist/esm2017/internal.js +2 -2
  25. package/dist/esm2017/src/core/providers/google.d.ts +1 -1
  26. package/dist/esm2017/src/core/util/version.d.ts +2 -1
  27. package/dist/esm2017/src/platform_browser/load_js.d.ts +11 -0
  28. package/dist/esm5/{index-dd399a6e.js → index-a5faf903.js} +61 -25
  29. package/dist/esm5/index-a5faf903.js.map +1 -0
  30. package/dist/esm5/index.js +1 -1
  31. package/dist/esm5/index.web-extension.d.ts +31 -0
  32. package/dist/esm5/internal.js +2 -2
  33. package/dist/esm5/src/core/providers/google.d.ts +1 -1
  34. package/dist/esm5/src/core/util/version.d.ts +2 -1
  35. package/dist/esm5/src/platform_browser/load_js.d.ts +11 -0
  36. package/dist/index.web-extension.d.ts +31 -0
  37. package/dist/index.webworker.esm5.js +25 -22
  38. package/dist/index.webworker.esm5.js.map +1 -1
  39. package/dist/node/index.js +1 -1
  40. package/dist/node/index.web-extension.d.ts +31 -0
  41. package/dist/node/internal.js +1 -1
  42. package/dist/node/src/core/providers/google.d.ts +1 -1
  43. package/dist/node/src/core/util/version.d.ts +2 -1
  44. package/dist/node/src/platform_browser/load_js.d.ts +11 -0
  45. package/dist/node/{totp-fe65684a.js → totp-eef93749.js} +26 -23
  46. package/dist/node/totp-eef93749.js.map +1 -0
  47. package/dist/node-esm/index.js +1 -1
  48. package/dist/node-esm/index.web-extension.d.ts +31 -0
  49. package/dist/node-esm/internal.js +2 -2
  50. package/dist/node-esm/src/core/providers/google.d.ts +1 -1
  51. package/dist/node-esm/src/core/util/version.d.ts +2 -1
  52. package/dist/node-esm/src/platform_browser/load_js.d.ts +11 -0
  53. package/dist/node-esm/{totp-4c2d4e67.js → totp-fae228ad.js} +22 -23
  54. package/dist/node-esm/totp-fae228ad.js.map +1 -0
  55. package/dist/rn/{index-96ab5fb1.js → index-d81c94f1.js} +37 -24
  56. package/dist/rn/index-d81c94f1.js.map +1 -0
  57. package/dist/rn/index.js +1 -1
  58. package/dist/rn/index.web-extension.d.ts +31 -0
  59. package/dist/rn/internal.js +27 -2
  60. package/dist/rn/internal.js.map +1 -1
  61. package/dist/rn/src/core/providers/google.d.ts +1 -1
  62. package/dist/rn/src/core/util/version.d.ts +2 -1
  63. package/dist/rn/src/platform_browser/load_js.d.ts +11 -0
  64. package/dist/src/core/providers/google.d.ts +1 -1
  65. package/dist/src/core/util/version.d.ts +2 -1
  66. package/dist/src/platform_browser/load_js.d.ts +11 -0
  67. package/dist/web-extension-cjs/index.cordova.d.ts +32 -0
  68. package/dist/web-extension-cjs/index.d.ts +37 -0
  69. package/dist/web-extension-cjs/index.doc.d.ts +24 -0
  70. package/dist/web-extension-cjs/index.js +114 -0
  71. package/dist/web-extension-cjs/index.js.map +1 -0
  72. package/dist/web-extension-cjs/index.node.d.ts +17 -0
  73. package/dist/web-extension-cjs/index.rn.d.ts +40 -0
  74. package/dist/web-extension-cjs/index.shared.d.ts +19 -0
  75. package/dist/web-extension-cjs/index.web-extension.d.ts +31 -0
  76. package/dist/web-extension-cjs/index.webworker.d.ts +21 -0
  77. package/dist/web-extension-cjs/internal/index.d.ts +42 -0
  78. package/dist/web-extension-cjs/internal.js +3452 -0
  79. package/dist/web-extension-cjs/internal.js.map +1 -0
  80. package/dist/web-extension-cjs/register-0d3d4fea.js +7874 -0
  81. package/dist/web-extension-cjs/register-0d3d4fea.js.map +1 -0
  82. package/dist/web-extension-cjs/scripts/run_node_tests.d.ts +17 -0
  83. package/dist/web-extension-cjs/src/api/account_management/account.d.ts +59 -0
  84. package/dist/web-extension-cjs/src/api/account_management/account.test.d.ts +17 -0
  85. package/dist/web-extension-cjs/src/api/account_management/email_and_password.d.ts +49 -0
  86. package/dist/web-extension-cjs/src/api/account_management/email_and_password.test.d.ts +17 -0
  87. package/dist/web-extension-cjs/src/api/account_management/mfa.d.ts +103 -0
  88. package/dist/web-extension-cjs/src/api/account_management/mfa.test.d.ts +17 -0
  89. package/dist/web-extension-cjs/src/api/account_management/profile.d.ts +29 -0
  90. package/dist/web-extension-cjs/src/api/account_management/profile.test.d.ts +17 -0
  91. package/dist/web-extension-cjs/src/api/authentication/create_auth_uri.d.ts +26 -0
  92. package/dist/web-extension-cjs/src/api/authentication/create_auth_uri.test.d.ts +17 -0
  93. package/dist/web-extension-cjs/src/api/authentication/custom_token.d.ts +26 -0
  94. package/dist/web-extension-cjs/src/api/authentication/custom_token.test.d.ts +17 -0
  95. package/dist/web-extension-cjs/src/api/authentication/email_and_password.d.ts +85 -0
  96. package/dist/web-extension-cjs/src/api/authentication/email_and_password.test.d.ts +17 -0
  97. package/dist/web-extension-cjs/src/api/authentication/email_link.d.ts +32 -0
  98. package/dist/web-extension-cjs/src/api/authentication/email_link.test.d.ts +17 -0
  99. package/dist/web-extension-cjs/src/api/authentication/idp.d.ts +40 -0
  100. package/dist/web-extension-cjs/src/api/authentication/idp.test.d.ts +17 -0
  101. package/dist/web-extension-cjs/src/api/authentication/mfa.d.ts +69 -0
  102. package/dist/web-extension-cjs/src/api/authentication/mfa.test.d.ts +17 -0
  103. package/dist/web-extension-cjs/src/api/authentication/recaptcha.d.ts +34 -0
  104. package/dist/web-extension-cjs/src/api/authentication/recaptcha.test.d.ts +17 -0
  105. package/dist/web-extension-cjs/src/api/authentication/sign_up.d.ts +34 -0
  106. package/dist/web-extension-cjs/src/api/authentication/sign_up.test.d.ts +17 -0
  107. package/dist/web-extension-cjs/src/api/authentication/sms.d.ts +50 -0
  108. package/dist/web-extension-cjs/src/api/authentication/sms.test.d.ts +17 -0
  109. package/dist/web-extension-cjs/src/api/authentication/token.d.ts +37 -0
  110. package/dist/web-extension-cjs/src/api/authentication/token.test.d.ts +17 -0
  111. package/dist/web-extension-cjs/src/api/errors.d.ts +128 -0
  112. package/dist/web-extension-cjs/src/api/index.d.ts +97 -0
  113. package/dist/web-extension-cjs/src/api/index.test.d.ts +17 -0
  114. package/dist/web-extension-cjs/src/api/password_policy/get_password_policy.d.ts +48 -0
  115. package/dist/web-extension-cjs/src/api/password_policy/get_password_policy.test.d.ts +17 -0
  116. package/dist/web-extension-cjs/src/api/project_config/get_project_config.d.ts +25 -0
  117. package/dist/web-extension-cjs/src/api/project_config/get_project_config.test.d.ts +17 -0
  118. package/dist/web-extension-cjs/src/core/action_code_url.d.ts +73 -0
  119. package/dist/web-extension-cjs/src/core/action_code_url.test.d.ts +17 -0
  120. package/dist/web-extension-cjs/src/core/auth/auth_event_manager.d.ts +34 -0
  121. package/dist/web-extension-cjs/src/core/auth/auth_event_manager.test.d.ts +17 -0
  122. package/dist/web-extension-cjs/src/core/auth/auth_impl.d.ts +129 -0
  123. package/dist/web-extension-cjs/src/core/auth/auth_impl.test.d.ts +17 -0
  124. package/dist/web-extension-cjs/src/core/auth/emulator.d.ts +42 -0
  125. package/dist/web-extension-cjs/src/core/auth/emulator.test.d.ts +17 -0
  126. package/dist/web-extension-cjs/src/core/auth/firebase_internal.d.ts +35 -0
  127. package/dist/web-extension-cjs/src/core/auth/firebase_internal.test.d.ts +17 -0
  128. package/dist/web-extension-cjs/src/core/auth/initialize.d.ts +46 -0
  129. package/dist/web-extension-cjs/src/core/auth/initialize.test.d.ts +17 -0
  130. package/dist/web-extension-cjs/src/core/auth/middleware.d.ts +25 -0
  131. package/dist/web-extension-cjs/src/core/auth/middleware.test.d.ts +17 -0
  132. package/dist/web-extension-cjs/src/core/auth/password_policy_impl.d.ts +59 -0
  133. package/dist/web-extension-cjs/src/core/auth/password_policy_impl.test.d.ts +17 -0
  134. package/dist/web-extension-cjs/src/core/auth/register.d.ts +23 -0
  135. package/dist/web-extension-cjs/src/core/credentials/auth_credential.d.ts +75 -0
  136. package/dist/web-extension-cjs/src/core/credentials/email.d.ts +60 -0
  137. package/dist/web-extension-cjs/src/core/credentials/email.test.d.ts +17 -0
  138. package/dist/web-extension-cjs/src/core/credentials/index.d.ts +23 -0
  139. package/dist/web-extension-cjs/src/core/credentials/oauth.d.ts +81 -0
  140. package/dist/web-extension-cjs/src/core/credentials/oauth.test.d.ts +17 -0
  141. package/dist/web-extension-cjs/src/core/credentials/phone.d.ts +52 -0
  142. package/dist/web-extension-cjs/src/core/credentials/phone.test.d.ts +17 -0
  143. package/dist/web-extension-cjs/src/core/credentials/saml.d.ts +52 -0
  144. package/dist/web-extension-cjs/src/core/credentials/saml.test.d.ts +17 -0
  145. package/dist/web-extension-cjs/src/core/errors.d.ts +325 -0
  146. package/dist/web-extension-cjs/src/core/errors.test.d.ts +17 -0
  147. package/dist/web-extension-cjs/src/core/index.d.ts +222 -0
  148. package/dist/web-extension-cjs/src/core/persistence/in_memory.d.ts +35 -0
  149. package/dist/web-extension-cjs/src/core/persistence/in_memory.test.d.ts +17 -0
  150. package/dist/web-extension-cjs/src/core/persistence/index.d.ts +41 -0
  151. package/dist/web-extension-cjs/src/core/persistence/persistence_user_manager.d.ts +45 -0
  152. package/dist/web-extension-cjs/src/core/persistence/persistence_user_manager.test.d.ts +17 -0
  153. package/dist/web-extension-cjs/src/core/providers/email.d.ts +83 -0
  154. package/dist/web-extension-cjs/src/core/providers/email.test.d.ts +17 -0
  155. package/dist/web-extension-cjs/src/core/providers/facebook.d.ts +93 -0
  156. package/dist/web-extension-cjs/src/core/providers/facebook.test.d.ts +17 -0
  157. package/dist/web-extension-cjs/src/core/providers/federated.d.ts +64 -0
  158. package/dist/web-extension-cjs/src/core/providers/federated.test.d.ts +17 -0
  159. package/dist/web-extension-cjs/src/core/providers/github.d.ts +89 -0
  160. package/dist/web-extension-cjs/src/core/providers/github.test.d.ts +17 -0
  161. package/dist/web-extension-cjs/src/core/providers/google.d.ts +96 -0
  162. package/dist/web-extension-cjs/src/core/providers/google.test.d.ts +17 -0
  163. package/dist/web-extension-cjs/src/core/providers/oauth.d.ts +151 -0
  164. package/dist/web-extension-cjs/src/core/providers/oauth.test.d.ts +17 -0
  165. package/dist/web-extension-cjs/src/core/providers/saml.d.ts +62 -0
  166. package/dist/web-extension-cjs/src/core/providers/saml.test.d.ts +17 -0
  167. package/dist/web-extension-cjs/src/core/providers/twitter.d.ts +103 -0
  168. package/dist/web-extension-cjs/src/core/providers/twitter.test.d.ts +17 -0
  169. package/dist/web-extension-cjs/src/core/strategies/abstract_popup_redirect_operation.d.ts +44 -0
  170. package/dist/web-extension-cjs/src/core/strategies/abstract_popup_redirect_operation.test.d.ts +17 -0
  171. package/dist/web-extension-cjs/src/core/strategies/action_code_settings.d.ts +19 -0
  172. package/dist/web-extension-cjs/src/core/strategies/action_code_settings.test.d.ts +17 -0
  173. package/dist/web-extension-cjs/src/core/strategies/anonymous.d.ts +29 -0
  174. package/dist/web-extension-cjs/src/core/strategies/anonymous.test.d.ts +17 -0
  175. package/dist/web-extension-cjs/src/core/strategies/credential.d.ts +58 -0
  176. package/dist/web-extension-cjs/src/core/strategies/credential.test.d.ts +17 -0
  177. package/dist/web-extension-cjs/src/core/strategies/custom_token.d.ts +34 -0
  178. package/dist/web-extension-cjs/src/core/strategies/custom_token.test.d.ts +17 -0
  179. package/dist/web-extension-cjs/src/core/strategies/email.d.ts +102 -0
  180. package/dist/web-extension-cjs/src/core/strategies/email.test.d.ts +17 -0
  181. package/dist/web-extension-cjs/src/core/strategies/email_and_password.d.ts +130 -0
  182. package/dist/web-extension-cjs/src/core/strategies/email_and_password.test.d.ts +17 -0
  183. package/dist/web-extension-cjs/src/core/strategies/email_link.d.ts +103 -0
  184. package/dist/web-extension-cjs/src/core/strategies/email_link.test.d.ts +17 -0
  185. package/dist/web-extension-cjs/src/core/strategies/idp.d.ts +32 -0
  186. package/dist/web-extension-cjs/src/core/strategies/idp.test.d.ts +17 -0
  187. package/dist/web-extension-cjs/src/core/strategies/redirect.d.ts +36 -0
  188. package/dist/web-extension-cjs/src/core/strategies/redirect.test.d.ts +17 -0
  189. package/dist/web-extension-cjs/src/core/user/account_info.d.ts +63 -0
  190. package/dist/web-extension-cjs/src/core/user/account_info.test.d.ts +17 -0
  191. package/dist/web-extension-cjs/src/core/user/additional_user_info.d.ts +31 -0
  192. package/dist/web-extension-cjs/src/core/user/additional_user_info.test.d.ts +17 -0
  193. package/dist/web-extension-cjs/src/core/user/id_token_result.d.ts +48 -0
  194. package/dist/web-extension-cjs/src/core/user/id_token_result.test.d.ts +17 -0
  195. package/dist/web-extension-cjs/src/core/user/invalidation.d.ts +18 -0
  196. package/dist/web-extension-cjs/src/core/user/invalidation.test.d.ts +17 -0
  197. package/dist/web-extension-cjs/src/core/user/link_unlink.d.ts +30 -0
  198. package/dist/web-extension-cjs/src/core/user/link_unlink.test.d.ts +17 -0
  199. package/dist/web-extension-cjs/src/core/user/proactive_refresh.d.ts +34 -0
  200. package/dist/web-extension-cjs/src/core/user/proactive_refresh.test.d.ts +17 -0
  201. package/dist/web-extension-cjs/src/core/user/reauthenticate.d.ts +20 -0
  202. package/dist/web-extension-cjs/src/core/user/reauthenticate.test.d.ts +17 -0
  203. package/dist/web-extension-cjs/src/core/user/reload.d.ts +27 -0
  204. package/dist/web-extension-cjs/src/core/user/reload.test.d.ts +17 -0
  205. package/dist/web-extension-cjs/src/core/user/token_manager.d.ts +49 -0
  206. package/dist/web-extension-cjs/src/core/user/token_manager.test.d.ts +17 -0
  207. package/dist/web-extension-cjs/src/core/user/user_credential_impl.d.ts +37 -0
  208. package/dist/web-extension-cjs/src/core/user/user_credential_impl.test.d.ts +17 -0
  209. package/dist/web-extension-cjs/src/core/user/user_impl.d.ts +68 -0
  210. package/dist/web-extension-cjs/src/core/user/user_impl.test.d.ts +17 -0
  211. package/dist/web-extension-cjs/src/core/user/user_metadata.d.ts +27 -0
  212. package/dist/web-extension-cjs/src/core/util/assert.d.ts +93 -0
  213. package/dist/web-extension-cjs/src/core/util/assert.test.d.ts +17 -0
  214. package/dist/web-extension-cjs/src/core/util/browser.d.ts +50 -0
  215. package/dist/web-extension-cjs/src/core/util/browser.test.d.ts +17 -0
  216. package/dist/web-extension-cjs/src/core/util/delay.d.ts +31 -0
  217. package/dist/web-extension-cjs/src/core/util/delay.test.d.ts +17 -0
  218. package/dist/web-extension-cjs/src/core/util/emulator.d.ts +18 -0
  219. package/dist/web-extension-cjs/src/core/util/emulator.test.d.ts +17 -0
  220. package/dist/web-extension-cjs/src/core/util/event_id.d.ts +17 -0
  221. package/dist/web-extension-cjs/src/core/util/event_id.test.d.ts +17 -0
  222. package/dist/web-extension-cjs/src/core/util/fetch_provider.d.ts +25 -0
  223. package/dist/web-extension-cjs/src/core/util/handler.d.ts +20 -0
  224. package/dist/web-extension-cjs/src/core/util/instantiator.d.ts +28 -0
  225. package/dist/web-extension-cjs/src/core/util/instantiator.test.d.ts +17 -0
  226. package/dist/web-extension-cjs/src/core/util/location.d.ts +19 -0
  227. package/dist/web-extension-cjs/src/core/util/log.d.ts +23 -0
  228. package/dist/web-extension-cjs/src/core/util/navigator.d.ts +21 -0
  229. package/dist/web-extension-cjs/src/core/util/providers.d.ts +23 -0
  230. package/dist/web-extension-cjs/src/core/util/resolver.d.ts +25 -0
  231. package/dist/web-extension-cjs/src/core/util/time.d.ts +17 -0
  232. package/dist/web-extension-cjs/src/core/util/validate_origin.d.ts +18 -0
  233. package/dist/web-extension-cjs/src/core/util/validate_origin.test.d.ts +17 -0
  234. package/dist/web-extension-cjs/src/core/util/version.d.ts +31 -0
  235. package/dist/web-extension-cjs/src/core/util/version.test.d.ts +17 -0
  236. package/dist/web-extension-cjs/src/index.d.ts +18 -0
  237. package/dist/web-extension-cjs/src/mfa/assertions/totp.d.ts +124 -0
  238. package/dist/web-extension-cjs/src/mfa/assertions/totp.test.d.ts +17 -0
  239. package/dist/web-extension-cjs/src/mfa/index.d.ts +18 -0
  240. package/dist/web-extension-cjs/src/mfa/mfa_assertion.d.ts +27 -0
  241. package/dist/web-extension-cjs/src/mfa/mfa_error.d.ts +35 -0
  242. package/dist/web-extension-cjs/src/mfa/mfa_info.d.ts +36 -0
  243. package/dist/web-extension-cjs/src/mfa/mfa_info.test.d.ts +17 -0
  244. package/dist/web-extension-cjs/src/mfa/mfa_resolver.d.ts +41 -0
  245. package/dist/web-extension-cjs/src/mfa/mfa_resolver.test.d.ts +17 -0
  246. package/dist/web-extension-cjs/src/mfa/mfa_session.d.ts +39 -0
  247. package/dist/web-extension-cjs/src/mfa/mfa_session.test.d.ts +17 -0
  248. package/dist/web-extension-cjs/src/mfa/mfa_user.d.ts +38 -0
  249. package/dist/web-extension-cjs/src/mfa/mfa_user.test.d.ts +17 -0
  250. package/dist/web-extension-cjs/src/model/application_verifier.d.ts +23 -0
  251. package/dist/web-extension-cjs/src/model/auth.d.ts +87 -0
  252. package/dist/web-extension-cjs/src/model/enum_maps.d.ts +98 -0
  253. package/dist/web-extension-cjs/src/model/enums.d.ts +74 -0
  254. package/dist/web-extension-cjs/src/model/id_token.d.ts +87 -0
  255. package/dist/web-extension-cjs/src/model/password_policy.d.ts +111 -0
  256. package/dist/web-extension-cjs/src/model/popup_redirect.d.ts +94 -0
  257. package/dist/web-extension-cjs/src/model/public_types.d.ts +1278 -0
  258. package/dist/web-extension-cjs/src/model/user.d.ts +83 -0
  259. package/dist/web-extension-cjs/src/platform_browser/auth.test.d.ts +17 -0
  260. package/dist/web-extension-cjs/src/platform_browser/auth_window.d.ts +37 -0
  261. package/dist/web-extension-cjs/src/platform_browser/iframe/gapi.d.ts +19 -0
  262. package/dist/web-extension-cjs/src/platform_browser/iframe/gapi.iframes.d.ts +47 -0
  263. package/dist/web-extension-cjs/src/platform_browser/iframe/gapi.test.d.ts +17 -0
  264. package/dist/web-extension-cjs/src/platform_browser/iframe/iframe.d.ts +18 -0
  265. package/dist/web-extension-cjs/src/platform_browser/iframe/iframe.test.d.ts +17 -0
  266. package/dist/web-extension-cjs/src/platform_browser/index.d.ts +27 -0
  267. package/dist/web-extension-cjs/src/platform_browser/load_js.d.ts +29 -0
  268. package/dist/web-extension-cjs/src/platform_browser/load_js.test.d.ts +17 -0
  269. package/dist/web-extension-cjs/src/platform_browser/messagechannel/index.d.ts +87 -0
  270. package/dist/web-extension-cjs/src/platform_browser/messagechannel/promise.d.ts +33 -0
  271. package/dist/web-extension-cjs/src/platform_browser/messagechannel/promise.test.d.ts +17 -0
  272. package/dist/web-extension-cjs/src/platform_browser/messagechannel/receiver.d.ts +63 -0
  273. package/dist/web-extension-cjs/src/platform_browser/messagechannel/receiver.test.d.ts +17 -0
  274. package/dist/web-extension-cjs/src/platform_browser/messagechannel/sender.d.ts +46 -0
  275. package/dist/web-extension-cjs/src/platform_browser/messagechannel/sender.test.d.ts +17 -0
  276. package/dist/web-extension-cjs/src/platform_browser/mfa/assertions/phone.d.ts +59 -0
  277. package/dist/web-extension-cjs/src/platform_browser/mfa/assertions/phone.test.d.ts +17 -0
  278. package/dist/web-extension-cjs/src/platform_browser/persistence/browser.d.ts +27 -0
  279. package/dist/web-extension-cjs/src/platform_browser/persistence/browser.test.d.ts +17 -0
  280. package/dist/web-extension-cjs/src/platform_browser/persistence/indexed_db.d.ts +33 -0
  281. package/dist/web-extension-cjs/src/platform_browser/persistence/indexed_db.test.d.ts +17 -0
  282. package/dist/web-extension-cjs/src/platform_browser/persistence/local_storage.d.ts +25 -0
  283. package/dist/web-extension-cjs/src/platform_browser/persistence/local_storage.test.d.ts +17 -0
  284. package/dist/web-extension-cjs/src/platform_browser/persistence/session_storage.d.ts +24 -0
  285. package/dist/web-extension-cjs/src/platform_browser/persistence/session_storage.test.d.ts +17 -0
  286. package/dist/web-extension-cjs/src/platform_browser/popup_redirect.d.ts +27 -0
  287. package/dist/web-extension-cjs/src/platform_browser/popup_redirect.test.d.ts +17 -0
  288. package/dist/web-extension-cjs/src/platform_browser/providers/phone.d.ts +152 -0
  289. package/dist/web-extension-cjs/src/platform_browser/providers/phone.test.d.ts +17 -0
  290. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha.d.ts +71 -0
  291. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  292. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +45 -0
  293. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  294. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_loader.d.ts +49 -0
  295. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_loader.test.d.ts +17 -0
  296. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_mock.d.ts +66 -0
  297. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_mock.test.d.ts +17 -0
  298. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_verifier.d.ts +92 -0
  299. package/dist/web-extension-cjs/src/platform_browser/recaptcha/recaptcha_verifier.test.d.ts +17 -0
  300. package/dist/web-extension-cjs/src/platform_browser/strategies/phone.d.ts +109 -0
  301. package/dist/web-extension-cjs/src/platform_browser/strategies/phone.test.d.ts +17 -0
  302. package/dist/web-extension-cjs/src/platform_browser/strategies/popup.d.ts +107 -0
  303. package/dist/web-extension-cjs/src/platform_browser/strategies/popup.test.d.ts +17 -0
  304. package/dist/web-extension-cjs/src/platform_browser/strategies/redirect.d.ts +172 -0
  305. package/dist/web-extension-cjs/src/platform_browser/strategies/redirect.test.d.ts +17 -0
  306. package/dist/web-extension-cjs/src/platform_browser/util/popup.d.ts +24 -0
  307. package/dist/web-extension-cjs/src/platform_browser/util/popup.test.d.ts +17 -0
  308. package/dist/web-extension-cjs/src/platform_browser/util/worker.d.ts +20 -0
  309. package/dist/web-extension-cjs/src/platform_cordova/plugins.d.ts +42 -0
  310. package/dist/web-extension-cjs/src/platform_cordova/popup_redirect/events.d.ts +39 -0
  311. package/dist/web-extension-cjs/src/platform_cordova/popup_redirect/events.test.d.ts +17 -0
  312. package/dist/web-extension-cjs/src/platform_cordova/popup_redirect/popup_redirect.d.ts +24 -0
  313. package/dist/web-extension-cjs/src/platform_cordova/popup_redirect/popup_redirect.test.d.ts +17 -0
  314. package/dist/web-extension-cjs/src/platform_cordova/popup_redirect/utils.d.ts +47 -0
  315. package/dist/web-extension-cjs/src/platform_cordova/popup_redirect/utils.test.d.ts +17 -0
  316. package/dist/web-extension-cjs/src/platform_cordova/strategies/redirect.d.ts +20 -0
  317. package/dist/web-extension-cjs/src/platform_node/index.d.ts +50 -0
  318. package/dist/web-extension-cjs/src/platform_react_native/persistence/react_native.d.ts +25 -0
  319. package/dist/web-extension-cjs/src/platform_react_native/persistence/react_native.test.d.ts +17 -0
  320. package/dist/web-extension-cjs/test/helpers/api/helper.d.ts +22 -0
  321. package/dist/web-extension-cjs/test/helpers/delay.d.ts +20 -0
  322. package/dist/web-extension-cjs/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
  323. package/dist/web-extension-cjs/test/helpers/fake_service_worker.d.ts +22 -0
  324. package/dist/web-extension-cjs/test/helpers/id_token_response.d.ts +18 -0
  325. package/dist/web-extension-cjs/test/helpers/iframe_event.d.ts +19 -0
  326. package/dist/web-extension-cjs/test/helpers/integration/emulator_rest_helpers.d.ts +35 -0
  327. package/dist/web-extension-cjs/test/helpers/integration/helpers.d.ts +30 -0
  328. package/dist/web-extension-cjs/test/helpers/integration/settings.d.ts +23 -0
  329. package/dist/web-extension-cjs/test/helpers/jwt.d.ts +17 -0
  330. package/dist/web-extension-cjs/test/helpers/mock_auth.d.ts +47 -0
  331. package/dist/web-extension-cjs/test/helpers/mock_auth_credential.d.ts +31 -0
  332. package/dist/web-extension-cjs/test/helpers/mock_fetch.d.ts +30 -0
  333. package/dist/web-extension-cjs/test/helpers/mock_fetch.test.d.ts +17 -0
  334. package/dist/web-extension-cjs/test/helpers/mock_popup_redirect_resolver.d.ts +24 -0
  335. package/dist/web-extension-cjs/test/helpers/redirect_persistence.d.ts +24 -0
  336. package/dist/web-extension-cjs/test/helpers/timeout_stub.d.ts +34 -0
  337. package/dist/web-extension-cjs/test/integration/flows/anonymous.test.d.ts +17 -0
  338. package/dist/web-extension-cjs/test/integration/flows/custom.local.test.d.ts +17 -0
  339. package/dist/web-extension-cjs/test/integration/flows/email.test.d.ts +17 -0
  340. package/dist/web-extension-cjs/test/integration/flows/idp.local.test.d.ts +17 -0
  341. package/dist/web-extension-cjs/test/integration/flows/middleware_test_generator.d.ts +18 -0
  342. package/dist/web-extension-cjs/test/integration/flows/oob.local.test.d.ts +17 -0
  343. package/dist/web-extension-cjs/test/integration/flows/password_policy.test.d.ts +17 -0
  344. package/dist/web-extension-cjs/test/integration/flows/phone.test.d.ts +17 -0
  345. package/dist/web-extension-cjs/test/integration/flows/totp.test.d.ts +17 -0
  346. package/dist/web-extension-cjs/test/integration/webdriver/anonymous.test.d.ts +17 -0
  347. package/dist/web-extension-cjs/test/integration/webdriver/compat/firebaseui.test.d.ts +17 -0
  348. package/dist/web-extension-cjs/test/integration/webdriver/persistence.test.d.ts +17 -0
  349. package/dist/web-extension-cjs/test/integration/webdriver/popup.test.d.ts +17 -0
  350. package/dist/web-extension-cjs/test/integration/webdriver/redirect.test.d.ts +17 -0
  351. package/dist/web-extension-cjs/test/integration/webdriver/util/auth_driver.d.ts +46 -0
  352. package/dist/web-extension-cjs/test/integration/webdriver/util/functions.d.ts +81 -0
  353. package/dist/web-extension-cjs/test/integration/webdriver/util/idp_page.d.ts +31 -0
  354. package/dist/web-extension-cjs/test/integration/webdriver/util/js_load_condition.d.ts +25 -0
  355. package/dist/web-extension-cjs/test/integration/webdriver/util/test_runner.d.ts +19 -0
  356. package/dist/web-extension-cjs/test/integration/webdriver/util/test_server.d.ts +27 -0
  357. package/dist/web-extension-cjs/test/integration/webdriver/util/ui_page.d.ts +33 -0
  358. package/dist/web-extension-esm2017/index.cordova.d.ts +32 -0
  359. package/dist/web-extension-esm2017/index.d.ts +37 -0
  360. package/dist/web-extension-esm2017/index.doc.d.ts +24 -0
  361. package/dist/web-extension-esm2017/index.js +50 -0
  362. package/dist/web-extension-esm2017/index.js.map +1 -0
  363. package/dist/web-extension-esm2017/index.node.d.ts +17 -0
  364. package/dist/web-extension-esm2017/index.rn.d.ts +40 -0
  365. package/dist/web-extension-esm2017/index.shared.d.ts +19 -0
  366. package/dist/web-extension-esm2017/index.web-extension.d.ts +31 -0
  367. package/dist/web-extension-esm2017/index.webworker.d.ts +21 -0
  368. package/dist/web-extension-esm2017/internal/index.d.ts +42 -0
  369. package/dist/web-extension-esm2017/internal.js +3350 -0
  370. package/dist/web-extension-esm2017/internal.js.map +1 -0
  371. package/dist/web-extension-esm2017/register-ec86a01e.js +7758 -0
  372. package/dist/web-extension-esm2017/register-ec86a01e.js.map +1 -0
  373. package/dist/web-extension-esm2017/scripts/run_node_tests.d.ts +17 -0
  374. package/dist/web-extension-esm2017/src/api/account_management/account.d.ts +59 -0
  375. package/dist/web-extension-esm2017/src/api/account_management/account.test.d.ts +17 -0
  376. package/dist/web-extension-esm2017/src/api/account_management/email_and_password.d.ts +49 -0
  377. package/dist/web-extension-esm2017/src/api/account_management/email_and_password.test.d.ts +17 -0
  378. package/dist/web-extension-esm2017/src/api/account_management/mfa.d.ts +103 -0
  379. package/dist/web-extension-esm2017/src/api/account_management/mfa.test.d.ts +17 -0
  380. package/dist/web-extension-esm2017/src/api/account_management/profile.d.ts +29 -0
  381. package/dist/web-extension-esm2017/src/api/account_management/profile.test.d.ts +17 -0
  382. package/dist/web-extension-esm2017/src/api/authentication/create_auth_uri.d.ts +26 -0
  383. package/dist/web-extension-esm2017/src/api/authentication/create_auth_uri.test.d.ts +17 -0
  384. package/dist/web-extension-esm2017/src/api/authentication/custom_token.d.ts +26 -0
  385. package/dist/web-extension-esm2017/src/api/authentication/custom_token.test.d.ts +17 -0
  386. package/dist/web-extension-esm2017/src/api/authentication/email_and_password.d.ts +85 -0
  387. package/dist/web-extension-esm2017/src/api/authentication/email_and_password.test.d.ts +17 -0
  388. package/dist/web-extension-esm2017/src/api/authentication/email_link.d.ts +32 -0
  389. package/dist/web-extension-esm2017/src/api/authentication/email_link.test.d.ts +17 -0
  390. package/dist/web-extension-esm2017/src/api/authentication/idp.d.ts +40 -0
  391. package/dist/web-extension-esm2017/src/api/authentication/idp.test.d.ts +17 -0
  392. package/dist/web-extension-esm2017/src/api/authentication/mfa.d.ts +69 -0
  393. package/dist/web-extension-esm2017/src/api/authentication/mfa.test.d.ts +17 -0
  394. package/dist/web-extension-esm2017/src/api/authentication/recaptcha.d.ts +34 -0
  395. package/dist/web-extension-esm2017/src/api/authentication/recaptcha.test.d.ts +17 -0
  396. package/dist/web-extension-esm2017/src/api/authentication/sign_up.d.ts +34 -0
  397. package/dist/web-extension-esm2017/src/api/authentication/sign_up.test.d.ts +17 -0
  398. package/dist/web-extension-esm2017/src/api/authentication/sms.d.ts +50 -0
  399. package/dist/web-extension-esm2017/src/api/authentication/sms.test.d.ts +17 -0
  400. package/dist/web-extension-esm2017/src/api/authentication/token.d.ts +37 -0
  401. package/dist/web-extension-esm2017/src/api/authentication/token.test.d.ts +17 -0
  402. package/dist/web-extension-esm2017/src/api/errors.d.ts +128 -0
  403. package/dist/web-extension-esm2017/src/api/index.d.ts +97 -0
  404. package/dist/web-extension-esm2017/src/api/index.test.d.ts +17 -0
  405. package/dist/web-extension-esm2017/src/api/password_policy/get_password_policy.d.ts +48 -0
  406. package/dist/web-extension-esm2017/src/api/password_policy/get_password_policy.test.d.ts +17 -0
  407. package/dist/web-extension-esm2017/src/api/project_config/get_project_config.d.ts +25 -0
  408. package/dist/web-extension-esm2017/src/api/project_config/get_project_config.test.d.ts +17 -0
  409. package/dist/web-extension-esm2017/src/core/action_code_url.d.ts +73 -0
  410. package/dist/web-extension-esm2017/src/core/action_code_url.test.d.ts +17 -0
  411. package/dist/web-extension-esm2017/src/core/auth/auth_event_manager.d.ts +34 -0
  412. package/dist/web-extension-esm2017/src/core/auth/auth_event_manager.test.d.ts +17 -0
  413. package/dist/web-extension-esm2017/src/core/auth/auth_impl.d.ts +129 -0
  414. package/dist/web-extension-esm2017/src/core/auth/auth_impl.test.d.ts +17 -0
  415. package/dist/web-extension-esm2017/src/core/auth/emulator.d.ts +42 -0
  416. package/dist/web-extension-esm2017/src/core/auth/emulator.test.d.ts +17 -0
  417. package/dist/web-extension-esm2017/src/core/auth/firebase_internal.d.ts +35 -0
  418. package/dist/web-extension-esm2017/src/core/auth/firebase_internal.test.d.ts +17 -0
  419. package/dist/web-extension-esm2017/src/core/auth/initialize.d.ts +46 -0
  420. package/dist/web-extension-esm2017/src/core/auth/initialize.test.d.ts +17 -0
  421. package/dist/web-extension-esm2017/src/core/auth/middleware.d.ts +25 -0
  422. package/dist/web-extension-esm2017/src/core/auth/middleware.test.d.ts +17 -0
  423. package/dist/web-extension-esm2017/src/core/auth/password_policy_impl.d.ts +59 -0
  424. package/dist/web-extension-esm2017/src/core/auth/password_policy_impl.test.d.ts +17 -0
  425. package/dist/web-extension-esm2017/src/core/auth/register.d.ts +23 -0
  426. package/dist/web-extension-esm2017/src/core/credentials/auth_credential.d.ts +75 -0
  427. package/dist/web-extension-esm2017/src/core/credentials/email.d.ts +60 -0
  428. package/dist/web-extension-esm2017/src/core/credentials/email.test.d.ts +17 -0
  429. package/dist/web-extension-esm2017/src/core/credentials/index.d.ts +23 -0
  430. package/dist/web-extension-esm2017/src/core/credentials/oauth.d.ts +81 -0
  431. package/dist/web-extension-esm2017/src/core/credentials/oauth.test.d.ts +17 -0
  432. package/dist/web-extension-esm2017/src/core/credentials/phone.d.ts +52 -0
  433. package/dist/web-extension-esm2017/src/core/credentials/phone.test.d.ts +17 -0
  434. package/dist/web-extension-esm2017/src/core/credentials/saml.d.ts +52 -0
  435. package/dist/web-extension-esm2017/src/core/credentials/saml.test.d.ts +17 -0
  436. package/dist/web-extension-esm2017/src/core/errors.d.ts +325 -0
  437. package/dist/web-extension-esm2017/src/core/errors.test.d.ts +17 -0
  438. package/dist/web-extension-esm2017/src/core/index.d.ts +222 -0
  439. package/dist/web-extension-esm2017/src/core/persistence/in_memory.d.ts +35 -0
  440. package/dist/web-extension-esm2017/src/core/persistence/in_memory.test.d.ts +17 -0
  441. package/dist/web-extension-esm2017/src/core/persistence/index.d.ts +41 -0
  442. package/dist/web-extension-esm2017/src/core/persistence/persistence_user_manager.d.ts +45 -0
  443. package/dist/web-extension-esm2017/src/core/persistence/persistence_user_manager.test.d.ts +17 -0
  444. package/dist/web-extension-esm2017/src/core/providers/email.d.ts +83 -0
  445. package/dist/web-extension-esm2017/src/core/providers/email.test.d.ts +17 -0
  446. package/dist/web-extension-esm2017/src/core/providers/facebook.d.ts +93 -0
  447. package/dist/web-extension-esm2017/src/core/providers/facebook.test.d.ts +17 -0
  448. package/dist/web-extension-esm2017/src/core/providers/federated.d.ts +64 -0
  449. package/dist/web-extension-esm2017/src/core/providers/federated.test.d.ts +17 -0
  450. package/dist/web-extension-esm2017/src/core/providers/github.d.ts +89 -0
  451. package/dist/web-extension-esm2017/src/core/providers/github.test.d.ts +17 -0
  452. package/dist/web-extension-esm2017/src/core/providers/google.d.ts +96 -0
  453. package/dist/web-extension-esm2017/src/core/providers/google.test.d.ts +17 -0
  454. package/dist/web-extension-esm2017/src/core/providers/oauth.d.ts +151 -0
  455. package/dist/web-extension-esm2017/src/core/providers/oauth.test.d.ts +17 -0
  456. package/dist/web-extension-esm2017/src/core/providers/saml.d.ts +62 -0
  457. package/dist/web-extension-esm2017/src/core/providers/saml.test.d.ts +17 -0
  458. package/dist/web-extension-esm2017/src/core/providers/twitter.d.ts +103 -0
  459. package/dist/web-extension-esm2017/src/core/providers/twitter.test.d.ts +17 -0
  460. package/dist/web-extension-esm2017/src/core/strategies/abstract_popup_redirect_operation.d.ts +44 -0
  461. package/dist/web-extension-esm2017/src/core/strategies/abstract_popup_redirect_operation.test.d.ts +17 -0
  462. package/dist/web-extension-esm2017/src/core/strategies/action_code_settings.d.ts +19 -0
  463. package/dist/web-extension-esm2017/src/core/strategies/action_code_settings.test.d.ts +17 -0
  464. package/dist/web-extension-esm2017/src/core/strategies/anonymous.d.ts +29 -0
  465. package/dist/web-extension-esm2017/src/core/strategies/anonymous.test.d.ts +17 -0
  466. package/dist/web-extension-esm2017/src/core/strategies/credential.d.ts +58 -0
  467. package/dist/web-extension-esm2017/src/core/strategies/credential.test.d.ts +17 -0
  468. package/dist/web-extension-esm2017/src/core/strategies/custom_token.d.ts +34 -0
  469. package/dist/web-extension-esm2017/src/core/strategies/custom_token.test.d.ts +17 -0
  470. package/dist/web-extension-esm2017/src/core/strategies/email.d.ts +102 -0
  471. package/dist/web-extension-esm2017/src/core/strategies/email.test.d.ts +17 -0
  472. package/dist/web-extension-esm2017/src/core/strategies/email_and_password.d.ts +130 -0
  473. package/dist/web-extension-esm2017/src/core/strategies/email_and_password.test.d.ts +17 -0
  474. package/dist/web-extension-esm2017/src/core/strategies/email_link.d.ts +103 -0
  475. package/dist/web-extension-esm2017/src/core/strategies/email_link.test.d.ts +17 -0
  476. package/dist/web-extension-esm2017/src/core/strategies/idp.d.ts +32 -0
  477. package/dist/web-extension-esm2017/src/core/strategies/idp.test.d.ts +17 -0
  478. package/dist/web-extension-esm2017/src/core/strategies/redirect.d.ts +36 -0
  479. package/dist/web-extension-esm2017/src/core/strategies/redirect.test.d.ts +17 -0
  480. package/dist/web-extension-esm2017/src/core/user/account_info.d.ts +63 -0
  481. package/dist/web-extension-esm2017/src/core/user/account_info.test.d.ts +17 -0
  482. package/dist/web-extension-esm2017/src/core/user/additional_user_info.d.ts +31 -0
  483. package/dist/web-extension-esm2017/src/core/user/additional_user_info.test.d.ts +17 -0
  484. package/dist/web-extension-esm2017/src/core/user/id_token_result.d.ts +48 -0
  485. package/dist/web-extension-esm2017/src/core/user/id_token_result.test.d.ts +17 -0
  486. package/dist/web-extension-esm2017/src/core/user/invalidation.d.ts +18 -0
  487. package/dist/web-extension-esm2017/src/core/user/invalidation.test.d.ts +17 -0
  488. package/dist/web-extension-esm2017/src/core/user/link_unlink.d.ts +30 -0
  489. package/dist/web-extension-esm2017/src/core/user/link_unlink.test.d.ts +17 -0
  490. package/dist/web-extension-esm2017/src/core/user/proactive_refresh.d.ts +34 -0
  491. package/dist/web-extension-esm2017/src/core/user/proactive_refresh.test.d.ts +17 -0
  492. package/dist/web-extension-esm2017/src/core/user/reauthenticate.d.ts +20 -0
  493. package/dist/web-extension-esm2017/src/core/user/reauthenticate.test.d.ts +17 -0
  494. package/dist/web-extension-esm2017/src/core/user/reload.d.ts +27 -0
  495. package/dist/web-extension-esm2017/src/core/user/reload.test.d.ts +17 -0
  496. package/dist/web-extension-esm2017/src/core/user/token_manager.d.ts +49 -0
  497. package/dist/web-extension-esm2017/src/core/user/token_manager.test.d.ts +17 -0
  498. package/dist/web-extension-esm2017/src/core/user/user_credential_impl.d.ts +37 -0
  499. package/dist/web-extension-esm2017/src/core/user/user_credential_impl.test.d.ts +17 -0
  500. package/dist/web-extension-esm2017/src/core/user/user_impl.d.ts +68 -0
  501. package/dist/web-extension-esm2017/src/core/user/user_impl.test.d.ts +17 -0
  502. package/dist/web-extension-esm2017/src/core/user/user_metadata.d.ts +27 -0
  503. package/dist/web-extension-esm2017/src/core/util/assert.d.ts +93 -0
  504. package/dist/web-extension-esm2017/src/core/util/assert.test.d.ts +17 -0
  505. package/dist/web-extension-esm2017/src/core/util/browser.d.ts +50 -0
  506. package/dist/web-extension-esm2017/src/core/util/browser.test.d.ts +17 -0
  507. package/dist/web-extension-esm2017/src/core/util/delay.d.ts +31 -0
  508. package/dist/web-extension-esm2017/src/core/util/delay.test.d.ts +17 -0
  509. package/dist/web-extension-esm2017/src/core/util/emulator.d.ts +18 -0
  510. package/dist/web-extension-esm2017/src/core/util/emulator.test.d.ts +17 -0
  511. package/dist/web-extension-esm2017/src/core/util/event_id.d.ts +17 -0
  512. package/dist/web-extension-esm2017/src/core/util/event_id.test.d.ts +17 -0
  513. package/dist/web-extension-esm2017/src/core/util/fetch_provider.d.ts +25 -0
  514. package/dist/web-extension-esm2017/src/core/util/handler.d.ts +20 -0
  515. package/dist/web-extension-esm2017/src/core/util/instantiator.d.ts +28 -0
  516. package/dist/web-extension-esm2017/src/core/util/instantiator.test.d.ts +17 -0
  517. package/dist/web-extension-esm2017/src/core/util/location.d.ts +19 -0
  518. package/dist/web-extension-esm2017/src/core/util/log.d.ts +23 -0
  519. package/dist/web-extension-esm2017/src/core/util/navigator.d.ts +21 -0
  520. package/dist/web-extension-esm2017/src/core/util/providers.d.ts +23 -0
  521. package/dist/web-extension-esm2017/src/core/util/resolver.d.ts +25 -0
  522. package/dist/web-extension-esm2017/src/core/util/time.d.ts +17 -0
  523. package/dist/web-extension-esm2017/src/core/util/validate_origin.d.ts +18 -0
  524. package/dist/web-extension-esm2017/src/core/util/validate_origin.test.d.ts +17 -0
  525. package/dist/web-extension-esm2017/src/core/util/version.d.ts +31 -0
  526. package/dist/web-extension-esm2017/src/core/util/version.test.d.ts +17 -0
  527. package/dist/web-extension-esm2017/src/index.d.ts +18 -0
  528. package/dist/web-extension-esm2017/src/mfa/assertions/totp.d.ts +124 -0
  529. package/dist/web-extension-esm2017/src/mfa/assertions/totp.test.d.ts +17 -0
  530. package/dist/web-extension-esm2017/src/mfa/index.d.ts +18 -0
  531. package/dist/web-extension-esm2017/src/mfa/mfa_assertion.d.ts +27 -0
  532. package/dist/web-extension-esm2017/src/mfa/mfa_error.d.ts +35 -0
  533. package/dist/web-extension-esm2017/src/mfa/mfa_info.d.ts +36 -0
  534. package/dist/web-extension-esm2017/src/mfa/mfa_info.test.d.ts +17 -0
  535. package/dist/web-extension-esm2017/src/mfa/mfa_resolver.d.ts +41 -0
  536. package/dist/web-extension-esm2017/src/mfa/mfa_resolver.test.d.ts +17 -0
  537. package/dist/web-extension-esm2017/src/mfa/mfa_session.d.ts +39 -0
  538. package/dist/web-extension-esm2017/src/mfa/mfa_session.test.d.ts +17 -0
  539. package/dist/web-extension-esm2017/src/mfa/mfa_user.d.ts +38 -0
  540. package/dist/web-extension-esm2017/src/mfa/mfa_user.test.d.ts +17 -0
  541. package/dist/web-extension-esm2017/src/model/application_verifier.d.ts +23 -0
  542. package/dist/web-extension-esm2017/src/model/auth.d.ts +87 -0
  543. package/dist/web-extension-esm2017/src/model/enum_maps.d.ts +98 -0
  544. package/dist/web-extension-esm2017/src/model/enums.d.ts +74 -0
  545. package/dist/web-extension-esm2017/src/model/id_token.d.ts +87 -0
  546. package/dist/web-extension-esm2017/src/model/password_policy.d.ts +111 -0
  547. package/dist/web-extension-esm2017/src/model/popup_redirect.d.ts +94 -0
  548. package/dist/web-extension-esm2017/src/model/public_types.d.ts +1278 -0
  549. package/dist/web-extension-esm2017/src/model/user.d.ts +83 -0
  550. package/dist/web-extension-esm2017/src/platform_browser/auth.test.d.ts +17 -0
  551. package/dist/web-extension-esm2017/src/platform_browser/auth_window.d.ts +37 -0
  552. package/dist/web-extension-esm2017/src/platform_browser/iframe/gapi.d.ts +19 -0
  553. package/dist/web-extension-esm2017/src/platform_browser/iframe/gapi.iframes.d.ts +47 -0
  554. package/dist/web-extension-esm2017/src/platform_browser/iframe/gapi.test.d.ts +17 -0
  555. package/dist/web-extension-esm2017/src/platform_browser/iframe/iframe.d.ts +18 -0
  556. package/dist/web-extension-esm2017/src/platform_browser/iframe/iframe.test.d.ts +17 -0
  557. package/dist/web-extension-esm2017/src/platform_browser/index.d.ts +27 -0
  558. package/dist/web-extension-esm2017/src/platform_browser/load_js.d.ts +29 -0
  559. package/dist/web-extension-esm2017/src/platform_browser/load_js.test.d.ts +17 -0
  560. package/dist/web-extension-esm2017/src/platform_browser/messagechannel/index.d.ts +87 -0
  561. package/dist/web-extension-esm2017/src/platform_browser/messagechannel/promise.d.ts +33 -0
  562. package/dist/web-extension-esm2017/src/platform_browser/messagechannel/promise.test.d.ts +17 -0
  563. package/dist/web-extension-esm2017/src/platform_browser/messagechannel/receiver.d.ts +63 -0
  564. package/dist/web-extension-esm2017/src/platform_browser/messagechannel/receiver.test.d.ts +17 -0
  565. package/dist/web-extension-esm2017/src/platform_browser/messagechannel/sender.d.ts +46 -0
  566. package/dist/web-extension-esm2017/src/platform_browser/messagechannel/sender.test.d.ts +17 -0
  567. package/dist/web-extension-esm2017/src/platform_browser/mfa/assertions/phone.d.ts +59 -0
  568. package/dist/web-extension-esm2017/src/platform_browser/mfa/assertions/phone.test.d.ts +17 -0
  569. package/dist/web-extension-esm2017/src/platform_browser/persistence/browser.d.ts +27 -0
  570. package/dist/web-extension-esm2017/src/platform_browser/persistence/browser.test.d.ts +17 -0
  571. package/dist/web-extension-esm2017/src/platform_browser/persistence/indexed_db.d.ts +33 -0
  572. package/dist/web-extension-esm2017/src/platform_browser/persistence/indexed_db.test.d.ts +17 -0
  573. package/dist/web-extension-esm2017/src/platform_browser/persistence/local_storage.d.ts +25 -0
  574. package/dist/web-extension-esm2017/src/platform_browser/persistence/local_storage.test.d.ts +17 -0
  575. package/dist/web-extension-esm2017/src/platform_browser/persistence/session_storage.d.ts +24 -0
  576. package/dist/web-extension-esm2017/src/platform_browser/persistence/session_storage.test.d.ts +17 -0
  577. package/dist/web-extension-esm2017/src/platform_browser/popup_redirect.d.ts +27 -0
  578. package/dist/web-extension-esm2017/src/platform_browser/popup_redirect.test.d.ts +17 -0
  579. package/dist/web-extension-esm2017/src/platform_browser/providers/phone.d.ts +152 -0
  580. package/dist/web-extension-esm2017/src/platform_browser/providers/phone.test.d.ts +17 -0
  581. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha.d.ts +71 -0
  582. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha.test.d.ts +17 -0
  583. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +45 -0
  584. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.d.ts +17 -0
  585. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_loader.d.ts +49 -0
  586. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_loader.test.d.ts +17 -0
  587. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_mock.d.ts +66 -0
  588. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_mock.test.d.ts +17 -0
  589. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_verifier.d.ts +92 -0
  590. package/dist/web-extension-esm2017/src/platform_browser/recaptcha/recaptcha_verifier.test.d.ts +17 -0
  591. package/dist/web-extension-esm2017/src/platform_browser/strategies/phone.d.ts +109 -0
  592. package/dist/web-extension-esm2017/src/platform_browser/strategies/phone.test.d.ts +17 -0
  593. package/dist/web-extension-esm2017/src/platform_browser/strategies/popup.d.ts +107 -0
  594. package/dist/web-extension-esm2017/src/platform_browser/strategies/popup.test.d.ts +17 -0
  595. package/dist/web-extension-esm2017/src/platform_browser/strategies/redirect.d.ts +172 -0
  596. package/dist/web-extension-esm2017/src/platform_browser/strategies/redirect.test.d.ts +17 -0
  597. package/dist/web-extension-esm2017/src/platform_browser/util/popup.d.ts +24 -0
  598. package/dist/web-extension-esm2017/src/platform_browser/util/popup.test.d.ts +17 -0
  599. package/dist/web-extension-esm2017/src/platform_browser/util/worker.d.ts +20 -0
  600. package/dist/web-extension-esm2017/src/platform_cordova/plugins.d.ts +42 -0
  601. package/dist/web-extension-esm2017/src/platform_cordova/popup_redirect/events.d.ts +39 -0
  602. package/dist/web-extension-esm2017/src/platform_cordova/popup_redirect/events.test.d.ts +17 -0
  603. package/dist/web-extension-esm2017/src/platform_cordova/popup_redirect/popup_redirect.d.ts +24 -0
  604. package/dist/web-extension-esm2017/src/platform_cordova/popup_redirect/popup_redirect.test.d.ts +17 -0
  605. package/dist/web-extension-esm2017/src/platform_cordova/popup_redirect/utils.d.ts +47 -0
  606. package/dist/web-extension-esm2017/src/platform_cordova/popup_redirect/utils.test.d.ts +17 -0
  607. package/dist/web-extension-esm2017/src/platform_cordova/strategies/redirect.d.ts +20 -0
  608. package/dist/web-extension-esm2017/src/platform_node/index.d.ts +50 -0
  609. package/dist/web-extension-esm2017/src/platform_react_native/persistence/react_native.d.ts +25 -0
  610. package/dist/web-extension-esm2017/src/platform_react_native/persistence/react_native.test.d.ts +17 -0
  611. package/dist/web-extension-esm2017/test/helpers/api/helper.d.ts +22 -0
  612. package/dist/web-extension-esm2017/test/helpers/delay.d.ts +20 -0
  613. package/dist/web-extension-esm2017/test/helpers/erroring_unavailable_persistence.d.ts +36 -0
  614. package/dist/web-extension-esm2017/test/helpers/fake_service_worker.d.ts +22 -0
  615. package/dist/web-extension-esm2017/test/helpers/id_token_response.d.ts +18 -0
  616. package/dist/web-extension-esm2017/test/helpers/iframe_event.d.ts +19 -0
  617. package/dist/web-extension-esm2017/test/helpers/integration/emulator_rest_helpers.d.ts +35 -0
  618. package/dist/web-extension-esm2017/test/helpers/integration/helpers.d.ts +30 -0
  619. package/dist/web-extension-esm2017/test/helpers/integration/settings.d.ts +23 -0
  620. package/dist/web-extension-esm2017/test/helpers/jwt.d.ts +17 -0
  621. package/dist/web-extension-esm2017/test/helpers/mock_auth.d.ts +47 -0
  622. package/dist/web-extension-esm2017/test/helpers/mock_auth_credential.d.ts +31 -0
  623. package/dist/web-extension-esm2017/test/helpers/mock_fetch.d.ts +30 -0
  624. package/dist/web-extension-esm2017/test/helpers/mock_fetch.test.d.ts +17 -0
  625. package/dist/web-extension-esm2017/test/helpers/mock_popup_redirect_resolver.d.ts +24 -0
  626. package/dist/web-extension-esm2017/test/helpers/redirect_persistence.d.ts +24 -0
  627. package/dist/web-extension-esm2017/test/helpers/timeout_stub.d.ts +34 -0
  628. package/dist/web-extension-esm2017/test/integration/flows/anonymous.test.d.ts +17 -0
  629. package/dist/web-extension-esm2017/test/integration/flows/custom.local.test.d.ts +17 -0
  630. package/dist/web-extension-esm2017/test/integration/flows/email.test.d.ts +17 -0
  631. package/dist/web-extension-esm2017/test/integration/flows/idp.local.test.d.ts +17 -0
  632. package/dist/web-extension-esm2017/test/integration/flows/middleware_test_generator.d.ts +18 -0
  633. package/dist/web-extension-esm2017/test/integration/flows/oob.local.test.d.ts +17 -0
  634. package/dist/web-extension-esm2017/test/integration/flows/password_policy.test.d.ts +17 -0
  635. package/dist/web-extension-esm2017/test/integration/flows/phone.test.d.ts +17 -0
  636. package/dist/web-extension-esm2017/test/integration/flows/totp.test.d.ts +17 -0
  637. package/dist/web-extension-esm2017/test/integration/webdriver/anonymous.test.d.ts +17 -0
  638. package/dist/web-extension-esm2017/test/integration/webdriver/compat/firebaseui.test.d.ts +17 -0
  639. package/dist/web-extension-esm2017/test/integration/webdriver/persistence.test.d.ts +17 -0
  640. package/dist/web-extension-esm2017/test/integration/webdriver/popup.test.d.ts +17 -0
  641. package/dist/web-extension-esm2017/test/integration/webdriver/redirect.test.d.ts +17 -0
  642. package/dist/web-extension-esm2017/test/integration/webdriver/util/auth_driver.d.ts +46 -0
  643. package/dist/web-extension-esm2017/test/integration/webdriver/util/functions.d.ts +81 -0
  644. package/dist/web-extension-esm2017/test/integration/webdriver/util/idp_page.d.ts +31 -0
  645. package/dist/web-extension-esm2017/test/integration/webdriver/util/js_load_condition.d.ts +25 -0
  646. package/dist/web-extension-esm2017/test/integration/webdriver/util/test_runner.d.ts +19 -0
  647. package/dist/web-extension-esm2017/test/integration/webdriver/util/test_server.d.ts +27 -0
  648. package/dist/web-extension-esm2017/test/integration/webdriver/util/ui_page.d.ts +33 -0
  649. package/package.json +20 -6
  650. package/web-extension/package.json +8 -0
  651. package/dist/browser-cjs/index-21814063.js.map +0 -1
  652. package/dist/cordova/popup_redirect-106f885f.js.map +0 -1
  653. package/dist/esm2017/index-dd468b12.js.map +0 -1
  654. package/dist/esm5/index-dd399a6e.js.map +0 -1
  655. package/dist/node/totp-fe65684a.js.map +0 -1
  656. package/dist/node-esm/totp-4c2d4e67.js.map +0 -1
  657. package/dist/rn/index-96ab5fb1.js.map +0 -1
@@ -0,0 +1,3452 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var register = require('./register-0d3d4fea.js');
6
+ var util = require('@firebase/util');
7
+ require('tslib');
8
+ var app = require('@firebase/app');
9
+ require('@firebase/component');
10
+ require('@firebase/logger');
11
+
12
+ /**
13
+ * @license
14
+ * Copyright 2021 Google LLC
15
+ *
16
+ * Licensed under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" BASIS,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ */
28
+ /**
29
+ * An enum of factors that may be used for multifactor authentication.
30
+ *
31
+ * @public
32
+ */
33
+ const FactorId = {
34
+ /** Phone as second factor */
35
+ PHONE: 'phone',
36
+ TOTP: 'totp'
37
+ };
38
+ /**
39
+ * Enumeration of supported providers.
40
+ *
41
+ * @public
42
+ */
43
+ const ProviderId = {
44
+ /** Facebook provider ID */
45
+ FACEBOOK: 'facebook.com',
46
+ /** GitHub provider ID */
47
+ GITHUB: 'github.com',
48
+ /** Google provider ID */
49
+ GOOGLE: 'google.com',
50
+ /** Password provider */
51
+ PASSWORD: 'password',
52
+ /** Phone provider */
53
+ PHONE: 'phone',
54
+ /** Twitter provider ID */
55
+ TWITTER: 'twitter.com'
56
+ };
57
+ /**
58
+ * Enumeration of supported sign-in methods.
59
+ *
60
+ * @public
61
+ */
62
+ const SignInMethod = {
63
+ /** Email link sign in method */
64
+ EMAIL_LINK: 'emailLink',
65
+ /** Email/password sign in method */
66
+ EMAIL_PASSWORD: 'password',
67
+ /** Facebook sign in method */
68
+ FACEBOOK: 'facebook.com',
69
+ /** GitHub sign in method */
70
+ GITHUB: 'github.com',
71
+ /** Google sign in method */
72
+ GOOGLE: 'google.com',
73
+ /** Phone sign in method */
74
+ PHONE: 'phone',
75
+ /** Twitter sign in method */
76
+ TWITTER: 'twitter.com'
77
+ };
78
+ /**
79
+ * Enumeration of supported operation types.
80
+ *
81
+ * @public
82
+ */
83
+ const OperationType = {
84
+ /** Operation involving linking an additional provider to an already signed-in user. */
85
+ LINK: 'link',
86
+ /** Operation involving using a provider to reauthenticate an already signed-in user. */
87
+ REAUTHENTICATE: 'reauthenticate',
88
+ /** Operation involving signing in a user. */
89
+ SIGN_IN: 'signIn'
90
+ };
91
+ /**
92
+ * An enumeration of the possible email action types.
93
+ *
94
+ * @public
95
+ */
96
+ const ActionCodeOperation = {
97
+ /** The email link sign-in action. */
98
+ EMAIL_SIGNIN: 'EMAIL_SIGNIN',
99
+ /** The password reset action. */
100
+ PASSWORD_RESET: 'PASSWORD_RESET',
101
+ /** The email revocation action. */
102
+ RECOVER_EMAIL: 'RECOVER_EMAIL',
103
+ /** The revert second factor addition email action. */
104
+ REVERT_SECOND_FACTOR_ADDITION: 'REVERT_SECOND_FACTOR_ADDITION',
105
+ /** The revert second factor addition email action. */
106
+ VERIFY_AND_CHANGE_EMAIL: 'VERIFY_AND_CHANGE_EMAIL',
107
+ /** The email verification action. */
108
+ VERIFY_EMAIL: 'VERIFY_EMAIL'
109
+ };
110
+
111
+ /**
112
+ * @license
113
+ * Copyright 2019 Google LLC
114
+ *
115
+ * Licensed under the Apache License, Version 2.0 (the "License");
116
+ * you may not use this file except in compliance with the License.
117
+ * You may obtain a copy of the License at
118
+ *
119
+ * http://www.apache.org/licenses/LICENSE-2.0
120
+ *
121
+ * Unless required by applicable law or agreed to in writing, software
122
+ * distributed under the License is distributed on an "AS IS" BASIS,
123
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124
+ * See the License for the specific language governing permissions and
125
+ * limitations under the License.
126
+ */
127
+ // There are two different browser persistence types: local and session.
128
+ // Both have the same implementation but use a different underlying storage
129
+ // object.
130
+ class BrowserPersistenceClass {
131
+ constructor(storageRetriever, type) {
132
+ this.storageRetriever = storageRetriever;
133
+ this.type = type;
134
+ }
135
+ _isAvailable() {
136
+ try {
137
+ if (!this.storage) {
138
+ return Promise.resolve(false);
139
+ }
140
+ this.storage.setItem(register.STORAGE_AVAILABLE_KEY, '1');
141
+ this.storage.removeItem(register.STORAGE_AVAILABLE_KEY);
142
+ return Promise.resolve(true);
143
+ }
144
+ catch (_a) {
145
+ return Promise.resolve(false);
146
+ }
147
+ }
148
+ _set(key, value) {
149
+ this.storage.setItem(key, JSON.stringify(value));
150
+ return Promise.resolve();
151
+ }
152
+ _get(key) {
153
+ const json = this.storage.getItem(key);
154
+ return Promise.resolve(json ? JSON.parse(json) : null);
155
+ }
156
+ _remove(key) {
157
+ this.storage.removeItem(key);
158
+ return Promise.resolve();
159
+ }
160
+ get storage() {
161
+ return this.storageRetriever();
162
+ }
163
+ }
164
+
165
+ /**
166
+ * @license
167
+ * Copyright 2020 Google LLC
168
+ *
169
+ * Licensed under the Apache License, Version 2.0 (the "License");
170
+ * you may not use this file except in compliance with the License.
171
+ * You may obtain a copy of the License at
172
+ *
173
+ * http://www.apache.org/licenses/LICENSE-2.0
174
+ *
175
+ * Unless required by applicable law or agreed to in writing, software
176
+ * distributed under the License is distributed on an "AS IS" BASIS,
177
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
178
+ * See the License for the specific language governing permissions and
179
+ * limitations under the License.
180
+ */
181
+ function _iframeCannotSyncWebStorage() {
182
+ const ua = util.getUA();
183
+ return register._isSafari(ua) || register._isIOS(ua);
184
+ }
185
+ // The polling period in case events are not supported
186
+ const _POLLING_INTERVAL_MS = 1000;
187
+ // The IE 10 localStorage cross tab synchronization delay in milliseconds
188
+ const IE10_LOCAL_STORAGE_SYNC_DELAY = 10;
189
+ class BrowserLocalPersistence extends BrowserPersistenceClass {
190
+ constructor() {
191
+ super(() => window.localStorage, "LOCAL" /* PersistenceType.LOCAL */);
192
+ this.boundEventHandler = (event, poll) => this.onStorageEvent(event, poll);
193
+ this.listeners = {};
194
+ this.localCache = {};
195
+ // setTimeout return value is platform specific
196
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
+ this.pollTimer = null;
198
+ // Safari or iOS browser and embedded in an iframe.
199
+ this.safariLocalStorageNotSynced = _iframeCannotSyncWebStorage() && register._isIframe();
200
+ // Whether to use polling instead of depending on window events
201
+ this.fallbackToPolling = register._isMobileBrowser();
202
+ this._shouldAllowMigration = true;
203
+ }
204
+ forAllChangedKeys(cb) {
205
+ // Check all keys with listeners on them.
206
+ for (const key of Object.keys(this.listeners)) {
207
+ // Get value from localStorage.
208
+ const newValue = this.storage.getItem(key);
209
+ const oldValue = this.localCache[key];
210
+ // If local map value does not match, trigger listener with storage event.
211
+ // Differentiate this simulated event from the real storage event.
212
+ if (newValue !== oldValue) {
213
+ cb(key, oldValue, newValue);
214
+ }
215
+ }
216
+ }
217
+ onStorageEvent(event, poll = false) {
218
+ // Key would be null in some situations, like when localStorage is cleared
219
+ if (!event.key) {
220
+ this.forAllChangedKeys((key, _oldValue, newValue) => {
221
+ this.notifyListeners(key, newValue);
222
+ });
223
+ return;
224
+ }
225
+ const key = event.key;
226
+ // Check the mechanism how this event was detected.
227
+ // The first event will dictate the mechanism to be used.
228
+ if (poll) {
229
+ // Environment detects storage changes via polling.
230
+ // Remove storage event listener to prevent possible event duplication.
231
+ this.detachListener();
232
+ }
233
+ else {
234
+ // Environment detects storage changes via storage event listener.
235
+ // Remove polling listener to prevent possible event duplication.
236
+ this.stopPolling();
237
+ }
238
+ // Safari embedded iframe. Storage event will trigger with the delta
239
+ // changes but no changes will be applied to the iframe localStorage.
240
+ if (this.safariLocalStorageNotSynced) {
241
+ // Get current iframe page value.
242
+ const storedValue = this.storage.getItem(key);
243
+ // Value not synchronized, synchronize manually.
244
+ if (event.newValue !== storedValue) {
245
+ if (event.newValue !== null) {
246
+ // Value changed from current value.
247
+ this.storage.setItem(key, event.newValue);
248
+ }
249
+ else {
250
+ // Current value deleted.
251
+ this.storage.removeItem(key);
252
+ }
253
+ }
254
+ else if (this.localCache[key] === event.newValue && !poll) {
255
+ // Already detected and processed, do not trigger listeners again.
256
+ return;
257
+ }
258
+ }
259
+ const triggerListeners = () => {
260
+ // Keep local map up to date in case storage event is triggered before
261
+ // poll.
262
+ const storedValue = this.storage.getItem(key);
263
+ if (!poll && this.localCache[key] === storedValue) {
264
+ // Real storage event which has already been detected, do nothing.
265
+ // This seems to trigger in some IE browsers for some reason.
266
+ return;
267
+ }
268
+ this.notifyListeners(key, storedValue);
269
+ };
270
+ const storedValue = this.storage.getItem(key);
271
+ if (register._isIE10() &&
272
+ storedValue !== event.newValue &&
273
+ event.newValue !== event.oldValue) {
274
+ // IE 10 has this weird bug where a storage event would trigger with the
275
+ // correct key, oldValue and newValue but localStorage.getItem(key) does
276
+ // not yield the updated value until a few milliseconds. This ensures
277
+ // this recovers from that situation.
278
+ setTimeout(triggerListeners, IE10_LOCAL_STORAGE_SYNC_DELAY);
279
+ }
280
+ else {
281
+ triggerListeners();
282
+ }
283
+ }
284
+ notifyListeners(key, value) {
285
+ this.localCache[key] = value;
286
+ const listeners = this.listeners[key];
287
+ if (listeners) {
288
+ for (const listener of Array.from(listeners)) {
289
+ listener(value ? JSON.parse(value) : value);
290
+ }
291
+ }
292
+ }
293
+ startPolling() {
294
+ this.stopPolling();
295
+ this.pollTimer = setInterval(() => {
296
+ this.forAllChangedKeys((key, oldValue, newValue) => {
297
+ this.onStorageEvent(new StorageEvent('storage', {
298
+ key,
299
+ oldValue,
300
+ newValue
301
+ }),
302
+ /* poll */ true);
303
+ });
304
+ }, _POLLING_INTERVAL_MS);
305
+ }
306
+ stopPolling() {
307
+ if (this.pollTimer) {
308
+ clearInterval(this.pollTimer);
309
+ this.pollTimer = null;
310
+ }
311
+ }
312
+ attachListener() {
313
+ window.addEventListener('storage', this.boundEventHandler);
314
+ }
315
+ detachListener() {
316
+ window.removeEventListener('storage', this.boundEventHandler);
317
+ }
318
+ _addListener(key, listener) {
319
+ if (Object.keys(this.listeners).length === 0) {
320
+ // Whether browser can detect storage event when it had already been pushed to the background.
321
+ // This may happen in some mobile browsers. A localStorage change in the foreground window
322
+ // will not be detected in the background window via the storage event.
323
+ // This was detected in iOS 7.x mobile browsers
324
+ if (this.fallbackToPolling) {
325
+ this.startPolling();
326
+ }
327
+ else {
328
+ this.attachListener();
329
+ }
330
+ }
331
+ if (!this.listeners[key]) {
332
+ this.listeners[key] = new Set();
333
+ // Populate the cache to avoid spuriously triggering on first poll.
334
+ this.localCache[key] = this.storage.getItem(key);
335
+ }
336
+ this.listeners[key].add(listener);
337
+ }
338
+ _removeListener(key, listener) {
339
+ if (this.listeners[key]) {
340
+ this.listeners[key].delete(listener);
341
+ if (this.listeners[key].size === 0) {
342
+ delete this.listeners[key];
343
+ }
344
+ }
345
+ if (Object.keys(this.listeners).length === 0) {
346
+ this.detachListener();
347
+ this.stopPolling();
348
+ }
349
+ }
350
+ // Update local cache on base operations:
351
+ async _set(key, value) {
352
+ await super._set(key, value);
353
+ this.localCache[key] = JSON.stringify(value);
354
+ }
355
+ async _get(key) {
356
+ const value = await super._get(key);
357
+ this.localCache[key] = JSON.stringify(value);
358
+ return value;
359
+ }
360
+ async _remove(key) {
361
+ await super._remove(key);
362
+ delete this.localCache[key];
363
+ }
364
+ }
365
+ BrowserLocalPersistence.type = 'LOCAL';
366
+ /**
367
+ * An implementation of {@link Persistence} of type `LOCAL` using `localStorage`
368
+ * for the underlying storage.
369
+ *
370
+ * @public
371
+ */
372
+ const browserLocalPersistence = BrowserLocalPersistence;
373
+
374
+ /**
375
+ * @license
376
+ * Copyright 2020 Google LLC
377
+ *
378
+ * Licensed under the Apache License, Version 2.0 (the "License");
379
+ * you may not use this file except in compliance with the License.
380
+ * You may obtain a copy of the License at
381
+ *
382
+ * http://www.apache.org/licenses/LICENSE-2.0
383
+ *
384
+ * Unless required by applicable law or agreed to in writing, software
385
+ * distributed under the License is distributed on an "AS IS" BASIS,
386
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
387
+ * See the License for the specific language governing permissions and
388
+ * limitations under the License.
389
+ */
390
+ class BrowserSessionPersistence extends BrowserPersistenceClass {
391
+ constructor() {
392
+ super(() => window.sessionStorage, "SESSION" /* PersistenceType.SESSION */);
393
+ }
394
+ _addListener(_key, _listener) {
395
+ // Listeners are not supported for session storage since it cannot be shared across windows
396
+ return;
397
+ }
398
+ _removeListener(_key, _listener) {
399
+ // Listeners are not supported for session storage since it cannot be shared across windows
400
+ return;
401
+ }
402
+ }
403
+ BrowserSessionPersistence.type = 'SESSION';
404
+ /**
405
+ * An implementation of {@link Persistence} of `SESSION` using `sessionStorage`
406
+ * for the underlying storage.
407
+ *
408
+ * @public
409
+ */
410
+ const browserSessionPersistence = BrowserSessionPersistence;
411
+
412
+ /**
413
+ * @license
414
+ * Copyright 2020 Google LLC
415
+ *
416
+ * Licensed under the Apache License, Version 2.0 (the "License");
417
+ * you may not use this file except in compliance with the License.
418
+ * You may obtain a copy of the License at
419
+ *
420
+ * http://www.apache.org/licenses/LICENSE-2.0
421
+ *
422
+ * Unless required by applicable law or agreed to in writing, software
423
+ * distributed under the License is distributed on an "AS IS" BASIS,
424
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
425
+ * See the License for the specific language governing permissions and
426
+ * limitations under the License.
427
+ */
428
+ const _SOLVE_TIME_MS = 500;
429
+ const _EXPIRATION_TIME_MS = 60000;
430
+ const _WIDGET_ID_START = 1000000000000;
431
+ class MockReCaptcha {
432
+ constructor(auth) {
433
+ this.auth = auth;
434
+ this.counter = _WIDGET_ID_START;
435
+ this._widgets = new Map();
436
+ }
437
+ render(container, parameters) {
438
+ const id = this.counter;
439
+ this._widgets.set(id, new MockWidget(container, this.auth.name, parameters || {}));
440
+ this.counter++;
441
+ return id;
442
+ }
443
+ reset(optWidgetId) {
444
+ var _a;
445
+ const id = optWidgetId || _WIDGET_ID_START;
446
+ void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.delete());
447
+ this._widgets.delete(id);
448
+ }
449
+ getResponse(optWidgetId) {
450
+ var _a;
451
+ const id = optWidgetId || _WIDGET_ID_START;
452
+ return ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.getResponse()) || '';
453
+ }
454
+ async execute(optWidgetId) {
455
+ var _a;
456
+ const id = optWidgetId || _WIDGET_ID_START;
457
+ void ((_a = this._widgets.get(id)) === null || _a === void 0 ? void 0 : _a.execute());
458
+ return '';
459
+ }
460
+ }
461
+ class MockWidget {
462
+ constructor(containerOrId, appName, params) {
463
+ this.params = params;
464
+ this.timerId = null;
465
+ this.deleted = false;
466
+ this.responseToken = null;
467
+ this.clickHandler = () => {
468
+ this.execute();
469
+ };
470
+ const container = typeof containerOrId === 'string'
471
+ ? document.getElementById(containerOrId)
472
+ : containerOrId;
473
+ register._assert(container, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, { appName });
474
+ this.container = container;
475
+ this.isVisible = this.params.size !== 'invisible';
476
+ if (this.isVisible) {
477
+ this.execute();
478
+ }
479
+ else {
480
+ this.container.addEventListener('click', this.clickHandler);
481
+ }
482
+ }
483
+ getResponse() {
484
+ this.checkIfDeleted();
485
+ return this.responseToken;
486
+ }
487
+ delete() {
488
+ this.checkIfDeleted();
489
+ this.deleted = true;
490
+ if (this.timerId) {
491
+ clearTimeout(this.timerId);
492
+ this.timerId = null;
493
+ }
494
+ this.container.removeEventListener('click', this.clickHandler);
495
+ }
496
+ execute() {
497
+ this.checkIfDeleted();
498
+ if (this.timerId) {
499
+ return;
500
+ }
501
+ this.timerId = window.setTimeout(() => {
502
+ this.responseToken = generateRandomAlphaNumericString(50);
503
+ const { callback, 'expired-callback': expiredCallback } = this.params;
504
+ if (callback) {
505
+ try {
506
+ callback(this.responseToken);
507
+ }
508
+ catch (e) { }
509
+ }
510
+ this.timerId = window.setTimeout(() => {
511
+ this.timerId = null;
512
+ this.responseToken = null;
513
+ if (expiredCallback) {
514
+ try {
515
+ expiredCallback();
516
+ }
517
+ catch (e) { }
518
+ }
519
+ if (this.isVisible) {
520
+ this.execute();
521
+ }
522
+ }, _EXPIRATION_TIME_MS);
523
+ }, _SOLVE_TIME_MS);
524
+ }
525
+ checkIfDeleted() {
526
+ if (this.deleted) {
527
+ throw new Error('reCAPTCHA mock was already deleted!');
528
+ }
529
+ }
530
+ }
531
+ function generateRandomAlphaNumericString(len) {
532
+ const chars = [];
533
+ const allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
534
+ for (let i = 0; i < len; i++) {
535
+ chars.push(allowedChars.charAt(Math.floor(Math.random() * allowedChars.length)));
536
+ }
537
+ return chars.join('');
538
+ }
539
+
540
+ /**
541
+ * @license
542
+ * Copyright 2020 Google LLC
543
+ *
544
+ * Licensed under the Apache License, Version 2.0 (the "License");
545
+ * you may not use this file except in compliance with the License.
546
+ * You may obtain a copy of the License at
547
+ *
548
+ * http://www.apache.org/licenses/LICENSE-2.0
549
+ *
550
+ * Unless required by applicable law or agreed to in writing, software
551
+ * distributed under the License is distributed on an "AS IS" BASIS,
552
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
553
+ * See the License for the specific language governing permissions and
554
+ * limitations under the License.
555
+ */
556
+ // ReCaptcha will load using the same callback, so the callback function needs
557
+ // to be kept around
558
+ const _JSLOAD_CALLBACK = register._generateCallbackName('rcb');
559
+ const NETWORK_TIMEOUT_DELAY = new register.Delay(30000, 60000);
560
+ /**
561
+ * Loader for the GReCaptcha library. There should only ever be one of this.
562
+ */
563
+ class ReCaptchaLoaderImpl {
564
+ constructor() {
565
+ var _a;
566
+ this.hostLanguage = '';
567
+ this.counter = 0;
568
+ /**
569
+ * Check for `render()` method. `window.grecaptcha` will exist if the Enterprise
570
+ * version of the ReCAPTCHA script was loaded by someone else (e.g. App Check) but
571
+ * `window.grecaptcha.render()` will not. Another load will add it.
572
+ */
573
+ this.librarySeparatelyLoaded = !!((_a = register._window().grecaptcha) === null || _a === void 0 ? void 0 : _a.render);
574
+ }
575
+ load(auth, hl = '') {
576
+ register._assert(isHostLanguageValid(hl), auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
577
+ if (this.shouldResolveImmediately(hl) && register.isV2(register._window().grecaptcha)) {
578
+ return Promise.resolve(register._window().grecaptcha);
579
+ }
580
+ return new Promise((resolve, reject) => {
581
+ const networkTimeout = register._window().setTimeout(() => {
582
+ reject(register._createError(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */));
583
+ }, NETWORK_TIMEOUT_DELAY.get());
584
+ register._window()[_JSLOAD_CALLBACK] = () => {
585
+ register._window().clearTimeout(networkTimeout);
586
+ delete register._window()[_JSLOAD_CALLBACK];
587
+ const recaptcha = register._window().grecaptcha;
588
+ if (!recaptcha || !register.isV2(recaptcha)) {
589
+ reject(register._createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
590
+ return;
591
+ }
592
+ // Wrap the greptcha render function so that we know if the developer has
593
+ // called it separately
594
+ const render = recaptcha.render;
595
+ recaptcha.render = (container, params) => {
596
+ const widgetId = render(container, params);
597
+ this.counter++;
598
+ return widgetId;
599
+ };
600
+ this.hostLanguage = hl;
601
+ resolve(recaptcha);
602
+ };
603
+ const url = `${register._recaptchaV2ScriptUrl()}?${util.querystring({
604
+ onload: _JSLOAD_CALLBACK,
605
+ render: 'explicit',
606
+ hl
607
+ })}`;
608
+ register._loadJS(url).catch(() => {
609
+ clearTimeout(networkTimeout);
610
+ reject(register._createError(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */));
611
+ });
612
+ });
613
+ }
614
+ clearedOneInstance() {
615
+ this.counter--;
616
+ }
617
+ shouldResolveImmediately(hl) {
618
+ var _a;
619
+ // We can resolve immediately if:
620
+ // • grecaptcha is already defined AND (
621
+ // 1. the requested language codes are the same OR
622
+ // 2. there exists already a ReCaptcha on the page
623
+ // 3. the library was already loaded by the app
624
+ // In cases (2) and (3), we _can't_ reload as it would break the recaptchas
625
+ // that are already in the page
626
+ return (!!((_a = register._window().grecaptcha) === null || _a === void 0 ? void 0 : _a.render) &&
627
+ (hl === this.hostLanguage ||
628
+ this.counter > 0 ||
629
+ this.librarySeparatelyLoaded));
630
+ }
631
+ }
632
+ function isHostLanguageValid(hl) {
633
+ return hl.length <= 6 && /^\s*[a-zA-Z0-9\-]*\s*$/.test(hl);
634
+ }
635
+ class MockReCaptchaLoaderImpl {
636
+ async load(auth) {
637
+ return new MockReCaptcha(auth);
638
+ }
639
+ clearedOneInstance() { }
640
+ }
641
+
642
+ /**
643
+ * @license
644
+ * Copyright 2020 Google LLC
645
+ *
646
+ * Licensed under the Apache License, Version 2.0 (the "License");
647
+ * you may not use this file except in compliance with the License.
648
+ * You may obtain a copy of the License at
649
+ *
650
+ * http://www.apache.org/licenses/LICENSE-2.0
651
+ *
652
+ * Unless required by applicable law or agreed to in writing, software
653
+ * distributed under the License is distributed on an "AS IS" BASIS,
654
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
655
+ * See the License for the specific language governing permissions and
656
+ * limitations under the License.
657
+ */
658
+ const RECAPTCHA_VERIFIER_TYPE = 'recaptcha';
659
+ const DEFAULT_PARAMS = {
660
+ theme: 'light',
661
+ type: 'image'
662
+ };
663
+ /**
664
+ * An {@link https://www.google.com/recaptcha/ | reCAPTCHA}-based application verifier.
665
+ *
666
+ * @remarks
667
+ * `RecaptchaVerifier` does not work in a Node.js environment.
668
+ *
669
+ * @public
670
+ */
671
+ class RecaptchaVerifier {
672
+ /**
673
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
674
+ *
675
+ * @param containerOrId - The reCAPTCHA container parameter.
676
+ *
677
+ * @remarks
678
+ * This has different meaning depending on whether the reCAPTCHA is hidden or visible. For a
679
+ * visible reCAPTCHA the container must be empty. If a string is used, it has to correspond to
680
+ * an element ID. The corresponding element must also must be in the DOM at the time of
681
+ * initialization.
682
+ *
683
+ * @param parameters - The optional reCAPTCHA parameters.
684
+ *
685
+ * @remarks
686
+ * Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted except for
687
+ * the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
688
+ * configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
689
+ * 'invisible'.
690
+ */
691
+ constructor(authExtern, containerOrId, parameters = Object.assign({}, DEFAULT_PARAMS)) {
692
+ this.parameters = parameters;
693
+ /**
694
+ * The application verifier type.
695
+ *
696
+ * @remarks
697
+ * For a reCAPTCHA verifier, this is 'recaptcha'.
698
+ */
699
+ this.type = RECAPTCHA_VERIFIER_TYPE;
700
+ this.destroyed = false;
701
+ this.widgetId = null;
702
+ this.tokenChangeListeners = new Set();
703
+ this.renderPromise = null;
704
+ this.recaptcha = null;
705
+ this.auth = register._castAuth(authExtern);
706
+ this.isInvisible = this.parameters.size === 'invisible';
707
+ register._assert(typeof document !== 'undefined', this.auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
708
+ const container = typeof containerOrId === 'string'
709
+ ? document.getElementById(containerOrId)
710
+ : containerOrId;
711
+ register._assert(container, this.auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
712
+ this.container = container;
713
+ this.parameters.callback = this.makeTokenCallback(this.parameters.callback);
714
+ this._recaptchaLoader = this.auth.settings.appVerificationDisabledForTesting
715
+ ? new MockReCaptchaLoaderImpl()
716
+ : new ReCaptchaLoaderImpl();
717
+ this.validateStartingState();
718
+ // TODO: Figure out if sdk version is needed
719
+ }
720
+ /**
721
+ * Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA token.
722
+ *
723
+ * @returns A Promise for the reCAPTCHA token.
724
+ */
725
+ async verify() {
726
+ this.assertNotDestroyed();
727
+ const id = await this.render();
728
+ const recaptcha = this.getAssertedRecaptcha();
729
+ const response = recaptcha.getResponse(id);
730
+ if (response) {
731
+ return response;
732
+ }
733
+ return new Promise(resolve => {
734
+ const tokenChange = (token) => {
735
+ if (!token) {
736
+ return; // Ignore token expirations.
737
+ }
738
+ this.tokenChangeListeners.delete(tokenChange);
739
+ resolve(token);
740
+ };
741
+ this.tokenChangeListeners.add(tokenChange);
742
+ if (this.isInvisible) {
743
+ recaptcha.execute(id);
744
+ }
745
+ });
746
+ }
747
+ /**
748
+ * Renders the reCAPTCHA widget on the page.
749
+ *
750
+ * @returns A Promise that resolves with the reCAPTCHA widget ID.
751
+ */
752
+ render() {
753
+ try {
754
+ this.assertNotDestroyed();
755
+ }
756
+ catch (e) {
757
+ // This method returns a promise. Since it's not async (we want to return the
758
+ // _same_ promise if rendering is still occurring), the API surface should
759
+ // reject with the error rather than just throw
760
+ return Promise.reject(e);
761
+ }
762
+ if (this.renderPromise) {
763
+ return this.renderPromise;
764
+ }
765
+ this.renderPromise = this.makeRenderPromise().catch(e => {
766
+ this.renderPromise = null;
767
+ throw e;
768
+ });
769
+ return this.renderPromise;
770
+ }
771
+ /** @internal */
772
+ _reset() {
773
+ this.assertNotDestroyed();
774
+ if (this.widgetId !== null) {
775
+ this.getAssertedRecaptcha().reset(this.widgetId);
776
+ }
777
+ }
778
+ /**
779
+ * Clears the reCAPTCHA widget from the page and destroys the instance.
780
+ */
781
+ clear() {
782
+ this.assertNotDestroyed();
783
+ this.destroyed = true;
784
+ this._recaptchaLoader.clearedOneInstance();
785
+ if (!this.isInvisible) {
786
+ this.container.childNodes.forEach(node => {
787
+ this.container.removeChild(node);
788
+ });
789
+ }
790
+ }
791
+ validateStartingState() {
792
+ register._assert(!this.parameters.sitekey, this.auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
793
+ register._assert(this.isInvisible || !this.container.hasChildNodes(), this.auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
794
+ register._assert(typeof document !== 'undefined', this.auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
795
+ }
796
+ makeTokenCallback(existing) {
797
+ return token => {
798
+ this.tokenChangeListeners.forEach(listener => listener(token));
799
+ if (typeof existing === 'function') {
800
+ existing(token);
801
+ }
802
+ else if (typeof existing === 'string') {
803
+ const globalFunc = register._window()[existing];
804
+ if (typeof globalFunc === 'function') {
805
+ globalFunc(token);
806
+ }
807
+ }
808
+ };
809
+ }
810
+ assertNotDestroyed() {
811
+ register._assert(!this.destroyed, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
812
+ }
813
+ async makeRenderPromise() {
814
+ await this.init();
815
+ if (!this.widgetId) {
816
+ let container = this.container;
817
+ if (!this.isInvisible) {
818
+ const guaranteedEmpty = document.createElement('div');
819
+ container.appendChild(guaranteedEmpty);
820
+ container = guaranteedEmpty;
821
+ }
822
+ this.widgetId = this.getAssertedRecaptcha().render(container, this.parameters);
823
+ }
824
+ return this.widgetId;
825
+ }
826
+ async init() {
827
+ register._assert(register._isHttpOrHttps() && !register._isWorker(), this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
828
+ await domReady();
829
+ this.recaptcha = await this._recaptchaLoader.load(this.auth, this.auth.languageCode || undefined);
830
+ const siteKey = await register.getRecaptchaParams(this.auth);
831
+ register._assert(siteKey, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
832
+ this.parameters.sitekey = siteKey;
833
+ }
834
+ getAssertedRecaptcha() {
835
+ register._assert(this.recaptcha, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
836
+ return this.recaptcha;
837
+ }
838
+ }
839
+ function domReady() {
840
+ let resolver = null;
841
+ return new Promise(resolve => {
842
+ if (document.readyState === 'complete') {
843
+ resolve();
844
+ return;
845
+ }
846
+ // Document not ready, wait for load before resolving.
847
+ // Save resolver, so we can remove listener in case it was externally
848
+ // cancelled.
849
+ resolver = () => resolve();
850
+ window.addEventListener('load', resolver);
851
+ }).catch(e => {
852
+ if (resolver) {
853
+ window.removeEventListener('load', resolver);
854
+ }
855
+ throw e;
856
+ });
857
+ }
858
+
859
+ /**
860
+ * @license
861
+ * Copyright 2020 Google LLC
862
+ *
863
+ * Licensed under the Apache License, Version 2.0 (the "License");
864
+ * you may not use this file except in compliance with the License.
865
+ * You may obtain a copy of the License at
866
+ *
867
+ * http://www.apache.org/licenses/LICENSE-2.0
868
+ *
869
+ * Unless required by applicable law or agreed to in writing, software
870
+ * distributed under the License is distributed on an "AS IS" BASIS,
871
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
872
+ * See the License for the specific language governing permissions and
873
+ * limitations under the License.
874
+ */
875
+ class ConfirmationResultImpl {
876
+ constructor(verificationId, onConfirmation) {
877
+ this.verificationId = verificationId;
878
+ this.onConfirmation = onConfirmation;
879
+ }
880
+ confirm(verificationCode) {
881
+ const authCredential = register.PhoneAuthCredential._fromVerification(this.verificationId, verificationCode);
882
+ return this.onConfirmation(authCredential);
883
+ }
884
+ }
885
+ /**
886
+ * Asynchronously signs in using a phone number.
887
+ *
888
+ * @remarks
889
+ * This method sends a code via SMS to the given
890
+ * phone number, and returns a {@link ConfirmationResult}. After the user
891
+ * provides the code sent to their phone, call {@link ConfirmationResult.confirm}
892
+ * with the code to sign the user in.
893
+ *
894
+ * For abuse prevention, this method also requires a {@link ApplicationVerifier}.
895
+ * This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
896
+ * This function can work on other platforms that do not support the
897
+ * {@link RecaptchaVerifier} (like React Native), but you need to use a
898
+ * third-party {@link ApplicationVerifier} implementation.
899
+ *
900
+ * This method does not work in a Node.js environment.
901
+ *
902
+ * @example
903
+ * ```javascript
904
+ * // 'recaptcha-container' is the ID of an element in the DOM.
905
+ * const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
906
+ * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
907
+ * // Obtain a verificationCode from the user.
908
+ * const credential = await confirmationResult.confirm(verificationCode);
909
+ * ```
910
+ *
911
+ * @param auth - The {@link Auth} instance.
912
+ * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
913
+ * @param appVerifier - The {@link ApplicationVerifier}.
914
+ *
915
+ * @public
916
+ */
917
+ async function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
918
+ const authInternal = register._castAuth(auth);
919
+ const verificationId = await _verifyPhoneNumber(authInternal, phoneNumber, util.getModularInstance(appVerifier));
920
+ return new ConfirmationResultImpl(verificationId, cred => register.signInWithCredential(authInternal, cred));
921
+ }
922
+ /**
923
+ * Links the user account with the given phone number.
924
+ *
925
+ * @remarks
926
+ * This method does not work in a Node.js environment.
927
+ *
928
+ * @param user - The user.
929
+ * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
930
+ * @param appVerifier - The {@link ApplicationVerifier}.
931
+ *
932
+ * @public
933
+ */
934
+ async function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
935
+ const userInternal = util.getModularInstance(user);
936
+ await register._assertLinkedStatus(false, userInternal, "phone" /* ProviderId.PHONE */);
937
+ const verificationId = await _verifyPhoneNumber(userInternal.auth, phoneNumber, util.getModularInstance(appVerifier));
938
+ return new ConfirmationResultImpl(verificationId, cred => register.linkWithCredential(userInternal, cred));
939
+ }
940
+ /**
941
+ * Re-authenticates a user using a fresh phone credential.
942
+ *
943
+ * @remarks
944
+ * Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
945
+ *
946
+ * This method does not work in a Node.js environment.
947
+ *
948
+ * @param user - The user.
949
+ * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
950
+ * @param appVerifier - The {@link ApplicationVerifier}.
951
+ *
952
+ * @public
953
+ */
954
+ async function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
955
+ const userInternal = util.getModularInstance(user);
956
+ const verificationId = await _verifyPhoneNumber(userInternal.auth, phoneNumber, util.getModularInstance(appVerifier));
957
+ return new ConfirmationResultImpl(verificationId, cred => register.reauthenticateWithCredential(userInternal, cred));
958
+ }
959
+ /**
960
+ * Returns a verification ID to be used in conjunction with the SMS code that is sent.
961
+ *
962
+ */
963
+ async function _verifyPhoneNumber(auth, options, verifier) {
964
+ var _a;
965
+ const recaptchaToken = await verifier.verify();
966
+ try {
967
+ register._assert(typeof recaptchaToken === 'string', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
968
+ register._assert(verifier.type === RECAPTCHA_VERIFIER_TYPE, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
969
+ let phoneInfoOptions;
970
+ if (typeof options === 'string') {
971
+ phoneInfoOptions = {
972
+ phoneNumber: options
973
+ };
974
+ }
975
+ else {
976
+ phoneInfoOptions = options;
977
+ }
978
+ if ('session' in phoneInfoOptions) {
979
+ const session = phoneInfoOptions.session;
980
+ if ('phoneNumber' in phoneInfoOptions) {
981
+ register._assert(session.type === "enroll" /* MultiFactorSessionType.ENROLL */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
982
+ const response = await register.startEnrollPhoneMfa(auth, {
983
+ idToken: session.credential,
984
+ phoneEnrollmentInfo: {
985
+ phoneNumber: phoneInfoOptions.phoneNumber,
986
+ recaptchaToken
987
+ }
988
+ });
989
+ return response.phoneSessionInfo.sessionInfo;
990
+ }
991
+ else {
992
+ register._assert(session.type === "signin" /* MultiFactorSessionType.SIGN_IN */, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
993
+ const mfaEnrollmentId = ((_a = phoneInfoOptions.multiFactorHint) === null || _a === void 0 ? void 0 : _a.uid) ||
994
+ phoneInfoOptions.multiFactorUid;
995
+ register._assert(mfaEnrollmentId, auth, "missing-multi-factor-info" /* AuthErrorCode.MISSING_MFA_INFO */);
996
+ const response = await register.startSignInPhoneMfa(auth, {
997
+ mfaPendingCredential: session.credential,
998
+ mfaEnrollmentId,
999
+ phoneSignInInfo: {
1000
+ recaptchaToken
1001
+ }
1002
+ });
1003
+ return response.phoneResponseInfo.sessionInfo;
1004
+ }
1005
+ }
1006
+ else {
1007
+ const { sessionInfo } = await register.sendPhoneVerificationCode(auth, {
1008
+ phoneNumber: phoneInfoOptions.phoneNumber,
1009
+ recaptchaToken
1010
+ });
1011
+ return sessionInfo;
1012
+ }
1013
+ }
1014
+ finally {
1015
+ verifier._reset();
1016
+ }
1017
+ }
1018
+ /**
1019
+ * Updates the user's phone number.
1020
+ *
1021
+ * @remarks
1022
+ * This method does not work in a Node.js environment.
1023
+ *
1024
+ * @example
1025
+ * ```
1026
+ * // 'recaptcha-container' is the ID of an element in the DOM.
1027
+ * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
1028
+ * const provider = new PhoneAuthProvider(auth);
1029
+ * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
1030
+ * // Obtain the verificationCode from the user.
1031
+ * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
1032
+ * await updatePhoneNumber(user, phoneCredential);
1033
+ * ```
1034
+ *
1035
+ * @param user - The user.
1036
+ * @param credential - A credential authenticating the new phone number.
1037
+ *
1038
+ * @public
1039
+ */
1040
+ async function updatePhoneNumber(user, credential) {
1041
+ await register._link(util.getModularInstance(user), credential);
1042
+ }
1043
+
1044
+ /**
1045
+ * @license
1046
+ * Copyright 2020 Google LLC
1047
+ *
1048
+ * Licensed under the Apache License, Version 2.0 (the "License");
1049
+ * you may not use this file except in compliance with the License.
1050
+ * You may obtain a copy of the License at
1051
+ *
1052
+ * http://www.apache.org/licenses/LICENSE-2.0
1053
+ *
1054
+ * Unless required by applicable law or agreed to in writing, software
1055
+ * distributed under the License is distributed on an "AS IS" BASIS,
1056
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1057
+ * See the License for the specific language governing permissions and
1058
+ * limitations under the License.
1059
+ */
1060
+ /**
1061
+ * Provider for generating an {@link PhoneAuthCredential}.
1062
+ *
1063
+ * @remarks
1064
+ * `PhoneAuthProvider` does not work in a Node.js environment.
1065
+ *
1066
+ * @example
1067
+ * ```javascript
1068
+ * // 'recaptcha-container' is the ID of an element in the DOM.
1069
+ * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
1070
+ * const provider = new PhoneAuthProvider(auth);
1071
+ * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
1072
+ * // Obtain the verificationCode from the user.
1073
+ * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
1074
+ * const userCredential = await signInWithCredential(auth, phoneCredential);
1075
+ * ```
1076
+ *
1077
+ * @public
1078
+ */
1079
+ class PhoneAuthProvider {
1080
+ /**
1081
+ * @param auth - The Firebase {@link Auth} instance in which sign-ins should occur.
1082
+ *
1083
+ */
1084
+ constructor(auth) {
1085
+ /** Always set to {@link ProviderId}.PHONE. */
1086
+ this.providerId = PhoneAuthProvider.PROVIDER_ID;
1087
+ this.auth = register._castAuth(auth);
1088
+ }
1089
+ /**
1090
+ *
1091
+ * Starts a phone number authentication flow by sending a verification code to the given phone
1092
+ * number.
1093
+ *
1094
+ * @example
1095
+ * ```javascript
1096
+ * const provider = new PhoneAuthProvider(auth);
1097
+ * const verificationId = await provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
1098
+ * // Obtain verificationCode from the user.
1099
+ * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
1100
+ * const userCredential = await signInWithCredential(auth, authCredential);
1101
+ * ```
1102
+ *
1103
+ * @example
1104
+ * An alternative flow is provided using the `signInWithPhoneNumber` method.
1105
+ * ```javascript
1106
+ * const confirmationResult = signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
1107
+ * // Obtain verificationCode from the user.
1108
+ * const userCredential = confirmationResult.confirm(verificationCode);
1109
+ * ```
1110
+ *
1111
+ * @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
1112
+ * E.164 format (e.g. +16505550101).
1113
+ * @param applicationVerifier - For abuse prevention, this method also requires a
1114
+ * {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
1115
+ * {@link RecaptchaVerifier}.
1116
+ *
1117
+ * @returns A Promise for a verification ID that can be passed to
1118
+ * {@link PhoneAuthProvider.credential} to identify this flow..
1119
+ */
1120
+ verifyPhoneNumber(phoneOptions, applicationVerifier) {
1121
+ return _verifyPhoneNumber(this.auth, phoneOptions, util.getModularInstance(applicationVerifier));
1122
+ }
1123
+ /**
1124
+ * Creates a phone auth credential, given the verification ID from
1125
+ * {@link PhoneAuthProvider.verifyPhoneNumber} and the code that was sent to the user's
1126
+ * mobile device.
1127
+ *
1128
+ * @example
1129
+ * ```javascript
1130
+ * const provider = new PhoneAuthProvider(auth);
1131
+ * const verificationId = provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
1132
+ * // Obtain verificationCode from the user.
1133
+ * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
1134
+ * const userCredential = signInWithCredential(auth, authCredential);
1135
+ * ```
1136
+ *
1137
+ * @example
1138
+ * An alternative flow is provided using the `signInWithPhoneNumber` method.
1139
+ * ```javascript
1140
+ * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
1141
+ * // Obtain verificationCode from the user.
1142
+ * const userCredential = await confirmationResult.confirm(verificationCode);
1143
+ * ```
1144
+ *
1145
+ * @param verificationId - The verification ID returned from {@link PhoneAuthProvider.verifyPhoneNumber}.
1146
+ * @param verificationCode - The verification code sent to the user's mobile device.
1147
+ *
1148
+ * @returns The auth provider credential.
1149
+ */
1150
+ static credential(verificationId, verificationCode) {
1151
+ return register.PhoneAuthCredential._fromVerification(verificationId, verificationCode);
1152
+ }
1153
+ /**
1154
+ * Generates an {@link AuthCredential} from a {@link UserCredential}.
1155
+ * @param userCredential - The user credential.
1156
+ */
1157
+ static credentialFromResult(userCredential) {
1158
+ const credential = userCredential;
1159
+ return PhoneAuthProvider.credentialFromTaggedObject(credential);
1160
+ }
1161
+ /**
1162
+ * Returns an {@link AuthCredential} when passed an error.
1163
+ *
1164
+ * @remarks
1165
+ *
1166
+ * This method works for errors like
1167
+ * `auth/account-exists-with-different-credentials`. This is useful for
1168
+ * recovering when attempting to set a user's phone number but the number
1169
+ * in question is already tied to another account. For example, the following
1170
+ * code tries to update the current user's phone number, and if that
1171
+ * fails, links the user with the account associated with that number:
1172
+ *
1173
+ * ```js
1174
+ * const provider = new PhoneAuthProvider(auth);
1175
+ * const verificationId = await provider.verifyPhoneNumber(number, verifier);
1176
+ * try {
1177
+ * const code = ''; // Prompt the user for the verification code
1178
+ * await updatePhoneNumber(
1179
+ * auth.currentUser,
1180
+ * PhoneAuthProvider.credential(verificationId, code));
1181
+ * } catch (e) {
1182
+ * if ((e as FirebaseError)?.code === 'auth/account-exists-with-different-credential') {
1183
+ * const cred = PhoneAuthProvider.credentialFromError(e);
1184
+ * await linkWithCredential(auth.currentUser, cred);
1185
+ * }
1186
+ * }
1187
+ *
1188
+ * // At this point, auth.currentUser.phoneNumber === number.
1189
+ * ```
1190
+ *
1191
+ * @param error - The error to generate a credential from.
1192
+ */
1193
+ static credentialFromError(error) {
1194
+ return PhoneAuthProvider.credentialFromTaggedObject((error.customData || {}));
1195
+ }
1196
+ static credentialFromTaggedObject({ _tokenResponse: tokenResponse }) {
1197
+ if (!tokenResponse) {
1198
+ return null;
1199
+ }
1200
+ const { phoneNumber, temporaryProof } = tokenResponse;
1201
+ if (phoneNumber && temporaryProof) {
1202
+ return register.PhoneAuthCredential._fromTokenResponse(phoneNumber, temporaryProof);
1203
+ }
1204
+ return null;
1205
+ }
1206
+ }
1207
+ /** Always set to {@link ProviderId}.PHONE. */
1208
+ PhoneAuthProvider.PROVIDER_ID = "phone" /* ProviderId.PHONE */;
1209
+ /** Always set to {@link SignInMethod}.PHONE. */
1210
+ PhoneAuthProvider.PHONE_SIGN_IN_METHOD = "phone" /* SignInMethod.PHONE */;
1211
+
1212
+ /**
1213
+ * @license
1214
+ * Copyright 2021 Google LLC
1215
+ *
1216
+ * Licensed under the Apache License, Version 2.0 (the "License");
1217
+ * you may not use this file except in compliance with the License.
1218
+ * You may obtain a copy of the License at
1219
+ *
1220
+ * http://www.apache.org/licenses/LICENSE-2.0
1221
+ *
1222
+ * Unless required by applicable law or agreed to in writing, software
1223
+ * distributed under the License is distributed on an "AS IS" BASIS,
1224
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1225
+ * See the License for the specific language governing permissions and
1226
+ * limitations under the License.
1227
+ */
1228
+ /**
1229
+ * Chooses a popup/redirect resolver to use. This prefers the override (which
1230
+ * is directly passed in), and falls back to the property set on the auth
1231
+ * object. If neither are available, this function errors w/ an argument error.
1232
+ */
1233
+ function _withDefaultResolver(auth, resolverOverride) {
1234
+ if (resolverOverride) {
1235
+ return register._getInstance(resolverOverride);
1236
+ }
1237
+ register._assert(auth._popupRedirectResolver, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
1238
+ return auth._popupRedirectResolver;
1239
+ }
1240
+
1241
+ /**
1242
+ * @license
1243
+ * Copyright 2019 Google LLC
1244
+ *
1245
+ * Licensed under the Apache License, Version 2.0 (the "License");
1246
+ * you may not use this file except in compliance with the License.
1247
+ * You may obtain a copy of the License at
1248
+ *
1249
+ * http://www.apache.org/licenses/LICENSE-2.0
1250
+ *
1251
+ * Unless required by applicable law or agreed to in writing, software
1252
+ * distributed under the License is distributed on an "AS IS" BASIS,
1253
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1254
+ * See the License for the specific language governing permissions and
1255
+ * limitations under the License.
1256
+ */
1257
+ class IdpCredential extends register.AuthCredential {
1258
+ constructor(params) {
1259
+ super("custom" /* ProviderId.CUSTOM */, "custom" /* ProviderId.CUSTOM */);
1260
+ this.params = params;
1261
+ }
1262
+ _getIdTokenResponse(auth) {
1263
+ return register.signInWithIdp(auth, this._buildIdpRequest());
1264
+ }
1265
+ _linkToIdToken(auth, idToken) {
1266
+ return register.signInWithIdp(auth, this._buildIdpRequest(idToken));
1267
+ }
1268
+ _getReauthenticationResolver(auth) {
1269
+ return register.signInWithIdp(auth, this._buildIdpRequest());
1270
+ }
1271
+ _buildIdpRequest(idToken) {
1272
+ const request = {
1273
+ requestUri: this.params.requestUri,
1274
+ sessionId: this.params.sessionId,
1275
+ postBody: this.params.postBody,
1276
+ tenantId: this.params.tenantId,
1277
+ pendingToken: this.params.pendingToken,
1278
+ returnSecureToken: true,
1279
+ returnIdpCredential: true
1280
+ };
1281
+ if (idToken) {
1282
+ request.idToken = idToken;
1283
+ }
1284
+ return request;
1285
+ }
1286
+ }
1287
+ function _signIn(params) {
1288
+ return register._signInWithCredential(params.auth, new IdpCredential(params), params.bypassAuthState);
1289
+ }
1290
+ function _reauth(params) {
1291
+ const { auth, user } = params;
1292
+ register._assert(user, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1293
+ return register._reauthenticate(user, new IdpCredential(params), params.bypassAuthState);
1294
+ }
1295
+ async function _link(params) {
1296
+ const { auth, user } = params;
1297
+ register._assert(user, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1298
+ return register._link(user, new IdpCredential(params), params.bypassAuthState);
1299
+ }
1300
+
1301
+ /**
1302
+ * @license
1303
+ * Copyright 2020 Google LLC
1304
+ *
1305
+ * Licensed under the Apache License, Version 2.0 (the "License");
1306
+ * you may not use this file except in compliance with the License.
1307
+ * You may obtain a copy of the License at
1308
+ *
1309
+ * http://www.apache.org/licenses/LICENSE-2.0
1310
+ *
1311
+ * Unless required by applicable law or agreed to in writing, software
1312
+ * distributed under the License is distributed on an "AS IS" BASIS,
1313
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
+ * See the License for the specific language governing permissions and
1315
+ * limitations under the License.
1316
+ */
1317
+ /**
1318
+ * Popup event manager. Handles the popup's entire lifecycle; listens to auth
1319
+ * events
1320
+ */
1321
+ class AbstractPopupRedirectOperation {
1322
+ constructor(auth, filter, resolver, user, bypassAuthState = false) {
1323
+ this.auth = auth;
1324
+ this.resolver = resolver;
1325
+ this.user = user;
1326
+ this.bypassAuthState = bypassAuthState;
1327
+ this.pendingPromise = null;
1328
+ this.eventManager = null;
1329
+ this.filter = Array.isArray(filter) ? filter : [filter];
1330
+ }
1331
+ execute() {
1332
+ return new Promise(async (resolve, reject) => {
1333
+ this.pendingPromise = { resolve, reject };
1334
+ try {
1335
+ this.eventManager = await this.resolver._initialize(this.auth);
1336
+ await this.onExecution();
1337
+ this.eventManager.registerConsumer(this);
1338
+ }
1339
+ catch (e) {
1340
+ this.reject(e);
1341
+ }
1342
+ });
1343
+ }
1344
+ async onAuthEvent(event) {
1345
+ const { urlResponse, sessionId, postBody, tenantId, error, type } = event;
1346
+ if (error) {
1347
+ this.reject(error);
1348
+ return;
1349
+ }
1350
+ const params = {
1351
+ auth: this.auth,
1352
+ requestUri: urlResponse,
1353
+ sessionId: sessionId,
1354
+ tenantId: tenantId || undefined,
1355
+ postBody: postBody || undefined,
1356
+ user: this.user,
1357
+ bypassAuthState: this.bypassAuthState
1358
+ };
1359
+ try {
1360
+ this.resolve(await this.getIdpTask(type)(params));
1361
+ }
1362
+ catch (e) {
1363
+ this.reject(e);
1364
+ }
1365
+ }
1366
+ onError(error) {
1367
+ this.reject(error);
1368
+ }
1369
+ getIdpTask(type) {
1370
+ switch (type) {
1371
+ case "signInViaPopup" /* AuthEventType.SIGN_IN_VIA_POPUP */:
1372
+ case "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */:
1373
+ return _signIn;
1374
+ case "linkViaPopup" /* AuthEventType.LINK_VIA_POPUP */:
1375
+ case "linkViaRedirect" /* AuthEventType.LINK_VIA_REDIRECT */:
1376
+ return _link;
1377
+ case "reauthViaPopup" /* AuthEventType.REAUTH_VIA_POPUP */:
1378
+ case "reauthViaRedirect" /* AuthEventType.REAUTH_VIA_REDIRECT */:
1379
+ return _reauth;
1380
+ default:
1381
+ register._fail(this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1382
+ }
1383
+ }
1384
+ resolve(cred) {
1385
+ register.debugAssert(this.pendingPromise, 'Pending promise was never set');
1386
+ this.pendingPromise.resolve(cred);
1387
+ this.unregisterAndCleanUp();
1388
+ }
1389
+ reject(error) {
1390
+ register.debugAssert(this.pendingPromise, 'Pending promise was never set');
1391
+ this.pendingPromise.reject(error);
1392
+ this.unregisterAndCleanUp();
1393
+ }
1394
+ unregisterAndCleanUp() {
1395
+ if (this.eventManager) {
1396
+ this.eventManager.unregisterConsumer(this);
1397
+ }
1398
+ this.pendingPromise = null;
1399
+ this.cleanUp();
1400
+ }
1401
+ }
1402
+
1403
+ /**
1404
+ * @license
1405
+ * Copyright 2020 Google LLC
1406
+ *
1407
+ * Licensed under the Apache License, Version 2.0 (the "License");
1408
+ * you may not use this file except in compliance with the License.
1409
+ * You may obtain a copy of the License at
1410
+ *
1411
+ * http://www.apache.org/licenses/LICENSE-2.0
1412
+ *
1413
+ * Unless required by applicable law or agreed to in writing, software
1414
+ * distributed under the License is distributed on an "AS IS" BASIS,
1415
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1416
+ * See the License for the specific language governing permissions and
1417
+ * limitations under the License.
1418
+ */
1419
+ const _POLL_WINDOW_CLOSE_TIMEOUT = new register.Delay(2000, 10000);
1420
+ /**
1421
+ * Authenticates a Firebase client using a popup-based OAuth authentication flow.
1422
+ *
1423
+ * @remarks
1424
+ * If succeeds, returns the signed in user along with the provider's credential. If sign in was
1425
+ * unsuccessful, returns an error object containing additional information about the error.
1426
+ *
1427
+ * This method does not work in a Node.js environment.
1428
+ *
1429
+ * @example
1430
+ * ```javascript
1431
+ * // Sign in using a popup.
1432
+ * const provider = new FacebookAuthProvider();
1433
+ * const result = await signInWithPopup(auth, provider);
1434
+ *
1435
+ * // The signed-in user info.
1436
+ * const user = result.user;
1437
+ * // This gives you a Facebook Access Token.
1438
+ * const credential = provider.credentialFromResult(auth, result);
1439
+ * const token = credential.accessToken;
1440
+ * ```
1441
+ *
1442
+ * @param auth - The {@link Auth} instance.
1443
+ * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1444
+ * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1445
+ * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1446
+ * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1447
+ *
1448
+ * @public
1449
+ */
1450
+ async function signInWithPopup(auth, provider, resolver) {
1451
+ const authInternal = register._castAuth(auth);
1452
+ register._assertInstanceOf(auth, provider, register.FederatedAuthProvider);
1453
+ const resolverInternal = _withDefaultResolver(authInternal, resolver);
1454
+ const action = new PopupOperation(authInternal, "signInViaPopup" /* AuthEventType.SIGN_IN_VIA_POPUP */, provider, resolverInternal);
1455
+ return action.executeNotNull();
1456
+ }
1457
+ /**
1458
+ * Reauthenticates the current user with the specified {@link OAuthProvider} using a pop-up based
1459
+ * OAuth flow.
1460
+ *
1461
+ * @remarks
1462
+ * If the reauthentication is successful, the returned result will contain the user and the
1463
+ * provider's credential.
1464
+ *
1465
+ * This method does not work in a Node.js environment.
1466
+ *
1467
+ * @example
1468
+ * ```javascript
1469
+ * // Sign in using a popup.
1470
+ * const provider = new FacebookAuthProvider();
1471
+ * const result = await signInWithPopup(auth, provider);
1472
+ * // Reauthenticate using a popup.
1473
+ * await reauthenticateWithPopup(result.user, provider);
1474
+ * ```
1475
+ *
1476
+ * @param user - The user.
1477
+ * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1478
+ * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1479
+ * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1480
+ * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1481
+ *
1482
+ * @public
1483
+ */
1484
+ async function reauthenticateWithPopup(user, provider, resolver) {
1485
+ const userInternal = util.getModularInstance(user);
1486
+ register._assertInstanceOf(userInternal.auth, provider, register.FederatedAuthProvider);
1487
+ const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1488
+ const action = new PopupOperation(userInternal.auth, "reauthViaPopup" /* AuthEventType.REAUTH_VIA_POPUP */, provider, resolverInternal, userInternal);
1489
+ return action.executeNotNull();
1490
+ }
1491
+ /**
1492
+ * Links the authenticated provider to the user account using a pop-up based OAuth flow.
1493
+ *
1494
+ * @remarks
1495
+ * If the linking is successful, the returned result will contain the user and the provider's credential.
1496
+ *
1497
+ * This method does not work in a Node.js environment.
1498
+ *
1499
+ * @example
1500
+ * ```javascript
1501
+ * // Sign in using some other provider.
1502
+ * const result = await signInWithEmailAndPassword(auth, email, password);
1503
+ * // Link using a popup.
1504
+ * const provider = new FacebookAuthProvider();
1505
+ * await linkWithPopup(result.user, provider);
1506
+ * ```
1507
+ *
1508
+ * @param user - The user.
1509
+ * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1510
+ * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1511
+ * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1512
+ * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1513
+ *
1514
+ * @public
1515
+ */
1516
+ async function linkWithPopup(user, provider, resolver) {
1517
+ const userInternal = util.getModularInstance(user);
1518
+ register._assertInstanceOf(userInternal.auth, provider, register.FederatedAuthProvider);
1519
+ const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1520
+ const action = new PopupOperation(userInternal.auth, "linkViaPopup" /* AuthEventType.LINK_VIA_POPUP */, provider, resolverInternal, userInternal);
1521
+ return action.executeNotNull();
1522
+ }
1523
+ /**
1524
+ * Popup event manager. Handles the popup's entire lifecycle; listens to auth
1525
+ * events
1526
+ *
1527
+ */
1528
+ class PopupOperation extends AbstractPopupRedirectOperation {
1529
+ constructor(auth, filter, provider, resolver, user) {
1530
+ super(auth, filter, resolver, user);
1531
+ this.provider = provider;
1532
+ this.authWindow = null;
1533
+ this.pollId = null;
1534
+ if (PopupOperation.currentPopupAction) {
1535
+ PopupOperation.currentPopupAction.cancel();
1536
+ }
1537
+ PopupOperation.currentPopupAction = this;
1538
+ }
1539
+ async executeNotNull() {
1540
+ const result = await this.execute();
1541
+ register._assert(result, this.auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1542
+ return result;
1543
+ }
1544
+ async onExecution() {
1545
+ register.debugAssert(this.filter.length === 1, 'Popup operations only handle one event');
1546
+ const eventId = register._generateEventId();
1547
+ this.authWindow = await this.resolver._openPopup(this.auth, this.provider, this.filter[0], // There's always one, see constructor
1548
+ eventId);
1549
+ this.authWindow.associatedEvent = eventId;
1550
+ // Check for web storage support and origin validation _after_ the popup is
1551
+ // loaded. These operations are slow (~1 second or so) Rather than
1552
+ // waiting on them before opening the window, optimistically open the popup
1553
+ // and check for storage support at the same time. If storage support is
1554
+ // not available, this will cause the whole thing to reject properly. It
1555
+ // will also close the popup, but since the promise has already rejected,
1556
+ // the popup closed by user poll will reject into the void.
1557
+ this.resolver._originValidation(this.auth).catch(e => {
1558
+ this.reject(e);
1559
+ });
1560
+ this.resolver._isIframeWebStorageSupported(this.auth, isSupported => {
1561
+ if (!isSupported) {
1562
+ this.reject(register._createError(this.auth, "web-storage-unsupported" /* AuthErrorCode.WEB_STORAGE_UNSUPPORTED */));
1563
+ }
1564
+ });
1565
+ // Handle user closure. Notice this does *not* use await
1566
+ this.pollUserCancellation();
1567
+ }
1568
+ get eventId() {
1569
+ var _a;
1570
+ return ((_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.associatedEvent) || null;
1571
+ }
1572
+ cancel() {
1573
+ this.reject(register._createError(this.auth, "cancelled-popup-request" /* AuthErrorCode.EXPIRED_POPUP_REQUEST */));
1574
+ }
1575
+ cleanUp() {
1576
+ if (this.authWindow) {
1577
+ this.authWindow.close();
1578
+ }
1579
+ if (this.pollId) {
1580
+ window.clearTimeout(this.pollId);
1581
+ }
1582
+ this.authWindow = null;
1583
+ this.pollId = null;
1584
+ PopupOperation.currentPopupAction = null;
1585
+ }
1586
+ pollUserCancellation() {
1587
+ const poll = () => {
1588
+ var _a, _b;
1589
+ if ((_b = (_a = this.authWindow) === null || _a === void 0 ? void 0 : _a.window) === null || _b === void 0 ? void 0 : _b.closed) {
1590
+ // Make sure that there is sufficient time for whatever action to
1591
+ // complete. The window could have closed but the sign in network
1592
+ // call could still be in flight. This is specifically true for
1593
+ // Firefox or if the opener is in an iframe, in which case the oauth
1594
+ // helper closes the popup.
1595
+ this.pollId = window.setTimeout(() => {
1596
+ this.pollId = null;
1597
+ this.reject(register._createError(this.auth, "popup-closed-by-user" /* AuthErrorCode.POPUP_CLOSED_BY_USER */));
1598
+ }, 8000 /* _Timeout.AUTH_EVENT */);
1599
+ return;
1600
+ }
1601
+ this.pollId = window.setTimeout(poll, _POLL_WINDOW_CLOSE_TIMEOUT.get());
1602
+ };
1603
+ poll();
1604
+ }
1605
+ }
1606
+ // Only one popup is ever shown at once. The lifecycle of the current popup
1607
+ // can be managed / cancelled by the constructor.
1608
+ PopupOperation.currentPopupAction = null;
1609
+
1610
+ /**
1611
+ * @license
1612
+ * Copyright 2020 Google LLC
1613
+ *
1614
+ * Licensed under the Apache License, Version 2.0 (the "License");
1615
+ * you may not use this file except in compliance with the License.
1616
+ * You may obtain a copy of the License at
1617
+ *
1618
+ * http://www.apache.org/licenses/LICENSE-2.0
1619
+ *
1620
+ * Unless required by applicable law or agreed to in writing, software
1621
+ * distributed under the License is distributed on an "AS IS" BASIS,
1622
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1623
+ * See the License for the specific language governing permissions and
1624
+ * limitations under the License.
1625
+ */
1626
+ const PENDING_REDIRECT_KEY = 'pendingRedirect';
1627
+ // We only get one redirect outcome for any one auth, so just store it
1628
+ // in here.
1629
+ const redirectOutcomeMap = new Map();
1630
+ class RedirectAction extends AbstractPopupRedirectOperation {
1631
+ constructor(auth, resolver, bypassAuthState = false) {
1632
+ super(auth, [
1633
+ "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */,
1634
+ "linkViaRedirect" /* AuthEventType.LINK_VIA_REDIRECT */,
1635
+ "reauthViaRedirect" /* AuthEventType.REAUTH_VIA_REDIRECT */,
1636
+ "unknown" /* AuthEventType.UNKNOWN */
1637
+ ], resolver, undefined, bypassAuthState);
1638
+ this.eventId = null;
1639
+ }
1640
+ /**
1641
+ * Override the execute function; if we already have a redirect result, then
1642
+ * just return it.
1643
+ */
1644
+ async execute() {
1645
+ let readyOutcome = redirectOutcomeMap.get(this.auth._key());
1646
+ if (!readyOutcome) {
1647
+ try {
1648
+ const hasPendingRedirect = await _getAndClearPendingRedirectStatus(this.resolver, this.auth);
1649
+ const result = hasPendingRedirect ? await super.execute() : null;
1650
+ readyOutcome = () => Promise.resolve(result);
1651
+ }
1652
+ catch (e) {
1653
+ readyOutcome = () => Promise.reject(e);
1654
+ }
1655
+ redirectOutcomeMap.set(this.auth._key(), readyOutcome);
1656
+ }
1657
+ // If we're not bypassing auth state, the ready outcome should be set to
1658
+ // null.
1659
+ if (!this.bypassAuthState) {
1660
+ redirectOutcomeMap.set(this.auth._key(), () => Promise.resolve(null));
1661
+ }
1662
+ return readyOutcome();
1663
+ }
1664
+ async onAuthEvent(event) {
1665
+ if (event.type === "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */) {
1666
+ return super.onAuthEvent(event);
1667
+ }
1668
+ else if (event.type === "unknown" /* AuthEventType.UNKNOWN */) {
1669
+ // This is a sentinel value indicating there's no pending redirect
1670
+ this.resolve(null);
1671
+ return;
1672
+ }
1673
+ if (event.eventId) {
1674
+ const user = await this.auth._redirectUserForId(event.eventId);
1675
+ if (user) {
1676
+ this.user = user;
1677
+ return super.onAuthEvent(event);
1678
+ }
1679
+ else {
1680
+ this.resolve(null);
1681
+ }
1682
+ }
1683
+ }
1684
+ async onExecution() { }
1685
+ cleanUp() { }
1686
+ }
1687
+ async function _getAndClearPendingRedirectStatus(resolver, auth) {
1688
+ const key = pendingRedirectKey(auth);
1689
+ const persistence = resolverPersistence(resolver);
1690
+ if (!(await persistence._isAvailable())) {
1691
+ return false;
1692
+ }
1693
+ const hasPendingRedirect = (await persistence._get(key)) === 'true';
1694
+ await persistence._remove(key);
1695
+ return hasPendingRedirect;
1696
+ }
1697
+ async function _setPendingRedirectStatus(resolver, auth) {
1698
+ return resolverPersistence(resolver)._set(pendingRedirectKey(auth), 'true');
1699
+ }
1700
+ function _clearRedirectOutcomes() {
1701
+ redirectOutcomeMap.clear();
1702
+ }
1703
+ function _overrideRedirectResult(auth, result) {
1704
+ redirectOutcomeMap.set(auth._key(), result);
1705
+ }
1706
+ function resolverPersistence(resolver) {
1707
+ return register._getInstance(resolver._redirectPersistence);
1708
+ }
1709
+ function pendingRedirectKey(auth) {
1710
+ return register._persistenceKeyName(PENDING_REDIRECT_KEY, auth.config.apiKey, auth.name);
1711
+ }
1712
+
1713
+ /**
1714
+ * @license
1715
+ * Copyright 2020 Google LLC
1716
+ *
1717
+ * Licensed under the Apache License, Version 2.0 (the "License");
1718
+ * you may not use this file except in compliance with the License.
1719
+ * You may obtain a copy of the License at
1720
+ *
1721
+ * http://www.apache.org/licenses/LICENSE-2.0
1722
+ *
1723
+ * Unless required by applicable law or agreed to in writing, software
1724
+ * distributed under the License is distributed on an "AS IS" BASIS,
1725
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1726
+ * See the License for the specific language governing permissions and
1727
+ * limitations under the License.
1728
+ */
1729
+ /**
1730
+ * Authenticates a Firebase client using a full-page redirect flow.
1731
+ *
1732
+ * @remarks
1733
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
1734
+ * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
1735
+ * | best practices} when using {@link signInWithRedirect}.
1736
+ *
1737
+ * This method does not work in a Node.js environment.
1738
+ *
1739
+ * @example
1740
+ * ```javascript
1741
+ * // Sign in using a redirect.
1742
+ * const provider = new FacebookAuthProvider();
1743
+ * // You can add additional scopes to the provider:
1744
+ * provider.addScope('user_birthday');
1745
+ * // Start a sign in process for an unauthenticated user.
1746
+ * await signInWithRedirect(auth, provider);
1747
+ * // This will trigger a full page redirect away from your app
1748
+ *
1749
+ * // After returning from the redirect when your app initializes you can obtain the result
1750
+ * const result = await getRedirectResult(auth);
1751
+ * if (result) {
1752
+ * // This is the signed-in user
1753
+ * const user = result.user;
1754
+ * // This gives you a Facebook Access Token.
1755
+ * const credential = provider.credentialFromResult(auth, result);
1756
+ * const token = credential.accessToken;
1757
+ * }
1758
+ * // As this API can be used for sign-in, linking and reauthentication,
1759
+ * // check the operationType to determine what triggered this redirect
1760
+ * // operation.
1761
+ * const operationType = result.operationType;
1762
+ * ```
1763
+ *
1764
+ * @param auth - The {@link Auth} instance.
1765
+ * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1766
+ * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1767
+ * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1768
+ * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1769
+ *
1770
+ * @public
1771
+ */
1772
+ function signInWithRedirect(auth, provider, resolver) {
1773
+ return _signInWithRedirect(auth, provider, resolver);
1774
+ }
1775
+ async function _signInWithRedirect(auth, provider, resolver) {
1776
+ const authInternal = register._castAuth(auth);
1777
+ register._assertInstanceOf(auth, provider, register.FederatedAuthProvider);
1778
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
1779
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
1780
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
1781
+ await authInternal._initializationPromise;
1782
+ const resolverInternal = _withDefaultResolver(authInternal, resolver);
1783
+ await _setPendingRedirectStatus(resolverInternal, authInternal);
1784
+ return resolverInternal._openRedirect(authInternal, provider, "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */);
1785
+ }
1786
+ /**
1787
+ * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
1788
+ * @remarks
1789
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
1790
+ * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
1791
+ * | best practices} when using {@link reauthenticateWithRedirect}.
1792
+ *
1793
+ * This method does not work in a Node.js environment.
1794
+ *
1795
+ * @example
1796
+ * ```javascript
1797
+ * // Sign in using a redirect.
1798
+ * const provider = new FacebookAuthProvider();
1799
+ * const result = await signInWithRedirect(auth, provider);
1800
+ * // This will trigger a full page redirect away from your app
1801
+ *
1802
+ * // After returning from the redirect when your app initializes you can obtain the result
1803
+ * const result = await getRedirectResult(auth);
1804
+ * // Reauthenticate using a redirect.
1805
+ * await reauthenticateWithRedirect(result.user, provider);
1806
+ * // This will again trigger a full page redirect away from your app
1807
+ *
1808
+ * // After returning from the redirect when your app initializes you can obtain the result
1809
+ * const result = await getRedirectResult(auth);
1810
+ * ```
1811
+ *
1812
+ * @param user - The user.
1813
+ * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1814
+ * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1815
+ * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1816
+ * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1817
+ *
1818
+ * @public
1819
+ */
1820
+ function reauthenticateWithRedirect(user, provider, resolver) {
1821
+ return _reauthenticateWithRedirect(user, provider, resolver);
1822
+ }
1823
+ async function _reauthenticateWithRedirect(user, provider, resolver) {
1824
+ const userInternal = util.getModularInstance(user);
1825
+ register._assertInstanceOf(userInternal.auth, provider, register.FederatedAuthProvider);
1826
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
1827
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
1828
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
1829
+ await userInternal.auth._initializationPromise;
1830
+ // Allow the resolver to error before persisting the redirect user
1831
+ const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1832
+ await _setPendingRedirectStatus(resolverInternal, userInternal.auth);
1833
+ const eventId = await prepareUserForRedirect(userInternal);
1834
+ return resolverInternal._openRedirect(userInternal.auth, provider, "reauthViaRedirect" /* AuthEventType.REAUTH_VIA_REDIRECT */, eventId);
1835
+ }
1836
+ /**
1837
+ * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
1838
+ * @remarks
1839
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
1840
+ * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
1841
+ * | best practices} when using {@link linkWithRedirect}.
1842
+ *
1843
+ * This method does not work in a Node.js environment.
1844
+ *
1845
+ * @example
1846
+ * ```javascript
1847
+ * // Sign in using some other provider.
1848
+ * const result = await signInWithEmailAndPassword(auth, email, password);
1849
+ * // Link using a redirect.
1850
+ * const provider = new FacebookAuthProvider();
1851
+ * await linkWithRedirect(result.user, provider);
1852
+ * // This will trigger a full page redirect away from your app
1853
+ *
1854
+ * // After returning from the redirect when your app initializes you can obtain the result
1855
+ * const result = await getRedirectResult(auth);
1856
+ * ```
1857
+ *
1858
+ * @param user - The user.
1859
+ * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1860
+ * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1861
+ * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1862
+ * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1863
+ *
1864
+ * @public
1865
+ */
1866
+ function linkWithRedirect(user, provider, resolver) {
1867
+ return _linkWithRedirect(user, provider, resolver);
1868
+ }
1869
+ async function _linkWithRedirect(user, provider, resolver) {
1870
+ const userInternal = util.getModularInstance(user);
1871
+ register._assertInstanceOf(userInternal.auth, provider, register.FederatedAuthProvider);
1872
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
1873
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
1874
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
1875
+ await userInternal.auth._initializationPromise;
1876
+ // Allow the resolver to error before persisting the redirect user
1877
+ const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1878
+ await register._assertLinkedStatus(false, userInternal, provider.providerId);
1879
+ await _setPendingRedirectStatus(resolverInternal, userInternal.auth);
1880
+ const eventId = await prepareUserForRedirect(userInternal);
1881
+ return resolverInternal._openRedirect(userInternal.auth, provider, "linkViaRedirect" /* AuthEventType.LINK_VIA_REDIRECT */, eventId);
1882
+ }
1883
+ /**
1884
+ * Returns a {@link UserCredential} from the redirect-based sign-in flow.
1885
+ *
1886
+ * @remarks
1887
+ * If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an
1888
+ * error. If no redirect operation was called, returns `null`.
1889
+ *
1890
+ * This method does not work in a Node.js environment.
1891
+ *
1892
+ * @example
1893
+ * ```javascript
1894
+ * // Sign in using a redirect.
1895
+ * const provider = new FacebookAuthProvider();
1896
+ * // You can add additional scopes to the provider:
1897
+ * provider.addScope('user_birthday');
1898
+ * // Start a sign in process for an unauthenticated user.
1899
+ * await signInWithRedirect(auth, provider);
1900
+ * // This will trigger a full page redirect away from your app
1901
+ *
1902
+ * // After returning from the redirect when your app initializes you can obtain the result
1903
+ * const result = await getRedirectResult(auth);
1904
+ * if (result) {
1905
+ * // This is the signed-in user
1906
+ * const user = result.user;
1907
+ * // This gives you a Facebook Access Token.
1908
+ * const credential = provider.credentialFromResult(auth, result);
1909
+ * const token = credential.accessToken;
1910
+ * }
1911
+ * // As this API can be used for sign-in, linking and reauthentication,
1912
+ * // check the operationType to determine what triggered this redirect
1913
+ * // operation.
1914
+ * const operationType = result.operationType;
1915
+ * ```
1916
+ *
1917
+ * @param auth - The {@link Auth} instance.
1918
+ * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1919
+ * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1920
+ *
1921
+ * @public
1922
+ */
1923
+ async function getRedirectResult(auth, resolver) {
1924
+ await register._castAuth(auth)._initializationPromise;
1925
+ return _getRedirectResult(auth, resolver, false);
1926
+ }
1927
+ async function _getRedirectResult(auth, resolverExtern, bypassAuthState = false) {
1928
+ const authInternal = register._castAuth(auth);
1929
+ const resolver = _withDefaultResolver(authInternal, resolverExtern);
1930
+ const action = new RedirectAction(authInternal, resolver, bypassAuthState);
1931
+ const result = await action.execute();
1932
+ if (result && !bypassAuthState) {
1933
+ delete result.user._redirectEventId;
1934
+ await authInternal._persistUserIfCurrent(result.user);
1935
+ await authInternal._setRedirectUser(null, resolverExtern);
1936
+ }
1937
+ return result;
1938
+ }
1939
+ async function prepareUserForRedirect(user) {
1940
+ const eventId = register._generateEventId(`${user.uid}:::`);
1941
+ user._redirectEventId = eventId;
1942
+ await user.auth._setRedirectUser(user);
1943
+ await user.auth._persistUserIfCurrent(user);
1944
+ return eventId;
1945
+ }
1946
+
1947
+ /**
1948
+ * @license
1949
+ * Copyright 2020 Google LLC
1950
+ *
1951
+ * Licensed under the Apache License, Version 2.0 (the "License");
1952
+ * you may not use this file except in compliance with the License.
1953
+ * You may obtain a copy of the License at
1954
+ *
1955
+ * http://www.apache.org/licenses/LICENSE-2.0
1956
+ *
1957
+ * Unless required by applicable law or agreed to in writing, software
1958
+ * distributed under the License is distributed on an "AS IS" BASIS,
1959
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1960
+ * See the License for the specific language governing permissions and
1961
+ * limitations under the License.
1962
+ */
1963
+ // The amount of time to store the UIDs of seen events; this is
1964
+ // set to 10 min by default
1965
+ const EVENT_DUPLICATION_CACHE_DURATION_MS = 10 * 60 * 1000;
1966
+ class AuthEventManager {
1967
+ constructor(auth) {
1968
+ this.auth = auth;
1969
+ this.cachedEventUids = new Set();
1970
+ this.consumers = new Set();
1971
+ this.queuedRedirectEvent = null;
1972
+ this.hasHandledPotentialRedirect = false;
1973
+ this.lastProcessedEventTime = Date.now();
1974
+ }
1975
+ registerConsumer(authEventConsumer) {
1976
+ this.consumers.add(authEventConsumer);
1977
+ if (this.queuedRedirectEvent &&
1978
+ this.isEventForConsumer(this.queuedRedirectEvent, authEventConsumer)) {
1979
+ this.sendToConsumer(this.queuedRedirectEvent, authEventConsumer);
1980
+ this.saveEventToCache(this.queuedRedirectEvent);
1981
+ this.queuedRedirectEvent = null;
1982
+ }
1983
+ }
1984
+ unregisterConsumer(authEventConsumer) {
1985
+ this.consumers.delete(authEventConsumer);
1986
+ }
1987
+ onEvent(event) {
1988
+ // Check if the event has already been handled
1989
+ if (this.hasEventBeenHandled(event)) {
1990
+ return false;
1991
+ }
1992
+ let handled = false;
1993
+ this.consumers.forEach(consumer => {
1994
+ if (this.isEventForConsumer(event, consumer)) {
1995
+ handled = true;
1996
+ this.sendToConsumer(event, consumer);
1997
+ this.saveEventToCache(event);
1998
+ }
1999
+ });
2000
+ if (this.hasHandledPotentialRedirect || !isRedirectEvent(event)) {
2001
+ // If we've already seen a redirect before, or this is a popup event,
2002
+ // bail now
2003
+ return handled;
2004
+ }
2005
+ this.hasHandledPotentialRedirect = true;
2006
+ // If the redirect wasn't handled, hang on to it
2007
+ if (!handled) {
2008
+ this.queuedRedirectEvent = event;
2009
+ handled = true;
2010
+ }
2011
+ return handled;
2012
+ }
2013
+ sendToConsumer(event, consumer) {
2014
+ var _a;
2015
+ if (event.error && !isNullRedirectEvent(event)) {
2016
+ const code = ((_a = event.error.code) === null || _a === void 0 ? void 0 : _a.split('auth/')[1]) ||
2017
+ "internal-error" /* AuthErrorCode.INTERNAL_ERROR */;
2018
+ consumer.onError(register._createError(this.auth, code));
2019
+ }
2020
+ else {
2021
+ consumer.onAuthEvent(event);
2022
+ }
2023
+ }
2024
+ isEventForConsumer(event, consumer) {
2025
+ const eventIdMatches = consumer.eventId === null ||
2026
+ (!!event.eventId && event.eventId === consumer.eventId);
2027
+ return consumer.filter.includes(event.type) && eventIdMatches;
2028
+ }
2029
+ hasEventBeenHandled(event) {
2030
+ if (Date.now() - this.lastProcessedEventTime >=
2031
+ EVENT_DUPLICATION_CACHE_DURATION_MS) {
2032
+ this.cachedEventUids.clear();
2033
+ }
2034
+ return this.cachedEventUids.has(eventUid(event));
2035
+ }
2036
+ saveEventToCache(event) {
2037
+ this.cachedEventUids.add(eventUid(event));
2038
+ this.lastProcessedEventTime = Date.now();
2039
+ }
2040
+ }
2041
+ function eventUid(e) {
2042
+ return [e.type, e.eventId, e.sessionId, e.tenantId].filter(v => v).join('-');
2043
+ }
2044
+ function isNullRedirectEvent({ type, error }) {
2045
+ return (type === "unknown" /* AuthEventType.UNKNOWN */ &&
2046
+ (error === null || error === void 0 ? void 0 : error.code) === `auth/${"no-auth-event" /* AuthErrorCode.NO_AUTH_EVENT */}`);
2047
+ }
2048
+ function isRedirectEvent(event) {
2049
+ switch (event.type) {
2050
+ case "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */:
2051
+ case "linkViaRedirect" /* AuthEventType.LINK_VIA_REDIRECT */:
2052
+ case "reauthViaRedirect" /* AuthEventType.REAUTH_VIA_REDIRECT */:
2053
+ return true;
2054
+ case "unknown" /* AuthEventType.UNKNOWN */:
2055
+ return isNullRedirectEvent(event);
2056
+ default:
2057
+ return false;
2058
+ }
2059
+ }
2060
+
2061
+ /**
2062
+ * @license
2063
+ * Copyright 2020 Google LLC
2064
+ *
2065
+ * Licensed under the Apache License, Version 2.0 (the "License");
2066
+ * you may not use this file except in compliance with the License.
2067
+ * You may obtain a copy of the License at
2068
+ *
2069
+ * http://www.apache.org/licenses/LICENSE-2.0
2070
+ *
2071
+ * Unless required by applicable law or agreed to in writing, software
2072
+ * distributed under the License is distributed on an "AS IS" BASIS,
2073
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2074
+ * See the License for the specific language governing permissions and
2075
+ * limitations under the License.
2076
+ */
2077
+ async function _getProjectConfig(auth, request = {}) {
2078
+ return register._performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/projects" /* Endpoint.GET_PROJECT_CONFIG */, request);
2079
+ }
2080
+
2081
+ /**
2082
+ * @license
2083
+ * Copyright 2020 Google LLC
2084
+ *
2085
+ * Licensed under the Apache License, Version 2.0 (the "License");
2086
+ * you may not use this file except in compliance with the License.
2087
+ * You may obtain a copy of the License at
2088
+ *
2089
+ * http://www.apache.org/licenses/LICENSE-2.0
2090
+ *
2091
+ * Unless required by applicable law or agreed to in writing, software
2092
+ * distributed under the License is distributed on an "AS IS" BASIS,
2093
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2094
+ * See the License for the specific language governing permissions and
2095
+ * limitations under the License.
2096
+ */
2097
+ const IP_ADDRESS_REGEX = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
2098
+ const HTTP_REGEX = /^https?/;
2099
+ async function _validateOrigin$1(auth) {
2100
+ // Skip origin validation if we are in an emulated environment
2101
+ if (auth.config.emulator) {
2102
+ return;
2103
+ }
2104
+ const { authorizedDomains } = await _getProjectConfig(auth);
2105
+ for (const domain of authorizedDomains) {
2106
+ try {
2107
+ if (matchDomain(domain)) {
2108
+ return;
2109
+ }
2110
+ }
2111
+ catch (_a) {
2112
+ // Do nothing if there's a URL error; just continue searching
2113
+ }
2114
+ }
2115
+ // In the old SDK, this error also provides helpful messages.
2116
+ register._fail(auth, "unauthorized-domain" /* AuthErrorCode.INVALID_ORIGIN */);
2117
+ }
2118
+ function matchDomain(expected) {
2119
+ const currentUrl = register._getCurrentUrl();
2120
+ const { protocol, hostname } = new URL(currentUrl);
2121
+ if (expected.startsWith('chrome-extension://')) {
2122
+ const ceUrl = new URL(expected);
2123
+ if (ceUrl.hostname === '' && hostname === '') {
2124
+ // For some reason we're not parsing chrome URLs properly
2125
+ return (protocol === 'chrome-extension:' &&
2126
+ expected.replace('chrome-extension://', '') ===
2127
+ currentUrl.replace('chrome-extension://', ''));
2128
+ }
2129
+ return protocol === 'chrome-extension:' && ceUrl.hostname === hostname;
2130
+ }
2131
+ if (!HTTP_REGEX.test(protocol)) {
2132
+ return false;
2133
+ }
2134
+ if (IP_ADDRESS_REGEX.test(expected)) {
2135
+ // The domain has to be exactly equal to the pattern, as an IP domain will
2136
+ // only contain the IP, no extra character.
2137
+ return hostname === expected;
2138
+ }
2139
+ // Dots in pattern should be escaped.
2140
+ const escapedDomainPattern = expected.replace(/\./g, '\\.');
2141
+ // Non ip address domains.
2142
+ // domain.com = *.domain.com OR domain.com
2143
+ const re = new RegExp('^(.+\\.' + escapedDomainPattern + '|' + escapedDomainPattern + ')$', 'i');
2144
+ return re.test(hostname);
2145
+ }
2146
+
2147
+ /**
2148
+ * @license
2149
+ * Copyright 2020 Google LLC.
2150
+ *
2151
+ * Licensed under the Apache License, Version 2.0 (the "License");
2152
+ * you may not use this file except in compliance with the License.
2153
+ * You may obtain a copy of the License at
2154
+ *
2155
+ * http://www.apache.org/licenses/LICENSE-2.0
2156
+ *
2157
+ * Unless required by applicable law or agreed to in writing, software
2158
+ * distributed under the License is distributed on an "AS IS" BASIS,
2159
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2160
+ * See the License for the specific language governing permissions and
2161
+ * limitations under the License.
2162
+ */
2163
+ const NETWORK_TIMEOUT = new register.Delay(30000, 60000);
2164
+ /**
2165
+ * Reset unlaoded GApi modules. If gapi.load fails due to a network error,
2166
+ * it will stop working after a retrial. This is a hack to fix this issue.
2167
+ */
2168
+ function resetUnloadedGapiModules() {
2169
+ // Clear last failed gapi.load state to force next gapi.load to first
2170
+ // load the failed gapi.iframes module.
2171
+ // Get gapix.beacon context.
2172
+ const beacon = register._window().___jsl;
2173
+ // Get current hint.
2174
+ if (beacon === null || beacon === void 0 ? void 0 : beacon.H) {
2175
+ // Get gapi hint.
2176
+ for (const hint of Object.keys(beacon.H)) {
2177
+ // Requested modules.
2178
+ beacon.H[hint].r = beacon.H[hint].r || [];
2179
+ // Loaded modules.
2180
+ beacon.H[hint].L = beacon.H[hint].L || [];
2181
+ // Set requested modules to a copy of the loaded modules.
2182
+ beacon.H[hint].r = [...beacon.H[hint].L];
2183
+ // Clear pending callbacks.
2184
+ if (beacon.CP) {
2185
+ for (let i = 0; i < beacon.CP.length; i++) {
2186
+ // Remove all failed pending callbacks.
2187
+ beacon.CP[i] = null;
2188
+ }
2189
+ }
2190
+ }
2191
+ }
2192
+ }
2193
+ function loadGapi(auth) {
2194
+ return new Promise((resolve, reject) => {
2195
+ var _a, _b, _c;
2196
+ // Function to run when gapi.load is ready.
2197
+ function loadGapiIframe() {
2198
+ // The developer may have tried to previously run gapi.load and failed.
2199
+ // Run this to fix that.
2200
+ resetUnloadedGapiModules();
2201
+ gapi.load('gapi.iframes', {
2202
+ callback: () => {
2203
+ resolve(gapi.iframes.getContext());
2204
+ },
2205
+ ontimeout: () => {
2206
+ // The above reset may be sufficient, but having this reset after
2207
+ // failure ensures that if the developer calls gapi.load after the
2208
+ // connection is re-established and before another attempt to embed
2209
+ // the iframe, it would work and would not be broken because of our
2210
+ // failed attempt.
2211
+ // Timeout when gapi.iframes.Iframe not loaded.
2212
+ resetUnloadedGapiModules();
2213
+ reject(register._createError(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */));
2214
+ },
2215
+ timeout: NETWORK_TIMEOUT.get()
2216
+ });
2217
+ }
2218
+ if ((_b = (_a = register._window().gapi) === null || _a === void 0 ? void 0 : _a.iframes) === null || _b === void 0 ? void 0 : _b.Iframe) {
2219
+ // If gapi.iframes.Iframe available, resolve.
2220
+ resolve(gapi.iframes.getContext());
2221
+ }
2222
+ else if (!!((_c = register._window().gapi) === null || _c === void 0 ? void 0 : _c.load)) {
2223
+ // Gapi loader ready, load gapi.iframes.
2224
+ loadGapiIframe();
2225
+ }
2226
+ else {
2227
+ // Create a new iframe callback when this is called so as not to overwrite
2228
+ // any previous defined callback. This happens if this method is called
2229
+ // multiple times in parallel and could result in the later callback
2230
+ // overwriting the previous one. This would end up with a iframe
2231
+ // timeout.
2232
+ const cbName = register._generateCallbackName('iframefcb');
2233
+ // GApi loader not available, dynamically load platform.js.
2234
+ register._window()[cbName] = () => {
2235
+ // GApi loader should be ready.
2236
+ if (!!gapi.load) {
2237
+ loadGapiIframe();
2238
+ }
2239
+ else {
2240
+ // Gapi loader failed, throw error.
2241
+ reject(register._createError(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */));
2242
+ }
2243
+ };
2244
+ // Load GApi loader.
2245
+ return register._loadJS(`${register._gapiScriptUrl()}?onload=${cbName}`)
2246
+ .catch(e => reject(e));
2247
+ }
2248
+ }).catch(error => {
2249
+ // Reset cached promise to allow for retrial.
2250
+ cachedGApiLoader = null;
2251
+ throw error;
2252
+ });
2253
+ }
2254
+ let cachedGApiLoader = null;
2255
+ function _loadGapi(auth) {
2256
+ cachedGApiLoader = cachedGApiLoader || loadGapi(auth);
2257
+ return cachedGApiLoader;
2258
+ }
2259
+
2260
+ /**
2261
+ * @license
2262
+ * Copyright 2020 Google LLC.
2263
+ *
2264
+ * Licensed under the Apache License, Version 2.0 (the "License");
2265
+ * you may not use this file except in compliance with the License.
2266
+ * You may obtain a copy of the License at
2267
+ *
2268
+ * http://www.apache.org/licenses/LICENSE-2.0
2269
+ *
2270
+ * Unless required by applicable law or agreed to in writing, software
2271
+ * distributed under the License is distributed on an "AS IS" BASIS,
2272
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2273
+ * See the License for the specific language governing permissions and
2274
+ * limitations under the License.
2275
+ */
2276
+ const PING_TIMEOUT = new register.Delay(5000, 15000);
2277
+ const IFRAME_PATH = '__/auth/iframe';
2278
+ const EMULATED_IFRAME_PATH = 'emulator/auth/iframe';
2279
+ const IFRAME_ATTRIBUTES = {
2280
+ style: {
2281
+ position: 'absolute',
2282
+ top: '-100px',
2283
+ width: '1px',
2284
+ height: '1px'
2285
+ },
2286
+ 'aria-hidden': 'true',
2287
+ tabindex: '-1'
2288
+ };
2289
+ // Map from apiHost to endpoint ID for passing into iframe. In current SDK, apiHost can be set to
2290
+ // anything (not from a list of endpoints with IDs as in legacy), so this is the closest we can get.
2291
+ const EID_FROM_APIHOST = new Map([
2292
+ ["identitytoolkit.googleapis.com" /* DefaultConfig.API_HOST */, 'p'],
2293
+ ['staging-identitytoolkit.sandbox.googleapis.com', 's'],
2294
+ ['test-identitytoolkit.sandbox.googleapis.com', 't'] // test
2295
+ ]);
2296
+ function getIframeUrl(auth) {
2297
+ const config = auth.config;
2298
+ register._assert(config.authDomain, auth, "auth-domain-config-required" /* AuthErrorCode.MISSING_AUTH_DOMAIN */);
2299
+ const url = config.emulator
2300
+ ? register._emulatorUrl(config, EMULATED_IFRAME_PATH)
2301
+ : `https://${auth.config.authDomain}/${IFRAME_PATH}`;
2302
+ const params = {
2303
+ apiKey: config.apiKey,
2304
+ appName: auth.name,
2305
+ v: app.SDK_VERSION
2306
+ };
2307
+ const eid = EID_FROM_APIHOST.get(auth.config.apiHost);
2308
+ if (eid) {
2309
+ params.eid = eid;
2310
+ }
2311
+ const frameworks = auth._getFrameworks();
2312
+ if (frameworks.length) {
2313
+ params.fw = frameworks.join(',');
2314
+ }
2315
+ return `${url}?${util.querystring(params).slice(1)}`;
2316
+ }
2317
+ async function _openIframe(auth) {
2318
+ const context = await _loadGapi(auth);
2319
+ const gapi = register._window().gapi;
2320
+ register._assert(gapi, auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2321
+ return context.open({
2322
+ where: document.body,
2323
+ url: getIframeUrl(auth),
2324
+ messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
2325
+ attributes: IFRAME_ATTRIBUTES,
2326
+ dontclear: true
2327
+ }, (iframe) => new Promise(async (resolve, reject) => {
2328
+ await iframe.restyle({
2329
+ // Prevent iframe from closing on mouse out.
2330
+ setHideOnLeave: false
2331
+ });
2332
+ const networkError = register._createError(auth, "network-request-failed" /* AuthErrorCode.NETWORK_REQUEST_FAILED */);
2333
+ // Confirm iframe is correctly loaded.
2334
+ // To fallback on failure, set a timeout.
2335
+ const networkErrorTimer = register._window().setTimeout(() => {
2336
+ reject(networkError);
2337
+ }, PING_TIMEOUT.get());
2338
+ // Clear timer and resolve pending iframe ready promise.
2339
+ function clearTimerAndResolve() {
2340
+ register._window().clearTimeout(networkErrorTimer);
2341
+ resolve(iframe);
2342
+ }
2343
+ // This returns an IThenable. However the reject part does not call
2344
+ // when the iframe is not loaded.
2345
+ iframe.ping(clearTimerAndResolve).then(clearTimerAndResolve, () => {
2346
+ reject(networkError);
2347
+ });
2348
+ }));
2349
+ }
2350
+
2351
+ /**
2352
+ * @license
2353
+ * Copyright 2020 Google LLC.
2354
+ *
2355
+ * Licensed under the Apache License, Version 2.0 (the "License");
2356
+ * you may not use this file except in compliance with the License.
2357
+ * You may obtain a copy of the License at
2358
+ *
2359
+ * http://www.apache.org/licenses/LICENSE-2.0
2360
+ *
2361
+ * Unless required by applicable law or agreed to in writing, software
2362
+ * distributed under the License is distributed on an "AS IS" BASIS,
2363
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2364
+ * See the License for the specific language governing permissions and
2365
+ * limitations under the License.
2366
+ */
2367
+ const BASE_POPUP_OPTIONS = {
2368
+ location: 'yes',
2369
+ resizable: 'yes',
2370
+ statusbar: 'yes',
2371
+ toolbar: 'no'
2372
+ };
2373
+ const DEFAULT_WIDTH = 500;
2374
+ const DEFAULT_HEIGHT = 600;
2375
+ const TARGET_BLANK = '_blank';
2376
+ const FIREFOX_EMPTY_URL = 'http://localhost';
2377
+ class AuthPopup {
2378
+ constructor(window) {
2379
+ this.window = window;
2380
+ this.associatedEvent = null;
2381
+ }
2382
+ close() {
2383
+ if (this.window) {
2384
+ try {
2385
+ this.window.close();
2386
+ }
2387
+ catch (e) { }
2388
+ }
2389
+ }
2390
+ }
2391
+ function _open(auth, url, name, width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT) {
2392
+ const top = Math.max((window.screen.availHeight - height) / 2, 0).toString();
2393
+ const left = Math.max((window.screen.availWidth - width) / 2, 0).toString();
2394
+ let target = '';
2395
+ const options = Object.assign(Object.assign({}, BASE_POPUP_OPTIONS), { width: width.toString(), height: height.toString(), top,
2396
+ left });
2397
+ // Chrome iOS 7 and 8 is returning an undefined popup win when target is
2398
+ // specified, even though the popup is not necessarily blocked.
2399
+ const ua = util.getUA().toLowerCase();
2400
+ if (name) {
2401
+ target = register._isChromeIOS(ua) ? TARGET_BLANK : name;
2402
+ }
2403
+ if (register._isFirefox(ua)) {
2404
+ // Firefox complains when invalid URLs are popped out. Hacky way to bypass.
2405
+ url = url || FIREFOX_EMPTY_URL;
2406
+ // Firefox disables by default scrolling on popup windows, which can create
2407
+ // issues when the user has many Google accounts, for instance.
2408
+ options.scrollbars = 'yes';
2409
+ }
2410
+ const optionsString = Object.entries(options).reduce((accum, [key, value]) => `${accum}${key}=${value},`, '');
2411
+ if (register._isIOSStandalone(ua) && target !== '_self') {
2412
+ openAsNewWindowIOS(url || '', target);
2413
+ return new AuthPopup(null);
2414
+ }
2415
+ // about:blank getting sanitized causing browsers like IE/Edge to display
2416
+ // brief error message before redirecting to handler.
2417
+ const newWin = window.open(url || '', target, optionsString);
2418
+ register._assert(newWin, auth, "popup-blocked" /* AuthErrorCode.POPUP_BLOCKED */);
2419
+ // Flaky on IE edge, encapsulate with a try and catch.
2420
+ try {
2421
+ newWin.focus();
2422
+ }
2423
+ catch (e) { }
2424
+ return new AuthPopup(newWin);
2425
+ }
2426
+ function openAsNewWindowIOS(url, target) {
2427
+ const el = document.createElement('a');
2428
+ el.href = url;
2429
+ el.target = target;
2430
+ const click = document.createEvent('MouseEvent');
2431
+ click.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 1, null);
2432
+ el.dispatchEvent(click);
2433
+ }
2434
+
2435
+ /**
2436
+ * @license
2437
+ * Copyright 2021 Google LLC
2438
+ *
2439
+ * Licensed under the Apache License, Version 2.0 (the "License");
2440
+ * you may not use this file except in compliance with the License.
2441
+ * You may obtain a copy of the License at
2442
+ *
2443
+ * http://www.apache.org/licenses/LICENSE-2.0
2444
+ *
2445
+ * Unless required by applicable law or agreed to in writing, software
2446
+ * distributed under the License is distributed on an "AS IS" BASIS,
2447
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2448
+ * See the License for the specific language governing permissions and
2449
+ * limitations under the License.
2450
+ */
2451
+ /**
2452
+ * URL for Authentication widget which will initiate the OAuth handshake
2453
+ *
2454
+ * @internal
2455
+ */
2456
+ const WIDGET_PATH = '__/auth/handler';
2457
+ /**
2458
+ * URL for emulated environment
2459
+ *
2460
+ * @internal
2461
+ */
2462
+ const EMULATOR_WIDGET_PATH = 'emulator/auth/handler';
2463
+ /**
2464
+ * Fragment name for the App Check token that gets passed to the widget
2465
+ *
2466
+ * @internal
2467
+ */
2468
+ const FIREBASE_APP_CHECK_FRAGMENT_ID = encodeURIComponent('fac');
2469
+ async function _getRedirectUrl(auth, provider, authType, redirectUrl, eventId, additionalParams) {
2470
+ register._assert(auth.config.authDomain, auth, "auth-domain-config-required" /* AuthErrorCode.MISSING_AUTH_DOMAIN */);
2471
+ register._assert(auth.config.apiKey, auth, "invalid-api-key" /* AuthErrorCode.INVALID_API_KEY */);
2472
+ const params = {
2473
+ apiKey: auth.config.apiKey,
2474
+ appName: auth.name,
2475
+ authType,
2476
+ redirectUrl,
2477
+ v: app.SDK_VERSION,
2478
+ eventId
2479
+ };
2480
+ if (provider instanceof register.FederatedAuthProvider) {
2481
+ provider.setDefaultLanguage(auth.languageCode);
2482
+ params.providerId = provider.providerId || '';
2483
+ if (!util.isEmpty(provider.getCustomParameters())) {
2484
+ params.customParameters = JSON.stringify(provider.getCustomParameters());
2485
+ }
2486
+ // TODO set additionalParams from the provider as well?
2487
+ for (const [key, value] of Object.entries(additionalParams || {})) {
2488
+ params[key] = value;
2489
+ }
2490
+ }
2491
+ if (provider instanceof register.BaseOAuthProvider) {
2492
+ const scopes = provider.getScopes().filter(scope => scope !== '');
2493
+ if (scopes.length > 0) {
2494
+ params.scopes = scopes.join(',');
2495
+ }
2496
+ }
2497
+ if (auth.tenantId) {
2498
+ params.tid = auth.tenantId;
2499
+ }
2500
+ // TODO: maybe set eid as endipointId
2501
+ // TODO: maybe set fw as Frameworks.join(",")
2502
+ const paramsDict = params;
2503
+ for (const key of Object.keys(paramsDict)) {
2504
+ if (paramsDict[key] === undefined) {
2505
+ delete paramsDict[key];
2506
+ }
2507
+ }
2508
+ // Sets the App Check token to pass to the widget
2509
+ const appCheckToken = await auth._getAppCheckToken();
2510
+ const appCheckTokenFragment = appCheckToken
2511
+ ? `#${FIREBASE_APP_CHECK_FRAGMENT_ID}=${encodeURIComponent(appCheckToken)}`
2512
+ : '';
2513
+ // Start at index 1 to skip the leading '&' in the query string
2514
+ return `${getHandlerBase(auth)}?${util.querystring(paramsDict).slice(1)}${appCheckTokenFragment}`;
2515
+ }
2516
+ function getHandlerBase({ config }) {
2517
+ if (!config.emulator) {
2518
+ return `https://${config.authDomain}/${WIDGET_PATH}`;
2519
+ }
2520
+ return register._emulatorUrl(config, EMULATOR_WIDGET_PATH);
2521
+ }
2522
+
2523
+ /**
2524
+ * @license
2525
+ * Copyright 2020 Google LLC
2526
+ *
2527
+ * Licensed under the Apache License, Version 2.0 (the "License");
2528
+ * you may not use this file except in compliance with the License.
2529
+ * You may obtain a copy of the License at
2530
+ *
2531
+ * http://www.apache.org/licenses/LICENSE-2.0
2532
+ *
2533
+ * Unless required by applicable law or agreed to in writing, software
2534
+ * distributed under the License is distributed on an "AS IS" BASIS,
2535
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2536
+ * See the License for the specific language governing permissions and
2537
+ * limitations under the License.
2538
+ */
2539
+ /**
2540
+ * The special web storage event
2541
+ *
2542
+ */
2543
+ const WEB_STORAGE_SUPPORT_KEY = 'webStorageSupport';
2544
+ class BrowserPopupRedirectResolver {
2545
+ constructor() {
2546
+ this.eventManagers = {};
2547
+ this.iframes = {};
2548
+ this.originValidationPromises = {};
2549
+ this._redirectPersistence = browserSessionPersistence;
2550
+ this._completeRedirectFn = _getRedirectResult;
2551
+ this._overrideRedirectResult = _overrideRedirectResult;
2552
+ }
2553
+ // Wrapping in async even though we don't await anywhere in order
2554
+ // to make sure errors are raised as promise rejections
2555
+ async _openPopup(auth, provider, authType, eventId) {
2556
+ var _a;
2557
+ register.debugAssert((_a = this.eventManagers[auth._key()]) === null || _a === void 0 ? void 0 : _a.manager, '_initialize() not called before _openPopup()');
2558
+ const url = await _getRedirectUrl(auth, provider, authType, register._getCurrentUrl(), eventId);
2559
+ return _open(auth, url, register._generateEventId());
2560
+ }
2561
+ async _openRedirect(auth, provider, authType, eventId) {
2562
+ await this._originValidation(auth);
2563
+ const url = await _getRedirectUrl(auth, provider, authType, register._getCurrentUrl(), eventId);
2564
+ register._setWindowLocation(url);
2565
+ return new Promise(() => { });
2566
+ }
2567
+ _initialize(auth) {
2568
+ const key = auth._key();
2569
+ if (this.eventManagers[key]) {
2570
+ const { manager, promise } = this.eventManagers[key];
2571
+ if (manager) {
2572
+ return Promise.resolve(manager);
2573
+ }
2574
+ else {
2575
+ register.debugAssert(promise, 'If manager is not set, promise should be');
2576
+ return promise;
2577
+ }
2578
+ }
2579
+ const promise = this.initAndGetManager(auth);
2580
+ this.eventManagers[key] = { promise };
2581
+ // If the promise is rejected, the key should be removed so that the
2582
+ // operation can be retried later.
2583
+ promise.catch(() => {
2584
+ delete this.eventManagers[key];
2585
+ });
2586
+ return promise;
2587
+ }
2588
+ async initAndGetManager(auth) {
2589
+ const iframe = await _openIframe(auth);
2590
+ const manager = new AuthEventManager(auth);
2591
+ iframe.register('authEvent', (iframeEvent) => {
2592
+ register._assert(iframeEvent === null || iframeEvent === void 0 ? void 0 : iframeEvent.authEvent, auth, "invalid-auth-event" /* AuthErrorCode.INVALID_AUTH_EVENT */);
2593
+ // TODO: Consider splitting redirect and popup events earlier on
2594
+ const handled = manager.onEvent(iframeEvent.authEvent);
2595
+ return { status: handled ? "ACK" /* GapiOutcome.ACK */ : "ERROR" /* GapiOutcome.ERROR */ };
2596
+ }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
2597
+ this.eventManagers[auth._key()] = { manager };
2598
+ this.iframes[auth._key()] = iframe;
2599
+ return manager;
2600
+ }
2601
+ _isIframeWebStorageSupported(auth, cb) {
2602
+ const iframe = this.iframes[auth._key()];
2603
+ iframe.send(WEB_STORAGE_SUPPORT_KEY, { type: WEB_STORAGE_SUPPORT_KEY }, result => {
2604
+ var _a;
2605
+ const isSupported = (_a = result === null || result === void 0 ? void 0 : result[0]) === null || _a === void 0 ? void 0 : _a[WEB_STORAGE_SUPPORT_KEY];
2606
+ if (isSupported !== undefined) {
2607
+ cb(!!isSupported);
2608
+ }
2609
+ register._fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2610
+ }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
2611
+ }
2612
+ _originValidation(auth) {
2613
+ const key = auth._key();
2614
+ if (!this.originValidationPromises[key]) {
2615
+ this.originValidationPromises[key] = _validateOrigin$1(auth);
2616
+ }
2617
+ return this.originValidationPromises[key];
2618
+ }
2619
+ get _shouldInitProactively() {
2620
+ // Mobile browsers and Safari need to optimistically initialize
2621
+ return register._isMobileBrowser() || register._isSafari() || register._isIOS();
2622
+ }
2623
+ }
2624
+ /**
2625
+ * An implementation of {@link PopupRedirectResolver} suitable for browser
2626
+ * based applications.
2627
+ *
2628
+ * @remarks
2629
+ * This method does not work in a Node.js environment.
2630
+ *
2631
+ * @public
2632
+ */
2633
+ const browserPopupRedirectResolver = BrowserPopupRedirectResolver;
2634
+
2635
+ /**
2636
+ * {@inheritdoc PhoneMultiFactorAssertion}
2637
+ *
2638
+ * @public
2639
+ */
2640
+ class PhoneMultiFactorAssertionImpl extends register.MultiFactorAssertionImpl {
2641
+ constructor(credential) {
2642
+ super("phone" /* FactorId.PHONE */);
2643
+ this.credential = credential;
2644
+ }
2645
+ /** @internal */
2646
+ static _fromCredential(credential) {
2647
+ return new PhoneMultiFactorAssertionImpl(credential);
2648
+ }
2649
+ /** @internal */
2650
+ _finalizeEnroll(auth, idToken, displayName) {
2651
+ return register.finalizeEnrollPhoneMfa(auth, {
2652
+ idToken,
2653
+ displayName,
2654
+ phoneVerificationInfo: this.credential._makeVerificationRequest()
2655
+ });
2656
+ }
2657
+ /** @internal */
2658
+ _finalizeSignIn(auth, mfaPendingCredential) {
2659
+ return register.finalizeSignInPhoneMfa(auth, {
2660
+ mfaPendingCredential,
2661
+ phoneVerificationInfo: this.credential._makeVerificationRequest()
2662
+ });
2663
+ }
2664
+ }
2665
+ /**
2666
+ * Provider for generating a {@link PhoneMultiFactorAssertion}.
2667
+ *
2668
+ * @public
2669
+ */
2670
+ class PhoneMultiFactorGenerator {
2671
+ constructor() { }
2672
+ /**
2673
+ * Provides a {@link PhoneMultiFactorAssertion} to confirm ownership of the phone second factor.
2674
+ *
2675
+ * @remarks
2676
+ * This method does not work in a Node.js environment.
2677
+ *
2678
+ * @param phoneAuthCredential - A credential provided by {@link PhoneAuthProvider.credential}.
2679
+ * @returns A {@link PhoneMultiFactorAssertion} which can be used with
2680
+ * {@link MultiFactorResolver.resolveSignIn}
2681
+ */
2682
+ static assertion(credential) {
2683
+ return PhoneMultiFactorAssertionImpl._fromCredential(credential);
2684
+ }
2685
+ }
2686
+ /**
2687
+ * The identifier of the phone second factor: `phone`.
2688
+ */
2689
+ PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
2690
+
2691
+ /**
2692
+ * @license
2693
+ * Copyright 2021 Google LLC
2694
+ *
2695
+ * Licensed under the Apache License, Version 2.0 (the "License");
2696
+ * you may not use this file except in compliance with the License.
2697
+ * You may obtain a copy of the License at
2698
+ *
2699
+ * http://www.apache.org/licenses/LICENSE-2.0
2700
+ *
2701
+ * Unless required by applicable law or agreed to in writing, software
2702
+ * distributed under the License is distributed on an "AS IS" BASIS,
2703
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2704
+ * See the License for the specific language governing permissions and
2705
+ * limitations under the License.
2706
+ */
2707
+ const DEFAULT_ID_TOKEN_MAX_AGE = 5 * 60;
2708
+ const authIdTokenMaxAge = util.getExperimentalSetting('authIdTokenMaxAge') || DEFAULT_ID_TOKEN_MAX_AGE;
2709
+ let lastPostedIdToken = null;
2710
+ const mintCookieFactory = (url) => async (user) => {
2711
+ const idTokenResult = user && (await user.getIdTokenResult());
2712
+ const idTokenAge = idTokenResult &&
2713
+ (new Date().getTime() - Date.parse(idTokenResult.issuedAtTime)) / 1000;
2714
+ if (idTokenAge && idTokenAge > authIdTokenMaxAge) {
2715
+ return;
2716
+ }
2717
+ // Specifically trip null => undefined when logged out, to delete any existing cookie
2718
+ const idToken = idTokenResult === null || idTokenResult === void 0 ? void 0 : idTokenResult.token;
2719
+ if (lastPostedIdToken === idToken) {
2720
+ return;
2721
+ }
2722
+ lastPostedIdToken = idToken;
2723
+ await fetch(url, {
2724
+ method: idToken ? 'POST' : 'DELETE',
2725
+ headers: idToken
2726
+ ? {
2727
+ 'Authorization': `Bearer ${idToken}`
2728
+ }
2729
+ : {}
2730
+ });
2731
+ };
2732
+ /**
2733
+ * Returns the Auth instance associated with the provided {@link @firebase/app#FirebaseApp}.
2734
+ * If no instance exists, initializes an Auth instance with platform-specific default dependencies.
2735
+ *
2736
+ * @param app - The Firebase App.
2737
+ *
2738
+ * @public
2739
+ */
2740
+ function getAuth(app$1 = app.getApp()) {
2741
+ const provider = app._getProvider(app$1, 'auth');
2742
+ if (provider.isInitialized()) {
2743
+ return provider.getImmediate();
2744
+ }
2745
+ const auth = register.initializeAuth(app$1, {
2746
+ popupRedirectResolver: browserPopupRedirectResolver,
2747
+ persistence: [
2748
+ register.indexedDBLocalPersistence,
2749
+ browserLocalPersistence,
2750
+ browserSessionPersistence
2751
+ ]
2752
+ });
2753
+ const authTokenSyncUrl = util.getExperimentalSetting('authTokenSyncURL');
2754
+ if (authTokenSyncUrl) {
2755
+ const mintCookie = mintCookieFactory(authTokenSyncUrl);
2756
+ register.beforeAuthStateChanged(auth, mintCookie, () => mintCookie(auth.currentUser));
2757
+ register.onIdTokenChanged(auth, user => mintCookie(user));
2758
+ }
2759
+ const authEmulatorHost = util.getDefaultEmulatorHost('auth');
2760
+ if (authEmulatorHost) {
2761
+ register.connectAuthEmulator(auth, `http://${authEmulatorHost}`);
2762
+ }
2763
+ return auth;
2764
+ }
2765
+ function getScriptParentElement() {
2766
+ var _a, _b;
2767
+ return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
2768
+ }
2769
+ register._setExternalJSProvider({
2770
+ loadJS(url) {
2771
+ // TODO: consider adding timeout support & cancellation
2772
+ return new Promise((resolve, reject) => {
2773
+ const el = document.createElement('script');
2774
+ el.setAttribute('src', url);
2775
+ el.onload = resolve;
2776
+ el.onerror = e => {
2777
+ const error = register._createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2778
+ error.customData = e;
2779
+ reject(error);
2780
+ };
2781
+ el.type = 'text/javascript';
2782
+ el.charset = 'UTF-8';
2783
+ getScriptParentElement().appendChild(el);
2784
+ });
2785
+ },
2786
+ gapiScript: 'https://apis.google.com/js/api.js',
2787
+ recaptchaV2Script: 'https://www.google.com/recaptcha/api.js',
2788
+ recaptchaEnterpriseScript: 'https://www.google.com/recaptcha/enterprise.js?render='
2789
+ });
2790
+ register.registerAuth("Browser" /* ClientPlatform.BROWSER */);
2791
+
2792
+ /**
2793
+ * @license
2794
+ * Copyright 2021 Google LLC
2795
+ *
2796
+ * Licensed under the Apache License, Version 2.0 (the "License");
2797
+ * you may not use this file except in compliance with the License.
2798
+ * You may obtain a copy of the License at
2799
+ *
2800
+ * http://www.apache.org/licenses/LICENSE-2.0
2801
+ *
2802
+ * Unless required by applicable law or agreed to in writing, software
2803
+ * distributed under the License is distributed on an "AS IS" BASIS,
2804
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2805
+ * See the License for the specific language governing permissions and
2806
+ * limitations under the License.
2807
+ */
2808
+ function _cordovaWindow() {
2809
+ return window;
2810
+ }
2811
+
2812
+ /**
2813
+ * @license
2814
+ * Copyright 2020 Google LLC
2815
+ *
2816
+ * Licensed under the Apache License, Version 2.0 (the "License");
2817
+ * you may not use this file except in compliance with the License.
2818
+ * You may obtain a copy of the License at
2819
+ *
2820
+ * http://www.apache.org/licenses/LICENSE-2.0
2821
+ *
2822
+ * Unless required by applicable law or agreed to in writing, software
2823
+ * distributed under the License is distributed on an "AS IS" BASIS,
2824
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2825
+ * See the License for the specific language governing permissions and
2826
+ * limitations under the License.
2827
+ */
2828
+ /**
2829
+ * How long to wait after the app comes back into focus before concluding that
2830
+ * the user closed the sign in tab.
2831
+ */
2832
+ const REDIRECT_TIMEOUT_MS = 2000;
2833
+ /**
2834
+ * Generates the URL for the OAuth handler.
2835
+ */
2836
+ async function _generateHandlerUrl(auth, event, provider) {
2837
+ var _a;
2838
+ // Get the cordova plugins
2839
+ const { BuildInfo } = _cordovaWindow();
2840
+ register.debugAssert(event.sessionId, 'AuthEvent did not contain a session ID');
2841
+ const sessionDigest = await computeSha256(event.sessionId);
2842
+ const additionalParams = {};
2843
+ if (register._isIOS()) {
2844
+ // iOS app identifier
2845
+ additionalParams['ibi'] = BuildInfo.packageName;
2846
+ }
2847
+ else if (register._isAndroid()) {
2848
+ // Android app identifier
2849
+ additionalParams['apn'] = BuildInfo.packageName;
2850
+ }
2851
+ else {
2852
+ register._fail(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
2853
+ }
2854
+ // Add the display name if available
2855
+ if (BuildInfo.displayName) {
2856
+ additionalParams['appDisplayName'] = BuildInfo.displayName;
2857
+ }
2858
+ // Attached the hashed session ID
2859
+ additionalParams['sessionId'] = sessionDigest;
2860
+ return _getRedirectUrl(auth, provider, event.type, undefined, (_a = event.eventId) !== null && _a !== void 0 ? _a : undefined, additionalParams);
2861
+ }
2862
+ /**
2863
+ * Validates that this app is valid for this project configuration
2864
+ */
2865
+ async function _validateOrigin(auth) {
2866
+ const { BuildInfo } = _cordovaWindow();
2867
+ const request = {};
2868
+ if (register._isIOS()) {
2869
+ request.iosBundleId = BuildInfo.packageName;
2870
+ }
2871
+ else if (register._isAndroid()) {
2872
+ request.androidPackageName = BuildInfo.packageName;
2873
+ }
2874
+ else {
2875
+ register._fail(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
2876
+ }
2877
+ // Will fail automatically if package name is not authorized
2878
+ await _getProjectConfig(auth, request);
2879
+ }
2880
+ function _performRedirect(handlerUrl) {
2881
+ // Get the cordova plugins
2882
+ const { cordova } = _cordovaWindow();
2883
+ return new Promise(resolve => {
2884
+ cordova.plugins.browsertab.isAvailable(browserTabIsAvailable => {
2885
+ let iabRef = null;
2886
+ if (browserTabIsAvailable) {
2887
+ cordova.plugins.browsertab.openUrl(handlerUrl);
2888
+ }
2889
+ else {
2890
+ // TODO: Return the inappbrowser ref that's returned from the open call
2891
+ iabRef = cordova.InAppBrowser.open(handlerUrl, register._isIOS7Or8() ? '_blank' : '_system', 'location=yes');
2892
+ }
2893
+ resolve(iabRef);
2894
+ });
2895
+ });
2896
+ }
2897
+ /**
2898
+ * This function waits for app activity to be seen before resolving. It does
2899
+ * this by attaching listeners to various dom events. Once the app is determined
2900
+ * to be visible, this promise resolves. AFTER that resolution, the listeners
2901
+ * are detached and any browser tabs left open will be closed.
2902
+ */
2903
+ async function _waitForAppResume(auth, eventListener, iabRef) {
2904
+ // Get the cordova plugins
2905
+ const { cordova } = _cordovaWindow();
2906
+ let cleanup = () => { };
2907
+ try {
2908
+ await new Promise((resolve, reject) => {
2909
+ let onCloseTimer = null;
2910
+ // DEFINE ALL THE CALLBACKS =====
2911
+ function authEventSeen() {
2912
+ var _a;
2913
+ // Auth event was detected. Resolve this promise and close the extra
2914
+ // window if it's still open.
2915
+ resolve();
2916
+ const closeBrowserTab = (_a = cordova.plugins.browsertab) === null || _a === void 0 ? void 0 : _a.close;
2917
+ if (typeof closeBrowserTab === 'function') {
2918
+ closeBrowserTab();
2919
+ }
2920
+ // Close inappbrowser emebedded webview in iOS7 and 8 case if still
2921
+ // open.
2922
+ if (typeof (iabRef === null || iabRef === void 0 ? void 0 : iabRef.close) === 'function') {
2923
+ iabRef.close();
2924
+ }
2925
+ }
2926
+ function resumed() {
2927
+ if (onCloseTimer) {
2928
+ // This code already ran; do not rerun.
2929
+ return;
2930
+ }
2931
+ onCloseTimer = window.setTimeout(() => {
2932
+ // Wait two seeconds after resume then reject.
2933
+ reject(register._createError(auth, "redirect-cancelled-by-user" /* AuthErrorCode.REDIRECT_CANCELLED_BY_USER */));
2934
+ }, REDIRECT_TIMEOUT_MS);
2935
+ }
2936
+ function visibilityChanged() {
2937
+ if ((document === null || document === void 0 ? void 0 : document.visibilityState) === 'visible') {
2938
+ resumed();
2939
+ }
2940
+ }
2941
+ // ATTACH ALL THE LISTENERS =====
2942
+ // Listen for the auth event
2943
+ eventListener.addPassiveListener(authEventSeen);
2944
+ // Listen for resume and visibility events
2945
+ document.addEventListener('resume', resumed, false);
2946
+ if (register._isAndroid()) {
2947
+ document.addEventListener('visibilitychange', visibilityChanged, false);
2948
+ }
2949
+ // SETUP THE CLEANUP FUNCTION =====
2950
+ cleanup = () => {
2951
+ eventListener.removePassiveListener(authEventSeen);
2952
+ document.removeEventListener('resume', resumed, false);
2953
+ document.removeEventListener('visibilitychange', visibilityChanged, false);
2954
+ if (onCloseTimer) {
2955
+ window.clearTimeout(onCloseTimer);
2956
+ }
2957
+ };
2958
+ });
2959
+ }
2960
+ finally {
2961
+ cleanup();
2962
+ }
2963
+ }
2964
+ /**
2965
+ * Checks the configuration of the Cordova environment. This has no side effect
2966
+ * if the configuration is correct; otherwise it throws an error with the
2967
+ * missing plugin.
2968
+ */
2969
+ function _checkCordovaConfiguration(auth) {
2970
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2971
+ const win = _cordovaWindow();
2972
+ // Check all dependencies installed.
2973
+ // https://github.com/nordnet/cordova-universal-links-plugin
2974
+ // Note that cordova-universal-links-plugin has been abandoned.
2975
+ // A fork with latest fixes is available at:
2976
+ // https://www.npmjs.com/package/cordova-universal-links-plugin-fix
2977
+ register._assert(typeof ((_a = win === null || win === void 0 ? void 0 : win.universalLinks) === null || _a === void 0 ? void 0 : _a.subscribe) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
2978
+ missingPlugin: 'cordova-universal-links-plugin-fix'
2979
+ });
2980
+ // https://www.npmjs.com/package/cordova-plugin-buildinfo
2981
+ register._assert(typeof ((_b = win === null || win === void 0 ? void 0 : win.BuildInfo) === null || _b === void 0 ? void 0 : _b.packageName) !== 'undefined', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
2982
+ missingPlugin: 'cordova-plugin-buildInfo'
2983
+ });
2984
+ // https://github.com/google/cordova-plugin-browsertab
2985
+ register._assert(typeof ((_e = (_d = (_c = win === null || win === void 0 ? void 0 : win.cordova) === null || _c === void 0 ? void 0 : _c.plugins) === null || _d === void 0 ? void 0 : _d.browsertab) === null || _e === void 0 ? void 0 : _e.openUrl) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
2986
+ missingPlugin: 'cordova-plugin-browsertab'
2987
+ });
2988
+ register._assert(typeof ((_h = (_g = (_f = win === null || win === void 0 ? void 0 : win.cordova) === null || _f === void 0 ? void 0 : _f.plugins) === null || _g === void 0 ? void 0 : _g.browsertab) === null || _h === void 0 ? void 0 : _h.isAvailable) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
2989
+ missingPlugin: 'cordova-plugin-browsertab'
2990
+ });
2991
+ // https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/
2992
+ register._assert(typeof ((_k = (_j = win === null || win === void 0 ? void 0 : win.cordova) === null || _j === void 0 ? void 0 : _j.InAppBrowser) === null || _k === void 0 ? void 0 : _k.open) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
2993
+ missingPlugin: 'cordova-plugin-inappbrowser'
2994
+ });
2995
+ }
2996
+ /**
2997
+ * Computes the SHA-256 of a session ID. The SubtleCrypto interface is only
2998
+ * available in "secure" contexts, which covers Cordova (which is served on a file
2999
+ * protocol).
3000
+ */
3001
+ async function computeSha256(sessionId) {
3002
+ const bytes = stringToArrayBuffer(sessionId);
3003
+ // TODO: For IE11 crypto has a different name and this operation comes back
3004
+ // as an object, not a promise. This is the old proposed standard that
3005
+ // is used by IE11:
3006
+ // https://www.w3.org/TR/2013/WD-WebCryptoAPI-20130108/#cryptooperation-interface
3007
+ const buf = await crypto.subtle.digest('SHA-256', bytes);
3008
+ const arr = Array.from(new Uint8Array(buf));
3009
+ return arr.map(num => num.toString(16).padStart(2, '0')).join('');
3010
+ }
3011
+ function stringToArrayBuffer(str) {
3012
+ // This function is only meant to deal with an ASCII charset and makes
3013
+ // certain simplifying assumptions.
3014
+ register.debugAssert(/[0-9a-zA-Z]+/.test(str), 'Can only convert alpha-numeric strings');
3015
+ if (typeof TextEncoder !== 'undefined') {
3016
+ return new TextEncoder().encode(str);
3017
+ }
3018
+ const buff = new ArrayBuffer(str.length);
3019
+ const view = new Uint8Array(buff);
3020
+ for (let i = 0; i < str.length; i++) {
3021
+ view[i] = str.charCodeAt(i);
3022
+ }
3023
+ return view;
3024
+ }
3025
+
3026
+ /**
3027
+ * @license
3028
+ * Copyright 2020 Google LLC
3029
+ *
3030
+ * Licensed under the Apache License, Version 2.0 (the "License");
3031
+ * you may not use this file except in compliance with the License.
3032
+ * You may obtain a copy of the License at
3033
+ *
3034
+ * http://www.apache.org/licenses/LICENSE-2.0
3035
+ *
3036
+ * Unless required by applicable law or agreed to in writing, software
3037
+ * distributed under the License is distributed on an "AS IS" BASIS,
3038
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3039
+ * See the License for the specific language governing permissions and
3040
+ * limitations under the License.
3041
+ */
3042
+ const SESSION_ID_LENGTH = 20;
3043
+ /** Custom AuthEventManager that adds passive listeners to events */
3044
+ class CordovaAuthEventManager extends AuthEventManager {
3045
+ constructor() {
3046
+ super(...arguments);
3047
+ this.passiveListeners = new Set();
3048
+ this.initPromise = new Promise(resolve => {
3049
+ this.resolveInialized = resolve;
3050
+ });
3051
+ }
3052
+ addPassiveListener(cb) {
3053
+ this.passiveListeners.add(cb);
3054
+ }
3055
+ removePassiveListener(cb) {
3056
+ this.passiveListeners.delete(cb);
3057
+ }
3058
+ // In a Cordova environment, this manager can live through multiple redirect
3059
+ // operations
3060
+ resetRedirect() {
3061
+ this.queuedRedirectEvent = null;
3062
+ this.hasHandledPotentialRedirect = false;
3063
+ }
3064
+ /** Override the onEvent method */
3065
+ onEvent(event) {
3066
+ this.resolveInialized();
3067
+ this.passiveListeners.forEach(cb => cb(event));
3068
+ return super.onEvent(event);
3069
+ }
3070
+ async initialized() {
3071
+ await this.initPromise;
3072
+ }
3073
+ }
3074
+ /**
3075
+ * Generates a (partial) {@link AuthEvent}.
3076
+ */
3077
+ function _generateNewEvent(auth, type, eventId = null) {
3078
+ return {
3079
+ type,
3080
+ eventId,
3081
+ urlResponse: null,
3082
+ sessionId: generateSessionId(),
3083
+ postBody: null,
3084
+ tenantId: auth.tenantId,
3085
+ error: register._createError(auth, "no-auth-event" /* AuthErrorCode.NO_AUTH_EVENT */)
3086
+ };
3087
+ }
3088
+ function _savePartialEvent(auth, event) {
3089
+ return storage()._set(persistenceKey(auth), event);
3090
+ }
3091
+ async function _getAndRemoveEvent(auth) {
3092
+ const event = (await storage()._get(persistenceKey(auth)));
3093
+ if (event) {
3094
+ await storage()._remove(persistenceKey(auth));
3095
+ }
3096
+ return event;
3097
+ }
3098
+ function _eventFromPartialAndUrl(partialEvent, url) {
3099
+ var _a, _b;
3100
+ // Parse the deep link within the dynamic link URL.
3101
+ const callbackUrl = _getDeepLinkFromCallback(url);
3102
+ // Confirm it is actually a callback URL.
3103
+ // Currently the universal link will be of this format:
3104
+ // https://<AUTH_DOMAIN>/__/auth/callback<OAUTH_RESPONSE>
3105
+ // This is a fake URL but is not intended to take the user anywhere
3106
+ // and just redirect to the app.
3107
+ if (callbackUrl.includes('/__/auth/callback')) {
3108
+ // Check if there is an error in the URL.
3109
+ // This mechanism is also used to pass errors back to the app:
3110
+ // https://<AUTH_DOMAIN>/__/auth/callback?firebaseError=<STRINGIFIED_ERROR>
3111
+ const params = searchParamsOrEmpty(callbackUrl);
3112
+ // Get the error object corresponding to the stringified error if found.
3113
+ const errorObject = params['firebaseError']
3114
+ ? parseJsonOrNull(decodeURIComponent(params['firebaseError']))
3115
+ : null;
3116
+ const code = (_b = (_a = errorObject === null || errorObject === void 0 ? void 0 : errorObject['code']) === null || _a === void 0 ? void 0 : _a.split('auth/')) === null || _b === void 0 ? void 0 : _b[1];
3117
+ const error = code ? register._createError(code) : null;
3118
+ if (error) {
3119
+ return {
3120
+ type: partialEvent.type,
3121
+ eventId: partialEvent.eventId,
3122
+ tenantId: partialEvent.tenantId,
3123
+ error,
3124
+ urlResponse: null,
3125
+ sessionId: null,
3126
+ postBody: null
3127
+ };
3128
+ }
3129
+ else {
3130
+ return {
3131
+ type: partialEvent.type,
3132
+ eventId: partialEvent.eventId,
3133
+ tenantId: partialEvent.tenantId,
3134
+ sessionId: partialEvent.sessionId,
3135
+ urlResponse: callbackUrl,
3136
+ postBody: null
3137
+ };
3138
+ }
3139
+ }
3140
+ return null;
3141
+ }
3142
+ function generateSessionId() {
3143
+ const chars = [];
3144
+ const allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
3145
+ for (let i = 0; i < SESSION_ID_LENGTH; i++) {
3146
+ const idx = Math.floor(Math.random() * allowedChars.length);
3147
+ chars.push(allowedChars.charAt(idx));
3148
+ }
3149
+ return chars.join('');
3150
+ }
3151
+ function storage() {
3152
+ return register._getInstance(browserLocalPersistence);
3153
+ }
3154
+ function persistenceKey(auth) {
3155
+ return register._persistenceKeyName("authEvent" /* KeyName.AUTH_EVENT */, auth.config.apiKey, auth.name);
3156
+ }
3157
+ function parseJsonOrNull(json) {
3158
+ try {
3159
+ return JSON.parse(json);
3160
+ }
3161
+ catch (e) {
3162
+ return null;
3163
+ }
3164
+ }
3165
+ // Exported for testing
3166
+ function _getDeepLinkFromCallback(url) {
3167
+ const params = searchParamsOrEmpty(url);
3168
+ const link = params['link'] ? decodeURIComponent(params['link']) : undefined;
3169
+ // Double link case (automatic redirect)
3170
+ const doubleDeepLink = searchParamsOrEmpty(link)['link'];
3171
+ // iOS custom scheme links.
3172
+ const iOSDeepLink = params['deep_link_id']
3173
+ ? decodeURIComponent(params['deep_link_id'])
3174
+ : undefined;
3175
+ const iOSDoubleDeepLink = searchParamsOrEmpty(iOSDeepLink)['link'];
3176
+ return iOSDoubleDeepLink || iOSDeepLink || doubleDeepLink || link || url;
3177
+ }
3178
+ /**
3179
+ * Optimistically tries to get search params from a string, or else returns an
3180
+ * empty search params object.
3181
+ */
3182
+ function searchParamsOrEmpty(url) {
3183
+ if (!(url === null || url === void 0 ? void 0 : url.includes('?'))) {
3184
+ return {};
3185
+ }
3186
+ const [_, ...rest] = url.split('?');
3187
+ return util.querystringDecode(rest.join('?'));
3188
+ }
3189
+
3190
+ /**
3191
+ * @license
3192
+ * Copyright 2021 Google LLC
3193
+ *
3194
+ * Licensed under the Apache License, Version 2.0 (the "License");
3195
+ * you may not use this file except in compliance with the License.
3196
+ * You may obtain a copy of the License at
3197
+ *
3198
+ * http://www.apache.org/licenses/LICENSE-2.0
3199
+ *
3200
+ * Unless required by applicable law or agreed to in writing, software
3201
+ * distributed under the License is distributed on an "AS IS" BASIS,
3202
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3203
+ * See the License for the specific language governing permissions and
3204
+ * limitations under the License.
3205
+ */
3206
+ /**
3207
+ * How long to wait for the initial auth event before concluding no
3208
+ * redirect pending
3209
+ */
3210
+ const INITIAL_EVENT_TIMEOUT_MS = 500;
3211
+ class CordovaPopupRedirectResolver {
3212
+ constructor() {
3213
+ this._redirectPersistence = browserSessionPersistence;
3214
+ this._shouldInitProactively = true; // This is lightweight for Cordova
3215
+ this.eventManagers = new Map();
3216
+ this.originValidationPromises = {};
3217
+ this._completeRedirectFn = _getRedirectResult;
3218
+ this._overrideRedirectResult = _overrideRedirectResult;
3219
+ }
3220
+ async _initialize(auth) {
3221
+ const key = auth._key();
3222
+ let manager = this.eventManagers.get(key);
3223
+ if (!manager) {
3224
+ manager = new CordovaAuthEventManager(auth);
3225
+ this.eventManagers.set(key, manager);
3226
+ this.attachCallbackListeners(auth, manager);
3227
+ }
3228
+ return manager;
3229
+ }
3230
+ _openPopup(auth) {
3231
+ register._fail(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
3232
+ }
3233
+ async _openRedirect(auth, provider, authType, eventId) {
3234
+ _checkCordovaConfiguration(auth);
3235
+ const manager = await this._initialize(auth);
3236
+ await manager.initialized();
3237
+ // Reset the persisted redirect states. This does not matter on Web where
3238
+ // the redirect always blows away application state entirely. On Cordova,
3239
+ // the app maintains control flow through the redirect.
3240
+ manager.resetRedirect();
3241
+ _clearRedirectOutcomes();
3242
+ await this._originValidation(auth);
3243
+ const event = _generateNewEvent(auth, authType, eventId);
3244
+ await _savePartialEvent(auth, event);
3245
+ const url = await _generateHandlerUrl(auth, event, provider);
3246
+ const iabRef = await _performRedirect(url);
3247
+ return _waitForAppResume(auth, manager, iabRef);
3248
+ }
3249
+ _isIframeWebStorageSupported(_auth, _cb) {
3250
+ throw new Error('Method not implemented.');
3251
+ }
3252
+ _originValidation(auth) {
3253
+ const key = auth._key();
3254
+ if (!this.originValidationPromises[key]) {
3255
+ this.originValidationPromises[key] = _validateOrigin(auth);
3256
+ }
3257
+ return this.originValidationPromises[key];
3258
+ }
3259
+ attachCallbackListeners(auth, manager) {
3260
+ // Get the global plugins
3261
+ const { universalLinks, handleOpenURL, BuildInfo } = _cordovaWindow();
3262
+ const noEventTimeout = setTimeout(async () => {
3263
+ // We didn't see that initial event. Clear any pending object and
3264
+ // dispatch no event
3265
+ await _getAndRemoveEvent(auth);
3266
+ manager.onEvent(generateNoEvent());
3267
+ }, INITIAL_EVENT_TIMEOUT_MS);
3268
+ const universalLinksCb = async (eventData) => {
3269
+ // We have an event so we can clear the no event timeout
3270
+ clearTimeout(noEventTimeout);
3271
+ const partialEvent = await _getAndRemoveEvent(auth);
3272
+ let finalEvent = null;
3273
+ if (partialEvent && (eventData === null || eventData === void 0 ? void 0 : eventData['url'])) {
3274
+ finalEvent = _eventFromPartialAndUrl(partialEvent, eventData['url']);
3275
+ }
3276
+ // If finalEvent is never filled, trigger with no event
3277
+ manager.onEvent(finalEvent || generateNoEvent());
3278
+ };
3279
+ // Universal links subscriber doesn't exist for iOS, so we need to check
3280
+ if (typeof universalLinks !== 'undefined' &&
3281
+ typeof universalLinks.subscribe === 'function') {
3282
+ universalLinks.subscribe(null, universalLinksCb);
3283
+ }
3284
+ // iOS 7 or 8 custom URL schemes.
3285
+ // This is also the current default behavior for iOS 9+.
3286
+ // For this to work, cordova-plugin-customurlscheme needs to be installed.
3287
+ // https://github.com/EddyVerbruggen/Custom-URL-scheme
3288
+ // Do not overwrite the existing developer's URL handler.
3289
+ const existingHandleOpenURL = handleOpenURL;
3290
+ const packagePrefix = `${BuildInfo.packageName.toLowerCase()}://`;
3291
+ _cordovaWindow().handleOpenURL = async (url) => {
3292
+ if (url.toLowerCase().startsWith(packagePrefix)) {
3293
+ // We want this intentionally to float
3294
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
3295
+ universalLinksCb({ url });
3296
+ }
3297
+ // Call the developer's handler if it is present.
3298
+ if (typeof existingHandleOpenURL === 'function') {
3299
+ try {
3300
+ existingHandleOpenURL(url);
3301
+ }
3302
+ catch (e) {
3303
+ // This is a developer error. Don't stop the flow of the SDK.
3304
+ console.error(e);
3305
+ }
3306
+ }
3307
+ };
3308
+ }
3309
+ }
3310
+ /**
3311
+ * An implementation of {@link PopupRedirectResolver} suitable for Cordova
3312
+ * based applications.
3313
+ *
3314
+ * @public
3315
+ */
3316
+ const cordovaPopupRedirectResolver = CordovaPopupRedirectResolver;
3317
+ function generateNoEvent() {
3318
+ return {
3319
+ type: "unknown" /* AuthEventType.UNKNOWN */,
3320
+ eventId: null,
3321
+ sessionId: null,
3322
+ urlResponse: null,
3323
+ postBody: null,
3324
+ tenantId: null,
3325
+ error: register._createError("no-auth-event" /* AuthErrorCode.NO_AUTH_EVENT */)
3326
+ };
3327
+ }
3328
+
3329
+ /**
3330
+ * @license
3331
+ * Copyright 2017 Google LLC
3332
+ *
3333
+ * Licensed under the Apache License, Version 2.0 (the "License");
3334
+ * you may not use this file except in compliance with the License.
3335
+ * You may obtain a copy of the License at
3336
+ *
3337
+ * http://www.apache.org/licenses/LICENSE-2.0
3338
+ *
3339
+ * Unless required by applicable law or agreed to in writing, software
3340
+ * distributed under the License is distributed on an "AS IS" BASIS,
3341
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3342
+ * See the License for the specific language governing permissions and
3343
+ * limitations under the License.
3344
+ */
3345
+ // This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
3346
+ // It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it out
3347
+ // of autogenerated documentation pages to reduce accidental misuse.
3348
+ function addFrameworkForLogging(auth, framework) {
3349
+ register._castAuth(auth)._logFramework(framework);
3350
+ }
3351
+
3352
+ exports.ActionCodeURL = register.ActionCodeURL;
3353
+ exports.AuthCredential = register.AuthCredential;
3354
+ exports.AuthErrorCodes = register.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY;
3355
+ exports.AuthImpl = register.AuthImpl;
3356
+ exports.EmailAuthCredential = register.EmailAuthCredential;
3357
+ exports.EmailAuthProvider = register.EmailAuthProvider;
3358
+ exports.FacebookAuthProvider = register.FacebookAuthProvider;
3359
+ exports.FetchProvider = register.FetchProvider;
3360
+ exports.GithubAuthProvider = register.GithubAuthProvider;
3361
+ exports.GoogleAuthProvider = register.GoogleAuthProvider;
3362
+ exports.OAuthCredential = register.OAuthCredential;
3363
+ exports.OAuthProvider = register.OAuthProvider;
3364
+ exports.PhoneAuthCredential = register.PhoneAuthCredential;
3365
+ exports.SAMLAuthCredential = register.SAMLAuthCredential;
3366
+ exports.SAMLAuthProvider = register.SAMLAuthProvider;
3367
+ exports.TotpMultiFactorGenerator = register.TotpMultiFactorGenerator;
3368
+ exports.TotpSecret = register.TotpSecret;
3369
+ exports.TwitterAuthProvider = register.TwitterAuthProvider;
3370
+ exports.UserImpl = register.UserImpl;
3371
+ exports._assert = register._assert;
3372
+ exports._castAuth = register._castAuth;
3373
+ exports._fail = register._fail;
3374
+ exports._generateEventId = register._generateEventId;
3375
+ exports._getClientVersion = register._getClientVersion;
3376
+ exports._getInstance = register._getInstance;
3377
+ exports._persistenceKeyName = register._persistenceKeyName;
3378
+ exports.applyActionCode = register.applyActionCode;
3379
+ exports.beforeAuthStateChanged = register.beforeAuthStateChanged;
3380
+ exports.checkActionCode = register.checkActionCode;
3381
+ exports.confirmPasswordReset = register.confirmPasswordReset;
3382
+ exports.connectAuthEmulator = register.connectAuthEmulator;
3383
+ exports.createUserWithEmailAndPassword = register.createUserWithEmailAndPassword;
3384
+ exports.debugErrorMap = register.debugErrorMap;
3385
+ exports.deleteUser = register.deleteUser;
3386
+ exports.fetchSignInMethodsForEmail = register.fetchSignInMethodsForEmail;
3387
+ exports.getAdditionalUserInfo = register.getAdditionalUserInfo;
3388
+ exports.getIdToken = register.getIdToken;
3389
+ exports.getIdTokenResult = register.getIdTokenResult;
3390
+ exports.getMultiFactorResolver = register.getMultiFactorResolver;
3391
+ exports.inMemoryPersistence = register.inMemoryPersistence;
3392
+ exports.indexedDBLocalPersistence = register.indexedDBLocalPersistence;
3393
+ exports.initializeAuth = register.initializeAuth;
3394
+ exports.initializeRecaptchaConfig = register.initializeRecaptchaConfig;
3395
+ exports.isSignInWithEmailLink = register.isSignInWithEmailLink;
3396
+ exports.linkWithCredential = register.linkWithCredential;
3397
+ exports.multiFactor = register.multiFactor;
3398
+ exports.onAuthStateChanged = register.onAuthStateChanged;
3399
+ exports.onIdTokenChanged = register.onIdTokenChanged;
3400
+ exports.parseActionCodeURL = register.parseActionCodeURL;
3401
+ exports.prodErrorMap = register.prodErrorMap;
3402
+ exports.reauthenticateWithCredential = register.reauthenticateWithCredential;
3403
+ exports.reload = register.reload;
3404
+ exports.revokeAccessToken = register.revokeAccessToken;
3405
+ exports.sendEmailVerification = register.sendEmailVerification;
3406
+ exports.sendPasswordResetEmail = register.sendPasswordResetEmail;
3407
+ exports.sendSignInLinkToEmail = register.sendSignInLinkToEmail;
3408
+ exports.setPersistence = register.setPersistence;
3409
+ exports.signInAnonymously = register.signInAnonymously;
3410
+ exports.signInWithCredential = register.signInWithCredential;
3411
+ exports.signInWithCustomToken = register.signInWithCustomToken;
3412
+ exports.signInWithEmailAndPassword = register.signInWithEmailAndPassword;
3413
+ exports.signInWithEmailLink = register.signInWithEmailLink;
3414
+ exports.signOut = register.signOut;
3415
+ exports.unlink = register.unlink;
3416
+ exports.updateCurrentUser = register.updateCurrentUser;
3417
+ exports.updateEmail = register.updateEmail;
3418
+ exports.updatePassword = register.updatePassword;
3419
+ exports.updateProfile = register.updateProfile;
3420
+ exports.useDeviceLanguage = register.useDeviceLanguage;
3421
+ exports.validatePassword = register.validatePassword;
3422
+ exports.verifyBeforeUpdateEmail = register.verifyBeforeUpdateEmail;
3423
+ exports.verifyPasswordResetCode = register.verifyPasswordResetCode;
3424
+ exports.ActionCodeOperation = ActionCodeOperation;
3425
+ exports.AuthPopup = AuthPopup;
3426
+ exports.FactorId = FactorId;
3427
+ exports.OperationType = OperationType;
3428
+ exports.PhoneAuthProvider = PhoneAuthProvider;
3429
+ exports.PhoneMultiFactorGenerator = PhoneMultiFactorGenerator;
3430
+ exports.ProviderId = ProviderId;
3431
+ exports.RecaptchaVerifier = RecaptchaVerifier;
3432
+ exports.SignInMethod = SignInMethod;
3433
+ exports._getRedirectResult = _getRedirectResult;
3434
+ exports._overrideRedirectResult = _overrideRedirectResult;
3435
+ exports.addFrameworkForLogging = addFrameworkForLogging;
3436
+ exports.browserLocalPersistence = browserLocalPersistence;
3437
+ exports.browserPopupRedirectResolver = browserPopupRedirectResolver;
3438
+ exports.browserSessionPersistence = browserSessionPersistence;
3439
+ exports.cordovaPopupRedirectResolver = cordovaPopupRedirectResolver;
3440
+ exports.getAuth = getAuth;
3441
+ exports.getRedirectResult = getRedirectResult;
3442
+ exports.linkWithPhoneNumber = linkWithPhoneNumber;
3443
+ exports.linkWithPopup = linkWithPopup;
3444
+ exports.linkWithRedirect = linkWithRedirect;
3445
+ exports.reauthenticateWithPhoneNumber = reauthenticateWithPhoneNumber;
3446
+ exports.reauthenticateWithPopup = reauthenticateWithPopup;
3447
+ exports.reauthenticateWithRedirect = reauthenticateWithRedirect;
3448
+ exports.signInWithPhoneNumber = signInWithPhoneNumber;
3449
+ exports.signInWithPopup = signInWithPopup;
3450
+ exports.signInWithRedirect = signInWithRedirect;
3451
+ exports.updatePhoneNumber = updatePhoneNumber;
3452
+ //# sourceMappingURL=internal.js.map