import type { User } from 'types'; import { Hono } from 'hono'; export type HonoVariables = { body: Record; origin: string; /** * The authenticated account, plus — on routes that resolve it — the home directory this request is * confined to. * * `homeDir` is optional because only the file browser's `confineToHome` middleware sets it, and it lives * on `user` rather than in its own variable for a blunt reason: `getRootDir(user, root)` is called from * fifteen places in that router, and the cost of missing one is serving the OWNER'S home to a member. * Carrying it on the object those call sites already receive means none of them can forget. */ user: User & { homeDir?: string }; /** * The narrowing carried by the credential that made this request — permission keys, or null when it * carries its holder's full authority (every session JWT, every key a human minted). * * Set by the permission gate, which has already resolved the token and is the only place that should. * A route reads it when it hands authority ONWARD — `POST /tasks/:name/run` mints a token for the * script it spawns, and that token must not be wider than the credential that asked for the run. */ credentialPermissions: string[] | null; }; export const createRouter = () => new Hono<{ Variables: HonoVariables }>();