tersign 0.1.5 → 0.1.6
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/dist/canonical.d.ts +9 -2
- package/dist/canonical.js +26 -14
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +1 -1
- package/package.json +1 -1
package/dist/canonical.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
/** Deterministic JSON
|
|
2
|
-
*
|
|
1
|
+
/** Deterministic JSON — RFC 8785 (JCS) conformant for JSON-domain inputs: keys sorted by
|
|
2
|
+
* UTF-16 code units, no whitespace, JSON.stringify scalar/escape semantics. Arrays keep
|
|
3
|
+
* order; undefined properties are dropped (matches JSON.stringify semantics).
|
|
4
|
+
*
|
|
5
|
+
* The string is built directly, never via an object rebuild: JS engines hoist integer-like
|
|
6
|
+
* keys ("1","2","10") into numeric order on insertion, which silently defeats a
|
|
7
|
+
* sort-then-stringify round-trip (JCS orders them "1","10","2"). Byte-identical to the old
|
|
8
|
+
* serializer for every shape without integer-like or control-char keys — the genesis receipt
|
|
9
|
+
* digest and all pinned wire vectors are unchanged. */
|
|
3
10
|
export declare function canonicalStringify(value: unknown): string;
|
|
4
11
|
export declare function digestOf(value: unknown): `0x${string}`;
|
package/dist/canonical.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import { keccak256, toBytes } from 'viem';
|
|
2
|
-
/** Deterministic JSON
|
|
3
|
-
*
|
|
2
|
+
/** Deterministic JSON — RFC 8785 (JCS) conformant for JSON-domain inputs: keys sorted by
|
|
3
|
+
* UTF-16 code units, no whitespace, JSON.stringify scalar/escape semantics. Arrays keep
|
|
4
|
+
* order; undefined properties are dropped (matches JSON.stringify semantics).
|
|
5
|
+
*
|
|
6
|
+
* The string is built directly, never via an object rebuild: JS engines hoist integer-like
|
|
7
|
+
* keys ("1","2","10") into numeric order on insertion, which silently defeats a
|
|
8
|
+
* sort-then-stringify round-trip (JCS orders them "1","10","2"). Byte-identical to the old
|
|
9
|
+
* serializer for every shape without integer-like or control-char keys — the genesis receipt
|
|
10
|
+
* digest and all pinned wire vectors are unchanged. */
|
|
4
11
|
export function canonicalStringify(value) {
|
|
5
|
-
return
|
|
12
|
+
return serialize(value);
|
|
6
13
|
}
|
|
7
|
-
function
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
10
|
-
if (value
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
function serialize(value) {
|
|
15
|
+
if (value === null)
|
|
16
|
+
return 'null';
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return '[' + Array.from(value, (v) => serialize(v) ?? 'null').join(',') + ']';
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'object') {
|
|
21
|
+
const obj = value;
|
|
22
|
+
const parts = [];
|
|
23
|
+
for (const key of Object.keys(obj).sort()) {
|
|
24
|
+
const s = serialize(obj[key]);
|
|
25
|
+
if (s !== undefined)
|
|
26
|
+
parts.push(JSON.stringify(key) + ':' + s);
|
|
16
27
|
}
|
|
17
|
-
return
|
|
28
|
+
return '{' + parts.join(',') + '}';
|
|
18
29
|
}
|
|
19
|
-
|
|
30
|
+
// string/number/boolean serialize per JCS; undefined/function/symbol yield undefined (dropped)
|
|
31
|
+
return JSON.stringify(value);
|
|
20
32
|
}
|
|
21
33
|
export function digestOf(value) {
|
|
22
34
|
return keccak256(toBytes(canonicalStringify(value)));
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export declare function envDeps(env?: Record<string, string | undefined>): McpDe
|
|
|
8
8
|
* every client; mcp.test.ts pins it against package.json so a release bump can't drift it. */
|
|
9
9
|
export declare const MCP_SERVER_IDENTITY: {
|
|
10
10
|
readonly name: "tersign";
|
|
11
|
-
readonly version: "0.1.
|
|
11
|
+
readonly version: "0.1.6";
|
|
12
12
|
};
|
|
13
13
|
export declare function buildServer(deps: McpDeps): McpServer;
|
package/dist/mcp/server.js
CHANGED
|
@@ -45,7 +45,7 @@ function json(value) {
|
|
|
45
45
|
}
|
|
46
46
|
/** MUST match package.json name/version — the MCP handshake self-reports this identity to
|
|
47
47
|
* every client; mcp.test.ts pins it against package.json so a release bump can't drift it. */
|
|
48
|
-
export const MCP_SERVER_IDENTITY = { name: 'tersign', version: '0.1.
|
|
48
|
+
export const MCP_SERVER_IDENTITY = { name: 'tersign', version: '0.1.6' };
|
|
49
49
|
export function buildServer(deps) {
|
|
50
50
|
const server = new McpServer(MCP_SERVER_IDENTITY);
|
|
51
51
|
server.registerTool('issue_receipt', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tersign",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Tersign \u2014 the evidence layer for the agent economy. Counter-signed receipts, agent action records, idempotency enforcement, refunds, disputes, and jury-ready evidence envelopes for x402/agent-commerce sellers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|