@peac/audit 0.12.4 → 0.12.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.
Files changed (2) hide show
  1. package/README.md +39 -86
  2. package/package.json +23 -6
package/README.md CHANGED
@@ -1,13 +1,6 @@
1
1
  # @peac/audit
2
2
 
3
- Audit logging and case bundle generation for PEAC protocol (v0.9.27+).
4
-
5
- ## Features
6
-
7
- - **JSONL Audit Logs** - Normative format for PEAC audit trails
8
- - **Case Bundles** - Collect related entries for dispute resolution
9
- - **Trace Correlation** - Link events via W3C Trace Context
10
- - **Privacy-Safe** - Designed for privacy-preserving logging
3
+ Audit logging, case bundle generation, and commerce evidence bundling for PEAC protocol disputes and observability.
11
4
 
12
5
  ## Installation
13
6
 
@@ -15,114 +8,72 @@ Audit logging and case bundle generation for PEAC protocol (v0.9.27+).
15
8
  pnpm add @peac/audit
16
9
  ```
17
10
 
18
- ## Usage
11
+ ## What It Does
12
+
13
+ `@peac/audit` provides structured audit logging in JSONL format, case bundle generation for dispute resolution, and commerce evidence bundling for multi-protocol payment observations. It includes trace correlation via W3C Trace Context, dispute bundle creation with cryptographic integrity verification, and privacy-safe logging patterns.
19
14
 
20
- ### Creating Audit Entries
15
+ ## How Do I Use It?
16
+
17
+ ### Create and format audit entries
21
18
 
22
19
  ```typescript
23
20
  import { createAuditEntry, formatJsonl } from '@peac/audit';
24
21
 
25
- // Create an audit entry
26
22
  const entry = createAuditEntry({
27
23
  event_type: 'receipt_issued',
28
24
  actor: { type: 'system', id: 'peac-issuer' },
29
25
  resource: { type: 'receipt', id: 'jti:rec_abc123' },
30
26
  outcome: { success: true, result: 'issued' },
31
- trace: {
32
- trace_id: 'abc123def456789012345678901234ab',
33
- span_id: '1234567890123456',
34
- },
35
27
  });
36
28
 
37
- // Format to JSONL for logging
38
- const line = formatJsonl([entry], { trailingNewline: true });
29
+ const jsonl = formatJsonl([entry]);
39
30
  ```
40
31
 
41
- ### Parsing Audit Logs
32
+ ### Build a dispute bundle with integrity verification
42
33
 
43
34
  ```typescript
44
- import { parseJsonl } from '@peac/audit';
45
-
46
- const logContent = `
47
- {"version":"peac.audit/0.9","id":"01ARZ...","event_type":"receipt_issued",...}
48
- {"version":"peac.audit/0.9","id":"01ARZ...","event_type":"access_decision",...}
49
- `;
35
+ import { createDisputeBundle, verifyBundle } from '@peac/audit';
50
36
 
