(runs: MaintainRun[], audit: HistoryAudit | undefined, key?: string)
| 69 | |
| 70 | /** Verify a snapshot's audit block against its own runs. PURE. */ |
| 71 | export function verifyHistoryAudit(runs: MaintainRun[], audit: HistoryAudit | undefined, key?: string): HistoryAuditVerdict { |
| 72 | if (!audit) return { present: false, ok: true }; // legacy snapshot — nothing to check |
| 73 | const headMatches = historyHead(runs.map(normalizeRun)) === audit.head; |
| 74 | const signaturePresent = !!audit.signature; |
| 75 | let signatureValid: boolean | undefined; |
| 76 | if (signaturePresent && key) signatureValid = verifyChainSignature(audit.head, audit.signature!, key); |
| 77 | return { present: true, headMatches, signaturePresent, signatureValid, ok: headMatches && (!signaturePresent || signatureValid !== false) }; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Parse a history snapshot back into runs. Tolerant of extra fields and either the wrapped file |
no test coverage detected