@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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var tslib = require('tslib');
4
- var util = require('@firebase/util');
5
4
  var app = require('@firebase/app');
5
+ var util = require('@firebase/util');
6
6
  var component = require('@firebase/component');
7
7
  var logger = require('@firebase/logger');
8
8
 
@@ -402,6 +402,9 @@ function _errorWithCustomMessage(auth, code, message) {
402
402
  appName: auth.name
403
403
  });
404
404
  }
405
+ function _serverAppCurrentUserOperationNotSupportedError(auth) {
406
+ 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');
407
+ }
405
408
  function _assertInstanceOf(auth, object, instance) {
406
409
  var constructorInstance = instance;
407
410
  if (!(object instanceof constructorInstance)) {
@@ -1689,16 +1692,21 @@ var StsTokenManager = /** @class */ (function () {
1689
1692
  : _tokenExpiresIn(response.idToken);
1690
1693
  this.updateTokensAndExpiration(response.idToken, response.refreshToken, expiresIn);
1691
1694
  };
1695
+ StsTokenManager.prototype.updateFromIdToken = function (idToken) {
1696
+ _assert(idToken.length !== 0, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
1697
+ var expiresIn = _tokenExpiresIn(idToken);
1698
+ this.updateTokensAndExpiration(idToken, null, expiresIn);
1699
+ };
1692
1700
  StsTokenManager.prototype.getToken = function (auth, forceRefresh) {
1693
1701
  if (forceRefresh === void 0) { forceRefresh = false; }
1694
1702
  return tslib.__awaiter(this, void 0, void 0, function () {
1695
1703
  return tslib.__generator(this, function (_a) {
1696
1704
  switch (_a.label) {
1697
1705
  case 0:
1698
- _assert(!this.accessToken || this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1699
1706
  if (!forceRefresh && this.accessToken && !this.isExpired) {
1700
1707
  return [2 /*return*/, this.accessToken];
1701
1708
  }
1709
+ _assert(this.refreshToken, auth, "user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */);
1702
1710
  if (!this.refreshToken) return [3 /*break*/, 2];
1703
1711
  return [4 /*yield*/, this.refresh(auth, this.refreshToken)];
1704
1712
  case 1:
@@ -1922,7 +1930,11 @@ var UserImpl = /** @class */ (function () {
1922
1930
  var idToken;
1923
1931
  return tslib.__generator(this, function (_a) {
1924
1932
  switch (_a.label) {
1925
- case 0: return [4 /*yield*/, this.getIdToken()];
1933
+ case 0:
1934
+ if (app._isFirebaseServerApp(this.auth.app)) {
1935
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this.auth))];
1936
+ }
1937
+ return [4 /*yield*/, this.getIdToken()];
1926
1938
  case 1:
1927
1939
  idToken = _a.sent();
1928
1940
  return [4 /*yield*/, _logoutIfInvalidated(this, deleteAccount(this.auth, { idToken: idToken }))];
@@ -2027,6 +2039,47 @@ var UserImpl = /** @class */ (function () {
2027
2039
  });
2028
2040
  });
2029
2041
  };
2042
+ /**
2043
+ * Initialize a User from an idToken server response
2044
+ * @param auth
2045
+ * @param idTokenResponse
2046
+ */
2047
+ UserImpl._fromGetAccountInfoResponse = function (auth, response, idToken) {
2048
+ return tslib.__awaiter(this, void 0, void 0, function () {
2049
+ var coreAccount, providerData, isAnonymous, stsTokenManager, user, updates;
2050
+ return tslib.__generator(this, function (_a) {
2051
+ coreAccount = response.users[0];
2052
+ _assert(coreAccount.localId !== undefined, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
2053
+ providerData = coreAccount.providerUserInfo !== undefined
2054
+ ? extractProviderData(coreAccount.providerUserInfo)
2055
+ : [];
2056
+ isAnonymous = !(coreAccount.email && coreAccount.passwordHash) && !(providerData === null || providerData === void 0 ? void 0 : providerData.length);
2057
+ stsTokenManager = new StsTokenManager();
2058
+ stsTokenManager.updateFromIdToken(idToken);
2059
+ user = new UserImpl({
2060
+ uid: coreAccount.localId,
2061
+ auth: auth,
2062
+ stsTokenManager: stsTokenManager,
2063
+ isAnonymous: isAnonymous
2064
+ });
2065
+ updates = {
2066
+ uid: coreAccount.localId,
2067
+ displayName: coreAccount.displayName || null,
2068
+ photoURL: coreAccount.photoUrl || null,
2069
+ email: coreAccount.email || null,
2070
+ emailVerified: coreAccount.emailVerified || false,
2071
+ phoneNumber: coreAccount.phoneNumber || null,
2072
+ tenantId: coreAccount.tenantId || null,
2073
+ providerData: providerData,
2074
+ metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
2075
+ isAnonymous: !(coreAccount.email && coreAccount.passwordHash) &&
2076
+ !(providerData === null || providerData === void 0 ? void 0 : providerData.length)
2077
+ };
2078
+ Object.assign(user, updates);
2079
+ return [2 /*return*/, user];
2080
+ });
2081
+ });
2082
+ };
2030
2083
  return UserImpl;
2031
2084
  }());
2032
2085
 
@@ -2928,13 +2981,59 @@ var AuthImpl = /** @class */ (function () {
2928
2981
  });
2929
2982
  });
2930
2983
  };
2984
+ AuthImpl.prototype.initializeCurrentUserFromIdToken = function (idToken) {
2985
+ return tslib.__awaiter(this, void 0, void 0, function () {
2986
+ var response, user, err_1;
2987
+ return tslib.__generator(this, function (_a) {
2988
+ switch (_a.label) {
2989
+ case 0:
2990
+ _a.trys.push([0, 4, , 6]);
2991
+ return [4 /*yield*/, getAccountInfo(this, { idToken: idToken })];
2992
+ case 1:
2993
+ response = _a.sent();
2994
+ return [4 /*yield*/, UserImpl._fromGetAccountInfoResponse(this, response, idToken)];
2995
+ case 2:
2996
+ user = _a.sent();
2997
+ return [4 /*yield*/, this.directlySetCurrentUser(user)];
2998
+ case 3:
2999
+ _a.sent();
3000
+ return [3 /*break*/, 6];
3001
+ case 4:
3002
+ err_1 = _a.sent();
3003
+ console.warn('FirebaseServerApp could not login user with provided authIdToken: ', err_1);
3004
+ return [4 /*yield*/, this.directlySetCurrentUser(null)];
3005
+ case 5:
3006
+ _a.sent();
3007
+ return [3 /*break*/, 6];
3008
+ case 6: return [2 /*return*/];
3009
+ }
3010
+ });
3011
+ });
3012
+ };
2931
3013
  AuthImpl.prototype.initializeCurrentUser = function (popupRedirectResolver) {
2932
3014
  var _a;
2933
3015
  return tslib.__awaiter(this, void 0, void 0, function () {
2934
- var previouslyStoredUser, futureCurrentUser, needsTocheckMiddleware, redirectUserEventId, storedUserEventId, result, e_2;
3016
+ var idToken_1, previouslyStoredUser, futureCurrentUser, needsTocheckMiddleware, redirectUserEventId, storedUserEventId, result, e_2;
3017
+ var _this = this;
2935
3018
  return tslib.__generator(this, function (_b) {
2936
3019
  switch (_b.label) {
2937
- case 0: return [4 /*yield*/, this.assertedPersistence.getCurrentUser()];
3020
+ case 0:
3021
+ if (app._isFirebaseServerApp(this.app)) {
3022
+ idToken_1 = this.app.settings.authIdToken;
3023
+ if (idToken_1) {
3024
+ // Start the auth operation in the next tick to allow a moment for the customer's app to
3025
+ // attach an emulator, if desired.
3026
+ return [2 /*return*/, new Promise(function (resolve) {
3027
+ setTimeout(function () {
3028
+ return _this.initializeCurrentUserFromIdToken(idToken_1).then(resolve, resolve);
3029
+ });
3030
+ })];
3031
+ }
3032
+ else {
3033
+ return [2 /*return*/, this.directlySetCurrentUser(null)];
3034
+ }
3035
+ }
3036
+ return [4 /*yield*/, this.assertedPersistence.getCurrentUser()];
2938
3037
  case 1:
2939
3038
  previouslyStoredUser = (_b.sent());
2940
3039
  futureCurrentUser = previouslyStoredUser;
@@ -3076,6 +3175,9 @@ var AuthImpl = /** @class */ (function () {
3076
3175
  return tslib.__awaiter(this, void 0, void 0, function () {
3077
3176
  var user;
3078
3177
  return tslib.__generator(this, function (_a) {
3178
+ if (app._isFirebaseServerApp(this.app)) {
3179
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this))];
3180
+ }
3079
3181
  user = userExtern
3080
3182
  ? util.getModularInstance(userExtern)
3081
3183
  : null;
@@ -3123,9 +3225,12 @@ var AuthImpl = /** @class */ (function () {
3123
3225
  return tslib.__awaiter(this, void 0, void 0, function () {
3124
3226
  return tslib.__generator(this, function (_a) {
3125
3227
  switch (_a.label) {
3126
- case 0:
3127
- // Run first, to block _setRedirectUser() if any callbacks fail.
3128
- return [4 /*yield*/, this.beforeStateQueue.runMiddleware(null)];
3228
+ case 0:
3229
+ if (app._isFirebaseServerApp(this.app)) {
3230
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this))];
3231
+ }
3232
+ // Run first, to block _setRedirectUser() if any callbacks fail.
3233
+ return [4 /*yield*/, this.beforeStateQueue.runMiddleware(null)];
3129
3234
  case 1:
3130
3235
  // Run first, to block _setRedirectUser() if any callbacks fail.
3131
3236
  _a.sent();
@@ -3144,6 +3249,9 @@ var AuthImpl = /** @class */ (function () {
3144
3249
  };
3145
3250
  AuthImpl.prototype.setPersistence = function (persistence) {
3146
3251
  var _this = this;
3252
+ if (app._isFirebaseServerApp(this.app)) {
3253
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(this));
3254
+ }
3147
3255
  return this.queue(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
3148
3256
  return tslib.__generator(this, function (_a) {
3149
3257
  switch (_a.label) {
@@ -5931,6 +6039,9 @@ function providerIdForResponse(response) {
5931
6039
  * If there is already an anonymous user signed in, that user will be returned; otherwise, a
5932
6040
  * new anonymous user identity will be created and returned.
5933
6041
  *
6042
+ * This method is not supported by {@link Auth} instances created with a
6043
+ * {@link @firebase/app#FirebaseServerApp}.
6044
+ *
5934
6045
  * @param auth - The {@link Auth} instance.
5935
6046
  *
5936
6047
  * @public
@@ -5942,6 +6053,9 @@ function signInAnonymously(auth) {
5942
6053
  return tslib.__generator(this, function (_b) {
5943
6054
  switch (_b.label) {
5944
6055
  case 0:
6056
+ if (app._isFirebaseServerApp(auth.app)) {
6057
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
6058
+ }
5945
6059
  authInternal = _castAuth(auth);
5946
6060
  return [4 /*yield*/, authInternal._initializationPromise];
5947
6061
  case 1:
@@ -6173,6 +6287,9 @@ function _reauthenticate(user, credential, bypassAuthState) {
6173
6287
  switch (_a.label) {
6174
6288
  case 0:
6175
6289
  auth = user.auth;
6290
+ if (app._isFirebaseServerApp(auth.app)) {
6291
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
6292
+ }
6176
6293
  operationType = "reauthenticate" /* OperationType.REAUTHENTICATE */;
6177
6294
  _a.label = 1;
6178
6295
  case 1:
@@ -6222,6 +6339,9 @@ function _signInWithCredential(auth, credential, bypassAuthState) {
6222
6339
  return tslib.__generator(this, function (_a) {
6223
6340
  switch (_a.label) {
6224
6341
  case 0:
6342
+ if (app._isFirebaseServerApp(auth.app)) {
6343
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
6344
+ }
6225
6345
  operationType = "signIn" /* OperationType.SIGN_IN */;
6226
6346
  return [4 /*yield*/, _processCredentialSavingMfaContextIfNecessary(auth, operationType, credential)];
6227
6347
  case 1:
@@ -6245,6 +6365,9 @@ function _signInWithCredential(auth, credential, bypassAuthState) {
6245
6365
  * @remarks
6246
6366
  * An {@link AuthProvider} can be used to generate the credential.
6247
6367
  *
6368
+ * This method is not supported by {@link Auth} instances created with a
6369
+ * {@link @firebase/app#FirebaseServerApp}.
6370
+ *
6248
6371
  * @param auth - The {@link Auth} instance.
6249
6372
  * @param credential - The auth credential.
6250
6373
  *
@@ -6291,6 +6414,9 @@ function linkWithCredential(user, credential) {
6291
6414
  * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
6292
6415
  * or a `TOKEN_EXPIRED` error.
6293
6416
  *
6417
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
6418
+ * created with a {@link @firebase/app#FirebaseServerApp}.
6419
+ *
6294
6420
  * @param user - The user.
6295
6421
  * @param credential - The auth credential.
6296
6422
  *
@@ -6355,6 +6481,9 @@ function signInWithCustomToken$1(auth, request) {
6355
6481
  *
6356
6482
  * Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
6357
6483
  *
6484
+ * This method is not supported by {@link Auth} instances created with a
6485
+ * {@link @firebase/app#FirebaseServerApp}.
6486
+ *
6358
6487
  * @param auth - The {@link Auth} instance.
6359
6488
  * @param customToken - The custom token to sign in with.
6360
6489
  *
@@ -6366,6 +6495,9 @@ function signInWithCustomToken(auth, customToken) {
6366
6495
  return tslib.__generator(this, function (_a) {
6367
6496
  switch (_a.label) {
6368
6497
  case 0:
6498
+ if (app._isFirebaseServerApp(auth.app)) {
6499
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
6500
+ }
6369
6501
  authInternal = _castAuth(auth);
6370
6502
  return [4 /*yield*/, signInWithCustomToken$1(authInternal, {
6371
6503
  token: customToken,
@@ -6722,6 +6854,9 @@ function verifyPasswordResetCode(auth, code) {
6722
6854
  *
6723
6855
  * User account creation can fail if the account already exists or the password is invalid.
6724
6856
  *
6857
+ * This method is not supported on {@link Auth} instances created with a
6858
+ * {@link @firebase/app#FirebaseServerApp}.
6859
+ *
6725
6860
  * Note: The email address acts as a unique identifier for the user and enables an email-based
6726
6861
  * password reset. This function will create a new user account and set the initial user password.
6727
6862
  *
@@ -6737,6 +6872,9 @@ function createUserWithEmailAndPassword(auth, email, password) {
6737
6872
  return tslib.__generator(this, function (_a) {
6738
6873
  switch (_a.label) {
6739
6874
  case 0:
6875
+ if (app._isFirebaseServerApp(auth.app)) {
6876
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
6877
+ }
6740
6878
  authInternal = _castAuth(auth);
6741
6879
  request = {
6742
6880
  returnSecureToken: true,
@@ -6772,10 +6910,14 @@ function createUserWithEmailAndPassword(auth, email, password) {
6772
6910
  * When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
6773
6911
  * this method fails with "auth/invalid-credential" in case of an invalid email/password.
6774
6912
  *
6913
+ * This method is not supported on {@link Auth} instances created with a
6914
+ * {@link @firebase/app#FirebaseServerApp}.
6915
+ *
6775
6916
  * Note: The user's password is NOT the password used to access the user's email account. The
6776
6917
  * email address serves as a unique identifier for the user, and the password is used to access
6777
6918
  * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
6778
6919
  *
6920
+ *
6779
6921
  * @param auth - The {@link Auth} instance.
6780
6922
  * @param email - The users email address.
6781
6923
  * @param password - The users password.
@@ -6784,6 +6926,9 @@ function createUserWithEmailAndPassword(auth, email, password) {
6784
6926
  */
6785
6927
  function signInWithEmailAndPassword(auth, email, password) {
6786
6928
  var _this = this;
6929
+ if (app._isFirebaseServerApp(auth.app)) {
6930
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth));
6931
+ }
6787
6932
  return signInWithCredential(util.getModularInstance(auth), EmailAuthProvider.credential(email, password)).catch(function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
6788
6933
  return tslib.__generator(this, function (_a) {
6789
6934
  if (error.code === "auth/".concat("password-does-not-meet-requirements" /* AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS */)) {
@@ -6895,6 +7040,9 @@ function isSignInWithEmailLink(auth, emailLink) {
6895
7040
  *
6896
7041
  * Fails with an error if the email address is invalid or OTP in email link expires.
6897
7042
  *
7043
+ * This method is not supported by {@link Auth} instances created with a
7044
+ * {@link @firebase/app#FirebaseServerApp}.
7045
+ *
6898
7046
  * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
6899
7047
  *
6900
7048
  * @example
@@ -6918,6 +7066,7 @@ function isSignInWithEmailLink(auth, emailLink) {
6918
7066
  * }
6919
7067
  * ```
6920
7068
  *
7069
+ *
6921
7070
  * @param auth - The {@link Auth} instance.
6922
7071
  * @param email - The user's email address.
6923
7072
  * @param emailLink - The link sent to the user's email address.
@@ -6928,6 +7077,9 @@ function signInWithEmailLink(auth, email, emailLink) {
6928
7077
  return tslib.__awaiter(this, void 0, void 0, function () {
6929
7078
  var authModular, credential;
6930
7079
  return tslib.__generator(this, function (_a) {
7080
+ if (app._isFirebaseServerApp(auth.app)) {
7081
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
7082
+ }
6931
7083
  authModular = util.getModularInstance(auth);
6932
7084
  credential = EmailAuthProvider.credentialWithLink(email, emailLink || _getCurrentUrl());
6933
7085
  // Check if the tenant ID in the email link matches the tenant ID on Auth
@@ -7241,6 +7393,9 @@ function updateProfile(user, _a) {
7241
7393
  * An email will be sent to the original email address (if it was set) that allows to revoke the
7242
7394
  * email address change, in order to protect them from account hijacking.
7243
7395
  *
7396
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
7397
+ * created with a {@link @firebase/app#FirebaseServerApp}.
7398
+ *
7244
7399
  * Important: this is a security sensitive operation that requires the user to have recently signed
7245
7400
  * in. If this requirement isn't met, ask the user to authenticate again and then call
7246
7401
  * {@link reauthenticateWithCredential}.
@@ -7254,7 +7409,11 @@ function updateProfile(user, _a) {
7254
7409
  * @public
7255
7410
  */
7256
7411
  function updateEmail(user, newEmail) {
7257
- return updateEmailOrPassword(util.getModularInstance(user), newEmail, null);
7412
+ var userInternal = util.getModularInstance(user);
7413
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
7414
+ return Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth));
7415
+ }
7416
+ return updateEmailOrPassword(userInternal, newEmail, null);
7258
7417
  }
7259
7418
  /**
7260
7419
  * Updates the user's password.
@@ -7459,7 +7618,8 @@ function getAdditionalUserInfo(userCredential) {
7459
7618
  * remembered or not. It also makes it easier to never persist the `Auth` state for applications
7460
7619
  * that are shared by other users or have sensitive data.
7461
7620
  *
7462
- * This method does not work in a Node.js environment.
7621
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
7622
+ * {@link @firebase/app#FirebaseServerApp}.
7463
7623
  *
7464
7624
  * @example
7465
7625
  * ```javascript
@@ -7610,6 +7770,9 @@ function useDeviceLanguage(auth) {
7610
7770
  * The operation fails with an error if the user to be updated belongs to a different Firebase
7611
7771
  * project.
7612
7772
  *
7773
+ * This method is not supported by {@link Auth} instances created with a
7774
+ * {@link @firebase/app#FirebaseServerApp}.
7775
+ *
7613
7776
  * @param auth - The {@link Auth} instance.
7614
7777
  * @param user - The new {@link User}.
7615
7778
  *
@@ -7621,6 +7784,10 @@ function updateCurrentUser(auth, user) {
7621
7784
  /**
7622
7785
  * Signs out the current user.
7623
7786
  *
7787
+ * @remarks
7788
+ * This method is not supported by {@link Auth} instances created with a
7789
+ * {@link @firebase/app#FirebaseServerApp}.
7790
+ *
7624
7791
  * @param auth - The {@link Auth} instance.
7625
7792
  *
7626
7793
  * @public
@@ -7969,7 +8136,7 @@ function multiFactor(user) {
7969
8136
  }
7970
8137
 
7971
8138
  var name = "@firebase/auth";
7972
- var version = "1.6.2";
8139
+ var version = "1.7.0-canary.42fcdfe4c";
7973
8140
 
7974
8141
  /**
7975
8142
  * @license
@@ -8882,7 +9049,8 @@ var ConfirmationResultImpl = /** @class */ (function () {
8882
9049
  * {@link RecaptchaVerifier} (like React Native), but you need to use a
8883
9050
  * third-party {@link ApplicationVerifier} implementation.
8884
9051
  *
8885
- * This method does not work in a Node.js environment.
9052
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
9053
+ * {@link @firebase/app#FirebaseServerApp}.
8886
9054
  *
8887
9055
  * @example
8888
9056
  * ```javascript
@@ -8905,6 +9073,9 @@ function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
8905
9073
  return tslib.__generator(this, function (_a) {
8906
9074
  switch (_a.label) {
8907
9075
  case 0:
9076
+ if (app._isFirebaseServerApp(auth.app)) {
9077
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(auth))];
9078
+ }
8908
9079
  authInternal = _castAuth(auth);
8909
9080
  return [4 /*yield*/, _verifyPhoneNumber(authInternal, phoneNumber, util.getModularInstance(appVerifier))];
8910
9081
  case 1:
@@ -8954,7 +9125,8 @@ function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
8954
9125
  * @remarks
8955
9126
  * Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
8956
9127
  *
8957
- * This method does not work in a Node.js environment.
9128
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
9129
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
8958
9130
  *
8959
9131
  * @param user - The user.
8960
9132
  * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
@@ -8969,6 +9141,9 @@ function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
8969
9141
  switch (_a.label) {
8970
9142
  case 0:
8971
9143
  userInternal = util.getModularInstance(user);
9144
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
9145
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth))];
9146
+ }
8972
9147
  return [4 /*yield*/, _verifyPhoneNumber(userInternal.auth, phoneNumber, util.getModularInstance(appVerifier))];
8973
9148
  case 1:
8974
9149
  verificationId = _a.sent();
@@ -9056,7 +9231,8 @@ function _verifyPhoneNumber(auth, options, verifier) {
9056
9231
  * Updates the user's phone number.
9057
9232
  *
9058
9233
  * @remarks
9059
- * This method does not work in a Node.js environment.
9234
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
9235
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
9060
9236
  *
9061
9237
  * @example
9062
9238
  * ```
@@ -9076,9 +9252,15 @@ function _verifyPhoneNumber(auth, options, verifier) {
9076
9252
  */
9077
9253
  function updatePhoneNumber(user, credential) {
9078
9254
  return tslib.__awaiter(this, void 0, void 0, function () {
9255
+ var userInternal;
9079
9256
  return tslib.__generator(this, function (_a) {
9080
9257
  switch (_a.label) {
9081
- case 0: return [4 /*yield*/, _link(util.getModularInstance(user), credential)];
9258
+ case 0:
9259
+ userInternal = util.getModularInstance(user);
9260
+ if (app._isFirebaseServerApp(userInternal.auth.app)) {
9261
+ return [2 /*return*/, Promise.reject(_serverAppCurrentUserOperationNotSupportedError(userInternal.auth))];
9262
+ }
9263
+ return [4 /*yield*/, _link(userInternal, credential)];
9082
9264
  case 1:
9083
9265
  _a.sent();
9084
9266
  return [2 /*return*/];
@@ -9574,6 +9756,7 @@ exports._logWarn = _logWarn;
9574
9756
  exports._performApiRequest = _performApiRequest;
9575
9757
  exports._persistenceKeyName = _persistenceKeyName;
9576
9758
  exports._reauthenticate = _reauthenticate;
9759
+ exports._serverAppCurrentUserOperationNotSupportedError = _serverAppCurrentUserOperationNotSupportedError;
9577
9760
  exports._setExternalJSProvider = _setExternalJSProvider;
9578
9761
  exports._setWindowLocation = _setWindowLocation;
9579
9762
  exports._signInWithCredential = _signInWithCredential;
@@ -9630,4 +9813,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
9630
9813
  exports.validatePassword = validatePassword;
9631
9814
  exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
9632
9815
  exports.verifyPasswordResetCode = verifyPasswordResetCode;
9633
- //# sourceMappingURL=index-8ee80bdc.js.map
9816
+ //# sourceMappingURL=index-bbdaa838.js.map