1/** 2 * apps/worker — symmetric encryption for secrets at rest (webhook signing 3 * secrets). 4 * 5 * TASK-0130: this now DELEGATES to the single canonical implementation in 6 * `@factory/shared` (`packages/shared/src/crypto.ts`). The API WRITES 7 * `webhooks.secretEncrypted` with the shared `aes256gcmEncrypt` 8 * (base64(iv || tag || ciphertext), 64-hex master keys used raw) and the 9 * worker READS it here for delivery signing — one format, one key 10 * derivation (C-13.8a). `MASTER_KEY_MISSING` is re-exported so the 11 * dispatcher can surface a clean error when MASTER_ENCRYPTION_KEY is 12 * unset (it refuses to sign without a master key). 13 */ 14export { 15 aes256gcmDecrypt, 16 aes256gcmEncrypt, 17 hmacSha256hex, 18 keyFromSecret, 19 safeEqual, 20 sha256hex 21} from "@factory/shared"; 22 23export class MasterKeyMissingError extends Error { 24 constructor() { 25 super("MASTER_ENCRYPTION_KEY is not configured — refusing to sign deliveries"); 26 this.name = "MasterKeyMissingError"; 27 } 28} 29 30/** Throw {@link MasterKeyMissingError} when the master key is blank. */ 31export function requireMasterKey(master: string): string { 32 if (!master) throw new MasterKeyMissingError(); 33 return master; 34} 35