@atp-protocol/spec 1.2.7 → 1.2.9
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 +11 -7
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -24,22 +24,26 @@ console.log(ATP_EXECUTION_STATUSES);// ["executed", "blocked", "expired", "error
|
|
|
24
24
|
### Sign and verify a receipt
|
|
25
25
|
|
|
26
26
|
```js
|
|
27
|
-
import {
|
|
27
|
+
import { createHash } from 'node:crypto';
|
|
28
|
+
import { generateSigningKeyPair, signReceipt, verifyReceiptSignature, canonicalBytes } from '@atp-protocol/spec';
|
|
28
29
|
|
|
29
30
|
const { publicKey, privateKey } = generateSigningKeyPair();
|
|
30
31
|
|
|
32
|
+
const eventSnapshot = { action: 'purchase', item: 'flowers' };
|
|
33
|
+
const now = new Date().toISOString();
|
|
34
|
+
|
|
31
35
|
const receipt = {
|
|
32
36
|
receipt_id: 'TR-123',
|
|
33
37
|
intent_id: 'TI-456',
|
|
34
38
|
decision_id: 'TD-789',
|
|
35
39
|
execution_status: 'executed',
|
|
36
40
|
schemaVersion: '1.0.0',
|
|
37
|
-
occurred_at:
|
|
38
|
-
received_at:
|
|
39
|
-
sealed_at:
|
|
40
|
-
captured_at:
|
|
41
|
-
event_snapshot:
|
|
42
|
-
event_snapshot_hash: '
|
|
41
|
+
occurred_at: now,
|
|
42
|
+
received_at: now,
|
|
43
|
+
sealed_at: now,
|
|
44
|
+
captured_at: now,
|
|
45
|
+
event_snapshot: eventSnapshot,
|
|
46
|
+
event_snapshot_hash: createHash('sha256').update(canonicalBytes(eventSnapshot)).digest('hex'),
|
|
43
47
|
correlation_id: 'sess-1'
|
|
44
48
|
};
|
|
45
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atp-protocol/spec",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
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)",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"schemas",
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/james-transient/transient-atp.git",
|
|
22
|
+
"directory": "packages/spec"
|
|
23
|
+
},
|
|
19
24
|
"publishConfig": {
|
|
20
25
|
"access": "public"
|
|
21
26
|
},
|