@hexclave/next 1.0.123 → 1.0.126

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 (169) hide show
  1. package/dist/{admin-app-impl-MncU_Oxy.d.ts → admin-app-impl-CjDjJ3PS.d.ts} +29 -13
  2. package/dist/admin-app-impl-CjDjJ3PS.d.ts.map +1 -0
  3. package/dist/clickmap/clickmap-core.d.ts +1 -1
  4. package/dist/clickmap/index.d.ts +1 -1
  5. package/dist/{client-app-B0cTytS5.d.ts → client-app-jAjrgwSh.d.ts} +34 -6
  6. package/dist/client-app-jAjrgwSh.d.ts.map +1 -0
  7. package/dist/{common-B2gkWlXX.d.ts → common-BjAI7WW6.d.ts} +15 -3
  8. package/dist/common-BjAI7WW6.d.ts.map +1 -0
  9. package/dist/{common-BK_sydxF.d.ts → common-DWfeER0s.d.ts} +2 -2
  10. package/dist/{common-BK_sydxF.d.ts.map → common-DWfeER0s.d.ts.map} +1 -1
  11. package/dist/components/message-cards/predefined-message-card.js +4 -2
  12. package/dist/components/message-cards/predefined-message-card.js.map +1 -1
  13. package/dist/components/selected-team-switcher.d.ts +1 -1
  14. package/dist/components/team-icon.d.ts +1 -1
  15. package/dist/components/team-switcher.d.ts +1 -1
  16. package/dist/components/user-button.js +9 -9
  17. package/dist/components/user-button.js.map +1 -1
  18. package/dist/components/user-button.test.d.ts +1 -0
  19. package/dist/components/user-button.test.js +71 -0
  20. package/dist/components/user-button.test.js.map +1 -0
  21. package/dist/components-page/account-settings/payments/payments-page.d.ts +1 -1
  22. package/dist/components-page/account-settings/payments/payments-panel.d.ts +1 -1
  23. package/dist/components-page/account-settings/settings/sign-out-section.d.ts +1 -1
  24. package/dist/components-page/account-settings/settings/sign-out-section.d.ts.map +1 -1
  25. package/dist/components-page/account-settings/settings/sign-out-section.js +4 -1
  26. package/dist/components-page/account-settings/settings/sign-out-section.js.map +1 -1
  27. package/dist/components-page/account-settings/teams/leave-team-section.d.ts +1 -1
  28. package/dist/components-page/account-settings/teams/team-api-keys-section.d.ts +1 -1
  29. package/dist/components-page/account-settings/teams/team-display-name-section.d.ts +1 -1
  30. package/dist/components-page/account-settings/teams/team-member-invitation-section.d.ts +1 -1
  31. package/dist/components-page/account-settings/teams/team-member-list-section.d.ts +1 -1
  32. package/dist/components-page/account-settings/teams/team-page.d.ts +1 -1
  33. package/dist/components-page/account-settings/teams/team-profile-image-section.d.ts +1 -1
  34. package/dist/components-page/account-settings/teams/team-profile-user-section.d.ts +1 -1
  35. package/dist/components-page/hexclave-handler-client.d.ts +1 -1
  36. package/dist/components-page/hexclave-handler.d.ts +1 -1
  37. package/dist/components-page/onboarding.js +15 -13
  38. package/dist/components-page/onboarding.js.map +1 -1
  39. package/dist/components-page/onboarding.test.js +2 -1
  40. package/dist/components-page/onboarding.test.js.map +1 -1
  41. package/dist/dev-tool/dev-tool-core.d.ts +1 -1
  42. package/dist/dev-tool/index.d.ts +1 -1
  43. package/dist/esm/components/message-cards/predefined-message-card.js +4 -2
  44. package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
  45. package/dist/esm/components/user-button.js +9 -9
  46. package/dist/esm/components/user-button.js.map +1 -1
  47. package/dist/esm/components/user-button.test.d.ts +1 -0
  48. package/dist/esm/components/user-button.test.js +70 -0
  49. package/dist/esm/components/user-button.test.js.map +1 -0
  50. package/dist/esm/components-page/account-settings/settings/sign-out-section.d.ts +1 -1
  51. package/dist/esm/components-page/account-settings/settings/sign-out-section.d.ts.map +1 -1
  52. package/dist/esm/components-page/account-settings/settings/sign-out-section.js +4 -1
  53. package/dist/esm/components-page/account-settings/settings/sign-out-section.js.map +1 -1
  54. package/dist/esm/components-page/onboarding.js +15 -13
  55. package/dist/esm/components-page/onboarding.js.map +1 -1
  56. package/dist/esm/components-page/onboarding.test.js +2 -1
  57. package/dist/esm/components-page/onboarding.test.js.map +1 -1
  58. package/dist/esm/generated/quetzal-translations.d.ts +2 -2
  59. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +4 -4
  60. package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  61. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +18 -2
  62. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  63. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.d.ts +1 -0
  64. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js +382 -0
  65. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js.map +1 -0
  66. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.d.ts +1 -0
  67. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js +66 -0
  68. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js.map +1 -0
  69. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +66 -14
  70. package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  71. package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
  72. package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts +31 -0
  73. package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts.map +1 -0
  74. package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js +115 -0
  75. package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js.map +1 -0
  76. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts +16 -1
  77. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts.map +1 -1
  78. package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
  79. package/dist/esm/lib/hexclave-app/common.d.ts +14 -2
  80. package/dist/esm/lib/hexclave-app/common.d.ts.map +1 -1
  81. package/dist/esm/lib/hexclave-app/common.js +17 -1
  82. package/dist/esm/lib/hexclave-app/common.js.map +1 -1
  83. package/dist/esm/lib/hexclave-app/index.d.ts +2 -2
  84. package/dist/esm/lib/hexclave-app/index.js +2 -2
  85. package/dist/esm/lib/hexclave-app/users/index.d.ts +14 -1
  86. package/dist/esm/lib/hexclave-app/users/index.d.ts.map +1 -1
  87. package/dist/esm/lib/hexclave-app/users/index.js.map +1 -1
  88. package/dist/generated/quetzal-translations.d.ts +1 -1
  89. package/dist/{hexclave-provider-XVO5TbFD.d.ts → hexclave-provider-Br8j6WHN.d.ts} +3 -3
  90. package/dist/{hexclave-provider-XVO5TbFD.d.ts.map → hexclave-provider-Br8j6WHN.d.ts.map} +1 -1
  91. package/dist/{hooks-nqzRtl9S.d.ts → hooks-DyC8t1Sh.d.ts} +3 -3
  92. package/dist/{hooks-nqzRtl9S.d.ts.map → hooks-DyC8t1Sh.d.ts.map} +1 -1
  93. package/dist/{index-DbiyXho6.d.ts → index-CQ4kC6Cu.d.ts} +2 -2
  94. package/dist/{index-DbiyXho6.d.ts.map → index-CQ4kC6Cu.d.ts.map} +1 -1
  95. package/dist/{index-BDzsJvkD.d.ts → index-CWaynElx.d.ts} +3 -3
  96. package/dist/{index-BDzsJvkD.d.ts.map → index-CWaynElx.d.ts.map} +1 -1
  97. package/dist/{index-BSr2pd22.d.ts → index-FsS-NA9c.d.ts} +2 -2
  98. package/dist/{index-BSr2pd22.d.ts.map → index-FsS-NA9c.d.ts.map} +1 -1
  99. package/dist/index.d.ts +7 -7
  100. package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
  101. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
  102. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.d.ts +1 -0
  103. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js +381 -0
  104. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js.map +1 -0
  105. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.d.ts +1 -0
  106. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js +65 -0
  107. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js.map +1 -0
  108. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +65 -13
  109. package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
  110. package/dist/lib/hexclave-app/apps/implementations/common.d.ts +1 -1
  111. package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
  112. package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts +31 -0
  113. package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts.map +1 -0
  114. package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js +117 -0
  115. package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js.map +1 -0
  116. package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
  117. package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts +1 -1
  118. package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
  119. package/dist/lib/hexclave-app/apps/index.d.ts +1 -1
  120. package/dist/lib/hexclave-app/apps/interfaces/admin-app.d.ts +1 -1
  121. package/dist/lib/hexclave-app/apps/interfaces/client-app.d.ts +1 -1
  122. package/dist/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
  123. package/dist/lib/hexclave-app/apps/interfaces/server-app.d.ts +1 -1
  124. package/dist/lib/hexclave-app/common.d.ts +2 -2
  125. package/dist/lib/hexclave-app/common.js +19 -0
  126. package/dist/lib/hexclave-app/common.js.map +1 -1
  127. package/dist/lib/hexclave-app/customers/index.d.ts +1 -1
  128. package/dist/lib/hexclave-app/data-vault/index.d.ts +1 -1
  129. package/dist/lib/hexclave-app/index.d.ts +4 -4
  130. package/dist/lib/hexclave-app/index.js +18 -0
  131. package/dist/lib/hexclave-app/projects/index.d.ts +1 -1
  132. package/dist/lib/hexclave-app/teams/index.d.ts +1 -1
  133. package/dist/lib/hexclave-app/url-targets.d.ts +1 -1
  134. package/dist/lib/hexclave-app/users/index.d.ts +1 -1
  135. package/dist/lib/hexclave-app/users/index.js.map +1 -1
  136. package/dist/lib/hooks.d.ts +1 -1
  137. package/dist/providers/hexclave-context.d.ts +1 -1
  138. package/dist/providers/hexclave-provider-client.d.ts +1 -1
  139. package/dist/providers/hexclave-provider.d.ts +1 -1
  140. package/dist/providers/translation-provider.d.ts +1 -1
  141. package/dist/pushed-config-error-overlay/index.d.ts +1 -1
  142. package/dist/{quetzal-translations-CwNB-iql.d.ts → quetzal-translations-XeH3zQ9l.d.ts} +3 -3
  143. package/dist/{quetzal-translations-CwNB-iql.d.ts.map → quetzal-translations-XeH3zQ9l.d.ts.map} +1 -1
  144. package/dist/{redirect-page-urls-ofcg3AYr.d.ts → redirect-page-urls-CnGvn0UJ.d.ts} +2 -2
  145. package/dist/{redirect-page-urls-ofcg3AYr.d.ts.map → redirect-page-urls-CnGvn0UJ.d.ts.map} +1 -1
  146. package/dist/tanstack-start-server-context.d.ts +804 -485
  147. package/dist/tanstack-start-server-context.d.ts.map +1 -1
  148. package/dist/{translation-provider-C0uPBd41.d.ts → translation-provider-WOaZXqAz.d.ts} +2 -2
  149. package/dist/{translation-provider-C0uPBd41.d.ts.map → translation-provider-WOaZXqAz.d.ts.map} +1 -1
  150. package/dist/{url-targets-CWO0mjTr.d.ts → url-targets-DbhzuQtY.d.ts} +2 -2
  151. package/dist/{url-targets-CWO0mjTr.d.ts.map → url-targets-DbhzuQtY.d.ts.map} +1 -1
  152. package/package.json +4 -4
  153. package/src/components/message-cards/predefined-message-card.tsx +4 -2
  154. package/src/components/user-button.test.tsx +87 -0
  155. package/src/components/user-button.tsx +9 -9
  156. package/src/components-page/account-settings/settings/sign-out-section.tsx +9 -1
  157. package/src/components-page/onboarding.test.tsx +1 -0
  158. package/src/components-page/onboarding.tsx +16 -13
  159. package/src/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.ts +425 -0
  160. package/src/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.ts +79 -0
  161. package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +124 -13
  162. package/src/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.ts +190 -0
  163. package/src/lib/hexclave-app/apps/interfaces/client-app.ts +17 -0
  164. package/src/lib/hexclave-app/common.ts +33 -0
  165. package/src/lib/hexclave-app/index.ts +4 -0
  166. package/src/lib/hexclave-app/users/index.ts +13 -1
  167. package/dist/admin-app-impl-MncU_Oxy.d.ts.map +0 -1
  168. package/dist/client-app-B0cTytS5.d.ts.map +0 -1
  169. package/dist/common-B2gkWlXX.d.ts.map +0 -1
