@atp-protocol/spec 1.2.2 → 1.2.5

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.
Files changed (2) hide show
  1. package/README.md +102 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @atp-protocol/spec
2
+
3
+ Protocol constants, JSON schemas, Ed25519 signing, and replay protection for the **Agent Transaction Protocol (ATP) 1.0** — the open specification for autonomous agent action governance.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @atp-protocol/spec
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Protocol constants
14
+
15
+ ```js
16
+ import { ATP_PROTOCOL, ATP_VERSION, ATP_DECISION_OUTCOMES, ATP_EXECUTION_STATUSES } from '@atp-protocol/spec';
17
+
18
+ console.log(ATP_PROTOCOL); // "ATP"
19
+ console.log(ATP_VERSION); // "1.0"
20
+ console.log(ATP_DECISION_OUTCOMES); // ["allow", "approve", "deny"]
21
+ console.log(ATP_EXECUTION_STATUSES);// ["executed", "blocked", "expired", "error"]
22
+ ```
23
+
24
+ ### Sign and verify a receipt
25
+
26
+ ```js
27
+ import { generateSigningKeyPair, signReceipt, verifyReceiptSignature } from '@atp-protocol/spec';
28
+
29
+ const { publicKey, privateKey } = generateSigningKeyPair();
30
+
31
+ const receipt = {
32
+ receipt_id: 'TR-123',
33
+ intent_id: 'TI-456',
34
+ decision_id: 'TD-789',
35
+ execution_status: 'executed',
36
+ schemaVersion: '1.0.0',
37
+ occurred_at: new Date().toISOString(),
38
+ received_at: new Date().toISOString(),
39
+ sealed_at: new Date().toISOString(),
40
+ captured_at: new Date().toISOString(),
41
+ event_snapshot: { action: 'purchase' },
42
+ event_snapshot_hash: '...',
43
+ correlation_id: 'sess-1'
44
+ };
45
+
46
+ const signed = signReceipt(receipt, privateKey, 'my-key-id');
47
+ const result = verifyReceiptSignature(signed, publicKey);
48
+ // result.ok === true
49
+ ```
50
+
51
+ ### Replay protection
52
+
53
+ ```js
54
+ import { ReplayGuard } from '@atp-protocol/spec';
55
+
56
+ const guard = new ReplayGuard({ windowMs: 300_000, skewMs: 5_000 });
57
+ const result = guard.check(signedReceipt);
58
+ // result.ok === true (first presentation)
59
+ // result.ok === false, result.reason === 'receipt_replay_detected' (duplicate)
60
+ ```
61
+
62
+ ### JSON schemas
63
+
64
+ ```js
65
+ import { getSchemaPath } from '@atp-protocol/spec';
66
+
67
+ const intentSchema = getSchemaPath('intent'); // absolute path to intent.schema.json
68
+ const decisionSchema = getSchemaPath('decision');
69
+ const receiptSchema = getSchemaPath('receipt');
70
+ ```
71
+
72
+ Or import directly:
73
+
74
+ ```js
75
+ import intentSchema from '@atp-protocol/spec/schemas/intent';
76
+ import decisionSchema from '@atp-protocol/spec/schemas/decision';
77
+ import receiptSchema from '@atp-protocol/spec/schemas/receipt';
78
+ ```
79
+
80
+ ## Exports
81
+
82
+ | Export | Description |
83
+ |--------|-------------|
84
+ | `ATP_PROTOCOL` | Protocol identifier — `"ATP"` |
85
+ | `ATP_VERSION` | Protocol version — `"1.0"` |
86
+ | `ATP_DECISION_OUTCOMES` | `["allow", "approve", "deny"]` |
87
+ | `ATP_EXECUTION_STATUSES` | `["executed", "blocked", "expired", "error"]` |
88
+ | `ATP_SIGNING_ALGORITHM` | `"Ed25519"` |
89
+ | `generateSigningKeyPair()` | Generate an Ed25519 key pair (PEM) |
90
+ | `signReceipt(receipt, privateKey, kid)` | Sign a receipt with Ed25519 + RFC8785-JCS |
91
+ | `verifyReceiptSignature(receipt, publicKey)` | Verify a signed receipt |
92
+ | `receiptFingerprint(receipt)` | SHA-256 fingerprint of a receipt |
93
+ | `canonicalJSONString(obj)` | RFC8785-JCS canonical JSON string |
94
+ | `canonicalBytes(obj)` | RFC8785-JCS canonical bytes (for hashing) |
95
+ | `exportPublicKeyAsJwk(publicKey, kid)` | Export public key as JWK |
96
+ | `buildJwks(keys)` | Build a JWKS document |
97
+ | `ReplayGuard` | Sliding-window replay protection |
98
+ | `getSchemaPath(name)` | Resolve path to a bundled JSON schema |
99
+
100
+ ## License
101
+
102
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atp-protocol/spec",
3
- "version": "1.2.2",
3
+ "version": "1.2.5",
4
4
  "description": "ATP protocol constants and JSON schemas.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "James Everest <james@transientintelligence.com> (https://transientintelligence.com)",
@@ -13,7 +13,8 @@
13
13
  },
14
14
  "files": [
15
15
  "src",
16
- "schemas"
16
+ "schemas",
17
+ "README.md"
17
18
  ],
18
19
  "publishConfig": {
19
20
  "access": "public"