mirror of
https://github.com/bitbaum/causius.git
synced 2026-12-05 06:47:23 +01:00
- 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>
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import { isStaff } from "@bitbaum/accountkit/auth";
|
|
import { createAuthRuntime } from "@bitbaum/accountkit/auth/next";
|
|
import { dbConfigured, getDb } from "../db";
|
|
import { mailConfigured, sendAuthMail } from "../mail";
|
|
import { SITE } from "../site";
|
|
import { adoptLegacyMatters } from "./legacy";
|
|
|
|
/**
|
|
* Accounts for Causius: the same account system as every fleet product
|
|
* (@bitbaum/accountkit/auth) — email and password, a link, a passkey, two-step
|
|
* codes, and, where configured, the shared bitbaum sign-in and OrangeCat. A
|
|
* person does not need an OrangeCat account; with one, it is one click.
|
|
*/
|
|
export const { GET, POST, getSession, requireUser, authStatus, getAuth } =
|
|
createAuthRuntime({
|
|
site: SITE,
|
|
mail: { configured: mailConfigured(), send: sendAuthMail },
|
|
isDatabaseConfigured: () => dbConfigured(),
|
|
getDatabase: () => getDb(),
|
|
// Matters made while OrangeCat was the only way in belong to the same person.
|
|
onAccountCreated: async ({ userId, providerId, accountId }) => {
|
|
if (providerId === "orangecat")
|
|
await adoptLegacyMatters(getDb(), accountId, userId);
|
|
},
|
|
});
|
|
|
|
/**
|
|
* The signed-in person as the rest of the app reads them: `actorId` is the
|
|
* account's id, kept under the name every call site already uses.
|
|
*/
|
|
export async function auth(): Promise<{
|
|
actorId: string;
|
|
user: { name: string; image: string | null };
|
|
} | null> {
|
|
const session = await getSession();
|
|
if (!session) return null;
|
|
return {
|
|
actorId: session.user.id,
|
|
user: { name: session.user.name, image: session.user.image ?? null },
|
|
};
|
|
}
|
|
|
|
/**
|
|
* The signed-in person if they may review credentials: staff or admin, the
|
|
* role only `pnpm run role:grant` (or the Grant role workflow) changes. Nobody
|
|
* reviews by holding an email address or by asking.
|
|
*/
|
|
export async function reviewer(): Promise<{ actorId: string } | null> {
|
|
const session = await getSession();
|
|
return session && isStaff(session.user.role) ? { actorId: session.user.id } : null;
|
|
}
|