@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.
- package/LICENSE +18 -18
- package/README.md +869 -53
- package/dist/acknowledgements.d.ts +32 -0
- package/dist/acknowledgements.js +88 -0
- package/dist/anchors.d.ts +349 -0
- package/dist/anchors.js +654 -0
- package/dist/attestation.d.ts +98 -0
- package/dist/attestation.js +145 -0
- package/dist/audit-export.d.ts +404 -29
- package/dist/audit-export.js +547 -28
- package/dist/batch-head.d.ts +28 -0
- package/dist/batch-head.js +169 -0
- package/dist/batch.d.ts +69 -0
- package/dist/batch.js +99 -0
- package/dist/bulk-export.d.ts +161 -0
- package/dist/bulk-export.js +711 -0
- package/dist/cbor-strict.d.ts +9 -0
- package/dist/cbor-strict.js +14 -0
- package/dist/chain.d.ts +221 -31
- package/dist/chain.js +339 -65
- package/dist/claim.d.ts +23 -0
- package/dist/claim.js +100 -0
- package/dist/export-anchors.d.ts +84 -0
- package/dist/export-anchors.js +109 -0
- package/dist/export-evidence.d.ts +90 -0
- package/dist/export-evidence.js +186 -0
- package/dist/export-pages.d.ts +476 -0
- package/dist/export-pages.js +586 -0
- package/dist/failures.d.ts +44 -26
- package/dist/failures.js +81 -31
- package/dist/federation-wire.d.ts +106 -20
- package/dist/federation-wire.js +286 -76
- package/dist/history-seal.d.ts +100 -0
- package/dist/history-seal.js +301 -0
- package/dist/index.d.ts +37 -9
- package/dist/index.js +18 -5
- package/dist/instant.d.ts +1 -1
- package/dist/instant.js +1 -1
- package/dist/key-statements.d.ts +160 -11
- package/dist/key-statements.js +261 -60
- package/dist/ml-dsa-kats.d.ts +18 -0
- package/dist/ml-dsa-kats.js +241 -0
- package/dist/options.js +4 -4
- package/dist/primitives.d.ts +287 -47
- package/dist/primitives.js +673 -101
- package/dist/read-log.d.ts +350 -0
- package/dist/read-log.js +816 -0
- package/dist/schema-chain-export.d.ts +82 -0
- package/dist/schema-chain-export.js +474 -0
- package/dist/walk-anchors.d.ts +115 -0
- package/dist/walk-anchors.js +133 -0
- package/dist/walk-checkpoints.d.ts +125 -0
- package/dist/walk-checkpoints.js +118 -0
- package/package.json +9 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DecodeOptions } from 'cborg';
|
|
2
|
+
/**
|
|
3
|
+
* Decode options for every CBOR value this package reads. The signed bytes
|
|
4
|
+
* are deterministic CBOR (RFC 8949 section 4.2.1), so anything a conforming
|
|
5
|
+
* encoder would not emit is refused rather than tolerated: duplicate map
|
|
6
|
+
* keys (two readers could take different values), non-minimal integer and
|
|
7
|
+
* length encodings, indefinite lengths, `undefined`, and invalid UTF-8.
|
|
8
|
+
*/
|
|
9
|
+
export declare const STRICT_CBOR_DECODE: Pick<DecodeOptions, 'strict' | 'allowIndefinite' | 'allowUndefined' | 'rejectDuplicateMapKeys' | 'rejectInvalidUtf8'>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode options for every CBOR value this package reads. The signed bytes
|
|
3
|
+
* are deterministic CBOR (RFC 8949 section 4.2.1), so anything a conforming
|
|
4
|
+
* encoder would not emit is refused rather than tolerated: duplicate map
|
|
5
|
+
* keys (two readers could take different values), non-minimal integer and
|
|
6
|
+
* length encodings, indefinite lengths, `undefined`, and invalid UTF-8.
|
|
7
|
+
*/
|
|
8
|
+
export const STRICT_CBOR_DECODE = {
|
|
9
|
+
strict: true,
|
|
10
|
+
allowIndefinite: false,
|
|
11
|
+
allowUndefined: false,
|
|
12
|
+
rejectDuplicateMapKeys: true,
|
|
13
|
+
rejectInvalidUtf8: true,
|
|
14
|
+
};
|
package/dist/chain.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* inputs): binding-integrity, OIDC-actor cross-check, temporal
|
|
20
20
|
* key-validity, the agent-signature re-check, and key anchoring (a
|
|
21
21
|
* registry marked by `applyKeyTrust`). The first three run on
|
|
22
|
-
* the dump and on any export from
|
|
22
|
+
* the dump and on any export from a Server that ships the row fields
|
|
23
23
|
* (>= v0.26.x). The agent-signature check needs the cert's public key,
|
|
24
24
|
* which neither surface carries, so it runs only when the caller passes
|
|
25
25
|
* `agentKeys`. A check without its input is reported `skipped_no_input`,
|
|
@@ -29,13 +29,15 @@
|
|
|
29
29
|
* branch comes LAST, after the binding/OIDC checks, so a row written without a
|
|
30
30
|
* signing key is still subject to every structural check, and a tamper finding
|
|
31
31
|
* on it is reported under its own code rather than as CHAIN_ENTRY_UNSIGNED.
|
|
32
|
-
* That branch grades the entry the way the
|
|
32
|
+
* That branch grades the entry the way the Server does: an unsigned entry
|
|
33
33
|
* after a signed one in its chain, or written at or after the earliest key
|
|
34
34
|
* activation (`signingSince`), is CHAIN_ENTRY_UNSIGNED; an earlier one is a
|
|
35
35
|
* `skipped` signature, reduced coverage rather than a break.
|
|
36
36
|
*/
|
|
37
37
|
import { type AgentPublicKeyJwk } from './primitives.js';
|
|
38
38
|
import { type FederationKeyRegistry } from './federation-wire.js';
|
|
39
|
+
import { type BatchHeadRegistry, type BatchProofInput } from './batch.js';
|
|
40
|
+
import { type HistorySealPlan, type HistorySealProofInput } from './history-seal.js';
|
|
39
41
|
import type { FailureCode } from './failures.js';
|
|
40
42
|
/**
|
|
41
43
|
* Where a verification key came from. `supplied`: the caller passed it (from
|
|
@@ -58,18 +60,18 @@ export type KeyTrustState = 'anchored' | 'unanchored' | 'undecided';
|
|
|
58
60
|
/** A public key the walk can verify signatures against. */
|
|
59
61
|
export interface VerificationKey {
|
|
60
62
|
keyId: string;
|
|
61
|
-
/** SPKI DER, base64-encoded (the
|
|
63
|
+
/** SPKI DER, base64-encoded (the shape the Server's key registry publishes). */
|
|
62
64
|
spkiBase64: string;
|
|
63
65
|
/**
|
|
64
66
|
* `supplied` = passed by the caller. `embedded` = shipped inside the
|
|
65
|
-
* artifact being verified (the export or dump the
|
|
67
|
+
* artifact being verified (the export or dump the Server produced). Surfaced
|
|
66
68
|
* in the result so a caller can tell whether it verified against a key it
|
|
67
69
|
* brought or against the artifact's own answer key.
|
|
68
70
|
*/
|
|
69
71
|
source: KeySource;
|
|
70
72
|
/**
|
|
71
|
-
* Algorithm the key registry DECLARES for this key (the
|
|
72
|
-
*
|
|
73
|
+
* Algorithm the key registry DECLARES for this key (the Server's
|
|
74
|
+
* registry algorithm field), when the input surface carries it.
|
|
73
75
|
* Cross-checked against the algorithm the SPKI key material actually commits
|
|
74
76
|
* to: a divergence means the registry row lies about its own key and fails
|
|
75
77
|
* CHAIN_ALG_MISMATCH. The declared string never selects the verification
|
|
@@ -116,18 +118,28 @@ export type KeyRegistry = ReadonlyMap<string, VerificationKey>;
|
|
|
116
118
|
export declare function buildKeyRegistry(keys: readonly VerificationKey[]): KeyRegistry;
|
|
117
119
|
/**
|
|
118
120
|
* Agent cert keys for the agent-signature check, indexed by the RFC 7638
|
|
119
|
-
* thumbprint (`sha256:<hex>`) the
|
|
121
|
+
* thumbprint (`sha256:<hex>`) the Server seals as
|
|
120
122
|
* `predicate.on_behalf_of.cert.thumbprint`. Values are SPKI DER, base64.
|
|
121
123
|
*/
|
|
122
124
|
export type AgentKeyRegistry = ReadonlyMap<string, string>;
|
|
125
|
+
/**
|
|
126
|
+
* An agent cert key as an agent records it: the JWK under `publicKeyJwk`,
|
|
127
|
+
* beside whatever else the record keeps (`certId`, `agentId`). Only the JWK is
|
|
128
|
+
* read.
|
|
129
|
+
*/
|
|
130
|
+
export interface AgentKeyEntry {
|
|
131
|
+
publicKeyJwk: AgentPublicKeyJwk;
|
|
132
|
+
[field: string]: unknown;
|
|
133
|
+
}
|
|
123
134
|
/**
|
|
124
135
|
* Index caller-supplied agent cert keys by thumbprint. A key is matched to an
|
|
125
136
|
* entry only through the thumbprint that entry signed, so a key supplied for
|
|
126
137
|
* the wrong cert is never checked against it: it simply matches nothing.
|
|
127
138
|
* That is also why the source of a key needs no trust: the signed thumbprint
|
|
128
|
-
* is what binds it. Throws `TypeError` on anything that is not an
|
|
139
|
+
* is what binds it. Throws `TypeError` on anything that is not an agent cert
|
|
140
|
+
* key JWK (see `AgentPublicKeyJwk`).
|
|
129
141
|
*/
|
|
130
|
-
export declare function buildAgentKeyRegistry(jwks:
|
|
142
|
+
export declare function buildAgentKeyRegistry(jwks: ReadonlyArray<AgentPublicKeyJwk | AgentKeyEntry>): AgentKeyRegistry;
|
|
131
143
|
/** One chain entry, plus the inputs the input-gated checks consume when the surface carries them. */
|
|
132
144
|
export interface NormalizedEntry {
|
|
133
145
|
/** Identity for messages: recordId (export) or chainKey (dump). */
|
|
@@ -140,7 +152,7 @@ export interface NormalizedEntry {
|
|
|
140
152
|
signingKeyId: string | null;
|
|
141
153
|
/**
|
|
142
154
|
* ISO-8601 write time, for temporal key-validity and the unsigned-entry
|
|
143
|
-
* rule. The
|
|
155
|
+
* rule. The Server writes one on every entry, so wherever the walk needs it
|
|
144
156
|
* (the entry's key carries a window, or the entry is unsigned and the key
|
|
145
157
|
* set dates the start of signing) a missing or unparseable value fails
|
|
146
158
|
* CHAIN_MALFORMED_ENTRY rather than skipping the check.
|
|
@@ -151,7 +163,36 @@ export interface NormalizedEntry {
|
|
|
151
163
|
recordId: string | null;
|
|
152
164
|
entryType: string;
|
|
153
165
|
payload: Record<string, unknown>;
|
|
166
|
+
/**
|
|
167
|
+
* True when `payload` is a projection that carries every envelope
|
|
168
|
+
* extension the entry signed, as an export entry's does: the Server
|
|
169
|
+
* writes `on_behalf_of` and `traceparent` into it from the signed
|
|
170
|
+
* predicate. Then a signed extension missing from `payload` is a
|
|
171
|
+
* mismatch. A vault row's payload never holds them, so the dump path
|
|
172
|
+
* leaves this unset.
|
|
173
|
+
*/
|
|
174
|
+
extensionsProjected?: boolean;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Set on an entry that lacks the `binding` inputs where the walk needs them
|
|
178
|
+
* (a sibling carries them, or the caller supplied federation keys), with
|
|
179
|
+
* what is missing. The entry then fails CHAIN_PAYLOAD_BINDING_MISMATCH
|
|
180
|
+
* rather than reading as an entry with nothing to check.
|
|
181
|
+
*/
|
|
182
|
+
bindingRequired?: {
|
|
183
|
+
detail: string;
|
|
184
|
+
federationWire: boolean;
|
|
154
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* The read time this entry is judged against when it carries the batch
|
|
188
|
+
* marker and no inclusion proof, as `batchPendingSince` is for the whole
|
|
189
|
+
* walk: set on an entry of a page walk, from the read time of the page it
|
|
190
|
+
* was served on. Present (a string or null), it takes the place of
|
|
191
|
+
* `batchPendingSince` for this entry; null reads as nothing dating it.
|
|
192
|
+
* Throws `TypeError` from `verifyChain` when it is a string that does not
|
|
193
|
+
* parse.
|
|
194
|
+
*/
|
|
195
|
+
batchPendingSince?: string | null;
|
|
155
196
|
/** Inputs for the OIDC-actor cross-check (dump path). */
|
|
156
197
|
oidcActor?: {
|
|
157
198
|
iss: string | null;
|
|
@@ -178,14 +219,27 @@ export interface NormalizedEntry {
|
|
|
178
219
|
inlinedEvidence?: {
|
|
179
220
|
value: unknown;
|
|
180
221
|
};
|
|
222
|
+
/**
|
|
223
|
+
* The inclusion proof the artifact carries for an entry written under the
|
|
224
|
+
* batched signing cadence (an export's `integrity.batch`, a dump's
|
|
225
|
+
* `vault_batch_leaves.ndjson` row). Read only on an entry whose protected
|
|
226
|
+
* header carries the batch marker.
|
|
227
|
+
*/
|
|
228
|
+
batch?: BatchProofInput | null;
|
|
229
|
+
/**
|
|
230
|
+
* The chain key a batch leaf names for this entry's chain: the record id on
|
|
231
|
+
* a record chain, the schema chain's checkpoint key on a schema chain. When
|
|
232
|
+
* absent, `scopeId` is used, which is right for a record export.
|
|
233
|
+
*/
|
|
234
|
+
batchChainKey?: string;
|
|
181
235
|
}
|
|
182
236
|
/**
|
|
183
237
|
* Checks that run only when their input is present. `agent_signature` is
|
|
184
|
-
* applied when at least one entry carrying
|
|
238
|
+
* applied when at least one entry carrying a Server-validated agent signature
|
|
185
239
|
* had its cert key supplied by the caller (`agentKeys`); neither the export
|
|
186
240
|
* nor the dump carries cert public keys.
|
|
187
241
|
*/
|
|
188
|
-
export type OptionalCheck = 'payload_binding' | 'oidc_actor' | 'actor_attribution' | 'key_temporal' | 'agent_signature' | 'key_anchoring' | 'federation_wire' | 'evidence_binding';
|
|
242
|
+
export type OptionalCheck = 'payload_binding' | 'oidc_actor' | 'actor_attribution' | 'key_temporal' | 'agent_signature' | 'key_anchoring' | 'federation_wire' | 'evidence_binding' | 'history_seal';
|
|
189
243
|
/**
|
|
190
244
|
* `applied`: the check ran. `skipped_no_input`: the input it needs is absent.
|
|
191
245
|
* `not_checked`: the input was given but no entry reached the check, because
|
|
@@ -197,9 +251,9 @@ export interface SignatureOutcome {
|
|
|
197
251
|
/**
|
|
198
252
|
* - `ok` / `invalid` / `decode-fail`: the signature was checked (and passed,
|
|
199
253
|
* failed, or the envelope would not decode).
|
|
200
|
-
* - `unsigned`:
|
|
201
|
-
*
|
|
202
|
-
* `invalid` (CHAIN_SIGNATURE_INVALID), as the
|
|
254
|
+
* - `unsigned`: kept for type compatibility; `verifyChain` does not
|
|
255
|
+
* produce it. An all-zero signature on an entry that names a key is
|
|
256
|
+
* `invalid` (CHAIN_SIGNATURE_INVALID), as the Server grades it.
|
|
203
257
|
* - `skipped`: the chain is intact but this entry has no signing key, so the
|
|
204
258
|
* signature check was deliberately not run. Only an entry written before
|
|
205
259
|
* the install began signing gets here: before any signed entry in its
|
|
@@ -211,15 +265,22 @@ export interface SignatureOutcome {
|
|
|
211
265
|
* - `unsupported`: the signature could not be computed at all, either
|
|
212
266
|
* because this build does not implement the algorithm or because the host
|
|
213
267
|
* runtime refused it (an active OpenSSL FIPS provider carries no EdDSA).
|
|
214
|
-
* CHAIN_UNSUPPORTED_ALGORITHM.
|
|
215
|
-
*
|
|
216
|
-
*
|
|
268
|
+
* CHAIN_UNSUPPORTED_ALGORITHM. Never a benign skip and never a pass: the
|
|
269
|
+
* entry is not verified and the result is not valid. Never tamper
|
|
270
|
+
* evidence either: distinguishing it from `invalid` is the whole point,
|
|
271
|
+
* since only `invalid` means a signature was checked and failed. A result
|
|
272
|
+
* that would be valid had the checks this host refused, under algorithms
|
|
273
|
+
* this build supports, verified reads `unverifiable`, not `failed` (see
|
|
274
|
+
* `isUnverifiable`).
|
|
275
|
+
* - `pending`: the entry was written under the batched signing cadence and
|
|
276
|
+
* no batch head covers it yet, inside the time the Server lets one wait.
|
|
277
|
+
* Nothing signs it so far. Not a failure and not a verified signature.
|
|
217
278
|
* - `accounted`: the signature verifies under a key `distrustedKeys` names,
|
|
218
279
|
* outside what the key is trusted for, and the entry was written before a
|
|
219
280
|
* key the walk trusts retired it (dumps only). Not a failure and not a
|
|
220
281
|
* verified entry: see {@link AccountedEntry}.
|
|
221
282
|
*/
|
|
222
|
-
state: 'ok' | 'invalid' | 'unsigned' | 'skipped' | 'not-checked' | 'decode-fail' | 'unsupported' | 'accounted';
|
|
283
|
+
state: 'ok' | 'invalid' | 'unsigned' | 'skipped' | 'not-checked' | 'decode-fail' | 'unsupported' | 'accounted' | 'pending';
|
|
223
284
|
/** Provenance of the key the signature was checked against ('ok' / 'invalid'). */
|
|
224
285
|
keySource?: KeySource;
|
|
225
286
|
}
|
|
@@ -238,6 +299,15 @@ export interface ChainEntryResult {
|
|
|
238
299
|
};
|
|
239
300
|
signature: SignatureOutcome['state'];
|
|
240
301
|
keySource?: KeySource;
|
|
302
|
+
/** True on an entry signed through a batch head rather than by its own signature. */
|
|
303
|
+
batched?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* On an entry an Ed25519, ES256 or ES384 key signed, when the walk trusts an
|
|
306
|
+
* ML-DSA key: `sealed` when it sits at or below its chain's leaf in the
|
|
307
|
+
* history seal covering that key, `unsealed` when no seal covers the key.
|
|
308
|
+
* An unsealed entry is valid and rests on its classical signature alone.
|
|
309
|
+
*/
|
|
310
|
+
historySeal?: 'sealed' | 'unsealed';
|
|
241
311
|
}
|
|
242
312
|
/** The code an {@link AccountedEntry} carries. Not a {@link FailureCode}: it never fails a verdict. */
|
|
243
313
|
export declare const ACCOUNTED_ENTRY_CODE = "CHAIN_SIGNED_BY_DISTRUSTED_KEY";
|
|
@@ -247,13 +317,13 @@ export type AccountedEntryCode = typeof ACCOUNTED_ENTRY_CODE;
|
|
|
247
317
|
* `distrustedKeys` names, that falls outside what the key is trusted for
|
|
248
318
|
* (the key is unanchored, or the entry was written at or after its cutoff),
|
|
249
319
|
* and that was written before a key the walk trusts retired it. The distrust
|
|
250
|
-
* entry and that retirement account for it, as the
|
|
320
|
+
* entry and that retirement account for it, as the Server's scan lists it in
|
|
251
321
|
* `distrustedEntries`: it is listed, it is not verified, and it fails
|
|
252
322
|
* nothing. An entry written after that retirement, or under a distrusted key
|
|
253
323
|
* no trusted key has retired, fails as before (CHAIN_SIGNING_KEY_UNANCHORED
|
|
254
324
|
* or CHAIN_KEY_EXPIRED). An audit export never carries one.
|
|
255
325
|
*
|
|
256
|
-
* `chain` and `recordId`/`orgId` name the chain as the
|
|
326
|
+
* `chain` and `recordId`/`orgId` name the chain as the Server does: a record
|
|
257
327
|
* chain by its record id, the platform-ops chain (record id
|
|
258
328
|
* 00000000-0000-0000-0000-000000000000) as `admin`, and an org's schema chain
|
|
259
329
|
* (`schema:<orgId>`, `schema:__platform__` for the platform's) as `schema`.
|
|
@@ -275,6 +345,11 @@ export interface ChainResult {
|
|
|
275
345
|
scopeId: string;
|
|
276
346
|
valid: boolean;
|
|
277
347
|
totalEntries: number;
|
|
348
|
+
/**
|
|
349
|
+
* Entries that passed every check. A batched entry no head covers yet
|
|
350
|
+
* (`signature: 'pending'`) is not one: it counts toward `valid` and in
|
|
351
|
+
* `signatureCoverage.pending`, and not here.
|
|
352
|
+
*/
|
|
278
353
|
verifiedEntries: number;
|
|
279
354
|
brokenAt?: {
|
|
280
355
|
position: number;
|
|
@@ -288,12 +363,7 @@ export interface ChainResult {
|
|
|
288
363
|
* or `signatureCoverage.signed`.
|
|
289
364
|
*/
|
|
290
365
|
accounted: AccountedEntry[];
|
|
291
|
-
signatureCoverage:
|
|
292
|
-
signed: number;
|
|
293
|
-
unsigned: number;
|
|
294
|
-
skipped: number;
|
|
295
|
-
total: number;
|
|
296
|
-
};
|
|
366
|
+
signatureCoverage: SignatureCoverage;
|
|
297
367
|
/** Which input-gated checks actually ran on this chain vs were skipped for absent input. */
|
|
298
368
|
optionalChecks: Record<OptionalCheck, CheckApplicability>;
|
|
299
369
|
/** How many signature checks resolved against supplied vs embedded keys. */
|
|
@@ -346,6 +416,23 @@ export interface ChainResult {
|
|
|
346
416
|
* nothing signed binds a body. Always zero on a dump, which carries none.
|
|
347
417
|
*/
|
|
348
418
|
evidenceBinding: EvidenceBindingCounts;
|
|
419
|
+
/** How entries classical keys signed stand against the artifact's history seals; all zero when no seal policy applies. */
|
|
420
|
+
historySeal: HistorySealCounts;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* How many entries carried a verified signature (`signed`), none by design
|
|
424
|
+
* (`skipped`: written before the install began signing), or none yet
|
|
425
|
+
* (`pending`: a batched entry still waiting for its batch head). `batched`
|
|
426
|
+
* counts the `signed` entries that are signed through a batch head rather
|
|
427
|
+
* than by a signature of their own.
|
|
428
|
+
*/
|
|
429
|
+
export interface SignatureCoverage {
|
|
430
|
+
signed: number;
|
|
431
|
+
unsigned: number;
|
|
432
|
+
skipped: number;
|
|
433
|
+
total: number;
|
|
434
|
+
pending: number;
|
|
435
|
+
batched: number;
|
|
349
436
|
}
|
|
350
437
|
/** See {@link ChainResult.evidenceBinding}. */
|
|
351
438
|
export interface EvidenceBindingCounts {
|
|
@@ -367,7 +454,7 @@ export interface VerifyChainOptions {
|
|
|
367
454
|
requireSuppliedKeys?: boolean;
|
|
368
455
|
/**
|
|
369
456
|
* Agent cert keys (see `buildAgentKeyRegistry`). When an entry's signed
|
|
370
|
-
* payload carries
|
|
457
|
+
* payload carries a Server-validated `on_behalf_of.agent_signature` and its
|
|
371
458
|
* sealed cert thumbprint matches a key here, the signature is re-verified
|
|
372
459
|
* offline; a failure is CHAIN_AGENT_SIGNATURE_INVALID.
|
|
373
460
|
*/
|
|
@@ -380,6 +467,14 @@ export interface VerifyChainOptions {
|
|
|
380
467
|
* the sealed body are checked on every sealed message, with or without a key.
|
|
381
468
|
*/
|
|
382
469
|
federationKeys?: FederationKeyRegistry;
|
|
470
|
+
/**
|
|
471
|
+
* Accept a sealed federation message signed by a key its sender's history
|
|
472
|
+
* had retired before the message was signed (beyond the clock-skew
|
|
473
|
+
* allowance), counting it in `federationWire.afterRetirement`. For the short
|
|
474
|
+
* gap while a publisher restarts onto its new key. Without it such a
|
|
475
|
+
* message fails CHAIN_FEDERATION_WIRE_INVALID.
|
|
476
|
+
*/
|
|
477
|
+
allowAfterRetirement?: boolean;
|
|
383
478
|
/**
|
|
384
479
|
* The instant this install began signing: the earliest `activatedAt` across
|
|
385
480
|
* its whole signing key set, retired keys included. An entry with a null
|
|
@@ -395,13 +490,55 @@ export interface VerifyChainOptions {
|
|
|
395
490
|
* switching the check off.
|
|
396
491
|
*/
|
|
397
492
|
signingSince?: string | null;
|
|
493
|
+
/**
|
|
494
|
+
* The artifact's batch heads, judged (see `buildBatchHeadRegistry`). An
|
|
495
|
+
* entry carrying the batch marker is verified through its inclusion proof
|
|
496
|
+
* and the head it names here.
|
|
497
|
+
*/
|
|
498
|
+
batchHeads?: BatchHeadRegistry;
|
|
499
|
+
/**
|
|
500
|
+
* The instant from which a batched entry with no inclusion proof is still
|
|
501
|
+
* inside the time the Server lets it wait for a head: the instant the
|
|
502
|
+
* artifact was cut, less `BATCH_PENDING_GRACE_SECONDS`. An unattested entry
|
|
503
|
+
* written at or after it is `pending`; one written before it, or when this
|
|
504
|
+
* is absent or null, fails BATCH_UNATTESTED. Throws `TypeError` when it is
|
|
505
|
+
* a string that does not parse.
|
|
506
|
+
*/
|
|
507
|
+
batchPendingSince?: string | null;
|
|
508
|
+
/**
|
|
509
|
+
* The artifact's history seals, judged (see `planHistorySeals`). With it,
|
|
510
|
+
* every entry a classical key signed is held to the seal covering that key.
|
|
511
|
+
*/
|
|
512
|
+
historySeals?: HistorySealPlan;
|
|
513
|
+
/**
|
|
514
|
+
* This chain's inclusion proof in each seal, by seal id (lowercase); null or
|
|
515
|
+
* absent where the seal has no leaf for the chain.
|
|
516
|
+
*/
|
|
517
|
+
historySealProofs?: ReadonlyMap<string, HistorySealProofInput | null>;
|
|
518
|
+
/**
|
|
519
|
+
* Walk the entries as a run of positions inside a longer chain rather than
|
|
520
|
+
* as the whole chain: the first entry is expected at `startPosition` and
|
|
521
|
+
* links to `previousHash`, the hash of the entry before it, which the
|
|
522
|
+
* artifact does not carry. Every entry is held to the same checks as on a
|
|
523
|
+
* whole chain; what lies below `startPosition` is not examined. A run that
|
|
524
|
+
* starts above position 1 with a null `previousHash` fails its first entry
|
|
525
|
+
* CHAIN_LINK_BROKEN. `openEnd` says the artifact does not establish the
|
|
526
|
+
* chain's tip, so a history seal whose sealed position lies above the last
|
|
527
|
+
* entry is not compared with an entry. Omitted, the chain starts at
|
|
528
|
+
* position 1 and its last entry is its tip.
|
|
529
|
+
*/
|
|
530
|
+
slice?: {
|
|
531
|
+
startPosition: number;
|
|
532
|
+
previousHash: string | null;
|
|
533
|
+
openEnd?: boolean;
|
|
534
|
+
};
|
|
398
535
|
}
|
|
399
536
|
/**
|
|
400
537
|
* The earliest `activatedAt` among `keys`, as the ISO string it was given in,
|
|
401
538
|
* or `null` when no key carries a parseable one. This is the instant from
|
|
402
|
-
* which the
|
|
539
|
+
* which the Server treats every chain entry and checkpoint as required to be
|
|
403
540
|
* signed; pass every key the verifier knows, retired ones included, since the
|
|
404
|
-
*
|
|
541
|
+
* Server reads it as `min(activated_at)` over its whole key registry.
|
|
405
542
|
*/
|
|
406
543
|
export declare function earliestKeyActivation(keys: Iterable<{
|
|
407
544
|
activatedAt?: string | null;
|
|
@@ -415,14 +552,67 @@ export declare function earliestKeyActivation(keys: Iterable<{
|
|
|
415
552
|
*
|
|
416
553
|
* False when `signingSince` is absent or unparseable: with no instant from
|
|
417
554
|
* which the install signs, nothing has to be signed. True when `signingSince`
|
|
418
|
-
* is known and `writtenAt` is missing or not strict RFC 3339: the
|
|
555
|
+
* is known and `writtenAt` is missing or not strict RFC 3339: the Server times every
|
|
419
556
|
* row, so a row with no readable time was edited, and it cannot be placed
|
|
420
557
|
* before signing began. It fails closed rather than reading as early history.
|
|
421
558
|
*/
|
|
422
559
|
export declare function writtenWhileSigning(writtenAt: unknown, signingSince: string | null | undefined): boolean;
|
|
560
|
+
/** How the entries classical keys signed stand against the history seals. */
|
|
561
|
+
export interface HistorySealCounts {
|
|
562
|
+
/** Entries at or below their chain's leaf in the seal covering their key. */
|
|
563
|
+
sealed: number;
|
|
564
|
+
/** Valid entries under a classical key that no seal covers. */
|
|
565
|
+
unsealed: number;
|
|
566
|
+
/** Each such key, once, with what would seal it. */
|
|
567
|
+
unsealedKeys: Array<{
|
|
568
|
+
keyId: string;
|
|
569
|
+
detail: string;
|
|
570
|
+
}>;
|
|
571
|
+
}
|
|
423
572
|
/**
|
|
424
573
|
* Verify a single hash chain. `entries` are all the entries for one scope; they
|
|
425
574
|
* are sorted by chainPosition internally (so a reordered export array still
|
|
426
575
|
* validates the true chain; tampering surfaces through the hash links).
|
|
427
576
|
*/
|
|
428
577
|
export declare function verifyChain(entries: readonly NormalizedEntry[], keys: KeyRegistry, options?: VerifyChainOptions): ChainResult;
|
|
578
|
+
/**
|
|
579
|
+
* Where a signed artifact other than a chain entry falls against the window
|
|
580
|
+
* of the key that signed it. `inside`: the key's window covers its write time,
|
|
581
|
+
* or the key carries no window. `accounted`: it was written at or after the
|
|
582
|
+
* instant `distrustedKeys` gives for the key and before a key the walk trusts
|
|
583
|
+
* retired it. `not-yet-active` and `expired`: outside the window. `unplaceable`:
|
|
584
|
+
* the write time or a window edge is not an RFC 3339 instant, so the artifact
|
|
585
|
+
* cannot be placed and the caller fails closed.
|
|
586
|
+
*/
|
|
587
|
+
export type KeyWindowPlacement = {
|
|
588
|
+
placement: 'inside' | 'accounted';
|
|
589
|
+
} | {
|
|
590
|
+
placement: 'not-yet-active' | 'expired' | 'unplaceable';
|
|
591
|
+
detail: string;
|
|
592
|
+
};
|
|
593
|
+
/**
|
|
594
|
+
* Place a vault checkpoint, a read-log leaf or a read-log tree head in the
|
|
595
|
+
* signed window of its key, by the time its row was written. The rule is the
|
|
596
|
+
* one chain entries are held to (CHAIN_KEY_NOT_YET_ACTIVE, CHAIN_KEY_EXPIRED):
|
|
597
|
+
* each edge is checked only when the key carries it, at millisecond
|
|
598
|
+
* precision, and an artifact written exactly at the key's retirement is
|
|
599
|
+
* inside. `what` names the artifact in the detail ("Checkpoint", "Leaf").
|
|
600
|
+
*
|
|
601
|
+
* The caller verifies the signature first: the Server reports a signature
|
|
602
|
+
* that does not verify ahead of a window finding.
|
|
603
|
+
*/
|
|
604
|
+
export declare function placeInKeyWindow(key: VerificationKey, writtenAt: unknown, what: string): KeyWindowPlacement;
|
|
605
|
+
/**
|
|
606
|
+
* Whether a `distrustedKeys` entry and the retirement a trusted key signed
|
|
607
|
+
* account for an artifact signed under `key` and written at `writtenAt`: the
|
|
608
|
+
* key is unanchored only because of the entry, or anchored and the artifact
|
|
609
|
+
* written at or after the entry's instant, and in both cases the artifact was
|
|
610
|
+
* written before that retirement. The same condition lists a chain entry as
|
|
611
|
+
* CHAIN_SIGNED_BY_DISTRUSTED_KEY.
|
|
612
|
+
*
|
|
613
|
+
* Such an artifact is listed, never verified, and never evidence for or
|
|
614
|
+
* against anything else. The caller still verifies its signature under the
|
|
615
|
+
* key before setting it aside: anything else under the key's id is bytes
|
|
616
|
+
* whoever writes to the database wrote.
|
|
617
|
+
*/
|
|
618
|
+
export declare function distrustAccounts(key: VerificationKey, writtenAt: unknown): boolean;
|