@firebase/auth 1.6.2 → 1.7.0-canary.0068ed5ab

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 (236) hide show
  1. package/dist/auth-public.d.ts +60 -10
  2. package/dist/auth.d.ts +61 -10
  3. package/dist/browser-cjs/{index-6a907fc6.js → index-e3deabf2.js} +202 -22
  4. package/dist/browser-cjs/index-e3deabf2.js.map +1 -0
  5. package/dist/browser-cjs/index.js +2 -2
  6. package/dist/browser-cjs/internal.js +1 -1
  7. package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +1 -0
  8. package/dist/browser-cjs/src/core/index.d.ts +9 -1
  9. package/dist/browser-cjs/src/core/strategies/anonymous.d.ts +3 -0
  10. package/dist/browser-cjs/src/core/strategies/credential.d.ts +6 -0
  11. package/dist/browser-cjs/src/core/strategies/custom_token.d.ts +3 -0
  12. package/dist/browser-cjs/src/core/strategies/email_and_password.d.ts +7 -0
  13. package/dist/browser-cjs/src/core/strategies/email_link.d.ts +4 -0
  14. package/dist/browser-cjs/src/core/user/account_info.d.ts +3 -0
  15. package/dist/browser-cjs/src/core/user/reload.d.ts +3 -1
  16. package/dist/browser-cjs/src/core/user/token_manager.d.ts +1 -0
  17. package/dist/browser-cjs/src/core/user/user_impl.d.ts +7 -1
  18. package/dist/browser-cjs/src/core/util/assert.d.ts +1 -0
  19. package/dist/browser-cjs/src/model/public_types.d.ts +7 -0
  20. package/dist/browser-cjs/src/platform_browser/strategies/phone.d.ts +6 -3
  21. package/dist/browser-cjs/src/platform_browser/strategies/popup.d.ts +4 -2
  22. package/dist/browser-cjs/src/platform_browser/strategies/redirect.d.ts +8 -4
  23. package/dist/browser-cjs/test/helpers/integration/helpers.d.ts +2 -0
  24. package/dist/browser-cjs/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  25. package/dist/cordova/index.js +2 -2
  26. package/dist/cordova/internal.js +45 -17
  27. package/dist/cordova/internal.js.map +1 -1
  28. package/dist/cordova/{popup_redirect-58faecee.js → popup_redirect-ea277afd.js} +197 -17
  29. package/dist/cordova/popup_redirect-ea277afd.js.map +1 -0
  30. package/dist/cordova/src/core/auth/auth_impl.d.ts +1 -0
  31. package/dist/cordova/src/core/index.d.ts +9 -1
  32. package/dist/cordova/src/core/strategies/anonymous.d.ts +3 -0
  33. package/dist/cordova/src/core/strategies/credential.d.ts +6 -0
  34. package/dist/cordova/src/core/strategies/custom_token.d.ts +3 -0
  35. package/dist/cordova/src/core/strategies/email_and_password.d.ts +7 -0
  36. package/dist/cordova/src/core/strategies/email_link.d.ts +4 -0
  37. package/dist/cordova/src/core/user/account_info.d.ts +3 -0
  38. package/dist/cordova/src/core/user/reload.d.ts +3 -1
  39. package/dist/cordova/src/core/user/token_manager.d.ts +1 -0
  40. package/dist/cordova/src/core/user/user_impl.d.ts +7 -1
  41. package/dist/cordova/src/core/util/assert.d.ts +1 -0
  42. package/dist/cordova/src/model/public_types.d.ts +7 -0
  43. package/dist/cordova/src/platform_browser/strategies/phone.d.ts +6 -3
  44. package/dist/cordova/src/platform_browser/strategies/popup.d.ts +4 -2
  45. package/dist/cordova/src/platform_browser/strategies/redirect.d.ts +8 -4
  46. package/dist/cordova/test/helpers/integration/helpers.d.ts +2 -0
  47. package/dist/cordova/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  48. package/dist/esm2017/{index-e939beb5.js → index-6dc4a3d1.js} +202 -22
  49. package/dist/esm2017/index-6dc4a3d1.js.map +1 -0
  50. package/dist/esm2017/index.js +2 -2
  51. package/dist/esm2017/internal.js +2 -2
  52. package/dist/esm2017/src/core/auth/auth_impl.d.ts +1 -0
  53. package/dist/esm2017/src/core/index.d.ts +9 -1
  54. package/dist/esm2017/src/core/strategies/anonymous.d.ts +3 -0
  55. package/dist/esm2017/src/core/strategies/credential.d.ts +6 -0
  56. package/dist/esm2017/src/core/strategies/custom_token.d.ts +3 -0
  57. package/dist/esm2017/src/core/strategies/email_and_password.d.ts +7 -0
  58. package/dist/esm2017/src/core/strategies/email_link.d.ts +4 -0
  59. package/dist/esm2017/src/core/user/account_info.d.ts +3 -0
  60. package/dist/esm2017/src/core/user/reload.d.ts +3 -1
  61. package/dist/esm2017/src/core/user/token_manager.d.ts +1 -0
  62. package/dist/esm2017/src/core/user/user_impl.d.ts +7 -1
  63. package/dist/esm2017/src/core/util/assert.d.ts +1 -0
  64. package/dist/esm2017/src/model/public_types.d.ts +7 -0
  65. package/dist/esm2017/src/platform_browser/strategies/phone.d.ts +6 -3
  66. package/dist/esm2017/src/platform_browser/strategies/popup.d.ts +4 -2
  67. package/dist/esm2017/src/platform_browser/strategies/redirect.d.ts +8 -4
  68. package/dist/esm2017/test/helpers/integration/helpers.d.ts +2 -0
  69. package/dist/esm2017/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  70. package/dist/esm5/{index-3bd54529.js → index-29ca3e8a.js} +238 -30
  71. package/dist/esm5/index-29ca3e8a.js.map +1 -0
  72. package/dist/esm5/index.js +2 -2
  73. package/dist/esm5/internal.js +2 -2
  74. package/dist/esm5/src/core/auth/auth_impl.d.ts +1 -0
  75. package/dist/esm5/src/core/index.d.ts +9 -1
  76. package/dist/esm5/src/core/strategies/anonymous.d.ts +3 -0
  77. package/dist/esm5/src/core/strategies/credential.d.ts +6 -0
  78. package/dist/esm5/src/core/strategies/custom_token.d.ts +3 -0
  79. package/dist/esm5/src/core/strategies/email_and_password.d.ts +7 -0
  80. package/dist/esm5/src/core/strategies/email_link.d.ts +4 -0
  81. package/dist/esm5/src/core/user/account_info.d.ts +3 -0
  82. package/dist/esm5/src/core/user/reload.d.ts +3 -1
  83. package/dist/esm5/src/core/user/token_manager.d.ts +1 -0
  84. package/dist/esm5/src/core/user/user_impl.d.ts +7 -1
  85. package/dist/esm5/src/core/util/assert.d.ts +1 -0
  86. package/dist/esm5/src/model/public_types.d.ts +7 -0
  87. package/dist/esm5/src/platform_browser/strategies/phone.d.ts +6 -3
  88. package/dist/esm5/src/platform_browser/strategies/popup.d.ts +4 -2
  89. package/dist/esm5/src/platform_browser/strategies/redirect.d.ts +8 -4
  90. package/dist/esm5/test/helpers/integration/helpers.d.ts +2 -0
  91. package/dist/esm5/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  92. package/dist/index.webworker.esm5.js +178 -11
  93. package/dist/index.webworker.esm5.js.map +1 -1
  94. package/dist/node/index.js +2 -2
  95. package/dist/node/internal.js +4 -1
  96. package/dist/node/internal.js.map +1 -1
  97. package/dist/node/src/core/auth/auth_impl.d.ts +1 -0
  98. package/dist/node/src/core/index.d.ts +9 -1
  99. package/dist/node/src/core/strategies/anonymous.d.ts +3 -0
  100. package/dist/node/src/core/strategies/credential.d.ts +6 -0
  101. package/dist/node/src/core/strategies/custom_token.d.ts +3 -0
  102. package/dist/node/src/core/strategies/email_and_password.d.ts +7 -0
  103. package/dist/node/src/core/strategies/email_link.d.ts +4 -0
  104. package/dist/node/src/core/user/account_info.d.ts +3 -0
  105. package/dist/node/src/core/user/reload.d.ts +3 -1
  106. package/dist/node/src/core/user/token_manager.d.ts +1 -0
  107. package/dist/node/src/core/user/user_impl.d.ts +7 -1
  108. package/dist/node/src/core/util/assert.d.ts +1 -0
  109. package/dist/node/src/model/public_types.d.ts +7 -0
  110. package/dist/node/src/platform_browser/strategies/phone.d.ts +6 -3
  111. package/dist/node/src/platform_browser/strategies/popup.d.ts +4 -2
  112. package/dist/node/src/platform_browser/strategies/redirect.d.ts +8 -4
  113. package/dist/node/test/helpers/integration/helpers.d.ts +2 -0
  114. package/dist/node/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  115. package/dist/node/{totp-7d693c11.js → totp-5883c255.js} +180 -12
  116. package/dist/node/totp-5883c255.js.map +1 -0
  117. package/dist/node-esm/index.js +2 -2
  118. package/dist/node-esm/internal.js +6 -3
  119. package/dist/node-esm/internal.js.map +1 -1
  120. package/dist/node-esm/src/core/auth/auth_impl.d.ts +1 -0
  121. package/dist/node-esm/src/core/index.d.ts +9 -1
  122. package/dist/node-esm/src/core/strategies/anonymous.d.ts +3 -0
  123. package/dist/node-esm/src/core/strategies/credential.d.ts +6 -0
  124. package/dist/node-esm/src/core/strategies/custom_token.d.ts +3 -0
  125. package/dist/node-esm/src/core/strategies/email_and_password.d.ts +7 -0
  126. package/dist/node-esm/src/core/strategies/email_link.d.ts +4 -0
  127. package/dist/node-esm/src/core/user/account_info.d.ts +3 -0
  128. package/dist/node-esm/src/core/user/reload.d.ts +3 -1
  129. package/dist/node-esm/src/core/user/token_manager.d.ts +1 -0
  130. package/dist/node-esm/src/core/user/user_impl.d.ts +7 -1
  131. package/dist/node-esm/src/core/util/assert.d.ts +1 -0
  132. package/dist/node-esm/src/model/public_types.d.ts +7 -0
  133. package/dist/node-esm/src/platform_browser/strategies/phone.d.ts +6 -3
  134. package/dist/node-esm/src/platform_browser/strategies/popup.d.ts +4 -2
  135. package/dist/node-esm/src/platform_browser/strategies/redirect.d.ts +8 -4
  136. package/dist/node-esm/test/helpers/integration/helpers.d.ts +2 -0
  137. package/dist/node-esm/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  138. package/dist/node-esm/{totp-56a8eeec.js → totp-81747288.js} +148 -7
  139. package/dist/node-esm/totp-81747288.js.map +1 -0
  140. package/dist/rn/{index-8ee80bdc.js → index-fc98a81c.js} +199 -16
  141. package/dist/rn/index-fc98a81c.js.map +1 -0
  142. package/dist/rn/index.js +1 -1
  143. package/dist/rn/internal.js +41 -15
  144. package/dist/rn/internal.js.map +1 -1
  145. package/dist/rn/src/core/auth/auth_impl.d.ts +1 -0
  146. package/dist/rn/src/core/index.d.ts +9 -1
  147. package/dist/rn/src/core/strategies/anonymous.d.ts +3 -0
  148. package/dist/rn/src/core/strategies/credential.d.ts +6 -0
  149. package/dist/rn/src/core/strategies/custom_token.d.ts +3 -0
  150. package/dist/rn/src/core/strategies/email_and_password.d.ts +7 -0
  151. package/dist/rn/src/core/strategies/email_link.d.ts +4 -0
  152. package/dist/rn/src/core/user/account_info.d.ts +3 -0
  153. package/dist/rn/src/core/user/reload.d.ts +3 -1
  154. package/dist/rn/src/core/user/token_manager.d.ts +1 -0
  155. package/dist/rn/src/core/user/user_impl.d.ts +7 -1
  156. package/dist/rn/src/core/util/assert.d.ts +1 -0
  157. package/dist/rn/src/model/public_types.d.ts +7 -0
  158. package/dist/rn/src/platform_browser/strategies/phone.d.ts +6 -3
  159. package/dist/rn/src/platform_browser/strategies/popup.d.ts +4 -2
  160. package/dist/rn/src/platform_browser/strategies/redirect.d.ts +8 -4
  161. package/dist/rn/test/helpers/integration/helpers.d.ts +2 -0
  162. package/dist/rn/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  163. package/dist/src/core/auth/auth_impl.d.ts +1 -0
  164. package/dist/src/core/index.d.ts +9 -1
  165. package/dist/src/core/strategies/anonymous.d.ts +3 -0
  166. package/dist/src/core/strategies/credential.d.ts +6 -0
  167. package/dist/src/core/strategies/custom_token.d.ts +3 -0
  168. package/dist/src/core/strategies/email_and_password.d.ts +7 -0
  169. package/dist/src/core/strategies/email_link.d.ts +4 -0
  170. package/dist/src/core/user/account_info.d.ts +3 -0
  171. package/dist/src/core/user/reload.d.ts +3 -1
  172. package/dist/src/core/user/token_manager.d.ts +1 -0
  173. package/dist/src/core/user/user_impl.d.ts +7 -1
  174. package/dist/src/core/util/assert.d.ts +1 -0
  175. package/dist/src/model/public_types.d.ts +7 -0
  176. package/dist/src/platform_browser/strategies/phone.d.ts +6 -3
  177. package/dist/src/platform_browser/strategies/popup.d.ts +4 -2
  178. package/dist/src/platform_browser/strategies/redirect.d.ts +8 -4
  179. package/dist/test/helpers/integration/helpers.d.ts +2 -0
  180. package/dist/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  181. package/dist/web-extension-cjs/index.js +1 -1
  182. package/dist/web-extension-cjs/internal.js +57 -18
  183. package/dist/web-extension-cjs/internal.js.map +1 -1
  184. package/dist/web-extension-cjs/{register-9438f377.js → register-151788a6.js} +148 -6
  185. package/dist/web-extension-cjs/register-151788a6.js.map +1 -0
  186. package/dist/web-extension-cjs/src/core/auth/auth_impl.d.ts +1 -0
  187. package/dist/web-extension-cjs/src/core/index.d.ts +9 -1
  188. package/dist/web-extension-cjs/src/core/strategies/anonymous.d.ts +3 -0
  189. package/dist/web-extension-cjs/src/core/strategies/credential.d.ts +6 -0
  190. package/dist/web-extension-cjs/src/core/strategies/custom_token.d.ts +3 -0
  191. package/dist/web-extension-cjs/src/core/strategies/email_and_password.d.ts +7 -0
  192. package/dist/web-extension-cjs/src/core/strategies/email_link.d.ts +4 -0
  193. package/dist/web-extension-cjs/src/core/user/account_info.d.ts +3 -0
  194. package/dist/web-extension-cjs/src/core/user/reload.d.ts +3 -1
  195. package/dist/web-extension-cjs/src/core/user/token_manager.d.ts +1 -0
  196. package/dist/web-extension-cjs/src/core/user/user_impl.d.ts +7 -1
  197. package/dist/web-extension-cjs/src/core/util/assert.d.ts +1 -0
  198. package/dist/web-extension-cjs/src/model/public_types.d.ts +7 -0
  199. package/dist/web-extension-cjs/src/platform_browser/strategies/phone.d.ts +6 -3
  200. package/dist/web-extension-cjs/src/platform_browser/strategies/popup.d.ts +4 -2
  201. package/dist/web-extension-cjs/src/platform_browser/strategies/redirect.d.ts +8 -4
  202. package/dist/web-extension-cjs/test/helpers/integration/helpers.d.ts +2 -0
  203. package/dist/web-extension-cjs/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  204. package/dist/web-extension-esm2017/index.js +2 -2
  205. package/dist/web-extension-esm2017/internal.js +58 -19
  206. package/dist/web-extension-esm2017/internal.js.map +1 -1
  207. package/dist/web-extension-esm2017/{register-7b89e556.js → register-b474ec12.js} +148 -7
  208. package/dist/web-extension-esm2017/register-b474ec12.js.map +1 -0
  209. package/dist/web-extension-esm2017/src/core/auth/auth_impl.d.ts +1 -0
  210. package/dist/web-extension-esm2017/src/core/index.d.ts +9 -1
  211. package/dist/web-extension-esm2017/src/core/strategies/anonymous.d.ts +3 -0
  212. package/dist/web-extension-esm2017/src/core/strategies/credential.d.ts +6 -0
  213. package/dist/web-extension-esm2017/src/core/strategies/custom_token.d.ts +3 -0
  214. package/dist/web-extension-esm2017/src/core/strategies/email_and_password.d.ts +7 -0
  215. package/dist/web-extension-esm2017/src/core/strategies/email_link.d.ts +4 -0
  216. package/dist/web-extension-esm2017/src/core/user/account_info.d.ts +3 -0
  217. package/dist/web-extension-esm2017/src/core/user/reload.d.ts +3 -1
  218. package/dist/web-extension-esm2017/src/core/user/token_manager.d.ts +1 -0
  219. package/dist/web-extension-esm2017/src/core/user/user_impl.d.ts +7 -1
  220. package/dist/web-extension-esm2017/src/core/util/assert.d.ts +1 -0
  221. package/dist/web-extension-esm2017/src/model/public_types.d.ts +7 -0
  222. package/dist/web-extension-esm2017/src/platform_browser/strategies/phone.d.ts +6 -3
  223. package/dist/web-extension-esm2017/src/platform_browser/strategies/popup.d.ts +4 -2
  224. package/dist/web-extension-esm2017/src/platform_browser/strategies/redirect.d.ts +8 -4
  225. package/dist/web-extension-esm2017/test/helpers/integration/helpers.d.ts +2 -0
  226. package/dist/web-extension-esm2017/test/integration/flows/firebaseserverapp.test.d.ts +17 -0
  227. package/package.json +10 -10
  228. package/dist/browser-cjs/index-6a907fc6.js.map +0 -1
  229. package/dist/cordova/popup_redirect-58faecee.js.map +0 -1
  230. package/dist/esm2017/index-e939beb5.js.map +0 -1
  231. package/dist/esm5/index-3bd54529.js.map +0 -1
  232. package/dist/node/totp-7d693c11.js.map +0 -1
  233. package/dist/node-esm/totp-56a8eeec.js.map +0 -1
  234. package/dist/rn/index-8ee80bdc.js.map +0 -1
  235. package/dist/web-extension-cjs/register-9438f377.js.map +0 -1
  236. package/dist/web-extension-esm2017/register-7b89e556.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var util = require('@firebase/util');
