Skip to content

Commit dd68259

Browse files
committed
fix: enforce auth secret and remove dead auth config exports
1 parent 1a8adfd commit dd68259

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

apps/web/alchemy.run.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,18 @@ const program = Effect.gen(function* () {
5353
//
5454
// See `docs/adr/0003-build-time-env-injection-with-effect-config.md`
5555
// (which supersedes the runtime-decrypt approach in ADR 0001).
56+
const betterAuthSecret = process.env.BETTER_AUTH_SECRET;
57+
if (!betterAuthSecret) {
58+
throw new Error("BETTER_AUTH_SECRET environment variable is required");
59+
}
60+
5661
const website = yield* Cloudflare.Vite("TanstackStart", {
5762
compatibility: {
5863
flags: ["nodejs_compat"],
5964
},
6065
env: {
6166
DATABASE_URL: db.connectionUri,
62-
BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET ?? "",
67+
BETTER_AUTH_SECRET: betterAuthSecret,
6368
POLAR_ACCESS_TOKEN: process.env.POLAR_ACCESS_TOKEN ?? "",
6469
POLAR_WEBHOOK_SECRET: process.env.POLAR_WEBHOOK_SECRET ?? "",
6570
POLAR_PRO_PRODUCT_ID_PRODUCTION:

packages/auth/src/config.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ import * as Option from "effect/Option";
2626
import * as Redacted from "effect/Redacted";
2727

2828
const program = Effect.gen(function* () {
29-
const betterAuthSecret = yield* Config.option(
30-
Config.redacted("BETTER_AUTH_SECRET"),
31-
);
3229
const polarAccessToken = yield* Config.option(
3330
Config.redacted("POLAR_ACCESS_TOKEN"),
3431
);
@@ -43,7 +40,6 @@ const program = Effect.gen(function* () {
4340
Config.string("STACKPANEL_DEPLOY_ENV"),
4441
);
4542
return {
46-
betterAuthSecret,
4743
polarAccessToken,
4844
polarWebhookSecret,
4945
polarSuccessUrl,
@@ -58,10 +54,6 @@ const program = Effect.gen(function* () {
5854
// throws is a true validation failure (none of these schemas have one).
5955
const resolved = Effect.runSync(program);
6056

61-
/** Better-Auth signing secret — `Redacted` so it doesn't accidentally leak. */
62-
export const betterAuthSecret: Option.Option<Redacted.Redacted<string>> =
63-
resolved.betterAuthSecret;
64-
6557
/** Polar API access token. When `None`, the polar plugin is not mounted. */
6658
export const polarAccessToken: Option.Option<Redacted.Redacted<string>> =
6759
resolved.polarAccessToken;
@@ -84,13 +76,6 @@ export const corsOrigin: Option.Option<string> = resolved.corsOrigin;
8476
export const stackpanelDeployEnv: Option.Option<string> =
8577
resolved.stackpanelDeployEnv;
8678

87-
/**
88-
* Unwrap a `Redacted<string>` only at the boundary where an SDK requires
89-
* a raw string. Centralized so callers don't sprinkle `Redacted.value`
90-
* around the codebase.
91-
*/
92-
export const reveal = Redacted.value;
93-
9479
/**
9580
* Treats an empty string the same as a missing value. Used because
9681
* `Cloudflare.Vite({ env: { POLAR_ACCESS_TOKEN: process.env.POLAR_ACCESS_TOKEN ?? "" } })`

0 commit comments

Comments
 (0)