@agledger/verify-core 2.1.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 (54) hide show
  1. package/LICENSE +18 -18
  2. package/README.md +869 -53
  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 +404 -29
  10. package/dist/audit-export.js +547 -28
  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/cbor-strict.d.ts +9 -0
  18. package/dist/cbor-strict.js +14 -0
  19. package/dist/chain.d.ts +221 -31
  20. package/dist/chain.js +339 -65
  21. package/dist/claim.d.ts +23 -0
  22. package/dist/claim.js +100 -0
  23. package/dist/export-anchors.d.ts +84 -0
  24. package/dist/export-anchors.js +109 -0
  25. package/dist/export-evidence.d.ts +90 -0
  26. package/dist/export-evidence.js +186 -0
  27. package/dist/export-pages.d.ts +476 -0
  28. package/dist/export-pages.js +586 -0
  29. package/dist/failures.d.ts +44 -26
  30. package/dist/failures.js +81 -31
  31. package/dist/federation-wire.d.ts +106 -20
  32. package/dist/federation-wire.js +286 -76
  33. package/dist/history-seal.d.ts +100 -0
  34. package/dist/history-seal.js +301 -0
  35. package/dist/index.d.ts +37 -9
  36. package/dist/index.js +18 -5
  37. package/dist/instant.d.ts +1 -1
  38. package/dist/instant.js +1 -1
  39. package/dist/key-statements.d.ts +160 -11
  40. package/dist/key-statements.js +261 -60
  41. package/dist/ml-dsa-kats.d.ts +18 -0
  42. package/dist/ml-dsa-kats.js +241 -0
  43. package/dist/options.js +4 -4
  44. package/dist/primitives.d.ts +287 -47
  45. package/dist/primitives.js +673 -101
  46. package/dist/read-log.d.ts +350 -0
  47. package/dist/read-log.js +816 -0
  48. package/dist/schema-chain-export.d.ts +82 -0
  49. package/dist/schema-chain-export.js +474 -0
  50. package/dist/walk-anchors.d.ts +115 -0
  51. package/dist/walk-anchors.js +133 -0
  52. package/dist/walk-checkpoints.d.ts +125 -0
  53. package/dist/walk-checkpoints.js +118 -0
  54. package/package.json +9 -5
@@ -6,7 +6,7 @@
6
6
  * normalized entry and runs `verifyChain`.
7
7
  *
8
8
  * The three row-level input-gated checks run on the export path when the wire
9
- * carries their inputs (engine ≥ v0.26.x): the `actorOidcSynthesized` flag +
9
+ * carries their inputs (Server 0.26 and later): the `actorOidcSynthesized` flag +
10
10
  * `actorOidcIss/Sub` enable the OIDC-actor cross-check; `signingKeyWindows` +
11
11
  * per-entry `createdAt` enable temporal key-validity; and the per-entry
12
12
  * denormalized `payload` + `entryType` enable binding-integrity, the export's
@@ -14,17 +14,22 @@
14
14
  * tampering of the human-readable `payload`/`criteria` view: the verifier
15
15
  * re-decodes the signed predicate from `coseSign1` and deep-equals it against
16
16
  * the row `payload`, so a rewritten `payload` with an intact envelope fails
