The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Accounts 1: sign-in card, auth-schema script, pinned library licences
Claude851c47e2a560
diff --git a/scripts/auth-schema.mjs b/scripts/auth-schema.mjsnew file mode 100644index 00000000..9eb5cf6b--- /dev/null+++ b/scripts/auth-schema.mjs@@ -0,0 +1,80 @@+#!/usr/bin/env node+/**+ * Better Auth's tables, frozen as SQL for Fuobe's migrations (docs/research/accounts-8.md §5.2, §7.1).+ *+ * Fuobe never lets Better Auth change the database at run time: its tables are created by an ordinary migration in+ * src/server/db.ts, with exactly the SQL Better Auth would have run. This prints that SQL.+ *+ * node scripts/auth-schema.mjs the full SQL for an empty database (what the identity base froze)+ * node scripts/auth-schema.mjs --db <file> what that database still lacks: append it as a new migration+ * node scripts/auth-schema.mjs --db <file> --check+ * exit 1 when anything is missing (the schema-guard test does the+ * same against the running configuration)+ *+ * The table names and plugin list come from src/server/identity/schema.ts, the file auth.ts reads them from. A+ * package that loads a plugin with tables adds it there and in PLUGINS below.+ */+import fs from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";+import Database from "better-sqlite3";+import { getMigrations } from "better-auth/db/migration";++// schema.ts is plain TypeScript Node can strip; it only warns that package.json names no module type.+process.removeAllListeners("warning");+process.on("warning", (w) => w.code !== "MODULE_TYPELESS_PACKAGE_JSON" && console.warn(w));+const { AUTH_PLUGINS_WITH_TABLES, AUTH_TABLES } = await import("../src/server/identity/schema.ts");++/** Plugin id → a factory with the options that matter for its tables. Empty until a package loads one. */+const PLUGINS = {};++const args = process.argv.slice(2);+const flag = (name) => args.includes(name);+const value = (name) => {+ const i = args.indexOf(name);+ return i >= 0 ? args[i + 1] : undefined;+};++const file = value("--db");+if (file && !fs.existsSync(file)) {+ console.error(`No database at ${file}`);+ process.exit(2);+}+const missing = AUTH_PLUGINS_WITH_TABLES.filter((id) => !PLUGINS[id]);+if (missing.length) {+ console.error(`scripts/auth-schema.mjs doesn't know how to load: ${missing.join(", ")}. Add them to PLUGINS.`);+ process.exit(2);+}++const database = new Database(file ?? ":memory:", { readonly: !!file });+const options = {+ database,+ telemetry: { enabled: false },+ logger: { disabled: true },+ user: { modelName: AUTH_TABLES.user },+ session: { modelName: AUTH_TABLES.session },+ account: { modelName: AUTH_TABLES.account },+ verification: { modelName: AUTH_TABLES.verification },+ rateLimit: { enabled: true, storage: "database", modelName: AUTH_TABLES.rateLimit },+ emailAndPassword: { enabled: true },+ plugins: AUTH_PLUGINS_WITH_TABLES.map((id) => PLUGINS[id]()),+};++const m = await getMigrations(options, { throwOnUnsafe: false });+const pending = m.toBeCreated.length + m.toBeAdded.length + m.toBeAddedIndexes.length;+const sql = pending ? (await m.compileMigrations()).trim() : "";+database.close();++const self = path.relative(process.cwd(), fileURLToPath(import.meta.url));+if (flag("--check")) {+ if (pending) {+ console.error(`Better Auth wants schema changes in ${file ?? "an empty database"}:\n\n${sql}\n\nFreeze them in a new migration (node ${self} --db ${file ?? "<file>"}).`);+ process.exit(1);+ }+ console.log("Better Auth's tables match.");+} else if (!pending) {+ console.log(`-- Nothing to freeze: ${file ?? "the database"} already has every table and column Better Auth uses.`);+} else {+ console.log(sql);+ for (const u of m.unsafeChanges) console.error(`warning: ${u}`);+}diff --git a/src/app/(studio)/settings/about/page.tsx b/src/app/(studio)/settings/about/page.tsxindex d8284f9f..899aed28 100644--- a/src/app/(studio)/settings/about/page.tsx+++ b/src/app/(studio)/settings/about/page.tsx@@ -8,7 +8,7 @@ import { PageHeader, PageShell } from "@/components/page-shell";import { MODELS } from "@/lib/catalog";import type { Manifest } from "@/lib/comfy";import { FUOBE_REPO } from "@/lib/connections";-import { buildLicenceList } from "@/lib/licences";+import { buildLicenceList, PINNED_LIBRARIES } from "@/lib/licences";export const metadata: Metadata = { title: "About & licences" };@@ -121,6 +121,19 @@ export default async function Page() {Models you pull into Ollama for Assist and prompt enhancement carry their own licences: <code className="font-mono text-[12px]">ollama show <model> --license</code>.</li><li>The optional TRIBE v2 worker for the Virality page isn't bundled; its weights are CC BY-NC 4.0 (non-commercial).</li>+ <li>+ Sign-in runs on{" "}+ {PINNED_LIBRARIES.map((l, i) => (+ <span key={l.name}>+ {i ? (i === PINNED_LIBRARIES.length - 1 ? " and " : ", ") : ""}+ <a href={l.licence.url} target="_blank" rel="noreferrer" className="text-brand-text underline underline-offset-2">+ {l.name} {l.version}+ </a>{" "}+ ({l.licence.name})+ </span>+ ))}+ .+ </li><li>Each workflow's models, sizes and download links are on the{" "}<Link href="/workflows" className="text-brand-text underline underline-offset-2">diff --git a/src/app/login/page.tsx b/src/app/login/page.tsxindex 9d5f993c..34e29a07 100644--- a/src/app/login/page.tsx+++ b/src/app/login/page.tsx@@ -1,14 +1,39 @@import type { Metadata } from "next";+import { connection } from "next/server";+import { Lock } from "lucide-react";import { Suspense } from "react";import { LoginForm } from "@/components/login-form";+import { Skeleton } from "@/components/ui/skeleton";+import { installName } from "@/server/mode";export const metadata: Metadata = { title: "Sign in" };+/** The install's name for the card's line ("Sign in to Fuobe."): read per request, never prerendered. */+async function Card() {+ await connection();+ return <LoginForm installName={installName()} />;+}++/** The card's frame while the name loads (prerendered; no field yet). */+function CardShell() {+ return (+ <div className="w-full max-w-sm rounded-2xl border bg-background p-7 shadow-soft max-[400px]:p-6" aria-busy>+ <div className="mb-5 grid size-11 place-items-center rounded-xl bg-primary text-primary-foreground">+ <Lock className="size-5" aria-hidden />+ </div>+ <h1 className="font-heading text-[28px] leading-tight">Welcome back</h1>+ <Skeleton className="mt-2 h-4 w-40" />+ <Skeleton className="mt-6 h-11 w-full" />+ <Skeleton className="mt-4 h-11 w-full" />+ </div>+ );+}+export default function Page() {return (<main className="grid min-h-svh place-items-center bg-sidebar px-4">- <Suspense>- <LoginForm />+ <Suspense fallback={<CardShell />}>+ <Card /></Suspense></main>);diff --git a/src/components/login-form.tsx b/src/components/login-form.tsxindex a93b01b8..a4fc86ad 100644--- a/src/components/login-form.tsx+++ b/src/components/login-form.tsx@@ -1,53 +1,93 @@"use client";-import { Loader2, Lock } from "lucide-react";+import { Eye, EyeOff, Loader2, Lock } from "lucide-react";import { useSearchParams } from "next/navigation";-import { useState } from "react";+import { useId, useState } from "react";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";+import { Label } from "@/components/ui/label";import { safeNext } from "@/lib/safe-redirect";+import { refusalMessage } from "@/lib/sign-in-refusals";-export function LoginForm() {+/**+ * The Personal sign-in card (docs/research/accounts-8-screens.md §S2.1): one password field, never an email. A+ * refusal the proxy sent here (?code=) shows above the field. After signing in the page loads in full, so nothing+ * from before stays in memory.+ */+export function LoginForm({ installName }: { installName: string }) {const params = useSearchParams();+ const id = useId();const [password, setPassword] = useState("");- const [error, setError] = useState<string | null>(null);+ const [shown, setShown] = useState(false);+ const [error, setError] = useState<string | null>(() => {+ const code = params.get("code");+ return code ? refusalMessage(code, { name: installName }) : null;+ });const [busy, setBusy] = useState(false);+ const [forgot, setForgot] = useState(false);const submit = async (e: React.FormEvent) => {e.preventDefault();setBusy(true);setError(null);- const res = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ password }) });- if (res.ok) {+ const res = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ password }) }).catch(() => null);+ if (res?.ok) {// Only a page on this site: never bounce to another origin after signing in.window.location.assign(safeNext(params.get("next"), window.location.origin));return;}- setError(((await res.json().catch(() => ({}))) as { error?: string }).error ?? "Couldn't sign in");+ setError(res ? (((await res.json().catch(() => ({}))) as { error?: string }).error ?? "Couldn't sign in. Try again.") : "Can't reach Fuobe. Check your connection and try again.");setBusy(false);};return (- <form onSubmit={submit} className="w-full max-w-sm animate-fade-up rounded-2xl border bg-background p-7 shadow-soft">+ <form onSubmit={submit} className="w-full max-w-sm animate-fade-up rounded-2xl border bg-background p-7 shadow-soft max-[400px]:p-6"><div className="mb-5 grid size-11 place-items-center rounded-xl bg-primary text-primary-foreground">- <Lock className="size-5" />+ <Lock className="size-5" aria-hidden /></div><h1 className="font-heading text-[28px] leading-tight">Welcome back</h1>- <p className="mt-1 text-[13px] text-muted-foreground">This Fuobe studio is password protected.</p>- <Input- type="password"- autoFocus- autoComplete="current-password"- placeholder="Password"- value={password}- onChange={(e) => setPassword(e.target.value)}- className="mt-5 h-11"- aria-invalid={!!error}- />- {error && <p className="mt-2 text-[13px] text-destructive">{error}</p>}+ <p className="mt-1 text-[13px] text-muted-foreground [overflow-wrap:anywhere]">Sign in to {installName}.</p>+ <Label htmlFor={`${id}-password`} className="mt-5 text-[13px]">+ Password+ </Label>+ <div className="relative mt-1.5">+ <Input+ id={`${id}-password`}+ type={shown ? "text" : "password"}+ autoFocus+ autoComplete="current-password"+ value={password}+ onChange={(e) => setPassword(e.target.value)}+ className="h-11 pr-11"+ aria-invalid={!!error}+ aria-describedby={error ? `${id}-error` : undefined}+ />+ <button+ type="button"+ onClick={() => setShown((s) => !s)}+ aria-pressed={shown}+ aria-label={shown ? "Hide password" : "Show password"}+ className="absolute inset-y-0 right-0 grid w-11 place-items-center rounded-r-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ {shown ? <EyeOff className="size-4" /> : <Eye className="size-4" />}+ </button>+ </div>+ {error && (+ <p id={`${id}-error`} role="alert" className="mt-2 text-[13px] text-destructive">+ {error}+ </p>+ )}<Button type="submit" className="mt-4 h-11 w-full" disabled={!password || busy}>{busy && <Loader2 className="animate-spin" />} Sign in</Button>+ <button type="button" onClick={() => setForgot((f) => !f)} aria-expanded={forgot} className="mt-4 text-[13px] text-muted-foreground underline-offset-4 hover:text-foreground hover:underline">+ Forgot password?+ </button>+ {forgot && (+ <p className="mt-2 text-[13px] leading-relaxed text-muted-foreground">+ On the computer where Fuobe runs, start it again with <code className="rounded bg-muted px-1 py-0.5 font-mono text-[12px] text-foreground">FUOBE_PASSWORD</code> set to a new password. That password works right away, and every browser signs in again.+ </p>+ )}</form>);}diff --git a/src/lib/licences.ts b/src/lib/licences.tsindex f1690323..5ff8239d 100644--- a/src/lib/licences.ts+++ b/src/lib/licences.ts@@ -435,6 +435,39 @@ export const NODE_PACKS: NodePack[] = [export const nodePack = (name: string): NodePack | undefined => NODE_PACKS.find((p) => p.name === name);+// ---------------------------------------------------------------------------+// Libraries pinned under the accounts plan's version rule (docs/research/accounts-8.md §5.2): the newest release at+// least 14 days old and free of OSV advisories, pinned exact in package.json (a test keeps the two in step). Each+// package that adds one records it here with its licence.++export interface PinnedLibrary {+ name: string;+ /** The exact version in package.json. */+ version: string;+ /** What Fuobe uses it for. */+ use: string;+ /** When the rule was applied (the 14 days count back from here). */+ pinnedOn: string;+ licence: LicenceInfo;+}++export const PINNED_LIBRARIES: PinnedLibrary[] = [+ {+ name: "better-auth",+ version: "1.7.10",+ use: "Sign-in behind Fuobe: passwords and sessions (later passkeys, two-step, Google/GitHub/OIDC and company sign-in)",+ pinnedOn: "2026-10-29",+ licence: { name: "MIT", class: "commercial", url: "https://github.com/better-auth/better-auth/blob/main/LICENSE.md", note: "MIT; every @better-auth/* package it pulls in is the same version" },+ },+ {+ name: "kysely",+ version: "0.29.6",+ use: "The SQL layer Better Auth runs on (Fuobe hands it the connection with transactions off)",+ pinnedOn: "2026-10-29",+ licence: { name: "MIT", class: "commercial", url: SPDX("MIT"), note: "MIT; already Better Auth's dependency, pinned so Fuobe and Better Auth share one copy" },+ },+];+/** The parts of a LoRA's licence snapshot the class needs (src/lib/catalog/types.ts LoraLicence). */interface LoraLicenceLike {commercial: boolean;diff --git a/src/server/identity/auth.ts b/src/server/identity/auth.tsindex 8891a0f8..0da40f46 100644--- a/src/server/identity/auth.ts+++ b/src/server/identity/auth.ts@@ -12,6 +12,7 @@ import { INSTALL, installMode, installValue, siteUrl } from "../mode";import { appendAudit } from "./audit-log";import { hashPassword, needsRehash, PASSWORD_MAX, PASSWORD_MIN, verifyPassword } from "./password";import { refusal } from "./refusals";+import { AUTH_TABLES } from "./schema";import { deriveKey } from "./secret";/**@@ -256,21 +257,21 @@ export function buildAuthOptions(site: AuthSite) {},},trustedOrigins: (request?: Request) => trustedOriginsFor(request),- user: { modelName: "auth_user" },+ user: { modelName: AUTH_TABLES.user },account: {- modelName: "auth_account",+ modelName: AUTH_TABLES.account,accountLinking: { trustedProviders: [] as string[], allowDifferentEmails: false },},session: {- modelName: "auth_session",+ modelName: AUTH_TABLES.session,expiresIn: 30 * 86_400,updateAge: 86_400,deferSessionRefresh: true,freshAge: 600,cookieCache: { enabled: false },},- verification: { modelName: "auth_verification", storeIdentifier: "hashed" as const },- rateLimit: { enabled: true, storage: "database" as const, modelName: "auth_rate_limit" },+ verification: { modelName: AUTH_TABLES.verification, storeIdentifier: "hashed" as const },+ rateLimit: { enabled: true, storage: "database" as const, modelName: AUTH_TABLES.rateLimit },emailAndPassword: {enabled: true,minPasswordLength: PASSWORD_MIN,diff --git a/src/server/identity/schema.ts b/src/server/identity/schema.tsnew file mode 100644index 00000000..c45e82ad--- /dev/null+++ b/src/server/identity/schema.ts@@ -0,0 +1,18 @@+/**+ * The parts of Better Auth's options that decide its tables (docs/research/accounts-8.md §7.1): table names and+ * the plugins whose tables are frozen in Fuobe's migrations. Plain data with no imports, so scripts/auth-schema.mjs+ * reads the same values as src/server/identity/auth.ts. A package that loads a plugin with tables (two-factor,+ * passkey, sso) adds its id here and to the script's plugin map, runs the script against a database and appends+ * the SQL it prints as that package's migration.+ */++export const AUTH_TABLES = {+ user: "auth_user",+ session: "auth_session",+ account: "auth_account",+ verification: "auth_verification",+ rateLimit: "auth_rate_limit",+} as const;++/** Plugins whose tables exist in the migrations (none in the identity base). */+export const AUTH_PLUGINS_WITH_TABLES: readonly string[] = [];diff --git a/tests/identity-better-auth.test.ts b/tests/identity-better-auth.test.tsindex a1be4225..531cacad 100644--- a/tests/identity-better-auth.test.ts+++ b/tests/identity-better-auth.test.ts@@ -4,6 +4,7 @@* database hooks, returnHeaders, the internal adapter — and the schema guard. A library upgrade that changes any* of these fails here first.*/+import { execFileSync } from "node:child_process";import fs from "node:fs";import os from "node:os";import path from "node:path";@@ -169,3 +170,18 @@ describe("admin operations (§7.1)", () => {}});});++describe("scripts/auth-schema.mjs", () => {+ const run = (...args: string[]) => execFileSync(process.execPath, ["scripts/auth-schema.mjs", ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });++ it("prints exactly the SQL frozen in the identity migration", () => {+ const frozen = fs.readFileSync(path.join(process.cwd(), "src/server/db.ts"), "utf8");+ const statements = run().split(/;\s*\n/).map((s) => s.trim().replace(/;$/, "")).filter(Boolean);+ expect(statements.length).toBeGreaterThanOrEqual(8);+ for (const s of statements) expect(frozen, s).toContain(`${s};`);+ });++ it("finds nothing missing in a migrated database", () => {+ expect(run("--db", path.join(dir, "fuobe.db"), "--check")).toMatch(/match/);+ });+});diff --git a/tests/licences.test.ts b/tests/licences.test.tsindex 374772cb..94ab586c 100644--- a/tests/licences.test.ts+++ b/tests/licences.test.ts@@ -84,3 +84,16 @@ describe("licences", () => {expect(without.notices.some((n) => n.text === "Built with DINOv3")).toBe(false);});});++describe("pinned libraries (accounts plan §5.2)", () => {+ it("record a licence for each, at the exact version package.json pins", async () => {+ const { PINNED_LIBRARIES } = await import("@/lib/licences");+ const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json"), "utf8")) as { dependencies: Record<string, string> };+ expect(PINNED_LIBRARIES.map((l) => l.name)).toEqual(expect.arrayContaining(["better-auth", "kysely"]));+ for (const l of PINNED_LIBRARIES) {+ expect(pkg.dependencies[l.name], l.name).toBe(l.version);+ expect(l.licence.name, l.name).toBeTruthy();+ expect(l.licence.note, l.name).toBeTruthy();+ }+ });+});