@agledger/verify-core 1.4.0 → 1.4.1

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 CHANGED
@@ -18,6 +18,17 @@ one surface passes identically in all of them.
18
18
  One dependency: [`cborg`](https://www.npmjs.com/package/cborg), for COSE_Sign1
19
19
  CBOR decoding.
20
20
 
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install @agledger/verify-core
25
+ ```
26
+
27
+ Node 24 or newer. If you want a ready-made verifier rather than a library, use
28
+ [`@agledger/verify`](https://github.com/agledger-ai/verify) for a full-vault dump
29
+ or the `verify` command in [`@agledger/cli`](https://github.com/agledger-ai/cli)
30
+ for a single record export.
31
+
21
32
  ## Usage
22
33
 
23
34
  ```ts
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Adapter: verify a live `/audit-export` JSON document (one record's chain).
3
3
  *
4
- * This is the customer/developer path — `client.records.getAuditExport(id)`
4
+ * This is the customer/developer path: `client.records.getAuditExport(id)`
5
5
  * then `verifyAuditExport(...)`. It maps the export wire shape onto the shared
6
6
  * normalized entry and runs `verifyChain`.
7
7
  *
@@ -9,13 +9,13 @@
9
9
  * their inputs (engine ≥ v0.26.x): 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
- * denormalized `payload` + `entryType` enable binding-integrity — the export's
12
+ * denormalized `payload` + `entryType` enable binding-integrity, the export's
13
13
  * own verificationGuide step 4. The binding check defends against post-export
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
17
  * CHAIN_PAYLOAD_BINDING_MISMATCH (validated against a real engine v0.26.4
18
- * export — `buildPredicateForRow` reconstructs the signed predicate exactly).
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
  */
@@ -27,7 +27,7 @@ export interface AuditExportEntryInput {
27
27
  chainPosition?: number;
28
28
  /** Legacy alias for `chainPosition`. */
29
29
  position?: number;
30
- /** ISO-8601 write time. Engine ≥ v0.26.x — gates the temporal key-validity check. */
30
+ /** ISO-8601 write time. Engine ≥ v0.26.x; gates the temporal key-validity check. */
31
31
  createdAt?: string;
32
32
  /** OIDC issuer the actor was synthesized from (engine ≥ v0.26.x). */
33
33
  actorOidcIss?: string | null;
@@ -35,9 +35,9 @@ export interface AuditExportEntryInput {
35
35
  actorOidcSub?: string | null;
36
36
  /** Tri-state from `audit_vault.actor_oidc_synthesized` (engine ≥ v0.26.x). Marker for the OIDC-actor check. */
37
37
  actorOidcSynthesized?: boolean | null;
38
- /** The record this entry belongs to — pairs with `payload`/`entryType` to drive the binding check. */
38
+ /** The record this entry belongs to; pairs with `payload`/`entryType` to drive the binding check. */
39
39
  recordId?: string | null;
40
- /** The audit-vault entry type (e.g. `RECORD_CREATED`) — drives the binding check's predicate reconstruction. */
40
+ /** The audit-vault entry type (e.g. `RECORD_CREATED`); drives the binding check's predicate reconstruction. */
41
41
  entryType?: string;
42
42
  /** Denormalized row `payload` jsonb. Present → the binding-integrity check runs (verificationGuide step 4). */
43
43
  payload?: Record<string, unknown>;
@@ -49,7 +49,7 @@ export interface AuditExportEntryInput {
49
49
  signingKeyId: string | null;
50
50
  };
51
51
  }
52
- /** Per-key activation/retirement window — drives temporal key-validity (engine ≥ v0.26.x). */
52
+ /** Per-key activation/retirement window; drives temporal key-validity (engine ≥ v0.26.x). */
53
53
  export interface SigningKeyWindow {
54
54
  activatedAt: string;
55
55
  retiredAt: string | null;
@@ -66,10 +66,10 @@ export interface RecordAuditExportInput {
66
66
  };
67
67
  entries: AuditExportEntryInput[];
68
68
  /**
69
- * Self-describing verification guidance the engine ships in the export (api#769).
69
+ * Self-describing verification guidance the engine ships in the export.
70
70
  * `unsignedFields` lists per-entry fields that are UNSIGNED display projections
71
71
  * (e.g. `actorDisplayName`) resolved at export time, not covered by the COSE_Sign1
72
- * signature. A PASS does NOT vouch for these labels — signed attribution is the
72
+ * signature. A PASS does NOT vouch for these labels; signed attribution is the
73
73
  * `actorOwnerId`/`actorId` UUID. Surfaced on the result so a verdict can say so.
74
74
  */
75
75
  verificationGuide?: {
@@ -79,13 +79,13 @@ export interface RecordAuditExportInput {
79
79
  /**
80
80
  * Structural shape for a single out-of-band key in array form. Matches the SDK's
81
81
  * `VerificationKey` (the `.data[]` from `client.verificationKeys.list()`) plus
82
- * the SCITT COSE_KeySet (`/.well-known/scitt-keys`) entry shape — extra fields
82
+ * the SCITT COSE_KeySet (`/.well-known/scitt-keys`) entry shape; extra fields
83
83
  * are ignored. `publicKey` must be SPKI DER base64.
84
84
  */
85
85
  export interface OutOfBandKeyEntry {
86
86
  keyId: string;
87
87
  publicKey: string;
88
- /** Optional activation timestamp — feeds temporal key-validity when present. */
88
+ /** Optional activation timestamp; feeds temporal key-validity when present. */
89
89
  activatedAt?: string;
90
90
  /** Optional retirement timestamp; `null` means "active, no scheduled retirement". */
91
91
  retiredAt?: string | null;
@@ -98,20 +98,20 @@ export interface VerifyExportOptions {
98
98
  * rather than trusting the export's own `signingPublicKeys`.
99
99
  *
100
100
  * Accepts either form:
101
- * - `Record<keyId, base64SpkiDer>` — the compact map shape
102
- * - `OutOfBandKeyEntry[]` — the natural shape returned by
101
+ * - `Record<keyId, base64SpkiDer>`: the compact map shape
102
+ * - `OutOfBandKeyEntry[]`: the natural shape returned by
103
103
  * `client.verificationKeys.list().data` and SCITT COSE_KeySet listings
104
104
  *
105
105
  * Anything else throws `TypeError` at the boundary. Fail-closed: the verifier
106
106
  * never silently falls back to embedded keys when the caller meant to defeat
107
- * trust in them. See agledger-agents#77 (F-698).
107
+ * trust in them.
108
108
  */
109
109
  publicKeys?: Record<string, string> | ReadonlyArray<OutOfBandKeyEntry>;
110
110
  /** Require every entry to reference this keyId (else CHAIN_KEY_POLICY_VIOLATION). */
111
111
  requireKeyId?: string;
112
112
  /**
113
113
  * High-assurance: refuse keys embedded in the export. An entry whose only key
114
- * is export-embedded fails CHAIN_KEY_POLICY_VIOLATION — verifying the engine
114
+ * is export-embedded fails CHAIN_KEY_POLICY_VIOLATION; verifying the engine
115
115
  * against its own embedded key is not an independent audit.
116
116
  */
117
117
  requireOutOfBandKeys?: boolean;
@@ -146,7 +146,7 @@ export interface VerifyExportResult {
146
146
  * - `oidc_actor` and `key_temporal` flip to `applied` when the export wire
147
147
  * carries their inputs (engine ≥ v0.26.x: `actorOidcSynthesized` per
148
148
  * entry, `signingKeyWindows` in exportMetadata, `createdAt` per entry).
149
- * - `payload_binding` stays `skipped_no_input` here by design — the export
149
+ * - `payload_binding` stays `skipped_no_input` here by design: the export
150
150
  * re-projects payload from the signed bytes, so this check is dump-only
151
151
  * (run `@agledger/verify` over a full vault dump to exercise it).
152
152
  *
@@ -158,7 +158,7 @@ export interface VerifyExportResult {
158
158
  /**
159
159
  * How many signature checks resolved against out-of-band vs export-embedded
160
160
  * keys. `embedded > 0` means the verdict trusts keys shipped by the engine
161
- * that produced the export — supply out-of-band keys for an independent audit.
161
+ * that produced the export. Supply out-of-band keys for an independent audit.
162
162
  */
163
163
  keyProvenance: {
164
164
  outOfBand: number;
@@ -166,7 +166,7 @@ export interface VerifyExportResult {
166
166
  };
167
167
  /**
168
168
  * Per-entry fields the export self-describes as UNSIGNED display projections
169
- * (from `verificationGuide.unsignedFields`, api#769) — e.g. `actorDisplayName`.
169
+ * (from `verificationGuide.unsignedFields`), e.g. `actorDisplayName`.
170
170
  * A valid signature does NOT cover these; signed attribution is the
171
171
  * `actorOwnerId`/`actorId` UUID. Empty when the export carries no such guidance.
172
172
  * A caller surfacing a PASS should warn that these labels are not vouched for.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Adapter: verify a live `/audit-export` JSON document (one record's chain).
3
3
  *
4
- * This is the customer/developer path — `client.records.getAuditExport(id)`
4
+ * This is the customer/developer path: `client.records.getAuditExport(id)`
5
5
  * then `verifyAuditExport(...)`. It maps the export wire shape onto the shared
6
6
  * normalized entry and runs `verifyChain`.
7
7
  *
@@ -9,13 +9,13 @@
9
9
  * their inputs (engine ≥ v0.26.x): 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
- * denormalized `payload` + `entryType` enable binding-integrity — the export's
12
+ * denormalized `payload` + `entryType` enable binding-integrity, the export's
13
13
  * own verificationGuide step 4. The binding check defends against post-export
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
17
  * CHAIN_PAYLOAD_BINDING_MISMATCH (validated against a real engine v0.26.4
18
- * export — `buildPredicateForRow` reconstructs the signed predicate exactly).
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
  */
@@ -43,7 +43,7 @@ export function verifyAuditExport(exportData, options = {}) {
43
43
  };
44
44
  // Binding-integrity: when the export carries the denormalized row `payload`
45
45
  // (engine ≥ v0.26.x), cross-check it against the predicate decoded from the
46
- // signed bytes — the export's own verificationGuide step 4. The threat is
46
+ // signed bytes, the export's own verificationGuide step 4. The threat is
47
47
  // post-export tampering of the human-readable `payload`/`criteria` view: an
48
48
  // attacker rewrites `payload` and leaves `coseSign1` intact. The verifier
49
49
  // re-decodes the signed predicate and compares, catching the divergence
@@ -61,7 +61,7 @@ export function verifyAuditExport(exportData, options = {}) {
61
61
  // The synthesized flag is the marker that the export carries the OIDC
62
62
  // wire shape at all. Older exports omit it entirely; new exports always
63
63
  // include it (false/null/true). Setting `oidcActor` flips `oidc_actor`
64
- // to `applied` in the chain result — never `applied` for old exports.
64
+ // to `applied` in the chain result; never `applied` for old exports.
65
65
  if (e.actorOidcSynthesized !== undefined) {
66
66
  base.oidcActor = {
67
67
  iss: e.actorOidcIss ?? null,
@@ -153,9 +153,9 @@ function resolveKeys(exportData, options) {
153
153
  // key out-of-band AND brought their own activation/retirement window,
154
154
  // the export's (untrusted) signingKeyWindows MUST NOT overwrite it.
155
155
  // A compromised export could otherwise hide a retirement by setting
156
- // retiredAt:null, reopening F-698 on the temporal axis. When the OOB
156
+ // retiredAt:null, reopening the fallback on the temporal axis. When the OOB
157
157
  // caller did not carry a window, we still fall through to the export's
158
- // window — most auditors trust the engine's published key-rotation log
158
+ // window, since most auditors trust the engine's published key-rotation log
159
159
  // even when they bring their own key catalogue.
160
160
  const oobCarriesWindow = existing.source === 'out-of-band' &&
161
161
  (existing.activatedAt !== undefined || existing.retiredAt !== undefined);
@@ -174,12 +174,12 @@ function resolveKeys(exportData, options) {
174
174
  * Normalize `options.publicKeys` into a uniform array of entries, or throw
175
175
  * `TypeError` at the boundary if the shape is wrong. Fail-closed by design:
176
176
  * an OOB-key argument that silently falls back to embedded keys would lie
177
- * about the audit-independence claim (see agledger-agents#77 / F-698).
177
+ * about the audit-independence claim.
178
178
  *
179
179
  * Accepts:
180
- * - `Record<keyId, base64SpkiDer>` — compact map (string-keyed object whose
180
+ * - `Record<keyId, base64SpkiDer>`: compact map (string-keyed object whose
181
181
  * values are all strings)
182
- * - `OutOfBandKeyEntry[]` — natural SDK shape from `verificationKeys.list()`,
182
+ * - `OutOfBandKeyEntry[]`: natural SDK shape from `verificationKeys.list()`,
183
183
  * or COSE_KeySet shape from `/.well-known/scitt-keys`
184
184
  *
185
185
  * Returns `null` when no keys were supplied; otherwise an array of normalized
@@ -192,14 +192,14 @@ function normalizeOutOfBandKeys(publicKeys) {
192
192
  return publicKeys.map((entry, i) => {
193
193
  if (entry === null || typeof entry !== 'object') {
194
194
  throw new TypeError(`verifyAuditExport: publicKeys[${i}] is not an object (got ${typeof entry}). ` +
195
- `Expected { keyId, publicKey } entries — e.g. the .data[] from client.verificationKeys.list().`);
195
+ `Expected { keyId, publicKey } entries, e.g. the .data[] from client.verificationKeys.list().`);
196
196
  }
197
197
  const keyId = entry.keyId;
198
198
  const publicKey = entry.publicKey;
199
199
  if (typeof keyId !== 'string' || typeof publicKey !== 'string') {
200
200
  throw new TypeError(`verifyAuditExport: publicKeys[${i}] is missing required string fields { keyId, publicKey } ` +
201
201
  `(got keyId=${typeof keyId}, publicKey=${typeof publicKey}). ` +
202
- `Expected the SDK VerificationKey shape — publicKey must be SPKI DER base64.`);
202
+ `Expected the SDK VerificationKey shape: publicKey must be SPKI DER base64.`);
203
203
  }
204
204
  const out = { keyId, spkiBase64: publicKey };
205
205
  const activatedAt = entry.activatedAt;
package/dist/chain.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { FailureCode } from './failures.js';
2
- /** Where a verification key came from — the trust-anchor provenance. */
2
+ /** Where a verification key came from: the trust-anchor provenance. */
3
3
  export type KeySource = 'out-of-band' | 'embedded';
4
4
  /** A public key the walk can verify signatures against. */
5
5
  export interface VerificationKey {
@@ -31,7 +31,7 @@ export type KeyRegistry = ReadonlyMap<string, VerificationKey>;
31
31
  export declare function buildKeyRegistry(keys: readonly VerificationKey[]): KeyRegistry;
32
32
  /** Inputs the input-gated checks consume; present only on the dump path. */
33
33
  export interface NormalizedEntry {
34
- /** Identity for messages — recordId (export) or chainKey (dump). */
34
+ /** Identity for messages: recordId (export) or chainKey (dump). */
35
35
  scopeId: string;
36
36
  chainPosition: number;
37
37
  payloadHash: string;
@@ -58,12 +58,12 @@ export type OptionalCheck = 'payload_binding' | 'oidc_actor' | 'key_temporal';
58
58
  export type CheckApplicability = 'applied' | 'skipped_no_input';
59
59
  export interface SignatureOutcome {
60
60
  /**
61
- * - `ok` / `invalid` / `decode-fail` — the signature was checked (and passed,
61
+ * - `ok` / `invalid` / `decode-fail`: the signature was checked (and passed,
62
62
  * failed, or the envelope would not decode).
63
- * - `unsigned` — the entry carries no signature by design.
64
- * - `skipped` — the chain is intact but this entry has no signing key, so the
63
+ * - `unsigned`: the entry carries no signature by design.
64
+ * - `skipped`: the chain is intact but this entry has no signing key, so the
65
65
  * signature check was deliberately not run (engine booted without a key).
66
- * - `not-checked` — a structural/chain check failed at or before this entry,
66
+ * - `not-checked`: a structural/chain check failed at or before this entry,
67
67
  * so verification short-circuited before reaching the signature. Reads as a
68
68
  * consequence of an upstream break, never as a benign skip.
69
69
  * - `unsupported`: the signature could not be computed at all, either
@@ -126,6 +126,6 @@ export interface VerifyChainOptions {
126
126
  /**
127
127
  * Verify a single hash chain. `entries` are all the entries for one scope; they
128
128
  * are sorted by chainPosition internally (so a reordered export array still
129
- * validates the true chain — tampering surfaces through the hash links).
129
+ * validates the true chain; tampering surfaces through the hash links).
130
130
  */
131
131
  export declare function verifyChain(entries: readonly NormalizedEntry[], keys: KeyRegistry, options?: VerifyChainOptions): ChainResult;
package/dist/chain.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * The shared per-chain verification walk.
3
3
  *
4
4
  * This is the single body of logic the SDK /verify, CLI, MCP server, and
5
- * @agledger/verify all run — replacing four hand-vendored copies. It walks ONE
5
+ * @agledger/verify all run, replacing four hand-vendored copies. It walks ONE
6
6
  * hash chain (a single record's lifecycle, or a single per-org schema-event
7
7
  * chain) over a normalized entry shape and emits the canonical failure
8
8
  * taxonomy.
@@ -15,13 +15,13 @@
15
15
  * - ALWAYS-RUN (every surface): position monotonicity, payloadHash =
16
16
  * sha256(cose_sign1), previous-hash link, COSE_Sign1 decode, the signed
17
17
  * protected-header chain-claim cross-check, and the Ed25519 signature.
18
- * - INPUT-GATED (only when the normalized entry carries the inputs — i.e. the
18
+ * - INPUT-GATED (only when the normalized entry carries the inputs, i.e. the
19
19
  * dump path): binding-integrity, OIDC-actor cross-check, temporal
20
20
  * key-validity. The `/audit-export` wire does NOT carry the inputs these
21
21
  * need (the API re-projects the export payload from the signed bytes and
22
22
  * omits the synthesized flag), so running them there would either no-op
23
23
  * silently or compare signed bytes to a derivative of themselves. They are
24
- * therefore reported as `skipped_no_input` on the export path — NEVER folded
24
+ * therefore reported as `skipped_no_input` on the export path, NEVER folded
25
25
  * into a green verdict.
26
26
  *
27
27
  * Failure ordering is fixed so `brokenAt` is deterministic. The null-key
@@ -38,7 +38,7 @@ export function buildKeyRegistry(keys) {
38
38
  /**
39
39
  * Verify a single hash chain. `entries` are all the entries for one scope; they
40
40
  * are sorted by chainPosition internally (so a reordered export array still
41
- * validates the true chain — tampering surfaces through the hash links).
41
+ * validates the true chain; tampering surfaces through the hash links).
42
42
  */
43
43
  export function verifyChain(entries, keys, options = {}) {
44
44
  const scopeId = entries[0]?.scopeId ?? '(empty)';
@@ -143,7 +143,7 @@ function verifyEntry(entry, expectedPosition, expectedPrevHash, keys, options, o
143
143
  chainClaim.previous_hash !== expectedPrev) {
144
144
  return fail(scopeId, expectedPosition, 'CHAIN_COSE_HEADER_MISMATCH', `Signed protected-header chain claim (position=${chainClaim?.position ?? 'null'}, prev=${chainClaim?.previous_hash ?? 'null'}) diverges from row columns (position=${entry.chainPosition}, prev=${entry.previousHash ?? 'null'}).`);
145
145
  }
146
- // Input-gated: binding-integrity. Runs whenever the row payload is present —
146
+ // Input-gated: binding-integrity. Runs whenever the row payload is present:
147
147
  // the dump always carries it, and the export now carries it too (engine ≥ v0.26.x).
148
148
  if (entry.binding) {
149
149
  optionalChecks.payload_binding = 'applied';
@@ -169,7 +169,7 @@ function verifyEntry(entry, expectedPosition, expectedPrevHash, keys, options, o
169
169
  if (entry.signingKeyId === null) {
170
170
  // Fail closed under a key policy: a high-assurance run that requires a
171
171
  // specific key (or out-of-band keys) must NOT accept an unsigned/null-key
172
- // entry as valid — otherwise an attacker forges an entry, nulls its
172
+ // entry as valid; otherwise an attacker forges an entry, nulls its
173
173
  // signingKeyId, and slips past the policy the auditor explicitly set.
174
174
  if (options.requireKeyId || options.requireOutOfBandKeys) {
175
175
  return fail(scopeId, expectedPosition, 'CHAIN_KEY_POLICY_VIOLATION', 'Entry has no signingKeyId but this run requires a signed entry (requireKeyId / requireOutOfBandKeys).');
@@ -198,7 +198,7 @@ function verifyEntry(entry, expectedPosition, expectedPrevHash, keys, options, o
198
198
  return fail(scopeId, expectedPosition, 'CHAIN_ALG_MISMATCH', `Key registry declares algorithm=${key.algorithm} for key ${entry.signingKeyId}, but the key material is ${keyAlg.name}.`);
199
199
  }
200
200
  }
201
- // Signed-kid binding (engine mirror: signing_key_drift, #893). The row's
201
+ // Signed-kid binding (engine mirror: signing_key_drift). The row's
202
202
  // signingKeyId column selected the key above, but the column is a
203
203
  // denormalized convenience; the kid at protected-header label 4 is
204
204
  // signature-covered. A divergence means the column was rewritten after
@@ -268,8 +268,7 @@ function checkOidcActor(oidc, payloadBstr, scopeId, position) {
268
268
  * `CHAIN_KEY_EXPIRED`, so a consumer branching on the code saw "expired" for a
269
269
  * key that had not started yet and would reason about rotation or retention
270
270
  * when the real condition is clock skew or backdating. Those are different
271
- * investigations, and the activation side is the security-relevant one
272
- * (agents#112).
271
+ * investigations, and the activation side is the security-relevant one.
273
272
  */
274
273
  function temporalKeyFailure(createdAt, key) {
275
274
  const written = Date.parse(createdAt);
@@ -2,7 +2,7 @@
2
2
  * Canonical failure taxonomy for AGLedger offline verification.
3
3
  *
4
4
  * One enum, shared by every surface (SDK /verify, CLI, MCP, @agledger/verify,
5
- * and — by mirroring these exact strings — the independent Python verifier).
5
+ * and, by mirroring these exact strings, the independent Python verifier).
6
6
  * SCREAMING_SNAKE to match the API's RFC 9290 problem-detail codes
7
7
  * (VALIDATION_ERROR, RATE_LIMIT_EXCEEDED, …), namespaced by sub-system:
8
8
  *
@@ -14,13 +14,13 @@
14
14
  * Every code carries an actionable next step (`suggestion`) so a result is a
15
15
  * directive, not just a verdict.
16
16
  *
17
- * This is the strict union of the two taxonomies it replaces — the dump
17
+ * This is the strict union of the two taxonomies it replaces: the dump
18
18
  * verifier's `CHAIN_*`/`CHECKPOINT_*`/`TENANT_*` codes and the export
19
- * verifier's lower_snake reasons — with no tamper class dropped. Two renames
19
+ * verifier's lower_snake reasons, with no tamper class dropped. Two renames
20
20
  * and three additions vs. the old dump set:
21
21
  * - CHAIN_PAYLOAD_DRIFT -> CHAIN_PAYLOAD_BINDING_MISMATCH (drift read as a
22
22
  * content/value judgement; this is a binding-
23
- * integrity check — the signed payload's STRUCTURE
23
+ * integrity check: the signed payload's STRUCTURE
24
24
  * no longer matches the canonical projection of the
25
25
  * row columns it is bound to. AGLedger never
26
26
  * inspects deliverable content.)
@@ -34,7 +34,7 @@
34
34
  * - CHAIN_KEY_NOT_YET_ACTIVE entry written before the key's activated_at.
35
35
  * Split from CHAIN_KEY_EXPIRED so a consumer is
36
36
  * not told "expired" about a key that had not
37
- * started yet (agents#112).
37
+ * started yet.
38
38
  * - CHAIN_EMPTY (new) a chain/vault with nothing to verify is a non-clean
39
39
  * verdict, never a silent pass.
40
40
  */
package/dist/failures.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Canonical failure taxonomy for AGLedger offline verification.
3
3
  *
4
4
  * One enum, shared by every surface (SDK /verify, CLI, MCP, @agledger/verify,
5
- * and — by mirroring these exact strings — the independent Python verifier).
5
+ * and, by mirroring these exact strings, the independent Python verifier).
6
6
  * SCREAMING_SNAKE to match the API's RFC 9290 problem-detail codes
7
7
  * (VALIDATION_ERROR, RATE_LIMIT_EXCEEDED, …), namespaced by sub-system:
8
8
  *
@@ -14,13 +14,13 @@
14
14
  * Every code carries an actionable next step (`suggestion`) so a result is a
15
15
  * directive, not just a verdict.
16
16
  *
17
- * This is the strict union of the two taxonomies it replaces — the dump
17
+ * This is the strict union of the two taxonomies it replaces: the dump
18
18
  * verifier's `CHAIN_*`/`CHECKPOINT_*`/`TENANT_*` codes and the export
19
- * verifier's lower_snake reasons — with no tamper class dropped. Two renames
19
+ * verifier's lower_snake reasons, with no tamper class dropped. Two renames
20
20
  * and three additions vs. the old dump set:
21
21
  * - CHAIN_PAYLOAD_DRIFT -> CHAIN_PAYLOAD_BINDING_MISMATCH (drift read as a
22
22
  * content/value judgement; this is a binding-
23
- * integrity check — the signed payload's STRUCTURE
23
+ * integrity check: the signed payload's STRUCTURE
24
24
  * no longer matches the canonical projection of the
25
25
  * row columns it is bound to. AGLedger never
26
26
  * inspects deliverable content.)
@@ -34,12 +34,12 @@
34
34
  * - CHAIN_KEY_NOT_YET_ACTIVE entry written before the key's activated_at.
35
35
  * Split from CHAIN_KEY_EXPIRED so a consumer is
36
36
  * not told "expired" about a key that had not
37
- * started yet (agents#112).
37
+ * started yet.
38
38
  * - CHAIN_EMPTY (new) a chain/vault with nothing to verify is a non-clean
39
39
  * verdict, never a silent pass.
40
40
  */
41
41
  /**
42
- * Actionable next step per failure code. Kept terse and operational — what the
42
+ * Actionable next step per failure code. Kept terse and operational: what the
43
43
  * verifier's caller (auditor, compliance team, or agent) should do next.
44
44
  */
45
45
  const SUGGESTIONS = {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @agledger/verify-core — shared offline verification core for AGLedger audit
2
+ * @agledger/verify-core: shared offline verification core for AGLedger audit
3
3
  * chains. One dependency (cborg), no network. The SDK /verify subpath, the CLI,
4
4
  * the MCP server, and @agledger/verify all build on this single body of logic.
5
5
  */
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @agledger/verify-core — shared offline verification core for AGLedger audit
2
+ * @agledger/verify-core: shared offline verification core for AGLedger audit
3
3
  * chains. One dependency (cborg), no network. The SDK /verify subpath, the CLI,
4
4
  * the MCP server, and @agledger/verify all build on this single body of logic.
5
5
  */
@@ -78,8 +78,8 @@ export declare function resolveKeyAlgorithm(publicKeyBase64: string): KeyAlgorit
78
78
  *
79
79
  * Refuses non-Ed25519 keys. Node's `verify(null, ...)` silently falls back to
80
80
  * ECDSA/SHA-256 for EC keys, which would accept a signature no conformant
81
- * EdDSA verifier accepts (the engine guards the signing side the same way,
82
- * api#1089), so the key type is asserted before any crypto runs.
81
+ * EdDSA verifier accepts (the engine guards the signing side the same way),
82
+ * so the key type is asserted before any crypto runs.
83
83
  *
84
84
  * CAUTION for direct callers: as with `verifySignatureBytes`, `false` conflates
85
85
  * "did not verify" with "this host cannot compute EdDSA". Check
@@ -127,7 +127,7 @@ export declare function describeUnsupportedAlgorithm(publicKeyBase64: string): s
127
127
  export declare function verifySignatureBytes(publicKeyBase64: string, input: Uint8Array, signature: Uint8Array): boolean;
128
128
  /**
129
129
  * Decode a tagged COSE_Sign1 envelope into its three load-bearing parts.
130
- * Returns null on any structural failure — the caller surfaces it as
130
+ * Returns null on any structural failure; the caller surfaces it as
131
131
  * CHAIN_COSE_DECODE_FAILED.
132
132
  */
133
133
  export interface CoseSign1Parts {
@@ -176,14 +176,14 @@ export declare function verifyCoseSign1(coseSign1: Uint8Array, publicKeyBase64:
176
176
  * hex, matching the engine's `vault_signing_keys.key_id` shape. Returns null
177
177
  * when absent or malformed. The caller cross-checks it against the row's
178
178
  * `signingKeyId` column: the column is a denormalized convenience, the kid is
179
- * signed, so a rewritten column surfaces as drift (engine mirror: #893).
179
+ * signed, so a rewritten column surfaces as drift (engine mirror: signing_key_drift).
180
180
  */
181
181
  export declare function extractKid(protectedBstr: Uint8Array): string | null;
182
182
  /**
183
183
  * Extract the chain-mechanics private claim (`-65537`) from a COSE_Sign1
184
184
  * protected header. Returns the decoded `{ position, previous_hash }` or null
185
185
  * if the claim is missing/malformed. The caller cross-checks it against the
186
- * row's `chainPosition` / `previousHash` columns — a divergence means the row
186
+ * row's `chainPosition` / `previousHash` columns; a divergence means the row
187
187
  * was renumbered after signing.
188
188
  */
189
189
  export interface ChainClaim {
@@ -207,7 +207,7 @@ export declare function extractTraceparentClaim(payloadBstr: Uint8Array): string
207
207
  /**
208
208
  * Decode the predicate object from a COSE_Sign1 payload bstr. The payload IS
209
209
  * the in-toto v1 Statement; the predicate body lives at `payload.predicate`.
210
- * Returns null on any decode failure. Used by the binding-integrity check — the
210
+ * Returns null on any decode failure. Used by the binding-integrity check; the
211
211
  * row's denormalised `payload` jsonb is a convenience view projected from this
212
212
  * predicate at write time; if the view was altered after signing,
213
213
  * `buildPredicateForRow(...) !== decodePredicate(...)`.
@@ -219,22 +219,22 @@ export declare function decodePredicate(payloadBstr: Uint8Array): Record<string,
219
219
  * build-vault-claim.ts). This is the verifier-side mirror.
220
220
  *
221
221
  * Returns null when the row's payload is structurally insufficient (e.g.
222
- * SCHEMA_REGISTERED missing manifestDigest) — the caller surfaces null as a
222
+ * SCHEMA_REGISTERED missing manifestDigest); the caller surfaces null as a
223
223
  * binding mismatch rather than throwing, so an attacker who zeros out payload
224
224
  * can't crash the verifier.
225
225
  */
226
226
  export declare function buildPredicateForRow(recordId: string | null, entryType: string, payload: Record<string, unknown>): Record<string, unknown> | null;
227
227
  /**
228
228
  * Order-insensitive deep equality over plain JSON-shaped values. Used by the
229
- * binding-integrity check — the rebuilt and decoded predicates may serialize
229
+ * binding-integrity check: the rebuilt and decoded predicates may serialize
230
230
  * keys in different order across writer/reader paths.
231
231
  */
232
232
  export declare function deepEqual(a: unknown, b: unknown): boolean;
233
233
  /**
234
234
  * Strip envelope-level sibling fields (`on_behalf_of`, `traceparent`) from a
235
235
  * decoded predicate. They ride alongside per-kind predicate fields on the wire
236
- * but the engine's `buildPredicateOnly` — and our `buildPredicateForRow`
237
- * mirror — exclude them from the rebuilt predicate. Stripping here makes the
236
+ * but the engine's `buildPredicateOnly` (and our `buildPredicateForRow`
237
+ * mirror) exclude them from the rebuilt predicate. Stripping here makes the
238
238
  * two shapes deep-equalable; envelope-level integrity is covered by the
239
239
  * signature and the OIDC-actor cross-check.
240
240
  */
@@ -264,10 +264,10 @@ export declare function extractReceiptInclusionProof(receiptBytes: Uint8Array):
264
264
  * `signedStatementBytes`, assert it matches the COSE payload (the signed root).
265
265
  *
266
266
  * Returns:
267
- * - 'ok' — TS sig valid AND reconstructed root matches
268
- * - 'decode-fail' — envelope or VDP malformed
269
- * - 'signature-invalid' — TS signature fails (root cannot be trusted)
270
- * - 'root-mismatch' — reconstructed root != COSE payload (proof lies about
267
+ * - 'ok': TS sig valid AND reconstructed root matches
268
+ * - 'decode-fail': envelope or VDP malformed
269
+ * - 'signature-invalid': TS signature fails (root cannot be trusted)
270
+ * - 'root-mismatch': reconstructed root != COSE payload (proof lies about
271
271
  * which tree the leaf belongs to)
272
272
  * - 'unsupported-algorithm': the TS key commits to an algorithm this build
273
273
  * cannot compute. Fail closed: the Receipt may be
@@ -6,7 +6,7 @@
6
6
  * - Merkle: audit-vault/merkle.ts
7
7
  *
8
8
  * Re-implemented here (not imported from any engine/SDK code) so the verifier
9
- * has zero engine dependency — the load-bearing property of an offline
9
+ * has zero engine dependency, the load-bearing property of an offline
10
10
  * auditor: the engine could be compromised and this still verifies correctly.
11
11
  * The only runtime dependency is `cborg`, a general-purpose CBOR library (not
12
12
  * AGLedger code), and Node's built-in `crypto`. No network, no filesystem.
@@ -142,8 +142,8 @@ export function resolveKeyAlgorithm(publicKeyBase64) {
142
142
  *
143
143
  * Refuses non-Ed25519 keys. Node's `verify(null, ...)` silently falls back to
144
144
  * ECDSA/SHA-256 for EC keys, which would accept a signature no conformant
145
- * EdDSA verifier accepts (the engine guards the signing side the same way,
146
- * api#1089), so the key type is asserted before any crypto runs.
145
+ * EdDSA verifier accepts (the engine guards the signing side the same way),
146
+ * so the key type is asserted before any crypto runs.
147
147
  *
148
148
  * CAUTION for direct callers: as with `verifySignatureBytes`, `false` conflates
149
149
  * "did not verify" with "this host cannot compute EdDSA". Check
@@ -172,7 +172,7 @@ export function verifyEd25519Bytes(publicKeyBase64, input, signature) {
172
172
  * distinguishable: a `false` return means the signature did not verify, while
173
173
  * a throw means the host runtime could not perform the operation at all (see
174
174
  * `runtimeCanCompute`). Collapsing those two into one boolean is what made a
175
- * FIPS-locked host report an intact Ed25519 chain as forged (agents#113).
175
+ * FIPS-locked host report an intact Ed25519 chain as forged.
176
176
  *
177
177
  * ES256 mirrors the engine's `verifyWithAlgorithm`: SHA-256 digest passed
178
178
  * positionally, `dsaEncoding: 'ieee-p1363'` (COSE raw r||s, 64 bytes). The
@@ -188,7 +188,7 @@ function dispatchVerify(keyAlg, publicKeyBase64, input, signature) {
188
188
  });
189
189
  // Redundant with resolution from the same bytes, kept so a refactor that
190
190
  // ever passes the algorithm in from elsewhere cannot reach Node's silent
191
- // key-type-dispatched fallback (the api#1089 trap).
191
+ // key-type-dispatched fallback.
192
192
  if (keyObj.asymmetricKeyType !== keyAlg.nodeKeyType)
193
193
  return false;
194
194
  if (keyAlg.nodeKeyType === 'ec') {
@@ -369,7 +369,7 @@ export function verifySignatureBytes(publicKeyBase64, input, signature) {
369
369
  }
370
370
  }
371
371
  // --- COSE_Sign1 (RFC 9052 §4.4) verification ---
372
- /** CBOR tag 18 — tagged COSE_Sign1 envelope. */
372
+ /** CBOR tag 18: tagged COSE_Sign1 envelope. */
373
373
  const COSE_SIGN1_TAG = 18;
374
374
  /** CBOR major type 6 (tag), value 18, short form: the required leading byte. */
375
375
  const COSE_SIGN1_TAG_PREFIX = 0xd2;
@@ -417,7 +417,7 @@ export function verifyCoseSign1(coseSign1, publicKeyBase64) {
417
417
  // an Ed25519 key (by OID) on a host that cannot compute EdDSA. A FIPS-locked
418
418
  // runtime refuses such a key at LOAD, so "did not parse" there means "this
419
419
  // host will not touch it", not "someone forged it". Without this, the whole
420
- // agents#113 capability gate below is unreachable on the one path it was
420
+ // runtime-capability gate below is unreachable on the one path it was
421
421
  // written for, and an intact chain still reads as tamper.
422
422
  if (keyAlg === 'unparseable') {
423
423
  return isRuntimeRefusedEd25519Key(publicKeyBase64) ? 'unsupported-key-algorithm' : 'invalid';
@@ -428,8 +428,8 @@ export function verifyCoseSign1(coseSign1, publicKeyBase64) {
428
428
  if (headerAlg === null || !keyAlg.coseAlgs.includes(headerAlg))
429
429
  return 'alg-mismatch';
430
430
  // Two independent reasons the signature cannot be checked: this build does
431
- // not implement the algorithm, or the host runtime refuses to compute it
432
- // (agents#113). Both must read as "not verified", never as "did not verify".
431
+ // not implement the algorithm, or the host runtime refuses to compute it.
432
+ // Both must read as "not verified", never as "did not verify".
433
433
  if (!keyAlg.verifiable || !runtimeCanCompute(keyAlg))
434
434
  return 'unsupported-key-algorithm';
435
435
  if (parts.signature.length === keyAlg.signatureLength &&
@@ -465,7 +465,7 @@ function extractHeaderAlg(protectedBstr) {
465
465
  * hex, matching the engine's `vault_signing_keys.key_id` shape. Returns null
466
466
  * when absent or malformed. The caller cross-checks it against the row's
467
467
  * `signingKeyId` column: the column is a denormalized convenience, the kid is
468
- * signed, so a rewritten column surfaces as drift (engine mirror: #893).
468
+ * signed, so a rewritten column surfaces as drift (engine mirror: signing_key_drift).
469
469
  */
470
470
  export function extractKid(protectedBstr) {
471
471
  try {
@@ -556,7 +556,7 @@ export function extractTraceparentClaim(payloadBstr) {
556
556
  /**
557
557
  * Decode the predicate object from a COSE_Sign1 payload bstr. The payload IS
558
558
  * the in-toto v1 Statement; the predicate body lives at `payload.predicate`.
559
- * Returns null on any decode failure. Used by the binding-integrity check — the
559
+ * Returns null on any decode failure. Used by the binding-integrity check; the
560
560
  * row's denormalised `payload` jsonb is a convenience view projected from this
561
561
  * predicate at write time; if the view was altered after signing,
562
562
  * `buildPredicateForRow(...) !== decodePredicate(...)`.
@@ -598,7 +598,7 @@ const RECORD_STATE_RESERVED_KEYS = new Set([
598
598
  * build-vault-claim.ts). This is the verifier-side mirror.
599
599
  *
600
600
  * Returns null when the row's payload is structurally insufficient (e.g.
601
- * SCHEMA_REGISTERED missing manifestDigest) — the caller surfaces null as a
601
+ * SCHEMA_REGISTERED missing manifestDigest); the caller surfaces null as a
602
602
  * binding mismatch rather than throwing, so an attacker who zeros out payload
603
603
  * can't crash the verifier.
604
604
  */
@@ -678,7 +678,7 @@ function buildSchemaEventPredicateForRow(entryType, payload) {
678
678
  }
679
679
  /**
680
680
  * Order-insensitive deep equality over plain JSON-shaped values. Used by the
681
- * binding-integrity check — the rebuilt and decoded predicates may serialize
681
+ * binding-integrity check: the rebuilt and decoded predicates may serialize
682
682
  * keys in different order across writer/reader paths.
683
683
  */
684
684
  export function deepEqual(a, b) {
@@ -718,8 +718,8 @@ export function deepEqual(a, b) {
718
718
  /**
719
719
  * Strip envelope-level sibling fields (`on_behalf_of`, `traceparent`) from a
720
720
  * decoded predicate. They ride alongside per-kind predicate fields on the wire
721
- * but the engine's `buildPredicateOnly` — and our `buildPredicateForRow`
722
- * mirror — exclude them from the rebuilt predicate. Stripping here makes the
721
+ * but the engine's `buildPredicateOnly` (and our `buildPredicateForRow`
722
+ * mirror) exclude them from the rebuilt predicate. Stripping here makes the
723
723
  * two shapes deep-equalable; envelope-level integrity is covered by the
724
724
  * signature and the OIDC-actor cross-check.
725
725
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agledger/verify-core",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Shared offline verification core for AGLedger audit chains: COSE_Sign1 (RFC 9052) decode/verify, Ed25519 + ES256, hash-chain walk, Merkle proofs, and the canonical failure taxonomy. One dependency (cborg); no network. The single source of truth the SDK, CLI, MCP server, and @agledger/verify all build on.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",