@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
@@ -0,0 +1,301 @@
1
+ /**
2
+ * The history seal: what an ML-DSA key signs over everything written under
3
+ * the keys before it.
4
+ *
5
+ * When a Server retires an Ed25519, ES256 or ES384 vault key from a process
6
+ * that signs with ML-DSA, it writes one seal: an RFC 9162 Merkle root over one
7
+ * leaf per chain, each leaf the chain's tip at that moment, in the 56-byte
8
+ * form the batched cadence uses ({@link BATCH_LEAF_FORMAT}). The retirement
9
+ * waits out every write under the retired key first, so nothing that key
10
+ * signs can land above a sealed tip.
11
+ *
12
+ * The seal is one COSE_Sign1 in the key-statement envelope: protected header
13
+ * `{1: alg, 3: cty, 4: kid}` with `cty` = {@link HISTORY_SEAL_CTY}, signed
14
+ * over the RFC 9052 `Sig_structure` with an empty external_aad. Its payload is
15
+ * a deterministic-CBOR map:
16
+ *
17
+ * typ 'history-seal'
18
+ * iss the Server's issuer URL (informational)
19
+ * seal the seal's id (a uuid string)
20
+ * treeSize how many leaves the root covers
21
+ * root bstr of 32 bytes
22
+ * leaf the leaf format
23
+ * subject { kid, spkiSha256, alg, activatedAt, retiredAt }: the retired key
24
+ * closure hex SHA-256 of the closure payload the same retirement signed
25
+ * iat epoch seconds, informational
26
+ *
27
+ * The seal and that closure name each other: the closure carries
28
+ * `history: { seal, root, treeSize }`, and both are signed by one key.
29
+ *
30
+ * What a verifier does with it, on a walk that trusts an ML-DSA key: every
31
+ * entry signed by a classical key must sit at or below its chain's leaf in the
32
+ * seal that covers that key, and the chain's entry at the sealed position must
33
+ * be the one the leaf names. A classical signature alone then proves nothing;
34
+ * the ML-DSA-signed root does. The seal that covers a key is its own, or, for
35
+ * a key retired before any seal was written, the first seal written after its
36
+ * retirement (every seal covers every chain's tip). A classical key no seal
37
+ * covers is reported as unsealed.
38
+ *
39
+ * A walk that trusts no ML-DSA key (an install that signs with ES384
40
+ * throughout, or a verification with no `trustAnchors`) writes no seal and is
41
+ * held to none.
42
+ */
43
+ import { decode as cborDecode, encode as cborEncode, rfc8949EncodeOptions } from 'cborg';
44
+ import { BATCH_LEAF_FORMAT, batchLeafBytes } from './batch.js';
45
+ import { STRICT_CBOR_DECODE } from './cbor-strict.js';
46
+ import { placeInKeyWindow } from './chain.js';
47
+ import { STATEMENT_COSE_ALG, decodeSign1, isPostQuantumKey, sigStructure, spkiSha256 } from './key-statements.js';
48
+ import { instantMs } from './instant.js';
49
+ import { describeUnsupportedAlgorithm, resolveKeyAlgorithm, resolveKeyAlgorithmOrHostRefused, rfc9162LeafHash, runtimeCanCompute, signatureShape, verifyRfc9162Inclusion, verifySignatureBytes, } from './primitives.js';
50
+ /** COSE content type (header label 3) of a signed history seal. */
51
+ export const HISTORY_SEAL_CTY = 'application/vnd.agledger.history-seal+cbor';
52
+ /** The chain key the platform-ops chain's leaf carries. */
53
+ export const PLATFORM_OPS_CHAIN_KEY = '00000000-0000-0000-0000-000000000000';
54
+ const HEX64 = /^[0-9a-f]{64}$/;
55
+ const HEX16 = /^[0-9a-f]{16}$/;
56
+ const INSTANT_US = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z$/;
57
+ function decodeHistorySealPayload(bytes) {
58
+ let raw;
59
+ try {
60
+ raw = cborDecode(bytes, { ...STRICT_CBOR_DECODE, useMaps: false });
61
+ if (Buffer.compare(Buffer.from(cborEncode(raw, rfc8949EncodeOptions)), Buffer.from(bytes)) !== 0)
62
+ return null;
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw) || raw instanceof Uint8Array)
68
+ return null;
69
+ const r = raw;
70
+ const { typ, iss, seal, treeSize, root, leaf, subject, closure, iat } = r;
71
+ if (typ !== 'history-seal' || typeof iss !== 'string' || typeof seal !== 'string'
72
+ || typeof treeSize !== 'number' || !Number.isSafeInteger(treeSize) || treeSize < 0
73
+ || !(root instanceof Uint8Array) || root.length !== 32
74
+ || typeof leaf !== 'string' || typeof iat !== 'number' || !Number.isInteger(iat)
75
+ || (closure !== undefined && (typeof closure !== 'string' || !HEX64.test(closure)))
76
+ || Object.keys(r).length !== (closure === undefined ? 8 : 9)) {
77
+ return null;
78
+ }
79
+ if (subject === null || typeof subject !== 'object' || Array.isArray(subject) || subject instanceof Uint8Array)
80
+ return null;
81
+ const s = subject;
82
+ const { kid, spkiSha256: digest, alg, activatedAt, retiredAt } = s;
83
+ if (typeof kid !== 'string' || !HEX16.test(kid) || typeof digest !== 'string' || !HEX64.test(digest) || digest.slice(0, 16) !== kid
84
+ || typeof alg !== 'string' || typeof activatedAt !== 'string' || !INSTANT_US.test(activatedAt)
85
+ || typeof retiredAt !== 'string' || !INSTANT_US.test(retiredAt) || Object.keys(s).length !== 5) {
86
+ return null;
87
+ }
88
+ return {
89
+ seal,
90
+ treeSize,
91
+ root: Buffer.from(root).toString('hex'),
92
+ leaf,
93
+ subject: { kid, spkiSha256: digest, alg, activatedAt, retiredAt },
94
+ closure: closure ?? null,
95
+ };
96
+ }
97
+ /**
98
+ * Judge one history seal against the keys the artifact's entries are verified
99
+ * with (after `applyKeyTrust`) and the walk that anchored them. Never throws
100
+ * on a malformed seal: it is `invalid`, with the reason.
101
+ */
102
+ export function judgeHistorySeal(seal, keys, trust) {
103
+ const id = typeof seal?.id === 'string' ? seal.id : '';
104
+ const signingKeyId = typeof seal?.signingKeyId === 'string' ? seal.signingKeyId : null;
105
+ const verdict = (state, detail, payload = null) => ({
106
+ id,
107
+ state,
108
+ detail,
109
+ // A seal that does not decode still counts against the key it is filed for.
110
+ subjectKeyId: payload?.subject.kid ?? (typeof seal?.retiredKeyId === 'string' ? seal.retiredKeyId : null),
111
+ subjectRetiredAt: payload?.subject.retiredAt ?? null,
112
+ treeSize: payload?.treeSize ?? null,
113
+ root: payload?.root ?? null,
114
+ signingKeyId,
115
+ });
116
+ if (id === '' || signingKeyId === null)
117
+ return verdict('invalid', 'The history seal carries no id or no signingKeyId.');
118
+ const sign1 = decodeSign1(seal.coseSign1);
119
+ if (sign1 === null)
120
+ return verdict('invalid', `History seal ${id} does not decode as a tagged COSE_Sign1.`);
121
+ if (sign1.cty !== HISTORY_SEAL_CTY)
122
+ return verdict('invalid', `History seal ${id} is not signed as a history seal (content type ${JSON.stringify(sign1.cty)}).`);
123
+ const payload = decodeHistorySealPayload(sign1.payloadBstr);
124
+ if (payload === null)
125
+ return verdict('invalid', `History seal ${id}'s payload does not decode as a history seal.`);
126
+ const bad = (detail) => verdict('invalid', detail, payload);
127
+ if (sign1.kid !== signingKeyId)
128
+ return bad(`History seal ${id} is filed under key ${signingKeyId} and its signed kid is ${sign1.kid ?? 'absent'}.`);
129
+ if (payload.seal.toLowerCase() !== id.toLowerCase())
130
+ return bad(`History seal ${id} signs the id ${payload.seal}.`);
131
+ if (payload.leaf !== BATCH_LEAF_FORMAT)
132
+ return bad(`History seal ${id} names the leaf format ${JSON.stringify(payload.leaf)}; this verifier reads ${BATCH_LEAF_FORMAT}.`);
133
+ if (typeof seal.retiredKeyId !== 'string' || seal.retiredKeyId !== payload.subject.kid) {
134
+ return bad(`History seal ${id} is filed for key ${String(seal.retiredKeyId)} and signs the retirement of ${payload.subject.kid}.`);
135
+ }
136
+ if (seal.treeSize !== undefined && seal.treeSize !== payload.treeSize)
137
+ return bad(`History seal ${id}'s treeSize is ${seal.treeSize} beside it and ${payload.treeSize} signed.`);
138
+ if (seal.rootHash !== undefined && (typeof seal.rootHash !== 'string' || seal.rootHash.toLowerCase() !== payload.root)) {
139
+ return bad(`History seal ${id}'s rootHash differs from the root it signs.`);
140
+ }
141
+ // The retired key: the one the artifact holds under that id, and a classical one.
142
+ const subject = keys.get(payload.subject.kid);
143
+ if (subject && spkiSha256(subject.spkiBase64) !== payload.subject.spkiSha256) {
144
+ return bad(`History seal ${id} names key ${payload.subject.kid} with another fingerprint than the key this artifact carries under that id.`);
145
+ }
146
+ if (payload.subject.alg.startsWith('ML-DSA') || (subject && isPostQuantumKey(subject.spkiBase64))) {
147
+ return bad(`History seal ${id} seals ${payload.subject.kid}, an ML-DSA key; a seal covers what an Ed25519, ES256 or ES384 key signed.`);
148
+ }
149
+ // The closure the same retirement signed, bound both ways and signed by the same key.
150
+ if (payload.closure === null)
151
+ return bad(`History seal ${id} names no closure, so nothing ties it to the retirement of ${payload.subject.kid}.`);
152
+ const closure = (trust.closures.get(payload.subject.spkiSha256) ?? []).find((c) => c.digest === payload.closure);
153
+ if (!closure) {
154
+ return bad(`History seal ${id} names a closure of ${payload.subject.kid} (payload digest ${payload.closure.slice(0, 16)}...) that is not among the closures of that key this walk counts.`);
155
+ }
156
+ if (closure.history === null || closure.history.seal.toLowerCase() !== id.toLowerCase()
157
+ || closure.history.root !== payload.root || closure.history.treeSize !== payload.treeSize) {
158
+ return bad(`History seal ${id} names a closure of ${payload.subject.kid} that does not name this seal, its root and its tree size back.`);
159
+ }
160
+ if (closure.endorserKeyId !== signingKeyId) {
161
+ return bad(`History seal ${id} is signed by ${signingKeyId}, and the closure it names is signed by ${closure.endorserKeyId}; one retirement signs both with one key.`);
162
+ }
163
+ if (closure.retiredAt !== payload.subject.retiredAt) {
164
+ return bad(`History seal ${id} dates ${payload.subject.kid}'s retirement ${payload.subject.retiredAt}, and the closure it names dates it ${closure.retiredAt}.`);
165
+ }
166
+ const key = keys.get(signingKeyId);
167
+ if (!key)
168
+ return bad(`No public key is available for history seal ${id}'s signing key ${signingKeyId}.`);
169
+ // An ML-DSA key this host refused to load is a host refusal, as it is for
170
+ // an entry's key, not a key of another type.
171
+ const algorithm = resolveKeyAlgorithmOrHostRefused(key.spkiBase64);
172
+ if (typeof algorithm !== 'object' || !algorithm.name.startsWith('ML-DSA')) {
173
+ return bad(`History seal ${id} is signed by ${signingKeyId}, which is not an ML-DSA key; only an ML-DSA signature seals what classical keys signed.`);
174
+ }
175
+ // Checks that need no computation run before this host's capability or the
176
+ // key's undecided trust is asked, so they read the same on every host.
177
+ if (algorithm.verifiable) {
178
+ if (sign1.alg !== STATEMENT_COSE_ALG[algorithm.name])
179
+ return bad(`History seal ${id}'s protected-header alg is not the one key ${signingKeyId} (${algorithm.name}) signs under.`);
180
+ if (signatureShape(algorithm, sign1.signature) !== 'signature') {
181
+ return bad(`History seal ${id}'s signature is not a signature under key ${signingKeyId} (${algorithm.name}): all zero, or not ${algorithm.signatureLength} bytes.`);
182
+ }
183
+ }
184
+ if (key.trust === 'undecided' || !algorithm.verifiable || !runtimeCanCompute(algorithm)) {
185
+ return verdict('unsupported', `History seal ${id}'s key ${signingKeyId} ${describeUnsupportedAlgorithm(key.spkiBase64)}`, payload);
186
+ }
187
+ if (key.trust !== 'anchored')
188
+ return bad(`History seal ${id}'s key ${signingKeyId} is not linked by any signed key statement to a pinned trust anchor.`);
189
+ const placed = placeInKeyWindow(key, seal.createdAt, `History seal ${id}`);
190
+ if (placed.placement !== 'inside') {
191
+ return bad('detail' in placed ? placed.detail : `History seal ${id} was written outside key ${signingKeyId}'s window.`);
192
+ }
193
+ if (!verifySignatureBytes(key.spkiBase64, sigStructure(sign1.protectedBstr, sign1.payloadBstr), sign1.signature)) {
194
+ return bad(`History seal ${id}'s signature does not verify under key ${signingKeyId}.`);
195
+ }
196
+ return verdict('ok', `History seal ${id} verifies under key ${signingKeyId} and seals what ${payload.subject.kid} signed until ${payload.subject.retiredAt}.`, payload);
197
+ }
198
+ /**
199
+ * Judge the seals an artifact carries and decide which one covers each
200
+ * classical key. `trust` is the key walk; null (no `trustAnchors`) holds no
201
+ * key to any seal.
202
+ */
203
+ export function planHistorySeals(seals, keys, trust) {
204
+ const judged = new Map();
205
+ const bytesOf = new Map();
206
+ if (trust !== null) {
207
+ for (const seal of seals) {
208
+ const v = judgeHistorySeal(seal, keys, trust);
209
+ const id = v.id.toLowerCase();
210
+ // Anything that is neither a string nor bytes is already `invalid` above; it only needs a spelling to compare.
211
+ const raw = seal?.coseSign1;
212
+ const bytes = typeof raw === 'string' ? raw : raw instanceof Uint8Array ? Buffer.from(raw).toString('base64') : `?${String(raw)}`;
213
+ if (judged.has(id) && bytesOf.get(id) !== bytes) {
214
+ judged.set(id, { ...v, state: 'invalid', detail: `History seal ${v.id} is listed twice with different bytes.` });
215
+ }
216
+ else if (!judged.has(id)) {
217
+ judged.set(id, v);
218
+ bytesOf.set(id, bytes);
219
+ }
220
+ }
221
+ }
222
+ const applies = trust !== null && [...keys.values()].some((k) => k.trust === 'anchored' && isPostQuantumKey(k.spkiBase64));
223
+ // Seals that hold, earliest retirement first: the order a key with no seal
224
+ // of its own is matched against.
225
+ const holding = [...judged.values()]
226
+ .filter((v) => v.state === 'ok' && v.subjectRetiredAt !== null)
227
+ .sort((a, b) => instantMs(a.subjectRetiredAt ?? '') - instantMs(b.subjectRetiredAt ?? ''));
228
+ const cache = new Map();
229
+ const decide = (keyId) => {
230
+ const key = keys.get(keyId);
231
+ if (!applies || !key || key.trust !== 'anchored')
232
+ return null;
233
+ const algorithm = resolveKeyAlgorithm(key.spkiBase64);
234
+ if (typeof algorithm !== 'object' || isPostQuantumKey(key.spkiBase64))
235
+ return null;
236
+ const own = [...judged.values()].filter((v) => v.subjectKeyId === keyId);
237
+ const ownOk = own.find((v) => v.state === 'ok');
238
+ if (ownOk)
239
+ return { state: 'sealed', seal: ownOk };
240
+ const ownBad = own.find((v) => v.state === 'invalid') ?? own[0];
241
+ if (ownBad)
242
+ return { state: ownBad.state === 'unsupported' ? 'unsupported' : 'invalid', detail: ownBad.detail };
243
+ if (typeof key.retiredAt !== 'string' || key.retiredAt === '') {
244
+ return {
245
+ state: 'unsealed',
246
+ detail: `Key ${keyId} (${algorithm.name}) has no retirement signed by an ML-DSA key and no history seal. Until it is retired from a process that signs with ML-DSA, what it signed rests on its ${algorithm.name} signatures alone. Retire it on the Server and take the export again.`,
247
+ };
248
+ }
249
+ const retired = instantMs(key.retiredAt);
250
+ const later = holding.find((v) => instantMs(v.subjectRetiredAt ?? '') >= retired);
251
+ if (later)
252
+ return { state: 'sealed', seal: later };
253
+ return {
254
+ state: 'unsealed',
255
+ detail: `Key ${keyId} (${algorithm.name}) was retired ${key.retiredAt}, and this artifact carries no history seal written at or after that. What it signed rests on its ${algorithm.name} signatures alone.`,
256
+ };
257
+ };
258
+ return {
259
+ seals: judged,
260
+ coverOf(keyId) {
261
+ if (!cache.has(keyId))
262
+ cache.set(keyId, decide(keyId));
263
+ return cache.get(keyId) ?? null;
264
+ },
265
+ };
266
+ }
267
+ /**
268
+ * Resolve a chain's leaf in a seal whose verdict is `ok`: the proof must be
269
+ * for this chain and reach the signed root. `proof` is null or undefined when
270
+ * the artifact carries none for this chain (the seal has no leaf for it).
271
+ */
272
+ export function resolveHistorySealLeaf(seal, chainKey, proof) {
273
+ if (proof === null || proof === undefined)
274
+ return { state: 'missing' };
275
+ const bad = (detail) => ({ state: 'invalid', detail });
276
+ const leaf = proof.leaf;
277
+ if (typeof proof !== 'object' || leaf === null || typeof leaf !== 'object')
278
+ return bad(`History seal ${seal.id}'s proof is not { leaf, leafIndex, auditPath }.`);
279
+ const { chainKey: named, chainPosition, entryHash } = leaf;
280
+ if (typeof named !== 'string' || typeof chainKey !== 'string' || named.toLowerCase() !== chainKey.toLowerCase()) {
281
+ return bad(`History seal ${seal.id}'s proof is for chain ${String(named)}, not this chain (${String(chainKey)}).`);
282
+ }
283
+ const bytes = typeof chainPosition === 'number' && typeof entryHash === 'string' ? batchLeafBytes(named.toLowerCase(), chainPosition, entryHash) : null;
284
+ if (bytes === null || typeof chainPosition !== 'number' || typeof entryHash !== 'string') {
285
+ return bad(`History seal ${seal.id}'s leaf for this chain is not a chain key, a position and a 64-character lowercase hex entry hash.`);
286
+ }
287
+ if (seal.treeSize === null || seal.root === null)
288
+ return bad(`History seal ${seal.id} carries no signed tree size or root.`);
289
+ if (!Number.isSafeInteger(proof.leafIndex) || proof.leafIndex < 0 || proof.leafIndex >= seal.treeSize) {
290
+ return bad(`History seal ${seal.id}'s proof names leaf ${String(proof.leafIndex)}, outside the ${seal.treeSize} leaves it signs.`);
291
+ }
292
+ const hashes = proof.auditPath;
293
+ if (!Array.isArray(hashes) || !hashes.every((h) => typeof h === 'string' && HEX64.test(h))) {
294
+ return bad(`History seal ${seal.id}'s auditPath is not an array of 64-character lowercase hex hashes.`);
295
+ }
296
+ const path = hashes.map((h) => new Uint8Array(Buffer.from(h, 'hex')));
297
+ if (!verifyRfc9162Inclusion(rfc9162LeafHash(bytes), proof.leafIndex, seal.treeSize, path, new Uint8Array(Buffer.from(seal.root, 'hex')))) {
298
+ return bad(`History seal ${seal.id}'s proof does not reach the root it signs from this chain's leaf.`);
299
+ }
300
+ return { state: 'ok', chainPosition, entryHash };
301
+ }
package/dist/index.d.ts CHANGED
@@ -5,15 +5,43 @@
5
5
  */
