@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.
- package/dist/{admin-app-impl-MncU_Oxy.d.ts → admin-app-impl-CjDjJ3PS.d.ts} +29 -13
- package/dist/admin-app-impl-CjDjJ3PS.d.ts.map +1 -0
- package/dist/clickmap/clickmap-core.d.ts +1 -1
- package/dist/clickmap/index.d.ts +1 -1
- package/dist/{client-app-B0cTytS5.d.ts → client-app-jAjrgwSh.d.ts} +34 -6
- package/dist/client-app-jAjrgwSh.d.ts.map +1 -0
- package/dist/{common-B2gkWlXX.d.ts → common-BjAI7WW6.d.ts} +15 -3
- package/dist/common-BjAI7WW6.d.ts.map +1 -0
- package/dist/{common-BK_sydxF.d.ts → common-DWfeER0s.d.ts} +2 -2
- package/dist/{common-BK_sydxF.d.ts.map → common-DWfeER0s.d.ts.map} +1 -1
- package/dist/components/message-cards/predefined-message-card.js +4 -2
- package/dist/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/components/selected-team-switcher.d.ts +1 -1
- package/dist/components/team-icon.d.ts +1 -1
- package/dist/components/team-switcher.d.ts +1 -1
- package/dist/components/user-button.js +9 -9
- package/dist/components/user-button.js.map +1 -1
- package/dist/components/user-button.test.d.ts +1 -0
- package/dist/components/user-button.test.js +71 -0
- package/dist/components/user-button.test.js.map +1 -0
- package/dist/components-page/account-settings/payments/payments-page.d.ts +1 -1
- package/dist/components-page/account-settings/payments/payments-panel.d.ts +1 -1
- package/dist/components-page/account-settings/settings/sign-out-section.d.ts +1 -1
- package/dist/components-page/account-settings/settings/sign-out-section.d.ts.map +1 -1
- package/dist/components-page/account-settings/settings/sign-out-section.js +4 -1
- package/dist/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/leave-team-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-api-keys-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-display-name-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-member-invitation-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-member-list-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-page.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-profile-image-section.d.ts +1 -1
- package/dist/components-page/account-settings/teams/team-profile-user-section.d.ts +1 -1
- package/dist/components-page/hexclave-handler-client.d.ts +1 -1
- package/dist/components-page/hexclave-handler.d.ts +1 -1
- package/dist/components-page/onboarding.js +15 -13
- package/dist/components-page/onboarding.js.map +1 -1
- package/dist/components-page/onboarding.test.js +2 -1
- package/dist/components-page/onboarding.test.js.map +1 -1
- package/dist/dev-tool/dev-tool-core.d.ts +1 -1
- package/dist/dev-tool/index.d.ts +1 -1
- package/dist/esm/components/message-cards/predefined-message-card.js +4 -2
- package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/esm/components/user-button.js +9 -9
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/components/user-button.test.d.ts +1 -0
- package/dist/esm/components/user-button.test.js +70 -0
- package/dist/esm/components/user-button.test.js.map +1 -0
- package/dist/esm/components-page/account-settings/settings/sign-out-section.d.ts +1 -1
- package/dist/esm/components-page/account-settings/settings/sign-out-section.d.ts.map +1 -1
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js +4 -1
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/esm/components-page/onboarding.js +15 -13
- package/dist/esm/components-page/onboarding.js.map +1 -1
- package/dist/esm/components-page/onboarding.test.js +2 -1
- package/dist/esm/components-page/onboarding.test.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.d.ts +2 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +4 -4
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +18 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.d.ts +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js +382 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.d.ts +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js +66 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js +66 -14
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts +31 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js +115 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts +16 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/hexclave-app/common.d.ts +14 -2
- package/dist/esm/lib/hexclave-app/common.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/common.js +17 -1
- package/dist/esm/lib/hexclave-app/common.js.map +1 -1
- package/dist/esm/lib/hexclave-app/index.d.ts +2 -2
- package/dist/esm/lib/hexclave-app/index.js +2 -2
- package/dist/esm/lib/hexclave-app/users/index.d.ts +14 -1
- package/dist/esm/lib/hexclave-app/users/index.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/users/index.js.map +1 -1
- package/dist/generated/quetzal-translations.d.ts +1 -1
- package/dist/{hexclave-provider-XVO5TbFD.d.ts → hexclave-provider-Br8j6WHN.d.ts} +3 -3
- package/dist/{hexclave-provider-XVO5TbFD.d.ts.map → hexclave-provider-Br8j6WHN.d.ts.map} +1 -1
- package/dist/{hooks-nqzRtl9S.d.ts → hooks-DyC8t1Sh.d.ts} +3 -3
- package/dist/{hooks-nqzRtl9S.d.ts.map → hooks-DyC8t1Sh.d.ts.map} +1 -1
- package/dist/{index-DbiyXho6.d.ts → index-CQ4kC6Cu.d.ts} +2 -2
- package/dist/{index-DbiyXho6.d.ts.map → index-CQ4kC6Cu.d.ts.map} +1 -1
- package/dist/{index-BDzsJvkD.d.ts → index-CWaynElx.d.ts} +3 -3
- package/dist/{index-BDzsJvkD.d.ts.map → index-CWaynElx.d.ts.map} +1 -1
- package/dist/{index-BSr2pd22.d.ts → index-FsS-NA9c.d.ts} +2 -2
- package/dist/{index-BSr2pd22.d.ts.map → index-FsS-NA9c.d.ts.map} +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.d.ts +1 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js +381 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.js.map +1 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.d.ts +1 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js +65 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.js.map +1 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +65 -13
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
- package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts +31 -0
- package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.d.ts.map +1 -0
- package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js +117 -0
- package/dist/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.js.map +1 -0
- package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/index.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/interfaces/admin-app.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/interfaces/client-app.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/hexclave-app/apps/interfaces/server-app.d.ts +1 -1
- package/dist/lib/hexclave-app/common.d.ts +2 -2
- package/dist/lib/hexclave-app/common.js +19 -0
- package/dist/lib/hexclave-app/common.js.map +1 -1
- package/dist/lib/hexclave-app/customers/index.d.ts +1 -1
- package/dist/lib/hexclave-app/data-vault/index.d.ts +1 -1
- package/dist/lib/hexclave-app/index.d.ts +4 -4
- package/dist/lib/hexclave-app/index.js +18 -0
- package/dist/lib/hexclave-app/projects/index.d.ts +1 -1
- package/dist/lib/hexclave-app/teams/index.d.ts +1 -1
- package/dist/lib/hexclave-app/url-targets.d.ts +1 -1
- package/dist/lib/hexclave-app/users/index.d.ts +1 -1
- package/dist/lib/hexclave-app/users/index.js.map +1 -1
- package/dist/lib/hooks.d.ts +1 -1
- package/dist/providers/hexclave-context.d.ts +1 -1
- package/dist/providers/hexclave-provider-client.d.ts +1 -1
- package/dist/providers/hexclave-provider.d.ts +1 -1
- package/dist/providers/translation-provider.d.ts +1 -1
- package/dist/pushed-config-error-overlay/index.d.ts +1 -1
- package/dist/{quetzal-translations-CwNB-iql.d.ts → quetzal-translations-XeH3zQ9l.d.ts} +3 -3
- package/dist/{quetzal-translations-CwNB-iql.d.ts.map → quetzal-translations-XeH3zQ9l.d.ts.map} +1 -1
- package/dist/{redirect-page-urls-ofcg3AYr.d.ts → redirect-page-urls-CnGvn0UJ.d.ts} +2 -2
- package/dist/{redirect-page-urls-ofcg3AYr.d.ts.map → redirect-page-urls-CnGvn0UJ.d.ts.map} +1 -1
- package/dist/tanstack-start-server-context.d.ts +804 -485
- package/dist/tanstack-start-server-context.d.ts.map +1 -1
- package/dist/{translation-provider-C0uPBd41.d.ts → translation-provider-WOaZXqAz.d.ts} +2 -2
- package/dist/{translation-provider-C0uPBd41.d.ts.map → translation-provider-WOaZXqAz.d.ts.map} +1 -1
- package/dist/{url-targets-CWO0mjTr.d.ts → url-targets-DbhzuQtY.d.ts} +2 -2
- package/dist/{url-targets-CWO0mjTr.d.ts.map → url-targets-DbhzuQtY.d.ts.map} +1 -1
- package/package.json +4 -4
- package/src/components/message-cards/predefined-message-card.tsx +4 -2
- package/src/components/user-button.test.tsx +87 -0
- package/src/components/user-button.tsx +9 -9
- package/src/components-page/account-settings/settings/sign-out-section.tsx +9 -1
- package/src/components-page/onboarding.test.tsx +1 -0
- package/src/components-page/onboarding.tsx +16 -13
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.external-token-store.test.ts +425 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.init-analytics.test.ts +79 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +124 -13
- package/src/lib/hexclave-app/apps/implementations/external-token-store-session-adapter.ts +190 -0
- package/src/lib/hexclave-app/apps/interfaces/client-app.ts +17 -0
- package/src/lib/hexclave-app/common.ts +33 -0
- package/src/lib/hexclave-app/index.ts +4 -0
- package/src/lib/hexclave-app/users/index.ts +13 -1
- package/dist/admin-app-impl-MncU_Oxy.d.ts.map +0 -1
- package/dist/client-app-B0cTytS5.d.ts.map +0 -1
- 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
|
|
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 (
|
|
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 (
|
|
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 =
|
|
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.
|
|
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) =>
|
|
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) =>
|
|
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,
|