@@ -18,7 +18,6 @@ let _hexclave_shared_dist_utils_redirect_urls = require("@hexclave/shared/dist/u
18
18
  let _hexclave_shared_dist_utils_bytes = require("@hexclave/shared/dist/utils/bytes");
19
19
  let ______common_js = require("../../common.js");
20
20
  let ______projects_index_js = require("../../projects/index.js");
21
- let _hexclave_shared_dist_sessions = require("@hexclave/shared/dist/sessions");
22
21
  let _hexclave_shared_dist_utils_stores = require("@hexclave/shared/dist/utils/stores");
23
22
  let __redirect_page_urls_js = require("./redirect-page-urls.js");
24
23
  let _hexclave_shared_dist_utils_browser_action_snippets = require("@hexclave/shared/dist/utils/browser-action-snippets");
@@ -42,6 +41,7 @@ let ______teams_index_js = require("../../teams/index.js");
42
41
  let ______url_targets_js = require("../../url-targets.js");
43
42
  let ______users_index_js = require("../../users/index.js");
44
43
  let __event_tracker_js = require("./event-tracker.js");
44
+ let __external_token_store_session_adapter_js = require("./external-token-store-session-adapter.js");
45
45
  let __redirect_back_state_js = require("./redirect-back-state.js");
46
46
  let __redirect_loop_breaker_js = require("./redirect-loop-breaker.js");
47
47
  let __session_refresh_subscription_js = require("./session-refresh-subscription.js");
@@ -150,6 +150,9 @@ function throwSetupError(error) {
150
150
  (0, ____________setup_error_overlay_index_js.showSetupErrorOverlay)(error);
151
151
  throw error;
152
152
  }
153
+ function createAnalyticsAppDisabledOnProjectError() {
154
+ return /* @__PURE__ */ new Error("initAnalytics() was called, but the Analytics app is not enabled on this Hexclave project, so the backend rejects all analytics uploads. Enable the Analytics app in the Hexclave dashboard (or in hexclave.config.ts), or remove the initAnalytics() call if this is intentional.");
155
+ }
153
156
  function getRedirectHelperInstruction(handlerName) {
154
157
  if (handlerName === "handler") return "Use a page-specific redirect helper such as app.redirectToSignIn() instead.";
155
158
  return `Use app.${`redirectTo${handlerName.slice(0, 1).toUpperCase()}${handlerName.slice(1)}`}() instead.`;
@@ -310,6 +313,8 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
310
313
  this._uniqueIdentifier = void 0;
311
314
  this._sessionRecorder = null;
312
315
  this._eventTracker = null;
316
+ this._initAnalyticsCalled = false;
317
+ this._analyticsAppDisabledOnProject = false;
313
318
  this._pendingSignOut = null;
314
319
  this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY = false;
315
320
  this._ownedAdminApps = new _hexclave_shared_dist_utils_maps.DependenciesMap();
@@ -516,6 +521,10 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
516
521
  }
517
522
  });