4
3
  var app = require('@firebase/app');
4
+ var util = require('@firebase/util');
5
5
  var logger = require('@firebase/logger');
6
6
  var tslib = require('tslib');
7
7
  var component = require('@firebase/component');
@@ -482,6 +482,9 @@ function _errorWithCustomMessage(auth, code, message) {
482
482
  appName: auth.name
483
483
  });
484
484
  }
485
+ function _serverAppCurrentUserOperationNotSupportedError(auth) {
486
+ return _errorWithCustomMessage(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */, 'Operations that alter the current user are not supported in conjunction with FirebaseServerApp');
487
+ }
485
488
  function _assertInstanceOf(auth, object, instance) {
486
489
  const constructorInstance = instance;
487
490
  if (!(object instanceof constructorInstance)) {
@@ -1590,11 +1593,16 @@ class StsTokenManager {
1590
1593
  : _tokenExpiresIn(response.idToken);
1591
1594
  this.updateTokensAndExpiration(response.idToken, response.refreshToken, expiresIn);
1592
1595
  }
1596
+ updateFromIdToken(idToken) {
1597
+ _assert(idToken.length !== 0, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1598
+ const expiresIn = _tokenExpiresIn(idToken);
1599
+ this.updateTokensAndExpiration(idToken, null, expiresIn);
1600
+ }
1593
1601
  async getToken(auth, forceRefresh = false) {
1594
- _assert(!this.accessToken || this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1595
1602
  if (!forceRefresh && this.accessToken && !this.isExpired) {
1596
1603
  return this.accessToken;
1597
1604
  }
1605
+ _assert(this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1598
1606
  if (this.refreshToken) {
1599
1607
  await this.refresh(auth, this.refreshToken);
1600
1608
  return this.accessToken;
@@ -1774,6 +1782,9 @@ class UserImpl {
1774
1782
  }
1775
1783
  }
1776
1784
  async delete() {
1785
+ if (app._isFirebaseServerApp(this.auth.app)) {
1786
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this.auth));
1787
+ }
1777
1788
  const idToken = await this.getIdToken();
1778
1789
  await _logoutIfInvalidated(this, deleteAccount(this.auth, { idToken }));
1779
1790
  this.stsTokenManager.clearRefreshToken();
@@ -1857,6 +1868,44 @@ class UserImpl {
1857
1868
  await _reloadWithoutSaving(user);
1858
1869
  return user;
1859
1870
  }
1871
+ /**
1872
+ * Initialize a User from an idToken server response
1873
+ * @param auth
1874
+ * @param idTokenResponse
1875
+ */
1876
+ static async _fromGetAccountInfoResponse(auth, response, idToken) {
1877
+ const coreAccount = response.users[0];
1878
+ _assert(coreAccount.localId !== undefined, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1879
+ const providerData = coreAccount.providerUserInfo !== undefined
1880
+ ? extractProviderData(coreAccount.providerUserInfo)
1881
+ : [];
1882
+ const isAnonymous = !(coreAccount.email && coreAccount.passwordHash) && !(providerData === null || providerData === void 0 ? void 0 : providerData.length);
1883
+ const stsTokenManager = new StsTokenManager();
1884
+ stsTokenManager.updateFromIdToken(idToken);
1885
+ // Initialize the Firebase Auth user.
1886
+ const user = new UserImpl({
1887
+ uid: coreAccount.localId,
1888
+ auth,
1889
+ stsTokenManager,
1890
+ isAnonymous
1891
+ });
1892
+ // update the user with data from the GetAccountInfo response.
1893
+ const updates = {
1894
+ uid: coreAccount.localId,
1895
+ displayName: coreAccount.displayName || null,
1896
+ photoURL: coreAccount.photoUrl || null,
1897
+ email: coreAccount.email || null,
1898
+ emailVerified: coreAccount.emailVerified || false,
1899
+ phoneNumber: coreAccount.phoneNumber || null,
1900
+ tenantId: coreAccount.tenantId || null,
1901
+ providerData,
1902
+ metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
1903
+ isAnonymous: !(coreAccount.email && coreAccount.passwordHash) &&
1904
+ !(providerData === null || providerData === void 0 ? void 0 : providerData.length)
1905
+ };
1906
+ Object.assign(user, updates);
1907
+ return user;
1908
+ }
1860
1909
  }
1861
1910
 
1862
1911
  /**
@@ -2600,8 +2649,32 @@ class AuthImpl {
2600
2649
  // Skip blocking callbacks, they should not apply to a change in another tab.
2601
2650
  await this._updateCurrentUser(user, /* skipBeforeStateCallbacks */ true);
2602
2651
  }
2652
+ async initializeCurrentUserFromIdToken(idToken) {
2653
+ try {
2654
+ const response = await getAccountInfo(this, { idToken });
2655
+ const user = await UserImpl._fromGetAccountInfoResponse(this, response, idToken);
2656
+ await this.directlySetCurrentUser(user);
2657
+ }
2658
+ catch (err) {
2659
+ console.warn('FirebaseServerApp could not login user with provided authIdToken: ', err);
2660
+ await this.directlySetCurrentUser(null);
2661
+ }
2662
+ }
2603
2663
  async initializeCurrentUser(popupRedirectResolver) {
2604
2664
  var _a;
2665
+ if (app._isFirebaseServerApp(this.app)) {
2666
+ const idToken = this.app.settings.authIdToken;
2667
+ if (idToken) {
2668
+ // Start the auth operation in the next tick to allow a moment for the customer's app to
2669
+ // attach an emulator, if desired.
2670
+ return new Promise(resolve => {
2671
+ setTimeout(() => this.initializeCurrentUserFromIdToken(idToken).then(resolve, resolve));
2672
+ });
2673
+ }
2674
+ else {
2675
+ return this.directlySetCurrentUser(null);
2676
+ }
2677
+ }
2605
2678
  // First check to see if we have a pending redirect event.
2606
2679
  const previouslyStoredUser = (await this.assertedPersistence.getCurrentUser());
2607
2680
  let futureCurrentUser = previouslyStoredUser;
@@ -2707,6 +2780,9 @@ class AuthImpl {
2707
2780
  this._deleted = true;
2708
2781
  }
2709
2782
  async updateCurrentUser(userExtern) {
2783
+ if (app._isFirebaseServerApp(this.app)) {
2784
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2785
+ }
2710
2786
  // The public updateCurrentUser method needs to make a copy of the user,
2711
2787
  // and also check that the project matches
2712
2788
  const user = userExtern
@@ -2733,6 +2809,9 @@ class AuthImpl {
2733
2809
  });
2734
2810
  }
2735
2811
  async signOut() {
2812
+ if (app._isFirebaseServerApp(this.app)) {
2813
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2814
+ }
2736
2815
  // Run first, to block _setRedirectUser() if any callbacks fail.
2737
2816
  await this.beforeStateQueue.runMiddleware(null);
2738
2817
  // Clear the redirect user when signOut is called
@@ -2744,6 +2823,9 @@ class AuthImpl {
2744
2823
  return this._updateCurrentUser(null, /* skipBeforeStateCallbacks */ true);
2745
2824
  }
2746
2825
  setPersistence(persistence) {
2826
+ if (app._isFirebaseServerApp(this.app)) {
2827
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2828
+ }
2747
2829
  return this.queue(async () => {
2748
2830
  await this.assertedPersistence.setPersistence(_getInstance(persistence));
2749
2831
  });
@@ -5189,12 +5271,18 @@ function providerIdForResponse(response) {
5189
5271
  * If there is already an anonymous user signed in, that user will be returned; otherwise, a
5190
5272
  * new anonymous user identity will be created and returned.
5191
5273
  *
5274
+ * This method is not supported by {@link Auth} instances created with a
5275
+ * {@link @firebase/app#FirebaseServerApp}.
5276
+ *
5192
5277
  * @param auth - The {@link Auth} instance.
5193
5278
  *
5194
5279
  * @public
5195
5280
  */
5196
5281
  async function signInAnonymously(auth) {
5197
5282
  var _a;
5283
+ if (app._isFirebaseServerApp(auth.app)) {
5284
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5285
+ }
5198
5286
  const authInternal = _castAuth(auth);
5199
5287
  await authInternal._initializationPromise;
5200
5288
  if ((_a = authInternal.currentUser) === null || _a === void 0 ? void 0 : _a.isAnonymous) {
@@ -5355,6 +5443,9 @@ async function _assertLinkedStatus(expected, user, provider) {
5355
5443
  */
5356
5444
  async function _reauthenticate(user, credential, bypassAuthState = false) {
5357
5445
  const { auth } = user;
5446
+ if (app._isFirebaseServerApp(auth.app)) {
5447
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5448
+ }
5358
5449
  const operationType = "reauthenticate" /* OperationType.REAUTHENTICATE */;
5359
5450
  try {
5360
5451
  const response = await _logoutIfInvalidated(user, _processCredentialSavingMfaContextIfNecessary(auth, operationType, credential, user), bypassAuthState);
@@ -5391,6 +5482,9 @@ async function _reauthenticate(user, credential, bypassAuthState = false) {
5391
5482
  * limitations under the License.
5392
5483
  */
5393
5484
  async function _signInWithCredential(auth, credential, bypassAuthState = false) {
5485
+ if (app._isFirebaseServerApp(auth.app)) {
5486
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5487
+ }
5394
5488
  const operationType = "signIn" /* OperationType.SIGN_IN */;
5395
5489
  const response = await _processCredentialSavingMfaContextIfNecessary(auth, operationType, credential);
5396
5490
  const userCredential = await UserCredentialImpl._fromIdTokenResponse(auth, operationType, response);
@@ -5405,6 +5499,9 @@ async function _signInWithCredential(auth, credential, bypassAuthState = false)
5405
5499
  * @remarks
5406
5500
  * An {@link AuthProvider} can be used to generate the credential.
5407
5501
  *
5502
+ * This method is not supported by {@link Auth} instances created with a
5503
+ * {@link @firebase/app#FirebaseServerApp}.
5504
+ *
5408
5505
  * @param auth - The {@link Auth} instance.
5409
5506
  * @param credential - The auth credential.
5410
5507
  *
@@ -5437,6 +5534,9 @@ async function linkWithCredential(user, credential) {
5437
5534
  * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
5438
5535
  * or a `TOKEN_EXPIRED` error.
5439
5536
  *
5537
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
5538
+ * created with a {@link @firebase/app#FirebaseServerApp}.
5539
+ *
5440
5540
  * @param user - The user.
5441
5541
  * @param credential - The auth credential.
5442
5542
  *
@@ -5493,12 +5593,18 @@ async function signInWithCustomToken$1(auth, request) {
5493
5593
  *
5494
5594
  * Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
5495
5595
  *
5596
+ * This method is not supported by {@link Auth} instances created with a
5597
+ * {@link @firebase/app#FirebaseServerApp}.
5598
+ *
5496
5599
  * @param auth - The {@link Auth} instance.
5497
5600
  * @param customToken - The custom token to sign in with.
5498
5601
  *
5499
5602
  * @public
5500
5603
  */
5501
5604
  async function signInWithCustomToken(auth, customToken) {
5605
+ if (app._isFirebaseServerApp(auth.app)) {
5606
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5607
+ }
5502
5608
  const authInternal = _castAuth(auth);
5503
5609
  const response = await signInWithCustomToken$1(authInternal, {
5504
5610
  token: customToken,
@@ -5786,6 +5892,9 @@ async function verifyPasswordResetCode(auth, code) {
5786
5892
  *
5787
5893
  * User account creation can fail if the account already exists or the password is invalid.
5788
5894
  *
5895
+ * This method is not supported on {@link Auth} instances created with a
5896
+ * {@link @firebase/app#FirebaseServerApp}.
5897
+ *
5789
5898
  * Note: The email address acts as a unique identifier for the user and enables an email-based
5790
5899
  * password reset. This function will create a new user account and set the initial user password.
5791
5900
  *
@@ -5796,6 +5905,9 @@ async function verifyPasswordResetCode(auth, code) {
5796
5905
  * @public
5797
5906
  */
5798
5907
  async function createUserWithEmailAndPassword(auth, email, password) {
5908
+ if (app._isFirebaseServerApp(auth.app)) {
5909
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5910
+ }
5799
5911
  const authInternal = _castAuth(auth);
5800
5912
  const request = {
5801
5913
  returnSecureToken: true,
@@ -5822,10 +5934,14 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5822
5934
  * When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
5823
5935
  * this method fails with "auth/invalid-credential" in case of an invalid email/password.
5824
5936
  *
5937
+ * This method is not supported on {@link Auth} instances created with a
5938
+ * {@link @firebase/app#FirebaseServerApp}.
5939
+ *
5825
5940
  * Note: The user's password is NOT the password used to access the user's email account. The
5826
5941
  * email address serves as a unique identifier for the user, and the password is used to access
5827
5942
  * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
5828
5943
  *
5944
+ *
5829
5945
  * @param auth - The {@link Auth} instance.
5830
5946
  * @param email - The users email address.
5831
5947
  * @param password - The users password.
@@ -5833,6 +5949,9 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5833
5949
  * @public
5834
5950
  */
5835
5951
  function signInWithEmailAndPassword(auth, email, password) {
5952
+ if (app._isFirebaseServerApp(auth.app)) {
5953
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5954
+ }
5836
5955
  return signInWithCredential(util.getModularInstance(auth), EmailAuthProvider.credential(email, password)).catch(async (error) => {
5837
5956
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5838
5957
  void recachePasswordPolicy(auth);
@@ -5931,6 +6050,9 @@ function isSignInWithEmailLink(auth, emailLink) {
5931
6050
  *
5932
6051
  * Fails with an error if the email address is invalid or OTP in email link expires.
5933
6052
  *
6053
+ * This method is not supported by {@link Auth} instances created with a
6054
+ * {@link @firebase/app#FirebaseServerApp}.
6055
+ *
5934
6056
  * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
5935
6057
  *
5936
6058
  * @example
@@ -5954,6 +6076,7 @@ function isSignInWithEmailLink(auth, emailLink) {
5954
6076
  * }
5955
6077
  * ```
5956
6078
  *
6079
+ *
5957
6080
  * @param auth - The {@link Auth} instance.
5958
6081
  * @param email - The user's email address.
5959
6082
  * @param emailLink - The link sent to the user's email address.
@@ -5961,6 +6084,9 @@ function isSignInWithEmailLink(auth, emailLink) {
5961
6084
  * @public
5962
6085
  */
5963
6086
  async function signInWithEmailLink(auth, email, emailLink) {
6087
+ if (app._isFirebaseServerApp(auth.app)) {
6088
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
6089
+ }
5964
6090
  const authModular = util.getModularInstance(auth);
5965
6091
  const credential = EmailAuthProvider.credentialWithLink(email, emailLink || _getCurrentUrl());
5966
6092
  // Check if the tenant ID in the email link matches the tenant ID on Auth
@@ -6207,6 +6333,9 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
6207
6333
  * An email will be sent to the original email address (if it was set) that allows to revoke the
6208
6334
  * email address change, in order to protect them from account hijacking.
6209
6335
  *
6336
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
6337
+ * created with a {@link @firebase/app#FirebaseServerApp}.
6338
+ *
6210
6339
  * Important: this is a security sensitive operation that requires the user to have recently signed
6211
6340
  * in. If this requirement isn't met, ask the user to authenticate again and then call
6212
6341
  * {@link reauthenticateWithCredential}.
@@ -6220,7 +6349,11 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
6220
6349
  * @public
6221
6350
  */
6222
6351
  function updateEmail(user, newEmail) {
6223
- return updateEmailOrPassword(util.getModularInstance(user), newEmail, null);
6352
+ const userInternal = util.getModularInstance(user);
6353
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
6354
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
6355
+ }
6356
+ return updateEmailOrPassword(userInternal, newEmail, null);
6224
6357
  }
6225
6358
  /**
6226
6359
  * Updates the user's password.
@@ -6397,7 +6530,8 @@ function getAdditionalUserInfo(userCredential) {
6397
6530
  * remembered or not. It also makes it easier to never persist the `Auth` state for applications
6398
6531
  * that are shared by other users or have sensitive data.
6399
6532
  *
6400
- * This method does not work in a Node.js environment.
6533
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
6534
+ * {@link @firebase/app#FirebaseServerApp}.
6401
6535
  *
6402
6536
  * @example
6403
6537
  * ```javascript
@@ -6543,6 +6677,9 @@ function useDeviceLanguage(auth) {
6543
6677
  * The operation fails with an error if the user to be updated belongs to a different Firebase
6544
6678
  * project.
6545
6679
  *
6680
+ * This method is not supported by {@link Auth} instances created with a
6681
+ * {@link @firebase/app#FirebaseServerApp}.
6682
+ *
6546
6683
  * @param auth - The {@link Auth} instance.
6547
6684
  * @param user - The new {@link User}.
6548
6685
  *
@@ -6554,6 +6691,10 @@ function updateCurrentUser(auth, user) {
6554
6691
  /**
6555
6692
  * Signs out the current user.
6556
6693
  *
6694
+ * @remarks
6695
+ * This method is not supported by {@link Auth} instances created with a
6696
+ * {@link @firebase/app#FirebaseServerApp}.
6697
+ *
6557
6698
  * @param auth - The {@link Auth} instance.
6558
6699
  *
6559
6700
  * @public
@@ -8333,7 +8474,8 @@ class ConfirmationResultImpl {
8333
8474
  * {@link RecaptchaVerifier} (like React Native), but you need to use a
8334
8475
  * third-party {@link ApplicationVerifier} implementation.
8335
8476
  *
8336
- * This method does not work in a Node.js environment.
8477
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
8478
+ * {@link @firebase/app#FirebaseServerApp}.
8337
8479
  *
8338
8480
  * @example
8339
8481
  * ```javascript
@@ -8351,6 +8493,9 @@ class ConfirmationResultImpl {
8351
8493
  * @public
8352
8494
  */
8353
8495
  async function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
8496
+ if (app._isFirebaseServerApp(auth.app)) {
8497
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
8498
+ }
8354
8499
  const authInternal = _castAuth(auth);
8355
8500
  const verificationId = await _verifyPhoneNumber(authInternal, phoneNumber, util.getModularInstance(appVerifier));
8356
8501
  return new ConfirmationResultImpl(verificationId, cred => signInWithCredential(authInternal, cred));
@@ -8379,7 +8524,8 @@ async function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
8379
8524
  * @remarks
8380
8525
  * Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
8381
8526
  *
8382
- * This method does not work in a Node.js environment.
8527
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
8528
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
8383
8529
  *
8384
8530
  * @param user - The user.
8385
8531
  * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
@@ -8389,6 +8535,9 @@ async function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
8389
8535
  */
8390
8536
  async function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
8391
8537
  const userInternal = util.getModularInstance(user);
8538
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
8539
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
8540
+ }
8392
8541
  const verificationId = await _verifyPhoneNumber(userInternal.auth, phoneNumber, util.getModularInstance(appVerifier));
8393
8542
  return new ConfirmationResultImpl(verificationId, cred => reauthenticateWithCredential(userInternal, cred));
8394
8543
  }
@@ -8455,7 +8604,8 @@ async function _verifyPhoneNumber(auth, options, verifier) {
8455
8604
  * Updates the user's phone number.
8456
8605
  *
8457
8606
  * @remarks
8458
- * This method does not work in a Node.js environment.
8607
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
8608
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
8459
8609
  *
8460
8610
  * @example
8461
8611
  * ```
@@ -8474,7 +8624,11 @@ async function _verifyPhoneNumber(auth, options, verifier) {
8474
8624
  * @public
8475
8625
  */
8476
8626
  async function updatePhoneNumber(user, credential) {
8477
- await _link$1(util.getModularInstance(user), credential);
8627
+ const userInternal = util.getModularInstance(user);
8628
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
8629
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
8630
+ }
8631
+ await _link$1(userInternal, credential);
8478
8632
  }
8479
8633
 
8480
8634
  /**
@@ -8860,7 +9014,8 @@ const _POLL_WINDOW_CLOSE_TIMEOUT = new Delay(2000, 10000);
8860
9014
  * If succeeds, returns the signed in user along with the provider's credential. If sign in was
8861
9015
  * unsuccessful, returns an error object containing additional information about the error.
8862
9016
  *
8863
- * This method does not work in a Node.js environment.
9017
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
9018
+ * {@link @firebase/app#FirebaseServerApp}.
8864
9019
  *
8865
9020
  * @example
8866
9021
  * ```javascript
@@ -8884,6 +9039,9 @@ const _POLL_WINDOW_CLOSE_TIMEOUT = new Delay(2000, 10000);
8884
9039
  * @public
8885
9040
  */
8886
9041
  async function signInWithPopup(auth, provider, resolver) {
9042
+ if (app._isFirebaseServerApp(auth.app)) {
9043
+ return Promise.reject(_createError(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */));
9044
+ }
8887
9045
  const authInternal = _castAuth(auth);
8888
9046
  _assertInstanceOf(auth, provider, FederatedAuthProvider);
8889
9047
  const resolverInternal = _withDefaultResolver(authInternal, resolver);
@@ -8898,7 +9056,8 @@ async function signInWithPopup(auth, provider, resolver) {
8898
9056
  * If the reauthentication is successful, the returned result will contain the user and the
8899
9057
  * provider's credential.
8900
9058
  *
8901
- * This method does not work in a Node.js environment.
9059
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
9060
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
8902
9061
  *
8903
9062
  * @example
8904
9063
  * ```javascript
@@ -8919,6 +9078,9 @@ async function signInWithPopup(auth, provider, resolver) {
8919
9078
  */
8920
9079
  async function reauthenticateWithPopup(user, provider, resolver) {
8921
9080
  const userInternal = util.getModularInstance(user);
9081
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
9082
+ return Promise.reject(_createError(userInternal.auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */));
9083
+ }
8922
9084
  _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
8923
9085
  const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
8924
9086
  const action = new PopupOperation(userInternal.auth, "reauthViaPopup" /* AuthEventType.REAUTH_VIA_POPUP */, provider, resolverInternal, userInternal);
@@ -9170,7 +9332,8 @@ function pendingRedirectKey(auth) {
9170
9332
  * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
9171
9333
  * | best practices} when using {@link signInWithRedirect}.
9172
9334
  *
9173
- * This method does not work in a Node.js environment.
9335
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
9336
+ * {@link @firebase/app#FirebaseServerApp}.
9174
9337
  *
9175
9338
  * @example
9176
9339
  * ```javascript
@@ -9209,6 +9372,9 @@ function signInWithRedirect(auth, provider, resolver) {
9209
9372
  return _signInWithRedirect(auth, provider, resolver);
9210
9373
  }
9211
9374
  async function _signInWithRedirect(auth, provider, resolver) {
9375
+ if (app._isFirebaseServerApp(auth.app)) {
9376
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
9377
+ }
9212
9378
  const authInternal = _castAuth(auth);
9213
9379
  _assertInstanceOf(auth, provider, FederatedAuthProvider);
9214
9380
  // Wait for auth initialization to complete, this will process pending redirects and clear the
@@ -9226,7 +9392,8 @@ async function _signInWithRedirect(auth, provider, resolver) {
9226
9392
  * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
9227
9393
  * | best practices} when using {@link reauthenticateWithRedirect}.
9228
9394
  *
9229
- * This method does not work in a Node.js environment.
9395
+ * This method does not work in a Node.js environment or with {@link Auth} instances
9396
+ * created with a {@link @firebase/app#FirebaseServerApp}.
9230
9397
  *
9231
9398
  * @example
9232
9399
  * ```javascript
@@ -9259,6 +9426,9 @@ function reauthenticateWithRedirect(user, provider, resolver) {
9259
9426
  async function _reauthenticateWithRedirect(user, provider, resolver) {
9260
9427
  const userInternal = util.getModularInstance(user);
9261
9428
  _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
9429
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
9430
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
9431
+ }
9262
9432
  // Wait for auth initialization to complete, this will process pending redirects and clear the
9263
9433
  // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
9264
9434
  // redirect and creating a PENDING_REDIRECT_KEY entry.
@@ -9276,7 +9446,8 @@ async function _reauthenticateWithRedirect(user, provider, resolver) {
9276
9446
  * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
9277
9447
  * | best practices} when using {@link linkWithRedirect}.
9278
9448
  *
9279
- * This method does not work in a Node.js environment.
9449
+ * This method does not work in a Node.js environment or with {@link Auth} instances
9450
+ * created with a {@link @firebase/app#FirebaseServerApp}.
9280
9451
  *
9281
9452
  * @example
9282
9453
  * ```javascript
@@ -9323,7 +9494,8 @@ async function _linkWithRedirect(user, provider, resolver) {
9323
9494
  * If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an
9324
9495
  * error. If no redirect operation was called, returns `null`.
9325
9496
  *
9326
- * This method does not work in a Node.js environment.
9497
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
9498
+ * {@link @firebase/app#FirebaseServerApp}.
9327
9499
  *
9328
9500
  * @example
9329
9501
  * ```javascript
@@ -9361,6 +9533,9 @@ async function getRedirectResult(auth, resolver) {
9361
9533
  return _getRedirectResult(auth, resolver, false);
9362
9534
  }
9363
9535
  async function _getRedirectResult(auth, resolverExtern, bypassAuthState = false) {
9536
+ if (app._isFirebaseServerApp(auth.app)) {
9537
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
9538
+ }
9364
9539
  const authInternal = _castAuth(auth);
9365
9540
  const resolver = _withDefaultResolver(authInternal, resolverExtern);
9366
9541
  const action = new RedirectAction(authInternal, resolver, bypassAuthState);
@@ -10289,7 +10464,7 @@ function _isEmptyString(input) {
10289
10464
  }
10290
10465
 
10291
10466
  var name = "@firebase/auth";
10292
- var version = "1.6.2";
10467
+ var version = "1.7.0-canary.0068ed5ab";
10293
10468
 
10294
10469
  /**
10295
10470
  * @license
@@ -10498,12 +10673,17 @@ function getAuth(app$1 = app.getApp()) {
10498
10673
  ]
10499
10674
  });
10500
10675
  const authTokenSyncPath = util.getExperimentalSetting('authTokenSyncURL');
10501
- // Don't allow urls (XSS possibility), only paths on the same domain
10502
- // (starting with a single '/')
10503
- if (authTokenSyncPath && authTokenSyncPath.match(/^\/[^\/].*/)) {
10504
- const mintCookie = mintCookieFactory(authTokenSyncPath);
10505
- beforeAuthStateChanged(auth, mintCookie, () => mintCookie(auth.currentUser));
10506
- onIdTokenChanged(auth, user => mintCookie(user));
10676
+ // Only do the Cookie exchange in a secure context
10677
+ if (authTokenSyncPath &&
10678
+ typeof isSecureContext === 'boolean' &&
10679
+ isSecureContext) {
10680
+ // Don't allow urls (XSS possibility), only paths on the same domain
10681
+ const authTokenSyncUrl = new URL(authTokenSyncPath, location.origin);
10682
+ if (location.origin === authTokenSyncUrl.origin) {
10683
+ const mintCookie = mintCookieFactory(authTokenSyncUrl.toString());
10684
+ beforeAuthStateChanged(auth, mintCookie, () => mintCookie(auth.currentUser));
10685
+ onIdTokenChanged(auth, user => mintCookie(user));
10686
+ }
10507
10687
  }
10508
10688
  const authEmulatorHost = util.getDefaultEmulatorHost('auth');
10509
10689
  if (authEmulatorHost) {
@@ -10645,4 +10825,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
10645
10825
  exports.validatePassword = validatePassword;
10646
10826
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
10647
10827
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
10648
- //# sourceMappingURL=index-6a907fc6.js.map
10828
+ //# sourceMappingURL=index-e3deabf2.js.map