@gadicc/loom 1.26.1 → 1.28.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 +7 -3
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +81 -15
- package/esm/src/next/auth/localTestLogin.d.ts +75 -0
- package/esm/src/next/auth/localTestLogin.d.ts.map +1 -0
- package/esm/src/next/auth/localTestLogin.js +284 -0
- package/esm/src/next/auth/mod.d.ts +1 -0
- package/esm/src/next/auth/mod.d.ts.map +1 -1
- package/esm/src/next/auth/mod.js +1 -0
- package/package.json +2 -2
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +81 -15
- package/script/src/next/auth/localTestLogin.d.ts +75 -0
- package/script/src/next/auth/localTestLogin.d.ts.map +1 -0
- package/script/src/next/auth/localTestLogin.js +291 -0
- package/script/src/next/auth/mod.d.ts +1 -0
- package/script/src/next/auth/mod.d.ts.map +1 -1
- package/script/src/next/auth/mod.js +1 -0
- package/skills/loom-auth/SKILL.md +57 -0
- package/skills/modernize-app/SKILL.md +90 -0
- package/skills/modernize-app/agents/openai.yaml +4 -0
- package/skills/modernize-app/references/architecture-and-characterization.md +205 -0
- package/skills/modernize-app/references/identity-and-data.md +251 -0
- package/skills/modernize-app/references/offline-and-media.md +403 -0
- package/skills/modernize-app/references/rollout-and-shared-work.md +400 -0
package/README.md
CHANGED
|
@@ -362,6 +362,10 @@ The package now publishes Codex skill folders under `skills/`.
|
|
|
362
362
|
dependency-upgrade workflow covering compatibility groups, rollback safety,
|
|
363
363
|
failure isolation, major migrations, reviewable commits, and exact-tree final
|
|
364
364
|
verification.
|
|
365
|
+
- `skills/modernize-app` guides staged modernization of an existing application,
|
|
366
|
+
including identity/data preservation, optional offline/media transitions and
|
|
367
|
+
verified rollout. Dependency-only work stays with `upgrade-deps`; new apps use
|
|
368
|
+
scaffolding rather than this migration workflow.
|
|
365
369
|
- `skills/loom-db` provides DB-feature guidance for Neon/Drizzle wiring, managed
|
|
366
370
|
local schema blueprints, Valibot generation, and the shared PGlite harness.
|
|
367
371
|
- `skills/loom-auth` covers Better Auth secrets, rotation, environment trust
|
|
@@ -375,9 +379,9 @@ Projects do not need to copy these files manually. `loom init`, `loom add db`,
|
|
|
375
379
|
`loom add jobs`, and `loom check` manage a small project-local `AGENTS.md` Loom
|
|
376
380
|
block plus `.agents/skills/*` symlinks that point to the installed
|
|
377
381
|
`node_modules/@gadicc/loom/skills/*` folders. The global `loom`,
|
|
378
|
-
`loom-torvalds-review`,
|
|
379
|
-
initialized project; feature skills are linked when their matching
|
|
380
|
-
active.
|
|
382
|
+
`loom-torvalds-review`, `upgrade-deps`, and `modernize-app` skills are linked
|
|
383
|
+
for every initialized project; feature skills are linked when their matching
|
|
384
|
+
feature is active.
|
|
381
385
|
|
|
382
386
|
Third-party skills are not packaged with Loom. Loom carries a metadata-only
|
|
383
387
|
catalog containing source URLs, immutable commits, content hashes, and license
|
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":"AAgCA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAC;AAuBjC,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,CA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deps",
|
|
97
97
|
},
|
|
98
|
+
{
|
|
99
|
+
label: "legacy app modernization skill",
|
|
100
|
+
relativePackagePath: "skills/modernize-app",
|
|
101
|
+
skillName: "modernize-app",
|
|
102
|
+
},
|
|
98
103
|
{
|
|
99
104
|
featureKey: "db",
|
|
100
105
|
label: "loom db skill",
|
|
@@ -1156,6 +1161,10 @@ async function mergeAuthConfig(cwd, framework, featureConfig) {
|
|
|
1156
1161
|
...defaults.modules,
|
|
1157
1162
|
...featureConfig?.modules,
|
|
1158
1163
|
},
|
|
1164
|
+
// Recorded by the app; Loom never infers or rewrites this choice.
|
|
1165
|
+
...(featureConfig?.requestSessionReaders
|
|
1166
|
+
? { requestSessionReaders: featureConfig.requestSessionReaders }
|
|
1167
|
+
: {}),
|
|
1159
1168
|
};
|
|
1160
1169
|
}
|
|
1161
1170
|
function dependencyExecutable(tooling, executable) {
|
|
@@ -3935,15 +3944,35 @@ function matchesAuthRouteWrapper(text, expectedSources, expectedExportName) {
|
|
|
3935
3944
|
if (!matchesImportSource(normalized, expectedSources)) {
|
|
3936
3945
|
return false;
|
|
3937
3946
|
}
|
|
3938
|
-
|
|
3939
|
-
|
|
3947
|
+
// Exactly one handler set, so every exported method is traceable to it.
|
|
3948
|
+
const calls = [
|
|
3949
|
+
...normalized.matchAll(/toNextJsHandler\(\s*([A-Za-z_$][\w$]*)\s*\)/g),
|
|
3950
|
+
];
|
|
3951
|
+
if (calls.length !== 1) {
|
|
3940
3952
|
return false;
|
|
3941
3953
|
}
|
|
3942
|
-
const
|
|
3943
|
-
if (
|
|
3954
|
+
const instanceName = calls[0][1];
|
|
3955
|
+
if (expectedExportName && instanceName !== expectedExportName) {
|
|
3944
3956
|
return false;
|
|
3945
3957
|
}
|
|
3946
|
-
|
|
3958
|
+
const match = normalized.match(/export\s+const\s+\{\s*([^}]+)\s*\}\s*=\s*toNextJsHandler\(/);
|
|
3959
|
+
if (match) {
|
|
3960
|
+
const actualSpecifiers = new Set(match[1].split(",").map((specifier) => specifier.trim()).filter(Boolean));
|
|
3961
|
+
return actualSpecifiers.has("GET") && actualSpecifiers.has("POST");
|
|
3962
|
+
}
|
|
3963
|
+
// An app may wrap the handlers, for example to fail closed until a
|
|
3964
|
+
// migration completes. Each exported method must still come from the
|
|
3965
|
+
// handlers that call returned.
|
|
3966
|
+
const handlers = normalized.match(/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*toNextJsHandler\(/);
|
|
3967
|
+
if (!handlers) {
|
|
3968
|
+
return false;
|
|
3969
|
+
}
|
|
3970
|
+
const handlersName = handlers[1];
|
|
3971
|
+
return ["GET", "POST"].every((method) => {
|
|
3972
|
+
const exported = normalized.match(new RegExp(`export\\s+const\\s+${method}\\s*=([^;]*);`));
|
|
3973
|
+
return Boolean(exported &&
|
|
3974
|
+
new RegExp(`\\b${escapeRegExp(handlersName)}\\.${method}\\b`).test(exported[1]));
|
|
3975
|
+
});
|
|
3947
3976
|
}
|
|
3948
3977
|
function authClientTemplate(config, authExportName) {
|
|
3949
3978
|
return `"use client";
|
|
@@ -8829,7 +8858,10 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
|
|
|
8829
8858
|
}
|
|
8830
8859
|
else {
|
|
8831
8860
|
const repositorySchemaImportCandidates = getImportSpecifierCandidates(config.modules.repositoryModule, schema.module);
|
|
8832
|
-
const repositoryDbImportCandidates =
|
|
8861
|
+
const repositoryDbImportCandidates = [
|
|
8862
|
+
...getImportSpecifierCandidates(config.modules.repositoryModule, dbConfig.modules.neonModule),
|
|
8863
|
+
...getImportSpecifierCandidates(config.modules.repositoryModule, dbConfig.modules.neonFullModule),
|
|
8864
|
+
];
|
|
8833
8865
|
const schemaExportName = schema.exports[0] ?? FILES_SCHEMA_DEFAULT_EXPORT;
|
|
8834
8866
|
if (!matchesImportSource(repositoryText, ["@gadicc/loom/files"])) {
|
|
8835
8867
|
issues.push(`Files repository is not typed against @gadicc/loom/files: ${config.modules.repositoryModule}`);
|
|
@@ -8844,7 +8876,7 @@ async function checkFilesFeature(cwd, framework, manifest, options) {
|
|
|
8844
8876
|
}
|
|
8845
8877
|
if (!matchesImportSource(repositoryText, repositoryDbImportCandidates)) {
|
|
8846
8878
|
issues.push(`Files repository does not import the configured DB module: ${config.modules.repositoryModule}`);
|
|
8847
|
-
suggestions.add(`Import the app DB client from ${dbConfig.modules.neonModule} in the files repository adapter.`);
|
|
8879
|
+
suggestions.add(`Import the app DB client from ${dbConfig.modules.neonModule} or ${dbConfig.modules.neonFullModule} in the files repository adapter.`);
|
|
8848
8880
|
}
|
|
8849
8881
|
if (!repositoryText.includes("filesRepository")) {
|
|
8850
8882
|
issues.push(`Files repository does not export \`filesRepository\`: ${config.modules.repositoryModule}`);
|
|
@@ -9254,6 +9286,7 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9254
9286
|
const config = await mergeAuthConfig(cwd, framework, feature.config);
|
|
9255
9287
|
const requiredFiles = [
|
|
9256
9288
|
config.modules.authModule,
|
|
9289
|
+
config.modules.authRuntimeModule,
|
|
9257
9290
|
config.modules.authClientModule,
|
|
9258
9291
|
config.entrypoints.routeHandler,
|
|
9259
9292
|
config.modules.authServerModule,
|
|
@@ -9269,6 +9302,37 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9269
9302
|
const authExportName = authModuleText
|
|
9270
9303
|
? detectBetterAuthExportName(authModuleText)
|
|
9271
9304
|
: null;
|
|
9305
|
+
// An app may build its instance in a separate runtime module, so the shared
|
|
9306
|
+
// helpers can be split across the two. Only a runtime module that imports
|
|
9307
|
+
// the auth module counts: otherwise its text proves nothing about the
|
|
9308
|
+
// instance this feature checks.
|
|
9309
|
+
const authRuntimeModule = config.modules.authRuntimeModule;
|
|
9310
|
+
const authRuntimeText = authRuntimeModule
|
|
9311
|
+
? await readTextIfExists(join(cwd, authRuntimeModule))
|
|
9312
|
+
: null;
|
|
9313
|
+
let creditedRuntimeText = null;
|
|
9314
|
+
if (authRuntimeModule && authRuntimeText) {
|
|
9315
|
+
if (matchesImportSource(authRuntimeText, getImportSpecifierCandidates(authRuntimeModule, config.modules.authModule))) {
|
|
9316
|
+
creditedRuntimeText = authRuntimeText;
|
|
9317
|
+
}
|
|
9318
|
+
else {
|
|
9319
|
+
issues.push(`Auth runtime module does not import the configured auth module: ${authRuntimeModule}`);
|
|
9320
|
+
suggestions.add("Point modules.authRuntimeModule at the module that builds the configured auth instance, or remove it from loom.json.");
|
|
9321
|
+
}
|
|
9322
|
+
}
|
|
9323
|
+
const authWiringSources = [
|
|
9324
|
+
{ path: config.modules.authModule, text: authModuleText },
|
|
9325
|
+
...(creditedRuntimeText
|
|
9326
|
+
? [{ path: authRuntimeModule, text: creditedRuntimeText }]
|
|
9327
|
+
: []),
|
|
9328
|
+
].filter((source) => source.text);
|
|
9329
|
+
// Modules reach the instance through whichever of the two exports it.
|
|
9330
|
+
const authImportCandidates = (fromPath) => [
|
|
9331
|
+
...getImportSpecifierCandidates(fromPath, config.modules.authModule),
|
|
9332
|
+
...(creditedRuntimeText && authRuntimeModule
|
|
9333
|
+
? getImportSpecifierCandidates(fromPath, authRuntimeModule)
|
|
9334
|
+
: []),
|
|
9335
|
+
];
|
|
9272
9336
|
if (authModuleText) {
|
|
9273
9337
|
const authModuleChecks = [
|
|
9274
9338
|
[
|
|
@@ -9281,8 +9345,8 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9281
9345
|
],
|
|
9282
9346
|
];
|
|
9283
9347
|
for (const [pattern, message] of authModuleChecks) {
|
|
9284
|
-
if (!pattern.test(
|
|
9285
|
-
issues.push(`${message}: ${
|
|
9348
|
+
if (!authWiringSources.some((source) => pattern.test(source.text))) {
|
|
9349
|
+
issues.push(`${message}: ${authWiringSources.map((source) => source.path).join(", ")}`);
|
|
9286
9350
|
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.");
|
|
9287
9351
|
}
|
|
9288
9352
|
}
|
|
@@ -9291,15 +9355,16 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9291
9355
|
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}`);
|
|
9292
9356
|
suggestions.add("Use createBetterAuthLocalDevelopmentConfig for loopback development behind a trusted proxy, or explicitly enable Better Auth trustedProxyHeaders only where that proxy boundary is trusted.");
|
|
9293
9357
|
}
|
|
9294
|
-
if (
|
|
9358
|
+
if (config.requestSessionReaders !== "app-owned" &&
|
|
9359
|
+
!config.modules.authServerModule &&
|
|
9295
9360
|
!authModuleText.includes("createRequestAuthSessionReaders")) {
|
|
9296
9361
|
issues.push(`Auth module is missing Loom request-scoped session readers: ${config.modules.authModule}`);
|
|
9297
|
-
suggestions.add(
|
|
9362
|
+
suggestions.add('Either wire createRequestAuthSessionReaders into the auth module, add an auth server helper module and record it in loom.json, or record requestSessionReaders: "app-owned" when the app must read sessions its own way.');
|
|
9298
9363
|
}
|
|
9299
9364
|
}
|
|
9300
9365
|
const authClientText = await readTextIfExists(join(cwd, config.modules.authClientModule));
|
|
9301
9366
|
if (authClientText) {
|
|
9302
|
-
const authClientImportCandidates =
|
|
9367
|
+
const authClientImportCandidates = authImportCandidates(config.modules.authClientModule);
|
|
9303
9368
|
const authClientChecks = [
|
|
9304
9369
|
[
|
|
9305
9370
|
authClientText.includes("createAuthClient"),
|
|
@@ -9323,7 +9388,7 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9323
9388
|
}
|
|
9324
9389
|
const routeHandlerText = await readTextIfExists(join(cwd, config.entrypoints.routeHandler));
|
|
9325
9390
|
if (routeHandlerText) {
|
|
9326
|
-
const routeImportCandidates =
|
|
9391
|
+
const routeImportCandidates = authImportCandidates(config.entrypoints.routeHandler);
|
|
9327
9392
|
if (!matchesAuthRouteWrapper(routeHandlerText, routeImportCandidates, authExportName)) {
|
|
9328
9393
|
issues.push(`Auth route-handler wrapper does not match loom manifest config: ${config.entrypoints.routeHandler}`);
|
|
9329
9394
|
suggestions.add("Run `loom add auth` to restore the thin auth route wrapper, or update loom.json if the app intentionally uses different auth paths.");
|
|
@@ -9332,10 +9397,11 @@ async function checkAuthFeature(cwd, framework, manifest) {
|
|
|
9332
9397
|
if (config.modules.authServerModule) {
|
|
9333
9398
|
const authServerText = await readTextIfExists(join(cwd, config.modules.authServerModule));
|
|
9334
9399
|
if (authServerText) {
|
|
9335
|
-
const authServerImportCandidates =
|
|
9400
|
+
const authServerImportCandidates = authImportCandidates(config.modules.authServerModule);
|
|
9336
9401
|
const authServerChecks = [
|
|
9337
9402
|
[
|
|
9338
|
-
|
|
9403
|
+
config.requestSessionReaders === "app-owned" ||
|
|
9404
|
+
authServerText.includes("createRequestAuthSessionReaders"),
|
|
9339
9405
|
"Auth server module is not wired to Loom request-scoped session readers",
|
|
9340
9406
|
],
|
|
9341
9407
|
[
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const DEFAULT_BETTER_AUTH_LOCAL_TEST_LOGIN_ENV = "LOOM_LOCAL_TEST_LOGIN";
|
|
2
|
+
export declare const DEFAULT_BETTER_AUTH_LOCAL_TEST_LOGIN_MAX_BODY_BYTES: number;
|
|
3
|
+
type BetterAuthLocalTestLoginEnv = Record<string, string | undefined>;
|
|
4
|
+
type BetterAuthLocalTestLoginContext = {
|
|
5
|
+
password: {
|
|
6
|
+
hash(password: string): Promise<string>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type BetterAuthLocalTestLoginAuth = {
|
|
10
|
+
$context: Promise<BetterAuthLocalTestLoginContext>;
|
|
11
|
+
handler(request: Request): Promise<Response>;
|
|
12
|
+
};
|
|
13
|
+
/** A fixed local identity selected by an opaque form value. */
|
|
14
|
+
export type BetterAuthLocalTestLoginIdentity = {
|
|
15
|
+
/** Same-origin application path used when the submitted callback is unsafe. */
|
|
16
|
+
defaultCallbackURL: string;
|
|
17
|
+
/** Dedicated identity email. Never populate this from request data. */
|
|
18
|
+
email: string;
|
|
19
|
+
/** Dedicated identity display name. Never populate this from request data. */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Optional fixed local password. A process-local random value is the default. */
|
|
22
|
+
password?: string;
|
|
23
|
+
};
|
|
24
|
+
export type BetterAuthLocalTestLoginProvisionContext<TKey extends string, TIdentity extends BetterAuthLocalTestLoginIdentity = BetterAuthLocalTestLoginIdentity> = {
|
|
25
|
+
/** Fixed identity configuration selected from the app-owned allowlist. */
|
|
26
|
+
identity: TIdentity;
|
|
27
|
+
/** Exact allowlisted selector submitted by the local form. */
|
|
28
|
+
key: TKey;
|
|
29
|
+
/** Better Auth-compatible hash for the generated or configured password. */
|
|
30
|
+
passwordHash: string;
|
|
31
|
+
/** Generated or configured password used only for the internal sign-in call. */
|
|
32
|
+
password: string;
|
|
33
|
+
};
|
|
34
|
+
export type CreateBetterAuthLocalTestLoginHandlerOptions<TIdentities extends Record<string, BetterAuthLocalTestLoginIdentity>> = {
|
|
35
|
+
/** Better Auth instance whose email sign-in handler creates the session. */
|
|
36
|
+
auth: BetterAuthLocalTestLoginAuth;
|
|
37
|
+
/** Fixed application-owned identity map. Request data selects only its keys. */
|
|
38
|
+
identities: TIdentities;
|
|
39
|
+
/** Runtime environment used for the explicit local-only enablement gate. */
|
|
40
|
+
env: BetterAuthLocalTestLoginEnv;
|
|
41
|
+
/**
|
|
42
|
+
* Idempotently provision the fixed identity and credential account.
|
|
43
|
+
*
|
|
44
|
+
* App-specific grants and fixtures remain in this callback or in a separate
|
|
45
|
+
* explicit fixture; Loom never infers authorization from an identity key.
|
|
46
|
+
*/
|
|
47
|
+
provisionIdentity(context: BetterAuthLocalTestLoginProvisionContext<Extract<keyof TIdentities, string>, TIdentities[Extract<keyof TIdentities, string>]>): Promise<void>;
|
|
48
|
+
/** Better Auth base path. Defaults to `/api/auth`. */
|
|
49
|
+
authBasePath?: string;
|
|
50
|
+
/** Maximum accepted URL-encoded request body size. */
|
|
51
|
+
maxBodyBytes?: number;
|
|
52
|
+
/** Server-only opt-in environment name. */
|
|
53
|
+
optInEnvName?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Returns whether developer UI login is explicitly enabled for this process.
|
|
57
|
+
*
|
|
58
|
+
* The helper deliberately rejects production/test modes and every Vercel
|
|
59
|
+
* runtime. Tests should pass an explicit development-shaped environment and
|
|
60
|
+
* exercise the handler with loopback requests.
|
|
61
|
+
*/
|
|
62
|
+
export declare function isBetterAuthLocalTestLoginEnabled(env: BetterAuthLocalTestLoginEnv, optInEnvName?: string): boolean;
|
|
63
|
+
/** Keep a callback on an application page of the current origin. */
|
|
64
|
+
export declare function safeBetterAuthLocalTestCallbackURL(value: unknown, fallback?: string): string;
|
|
65
|
+
/** Return a safe same-origin application callback path, or null. */
|
|
66
|
+
export declare function normalizeBetterAuthLocalTestCallbackURL(value: unknown): string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a POST-only, loopback-only Better Auth developer-login handler.
|
|
69
|
+
*
|
|
70
|
+
* All request/deployment guards run before the body is read, Better Auth hashes
|
|
71
|
+
* a credential, or the app provisioning callback can reach its database.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createBetterAuthLocalTestLoginHandler<TIdentities extends Record<string, BetterAuthLocalTestLoginIdentity>>(options: CreateBetterAuthLocalTestLoginHandlerOptions<TIdentities>): (request: Request) => Promise<Response>;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=localTestLogin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localTestLogin.d.ts","sourceRoot":"","sources":["../../../../src/src/next/auth/localTestLogin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wCAAwC,0BAA0B,CAAC;AAChF,eAAO,MAAM,mDAAmD,QAAW,CAAC;AAE5E,KAAK,2BAA2B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEtE,KAAK,+BAA+B,GAAG;IACrC,QAAQ,EAAE;QACR,IAAI,CAAC,QA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AsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,2BAA2B,EAChC,YAAY,SAA2C,GACtD,OAAO,CAMT;AA6FD,oEAAoE;AACpE,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,EACd,QAAQ,SAAM,GACb,MAAM,CAMR;AAED,oEAAoE;AACpE,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,OAAO,GACb,MAAM,GAAG,IAAI,CA2Bf;AAyED;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,gCAAgC,CAAC,EAEpE,OAAO,EAAE,4CAA4C,CAAC,WAAW,CAAC,GACjE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAkGzC"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
export const DEFAULT_BETTER_AUTH_LOCAL_TEST_LOGIN_ENV = "LOOM_LOCAL_TEST_LOGIN";
|
|
2
|
+
export const DEFAULT_BETTER_AUTH_LOCAL_TEST_LOGIN_MAX_BODY_BYTES = 8 * 1024;
|
|
3
|
+
/**
|
|
4
|
+
* Returns whether developer UI login is explicitly enabled for this process.
|
|
5
|
+
*
|
|
6
|
+
* The helper deliberately rejects production/test modes and every Vercel
|
|
7
|
+
* runtime. Tests should pass an explicit development-shaped environment and
|
|
8
|
+
* exercise the handler with loopback requests.
|
|
9
|
+
*/
|
|
10
|
+
export function isBetterAuthLocalTestLoginEnabled(env, optInEnvName = DEFAULT_BETTER_AUTH_LOCAL_TEST_LOGIN_ENV) {
|
|
11
|
+
return env.NODE_ENV === "development" &&
|
|
12
|
+
env[optInEnvName] === "1" &&
|
|
13
|
+
!Object.entries(env).some(([name, value]) => name.startsWith("VERCEL") && Boolean(value));
|
|
14
|
+
}
|
|
15
|
+
function randomLocalPassword() {
|
|
16
|
+
return `${crypto.randomUUID()}${crypto.randomUUID()}`;
|
|
17
|
+
}
|
|
18
|
+
function isLoopbackHostname(hostname) {
|
|
19
|
+
const normalized = hostname.toLowerCase();
|
|
20
|
+
return normalized === "localhost" ||
|
|
21
|
+
normalized === "127.0.0.1" ||
|
|
22
|
+
normalized === "[::1]" ||
|
|
23
|
+
normalized === "::1";
|
|
24
|
+
}
|
|
25
|
+
function hasControlCharacters(value) {
|
|
26
|
+
return [...value].some((character) => {
|
|
27
|
+
const code = character.charCodeAt(0);
|
|
28
|
+
return code <= 0x1f || code === 0x7f;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function parseHttpOrigin(value) {
|
|
32
|
+
try {
|
|
33
|
+
const origin = new URL(value);
|
|
34
|
+
if (origin.protocol !== "http:" ||
|
|
35
|
+
origin.origin !== value ||
|
|
36
|
+
!isLoopbackHostname(origin.hostname)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return origin;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function parseLoopbackHost(value) {
|
|
46
|
+
if (!value || /[\\/?#@]/.test(value) || hasControlCharacters(value)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const parsed = new URL(`http://${value}`);
|
|
51
|
+
if (!isLoopbackHostname(parsed.hostname))
|
|
52
|
+
return null;
|
|
53
|
+
return parsed.host;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function commaSeparatedValues(value) {
|
|
60
|
+
if (value === null)
|
|
61
|
+
return [];
|
|
62
|
+
const values = value.split(",").map((entry) => entry.trim());
|
|
63
|
+
return values.every(Boolean) ? values : [];
|
|
64
|
+
}
|
|
65
|
+
function requestLoopbackOrigin(request) {
|
|
66
|
+
const requestOrigin = parseHttpOrigin(new URL(request.url).origin);
|
|
67
|
+
const origin = request.headers.get("origin");
|
|
68
|
+
const parsedOrigin = origin ? parseHttpOrigin(origin) : null;
|
|
69
|
+
const host = request.headers.get("host");
|
|
70
|
+
const parsedHost = host ? parseLoopbackHost(host) : null;
|
|
71
|
+
if (!requestOrigin || !parsedOrigin || !parsedHost)
|
|
72
|
+
return null;
|
|
73
|
+
const forwardedHosts = commaSeparatedValues(request.headers.get("x-forwarded-host"));
|
|
74
|
+
if (request.headers.has("x-forwarded-host") &&
|
|
75
|
+
(forwardedHosts.length !== 1 || !parseLoopbackHost(forwardedHosts[0]))) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const forwardedProtocols = commaSeparatedValues(request.headers.get("x-forwarded-proto"));
|
|
79
|
+
if (request.headers.has("x-forwarded-proto") &&
|
|
80
|
+
(forwardedProtocols.length !== 1 ||
|
|
81
|
+
forwardedProtocols[0].toLowerCase() !== "http")) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const effectivePublicHost = forwardedHosts.length
|
|
85
|
+
? parseLoopbackHost(forwardedHosts[0])
|
|
86
|
+
: parsedHost;
|
|
87
|
+
if (parsedOrigin.host !== effectivePublicHost)
|
|
88
|
+
return null;
|
|
89
|
+
return parsedOrigin;
|
|
90
|
+
}
|
|
91
|
+
/** Keep a callback on an application page of the current origin. */
|
|
92
|
+
export function safeBetterAuthLocalTestCallbackURL(value, fallback = "/") {
|
|
93
|
+
const safeFallback = normalizeBetterAuthLocalTestCallbackURL(fallback);
|
|
94
|
+
if (!safeFallback) {
|
|
95
|
+
throw new Error("Invalid local test login fallback callback URL");
|
|
96
|
+
}
|
|
97
|
+
return normalizeBetterAuthLocalTestCallbackURL(value) ?? safeFallback;
|
|
98
|
+
}
|
|
99
|
+
/** Return a safe same-origin application callback path, or null. */
|
|
100
|
+
export function normalizeBetterAuthLocalTestCallbackURL(value) {
|
|
101
|
+
if (typeof value !== "string" ||
|
|
102
|
+
!value.startsWith("/") ||
|
|
103
|
+
value.length > 4096) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const decoded = decodeURIComponent(value);
|
|
108
|
+
if (decoded.startsWith("//") || decoded.includes("\\") ||
|
|
109
|
+
hasControlCharacters(decoded)) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const url = new URL(value, "https://local-test.invalid");
|
|
113
|
+
if (url.origin !== "https://local-test.invalid" ||
|
|
114
|
+
/^\/api(?:\/|$)/.test(decodeURIComponent(url.pathname))) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
return url.pathname + url.search + url.hash;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function contentLengthIsAllowed(request, maxBodyBytes) {
|
|
124
|
+
const value = request.headers.get("content-length");
|
|
125
|
+
if (value === null)
|
|
126
|
+
return true;
|
|
127
|
+
if (!/^(0|[1-9]\d*)$/.test(value))
|
|
128
|
+
return false;
|
|
129
|
+
return Number(value) <= maxBodyBytes;
|
|
130
|
+
}
|
|
131
|
+
async function readBoundedBody(request, maxBodyBytes) {
|
|
132
|
+
if (!request.body)
|
|
133
|
+
return "";
|
|
134
|
+
const reader = request.body.getReader();
|
|
135
|
+
const chunks = [];
|
|
136
|
+
let size = 0;
|
|
137
|
+
try {
|
|
138
|
+
while (true) {
|
|
139
|
+
const { done, value } = await reader.read();
|
|
140
|
+
if (done)
|
|
141
|
+
break;
|
|
142
|
+
size += value.byteLength;
|
|
143
|
+
if (size > maxBodyBytes) {
|
|
144
|
+
try {
|
|
145
|
+
await reader.cancel();
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// The request is already rejected; a broken producer cannot escape.
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
chunks.push(value);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
try {
|
|
157
|
+
await reader.cancel();
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// The request is already rejected; a broken producer cannot escape.
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
try {
|
|
166
|
+
reader.releaseLock();
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// A failed stream read is handled as invalid input below.
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const body = new Uint8Array(size);
|
|
173
|
+
let offset = 0;
|
|
174
|
+
for (const chunk of chunks) {
|
|
175
|
+
body.set(chunk, offset);
|
|
176
|
+
offset += chunk.byteLength;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(body);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function notFoundResponse() {
|
|
186
|
+
return new Response("Not found", { status: 404 });
|
|
187
|
+
}
|
|
188
|
+
function getSetCookieValues(headers) {
|
|
189
|
+
const getSetCookie = headers.getSetCookie;
|
|
190
|
+
if (getSetCookie)
|
|
191
|
+
return getSetCookie.call(headers);
|
|
192
|
+
const value = headers.get("set-cookie");
|
|
193
|
+
return value ? [value] : [];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Creates a POST-only, loopback-only Better Auth developer-login handler.
|
|
197
|
+
*
|
|
198
|
+
* All request/deployment guards run before the body is read, Better Auth hashes
|
|
199
|
+
* a credential, or the app provisioning callback can reach its database.
|
|
200
|
+
*/
|
|
201
|
+
export function createBetterAuthLocalTestLoginHandler(options) {
|
|
202
|
+
const enabled = isBetterAuthLocalTestLoginEnabled(options.env, options.optInEnvName);
|
|
203
|
+
const authBasePath = options.authBasePath ?? "/api/auth";
|
|
204
|
+
const maxBodyBytes = options.maxBodyBytes ??
|
|
205
|
+
DEFAULT_BETTER_AUTH_LOCAL_TEST_LOGIN_MAX_BODY_BYTES;
|
|
206
|
+
if (!/^\/[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*$/.test(authBasePath)) {
|
|
207
|
+
throw new Error("Invalid Better Auth base path");
|
|
208
|
+
}
|
|
209
|
+
if (!Number.isSafeInteger(maxBodyBytes) || maxBodyBytes < 1) {
|
|
210
|
+
throw new Error("Invalid local test login body limit");
|
|
211
|
+
}
|
|
212
|
+
const passwords = new Map();
|
|
213
|
+
return async function localTestLogin(request) {
|
|
214
|
+
if (!enabled || request.method !== "POST")
|
|
215
|
+
return notFoundResponse();
|
|
216
|
+
const publicOrigin = requestLoopbackOrigin(request);
|
|
217
|
+
if (!publicOrigin)
|
|
218
|
+
return notFoundResponse();
|
|
219
|
+
const contentType = request.headers.get("content-type")?.split(";", 1)[0]
|
|
220
|
+
.trim().toLowerCase();
|
|
221
|
+
if (contentType !== "application/x-www-form-urlencoded" ||
|
|
222
|
+
!contentLengthIsAllowed(request, maxBodyBytes)) {
|
|
223
|
+
return new Response("Invalid request", { status: 400 });
|
|
224
|
+
}
|
|
225
|
+
const body = await readBoundedBody(request, maxBodyBytes);
|
|
226
|
+
if (body === null)
|
|
227
|
+
return new Response("Invalid request", { status: 400 });
|
|
228
|
+
const fields = new URLSearchParams(body);
|
|
229
|
+
const allowedFields = new Set(["identity", "callbackURL"]);
|
|
230
|
+
if ([...fields.keys()].some((key) => !allowedFields.has(key))) {
|
|
231
|
+
return new Response("Invalid request", { status: 400 });
|
|
232
|
+
}
|
|
233
|
+
const identityKeys = fields.getAll("identity");
|
|
234
|
+
const callbackValues = fields.getAll("callbackURL");
|
|
235
|
+
if (identityKeys.length !== 1 || callbackValues.length > 1) {
|
|
236
|
+
return new Response("Invalid request", { status: 400 });
|
|
237
|
+
}
|
|
238
|
+
const key = identityKeys[0];
|
|
239
|
+
if (!Object.prototype.hasOwnProperty.call(options.identities, key)) {
|
|
240
|
+
return new Response("Invalid request", { status: 400 });
|
|
241
|
+
}
|
|
242
|
+
const identity = options.identities[key];
|
|
243
|
+
const callbackURL = safeBetterAuthLocalTestCallbackURL(callbackValues[0], identity.defaultCallbackURL);
|
|
244
|
+
let password = passwords.get(key);
|
|
245
|
+
if (!password) {
|
|
246
|
+
password = identity.password?.trim() || randomLocalPassword();
|
|
247
|
+
passwords.set(key, password);
|
|
248
|
+
}
|
|
249
|
+
const context = await options.auth.$context;
|
|
250
|
+
const passwordHash = await context.password.hash(password);
|
|
251
|
+
await options.provisionIdentity({
|
|
252
|
+
identity,
|
|
253
|
+
key,
|
|
254
|
+
password,
|
|
255
|
+
passwordHash,
|
|
256
|
+
});
|
|
257
|
+
const signInHeaders = new Headers({
|
|
258
|
+
"content-type": "application/json",
|
|
259
|
+
origin: publicOrigin.origin,
|
|
260
|
+
});
|
|
261
|
+
const userAgent = request.headers.get("user-agent");
|
|
262
|
+
if (userAgent)
|
|
263
|
+
signInHeaders.set("user-agent", userAgent);
|
|
264
|
+
const signInResponse = await options.auth.handler(new Request(new URL(`${authBasePath}/sign-in/email`, publicOrigin), {
|
|
265
|
+
body: JSON.stringify({
|
|
266
|
+
email: identity.email,
|
|
267
|
+
password,
|
|
268
|
+
rememberMe: true,
|
|
269
|
+
}),
|
|
270
|
+
headers: signInHeaders,
|
|
271
|
+
method: "POST",
|
|
272
|
+
}));
|
|
273
|
+
if (!signInResponse.ok)
|
|
274
|
+
return signInResponse;
|
|
275
|
+
const responseHeaders = new Headers({ location: callbackURL });
|
|
276
|
+
for (const cookie of getSetCookieValues(signInResponse.headers)) {
|
|
277
|
+
responseHeaders.append("set-cookie", cookie);
|
|
278
|
+
}
|
|
279
|
+
return new Response(null, {
|
|
280
|
+
headers: responseHeaders,
|
|
281
|
+
status: 303,
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/next/auth/mod.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/next/auth/mod.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
package/esm/src/next/auth/mod.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadicc/loom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.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": "e381c057d5eb321d4982119984d98ec292d79c41"
|
|
235
235
|
},
|
|
236
236
|
"bin": {
|
|
237
237
|
"loom": "script/bin/loom.js"
|