mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 06:17:23 +01:00
scripts/site-template is now bitbaum/fleet templates/app — Next.js 16, better-auth accounts (password, link, passkey, 2FA, OrangeCat/bitbaum sign-in as env-gated OIDC), en/de/fr, nonce CSP, ai-kit/mail-kit/limitkit/bip-kit, tests and CI — copied at a pinned fleet commit by scripts/templates/sync-starter.sh. CI proves the copy is exact (sync-starter.sh --check), and starter-sync.yml opens the PR when fleet's starter moves. Never edited here. The kickoff's "nextjs-tailwind" starter seeds the same app from src/lib/starter-app.generated.ts (generated from the directory, pinned by scripts/test/starter-app.ts), minus the workflows register-site.sh adds with the site's CD. The repo is seeded in one Trees API call with inline contents instead of a blob POST per file (~85 for this starter). The widget token rides in .env.production; the starter's .gitleaks.toml allows NEXT_PUBLIC_* values. The new-from-scratch picker reads the light template list, so the starter's file bodies never reach a client bundle. Both paths give the site its database and auth/seal secrets ON THE BOX (scripts/hetzner/provision-db-on-box.sh: role + database, ~/.db-credentials, /opt/<slug>/shared/.env; existing secrets never replaced; nothing printed), and record the db in the register row so every deploy applies drizzle/. register-site.sh seeds the starter's full workflow set to starter repos and the golden CI floor to anything else, never overwriting another repo's ci.yml. test-site-template.sh follows the starter (verify SSOT, design tokens instead of a local palette) and its comment stripper is fixed: the sed range deleted the page from the doc comment to EOF, so every day-zero check had been passing against an empty string. check-template-contrast.mjs and the starter-lock generator are retired with the files they checked. Claude-Session: https://claude.ai/code/session_01W7K2Gm5wcbfCi7THtmV1Hy Co-authored-by: Claude <noreply@anthropic.com>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { canSeal, hintOf, open, seal, sealKey } from "./secrets";
|
|
|
|
const KEY = "k".repeat(48);
|
|
|
|
describe("seal / open", () => {
|
|
const before = process.env.SECRET_SEAL_KEY;
|
|
beforeEach(() => {
|
|
process.env.SECRET_SEAL_KEY = KEY;
|
|
});
|
|
afterEach(() => {
|
|
process.env.SECRET_SEAL_KEY = before;
|
|
});
|
|
|
|
it("round-trips, and the sealed form does not contain the secret", () => {
|
|
const sealed = seal("sk-live-abcdef123456", "model-key:user-1");
|
|
expect(sealed).not.toContain("abcdef");
|
|
expect(open(sealed, "model-key:user-1")).toBe("sk-live-abcdef123456");
|
|
});
|
|
|
|
it("will not open under another context — a value copied to another row is useless", () => {
|
|
const sealed = seal("secret", "model-key:user-1");
|
|
expect(() => open(sealed, "model-key:user-2")).toThrow();
|
|
});
|
|
|
|
it("will not open a tampered value", () => {
|
|
const sealed = seal("secret", "c");
|
|
const tampered = sealed.slice(0, -2) + (sealed.endsWith("00") ? "11" : "00");
|
|
expect(() => open(tampered, "c")).toThrow();
|
|
});
|
|
|
|
it("refuses to seal without a long enough key", () => {
|
|
process.env.SECRET_SEAL_KEY = "short";
|
|
expect(canSeal()).toBe(false);
|
|
expect(() => seal("x", "c")).toThrow();
|
|
});
|
|
});
|
|
|
|
describe("sealKey", () => {
|
|
it("needs 32 characters", () => {
|
|
expect(sealKey({ SECRET_SEAL_KEY: "x".repeat(31) })).toBeNull();
|
|
expect(sealKey({ SECRET_SEAL_KEY: "x".repeat(32) })).toBe("x".repeat(32));
|
|
expect(sealKey({})).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("hintOf", () => {
|
|
it("shows the last four characters only", () => {
|
|
expect(hintOf("sk-or-v1-1234567890abcd")).toBe("…abcd");
|
|
expect(hintOf("")).toBe("");
|
|
});
|
|
});
|