lib/crypto.ts¶
Purpose¶
AES‑256‑GCM encrypt/decrypt helpers for BYOK secrets.
Public Surface¶
encryptAesGcm(plaintext: Buffer|string, aad?: Buffer): BufferdecryptAesGcm(blob: Buffer, aad?: Buffer): Buffer
Behavior & Invariants¶
RUNFORGE_MASTER_KEYmust be 32 bytes (base64 or 64‑hex). Throws otherwise.- Output format:
[12B IV][16B TAG][CIPHERTEXT...].
Security & Privacy¶
- Use distinct AAD per record when possible (e.g., orgId).
- Store only ciphertext in Postgres.