@atp-protocol/spec 1.2.8 → 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.
Files changed (2) hide show
  1. package/README.md +11 -7
  2. package/package.json +1 -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 { generateSigningKeyPair, signReceipt, verifyReceiptSignature } from '@atp-protocol/spec';
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: 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: '...',
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.8",
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)",