518
523
  }
524
+ this._externalTokenStoreSessionAdapter = new __external_token_store_session_adapter_js.ExternalTokenStoreSessionAdapter((sessionOptions) => this._interface.createSession(sessionOptions), async (providerId, token) => {
525
+ const exchange = await this._interface.exchangeExternalAuthToken(providerId, token);
526
+ return _hexclave_shared_dist_utils_results.Result.orThrow(exchange).accessToken;
527
+ });
519
528
  this._tokenStoreInit = resolvedOptions.tokenStore;
520
529
  this._redirectMethod = resolvedOptions.redirectMethod || ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() ? "window" : "none");
521
530
  this._redirectMethod = resolvedOptions.redirectMethod || "nextjs";
@@ -540,22 +549,22 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
540
549
  })) return await this._getSession();
541
550
  return (await this.getUser({ or: "anonymous" }))._internalSession;
542
551
  };
543
- const analyticsEnabled = this._analyticsOptions?.enabled !== false;
552
+ const recordsAnalytics = this._getAnalyticsDisabledReason() == null && (0, _hexclave_shared_dist_utils_env.isBrowserLike)();
544
553
  const sessionReplayOptions = (0, __session_replay_js.getSessionReplayOptions)(this._analyticsOptions);
545
- if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore() && sessionReplayOptions.enabled) {
554
+ if (recordsAnalytics && sessionReplayOptions.enabled) {
546
555
  this._sessionRecorder = new __session_replay_js.SessionRecorder({
547
556
  projectId: this.projectId,
548
557
  sendBatch: async (body, opts) => {
549
- return await this._interface.sendSessionReplayBatch(body, await getAnalyticsSession(), opts);
558
+ return this._handleAnalyticsUploadResult(await this._interface.sendSessionReplayBatch(body, await getAnalyticsSession(), opts));
550
559
  }
551
560
  }, sessionReplayOptions);
552
561
  this._sessionRecorder.start();
553
562
  }
554
- if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore()) {
563
+ if (recordsAnalytics) {
555
564
  this._eventTracker = new __event_tracker_js.EventTracker({
556
565
  projectId: this.projectId,
557
566
  sendBatch: async (body, opts) => {
558
- return await this._interface.sendAnalyticsEventBatch(body, await getAnalyticsSession(), opts);
567
+ return this._handleAnalyticsUploadResult(await this._interface.sendAnalyticsEventBatch(body, await getAnalyticsSession(), opts));
559
568
  }
560
569
  });
561
570
  this._eventTracker.start();
@@ -1130,6 +1139,9 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
1130
1139
  case "memory": return this._memoryTokenStore;
1131
1140
  default:
1132
1141
  if (tokenStoreInit === null) return (0, __common_js.createEmptyTokenStore)();
1142
+ else if (typeof tokenStoreInit === "object" && (0, __external_token_store_session_adapter_js.isExternalTokenStore)(tokenStoreInit)) return this._externalTokenStoreSessionAdapter.getOrCreateTokenStore(tokenStoreInit, (store, previousSessionKey) => {
1143
+ this._sessionsByTokenStoreAndSessionKey.get(store)?.get(previousSessionKey)?.suggestAccessTokenExpired();
1144
+ });
1133
1145
  else if (typeof tokenStoreInit === "object" && "headers" in tokenStoreInit) {
1134
1146
  if (this._requestTokenStores.has(tokenStoreInit)) return this._requestTokenStores.get(tokenStoreInit);
1135
1147
  const authorizationHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "authorization");
@@ -1176,27 +1188,27 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
1176
1188
  const cookieHelper = (0, _________cookie_js.createBrowserCookieHelper)();
1177
1189
  return this._getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit);
1178
1190
  }
