@firebase/auth 1.6.2 → 1.7.0-canary.42fcdfe4c

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-fcf80d66.js} +202 -22
  4. package/dist/browser-cjs/index-fcf80d66.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-65e04583.js} +197 -17
  29. package/dist/cordova/popup_redirect-65e04583.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-3ad9a9b9.js} +202 -22
  49. package/dist/esm2017/index-3ad9a9b9.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-dcfb76ea.js} +238 -30
  71. package/dist/esm5/index-dcfb76ea.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-fbe187a4.js} +180 -12
  116. package/dist/node/totp-fbe187a4.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-4d1c9ab1.js} +148 -7
  139. package/dist/node-esm/totp-4d1c9ab1.js.map +1 -0
  140. package/dist/rn/{index-8ee80bdc.js → index-bbdaa838.js} +199 -16
  141. package/dist/rn/index-bbdaa838.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-4ce22251.js} +148 -6
  185. package/dist/web-extension-cjs/register-4ce22251.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-3473374b.js} +148 -7
  208. package/dist/web-extension-esm2017/register-3473374b.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 +7 -7
  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,5 +1,5 @@
1
+ import { SDK_VERSION, _isFirebaseServerApp, _getProvider, _registerComponent, registerVersion } from '@firebase/app';
1
2
  import { ErrorFactory, isBrowserExtension, isMobileCordova, isReactNative, FirebaseError, querystring, getModularInstance, base64Decode, getUA, isIE, createSubscribe, deepEqual, querystringDecode, extractQuerystring } from '@firebase/util';
2
- import { SDK_VERSION, _getProvider, _registerComponent, registerVersion } from '@firebase/app';
3
3
  import { __rest } from 'tslib';
4
4
  import { Component } from '@firebase/component';
5
5
  import { Logger, LogLevel } from '@firebase/logger';
@@ -381,6 +381,9 @@ function _errorWithCustomMessage(auth, code, message) {
381
381
  appName: auth.name
382
382
  });
383
383
  }
