@agledger/verify-core 2.1.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.
@@ -112,12 +112,11 @@ export declare function extractFederationWire(payload: Record<string, unknown>):
112
112
  export type FederationWireOutcome =
113
113
  /**
114
114
  * The hash, the entry's fields and, under a supplied key, the signature all
115
- * hold. `afterRetirement`: the key the message is sealed under was retired,
116
- * by a succession it signed, before the sender signed the message. The
117
- * receiver accepts the old key until it revokes the peer, so a publisher
118
- * process not yet restarted onto the new key sends exactly this; it is in
119
- * order when the receiver's `federation.peer_revoked` audit row for the
120
- * publisher comes after the entry.
115
+ * hold. `afterRetirement` (only with `allowAfterRetirement`): the key the
116
+ * message is sealed under was retired, by a succession it signed, before the
117
+ * sender signed the message. The receiver accepts the old key until it
118
+ * revokes the peer, so a publisher process not yet restarted onto the new
119
+ * key sends exactly this for a short gap.
121
120
  */
122
121
  {
123
122
  outcome: 'ok';
@@ -136,17 +135,37 @@ export type FederationWireOutcome =
136
135
  outcome: 'unsupported';
137
136
  detail: string;
138
137
  };
138
+ /**
139
+ * The allowance at both edges of a federation key's window, as the Server's
140
+ * receiver recipe gives it. `wire.timestamp` is the clock of the process that
141
+ * signed the message and the window's edges are the sender's database clock,
142
+ * so a message signed within this of a key change is on the right key.
143
+ */
144
+ export declare const FEDERATION_KEY_WINDOW_SKEW_MS = 300000;
145
+ export interface CheckFederationWireOptions {
146
+ /**
147
+ * Accept a message signed by a key its history had already retired (beyond
148
+ * the clock-skew allowance), and count it in `afterRetirement`. A publisher
149
+ * process not yet restarted onto the new key sends exactly this for a short
150
+ * gap, and the receiver accepts the old key until it revokes the peer. Off
151
+ * by default: a retired key signing at any later time is also what a leaked
152
+ * key does.
153
+ */
154
+ allowAfterRetirement?: boolean;
155
+ }
139
156
  /**
140
157
  * Check one sealed message against the entry that carries it, and under the
141
158
  * sender's key when `keys` has one for `wire.senderHubId`.
142
159
  *
143
160
  * Runs on an entry that already passed every other check, so `payload` is
144
161
  * what the receiver signed. `recordId` is the entry's record; the body names
145
- * the same record on every message type that carries one. When the sender's
162
+ * the same record on every message type that carries one, or, on an entry that
163
+ * signs `origin`, the record id `origin` names. When the sender's
146
164
  * keys came with a history, the message is placed in a key's window by
147
165
  * `wire.timestamp`: the sender signed it, the receiver sealed it under its own
148
166
  * signature after holding it to its clock-skew allowance, and it is read from
149
- * the sender's clock, the clock the history's windows are written by. The
167
+ * the sender's clock, the clock the history's windows are written by, with
168
+ * {@link FEDERATION_KEY_WINDOW_SKEW_MS} allowed at each edge. The
150
169
  * entry's `createdAt` is a column no signature covers, so it places nothing.
151
170
  */
