@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
@@ -13,25 +13,26 @@ export declare function sha256HexString(s: string): string;
13
13
  * public key can never be repurposed as a MAC key.
14
14
  */
15
15
  export interface KeyAlgorithm {
16
- /** Registry name, matching the engine's `vault_signing_keys.algorithm` values. */
16
+ /** Registry name, matching the algorithm names the Server's key registry uses. */
17
17
  name: string;
18
18
  /** COSE `alg` values (protected header label 1) acceptable for this key. */
19
19
  coseAlgs: readonly number[];
20
20
  /** Raw signature length; also the length of the all-zero unsigned sentinel. */
21
21
  signatureLength: number;
22
- /** Whether THIS build can compute the algorithm (Ed25519 and ES256 today). */
22
+ /** Whether THIS build can compute the algorithm (Ed25519, ES256, ES384 and ML-DSA today). */
23
23
  verifiable: boolean;
24
24
  /** Node `asymmetricKeyType` the key material must carry. */
25
- nodeKeyType: 'ed25519' | 'ec';
25
+ nodeKeyType: 'ed25519' | 'ec' | 'ml-dsa-44' | 'ml-dsa-65' | 'ml-dsa-87';
26
26
  /** OpenSSL curve name from `asymmetricKeyDetails.namedCurve` (EC only). */
27
27
  namedCurve: string | null;
28
28
  /**
29
29
  * Digest passed as the FIRST POSITIONAL argument to node:crypto verify().
30
- * Part of algorithm identity (RFC 9053 §2.1 fixes SHA-256 to ES256), not a
30
+ * Part of algorithm identity (RFC 9053 §2.1 fixes SHA-256 to ES256 and
31
+ * SHA-384 to ES384), not a
31
32
  * caller choice: passing null for an EC key silently gets Node's
32
33
  * key-type-dispatched fallback, so the dispatcher refuses that combination.
33
34
  */
34
- digest: 'sha256' | null;
35
+ digest: 'sha256' | 'sha384' | null;
35
36
  /** Signature encoding for ECDSA (COSE requires raw r||s, not DER). */
36
37
  dsaEncoding: 'ieee-p1363' | null;
37
38
  }
@@ -60,6 +61,14 @@ export declare function algorithmByName(name: string): KeyAlgorithm | null;
60
61
  * implementations classify the same bytes the same way.
61
62
  */
62
63
  export declare function looksLikeEd25519Key(spkiDer: Uint8Array): boolean;
64
+ /**
65
+ * The table entry these bytes DECLARE by their SPKI structure, without asking
66
+ * node:crypto to load them: Ed25519 or an ML-DSA parameter set, else null.
67
+ * Same purpose as `looksLikeEd25519Key`, widened to every algorithm a host
68
+ * can refuse at load: a Node.js build without ML-DSA cannot load an ML-DSA
69
+ * key, and that must read as "not verified here", not as tamper.
70
+ */
71
+ export declare function declaredKeyAlgorithm(spkiDer: Uint8Array): KeyAlgorithm | null;
63
72
  /**
64
73
  * Resolve the algorithm a base64 SPKI DER public key commits to. Returns:
65
74
  *
@@ -71,14 +80,25 @@ export declare function looksLikeEd25519Key(spkiDer: Uint8Array): boolean;
71
80
  * - `'unparseable'` when the bytes are not a public key at all.
72
81
  */
73
82
  export declare function resolveKeyAlgorithm(publicKeyBase64: string): KeyAlgorithm | 'unparseable' | 'unrecognized';