6
6
  export { suggestion } from './failures.js';
7
7
  export type { FailureCode } from './failures.js';
8
- export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, earliestKeyActivation, verifyChain, writtenWhileSigning, } from './chain.js';
9
- export type { AccountedEntry, AccountedEntryCode, AgentKeyRegistry, KeySource, KeyTrustState, VerificationKey, KeyRegistry, NormalizedEntry, OptionalCheck, CheckApplicability, SignatureOutcome, ChainEntryResult, ChainResult, EvidenceBindingCounts, VerifyChainOptions, } from './chain.js';
10
- export { verifyAuditExport } from './audit-export.js';
11
- export type { AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerifyExportOptions, SuppliedKeyEntry, EntryVerificationResult, VerifyExportResult, } from './audit-export.js';
12
- export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
8
+ export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, distrustAccounts, earliestKeyActivation, placeInKeyWindow, verifyChain, writtenWhileSigning, } from './chain.js';
9
+ export type { AccountedEntry, AccountedEntryCode, AgentKeyEntry, AgentKeyRegistry, KeySource, KeyTrustState, KeyWindowPlacement, VerificationKey, KeyRegistry, NormalizedEntry, OptionalCheck, CheckApplicability, SignatureOutcome, ChainEntryResult, ChainResult, EvidenceBindingCounts, HistorySealCounts, SignatureCoverage, VerifyChainOptions, } from './chain.js';
10
+ export { NOT_A_RECORD_EXPORT, auditVaultExportKind, capVerdict, verifyAuditExport } from './audit-export.js';
11
+ export type { VerdictCap, VerdictCapReason, AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerifyExportOptions, SuppliedKeyEntry, EntryVerificationResult, VerifyExportResult, ExportOptionalCheck, } from './audit-export.js';
12
+ export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, sealedVerdict, pinReachesNoKey, isPostQuantumKey, pinPredatesDetail, pinPredatesSuccessors, isUnverifiable, unverifiableVerdict, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
13
13
  export type { ComputeKeyTrustInput, DistrustedKey, DistrustSpan, DumpKeyStatementRow, DumpSigningKeyRow, KeyRegistryFinding, KeyRegistryFindingCode, KeyStatementInput, KeyStatementKind, KeyTrust, KeyTrustEntry, KeyTrustNote, KeyTrustReport, KeyTrustStatus, PublishedKeyStatement, TrustKeyInput, Verdict, VerificationKeysDocument, } from './key-statements.js';
