@hexclave/react 1.0.5 → 1.0.6
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/cli-auth-confirm.js +1 -1
- package/dist/components-page/cli-auth-confirm.test.js +2 -2
- 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 +46 -11
- 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 +4 -4
- package/dist/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/dev-tool/dev-tool-trigger-position.test.js +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/cli-auth-confirm.js +1 -1
- package/dist/esm/components-page/cli-auth-confirm.test.js +2 -2
- 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 +48 -14
- 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 +4 -4
- package/dist/esm/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-trigger-position.test.js +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/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/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 +8 -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/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 React, { useCallback, useMemo } from "react"; // THIS_LINE_PLATFORM react-like
|
|
@@ -47,7 +47,7 @@ import type * as yup from "yup";
|
|
|
47
47
|
import { constructRedirectUrl } from "../../../../utils/url";
|
|
48
48
|
import { callOAuthCallback, getNewOAuthProviderOrScopeUrl } from "../../../auth";
|
|
49
49
|
import { CookieHelper, createBrowserCookieHelper, createCookieHelper, createPlaceholderCookieHelper, deleteCookie, deleteCookieClient, getCookieClient, isSecure as isSecureCookieContext, saveVerifierAndState, setOrDeleteCookie, setOrDeleteCookieClient } from "../../../cookie";
|
|
50
|
-
import { envVars } from "
|
|
50
|
+
import { envVars } from "../../../../generated/env";
|
|
51
51
|
import { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud } from "../../api-keys";
|
|
52
52
|
import { ConvexCtx, GetCurrentPartialUserOptions, GetCurrentUserOptions, HandlerUrlOptions, HandlerUrls, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, RequestLike, ResolvedHandlerUrls, TokenStoreInit, hexclaveAppInternalsSymbol } from "../../common";
|
|
53
53
|
import { DeprecatedOAuthConnection, OAuthConnection } from "../../connected-accounts";
|
|
@@ -806,12 +806,16 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
806
806
|
return currentUrl.toString();
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
-
protected async
|
|
809
|
+
protected async _fetchCurrentRefreshTokenIdIfSignedIn(options?: {
|
|
810
810
|
awaitPendingAuthResolutions?: boolean,
|
|
811
811
|
overrideTokenStoreInit?: TokenStoreInit,
|
|
812
812
|
}): Promise<string | null> {
|
|
813
813
|
const session = await this._getSession(options?.overrideTokenStoreInit, options);
|
|
814
|
-
|
|
814
|
+
// Nested cross-domain auth passes this ID to another origin, which later
|
|
815
|
+
// asks us to prove the same raw refresh token. A cached access token can be
|
|
816
|
+
// valid but stale relative to the refresh token, so mint from the refresh
|
|
817
|
+
// token that owns this session before exposing the ID.
|
|
818
|
+
const tokens = await session.fetchNewTokens();
|
|
815
819
|
if (tokens?.refreshToken == null) {
|
|
816
820
|
return null;
|
|
817
821
|
}
|
|
@@ -829,7 +833,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
829
833
|
return options.url;
|
|
830
834
|
}
|
|
831
835
|
|
|
832
|
-
const refreshTokenId = await this.
|
|
836
|
+
const refreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({
|
|
833
837
|
awaitPendingAuthResolutions: options.awaitPendingAuthResolutions,
|
|
834
838
|
overrideTokenStoreInit: options.overrideTokenStoreInit,
|
|
835
839
|
});
|
|
@@ -884,7 +888,7 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
884
888
|
if (!await this._isTrusted(afterCallbackRedirectUrl.toString())) {
|
|
885
889
|
throw new Error(`Nested cross-domain auth after-callback redirect URL ${afterCallbackRedirectUrlString} is not trusted.`);
|
|
886
890
|
}
|
|
887
|
-
const currentRefreshTokenId = await this.
|
|
891
|
+
const currentRefreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false });
|
|
888
892
|
if (currentRefreshTokenId !== refreshTokenId) {
|
|
889
893
|
throw new Error("Nested cross-domain auth source session does not match the requested refresh token ID.");
|
|
890
894
|
}
|
|
@@ -903,8 +907,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
903
907
|
|
|
904
908
|
// We are on b.com. Bounce to the trusted callback on a.com with a normal OAuth request
|
|
905
909
|
// shape; a.com will verify the source session and issue the one-time code.
|
|
906
|
-
const currentRefreshTokenId = await this.
|
|
910
|
+
const currentRefreshTokenId = await this._fetchCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false });
|
|
907
911
|
if (currentRefreshTokenId === refreshTokenId) return false;
|
|
912
|
+
if (currentRefreshTokenId != null) {
|
|
913
|
+
const session = await this._getSession(undefined, { awaitPendingAuthResolutions: false });
|
|
914
|
+
session.markInvalid();
|
|
915
|
+
}
|
|
908
916
|
const callbackUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
909
917
|
if (callbackUrlString == null) {
|
|
910
918
|
throw new HexclaveAssertionError("Nested cross-domain auth URL is missing callback URL");
|
|
@@ -1097,6 +1105,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1097
1105
|
accessToken,
|
|
1098
1106
|
};
|
|
1099
1107
|
}
|
|
1108
|
+
private _getCurrentBrowserCookieTokenStoreValue(old: TokenObject | null): TokenObject {
|
|
1109
|
+
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
1110
|
+
return {
|
|
1111
|
+
refreshToken: tokens.refreshToken,
|
|
1112
|
+
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null),
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1100
1115
|
protected get _accessTokenCookieName() {
|
|
1101
1116
|
// The access token, unlike the refresh token, should not depend on the project ID. We never want to store the
|
|
1102
1117
|
// access token in cookies more than once because of how big it is (there's a limit of 4096 bytes for all cookies
|
|
@@ -1239,20 +1254,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1239
1254
|
}
|
|
1240
1255
|
|
|
1241
1256
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
1242
|
-
|
|
1243
|
-
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
1244
|
-
return {
|
|
1245
|
-
refreshToken: tokens.refreshToken,
|
|
1246
|
-
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null),
|
|
1247
|
-
};
|
|
1248
|
-
};
|
|
1249
|
-
this._storedBrowserCookieTokenStore = new Store<TokenObject>(getCurrentValue(null));
|
|
1257
|
+
this._storedBrowserCookieTokenStore = new Store<TokenObject>(this._getCurrentBrowserCookieTokenStoreValue(null));
|
|
1250
1258
|
let hasSucceededInWriting = true;
|
|
1251
1259
|
|
|
1252
1260
|
setInterval(() => {
|
|
1253
1261
|
if (hasSucceededInWriting) {
|
|
1254
1262
|
const oldValue = this._storedBrowserCookieTokenStore!.get();
|
|
1255
|
-
const currentValue =
|
|
1263
|
+
const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
|
|
1256
1264
|
if (!deepPlainEquals(currentValue, oldValue)) {
|
|
1257
1265
|
this._storedBrowserCookieTokenStore!.set(currentValue);
|
|
1258
1266
|
}
|
|
@@ -1286,6 +1294,12 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1286
1294
|
}
|
|
1287
1295
|
}
|
|
1288
1296
|
});
|
|
1297
|
+
} else {
|
|
1298
|
+
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
1299
|
+
const currentValue = this._getCurrentBrowserCookieTokenStoreValue(oldValue);
|
|
1300
|
+
if (!deepPlainEquals(currentValue, oldValue)) {
|
|
1301
|
+
this._storedBrowserCookieTokenStore.set(currentValue);
|
|
1302
|
+
}
|
|
1289
1303
|
}
|
|
1290
1304
|
|
|
1291
1305
|
return this._storedBrowserCookieTokenStore;
|
|
@@ -1428,17 +1442,17 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
1428
1442
|
accessToken: tokenObj.accessToken,
|
|
1429
1443
|
});
|
|
1430
1444
|
session.onAccessTokenChange((newAccessToken) => {
|
|
1431
|
-
tokenStore.update((old) => ({
|
|
1445
|
+
tokenStore.update((old) => InternalSession.calculateSessionKey(old) === sessionKey ? {
|
|
1432
1446
|
...old,
|
|
1433
1447
|
accessToken: newAccessToken?.token ?? null
|
|
1434
|
-
})
|
|
1448
|
+
} : old);
|
|
1435
1449
|
});
|
|
1436
1450
|
session.onInvalidate(() => {
|
|
1437
|
-
tokenStore.update((old) => ({
|
|
1451
|
+
tokenStore.update((old) => InternalSession.calculateSessionKey(old) === sessionKey ? {
|
|
1438
1452
|
...old,
|
|
1439
1453
|
accessToken: null,
|
|
1440
1454
|
refreshToken: null,
|
|
1441
|
-
})
|
|
1455
|
+
} : old);
|
|
1442
1456
|
});
|
|
1443
1457
|
|
|
1444
1458
|
let sessionsBySessionKey = this._sessionsByTokenStoreAndSessionKey.get(tokenStore) ?? new Map();
|
|
@@ -2538,16 +2552,16 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2538
2552
|
private _getBotChallengeSiteKeys(): { visibleSiteKey: string, invisibleSiteKey: string } | null {
|
|
2539
2553
|
if (!isBrowserLike()) return null;
|
|
2540
2554
|
|
|
2541
|
-
const visibleSiteKey = envVars.
|
|
2555
|
+
const visibleSiteKey = envVars.HEXCLAVE_BOT_CHALLENGE_SITE_KEY;
|
|
2542
2556
|
if (!visibleSiteKey) {
|
|
2543
2557
|
if (!this._botChallengeSiteKeysWarned) {
|
|
2544
2558
|
this._botChallengeSiteKeysWarned = true;
|
|
2545
|
-
console.warn("[stack-auth]
|
|
2559
|
+
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.");
|
|
2546
2560
|
}
|
|
2547
2561
|
return null;
|
|
2548
2562
|
}
|
|
2549
2563
|
|
|
2550
|
-
const invisibleSiteKey = envVars.
|
|
2564
|
+
const invisibleSiteKey = envVars.HEXCLAVE_BOT_CHALLENGE_INVISIBLE_SITE_KEY ?? visibleSiteKey;
|
|
2551
2565
|
|
|
2552
2566
|
return { visibleSiteKey, invisibleSiteKey };
|
|
2553
2567
|
}
|
|
@@ -2729,6 +2743,11 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2729
2743
|
overrideTokenStoreInit?: TokenStoreInit,
|
|
2730
2744
|
}): Promise<string> {
|
|
2731
2745
|
const session = await this._getSession(options.overrideTokenStoreInit, { awaitPendingAuthResolutions: options.awaitPendingAuthResolutions });
|
|
2746
|
+
// The authorize endpoint intentionally verifies that the access token and
|
|
2747
|
+
// raw refresh token describe the same DB session. Force the access token to
|
|
2748
|
+
// be minted from the refresh token we are about to send, instead of reusing
|
|
2749
|
+
// a still-valid cached token from a pre-handoff session snapshot.
|
|
2750
|
+
await session.fetchNewTokens();
|
|
2732
2751
|
const response = await this._interface.sendClientRequest(
|
|
2733
2752
|
"/auth/oauth/cross-domain/authorize",
|
|
2734
2753
|
{
|
|
@@ -2864,7 +2883,13 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
2864
2883
|
|
|
2865
2884
|
async redirectToSignIn(options?: RedirectToOptions) { return await this._redirectToHandler("signIn", options); }
|
|
2866
2885
|
async redirectToSignUp(options?: RedirectToOptions) { return await this._redirectToHandler("signUp", options); }
|
|
2867
|
-
async redirectToSignOut(options?: RedirectToOptions) {
|
|
2886
|
+
async redirectToSignOut(options?: RedirectToOptions) {
|
|
2887
|
+
const configuredSignOutTarget = this._urlOptions.signOut ?? this._urlOptions.default;
|
|
2888
|
+
if (typeof configuredSignOutTarget !== "string" && configuredSignOutTarget?.type === "hosted") {
|
|
2889
|
+
return await this.signOut();
|
|
2890
|
+
}
|
|
2891
|
+
return await this._redirectToHandler("signOut", options);
|
|
2892
|
+
}
|
|
2868
2893
|
async redirectToEmailVerification(options?: RedirectToOptions) { return await this._redirectToHandler("emailVerification", options); }
|
|
2869
2894
|
async redirectToPasswordReset(options?: RedirectToOptions) { return await this._redirectToHandler("passwordReset", options); }
|
|
2870
2895
|
async redirectToForgotPassword(options?: RedirectToOptions) { return await this._redirectToHandler("forgotPassword", options); }
|
|
@@ -3661,11 +3686,30 @@ export class _HexclaveClientAppImplIncomplete<HasTokenStore extends boolean, Pro
|
|
|
3661
3686
|
if (options?.redirectUrl) {
|
|
3662
3687
|
await this._redirectTo({ url: options.redirectUrl, replace: true });
|
|
3663
3688
|
} else {
|
|
3664
|
-
await this.
|
|
3689
|
+
await this._redirectToDefaultAfterSignOut();
|
|
3665
3690
|
}
|
|
3666
3691
|
});
|
|
3667
3692
|
}
|
|
3668
3693
|
|
|
3694
|
+
protected async _redirectToDefaultAfterSignOut(): Promise<void> {
|
|
3695
|
+
if (this._urlOptions.afterSignOut != null) {
|
|
3696
|
+
await this.redirectToAfterSignOut({ replace: true });
|
|
3697
|
+
return;
|
|
3698
|
+
}
|
|
3699
|
+
|
|
3700
|
+
if (this._urlOptions.home != null) {
|
|
3701
|
+
await this.redirectToHome({ replace: true });
|
|
3702
|
+
return;
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
if (this._urlOptions.default?.type === "hosted" && typeof window !== "undefined") {
|
|
3706
|
+
await this._redirectTo({ url: getRelativePart(new URL(window.location.href)), replace: true });
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
|
|
3710
|
+
await this.redirectToAfterSignOut({ replace: true });
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3669
3713
|
async signOut(options?: { redirectUrl?: URL | string, tokenStore?: TokenStoreInit }): Promise<void> {
|
|
3670
3714
|
const user = await this.getUser({ tokenStore: options?.tokenStore ?? undefined as any });
|
|
3671
3715
|
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":";;;;;;;;;;;;AAeA,MAAa,UAAU;CAErB,IAAI,mCAAmC;AACrC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,mCAAmC,WAAc;;CAExG,IAAI,+BAA+B;AACjC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,mCAAmC,QAAQ,IAAI,+BAA+B,WAAc;;CAEnJ,IAAI,mBAAmB;AACrB,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,uBAAuB,QAAQ,IAAI,mBAAmB,WAAc;;CAE3H,IAAI,2CAA2C;AAC7C,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,+CAA+C,QAAQ,IAAI,2CAA2C,WAAc;;CAE3K,IAAI,+BAA+B;AACjC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,mCAAmC,QAAQ,IAAI,+BAA+B,WAAc;;CAEnJ,IAAI,0BAA0B;AAC5B,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,8BAA8B,QAAQ,IAAI,0BAA0B,WAAc;;CAEzI,IAAI,+BAA+B;AACjC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,mCAAmC,QAAQ,IAAI,+BAA+B,WAAc;;CAEnJ,IAAI,0CAA0C;AAC5C,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,8CAA8C,QAAQ,IAAI,0CAA0C,WAAc;;CAEzK,IAAI,8BAA8B;AAChC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,kCAAkC,QAAQ,IAAI,8BAA8B,WAAc;;CAEjJ,IAAI,oCAAoC;AACtC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,wCAAwC,QAAQ,IAAI,oCAAoC,WAAc;;CAE7J,IAAI,oCAAoC;AACtC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,wCAAwC,QAAQ,IAAI,oCAAoC,WAAc;;CAE7J,IAAI,wBAAwB;AAC1B,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,4BAA4B,QAAQ,IAAI,wBAAwB,WAAc;;CAErI,IAAI,mCAAmC;AACrC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,uCAAuC,QAAQ,IAAI,mCAAmC,WAAc;;CAE3J,IAAI,mCAAmC;AACrC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,uCAAuC,QAAQ,IAAI,mCAAmC,WAAc;;CAE3J,IAAI,uBAAuB;AACzB,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,2BAA2B,QAAQ,IAAI,uBAAuB,WAAc;;CAEnI,IAAI,4BAA4B;AAC9B,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,gCAAgC,QAAQ,IAAI,4BAA4B,WAAc;;CAE7I,IAAI,gBAAgB;AAClB,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,gBAAgB,WAAc;;CAErH,IAAI,wBAAwB;AAC1B,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,4BAA4B,QAAQ,IAAI,wBAAwB,WAAc;;CAErI,IAAI,iDAAiD;AACnD,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,qDAAqD,QAAQ,IAAI,iDAAiD,WAAc;;CAEvL,IAAI,gDAAgD;AAClD,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,oDAAoD,QAAQ,IAAI,gDAAgD,WAAc;;CAErL,IAAI,2CAA2C;AAC7C,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,+CAA+C,QAAQ,IAAI,2CAA2C,WAAc;;CAE3K,IAAI,2CAA2C;AAC7C,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,+CAA+C,QAAQ,IAAI,2CAA2C,WAAc;;CAE3K,IAAI,qDAAqD;AACvD,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,yDAAyD,QAAQ,IAAI,qDAAqD,WAAc;;CAE/L,IAAI,WAAW;AACb,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,WAAW,WAAc;;CAEhF,IAAI,sCAAsC;AACxC,UAAQ,OAAO,YAAY,cAAc,QAAQ,IAAI,0CAA0C,QAAQ,IAAI,sCAAsC,WAAc;;CAElK"}
|
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
|