@gadicc/loom 1.21.1 → 1.22.0
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/README.md +8 -4
- package/esm/src/cli/migrationEnv.d.ts +23 -0
- package/esm/src/cli/migrationEnv.d.ts.map +1 -1
- package/esm/src/cli/migrationEnv.js +76 -1
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +47 -8
- package/esm/src/next/auth/config.d.ts +28 -0
- package/esm/src/next/auth/config.d.ts.map +1 -1
- package/esm/src/next/auth/config.js +35 -0
- package/package.json +3 -2
- package/script/src/cli/migrationEnv.d.ts +23 -0
- package/script/src/cli/migrationEnv.d.ts.map +1 -1
- package/script/src/cli/migrationEnv.js +111 -1
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +46 -7
- package/script/src/next/auth/config.d.ts +28 -0
- package/script/src/next/auth/config.d.ts.map +1 -1
- package/script/src/next/auth/config.js +37 -1
- package/skills/loom/SKILL.md +4 -1
- package/skills/loom-auth/SKILL.md +29 -0
- package/skills/loom-db/SKILL.md +5 -2
package/README.md
CHANGED
|
@@ -79,6 +79,8 @@ documented in [`docs/project-tooling.md`](docs/project-tooling.md).
|
|
|
79
79
|
short description for each one.
|
|
80
80
|
- `loom add <feature>` activates one shared feature in `loom.json` and applies
|
|
81
81
|
that feature's scaffolding without overwriting app-local wrappers.
|
|
82
|
+
- `loom add auth` records app-owned Better Auth entrypoints, scaffolds missing
|
|
83
|
+
thin client and route wrappers, and enables the `loom-auth` skill link.
|
|
82
84
|
- `loom add jobs` activates the shared jobs feature in `loom.json` and scaffolds
|
|
83
85
|
any missing local jobs/admin route files without overwriting existing
|
|
84
86
|
app-local wrappers, while also enabling the `loom-jobs` skill link.
|
|
@@ -229,10 +231,10 @@ documented in [`docs/project-tooling.md`](docs/project-tooling.md).
|
|
|
229
231
|
active PWA installs. The DB release-flow check expects Vercel automatic
|
|
230
232
|
production Git deployments to be disabled in `vercel.json` and a GitHub
|
|
231
233
|
Actions workflow to pull Vercel production settings, build, upload a staged
|
|
232
|
-
prebuilt production deployment, run
|
|
233
|
-
`
|
|
234
|
-
`loom check --network` also verifies the required GitHub
|
|
235
|
-
secret/variables when that workflow exists. When
|
|
234
|
+
prebuilt production deployment, run a live migration credential preflight, run
|
|
235
|
+
`db:migrate` against the preserved production environment, then promote the
|
|
236
|
+
staged deployment. `loom check --network` also verifies the required GitHub
|
|
237
|
+
release secret/variables when that workflow exists. When
|
|
236
238
|
`.github/workflows/*.yml|yaml` still contains Loom's obsolete GitHub Packages
|
|
237
239
|
registry/auth setup, `loom check` recommends removing it. The command also
|
|
238
240
|
activates newly discovered npm package skills with a notice, warns when the
|
|
@@ -344,6 +346,8 @@ The package now publishes Codex skill folders under `skills/`.
|
|
|
344
346
|
verification.
|
|
345
347
|
- `skills/loom-db` provides DB-feature guidance for Neon/Drizzle wiring, managed
|
|
346
348
|
local schema blueprints, Valibot generation, and the shared PGlite harness.
|
|
349
|
+
- `skills/loom-auth` covers Better Auth secrets, rotation, environment trust
|
|
350
|
+
boundaries, and proxy-aware localhost OAuth configuration.
|
|
347
351
|
- `skills/loom-jobs` provides jobs-feature guidance for app-local catalogs,
|
|
348
352
|
admin route wrappers, and shared helper wiring.
|
|
349
353
|
- `skills/loom-api-keys` provides API-key adoption, authorization, audit, Vercel
|
|
@@ -7,6 +7,18 @@ export type MigrationEnvironmentResolution = {
|
|
|
7
7
|
hostname: string;
|
|
8
8
|
role: string;
|
|
9
9
|
};
|
|
10
|
+
/** Non-secret identity metadata confirmed by a live migration connection. */
|
|
11
|
+
export type MigrationConnectionVerification = MigrationEnvironmentResolution & {
|
|
12
|
+
schema: string;
|
|
13
|
+
};
|
|
14
|
+
type MigrationDatabaseProbeResult = {
|
|
15
|
+
canCreateInSchema: boolean;
|
|
16
|
+
canUseSchema: boolean;
|
|
17
|
+
database: string;
|
|
18
|
+
role: string;
|
|
19
|
+
schema: string | null;
|
|
20
|
+
};
|
|
21
|
+
type MigrationDatabaseProbe = (databaseUrl: string) => Promise<MigrationDatabaseProbeResult>;
|
|
10
22
|
/**
|
|
11
23
|
* Resolves and validates the migration database URL without returning or
|
|
12
24
|
* printing the credential itself.
|
|
@@ -17,5 +29,16 @@ export declare function resolveMigrationEnvironment(env: Record<string, string |
|
|
|
17
29
|
* process values, including a dedicated migration secret, to take precedence.
|
|
18
30
|
*/
|
|
19
31
|
export declare function resolveMigrationEnvironmentFromEnvFile(envFile: string, env: Record<string, string | undefined>): MigrationEnvironmentResolution;
|
|
32
|
+
/**
|
|
33
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
34
|
+
* connection reaches the declared role/database with usable schema access.
|
|
35
|
+
* Credential values and provider error messages are never returned.
|
|
36
|
+
*/
|
|
37
|
+
export declare function verifyMigrationConnection(env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
38
|
+
/**
|
|
39
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
40
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifyMigrationConnectionFromEnvFile(envFile: string, env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
20
43
|
export {};
|
|
21
44
|
//# sourceMappingURL=migrationEnv.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationEnv.d.ts","sourceRoot":"","sources":["../../../src/src/cli/migrationEnv.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,wCAAwC,iHAKpC,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACrC,OAAO,wCAAwC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,2BAA2B,CAAC;IACrC,QAAQ,EAAE,MAAM,C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AE,sBAA+C,GACrD,OAAO,CAAC,+BAA+B,CAAC,CA0C1C;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,KAAK,GAAE,sBAA+C,4CAGvD"}
|
|
@@ -51,6 +51,81 @@ export function resolveMigrationEnvironment(env) {
|
|
|
51
51
|
* process values, including a dedicated migration secret, to take precedence.
|
|
52
52
|
*/
|
|
53
53
|
export function resolveMigrationEnvironmentFromEnvFile(envFile, env) {
|
|
54
|
+
return resolveMigrationEnvironment(loadMigrationEnvFile(envFile, env));
|
|
55
|
+
}
|
|
56
|
+
function loadMigrationEnvFile(envFile, env) {
|
|
54
57
|
const pulledEnv = parseEnv(readFileSync(envFile, "utf8"));
|
|
55
|
-
return
|
|
58
|
+
return { ...pulledEnv, ...env };
|
|
59
|
+
}
|
|
60
|
+
async function probeMigrationDatabase(databaseUrl) {
|
|
61
|
+
const { default: postgres } = await import("postgres");
|
|
62
|
+
const sql = postgres(databaseUrl, {
|
|
63
|
+
connect_timeout: 5,
|
|
64
|
+
idle_timeout: 1,
|
|
65
|
+
max: 1,
|
|
66
|
+
prepare: false,
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
const rows = await sql.unsafe(`
|
|
70
|
+
select
|
|
71
|
+
current_user::text as "role",
|
|
72
|
+
current_database()::text as "database",
|
|
73
|
+
current_schema()::text as "schema",
|
|
74
|
+
has_schema_privilege(current_user, current_schema(), 'USAGE') as "canUseSchema",
|
|
75
|
+
has_schema_privilege(current_user, current_schema(), 'CREATE') as "canCreateInSchema"
|
|
76
|
+
`);
|
|
77
|
+
if (!rows[0]) {
|
|
78
|
+
throw new Error("Migration database preflight returned no result.");
|
|
79
|
+
}
|
|
80
|
+
return rows[0];
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
await sql.end({ timeout: 1 }).catch(() => undefined);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function databaseErrorCode(error) {
|
|
87
|
+
if (typeof error === "object" && error !== null && "code" in error &&
|
|
88
|
+
typeof error.code === "string" && /^[A-Z0-9_]{2,20}$/.test(error.code)) {
|
|
89
|
+
return error.code;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
95
|
+
* connection reaches the declared role/database with usable schema access.
|
|
96
|
+
* Credential values and provider error messages are never returned.
|
|
97
|
+
*/
|
|
98
|
+
export async function verifyMigrationConnection(env, probe = probeMigrationDatabase) {
|
|
99
|
+
const resolution = resolveMigrationEnvironment(env);
|
|
100
|
+
if (resolution.envName.startsWith("MIGRATION_") && !resolution.direct) {
|
|
101
|
+
throw new Error(`${resolution.envName} must use a direct, unpooled connection.`);
|
|
102
|
+
}
|
|
103
|
+
let connected;
|
|
104
|
+
try {
|
|
105
|
+
connected = await probe(env[resolution.envName]);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const code = databaseErrorCode(error);
|
|
109
|
+
throw new Error(`${resolution.envName} failed the migration database connection preflight${code ? ` (${code})` : ""}. Check the hostname, credential, and network reachability.`);
|
|
110
|
+
}
|
|
111
|
+
if (connected.role !== resolution.role) {
|
|
112
|
+
throw new Error(`${resolution.envName} authenticated as role ${connected.role}, but its URL declares ${resolution.role}.`);
|
|
113
|
+
}
|
|
114
|
+
if (connected.database !== resolution.database) {
|
|
115
|
+
throw new Error(`${resolution.envName} reached database ${connected.database}, but its URL declares ${resolution.database}.`);
|
|
116
|
+
}
|
|
117
|
+
if (!connected.schema) {
|
|
118
|
+
throw new Error(`${resolution.envName} authenticated without a current database schema.`);
|
|
119
|
+
}
|
|
120
|
+
if (!connected.canUseSchema || !connected.canCreateInSchema) {
|
|
121
|
+
throw new Error(`${resolution.envName} role ${connected.role} needs USAGE and CREATE on schema ${connected.schema}.`);
|
|
122
|
+
}
|
|
123
|
+
return { ...resolution, schema: connected.schema };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
127
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
128
|
+
*/
|
|
129
|
+
export function verifyMigrationConnectionFromEnvFile(envFile, env, probe = probeMigrationDatabase) {
|
|
130
|
+
return verifyMigrationConnection(loadMigrationEnvFile(envFile, env), probe);
|
|
56
131
|
}
|
package/esm/src/cli/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"AAyCA,OAAO,EAUL,KAAK,cAAc,EAMpB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAC9C,eAAO,MAAM,oBAAoB,2DACyB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,uCAAuC,CAAC;AAC9E,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAC1E,eAAO,MAAM,8BAA8B,8CACE,CAAC;AAC9C,eAAO,MAAM,4BAA4B,4CACE,CAAC;AAC5C,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAC1E,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AACtE,eAAO,MAAM,kCAAkC,yBAAyB,CAAC;AACzE,eAAO,MAAM,mCAAmC,yBAAyB,CAAC;AAI1E,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAO,CAAC;AAwCtD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAA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GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AA0/BD,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,EAAE,SAAS,EACb,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,aAAa,CAAC;CAC1B,mBAiBP;AAymBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBAuKF"}
|
package/esm/src/cli/mod.js
CHANGED
|
@@ -8,7 +8,7 @@ import process from "node:process";
|
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
9
9
|
import { DEFAULT_API_KEY_AUDIT_RETENTION } from "../apiKeys/retention.js";
|
|
10
10
|
import { checkProjectSkills, getProjectSkillStatus, LOOM_EXTERNAL_SKILLS_GITIGNORE_LINE, removeLegacyNextSkillLink, setProjectSkillDisabled, syncExternalProjectSkills, syncInstalledPackageSkills, } from "./projectSkills.js";
|
|
11
|
-
import { resolveMigrationEnvironment, resolveMigrationEnvironmentFromEnvFile, } from "./migrationEnv.js";
|
|
11
|
+
import { resolveMigrationEnvironment, resolveMigrationEnvironmentFromEnvFile, verifyMigrationConnection, verifyMigrationConnectionFromEnvFile, } from "./migrationEnv.js";
|
|
12
12
|
import { prepareVercelBuildEnvironment, verifyVercelBuildArtifact, } from "./vercelBuildEnv.js";
|
|
13
13
|
import { detectProjectTooling, ensureTask, ensureTaskFollowup, ensureTaskPrerequisite, findTaskConflicts, formatTaskInvocation, getTaskCommand, mutateDenoLinks, mutateProjectDependencies, readDenoLinks, readProjectPackageMetadata, readTaskStore, taskInvokes, taskRunsBeforeCommand, } from "./projectTooling.js";
|
|
14
14
|
export const DEFAULT_LOOM_RANGE = "^1.0.0";
|
|
@@ -70,6 +70,12 @@ const managedSkills = [
|
|
|
70
70
|
relativePackagePath: "skills/loom-api-keys",
|
|
71
71
|
skillName: "loom-api-keys",
|
|
72
72
|
},
|
|
73
|
+
{
|
|
74
|
+
featureKey: "auth",
|
|
75
|
+
label: "loom auth skill",
|
|
76
|
+
relativePackagePath: "skills/loom-auth",
|
|
77
|
+
skillName: "loom-auth",
|
|
78
|
+
},
|
|
73
79
|
{
|
|
74
80
|
label: "loom global skill",
|
|
75
81
|
relativePackagePath: "skills/loom",
|
|
@@ -3193,6 +3199,9 @@ function workflowStepVerifiesMigrationEnvWithPulledSnapshot(block) {
|
|
|
3193
3199
|
/--env-file(?:=|\s+)["']?\$RUNNER_TEMP\/vercel-production\.env["']?/
|
|
3194
3200
|
.test(block);
|
|
3195
3201
|
}
|
|
3202
|
+
function workflowStepVerifiesMigrationConnection(block) {
|
|
3203
|
+
return workflowStepVerifiesMigrationEnv(block) && /(?:^|\s)--connect\b/.test(block);
|
|
3204
|
+
}
|
|
3196
3205
|
function workflowStepStagesVercelProductionDeployment(block) {
|
|
3197
3206
|
return workflowStepUsesVercelCommand(block, "deploy") &&
|
|
3198
3207
|
/\s--prebuilt\b/.test(block) &&
|
|
@@ -3310,6 +3319,7 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
3310
3319
|
hasWorkflowEnvBinding(migrateStep, "DATABASE_URL"),
|
|
3311
3320
|
id: job.id,
|
|
3312
3321
|
metadataStepIndex,
|
|
3322
|
+
migrationVerifyConnects: workflowStepVerifiesMigrationConnection(migrationVerifyStep),
|
|
3313
3323
|
migrationVerifyStepIndex,
|
|
3314
3324
|
migrationVerifyUsesPulledSnapshot: workflowStepVerifiesMigrationEnvWithPulledSnapshot(migrationVerifyStep),
|
|
3315
3325
|
migrateStepIndex,
|
|
@@ -3419,6 +3429,9 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3419
3429
|
!job.migrationVerifyUsesPulledSnapshot
|
|
3420
3430
|
? [inspection.relativePath]
|
|
3421
3431
|
: []));
|
|
3432
|
+
const structuralOnlyMigrationValidationPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.flatMap((job) => job.migrationVerifyStepIndex >= 0 && !job.migrationVerifyConnects
|
|
3433
|
+
? [inspection.relativePath]
|
|
3434
|
+
: []));
|
|
3422
3435
|
const vercelCurlWorkflowPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.some((job) => job.vercelCurlStepIndex >= 0)
|
|
3423
3436
|
? [inspection.relativePath]
|
|
3424
3437
|
: []);
|
|
@@ -3473,7 +3486,12 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3473
3486
|
if (invalidMigrationValidationPaths.length) {
|
|
3474
3487
|
findings.push("DB production migration validation does not load the preserved Vercel production env snapshot: " +
|
|
3475
3488
|
[...new Set(invalidMigrationValidationPaths)].join(", "));
|
|
3476
|
-
suggestions.add('Run `loom db migrations verify-env --env-file "$RUNNER_TEMP/vercel-production.env"` so the optional GitHub migration secret overlays the readable gradual-adoption pull snapshot.');
|
|
3489
|
+
suggestions.add('Run `loom db migrations verify-env --connect --env-file "$RUNNER_TEMP/vercel-production.env"` so the optional GitHub migration secret overlays the readable gradual-adoption pull snapshot and proves live access.');
|
|
3490
|
+
}
|
|
3491
|
+
if (structuralOnlyMigrationValidationPaths.length) {
|
|
3492
|
+
warnings.push("DB production migration validation checks URL structure without proving live database access: " +
|
|
3493
|
+
[...new Set(structuralOnlyMigrationValidationPaths)].join(", "));
|
|
3494
|
+
suggestions.add("Add `--connect` to the migration `verify-env` command so a selected override must authenticate and have migration schema access before it supersedes the Vercel integration fallback.");
|
|
3477
3495
|
}
|
|
3478
3496
|
if (legacyUnpooledSecretWorkflows.length) {
|
|
3479
3497
|
warnings.push("DB production migration flow still uses the gradual-adoption GitHub secret `DATABASE_URL_UNPOOLED` instead of the migration-scoped `MIGRATION_DATABASE_URL_UNPOOLED`: " +
|
|
@@ -9108,9 +9126,10 @@ async function checkApiKeysFeature(cwd, framework, manifest, options) {
|
|
|
9108
9126
|
async function checkAuthFeature(cwd, framework, manifest) {
|
|
9109
9127
|
const issues = [];
|
|
9110
9128
|
const suggestions = new Set();
|
|
9129
|
+
const warnings = [];
|
|
9111
9130
|
const feature = manifest.features.auth;
|
|
9112
9131
|
if (!feature || feature.status !== "active") {
|
|
9113
|
-
return { issues, suggestions: [], warnings
|
|
9132
|
+
return { issues, suggestions: [], warnings };
|
|
9114
9133
|
}
|
|
9115
9134
|
const config = await mergeAuthConfig(cwd, framework, feature.config);
|
|
9116
9135
|
const requiredFiles = [
|
|
@@ -9147,6 +9166,11 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9147
9166
|
suggestions.add("Update the auth module to use the shared Loom Better Auth helpers, or rerun `loom add auth` and reapply any app-local customizations.");
|
|
9148
9167
|
}
|
|
9149
9168
|
}
|
|
9169
|
+
if (/baseURL\s*:\s*\{[\s\S]*?allowedHosts\s*:/.test(authModuleText) &&
|
|
9170
|
+
!/trustedProxyHeaders\s*:\s*true/.test(authModuleText)) {
|
|
9171
|
+
warnings.push(`Auth module uses a dynamic Better Auth baseURL without trusted proxy headers; trusted reverse proxies such as \`vercel dev\` can leak an internal callback host: ${config.modules.authModule}`);
|
|
9172
|
+
suggestions.add("Use createBetterAuthLocalDevelopmentConfig for loopback development behind a trusted proxy, or explicitly enable Better Auth trustedProxyHeaders only where that proxy boundary is trusted.");
|
|
9173
|
+
}
|
|
9150
9174
|
if (!config.modules.authServerModule &&
|
|
9151
9175
|
!authModuleText.includes("createRequestAuthSessionReaders")) {
|
|
9152
9176
|
issues.push(`Auth module is missing Loom request-scoped session readers: ${config.modules.authModule}`);
|
|
@@ -9213,7 +9237,7 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9213
9237
|
return {
|
|
9214
9238
|
issues,
|
|
9215
9239
|
suggestions: [...suggestions],
|
|
9216
|
-
warnings
|
|
9240
|
+
warnings,
|
|
9217
9241
|
};
|
|
9218
9242
|
}
|
|
9219
9243
|
async function findNextConfigPath(cwd) {
|
|
@@ -10466,7 +10490,7 @@ function printHelp({ out }) {
|
|
|
10466
10490
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
10467
10491
|
out(" db neon setup Provision and connect a Vercel-managed Neon database for Production and Preview.");
|
|
10468
10492
|
out(" db neon check Run the DB/Neon network checks registered for the active DB feature.");
|
|
10469
|
-
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials.
|
|
10493
|
+
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials. Add --connect for a live access preflight.");
|
|
10470
10494
|
out(" db migrations setup-github Store an existing direct migration URL as a protected GitHub Environment secret.");
|
|
10471
10495
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
10472
10496
|
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
@@ -10501,6 +10525,7 @@ function printHelp({ out }) {
|
|
|
10501
10525
|
out(" --token-name <name> Override the Vercel token name for `loom db release setup-github`.");
|
|
10502
10526
|
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
10503
10527
|
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
10528
|
+
out(" --connect Authenticate and check migration database identity and schema privileges.");
|
|
10504
10529
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
10505
10530
|
out(" --action <name> Permission action for API-key integration.");
|
|
10506
10531
|
out(" --allow-query Allow the integration's explicit query credential transport.");
|
|
@@ -11104,9 +11129,18 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11104
11129
|
return 0;
|
|
11105
11130
|
}
|
|
11106
11131
|
case "verify-env": {
|
|
11107
|
-
const
|
|
11108
|
-
?
|
|
11109
|
-
:
|
|
11132
|
+
const envFile = options.envFile
|
|
11133
|
+
? resolve(cwd, options.envFile)
|
|
11134
|
+
: undefined;
|
|
11135
|
+
const connected = options.connect
|
|
11136
|
+
? envFile
|
|
11137
|
+
? await verifyMigrationConnectionFromEnvFile(envFile, process.env)
|
|
11138
|
+
: await verifyMigrationConnection(process.env)
|
|
11139
|
+
: undefined;
|
|
11140
|
+
const result = connected ??
|
|
11141
|
+
(envFile
|
|
11142
|
+
? resolveMigrationEnvironmentFromEnvFile(envFile, process.env)
|
|
11143
|
+
: resolveMigrationEnvironment(process.env));
|
|
11110
11144
|
io.out(`Migration database environment is usable: ${result.envName} selects role ${result.role} and database ${result.database}.`);
|
|
11111
11145
|
if (!result.envName.startsWith("MIGRATION_")) {
|
|
11112
11146
|
io.out("Warning: using the gradual-adoption application database fallback; prefer MIGRATION_DATABASE_URL_UNPOOLED after provisioning a dedicated migration credential.");
|
|
@@ -11114,6 +11148,9 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11114
11148
|
if (!result.direct) {
|
|
11115
11149
|
io.out("Warning: the selected URL appears pooled; migrations should prefer a direct, unpooled connection.");
|
|
11116
11150
|
}
|
|
11151
|
+
if (connected) {
|
|
11152
|
+
io.out(`Migration database connection preflight succeeded: ${connected.envName} authenticated as role ${connected.role} in database ${connected.database} with USAGE and CREATE on schema ${connected.schema}.`);
|
|
11153
|
+
}
|
|
11117
11154
|
return 0;
|
|
11118
11155
|
}
|
|
11119
11156
|
default:
|
|
@@ -11284,6 +11321,7 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
11284
11321
|
"cloudflare-profile": { type: "string" },
|
|
11285
11322
|
"cleanup-batch-size": { type: "string" },
|
|
11286
11323
|
"configure-secrets": { type: "boolean" },
|
|
11324
|
+
connect: { type: "boolean" },
|
|
11287
11325
|
cwd: { type: "string" },
|
|
11288
11326
|
environment: { type: "string" },
|
|
11289
11327
|
"env-file": { type: "string" },
|
|
@@ -11388,6 +11426,7 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
11388
11426
|
return await runEnvCommand(cwd, arg1, [arg2, ...rest].filter((arg) => arg !== undefined), io);
|
|
11389
11427
|
case "db":
|
|
11390
11428
|
return await runDb(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
11429
|
+
connect: parsed.values.connect,
|
|
11391
11430
|
name: parsed.values.name,
|
|
11392
11431
|
environment: parsed.values.environment,
|
|
11393
11432
|
envFile: parsed.values["env-file"],
|
|
@@ -2,6 +2,8 @@ export declare const DEFAULT_BETTER_AUTH_SECRET_ENV = "BETTER_AUTH_SECRET";
|
|
|
2
2
|
export declare const DEFAULT_BETTER_AUTH_SECRETS_ENV = "BETTER_AUTH_SECRETS";
|
|
3
3
|
export declare const DEFAULT_BETTER_AUTH_DEPRECATED_SECRET_ENVS: readonly ["AUTH_SECRET", "NEXTAUTH_SECRET"];
|
|
4
4
|
export declare const DEFAULT_BETTER_AUTH_COOKIE_CACHE_MAX_AGE_SECONDS = 10;
|
|
5
|
+
export declare const DEFAULT_BETTER_AUTH_LOCAL_ALLOWED_HOSTS: readonly ["localhost:*", "127.0.0.1:*", "[::1]:*"];
|
|
6
|
+
export declare const DEFAULT_BETTER_AUTH_LOCAL_TRUSTED_ORIGINS: readonly ["http://localhost:*", "http://127.0.0.1:*", "http://[::1]:*"];
|
|
5
7
|
export type BetterAuthSecretResolution = {
|
|
6
8
|
deprecated: boolean;
|
|
7
9
|
preferredEnvName: string;
|
|
@@ -22,6 +24,32 @@ export type RequireBetterAuthSecretOptions = ResolveBetterAuthSecretOptions & {
|
|
|
22
24
|
export type CreateBetterAuthSessionConfigOptions = {
|
|
23
25
|
cookieCacheMaxAgeSeconds?: number;
|
|
24
26
|
};
|
|
27
|
+
export type CreateBetterAuthLocalDevelopmentConfigOptions = {
|
|
28
|
+
/** Loopback hosts Better Auth may derive from a local request. */
|
|
29
|
+
allowedHosts?: readonly string[];
|
|
30
|
+
/** Stable public URL used when the incoming host cannot be accepted. */
|
|
31
|
+
fallback?: string | undefined;
|
|
32
|
+
/** Browser origins allowed to call the local auth endpoints. */
|
|
33
|
+
trustedOrigins?: readonly string[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Creates a loopback-only Better Auth policy for local reverse proxies.
|
|
37
|
+
*
|
|
38
|
+
* Proxy headers are trusted so tools such as `vercel dev` retain their public
|
|
39
|
+
* localhost URL instead of leaking an internal worker port into OAuth
|
|
40
|
+
* callbacks. Only spread this config into a non-production Better Auth setup.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createBetterAuthLocalDevelopmentConfig(options?: CreateBetterAuthLocalDevelopmentConfigOptions): {
|
|
43
|
+
advanced: {
|
|
44
|
+
trustedProxyHeaders: boolean;
|
|
45
|
+
};
|
|
46
|
+
baseURL: {
|
|
47
|
+
protocol: "http";
|
|
48
|
+
fallback?: string | undefined;
|
|
49
|
+
allowedHosts: string[];
|
|
50
|
+
};
|
|
51
|
+
trustedOrigins: string[];
|
|
52
|
+
};
|
|
25
53
|
export declare function createBetterAuthSessionConfig(options?: CreateBetterAuthSessionConfigOptions): {
|
|
26
54
|
cookieCache: {
|
|
27
55
|
enabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/src/next/auth/config.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AACnE,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,0CAA0C,6CAG7C,CAAC;AACX,eAAO,MAAM,gDAAgD,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/src/next/auth/config.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AACnE,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,0CAA0C,6CAG7C,CAAC;AACX,eAAO,MAAM,gDAAgD,KAAK,CAAC;AACnE,eAAO,MAAM,uCAAuC,oDAI1C,CAAC;AACX,eAAO,MAAM,yCAAyC,yEAI5C,CAAC;AAEX,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,M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VS = [
|
|
|
6
6
|
"NEXTAUTH_SECRET",
|
|
7
7
|
];
|
|
8
8
|
export const DEFAULT_BETTER_AUTH_COOKIE_CACHE_MAX_AGE_SECONDS = 10;
|
|
9
|
+
export const DEFAULT_BETTER_AUTH_LOCAL_ALLOWED_HOSTS = [
|
|
10
|
+
"localhost:*",
|
|
11
|
+
"127.0.0.1:*",
|
|
12
|
+
"[::1]:*",
|
|
13
|
+
];
|
|
14
|
+
export const DEFAULT_BETTER_AUTH_LOCAL_TRUSTED_ORIGINS = [
|
|
15
|
+
"http://localhost:*",
|
|
16
|
+
"http://127.0.0.1:*",
|
|
17
|
+
"http://[::1]:*",
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a loopback-only Better Auth policy for local reverse proxies.
|
|
21
|
+
*
|
|
22
|
+
* Proxy headers are trusted so tools such as `vercel dev` retain their public
|
|
23
|
+
* localhost URL instead of leaking an internal worker port into OAuth
|
|
24
|
+
* callbacks. Only spread this config into a non-production Better Auth setup.
|
|
25
|
+
*/
|
|
26
|
+
export function createBetterAuthLocalDevelopmentConfig(options = {}) {
|
|
27
|
+
const fallback = options.fallback?.trim();
|
|
28
|
+
return {
|
|
29
|
+
advanced: {
|
|
30
|
+
trustedProxyHeaders: true,
|
|
31
|
+
},
|
|
32
|
+
baseURL: {
|
|
33
|
+
allowedHosts: [
|
|
34
|
+
...(options.allowedHosts ?? DEFAULT_BETTER_AUTH_LOCAL_ALLOWED_HOSTS),
|
|
35
|
+
],
|
|
36
|
+
...(fallback ? { fallback } : {}),
|
|
37
|
+
protocol: "http",
|
|
38
|
+
},
|
|
39
|
+
trustedOrigins: [
|
|
40
|
+
...(options.trustedOrigins ?? DEFAULT_BETTER_AUTH_LOCAL_TRUSTED_ORIGINS),
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
9
44
|
export function createBetterAuthSessionConfig(options = {}) {
|
|
10
45
|
return {
|
|
11
46
|
cookieCache: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadicc/loom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Deno-first shared helpers for extracting common Next.js app code.",
|
|
5
5
|
"homepage": "https://github.com/gadicc/loom#readme",
|
|
6
6
|
"repository": {
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
},
|
|
232
232
|
"scripts": {},
|
|
233
233
|
"loom": {
|
|
234
|
-
"gitCommit": "
|
|
234
|
+
"gitCommit": "049978cd318628403b7b61c75311d6459cf7fc7e"
|
|
235
235
|
},
|
|
236
236
|
"bin": {
|
|
237
237
|
"loom": "script/bin/loom.js"
|
|
@@ -331,6 +331,7 @@
|
|
|
331
331
|
"@mui/material": "9.2.0",
|
|
332
332
|
"@next/env": "^16.2.10",
|
|
333
333
|
"jsonc-parser": "^3.3.1",
|
|
334
|
+
"postgres": "^3.4.9",
|
|
334
335
|
"react": "19.2.7",
|
|
335
336
|
"react-dom": "19.2.7",
|
|
336
337
|
"tsx": "^4.23.1",
|
|
@@ -7,6 +7,18 @@ export type MigrationEnvironmentResolution = {
|
|
|
7
7
|
hostname: string;
|
|
8
8
|
role: string;
|
|
9
9
|
};
|
|
10
|
+
/** Non-secret identity metadata confirmed by a live migration connection. */
|
|
11
|
+
export type MigrationConnectionVerification = MigrationEnvironmentResolution & {
|
|
12
|
+
schema: string;
|
|
13
|
+
};
|
|
14
|
+
type MigrationDatabaseProbeResult = {
|
|
15
|
+
canCreateInSchema: boolean;
|
|
16
|
+
canUseSchema: boolean;
|
|
17
|
+
database: string;
|
|
18
|
+
role: string;
|
|
19
|
+
schema: string | null;
|
|
20
|
+
};
|
|
21
|
+
type MigrationDatabaseProbe = (databaseUrl: string) => Promise<MigrationDatabaseProbeResult>;
|
|
10
22
|
/**
|
|
11
23
|
* Resolves and validates the migration database URL without returning or
|
|
12
24
|
* printing the credential itself.
|
|
@@ -17,5 +29,16 @@ export declare function resolveMigrationEnvironment(env: Record<string, string |
|
|
|
17
29
|
* process values, including a dedicated migration secret, to take precedence.
|
|
18
30
|
*/
|
|
19
31
|
export declare function resolveMigrationEnvironmentFromEnvFile(envFile: string, env: Record<string, string | undefined>): MigrationEnvironmentResolution;
|
|
32
|
+
/**
|
|
33
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
34
|
+
* connection reaches the declared role/database with usable schema access.
|
|
35
|
+
* Credential values and provider error messages are never returned.
|
|
36
|
+
*/
|
|
37
|
+
export declare function verifyMigrationConnection(env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
38
|
+
/**
|
|
39
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
40
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifyMigrationConnectionFromEnvFile(envFile: string, env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
20
43
|
export {};
|
|
21
44
|
//# sourceMappingURL=migrationEnv.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationEnv.d.ts","sourceRoot":"","sources":["../../../src/src/cli/migrationEnv.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,wCAAwC,iHAKpC,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACrC,OAAO,wCAAwC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,2BAA2B,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;
|
|
1
|
+
{"version":3,"file":"migrationEnv.d.ts","sourceRoot":"","sources":["../../../src/src/cli/migrationEnv.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,wCAAwC,iHAKpC,C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,EACvC,KAAK,GAAE,sBAA+C,4CAGvD"}
|
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.resolveMigrationEnvironment = resolveMigrationEnvironment;
|
|
4
37
|
exports.resolveMigrationEnvironmentFromEnvFile = resolveMigrationEnvironmentFromEnvFile;
|
|
38
|
+
exports.verifyMigrationConnection = verifyMigrationConnection;
|
|
39
|
+
exports.verifyMigrationConnectionFromEnvFile = verifyMigrationConnectionFromEnvFile;
|
|
5
40
|
const node_fs_1 = require("node:fs");
|
|
6
41
|
const node_util_1 = require("node:util");
|
|
7
42
|
const DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES = [
|
|
@@ -55,6 +90,81 @@ function resolveMigrationEnvironment(env) {
|
|
|
55
90
|
* process values, including a dedicated migration secret, to take precedence.
|
|
56
91
|
*/
|
|
57
92
|
function resolveMigrationEnvironmentFromEnvFile(envFile, env) {
|
|
93
|
+
return resolveMigrationEnvironment(loadMigrationEnvFile(envFile, env));
|
|
94
|
+
}
|
|
95
|
+
function loadMigrationEnvFile(envFile, env) {
|
|
58
96
|
const pulledEnv = (0, node_util_1.parseEnv)((0, node_fs_1.readFileSync)(envFile, "utf8"));
|
|
59
|
-
return
|
|
97
|
+
return { ...pulledEnv, ...env };
|
|
98
|
+
}
|
|
99
|
+
async function probeMigrationDatabase(databaseUrl) {
|
|
100
|
+
const { default: postgres } = await Promise.resolve().then(() => __importStar(require("postgres")));
|
|
101
|
+
const sql = postgres(databaseUrl, {
|
|
102
|
+
connect_timeout: 5,
|
|
103
|
+
idle_timeout: 1,
|
|
104
|
+
max: 1,
|
|
105
|
+
prepare: false,
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
const rows = await sql.unsafe(`
|
|
109
|
+
select
|
|
110
|
+
current_user::text as "role",
|
|
111
|
+
current_database()::text as "database",
|
|
112
|
+
current_schema()::text as "schema",
|
|
113
|
+
has_schema_privilege(current_user, current_schema(), 'USAGE') as "canUseSchema",
|
|
114
|
+
has_schema_privilege(current_user, current_schema(), 'CREATE') as "canCreateInSchema"
|
|
115
|
+
`);
|
|
116
|
+
if (!rows[0]) {
|
|
117
|
+
throw new Error("Migration database preflight returned no result.");
|
|
118
|
+
}
|
|
119
|
+
return rows[0];
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
await sql.end({ timeout: 1 }).catch(() => undefined);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function databaseErrorCode(error) {
|
|
126
|
+
if (typeof error === "object" && error !== null && "code" in error &&
|
|
127
|
+
typeof error.code === "string" && /^[A-Z0-9_]{2,20}$/.test(error.code)) {
|
|
128
|
+
return error.code;
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
134
|
+
* connection reaches the declared role/database with usable schema access.
|
|
135
|
+
* Credential values and provider error messages are never returned.
|
|
136
|
+
*/
|
|
137
|
+
async function verifyMigrationConnection(env, probe = probeMigrationDatabase) {
|
|
138
|
+
const resolution = resolveMigrationEnvironment(env);
|
|
139
|
+
if (resolution.envName.startsWith("MIGRATION_") && !resolution.direct) {
|
|
140
|
+
throw new Error(`${resolution.envName} must use a direct, unpooled connection.`);
|
|
141
|
+
}
|
|
142
|
+
let connected;
|
|
143
|
+
try {
|
|
144
|
+
connected = await probe(env[resolution.envName]);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
const code = databaseErrorCode(error);
|
|
148
|
+
throw new Error(`${resolution.envName} failed the migration database connection preflight${code ? ` (${code})` : ""}. Check the hostname, credential, and network reachability.`);
|
|
149
|
+
}
|
|
150
|
+
if (connected.role !== resolution.role) {
|
|
151
|
+
throw new Error(`${resolution.envName} authenticated as role ${connected.role}, but its URL declares ${resolution.role}.`);
|
|
152
|
+
}
|
|
153
|
+
if (connected.database !== resolution.database) {
|
|
154
|
+
throw new Error(`${resolution.envName} reached database ${connected.database}, but its URL declares ${resolution.database}.`);
|
|
155
|
+
}
|
|
156
|
+
if (!connected.schema) {
|
|
157
|
+
throw new Error(`${resolution.envName} authenticated without a current database schema.`);
|
|
158
|
+
}
|
|
159
|
+
if (!connected.canUseSchema || !connected.canCreateInSchema) {
|
|
160
|
+
throw new Error(`${resolution.envName} role ${connected.role} needs USAGE and CREATE on schema ${connected.schema}.`);
|
|
161
|
+
}
|
|
162
|
+
return { ...resolution, schema: connected.schema };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
166
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
167
|
+
*/
|
|
168
|
+
function verifyMigrationConnectionFromEnvFile(envFile, env, probe = probeMigrationDatabase) {
|
|
169
|
+
return verifyMigrationConnection(loadMigrationEnvFile(envFile, env), probe);
|
|
60
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"AAyCA,OAAO,EAUL,KAAK,cAAc,EAMpB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAC9C,eAAO,MAAM,oBAAoB,2DACyB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,uCAAuC,CAAC;AAC9E,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAC1E,eAAO,MAAM,8BAA8B,8CACE,CAAC;AAC9C,eAAO,MAAM,4BAA4B,4CACE,CAAC;AAC5C,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAC1E,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AACtE,eAAO,MAAM,kCAAkC,yBAAyB,CAAC;AACzE,eAAO,MAAM,mCAAmC,yBAAyB,CAAC;AAI1E,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAO,CAAC;AAwCtD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,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gBACL,sBAAsB;;;;GA2GjC;AAuFD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,uBAAuB,EAC9B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AA0/BD,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,EAAE,SAAS,EACb,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,aAAa,CAAC;CAC1B,mBAiBP;AAymBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBAuKF"}
|
package/script/src/cli/mod.js
CHANGED
|
@@ -140,6 +140,12 @@ const managedSkills = [
|
|
|
140
140
|
relativePackagePath: "skills/loom-api-keys",
|
|
141
141
|
skillName: "loom-api-keys",
|
|
142
142
|
},
|
|
143
|
+
{
|
|
144
|
+
featureKey: "auth",
|
|
145
|
+
label: "loom auth skill",
|
|
146
|
+
relativePackagePath: "skills/loom-auth",
|
|
147
|
+
skillName: "loom-auth",
|
|
148
|
+
},
|
|
143
149
|
{
|
|
144
150
|
label: "loom global skill",
|
|
145
151
|
relativePackagePath: "skills/loom",
|
|
@@ -3263,6 +3269,9 @@ function workflowStepVerifiesMigrationEnvWithPulledSnapshot(block) {
|
|
|
3263
3269
|
/--env-file(?:=|\s+)["']?\$RUNNER_TEMP\/vercel-production\.env["']?/
|
|
3264
3270
|
.test(block);
|
|
3265
3271
|
}
|
|
3272
|
+
function workflowStepVerifiesMigrationConnection(block) {
|
|
3273
|
+
return workflowStepVerifiesMigrationEnv(block) && /(?:^|\s)--connect\b/.test(block);
|
|
3274
|
+
}
|
|
3266
3275
|
function workflowStepStagesVercelProductionDeployment(block) {
|
|
3267
3276
|
return workflowStepUsesVercelCommand(block, "deploy") &&
|
|
3268
3277
|
/\s--prebuilt\b/.test(block) &&
|
|
@@ -3380,6 +3389,7 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
3380
3389
|
hasWorkflowEnvBinding(migrateStep, "DATABASE_URL"),
|
|
3381
3390
|
id: job.id,
|
|
3382
3391
|
metadataStepIndex,
|
|
3392
|
+
migrationVerifyConnects: workflowStepVerifiesMigrationConnection(migrationVerifyStep),
|
|
3383
3393
|
migrationVerifyStepIndex,
|
|
3384
3394
|
migrationVerifyUsesPulledSnapshot: workflowStepVerifiesMigrationEnvWithPulledSnapshot(migrationVerifyStep),
|
|
3385
3395
|
migrateStepIndex,
|
|
@@ -3489,6 +3499,9 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3489
3499
|
!job.migrationVerifyUsesPulledSnapshot
|
|
3490
3500
|
? [inspection.relativePath]
|
|
3491
3501
|
: []));
|
|
3502
|
+
const structuralOnlyMigrationValidationPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.flatMap((job) => job.migrationVerifyStepIndex >= 0 && !job.migrationVerifyConnects
|
|
3503
|
+
? [inspection.relativePath]
|
|
3504
|
+
: []));
|
|
3492
3505
|
const vercelCurlWorkflowPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.some((job) => job.vercelCurlStepIndex >= 0)
|
|
3493
3506
|
? [inspection.relativePath]
|
|
3494
3507
|
: []);
|
|
@@ -3543,7 +3556,12 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3543
3556
|
if (invalidMigrationValidationPaths.length) {
|
|
3544
3557
|
findings.push("DB production migration validation does not load the preserved Vercel production env snapshot: " +
|
|
3545
3558
|
[...new Set(invalidMigrationValidationPaths)].join(", "));
|
|
3546
|
-
suggestions.add('Run `loom db migrations verify-env --env-file "$RUNNER_TEMP/vercel-production.env"` so the optional GitHub migration secret overlays the readable gradual-adoption pull snapshot.');
|
|
3559
|
+
suggestions.add('Run `loom db migrations verify-env --connect --env-file "$RUNNER_TEMP/vercel-production.env"` so the optional GitHub migration secret overlays the readable gradual-adoption pull snapshot and proves live access.');
|
|
3560
|
+
}
|
|
3561
|
+
if (structuralOnlyMigrationValidationPaths.length) {
|
|
3562
|
+
warnings.push("DB production migration validation checks URL structure without proving live database access: " +
|
|
3563
|
+
[...new Set(structuralOnlyMigrationValidationPaths)].join(", "));
|
|
3564
|
+
suggestions.add("Add `--connect` to the migration `verify-env` command so a selected override must authenticate and have migration schema access before it supersedes the Vercel integration fallback.");
|
|
3547
3565
|
}
|
|
3548
3566
|
if (legacyUnpooledSecretWorkflows.length) {
|
|
3549
3567
|
warnings.push("DB production migration flow still uses the gradual-adoption GitHub secret `DATABASE_URL_UNPOOLED` instead of the migration-scoped `MIGRATION_DATABASE_URL_UNPOOLED`: " +
|
|
@@ -9178,9 +9196,10 @@ async function checkApiKeysFeature(cwd, framework, manifest, options) {
|
|
|
9178
9196
|
async function checkAuthFeature(cwd, framework, manifest) {
|
|
9179
9197
|
const issues = [];
|
|
9180
9198
|
const suggestions = new Set();
|
|
9199
|
+
const warnings = [];
|
|
9181
9200
|
const feature = manifest.features.auth;
|
|
9182
9201
|
if (!feature || feature.status !== "active") {
|
|
9183
|
-
return { issues, suggestions: [], warnings
|
|
9202
|
+
return { issues, suggestions: [], warnings };
|
|
9184
9203
|
}
|
|
9185
9204
|
const config = await mergeAuthConfig(cwd, framework, feature.config);
|
|
9186
9205
|
const requiredFiles = [
|
|
@@ -9217,6 +9236,11 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9217
9236
|
suggestions.add("Update the auth module to use the shared Loom Better Auth helpers, or rerun `loom add auth` and reapply any app-local customizations.");
|
|
9218
9237
|
}
|
|
9219
9238
|
}
|
|
9239
|
+
if (/baseURL\s*:\s*\{[\s\S]*?allowedHosts\s*:/.test(authModuleText) &&
|
|
9240
|
+
!/trustedProxyHeaders\s*:\s*true/.test(authModuleText)) {
|
|
9241
|
+
warnings.push(`Auth module uses a dynamic Better Auth baseURL without trusted proxy headers; trusted reverse proxies such as \`vercel dev\` can leak an internal callback host: ${config.modules.authModule}`);
|
|
9242
|
+
suggestions.add("Use createBetterAuthLocalDevelopmentConfig for loopback development behind a trusted proxy, or explicitly enable Better Auth trustedProxyHeaders only where that proxy boundary is trusted.");
|
|
9243
|
+
}
|
|
9220
9244
|
if (!config.modules.authServerModule &&
|
|
9221
9245
|
!authModuleText.includes("createRequestAuthSessionReaders")) {
|
|
9222
9246
|
issues.push(`Auth module is missing Loom request-scoped session readers: ${config.modules.authModule}`);
|
|
@@ -9283,7 +9307,7 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9283
9307
|
return {
|
|
9284
9308
|
issues,
|
|
9285
9309
|
suggestions: [...suggestions],
|
|
9286
|
-
warnings
|
|
9310
|
+
warnings,
|
|
9287
9311
|
};
|
|
9288
9312
|
}
|
|
9289
9313
|
async function findNextConfigPath(cwd) {
|
|
@@ -10536,7 +10560,7 @@ function printHelp({ out }) {
|
|
|
10536
10560
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
10537
10561
|
out(" db neon setup Provision and connect a Vercel-managed Neon database for Production and Preview.");
|
|
10538
10562
|
out(" db neon check Run the DB/Neon network checks registered for the active DB feature.");
|
|
10539
|
-
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials.
|
|
10563
|
+
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials. Add --connect for a live access preflight.");
|
|
10540
10564
|
out(" db migrations setup-github Store an existing direct migration URL as a protected GitHub Environment secret.");
|
|
10541
10565
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
10542
10566
|
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
@@ -10571,6 +10595,7 @@ function printHelp({ out }) {
|
|
|
10571
10595
|
out(" --token-name <name> Override the Vercel token name for `loom db release setup-github`.");
|
|
10572
10596
|
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
10573
10597
|
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
10598
|
+
out(" --connect Authenticate and check migration database identity and schema privileges.");
|
|
10574
10599
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
10575
10600
|
out(" --action <name> Permission action for API-key integration.");
|
|
10576
10601
|
out(" --allow-query Allow the integration's explicit query credential transport.");
|
|
@@ -11174,9 +11199,18 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11174
11199
|
return 0;
|
|
11175
11200
|
}
|
|
11176
11201
|
case "verify-env": {
|
|
11177
|
-
const
|
|
11178
|
-
? (0,
|
|
11179
|
-
:
|
|
11202
|
+
const envFile = options.envFile
|
|
11203
|
+
? (0, node_path_1.resolve)(cwd, options.envFile)
|
|
11204
|
+
: undefined;
|
|
11205
|
+
const connected = options.connect
|
|
11206
|
+
? envFile
|
|
11207
|
+
? await (0, migrationEnv_js_1.verifyMigrationConnectionFromEnvFile)(envFile, node_process_1.default.env)
|
|
11208
|
+
: await (0, migrationEnv_js_1.verifyMigrationConnection)(node_process_1.default.env)
|
|
11209
|
+
: undefined;
|
|
11210
|
+
const result = connected ??
|
|
11211
|
+
(envFile
|
|
11212
|
+
? (0, migrationEnv_js_1.resolveMigrationEnvironmentFromEnvFile)(envFile, node_process_1.default.env)
|
|
11213
|
+
: (0, migrationEnv_js_1.resolveMigrationEnvironment)(node_process_1.default.env));
|
|
11180
11214
|
io.out(`Migration database environment is usable: ${result.envName} selects role ${result.role} and database ${result.database}.`);
|
|
11181
11215
|
if (!result.envName.startsWith("MIGRATION_")) {
|
|
11182
11216
|
io.out("Warning: using the gradual-adoption application database fallback; prefer MIGRATION_DATABASE_URL_UNPOOLED after provisioning a dedicated migration credential.");
|
|
@@ -11184,6 +11218,9 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11184
11218
|
if (!result.direct) {
|
|
11185
11219
|
io.out("Warning: the selected URL appears pooled; migrations should prefer a direct, unpooled connection.");
|
|
11186
11220
|
}
|
|
11221
|
+
if (connected) {
|
|
11222
|
+
io.out(`Migration database connection preflight succeeded: ${connected.envName} authenticated as role ${connected.role} in database ${connected.database} with USAGE and CREATE on schema ${connected.schema}.`);
|
|
11223
|
+
}
|
|
11187
11224
|
return 0;
|
|
11188
11225
|
}
|
|
11189
11226
|
default:
|
|
@@ -11354,6 +11391,7 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
11354
11391
|
"cloudflare-profile": { type: "string" },
|
|
11355
11392
|
"cleanup-batch-size": { type: "string" },
|
|
11356
11393
|
"configure-secrets": { type: "boolean" },
|
|
11394
|
+
connect: { type: "boolean" },
|
|
11357
11395
|
cwd: { type: "string" },
|
|
11358
11396
|
environment: { type: "string" },
|
|
11359
11397
|
"env-file": { type: "string" },
|
|
@@ -11458,6 +11496,7 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
11458
11496
|
return await runEnvCommand(cwd, arg1, [arg2, ...rest].filter((arg) => arg !== undefined), io);
|
|
11459
11497
|
case "db":
|
|
11460
11498
|
return await runDb(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
11499
|
+
connect: parsed.values.connect,
|
|
11461
11500
|
name: parsed.values.name,
|
|
11462
11501
|
environment: parsed.values.environment,
|
|
11463
11502
|
envFile: parsed.values["env-file"],
|
|
@@ -2,6 +2,8 @@ export declare const DEFAULT_BETTER_AUTH_SECRET_ENV = "BETTER_AUTH_SECRET";
|
|
|
2
2
|
export declare const DEFAULT_BETTER_AUTH_SECRETS_ENV = "BETTER_AUTH_SECRETS";
|
|
3
3
|
export declare const DEFAULT_BETTER_AUTH_DEPRECATED_SECRET_ENVS: readonly ["AUTH_SECRET", "NEXTAUTH_SECRET"];
|
|
4
4
|
export declare const DEFAULT_BETTER_AUTH_COOKIE_CACHE_MAX_AGE_SECONDS = 10;
|
|
5
|
+
export declare const DEFAULT_BETTER_AUTH_LOCAL_ALLOWED_HOSTS: readonly ["localhost:*", "127.0.0.1:*", "[::1]:*"];
|
|
6
|
+
export declare const DEFAULT_BETTER_AUTH_LOCAL_TRUSTED_ORIGINS: readonly ["http://localhost:*", "http://127.0.0.1:*", "http://[::1]:*"];
|
|
5
7
|
export type BetterAuthSecretResolution = {
|
|
6
8
|
deprecated: boolean;
|
|
7
9
|
preferredEnvName: string;
|
|
@@ -22,6 +24,32 @@ export type RequireBetterAuthSecretOptions = ResolveBetterAuthSecretOptions & {
|
|
|
22
24
|
export type CreateBetterAuthSessionConfigOptions = {
|
|
23
25
|
cookieCacheMaxAgeSeconds?: number;
|
|
24
26
|
};
|
|
27
|
+
export type CreateBetterAuthLocalDevelopmentConfigOptions = {
|
|
28
|
+
/** Loopback hosts Better Auth may derive from a local request. */
|
|
29
|
+
allowedHosts?: readonly string[];
|
|
30
|
+
/** Stable public URL used when the incoming host cannot be accepted. */
|
|
31
|
+
fallback?: string | undefined;
|
|
32
|
+
/** Browser origins allowed to call the local auth endpoints. */
|
|
33
|
+
trustedOrigins?: readonly string[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Creates a loopback-only Better Auth policy for local reverse proxies.
|
|
37
|
+
*
|
|
38
|
+
* Proxy headers are trusted so tools such as `vercel dev` retain their public
|
|
39
|
+
* localhost URL instead of leaking an internal worker port into OAuth
|
|
40
|
+
* callbacks. Only spread this config into a non-production Better Auth setup.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createBetterAuthLocalDevelopmentConfig(options?: CreateBetterAuthLocalDevelopmentConfigOptions): {
|
|
43
|
+
advanced: {
|
|
44
|
+
trustedProxyHeaders: boolean;
|
|
45
|
+
};
|
|
46
|
+
baseURL: {
|
|
47
|
+
protocol: "http";
|
|
48
|
+
fallback?: string | undefined;
|
|
49
|
+
allowedHosts: string[];
|
|
50
|
+
};
|
|
51
|
+
trustedOrigins: string[];
|
|
52
|
+
};
|
|
25
53
|
export declare function createBetterAuthSessionConfig(options?: CreateBetterAuthSessionConfigOptions): {
|
|
26
54
|
cookieCache: {
|
|
27
55
|
enabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/src/next/auth/config.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AACnE,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,0CAA0C,6CAG7C,CAAC;AACX,eAAO,MAAM,gDAAgD,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/src/next/auth/config.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AACnE,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,0CAA0C,6CAG7C,CAAC;AACX,eAAO,MAAM,gDAAgD,KAAK,CAAC;AACnE,eAAO,MAAM,uCAAuC,oDAI1C,CAAC;AACX,eAAO,MAAM,yCAAyC,yEAI5C,CAAC;AAEX,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAKxD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,8BAA8B,GAAG;IAC5E,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,0BAA0B,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CAC7E,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,6CAA6C,GAAG;IAC1D,kEAAkE;IAClE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,gEAAgE;IAChE,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,GAAE,6CAAkD;;;;;;;;;;EAuB5D;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,oCAAyC;;;;;EASnD;AAMD,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,8BAAmC,GAC3C,0BAA0B,GAAG,IAAI,CA6EnC;AAED,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,8BAAmC,UAuB7C"}
|
|
@@ -33,7 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.DEFAULT_BETTER_AUTH_COOKIE_CACHE_MAX_AGE_SECONDS = exports.DEFAULT_BETTER_AUTH_DEPRECATED_SECRET_ENVS = exports.DEFAULT_BETTER_AUTH_SECRETS_ENV = exports.DEFAULT_BETTER_AUTH_SECRET_ENV = void 0;
|
|
36
|
+
exports.DEFAULT_BETTER_AUTH_LOCAL_TRUSTED_ORIGINS = exports.DEFAULT_BETTER_AUTH_LOCAL_ALLOWED_HOSTS = exports.DEFAULT_BETTER_AUTH_COOKIE_CACHE_MAX_AGE_SECONDS = exports.DEFAULT_BETTER_AUTH_DEPRECATED_SECRET_ENVS = exports.DEFAULT_BETTER_AUTH_SECRETS_ENV = exports.DEFAULT_BETTER_AUTH_SECRET_ENV = void 0;
|
|
37
|
+
exports.createBetterAuthLocalDevelopmentConfig = createBetterAuthLocalDevelopmentConfig;
|
|
37
38
|
exports.createBetterAuthSessionConfig = createBetterAuthSessionConfig;
|
|
38
39
|
exports.resolveBetterAuthSecret = resolveBetterAuthSecret;
|
|
39
40
|
exports.requireBetterAuthSecret = requireBetterAuthSecret;
|
|
@@ -45,6 +46,41 @@ exports.DEFAULT_BETTER_AUTH_DEPRECATED_SECRET_ENVS = [
|
|
|
45
46
|
"NEXTAUTH_SECRET",
|
|
46
47
|
];
|
|
47
48
|
exports.DEFAULT_BETTER_AUTH_COOKIE_CACHE_MAX_AGE_SECONDS = 10;
|
|
49
|
+
exports.DEFAULT_BETTER_AUTH_LOCAL_ALLOWED_HOSTS = [
|
|
50
|
+
"localhost:*",
|
|
51
|
+
"127.0.0.1:*",
|
|
52
|
+
"[::1]:*",
|
|
53
|
+
];
|
|
54
|
+
exports.DEFAULT_BETTER_AUTH_LOCAL_TRUSTED_ORIGINS = [
|
|
55
|
+
"http://localhost:*",
|
|
56
|
+
"http://127.0.0.1:*",
|
|
57
|
+
"http://[::1]:*",
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Creates a loopback-only Better Auth policy for local reverse proxies.
|
|
61
|
+
*
|
|
62
|
+
* Proxy headers are trusted so tools such as `vercel dev` retain their public
|
|
63
|
+
* localhost URL instead of leaking an internal worker port into OAuth
|
|
64
|
+
* callbacks. Only spread this config into a non-production Better Auth setup.
|
|
65
|
+
*/
|
|
66
|
+
function createBetterAuthLocalDevelopmentConfig(options = {}) {
|
|
67
|
+
const fallback = options.fallback?.trim();
|
|
68
|
+
return {
|
|
69
|
+
advanced: {
|
|
70
|
+
trustedProxyHeaders: true,
|
|
71
|
+
},
|
|
72
|
+
baseURL: {
|
|
73
|
+
allowedHosts: [
|
|
74
|
+
...(options.allowedHosts ?? exports.DEFAULT_BETTER_AUTH_LOCAL_ALLOWED_HOSTS),
|
|
75
|
+
],
|
|
76
|
+
...(fallback ? { fallback } : {}),
|
|
77
|
+
protocol: "http",
|
|
78
|
+
},
|
|
79
|
+
trustedOrigins: [
|
|
80
|
+
...(options.trustedOrigins ?? exports.DEFAULT_BETTER_AUTH_LOCAL_TRUSTED_ORIGINS),
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
48
84
|
function createBetterAuthSessionConfig(options = {}) {
|
|
49
85
|
return {
|
|
50
86
|
cookieCache: {
|
package/skills/loom/SKILL.md
CHANGED
|
@@ -83,9 +83,12 @@ from the consumer's working directory.
|
|
|
83
83
|
adoption.
|
|
84
84
|
- Validate the migration boundary with
|
|
85
85
|
`loom db migrations verify-env
|
|
86
|
+
--connect
|
|
86
87
|
--env-file "$RUNNER_TEMP/vercel-production.env"`
|
|
87
88
|
so the optional protected migration secret overlays the untouched readable
|
|
88
|
-
pull snapshot instead of replacing that gradual-adoption fallback.
|
|
89
|
+
pull snapshot instead of replacing that gradual-adoption fallback. The live
|
|
90
|
+
probe must authenticate with the selected URL and confirm migration schema
|
|
91
|
+
access before a present override supersedes the fallback.
|
|
89
92
|
|
|
90
93
|
## Re-establishing work context
|
|
91
94
|
|
|
@@ -71,6 +71,35 @@ If the app uses Better Auth's OAuth Proxy plugin, check that plugin's secret
|
|
|
71
71
|
requirements before separating keys; the proxy may need an explicitly shared
|
|
72
72
|
secret for cross-environment state exchange.
|
|
73
73
|
|
|
74
|
+
## Local reverse proxies
|
|
75
|
+
|
|
76
|
+
`vercel dev` exposes a stable public localhost port but runs the framework dev
|
|
77
|
+
server on a separate internal port. Better Auth trusts `x-forwarded-host` only
|
|
78
|
+
when `advanced.trustedProxyHeaders` is enabled; otherwise a dynamic `baseURL`
|
|
79
|
+
can leak the internal port into an OAuth callback and cause
|
|
80
|
+
`redirect_uri_mismatch`.
|
|
81
|
+
|
|
82
|
+
Use Loom's loopback-only helper in the non-production branch:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { createBetterAuthLocalDevelopmentConfig } from "@gadicc/loom/next/auth";
|
|
86
|
+
|
|
87
|
+
const developmentAuthOptions = process.env.NODE_ENV === "production"
|
|
88
|
+
? {}
|
|
89
|
+
: createBetterAuthLocalDevelopmentConfig({
|
|
90
|
+
fallback: process.env.BETTER_AUTH_URL,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const auth = betterAuth({
|
|
94
|
+
...developmentAuthOptions,
|
|
95
|
+
// app-owned database, providers, and plugins
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The helper accepts only loopback hosts and origins by default. Do not spread it
|
|
100
|
+
into production configuration or enable trusted proxy headers when requests can
|
|
101
|
+
bypass or spoof the intended proxy boundary.
|
|
102
|
+
|
|
74
103
|
## Verification
|
|
75
104
|
|
|
76
105
|
- Run `loom check` and the consumer's typecheck/tests.
|
package/skills/loom-db/SKILL.md
CHANGED
|
@@ -89,11 +89,14 @@ Use this skill when working on the shared DB stack from a consuming app.
|
|
|
89
89
|
`loom db release verify-build-env`; keep only the declarative requirements
|
|
90
90
|
policy app-local.
|
|
91
91
|
- Use
|
|
92
|
-
`loom db migrations verify-env --env-file
|
|
92
|
+
`loom db migrations verify-env --connect --env-file
|
|
93
93
|
"$RUNNER_TEMP/vercel-production.env"`
|
|
94
94
|
before a release migration. It validates the preserved pull snapshot plus any
|
|
95
95
|
process-level migration-secret overlay, including URL precedence, database
|
|
96
|
-
role, and direct-vs-pooled endpoint,
|
|
96
|
+
role, and direct-vs-pooled endpoint, then authenticates with the selected URL
|
|
97
|
+
and checks the target database and schema privileges without printing
|
|
98
|
+
credentials. A present but invalid override must fail instead of silently
|
|
99
|
+
falling back.
|
|
97
100
|
- Once a dedicated direct URL has been provisioned, load it as
|
|
98
101
|
`MIGRATION_DATABASE_URL_UNPOOLED` in the local process and run
|
|
99
102
|
`loom db migrations setup-github`. Loom sends the value to GitHub over stdin,
|