@agledger/mcp-server 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +67 -23
- package/dist/server.js.map +1 -1
- package/dist/verify/verify-export.d.ts +24 -13
- package/dist/verify/verify-export.d.ts.map +1 -1
- package/dist/verify/verify-export.js +135 -80
- package/dist/verify/verify-export.js.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to the AGLedger MCP Server will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.3.3] - 2026-05-06
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Gemini-MCP integrations no longer break on the first non-trivial call.** The three free-form object fields (`agledger_api.params`, `agledger_verify.export`, `agledger_verify.publicKeys`) were emitting `additionalProperties: {}` on a properties-less OBJECT — both keywords are outside Gemini's strict OpenAPI 3.0 function-call grammar, so any non-trivial body returned `MALFORMED_FUNCTION_CALL`. Each field is now declared as a JSON-encoded `string` on the wire (Gemini-friendly) and parsed server-side. Object-native runtimes (Claude Desktop, ChatGPT MCP) keep working — the server accepts either a stringified-JSON string or a native object via a Zod preprocess. Tool descriptions document the JSON-encoded shape with examples. (testbed F-532 / agledger-agents#67)
|
|
12
|
+
|
|
13
|
+
### Tests
|
|
14
|
+
|
|
15
|
+
- Added Gemini-shape regressions covering all three affected fields: stringified-JSON path, native-object path (back-compat), and malformed-JSON error path. The new `INVALID_JSON` error code surfaces a structured suggestion telling the agent how to retry.
|
|
16
|
+
|
|
7
17
|
## [2.3.2] - 2026-05-06
|
|
8
18
|
|
|
9
19
|
### Fixed
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmFD,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;gBAEf,OAAO,EAAE,wBAAwB;IAc7C,OAAO,CAAC,aAAa;IAkPrB,OAAO,CAAC,iBAAiB;CAkC1B"}
|
package/dist/server.js
CHANGED
|
@@ -10,7 +10,7 @@ const QUICKSTART = {
|
|
|
10
10
|
{ step: 1, action: 'List available Record types', method: 'GET', path: '/v1/schemas' },
|
|
11
11
|
{ step: 2, action: 'Get schema for your Record type', method: 'GET', path: '/v1/schemas/{type}' },
|
|
12
12
|
{ step: 3, action: 'Create a record', method: 'POST', path: '/v1/records' },
|
|
13
|
-
{ step: 4, action: 'Do your work, then submit a
|
|
13
|
+
{ step: 4, action: 'Do your work, then submit a completion', method: 'POST', path: '/v1/records/{id}/completions' },
|
|
14
14
|
],
|
|
15
15
|
};
|
|
16
16
|
const DOCS = {
|
|
@@ -41,6 +41,32 @@ function errorResult(message, code, suggestion) {
|
|
|
41
41
|
isError: true,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
+
// Free-form object fields are declared as `string` on the wire so Gemini's
|
|
45
|
+
// function-call grammar (a strict OpenAPI 3.0 subset that rejects
|
|
46
|
+
// `additionalProperties` and properties-less OBJECT) can emit them. Preprocess
|
|
47
|
+
// keeps the door open for object-native runtimes (Claude Desktop, ChatGPT MCP)
|
|
48
|
+
// that pass a native object — it re-stringifies before validation, then the
|
|
49
|
+
// handler JSON.parses uniformly.
|
|
50
|
+
const jsonStringField = z.preprocess((v) => (v !== null && typeof v === 'object' ? JSON.stringify(v) : v), z.string());
|
|
51
|
+
function parseJsonObject(value, fieldName) {
|
|
52
|
+
let parsed;
|
|
53
|
+
try {
|
|
54
|
+
parsed = JSON.parse(value);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
return {
|
|
58
|
+
ok: false,
|
|
59
|
+
error: errorResult(`Argument \`${fieldName}\` is not valid JSON: ${err instanceof Error ? err.message : String(err)}`, 'INVALID_JSON', `Pass \`${fieldName}\` as a JSON-encoded string (e.g. '{"key":"value"}') or as a native object.`),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
error: errorResult(`Argument \`${fieldName}\` must decode to a JSON object.`, 'INVALID_JSON', `Pass \`${fieldName}\` as a JSON object, e.g. '{"key":"value"}'.`),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return { ok: true, value: parsed };
|
|
69
|
+
}
|
|
44
70
|
export class AgledgerMcpServer {
|
|
45
71
|
mcp;
|
|
46
72
|
client;
|
|
@@ -108,7 +134,7 @@ export class AgledgerMcpServer {
|
|
|
108
134
|
'1. GET /v1/schemas — list Record types. ' +
|
|
109
135
|
'2. GET /v1/schemas/{type} — get required fields and examples. ' +
|
|
110
136
|
'3. POST /v1/records — create a record. ' +
|
|
111
|
-
'4. POST /v1/records/{id}/
|
|
137
|
+
'4. POST /v1/records/{id}/completions — submit evidence when done. ' +
|
|
112
138
|
'If a call fails, read the suggestion field in the error response. ' +
|
|
113
139
|
'For the full API catalog, GET /openapi.json (or read the agledger://openapi resource). ' +
|
|
114
140
|
'For GET/DELETE, params become query parameters. For POST/PUT/PATCH, params become the JSON body.',
|
|
@@ -116,11 +142,12 @@ export class AgledgerMcpServer {
|
|
|
116
142
|
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).describe('HTTP method'),
|
|
117
143
|
path: z
|
|
118
144
|
.string()
|
|
119
|
-
.describe('API path starting with / (e.g. /v1/records, /v1/schemas, /v1/records/{id}/
|
|
120
|
-
params:
|
|
121
|
-
.record(z.string(), z.unknown())
|
|
145
|
+
.describe('API path starting with / (e.g. /v1/records, /v1/schemas, /v1/records/{id}/completions)'),
|
|
146
|
+
params: jsonStringField
|
|
122
147
|
.optional()
|
|
123
|
-
.describe('Request parameters
|
|
148
|
+
.describe('Request parameters as a JSON-encoded string, e.g. \'{"type":"ACH-PROC-v1","platform":"my-app"}\'. ' +
|
|
149
|
+
'For GET/DELETE: becomes query parameters. For POST/PUT/PATCH: becomes the JSON body. ' +
|
|
150
|
+
'Native JSON objects are also accepted for compatibility.'),
|
|
124
151
|
},
|
|
125
152
|
annotations: {
|
|
126
153
|
readOnlyHint: false,
|
|
@@ -136,12 +163,15 @@ export class AgledgerMcpServer {
|
|
|
136
163
|
'Example: /v1/records, /v1/schemas. Call agledger_discover for the full workflow.', 'PATH_INVALID', 'Prefix the path with /v1/ (e.g. /v1/records). Call agledger_discover if unsure which path to use.');
|
|
137
164
|
}
|
|
138
165
|
const options = {};
|
|
139
|
-
if (params) {
|
|
166
|
+
if (params !== undefined && params !== '') {
|
|
167
|
+
const decoded = parseJsonObject(params, 'params');
|
|
168
|
+
if (!decoded.ok)
|
|
169
|
+
return decoded.error;
|
|
140
170
|
if (method === 'GET' || method === 'DELETE') {
|
|
141
|
-
options.query =
|
|
171
|
+
options.query = decoded.value;
|
|
142
172
|
}
|
|
143
173
|
else {
|
|
144
|
-
options.body =
|
|
174
|
+
options.body = decoded.value;
|
|
145
175
|
}
|
|
146
176
|
}
|
|
147
177
|
const response = await client.request(method, path, options);
|
|
@@ -173,22 +203,25 @@ export class AgledgerMcpServer {
|
|
|
173
203
|
});
|
|
174
204
|
this.mcp.registerTool('agledger_verify', {
|
|
175
205
|
title: 'Verify Audit Export',
|
|
176
|
-
description: 'Verify an AGLedger audit export offline
|
|
177
|
-
'
|
|
206
|
+
description: 'Verify an AGLedger record audit export offline (format 2.0, COSE_Sign1). ' +
|
|
207
|
+
'Decodes each entry\'s tagged COSE_Sign1 envelope (RFC 9052, EdDSA), recomputes ' +
|
|
208
|
+
'sha256 over the envelope bytes, walks the hash chain, cross-checks the protected-' +
|
|
209
|
+
'header chain claim against the row columns, and verifies every Ed25519 signature. ' +
|
|
178
210
|
'No network calls — trust is rooted in the export\'s embedded signing keys (and/or ' +
|
|
179
211
|
'the publicKeys override). On failure, brokenAt pinpoints the first entry that failed ' +
|
|
180
|
-
'and why (payload_hash_mismatch, chain_break,
|
|
181
|
-
'position_gap, malformed_entry, unsupported_algorithm). ' +
|
|
182
|
-
'Obtain the export via agledger_api with method=GET, path=/v1/records/{id}/audit-export.'
|
|
212
|
+
'and why (payload_hash_mismatch, chain_break, cose_decode_failed, cose_header_mismatch, ' +
|
|
213
|
+
'signature_invalid, unknown_key, position_gap, malformed_entry, unsupported_algorithm). ' +
|
|
214
|
+
'Obtain the export via agledger_api with method=GET, path=/v1/records/{id}/audit-export. ' +
|
|
215
|
+
'For the raw COSE_Sign1 stream, use path=/v1/records/{id}/attestation.',
|
|
183
216
|
inputSchema: {
|
|
184
|
-
export:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
publicKeys:
|
|
188
|
-
.record(z.string(), z.string())
|
|
217
|
+
export: jsonStringField.describe('The audit export as a JSON-encoded string (the response body from ' +
|
|
218
|
+
'GET /v1/records/{id}/audit-export, JSON.stringify\'d). Native JSON ' +
|
|
219
|
+
'objects are also accepted for compatibility.'),
|
|
220
|
+
publicKeys: jsonStringField
|
|
189
221
|
.optional()
|
|
190
|
-
.describe('Optional map of signingKeyId → SPKI DER base64 public key
|
|
191
|
-
'
|
|
222
|
+
.describe('Optional map of signingKeyId → SPKI DER base64 public key, as a JSON-encoded ' +
|
|
223
|
+
'string, e.g. \'{"key-1":"MCowBQYDK2VwAyEA..."}\'. Merged over any keys embedded ' +
|
|
224
|
+
'in the export. Native JSON objects are also accepted.'),
|
|
192
225
|
requireKeyId: z
|
|
193
226
|
.string()
|
|
194
227
|
.optional()
|
|
@@ -203,10 +236,21 @@ export class AgledgerMcpServer {
|
|
|
203
236
|
},
|
|
204
237
|
}, async (args) => {
|
|
205
238
|
try {
|
|
206
|
-
const { export:
|
|
207
|
-
|
|
239
|
+
const { export: exportRaw, publicKeys: publicKeysRaw, requireKeyId } = args;
|
|
240
|
+
const decodedExport = parseJsonObject(exportRaw, 'export');
|
|
241
|
+
if (!decodedExport.ok)
|
|
242
|
+
return decodedExport.error;
|
|
243
|
+
const exportData = decodedExport.value;
|
|
244
|
+
if (!('entries' in exportData)) {
|
|
208
245
|
return errorResult('Input is not a valid audit export. Expected an object with exportMetadata and entries.', 'INVALID_EXPORT', 'Call agledger_api with method=GET and path=/v1/records/{id}/audit-export, then pass the response body as the `export` argument.');
|
|
209
246
|
}
|
|
247
|
+
let publicKeys;
|
|
248
|
+
if (publicKeysRaw !== undefined && publicKeysRaw !== '') {
|
|
249
|
+
const decodedKeys = parseJsonObject(publicKeysRaw, 'publicKeys');
|
|
250
|
+
if (!decodedKeys.ok)
|
|
251
|
+
return decodedKeys.error;
|
|
252
|
+
publicKeys = decodedKeys.value;
|
|
253
|
+
}
|
|
210
254
|
const result = verifyExport(exportData, {
|
|
211
255
|
publicKeys,
|
|
212
256
|
requireKeyId,
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,YAAY,EAA0B,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAS1B,MAAM,UAAU,GAAG;IACjB,WAAW,EAAE,qEAAqE;IAClF,KAAK,EAAE;QACL,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,6BAA6B,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE;QACtF,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,iCAAiC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE;QACjG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE;QAC3E,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,YAAY,EAA0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AE,kBAAkB;SAC7B,EACD,KAAK,IAAI,EAAE;YACT,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;YAC9D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC5E,CAAC;YACD,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,GAAG,EAAE,oBAAoB;wBACzB,QAAQ,EAAE,kBAAkB;wBAC5B,IAAI,EAAE,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;qBACxF;iBACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Offline verification of an AGLedger audit export.
|
|
2
|
+
* Offline verification of an AGLedger record audit export.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Format version 2.0: each entry carries a canonical COSE_Sign1
|
|
5
|
+
* (RFC 9052 §4.4, tag 18, EdDSA) envelope over an in-toto v1 Statement
|
|
6
|
+
* payload, deterministically CBOR-encoded per RFC 8949 §4.2.1. The hash chain
|
|
7
|
+
* links via sha256 of the COSE_Sign1 envelope bytes; the per-entry signature
|
|
8
|
+
* is the COSE signature itself.
|
|
7
9
|
*
|
|
8
10
|
* Duplicated in each shipping surface (TS SDK, CLI, MCP server) on purpose —
|
|
9
|
-
* see feedback_mcp_no_sdk.md. The CLI/MCP
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* see feedback_mcp_no_sdk.md. The CLI / MCP cannot depend on @agledger/sdk
|
|
12
|
+
* even for offline crypto. Three independent copies in this repo plus an
|
|
13
|
+
* independent Python port also serve as a cross-implementation correctness
|
|
14
|
+
* check via shared test vectors at testdata/verifier/.
|
|
13
15
|
*/
|
|
14
16
|
export interface AuditExportEntry {
|
|
15
17
|
position: number;
|
|
@@ -19,12 +21,13 @@ export interface AuditExportEntry {
|
|
|
19
21
|
payload: Record<string, unknown>;
|
|
20
22
|
integrity: {
|
|
21
23
|
payloadHash: string;
|
|
22
|
-
hashAlg?: string;
|
|
23
24
|
previousHash: string | null;
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
/** Base64-encoded canonical COSE_Sign1 envelope (RFC 9052) over an in-toto v1 Statement. */
|
|
26
|
+
coseSign1: string;
|
|
26
27
|
signingKeyId: string | null;
|
|
27
28
|
valid: boolean;
|
|
29
|
+
/** Optional base64 SCITT Receipt (COSE_Sign1 carrying an RFC 9162 inclusion proof). */
|
|
30
|
+
receipt?: string;
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
export interface RecordAuditExport {
|
|
@@ -35,20 +38,23 @@ export interface RecordAuditExport {
|
|
|
35
38
|
exportDate: string;
|
|
36
39
|
totalEntries: number;
|
|
37
40
|
chainIntegrity: boolean;
|
|
41
|
+
/** `2.0` since the COSE_Sign1 cutover. */
|
|
38
42
|
exportFormatVersion: string;
|
|
43
|
+
/** `RFC8949-CDE` since 2.0 (deterministic CBOR per §4.2.1). */
|
|
39
44
|
canonicalization: string;
|
|
40
45
|
signingPublicKey: string | null;
|
|
41
46
|
signingPublicKeys?: Record<string, string>;
|
|
42
47
|
};
|
|
43
48
|
entries: AuditExportEntry[];
|
|
44
49
|
}
|
|
50
|
+
export type EntryFailureReason = 'position_gap' | 'payload_hash_mismatch' | 'chain_break' | 'cose_decode_failed' | 'cose_header_mismatch' | 'signature_invalid' | 'unknown_key' | 'malformed_entry' | 'unsupported_algorithm';
|
|
45
51
|
export interface EntryVerificationResult {
|
|
46
52
|
position: number;
|
|
47
53
|
valid: boolean;
|
|
48
54
|
reason?: EntryFailureReason;
|
|
49
55
|
detail?: string;
|
|
56
|
+
signature?: 'ok' | 'invalid' | 'unsigned' | 'skipped' | 'decode-fail';
|
|
50
57
|
}
|
|
51
|
-
export type EntryFailureReason = 'payload_hash_mismatch' | 'chain_break' | 'position_gap' | 'signature_invalid' | 'unknown_key' | 'malformed_entry' | 'unsupported_algorithm';
|
|
52
58
|
export interface VerifyExportResult {
|
|
53
59
|
valid: boolean;
|
|
54
60
|
totalEntries: number;
|
|
@@ -60,11 +66,16 @@ export interface VerifyExportResult {
|
|
|
60
66
|
};
|
|
61
67
|
entries: EntryVerificationResult[];
|
|
62
68
|
recordId: string;
|
|
69
|
+
signatureCoverage: {
|
|
70
|
+
signed: number;
|
|
71
|
+
unsigned: number;
|
|
72
|
+
skipped: number;
|
|
73
|
+
total: number;
|
|
74
|
+
};
|
|
63
75
|
}
|
|
64
76
|
export interface VerifyExportOptions {
|
|
65
77
|
publicKeys?: Record<string, string>;
|
|
66
78
|
requireKeyId?: string;
|
|
67
79
|
}
|
|
68
80
|
export declare function verifyExport(exportData: RecordAuditExport, options?: VerifyExportOptions): VerifyExportResult;
|
|
69
|
-
export declare function canonicalize(value: unknown): string;
|
|
70
81
|
//# sourceMappingURL=verify-export.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-export.d.ts","sourceRoot":"","sources":["../../src/verify/verify-export.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify-export.d.ts","sourceRoot":"","sources":["../../src/verify/verify-export.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE;QACT,W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,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7E,OAAO,EAAE,uBAAuB,EAAE,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACzF;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,iBAAiB,EAC7B,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CA2CpB"}
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
import { createPublicKey, hash, verify as cryptoVerify } from 'node:crypto';
|
|
2
|
+
import { decode as cborDecode, encode as cborEncode, rfc8949EncodeOptions } from 'cborg';
|
|
3
|
+
const SUPPORTED_FORMAT_VERSION = '2.0';
|
|
4
|
+
const SUPPORTED_CANONICALIZATION = 'RFC8949-CDE';
|
|
5
5
|
export function verifyExport(exportData, options = {}) {
|
|
6
6
|
const meta = exportData.exportMetadata;
|
|
7
7
|
const entries = exportData.entries ?? [];
|
|
8
8
|
const keys = new KeyCache(resolveKeys(exportData, options));
|
|
9
|
+
const coverage = { signed: 0, unsigned: 0, skipped: 0, total: entries.length };
|
|
9
10
|
const entryResults = [];
|
|
10
11
|
let verifiedEntries = 0;
|
|
11
12
|
let brokenAt;
|
|
12
|
-
if (meta.
|
|
13
|
-
const detail = `Unsupported
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
valid: false,
|
|
22
|
-
totalEntries: entries.length,
|
|
23
|
-
verifiedEntries: 0,
|
|
24
|
-
brokenAt: { position: 0, reason: 'unsupported_algorithm', detail },
|
|
25
|
-
entries: [result],
|
|
26
|
-
recordId: meta.recordId,
|
|
27
|
-
};
|
|
13
|
+
if (meta.exportFormatVersion && meta.exportFormatVersion !== SUPPORTED_FORMAT_VERSION) {
|
|
14
|
+
const detail = `Unsupported exportFormatVersion ${meta.exportFormatVersion} (this verifier reads ${SUPPORTED_FORMAT_VERSION}).`;
|
|
15
|
+
return earlyFailure(meta.recordId, entries.length, detail, coverage);
|
|
16
|
+
}
|
|
17
|
+
if (meta.canonicalization && meta.canonicalization !== SUPPORTED_CANONICALIZATION) {
|
|
18
|
+
const detail = `Unsupported canonicalization ${meta.canonicalization} (only ${SUPPORTED_CANONICALIZATION} supported).`;
|
|
19
|
+
return earlyFailure(meta.recordId, entries.length, detail, coverage);
|
|
28
20
|
}
|
|
29
21
|
let prevPayloadHash = null;
|
|
30
22
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -37,6 +29,12 @@ export function verifyExport(exportData, options = {}) {
|
|
|
37
29
|
else if (!brokenAt && result.reason) {
|
|
38
30
|
brokenAt = { position: result.position, reason: result.reason, detail: result.detail };
|
|
39
31
|
}
|
|
32
|
+
if (result.signature === 'ok')
|
|
33
|
+
coverage.signed++;
|
|
34
|
+
else if (result.signature === 'unsigned')
|
|
35
|
+
coverage.unsigned++;
|
|
36
|
+
else if (result.signature === 'skipped')
|
|
37
|
+
coverage.skipped++;
|
|
40
38
|
prevPayloadHash = entry.integrity.payloadHash;
|
|
41
39
|
}
|
|
42
40
|
return {
|
|
@@ -46,11 +44,29 @@ export function verifyExport(exportData, options = {}) {
|
|
|
46
44
|
brokenAt,
|
|
47
45
|
entries: entryResults,
|
|
48
46
|
recordId: meta.recordId,
|
|
47
|
+
signatureCoverage: coverage,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function earlyFailure(recordId, totalEntries, detail, coverage) {
|
|
51
|
+
const result = {
|
|
52
|
+
position: 0,
|
|
53
|
+
valid: false,
|
|
54
|
+
reason: 'unsupported_algorithm',
|
|
55
|
+
detail,
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
valid: false,
|
|
59
|
+
totalEntries,
|
|
60
|
+
verifiedEntries: 0,
|
|
61
|
+
brokenAt: { position: 0, reason: 'unsupported_algorithm', detail },
|
|
62
|
+
entries: [result],
|
|
63
|
+
recordId,
|
|
64
|
+
signatureCoverage: coverage,
|
|
49
65
|
};
|
|
50
66
|
}
|
|
51
67
|
function resolveKeys(exportData, options) {
|
|
52
|
-
const meta = exportData.exportMetadata;
|
|
53
68
|
const merged = {};
|
|
69
|
+
const meta = exportData.exportMetadata;
|
|
54
70
|
if (meta.signingPublicKeys) {
|
|
55
71
|
for (const [k, v] of Object.entries(meta.signingPublicKeys))
|
|
56
72
|
merged[k] = v;
|
|
@@ -89,17 +105,9 @@ function verifyEntry(entry, expectedPosition, expectedPrevHash, keys, requireKey
|
|
|
89
105
|
detail: `Expected position ${expectedPosition}, got ${entry.position}`,
|
|
90
106
|
};
|
|
91
107
|
}
|
|
92
|
-
const { payloadHash, previousHash,
|
|
93
|
-
if (
|
|
94
|
-
return { position, valid: false, reason: '
|
|
95
|
-
}
|
|
96
|
-
if (signatureAlg && !SUPPORTED_SIG.has(signatureAlg)) {
|
|
97
|
-
return {
|
|
98
|
-
position,
|
|
99
|
-
valid: false,
|
|
100
|
-
reason: 'unsupported_algorithm',
|
|
101
|
-
detail: `signatureAlg=${signatureAlg}`,
|
|
102
|
-
};
|
|
108
|
+
const { payloadHash, previousHash, coseSign1, signingKeyId } = entry.integrity;
|
|
109
|
+
if (!coseSign1 || !payloadHash) {
|
|
110
|
+
return { position, valid: false, reason: 'malformed_entry', detail: 'Missing coseSign1 or payloadHash' };
|
|
103
111
|
}
|
|
104
112
|
if (previousHash !== expectedPrevHash) {
|
|
105
113
|
return {
|
|
@@ -109,80 +117,127 @@ function verifyEntry(entry, expectedPosition, expectedPrevHash, keys, requireKey
|
|
|
109
117
|
detail: `Expected previousHash=${expectedPrevHash ?? 'null'}, got ${previousHash ?? 'null'}`,
|
|
110
118
|
};
|
|
111
119
|
}
|
|
112
|
-
const
|
|
120
|
+
const envelope = Buffer.from(coseSign1, 'base64');
|
|
121
|
+
const recomputed = hash('sha256', envelope, 'hex');
|
|
113
122
|
if (recomputed !== payloadHash) {
|
|
114
123
|
return {
|
|
115
124
|
position,
|
|
116
125
|
valid: false,
|
|
117
126
|
reason: 'payload_hash_mismatch',
|
|
118
|
-
detail: `
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if (!signature || !signingKeyId) {
|
|
122
|
-
return {
|
|
123
|
-
position,
|
|
124
|
-
valid: false,
|
|
125
|
-
reason: 'malformed_entry',
|
|
126
|
-
detail: 'Missing signature or signingKeyId',
|
|
127
|
+
detail: `sha256(coseSign1) recomputed ${recomputed.slice(0, 16)}…, stored ${payloadHash.slice(0, 16)}…`,
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
+
const parts = decodeCoseSign1(envelope);
|
|
131
|
+
if (!parts) {
|
|
130
132
|
return {
|
|
131
133
|
position,
|
|
132
134
|
valid: false,
|
|
133
|
-
reason: '
|
|
134
|
-
detail:
|
|
135
|
+
reason: 'cose_decode_failed',
|
|
136
|
+
detail: 'COSE_Sign1 envelope failed to decode',
|
|
137
|
+
signature: 'decode-fail',
|
|
135
138
|
};
|
|
136
139
|
}
|
|
137
|
-
const
|
|
138
|
-
if (!
|
|
140
|
+
const chainClaim = extractChainClaim(parts.protectedBstr);
|
|
141
|
+
if (!chainClaim ||
|
|
142
|
+
chainClaim.position !== entry.position ||
|
|
143
|
+
chainClaim.previous_hash !== entry.integrity.previousHash) {
|
|
139
144
|
return {
|
|
140
145
|
position,
|
|
141
146
|
valid: false,
|
|
142
|
-
reason: '
|
|
143
|
-
detail: `
|
|
147
|
+
reason: 'cose_header_mismatch',
|
|
148
|
+
detail: `Protected-header chain claim diverges from row columns ` +
|
|
149
|
+
`(envelope says position=${chainClaim?.position ?? 'null'}, prev=${chainClaim?.previous_hash ?? 'null'}; ` +
|
|
150
|
+
`row says position=${entry.position}, prev=${entry.integrity.previousHash ?? 'null'})`,
|
|
144
151
|
};
|
|
145
152
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
sigValid = verifyEd25519(publicKey, signInput, signature);
|
|
153
|
+
if (!signingKeyId) {
|
|
154
|
+
return { position, valid: true, signature: 'skipped' };
|
|
150
155
|
}
|
|
151
|
-
|
|
156
|
+
if (requireKeyId && signingKeyId !== requireKeyId) {
|
|
152
157
|
return {
|
|
153
158
|
position,
|
|
154
159
|
valid: false,
|
|
155
|
-
reason: '
|
|
156
|
-
detail: `
|
|
160
|
+
reason: 'unknown_key',
|
|
161
|
+
detail: `Entry keyId=${signingKeyId} does not match requireKeyId=${requireKeyId}`,
|
|
157
162
|
};
|
|
158
163
|
}
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
const publicKey = keys.get(signingKeyId);
|
|
165
|
+
if (!publicKey) {
|
|
166
|
+
return { position, valid: false, reason: 'unknown_key', detail: `No public key for keyId=${signingKeyId}` };
|
|
161
167
|
}
|
|
162
|
-
|
|
168
|
+
const sigOutcome = verifyCoseSignature(parts, publicKey);
|
|
169
|
+
if (sigOutcome === 'unsigned')
|
|
170
|
+
return { position, valid: true, signature: 'unsigned' };
|
|
171
|
+
if (sigOutcome === 'ok')
|
|
172
|
+
return { position, valid: true, signature: 'ok' };
|
|
173
|
+
return {
|
|
174
|
+
position,
|
|
175
|
+
valid: false,
|
|
176
|
+
reason: 'signature_invalid',
|
|
177
|
+
detail: 'COSE_Sign1 signature did not verify',
|
|
178
|
+
signature: 'invalid',
|
|
179
|
+
};
|
|
163
180
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
// --- COSE_Sign1 primitives ---
|
|
182
|
+
const COSE_SIGN1_TAG = 18;
|
|
183
|
+
const SIG_STRUCTURE_CONTEXT = 'Signature1';
|
|
184
|
+
const AGLEDGER_LABEL_CHAIN = -65537;
|
|
185
|
+
const CHAIN_SUBLABEL_POSITION = 1;
|
|
186
|
+
const CHAIN_SUBLABEL_PREVIOUS_HASH = 2;
|
|
187
|
+
function decodeCoseSign1(bytes) {
|
|
188
|
+
try {
|
|
189
|
+
const decoded = cborDecode(bytes, {
|
|
190
|
+
useMaps: true,
|
|
191
|
+
tags: { [COSE_SIGN1_TAG]: (control) => control() },
|
|
192
|
+
});
|
|
193
|
+
if (!Array.isArray(decoded) || decoded.length !== 4)
|
|
194
|
+
return null;
|
|
195
|
+
const [protectedBstr, , payloadBstr, signature] = decoded;
|
|
196
|
+
if (!(protectedBstr instanceof Uint8Array))
|
|
197
|
+
return null;
|
|
198
|
+
if (!(payloadBstr instanceof Uint8Array))
|
|
199
|
+
return null;
|
|
200
|
+
if (!(signature instanceof Uint8Array))
|
|
201
|
+
return null;
|
|
202
|
+
return { protectedBstr, payloadBstr, signature };
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
181
207
|
}
|
|
182
|
-
function
|
|
183
|
-
|
|
208
|
+
function extractChainClaim(protectedBstr) {
|
|
209
|
+
try {
|
|
210
|
+
const ph = cborDecode(protectedBstr, { useMaps: true });
|
|
211
|
+
const chain = ph.get(AGLEDGER_LABEL_CHAIN);
|
|
212
|
+
if (!(chain instanceof Map))
|
|
213
|
+
return null;
|
|
214
|
+
const position = chain.get(CHAIN_SUBLABEL_POSITION);
|
|
215
|
+
const prev = chain.get(CHAIN_SUBLABEL_PREVIOUS_HASH);
|
|
216
|
+
if (typeof position !== 'number' && typeof position !== 'bigint')
|
|
217
|
+
return null;
|
|
218
|
+
const positionNumber = typeof position === 'bigint' ? Number(position) : position;
|
|
219
|
+
if (!Number.isInteger(positionNumber) || positionNumber < 1)
|
|
220
|
+
return null;
|
|
221
|
+
if (prev === null)
|
|
222
|
+
return { position: positionNumber, previous_hash: null };
|
|
223
|
+
if (!(prev instanceof Uint8Array))
|
|
224
|
+
return null;
|
|
225
|
+
return { position: positionNumber, previous_hash: Buffer.from(prev).toString('hex') };
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
184
230
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
231
|
+
function verifyCoseSignature(parts, publicKey) {
|
|
232
|
+
if (parts.signature.length === 64 && parts.signature.every((b) => b === 0))
|
|
233
|
+
return 'unsigned';
|
|
234
|
+
const sigStructure = [
|
|
235
|
+
SIG_STRUCTURE_CONTEXT,
|
|
236
|
+
parts.protectedBstr,
|
|
237
|
+
new Uint8Array(0),
|
|
238
|
+
parts.payloadBstr,
|
|
239
|
+
];
|
|
240
|
+
const toBeSigned = cborEncode(sigStructure, rfc8949EncodeOptions);
|
|
241
|
+
return cryptoVerify(null, toBeSigned, publicKey, parts.signature) ? 'ok' : 'invalid';
|
|
187
242
|
}
|
|
188
243
|
//# sourceMappingURL=verify-export.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-export.js","sourceRoot":"","sources":["../../src/verify/verify-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"verify-export.js","sourceRoot":"","sources":["../../src/verify/verify-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,IAAI,YAAY,EAA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AClE,OAAO,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACvF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agledger/mcp-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "AGLedger MCP Server — Thin API pass-through for AI agents via MCP protocol",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "AGLedger LLC",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
50
|
+
"cborg": "^5.1.1",
|
|
50
51
|
"zod": "^4.3.6"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|