83
+ /**
84
+ * {@link resolveKeyAlgorithm}, with a key this host refused to LOAD read as
85
+ * the algorithm its bytes declare (Ed25519 or ML-DSA, by structure, on a host
86
+ * whose own known-answer test says it does not compute that algorithm). For a
87
+ * site that judges a key before computing anything under it (a batched
88
+ * entry's own key, a batch head's key, a history seal's key), so a host
89
+ * refusal there reads as one, as it does for an entry's signature, and never
90
+ * as a malformed key. Garbage bytes still resolve `'unparseable'`, and a key
91
+ * of a type this build cannot compute still resolves `'unrecognized'`.
92
+ */
93
+ export declare function resolveKeyAlgorithmOrHostRefused(publicKeyBase64: string): KeyAlgorithm | 'unparseable' | 'unrecognized';
74
94
  /**
75
95
  * Verify an Ed25519 signature over raw bytes.
76
96
  * `publicKeyBase64` is the SPKI DER public key, base64-encoded
77
- * (matches the engine's vault_signing_keys.public_key column).
97
+ * (the shape the Server's key registry publishes).
78
98
  *
79
99
  * Refuses non-Ed25519 keys. Node's `verify(null, ...)` silently falls back to
80
100
  * ECDSA/SHA-256 for EC keys, which would accept a signature no conformant
81
- * EdDSA verifier accepts (the engine guards the signing side the same way),
101
+ * EdDSA verifier accepts (the Server guards the signing side the same way),
82
102
  * so the key type is asserted before any crypto runs.
83
103
  *
84
104
  * CAUTION for direct callers: as with `verifySignatureBytes`, `false` conflates
@@ -97,6 +117,26 @@ export declare function verifyEd25519Bytes(publicKeyBase64: string, input: Uint8
97
117
  * as tamper evidence.
98
118
  */
99
119
  export declare function runtimeCanCompute(keyAlg: KeyAlgorithm): boolean;
120
+ /** The lowest Node.js release this package verifies on: the first that computes ML-DSA, the Server's default signing algorithm. */
121
+ export declare const NODE_FLOOR = "24.6.0";
122
+ /** Present on a result, and returned by {@link runtimeBelowFloor}, only when the running Node.js is older than {@link NODE_FLOOR}. */
123
+ export interface RuntimeBelowFloor {
124
+ belowFloor: true;
125
+ /** The running Node.js, as `process.version` gives it. */
126
+ nodeVersion: string;
127
+ /** The lowest Node.js release verification runs on. */
128
+ floor: string;
129
+ }
130
+ /**
131
+ * Whether the running Node.js is older than {@link NODE_FLOOR}; null when it
132
+ * is not. Node.js releases before the floor do not compute ML-DSA, so a
133
+ * verdict reached there on a record a current Server signed is not one to
134
+ * act on. The command-line verifiers stop here and reach no verdict; a
135
+ * library caller reads this, or `runtime` on a result, and does the same.
136
+ */
137
+ export declare function runtimeBelowFloor(): RuntimeBelowFloor | null;
138
+ /** The sentence to show first when {@link runtimeBelowFloor} is not null. */
139
+ export declare function belowFloorNotice(runtime: RuntimeBelowFloor): string;
100
140
  /**
101
141
  * Human-readable reason an algorithm could not be computed, for the detail
102
142
  * line of CHAIN_UNSUPPORTED_ALGORITHM. Distinguishes the two causes that share
@@ -104,6 +144,158 @@ export declare function runtimeCanCompute(keyAlg: KeyAlgorithm): boolean;
104
144
  * verifier, versus re-run somewhere the algorithm is permitted.
105
145
  */
106
146
  export declare function describeUnsupportedAlgorithm(publicKeyBase64: string): string;
