@agledger/verify-core 2.0.0 → 2.2.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.
- package/README.md +140 -21
- package/dist/audit-export.d.ts +124 -16
- package/dist/audit-export.js +171 -16
- package/dist/cbor-strict.d.ts +9 -0
- package/dist/cbor-strict.js +14 -0
- package/dist/chain.d.ts +144 -19
- package/dist/chain.js +212 -41
- package/dist/failures.d.ts +25 -11
- package/dist/failures.js +39 -15
- package/dist/federation-wire.d.ts +171 -0
- package/dist/federation-wire.js +515 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -1
- package/dist/instant.d.ts +1 -1
- package/dist/instant.js +1 -1
- package/dist/key-statements.d.ts +27 -11
- package/dist/key-statements.js +74 -44
- package/dist/options.js +4 -4
- package/dist/primitives.d.ts +35 -32
- package/dist/primitives.js +65 -50
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@ The shared offline verification core for AGLedger audit chains. Decodes
|
|
|
4
4
|
canonical **COSE_Sign1** envelopes (RFC 9052, tag 18) over in-toto v1
|
|
5
5
|
Statement payloads, walks the per-record hash chain, and verifies the
|
|
6
6
|
signature over each `Sig_structure` under the algorithm the verification key
|
|
7
|
-
commits to (Ed25519 or ES256), with no
|
|
7
|
+
commits to (Ed25519 or ES256), with no Server, no database, and no network.
|
|
8
|
+
|
|
9
|
+
Reads exports and dumps from an AGLedger Server 2.0 or later. For a 1.x Server's, use `npm i @agledger/verify-core@1.5.0`, the last release that reads them.
|
|
8
10
|
|
|
9
11
|
This is the single body of logic that underpins the SDK `/verify` subpath
|
|
10
12
|
(`@agledger/sdk/verify`), the [`@agledger/cli`](https://github.com/agledger-ai/cli)
|
|
@@ -50,8 +52,8 @@ console.log(result.verdict); // 'trusted', or 'unanchored' when nothing pinned b
|
|
|
50
52
|
Read `verdict` rather than `valid`: a valid result with no `trustAnchors` is
|
|
51
53
|
`unanchored`, which is not a trusted verdict. An option the function does not
|
|
52
54
|
read throws `TypeError` rather than being ignored, so a misspelt option, or
|
|
53
|
-
`requireOutOfBandKeys` (
|
|
54
|
-
check off without a word.
|
|
55
|
+
the old name `requireOutOfBandKeys` (the option is `requireSuppliedKeys`),
|
|
56
|
+
cannot turn a check off without a word.
|
|
55
57
|
|
|
56
58
|
## What it verifies
|
|
57
59
|
|
|
@@ -92,16 +94,51 @@ check off without a word.
|
|
|
92
94
|
activation window. With `trustAnchors`, the window is the one the key
|
|
93
95
|
statements sign.
|
|
94
96
|
- **Agent signatures**, when you supply the agent's cert key (below).
|
|
97
|
+
- **Inlined evidence**, on an export taken with `?evidence=true`: each
|
|
98
|
+
completion's evidence body and each dispute's filed payload hashes (SHA-256
|
|
99
|
+
over its RFC 8785 form) to the `payload.evidenceHash` or `payload.payloadHash`
|
|
100
|
+
its entry signs, or the entry fails `CHAIN_EVIDENCE_BINDING_MISMATCH`.
|
|
101
|
+
`result.evidenceBinding` counts them. An encrypted-mode completion signs a
|
|
102
|
+
hash over a cleartext the export does not carry, so its ciphertext is counted
|
|
103
|
+
as `clientHashed`, not re-bound.
|
|
104
|
+
- **The chain's length**, against the two counts the export states: fewer
|
|
105
|
+
entries than `exportMetadata.expectedEntries` (the position of the record's
|
|
106
|
+
latest checkpoint) fails `CHECKPOINT_ROW_MISSING`, and fewer than
|
|
107
|
+
`exportMetadata.totalEntries` (what the Server wrote) fails
|
|
108
|
+
`CHAIN_POSITION_GAP`. `result.entryCount` reports both, each null when the
|
|
109
|
+
export does not state it. Those counts sit in unsigned metadata, which
|
|
110
|
+
whoever cut the chain can also edit, so pass the count you obtained out of
|
|
111
|
+
band as `expectedEntryCount`: an export carrying a different number of
|
|
112
|
+
entries fails `CHAIN_POSITION_GAP`. `optionalChecks.entry_count` is
|
|
113
|
+
`applied` when any count was held and `skipped_no_input` when none was.
|
|
114
|
+
- **The record id**: `result.recordId` is the id the entries sign, never the
|
|
115
|
+
unsigned `exportMetadata.recordId`. A metadata id that disagrees with what
|
|
116
|
+
the entries sign, or entries that name different records, fails
|
|
117
|
+
`CHAIN_PAYLOAD_BINDING_MISMATCH`.
|
|
118
|
+
- **The format**: an export that does not state `exportFormatVersion` and
|
|
119
|
+
`canonicalization`, or states others than this verifier reads, fails
|
|
120
|
+
`UNSUPPORTED_FORMAT`.
|
|
95
121
|
|
|
96
122
|
The payload, OIDC, attribution and key-window checks run when the export
|
|
97
|
-
carries their inputs, which every current Server does.
|
|
123
|
+
carries their inputs, which every current Server does. Once one entry carries
|
|
124
|
+
its `payload` and `entryType`, or you pass `federationKeys`, an entry without
|
|
125
|
+
them fails `CHAIN_PAYLOAD_BINDING_MISMATCH` and the check reads `not_checked`,
|
|
126
|
+
so deleting them cannot switch a check off. The result's `optionalChecks` says
|
|
98
127
|
which ran, so "not checked" never reads as "passed".
|
|
99
128
|
|
|
129
|
+
### SCITT receipts
|
|
130
|
+
|
|
131
|
+
`verifyAuditExport` does not verify receipts. Verify each Receipt (an export
|
|
132
|
+
taken with `?receipts=true` carries them) by calling
|
|
133
|
+
`verifyReceipt(receiptBytes, signedStatementBytes, transparencyServicePublicKeyBase64)`,
|
|
134
|
+
which returns `'ok'` or the reason it failed.
|
|
135
|
+
|
|
100
136
|
## Anchoring keys
|
|
101
137
|
|
|
102
138
|
A vault key the Server publishes comes from its database, and anything with
|
|
103
139
|
write access to that database can add a key row and entries signed with it.
|
|
104
|
-
What it cannot add
|
|
140
|
+
What it cannot add, unless it also holds the private half of a key you trust,
|
|
141
|
+
is a **key statement**: a COSE_Sign1 signed by a key the
|
|
105
142
|
Server already trusted (and, for a new key, by the new key too). Pass the SPKI
|
|
106
143
|
digest of a vault key you hold or took out of band as `trustAnchors`, and the
|
|
107
144
|
verifier walks the statements from it:
|
|
@@ -125,11 +162,17 @@ statements sign. `keyTrust.status` says whether a pass can be trusted:
|
|
|
125
162
|
- `no_anchored_signature`: the walk ran, but no entry verified under a key it
|
|
126
163
|
anchors, so `optionalChecks.key_anchoring` is `not_checked`. An export of
|
|
127
164
|
entries written before the install began signing passes under any pin, and
|
|
128
|
-
|
|
165
|
+
says nothing about the pin.
|
|
129
166
|
|
|
130
167
|
A pass on `no_anchor` or `no_anchored_signature` is not a trusted verdict; the
|
|
131
168
|
`detail` says so, and `verdict` (and every AGLedger surface) reports it as
|
|
132
|
-
`unanchored`.
|
|
169
|
+
`unanchored`. So is a pinned result that fails only because the pin reaches no
|
|
170
|
+
key in the export at all, as with an export checked against another Server's
|
|
171
|
+
pin: `valid` is false, but the same export verified without the pin passes,
|
|
172
|
+
so nothing in it was tampered with, and the verdict says the pin was not met
|
|
173
|
+
rather than `failed`. Once the pin anchors any key, an entry under a key it
|
|
174
|
+
does not reach is a substitution and the verdict is `failed`.
|
|
175
|
+
`distrustedKeys` without `trustAnchors` throws `TypeError`, since
|
|
133
176
|
nothing would apply them, and so does a pinned key distrusted with no instant,
|
|
134
177
|
which the Server refuses to start with. A pin beside a dated entry
|
|
135
178
|
(`sha256:<hex>@<instant>`) is how a leaked key's history stays verifiable: the
|
|
@@ -188,15 +231,15 @@ no longer trusted and its window no longer graded.
|
|
|
188
231
|
|
|
189
232
|
Statements are walked in the order the Server's database stored them,
|
|
190
233
|
`createdAt` then the row `id`, never by an instant a statement signs. A dump
|
|
191
|
-
carries that order (`created_at`), and so does every key document
|
|
192
|
-
|
|
234
|
+
carries that order (`created_at`), and so does every key document a Server 2.0
|
|
235
|
+
or later serves: each statement in an export's `signingKeyStatements`,
|
|
193
236
|
`/v1/verification-keys` and `/.well-known/agledger-vault-keys.json` carries
|
|
194
237
|
its row `id` and `createdAt` at microsecond precision, and `keyTrust.order`
|
|
195
238
|
reads `written`. A `createdAt` that is not strict RFC 3339 (a `T`, an offset
|
|
196
239
|
or `Z`, a real calendar date) places nothing, and its statement is
|
|
197
240
|
`KEY_STATEMENT_INVALID`. Such a document lists under a trusted key its
|
|
198
241
|
admission, every later admission it signed, and the closures that count for
|
|
199
|
-
it, so a walk over it dates each window and cuts each edge back as the
|
|
242
|
+
it, so a walk over it dates each window and cuts each edge back as the Server
|
|
200
243
|
does. Where it cannot (a later succession whose endorser the document does not
|
|
201
244
|
carry, or a closure by a key it does not list), the walk grades the window
|
|
202
245
|
more loosely than the listed one, and the listed `activatedAt` or `retiredAt`
|
|
@@ -220,14 +263,14 @@ out of a distrusted key never admits a key or keeps one reachable, whatever
|
|
|
220
263
|
time it carries. Such a statement still counts for everything that can only
|
|
221
264
|
narrow trust: it dates its subject's window, cuts the subject's edge back as a
|
|
222
265
|
later admission, and a closure the key signed still ends a window. Where the
|
|
223
|
-
document dates it before the cutoff, so the
|
|
266
|
+
document dates it before the cutoff, so the Server would count it, it is no
|
|
224
267
|
finding: it is listed in `keyTrust.notes`, which never fails a verdict, and an
|
|
225
268
|
honest rotation away from the key passes when you pin its successor. Pinned
|
|
226
269
|
only on the distrusted key, its successor is not anchored. This is narrower
|
|
227
|
-
than the
|
|
270
|
+
than the Server, which holds the key to the time its statements were really
|
|
228
271
|
stored, and never wider. Only
|
|
229
272
|
a dump walk holds a distrusted key's statements to their `created_at`, as the
|
|
230
|
-
|
|
273
|
+
Server does, and that adds assurance only for a dump you took from the Server
|
|
231
274
|
yourself or over a channel you trust; for any other dump it assures no more
|
|
232
275
|
than the stored times its holder chose.
|
|
233
276
|
|
|
@@ -276,17 +319,25 @@ and, once its chains are walked, settles it with
|
|
|
276
319
|
verified: with none, the status becomes `no_anchored_signature`.
|
|
277
320
|
`writtenWhileSigning(rowTime, signingSince)` is the unsigned-row rule for
|
|
278
321
|
checkpoints and read-log rows, and fails closed on a row with no readable time
|
|
279
|
-
once signing began.
|
|
322
|
+
once signing began. `placeInKeyWindow(key, rowTime, 'Checkpoint')` holds a
|
|
323
|
+
vault checkpoint, a read-log leaf or a read-log tree head to the signed window
|
|
324
|
+
of its key by the rule entries are held to (`inside`, `not-yet-active`,
|
|
325
|
+
`expired`, `accounted`, or `unplaceable` when a time cannot be read), and
|
|
326
|
+
`distrustAccounts(key, rowTime)` says whether a `distrustedKeys` entry and the
|
|
327
|
+
trusted retirement account for it. Verify the signature first: an artifact
|
|
328
|
+
that is accounted for is set aside only when its signature verifies under the
|
|
329
|
+
key, and a signature that does not verify is reported ahead of a window
|
|
330
|
+
finding.
|
|
280
331
|
|
|
281
332
|
A dump row repeating an earlier row's signed payload counts once, at its
|
|
282
333
|
first write: a row copied in the database under a new id and time says
|
|
283
|
-
nothing new, as the
|
|
334
|
+
nothing new, as the Server reads it. On a key document a copy stays a second
|
|
284
335
|
statement, since its `createdAt` is the holder's word.
|
|
285
336
|
|
|
286
337
|
On a dump, a `distrustedKeys` key that a key the walk trusts has retired is
|
|
287
338
|
bounded by that retirement (its `DistrustSpan` in `trust.distrustSpans`; only a
|
|
288
|
-
retirement by a key the walk trusts counts, as in the
|
|
289
|
-
what it signed before then is accounted for rather than failed, as the
|
|
339
|
+
retirement by a key the walk trusts counts, as in the Server), and
|
|
340
|
+
what it signed before then is accounted for rather than failed, as the Server's
|
|
290
341
|
scan lists it: a key statement it signed that counts for nothing is listed in
|
|
291
342
|
`trust.accounted` (and the report's `accounted`) instead of `findings`, and a
|
|
292
343
|
chain entry whose signature verifies under it, outside what the key is
|
|
@@ -311,8 +362,8 @@ entries under it are `CHAIN_UNSUPPORTED_ALGORITHM` rather than unanchored.
|
|
|
311
362
|
An agent that authenticates with an ephemeral cert can sign each request body
|
|
312
363
|
it sends. The Server checks that signature, then seals it into the chain entry
|
|
313
364
|
as `predicate.on_behalf_of.agent_signature`, beside the RFC 7638 thumbprint of
|
|
314
|
-
the cert's public key. The envelope signature
|
|
315
|
-
|
|
365
|
+
the cert's public key. The envelope signature covers it as the Server wrote it. To
|
|
366
|
+
check that the agent itself signed, without taking the Server's word for it,
|
|
316
367
|
re-verify the agent signature against the cert's public key.
|
|
317
368
|
|
|
318
369
|
The export does not carry cert public keys. Supply them as the Ed25519 JWK the
|
|
@@ -338,6 +389,72 @@ verify fails `CHAIN_AGENT_SIGNATURE_INVALID`. The check runs only where
|
|
|
338
389
|
`on_behalf_of.validated` is `true`: on a caller-asserted identity the two fields
|
|
339
390
|
may be passthrough from an older Server, and the export cannot tell which.
|
|
340
391
|
|
|
392
|
+
### Messages sealed from a federated peer
|
|
393
|
+
|
|
394
|
+
A receiving Server seals each peer message it accepts on the chain entry it
|
|
395
|
+
writes for it (`payload.wire` on its `FEDERATION_*` entries): the body as the
|
|
396
|
+
peer signed it, the peer's registered key, the hub ids, the body hash, the
|
|
397
|
+
timestamp, the nonce and the signature. Every sealed message is held to its
|
|
398
|
+
body hash and to the entry that carries it (`federation_wire` in
|
|
399
|
+
`optionalChecks`, `applied` once one was seen). Pass the peer's federation key,
|
|
400
|
+
as its operator gives it (base64 SPKI DER or base64 of the raw 32 bytes), to
|
|
401
|
+
also re-verify the peer's signature:
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
import { verifyAuditExport } from '@agledger/verify-core';
|
|
405
|
+
|
|
406
|
+
const result = verifyAuditExport(exportDocument, { federationKeys: { 'hub-b': 'MCowBQYDK2VwAyEA...' } });
|
|
407
|
+
|
|
408
|
+
console.log(result.federationWire); // e.g. { present: 2, verified: 2, failed: 0, afterRetirement: 0 }
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
A peer that changed its federation key signed its earlier messages under the
|
|
412
|
+
earlier key. Pass its key history (`GET /.well-known/agledger-federation-keys.json`
|
|
413
|
+
on the peer, no auth) beside the key you pinned for it, and every key the
|
|
414
|
+
history links to the pin through successions both keys signed is trusted
|
|
415
|
+
inside its window:
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
import { verifyAuditExport, type FederationKeyHistoryDocument } from '@agledger/verify-core';
|
|
419
|
+
|
|
420
|
+
const response = await fetch('https://hub-b.example.com/.well-known/agledger-federation-keys.json');
|
|
421
|
+
const history = (await response.json()) as FederationKeyHistoryDocument;
|
|
422
|
+
|
|
423
|
+
const result = verifyAuditExport(exportDocument, {
|
|
424
|
+
federationKeys: [{ hubId: 'hub-b', publicKey: 'MCowBQYDK2VwAyEA...', history }],
|
|
425
|
+
});
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
The windows come from the signed statements, not the document's `keys`
|
|
429
|
+
summary. Each message is placed by its sealed `wire.timestamp`, which the peer
|
|
430
|
+
signed and the receiver sealed under its own signature, and which comes from
|
|
431
|
+
the peer's clock, the same clock its windows are written by. The entry's
|
|
432
|
+
`createdAt` is not signed, so it places nothing. The timestamp is the signing
|
|
433
|
+
process's clock and the window is the peer's database clock, so each edge
|
|
434
|
+
carries an allowance of 300 seconds (`FEDERATION_KEY_WINDOW_SKEW_MS`), as the
|
|
435
|
+
Server's own receiver guidance gives it. A message signed under a key more
|
|
436
|
+
than that before the key's activation fails. One signed under a key more than
|
|
437
|
+
that after the key's retirement fails `CHAIN_FEDERATION_WIRE_INVALID`, since a
|
|
438
|
+
retired key signing later is also what a leaked key does. Pass
|
|
439
|
+
`allowAfterRetirement: true` for the short gap while a peer's publisher
|
|
440
|
+
restarts onto its new key: such a message then verifies and is counted in
|
|
441
|
+
`federationWire.afterRetirement`. A key behind a genesis that named it only by digest
|
|
442
|
+
(`linked: false`) is not linked to the newer keys; name the hub a second time
|
|
443
|
+
with that key once its operator confirms it. The same goes for a key the
|
|
444
|
+
history does not list at all, such as the key in use before a change made with
|
|
445
|
+
neither predecessor setting: a second entry for the hub pins it, and it is
|
|
446
|
+
trusted on its own. A history that is another hub's, carries a statement that
|
|
447
|
+
does not verify, or lists none of the keys pinned for its hub throws
|
|
448
|
+
`TypeError` before anything is verified. Federation key histories need a Server 2.2 or later on the peer.
|
|
449
|
+
|
|
450
|
+
A sealed signature that does not verify, a sealed key that is not the one
|
|
451
|
+
supplied for that hub, a body that no longer hashes to what was signed, or an
|
|
452
|
+
entry that asserts a state the sealed body does not carry fails
|
|
453
|
+
`CHAIN_FEDERATION_WIRE_INVALID`. The pieces are exported for a caller that
|
|
454
|
+
reads the sealed message itself: `extractFederationWire`,
|
|
455
|
+
`checkFederationWire`, `federationSignInput`, `canonicalizeJson` (RFC 8785)
|
|
456
|
+
and `normalizeFederationKey`.
|
|
457
|
+
|
|
341
458
|
The Server's own chain verification also compares each sealed cert against its
|
|
342
459
|
live cert record (`cert_missing`, `cert_actor_drift`, `cert_window_drift`,
|
|
343
460
|
`cert_expired`). That record is not exported, so those checks have no offline
|
|
@@ -351,12 +468,12 @@ runtime. An active OpenSSL FIPS provider carries no EdDSA, so **an Ed25519
|
|
|
351
468
|
chain cannot be verified on a FIPS-locked host**. ES256 chains can.
|
|
352
469
|
|
|
353
470
|
That is reported as `CHAIN_UNSUPPORTED_ALGORITHM`, never as a signature
|
|
354
|
-
failure. The
|
|
471
|
+
failure. The two are kept apart because "I could not check this" and "I
|
|
355
472
|
checked this and it failed" lead to opposite conclusions, and only one of them
|
|
356
473
|
is grounds for a tamper investigation. The result still fails closed, because
|
|
357
474
|
an unverified chain is not a verified one. To actually verify an Ed25519 chain,
|
|
358
475
|
re-run on a host without the restriction; the export and keys are portable and
|
|
359
|
-
the verification is entirely offline, so
|
|
476
|
+
the verification is entirely offline, so all it needs is a second host.
|
|
360
477
|
|
|
361
478
|
### Asking about an algorithm directly
|
|
362
479
|
|
|
@@ -432,3 +549,5 @@ a key fetched from the Server comes from its database too. Trust is what
|
|
|
432
549
|
## License
|
|
433
550
|
|
|
434
551
|
Proprietary. See [LICENSE](./LICENSE). © AGLedger LLC. All rights reserved.
|
|
552
|
+
|
|
553
|
+
AGLedger is a trademark of AGLedger LLC. All other trademarks are the property of their respective owners. Patent pending.
|
package/dist/audit-export.d.ts
CHANGED
|
@@ -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 (
|
|
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,14 +14,15 @@
|
|
|
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
|
|
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 OptionalCheck, type SignatureOutcome } from './chain.js';
|
|
22
|
+
import { type CheckApplicability, type EvidenceBindingCounts, type OptionalCheck, type SignatureOutcome } from './chain.js';
|
|
23
23
|
import type { FailureCode } from './failures.js';
|
|
24
|
-
import type
|
|
24
|
+
import { type AgentPublicKeyJwk } from './primitives.js';
|
|
25
|
+
import { type FederationKeyEntry } from './federation-wire.js';
|
|
25
26
|
import { type DistrustedKey, type KeyTrustReport, type PublishedKeyStatement, type Verdict } from './key-statements.js';
|
|
26
27
|
/** One entry of a `/audit-export` document. */
|
|
27
28
|
export interface AuditExportEntryInput {
|
|
@@ -35,11 +36,11 @@ export interface AuditExportEntryInput {
|
|
|
35
36
|
* CHAIN_MALFORMED_ENTRY.
|
|
36
37
|
*/
|
|
37
38
|
createdAt?: string | null;
|
|
38
|
-
/** OIDC issuer the actor was synthesized from (
|
|
39
|
+
/** OIDC issuer the actor was synthesized from (Server 0.26 and later). */
|
|
39
40
|
actorOidcIss?: string | null;
|
|
40
|
-
/** OIDC subject the actor was synthesized from (
|
|
41
|
+
/** OIDC subject the actor was synthesized from (Server 0.26 and later). */
|
|
41
42
|
actorOidcSub?: string | null;
|
|
42
|
-
/** Tri-state
|
|
43
|
+
/** Tri-state `actor_oidc_synthesized` marker (Server 0.26 and later). Marker for the OIDC-actor check. */
|
|
43
44
|
actorOidcSynthesized?: boolean | null;
|
|
44
45
|
/**
|
|
45
46
|
* API-key id of the credential that performed this state-change, mirroring
|
|
@@ -55,8 +56,15 @@ export interface AuditExportEntryInput {
|
|
|
55
56
|
recordId?: string | null;
|
|
56
57
|
/** The audit-vault entry type (e.g. `RECORD_CREATED`); drives the binding check's predicate reconstruction. */
|
|
57
58
|
entryType?: string;
|
|
58
|
-
/**
|
|
59
|
+
/** The entry's readable `payload`, a projection of the signed predicate. Present → the binding-integrity check runs (verificationGuide step 4). */
|
|
59
60
|
payload?: Record<string, unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* The evidence body `?evidence=true` inlines: the completion evidence on a
|
|
63
|
+
* COMPLETION_SUBMITTED entry, the filed payload on a DISPUTE_EVIDENCE entry.
|
|
64
|
+
* Unsigned. Present → the evidence-binding check re-hashes it against the
|
|
65
|
+
* signed `payload.evidenceHash` / `payload.payloadHash`.
|
|
66
|
+
*/
|
|
67
|
+
evidence?: Record<string, unknown>;
|
|
60
68
|
integrity: {
|
|
61
69
|
payloadHash: string;
|
|
62
70
|
previousHash: string | null;
|
|
@@ -65,7 +73,7 @@ export interface AuditExportEntryInput {
|
|
|
65
73
|
signingKeyId: string | null;
|
|
66
74
|
};
|
|
67
75
|
}
|
|
68
|
-
/** Per-key activation/retirement window; drives temporal key-validity (
|
|
76
|
+
/** Per-key activation/retirement window; drives temporal key-validity (Server 0.26 and later). */
|
|
69
77
|
export interface SigningKeyWindow {
|
|
70
78
|
activatedAt: string;
|
|
71
79
|
retiredAt: string | null;
|
|
@@ -84,6 +92,14 @@ export interface RecordAuditExportInput {
|
|
|
84
92
|
recordId: string;
|
|
85
93
|
exportFormatVersion?: string;
|
|
86
94
|
canonicalization?: string;
|
|
95
|
+
/** How many entries the Server wrote into this export. */
|
|
96
|
+
totalEntries?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Position of the record's latest signed checkpoint, or null when no
|
|
99
|
+
* checkpoint has been written for it yet. The chain is held to it: fewer
|
|
100
|
+
* entries than this is CHECKPOINT_ROW_MISSING.
|
|
101
|
+
*/
|
|
102
|
+
expectedEntries?: number | null;
|
|
87
103
|
signingPublicKeys?: Record<string, string>;
|
|
88
104
|
/** keyId → activation/retirement window, the values the key statements sign. */
|
|
89
105
|
signingKeyWindows?: Record<string, SigningKeyWindow>;
|
|
@@ -97,7 +113,7 @@ export interface RecordAuditExportInput {
|
|
|
97
113
|
};
|
|
98
114
|
entries: AuditExportEntryInput[];
|
|
99
115
|
/**
|
|
100
|
-
* Self-describing verification guidance the
|
|
116
|
+
* Self-describing verification guidance the Server ships in the export.
|
|
101
117
|
* `unsignedFields` lists per-entry fields that are UNSIGNED display projections
|
|
102
118
|
* (e.g. `actorDisplayName`) resolved at export time, not covered by the COSE_Sign1
|
|
103
119
|
* signature. A PASS does NOT vouch for these labels. The attribution the guide
|
|
@@ -186,15 +202,60 @@ export interface VerifyExportOptions {
|
|
|
186
202
|
* the agent sent to `POST /v1/auth/oidc/cert`, which is also the `cnf.jwk`
|
|
187
203
|
* claim inside the returned `certJws`. The export does not carry them.
|
|
188
204
|
*
|
|
189
|
-
* When an entry's signed payload carries
|
|
205
|
+
* When an entry's signed payload carries a Server-validated
|
|
190
206
|
* `predicate.on_behalf_of.agent_signature` and its sealed cert thumbprint
|
|
191
207
|
* matches one of these keys, the signature is re-verified offline, proving
|
|
192
208
|
* the cert holder signed that request-body hash without trusting the
|
|
193
|
-
*
|
|
209
|
+
* Server's word for it. A key is matched only through the thumbprint the
|
|
194
210
|
* entry signed, so where a key came from does not need to be trusted.
|
|
195
211
|
* Anything that is not an Ed25519 JWK throws `TypeError`.
|
|
196
212
|
*/
|
|
197
213
|
agentKeys?: ReadonlyArray<AgentPublicKeyJwk>;
|
|
214
|
+
/**
|
|
215
|
+
* Federation keys of the Servers this one peers with, keyed by their hub id:
|
|
216
|
+
* `{ [hubId]: publicKey }` or `[{ hubId, publicKey }]`, each key as base64
|
|
217
|
+
* SPKI DER or base64 of the raw 32 bytes, as the peer registered it at
|
|
218
|
+
* handshake. Take them from the peer's operator, not from this Server.
|
|
219
|
+
*
|
|
220
|
+
* A receiving Server's FEDERATION_* entries seal the peer's message as the
|
|
221
|
+
* peer signed it (`payload.wire`). Every sealed message is held to its own
|
|
222
|
+
* body hash and to the entry that carries it; one from a hub listed here also
|
|
223
|
+
* has its signature re-verified under that key, which proves what the peer
|
|
224
|
+
* asserted from this export alone. A failure is
|
|
225
|
+
* CHAIN_FEDERATION_WIRE_INVALID. `result.federationWire` counts how many were
|
|
226
|
+
* present, how many were verified under a key, and how many failed. A key that is not an
|
|
227
|
+
* Ed25519 key throws `TypeError`.
|
|
228
|
+
*
|
|
229
|
+
* After a sender changes its federation key, entries from before the change
|
|
230
|
+
* seal the earlier key. Give the list form an entry's `history`, the
|
|
231
|
+
* sender's `GET /.well-known/agledger-federation-keys.json`, beside the key
|
|
232
|
+
* you pinned: every key the history links to the pin through successions
|
|
233
|
+
* both keys signed is trusted inside its window, placed by the message's
|
|
234
|
+
* signed `wire.timestamp`. A second entry for the hub may pin a key the
|
|
235
|
+
* history does not list, trusted on its own. A history that is another
|
|
236
|
+
* hub's, carries a statement that does not verify, or lists none of the
|
|
237
|
+
* hub's pins throws `TypeError`.
|
|
238
|
+
*/
|
|
239
|
+
federationKeys?: Readonly<Record<string, string>> | ReadonlyArray<FederationKeyEntry>;
|
|
240
|
+
/**
|
|
241
|
+
* Accept a sealed federation message signed by a key its sender's history
|
|
242
|
+
* had already retired (beyond the 300 second clock-skew allowance), counted
|
|
243
|
+
* in `federationWire.afterRetirement`. For the short gap while a sender's
|
|
244
|
+
* publisher restarts onto its new key. Without it such a message fails
|
|
245
|
+
* CHAIN_FEDERATION_WIRE_INVALID, since a retired key signing later is also
|
|
246
|
+
* what a leaked key does.
|
|
247
|
+
*/
|
|
248
|
+
allowAfterRetirement?: boolean;
|
|
249
|
+
/**
|
|
250
|
+
* The number of entries the record's chain holds, obtained out of band (the
|
|
251
|
+
* operator's statement, or your own count when you took the export). The
|
|
252
|
+
* count the export states about itself sits in unsigned metadata, which
|
|
253
|
+
* whoever removed entries can also remove; this one cannot be edited from
|
|
254
|
+
* the document. An export carrying a different number of entries fails
|
|
255
|
+
* CHAIN_POSITION_GAP. A non-negative integer: anything else throws
|
|
256
|
+
* `TypeError`.
|
|
257
|
+
*/
|
|
258
|
+
expectedEntryCount?: number;
|
|
198
259
|
}
|
|
199
260
|
export interface EntryVerificationResult {
|
|
200
261
|
position: number;
|
|
@@ -203,6 +264,13 @@ export interface EntryVerificationResult {
|
|
|
203
264
|
detail?: string;
|
|
204
265
|
signature?: SignatureOutcome['state'];
|
|
205
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* The checks `optionalChecks` reports on an export: the chain's, and
|
|
269
|
+
* `entry_count`, which is `applied` when the chain's length was held to a
|
|
270
|
+
* count (the export's own `expectedEntries` / `totalEntries`, or the
|
|
271
|
+
* `expectedEntryCount` option) and `skipped_no_input` when none was given.
|
|
272
|
+
*/
|
|
273
|
+
export type ExportOptionalCheck = OptionalCheck | 'entry_count';
|
|
206
274
|
export interface VerifyExportResult {
|
|
207
275
|
valid: boolean;
|
|
208
276
|
totalEntries: number;
|
|
@@ -227,17 +295,20 @@ export interface VerifyExportResult {
|
|
|
227
295
|
* `actorId` / `actorRole` / `actorOwnerId` columns and the envelope carries
|
|
228
296
|
* the signed actor claim, which is every current export.
|
|
229
297
|
* - `payload_binding`, `oidc_actor` and `key_temporal` flip to `applied`
|
|
230
|
-
* when the export wire carries their inputs (
|
|
298
|
+
* when the export wire carries their inputs (Server >= v0.26.x: per-entry
|
|
231
299
|
* `payload` + `entryType`, `actorOidcSynthesized`, `createdAt`, and
|
|
232
300
|
* `signingKeyWindows` in exportMetadata). Older exports without those
|
|
233
301
|
* fields stay `skipped_no_input`.
|
|
234
302
|
* - `agent_signature` is `applied` only when `agentKeys` supplied the cert
|
|
235
|
-
* key for at least one
|
|
303
|
+
* key for at least one Server-validated agent signature on the chain.
|
|
304
|
+
* - `entry_count` is `applied` when the chain's length was held to a stated
|
|
305
|
+
* or supplied count, and `skipped_no_input` when the export states none
|
|
306
|
+
* and `expectedEntryCount` was not given.
|
|
236
307
|
*
|
|
237
308
|
* The applicability is surfaced so a caller never mistakes "not checked
|
|
238
309
|
* here" for "checked and passed".
|
|
239
310
|
*/
|
|
240
|
-
optionalChecks: Record<
|
|
311
|
+
optionalChecks: Record<ExportOptionalCheck, CheckApplicability>;
|
|
241
312
|
/**
|
|
242
313
|
* How many signature checks resolved against supplied vs export-embedded
|
|
243
314
|
* keys. Provenance only; whether a key is trusted is `keyTrust`.
|
|
@@ -271,10 +342,47 @@ export interface VerifyExportResult {
|
|
|
271
342
|
present: number;
|
|
272
343
|
verified: number;
|
|
273
344
|
};
|
|
345
|
+
/**
|
|
346
|
+
* Federation messages sealed on the chain (`payload.wire`) vs re-verified
|
|
347
|
+
* under a `federationKeys` entry for their sender. Every present one held
|
|
348
|
+
* to its body hash and to its entry; `failed` counts those that failed a
|
|
349
|
+
* check, and `present - verified - failed` is the ones from a hub with no
|
|
350
|
+
* key supplied. `afterRetirement` counts verified ones sealed under a key
|
|
351
|
+
* the sender's history retired before the sender signed the message.
|
|
352
|
+
*/
|
|
353
|
+
federationWire: {
|
|
354
|
+
present: number;
|
|
355
|
+
verified: number;
|
|
356
|
+
failed: number;
|
|
357
|
+
afterRetirement: number;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Inlined evidence bodies (`?evidence=true`) vs re-bound to the hash their
|
|
361
|
+
* entry signs. A body that does not hash to it fails
|
|
362
|
+
* CHAIN_EVIDENCE_BINDING_MISMATCH; `clientHashed` counts encrypted-mode
|
|
363
|
+
* completions, whose signed hash covers a cleartext the export does not
|
|
364
|
+
* carry. See `ChainResult.evidenceBinding`.
|
|
365
|
+
*/
|
|
366
|
+
evidenceBinding: EvidenceBindingCounts;
|
|
367
|
+
/**
|
|
368
|
+
* The entry counts the export states, which the chain is held to.
|
|
369
|
+
* `expectedEntries` is the position of the record's latest checkpoint
|
|
370
|
+
* (null when the export names none) and `statedEntries` the number of
|
|
371
|
+
* entries the Server wrote into the export (null when it does not say).
|
|
372
|
+
* Fewer entries than `expectedEntries` fails CHECKPOINT_ROW_MISSING, and
|
|
373
|
+
* fewer than `statedEntries` fails CHAIN_POSITION_GAP. With both null the
|
|
374
|
+
* entry count is the file's own and is held to nothing.
|
|
375
|
+
*/
|
|
376
|
+
entryCount: {
|
|
377
|
+
expectedEntries: number | null;
|
|
378
|
+
statedEntries: number | null;
|
|
379
|
+
};
|
|
274
380
|
/**
|
|
275
381
|
* `trusted`, `unanchored` or `failed` (see `Verdict`). Read this rather
|
|
276
382
|
* than `valid` alone: a valid result with no `trustAnchors`, or none that
|
|
277
|
-
* anchored a signature, is `unanchored`, which is not a trusted verdict.
|
|
383
|
+
* anchored a signature, is `unanchored`, which is not a trusted verdict. So
|
|
384
|
+
* is a pinned result that failed only because the pin anchored no signature
|
|
385
|
+
* (`valid: false`; see `verdictOf`).
|
|
278
386
|
*/
|
|
279
387
|
verdict: Verdict;
|
|
280
388
|
}
|