@agledger/verify-core 2.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/LICENSE +18 -18
  2. package/README.md +797 -29
  3. package/dist/acknowledgements.d.ts +32 -0
  4. package/dist/acknowledgements.js +88 -0
  5. package/dist/anchors.d.ts +349 -0
  6. package/dist/anchors.js +654 -0
  7. package/dist/attestation.d.ts +98 -0
  8. package/dist/attestation.js +145 -0
  9. package/dist/audit-export.d.ts +343 -20
  10. package/dist/audit-export.js +400 -22
  11. package/dist/batch-head.d.ts +28 -0
  12. package/dist/batch-head.js +169 -0
  13. package/dist/batch.d.ts +69 -0
  14. package/dist/batch.js +99 -0
  15. package/dist/bulk-export.d.ts +161 -0
  16. package/dist/bulk-export.js +711 -0
  17. package/dist/chain.d.ts +135 -13
  18. package/dist/chain.js +229 -24
  19. package/dist/claim.d.ts +23 -0
  20. package/dist/claim.js +100 -0
  21. package/dist/export-anchors.d.ts +84 -0
  22. package/dist/export-anchors.js +109 -0
  23. package/dist/export-evidence.d.ts +90 -0
  24. package/dist/export-evidence.js +186 -0
  25. package/dist/export-pages.d.ts +476 -0
  26. package/dist/export-pages.js +586 -0
  27. package/dist/failures.d.ts +20 -16
  28. package/dist/failures.js +44 -16
  29. package/dist/federation-wire.d.ts +78 -11
  30. package/dist/federation-wire.js +199 -57
  31. package/dist/history-seal.d.ts +100 -0
  32. package/dist/history-seal.js +301 -0
  33. package/dist/index.d.ts +36 -8
  34. package/dist/index.js +17 -4
  35. package/dist/key-statements.d.ts +138 -5
  36. package/dist/key-statements.js +191 -20
  37. package/dist/ml-dsa-kats.d.ts +18 -0
  38. package/dist/ml-dsa-kats.js +241 -0
  39. package/dist/primitives.d.ts +255 -18
  40. package/dist/primitives.js +612 -55
  41. package/dist/read-log.d.ts +350 -0
  42. package/dist/read-log.js +816 -0
  43. package/dist/schema-chain-export.d.ts +82 -0
  44. package/dist/schema-chain-export.js +474 -0
  45. package/dist/walk-anchors.d.ts +115 -0
  46. package/dist/walk-anchors.js +133 -0
  47. package/dist/walk-checkpoints.d.ts +125 -0
  48. package/dist/walk-checkpoints.js +118 -0
  49. package/package.json +6 -5