147
+ /** Why the host refused `name`, as the clause that ends the refusal sentence. */
148
+ /**
149
+ * What a signature's bytes are under `keyAlg`, before anything is computed:
150
+ * the all-zero sentinel of the algorithm's length, a length no signature
151
+ * under it has, or a candidate signature. Read the same on every host, so a
152
+ * site asks it before asking whether this host computes the algorithm.
153
+ */
154
+ export declare function signatureShape(keyAlg: KeyAlgorithm, signature: Uint8Array): 'zero' | 'wrong-length' | 'signature';
155
+ /**
156
+ * Why this host refused to compute `name`, when that is known, as a clause:
157
+ * an active OpenSSL FIPS provider for Ed25519 (it carries no EdDSA) or for
158
+ * ML-DSA, or a Node.js runtime older than ML-DSA's for ML-DSA. Null when no
159
+ * cause is known: the line then names the algorithm and claims no cause.
160
+ */
161
+ export declare function hostRefusalCause(name: string): string | null;
162
+ /**
163
+ * An algorithm a key commits to that could not be computed here, and why:
164
+ * `host` when this verifier build supports it and the host runtime refused to
165
+ * compute it (an active OpenSSL FIPS provider and Ed25519, or a Node.js build
166
+ * without ML-DSA), `build` when this verifier build cannot compute it.
167
+ * `algorithm` is null for a well-formed key of a type this build does not
168
+ * recognize at all.
169
+ */
170
+ export interface UncomputableAlgorithm {
171
+ algorithm: string | null;
172
+ cause: 'host' | 'build';
173
+ }
174
+ /**
175
+ * The signature checks of a result that could not be computed, counted over
176
+ * the whole artifact (each `CHAIN_UNSUPPORTED_ALGORITHM`, and each key
177
+ * statement the walk could not check), and the algorithms of its keys this
178
+ * host or build cannot compute. `count` 0 means every signature reached was
179
+ * computed.
180
+ */
181
+ export interface Uncomputable {
182
+ count: number;
183
+ algorithms: UncomputableAlgorithm[];
184
+ /**
185
+ * On an `unverifiable` result, every other failure code it lists (such as
186
+ * KEY_CLOSURE_INVALID or CHAIN_SIGNING_KEY_UNANCHORED): each follows from
187
+ * the checks this host could not compute, since with them verified nothing
188
+ * fails. Empty on any other verdict.
189
+ */
190
+ consequences: string[];
191
+ /**
192
+ * On an `unverifiable` result, what the rerun behind it assumed verified.
193
+ * `data`: a trust anchor this host computes was given, so every key was
194
+ * trusted through signatures this host computed, and only signatures over
195
+ * data that this host refused were assumed. `data-and-key-statements`: no
196
+ * such anchor, so the key statements this host could not check were
197
+ * assumed too, and the result is the same for an artifact and a forgery of
198
+ * it; nothing about its keys was established here. Absent on any other
199
+ * verdict.
200
+ */
201
+ assumed?: 'data' | 'data-and-key-statements';
202
+ /**
203
+ * With `assumed: 'data-and-key-statements'`, the algorithms of the trust
204
+ * anchors given that name a key here; empty when none was given or none
205
+ * names a key here.
206
+ */
207
+ anchorAlgorithms?: string[];
208
+ /**
209
+ * With `assumed: 'data-and-key-statements'`, true when trust anchors were
210
+ * given and none names a key here, and the input would be valid without
211
+ * them had the refused checks verified. A host that computes every
212
+ * algorithm here reads the same input as `unanchored`. Absent otherwise.
213
+ */
214
+ pinUnmet?: true;
215
+ }
216
+ /**
217
+ * The {@link UncomputableAlgorithm} of a key, given its SPKI DER base64, or
218
+ * null when this build and this host can both compute it, or when the bytes
219
+ * are not a public key at all (which is tamper class, not a gap).
220
+ */
221
+ export declare function uncomputableAlgorithm(publicKeyBase64: string): UncomputableAlgorithm | null;
222
+ /**
223
+ * Run `run` as though the signature checks this host refused under an
224
+ * algorithm this build supports had verified, and return what it returns.
225
+ * The counterfactual behind the `unverifiable` verdict (see
226
+ * `unverifiableVerdict`): a result is unverifiable only when the same input,
227
+ * re-verified this way, is valid.
228
+ *
229
+ * Only the host's refusals change. "Refused" is this build's own known-answer
230
+ * test of the algorithm on this host, which nothing in an artifact can change,
231
+ * so on a host that computes every algorithm this build supports, `run`
232
+ * behaves exactly as it would outside. A key of a type this build cannot
233
+ * compute still cannot be computed, a signature that was checked and did not
234
+ * verify still does not, and hash, link and count checks run as they are.
235
+ *
236
+ * With `statements: false`, a refused check over a key statement (a vault
237
+ * key's genesis, succession or closure, a federation key's history) is not
238
+ * assumed: it reads exactly as it does outside, so no key reaches trust
239
+ * through a signature this host did not compute. That is the rerun for a run
240
+ * with a trust anchor this host can compute (see `hasComputableAnchor`).
241
+ *
242
+ * For verifiers built on this package. `run` must be synchronous; the
243
+ * assumption is withdrawn when it returns or throws, and never outlives it. A
244
+ * result read inside it is a counterfactual and must never be reported as a
245
+ * verification.
246
+ */
247
+ export declare function verifyAsIfHostComputed<T>(run: () => T, options?: {
248
+ statements: boolean;
249
+ }): T;
250
+ /** Whether the caller is inside {@link verifyAsIfHostComputed}. */
251
+ export declare function isVerifyingAsIfHostComputed(): boolean;
252
+ /**
253
+ * Whether this is a rerun that assumes only the refused signatures over data:
254
+ * one under a trust anchor this host computes, where a key is trusted only
255
+ * through signatures this host computed.
256
+ */
257
+ export declare function isDataOnlyRerun(): boolean;
258
+ /**
259
+ * Run `run`, which judges key statement signatures, so that a rerun that does
260
+ * not assume key statements reads them as this host does. Every site that
261
+ * decides key trust from a signature runs inside it.
262
+ */
263
+ export declare function judgingKeyStatements<T>(run: () => T): T;
264
+ /**
265
+ * Whether one of `anchors` is the digest of one of `publicKeys` (SPKI DER
266
+ * base64) whose algorithm this host computes, by its own known-answer test.
267
+ * With such an anchor this host can establish key trust itself, and the
268
+ * counterfactual rerun assumes no key statement. Read from the host alone,
269
+ * never from inside a rerun.
270
+ */
271
+ export declare function hasComputableAnchor(anchors: readonly string[], publicKeys: Iterable<string>): boolean;
272
+ /** The algorithms of the keys among `publicKeys` that `anchors` name, each once. */
273
+ export declare function anchorAlgorithms(anchors: readonly string[], publicKeys: Iterable<string>): string[];
274
+ /**
275
+ * The algorithms among `publicKeys` (SPKI DER base64) this host or build
276
+ * cannot compute, each once, in the order first met.
277
+ */
278
+ export declare function uncomputableAlgorithms(publicKeys: Iterable<string>): UncomputableAlgorithm[];
279
+ /**
280
+ * What to tell the holder of a result whose verdict is `unverifiable`: how
281
+ * many signature checks could not be computed and under which algorithms,
282
+ * that nothing was found wrong and the refused signatures were never
283
+ * checked, that it is neither
284
+ * evidence of tampering nor a pass, and the remedy for each cause. Built from
285
+ * the same claims as the `CHAIN_UNSUPPORTED_ALGORITHM` detail lines. Show it
286
+ * only where the verdict is `unverifiable`: it says nothing was found wrong,
287
+ * which a `failed` result does not support.
288
+ */
289
+ export declare function unverifiableDetail(uncomputable: Pick<Uncomputable, 'count' | 'algorithms'> & Partial<Pick<Uncomputable, 'consequences' | 'assumed' | 'anchorAlgorithms' | 'pinUnmet'>>): string;
290
+ /**
291
+ * The line a `failed` result shows for the signature checks it could not
292
+ * compute, beside the failure it names: how many, under which algorithms, and
293
+ * that they were not checked here. Empty when there were none. A `failed`
294
+ * result has a real failure, so this line never says nothing was found wrong.
295
+ */
296
+ export declare function uncomputableNote(uncomputable: Pick<Uncomputable, 'count' | 'algorithms'>): string;
297
+ /** Best-effort FIPS detection, used only to explain a failure, never to gate one. */
298
+ export declare function isFipsActive(): boolean;
107
299
  /**
108
300
  * Verify a raw signature under whatever algorithm the TRUSTED key commits to.
109
301
  * Generalizes `verifyEd25519Bytes`: the algorithm is resolved from the SPKI
@@ -112,9 +304,10 @@ export declare function describeUnsupportedAlgorithm(publicKeyBase64: string): s
112
304
  * the upgrade-vs-forgery distinction use `resolveKeyAlgorithm` first, as
113
305
  * `verifyCoseSign1` does).
114
306
  *
115
- * ES256 mirrors the engine's `verifyWithAlgorithm`: SHA-256 digest passed
116
- * positionally, `dsaEncoding: 'ieee-p1363'` (COSE raw r||s, 64 bytes). The
117
- * engine normalizes to low-S at sign time but, like the engine's verifier,
307
+ * ES256 and ES384 mirror how the Server verifies them: the SHA-256 or SHA-384
308
+ * digest passed positionally, `dsaEncoding: 'ieee-p1363'` (COSE raw r||s, 64
309
+ * or 96 bytes). The
310
+ * Server normalizes to low-S at sign time but, like the Server's verifier,
118
311
  * high-S is accepted here: ECDSA malleability changes the envelope bytes,
119
312
  * which the hash-link layer already pins.
120
313
  *
@@ -142,7 +335,7 @@ export declare function decodeCoseSign1(bytes: Uint8Array): CoseSign1Parts | nul
142
335
  * Reconstructs Sig_structure = ["Signature1", protected_bstr, h'' (empty
143
336
  * external_aad), payload_bstr] per RFC 9052 §4.4, deterministically CBOR-
144
337
  * encodes it (RFC 8949 §4.2.1), and verifies under the algorithm the trusted
145
- * key commits to (Ed25519 or ES256). The producer used the exact same
338
+ * key commits to. The producer used the exact same
146
339
  * construction, so byte-equality is required.
147
340
  *
148
341
  * Returns:
@@ -150,7 +343,7 @@ export declare function decodeCoseSign1(bytes: Uint8Array): CoseSign1Parts | nul
150
343
  * - 'decode-fail' if the envelope is malformed
151
344
  * - 'invalid' if the signature does not verify
152
345
  * - 'unsigned' if the signature slot is all-zero at the key's expected
153
- * signature length (engine booted without VAULT_SIGNING_KEY
346
+ * signature length (a Server running without a signing key
154
347
  * at write time; chain integrity falls back to the hash-link
155
348
  * layer)
156
349
  * - 'alg-mismatch' if the protected header's `alg` (label 1) is absent or is
@@ -171,12 +364,14 @@ export declare function decodeCoseSign1(bytes: Uint8Array): CoseSign1Parts | nul
171
364
  */