384
+ function _serverAppCurrentUserOperationNotSupportedError(auth) {
385
+ 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');
386
+ }
384
387
  function _assertInstanceOf(auth, object, instance) {
385
388
  const constructorInstance = instance;
386
389
  if (!(object instanceof constructorInstance)) {
@@ -1489,11 +1492,16 @@ class StsTokenManager {
1489
1492
  : _tokenExpiresIn(response.idToken);
1490
1493
  this.updateTokensAndExpiration(response.idToken, response.refreshToken, expiresIn);
1491
1494
  }
1495
+ updateFromIdToken(idToken) {
1496
+ _assert(idToken.length !== 0, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1497
+ const expiresIn = _tokenExpiresIn(idToken);
1498
+ this.updateTokensAndExpiration(idToken, null, expiresIn);
1499
+ }
1492
1500
  async getToken(auth, forceRefresh = false) {
1493
- _assert(!this.accessToken || this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1494
1501
  if (!forceRefresh && this.accessToken && !this.isExpired) {
1495
1502
  return this.accessToken;
1496
1503
  }
1504
+ _assert(this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1497
1505
  if (this.refreshToken) {
1498
1506
  await this.refresh(auth, this.refreshToken);
1499
1507
  return this.accessToken;
@@ -1673,6 +1681,9 @@ class UserImpl {
1673
1681
  }
1674
1682
  }
1675
1683
  async delete() {
1684
+ if (_isFirebaseServerApp(this.auth.app)) {
1685
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this.auth));
1686
+ }
1676
1687
  const idToken = await this.getIdToken();
1677
1688
  await _logoutIfInvalidated(this, deleteAccount(this.auth, { idToken }));
1678
1689
  this.stsTokenManager.clearRefreshToken();
@@ -1756,6 +1767,44 @@ class UserImpl {
1756
1767
  await _reloadWithoutSaving(user);
1757
1768
  return user;
1758
1769
  }
1770
+ /**
1771
+ * Initialize a User from an idToken server response
1772
+ * @param auth
1773
+ * @param idTokenResponse
1774
+ */
1775
+ static async _fromGetAccountInfoResponse(auth, response, idToken) {
1776
+ const coreAccount = response.users[0];
1777
+ _assert(coreAccount.localId !== undefined, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1778
+ const providerData = coreAccount.providerUserInfo !== undefined
1779
+ ? extractProviderData(coreAccount.providerUserInfo)
1780
+ : [];
1781
+ const isAnonymous = !(coreAccount.email && coreAccount.passwordHash) && !(providerData === null || providerData === void 0 ? void 0 : providerData.length);
1782
+ const stsTokenManager = new StsTokenManager();
1783
+ stsTokenManager.updateFromIdToken(idToken);
1784
+ // Initialize the Firebase Auth user.
1785
+ const user = new UserImpl({
1786
+ uid: coreAccount.localId,
1787
+ auth,
1788
+ stsTokenManager,
1789
+ isAnonymous
1790
+ });
1791
+ // update the user with data from the GetAccountInfo response.
1792
+ const updates = {
1793
+ uid: coreAccount.localId,
1794
+ displayName: coreAccount.displayName || null,
1795
+ photoURL: coreAccount.photoUrl || null,
1796
+ email: coreAccount.email || null,
1797
+ emailVerified: coreAccount.emailVerified || false,
1798
+ phoneNumber: coreAccount.phoneNumber || null,
1799
+ tenantId: coreAccount.tenantId || null,
1800
+ providerData,
1801
+ metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
1802
+ isAnonymous: !(coreAccount.email && coreAccount.passwordHash) &&
1803
+ !(providerData === null || providerData === void 0 ? void 0 : providerData.length)
1804
+ };
1805
+ Object.assign(user, updates);
1806
+ return user;
1807
+ }
1759
1808
  }
1760
1809
 
1761
1810
  /**
@@ -2499,8 +2548,32 @@ class AuthImpl {
2499
2548
  // Skip blocking callbacks, they should not apply to a change in another tab.
2500
2549
  await this._updateCurrentUser(user, /* skipBeforeStateCallbacks */ true);
2501
2550
  }
2551
+ async initializeCurrentUserFromIdToken(idToken) {
2552
+ try {
2553
+ const response = await getAccountInfo(this, { idToken });
2554
+ const user = await UserImpl._fromGetAccountInfoResponse(this, response, idToken);
2555
+ await this.directlySetCurrentUser(user);
2556
+ }
2557
+ catch (err) {
2558
+ console.warn('FirebaseServerApp could not login user with provided authIdToken: ', err);
2559
+ await this.directlySetCurrentUser(null);
2560
+ }
2561
+ }
2502
2562
  async initializeCurrentUser(popupRedirectResolver) {
2503
2563
  var _a;
2564
+ if (_isFirebaseServerApp(this.app)) {
2565
+ const idToken = this.app.settings.authIdToken;
2566
+ if (idToken) {
2567
+ // Start the auth operation in the next tick to allow a moment for the customer's app to
2568
+ // attach an emulator, if desired.
2569
+ return new Promise(resolve => {
2570
+ setTimeout(() => this.initializeCurrentUserFromIdToken(idToken).then(resolve, resolve));
2571
+ });
2572
+ }
2573
+ else {
2574
+ return this.directlySetCurrentUser(null);
2575
+ }
2576
+ }
2504
2577
  // First check to see if we have a pending redirect event.
2505
2578
  const previouslyStoredUser = (await this.assertedPersistence.getCurrentUser());
2506
2579
  let futureCurrentUser = previouslyStoredUser;
@@ -2606,6 +2679,9 @@ class AuthImpl {
2606
2679
  this._deleted = true;
2607
2680
  }
2608
2681
  async updateCurrentUser(userExtern) {
2682
+ if (_isFirebaseServerApp(this.app)) {
2683
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2684
+ }
2609
2685
  // The public updateCurrentUser method needs to make a copy of the user,
2610
2686
  // and also check that the project matches
2611
2687
  const user = userExtern
@@ -2632,6 +2708,9 @@ class AuthImpl {
2632
2708
  });
2633
2709
  }
2634
2710
  async signOut() {
2711
+ if (_isFirebaseServerApp(this.app)) {
2712
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2713
+ }
2635
2714
  // Run first, to block _setRedirectUser() if any callbacks fail.
2636
2715
  await this.beforeStateQueue.runMiddleware(null);
2637
2716
  // Clear the redirect user when signOut is called
@@ -2643,6 +2722,9 @@ class AuthImpl {
2643
2722
  return this._updateCurrentUser(null, /* skipBeforeStateCallbacks */ true);
2644
2723
  }
2645
2724
  setPersistence(persistence) {
2725
+ if (_isFirebaseServerApp(this.app)) {
2726
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2727
+ }
2646
2728
  return this.queue(async () => {
2647
2729
  await this.assertedPersistence.setPersistence(_getInstance(persistence));
2648
2730
  });
@@ -5088,12 +5170,18 @@ function providerIdForResponse(response) {
5088
5170
  * If there is already an anonymous user signed in, that user will be returned; otherwise, a
5089
5171
  * new anonymous user identity will be created and returned.
5090
5172
  *
5173
+ * This method is not supported by {@link Auth} instances created with a
5174
+ * {@link @firebase/app#FirebaseServerApp}.
5175
+ *
5091
5176
  * @param auth - The {@link Auth} instance.
5092
5177
  *
5093
5178
  * @public
5094
5179
  */
5095
5180
  async function signInAnonymously(auth) {
5096
5181
  var _a;
5182
+ if (_isFirebaseServerApp(auth.app)) {
5183
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5184
+ }
5097
5185
  const authInternal = _castAuth(auth);
5098
5186
  await authInternal._initializationPromise;
5099
5187
  if ((_a = authInternal.currentUser) === null || _a === void 0 ? void 0 : _a.isAnonymous) {
@@ -5254,6 +5342,9 @@ async function _assertLinkedStatus(expected, user, provider) {
5254
5342
  */
5255
5343
  async function _reauthenticate(user, credential, bypassAuthState = false) {
5256
5344
  const { auth } = user;
5345
+ if (_isFirebaseServerApp(auth.app)) {
5346
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5347
+ }
5257
5348
  const operationType = "reauthenticate" /* OperationType.REAUTHENTICATE */;
5258
5349
  try {
5259
5350
  const response = await _logoutIfInvalidated(user, _processCredentialSavingMfaContextIfNecessary(auth, operationType, credential, user), bypassAuthState);
@@ -5290,6 +5381,9 @@ async function _reauthenticate(user, credential, bypassAuthState = false) {
5290
5381
  * limitations under the License.
5291
5382
  */
5292
5383
  async function _signInWithCredential(auth, credential, bypassAuthState = false) {
5384
+ if (_isFirebaseServerApp(auth.app)) {
5385
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5386
+ }
5293
5387
  const operationType = "signIn" /* OperationType.SIGN_IN */;
5294
5388
  const response = await _processCredentialSavingMfaContextIfNecessary(auth, operationType, credential);
5295
5389
  const userCredential = await UserCredentialImpl._fromIdTokenResponse(auth, operationType, response);
@@ -5304,6 +5398,9 @@ async function _signInWithCredential(auth, credential, bypassAuthState = false)
5304
5398
  * @remarks
5305
5399
  * An {@link AuthProvider} can be used to generate the credential.
5306
5400
  *
5401
+ * This method is not supported by {@link Auth} instances created with a
5402
+ * {@link @firebase/app#FirebaseServerApp}.
5403
+ *
5307
5404
  * @param auth - The {@link Auth} instance.
5308
5405
  * @param credential - The auth credential.
5309
5406
  *
@@ -5336,6 +5433,9 @@ async function linkWithCredential(user, credential) {
5336
5433
  * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
5337
5434
  * or a `TOKEN_EXPIRED` error.
5338
5435
  *
5436
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
5437
+ * created with a {@link @firebase/app#FirebaseServerApp}.
5438
+ *
5339
5439
  * @param user - The user.
5340
5440
  * @param credential - The auth credential.
5341
5441
  *
@@ -5392,12 +5492,18 @@ async function signInWithCustomToken$1(auth, request) {
5392
5492
  *
5393
5493
  * Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
5394
5494
  *
5495
+ * This method is not supported by {@link Auth} instances created with a
5496
+ * {@link @firebase/app#FirebaseServerApp}.
5497
+ *
5395
5498
  * @param auth - The {@link Auth} instance.
5396
5499
  * @param customToken - The custom token to sign in with.
5397
5500
  *
5398
5501
  * @public
5399
5502
  */
5400
5503
  async function signInWithCustomToken(auth, customToken) {
5504
+ if (_isFirebaseServerApp(auth.app)) {
5505
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5506
+ }
5401
5507
  const authInternal = _castAuth(auth);
5402
5508
  const response = await signInWithCustomToken$1(authInternal, {
5403
5509
  token: customToken,
@@ -5685,6 +5791,9 @@ async function verifyPasswordResetCode(auth, code) {
5685
5791
  *
5686
5792
  * User account creation can fail if the account already exists or the password is invalid.
5687
5793
  *
5794
+ * This method is not supported on {@link Auth} instances created with a
5795
+ * {@link @firebase/app#FirebaseServerApp}.
5796
+ *
5688
5797
  * Note: The email address acts as a unique identifier for the user and enables an email-based
5689
5798
  * password reset. This function will create a new user account and set the initial user password.
5690
5799
  *
@@ -5695,6 +5804,9 @@ async function verifyPasswordResetCode(auth, code) {
5695
5804
  * @public
5696
5805
  */
5697
5806
  async function createUserWithEmailAndPassword(auth, email, password) {
5807
+ if (_isFirebaseServerApp(auth.app)) {
5808
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5809
+ }
5698
5810
  const authInternal = _castAuth(auth);
5699
5811
  const request = {
5700
5812
  returnSecureToken: true,
@@ -5721,10 +5833,14 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5721
5833
  * When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
5722
5834
  * this method fails with "auth/invalid-credential" in case of an invalid email/password.
5723
5835
  *
5836
+ * This method is not supported on {@link Auth} instances created with a
5837
+ * {@link @firebase/app#FirebaseServerApp}.
5838
+ *
5724
5839
  * Note: The user's password is NOT the password used to access the user's email account. The
5725
5840
  * email address serves as a unique identifier for the user, and the password is used to access
5726
5841
  * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
5727
5842
  *
5843
+ *
5728
5844
  * @param auth - The {@link Auth} instance.
5729
5845
  * @param email - The users email address.
5730
5846
  * @param password - The users password.
@@ -5732,6 +5848,9 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5732
5848
  * @public
5733
5849
  */
5734
5850
  function signInWithEmailAndPassword(auth, email, password) {
5851
+ if (_isFirebaseServerApp(auth.app)) {
5852
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5853
+ }
5735
5854
  return signInWithCredential(getModularInstance(auth), EmailAuthProvider.credential(email, password)).catch(async (error) => {
5736
5855
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5737
5856
  void recachePasswordPolicy(auth);
@@ -5830,6 +5949,9 @@ function isSignInWithEmailLink(auth, emailLink) {
5830
5949
  *
5831
5950
  * Fails with an error if the email address is invalid or OTP in email link expires.
5832
5951
  *
5952
+ * This method is not supported by {@link Auth} instances created with a
5953
+ * {@link @firebase/app#FirebaseServerApp}.
5954
+ *
5833
5955
  * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
5834
5956
  *
5835
5957
  * @example
@@ -5853,6 +5975,7 @@ function isSignInWithEmailLink(auth, emailLink) {
5853
5975
  * }
5854
5976
  * ```
5855
5977
  *
5978
+ *
5856
5979
  * @param auth - The {@link Auth} instance.
5857
5980
  * @param email - The user's email address.
5858
5981
  * @param emailLink - The link sent to the user's email address.
@@ -5860,6 +5983,9 @@ function isSignInWithEmailLink(auth, emailLink) {
5860
5983
  * @public
5861
5984
  */
5862
5985
  async function signInWithEmailLink(auth, email, emailLink) {
5986
+ if (_isFirebaseServerApp(auth.app)) {
5987
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5988
+ }
5863
5989
  const authModular = getModularInstance(auth);
5864
5990
  const credential = EmailAuthProvider.credentialWithLink(email, emailLink || _getCurrentUrl());
5865
5991
  // Check if the tenant ID in the email link matches the tenant ID on Auth
@@ -6106,6 +6232,9 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
6106
6232
  * An email will be sent to the original email address (if it was set) that allows to revoke the
6107
6233
  * email address change, in order to protect them from account hijacking.
6108
6234
  *
6235
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
6236
+ * created with a {@link @firebase/app#FirebaseServerApp}.
6237
+ *
6109
6238
  * Important: this is a security sensitive operation that requires the user to have recently signed
6110
6239
  * in. If this requirement isn't met, ask the user to authenticate again and then call
6111
6240
  * {@link reauthenticateWithCredential}.
@@ -6119,7 +6248,11 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
6119
6248
  * @public
6120
6249
  */
6121
6250
  function updateEmail(user, newEmail) {
6122
- return updateEmailOrPassword(getModularInstance(user), newEmail, null);
6251
+ const userInternal = getModularInstance(user);
6252
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
6253
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
6254
+ }
6255
+ return updateEmailOrPassword(userInternal, newEmail, null);
6123
6256
  }
6124
6257
  /**
6125
6258
  * Updates the user's password.
@@ -6296,7 +6429,8 @@ function getAdditionalUserInfo(userCredential) {
6296
6429
  * remembered or not. It also makes it easier to never persist the `Auth` state for applications
6297
6430
  * that are shared by other users or have sensitive data.
6298
6431
  *
6299
- * This method does not work in a Node.js environment.
6432
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
6433
+ * {@link @firebase/app#FirebaseServerApp}.
6300
6434
  *
6301
6435
  * @example
6302
6436
  * ```javascript
@@ -6442,6 +6576,9 @@ function useDeviceLanguage(auth) {
6442
6576
  * The operation fails with an error if the user to be updated belongs to a different Firebase
6443
6577
  * project.
6444
6578
  *
6579
+ * This method is not supported by {@link Auth} instances created with a
6580
+ * {@link @firebase/app#FirebaseServerApp}.
6581
+ *
6445
6582
  * @param auth - The {@link Auth} instance.
6446
6583
  * @param user - The new {@link User}.
6447
6584
  *
@@ -6453,6 +6590,10 @@ function updateCurrentUser(auth, user) {
6453
6590
  /**
6454
6591
  * Signs out the current user.
6455
6592
  *
6593
+ * @remarks
6594
+ * This method is not supported by {@link Auth} instances created with a
6595
+ * {@link @firebase/app#FirebaseServerApp}.
6596
+ *
6456
6597
  * @param auth - The {@link Auth} instance.
6457
6598
  *
6458
6599
  * @public
@@ -7608,7 +7749,7 @@ function _isEmptyString(input) {
7608
7749
  }
7609
7750
 
7610
7751
  var name = "@firebase/auth";
7611
- var version = "1.6.2";
7752
+ var version = "1.7.0-canary.42fcdfe4c";
7612
7753
 
7613
7754
  /**
7614
7755
  * @license
@@ -7754,5 +7895,5 @@ function registerAuth(clientPlatform) {
7754
7895
  registerVersion(name, version, 'esm2017');
7755
7896
  }
7756
7897
 
7757
- export { updateEmail as $, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as A, linkWithCredential as B, reauthenticateWithCredential as C, signInWithCustomToken as D, EmailAuthCredential as E, FacebookAuthProvider as F, GoogleAuthProvider as G, sendPasswordResetEmail as H, confirmPasswordReset as I, applyActionCode as J, checkActionCode as K, verifyPasswordResetCode as L, createUserWithEmailAndPassword as M, signInWithEmailAndPassword as N, OAuthCredential as O, PhoneAuthCredential as P, sendSignInLinkToEmail as Q, isSignInWithEmailLink as R, SAMLAuthProvider as S, TotpMultiFactorGenerator as T, signInWithEmailLink as U, fetchSignInMethodsForEmail as V, sendEmailVerification as W, verifyBeforeUpdateEmail as X, ActionCodeURL as Y, parseActionCodeURL as Z, updateProfile as _, indexedDBLocalPersistence as a, updatePassword as a0, getIdToken as a1, getIdTokenResult as a2, unlink as a3, getAdditionalUserInfo as a4, reload as a5, getMultiFactorResolver as a6, multiFactor as a7, STORAGE_AVAILABLE_KEY as a8, _isIframe as a9, debugAssert as aA, _assertInstanceOf as aB, _generateEventId as aC, FederatedAuthProvider as aD, _persistenceKeyName as aE, _performApiRequest as aF, _getCurrentUrl as aG, _gapiScriptUrl as aH, _emulatorUrl as aI, _isChromeIOS as aJ, _isFirefox as aK, _isIOSStandalone as aL, BaseOAuthProvider as aM, _setWindowLocation as aN, MultiFactorAssertionImpl as aO, finalizeEnrollPhoneMfa as aP, finalizeSignInPhoneMfa as aQ, _setExternalJSProvider as aR, _isAndroid as aS, _isIOS7Or8 as aT, UserImpl as aU, AuthImpl as aV, _getClientVersion as aW, FetchProvider as aX, SAMLAuthCredential as aY, _isMobileBrowser as aa, _isIE10 as ab, _isSafari as ac, _isIOS as ad, _assert as ae, Delay as af, _window as ag, isV2 as ah, _createError as ai, _recaptchaV2ScriptUrl as aj, _loadJS as ak, _generateCallbackName as al, _castAuth as am, _isHttpOrHttps as an, _isWorker as ao, getRecaptchaParams as ap, _assertLinkedStatus as aq, startEnrollPhoneMfa as ar, startSignInPhoneMfa as as, sendPhoneVerificationCode as at, _link as au, _getInstance as av, _signInWithCredential as aw, _reauthenticate as ax, signInWithIdp as ay, _fail as az, TotpSecret as b, connectAuthEmulator as c, initializeRecaptchaConfig as d, beforeAuthStateChanged as e, onAuthStateChanged as f, updateCurrentUser as g, signOut as h, initializeAuth as i, revokeAccessToken as j, deleteUser as k, debugErrorMap as l, AuthCredential as m, inMemoryPersistence as n, onIdTokenChanged as o, prodErrorMap as p, EmailAuthProvider as q, registerAuth as r, setPersistence as s, GithubAuthProvider as t, useDeviceLanguage as u, validatePassword as v, OAuthProvider as w, TwitterAuthProvider as x, signInAnonymously as y, signInWithCredential as z };
7758
- //# sourceMappingURL=register-7b89e556.js.map
7898
+ export { updateEmail as $, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as A, linkWithCredential as B, reauthenticateWithCredential as C, signInWithCustomToken as D, EmailAuthCredential as E, FacebookAuthProvider as F, GoogleAuthProvider as G, sendPasswordResetEmail as H, confirmPasswordReset as I, applyActionCode as J, checkActionCode as K, verifyPasswordResetCode as L, createUserWithEmailAndPassword as M, signInWithEmailAndPassword as N, OAuthCredential as O, PhoneAuthCredential as P, sendSignInLinkToEmail as Q, isSignInWithEmailLink as R, SAMLAuthProvider as S, TotpMultiFactorGenerator as T, signInWithEmailLink as U, fetchSignInMethodsForEmail as V, sendEmailVerification as W, verifyBeforeUpdateEmail as X, ActionCodeURL as Y, parseActionCodeURL as Z, updateProfile as _, indexedDBLocalPersistence as a, updatePassword as a0, getIdToken as a1, getIdTokenResult as a2, unlink as a3, getAdditionalUserInfo as a4, reload as a5, getMultiFactorResolver as a6, multiFactor as a7, STORAGE_AVAILABLE_KEY as a8, _isIframe as a9, _fail as aA, debugAssert as aB, _assertInstanceOf as aC, _generateEventId as aD, FederatedAuthProvider as aE, _persistenceKeyName as aF, _performApiRequest as aG, _getCurrentUrl as aH, _gapiScriptUrl as aI, _emulatorUrl as aJ, _isChromeIOS as aK, _isFirefox as aL, _isIOSStandalone as aM, BaseOAuthProvider as aN, _setWindowLocation as aO, MultiFactorAssertionImpl as aP, finalizeEnrollPhoneMfa as aQ, finalizeSignInPhoneMfa as aR, _setExternalJSProvider as aS, _isAndroid as aT, _isIOS7Or8 as aU, UserImpl as aV, AuthImpl as aW, _getClientVersion as aX, FetchProvider as aY, SAMLAuthCredential as aZ, _isMobileBrowser as aa, _isIE10 as ab, _isSafari as ac, _isIOS as ad, _assert as ae, Delay as af, _window as ag, isV2 as ah, _createError as ai, _recaptchaV2ScriptUrl as aj, _loadJS as ak, _generateCallbackName as al, _castAuth as am, _isHttpOrHttps as an, _isWorker as ao, getRecaptchaParams as ap, _serverAppCurrentUserOperationNotSupportedError as aq, _assertLinkedStatus as ar, startEnrollPhoneMfa as as, startSignInPhoneMfa as at, sendPhoneVerificationCode as au, _link as av, _getInstance as aw, _signInWithCredential as ax, _reauthenticate as ay, signInWithIdp as az, TotpSecret as b, connectAuthEmulator as c, initializeRecaptchaConfig as d, beforeAuthStateChanged as e, onAuthStateChanged as f, updateCurrentUser as g, signOut as h, initializeAuth as i, revokeAccessToken as j, deleteUser as k, debugErrorMap as l, AuthCredential as m, inMemoryPersistence as n, onIdTokenChanged as o, prodErrorMap as p, EmailAuthProvider as q, registerAuth as r, setPersistence as s, GithubAuthProvider as t, useDeviceLanguage as u, validatePassword as v, OAuthProvider as w, TwitterAuthProvider as x, signInAnonymously as y, signInWithCredential as z };
7899
+ //# sourceMappingURL=register-3473374b.js.map