@@ -0,0 +1,476 @@
1
+ /**
2
+ * The pages of a cross-record export walk, read and held to each other: the
3
+ * bulk export (`GET /v1/audit-vault/export`) and the schema-chain export
4
+ * (`GET /v1/audit-vault/schema-chain/export`). Both are paged, both come as a
5
+ * JSON document or as NDJSON (a `kind: 'metadata'` line, then one
6
+ * `kind: 'entry'` line per entry), and both carry the same flat entry rows
7
+ * and the same key material on every page.
8
+ *
9
+ * This module turns the input into pages, merges what every page carries
10
+ * (keys, key statements, batch heads, history seals) into one set, reporting
11
+ * bytes that differ under one id as EXPORT_PAGE_CONFLICT, and turns each
12
+ * chain's rows into the record-export document `verifyAuditExport` reads.
13
+ * The two readers (`bulk-export.ts`, `schema-chain-export.ts`) hold the walk
14
+ * to its own rules and judge the chains.
15
+ */
16
+ import type { AcknowledgedRewindInput } from './anchors.js';
17
+ import type { AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerdictCap, VerifyExportOptions, VerifyExportResult } from './audit-export.js';
18
+ import type { CheckpointEvidenceInput } from './export-evidence.js';
19
+ import type { FailureCode } from './failures.js';
20
+ import type { KeyTrustReport, PublishedKeyStatement, Verdict } from './key-statements.js';
21
+ import { type RuntimeBelowFloor, type Uncomputable } from './primitives.js';
22
+ import type { WalkAnchorsReport } from './walk-anchors.js';
23
+ import type { ChainHeldTo } from './walk-checkpoints.js';
24
+ /** One entry row of a bulk or schema-chain export page (`data[]`, or an NDJSON `kind: 'entry'` line). */
25
+ export interface ExportPageRow {
26
+ /** The vault row id (UUIDv7). The bulk export is ordered by it. */
27
+ id?: string;
28
+ /** The record whose chain the entry is on; null on a schema-chain entry. */
29
+ recordId?: string | null;
30
+ entryType?: string;
31
+ /** Unsigned display projection. */
32
+ humanReadableLabel?: string;
33
+ /** The entry's readable payload, with `on_behalf_of` and `traceparent` restored from the signed envelope. */
34
+ payload?: Record<string, unknown>;
35
+ payloadHash?: string;
36
+ previousHash?: string | null;
37
+ chainPosition?: number;
38
+ /** Base64 canonical COSE_Sign1 envelope. */
39
+ coseSign1?: string;
40
+ signingKeyId?: string | null;
41
+ actorId?: string | null;
42
+ actorRole?: string | null;
43
+ actorOwnerId?: string | null;
44
+ /** Unsigned display projection. */
45
+ actorDisplayName?: string | null;
46
+ /** Unsigned display projection. */
47
+ actorOwnerType?: string | null;
48
+ actorOidcIss?: string | null;
49
+ actorOidcSub?: string | null;
50
+ actorOidcSynthesized?: boolean | null;
51
+ /** The Server's own decode result. Never read as one. */
52
+ coseSign1Decoded?: boolean;
53
+ /** The entry's batch inclusion proof, on the batched signing cadence. */
54
+ batch?: {
55
+ batchId: string;
56
+ leafIndex: number;
57
+ treeSize: number;
58
+ auditPath: string[];
59
+ } | null;
60
+ createdAt?: string;
61
+ }
62
+ /** The `exportMetadata` of a bulk or schema-chain page (on NDJSON, the metadata line's own fields). */
63
+ export interface ExportPageMetadata {
64
+ /**
65
+ * The instant the Server read this page (RFC 3339), taken after its
66
+ * entries and their batch proofs: a batched row served on the page without
67
+ * a proof was waiting for its head at that instant. Pages from a Server
68
+ * before 4.0.0 carry none.
69
+ */
70
+ exportDate?: string;
71
+ exportFormatVersion?: string;
72
+ canonicalization?: string;
73
+ signingPublicKey?: string | null;
74
+ signingPublicKeys?: Record<string, string>;
75
+ signingKeyWindows?: Record<string, SigningKeyWindow>;
76
+ signingKeyStatements?: Record<string, PublishedKeyStatement[]>;
77
+ anchoredFrom?: string | null;
78
+ /** The batch heads this page's proofs name. */
79
+ batchHeads?: Array<{
80
+ id: string;
81
+ signingKeyId: string;
82
+ coseSign1: string;
83
+ createdAt: string;
84
+ }>;
85
+ /** On a schema-chain page: every history seal, each with this chain's proof. */
86
+ historySeals?: RecordAuditExportInput['exportMetadata']['historySeals'];
87
+ /**
88
+ * The `cursor` the request for this page sent, verbatim: null on the first
89
+ * page of a walk, and page N+1's equals page N's `nextCursor`. Unsigned.
90
+ * Pages from a Server before 4.0.0 carry none.
91
+ */
92
+ cursor?: string | null;
93
+ /**
94
+ * On a bulk page: the acknowledgements of lost history naming a chain the
95
+ * page holds an entry of, as a record export's
96
+ * `checkpointEvidence.acknowledgedRewinds` lists them. Each is verified
97
+ * from its own envelope.
98
+ */
99
+ acknowledgedRewinds?: AcknowledgedRewindInput[];
100
+ }
101
+ /** One page of `GET /v1/audit-vault/export`, as JSON. An NDJSON page is read into this shape; its metadata line carries `hasMore` on a 4.0.0 Server. */
102
+ export interface BulkExportPage {
103
+ data: ExportPageRow[];
104
+ exportMetadata: ExportPageMetadata;
105
+ /** About this page only. `hashChainValid` is the Server's own check of adjacent rows, never read as a verdict. */
106
+ chainMetadata: {
107
+ firstPosition: number | null;
108
+ lastPosition: number | null;
109
+ hashChainValid?: boolean;
110
+ };
111
+ verificationGuide?: {
112
+ unsignedFields?: string[];
113
+ };
114
+ hasMore?: boolean;
115
+ nextCursor: string | null;
116
+ /** True when entries above the Server's visibility ceiling were not yet readable. */
117
+ heldBack?: boolean;
118
+ holdbackSeconds?: number;
119
+ retryAfterSeconds?: number | null;
120
+ /**
121
+ * The read-transparency manifest the page was logged under (an org admin's
122
+ * read). `queryHash` is the sha256 of the RFC 8785 form of the query's
123
+ * filter `{ agentId, cursor, from, limit, recordId, to }`.
124
+ */
125
+ bulkExport?: {
126
+ exportBatchId?: string;
127
+ manifestId?: string;
128
+ recordCount?: number;
129
+ queryHash?: string;
130
+ };
131
+ /** The same, one per org whose records the page read, under a platform key. */
132
+ bulkExports?: Array<{
133
+ orgId?: string;
134
+ exportBatchId?: string;
135
+ manifestId?: string;
136
+ recordCount?: number;
137
+ queryHash?: string;
138
+ }>;
139
+ }
140
+ /** One page of `GET /v1/audit-vault/schema-chain/export`, as JSON. An NDJSON page is read into this shape. */
141
+ export interface SchemaChainExportPage {
142
+ data: ExportPageRow[];
143
+ exportMetadata: ExportPageMetadata;
144
+ chainMetadata: {
145
+ chain: 'schema';
146
+ /** The org whose chain this is; null for the Server-wide chain. Unsigned: held to the org id each entry signs. */
147
+ orgId: string | null;
148
+ /** The uuid the chain's checkpoints and batch leaves are filed under, derived from `orgId`. */
149
+ checkpointKey: string;
150
+ firstPosition: number | null;
151
+ lastPosition: number | null;
152
+ /** The chain's length as this page read it. */
153
+ totalEntries?: number;
154
+ /** Position of the chain's latest signed checkpoint, or null. */
155
+ expectedEntries?: number | null;
156
+ checkpointEvidence?: CheckpointEvidenceInput | null;
157
+ /** The Server's own verdict on the whole chain, on the first page; never read as one. */
158
+ chainIntegrity?: boolean | null;
159
+ chainIntegrityReason?: string | null;
160
+ brokenAtPosition?: number | null;
161
+ };
162
+ verificationGuide?: {
163
+ unsignedFields?: string[];
164
+ };
165
+ /** The chain's length when the walk began, carried page to page. */
166
+ total?: number;
167
+ hasMore?: boolean;
168
+ nextCursor: string | null;
169
+ }
170
+ /**
171
+ * A walk as a caller holds it: its pages in order, each a parsed JSON page or
172
+ * the NDJSON text of one or more pages; or one page; or the NDJSON text of a
173
+ * whole walk.
174
+ */
175
+ export type ExportWalkInput<P> = P | string | ReadonlyArray<P | string>;
176
+ /** A finding on the pages themselves rather than on one chain. `page` is 1-based; 0 when it concerns no single page. */
177
+ export interface ExportWalkFinding {
178
+ code: FailureCode;
179
+ page: number;
180
+ detail: string;
181
+ }
182
+ /**
183
+ * What the pages establish about the walk. A page from Server 4.0.0 states
184
+ * the cursor it was requested with (`exportMetadata.cursor`) and the one it
185
+ * ends at, so a page missing before or between the pages given shows as a
186
+ * break in that link. The cursors are unsigned: they catch a lost or
187
+ * misordered page, not a rewritten one. Pages that state no cursor (a Server
188
+ * before 4.0.0) show a missing page only where a chain does (a chain whose
189
+ * first entry held is above position 1 on a walk with no `from` bound). The chains a bulk walk holds are the ones these pages hold;
190
+ * `VerifyBulkExportResult.chainSet` says whether that set was held to
191
+ * anything signed.
192
+ */
193
+ export interface ExportWalkReport {
194
+ pages: number;
195
+ /** Entries the walk holds, duplicates removed. */
196
+ entries: number;
197
+ /**
198
+ * The last page carries a null nextCursor (and is not held back), and
199
+ * nothing in the pages shows they are not one walk up to it: the first
200
+ * page was requested with no cursor and each later one with the
201
+ * nextCursor of the page before it (where the pages state it), no page
202
+ * overlaps another, each page's nextCursor resumes after its own last
203
+ * entry, and no chain starts above position 1 on a walk with no `from`
204
+ * bound. A walk for which this is false reads at best `unanchored`.
205
+ */
206
+ endsAtNullCursor: boolean;
207
+ /** Each reason `endsAtNullCursor` is false. */
208
+ incomplete: string[];
209
+ /**
210
+ * For each page in walk order, its index among the pages as given (0-based,
211
+ * counting each page a string or array holds). Pages that all state their
212
+ * `cursor` are put in walk order by it: the one requested with none first,
213
+ * then each requested with the nextCursor of the one before. Otherwise they
214
+ * are put in walk order by what they hold: a bulk page by its first entry's id, a
215
+ * schema-chain page by its first entry's position; a page with no entry
216
+ * right after the page whose nextCursor it carries (a held-back page hands
217
+ * back the cursor it was sent), and one with a null nextCursor last.
218
+ */
219
+ order: number[];
220
+ /** What was not checked about the walk, and why. */
221
+ notes: string[];
222
+ /**
223
+ * Which pages state the cursor they were requested with
224
+ * (`exportMetadata.cursor`, Server 4.0.0): `all`, `some` (itself a reason
225
+ * in `incomplete`), or `none` (a Server before 4.0.0), where a page missing
226
+ * between two given pages shows only where something signed names what it
227
+ * held.
228
+ */
229
+ cursors: 'all' | 'some' | 'none';
230
+ }
231
+ /**
232
+ * Where a page's read time came from. `pages`: the page's own
233
+ * `exportMetadata.exportDate`. `option`: the caller's `exportDate`, for a page
234
+ * that states none. `checkpoint_evidence`: on a schema-chain page that states
235
+ * neither, the latest `chainMetadata.checkpointEvidence.evidenceReadAt` the
236
+ * pages state.
237
+ */
238
+ export type ReadTimeSource = 'pages' | 'option' | 'checkpoint_evidence';
239
+ /**
240
+ * How batched entries with no inclusion proof were dated. Each row is judged
241
+ * against the read time of the page it was served on: the page's own
242
+ * `exportMetadata.exportDate`; for a page that states none (a Server before
243
+ * 4.0.0), the caller's `exportDate`; on a schema-chain page that states
244
+ * neither, the latest `evidenceReadAt` the pages state.
245
+ */
246
+ export interface ExportReadTime {
247
+ /** The latest read time of any page, which anchors are judged through; null when no page was dated. */
248
+ exportDate: string | null;
249
+ /** Where the pages' read times came from: one source, `mixed` when pages were dated from different ones, null when none was. */
250
+ source: ReadTimeSource | 'mixed' | null;
251
+ /** The same, for each chain, over the pages its rows were served on. */
252
+ chains: Array<{
253
+ chainKey: string;
254
+ exportDate: string | null;
255
+ source: ReadTimeSource | 'mixed' | null;
256
+ }>;
257
+ /** Batched entries with no proof that failed BATCH_UNATTESTED because nothing dated the page they were on. */
258
+ undated: Array<{
259
+ chainKey: string;
260
+ position: number;
261
+ }>;
262
+ /** What resolves `undated`, when it is not empty. */
263
+ detail: string | null;
264
+ }
265
+ /** One page's read time and where it came from; both null when nothing dates the page. */
266
+ export interface PageReadTime {
267
+ exportDate: string | null;
268
+ source: ReadTimeSource | null;
269
+ }
270
+ /**
271
+ * Each page's read time: its own `exportMetadata.exportDate`, else
272
+ * `option`, else `fallback` (with `fallbackSource`). A page whose
273
+ * `exportDate` is present and not an RFC 3339 instant states none, and
274
+ * `notes` says so.
275
+ */
276
+ export declare function pageReadTimes(pages: ReadonlyArray<{
277
+ exportMetadata: ExportPageMetadata;
278
+ }>, option: string | undefined, notes: string[], fallback?: {
279
+ exportDate: string;
280
+ source: ReadTimeSource;
281
+ } | null): PageReadTime[];
282
+ /** The latest of some page read times, and where the read times came from. */
283
+ export declare function latestReadTime(times: ReadonlyArray<PageReadTime>): {
284
+ exportDate: string | null;
285
+ source: ReadTimeSource | 'mixed' | null;
286
+ latestSource: ReadTimeSource | null;
287
+ };
288
+ /** One chain the walk holds, and its verdict. */
289
+ export interface ExportChainResult {
290
+ /** The record id the chain is filed under (bulk), or the schema chain's checkpoint key. */
291
+ chainKey: string;
292
+ chain: 'record' | 'platform-ops' | 'schema';
293
+ /** Lowest and highest chain position the walk holds for it. */
294
+ firstPosition: number;
295
+ lastPosition: number;
296
+ /** `whole`: from position 1, in a walk read to its end. `slice`: a run of positions inside a chain whose start or tip the walk does not establish. */
297
+ extent: 'whole' | 'slice';
298
+ /** Why the chain is read as a slice. */
299
+ sliceReason?: string;
300
+ /**
301
+ * The last position the walk holds of the chain, and what holds it there:
302
+ * the page content, or a listed signed checkpoint (`checkpoints`) of that
303
+ * position. A chain the walk holds from position 1 to a position such a
304
+ * checkpoint signs is `whole` through that position.
305
+ */
306
+ heldTo: ChainHeldTo;
307
+ /**
308
+ * The verification, as `verifyAuditExport` reads a record export of these
309
+ * entries. On a slice, a verdict that would read `trusted` reads
310
+ * `unanchored`: the run is not held to the chain's first entry or its tip.
311
+ */
312
+ result: VerifyExportResult;
313
+ }
314
+ /** What `verifyBulkExport` and `verifySchemaChainExport` share. */
315
+ export interface ExportWalkResultBase {
316
+ /**
317
+ * The worst chain verdict (`failed`, then `unverifiable`, then
318
+ * `unanchored`, then `trusted`), or `failed` on a finding on the pages.
319
+ * Null when the walk holds no entry: nothing was verified.
320
+ */
321
+ verdict: Verdict | null;
322
+ /** The walk holds no entry. */
323
+ empty: boolean;
324
+ /** Every chain valid and no finding on the pages. False on an empty walk. */
325
+ valid: boolean;
326
+ totalEntries: number;
327
+ verifiedEntries: number;
328
+ walk: ExportWalkReport;
329
+ chains: ExportChainResult[];
330
+ /** Findings on the pages themselves (EXPORT_PAGE_CONFLICT and the like). */
331
+ findings: ExportWalkFinding[];
332
+ /** The first failure: a finding on the pages, else the first failed chain's `brokenAt`. */
333
+ brokenAt?: {
334
+ chainKey: string | null;
335
+ position: number;
336
+ code: FailureCode;
337
+ detail?: string;
338
+ };
339
+ /**
340
+ * The key-anchoring report of the chain that set the verdict (of a chain
341
+ * whose signatures the walk anchored, when that chain verified none of its
342
+ * own), or null on an empty walk.
343
+ */
344
+ keyTrust: KeyTrustReport | null;
345
+ /** The checks that could not be computed, over the whole walk. */
346
+ uncomputable: Uncomputable;
347
+ readTime: ExportReadTime;
348
+ /** The anchor documents given (`anchorDocuments`) against the walk's chains. */
349
+ anchors: WalkAnchorsReport;
350
+ /**
351
+ * Fields of the rows that nothing signs: the per-entry display projections
352
+ * the pages list (`verificationGuide.unsignedFields`), and on a
353
+ * schema-chain walk the payload keys of the rows the signed statement does
354
+ * not carry (as `payload.<key>`).
355
+ */
356
+ unsignedProjectionFields: string[];
357
+ /**
358
+ * Each reason the walk reads at best `unanchored` although nothing failed
359
+ * (`VerdictCapReason`), the walk's own and those of its chains, each once.
360
+ */
361
+ capped: VerdictCap[];
362
+ /** Present only when the running Node.js is older than `NODE_FLOOR`; see `VerifyExportResult.runtime`. */
363
+ runtime?: RuntimeBelowFloor;
364
+ }
365
+ /** One page as read, with where it came from. */
366
+ export interface ReadPage<P> {
367
+ page: P;
368
+ format: 'json' | 'ndjson';
369
+ /** Its index among the pages as given. */
370
+ given: number;
371
+ }
372
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
373
+ /**
374
+ * The input as pages, each checked to be a page of `kind`. Throws
375
+ * `TypeError` on anything that is not one: a malformed NDJSON line, a page
376
+ * without `data`, `exportMetadata` or `chainMetadata`, or a page of the
377
+ * other export.
378
+ */
379
+ export declare function readPages<P>(input: unknown, kind: 'bulk' | 'schema-chain', fn: string): Array<ReadPage<P>>;
380
+ /**
381
+ * The walk order of some pages, as indexes into them: by first entry (the
382
+ * bulk export serves rows in ascending entry id, the schema-chain export in
383
+ * ascending position), a page with no entry right after the page whose
384
+ * nextCursor it carries, and a page with no entry and a null nextCursor
385
+ * last. Ties keep the order given. The cursor is compared as a whole string,
386
+ * never decoded.
387
+ */
388
+ export declare function walkOrder(pages: ReadonlyArray<Record<string, unknown>>, kind: 'bulk' | 'schema-chain'): number[];
389
+ /** The cursor a page states it was requested with: a string, null, or undefined when it states none. */
390
+ export declare function requestCursor(page: Record<string, unknown>): string | null | undefined;
391
+ /**
392
+ * Each reason the pages, in walk order, do not link by their cursors: the
393
+ * first page requested with a cursor (a page before it is missing), or a page
394
+ * requested with a cursor other than the nextCursor of the page before it.
395
+ * Empty when they link, and when no page states its cursor (one note says so);
396
+ * a walk where only some pages state it gets a reason for each that does not.
397
+ */
398
+ export declare function cursorLinkReasons(pages: ReadonlyArray<Record<string, unknown>>, notes: string[]): string[];
399
+ /** Which of the pages state the cursor they were requested with. */
400
+ export declare function cursorsStated(pages: ReadonlyArray<Record<string, unknown>>): 'all' | 'some' | 'none';
401
+ /** Throw `TypeError` on an `exportDate` that is not a strict RFC 3339 instant. */
402
+ export declare function assertExportDate(fn: string, value: unknown): void;
403
+ /** The key material every page carries, merged across the walk, and what disagreed. */
404
+ export interface MergedMetadata {
405
+ meta: Omit<RecordAuditExportInput['exportMetadata'], 'recordId'>;
406
+ findings: ExportWalkFinding[];
407
+ unsignedFields: string[];
408
+ }
409
+ /**
410
+ * Merge the key material of every page. A key, a key statement, a batch head
411
+ * or a history seal that two pages carry under one id with different bytes is
412
+ * EXPORT_PAGE_CONFLICT, and the first page's stands. A key's window may close
413
+ * during a walk (a retirement, or a distrust instant added), so a later page's
414
+ * window wins where it only adds those; any other difference is a conflict.
415
+ * New keys and statements on later pages are added. `anchoredFrom` is the last
416
+ * page's: the Server's own key, which can change during a walk.
417
+ */
418
+ export declare function mergePageMetadata(pages: ReadonlyArray<{
419
+ exportMetadata: ExportPageMetadata;
420
+ verificationGuide?: {
421
+ unsignedFields?: string[];
422
+ };
423
+ }>): MergedMetadata;
424
+ /** A page row as the record export's entry shape `verifyAuditExport` reads. */
425
+ export declare function entryOfRow(row: ExportPageRow): AuditExportEntryInput;
426
+ /** The lowest and highest safe-integer position among `rows`, or null when none carries one. */
427
+ export declare function positionRange(rows: ReadonlyArray<ExportPageRow>): {
428
+ first: number;
429
+ last: number;
430
+ } | null;
431
+ /** The base64url JSON object an opaque cursor decodes to, or null. */
432
+ export declare function decodeCursor(cursor: unknown): Record<string, unknown> | null;
433
+ /** The worse of two verdicts. */
434
+ export declare function worseVerdict(a: Verdict, b: Verdict): Verdict;
435
+ /**
436
+ * Put the walk's result together from its chains and the findings on its
437
+ * pages. The verdict is the worst chain's, `failed` on any page finding, and
438
+ * null on a walk that holds no entry.
439
+ */
440
+ export declare function walkResult(input: {
441
+ chains: ExportChainResult[];
442
+ findings: ExportWalkFinding[];
443
+ walk: ExportWalkReport;
444
+ readTime: Omit<ExportReadTime, 'undated' | 'detail'>;
445
+ anchors: WalkAnchorsReport;
446
+ unsignedFields: string[];
447
+ /** The walk's own caps (`walk_not_read_to_end`, `chain_set_undecided`). */
448
+ capped?: VerdictCap[];
449
+ }): ExportWalkResultBase;
450
+ /** Cap a slice's verdict: a run not held to its chain's start or tip is never `trusted`. */
451
+ export declare function capSlice(result: VerifyExportResult): VerifyExportResult;
452
+ /** The options `verifyAuditExport` reads, without the walk's own (the anchor documents go to each chain by its key). */
453
+ export declare function chainOptions<O extends VerifyExportOptions & {
454
+ exportDate?: string;
455
+ checkpoints?: unknown;
456
+ }>(options: O): VerifyExportOptions;
457
+ /**
458
+ * Hold each page's own read time (`exportMetadata.exportDate`) to the signed
459
+ * iat of the entries served on it: a page read before one of its entries was
460
+ * signed states a time that was moved earlier, EXPORT_READ_TIME_INVALID.
461
+ */
462
+ export declare function pageReadTimeFindings(pages: ReadonlyArray<{
463
+ data: ExportPageRow[];
464
+ exportMetadata: ExportPageMetadata;
465
+ }>): ExportWalkFinding[];
466
+ /** The signed iat of a row's envelope, or null. */
467
+ export declare function rowIat(row: ExportPageRow): number | null;
468
+ /**
469
+ * Throw `TypeError` when the caller's `exportDate` is earlier than the signed
470
+ * iat of an entry the pages hold: the walk was read after that entry.
471
+ */
472
+ export declare function assertWalkReadAfterSigned(fn: string, exportDate: string | undefined, pages: ReadonlyArray<{
473
+ data: ExportPageRow[];
474
+ }>): void;
475
+ /** How far a chain is held when no listed checkpoint was given for it. */
476
+ export declare function heldByPages(lastPosition: number): ChainHeldTo;