@hexclave/js 1.0.73 → 1.0.74
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-BVMjDLZU.d.ts → admin-app-impl-BgUMxiV3.d.ts} +10 -4
- package/dist/admin-app-impl-BgUMxiV3.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-D0wv_Di-.d.ts → client-app-WOX3pOo1.d.ts} +11 -3
- package/dist/{client-app-D0wv_Di-.d.ts.map → client-app-WOX3pOo1.d.ts.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/lib/auth.d.ts.map +1 -1
- package/dist/esm/lib/auth.js +1 -1
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/auth.test.js +2 -2
- package/dist/esm/lib/auth.test.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +3 -0
- 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.automatic-side-effects.test.d.ts +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.automatic-side-effects.test.js +102 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.automatic-side-effects.test.js.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +57 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +5 -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.js +44 -12
- 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/redirect-back-state.d.ts +13 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-back-state.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-back-state.js +15 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-back-state.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-back-state.test.js +25 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-back-state.test.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.js +67 -12
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.test.d.ts +1 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js +87 -0
- package/dist/esm/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js.map +1 -0
- package/dist/esm/lib/hexclave-app/apps/interfaces/client-app.d.ts +9 -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/utils/url.js +10 -2
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/esm/utils/url.test.d.ts +1 -0
- package/dist/esm/utils/url.test.js +28 -0
- package/dist/esm/utils/url.test.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +1 -1
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/auth.test.js +2 -2
- package/dist/lib/auth.test.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.automatic-side-effects.test.d.ts +1 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.automatic-side-effects.test.js +101 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.automatic-side-effects.test.js.map +1 -0
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +57 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js.map +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.js +43 -11
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
- package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-back-state.d.ts +13 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-back-state.d.ts.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-back-state.js +15 -0
- package/dist/lib/hexclave-app/apps/implementations/redirect-back-state.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-back-state.test.js +24 -0
- package/dist/lib/hexclave-app/apps/implementations/redirect-back-state.test.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.js +67 -12
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.test.d.ts +1 -0
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js +86 -0
- package/dist/lib/hexclave-app/apps/implementations/redirect-page-urls.test.js.map +1 -0
- 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/index.d.ts +1 -1
- 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/users/index.d.ts +1 -1
- package/dist/pushed-config-error-overlay/index.d.ts +1 -1
- package/dist/{redirect-page-urls-elbPx2J1.d.ts → redirect-page-urls-Cu5BRQwm.d.ts} +2 -1
- package/dist/redirect-page-urls-Cu5BRQwm.d.ts.map +1 -0
- package/dist/utils/url.js +10 -2
- package/dist/utils/url.js.map +1 -1
- package/dist/utils/url.test.d.ts +1 -0
- package/dist/utils/url.test.js +27 -0
- package/dist/utils/url.test.js.map +1 -0
- package/package.json +2 -2
- package/src/lib/auth.test.ts +2 -2
- package/src/lib/auth.ts +3 -1
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.automatic-side-effects.test.ts +126 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +75 -0
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +73 -16
- package/src/lib/hexclave-app/apps/implementations/redirect-back-state.test.ts +29 -1
- package/src/lib/hexclave-app/apps/implementations/redirect-back-state.ts +17 -0
- package/src/lib/hexclave-app/apps/implementations/redirect-page-urls.test.ts +119 -0
- package/src/lib/hexclave-app/apps/implementations/redirect-page-urls.ts +104 -12
- package/src/lib/hexclave-app/apps/interfaces/client-app.ts +12 -2
- package/src/utils/url.test.ts +54 -0
- package/src/utils/url.ts +12 -3
- package/dist/admin-app-impl-BVMjDLZU.d.ts.map +0 -1
- package/dist/redirect-page-urls-elbPx2J1.d.ts.map +0 -1
|
@@ -13,6 +13,7 @@ import { hexclaveAppInternalsSymbol } from "../../common.js";
|
|
|
13
13
|
import { adminProjectCreateOptionsToCrud } from "../../projects/index.js";
|
|
14
14
|
import { InternalSession } from "@hexclave/shared/dist/sessions";
|
|
15
15
|
import { Store, storeLock } from "@hexclave/shared/dist/utils/stores";
|
|
16
|
+
import { crossDomainAuthQueryParams, getCrossDomainHandoffParamsFromCurrentUrl, planRedirectToHandler } from "./redirect-page-urls.js";
|
|
16
17
|
import { parseJson } from "@hexclave/shared/dist/utils/json";
|
|
17
18
|
import { DependenciesMap } from "@hexclave/shared/dist/utils/maps";
|
|
18
19
|
import { BotChallengeExecutionFailedError, BotChallengeUserCancelledError, withBotChallengeFlow } from "@hexclave/shared/dist/utils/turnstile-flow";
|
|
@@ -27,18 +28,18 @@ import { apiKeyCreationOptionsToCrud } from "../../api-keys/index.js";
|
|
|
27
28
|
import { contactChannelCreateOptionsToCrud, contactChannelUpdateOptionsToCrud } from "../../contact-channels/index.js";
|
|
28
29
|
import { teamCreateOptionsToCrud, teamUpdateOptionsToCrud } from "../../teams/index.js";
|
|
29
30
|
import { buildCliAuthConfirmUrl, getHostedHandlerUrl, isHostedHandlerUrlForProject, resolveHandlerUrls } from "../../url-targets.js";
|
|
30
|
-
import { augmentUrlWithPersistedRedirectBackState, saveRedirectBackStateFromUrl } from "./redirect-back-state.js";
|
|
31
|
+
import { augmentUrlWithPersistedRedirectBackState, getRawAfterAuthReturnTo, saveRedirectBackStateFromUrl } from "./redirect-back-state.js";
|
|
31
32
|
import { recordRedirectAndThrowIfLoopDetected } from "./redirect-loop-breaker.js";
|
|
32
33
|
import { scopePasskeyAuthenticationToHostname, scopePasskeyRegistrationToHostname } from "../../passkey-rp-id.js";
|
|
33
34
|
import { userUpdateOptionsToCrud, withUserDestructureGuard } from "../../users/index.js";
|
|
34
35
|
import { EventTracker } from "./event-tracker.js";
|
|
35
|
-
import { crossDomainAuthQueryParams, getCrossDomainHandoffParamsFromCurrentUrl, planRedirectToHandler } from "./redirect-page-urls.js";
|
|
36
36
|
import { SessionRecorder, analyticsOptionsFromJson, analyticsOptionsToJson, getSessionReplayOptions } from "./session-replay.js";
|
|
37
37
|
import { mountClickmapOverlay } from "../../../../clickmap/index.js";
|
|
38
38
|
import { mountDevTool } from "../../../../dev-tool/index.js";
|
|
39
39
|
import { mountPushedConfigErrorOverlay } from "../../../../pushed-config-error-overlay/index.js";
|
|
40
40
|
//#region src/lib/hexclave-app/apps/implementations/client-app-impl.ts
|
|
41
41
|
const prefetchedCrossDomainHandoffTtlMs = 3300 * 1e3;
|
|
42
|
+
const oauthAfterCallbackRedirectUrlQueryParam = "after_callback_redirect_url";
|
|
42
43
|
const nestedCrossDomainAuthQueryParams = {
|
|
43
44
|
refreshTokenId: "stack_nested_cross_domain_auth_refresh_token_id",
|
|
44
45
|
callbackUrl: "stack_nested_cross_domain_auth_callback_url",
|
|
@@ -46,7 +47,7 @@ const nestedCrossDomainAuthQueryParams = {
|
|
|
46
47
|
state: "state",
|
|
47
48
|
codeChallenge: "code_challenge",
|
|
48
49
|
codeChallengeMethod: "code_challenge_method",
|
|
49
|
-
afterCallbackRedirectUrl:
|
|
50
|
+
afterCallbackRedirectUrl: oauthAfterCallbackRedirectUrlQueryParam
|
|
50
51
|
};
|
|
51
52
|
function getRedirectHelperInstruction(handlerName) {
|
|
52
53
|
if (handlerName === "handler") return "Use a page-specific redirect helper such as app.redirectToSignIn() instead.";
|
|
@@ -383,15 +384,17 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
383
384
|
this._redirectMethod = resolvedOptions.redirectMethod || (isBrowserLike() ? "window" : "none");
|
|
384
385
|
this._urlOptions = resolvedOptions.urls ?? {};
|
|
385
386
|
this._oauthScopesOnSignIn = resolvedOptions.oauthScopesOnSignIn ?? {};
|
|
387
|
+
this._analyticsOptions = resolvedOptions.analytics;
|
|
388
|
+
if (extraOptions?.uniqueIdentifier !== void 0) this._uniqueIdentifier = extraOptions.uniqueIdentifier;
|
|
389
|
+
if (resolvedOptions.automaticSideEffects === false) return;
|
|
390
|
+
this._initializeAutomaticSideEffects(resolvedOptions);
|
|
391
|
+
}
|
|
392
|
+
_initializeAutomaticSideEffects(resolvedOptions) {
|
|
386
393
|
if (isBrowserLike() && (resolvedOptions.tokenStore === "cookie" || resolvedOptions.tokenStore === "nextjs-cookie")) {
|
|
387
394
|
runAsynchronously(this._trustedParentDomainCache.getOrWait([window.location.hostname], "write-only"));
|
|
388
395
|
this._ensureCrossSubdomainCookieExists();
|
|
389
396
|
}
|
|
390
|
-
if (
|
|
391
|
-
this._uniqueIdentifier = extraOptions.uniqueIdentifier;
|
|
392
|
-
this._initUniqueIdentifier();
|
|
393
|
-
}
|
|
394
|
-
this._analyticsOptions = resolvedOptions.analytics;
|
|
397
|
+
if (this._uniqueIdentifier !== void 0) this._initUniqueIdentifier();
|
|
395
398
|
const getAnalyticsSession = async () => {
|
|
396
399
|
this._ensurePersistentTokenStore();
|
|
397
400
|
if (await this.getPartialUser({
|
|
@@ -502,9 +505,24 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
502
505
|
}
|
|
503
506
|
async _redirectToOAuthCallbackError(error) {
|
|
504
507
|
const errorUrl = new URL(this._getUrls().error, window.location.href);
|
|
508
|
+
const callbackUrl = augmentUrlWithPersistedRedirectBackState({
|
|
509
|
+
currentUrl: new URL(window.location.href),
|
|
510
|
+
projectId: this.projectId
|
|
511
|
+
});
|
|
505
512
|
errorUrl.searchParams.set("errorCode", error.errorCode);
|
|
506
513
|
errorUrl.searchParams.set("message", error.message);
|
|
507
514
|
errorUrl.searchParams.set("details", JSON.stringify(error.details ?? {}));
|
|
515
|
+
for (const paramName of [
|
|
516
|
+
"after_auth_return_to",
|
|
517
|
+
crossDomainAuthQueryParams.state,
|
|
518
|
+
crossDomainAuthQueryParams.codeChallenge,
|
|
519
|
+
crossDomainAuthQueryParams.afterCallbackRedirectUrl
|
|
520
|
+
]) {
|
|
521
|
+
const value = callbackUrl.searchParams.get(paramName);
|
|
522
|
+
if (value != null) errorUrl.searchParams.set(paramName, value);
|
|
523
|
+
}
|
|
524
|
+
const afterCallbackRedirectUrl = callbackUrl.searchParams.get(oauthAfterCallbackRedirectUrlQueryParam);
|
|
525
|
+
if (afterCallbackRedirectUrl != null) errorUrl.searchParams.set(oauthAfterCallbackRedirectUrlQueryParam, afterCallbackRedirectUrl);
|
|
508
526
|
await this._redirectIfTrusted(errorUrl.toString(), { replace: true });
|
|
509
527
|
}
|
|
510
528
|
async _handleHostedOAuthCallbackDuringStartup() {
|
|
@@ -1724,7 +1742,8 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
1724
1742
|
projectId: forProjectId,
|
|
1725
1743
|
tokenStore: null,
|
|
1726
1744
|
projectOwnerSession: session,
|
|
1727
|
-
noAutomaticPrefetch: true
|
|
1745
|
+
noAutomaticPrefetch: true,
|
|
1746
|
+
automaticSideEffects: false
|
|
1728
1747
|
}));
|
|
1729
1748
|
return this._ownedAdminApps.get([session, forProjectId]);
|
|
1730
1749
|
}
|
|
@@ -1934,10 +1953,12 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
1934
1953
|
});
|
|
1935
1954
|
}
|
|
1936
1955
|
async _getRedirectToHandlerUrl(handlerName, options, internalOptions) {
|
|
1937
|
-
const
|
|
1956
|
+
const rawUrls = getUrls(this._urlOptions, { projectId: this.projectId });
|
|
1957
|
+
const rawHandlerUrl = rawUrls[handlerName];
|
|
1938
1958
|
if (!rawHandlerUrl) throw new Error(`No URL for handler name ${handlerName}`);
|
|
1939
1959
|
let currentUrl = typeof window === "undefined" ? null : new URL(window.location.href);
|
|
1940
|
-
|
|
1960
|
+
const shouldRestorePersistedRedirectBackState = options?.noRedirectBack !== true && (handlerName === "afterSignIn" || handlerName === "afterSignUp") || handlerName === "forgotPassword" || handlerName === "passwordReset" || handlerName === "signIn" && options?.noRedirectBack === true;
|
|
1961
|
+
if (currentUrl != null && shouldRestorePersistedRedirectBackState) currentUrl = augmentUrlWithPersistedRedirectBackState({
|
|
1941
1962
|
currentUrl,
|
|
1942
1963
|
projectId: this.projectId
|
|
1943
1964
|
});
|
|
@@ -1947,6 +1968,7 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
1947
1968
|
noRedirectBack: options?.noRedirectBack === true,
|
|
1948
1969
|
currentUrl,
|
|
1949
1970
|
localOAuthCallbackUrl: this._getLocalOAuthCallbackHandlerUrl(),
|
|
1971
|
+
rawHomeUrl: rawUrls.home,
|
|
1950
1972
|
getCrossDomainHandoffParams: async (href) => await this._getCrossDomainHandoffParamsForRedirect(href)
|
|
1951
1973
|
});
|
|
1952
1974
|
if (plan.type === "cross-domain-authorize") return await this._createCrossDomainAuthRedirectUrl({
|
|
@@ -2558,13 +2580,15 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
2558
2580
|
return clientApp;
|
|
2559
2581
|
}
|
|
2560
2582
|
const { analytics, ...restJson } = omit(json, ["uniqueIdentifier"]);
|
|
2561
|
-
|
|
2583
|
+
const app = new _HexclaveClientAppImplIncomplete({
|
|
2562
2584
|
...restJson,
|
|
2563
2585
|
analytics: analyticsOptionsFromJson(analytics)
|
|
2564
2586
|
}, {
|
|
2565
2587
|
uniqueIdentifier: json.uniqueIdentifier,
|
|
2566
2588
|
checkString: providedCheckString
|
|
2567
2589
|
});
|
|
2590
|
+
if (json.automaticSideEffects === false) app._initUniqueIdentifier();
|
|
2591
|
+
return app;
|
|
2568
2592
|
} };
|
|
2569
2593
|
}
|
|
2570
2594
|
get [hexclaveAppInternalsSymbol]() {
|
|
@@ -2583,6 +2607,7 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
2583
2607
|
redirectMethod: this._redirectMethod,
|
|
2584
2608
|
extraRequestHeaders: this._options.extraRequestHeaders,
|
|
2585
2609
|
devTool: this._options.devTool,
|
|
2610
|
+
automaticSideEffects: this._options.automaticSideEffects,
|
|
2586
2611
|
analytics: analyticsOptionsToJson(this._analyticsOptions)
|
|
2587
2612
|
};
|
|
2588
2613
|
},
|
|
@@ -2618,6 +2643,13 @@ var _HexclaveClientAppImplIncomplete = class _HexclaveClientAppImplIncomplete {
|
|
|
2618
2643
|
redirectToHandler: async (handlerName, options) => {
|
|
2619
2644
|
await this._redirectToHandler(handlerName, options);
|
|
2620
2645
|
},
|
|
2646
|
+
getRawAfterAuthReturnTo: () => {
|
|
2647
|
+
if (typeof window === "undefined") return null;
|
|
2648
|
+
return getRawAfterAuthReturnTo({
|
|
2649
|
+
currentUrl: new URL(window.location.href),
|
|
2650
|
+
projectId: this.projectId
|
|
2651
|
+
});
|
|
2652
|
+
},
|
|
2621
2653
|
refreshOwnedProjects: async () => {
|
|
2622
2654
|
await this._refreshOwnedProjects(await this._getSession());
|
|
2623
2655
|
},
|