@hexclave/tanstack-start 1.0.5 → 1.0.8
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/components-page/account-settings/email-and-auth/mfa-section.js +1 -1
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js +1 -1
- package/dist/components-page/account-settings/email-and-auth/password-section.js +2 -2
- package/dist/components-page/account-settings/payments/payments-panel.js +4 -4
- package/dist/components-page/account-settings/payments/payments-panel.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-creation-page.js +1 -1
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js +1 -1
- package/dist/components-page/hexclave-handler-client.d.ts +13 -1
- package/dist/components-page/hexclave-handler-client.d.ts.map +1 -1
- package/dist/components-page/hexclave-handler-client.js +44 -9
- package/dist/components-page/hexclave-handler-client.js.map +1 -1
- package/dist/components-page/hexclave-handler-client.test.d.ts +1 -0
- package/dist/components-page/hexclave-handler-client.test.js +51 -0
- package/dist/components-page/hexclave-handler-client.test.js.map +1 -0
- package/dist/dev-tool/dev-tool-core.js +2 -2
- package/dist/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.js +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.js +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js +2 -2
- package/dist/esm/components-page/account-settings/payments/payments-panel.js +3 -3
- package/dist/esm/components-page/account-settings/payments/payments-panel.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js +1 -1
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js +1 -1
- package/dist/esm/components-page/hexclave-handler-client.d.ts +12 -1
- package/dist/esm/components-page/hexclave-handler-client.d.ts.map +1 -1
- package/dist/esm/components-page/hexclave-handler-client.js +46 -12
- package/dist/esm/components-page/hexclave-handler-client.js.map +1 -1
- package/dist/esm/components-page/hexclave-handler-client.test.d.ts +1 -0
- package/dist/esm/components-page/hexclave-handler-client.test.js +51 -0
- package/dist/esm/components-page/hexclave-handler-client.test.js.map +1 -0
- package/dist/esm/dev-tool/dev-tool-core.js +2 -2
- package/dist/esm/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/esm/generated/env.d.ts +26 -0
- package/dist/esm/{lib → generated}/env.d.ts.map +1 -1
- package/dist/esm/generated/env.js +67 -0
- package/dist/esm/generated/env.js.map +1 -0
- package/dist/esm/global.d.ts +8 -1
- package/dist/esm/global.d.ts.map +1 -0
- package/dist/esm/lib/auth.js +1 -1
- package/dist/esm/lib/cookie.d.ts +0 -8
- package/dist/esm/lib/cookie.d.ts.map +1 -1
- package/dist/esm/lib/cookie.js +2 -2
- package/dist/esm/lib/cookie.js.map +1 -1
- 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.cross-domain.test.js +263 -3
- 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 +3 -1
- 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 +54 -27
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/common.d.ts +8 -8
- package/dist/esm/lib/hexclave-app/apps/implementations/common.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js +29 -15
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.js +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.d.ts.map +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.js +25 -11
- package/dist/esm/lib/hexclave-app/url-targets.js.map +1 -1
- package/dist/esm/lib/hexclave-app/url-targets.test.js +12 -0
- package/dist/esm/lib/hexclave-app/url-targets.test.js.map +1 -1
- package/dist/generated/env.d.ts +26 -0
- package/dist/{lib → generated}/env.d.ts.map +1 -1
- package/dist/generated/env.js +69 -0
- package/dist/generated/env.js.map +1 -0
- package/dist/global.d.ts +8 -1
- package/dist/global.d.ts.map +1 -0
- package/dist/lib/auth.js +1 -1
- package/dist/lib/cookie.d.ts +0 -8
- package/dist/lib/cookie.d.ts.map +1 -1
- package/dist/lib/cookie.js +2 -2
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.js +263 -3
- 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 +3 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js +53 -26
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.d.ts +8 -8
- package/dist/lib/hexclave-app/apps/implementations/common.d.ts.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.js +29 -15
- package/dist/lib/hexclave-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.js +1 -1
- package/dist/lib/hexclave-app/url-targets.d.ts.map +1 -1
- package/dist/lib/hexclave-app/url-targets.js +25 -11
- package/dist/lib/hexclave-app/url-targets.js.map +1 -1
- package/dist/lib/hexclave-app/url-targets.test.js +12 -0
- package/dist/lib/hexclave-app/url-targets.test.js.map +1 -1
- package/package.json +13 -6
- package/src/components-page/account-settings/payments/payments-panel.tsx +2 -2
- package/src/components-page/hexclave-handler-client.test.tsx +64 -0
- package/src/components-page/hexclave-handler-client.tsx +51 -12
- package/src/dev-tool/dev-tool-core.ts +2 -2
- package/src/generated/.gitignore +1 -1
- package/src/global.d.ts +8 -1
- package/src/lib/cookie.ts +2 -15
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.cross-domain.test.ts +316 -3
- package/src/lib/hexclave-app/apps/implementations/client-app-impl.ts +69 -25
- package/src/lib/hexclave-app/apps/implementations/common.ts +34 -14
- package/src/lib/hexclave-app/url-targets.test.ts +17 -0
- package/src/lib/hexclave-app/url-targets.ts +25 -7
- package/dist/esm/lib/env.d.ts +0 -42
- package/dist/esm/lib/env.js +0 -93
- package/dist/esm/lib/env.js.map +0 -1
- package/dist/lib/env.d.ts +0 -42
- package/dist/lib/env.js +0 -95
- package/dist/lib/env.js.map +0 -1
- package/src/lib/env.ts +0 -93
|
@@ -39,7 +39,7 @@ import { Store, storeLock } from "@hexclave/shared/dist/utils/stores";
|
|
|
39
39
|
import { deindent, mergeScopeStrings } from "@hexclave/shared/dist/utils/strings";
|
|
40
40
|
import type { TurnstileAction } from "@hexclave/shared/dist/utils/turnstile";
|
|
41
41
|
import { BotChallengeExecutionFailedError, BotChallengeUserCancelledError, withBotChallengeFlow } from "@hexclave/shared/dist/utils/turnstile-flow";
|
|
42
|
-
import { createUrlIfValid, isRelative } from "@hexclave/shared/dist/utils/urls";
|
|
42
|
+
import { createUrlIfValid, getRelativePart, isRelative } from "@hexclave/shared/dist/utils/urls";
|
|
43
43
|
import { generateUuid } from "@hexclave/shared/dist/utils/uuids";
|
|
44
44
|
import * as tanstackStartServerContext from "@hexclave/tanstack-start/tanstack-start-server-context"; // THIS_LINE_PLATFORM tanstack-start
|
|
45
45
|
import * as TanStackRouter from "@tanstack/react-router"; // THIS_LINE_PLATFORM tanstack-start
|
|
@@ -49,7 +49,7 @@ import type * as yup from "yup";
|
|
|
49
49
|
import { constructRedirectUrl } from "../../../../utils/url";
|
|
50
50
|
import { callOAuthCallback, getNewOAuthProviderOrScopeUrl } from "../../../auth";
|
|
51
51
|
import { CookieHelper, createBrowserCookieHelper, createCookieHelper, createPlaceholderCookieHelper, deleteCookie, deleteCookieClient, getCookieClient, isSecure as isSecureCookieContext, saveVerifierAndState, setOrDeleteCookie, setOrDeleteCookieClient } from "../../../cookie";
|
|
52
|
-
import { envVars } from "
|
|
52
|
+
import { envVars } from "../../../../generated/env";
|
|
53
53
|
import { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud } from "../../api-keys";
|
|
54
54
|
import { ConvexCtx, GetCurrentPartialUserOptions, GetCurrentUserOptions, HandlerUrlOptions, HandlerUrls, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, RequestLike, ResolvedHandlerUrls, TokenStoreInit, hexclaveAppInternalsSymbol } from "../../common";
|
|
55
55
|
import { DeprecatedOAuthConnection, OAuthConnection } from "../../connected-accounts";
|
|
@@ -816,12 +816,16 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
816
816
|
return currentUrl.toString();
|
|
817
817
|
}
|
|
818
818
|
|
|
819
|
-
protected async
|
|
819
|
+
protected async _fetchCurrentRefreshTokenIdIfSignedIn(options?: {
|
|
820
820
|
awaitPendingAuthResolutions?: boolean,
|
|
821
821
|
overrideTokenStoreInit?: TokenStoreInit,
|
|
822
822
|
}): Promise<string | null> {
|
|
823
823
|
const session = await this._getSession(options?.overrideTokenStoreInit, options);
|
|
824
|
-
|
|
824
|
+
// Nested cross-domain auth passes this ID to another origin, which later
|
|
825
|
+
// asks us to prove the same raw refresh token. A cached access token can be
|
|
826
|
+
// valid but stale relative to the refresh token, so mint from the refresh
|
|
827
|
+
// token that owns this session before exposing the ID.
|
|
828
|
+
const tokens = await session.fetchNewTokens();
|
|
825
829
|
if (tokens?.refreshToken == null) {
|
|
826
830
|
return null;
|
|
827
831
|
}
|
|
@@ -839,7 +843,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
839
843
|
return options.url;
|
|
840
844
|
}
|
|
841
845
|
|
|
842
|
-
const refreshTokenId = await this.
|
|
846
|
+
const refreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({
|
|
843
847
|
awaitPendingAuthResolutions: options.awaitPendingAuthResolutions,
|
|
844
848
|
overrideTokenStoreInit: options.overrideTokenStoreInit,
|
|
845
849
|
});
|
|
@@ -894,7 +898,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
894
898
|
if (!await this._isTrusted(afterCallbackRedirectUrl.toString())) {
|
|
895
899
|
throw new Error(`Nested cross-domain auth after-callback redirect URL ${afterCallbackRedirectUrlString} is not trusted.`);
|
|
896
900
|
}
|
|
897
|
-
const currentRefreshTokenId = await this.
|
|
901
|
+
const currentRefreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false });
|
|
898
902
|
if (currentRefreshTokenId !== refreshTokenId) {
|
|
899
903
|
throw new Error("Nested cross-domain auth source session does not match the requested refresh token ID.");
|
|
900
904
|
}
|
|
@@ -913,8 +917,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
913
917
|
|
|
914
918
|
// We are on b.com. Bounce to the trusted callback on a.com with a normal OAuth request
|
|
915
919
|
// shape; a.com will verify the source session and issue the one-time code.
|
|
916
|
-
const currentRefreshTokenId = await this.
|
|
920
|
+
const currentRefreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false });
|
|
917
921
|
if (currentRefreshTokenId === refreshTokenId) return false;
|
|
922
|
+
if (currentRefreshTokenId != null) {
|
|
923
|
+
const session = await this._getSession(undefined, { awaitPendingAuthResolutions: false });
|
|
924
|
+
session.markInvalid();
|
|
925
|
+
}
|
|
918
926
|
const callbackUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
919
927
|
if (callbackUrlString == null) {
|
|
920
928
|
throw new HexclaveAssertionError("Nested cross-domain auth URL is missing callback URL");
|
|
@@ -1107,6 +1115,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1107
1115
|
accessToken,
|
|
1108
1116
|
};
|
|
1109
1117
|
}
|
|
1118
|
+
private _getCurrentBrowserCookieTokenStoreValue(old: TokenObject | null): TokenObject {
|
|
1119
|
+
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
1120
|
+
return {
|
|
1121
|
+
refreshToken: tokens.refreshToken,
|
|
1122
|
+
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null),
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1110
1125
|
protected get _accessTokenCookieName() {
|
|
1111
1126
|
// The access token, unlike the refresh token, should not depend on the project ID. We never want to store the
|
|
1112
1127
|
// access token in cookies more than once because of how big it is (there's a limit of 4096 bytes for all cookies
|
|
@@ -1249,20 +1264,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1249
1264
|
}
|
|
1250
1265
|
|
|
1251
1266
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
1252
|
-
|
|
1253
|
-
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
1254
|
-
return {
|
|
1255
|
-
refreshToken: tokens.refreshToken,
|
|
1256
|
-
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null),
|
|
1257
|
-
};
|
|
1258
|
-
};
|
|
1259
|
-
this._storedBrowserCookieTokenStore = new Store<TokenObject>(getCurrentValue(null));
|
|
1267
|
+
this._storedBrowserCookieTokenStore = new Store<TokenObject>(this._getCurrentBrowserCookieTokenStoreValue(null));
|
|
1260
1268
|
let hasSucceededInWriting = true;
|
|
1261
1269
|
|
|
1262
1270
|
setInterval(() => {
|
|
1263
1271
|
if (hasSucceededInWriting) {
|
|
1264
1272
|
const oldValue = this._storedBrowserCookieTokenStore!.get();
|
|
1265
|
-
const currentValue =
|
|
1273
|
+
const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
|
|
1266
1274
|
if (!deepPlainEquals(currentValue, oldValue)) {
|
|
1267
1275
|
this._storedBrowserCookieTokenStore!.set(currentValue);
|
|
1268
1276
|
}
|
|
@@ -1296,6 +1304,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1296
1304
|
}
|
|
1297
1305
|
}
|
|
1298
1306
|
});
|
|
1307
|
+
} else {
|
|
1308
|
+
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
1309
|
+
const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
|
|
1310
|
+
if (!deepPlainEquals(currentValue, oldValue)) {
|
|
1311
|
+
this._storedBrowserCookieTokenStore.set(currentValue);
|
|
1312
|
+
}
|
|
1299
1313
|
}
|
|
1300
1314
|
|
|
1301
1315
|
return this._storedBrowserCookieTokenStore;
|
|
@@ -1444,17 +1458,17 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1444
1458
|
accessToken: tokenObj.accessToken,
|
|
1445
1459
|
});
|
|
1446
1460
|
session.onAccessTokenChange((newAccessToken) => {
|
|
1447
|
-
tokenStore.update((old) => ({
|
|
1461
|
+
tokenStore.update((old) => InternalSession.calculateSessionKey(old) === sessionKey ? {
|
|
1448
1462
|
...old,
|
|
1449
1463
|
accessToken: newAccessToken?.token ?? null
|
|
1450
|
-
})
|
|
1464
|
+
} : old);
|
|
1451
1465
|
});
|
|
1452
1466
|
session.onInvalidate(() => {
|
|
1453
|
-
tokenStore.update((old) => ({
|
|
1467
|
+
tokenStore.update((old) => InternalSession.calculateSessionKey(old) === sessionKey ? {
|
|
1454
1468
|
...old,
|
|
1455
1469
|
accessToken: null,
|
|
1456
1470
|
refreshToken: null,
|
|
1457
|
-
})
|
|
1471
|
+
} : old);
|
|
1458
1472
|
});
|
|
1459
1473
|
|
|
1460
1474
|
let sessionsBySessionKey = this._sessionsByTokenStoreAndSessionKey.get(tokenStore) ?? new Map();
|
|
@@ -2554,16 +2568,16 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2554
2568
|
private _getBotChallengeSiteKeys(): { visibleSiteKey: string, invisibleSiteKey: string } | null {
|
|
2555
2569
|
if (!isBrowserLike()) return null;
|
|
2556
2570
|
|
|
2557
|
-
const visibleSiteKey = envVars.
|
|
2571
|
+
const visibleSiteKey = envVars.HEXCLAVE_BOT_CHALLENGE_SITE_KEY;
|
|
2558
2572
|
if (!visibleSiteKey) {
|
|
2559
2573
|
if (!this._botChallengeSiteKeysWarned) {
|
|
2560
2574
|
this._botChallengeSiteKeysWarned = true;
|
|
2561
|
-
console.warn("[stack-auth]
|
|
2575
|
+
console.warn("[stack-auth] HEXCLAVE_BOT_CHALLENGE_SITE_KEY is not set — bot challenge fraud protection is disabled. Set the env variable to enable it.");
|
|
2562
2576
|
}
|
|
2563
2577
|
return null;
|
|
2564
2578
|
}
|
|
2565
2579
|
|
|
2566
|
-
const invisibleSiteKey = envVars.
|
|
2580
|
+
const invisibleSiteKey = envVars.HEXCLAVE_BOT_CHALLENGE_INVISIBLE_SITE_KEY ?? visibleSiteKey;
|
|
2567
2581
|
|
|
2568
2582
|
return { visibleSiteKey, invisibleSiteKey };
|
|
2569
2583
|
}
|
|
@@ -2745,6 +2759,11 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2745
2759
|
overrideTokenStoreInit?: TokenStoreInit,
|
|
2746
2760
|
}): Promise<string> {
|
|
2747
2761
|
const session = await this._getSession(options.overrideTokenStoreInit, { awaitPendingAuthResolutions: options.awaitPendingAuthResolutions });
|
|
2762
|
+
// The authorize endpoint intentionally verifies that the access token and
|
|
2763
|
+
// raw refresh token describe the same DB session. Force the access token to
|
|
2764
|
+
// be minted from the refresh token we are about to send, instead of reusing
|
|
2765
|
+
// a still-valid cached token from a pre-handoff session snapshot.
|
|
2766
|
+
await session.fetchNewTokens();
|
|
2748
2767
|
const response = await this._interface.sendClientRequest(
|
|
2749
2768
|
"/auth/oauth/cross-domain/authorize",
|
|
2750
2769
|
{
|
|
@@ -2892,7 +2911,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2892
2911
|
|
|
2893
2912
|
async redirectToSignIn(options?: RedirectToOptions) { return await this._redirectToHandler("signIn", options); }
|
|
2894
2913
|
async redirectToSignUp(options?: RedirectToOptions) { return await this._redirectToHandler("signUp", options); }
|
|
2895
|
-
async redirectToSignOut(options?: RedirectToOptions) {
|
|
2914
|
+
async redirectToSignOut(options?: RedirectToOptions) {
|
|
2915
|
+
const configuredSignOutTarget = this._urlOptions.signOut ?? this._urlOptions.default;
|
|
2916
|
+
if (typeof configuredSignOutTarget !== "string" && configuredSignOutTarget?.type === "hosted") {
|
|
2917
|
+
return await this.signOut();
|
|
2918
|
+
}
|
|
2919
|
+
return await this._redirectToHandler("signOut", options);
|
|
2920
|
+
}
|
|
2896
2921
|
async redirectToEmailVerification(options?: RedirectToOptions) { return await this._redirectToHandler("emailVerification", options); }
|
|
2897
2922
|
async redirectToPasswordReset(options?: RedirectToOptions) { return await this._redirectToHandler("passwordReset", options); }
|
|
2898
2923
|
async redirectToForgotPassword(options?: RedirectToOptions) { return await this._redirectToHandler("forgotPassword", options); }
|
|
@@ -3689,11 +3714,30 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
3689
3714
|
if (options?.redirectUrl) {
|
|
3690
3715
|
await this._redirectTo({ url: options.redirectUrl, replace: true });
|
|
3691
3716
|
} else {
|
|
3692
|
-
await this.
|
|
3717
|
+
await this._redirectToDefaultAfterSignOut();
|
|
3693
3718
|
}
|
|
3694
3719
|
});
|
|
3695
3720
|
}
|
|
3696
3721
|
|
|
3722
|
+
protected async _redirectToDefaultAfterSignOut(): Promise<void> {
|
|
3723
|
+
if (this._urlOptions.afterSignOut != null) {
|
|
3724
|
+
await this.redirectToAfterSignOut({ replace: true });
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
if (this._urlOptions.home != null) {
|
|
3729
|
+
await this.redirectToHome({ replace: true });
|
|
3730
|
+
return;
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3733
|
+
if (this._urlOptions.default?.type === "hosted" && typeof window !== "undefined") {
|
|
3734
|
+
await this._redirectTo({ url: getRelativePart(new URL(window.location.href)), replace: true });
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
await this.redirectToAfterSignOut({ replace: true });
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3697
3741
|
async signOut(options?: { redirectUrl?: URL | string, tokenStore?: TokenStoreInit }): Promise<void> {
|
|
3698
3742
|
const user = await this.getUser({ tokenStore: options?.tokenStore ?? undefined as any });
|
|
3699
3743
|
if (user) {
|
|
@@ -14,7 +14,7 @@ import { Result } from "@hexclave/shared/dist/utils/results";
|
|
|
14
14
|
import { Store } from "@hexclave/shared/dist/utils/stores";
|
|
15
15
|
import { getDefaultApiUrls } from "@hexclave/shared/dist/utils/urls";
|
|
16
16
|
import React, { useCallback } from "react"; // THIS_LINE_PLATFORM react-like
|
|
17
|
-
import { envVars } from "
|
|
17
|
+
import { envVars } from "../../../../generated/env";
|
|
18
18
|
import { HandlerUrlOptions, ResolvedHandlerUrls, hexclaveAppInternalsSymbol } from "../../common";
|
|
19
19
|
import { resolveHandlerUrls } from "../../url-targets";
|
|
20
20
|
|
|
@@ -25,10 +25,30 @@ if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
|
25
25
|
|
|
26
26
|
const replaceHexclavePortPrefix = <T extends string | undefined>(input: T): T => {
|
|
27
27
|
if (!input) return input;
|
|
28
|
-
const prefix = envVars.
|
|
28
|
+
const prefix = envVars.HEXCLAVE_PORT_PREFIX;
|
|
29
29
|
return prefix ? input.replace(/\$\{NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX:-81\}/g, prefix) as T : input;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const showMissingConfigAlertInBrowser = (message: string) => {
|
|
33
|
+
if (!isBrowserLike()) return;
|
|
34
|
+
|
|
35
|
+
const global = globalThis as any;
|
|
36
|
+
const alertAlreadyShownKey = "__hexclave_missing_config_alert_already_shown";
|
|
37
|
+
if (global[alertAlreadyShownKey]) return;
|
|
38
|
+
global[alertAlreadyShownKey] = true;
|
|
39
|
+
|
|
40
|
+
const alertFn = global.alert;
|
|
41
|
+
if (typeof alertFn === "function") {
|
|
42
|
+
alertFn(message);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const throwMissingProjectIdError = (): never => {
|
|
47
|
+
const message = "Welcome to Hexclave! It seems that you haven't provided a project ID. Please create a project on the Hexclave dashboard at https://app.hexclave.com and put it in the HEXCLAVE_PROJECT_ID environment variable.";
|
|
48
|
+
showMissingConfigAlertInBrowser(message);
|
|
49
|
+
return throwErr(new Error(message));
|
|
50
|
+
};
|
|
51
|
+
|
|
32
52
|
|
|
33
53
|
export const createCache = <D extends any[], T>(fetcher: (dependencies: D) => Promise<T>) => {
|
|
34
54
|
return new AsyncCache<D, Result<T>>(
|
|
@@ -66,23 +86,23 @@ export function getUrls(partial: HandlerUrlOptions, options: { projectId: string
|
|
|
66
86
|
}
|
|
67
87
|
|
|
68
88
|
export function getDefaultProjectId() {
|
|
69
|
-
return envVars.
|
|
89
|
+
return envVars.HEXCLAVE_PROJECT_ID || throwMissingProjectIdError();
|
|
70
90
|
}
|
|
71
91
|
|
|
72
92
|
export function getDefaultPublishableClientKey() {
|
|
73
|
-
return envVars.
|
|
93
|
+
return envVars.HEXCLAVE_PUBLISHABLE_CLIENT_KEY;
|
|
74
94
|
}
|
|
75
95
|
|
|
76
96
|
export function getDefaultSecretServerKey() {
|
|
77
|
-
return envVars.
|
|
97
|
+
return envVars.HEXCLAVE_SECRET_SERVER_KEY || throwErr(new Error("No secret server key provided. Please copy your key from the Hexclave dashboard and put it in the HEXCLAVE_SECRET_SERVER_KEY environment variable."));
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
export function getDefaultSuperSecretAdminKey() {
|
|
81
|
-
return envVars.
|
|
101
|
+
return envVars.HEXCLAVE_SUPER_SECRET_ADMIN_KEY || throwErr(new Error("No super secret admin key provided. Please copy your key from the Hexclave dashboard and put it in the HEXCLAVE_SUPER_SECRET_ADMIN_KEY environment variable."));
|
|
82
102
|
}
|
|
83
103
|
|
|
84
104
|
export function getDefaultExtraRequestHeaders() {
|
|
85
|
-
return JSON.parse(envVars.
|
|
105
|
+
return JSON.parse(envVars.HEXCLAVE_EXTRA_REQUEST_HEADERS || '{}');
|
|
86
106
|
}
|
|
87
107
|
|
|
88
108
|
/**
|
|
@@ -91,9 +111,9 @@ export function getDefaultExtraRequestHeaders() {
|
|
|
91
111
|
* The URL can be specified in several ways, in order of precedence:
|
|
92
112
|
* 1. Directly through userSpecifiedBaseUrl parameter as string or browser/server object
|
|
93
113
|
* 2. Through environment variables:
|
|
94
|
-
* - Browser:
|
|
95
|
-
* - Server:
|
|
96
|
-
* -
|
|
114
|
+
* - Browser: NEXT_PUBLIC_HEXCLAVE_API_URL_BROWSER/VITE_HEXCLAVE_API_URL_BROWSER
|
|
115
|
+
* - Server: HEXCLAVE_API_URL_SERVER
|
|
116
|
+
* - Default: HEXCLAVE_API_URL
|
|
97
117
|
* 3. Default base URL if none of the above are specified
|
|
98
118
|
*
|
|
99
119
|
* The function also ensures the URL doesn't end with a trailing slash
|
|
@@ -116,13 +136,12 @@ export function getBaseUrl(userSpecifiedBaseUrl: string | { browser: string, ser
|
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
138
|
} else {
|
|
119
|
-
// note: NEXT_PUBLIC_BROWSER_STACK_API_URL was renamed to NEXT_PUBLIC_STACK_API_URL_BROWSER, and NEXT_PUBLIC_STACK_URL to NEXT_PUBLIC_STACK_API_URL
|
|
120
139
|
if (isBrowserLike()) {
|
|
121
|
-
url = envVars.
|
|
140
|
+
url = envVars.HEXCLAVE_API_URL_BROWSER;
|
|
122
141
|
} else {
|
|
123
|
-
url = envVars.
|
|
142
|
+
url = envVars.HEXCLAVE_API_URL_SERVER;
|
|
124
143
|
}
|
|
125
|
-
url = url || envVars.
|
|
144
|
+
url = url || envVars.HEXCLAVE_API_URL || defaultBaseUrl;
|
|
126
145
|
}
|
|
127
146
|
|
|
128
147
|
return replaceHexclavePortPrefix(url.endsWith('/') ? url.slice(0, -1) : url);
|
|
@@ -220,6 +239,7 @@ export function useAsyncCache<D extends any[], T>(cache: AsyncCache<D, Result<T>
|
|
|
220
239
|
});
|
|
221
240
|
return unsubscribe;
|
|
222
241
|
}, [cache, ...dependencies]);
|
|
242
|
+
|
|
223
243
|
const getSnapshot = useCallback(() => {
|
|
224
244
|
// React checks whether a promise passed to `use` is still the same as the previous one by comparing the reference.
|
|
225
245
|
// If we didn't cache here, this wouldn't work because the promise would be recreated every time the value changes.
|
|
@@ -100,6 +100,23 @@ describe("handler URL targets", () => {
|
|
|
100
100
|
expect(urls.cliAuthConfirm).toBe("https://project-id.example-stack-hosted.test/handler/cli-auth-confirm");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
+
it("keeps redirect-only post-auth targets local even when the default target is hosted", () => {
|
|
104
|
+
vi.stubEnv("NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX", ".example-stack-hosted.test");
|
|
105
|
+
|
|
106
|
+
const urls = resolveHandlerUrls({
|
|
107
|
+
projectId: "project-id",
|
|
108
|
+
urls: {
|
|
109
|
+
default: { type: "hosted" },
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(urls.signIn).toBe("https://project-id.example-stack-hosted.test/handler/sign-in");
|
|
114
|
+
expect(urls.signOut).toBe("https://project-id.example-stack-hosted.test/handler/sign-out");
|
|
115
|
+
expect(urls.afterSignIn).toBe("/");
|
|
116
|
+
expect(urls.afterSignUp).toBe("/");
|
|
117
|
+
expect(urls.afterSignOut).toBe("/");
|
|
118
|
+
});
|
|
119
|
+
|
|
103
120
|
it("rejects absolute OAuth callback string targets", () => {
|
|
104
121
|
expect(() => resolveHandlerUrls({
|
|
105
122
|
projectId: "project-id",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { getCustomPagePrompts, type CustomPagePrompt } from "@hexclave/shared/dist/interface/handler-urls";
|
|
6
6
|
import { HexclaveAssertionError } from "@hexclave/shared/dist/utils/errors";
|
|
7
7
|
import { getHostedHandlerUrlFromConfig } from "@hexclave/shared/dist/utils/redirect-urls";
|
|
8
|
-
import { envVars } from "
|
|
8
|
+
import { envVars } from "../../generated/env";
|
|
9
9
|
import { DefaultHandlerUrlTarget, HandlerPageUrls, HandlerUrlOptions, HandlerUrlTarget, HandlerUrls, ResolvedHandlerUrls } from "./common";
|
|
10
10
|
|
|
11
11
|
const localUrlPlaceholderOrigin = "http://example.com";
|
|
@@ -111,9 +111,9 @@ export const getHostedHandlerUrl = (options: { projectId: string, pagePath: stri
|
|
|
111
111
|
return getHostedHandlerUrlFromConfig({
|
|
112
112
|
projectId: options.projectId,
|
|
113
113
|
hostedPath,
|
|
114
|
-
hostedHandlerDomainSuffix: envVars.
|
|
115
|
-
hostedHandlerUrlTemplate: envVars.
|
|
116
|
-
hexclavePortPrefix: envVars.
|
|
114
|
+
hostedHandlerDomainSuffix: envVars.HEXCLAVE_HOSTED_HANDLER_DOMAIN_SUFFIX,
|
|
115
|
+
hostedHandlerUrlTemplate: envVars.HEXCLAVE_HOSTED_HANDLER_URL_TEMPLATE,
|
|
116
|
+
hexclavePortPrefix: envVars.HEXCLAVE_PORT_PREFIX,
|
|
117
117
|
});
|
|
118
118
|
};
|
|
119
119
|
|
|
@@ -124,6 +124,12 @@ const isRelativeUrlString = (url: string): boolean => {
|
|
|
124
124
|
return !schemePrefixRegex.test(url);
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
const nonHostedHandlerNames = new Set<keyof HandlerUrls>([
|
|
128
|
+
"afterSignIn",
|
|
129
|
+
"afterSignUp",
|
|
130
|
+
"afterSignOut",
|
|
131
|
+
]);
|
|
132
|
+
|
|
127
133
|
export const isLocalHandlerUrlTarget = (options: {
|
|
128
134
|
targetUrl: string,
|
|
129
135
|
handlerPath: string,
|
|
@@ -159,6 +165,9 @@ const resolveUrlTarget = (options: {
|
|
|
159
165
|
return options.fallbackPath;
|
|
160
166
|
}
|
|
161
167
|
case "hosted": {
|
|
168
|
+
if (nonHostedHandlerNames.has(options.handlerName)) {
|
|
169
|
+
return options.fallbackPath;
|
|
170
|
+
}
|
|
162
171
|
return getHostedHandlerUrl({
|
|
163
172
|
projectId: options.projectId,
|
|
164
173
|
pagePath: getHostedPagePathForHandlerName(options.handlerName),
|
|
@@ -206,15 +215,24 @@ export const resolveHandlerUrls = (options: { urls: HandlerUrlOptions | undefine
|
|
|
206
215
|
});
|
|
207
216
|
}
|
|
208
217
|
|
|
218
|
+
const homeTarget = configuredUrls?.home ?? defaultTarget;
|
|
219
|
+
const localHome = resolveUrlTarget({
|
|
220
|
+
target: typeof homeTarget !== "string" && homeTarget.type === "hosted"
|
|
221
|
+
? { type: "handler-component" }
|
|
222
|
+
: homeTarget,
|
|
223
|
+
fallbackPath: "/",
|
|
224
|
+
handlerName: "home",
|
|
225
|
+
projectId: options.projectId,
|
|
226
|
+
});
|
|
209
227
|
const home = resolveUrlTarget({
|
|
210
|
-
target:
|
|
228
|
+
target: homeTarget,
|
|
211
229
|
fallbackPath: "/",
|
|
212
230
|
handlerName: "home",
|
|
213
231
|
projectId: options.projectId,
|
|
214
232
|
});
|
|
215
233
|
const afterSignIn = resolveUrlTarget({
|
|
216
234
|
target: configuredUrls?.afterSignIn ?? defaultTarget,
|
|
217
|
-
fallbackPath:
|
|
235
|
+
fallbackPath: localHome,
|
|
218
236
|
handlerName: "afterSignIn",
|
|
219
237
|
projectId: options.projectId,
|
|
220
238
|
});
|
|
@@ -253,7 +271,7 @@ export const resolveHandlerUrls = (options: { urls: HandlerUrlOptions | undefine
|
|
|
253
271
|
}),
|
|
254
272
|
afterSignOut: resolveUrlTarget({
|
|
255
273
|
target: configuredUrls?.afterSignOut ?? defaultTarget,
|
|
256
|
-
fallbackPath:
|
|
274
|
+
fallbackPath: localHome,
|
|
257
275
|
handlerName: "afterSignOut",
|
|
258
276
|
projectId: options.projectId,
|
|
259
277
|
}),
|
package/dist/esm/lib/env.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region src/lib/env.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Centralized environment-variable reads for the SDK.
|
|
4
|
-
*
|
|
5
|
-
* Keep each key explicit and reference `process.env.KEY` directly so bundlers
|
|
6
|
-
* like Next.js can inline values at build time.
|
|
7
|
-
*
|
|
8
|
-
* Hexclave rebrand: each getter prefers the HEXCLAVE_*-prefixed literal and
|
|
9
|
-
* falls back to the legacy STACK_* literal(s). Both operands stay literal
|
|
10
|
-
* `process.env.X` references so bundlers can inline them. The port-prefix var
|
|
11
|
-
* is a straight rename (no dual-read).
|
|
12
|
-
*/
|
|
13
|
-
declare const envVars: {
|
|
14
|
-
readonly NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX: string | undefined;
|
|
15
|
-
readonly NEXT_PUBLIC_STACK_PROJECT_ID: string | undefined;
|
|
16
|
-
readonly STACK_PROJECT_ID: string | undefined;
|
|
17
|
-
readonly NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY: string | undefined;
|
|
18
|
-
readonly STACK_PUBLISHABLE_CLIENT_KEY: string | undefined;
|
|
19
|
-
readonly STACK_SECRET_SERVER_KEY: string | undefined;
|
|
20
|
-
readonly STACK_SUPER_SECRET_ADMIN_KEY: string | undefined;
|
|
21
|
-
readonly NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS: string | undefined;
|
|
22
|
-
readonly STACK_EXTRA_REQUEST_HEADERS: string | undefined;
|
|
23
|
-
readonly NEXT_PUBLIC_BROWSER_STACK_API_URL: string | undefined;
|
|
24
|
-
readonly NEXT_PUBLIC_STACK_API_URL_BROWSER: string | undefined;
|
|
25
|
-
readonly STACK_API_URL_BROWSER: string | undefined;
|
|
26
|
-
readonly NEXT_PUBLIC_SERVER_STACK_API_URL: string | undefined;
|
|
27
|
-
readonly NEXT_PUBLIC_STACK_API_URL_SERVER: string | undefined;
|
|
28
|
-
readonly STACK_API_URL_SERVER: string | undefined;
|
|
29
|
-
readonly NEXT_PUBLIC_STACK_API_URL: string | undefined;
|
|
30
|
-
readonly STACK_API_URL: string | undefined;
|
|
31
|
-
readonly NEXT_PUBLIC_STACK_URL: string | undefined;
|
|
32
|
-
readonly NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX: string | undefined;
|
|
33
|
-
readonly NEXT_PUBLIC_STACK_HOSTED_HANDLER_URL_TEMPLATE: string | undefined;
|
|
34
|
-
readonly NEXT_PUBLIC_STACK_STRIPE_PUBLISHABLE_KEY: string | undefined;
|
|
35
|
-
readonly NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY: string | undefined;
|
|
36
|
-
readonly NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY: string | undefined;
|
|
37
|
-
readonly NODE_ENV: string | undefined;
|
|
38
|
-
readonly NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR: string | undefined;
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
41
|
-
export { envVars };
|
|
42
|
-
//# sourceMappingURL=env.d.ts.map
|
package/dist/esm/lib/env.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
//#region src/lib/env.ts
|
|
2
|
-
/**
|
|
3
|
-
* Centralized environment-variable reads for the SDK.
|
|
4
|
-
*
|
|
5
|
-
* Keep each key explicit and reference `process.env.KEY` directly so bundlers
|
|
6
|
-
* like Next.js can inline values at build time.
|
|
7
|
-
*
|
|
8
|
-
* Hexclave rebrand: each getter prefers the HEXCLAVE_*-prefixed literal and
|
|
9
|
-
* falls back to the legacy STACK_* literal(s). Both operands stay literal
|
|
10
|
-
* `process.env.X` references so bundlers can inline them. The port-prefix var
|
|
11
|
-
* is a straight rename (no dual-read).
|
|
12
|
-
*/
|
|
13
|
-
const envVars = {
|
|
14
|
-
get NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX() {
|
|
15
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX : void 0) ?? void 0;
|
|
16
|
-
},
|
|
17
|
-
get NEXT_PUBLIC_STACK_PROJECT_ID() {
|
|
18
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_PROJECT_ID ?? process.env.NEXT_PUBLIC_STACK_PROJECT_ID : void 0) ?? void 0;
|
|
19
|
-
},
|
|
20
|
-
get STACK_PROJECT_ID() {
|
|
21
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_PROJECT_ID ?? process.env.STACK_PROJECT_ID : void 0) ?? void 0;
|
|
22
|
-
},
|
|
23
|
-
get NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY() {
|
|
24
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_PUBLISHABLE_CLIENT_KEY ?? process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY : void 0) ?? void 0;
|
|
25
|
-
},
|
|
26
|
-
get STACK_PUBLISHABLE_CLIENT_KEY() {
|
|
27
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_PUBLISHABLE_CLIENT_KEY ?? process.env.STACK_PUBLISHABLE_CLIENT_KEY : void 0) ?? void 0;
|
|
28
|
-
},
|
|
29
|
-
get STACK_SECRET_SERVER_KEY() {
|
|
30
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_SECRET_SERVER_KEY ?? process.env.STACK_SECRET_SERVER_KEY : void 0) ?? void 0;
|
|
31
|
-
},
|
|
32
|
-
get STACK_SUPER_SECRET_ADMIN_KEY() {
|
|
33
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_SUPER_SECRET_ADMIN_KEY ?? process.env.STACK_SUPER_SECRET_ADMIN_KEY : void 0) ?? void 0;
|
|
34
|
-
},
|
|
35
|
-
get NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS() {
|
|
36
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_EXTRA_REQUEST_HEADERS ?? process.env.NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS : void 0) ?? void 0;
|
|
37
|
-
},
|
|
38
|
-
get STACK_EXTRA_REQUEST_HEADERS() {
|
|
39
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_EXTRA_REQUEST_HEADERS ?? process.env.STACK_EXTRA_REQUEST_HEADERS : void 0) ?? void 0;
|
|
40
|
-
},
|
|
41
|
-
get NEXT_PUBLIC_BROWSER_STACK_API_URL() {
|
|
42
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_BROWSER_HEXCLAVE_API_URL ?? process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL : void 0) ?? void 0;
|
|
43
|
-
},
|
|
44
|
-
get NEXT_PUBLIC_STACK_API_URL_BROWSER() {
|
|
45
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_API_URL_BROWSER ?? process.env.NEXT_PUBLIC_STACK_API_URL_BROWSER : void 0) ?? void 0;
|
|
46
|
-
},
|
|
47
|
-
get STACK_API_URL_BROWSER() {
|
|
48
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_API_URL_BROWSER ?? process.env.STACK_API_URL_BROWSER : void 0) ?? void 0;
|
|
49
|
-
},
|
|
50
|
-
get NEXT_PUBLIC_SERVER_STACK_API_URL() {
|
|
51
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_SERVER_HEXCLAVE_API_URL ?? process.env.NEXT_PUBLIC_SERVER_STACK_API_URL : void 0) ?? void 0;
|
|
52
|
-
},
|
|
53
|
-
get NEXT_PUBLIC_STACK_API_URL_SERVER() {
|
|
54
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_API_URL_SERVER ?? process.env.NEXT_PUBLIC_STACK_API_URL_SERVER : void 0) ?? void 0;
|
|
55
|
-
},
|
|
56
|
-
get STACK_API_URL_SERVER() {
|
|
57
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_API_URL_SERVER ?? process.env.STACK_API_URL_SERVER : void 0) ?? void 0;
|
|
58
|
-
},
|
|
59
|
-
get NEXT_PUBLIC_STACK_API_URL() {
|
|
60
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_API_URL ?? process.env.NEXT_PUBLIC_STACK_API_URL : void 0) ?? void 0;
|
|
61
|
-
},
|
|
62
|
-
get STACK_API_URL() {
|
|
63
|
-
return (typeof process !== "undefined" ? process.env.HEXCLAVE_API_URL ?? process.env.STACK_API_URL : void 0) ?? void 0;
|
|
64
|
-
},
|
|
65
|
-
get NEXT_PUBLIC_STACK_URL() {
|
|
66
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_URL ?? process.env.NEXT_PUBLIC_STACK_URL : void 0) ?? void 0;
|
|
67
|
-
},
|
|
68
|
-
get NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX() {
|
|
69
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_HOSTED_HANDLER_DOMAIN_SUFFIX ?? process.env.NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX : void 0) ?? void 0;
|
|
70
|
-
},
|
|
71
|
-
get NEXT_PUBLIC_STACK_HOSTED_HANDLER_URL_TEMPLATE() {
|
|
72
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_HOSTED_HANDLER_URL_TEMPLATE ?? process.env.NEXT_PUBLIC_STACK_HOSTED_HANDLER_URL_TEMPLATE : void 0) ?? void 0;
|
|
73
|
-
},
|
|
74
|
-
get NEXT_PUBLIC_STACK_STRIPE_PUBLISHABLE_KEY() {
|
|
75
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_STRIPE_PUBLISHABLE_KEY ?? process.env.NEXT_PUBLIC_STACK_STRIPE_PUBLISHABLE_KEY : void 0) ?? void 0;
|
|
76
|
-
},
|
|
77
|
-
get NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY() {
|
|
78
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_BOT_CHALLENGE_SITE_KEY ?? process.env.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY : void 0) ?? void 0;
|
|
79
|
-
},
|
|
80
|
-
get NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY() {
|
|
81
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_BOT_CHALLENGE_INVISIBLE_SITE_KEY ?? process.env.NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY : void 0) ?? void 0;
|
|
82
|
-
},
|
|
83
|
-
get NODE_ENV() {
|
|
84
|
-
return (typeof process !== "undefined" ? process.env.NODE_ENV : void 0) ?? void 0;
|
|
85
|
-
},
|
|
86
|
-
get NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR() {
|
|
87
|
-
return (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_IS_LOCAL_EMULATOR ?? process.env.NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR : void 0) ?? void 0;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
//#endregion
|
|
92
|
-
export { envVars };
|
|
93
|
-
//# sourceMappingURL=env.js.map
|
package/dist/esm/lib/env.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","names":[],"sources":["../../../src/lib/env.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n/**\n * Centralized environment-variable reads for the SDK.\n *\n * Keep each key explicit and reference `process.env.KEY` directly so bundlers\n * like Next.js can inline values at build time.\n *\n * Hexclave rebrand: each getter prefers the HEXCLAVE_*-prefixed literal and\n * falls back to the legacy STACK_* literal(s). Both operands stay literal\n * `process.env.X` references so bundlers can inline them. The port-prefix var\n * is a straight rename (no dual-read).\n */\nexport const envVars = {\n // Hexclave rebrand: port-prefix var renamed outright (no dual-read).\n get NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_PROJECT_ID() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_PROJECT_ID ?? process.env.NEXT_PUBLIC_STACK_PROJECT_ID : undefined) ?? undefined;\n },\n get STACK_PROJECT_ID() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_PROJECT_ID ?? process.env.STACK_PROJECT_ID : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_PUBLISHABLE_CLIENT_KEY ?? process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY : undefined) ?? undefined;\n },\n get STACK_PUBLISHABLE_CLIENT_KEY() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_PUBLISHABLE_CLIENT_KEY ?? process.env.STACK_PUBLISHABLE_CLIENT_KEY : undefined) ?? undefined;\n },\n get STACK_SECRET_SERVER_KEY() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_SECRET_SERVER_KEY ?? process.env.STACK_SECRET_SERVER_KEY : undefined) ?? undefined;\n },\n get STACK_SUPER_SECRET_ADMIN_KEY() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_SUPER_SECRET_ADMIN_KEY ?? process.env.STACK_SUPER_SECRET_ADMIN_KEY : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_EXTRA_REQUEST_HEADERS ?? process.env.NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS : undefined) ?? undefined;\n },\n get STACK_EXTRA_REQUEST_HEADERS() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_EXTRA_REQUEST_HEADERS ?? process.env.STACK_EXTRA_REQUEST_HEADERS : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_BROWSER_STACK_API_URL() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_BROWSER_HEXCLAVE_API_URL ?? process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_API_URL_BROWSER() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_API_URL_BROWSER ?? process.env.NEXT_PUBLIC_STACK_API_URL_BROWSER : undefined) ?? undefined;\n },\n get STACK_API_URL_BROWSER() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_API_URL_BROWSER ?? process.env.STACK_API_URL_BROWSER : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_SERVER_STACK_API_URL() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_SERVER_HEXCLAVE_API_URL ?? process.env.NEXT_PUBLIC_SERVER_STACK_API_URL : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_API_URL_SERVER() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_API_URL_SERVER ?? process.env.NEXT_PUBLIC_STACK_API_URL_SERVER : undefined) ?? undefined;\n },\n get STACK_API_URL_SERVER() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_API_URL_SERVER ?? process.env.STACK_API_URL_SERVER : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_API_URL() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_API_URL ?? process.env.NEXT_PUBLIC_STACK_API_URL : undefined) ?? undefined;\n },\n get STACK_API_URL() {\n return (typeof process !== \"undefined\" ? process.env.HEXCLAVE_API_URL ?? process.env.STACK_API_URL : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_URL() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_URL ?? process.env.NEXT_PUBLIC_STACK_URL : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_HOSTED_HANDLER_DOMAIN_SUFFIX ?? process.env.NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_HOSTED_HANDLER_URL_TEMPLATE() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_HOSTED_HANDLER_URL_TEMPLATE ?? process.env.NEXT_PUBLIC_STACK_HOSTED_HANDLER_URL_TEMPLATE : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_STRIPE_PUBLISHABLE_KEY() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_STRIPE_PUBLISHABLE_KEY ?? process.env.NEXT_PUBLIC_STACK_STRIPE_PUBLISHABLE_KEY : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_BOT_CHALLENGE_SITE_KEY ?? process.env.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_BOT_CHALLENGE_INVISIBLE_SITE_KEY ?? process.env.NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY : undefined) ?? undefined;\n },\n get NODE_ENV() {\n return (typeof process !== \"undefined\" ? process.env.NODE_ENV : undefined) ?? undefined;\n },\n get NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR() {\n return (typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_IS_LOCAL_EMULATOR ?? process.env.NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR : undefined) ?? undefined;\n },\n};\n"],"mappings":"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"}
|
package/dist/lib/env.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region src/lib/env.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Centralized environment-variable reads for the SDK.
|
|
4
|
-
*
|
|
5
|
-
* Keep each key explicit and reference `process.env.KEY` directly so bundlers
|
|
6
|
-
* like Next.js can inline values at build time.
|
|
7
|
-
*
|
|
8
|
-
* Hexclave rebrand: each getter prefers the HEXCLAVE_*-prefixed literal and
|
|
9
|
-
* falls back to the legacy STACK_* literal(s). Both operands stay literal
|
|
10
|
-
* `process.env.X` references so bundlers can inline them. The port-prefix var
|
|
11
|
-
* is a straight rename (no dual-read).
|
|
12
|
-
*/
|
|
13
|
-
declare const envVars: {
|
|
14
|
-
readonly NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX: string | undefined;
|
|
15
|
-
readonly NEXT_PUBLIC_STACK_PROJECT_ID: string | undefined;
|
|
16
|
-
readonly STACK_PROJECT_ID: string | undefined;
|
|
17
|
-
readonly NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY: string | undefined;
|
|
18
|
-
readonly STACK_PUBLISHABLE_CLIENT_KEY: string | undefined;
|
|
19
|
-
readonly STACK_SECRET_SERVER_KEY: string | undefined;
|
|
20
|
-
readonly STACK_SUPER_SECRET_ADMIN_KEY: string | undefined;
|
|
21
|
-
readonly NEXT_PUBLIC_STACK_EXTRA_REQUEST_HEADERS: string | undefined;
|
|
22
|
-
readonly STACK_EXTRA_REQUEST_HEADERS: string | undefined;
|
|
23
|
-
readonly NEXT_PUBLIC_BROWSER_STACK_API_URL: string | undefined;
|
|
24
|
-
readonly NEXT_PUBLIC_STACK_API_URL_BROWSER: string | undefined;
|
|
25
|
-
readonly STACK_API_URL_BROWSER: string | undefined;
|
|
26
|
-
readonly NEXT_PUBLIC_SERVER_STACK_API_URL: string | undefined;
|
|
27
|
-
readonly NEXT_PUBLIC_STACK_API_URL_SERVER: string | undefined;
|
|
28
|
-
readonly STACK_API_URL_SERVER: string | undefined;
|
|
29
|
-
readonly NEXT_PUBLIC_STACK_API_URL: string | undefined;
|
|
30
|
-
readonly STACK_API_URL: string | undefined;
|
|
31
|
-
readonly NEXT_PUBLIC_STACK_URL: string | undefined;
|
|
32
|
-
readonly NEXT_PUBLIC_STACK_HOSTED_HANDLER_DOMAIN_SUFFIX: string | undefined;
|
|
33
|
-
readonly NEXT_PUBLIC_STACK_HOSTED_HANDLER_URL_TEMPLATE: string | undefined;
|
|
34
|
-
readonly NEXT_PUBLIC_STACK_STRIPE_PUBLISHABLE_KEY: string | undefined;
|
|
35
|
-
readonly NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY: string | undefined;
|
|
36
|
-
readonly NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY: string | undefined;
|
|
37
|
-
readonly NODE_ENV: string | undefined;
|
|
38
|
-
readonly NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR: string | undefined;
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
41
|
-
export { envVars };
|
|
42
|
-
//# sourceMappingURL=env.d.ts.map
|