51
- const result = parseJsonl(logContent, { skipInvalid: true });
52
- console.log(`Parsed ${result.successCount}/${result.totalLines} entries`);
53
- ```
54
-
55
- ### Creating Case Bundles for Disputes
56
-
57
- ```typescript
58
- import { createCaseBundle, filterByDispute } from '@peac/audit';
59
-
60
- // Filter entries related to a dispute
61
- const disputeEntries = filterByDispute(allEntries, '01ARZ3NDEKTSV4RRFFQ69G5FAV');
62
-
63
- // Create a case bundle
64
- const bundle = createCaseBundle({
65
- dispute_ref: '01ARZ3NDEKTSV4RRFFQ69G5FAV',
66
- generated_by: 'https://platform.example.com/disputes',
67
- entries: disputeEntries,
37
+ const bundle = await createDisputeBundle({
38
+ kind: 'dispute',
39
+ receipts: [{ jws: compactJws, ref: receiptRef }],
40
+ jwks: { keys: [publicJwk] },
68
41
  });
69
42
 
70
- console.log(`Bundle contains ${bundle.summary.entry_count} entries`);
71
- console.log(`Time span: ${bundle.summary.first_event} to ${bundle.summary.last_event}`);
43
+ const report = await verifyBundle({ bundle });
44
+ console.log(report.summary);
72
45
  ```
73
46
 
74
- ### Trace Correlation
47
+ ### Correlate entries by trace
75
48
 
76
49
  ```typescript
77
- import { correlateByTrace } from '@peac/audit';
50
+ import { correlateByTrace, filterByTimeRange } from '@peac/audit';
78
51
 
79
- const correlations = correlateByTrace(entries);
52
+ const recent = filterByTimeRange(entries, {
53
+ start: '2026-03-01T00:00:00Z',
54
+ end: '2026-03-29T00:00:00Z',
55
+ });
80
56
 
81
- for (const trace of correlations) {
82
- console.log(`Trace ${trace.trace_id}:`);
83
- console.log(` - ${trace.entries.length} events`);
84
- console.log(` - ${trace.span_ids.length} spans`);
85
- console.log(` - Duration: ${trace.duration_ms}ms`);
57
+ const traces = correlateByTrace(recent);
58
+ for (const t of traces) {
59
+ console.log(`Trace ${t.trace_id}: ${t.entries.length} events`);
86
60
  }
87
61
  ```
88
62
 
89
- ## Audit Entry Format
63
+ ## Integrates With
90
64
 
91
- Each audit entry follows this structure:
65
+ - `@peac/kernel` (Layer 0): Error codes and type definitions
66
+ - `@peac/schema` (Layer 1): Receipt validation schemas
67
+ - `@peac/crypto` (Layer 2): Signature verification for dispute bundles
68
+ - `@peac/protocol` (Layer 3): Receipt issuance and verification
92
69
 
93
- ```typescript
94
- interface AuditEntry {
95
- version: 'peac.audit/0.9';
96
- id: string; // ULID format
97
- event_type: AuditEventType;
98
- timestamp: string; // ISO 8601
99
- severity: 'info' | 'warn' | 'error' | 'critical';
100
- trace?: TraceContext;
101
- actor: AuditActor;
102
- resource: AuditResource;
103
- outcome: AuditOutcome;
104
- context?: Record<string, unknown>;
105
- dispute_ref?: string; // ULID if related to dispute
106
- }
107
- ```
70
+ ## For Agent Developers
108
71
 
109
- ## Event Types
110
-
111
- - `receipt_issued` - Receipt was created
112
- - `receipt_verified` - Receipt was verified
113
- - `receipt_denied` - Receipt verification failed
114
- - `access_decision` - Access control decision made
115
- - `dispute_filed` - Dispute was filed
116
- - `dispute_acknowledged` - Dispute acknowledged
117
- - `dispute_resolved` - Dispute resolved
118
- - `dispute_rejected` - Dispute rejected
119
- - `dispute_appealed` - Dispute appealed
120
- - `dispute_final` - Final dispute decision
121
- - `attribution_created` - Attribution created
122
- - `attribution_verified` - Attribution verified
123
- - `identity_verified` - Identity verified
124
- - `identity_rejected` - Identity rejected
125
- - `policy_evaluated` - Policy evaluated
72
+ If you are building an AI agent or MCP server that needs evidence receipts:
73
+
74
+ - Start with [`@peac/mcp-server`](https://www.npmjs.com/package/@peac/mcp-server) for a ready-to-use MCP tool server
75
+ - Use `@peac/protocol` for programmatic receipt issuance and verification
76
+ - See the [llms.txt](https://github.com/peacprotocol/peac/blob/main/llms.txt) for a concise overview
126
77
 
127
78
  ## License
128
79
 
@@ -130,4 +81,6 @@ Apache-2.0
130
81
 
131
82
  ---
132
83
 
133
- Part of the [PEAC Protocol](https://github.com/peacprotocol/peac).
84
+ PEAC Protocol is an open source project stewarded by Originary and community contributors.
85
+
86
+ [Docs](https://www.peacprotocol.org) | [GitHub](https://github.com/peacprotocol/peac) | [Originary](https://www.originary.xyz)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peac/audit",
3
- "version": "0.12.4",
3
+ "version": "0.12.6",
4
4
  "description": "Audit logging and case bundle generation for PEAC protocol disputes",
5
5
  "main": "dist/index.cjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,10 +19,10 @@
19
19
  ],
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "https://github.com/peacprotocol/peac.git",
22
+ "url": "git+https://github.com/peacprotocol/peac.git",
23
23
  "directory": "packages/audit"
24
24
  },
25
- "author": "jithinraj <7850727+jithinraj@users.noreply.github.com>",
25
+ "author": "PEAC Protocol Contributors",
26
26
  "license": "Apache-2.0",
27
27
  "engines": {
28
28
  "node": ">=22.0.0"
@@ -30,9 +30,9 @@
30
30
  "dependencies": {
31
31
  "yazl": "^3.3.1",
32
32
  "yauzl": "^2.10.0",
33
- "@peac/crypto": "0.12.4",
34
- "@peac/schema": "0.12.4",
35
- "@peac/kernel": "0.12.4"
33
+ "@peac/crypto": "0.12.6",
34
+ "@peac/kernel": "0.12.6",
35
+ "@peac/schema": "0.12.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^22.19.11",
@@ -47,6 +47,23 @@
47
47
  "provenance": true
48
48
  },
49
49
  "sideEffects": false,
50
+ "bugs": {
51
+ "url": "https://github.com/peacprotocol/peac/issues"
52
+ },
53
+ "homepage": "https://github.com/peacprotocol/peac#readme",
54
+ "keywords": [
55
+ "peac",
56
+ "peacprotocol",
57
+ "interaction-records",
58
+ "signed-records",
59
+ "receipts",
60
+ "originary",
61
+ "audit",
62
+ "evidence",
63
+ "commerce",
64
+ "bundle",
65
+ "correlation"
66
+ ],
50
67
  "scripts": {
51
68
  "prebuild": "rm -rf dist",
52
69
  "build": "pnpm run build:js && pnpm run build:types",