152
- export declare function checkFederationWire(entryType: string, recordId: string | null, payload: Record<string, unknown>, wire: FederationWire, keys: FederationKeyRegistry | undefined): FederationWireOutcome;
171
+ export declare function checkFederationWire(entryType: string, recordId: string | null, payload: Record<string, unknown>, wire: FederationWire, keys: FederationKeyRegistry | undefined, options?: CheckFederationWireOptions): FederationWireOutcome;
@@ -130,7 +130,7 @@ function verifyKeyStatement(stmt, hubId) {
130
130
  if (!verifyStatementSignature(subject.publicKey, String(stmt.subjectSignature), stmt.payload))
131
131
  return 'its subjectSignature does not verify under its subject key';
132
132
  if (typ === 'succession') {
133
- if (typeof stmt.predecessorSignature !== 'string' || !verifyStatementSignature(predecessor.publicKey, stmt.predecessorSignature, stmt.payload)) {
133
+ if (typeof stmt.predecessorSignature !== 'string' || predecessor === undefined || !verifyStatementSignature(predecessor.publicKey, stmt.predecessorSignature, stmt.payload)) {
134
134
  return 'its predecessorSignature does not verify under its predecessor key';
135
135
  }
136
136
  }
@@ -151,7 +151,8 @@ function verifyKeyStatement(stmt, hubId) {
151
151
  * signature, so it links nothing.
152
152
  */
153
153
  function trustedKeysFromHistory(hubId, pins, histories) {
154
- if (algorithmByName('Ed25519') === null || !runtimeCanCompute(algorithmByName('Ed25519'))) {
154
+ const ed25519 = algorithmByName('Ed25519');
155
+ if (ed25519 === null || !runtimeCanCompute(ed25519)) {
155
156
  throw new TypeError(`The federation key history for hub ${hubId} cannot be checked: this host cannot compute Ed25519 (an active OpenSSL FIPS provider carries no EdDSA).`);
156
157
  }
157
158
  const statements = [];
@@ -219,18 +220,24 @@ function trustedKeysFromHistory(hubId, pins, histories) {
219
220
  const queue = [digest];
220
221
  while (queue.length > 0) {
221
222
  const k = queue.pop();
222
- if (trusted.has(k))
223
+ if (k === undefined || trusted.has(k))
223
224
  continue;
224
225
  trusted.add(k);
225
226
  queue.push(...(links.get(k) ?? []));
226
227
  }
227
228
  }
228
229
  return [
229
- ...[...trusted].map((digest) => ({
230
- publicKey: publicKeyOf.get(digest),
231
- activatedAt: admission.get(digest)?.subject.activatedAt ?? null,
232
- retiredAt: retiredAt.get(digest) ?? null,
233
- })),
230
+ ...[...trusted].flatMap((digest) => {
231
+ const publicKey = publicKeyOf.get(digest);
232
+ // Every trusted digest was reached through publicKeyOf, so none is skipped.
233
+ if (publicKey === undefined)
234
+ return [];
235
+ return [{
236
+ publicKey,
237
+ activatedAt: admission.get(digest)?.subject.activatedAt ?? null,
238
+ retiredAt: retiredAt.get(digest) ?? null,
239
+ }];
240
+ }),
234
241
  ...[...standalone].map((publicKey) => ({ publicKey, activatedAt: null, retiredAt: null })),
235
242
  ];
236
243
  }
@@ -337,40 +344,46 @@ export function extractFederationWire(payload) {
337
344
  return 'malformed';
338
345
  return w;
339
346
  }
340
- /**
341
- * Which entry payload fields must equal which body fields, per entry type.
342
- * The receiver projects these from the message, so a disagreement means the
343
- * entry says something the sender did not sign.
344
- */
347
+ /** A state sync with `kind: "dispute"` projects a dispute event, which carries no state. */
348
+ const isDisputeSync = (payload) => payload.kind === 'dispute';
345
349
  const FIELD_PAIRS = {
346
350
  FEDERATION_STATE_SYNC: [
347
- ['state', 'state'],
348
- ['recordType', 'type'],
349
- ['disputeId', 'disputeId'],
350
- ['action', 'action'],
351
+ ['state', 'state', (p) => !isDisputeSync(p)],
352
+ ['recordType', 'type', false],
353
+ ['disputeId', 'disputeId', isDisputeSync],
354
+ ['action', 'action', isDisputeSync],
351
355
  ],
352
- FEDERATION_SIGNAL_RECEIVED: [['recommendation', 'recommendation']],
356
+ FEDERATION_SIGNAL_RECEIVED: [['recommendation', 'recommendation', true]],
353
357
  FEDERATION_CO_SIGN_RESPONDED: [
354
- ['recommendation', 'recommendation'],
355
- ['state', 'state'],
356
- ['outcomeHash', 'outcomeHash'],
357
- ['idempotencyKey', 'idempotencyKey'],
358
+ ['recommendation', 'recommendation', true],
359
+ ['state', 'state', true],
360
+ ['outcomeHash', 'outcomeHash', false],
361
+ ['idempotencyKey', 'idempotencyKey', false],
358
362
  ],
359
363
  };
364
+ /**
365
+ * The allowance at both edges of a federation key's window, as the Server's
366
+ * receiver recipe gives it. `wire.timestamp` is the clock of the process that
367
+ * signed the message and the window's edges are the sender's database clock,
368
+ * so a message signed within this of a key change is on the right key.
369
+ */
370
+ export const FEDERATION_KEY_WINDOW_SKEW_MS = 300_000;
360
371
  /**
361
372
  * Check one sealed message against the entry that carries it, and under the
362
373
  * sender's key when `keys` has one for `wire.senderHubId`.
363
374
  *
364
375
  * Runs on an entry that already passed every other check, so `payload` is
365
376
  * what the receiver signed. `recordId` is the entry's record; the body names
366
- * the same record on every message type that carries one. When the sender's
377
+ * the same record on every message type that carries one, or, on an entry that
378
+ * signs `origin`, the record id `origin` names. When the sender's
367
379
  * keys came with a history, the message is placed in a key's window by
368
380
  * `wire.timestamp`: the sender signed it, the receiver sealed it under its own
369
381
  * signature after holding it to its clock-skew allowance, and it is read from
370
- * the sender's clock, the clock the history's windows are written by. The
382
+ * the sender's clock, the clock the history's windows are written by, with
383
+ * {@link FEDERATION_KEY_WINDOW_SKEW_MS} allowed at each edge. The
371
384
  * entry's `createdAt` is a column no signature covers, so it places nothing.
372
385
  */
373
- export function checkFederationWire(entryType, recordId, payload, wire, keys) {
386
+ export function checkFederationWire(entryType, recordId, payload, wire, keys, options = {}) {
374
387
  if (wire.scheme !== FEDERATION_WIRE_SCHEME) {
375
388
  return { outcome: 'invalid', detail: `Sealed message scheme is ${JSON.stringify(wire.scheme)}, not ${FEDERATION_WIRE_SCHEME}.` };
376
389
  }
@@ -381,15 +394,64 @@ export function checkFederationWire(entryType, recordId, payload, wire, keys) {
381
394
  if (typeof payload.peerHubId === 'string' && payload.peerHubId !== wire.senderHubId) {
382
395
  return { outcome: 'invalid', detail: `Entry names peer ${payload.peerHubId}, the sealed message was sent by ${wire.senderHubId}.` };
383
396
  }
397
+ // A projection is keyed by its sending Server and the record id that Server
398
+ // named. When the receiver already held that id, the projection lives under
399
+ // a fresh local id and its entries sign `origin`, the sender and the id it
400
+ // sent: the sealed body names `origin.recordId`, not the entry's record.
401
+ // Entries written before `origin` was signed name the entry's own record.
402
+ const origin = payload.origin;
403
+ let expectedRecordId = recordId;
404
+ if (origin !== undefined && origin !== null) {
405
+ if (typeof origin !== 'object' || Array.isArray(origin)) {
406
+ return { outcome: 'invalid', detail: `Entry origin is ${canonicalizeJson(origin)}, not an object naming the sending Server and the record id it sent.` };
407
+ }
408
+ const o = origin;
409
+ if (typeof o.peerHubId !== 'string' || typeof o.recordId !== 'string') {
410
+ return { outcome: 'invalid', detail: `Entry origin ${canonicalizeJson(origin)} does not name both peerHubId and recordId as strings.` };
411
+ }
412
+ if (o.peerHubId !== wire.senderHubId) {
413
+ return { outcome: 'invalid', detail: `Entry origin names peer ${o.peerHubId}, the sealed message was sent by ${wire.senderHubId}.` };
414
+ }
415
+ expectedRecordId = o.recordId;
416
+ }
384
417
  const bodyRecordId = wire.body.recordId;
385
- if (recordId !== null && typeof bodyRecordId === 'string' && bodyRecordId !== recordId) {
386
- return { outcome: 'invalid', detail: `Entry is on record ${recordId}, the sealed message names record ${bodyRecordId}.` };
418
+ const pairs = FIELD_PAIRS[entryType];
419
+ if (pairs !== undefined) {
420
+ // A message of these types is about one record, so a body that names none,
421
+ // or an entry that names none to compare it with, proves nothing.
422
+ if (typeof bodyRecordId !== 'string') {
423
+ return { outcome: 'invalid', detail: `A ${entryType} message must name its record, and the sealed body carries no string recordId.` };
424
+ }
425
+ if (expectedRecordId === null) {
426
+ return { outcome: 'invalid', detail: `A ${entryType} entry carries no record id, so the record the sealed message names (${bodyRecordId}) cannot be compared with it.` };
427
+ }
387
428
  }
388
- for (const [entryField, bodyField] of FIELD_PAIRS[entryType] ?? []) {
429
+ if (expectedRecordId !== null && typeof bodyRecordId === 'string' && bodyRecordId.toLowerCase() !== expectedRecordId.toLowerCase()) {
430
+ return {
431
+ outcome: 'invalid',
432
+ detail: origin === undefined || origin === null
433
+ ? `Entry is on record ${recordId}, the sealed message names record ${bodyRecordId}.`
434
+ : `Entry origin names record ${expectedRecordId}, the sealed message names record ${bodyRecordId}.`,
435
+ };
436
+ }
437
+ for (const [entryField, bodyField, required] of pairs ?? []) {
389
438
  const mine = payload[entryField];
390
439
  const theirs = wire.body[bodyField];
391
- if (mine === undefined || theirs === undefined || mine === null || theirs === null)
392
- continue;
440
+ const mineAbsent = mine === undefined || mine === null;
441
+ const theirsAbsent = theirs === undefined || theirs === null;
442
+ if (mineAbsent && theirsAbsent) {
443
+ if (!(typeof required === 'function' ? required(payload) : required))
444
+ continue;
445
+ return { outcome: 'invalid', detail: `A ${entryType} entry must carry ${entryField}, and neither the entry nor the sealed message's ${bodyField} does.` };
446
+ }
447
+ if (mineAbsent || theirsAbsent) {
448
+ return {
449
+ outcome: 'invalid',
450
+ detail: mineAbsent
451
+ ? `The sealed message's ${bodyField} is ${canonicalizeJson(theirs)} and the entry carries no ${entryField}: the entry leaves out what the sender signed.`
452
+ : `Entry ${entryField} is ${canonicalizeJson(mine)} and the sealed message carries no ${bodyField}: the entry asserts what the sender did not sign.`,
453
+ };
454
+ }
393
455
  if (canonicalizeJson(mine) !== canonicalizeJson(theirs)) {
394
456
  return {
395
457
  outcome: 'invalid',
@@ -417,13 +479,19 @@ export function checkFederationWire(entryType, recordId, payload, wire, keys) {
417
479
  if (Number.isNaN(at)) {
418
480
  return { outcome: 'invalid', detail: `Sealed message from ${wire.senderHubId} carries timestamp ${JSON.stringify(wire.timestamp)}, which is not an RFC 3339 instant, so it cannot be placed in its key's window.` };
419
481
  }
420
- if (key.activatedAt !== null && at < rfc3339Ms(key.activatedAt)) {
482
+ if (key.activatedAt !== null && at < rfc3339Ms(key.activatedAt) - FEDERATION_KEY_WINDOW_SKEW_MS) {
483
+ return {
484
+ outcome: 'invalid',
485
+ detail: `Sealed message from ${wire.senderHubId} is signed at ${wire.timestamp} under a federation key its history activates at ${key.activatedAt}, more than ${FEDERATION_KEY_WINDOW_SKEW_MS / 1000}s after the sender signed it.`,
486
+ };
487
+ }
488
+ afterRetirement = key.retiredAt !== null && at > rfc3339Ms(key.retiredAt) + FEDERATION_KEY_WINDOW_SKEW_MS;
489
+ if (afterRetirement && options.allowAfterRetirement !== true) {
421
490
  return {
422
491
  outcome: 'invalid',
423
- detail: `Sealed message from ${wire.senderHubId} is signed at ${wire.timestamp} under a federation key its history activates at ${key.activatedAt}, after the sender signed it.`,
492
+ detail: `Sealed message from ${wire.senderHubId} is signed at ${wire.timestamp} under a federation key its history retired at ${key.retiredAt}, more than ${FEDERATION_KEY_WINDOW_SKEW_MS / 1000}s before the sender signed it. A retired key signing is what a leaked key does; if the sender's publisher was only slow to restart onto its new key, pass allowAfterRetirement.`,
424
493
  };
425
494
  }
426
- afterRetirement = key.retiredAt !== null && at > rfc3339Ms(key.retiredAt);
427
495
  }
428
496
  const ed25519 = algorithmByName('Ed25519');
429
497
  if (ed25519 === null || !runtimeCanCompute(ed25519)) {
package/dist/index.d.ts CHANGED
@@ -5,14 +5,14 @@
5
5
  */
6
6
  export { suggestion } from './failures.js';
7
7
  export type { FailureCode } from './failures.js';
8
- export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, earliestKeyActivation, verifyChain, writtenWhileSigning, } from './chain.js';
9
- export type { AccountedEntry, AccountedEntryCode, AgentKeyRegistry, KeySource, KeyTrustState, VerificationKey, KeyRegistry, NormalizedEntry, OptionalCheck, CheckApplicability, SignatureOutcome, ChainEntryResult, ChainResult, EvidenceBindingCounts, VerifyChainOptions, } from './chain.js';
8
+ export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, distrustAccounts, earliestKeyActivation, placeInKeyWindow, verifyChain, writtenWhileSigning, } from './chain.js';
9
+ export type { AccountedEntry, AccountedEntryCode, AgentKeyRegistry, KeySource, KeyTrustState, KeyWindowPlacement, VerificationKey, KeyRegistry, NormalizedEntry, OptionalCheck, CheckApplicability, SignatureOutcome, ChainEntryResult, ChainResult, EvidenceBindingCounts, VerifyChainOptions, } from './chain.js';
10
10
  export { verifyAuditExport } from './audit-export.js';
11
- export type { AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerifyExportOptions, SuppliedKeyEntry, EntryVerificationResult, VerifyExportResult, } from './audit-export.js';
11
+ export type { AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerifyExportOptions, SuppliedKeyEntry, EntryVerificationResult, VerifyExportResult, ExportOptionalCheck, } from './audit-export.js';
12
12
  export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
13
13
  export type { ComputeKeyTrustInput, DistrustedKey, DistrustSpan, DumpKeyStatementRow, DumpSigningKeyRow, KeyRegistryFinding, KeyRegistryFindingCode, KeyStatementInput, KeyStatementKind, KeyTrust, KeyTrustEntry, KeyTrustNote, KeyTrustReport, KeyTrustStatus, PublishedKeyStatement, TrustKeyInput, Verdict, VerificationKeysDocument, } from './key-statements.js';
14
- export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, } from './federation-wire.js';
15
- export type { FederationKeyEntry, FederationKeyHistoryDocument, FederationKeyHistoryStatement, FederationKeyRegistry, FederationTrustedKey, FederationWire, FederationWireOutcome, } from './federation-wire.js';
14
+ export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, } from './federation-wire.js';
15
+ export type { FederationKeyEntry, FederationKeyHistoryDocument, FederationKeyHistoryStatement, FederationKeyRegistry, FederationTrustedKey, FederationWire, FederationWireOutcome, CheckFederationWireOptions, } from './federation-wire.js';
16
16
  export { instantMs } from './instant.js';
17
17
  export { assertKnownOptions } from './options.js';
18
18
  export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
package/dist/index.js CHANGED
@@ -4,10 +4,10 @@
4
4
  * the MCP server, and @agledger/verify all build on this single body of logic.
5
5
  */
6
6
  export { suggestion } from './failures.js';
7
- export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, earliestKeyActivation, verifyChain, writtenWhileSigning, } from './chain.js';
7
+ export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, distrustAccounts, earliestKeyActivation, placeInKeyWindow, verifyChain, writtenWhileSigning, } from './chain.js';
8
8
  export { verifyAuditExport } from './audit-export.js';
9
9
  export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
10
- export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, } from './federation-wire.js';
10
+ export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, } from './federation-wire.js';
11
11
  export { instantMs } from './instant.js';
12
12
  export { assertKnownOptions } from './options.js';
13
13
  export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
package/dist/instant.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Milliseconds of an RFC 3339 instant, truncating any finer fraction the way
3
- * the engine reads a microsecond instant (its `instantToDate`). Key statements
3
+ * the Server reads a microsecond instant. Key statements
4
4
  * sign microsecond instants; entry write times, dump columns and key documents
5
5
  * carry milliseconds, so every comparison between them is made here. Strict:
6
6
  * a `T`, an offset or `Z`, a real calendar date and time of day; NaN for
package/dist/instant.js CHANGED
@@ -2,7 +2,7 @@
2
2
  const RFC3339 = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?([Zz]|([+-])(\d{2}):(\d{2}))$/;
3
3
  /**
4
4
  * Milliseconds of an RFC 3339 instant, truncating any finer fraction the way
5
- * the engine reads a microsecond instant (its `instantToDate`). Key statements
5
+ * the Server reads a microsecond instant. Key statements
6
6
  * sign microsecond instants; entry write times, dump columns and key documents
7
7
  * carry milliseconds, so every comparison between them is made here. Strict:
8
8
  * a `T`, an offset or `Z`, a real calendar date and time of day; NaN for
@@ -13,7 +13,7 @@ export interface KeyStatementInput {
13
13
  /**
14
14
  * Row id (the dump's or a key document's `id`), named in findings. Under the
15
15
  * write order it breaks a tie between two statements whose `createdAt` are
16
- * the same microsecond, as the engine's `created_at, id` does.
16
+ * the same microsecond, as the Server's `created_at, id` does.
17
17
  */
18
18
  id?: string | null;
19
19
  /** The source's own `kind` column, bound to the signed `typ`. */
@@ -30,7 +30,7 @@ export interface KeyStatementInput {
30
30
  * Where the statement was read from. `dump`: a row of a dump's
31
31
  * `vault_key_statements.ndjson` ({@link keyStatementFromDumpRow} sets it),
32
32
  * whose `created_at` the walk holds a distrusted key's statements to, as the
33
- * engine does. Anything else, absent included, is a key document's (an
33
+ * Server does. Anything else, absent included, is a key document's (an
34
34
  * export's or a supplied `/v1/verification-keys` entry's): its `createdAt`
35
35
  * orders it but never keeps an edge out of a distrusted key.
36
36
  */
@@ -120,7 +120,7 @@ export interface KeyRegistryFinding {
120
120
  * Something the walk did that is not a finding and does not fail a verdict:
121
121
  * a statement from a key document signed by a distrusted key that admits
122
122
  * nothing here, because the document's write time is the holder's word and is
123
- * never held against the key's cutoff, though the engine, holding it to the
123
+ * never held against the key's cutoff, though the Server, holding it to the
124
124
  * time it was stored, counts it. It still dates windows and cuts edges back.
125
125
  * Also a listed key whose `distrustedFrom` differs from the instant the
126
126
  * caller's `distrustedKeys` entry gives it, where no finding on its window
@@ -200,7 +200,7 @@ export interface KeyTrust {
200
200
  };
201
201
  }
202
202
  /**
203
- * What a `distrustedKeys` entry covers for one key, as the engine's
203
+ * What a `distrustedKeys` entry covers for one key, as the Server's
204
204
  * `distrustSpans` gives it. `cutoff`: the instant from which what the key
205
205
  * signs counts for nothing (the entry's own, else `retiredAt`; null: trusted
206
206
  * for nothing). `retiredAt`: the earliest retirement of the key that a key
@@ -238,7 +238,7 @@ export declare function parseDistrustedKeys(raw: string | readonly string[]): Di
238
238
  * (`sha256:<hex>@<instant>`) is how a leaked key whose history is still
239
239
  * needed is kept from signing anything new: the pin vouches for what it
240
240
  * stored before the instant. `computeKeyTrust` itself walks any pair as the
241
- * engine's walk does; a verifier calls this on what its caller passed before
241
+ * Server's walk does; a verifier calls this on what its caller passed before
242
242
  * it walks.
243
243
  */
244
244
  export declare function assertNotPinnedAndDistrusted(trustAnchors: string | readonly string[] | undefined, distrustedKeys: ReadonlyArray<string | DistrustedKey> | undefined): void;
@@ -346,7 +346,7 @@ export declare function keyStatementsFromVerificationKeys(doc: VerificationKeysD
346
346
  /**
347
347
  * Mark every key of a registry with the walk's verdict, and give each anchored
348
348
  * key the window its statements sign in place of whatever window it carried,
349
- * as the engine grades entries. An anchored key no statement dates carries no
349
+ * as the Server grades entries. An anchored key no statement dates carries no
350
350
  * edge on that side. A key is anchored only when its key id is the
351
351
  * fingerprint of its own SPKI: a row filed under another key's id names that
352
352
  * key's entries, and is anchored to nothing. On a walk over a dump, a key a
@@ -376,15 +376,31 @@ export type KeyTrustStatus = 'walked' | 'no_anchor' | 'no_anchored_signature';
376
376
  * The one-word reading of a verification result, as every surface prints it:
377
377
  * `failed` when it is not valid, `trusted` when it is valid and the walk
378
378
  * anchored a signature (`keyTrust.status: 'walked'`), and `unanchored` when it
379
- * is valid but rests on nothing pinned. Read this rather than `valid` alone: a
380
- * valid result with no `trustAnchors` is `unanchored`.
379
+ * is valid but rests on nothing pinned, or when the only thing that failed is
380
+ * that nothing is signed by a key the pinned trustAnchors anchor (see
381
+ * {@link verdictOf}). Read this rather than `valid` alone: a valid result with
382
+ * no `trustAnchors` is `unanchored`.
381
383
  */
382
384
  export type Verdict = 'trusted' | 'unanchored' | 'failed';
383
- /** The {@link Verdict} of a result that carries `valid` and a `keyTrust` report. */
385
+ /**
386
+ * The {@link Verdict} of a result that carries `valid` and a `keyTrust` report.
387
+ *
388
+ * Pass `passesUnpinned` on a run that supplied trustAnchors: it reruns the
389
+ * same input with the same options minus `trustAnchors` and `distrustedKeys`
390
+ * and says whether that run is valid. A pinned run that failed, whose walk
391
+ * anchored no key at all, and whose unpinned rerun passes, is `unanchored`
392
+ * rather than `failed`: the only thing wrong is that the pin reaches nothing
393
+ * in the artifact (the key-statement findings and CHAIN_SIGNING_KEY_UNANCHORED
394
+ * entries such a walk reports all follow from that). That is an export checked
395
+ * against another Server's pin, and equally one re-signed wholesale under keys
396
+ * of its own; neither is trusted, and the result keeps `valid: false`. An
397
+ * artifact in which the pin anchors even one key stays `failed`, since an
398
+ * entry beside it under an unanchored key is a substitution.
399
+ */
384
400
  export declare function verdictOf(result: {
385
401
  valid: boolean;
386
- keyTrust: Pick<KeyTrustReport, 'status'>;
387
- }): Verdict;
402
+ keyTrust: Pick<KeyTrustReport, 'status' | 'anchoredKeyIds'>;
403
+ }, passesUnpinned?: () => boolean): Verdict;
388
404
  /** What a verification result says about key anchoring. */
389
405
  export interface KeyTrustReport {
390
406
  /** See {@link KeyTrustStatus}. */