mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-06 04:39:07 +01:00
The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
/**
|
|
* Prints `name=value` for the private-zone unlock cookie, for automation.
|
|
*
|
|
* The prod smoke and the UI dogfood need /people, /habits, /money and /events.
|
|
* Those sit behind the PIN gate, and a PIN is by design something only a human
|
|
* holds — so the suite skipped them on every run and reported the skips as
|
|
* failures, which looks like coverage and is not.
|
|
*
|
|
* The gate's real currency is an HMAC under AUTH_SECRET, not the PIN. Anything
|
|
* holding AUTH_SECRET can already mint a session as any user (that is exactly
|
|
* what print-session-token.ts does), so minting the unlock too grants no new
|
|
* access — it only lets the tests see the half of the product they were blind
|
|
* to. The PIN keeps guarding what it was built to guard: a person at a keyboard.
|
|
*
|
|
* Needs a session token and AUTH_SECRET; the user id comes from /api/me, so no
|
|
* database and no SSH tunnel are required.
|
|
*
|
|
* LOKI_SESSION_TOKEN=… npx tsx scripts/test/print-private-zone-cookie.ts
|
|
*/
|
|
import { config } from "dotenv";
|
|
|
|
import { smokeSessionToken } from "@/lib/brand-env";
|
|
import { privateZoneCookiePair } from "@/lib/private-zone-token";
|
|
|
|
config({ path: ".env.local", quiet: true });
|
|
config({ path: ".env.hetzner.local", quiet: true });
|
|
|
|
const BASE = (process.env.BASE ?? "https://loki.orangecat.ch").replace(/\/$/, "");
|
|
|
|
function sessionCookieName(): string {
|
|
return BASE.startsWith("https://") ? "__Secure-authjs.session-token" : "authjs.session-token";
|
|
}
|
|
|
|
async function main() {
|
|
const token = smokeSessionToken().trim();
|
|
if (!token) throw new Error("No session — set LOKI_SESSION_TOKEN");
|
|
if (!process.env.AUTH_SECRET?.trim())
|
|
throw new Error("AUTH_SECRET is required to mint the unlock");
|
|
|
|
const res = await fetch(`${BASE}/api/me`, {
|
|
headers: { Cookie: `${sessionCookieName()}=${token}` },
|
|
signal: AbortSignal.timeout(20_000),
|
|
});
|
|
if (!res.ok) throw new Error(`/api/me returned ${res.status} — session is not valid for ${BASE}`);
|
|
const me = (await res.json()) as { id?: string };
|
|
if (!me.id) throw new Error("/api/me returned no user id");
|
|
|
|
process.stdout.write(privateZoneCookiePair(me.id));
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e instanceof Error ? e.message : e);
|
|
process.exit(1);
|
|
});
|