tersign 0.1.2 → 0.1.4
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 +121 -43
- package/dist/cli.js +10 -0
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/verify-bin.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,55 +1,133 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://tersign-ledger.kevinn-zhang.workers.dev"><img src="https://raw.githubusercontent.com/tersignhq/.github/main/assets/banner.svg" alt="Tersign — the evidence layer for the agent economy" width="760"></a>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/tersign"><img src="https://img.shields.io/npm/v/tersign?style=flat-square" alt="npm version"></a>
|
|
7
|
+
<a href="https://github.com/tersignhq/tersign-js/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/tersign?style=flat-square" alt="MIT license"></a>
|
|
8
|
+
<img src="https://img.shields.io/badge/npm-provenance%20attested-2ea44f?style=flat-square" alt="npm provenance attested">
|
|
9
|
+
<img src="https://img.shields.io/badge/MCP%20registry-io.github.tersignhq%2Fevidence-1c1c1c?style=flat-square" alt="MCP registry">
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
**Tersign is the evidence layer for the agent economy** — a neutral, counter-signed, hash-chained ledger for agent commerce. Sellers sign EIP-712 receipts; Tersign chains them per seller and counter-signs every entry. When the dispute comes, the transcript is already sealed.
|
|
13
|
+
|
|
14
|
+
> **Venues rotate. The transcript endures.**
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Verify a Real Entry — Right Now
|
|
19
|
+
|
|
20
|
+
No account. No API key. This is the genesis receipt, `seq 1` on the production chain:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npx tersign verify 0xe5874f1ffe87f0a6dd9eb157730f67b86ee4538b125fe30fcc4e165213dd3fc4 --ledger https://tersign-ledger.kevinn-zhang.workers.dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
ledger: counter-signed OK (seller tersign-first, seq 1 …) VALID
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`npx tersign verify <receipt.json | 0xdigest> [--ledger url]` recovers the EIP-712 signature **locally**, then checks the entry against the public chain — yours or anyone's. Prefer raw HTTP? The same proof, no CLI:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
curl https://tersign-ledger.kevinn-zhang.workers.dev/v1/receipts/0xe5874f1ffe87f0a6dd9eb157730f67b86ee4538b125fe30fcc4e165213dd3fc4/verify
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Chain of Custody
|
|
37
|
+
|
|
38
|
+
Every entry takes the same path: the seller **signs** the receipt (EIP-712, x402 offer-receipt extension) → Tersign computes the **keccak256 canonical digest** → the digest joins that **seller's hash chain**, each `seq n` bound to `seq n−1` → the neutral ledger **counter-signs** (secp256k1) → **anyone verifies**, and any venue gets a serialized envelope.
|
|
39
|
+
|
|
40
|
+
```mermaid
|
|
41
|
+
graph LR
|
|
42
|
+
A["agent transaction<br/>x402"] --> B["seller-signed receipt<br/>EIP-712"]
|
|
43
|
+
B --> C["canonical digest<br/>keccak256"]
|
|
44
|
+
C --> D["per-seller hash chain<br/>seq n binds seq n−1"]
|
|
45
|
+
D --> E["neutral counter-signature<br/>secp256k1 ledger"]
|
|
46
|
+
E --> F["verifiable by anyone<br/>venue-ready envelope"]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<sub>Diagram renders on GitHub. On npm, the paragraph above IS the diagram.</sub>
|
|
50
|
+
|
|
51
|
+
Refunds chain back to the original receipt via `refundOf`. Disputes attach to the digest with objective reason codes. Party statements are structurally segregated behind an `UNVERIFIED` marker — the evidence stays prompt-injection-hardened.
|
|
52
|
+
|
|
53
|
+
## Enter the Record
|
|
4
54
|
|
|
5
55
|
```sh
|
|
6
|
-
npm
|
|
56
|
+
npm i tersign
|
|
7
57
|
```
|
|
8
58
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
payer: settlement.payer,
|
|
38
|
-
settledAt: Math.floor(Date.now() / 1000),
|
|
39
|
-
txHash: settlement.transaction,
|
|
40
|
-
supplyDescription: 'Market data, per call',
|
|
41
|
-
});
|
|
42
|
-
return Response.json(attachToExtensions(body, issued));
|
|
59
|
+
`withAssure()` wraps your x402 fetch handler so every paid call issues a signed, chained receipt. The full register:
|
|
60
|
+
|
|
61
|
+
| Capability | In the record |
|
|
62
|
+
|---|---|
|
|
63
|
+
| Receipts | Seller-signed EIP-712 (x402 offer-receipt extension), keccak256 canonical digests |
|
|
64
|
+
| `withAssure()` | x402 fetch-handler adapter — a receipt per paid call |
|
|
65
|
+
| Compliance records | EU Art-226b minimal tier · EN 16931 full tier · HK IRO s.51C retention |
|
|
66
|
+
| Action records | `ActionRecordV1` — GDPR-minimized, EU AI Act Art-50 mapped (Art 50 binds 2026-08-02) |
|
|
67
|
+
| Refunds | Chained to the original receipt via `refundOf` |
|
|
68
|
+
| Disputes v0 | Objective reason codes, evidence submission, adjudication |
|
|
69
|
+
| Venue envelopes | Internet Court (5,000-char slot) · Kleros ERC-1497 · UMA · generic |
|
|
70
|
+
| Evidence packs | `format=art50` · `format=safr` (beta) |
|
|
71
|
+
| Idempotency | In-memory + Cloudflare D1 stores |
|
|
72
|
+
|
|
73
|
+
## For Agents — the MCP Server
|
|
74
|
+
|
|
75
|
+
`npx tersign` starts the MCP server (stdio). Official registry entry: `io.github.tersignhq/evidence` (active).
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"tersign": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["tersign"],
|
|
83
|
+
"env": { "TERSIGN_SELLER_KEY": "0x<your-seller-key>" }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
43
87
|
```
|
|
44
88
|
|
|
45
|
-
|
|
89
|
+
**Tools** — `issue_receipt` · `verify_receipt` · `verify_compliance_record` · `record_refund` · `open_dispute` · `submit_dispute_evidence` · `adjudicate_dispute` · `get_dispute`
|
|
90
|
+
|
|
91
|
+
| Env var | Required | Purpose |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `TERSIGN_SELLER_KEY` | yes | 0x-prefixed private key that signs your receipts and records |
|
|
94
|
+
| `TERSIGN_LEDGER_URL` | no | hosted ledger for counter-signing + chain checks |
|
|
95
|
+
| `TERSIGN_LEDGER_API_KEY` | no | your seller API key on that ledger |
|
|
96
|
+
| `TERSIGN_LEDGER_SELLER_ID` | no | your seller id on that ledger |
|
|
97
|
+
| `TERSIGN_ISSUER_NAME` | no | issuer name stamped on compliance records |
|
|
98
|
+
| `TERSIGN_ISSUER_JURISDICTION` | no | issuer jurisdiction stamped on compliance records |
|
|
99
|
+
|
|
100
|
+
Cold to counter-signed in one session: call `issue_receipt`, then check the issued receipt's digest with `npx tersign verify <digest> --ledger <url>`.
|
|
101
|
+
|
|
102
|
+
The agent skill `tersign-evidence` ships at [tersignhq/skills](https://github.com/tersignhq/skills).
|
|
103
|
+
|
|
104
|
+
## The Live Record
|
|
105
|
+
|
|
106
|
+
- **Ledger + dashboard** — public verify page: https://tersign-ledger.kevinn-zhang.workers.dev/verify
|
|
107
|
+
- **Census** — 1,500+ hash-chained observations across 1,000+ x402 seller endpoints, probed hourly and autonomously. Live counts: https://tersign-prober.kevinn-zhang.workers.dev/v1/prober/stats
|
|
108
|
+
|
|
109
|
+
## Machine Surfaces
|
|
110
|
+
|
|
111
|
+
Full URLs, readable without auth. If you are an agent, start here.
|
|
46
112
|
|
|
47
|
-
|
|
113
|
+
| Surface | Address |
|
|
114
|
+
|---|---|
|
|
115
|
+
| npm package | `tersign` — https://www.npmjs.com/package/tersign |
|
|
116
|
+
| MCP registry | `io.github.tersignhq/evidence` |
|
|
117
|
+
| ARD catalog (Agentic Resource Discovery) | https://tersign-ledger.kevinn-zhang.workers.dev/.well-known/ai-catalog.json |
|
|
118
|
+
| Verify API | `GET https://tersign-ledger.kevinn-zhang.workers.dev/v1/receipts/{digest}/verify` |
|
|
119
|
+
| Envelope API | `GET https://tersign-ledger.kevinn-zhang.workers.dev/v1/receipts/{digest}/envelope?venue={internet-court\|kleros\|uma\|generic}` |
|
|
120
|
+
| Ledger stats | `GET https://tersign-ledger.kevinn-zhang.workers.dev/v1/stats` |
|
|
121
|
+
| Ledger signer | `GET https://tersign-ledger.kevinn-zhang.workers.dev/v1/ledger` |
|
|
122
|
+
| llms.txt | https://raw.githubusercontent.com/tersignhq/tersign-js/main/llms.txt |
|
|
123
|
+
| Genesis verify | `npx tersign verify 0xe5874f1ffe87f0a6dd9eb157730f67b86ee4538b125fe30fcc4e165213dd3fc4 --ledger https://tersign-ledger.kevinn-zhang.workers.dev` |
|
|
48
124
|
|
|
49
|
-
|
|
125
|
+
---
|
|
50
126
|
|
|
51
|
-
|
|
127
|
+
<p align="center">
|
|
128
|
+
<img src="https://raw.githubusercontent.com/tersignhq/.github/main/assets/seal.svg" alt="Tersign seal" width="72">
|
|
129
|
+
</p>
|
|
52
130
|
|
|
53
|
-
|
|
131
|
+
<p align="center"><sub>MIT · built and published from <a href="https://github.com/tersignhq/tersign-js">tersignhq/tersign-js</a> via trusted-publishing CI, provenance attested · <code>tersign</code> reserved on PyPI</sub></p>
|
|
54
132
|
|
|
55
|
-
|
|
133
|
+
<p align="center"><sub><b>Venues rotate. The transcript endures.</b></sub></p>
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,16 @@ const sub = process.argv[2];
|
|
|
3
3
|
if (sub === undefined || sub === 'mcp') {
|
|
4
4
|
if (sub === 'mcp')
|
|
5
5
|
process.argv.splice(2, 1);
|
|
6
|
+
// Bare `npx tersign` with no config is almost always a curious human, not an MCP client —
|
|
7
|
+
// greet them with the wiring instructions instead of a stack trace.
|
|
8
|
+
if (!process.env.TERSIGN_SELLER_KEY) {
|
|
9
|
+
console.error('tersign: this command starts the MCP server, which needs TERSIGN_SELLER_KEY set.\n\n' +
|
|
10
|
+
'Wire it into your MCP client config:\n' +
|
|
11
|
+
' { "mcpServers": { "tersign": { "command": "npx", "args": ["tersign"],\n' +
|
|
12
|
+
' "env": { "TERSIGN_SELLER_KEY": "0x<your-seller-key>" } } } }\n\n' +
|
|
13
|
+
"Just exploring? Try: tersign help · tersign verify <receipt.json | 0xdigest> [--ledger url]");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
6
16
|
await import('./mcp/bin.js');
|
|
7
17
|
}
|
|
8
18
|
else if (sub === 'verify') {
|
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.4";
|
|
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.4' };
|
|
49
49
|
export function buildServer(deps) {
|
|
50
50
|
const server = new McpServer(MCP_SERVER_IDENTITY);
|
|
51
51
|
server.registerTool('issue_receipt', {
|
package/dist/verify-bin.js
CHANGED
|
@@ -43,7 +43,20 @@ if (/^0x[0-9a-f]{64}$/i.test(target)) {
|
|
|
43
43
|
console.log('VALID');
|
|
44
44
|
process.exit(0);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
let raw;
|
|
47
|
+
try {
|
|
48
|
+
raw = readFileSync(target, 'utf8');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
fail(`cannot read '${target}' — pass a receipt JSON file that exists, or a 0x… digest with --ledger`);
|
|
52
|
+
}
|
|
53
|
+
let parsed;
|
|
54
|
+
try {
|
|
55
|
+
parsed = JSON.parse(raw);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
fail(`'${target}' is not valid JSON — expected a signed receipt file`);
|
|
59
|
+
}
|
|
47
60
|
const receipt = 'payload' in parsed || 'signature' in parsed ? parsed : parsed.receipt;
|
|
48
61
|
const record = 'receipt' in parsed ? parsed.record : undefined;
|
|
49
62
|
const result = await verifyReceipt(receipt, expectedSigner);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tersign",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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",
|