@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, getApp } from '@firebase/app';
1
2
  import { ErrorFactory, isBrowserExtension, isMobileCordova, isReactNative, FirebaseError, querystring, getModularInstance, base64Decode, getUA, isIE, createSubscribe, deepEqual, querystringDecode, extractQuerystring, getDefaultEmulatorHost } from '@firebase/util';
2
- import { SDK_VERSION, _getProvider, _registerComponent, registerVersion, getApp } from '@firebase/app';
3
3
  import { __rest } from 'tslib';
4
4
  import { Component } from '@firebase/component';
5
5
  import { fetch as fetch$1, Headers as Headers$1, Response as Response$1 } from 'undici';
@@ -481,6 +481,9 @@ function _errorWithCustomMessage(auth, code, message) {
481
481
  appName: auth.name
482
482
  });
483
483
  }
484
+ function _serverAppCurrentUserOperationNotSupportedError(auth) {
485
+ 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');
486
+ }
484
487
  function createErrorInternal(authOrCode, ...rest) {
485
488
  if (typeof authOrCode !== 'string') {
486
489
  const code = rest[0];
@@ -1572,11 +1575,16 @@ class StsTokenManager {
1572
1575
  : _tokenExpiresIn(response.idToken);
1573
1576
  this.updateTokensAndExpiration(response.idToken, response.refreshToken, expiresIn);
1574
1577
  }
1578
+ updateFromIdToken(idToken) {
1579
+ _assert(idToken.length !== 0, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1580
+ const expiresIn = _tokenExpiresIn(idToken);
1581
+ this.updateTokensAndExpiration(idToken, null, expiresIn);
1582
+ }
1575
1583
  async getToken(auth, forceRefresh = false) {
1576
- _assert(!this.accessToken || this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1577
1584
  if (!forceRefresh && this.accessToken && !this.isExpired) {
1578
1585
  return this.accessToken;
1579
1586
  }
1587
+ _assert(this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1580
1588
  if (this.refreshToken) {
1581
1589
  await this.refresh(auth, this.refreshToken);
1582
1590
  return this.accessToken;
@@ -1756,6 +1764,9 @@ class UserImpl {
1756
1764
  }
1757
1765
  }
1758
1766
  async delete() {
1767
+ if (_isFirebaseServerApp(this.auth.app)) {
1768
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this.auth));
1769
+ }
1759
1770
  const idToken = await this.getIdToken();
1760
1771
  await _logoutIfInvalidated(this, deleteAccount(this.auth, { idToken }));
1761
1772
  this.stsTokenManager.clearRefreshToken();
@@ -1839,6 +1850,44 @@ class UserImpl {
1839
1850
  await _reloadWithoutSaving(user);
1840
1851
  return user;
1841
1852
  }
1853
+ /**
1854
+ * Initialize a User from an idToken server response
1855
+ * @param auth
1856
+ * @param idTokenResponse
1857
+ */
1858
+ static async _fromGetAccountInfoResponse(auth, response, idToken) {
1859
+ const coreAccount = response.users[0];
1860
+ _assert(coreAccount.localId !== undefined, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1861
+ const providerData = coreAccount.providerUserInfo !== undefined
1862
+ ? extractProviderData(coreAccount.providerUserInfo)
1863
+ : [];
1864
+ const isAnonymous = !(coreAccount.email && coreAccount.passwordHash) && !(providerData === null || providerData === void 0 ? void 0 : providerData.length);
1865
+ const stsTokenManager = new StsTokenManager();
1866
+ stsTokenManager.updateFromIdToken(idToken);
1867
+ // Initialize the Firebase Auth user.
1868
+ const user = new UserImpl({
1869
+ uid: coreAccount.localId,
1870
+ auth,
1871
+ stsTokenManager,
1872
+ isAnonymous
1873
+ });
1874
+ // update the user with data from the GetAccountInfo response.
1875
+ const updates = {
1876
+ uid: coreAccount.localId,
1877
+ displayName: coreAccount.displayName || null,
1878
+ photoURL: coreAccount.photoUrl || null,
1879
+ email: coreAccount.email || null,
1880
+ emailVerified: coreAccount.emailVerified || false,
1881
+ phoneNumber: coreAccount.phoneNumber || null,
1882
+ tenantId: coreAccount.tenantId || null,
1883
+ providerData,
1884
+ metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
1885
+ isAnonymous: !(coreAccount.email && coreAccount.passwordHash) &&
1886
+ !(providerData === null || providerData === void 0 ? void 0 : providerData.length)
1887
+ };
1888
+ Object.assign(user, updates);
1889
+ return user;
1890
+ }
1842
1891
  }
1843
1892
 
1844
1893
  /**
@@ -2578,8 +2627,32 @@ class AuthImpl {
2578
2627
  // Skip blocking callbacks, they should not apply to a change in another tab.
2579
2628
  await this._updateCurrentUser(user, /* skipBeforeStateCallbacks */ true);
2580
2629
  }
2630
+ async initializeCurrentUserFromIdToken(idToken) {
2631
+ try {
2632
+ const response = await getAccountInfo(this, { idToken });
2633
+ const user = await UserImpl._fromGetAccountInfoResponse(this, response, idToken);
2634
+ await this.directlySetCurrentUser(user);
2635
+ }
2636
+ catch (err) {
2637
+ console.warn('FirebaseServerApp could not login user with provided authIdToken: ', err);
2638
+ await this.directlySetCurrentUser(null);
2639
+ }
2640
+ }
2581
2641
  async initializeCurrentUser(popupRedirectResolver) {
2582
2642
  var _a;
2643
+ if (_isFirebaseServerApp(this.app)) {
2644
+ const idToken = this.app.settings.authIdToken;
2645
+ if (idToken) {
2646
+ // Start the auth operation in the next tick to allow a moment for the customer's app to
2647
+ // attach an emulator, if desired.
2648
+ return new Promise(resolve => {
2649
+ setTimeout(() => this.initializeCurrentUserFromIdToken(idToken).then(resolve, resolve));
2650
+ });
2651
+ }
2652
+ else {
2653
+ return this.directlySetCurrentUser(null);
2654
+ }
2655
+ }
2583
2656
  // First check to see if we have a pending redirect event.
2584
2657
  const previouslyStoredUser = (await this.assertedPersistence.getCurrentUser());
2585
2658
  let futureCurrentUser = previouslyStoredUser;
@@ -2685,6 +2758,9 @@ class AuthImpl {
2685
2758
  this._deleted = true;
2686
2759
  }
2687
2760
  async updateCurrentUser(userExtern) {
2761
+ if (_isFirebaseServerApp(this.app)) {
2762
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2763
+ }
2688
2764
  // The public updateCurrentUser method needs to make a copy of the user,
2689
2765
  // and also check that the project matches
2690
2766
  const user = userExtern
@@ -2711,6 +2787,9 @@ class AuthImpl {
2711
2787
  });
2712
2788
  }
2713
2789
  async signOut() {
2790
+ if (_isFirebaseServerApp(this.app)) {
2791
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2792
+ }
2714
2793
  // Run first, to block _setRedirectUser() if any callbacks fail.
2715
2794
  await this.beforeStateQueue.runMiddleware(null);
2716
2795
  // Clear the redirect user when signOut is called
@@ -2722,6 +2801,9 @@ class AuthImpl {
2722
2801
  return this._updateCurrentUser(null, /* skipBeforeStateCallbacks */ true);
2723
2802
  }
2724
2803
  setPersistence(persistence) {
2804
+ if (_isFirebaseServerApp(this.app)) {
2805
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
2806
+ }
2725
2807
  return this.queue(async () => {
2726
2808
  await this.assertedPersistence.setPersistence(_getInstance(persistence));
2727
2809
  });
@@ -5152,12 +5234,18 @@ function providerIdForResponse(response) {
5152
5234
  * If there is already an anonymous user signed in, that user will be returned; otherwise, a
5153
5235
  * new anonymous user identity will be created and returned.
5154
5236
  *
5237
+ * This method is not supported by {@link Auth} instances created with a
5238
+ * {@link @firebase/app#FirebaseServerApp}.
5239
+ *
5155
5240
  * @param auth - The {@link Auth} instance.
5156
5241
  *
5157
5242
  * @public
5158
5243
  */
5159
5244
  async function signInAnonymously(auth) {
5160
5245
  var _a;
5246
+ if (_isFirebaseServerApp(auth.app)) {
5247
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5248
+ }
5161
5249
  const authInternal = _castAuth(auth);
5162
5250
  await authInternal._initializationPromise;
5163
5251
  if ((_a = authInternal.currentUser) === null || _a === void 0 ? void 0 : _a.isAnonymous) {
@@ -5318,6 +5406,9 @@ async function _assertLinkedStatus(expected, user, provider) {
5318
5406
  */
5319
5407
  async function _reauthenticate(user, credential, bypassAuthState = false) {
5320
5408
  const { auth } = user;
5409
+ if (_isFirebaseServerApp(auth.app)) {
5410
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5411
+ }
5321
5412
  const operationType = "reauthenticate" /* OperationType.REAUTHENTICATE */;
5322
5413
  try {
5323
5414
  const response = await _logoutIfInvalidated(user, _processCredentialSavingMfaContextIfNecessary(auth, operationType, credential, user), bypassAuthState);
@@ -5354,6 +5445,9 @@ async function _reauthenticate(user, credential, bypassAuthState = false) {
5354
5445
  * limitations under the License.
5355
5446
  */
5356
5447
  async function _signInWithCredential(auth, credential, bypassAuthState = false) {
5448
+ if (_isFirebaseServerApp(auth.app)) {
5449
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5450
+ }
5357
5451
  const operationType = "signIn" /* OperationType.SIGN_IN */;
5358
5452
  const response = await _processCredentialSavingMfaContextIfNecessary(auth, operationType, credential);
5359
5453
  const userCredential = await UserCredentialImpl._fromIdTokenResponse(auth, operationType, response);
@@ -5368,6 +5462,9 @@ async function _signInWithCredential(auth, credential, bypassAuthState = false)
5368
5462
  * @remarks
5369
5463
  * An {@link AuthProvider} can be used to generate the credential.
5370
5464
  *
5465
+ * This method is not supported by {@link Auth} instances created with a
5466
+ * {@link @firebase/app#FirebaseServerApp}.
5467
+ *
5371
5468
  * @param auth - The {@link Auth} instance.
5372
5469
  * @param credential - The auth credential.
5373
5470
  *
@@ -5400,6 +5497,9 @@ async function linkWithCredential(user, credential) {
5400
5497
  * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
5401
5498
  * or a `TOKEN_EXPIRED` error.
5402
5499
  *
5500
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
5501
+ * created with a {@link @firebase/app#FirebaseServerApp}.
5502
+ *
5403
5503
  * @param user - The user.
5404
5504
  * @param credential - The auth credential.
5405
5505
  *
@@ -5456,12 +5556,18 @@ async function signInWithCustomToken$1(auth, request) {
5456
5556
  *
5457
5557
  * Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
5458
5558
  *
5559
+ * This method is not supported by {@link Auth} instances created with a
5560
+ * {@link @firebase/app#FirebaseServerApp}.
5561
+ *
5459
5562
  * @param auth - The {@link Auth} instance.
5460
5563
  * @param customToken - The custom token to sign in with.
5461
5564
  *
5462
5565
  * @public
5463
5566
  */
5464
5567
  async function signInWithCustomToken(auth, customToken) {
5568
+ if (_isFirebaseServerApp(auth.app)) {
5569
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5570
+ }
5465
5571
  const authInternal = _castAuth(auth);
5466
5572
  const response = await signInWithCustomToken$1(authInternal, {
5467
5573
  token: customToken,
@@ -5749,6 +5855,9 @@ async function verifyPasswordResetCode(auth, code) {
5749
5855
  *
5750
5856
  * User account creation can fail if the account already exists or the password is invalid.
5751
5857
  *
5858
+ * This method is not supported on {@link Auth} instances created with a
5859
+ * {@link @firebase/app#FirebaseServerApp}.
5860
+ *
5752
5861
  * Note: The email address acts as a unique identifier for the user and enables an email-based
5753
5862
  * password reset. This function will create a new user account and set the initial user password.
5754
5863
  *
@@ -5759,6 +5868,9 @@ async function verifyPasswordResetCode(auth, code) {
5759
5868
  * @public
5760
5869
  */
5761
5870
  async function createUserWithEmailAndPassword(auth, email, password) {
5871
+ if (_isFirebaseServerApp(auth.app)) {
5872
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5873
+ }
5762
5874
  const authInternal = _castAuth(auth);
5763
5875
  const request = {
5764
5876
  returnSecureToken: true,
@@ -5785,10 +5897,14 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5785
5897
  * When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
5786
5898
  * this method fails with "auth/invalid-credential" in case of an invalid email/password.
5787
5899
  *
5900
+ * This method is not supported on {@link Auth} instances created with a
5901
+ * {@link @firebase/app#FirebaseServerApp}.
5902
+ *
5788
5903
  * Note: The user's password is NOT the password used to access the user's email account. The
5789
5904
  * email address serves as a unique identifier for the user, and the password is used to access
5790
5905
  * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
5791
5906
  *
5907
+ *
5792
5908
  * @param auth - The {@link Auth} instance.
5793
5909
  * @param email - The users email address.
5794
5910
  * @param password - The users password.
@@ -5796,6 +5912,9 @@ async function createUserWithEmailAndPassword(auth, email, password) {
5796
5912
  * @public
5797
5913
  */
5798
5914
  function signInWithEmailAndPassword(auth, email, password) {
5915
+ if (_isFirebaseServerApp(auth.app)) {
5916
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
5917
+ }
5799
5918
  return signInWithCredential(getModularInstance(auth), EmailAuthProvider.credential(email, password)).catch(async (error) => {
5800
5919
  if (error.code === `auth/${"password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */}`) {
5801
5920
  void recachePasswordPolicy(auth);
@@ -5894,6 +6013,9 @@ function isSignInWithEmailLink(auth, emailLink) {
5894
6013
  *
5895
6014
  * Fails with an error if the email address is invalid or OTP in email link expires.
5896
6015
  *
6016
+ * This method is not supported by {@link Auth} instances created with a
6017
+ * {@link @firebase/app#FirebaseServerApp}.
6018
+ *
5897
6019
  * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
5898
6020
  *
5899
6021
  * @example
@@ -5917,6 +6039,7 @@ function isSignInWithEmailLink(auth, emailLink) {
5917
6039
  * }
5918
6040
  * ```
5919
6041
  *
6042
+ *
5920
6043
  * @param auth - The {@link Auth} instance.
5921
6044
  * @param email - The user's email address.
5922
6045
  * @param emailLink - The link sent to the user's email address.
@@ -5924,6 +6047,9 @@ function isSignInWithEmailLink(auth, emailLink) {
5924
6047
  * @public
5925
6048
  */
5926
6049
  async function signInWithEmailLink(auth, email, emailLink) {
6050
+ if (_isFirebaseServerApp(auth.app)) {
6051
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
6052
+ }
5927
6053
  const authModular = getModularInstance(auth);
5928
6054
  const credential = EmailAuthProvider.credentialWithLink(email, emailLink || _getCurrentUrl());
5929
6055
  // Check if the tenant ID in the email link matches the tenant ID on Auth
@@ -6170,6 +6296,9 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
6170
6296
  * An email will be sent to the original email address (if it was set) that allows to revoke the
6171
6297
  * email address change, in order to protect them from account hijacking.
6172
6298
  *
6299
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
6300
+ * created with a {@link @firebase/app#FirebaseServerApp}.
6301
+ *
6173
6302
  * Important: this is a security sensitive operation that requires the user to have recently signed
6174
6303
  * in. If this requirement isn't met, ask the user to authenticate again and then call
6175
6304
  * {@link reauthenticateWithCredential}.
@@ -6183,7 +6312,11 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
6183
6312
  * @public
6184
6313
  */
6185
6314
  function updateEmail(user, newEmail) {
6186
- return updateEmailOrPassword(getModularInstance(user), newEmail, null);
6315
+ const userInternal = getModularInstance(user);
6316
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
6317
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
6318
+ }
6319
+ return updateEmailOrPassword(userInternal, newEmail, null);
6187
6320
  }
6188
6321
  /**
6189
6322
  * Updates the user's password.
@@ -6360,7 +6493,8 @@ function getAdditionalUserInfo(userCredential) {
6360
6493
  * remembered or not. It also makes it easier to never persist the `Auth` state for applications
6361
6494
  * that are shared by other users or have sensitive data.
6362
6495
  *
6363
- * This method does not work in a Node.js environment.
6496
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
6497
+ * {@link @firebase/app#FirebaseServerApp}.
6364
6498
  *
6365
6499
  * @example
6366
6500
  * ```javascript
@@ -6506,6 +6640,9 @@ function useDeviceLanguage(auth) {
6506
6640
  * The operation fails with an error if the user to be updated belongs to a different Firebase
6507
6641
  * project.
6508
6642
  *
6643
+ * This method is not supported by {@link Auth} instances created with a
6644
+ * {@link @firebase/app#FirebaseServerApp}.
6645
+ *
6509
6646
  * @param auth - The {@link Auth} instance.
6510
6647
  * @param user - The new {@link User}.
6511
6648
  *
@@ -6517,6 +6654,10 @@ function updateCurrentUser(auth, user) {
6517
6654
  /**
6518
6655
  * Signs out the current user.
6519
6656
  *
6657
+ * @remarks
6658
+ * This method is not supported by {@link Auth} instances created with a
6659
+ * {@link @firebase/app#FirebaseServerApp}.
6660
+ *
6520
6661
  * @param auth - The {@link Auth} instance.
6521
6662
  *
6522
6663
  * @public
@@ -6774,7 +6915,7 @@ function multiFactor(user) {
6774
6915
  }
6775
6916
 
6776
6917
  var name = "@firebase/auth";
6777
- var version = "1.6.2";
6918
+ var version = "1.7.0-canary.42fcdfe4c";
6778
6919
 
6779
6920
  /**
6780
6921
  * @license
@@ -7185,5 +7326,5 @@ function _isEmptyString(input) {
7185
7326
  return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
7186
7327
  }
7187
7328
 
7188
- export { TwitterAuthProvider as $, ActionCodeOperation as A, updateCurrentUser as B, signOut as C, revokeAccessToken as D, deleteUser as E, FactorId as F, debugErrorMap as G, prodErrorMap as H, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as I, initializeAuth as J, connectAuthEmulator as K, AuthCredential as L, EmailAuthCredential as M, OAuthCredential as N, OperationType as O, PhoneAuthProvider as P, PhoneAuthCredential as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, inMemoryPersistence as U, EmailAuthProvider as V, FacebookAuthProvider as W, GoogleAuthProvider as X, GithubAuthProvider as Y, OAuthProvider as Z, SAMLAuthProvider as _, browserSessionPersistence as a, signInAnonymously as a0, signInWithCredential as a1, linkWithCredential as a2, reauthenticateWithCredential as a3, signInWithCustomToken as a4, sendPasswordResetEmail as a5, confirmPasswordReset as a6, applyActionCode as a7, checkActionCode as a8, verifyPasswordResetCode as a9, _fail as aA, debugAssert as aB, _persistenceKeyName as aC, _castAuth as aD, FederatedAuthProvider as aE, BaseOAuthProvider as aF, _emulatorUrl as aG, _performApiRequest as aH, _isIOS as aI, _isAndroid as aJ, _isIOS7Or8 as aK, _createError as aL, _isIframe as aM, _isMobileBrowser as aN, _isIE10 as aO, _isSafari as aP, UserImpl as aQ, AuthImpl as aR, _getClientVersion as aS, FetchProvider as aT, SAMLAuthCredential as aU, createUserWithEmailAndPassword as aa, signInWithEmailAndPassword as ab, sendSignInLinkToEmail as ac, isSignInWithEmailLink as ad, signInWithEmailLink as ae, fetchSignInMethodsForEmail as af, sendEmailVerification as ag, verifyBeforeUpdateEmail as ah, ActionCodeURL as ai, parseActionCodeURL as aj, updateProfile as ak, updateEmail as al, updatePassword as am, getIdToken as an, getIdTokenResult as ao, unlink as ap, getAdditionalUserInfo as aq, reload as ar, getMultiFactorResolver as as, multiFactor as at, _getInstance as au, _assert as av, _signInWithCredential as aw, _reauthenticate as ax, _link as ay, signInWithIdp as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, initializeRecaptchaConfig as t, updatePhoneNumber as u, validatePassword as v, onIdTokenChanged as w, beforeAuthStateChanged as x, onAuthStateChanged as y, useDeviceLanguage as z };
7189
- //# sourceMappingURL=totp-56a8eeec.js.map
7329
+ export { TwitterAuthProvider as $, ActionCodeOperation as A, updateCurrentUser as B, signOut as C, revokeAccessToken as D, deleteUser as E, FactorId as F, debugErrorMap as G, prodErrorMap as H, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as I, initializeAuth as J, connectAuthEmulator as K, AuthCredential as L, EmailAuthCredential as M, OAuthCredential as N, OperationType as O, PhoneAuthProvider as P, PhoneAuthCredential as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, inMemoryPersistence as U, EmailAuthProvider as V, FacebookAuthProvider as W, GoogleAuthProvider as X, GithubAuthProvider as Y, OAuthProvider as Z, SAMLAuthProvider as _, browserSessionPersistence as a, signInAnonymously as a0, signInWithCredential as a1, linkWithCredential as a2, reauthenticateWithCredential as a3, signInWithCustomToken as a4, sendPasswordResetEmail as a5, confirmPasswordReset as a6, applyActionCode as a7, checkActionCode as a8, verifyPasswordResetCode as a9, _fail as aA, debugAssert as aB, _persistenceKeyName as aC, _serverAppCurrentUserOperationNotSupportedError as aD, _castAuth as aE, FederatedAuthProvider as aF, BaseOAuthProvider as aG, _emulatorUrl as aH, _performApiRequest as aI, _isIOS as aJ, _isAndroid as aK, _isIOS7Or8 as aL, _createError as aM, _isIframe as aN, _isMobileBrowser as aO, _isIE10 as aP, _isSafari as aQ, UserImpl as aR, AuthImpl as aS, _getClientVersion as aT, FetchProvider as aU, SAMLAuthCredential as aV, createUserWithEmailAndPassword as aa, signInWithEmailAndPassword as ab, sendSignInLinkToEmail as ac, isSignInWithEmailLink as ad, signInWithEmailLink as ae, fetchSignInMethodsForEmail as af, sendEmailVerification as ag, verifyBeforeUpdateEmail as ah, ActionCodeURL as ai, parseActionCodeURL as aj, updateProfile as ak, updateEmail as al, updatePassword as am, getIdToken as an, getIdTokenResult as ao, unlink as ap, getAdditionalUserInfo as aq, reload as ar, getMultiFactorResolver as as, multiFactor as at, _getInstance as au, _assert as av, _signInWithCredential as aw, _reauthenticate as ax, _link as ay, signInWithIdp as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, initializeRecaptchaConfig as t, updatePhoneNumber as u, validatePassword as v, onIdTokenChanged as w, beforeAuthStateChanged as x, onAuthStateChanged as y, useDeviceLanguage as z };
7330
+ //# sourceMappingURL=totp-4d1c9ab1.js.map