@keystrokehq/platform 0.0.171 → 0.0.172

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/run.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const require_config = require("./config.cjs");
2
- const require_start = require("./start-uYyPk7oF.cjs");
2
+ const require_start = require("./start-CfZfvlbY.cjs");
3
3
  //#region src/run.ts
4
4
  async function main() {
5
5
  await require_start.startPlatformServer(require_config.definePlatformConfig());
package/dist/run.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { definePlatformConfig } from "./config.mjs";
2
- import { t as startPlatformServer } from "./start-avYKDymy.mjs";
2
+ import { t as startPlatformServer } from "./start-CCSEG2WQ.mjs";
3
3
  //#region src/run.ts
4
4
  async function main() {
5
5
  await startPlatformServer(definePlatformConfig());
@@ -1480,10 +1480,15 @@ const AUTH_API_PATH = "/api/auth/*";
1480
1480
  function createAuthInstance(options) {
1481
1481
  const socialProviders = resolveSocialProviders();
1482
1482
  const magicLinkPlugin = createMagicLinkPlugin();
1483
+ const advanced = options.crossSubDomainCookieDomain ? { crossSubDomainCookies: {
1484
+ enabled: true,
1485
+ domain: options.crossSubDomainCookieDomain
1486
+ } } : void 0;
1483
1487
  return betterAuth({
1484
1488
  secret: options.secret,
1485
1489
  baseURL: options.baseURL,
1486
1490
  trustedOrigins: options.trustedOrigins,
1491
+ ...advanced ? { advanced } : {},
1487
1492
  account: { accountLinking: {
1488
1493
  enabled: true,
1489
1494
  trustedProviders: ["google", "github"],
@@ -1532,6 +1537,23 @@ function createAuth(options = {}) {
1532
1537
  function handleAuthRequest(auth, request) {
1533
1538
  return auth.handler(request);
1534
1539
  }
1540
+ /** Shared parent domain for Better Auth cross-subdomain cookies (e.g. keystroke.ai). */
1541
+ function resolveCrossSubDomainCookieDomain(webUrl, platformUrl) {
1542
+ try {
1543
+ const webHost = new URL(webUrl).hostname;
1544
+ const platformHost = new URL(platformUrl).hostname;
1545
+ if (webHost === platformHost) return;
1546
+ if (webHost === "localhost" || platformHost === "localhost" || webHost === "127.0.0.1" || platformHost === "127.0.0.1") return;
1547
+ const webParts = webHost.split(".");
1548
+ const platformParts = platformHost.split(".");
1549
+ if (webParts.length < 2 || platformParts.length < 2) return;
1550
+ const webParent = webParts.slice(1).join(".");
1551
+ if (webParent !== platformParts.slice(1).join(".")) return;
1552
+ return webParent;
1553
+ } catch {
1554
+ return;
1555
+ }
1556
+ }
1535
1557
  function extractWebhookApiKeyFromRequest(request) {
1536
1558
  const url = new URL(request.url);
1537
1559
  const queryToken = url.searchParams.get("token") ?? url.searchParams.get("api_key");
@@ -5425,10 +5447,12 @@ async function startPlatformServer(platformConfig, hooks = {}) {
5425
5447
  if (!webUrl) throw new Error("PUBLIC_WEB_URL is required for the platform server");
5426
5448
  const platformUrl = process.env.PUBLIC_PLATFORM_URL?.replace(/\/+$/, "");
5427
5449
  if (!platformUrl) throw new Error("PUBLIC_PLATFORM_URL is required for the platform server");
5450
+ const crossSubDomainCookieDomain = resolveCrossSubDomainCookieDomain(webUrl, platformUrl);
5428
5451
  const auth = createAuth({
5429
5452
  baseURL: platformUrl,
5430
5453
  verificationUri: `${webUrl.replace(/\/+$/, "")}/device`,
5431
- trustedOrigins: [webUrl]
5454
+ trustedOrigins: [webUrl],
5455
+ crossSubDomainCookieDomain
5432
5456
  });
5433
5457
  if (!auth) throw new Error("BETTER_AUTH_SECRET is required for the platform server");
5434
5458
  const app = await createApp(auth, {
@@ -5450,4 +5474,4 @@ async function startPlatformServer(platformConfig, hooks = {}) {
5450
5474
  //#endregion
5451
5475
  export { startPlatformServer as t };
5452
5476
 
5453
- //# sourceMappingURL=start-avYKDymy.mjs.map
5477
+ //# sourceMappingURL=start-CCSEG2WQ.mjs.map