@hexclave/next 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/payments/payments-panel.js +3 -3
- package/dist/components-page/account-settings/payments/payments-panel.js.map +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/payments/payments-panel.js +2 -2
- package/dist/esm/components-page/account-settings/payments/payments-panel.js.map +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/generated/quetzal-translations.d.ts +2 -2
- package/dist/esm/global.d.ts +8 -1
- package/dist/esm/global.d.ts.map +1 -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.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 +53 -26
- 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 +28 -14
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +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/generated/quetzal-translations.d.ts +2 -2
- package/dist/global.d.ts +8 -1
- package/dist/global.d.ts.map +1 -0
- 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 +52 -25
- 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 +28 -14
- package/dist/lib/hexclave-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +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 +9 -7
- 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 +50 -11
- 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/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 cookie from "cookie";
|
|
45
45
|
import * as NextNavigationUnscrambled from "next/navigation"; // import the entire module to get around some static compiler warnings emitted by Next.js in some cases | THIS_LINE_PLATFORM next
|
|
@@ -48,7 +48,7 @@ import type * as yup from "yup";
|
|
|
48
48
|
import { constructRedirectUrl } from "../../../../utils/url";
|
|
49
49
|
import { callOAuthCallback, getNewOAuthProviderOrScopeUrl } from "../../../auth";
|
|
50
50
|
import { CookieHelper, createBrowserCookieHelper, createCookieHelper, createPlaceholderCookieHelper, deleteCookie, deleteCookieClient, getCookieClient, isSecure as isSecureCookieContext, saveVerifierAndState, setOrDeleteCookie, setOrDeleteCookieClient } from "../../../cookie";
|
|
51
|
-
import { envVars } from "
|
|
51
|
+
import { envVars } from "../../../../generated/env";
|
|
52
52
|
import { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud } from "../../api-keys";
|
|
53
53
|
import { ConvexCtx, GetCurrentPartialUserOptions, GetCurrentUserOptions, HandlerUrlOptions, HandlerUrls, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, RequestLike, ResolvedHandlerUrls, TokenStoreInit, hexclaveAppInternalsSymbol } from "../../common";
|
|
54
54
|
import { DeprecatedOAuthConnection, OAuthConnection } from "../../connected-accounts";
|
|
@@ -815,12 +815,16 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
815
815
|
return currentUrl.toString();
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
protected async
|
|
818
|
+
protected async _fetchCurrentRefreshTokenIdIfSignedIn(options?: {
|
|
819
819
|
awaitPendingAuthResolutions?: boolean,
|
|
820
820
|
overrideTokenStoreInit?: TokenStoreInit,
|
|
821
821
|
}): Promise<string | null> {
|
|
822
822
|
const session = await this._getSession(options?.overrideTokenStoreInit, options);
|
|
823
|
-
|
|
823
|
+
// Nested cross-domain auth passes this ID to another origin, which later
|
|
824
|
+
// asks us to prove the same raw refresh token. A cached access token can be
|
|
825
|
+
// valid but stale relative to the refresh token, so mint from the refresh
|
|
826
|
+
// token that owns this session before exposing the ID.
|
|
827
|
+
const tokens = await session.fetchNewTokens();
|
|
824
828
|
if (tokens?.refreshToken == null) {
|
|
825
829
|
return null;
|
|
826
830
|
}
|
|
@@ -838,7 +842,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
838
842
|
return options.url;
|
|
839
843
|
}
|
|
840
844
|
|
|
841
|
-
const refreshTokenId = await this.
|
|
845
|
+
const refreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({
|
|
842
846
|
awaitPendingAuthResolutions: options.awaitPendingAuthResolutions,
|
|
843
847
|
overrideTokenStoreInit: options.overrideTokenStoreInit,
|
|
844
848
|
});
|
|
@@ -893,7 +897,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
893
897
|
if (!await this._isTrusted(afterCallbackRedirectUrl.toString())) {
|
|
894
898
|
throw new Error(`Nested cross-domain auth after-callback redirect URL ${afterCallbackRedirectUrlString} is not trusted.`);
|
|
895
899
|
}
|
|
896
|
-
const currentRefreshTokenId = await this.
|
|
900
|
+
const currentRefreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false });
|
|
897
901
|
if (currentRefreshTokenId !== refreshTokenId) {
|
|
898
902
|
throw new Error("Nested cross-domain auth source session does not match the requested refresh token ID.");
|
|
899
903
|
}
|
|
@@ -912,8 +916,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
912
916
|
|
|
913
917
|
// We are on b.com. Bounce to the trusted callback on a.com with a normal OAuth request
|
|
914
918
|
// shape; a.com will verify the source session and issue the one-time code.
|
|
915
|
-
const currentRefreshTokenId = await this.
|
|
919
|
+
const currentRefreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false });
|
|
916
920
|
if (currentRefreshTokenId === refreshTokenId) return false;
|
|
921
|
+
if (currentRefreshTokenId != null) {
|
|
922
|
+
const session = await this._getSession(undefined, { awaitPendingAuthResolutions: false });
|
|
923
|
+
session.markInvalid();
|
|
924
|
+
}
|
|
917
925
|
const callbackUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
918
926
|
if (callbackUrlString == null) {
|
|
919
927
|
throw new HexclaveAssertionError("Nested cross-domain auth URL is missing callback URL");
|
|
@@ -1106,6 +1114,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1106
1114
|
accessToken,
|
|
1107
1115
|
};
|
|
1108
1116
|
}
|
|
1117
|
+
private _getCurrentBrowserCookieTokenStoreValue(old: TokenObject | null): TokenObject {
|
|
1118
|
+
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
1119
|
+
return {
|
|
1120
|
+
refreshToken: tokens.refreshToken,
|
|
1121
|
+
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null),
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1109
1124
|
protected get _accessTokenCookieName() {
|
|
1110
1125
|
// The access token, unlike the refresh token, should not depend on the project ID. We never want to store the
|
|
1111
1126
|
// access token in cookies more than once because of how big it is (there's a limit of 4096 bytes for all cookies
|
|
@@ -1248,20 +1263,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1248
1263
|
}
|
|
1249
1264
|
|
|
1250
1265
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
1251
|
-
|
|
1252
|
-
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
1253
|
-
return {
|
|
1254
|
-
refreshToken: tokens.refreshToken,
|
|
1255
|
-
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null),
|
|
1256
|
-
};
|
|
1257
|
-
};
|
|
1258
|
-
this._storedBrowserCookieTokenStore = new Store<TokenObject>(getCurrentValue(null));
|
|
1266
|
+
this._storedBrowserCookieTokenStore = new Store<TokenObject>(this._getCurrentBrowserCookieTokenStoreValue(null));
|
|
1259
1267
|
let hasSucceededInWriting = true;
|
|
1260
1268
|
|
|
1261
1269
|
setInterval(() => {
|
|
1262
1270
|
if (hasSucceededInWriting) {
|
|
1263
1271
|
const oldValue = this._storedBrowserCookieTokenStore!.get();
|
|
1264
|
-
const currentValue =
|
|
1272
|
+
const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
|
|
1265
1273
|
if (!deepPlainEquals(currentValue, oldValue)) {
|
|
1266
1274
|
this._storedBrowserCookieTokenStore!.set(currentValue);
|
|
1267
1275
|
}
|
|
@@ -1295,6 +1303,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1295
1303
|
}
|
|
1296
1304
|
}
|
|
1297
1305
|
});
|
|
1306
|
+
} else {
|
|
1307
|
+
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
1308
|
+
const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
|
|
1309
|
+
if (!deepPlainEquals(currentValue, oldValue)) {
|
|
1310
|
+
this._storedBrowserCookieTokenStore.set(currentValue);
|
|
1311
|
+
}
|
|
1298
1312
|
}
|
|
1299
1313
|
|
|
1300
1314
|
return this._storedBrowserCookieTokenStore;
|
|
@@ -1437,17 +1451,17 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1437
1451
|
accessToken: tokenObj.accessToken,
|
|
1438
1452
|
});
|
|
1439
1453
|
session.onAccessTokenChange((newAccessToken) => {
|
|
1440
|
-
tokenStore.update((old) => ({
|
|
1454
|
+
tokenStore.update((old) => InternalSession.calculateSessionKey(old) === sessionKey ? {
|
|
1441
1455
|
...old,
|
|
1442
1456
|
accessToken: newAccessToken?.token ?? null
|
|
1443
|
-
})
|
|
1457
|
+
} : old);
|
|
1444
1458
|
});
|
|
1445
1459
|
session.onInvalidate(() => {
|
|
1446
|
-
tokenStore.update((old) => ({
|
|
1460
|
+
tokenStore.update((old) => InternalSession.calculateSessionKey(old) === sessionKey ? {
|
|
1447
1461
|
...old,
|
|
1448
1462
|
accessToken: null,
|
|
1449
1463
|
refreshToken: null,
|
|
1450
|
-
})
|
|
1464
|
+
} : old);
|
|
1451
1465
|
});
|
|
1452
1466
|
|
|
1453
1467
|
let sessionsBySessionKey = this._sessionsByTokenStoreAndSessionKey.get(tokenStore) ?? new Map();
|
|
@@ -2547,16 +2561,16 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2547
2561
|
private _getBotChallengeSiteKeys(): { visibleSiteKey: string, invisibleSiteKey: string } | null {
|
|
2548
2562
|
if (!isBrowserLike()) return null;
|
|
2549
2563
|
|
|
2550
|
-
const visibleSiteKey = envVars.
|
|
2564
|
+
const visibleSiteKey = envVars.HEXCLAVE_BOT_CHALLENGE_SITE_KEY;
|
|
2551
2565
|
if (!visibleSiteKey) {
|
|
2552
2566
|
if (!this._botChallengeSiteKeysWarned) {
|
|
2553
2567
|
this._botChallengeSiteKeysWarned = true;
|
|
2554
|
-
console.warn("[stack-auth]
|
|
2568
|
+
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.");
|
|
2555
2569
|
}
|
|
2556
2570
|
return null;
|
|
2557
2571
|
}
|
|
2558
2572
|
|
|
2559
|
-
const invisibleSiteKey = envVars.
|
|
2573
|
+
const invisibleSiteKey = envVars.HEXCLAVE_BOT_CHALLENGE_INVISIBLE_SITE_KEY ?? visibleSiteKey;
|
|
2560
2574
|
|
|
2561
2575
|
return { visibleSiteKey, invisibleSiteKey };
|
|
2562
2576
|
}
|
|
@@ -2738,6 +2752,11 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2738
2752
|
overrideTokenStoreInit?: TokenStoreInit,
|
|
2739
2753
|
}): Promise<string> {
|
|
2740
2754
|
const session = await this._getSession(options.overrideTokenStoreInit, { awaitPendingAuthResolutions: options.awaitPendingAuthResolutions });
|
|
2755
|
+
// The authorize endpoint intentionally verifies that the access token and
|
|
2756
|
+
// raw refresh token describe the same DB session. Force the access token to
|
|
2757
|
+
// be minted from the refresh token we are about to send, instead of reusing
|
|
2758
|
+
// a still-valid cached token from a pre-handoff session snapshot.
|
|
2759
|
+
await session.fetchNewTokens();
|
|
2741
2760
|
const response = await this._interface.sendClientRequest(
|
|
2742
2761
|
"/auth/oauth/cross-domain/authorize",
|
|
2743
2762
|
{
|
|
@@ -2878,7 +2897,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2878
2897
|
|
|
2879
2898
|
async redirectToSignIn(options?: RedirectToOptions) { return await this._redirectToHandler("signIn", options); }
|
|
2880
2899
|
async redirectToSignUp(options?: RedirectToOptions) { return await this._redirectToHandler("signUp", options); }
|
|
2881
|
-
async redirectToSignOut(options?: RedirectToOptions) {
|
|
2900
|
+
async redirectToSignOut(options?: RedirectToOptions) {
|
|
2901
|
+
const configuredSignOutTarget = this._urlOptions.signOut ?? this._urlOptions.default;
|
|
2902
|
+
if (typeof configuredSignOutTarget !== "string" && configuredSignOutTarget?.type === "hosted") {
|
|
2903
|
+
return await this.signOut();
|
|
2904
|
+
}
|
|
2905
|
+
return await this._redirectToHandler("signOut", options);
|
|
2906
|
+
}
|
|
2882
2907
|
async redirectToEmailVerification(options?: RedirectToOptions) { return await this._redirectToHandler("emailVerification", options); }
|
|
2883
2908
|
async redirectToPasswordReset(options?: RedirectToOptions) { return await this._redirectToHandler("passwordReset", options); }
|
|
2884
2909
|
async redirectToForgotPassword(options?: RedirectToOptions) { return await this._redirectToHandler("forgotPassword", options); }
|
|
@@ -3675,11 +3700,30 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
3675
3700
|
if (options?.redirectUrl) {
|
|
3676
3701
|
await this._redirectTo({ url: options.redirectUrl, replace: true });
|
|
3677
3702
|
} else {
|
|
3678
|
-
await this.
|
|
3703
|
+
await this._redirectToDefaultAfterSignOut();
|
|
3679
3704
|
}
|
|
3680
3705
|
});
|
|
3681
3706
|
}
|
|
3682
3707
|
|
|
3708
|
+
protected async _redirectToDefaultAfterSignOut(): Promise<void> {
|
|
3709
|
+
if (this._urlOptions.afterSignOut != null) {
|
|
3710
|
+
await this.redirectToAfterSignOut({ replace: true });
|
|
3711
|
+
return;
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
if (this._urlOptions.home != null) {
|
|
3715
|
+
await this.redirectToHome({ replace: true });
|
|
3716
|
+
return;
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3719
|
+
if (this._urlOptions.default?.type === "hosted" && typeof window !== "undefined") {
|
|
3720
|
+
await this._redirectTo({ url: getRelativePart(new URL(window.location.href)), replace: true });
|
|
3721
|
+
return;
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
await this.redirectToAfterSignOut({ replace: true });
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3683
3727
|
async signOut(options?: { redirectUrl?: URL | string, tokenStore?: TokenStoreInit }): Promise<void> {
|
|
3684
3728
|
const user = await this.getUser({ tokenStore: options?.tokenStore ?? undefined as any });
|
|
3685
3729
|
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);
|
|
@@ -214,6 +233,7 @@ export function useAsyncCache<D extends any[], T>(cache: AsyncCache<D, Result<T>
|
|
|
214
233
|
});
|
|
215
234
|
return unsubscribe;
|
|
216
235
|
}, [cache, ...dependencies]);
|
|
236
|
+
|
|
217
237
|
const getSnapshot = useCallback(() => {
|
|
218
238
|
// React checks whether a promise passed to `use` is still the same as the previous one by comparing the reference.
|
|
219
239
|
// 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
|