Files
causius/lib/helpers/http.ts
CatoandClaude e3dcbda881 feat(helpers): a directory of helpers, lawyers checked and still pseudonymous (#25)
- Helpers list themselves (AI service, legal assistant, licensed lawyer) under
  a name or pseudonym; the same account keeps matters of its own. Directory
  search and filters through searchkit and listkit, with the typo suite.
- A lawyer's admission is submitted privately (evidence sealed per
  credential), checked by a staff reviewer, and published as an SD-JWT signed
  with Ed25519: the place in clear, the legal name only as a salted digest.
  Key at /.well-known/jwks.json; anyone can check at /verify. A lawyer is
  listed only where verified.
- An owner asks a helper about a matter, with or without their personal
  details; the request is previewed exactly as it will be read. Accepted, the
  helper becomes a participant; anonymisation is applied in the store, so no
  route can forget it. A lawyer hands over the checked name with proof.
  Ending it removes access in the same transaction.
- Reviewers are staff/admin accounts, granted by the Grant role workflow.
- Who may do what is lib/professions.ts, the one domain file, so Diplodoctor
  reuses the engine by changing it.
- Fixes: the account menu label template; one site URL instead of three, with
  a dev-only origin so local sign-in works.


Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-21 05:48:41 +02:00

21 lines
915 B
TypeScript

import { reviewer } from "@/lib/auth";
import { encryptionConfigured, masterKey } from "@/lib/crypto";
import { dbConfigured, getDb, type Db } from "@/lib/db";
import { json } from "@/lib/matters/http";
/**
* The directory and a profile are public: they need the database and nothing
* else. Signed-in helper routes use the matters' `context()`; review routes
* use `reviewContext()`, which answers 403 to anyone who is not staff.
*/
export function publicDb(): Db | Response {
return dbConfigured() ? getDb() : json({ error: "not_configured" }, 503);
}
export async function reviewContext(): Promise<{ db: Db; master: Buffer; sub: string } | Response> {
if (!dbConfigured() || !encryptionConfigured()) return json({ error: "not_configured" }, 503);
const who = await reviewer();
if (!who) return json({ error: "not_allowed" }, 403);
return { db: getDb(), master: masterKey(), sub: who.actorId };
}