mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 05:37:19 +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>
74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { createHmac, randomUUID } from "node:crypto";
|
|
import { verifyOrangeCatBuildIntent } from "../../src/lib/integrations/orangecat-build-intent";
|
|
|
|
const secret = "test-secret-that-is-at-least-thirty-two-characters";
|
|
process.env.LOKI_BUILD_INTENT_SECRET = secret;
|
|
|
|
function sign(overrides: Record<string, unknown> = {}): string {
|
|
const now = Math.floor(Date.now() / 1000);
|
|
const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT" })).toString("base64url");
|
|
const payload = Buffer.from(
|
|
JSON.stringify({
|
|
iss: "orangecat",
|
|
aud: "loki",
|
|
sub: randomUUID(),
|
|
jti: randomUUID(),
|
|
iat: now,
|
|
exp: now + 600,
|
|
entity: {
|
|
type: "group",
|
|
id: randomUUID(),
|
|
title: "Neighbourhood club",
|
|
description: "A real place people want to open.",
|
|
publicUrl: "https://www.orangecat.ch/groups/neighbourhood-club",
|
|
},
|
|
suggestedHandoff: ["Draft the owner-approved plan."],
|
|
...overrides,
|
|
}),
|
|
).toString("base64url");
|
|
const signature = createHmac("sha256", secret).update(`${header}.${payload}`).digest("base64url");
|
|
return `${header}.${payload}.${signature}`;
|
|
}
|
|
|
|
const valid = verifyOrangeCatBuildIntent(sign());
|
|
assert.equal(valid.iss, "orangecat");
|
|
assert.equal(valid.aud, "loki");
|
|
assert.equal(valid.exp - valid.iat, 600);
|
|
|
|
const signed = sign();
|
|
const [signedHeader, signedPayload, signedSignature] = signed.split(".");
|
|
const tamperedSignature = `${signedSignature[0] === "A" ? "B" : "A"}${signedSignature.slice(1)}`;
|
|
assert.throws(() =>
|
|
verifyOrangeCatBuildIntent(`${signedHeader}.${signedPayload}.${tamperedSignature}`),
|
|
);
|
|
assert.throws(() => verifyOrangeCatBuildIntent(sign({ exp: 1 })));
|
|
assert.throws(() =>
|
|
verifyOrangeCatBuildIntent(
|
|
sign({
|
|
entity: {
|
|
type: "project",
|
|
id: randomUUID(),
|
|
title: "Wrong host",
|
|
description: null,
|
|
publicUrl: "https://example.com/projects/no",
|
|
},
|
|
}),
|
|
),
|
|
);
|
|
assert.throws(() =>
|
|
verifyOrangeCatBuildIntent(
|
|
sign({
|
|
entity: {
|
|
type: "project",
|
|
id: randomUUID(),
|
|
title: "Lookalike host",
|
|
description: null,
|
|
publicUrl: "https://evilorangecat.ch/projects/no",
|
|
},
|
|
}),
|
|
),
|
|
);
|
|
|
|
console.log("OrangeCat integration intent checks passed.");
|