14
- export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, } from './federation-wire.js';
15
- export type { FederationKeyEntry, FederationKeyHistoryDocument, FederationKeyHistoryStatement, FederationKeyRegistry, FederationTrustedKey, FederationWire, FederationWireOutcome, } from './federation-wire.js';
14
+ export { BATCH_HEAD_CTY, BATCH_LEAF_FORMAT, BATCH_MARKER_LABEL, BATCH_PENDING_GRACE_SECONDS, batchLeafBytes, checkBatchProof, isBatchedProtectedHeader, } from './batch.js';
15
+ export type { BatchHeadRegistry, BatchHeadVerdict, BatchProofInput } from './batch.js';
16
+ export { buildBatchHeadRegistry, judgeBatchHead } from './batch-head.js';
17
+ export type { BatchHeadInput } from './batch-head.js';
18
+ export { HISTORY_SEAL_CTY, PLATFORM_OPS_CHAIN_KEY, judgeHistorySeal, planHistorySeals, resolveHistorySealLeaf } from './history-seal.js';
19
+ export type { HistorySealCover, HistorySealInput, HistorySealLeaf, HistorySealPlan, HistorySealProofInput, HistorySealVerdict } from './history-seal.js';
20
+ export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, FEDERATION_ACK_DOMAIN, FEDERATION_ACK_KINDS, FEDERATION_CO_SIGN_CLAIM_FIELDS, FEDERATION_CO_SIGN_DOMAIN, FederationKeyHistoryError, verifyFederationAck, verifyFederationCoSign, } from './federation-wire.js';
21
+ export type { FederationKeyEntry, FederationKeyHistoryDocument, FederationKeyHistoryStatement, FederationKeyRegistry, FederationTrustedKey, FederationWire, FederationWireOutcome, CheckFederationWireOptions, FederationAckInput, FederationCoSignInput, FederationSignatureOutcome, } from './federation-wire.js';
16
22
  export { instantMs } from './instant.js';