172
365
  export type CoseVerifyOutcome = 'ok' | 'decode-fail' | 'invalid' | 'unsigned' | 'alg-mismatch' | 'unsupported-key-algorithm';
173
366
  export declare function verifyCoseSign1(coseSign1: Uint8Array, publicKeyBase64: string): CoseVerifyOutcome;
367
+ /** Decode the protected header's `alg` (label 1); null when absent or not an int. */
368
+ export declare function extractHeaderAlg(protectedBstr: Uint8Array): number | null;
174
369
  /**
175
370
  * Extract the signature-covered `kid` (protected header label 4) as lowercase
176
- * hex, matching the engine's `vault_signing_keys.key_id` shape. Returns null
371
+ * hex, matching the key id shape the Server's key registry uses. Returns null
177
372
  * when absent or malformed. The caller cross-checks it against the row's
178
373
  * `signingKeyId` column: the column is a denormalized convenience, the kid is
179
- * signed, so a rewritten column surfaces as drift (engine mirror: signing_key_drift).
374
+ * signed, so a rewritten column surfaces as drift (Server mirror: signing_key_drift).
180
375
  */
181
376
  export declare function extractKid(protectedBstr: Uint8Array): string | null;
182
377
  /**
@@ -195,12 +390,12 @@ export declare function extractChainClaim(protectedBstr: Uint8Array): ChainClaim
195
390
  * Extract the actor identity claim (`-65539`) from a COSE_Sign1 protected
196
391
  * header. It is nested inside CWT_Claims (RFC 9597, label 15) rather than
197
392
  * sitting at the outer header level, because it IS an identity statement: the
198
- * engine keeps the outer level to IANA-known labels plus chain mechanics.
393
+ * Server keeps the outer level to IANA-known labels plus chain mechanics.
199
394
  *
200
- * `key_id` and `owner_id` are UUIDs the engine encodes as 16-byte CBOR byte
395
+ * `key_id` and `owner_id` are UUIDs the Server encodes as 16-byte CBOR byte
201
396
  * strings, returned here in canonical lowercase-hyphenated form so they
202
397
  * compare directly against the export's `actorId` / `actorOwnerId` columns.
203
- * Returns null when the claim is missing or malformed (engines older than the
398
+ * Returns null when the claim is missing or malformed (Servers older than the
204
399
  * claim, or an envelope that will not decode) so the caller can skip rather
205
400
  * than fail an entry that never carried it.
206
401
  */
