返回 CodeWhale
keys.ts
根目录 / web / lib / cloud-facts / keys.ts
1 /**
2 * Ed25519 verifying keys for the CodeWhale cloud facts channel (facts/v1).
3 *
4 * Mirror of `crates/config/src/cloud_facts/keys.rs` — `check:facts` fails if
5 * the two diverge. Keys are pinned here (and in the binary); the Supabase
6 * `facts_key` table is informational and never a trust root.
7 *
8 * The pinned anchor below is the trust root for delivery. Tests supply their
9 * own public fixture keys; those keys never belong in this table.
10 */
11 export type KeyStatus = "active" | "retired";
12 export type KeyRole = "founder" | "automation";
13
14 export interface TrustedKey {
15 keyId: string;
16 /** Standard base64 of the raw 32-byte Ed25519 public key. */
17 publicKey: string;
18 status: KeyStatus;
19 role: KeyRole;
20 }
21
22 export const AUTOMATION_CHANNEL_SUFFIX = "-models";
23 export const AUTOMATION_MAX_VALIDITY_MS = 7 * 24 * 60 * 60 * 1000;
24 export const AUTOMATION_MAX_MODELS = 256;
25
26 export const DOMAIN = "codewhale-facts/v1\0";
27 export const ENVELOPE_VERSION = 1;
28 export const SUPPORTED_SCHEMA_VERSION = 1;
29 export const MAX_PAYLOAD_BYTES = 512 * 1024;
30 export const REGISTRY_CHANNEL = "registry";
31 export const REGISTRY_SCHEMA = "codewhale.registry.v1";
32 export const MAX_REGISTRY_PAYLOAD_BYTES = 8 * 1024 * 1024;
33 export const MAX_REGISTRY_ENVELOPE_BYTES = Math.floor(MAX_REGISTRY_PAYLOAD_BYTES / 3) * 4 + 64 * 1024;
34
35 export const TRUSTED_KEYS: readonly TrustedKey[] = [
36 {
37 // Approved 2026-09-10. Mirrors crates/config/src/cloud_facts/keys.rs.
38 // Private half held by the founder outside any repository.
39 keyId: "cwf-2026-09",
40 publicKey: "5d1syIWzufnSTlVrfFVb7CePHL6B3Ol92IhS15QaBoU=",
41 status: "active",
42 role: "founder",
43 },
44 ];
45
46 export function trustedKey(keyId: string): TrustedKey | undefined {
47 return TRUSTED_KEYS.find((key) => key.keyId === keyId);
48 }
49
49 lines TYPESCRIPT