MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / verifyAuditLog

Function verifyAuditLog

src/cli/maintain-audit.ts:195–214  ·  view source on GitHub ↗
(log: SignedAuditLog, key?: string)

Source from the content-addressed store, hash-verified

193 * and (when a key is available) the HMAC signature. PURE. `ok` = everything checkable passed.
194 */
195export function verifyAuditLog(log: SignedAuditLog, key?: string): AuditVerifyResult {
196 const entries = Array.isArray(log?.entries) ? log.entries : [];
197 const chain = verifyAuditChain(entries);
198 const recomputedHead = chainHead(entries);
199 const headMatches = recomputedHead === log?.head;
200 const signaturePresent = !!log?.signature;
201 let signatureValid: boolean | undefined;
202 if (signaturePresent && key) signatureValid = verifyChainSignature(log.head, log.signature!, key);
203 const ok = chain.valid && headMatches && (!signaturePresent || signatureValid === true);
204 return {
205 ok,
206 chainValid: chain.valid,
207 brokenAt: chain.brokenAt,
208 reason: chain.reason,
209 signaturePresent,
210 signatureValid,
211 headMatches,
212 count: entries.length,
213 };
214}

Callers 2

index.tsFile · 0.85

Calls 3

verifyAuditChainFunction · 0.85
chainHeadFunction · 0.85
verifyChainSignatureFunction · 0.85

Tested by

no test coverage detected