17
23
  export { assertKnownOptions } from './options.js';
18
- export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
19
- export type { CoseSign1Parts, CoseVerifyOutcome, KeyAlgorithm, ActorClaim, ChainClaim, AgentPublicKeyJwk, AgentSignatureClaim, AgentSignatureOutcome, ReceiptInclusionProof, ReceiptVerifyOutcome, } from './primitives.js';
24
+ export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, hostRefusalCause, uncomputableAlgorithm, uncomputableAlgorithms, uncomputableNote, verifyAsIfHostComputed, isVerifyingAsIfHostComputed, hasComputableAnchor, anchorAlgorithms, unverifiableDetail, NODE_FLOOR, runtimeBelowFloor, belowFloorNotice, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, agentJwkThumbprint, agentJwkToSpki, agentKeyAlgorithm, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
25
+ export type { CoseSign1Parts, CoseVerifyOutcome, KeyAlgorithm, ActorClaim, ChainClaim, AgentPublicKeyJwk, AgentSignatureClaim, AgentSignatureOutcome, ReceiptInclusionProof, ReceiptVerifyOutcome, Uncomputable, UncomputableAlgorithm, RuntimeBelowFloor, } from './primitives.js';
26
+ export { decodeSignedClaim, uuidSubjectDigest, UNSIGNED_KID } from './claim.js';
27
+ export type { SignedClaim } from './claim.js';
28
+ export { verifyExportCheckpoint, verifyExportReceipts } from './export-evidence.js';
29
+ export type { CheckpointEvidenceInput, CheckpointEvidenceReport, ExportCheckpointInput, ReceiptCounts, } from './export-evidence.js';
30
+ export { ANCHOR_DOCUMENT_VERSION, KEY_WINDOW_CLOCK_SKEW_SECONDS, VAULT_CHECKPOINT_PREDICATE_TYPE, anchorDocumentChainKey, anchorObjectKeyOfPath, compareCheckpointAnchors, placeSignedIat, rewindAcknowledgementOf, unreadableAnchorVerdict, verifyRewindAcknowledgements, } from './anchors.js';
31
+ export type { AcknowledgedRewindInput, AcknowledgementReport, AcknowledgementVerdict, AnchorChainView, AnchorComparison, AnchorDisagreementCode, AnchorDocumentInput, AnchorFinding, AnchorNotComparableReason, AnchorVerdict, CoveredFinding, RewindAcknowledgement, } from './anchors.js';
32
+ export { verifyCheckpointCoverage, verifyExportAnchors } from './export-anchors.js';
33
+ export type { CheckpointCoverageReport, ExportAnchorsReport, ExportAnchorsWalkView, ExportEvidenceFinding } from './export-anchors.js';
34
+ export { CONTENT_BOUND_ENTRY_TYPES, CONTENT_HASH_PATTERN, readComplianceRecords, verifyAttestations } from './attestation.js';
35
+ export type { AttestationEntryReport, AttestationFinding, AttestationReport, AttestationEntryView, ComplianceRecordInput } from './attestation.js';
36
+ export { verifyBulkExport } from './bulk-export.js';
37
+ export type { BulkWalkChainSet, BulkWalkQuery, VerifyBulkExportOptions, VerifyBulkExportResult } from './bulk-export.js';
38
+ export type { AcknowledgementSource } from './acknowledgements.js';
39
+ export { walkOrder } from './export-pages.js';
40
+ export { schemaCheckpointKey, verifySchemaChainExport } from './schema-chain-export.js';
41
+ export type { VerifySchemaChainExportOptions, VerifySchemaChainExportResult } from './schema-chain-export.js';
42
+ export type { BulkExportPage, ExportChainResult, ExportPageMetadata, ExportPageRow, ExportReadTime, ReadTimeSource, ExportWalkFinding, ExportWalkInput, ExportWalkReport, ExportWalkResultBase, SchemaChainExportPage, } from './export-pages.js';
43
+ export { judgeListedCheckpoints } from './walk-checkpoints.js';
44
+ export type { ChainHeldTo, ListedCheckpointFinding, ListedCheckpointOutcome, ListedCheckpointView, VaultCheckpointRow, VaultCheckpointsPage } from './walk-checkpoints.js';
45
+ export type { WalkAcknowledgements, WalkAnchorsReport } from './walk-anchors.js';
46
+ export { orgReadDocumentKind, READ_LOG_STAMP_SKEW_SECONDS, readLogStampDisagreement, verifyOrgReadCheckpoint, verifyOrgReadLog, verifyOrgReadProof } from './read-log.js';
47
+ export type { OrgReadCheckpointInput, OrgReadCheckpointReport, OrgReadCheckpointsPage, OrgReadCosignatureReport, OrgReadCosignerKey, OrgReadDumpRow, OrgReadEntriesPage, OrgReadEntryInput, OrgReadFinding, OrgReadLeafReport, OrgReadListedCheckpoint, OrgReadProofInput, VerifyOrgReadCheckpointResult, VerifyOrgReadLogResult, VerifyOrgReadOptions, VerifyOrgReadProofResult, } from './read-log.js';
package/dist/index.js CHANGED
@@ -4,10 +4,23 @@
4
4
  * the MCP server, and @agledger/verify all build on this single body of logic.