17
- * CHAIN_PAYLOAD_BINDING_MISMATCH (validated against a real engine v0.26.4
17
+ * CHAIN_PAYLOAD_BINDING_MISMATCH (validated against a real Server v0.26.4
18
18
  * export; `buildPredicateForRow` reconstructs the signed predicate exactly).
19
19
  * Older exports without these fields stay `skipped_no_input`, surfaced in the
20
20
  * result so a caller never mistakes "not checked here" for "checked and passed".
21
21
  */
22
- import { type CheckApplicability, type EvidenceBindingCounts, type OptionalCheck, type SignatureOutcome } from './chain.js';
22
+ import { type AgentKeyEntry, type CheckApplicability, type EvidenceBindingCounts, type HistorySealCounts, type KeyRegistry, type OptionalCheck, type SignatureCoverage, type SignatureOutcome } from './chain.js';
23
23
  import type { FailureCode } from './failures.js';
24
- import type { AgentPublicKeyJwk } from './primitives.js';
24
+ import { type AcknowledgementReport, type AnchorDocumentInput } from './anchors.js';
25
+ import { type AcknowledgementSource } from './acknowledgements.js';
26
+ import { type AttestationReport, type ComplianceRecordInput } from './attestation.js';
27
+ import { type CheckpointCoverageReport, type ExportAnchorsReport, type ExportAnchorsWalkView } from './export-anchors.js';
28
+ import { type ChainHeldTo, type ListedCheckpointView, type VaultCheckpointRow } from './walk-checkpoints.js';
29
+ import { type AgentPublicKeyJwk, type RuntimeBelowFloor, type Uncomputable } from './primitives.js';
25
30
  import { type FederationKeyEntry } from './federation-wire.js';
26
- import { type DistrustedKey, type KeyTrustReport, type PublishedKeyStatement, type Verdict } from './key-statements.js';
27
- /** One entry of a `/audit-export` document. */
31
+ import { type CheckpointEvidenceInput, type CheckpointEvidenceReport, type ReceiptCounts } from './export-evidence.js';
32
+ import { type DistrustedKey, type KeyTrust, type KeyTrustReport, type PublishedKeyStatement, type Verdict } from './key-statements.js';
28
33
  export interface AuditExportEntryInput {
29
34
  /** 1-based chain position. Current exports emit `chainPosition`; pre-v0.25 used `position`. */
30
35
  chainPosition?: number;
@@ -36,11 +41,11 @@ export interface AuditExportEntryInput {
36
41
  * CHAIN_MALFORMED_ENTRY.
37
42
  */
38
43
  createdAt?: string | null;
39
- /** OIDC issuer the actor was synthesized from (engine ≥ v0.26.x). */
44
+ /** OIDC issuer the actor was synthesized from (Server 0.26 and later). */
40
45
  actorOidcIss?: string | null;
41
- /** OIDC subject the actor was synthesized from (engine ≥ v0.26.x). */
46
+ /** OIDC subject the actor was synthesized from (Server 0.26 and later). */
42
47
  actorOidcSub?: string | null;
43
- /** Tri-state from `audit_vault.actor_oidc_synthesized` (engine ≥ v0.26.x). Marker for the OIDC-actor check. */
48
+ /** Tri-state `actor_oidc_synthesized` marker (Server 0.26 and later). Marker for the OIDC-actor check. */
44
49
  actorOidcSynthesized?: boolean | null;
45
50
  /**
46
51
  * API-key id of the credential that performed this state-change, mirroring
@@ -56,7 +61,7 @@ export interface AuditExportEntryInput {
56
61
  recordId?: string | null;
57
62
  /** The audit-vault entry type (e.g. `RECORD_CREATED`); drives the binding check's predicate reconstruction. */
58
63
  entryType?: string;
59
- /** Denormalized row `payload` jsonb. Present → the binding-integrity check runs (verificationGuide step 4). */
64
+ /** The entry's readable `payload`, a projection of the signed predicate. Present → the binding-integrity check runs (verificationGuide step 4). */
60
65
  payload?: Record<string, unknown>;
61
66
  /**
62
67
  * The evidence body `?evidence=true` inlines: the completion evidence on a
@@ -71,9 +76,38 @@ export interface AuditExportEntryInput {
71
76
  /** Base64-encoded canonical COSE_Sign1 envelope (RFC 9052). */
72
77
  coseSign1: string;
73
78
  signingKeyId: string | null;
79
+ /** The Server's own verdict on the entry. Never read as one. */
80
+ valid?: boolean;
81
+ /**
82
+ * Base64 SCITT Receipt (COSE_Sign1, draft-ietf-cose-merkle-tree-proofs)
83
+ * on a `?receipts=true` export: an RFC 9162 inclusion proof of this
84
+ * entry's `coseSign1` bytes in a Merkle tree over the record's chain,
85
+ * signed by the vault signing key. Verified when present (`receipts`).
86
+ */
87
+ receipt?: string;
88
+ /** On a creation entry: the Server's answer on whether the stored schema still matches the `schemaRef` the entry signs. Unsigned. */
89
+ schemaBinding?: string;
90
+ /**
91
+ * On COMPLIANCE_ATTESTATION and AI_IMPACT_ASSESSMENT entries: the Server's
92
+ * answer on whether the row the entry names still hashes to the signed
93
+ * `payload.contentHash`. Unsigned; the signed hash is in the payload.
94
+ */
95
+ contentBinding?: string;
96
+ /**
97
+ * On an entry written under the batched signing cadence: the RFC 9162
98
+ * inclusion proof from the entry's leaf to the root its batch head signs
99
+ * (`exportMetadata.batchHeads`). Absent on a batched entry no head covers
100
+ * yet. The entry is verified through it.
101
+ */
102
+ batch?: {
103
+ batchId: string;
104
+ leafIndex: number;
105
+ treeSize: number;
106
+ auditPath: string[];
107
+ } | null;
74
108
  };
75
109
  }
76
- /** Per-key activation/retirement window; drives temporal key-validity (engine ≥ v0.26.x). */
110
+ /** Per-key activation/retirement window; drives temporal key-validity (Server 0.26 and later). */
77
111
  export interface SigningKeyWindow {
78
112
  activatedAt: string;
79
113
  retiredAt: string | null;
@@ -92,6 +126,14 @@ export interface RecordAuditExportInput {
92
126
  recordId: string;
93
127
  exportFormatVersion?: string;
94
128
  canonicalization?: string;
129
+ /** How many entries the Server wrote into this export. */
130
+ totalEntries?: number;
131
+ /**
132
+ * Position of the record's latest signed checkpoint, or null when no
133
+ * checkpoint has been written for it yet. The chain is held to it: fewer
134
+ * entries than this is CHECKPOINT_ROW_MISSING.
135
+ */
136
+ expectedEntries?: number | null;
95
137
  signingPublicKeys?: Record<string, string>;
96
138
  /** keyId → activation/retirement window, the values the key statements sign. */
97
139
  signingKeyWindows?: Record<string, SigningKeyWindow>;
@@ -102,10 +144,65 @@ export interface RecordAuditExportInput {
102
144
  * caller's anchors, never used as one: it is the artifact's word.
103
145
  */
104
146
  anchoredFrom?: string | null;
147
+ /** The contract type the record was created under, as its creation entry signs it (`payload.schemaRef`). Unsigned copy. */
148
+ /**
149
+ * Absent from exports by older Servers. A field the Server could not
150
+ * resolve is absent, never null.
151
+ */
152
+ schemaRef?: {
153
+ publisher?: string;
154
+ type?: string;
155
+ version?: string;
156
+ manifestDigest?: string;
157
+ } | null;
158
+ /** The Server's answer on whether the stored schema still matches `schemaRef`. Unsigned. */
159
+ schemaBinding?: string;
160
+ /**
161
+ * The record's latest signed checkpoint and how far it covers the chain
162
+ * (Server 3.0.0 and later). The embedded checkpoint is verified
163
+ * (`checkpoint_evidence`); the coverage fields are the Server's word.
164
+ */
165
+ checkpointEvidence?: CheckpointEvidenceInput | null;
166
+ /** When the Server cut the export. Unsigned; it dates how long a batched entry with no proof has waited. */
167
+ exportDate?: string;
168
+ /**
169
+ * The signed batch heads the export's batched entries name, each once
170
+ * (a Server on the batched signing cadence). Verified under keys resolved
171
+ * like the entries' keys, at each head's own `createdAt`.
172
+ */
173
+ batchHeads?: Array<{
174
+ id: string;
175
+ signingKeyId: string;
176
+ coseSign1: string;
177
+ createdAt: string;
178
+ }>;
179
+ /**
180
+ * Every history seal the Server holds, each with this record chain's
181
+ * inclusion proof, or `proof: null` where the seal has no leaf for it (a
182
+ * chain created after the seal).
183
+ */
184
+ historySeals?: Array<{
185
+ id: string;
186
+ retiredKeyId: string;
187
+ signingKeyId: string;
188
+ treeSize: number;
189
+ rootHash: string;
190
+ coseSign1: string;
191
+ createdAt: string;
192
+ proof: {
193
+ leaf: {
194
+ chainKey: string;
195
+ chainPosition: number;
196
+ entryHash: string;
197
+ };
198
+ leafIndex: number;
199
+ auditPath: string[];
200
+ } | null;
201
+ }>;
105
202
  };
106
203
  entries: AuditExportEntryInput[];
107
204
  /**
108
- * Self-describing verification guidance the engine ships in the export.
205
+ * Self-describing verification guidance the Server ships in the export.
109
206
  * `unsignedFields` lists per-entry fields that are UNSIGNED display projections
110
207
  * (e.g. `actorDisplayName`) resolved at export time, not covered by the COSE_Sign1
111
208
  * signature. A PASS does NOT vouch for these labels. The attribution the guide
@@ -190,19 +287,19 @@ export interface VerifyExportOptions {
190
287
  */
191
288
  distrustedKeys?: ReadonlyArray<string | DistrustedKey>;
192
289
  /**
193
- * Ed25519 public keys of agent ephemeral certs, as JWKs: the `publicKeyJwk`
290
+ * Public keys of agent ephemeral certs, as JWKs: the `publicKeyJwk`
194
291
  * the agent sent to `POST /v1/auth/oidc/cert`, which is also the `cnf.jwk`
195
292
  * claim inside the returned `certJws`. The export does not carry them.
196
293
  *
197
- * When an entry's signed payload carries an engine-validated
294
+ * When an entry's signed payload carries a Server-validated
198
295
  * `predicate.on_behalf_of.agent_signature` and its sealed cert thumbprint
199
296
  * matches one of these keys, the signature is re-verified offline, proving
200
297
  * the cert holder signed that request-body hash without trusting the
201
- * engine's word for it. A key is matched only through the thumbprint the
298
+ * Server's word for it. A key is matched only through the thumbprint the
202
299
  * entry signed, so where a key came from does not need to be trusted.
203
- * Anything that is not an Ed25519 JWK throws `TypeError`.
300
+ * Anything that is not an agent cert key JWK throws `TypeError`.
204
301
  */
205
- agentKeys?: ReadonlyArray<AgentPublicKeyJwk>;
302
+ agentKeys?: ReadonlyArray<AgentPublicKeyJwk | AgentKeyEntry>;
206
303
  /**
207
304
  * Federation keys of the Servers this one peers with, keyed by their hub id:
208
305
  * `{ [hubId]: publicKey }` or `[{ hubId, publicKey }]`, each key as base64
@@ -229,7 +326,91 @@ export interface VerifyExportOptions {
229
326
  * hub's pins throws `TypeError`.
230
327
  */
231
328
  federationKeys?: Readonly<Record<string, string>> | ReadonlyArray<FederationKeyEntry>;
329
+ /**
330
+ * Accept a sealed federation message signed by a key its sender's history
331
+ * had already retired (beyond the 300 second clock-skew allowance), counted
332
+ * in `federationWire.afterRetirement`. For the short gap while a sender's
333
+ * publisher restarts onto its new key. Without it such a message fails
334
+ * CHAIN_FEDERATION_WIRE_INVALID, since a retired key signing later is also
335
+ * what a leaked key does.
336
+ */
337
+ allowAfterRetirement?: boolean;
338
+ /**
339
+ * The number of entries the record's chain holds, obtained out of band (the
340
+ * operator's statement, or your own count when you took the export). The
341
+ * count the export states about itself sits in unsigned metadata, which
342
+ * whoever removed entries can also remove; this one cannot be edited from
343
+ * the document. An export carrying a different number of entries fails
344
+ * CHAIN_POSITION_GAP. A non-negative integer: anything else throws
345
+ * `TypeError`.
346
+ */
347
+ expectedEntryCount?: number;
348
+ /**
349
+ * Anchor documents read from the anchor bucket
350
+ * (`vault-anchors/<instanceId>/<chainKey>/<chainPosition>.json`), each as
351
+ * `{ source, document, objectKey? }` with `document` the parsed JSON. Each
352
+ * checkpoint a document carries that verifies under the export's keys is
353
+ * compared with the chain (`anchors`); an unaccounted cut, rewrite or fork
354
+ * fails ANCHOR_CHAIN_CUT, ANCHOR_CHAIN_REWRITTEN or ANCHOR_FORK. Anything
355
+ * else throws `TypeError`.
356
+ */
357
+ anchorDocuments?: ReadonlyArray<AnchorDocumentInput>;
358
+ /**
359
+ * Compliance records as `GET /v1/records/{id}/compliance-records/{complianceRecordId}`
360
+ * serves them: one response, an array, or the list body `{ data: [...] }`.
361
+ * Each is bound by its `id` to the COMPLIANCE_ATTESTATION entry that names
362
+ * it, and its attestation is held to the signed contentHash
363
+ * (`attestation_bodies`). Anything else throws `TypeError`.
364
+ */
365
+ complianceRecords?: ComplianceRecordInput | ReadonlyArray<ComplianceRecordInput> | {
366
+ data: ReadonlyArray<ComplianceRecordInput>;
367
+ };
368
+ /**
369
+ * When the caller read the export (RFC 3339). Anchors are judged through
370
+ * it, less one second, in place of the export's own
371
+ * `checkpointEvidence.anchorsJudgedThroughIat`, which is unsigned. An
372
+ * anchor whose checkpoint verifies and signs a position above the last
373
+ * entry held is set aside as signed after the read only on a read time the
374
+ * caller gave: on the export's own word, or with none, it holds the verdict
375
+ * at best `unanchored` (`capped`). A time earlier than the signed `iat` of
376
+ * an entry or of the embedded checkpoint the export holds throws
377
+ * `TypeError` naming the entry: the export was read after it was signed.
378
+ * Batched entries with no proof are still dated by `exportMetadata.exportDate`.
379
+ */
380
+ exportDate?: string;
381
+ /**
382
+ * Acknowledgements of lost history the export does not carry, each a parsed
383
+ * document: a record export (read at
384
+ * `exportMetadata.checkpointEvidence.acknowledgedRewinds`), a page of a bulk
385
+ * export walk under a platform key (the RESTORE_EPOCH rows of its
386
+ * platform-ops chain), or `acknowledgedRewinds` items. Each is verified
387
+ * from its own envelope as the export's own are, and only its signed
388
+ * `coveredFindings` are read; `suppliedAcknowledgements` reports each. One
389
+ * that fails reads REWIND_ACKNOWLEDGEMENT_INVALID and covers nothing. A
390
+ * `GET /v1/admin/vault/rewind` response carries no signed envelope, and any
391
+ * other shape, throws `TypeError`.
392
+ */
393
+ acknowledgements?: ReadonlyArray<AcknowledgementSource>;
232
394
  }
395
+ /**
396
+ * Why a result that would read `trusted` reads `unanchored`.
397
+ * - `read_time_not_given`: an anchor or a listed checkpoint above the last
398
+ * entry held was set aside on the artifact's own unsigned read time, or on
399
+ * none; the caller's read time (`exportDate`) decides it.
400
+ * - `walk_not_read_to_end`: an export walk whose pages do not end at a null
401
+ * nextCursor, or show a page missing (`walk.incomplete`).
402
+ * - `chain_set_undecided`: a listed checkpoint or an anchor of a chain the
403
+ * walk holds no entry of could not be placed inside or outside the walk's
404
+ * query (`chainSet`).
405
+ */
406
+ export type VerdictCapReason = 'read_time_not_given' | 'walk_not_read_to_end' | 'chain_set_undecided';
407
+ /** One reason a result reads at best `unanchored`, with the sentence to show. */
408
+ export interface VerdictCap {
409
+ reason: VerdictCapReason;
410
+ detail: string;
411
+ }
412
+ /** A verdict held at best `unanchored` when any cap applies. */
413
+ export declare function capVerdict(verdict: Verdict, caps: readonly VerdictCap[]): Verdict;
233
414
  export interface EntryVerificationResult {
234
415
  position: number;
235
416
  valid: boolean;
@@ -237,6 +418,20 @@ export interface EntryVerificationResult {
237
418
  detail?: string;
238
419
  signature?: SignatureOutcome['state'];
239
420
  }
421
+ /**
422
+ * The checks `optionalChecks` reports on an export: the chain's, and
423
+ * `entry_count`, which is `applied` when the chain's length was held to a
424
+ * count (the export's own `expectedEntries` / `totalEntries`, or the
425
+ * `expectedEntryCount` option) and `skipped_no_input` when none was given;
426
+ * `checkpoint_evidence`, `applied` when the export embeds a checkpoint and it
427
+ * was verified against the chain; and `receipts`, `applied` when the export
428
+ * carries Receipts (`?receipts=true`) and each was verified.
429
+ *
430
+ * `anchors` is `applied` when `anchorDocuments` were given and at least one
431
+ * checkpoint in them was compared with the chain, and `attestation_bodies`
432
+ * when `complianceRecords` were given and at least one was held to an entry.
433
+ */
434
+ export type ExportOptionalCheck = OptionalCheck | 'entry_count' | 'checkpoint_evidence' | 'receipts' | 'anchors' | 'attestation_bodies';
240
435
  export interface VerifyExportResult {
241
436
  valid: boolean;
242
437
  totalEntries: number;
@@ -248,12 +443,12 @@ export interface VerifyExportResult {
248
443
  };
249
444
  entries: EntryVerificationResult[];
250
445
  recordId: string;
251
- signatureCoverage: {
252
- signed: number;
253
- unsigned: number;
254
- skipped: number;
255
- total: number;
256
- };
446
+ /**
447
+ * `signed` counts entries whose signature verified, `batched` how many of
448
+ * those are signed through a batch head, `skipped` entries from before the
449
+ * install began signing, and `pending` batched entries no head covers yet.
450
+ */
451
+ signatureCoverage: SignatureCoverage;
257
452
  /**
258
453
  * Which input-gated checks ran on this export.
259
454
  *
@@ -261,17 +456,20 @@ export interface VerifyExportResult {
261
456
  * `actorId` / `actorRole` / `actorOwnerId` columns and the envelope carries
262
457
  * the signed actor claim, which is every current export.
263
458
  * - `payload_binding`, `oidc_actor` and `key_temporal` flip to `applied`
264
- * when the export wire carries their inputs (engine >= v0.26.x: per-entry
459
+ * when the export wire carries their inputs (Server >= v0.26.x: per-entry
265
460
  * `payload` + `entryType`, `actorOidcSynthesized`, `createdAt`, and
266
461
  * `signingKeyWindows` in exportMetadata). Older exports without those
267
462
  * fields stay `skipped_no_input`.
268
463
  * - `agent_signature` is `applied` only when `agentKeys` supplied the cert
269
- * key for at least one engine-validated agent signature on the chain.
464
+ * key for at least one Server-validated agent signature on the chain.
465
+ * - `entry_count` is `applied` when the chain's length was held to a stated
466
+ * or supplied count, and `skipped_no_input` when the export states none
467
+ * and `expectedEntryCount` was not given.
270
468
  *
271
469
  * The applicability is surfaced so a caller never mistakes "not checked
272
470
  * here" for "checked and passed".
273
471
  */
274
- optionalChecks: Record<OptionalCheck, CheckApplicability>;
472
+ optionalChecks: Record<ExportOptionalCheck, CheckApplicability>;
275
473
  /**
276
474
  * How many signature checks resolved against supplied vs export-embedded
277
475
  * keys. Provenance only; whether a key is trusted is `keyTrust`.
@@ -328,12 +526,157 @@ export interface VerifyExportResult {
328
526
  */
329
527
  evidenceBinding: EvidenceBindingCounts;
330
528
  /**
331
- * `trusted`, `unanchored` or `failed` (see `Verdict`). Read this rather
332
- * than `valid` alone: a valid result with no `trustAnchors`, or none that
333
- * anchored a signature, is `unanchored`, which is not a trusted verdict.
529
+ * How entries an Ed25519, ES256 or ES384 key signed stand against the
530
+ * export's history seals. `unsealed` entries are valid and rest on their
531
+ * classical signature alone; a result that carries any reads `unanchored`,
532
+ * never `trusted`, and `unsealedKeys` says what would seal each key.
533
+ */
534
+ historySeal: HistorySealCounts;
535
+ /**
536
+ * The entry counts the export states, which the chain is held to.
537
+ * `expectedEntries` is the position of the record's latest checkpoint
538
+ * (null when the export names none) and `statedEntries` the number of
539
+ * entries the Server wrote into the export (null when it does not say).
540
+ * Fewer entries than `expectedEntries` fails CHECKPOINT_ROW_MISSING, and
541
+ * fewer than `statedEntries` fails CHAIN_POSITION_GAP. With both null the
542
+ * entry count is the file's own and is held to nothing.
543
+ */
544
+ entryCount: {
545
+ expectedEntries: number | null;
546
+ statedEntries: number | null;
547
+ };
548
+ /**
549
+ * The checkpoint `exportMetadata.checkpointEvidence` embeds, held to the
550
+ * chain the way a dump's checkpoint is: the entry at its position must
551
+ * exist and carry its signed tip hash, and its signature must verify under
552
+ * a key resolved like the entries' keys. `state: 'absent'` when the export
553
+ * embeds none, which holds the chain to nothing signed.
554
+ */
555
+ checkpointEvidence: CheckpointEvidenceReport;
556
+ /** Receipts on a `?receipts=true` export: present vs verified. */
557
+ receipts: ReceiptCounts;
558
+ /**
559
+ * The coverage fields of `checkpointEvidence` (`lastEntryPosition`,
560
+ * `coveredThroughPosition`, `coverage`, `uncoveredFromPosition`,
561
+ * `uncoveredEntries`) held to the entries and the embedded checkpoint. A
562
+ * disagreement fails CHECKPOINT_COVERAGE_MISMATCH, and a last position above
563
+ * the entries carried CHAIN_POSITION_GAP.
564
+ */
565
+ checkpointCoverage: CheckpointCoverageReport;
566
+ /**
567
+ * The acknowledgements of lost history `checkpointEvidence.acknowledgedRewinds`
568
+ * lists, each verified from its own envelope. `linkChecked` is false: an
569
+ * acknowledgement's link in the platform-ops chain is established only by a
570
+ * dump of that chain.
571
+ */
572
+ acknowledgedRewinds: AcknowledgementReport;
573
+ /** The supplied anchor documents against the chain (see `anchorDocuments`). */
574
+ anchors: ExportAnchorsReport;
575
+ /** The acknowledgements the caller gave (`acknowledgements`), each verified from its own envelope. */
576
+ suppliedAcknowledgements: AcknowledgementReport;
577
+ /**
578
+ * Each reason the verdict reads at best `unanchored` although nothing
579
+ * failed: see `VerdictCapReason`. Empty when none applies.
580
+ */
581
+ capped: VerdictCap[];
582
+ /**
583
+ * The COMPLIANCE_ATTESTATION and AI_IMPACT_ASSESSMENT entries: the signed
584
+ * contentHash and attestedAt in the forms the Server writes, and each
585
+ * supplied compliance record held to its entry (see `complianceRecords`).
586
+ * Each entry's `serverContentBinding` is the export's
587
+ * `integrity.contentBinding`: the Server's own statement, unsigned, and
588
+ * kept out of the verdict.
589
+ */
590
+ attestations: AttestationReport;
591
+ /**
592
+ * The signature checks that could not be computed on this host or by this
593
+ * build (`CHAIN_UNSUPPORTED_ALGORITHM`, wherever it was reported), and the
594
+ * algorithms of the export's keys behind them, on any verdict. Where the
595
+ * verdict is `unverifiable`, `unverifiableDetail` gives the sentence to show
596
+ * for it.
597
+ */
598
+ uncomputable: Uncomputable;
599
+ /**
600
+ * Present only when the running Node.js is older than `NODE_FLOOR`, which
601
+ * does not compute ML-DSA. Read it before the verdict: show
602
+ * `belowFloorNotice(result.runtime)` first and do not act on the verdict
603
+ * until the same input is verified on a Node.js at or above the floor.
604
+ */
605
+ runtime?: RuntimeBelowFloor;
606
+ /**
607
+ * `trusted`, `unanchored`, `unverifiable` or `failed` (see `Verdict`). Read
608
+ * this rather than `valid` alone: a valid result with no `trustAnchors`, or
609
+ * none that anchored a signature, is `unanchored`, which is not a trusted
610
+ * verdict. So is a pinned result that failed only because the pin anchored
611
+ * no signature (`valid: false`; see `verdictOf`). A result that
612
+ * would be valid had the signature checks this host refused, under
613
+ * algorithms this build supports, verified is `unverifiable` (`valid: false`;
614
+ * see `isUnverifiable`): nothing was found wrong, and the signatures this
615
+ * host refused were not verified.
616
+ * A check under an algorithm this build cannot compute stays a failure. On a
617
+ * `failed` result, `brokenAt` is the first failure that is not a check this
618
+ * host or build could not compute.
334
619
  */
335
620
  verdict: Verdict;
336
621
  }
622
+ /**
623
+ * Which of the Server's cross-record exports a document is, or null: a page
624
+ * of `GET /v1/audit-vault/export` (`'bulk'`) or of
625
+ * `GET /v1/audit-vault/schema-chain/export` (`'schema-chain'`). Both carry
626
+ * their entries in `data` beside `chainMetadata`, where a record's audit
627
+ * export carries `entries`. `verifyAuditExport` reads a record's audit export
628
+ * and names the function that reads these: `verifyBulkExport` and
629
+ * `verifySchemaChainExport`. An NDJSON page parsed line by line is read by
630
+ * those functions as text.
631
+ */
632
+ export declare function auditVaultExportKind(value: unknown): 'bulk' | 'schema-chain' | null;
633
+ /** What reads a cross-record export page in place of `verifyAuditExport`. */
634
+ export declare const NOT_A_RECORD_EXPORT: Readonly<Record<'bulk' | 'schema-chain', string>>;
635
+ /**
636
+ * How a cross-record export's reader holds one chain it took from the pages:
637
+ * the run of positions the pages carry, and what the entries' signed identity
638
+ * is held to in place of the record id. Set by `bulk-export.ts` and
639
+ * `schema-chain-export.ts` on the document they build for each chain, and
640
+ * read by every run `verifyAuditExport` makes on that document, reruns
641
+ * included.
642
+ */
643
+ export interface ChainReading {
644
+ slice?: {
645
+ startPosition: number;
646
+ previousHash: string | null;
647
+ openEnd?: boolean;
648
+ };
649
+ identity?: (entries: ReadonlyArray<unknown>) => {
650
+ recordId: string;
651
+ finding?: NonNullable<VerifyExportResult['brokenAt']>;
652
+ };
653
+ /** What the walk adds to the anchor comparison: its judged-through time, the run it holds, its acknowledgements. */
654
+ anchors?: ExportAnchorsWalkView;
655
+ /** Capture the key registry of the outer run, for checks the walk makes outside any one chain. */
656
+ keys?: (keys: KeyRegistry, signingSince: string | null) => void;
657
+ /**
658
+ * Signed checkpoints listed for the chain (GET /v1/audit-vault/checkpoints),
659
+ * held to its entries; `report` receives how far the chain is held, once
660
+ * per run, the outer run last.
661
+ */
662
+ listedCheckpoints?: {
663
+ rows: ReadonlyArray<{
664
+ row: VaultCheckpointRow;
665
+ source: string;
666
+ }>;
667
+ view: ListedCheckpointView;
668
+ report: (heldTo: ChainHeldTo) => void;
669
+ };
670
+ /**
671
+ * The read time of the page each entry was served on, by index into
672
+ * `entries` (RFC 3339, or null where nothing dates that page). A batched
673
+ * entry with no inclusion proof is judged against its own page's read
674
+ * time, in place of `exportMetadata.exportDate`.
675
+ */
676
+ entryReadTimes?: ReadonlyArray<string | null>;
677
+ }
678
+ /** `verifyAuditExport` on a document built for one chain of a cross-record export. Internal to this package. */
679
+ export declare function verifyExportChain(exportData: RecordAuditExportInput, options: VerifyExportOptions, reading: ChainReading): VerifyExportResult;
337
680
  /**
338
681
  * Verify one record's `/audit-export` document offline.
339
682
  *
@@ -343,3 +686,35 @@ export interface VerifyExportResult {
343
686
  * inside a well-formed document is a failure code on that entry, never a throw.
344
687
  */
345
688
  export declare function verifyAuditExport(exportData: RecordAuditExportInput, given?: VerifyExportOptions): VerifyExportResult;
689
+ /**
690
+ * The record id the export is about, taken from what it signs. The id in
691
+ * `exportMetadata` is unsigned, so it is held to the id each entry's signed
692
+ * predicate names and to the entry's own `recordId` column: any disagreement,
693
+ * among the entries or with the metadata, fails CHAIN_PAYLOAD_BINDING_MISMATCH,
694
+ * and the id reported is the signed one, never the metadata's.
695
+ */
696
+ export declare function signedRecordId(stated: unknown, entries: ReadonlyArray<unknown>): {
697
+ recordId: string;
698
+ finding?: NonNullable<VerifyExportResult['brokenAt']>;
699
+ };
700
+ /** The keys a document that carries none of its own is verified under: what `suppliedKeyContext` returns. */
701
+ export interface SuppliedKeyContext {
702
+ /** The supplied keys, marked with the walk's verdict when `trustAnchors` were given. */
703
+ keys: KeyRegistry;
704
+ trust: KeyTrust | null;
705
+ /** The earliest activation among the supplied keys and the keys the walk trusts (see `earliestKeyActivation`). */
706
+ signingSince: string | null;
707
+ /** The walk's report, before it is settled against the signatures that verified. */
708
+ walkReport: KeyTrustReport;
709
+ /** The SPKI of every supplied key, for the could-not-compute accounting. */
710
+ publicKeys: string[];
711
+ }
712
+ /**
713
+ * Resolve `publicKeys`, `trustAnchors` and `distrustedKeys` exactly as
714
+ * `verifyAuditExport` does for an export that embeds no key of its own: the
715
+ * same shapes accepted (the `/v1/verification-keys` body included), the same
716
+ * `TypeError`s at the boundary, the same walk from the anchors over the
717
+ * statements the supplied keys carry. Internal to this package: the read-log
718
+ * reader verifies documents that carry no keys with it.
719
+ */
720
+ export declare function suppliedKeyContext(fn: string, given: Pick<VerifyExportOptions, 'publicKeys' | 'trustAnchors' | 'distrustedKeys'>): SuppliedKeyContext;