MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / readReported

Function readReported

apps/desktop/src/main/reported-fingerprints.ts:41–66  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

39}
40
41export function readReported(filePath: string): ReportedFingerprintsFile {
42 if (!existsSync(filePath)) return emptyFile();
43 try {
44 const raw = readFileSync(filePath, 'utf8');
45 const parsed = JSON.parse(raw) as unknown;
46 if (
47 typeof parsed !== 'object' ||
48 parsed === null ||
49 (parsed as { schemaVersion?: unknown }).schemaVersion !== 1 ||
50 !Array.isArray((parsed as { entries?: unknown }).entries)
51 ) {
52 return emptyFile();
53 }
54 const entries = ((parsed as ReportedFingerprintsFile).entries ?? []).filter(
55 (e): e is ReportedFingerprint =>
56 typeof e === 'object' &&
57 e !== null &&
58 typeof e.fingerprint === 'string' &&
59 typeof e.ts === 'number' &&
60 typeof e.issueUrl === 'string',
61 );
62 return { schemaVersion: 1, entries };
63 } catch {
64 return emptyFile();
65 }
66}
67
68/**
69 * Write `content` to `path` atomically via a temp file + rename. `renameSync`

Callers 4

recordReportedFunction · 0.85
findRecentFunction · 0.85

Calls 1

emptyFileFunction · 0.85

Tested by

no test coverage detected