1191
+ _getSessionKeyForTokenStore(tokenStore, tokenObj) {
1192
+ return this._externalTokenStoreSessionAdapter.getSessionKey(tokenStore, tokenObj);
1193
+ }
1179
1194
  /**
1180
1195
  * @param overrideTokenObj The tokens to build the session for, if they haven't been written to the token store yet
1181
1196
  * (so we can warm a sign-in's session before the token store publishes it).
1182
1197
  */
1183
1198
  _getSessionFromTokenStore(tokenStore, overrideTokenObj) {
1184
1199
  const tokenObj = overrideTokenObj ?? tokenStore.get();
1185
- const sessionKey = _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(tokenObj);
1200
+ const sessionKey = this._getSessionKeyForTokenStore(tokenStore, tokenObj);
1186
1201
  const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
1187
1202
  if (existing) return existing;
1188
- const session = this._interface.createSession({
1189
- refreshToken: tokenObj.refreshToken,
1190
- accessToken: tokenObj.accessToken
1191
- });
1203
+ const session = this._externalTokenStoreSessionAdapter.createSessionForTokenStore(tokenStore, tokenObj, sessionKey);
1192
1204
  session.onAccessTokenChange((newAccessToken) => {
1193
- tokenStore.update((old) => _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(old) === sessionKey ? {
1205
+ tokenStore.update((old) => this._getSessionKeyForTokenStore(tokenStore, old) === sessionKey ? {
1194
1206
  ...old,
1195
1207
  accessToken: newAccessToken?.token ?? null
1196
1208
  } : old);
1197
1209
  });
1198
1210
  session.onInvalidate(() => {
1199
- tokenStore.update((old) => _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(old) === sessionKey ? {
1211
+ tokenStore.update((old) => this._getSessionKeyForTokenStore(tokenStore, old) === sessionKey ? {
1200
1212
  ...old,
1201
1213
  accessToken: null,
1202
1214
  refreshToken: null
@@ -1227,6 +1239,7 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
1227
1239
  }
1228
1240
  async _signInToAccountWithTokens(tokens) {
1229
1241
  if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Invalid tokens object; can't sign in with this", { tokens });
1242
+ if (this.isExternalAuthApp()) throw new Error("This app authenticates through an external provider and cannot sign in with Hexclave tokens. Sign in through the provider instead.");
1230
1243
  const attemptId = ++this._signInAttemptCounter;
1231
1244
  const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper());
1232
1245
  const session = this._getSessionFromTokenStore(tokenStore, tokens);
@@ -1620,6 +1633,7 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
1620
1633
  emailAuthEnabled: crud.auth_with_email,
1621
1634
  otpAuthEnabled: crud.otp_auth_enabled,
1622
1635
  oauthProviders: crud.oauth_providers,
1636
+ externalAuthProviders: crud.external_auth_providers,
1623
1637
  passkeyAuthEnabled: crud.passkey_auth_enabled,
1624
1638
  isMultiFactorRequired: crud.requires_totp_mfa,
1625
1639
  isAnonymous: crud.is_anonymous,
@@ -2582,6 +2596,37 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
2582
2596
  }
2583
2597
  return crud && this._currentUserFromCrud(crud, session);
2584
2598
  }
2599
+ isExternalAuthApp() {
2600
+ return typeof this._tokenStoreInit === "object" && this._tokenStoreInit != null && (0, __external_token_store_session_adapter_js.isExternalTokenStore)(this._tokenStoreInit);
2601
+ }
2602
+ initAnalytics() {
2603
+ this._initAnalyticsCalled = true;
2604
+ const disabledReason = this._getAnalyticsDisabledReason();
2605
+ if (disabledReason != null) throw new Error(`initAnalytics() was called, but this Hexclave app will not record analytics because ${disabledReason}. Remove the initAnalytics() call if this is intentional.`);
2606
+ if (this._analyticsAppDisabledOnProject) throw createAnalyticsAppDisabledOnProjectError();
2607
+ if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._eventTracker == null) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("initAnalytics() was called in the browser and _getAnalyticsDisabledReason() returned null, but the constructor did not start the event tracker. The two must agree on when analytics are recorded.");
2608
+ }
2609
+ /**
2610
+ * Returns why this app will never record analytics, or null if it records them whenever it runs in a browser. The
2611
+ * constructor and initAnalytics() both use this, so that the conditions under which analytics start and the
2612
+ * conditions under which initAnalytics() throws can't drift apart.
2613
+ *
2614
+ * Whether the Analytics app is enabled on the project is not part of this, as the client only learns that once the
2615
+ * backend rejects an upload; see _handleAnalyticsUploadResult.
2616
+ */
2617
+ _getAnalyticsDisabledReason() {
2618
+ if (this._analyticsOptions?.enabled === false) return "the `analytics.enabled` constructor option is set to false";
2619
+ if (this._options.automaticSideEffects === false) return "the `automaticSideEffects` constructor option is set to false, which also disables analytics";
2620
+ if (!this._hasPersistentTokenStore()) return "the `tokenStore` constructor option is null; analytics require a persistent token store such as \"cookie\" (or \"nextjs-cookie\" in Next.js)";
2621
+ return null;
2622
+ }
2623
+ _handleAnalyticsUploadResult(result) {
2624
+ if (result.status === "error" && (0, __session_replay_js.isAnalyticsNotEnabledError)(result.error) && !this._analyticsAppDisabledOnProject) {
2625
+ this._analyticsAppDisabledOnProject = true;
2626
+ if (this._initAnalyticsCalled) (0, _hexclave_shared_dist_utils_errors.captureError)("initAnalytics", createAnalyticsAppDisabledOnProjectError());
2627
+ }
2628
+ return result;
2629
+ }
2585
2630
  useUser(options) {
2586
2631
  if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
2587
2632
  this._ensurePersistentTokenStore(options?.tokenStore);
@@ -2631,6 +2676,7 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
2631
2676
  primaryEmail: accessToken.payload.email,
2632
2677
  displayName: accessToken.payload.name,
2633
2678
  primaryEmailVerified: accessToken.payload.email_verified,
2679
+ selectedTeamId: accessToken.payload.selected_team_id,
2634
2680
  isAnonymous,
2635
2681
  isMultiFactorRequired: accessToken.payload.requires_totp_mfa,
2636
2682
  isRestricted: accessToken.payload.is_restricted,
@@ -2640,11 +2686,14 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
2640
2686
  async _getPartialUserFromConvex(ctx) {
2641
2687
  const auth = await ctx.auth.getUserIdentity();
2642
2688
  if (!auth) return null;
2689
+ const selectedTeamId = auth.selected_team_id ?? null;
2690
+ if (selectedTeamId !== null && typeof selectedTeamId !== "string") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Expected the Convex selected_team_id claim to be a string or null.");
2643
2691
  return {
2644
2692
  id: auth.subject,
2645
2693
  displayName: auth.name ?? null,
2646
2694
  primaryEmail: auth.email ?? null,
2647
2695
  primaryEmailVerified: auth.email_verified,
2696
+ selectedTeamId,
2648
2697
  isAnonymous: auth.is_anonymous,
2649
2698
  isMultiFactorRequired: auth.requires_totp_mfa,
2650
2699
  isRestricted: auth.is_restricted,
@@ -2995,6 +3044,8 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
2995
3044
  const previousSignOut = this._pendingSignOut;
2996
3045
  const signOutOperation = (async () => {
2997
3046
  await previousSignOut;
3047
+ const externalTokenStore = this._externalTokenStoreSessionAdapter.getExternalTokenStoreForSession(session);
3048
+ if (externalTokenStore != null) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Cannot sign out an externally authenticated session through Hexclave. Sign out through the ${externalTokenStore.providerId} provider instead.`);
2998
3049
  await this._interface.signOut(session);
2999
3050
  if (options?.redirectUrl) await this._redirectTo({
3000
3051
  url: options.redirectUrl,
@@ -3148,6 +3199,7 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
3148
3199
  return {
3149
3200
  toClientJson: () => {
3150
3201
  if (typeof this._redirectMethod !== "string") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot serialize to JSON from an application with a non-string redirect method");
3202
+ if (typeof this._tokenStoreInit === "object" && this._tokenStoreInit != null && (0, __external_token_store_session_adapter_js.isExternalTokenStore)(this._tokenStoreInit)) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot serialize an app with an external token store because its callbacks are not serializable. Construct this app in the client runtime instead.");
3151
3203
  const publishableClientKey = "publishableClientKey" in this._interface.options ? this._interface.options.publishableClientKey : void 0;
3152
3204
  return {
3153
3205
  baseUrl: this._options.baseUrl,