5
5
  */
6
6
  export { suggestion } from './failures.js';
7
- export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, earliestKeyActivation, verifyChain, writtenWhileSigning, } from './chain.js';
8
- export { verifyAuditExport } from './audit-export.js';
9
- export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
10
- export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, } from './federation-wire.js';
7
+ export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, distrustAccounts, earliestKeyActivation, placeInKeyWindow, verifyChain, writtenWhileSigning, } from './chain.js';
8
+ export { NOT_A_RECORD_EXPORT, auditVaultExportKind, capVerdict, verifyAuditExport } from './audit-export.js';
9
+ export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, sealedVerdict, pinReachesNoKey, isPostQuantumKey, pinPredatesDetail, pinPredatesSuccessors, isUnverifiable, unverifiableVerdict, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
10
+ export { BATCH_HEAD_CTY, BATCH_LEAF_FORMAT, BATCH_MARKER_LABEL, BATCH_PENDING_GRACE_SECONDS, batchLeafBytes, checkBatchProof, isBatchedProtectedHeader, } from './batch.js';
11
+ export { buildBatchHeadRegistry, judgeBatchHead } from './batch-head.js';
12
+ export { HISTORY_SEAL_CTY, PLATFORM_OPS_CHAIN_KEY, judgeHistorySeal, planHistorySeals, resolveHistorySealLeaf } from './history-seal.js';
13
+ export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, FEDERATION_ACK_DOMAIN, FEDERATION_ACK_KINDS, FEDERATION_CO_SIGN_CLAIM_FIELDS, FEDERATION_CO_SIGN_DOMAIN, FederationKeyHistoryError, verifyFederationAck, verifyFederationCoSign, } from './federation-wire.js';
11
14
  export { instantMs } from './instant.js';
