@agledger/verify-core 1.3.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 +52 -0
- package/dist/audit-export.d.ts +18 -19
- package/dist/audit-export.js +12 -13
- package/dist/chain.d.ts +13 -11
- package/dist/chain.js +10 -12
- package/dist/failures.d.ts +5 -6
- package/dist/failures.js +21 -22
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/primitives.d.ts +67 -15
- package/dist/primitives.js +265 -33
- package/package.json +5 -1
- package/dist/audit-export.d.ts.map +0 -1
- package/dist/audit-export.js.map +0 -1
- package/dist/chain.d.ts.map +0 -1
- package/dist/chain.js.map +0 -1
- package/dist/failures.d.ts.map +0 -1
- package/dist/failures.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/primitives.d.ts.map +0 -1
- package/dist/primitives.js.map +0 -1
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
|
|
@@ -47,6 +58,47 @@ if (!result.valid) {
|
|
|
47
58
|
matched verification key, under the algorithm its SPKI commits to (Ed25519
|
|
48
59
|
or ES256; anything else fails closed as `CHAIN_UNSUPPORTED_ALGORITHM`).
|
|
49
60
|
|
|
61
|
+
## Verifying on a FIPS-locked host
|
|
62
|
+
|
|
63
|
+
This package has no crypto of its own: it verifies through the host's Node
|
|
64
|
+
runtime. An active OpenSSL FIPS provider carries no EdDSA, so **an Ed25519
|
|
65
|
+
chain cannot be verified on a FIPS-locked host**. ES256 chains can.
|
|
66
|
+
|
|
67
|
+
That is reported as `CHAIN_UNSUPPORTED_ALGORITHM`, never as a signature
|
|
68
|
+
failure. The distinction is the whole point: "I could not check this" and "I
|
|
69
|
+
checked this and it failed" lead to opposite conclusions, and only one of them
|
|
70
|
+
is grounds for a tamper investigation. The result still fails closed, because
|
|
71
|
+
an unverified chain is not a verified one. To actually verify an Ed25519 chain,
|
|
72
|
+
re-run on a host without the restriction; the export and keys are portable and
|
|
73
|
+
the verification is entirely offline, so this costs nothing but a second host.
|
|
74
|
+
|
|
75
|
+
### Asking about an algorithm directly
|
|
76
|
+
|
|
77
|
+
`CHAIN_UNSUPPORTED_ALGORITHM` covers two causes with different remedies (this
|
|
78
|
+
build does not implement the algorithm, versus this host refuses to compute it),
|
|
79
|
+
so a consumer writing its own report can ask about either:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { algorithmByName, runtimeCanCompute, describeUnsupportedAlgorithm } from '@agledger/verify-core';
|
|
83
|
+
|
|
84
|
+
// runtimeCanCompute takes a KeyAlgorithm from this build's table, NOT a name
|
|
85
|
+
// string. Look one up with algorithmByName ('Ed25519', 'ES256', 'ES384',
|
|
86
|
+
// 'ES512', 'ES256K'); it returns null for anything else.
|
|
87
|
+
const ed25519 = algorithmByName('Ed25519');
|
|
88
|
+
if (ed25519 && !runtimeCanCompute(ed25519)) {
|
|
89
|
+
console.warn('This host cannot verify Ed25519 chains.');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Or ask about a specific key, given its SPKI DER base64. Safe to call without
|
|
93
|
+
// having established that a gap exists: a key that verifies fine here says so
|
|
94
|
+
// rather than asserting a refusal that did not happen.
|
|
95
|
+
console.log(describeUnsupportedAlgorithm(spkiBase64));
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`algorithmByName` exists for the case `resolveKeyAlgorithm` cannot serve: a host
|
|
99
|
+
that refuses to *load* a key of some algorithm produces no key object to
|
|
100
|
+
resolve, which is exactly when the question matters most.
|
|
101
|
+
|
|
50
102
|
## Out-of-band keys
|
|
51
103
|
|
|
52
104
|
`options.publicKeys` accepts either of two shapes:
|
package/dist/audit-export.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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`)
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
102
|
-
* - `OutOfBandKeyEntry[]
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
@@ -174,4 +174,3 @@ export interface VerifyExportResult {
|
|
|
174
174
|
unsignedProjectionFields: string[];
|
|
175
175
|
}
|
|
176
176
|
export declare function verifyAuditExport(exportData: RecordAuditExportInput, options?: VerifyExportOptions): VerifyExportResult;
|
|
177
|
-
//# sourceMappingURL=audit-export.d.ts.map
|
package/dist/audit-export.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
177
|
+
* about the audit-independence claim.
|
|
178
178
|
*
|
|
179
179
|
* Accepts:
|
|
180
|
-
* - `Record<keyId, base64SpkiDer
|
|
180
|
+
* - `Record<keyId, base64SpkiDer>`: compact map (string-keyed object whose
|
|
181
181
|
* values are all strings)
|
|
182
|
-
* - `OutOfBandKeyEntry[]
|
|
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
|
|
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
|
|
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;
|
|
@@ -226,4 +226,3 @@ function normalizeOutOfBandKeys(publicKeys) {
|
|
|
226
226
|
}
|
|
227
227
|
return entries;
|
|
228
228
|
}
|
|
229
|
-
//# sourceMappingURL=audit-export.js.map
|
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
|
|
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
|
|
34
|
+
/** Identity for messages: recordId (export) or chainKey (dump). */
|
|
35
35
|
scopeId: string;
|
|
36
36
|
chainPosition: number;
|
|
37
37
|
payloadHash: string;
|
|
@@ -58,17 +58,20 @@ 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
|
|
61
|
+
* - `ok` / `invalid` / `decode-fail`: the signature was checked (and passed,
|
|
62
62
|
* failed, or the envelope would not decode).
|
|
63
|
-
* - `unsigned
|
|
64
|
-
* - `skipped
|
|
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
|
|
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
|
-
* - `unsupported`: the
|
|
70
|
-
* build
|
|
71
|
-
*
|
|
69
|
+
* - `unsupported`: the signature could not be computed at all, either
|
|
70
|
+
* because this build does not implement the algorithm or because the host
|
|
71
|
+
* runtime refused it (an active OpenSSL FIPS provider carries no EdDSA).
|
|
72
|
+
* CHAIN_UNSUPPORTED_ALGORITHM. A failure state, never a benign skip, and
|
|
73
|
+
* never tamper evidence: distinguishing it from `invalid` is the whole
|
|
74
|
+
* point, since only `invalid` means a signature was checked and failed.
|
|
72
75
|
*/
|
|
73
76
|
state: 'ok' | 'invalid' | 'unsigned' | 'skipped' | 'not-checked' | 'decode-fail' | 'unsupported';
|
|
74
77
|
/** Provenance of the key the signature was checked against ('ok' / 'invalid'). */
|
|
@@ -123,7 +126,6 @@ export interface VerifyChainOptions {
|
|
|
123
126
|
/**
|
|
124
127
|
* Verify a single hash chain. `entries` are all the entries for one scope; they
|
|
125
128
|
* are sorted by chainPosition internally (so a reordered export array still
|
|
126
|
-
* validates the true chain
|
|
129
|
+
* validates the true chain; tampering surfaces through the hash links).
|
|
127
130
|
*/
|
|
128
131
|
export declare function verifyChain(entries: readonly NormalizedEntry[], keys: KeyRegistry, options?: VerifyChainOptions): ChainResult;
|
|
129
|
-
//# sourceMappingURL=chain.d.ts.map
|
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
|
|
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,20 +15,20 @@
|
|
|
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
|
|
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
|
|
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
|
|
28
28
|
* signature skip happens LAST, after the binding/OIDC checks, so a row written
|
|
29
29
|
* without a signing key is still subject to every structural check.
|
|
30
30
|
*/
|
|
31
|
-
import { buildPredicateForRow, decodeCoseSign1, decodePredicate, deepEqual, extractChainClaim, extractKid, extractOnBehalfOfClaim, resolveKeyAlgorithm, sha256Hex, stripEnvelopeExtensions, verifyCoseSign1, } from './primitives.js';
|
|
31
|
+
import { buildPredicateForRow, decodeCoseSign1, decodePredicate, deepEqual, describeUnsupportedAlgorithm, extractChainClaim, extractKid, extractOnBehalfOfClaim, resolveKeyAlgorithm, sha256Hex, stripEnvelopeExtensions, verifyCoseSign1, } from './primitives.js';
|
|
32
32
|
export function buildKeyRegistry(keys) {
|
|
33
33
|
const map = new Map();
|
|
34
34
|
for (const k of keys)
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
@@ -234,7 +234,7 @@ function verifyEntry(entry, expectedPosition, expectedPrevHash, keys, options, o
|
|
|
234
234
|
return fail(scopeId, expectedPosition, 'CHAIN_ALG_MISMATCH', `Protected-header alg (label 1) is absent or is not an algorithm key ${entry.signingKeyId} can produce. Tamper class: a rewritten alg must read as forgery, never as an upgrade notice.`, 'invalid');
|
|
235
235
|
}
|
|
236
236
|
if (outcome === 'unsupported-key-algorithm') {
|
|
237
|
-
return fail(scopeId, expectedPosition, 'CHAIN_UNSUPPORTED_ALGORITHM', `Key ${entry.signingKeyId}
|
|
237
|
+
return fail(scopeId, expectedPosition, 'CHAIN_UNSUPPORTED_ALGORITHM', `Key ${entry.signingKeyId} ${describeUnsupportedAlgorithm(key.spkiBase64)}`, 'unsupported');
|
|
238
238
|
}
|
|
239
239
|
return fail(scopeId, expectedPosition, 'CHAIN_SIGNATURE_INVALID', `COSE_Sign1 signature did not verify against key ${entry.signingKeyId}.`, outcome === 'decode-fail' ? 'decode-fail' : 'invalid');
|
|
240
240
|
}
|
|
@@ -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);
|
|
@@ -295,4 +294,3 @@ function temporalKeyFailure(createdAt, key) {
|
|
|
295
294
|
}
|
|
296
295
|
return null;
|
|
297
296
|
}
|
|
298
|
-
//# sourceMappingURL=chain.js.map
|
package/dist/failures.d.ts
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
|
|
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
|
|
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
|
|
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
|
|
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,11 +34,10 @@
|
|
|
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
|
|
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
|
export type FailureCode = 'UNSUPPORTED_FORMAT' | 'CHAIN_EMPTY' | 'CHAIN_POSITION_GAP' | 'CHAIN_GENESIS_INVALID' | 'CHAIN_LINK_BROKEN' | 'CHAIN_HASH_MISMATCH' | 'CHAIN_MALFORMED_ENTRY' | 'CHAIN_COSE_DECODE_FAILED' | 'CHAIN_COSE_HEADER_MISMATCH' | 'CHAIN_PAYLOAD_BINDING_MISMATCH' | 'CHAIN_OIDC_ACTOR_MISMATCH' | 'CHAIN_SIGNATURE_INVALID' | 'CHAIN_SIGNATURE_MISSING_KEY' | 'CHAIN_KEY_POLICY_VIOLATION' | 'CHAIN_KEY_EXPIRED' | 'CHAIN_KEY_NOT_YET_ACTIVE' | 'CHAIN_ALG_MISMATCH' | 'CHAIN_UNSUPPORTED_ALGORITHM' | 'CHAIN_SIGNING_KEY_DRIFT' | 'CHECKPOINT_ROW_MISSING' | 'CHECKPOINT_HASH_MISMATCH' | 'CHECKPOINT_SIGNATURE_INVALID' | 'TENANT_READ_LEAF_HASH_MISMATCH' | 'TENANT_READ_LEAF_INDEX_GAP' | 'TENANT_READ_SIGNATURE_INVALID' | 'TENANT_CHECKPOINT_LEAF_COUNT_MISMATCH' | 'TENANT_CHECKPOINT_ROOT_MISMATCH' | 'TENANT_CHECKPOINT_SIGNATURE_INVALID' | 'TENANT_CHECKPOINT_FORK';
|
|
42
42
|
/** The actionable next step for a failure code. */
|
|
43
43
|
export declare function suggestion(code: FailureCode): string;
|
|
44
|
-
//# sourceMappingURL=failures.d.ts.map
|
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
|
|
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
|
|
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
|
|
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
|
|
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,47 +34,46 @@
|
|
|
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
|
|
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
|
|
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 = {
|
|
46
46
|
UNSUPPORTED_FORMAT: 'This verifier reads exportFormatVersion 2.0 / RFC8949-CDE canonicalization. Re-export the chain from a current AGLedger instance, or upgrade the verifier to match the producing engine.',
|
|
47
47
|
CHAIN_EMPTY: 'No entries were present to verify. Confirm the record id / dump directory is correct and that the chain has not been truncated to zero rows.',
|
|
48
|
-
CHAIN_POSITION_GAP: 'A chain position is missing or out of order. The chain was truncated or reordered
|
|
49
|
-
CHAIN_GENESIS_INVALID: 'The first entry must carry previousHash = null. A non-null genesis link means the head of the chain was removed
|
|
50
|
-
CHAIN_LINK_BROKEN: 'An entry\'s previousHash does not match the prior entry\'s payloadHash. The chain was edited between these two entries
|
|
51
|
-
CHAIN_HASH_MISMATCH: 'sha256(cose_sign1) does not equal the stored payloadHash. The envelope bytes or the stored hash were altered
|
|
52
|
-
CHAIN_MALFORMED_ENTRY: 'An entry is missing a required field (coseSign1 or payloadHash). The export/dump is incomplete or corrupt
|
|
53
|
-
CHAIN_COSE_DECODE_FAILED: 'The COSE_Sign1 envelope did not decode as a tagged 4-element structure. The signed bytes are corrupt
|
|
54
|
-
CHAIN_COSE_HEADER_MISMATCH: 'The position/previousHash signed in the COSE protected header disagree with the row columns. The visible columns were renumbered after signing
|
|
55
|
-
CHAIN_PAYLOAD_BINDING_MISMATCH: 'The signed payload\'s structure no longer matches the canonical projection of the row columns it is bound to
|
|
48
|
+
CHAIN_POSITION_GAP: 'A chain position is missing or out of order. The chain was truncated or reordered. Obtain a complete, unmodified export/dump from the operator and re-run.',
|
|
49
|
+
CHAIN_GENESIS_INVALID: 'The first entry must carry previousHash = null. A non-null genesis link means the head of the chain was removed. Request the full chain from position 1.',
|
|
50
|
+
CHAIN_LINK_BROKEN: 'An entry\'s previousHash does not match the prior entry\'s payloadHash. The chain was edited between these two entries. Treat every entry from this position on as untrusted.',
|
|
51
|
+
CHAIN_HASH_MISMATCH: 'sha256(cose_sign1) does not equal the stored payloadHash. The envelope bytes or the stored hash were altered. The signed bytes are authoritative; the row was tampered with.',
|
|
52
|
+
CHAIN_MALFORMED_ENTRY: 'An entry is missing a required field (coseSign1 or payloadHash). The export/dump is incomplete or corrupt. Regenerate it.',
|
|
53
|
+
CHAIN_COSE_DECODE_FAILED: 'The COSE_Sign1 envelope did not decode as a tagged 4-element structure. The signed bytes are corrupt. Regenerate the export/dump.',
|
|
54
|
+
CHAIN_COSE_HEADER_MISMATCH: 'The position/previousHash signed in the COSE protected header disagree with the row columns. The visible columns were renumbered after signing. Trust the signed header, not the columns.',
|
|
55
|
+
CHAIN_PAYLOAD_BINDING_MISMATCH: 'The signed payload\'s structure no longer matches the canonical projection of the row columns it is bound to: the visible (denormalised) payload was altered after signing. This is a binding-integrity failure, not a judgement on content.',
|
|
56
56
|
CHAIN_OIDC_ACTOR_MISMATCH: 'The denormalised actor OIDC issuer/subject columns disagree with the identity signed in predicate.on_behalf_of. The actor columns were tampered with after signing.',
|
|
57
|
-
CHAIN_SIGNATURE_INVALID: 'The
|
|
57
|
+
CHAIN_SIGNATURE_INVALID: 'The COSE_Sign1 signature did not verify against the entry\'s signing key, under the algorithm that key commits to. The entry was forged or altered: obtain the verification keys out of band and re-run.',
|
|
58
58
|
CHAIN_SIGNATURE_MISSING_KEY: 'No public key was available for the entry\'s signingKeyId. Supply the key out of band (GET /v1/verification-keys or /.well-known/scitt-keys) and re-run.',
|
|
59
59
|
CHAIN_KEY_POLICY_VIOLATION: 'The entry\'s signing key violates the caller\'s trust policy (requireKeyId, or out-of-band keys required). Re-run with the expected key id, or with keys obtained out of band rather than the engine-embedded set.',
|
|
60
60
|
CHAIN_KEY_EXPIRED: 'The entry was written AFTER its signing key was retired. Possible use of a compromised retired key: check the key rotation and retention record for that key id.',
|
|
61
61
|
CHAIN_KEY_NOT_YET_ACTIVE: 'The entry was written BEFORE its signing key was activated. Not a rotation problem: the usual causes are a backdated entry or clock skew between the signer and the key registry. Compare the entry write time against the key activation time before treating this as tamper.',
|
|
62
62
|
CHAIN_ALG_MISMATCH: 'The algorithm in the signed protected header (label 1) is not one the entry\'s trusted verification key can produce, or the key registry\'s declared algorithm contradicts the key material itself. Tamper class: the header alg or the key registry was rewritten. Treat the entry as forged; obtain the verification keys out of band and re-run.',
|
|
63
|
-
CHAIN_UNSUPPORTED_ALGORITHM: 'The entry\'s trusted verification key commits to a signature algorithm this verifier build
|
|
63
|
+
CHAIN_UNSUPPORTED_ALGORITHM: 'The entry\'s trusted verification key commits to a signature algorithm that could not be computed, either because this verifier build does not implement it or because the host runtime refused it (an active OpenSSL FIPS provider carries no EdDSA). The chain is NOT verified, and this is NOT tamper evidence: the signature was never checked. Upgrade the verifier, or re-run on a host without the restriction. Never treat this result as a pass.',
|
|
64
64
|
CHAIN_SIGNING_KEY_DRIFT: 'The entry\'s signingKeyId column names a different key than the signature-covered kid in the COSE protected header. The column is a denormalized convenience and was rewritten after signing (possibly to point verification at another key). Trust the signed kid; treat the row as tampered.',
|
|
65
|
-
CHECKPOINT_ROW_MISSING: 'A signed checkpoint anchors a position that has no matching chain row. The chain was truncated below a checkpoint (out-of-band DELETE/TRUNCATE)
|
|
66
|
-
CHECKPOINT_HASH_MISMATCH: 'A checkpoint\'s payloadHash does not match the chain row at its position. The chain diverged from what was checkpointed
|
|
67
|
-
CHECKPOINT_SIGNATURE_INVALID: 'A checkpoint\'s COSE_Sign1 signature did not verify. The checkpoint was forged or altered
|
|
65
|
+
CHECKPOINT_ROW_MISSING: 'A signed checkpoint anchors a position that has no matching chain row. The chain was truncated below a checkpoint (out-of-band DELETE/TRUNCATE). The checkpoint is proof of the missing rows.',
|
|
66
|
+
CHECKPOINT_HASH_MISMATCH: 'A checkpoint\'s payloadHash does not match the chain row at its position. The chain diverged from what was checkpointed. Treat the chain as tampered.',
|
|
67
|
+
CHECKPOINT_SIGNATURE_INVALID: 'A checkpoint\'s COSE_Sign1 signature did not verify. The checkpoint was forged or altered. Re-run with out-of-band verification keys.',
|
|
68
68
|
TENANT_READ_LEAF_HASH_MISMATCH: 'An org_admin_reads leaf hash does not match sha256(cose_sign1). The read-log leaf was altered after recording.',
|
|
69
|
-
TENANT_READ_LEAF_INDEX_GAP: 'org_admin_reads leaf indices are not gap-free for this org. A read-log entry was removed
|
|
69
|
+
TENANT_READ_LEAF_INDEX_GAP: 'org_admin_reads leaf indices are not gap-free for this org. A read-log entry was removed. Obtain the complete log.',
|
|
70
70
|
TENANT_READ_SIGNATURE_INVALID: 'An org_admin_reads leaf\'s COSE_Sign1 signature did not verify. The read-log leaf was forged or altered.',
|
|
71
71
|
TENANT_CHECKPOINT_LEAF_COUNT_MISMATCH: 'A signed tree head commits to more leaves than the dump contains. The read log was truncated below a checkpoint.',
|
|
72
72
|
TENANT_CHECKPOINT_ROOT_MISMATCH: 'The recomputed Merkle root does not match the signed root_hash. The read log diverged from what was checkpointed.',
|
|
73
73
|
TENANT_CHECKPOINT_SIGNATURE_INVALID: 'A signed-tree-head COSE_Sign1 signature did not verify. The STH was forged or altered.',
|
|
74
|
-
TENANT_CHECKPOINT_FORK: 'Two signed tree heads at the same tree_size carry different roots. This is an engine fork or signing-key compromise
|
|
74
|
+
TENANT_CHECKPOINT_FORK: 'Two signed tree heads at the same tree_size carry different roots. This is an engine fork or signing-key compromise. Escalate immediately.',
|
|
75
75
|
};
|
|
76
76
|
/** The actionable next step for a failure code. */
|
|
77
77
|
export function suggestion(code) {
|
|
78
78
|
return SUGGESTIONS[code];
|
|
79
79
|
}
|
|
80
|
-
//# sourceMappingURL=failures.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @agledger/verify-core
|
|
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
|
*/
|
|
@@ -9,6 +9,5 @@ export { buildKeyRegistry, verifyChain, } from './chain.js';
|
|
|
9
9
|
export type { KeySource, VerificationKey, KeyRegistry, NormalizedEntry, OptionalCheck, CheckApplicability, SignatureOutcome, ChainEntryResult, ChainResult, VerifyChainOptions, } from './chain.js';
|
|
10
10
|
export { verifyAuditExport } from './audit-export.js';
|
|
11
11
|
export type { AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerifyExportOptions, OutOfBandKeyEntry, EntryVerificationResult, VerifyExportResult, } from './audit-export.js';
|
|
12
|
-
export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, decodeCoseSign1, verifyCoseSign1, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, merkleRoot, verifyInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
|
|
12
|
+
export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, merkleRoot, verifyInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
|
|
13
13
|
export type { CoseSign1Parts, CoseVerifyOutcome, KeyAlgorithm, ChainClaim, ReceiptInclusionProof, ReceiptVerifyOutcome, } from './primitives.js';
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @agledger/verify-core
|
|
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
|
*/
|
|
6
6
|
export { suggestion } from './failures.js';
|
|
7
7
|
export { buildKeyRegistry, verifyChain, } from './chain.js';
|
|
8
8
|
export { verifyAuditExport } from './audit-export.js';
|
|
9
|
-
export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, decodeCoseSign1, verifyCoseSign1, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, merkleRoot, verifyInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
9
|
+
export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, merkleRoot, verifyInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
|