@@ -224,28 +419,44 @@ export declare function extractOnBehalfOfClaim(payloadBstr: Uint8Array): Record<
224
419
  */
225
420
  export declare function extractTraceparentClaim(payloadBstr: Uint8Array): string | null;
226
421
  /**
227
- * Domain-separation prefix the engine applies before verifying an agent's
422
+ * Domain-separation prefix the Server applies before verifying an agent's
228
423
  * `X-Agent-Signature` at intake: the agent signs the UTF-8 bytes of this
229
424
  * prefix followed by the lowercase hex sha256 of the raw request body (the
230
425
  * hex string, not the digest bytes). Distinct from the cert proof-of-possession
231
426
  * prefix, so one signature cannot be replayed as the other.
232
427
  */
233
428
  export declare const AGENT_SIGNATURE_CONTEXT = "agledger.agent.sig.v1\n";
234
- /** An Ed25519 public key in JWK form, as sent in `publicKeyJwk` at cert exchange. */
235
- export interface AgentPublicKeyJwk {
429
+ /**
430
+ * An agent cert's public key in JWK form, as sent in `publicKeyJwk` at cert
431
+ * exchange and signed into the cert's `EPHEMERAL_CERT_ISSUED` entry: an AKP
432
+ * key (RFC 9964) for ML-DSA-87 or ML-DSA-65, a P-384 EC key, or the Ed25519
433
+ * OKP key of a cert a Server before 4.0.0 issued.
434
+ */
435
+ export type AgentPublicKeyJwk = {
436
+ kty: 'AKP';
437
+ alg: 'ML-DSA-87' | 'ML-DSA-65';
438
+ /** base64url of the raw public key. */
439
+ pub: string;
440
+ } | {
441
+ kty: 'EC';
442
+ crv: 'P-384';
443
+ /** base64url of the 48-byte coordinates. */
444
+ x: string;
445
+ y: string;
446
+ } | {
236
447
  kty: 'OKP';
237
448
  crv: 'Ed25519';
238
449
  /** base64url of the raw 32-byte public key. */
239
450
  x: string;
240
- }
451
+ };
241
452
  /**
242
- * The agent-signature evidence the engine sealed into a chain entry, read from
453
+ * The agent-signature evidence the Server sealed into a chain entry, read from
243
454
  * the signed payload. Fields are left `unknown` where the verifier must check
244
- * their shape itself: a sealed value the engine never writes is a finding, not
455
+ * their shape itself: a sealed value the Server never writes is a finding, not
245
456
  * something to coerce.
246
457
  */