12
15
  export { assertKnownOptions } from './options.js';
13
- export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
16
+ export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, hostRefusalCause, uncomputableAlgorithm, uncomputableAlgorithms, uncomputableNote, verifyAsIfHostComputed, isVerifyingAsIfHostComputed, hasComputableAnchor, anchorAlgorithms, unverifiableDetail, NODE_FLOOR, runtimeBelowFloor, belowFloorNotice, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, agentJwkThumbprint, agentJwkToSpki, agentKeyAlgorithm, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
17
+ export { decodeSignedClaim, uuidSubjectDigest, UNSIGNED_KID } from './claim.js';
18
+ export { verifyExportCheckpoint, verifyExportReceipts } from './export-evidence.js';
19
+ export { ANCHOR_DOCUMENT_VERSION, KEY_WINDOW_CLOCK_SKEW_SECONDS, VAULT_CHECKPOINT_PREDICATE_TYPE, anchorDocumentChainKey, anchorObjectKeyOfPath, compareCheckpointAnchors, placeSignedIat, rewindAcknowledgementOf, unreadableAnchorVerdict, verifyRewindAcknowledgements, } from './anchors.js';
20
+ export { verifyCheckpointCoverage, verifyExportAnchors } from './export-anchors.js';
21
+ export { CONTENT_BOUND_ENTRY_TYPES, CONTENT_HASH_PATTERN, readComplianceRecords, verifyAttestations } from './attestation.js';
22
+ export { verifyBulkExport } from './bulk-export.js';
23
+ export { walkOrder } from './export-pages.js';
24
+ export { schemaCheckpointKey, verifySchemaChainExport } from './schema-chain-export.js';
25
+ export { judgeListedCheckpoints } from './walk-checkpoints.js';
26
+ export { orgReadDocumentKind, READ_LOG_STAMP_SKEW_SECONDS, readLogStampDisagreement, verifyOrgReadCheckpoint, verifyOrgReadLog, verifyOrgReadProof } from './read-log.js';
package/dist/instant.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Milliseconds of an RFC 3339 instant, truncating any finer fraction the way
3
- * the engine reads a microsecond instant (its `instantToDate`). Key statements
3
+ * the Server reads a microsecond instant. Key statements
4
4
  * sign microsecond instants; entry write times, dump columns and key documents
5
5
  * carry milliseconds, so every comparison between them is made here. Strict:
6
6
  * a `T`, an offset or `Z`, a real calendar date and time of day; NaN for
package/dist/instant.js CHANGED
@@ -2,7 +2,7 @@
2
2
  const RFC3339 = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?([Zz]|([+-])(\d{2}):(\d{2}))$/;
3
3
  /**
4
4
  * Milliseconds of an RFC 3339 instant, truncating any finer fraction the way
5
- * the engine reads a microsecond instant (its `instantToDate`). Key statements
5
+ * the Server reads a microsecond instant. Key statements
6
6
  * sign microsecond instants; entry write times, dump columns and key documents
7
7
  * carry milliseconds, so every comparison between them is made here. Strict:
8
8
  * a `T`, an offset or `Z`, a real calendar date and time of day; NaN for