247
458
  export interface AgentSignatureClaim {
248
- /** `on_behalf_of.validated === true`: the engine vouched for the identity. */
459
+ /** `on_behalf_of.validated === true`: the Server vouched for the identity. */
249
460
  validated: boolean;
250
461
  /** `on_behalf_of.cert.id`, when a cert is sealed beside the signature. */
251
462
  certId: string | null;
@@ -262,26 +473,47 @@ export interface AgentSignatureClaim {
262
473
  */
263
474
  export declare function extractAgentSignatureClaim(payloadBstr: Uint8Array): AgentSignatureClaim | null;
264
475
  /**
265
- * RFC 7638 thumbprint of an Ed25519 JWK in the engine's `sha256:<hex>` form,
476
+ * RFC 7638 thumbprint of an Ed25519 JWK in the Server's `sha256:<hex>` form,
266
477
  * or null when the value is not an Ed25519 public-key JWK. The members are
267
478
  * hashed in the RFC's lexicographic order (`crv`, `kty`, `x`), which is what
268
- * the engine's thumbprint function produces for an OKP key.
479
+ * the Server's thumbprint function produces for an OKP key.
269
480
  */
270
481
  export declare function ed25519JwkThumbprint(jwk: unknown): string | null;
271
482
  /** SPKI DER (base64) for an Ed25519 JWK, or null when it is not one. */
272
483
  export declare function ed25519JwkToSpki(jwk: unknown): string | null;
484
+ /**
485
+ * JWK thumbprint of an agent cert key in the Server's `sha256:<hex>` form, or
486
+ * null when the value is not one (see {@link AgentPublicKeyJwk}). The members
487
+ * hashed are the required ones in lexicographic order: `alg`, `kty`, `pub`
488
+ * for an AKP key (RFC 9964), `crv`, `kty`, `x`, `y` for P-384 and `crv`,
489
+ * `kty`, `x` for Ed25519 (RFC 7638). Other members (`use`, `kid`) are not
490
+ * hashed.
491
+ */
492
+ export declare function agentJwkThumbprint(jwk: unknown): string | null;
493
+ /** SPKI DER (base64) for an agent cert key, or null when the value is not one. */
494
+ export declare function agentJwkToSpki(jwk: unknown): string | null;
273
495
  export type AgentSignatureOutcome = 'ok' | 'invalid' | 'malformed' | 'unsupported';
274
496
  /**
275
- * Verify a sealed agent signature against the cert's Ed25519 key.
497
+ * The algorithm an agent cert key signs with, or null when the key is not an
498
+ * agent key. Read from the key's structure first, so an ML-DSA or Ed25519 key
499
+ * reads as itself on a host that cannot load it.
500
+ */
501
+ export declare function agentKeyAlgorithm(spkiBase64: string): KeyAlgorithm | null;
502
+ /**
503
+ * Verify a sealed agent signature against the cert's key. The algorithm is
504
+ * the key's own: ML-DSA-87 or ML-DSA-65 (pure, empty context), ES384 (the
505
+ * 96-byte `r||s`, either S half), or Ed25519 on an entry sealed before
506
+ * Server 4.0.0.
276
507
  *
277
508
  * - `ok`: the signature verifies over `AGENT_SIGNATURE_CONTEXT + <hex>`.
278
- * - `invalid`: well formed, does not verify under this key.
279
- * - `malformed`: a shape the engine never writes (alg other than EdDSA, a
280
- * content hash not `sha256:<hex64>`, a signature that is not 64 bytes of
281
- * standard base64). Nothing can verify it, which the engine also treats as
282
- * a break.
283
- * - `unsupported`: this host cannot compute Ed25519 (an active OpenSSL FIPS
284
- * provider). NOT verified and NOT tamper evidence.
509
+ * - `invalid`: well formed, and does not verify under this key, or the sealed
510
+ * `alg` names another algorithm than the key's.
511
+ * - `malformed`: a shape the Server never writes (an `alg` it does not seal,
512
+ * a content hash not `sha256:<hex64>`, a signature that is not standard
513
+ * base64 at the algorithm's length). Nothing can verify it, which the Server
514
+ * also treats as a break.
515
+ * - `unsupported`: this host cannot compute the key's algorithm. NOT verified
516
+ * and NOT tamper evidence.
285
517
  *
286
518
  * What it proves: the holder of the cert's private key signed that content
287
519
  * hash. It does not re-hash a request body; the export carries the hash, not
@@ -292,15 +524,14 @@ export declare function verifyAgentSignature(spkiBase64: string, claim: Pick<Age
292
524
  * Decode the predicate object from a COSE_Sign1 payload bstr. The payload IS
293
525
  * the in-toto v1 Statement; the predicate body lives at `payload.predicate`.
294
526
  * Returns null on any decode failure. Used by the binding-integrity check; the
295
- * row's denormalised `payload` jsonb is a convenience view projected from this
527
+ * entry's readable `payload` is a convenience view projected from this
296
528
  * predicate at write time; if the view was altered after signing,
297
529
  * `buildPredicateForRow(...) !== decodePredicate(...)`.
298
530
  */
299
531
  export declare function decodePredicate(payloadBstr: Uint8Array): Record<string, unknown> | null;
300
532
  /**
301
533
  * Re-project (record_id, entry_type, payload) -> predicate body using the SAME
302
- * logic the engine uses at write time (engine-side: audit-vault/
303
- * build-vault-claim.ts). This is the verifier-side mirror.
534
+ * logic the Server uses at write time. This is the verifier-side mirror.
304
535
  *
305
536
  * Returns null when the row's payload is structurally insufficient (e.g.
306
537
  * SCHEMA_REGISTERED missing manifestDigest) or is not a JSON object at all (a
@@ -318,7 +549,7 @@ export declare function deepEqual(a: unknown, b: unknown): boolean;
318
549
  /**
319
550
  * Strip envelope-level sibling fields (`on_behalf_of`, `traceparent`) from a
320
551
  * decoded predicate. They ride alongside per-kind predicate fields on the wire
321
- * but the engine's `buildPredicateOnly` (and our `buildPredicateForRow`
552
+ * but the Server's own predicate builder (and our `buildPredicateForRow`
322
553
  * mirror) exclude them from the rebuilt predicate. Stripping here makes the
323
554
  * two shapes deep-equalable; envelope-level integrity is covered by the
324
555
  * signature and the OIDC-actor cross-check.
@@ -328,30 +559,34 @@ export declare function stripEnvelopeExtensions(predicate: Record<string, unknow
328
559
  * Whether the envelope extensions a row's payload carries are the ones the
329
560
  * entry signed. When a writer puts `on_behalf_of` (an object) or
330
561
  * `traceparent` (a W3C v00 string; any other value is dropped) at the top
331
- * level of the row payload, the engine lifts it into `predicate.on_behalf_of`
562
+ * level of the row payload, the Server lifts it into `predicate.on_behalf_of`
332
563
  * / `predicate.traceparent`, so a row copy must equal the signed value. The
333
564
  * row copy is what a reader of an export or dump sees, and
334
565
  * {@link stripEnvelopeExtensions} takes both sides out of the predicate
335
566
  * comparison, so without this check a rewritten or added row copy would still
336
567
  * verify.
337
568
  *
338
- * Anything else under those keys is ignored, as the engine ignores it: it
569
+ * Anything else under those keys is ignored, as the Server ignores it: it
339
570
  * lifts only an object `on_behalf_of` and a v00 `traceparent`, so a genuine
340
571
  * older row holding another shape signed nothing for it.
341
572
  *
342
- * A row without them is not a mismatch: the engine also signs an
343
- * `on_behalf_of` built from the request's authentication rather than from the
344
- * payload, and that one never reaches the row payload. Its identity is held to
345
- * the row's actor columns by the OIDC-actor check instead.
573
+ * `projected` says whether the payload is one the Server fills from the
574
+ * signed predicate. An export entry's is: the Server writes every
575
+ * `on_behalf_of` and v00 `traceparent` the entry signed into it, including an
576
+ * `on_behalf_of` built from the request's authentication, so a signed one the
577
+ * payload lacks was deleted after export. A vault row's payload never holds
578
+ * them (the Server keeps them only inside the signed envelope), so on a dump
579
+ * a row without them is not a mismatch, and the identity is held to the row's
580
+ * actor columns by the OIDC-actor check instead.
346
581
  */
347
- export declare function envelopeExtensionsMatch(rowPayload: Record<string, unknown>, signedPredicate: Record<string, unknown>): boolean;
582
+ export declare function envelopeExtensionsMatch(rowPayload: Record<string, unknown>, signedPredicate: Record<string, unknown>, projected?: boolean): boolean;
348
583
  /** RFC 9162 §2.1.1 leaf hash: SHA-256(0x00 || d). */
349
584
  export declare function rfc9162LeafHash(leafData: Uint8Array): Uint8Array;
350
585
  /** RFC 9162 §2.1.1 internal-node hash: SHA-256(0x01 || left || right). */
351
586
  export declare function rfc9162NodeHash(left: Uint8Array, right: Uint8Array): Uint8Array;
352
587
  /**
353
- * Verify a RFC 9162 §2.1.3.2 inclusion proof. Mirrors the engine-side
354
- * implementation; reproduced here so the verifier stays engine-free. False
588
+ * Verify a RFC 9162 §2.1.3.2 inclusion proof. Mirrors the Server-side
589
+ * implementation; reproduced here so the verifier stays Server-free. False
355
590
  * when `leafIndex` or `treeSize` is not a safe integer: the walk halves them,
356
591
  * and a fraction, NaN or an unsafe integer would walk some other tree.
357
592
  */
@@ -404,3 +639,8 @@ export declare function orgReadMerkleRoot(leafHashesHex: readonly string[]): str
404
639
  * `treeSize` that is not a safe integer (a JSON number can be 0.5 or 1e300).
405
640
  */
406
641
  export declare function verifyOrgReadInclusion(leafHashHex: string, leafIndex: number, treeSize: number, pathHex: readonly string[], expectedRootHex: string): boolean;
642
+ /**
643
+ * A run of chain positions in prose: `entry 4 was` for one position, `entries
644
+ * 4 through 9 were` for more. `verb` is the plural form (`were`, `are`).
645
+ */
646
+ export declare function entryRun(from: number, through: number, verb: 'were' | 'are'): string;