@peac/audit 0.10.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-dag.d.ts","sourceRoot":"","sources":["../src/workflow-dag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM3C;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB,sCAAsC;;IAEtC,6CAA6C;;IAE7C,yDAAyD;;CAEjD,CAAC;AAMX;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,OAAO,WAAW,CAAC,qBAAqB,GACxC,OAAO,WAAW,CAAC,0BAA0B,GAC7C,OAAO,WAAW,CAAC,sBAAsB,GACzC,OAAO,WAAW,CAAC,yBAAyB,GAC5C,OAAO,WAAW,CAAC,2BAA2B,GAC9C,OAAO,WAAW,CAAC,yBAAyB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,IAAI,EAAE,iBAAiB,CAAC;IACxB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE;QACP,wCAAwC;QACxC,MAAM,EAAE,MAAM,CAAC;QACf,uCAAuC;QACvC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,8CAA8C;QAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,2CAA2C;QAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,8CAA8C;QAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,oCAAoC;QACpC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,4CAA4C;QAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,iCAAiC;QACjC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,0CAA0C;IAC1C,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,oDAAoD;IACpD,KAAK,EAAE;QACL,sBAAsB;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,wCAAwC;QACxC,SAAS,EAAE,MAAM,CAAC;QAClB,4BAA4B;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,uBAAuB;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,kDAAkD;QAClD,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,qBAAqB,CA2NpF;AA2KD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,MAAM,GACb,YAAY,GAAG,SAAS,CAE1B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAET"}
@@ -0,0 +1,409 @@
1
+ "use strict";
2
+ /**
3
+ * Workflow DAG Verification (v0.10.1+)
4
+ *
5
+ * Verifies the structural integrity of workflow DAGs by checking:
6
+ * - ID format validity (workflow_id, step_id)
7
+ * - Unique step IDs
8
+ * - Consistent workflow IDs
9
+ * - Parent existence (no dangling references)
10
+ * - No self-parenting
11
+ * - Acyclicity (no cycles in the DAG)
12
+ * - Limits enforcement (node count, parent count, depth, edges)
13
+ *
14
+ * Each violation maps to a specific E_WORKFLOW_* error code for structured
15
+ * error handling and audit trails.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DAG_LIMITS = void 0;
19
+ exports.verifyWorkflowDag = verifyWorkflowDag;
20
+ exports.findViolationByReason = findViolationByReason;
21
+ exports.hasViolationCode = hasViolationCode;
22
+ const schema_1 = require("@peac/schema");
23
+ const kernel_1 = require("@peac/kernel");
24
+ // ============================================================================
25
+ // Constants
26
+ // ============================================================================
27
+ /**
28
+ * DAG verification limits (DoS protection for full DAG analysis)
29
+ */
30
+ exports.DAG_LIMITS = {
31
+ /** Maximum steps in a workflow DAG */
32
+ maxSteps: 10000,
33
+ /** Maximum depth (longest path from root) */
34
+ maxDepth: 100,
35
+ /** Maximum total edges (sum of all parent references) */
36
+ maxTotalEdges: 100000,
37
+ };
38
+ // ============================================================================
39
+ // Implementation
40
+ // ============================================================================
41
+ /**
42
+ * Verify a workflow DAG for structural integrity
43
+ *
44
+ * @param contexts - Array of WorkflowContext objects representing the DAG
45
+ * @returns DagVerificationResult with violations and statistics
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * import { verifyWorkflowDag } from '@peac/audit';
50
+ *
51
+ * const result = verifyWorkflowDag(contexts);
52
+ * if (!result.valid) {
53
+ * for (const v of result.violations) {
54
+ * console.error(`${v.code}: ${v.message}`);
55
+ * }
56
+ * }
57
+ * ```
58
+ */
59
+ function verifyWorkflowDag(contexts) {
60
+ const violations = [];
61
+ const stepIdSet = new Set();
62
+ const workflowIds = new Set();
63
+ const stepMap = new Map();
64
+ let totalEdges = 0;
65
+ // -------------------------------------------------------------------------
66
+ // Phase 1: Basic validation and index building
67
+ // -------------------------------------------------------------------------
68
+ for (const ctx of contexts) {
69
+ // 1. Workflow ID format validation
70
+ if (!schema_1.WORKFLOW_ID_PATTERN.test(ctx.workflow_id)) {
71
+ violations.push({
72
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_ID_INVALID,
73
+ message: `Invalid workflow ID format: ${ctx.workflow_id}`,
74
+ details: {
75
+ reason: 'invalid_format',
76
+ workflow_id: ctx.workflow_id,
77
+ },
78
+ });
79
+ }
80
+ workflowIds.add(ctx.workflow_id);
81
+ // 2. Step ID format validation
82
+ if (!schema_1.STEP_ID_PATTERN.test(ctx.step_id)) {
83
+ violations.push({
84
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_STEP_ID_INVALID,
85
+ message: `Invalid step ID format: ${ctx.step_id}`,
86
+ details: {
87
+ reason: 'invalid_format',
88
+ step_id: ctx.step_id,
89
+ },
90
+ });
91
+ }
92
+ // 3. Unique step IDs
93
+ if (stepIdSet.has(ctx.step_id)) {
94
+ violations.push({
95
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_DAG_INVALID,
96
+ message: `Duplicate step ID: ${ctx.step_id}`,
97
+ details: {
98
+ reason: 'duplicate_step_id',
99
+ step_id: ctx.step_id,
100
+ },
101
+ });
102
+ }
103
+ else {
104
+ stepIdSet.add(ctx.step_id);
105
+ stepMap.set(ctx.step_id, ctx);
106
+ }
107
+ // 4. Self-parenting check
108
+ if (ctx.parent_step_ids.includes(ctx.step_id)) {
109
+ violations.push({
110
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_DAG_INVALID,
111
+ message: `Step cannot be its own parent: ${ctx.step_id}`,
112
+ details: {
113
+ reason: 'self_parent',
114
+ step_id: ctx.step_id,
115
+ },
116
+ });
117
+ }
118
+ // 5. Duplicate parents check
119
+ const uniqueParents = new Set(ctx.parent_step_ids);
120
+ if (uniqueParents.size !== ctx.parent_step_ids.length) {
121
+ violations.push({
122
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_DAG_INVALID,
123
+ message: `Duplicate parent references in step: ${ctx.step_id}`,
124
+ details: {
125
+ reason: 'duplicate_parents',
126
+ step_id: ctx.step_id,
127
+ },
128
+ });
129
+ }
130
+ // 6. Per-step parent count limit
131
+ if (ctx.parent_step_ids.length > schema_1.WORKFLOW_LIMITS.maxParentSteps) {
132
+ violations.push({
133
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_LIMIT_EXCEEDED,
134
+ message: `Step ${ctx.step_id} exceeds max parent count`,
135
+ details: {
136
+ reason: 'parent_count_exceeded',
137
+ step_id: ctx.step_id,
138
+ limit: 'maxParentSteps',
139
+ value: ctx.parent_step_ids.length,
140
+ max: schema_1.WORKFLOW_LIMITS.maxParentSteps,
141
+ },
142
+ });
143
+ }
144
+ totalEdges += ctx.parent_step_ids.length;
145
+ }
146
+ // -------------------------------------------------------------------------
147
+ // Phase 2: Workflow-level validation
148
+ // -------------------------------------------------------------------------
149
+ // 7. Consistent workflow IDs
150
+ if (workflowIds.size > 1) {
151
+ violations.push({
152
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_DAG_INVALID,
153
+ message: `Multiple workflow IDs found: ${[...workflowIds].join(', ')}`,
154
+ details: {
155
+ reason: 'inconsistent_workflow_ids',
156
+ workflow_id: [...workflowIds][0],
157
+ },
158
+ });
159
+ }
160
+ // 8. Node count limit
161
+ if (contexts.length > exports.DAG_LIMITS.maxSteps) {
162
+ violations.push({
163
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_LIMIT_EXCEEDED,
164
+ message: `Workflow exceeds max step count (${contexts.length} > ${exports.DAG_LIMITS.maxSteps})`,
165
+ details: {
166
+ reason: 'step_count_exceeded',
167
+ limit: 'maxSteps',
168
+ value: contexts.length,
169
+ max: exports.DAG_LIMITS.maxSteps,
170
+ },
171
+ });
172
+ }
173
+ // 9. Total edges limit
174
+ if (totalEdges > exports.DAG_LIMITS.maxTotalEdges) {
175
+ violations.push({
176
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_LIMIT_EXCEEDED,
177
+ message: `Workflow exceeds max edge count (${totalEdges} > ${exports.DAG_LIMITS.maxTotalEdges})`,
178
+ details: {
179
+ reason: 'edge_count_exceeded',
180
+ limit: 'maxTotalEdges',
181
+ value: totalEdges,
182
+ max: exports.DAG_LIMITS.maxTotalEdges,
183
+ },
184
+ });
185
+ }
186
+ // -------------------------------------------------------------------------
187
+ // Phase 3: Parent existence validation
188
+ // -------------------------------------------------------------------------
189
+ for (const ctx of contexts) {
190
+ for (const parentId of ctx.parent_step_ids) {
191
+ // 10. Parent format validation
192
+ if (!schema_1.STEP_ID_PATTERN.test(parentId)) {
193
+ violations.push({
194
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_STEP_ID_INVALID,
195
+ message: `Invalid parent step ID format: ${parentId}`,
196
+ details: {
197
+ reason: 'invalid_format',
198
+ step_id: ctx.step_id,
199
+ parent_step_id: parentId,
200
+ },
201
+ });
202
+ }
203
+ // 11. Parent existence
204
+ if (!stepMap.has(parentId)) {
205
+ violations.push({
206
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_PARENT_NOT_FOUND,
207
+ message: `Parent step not found: ${parentId} (referenced by ${ctx.step_id})`,
208
+ details: {
209
+ reason: 'parent_not_found',
210
+ step_id: ctx.step_id,
211
+ parent_step_id: parentId,
212
+ },
213
+ });
214
+ }
215
+ }
216
+ }
217
+ // -------------------------------------------------------------------------
218
+ // Phase 4: Cycle detection (DFS with color marking)
219
+ // -------------------------------------------------------------------------
220
+ const cycleViolation = detectCycle(stepMap);
221
+ if (cycleViolation) {
222
+ violations.push(cycleViolation);
223
+ }
224
+ // -------------------------------------------------------------------------
225
+ // Phase 5: Depth calculation and limit check
226
+ // -------------------------------------------------------------------------
227
+ const maxDepth = calculateMaxDepth(stepMap);
228
+ if (maxDepth > exports.DAG_LIMITS.maxDepth) {
229
+ violations.push({
230
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_LIMIT_EXCEEDED,
231
+ message: `Workflow exceeds max depth (${maxDepth} > ${exports.DAG_LIMITS.maxDepth})`,
232
+ details: {
233
+ reason: 'depth_exceeded',
234
+ limit: 'maxDepth',
235
+ value: maxDepth,
236
+ max: exports.DAG_LIMITS.maxDepth,
237
+ },
238
+ });
239
+ }
240
+ // -------------------------------------------------------------------------
241
+ // Compute statistics
242
+ // -------------------------------------------------------------------------
243
+ const rootCount = [...stepMap.values()].filter((ctx) => ctx.parent_step_ids.length === 0).length;
244
+ return {
245
+ valid: violations.length === 0,
246
+ violations,
247
+ stats: {
248
+ stepCount: contexts.length,
249
+ rootCount,
250
+ maxDepth,
251
+ totalEdges,
252
+ uniqueWorkflowIds: workflowIds.size,
253
+ },
254
+ };
255
+ }
256
+ /**
257
+ * Detect cycles using DFS with white-gray-black coloring
258
+ *
259
+ * White = unvisited
260
+ * Gray = in current path (visiting)
261
+ * Black = fully processed
262
+ */
263
+ function detectCycle(stepMap) {
264
+ const WHITE = 0;
265
+ const GRAY = 1;
266
+ const BLACK = 2;
267
+ const color = new Map();
268
+ const parent = new Map();
269
+ // Initialize all nodes as white
270
+ for (const stepId of stepMap.keys()) {
271
+ color.set(stepId, WHITE);
272
+ }
273
+ // DFS from each unvisited node
274
+ for (const startId of stepMap.keys()) {
275
+ if (color.get(startId) === WHITE) {
276
+ const cyclePath = dfsVisit(startId, stepMap, color, parent);
277
+ if (cyclePath) {
278
+ return {
279
+ code: kernel_1.ERROR_CODES.E_WORKFLOW_CYCLE_DETECTED,
280
+ message: `Cycle detected in workflow DAG: ${cyclePath.join(' -> ')}`,
281
+ details: {
282
+ reason: 'cycle_detected',
283
+ cycle_path: cyclePath,
284
+ },
285
+ };
286
+ }
287
+ }
288
+ }
289
+ return null;
290
+ }
291
+ /**
292
+ * DFS visit helper for cycle detection
293
+ *
294
+ * Note: We traverse from child to parent (reverse edge direction)
295
+ * because parent_step_ids points to predecessors.
296
+ */
297
+ function dfsVisit(nodeId, stepMap, color, parent) {
298
+ const WHITE = 0;
299
+ const GRAY = 1;
300
+ const BLACK = 2;
301
+ color.set(nodeId, GRAY);
302
+ const ctx = stepMap.get(nodeId);
303
+ if (ctx) {
304
+ for (const parentId of ctx.parent_step_ids) {
305
+ // Skip if parent doesn't exist (handled separately)
306
+ if (!stepMap.has(parentId))
307
+ continue;
308
+ if (color.get(parentId) === GRAY) {
309
+ // Found back edge -> cycle
310
+ const cyclePath = reconstructCyclePath(nodeId, parentId, parent);
311
+ return cyclePath;
312
+ }
313
+ if (color.get(parentId) === WHITE) {
314
+ parent.set(parentId, nodeId);
315
+ const result = dfsVisit(parentId, stepMap, color, parent);
316
+ if (result)
317
+ return result;
318
+ }
319
+ }
320
+ }
321
+ color.set(nodeId, BLACK);
322
+ return null;
323
+ }
324
+ /**
325
+ * Reconstruct cycle path for error reporting
326
+ */
327
+ function reconstructCyclePath(from, to, parent) {
328
+ const path = [to, from];
329
+ let current = from;
330
+ // Walk back from 'from' until we reach 'to' again
331
+ while (parent.has(current)) {
332
+ const prev = parent.get(current);
333
+ if (prev === null || prev === undefined || prev === to)
334
+ break;
335
+ path.push(prev);
336
+ current = prev;
337
+ }
338
+ // Close the cycle
339
+ path.push(to);
340
+ return path.reverse();
341
+ }
342
+ /**
343
+ * Calculate maximum depth of the DAG
344
+ *
345
+ * Depth is the longest path from any root (node with no parents) to any leaf.
346
+ * Uses memoization to avoid redundant computation.
347
+ */
348
+ function calculateMaxDepth(stepMap) {
349
+ const memo = new Map();
350
+ // Find all roots (steps with no parents)
351
+ const roots = [];
352
+ for (const [stepId, ctx] of stepMap) {
353
+ if (ctx.parent_step_ids.length === 0) {
354
+ roots.push(stepId);
355
+ }
356
+ }
357
+ // If no roots, the graph might be cyclic or empty
358
+ if (roots.length === 0) {
359
+ return stepMap.size > 0 ? -1 : 0; // -1 indicates no roots (likely cyclic)
360
+ }
361
+ // Build child map for forward traversal
362
+ const childMap = new Map();
363
+ for (const [stepId, ctx] of stepMap) {
364
+ for (const parentId of ctx.parent_step_ids) {
365
+ if (!childMap.has(parentId)) {
366
+ childMap.set(parentId, []);
367
+ }
368
+ childMap.get(parentId).push(stepId);
369
+ }
370
+ }
371
+ // Calculate depth from each root
372
+ function getDepth(stepId) {
373
+ if (memo.has(stepId)) {
374
+ return memo.get(stepId);
375
+ }
376
+ const children = childMap.get(stepId) || [];
377
+ if (children.length === 0) {
378
+ memo.set(stepId, 1);
379
+ return 1;
380
+ }
381
+ let maxChildDepth = 0;
382
+ for (const childId of children) {
383
+ maxChildDepth = Math.max(maxChildDepth, getDepth(childId));
384
+ }
385
+ const depth = 1 + maxChildDepth;
386
+ memo.set(stepId, depth);
387
+ return depth;
388
+ }
389
+ let maxDepth = 0;
390
+ for (const rootId of roots) {
391
+ maxDepth = Math.max(maxDepth, getDepth(rootId));
392
+ }
393
+ return maxDepth;
394
+ }
395
+ /**
396
+ * Extract a specific violation by reason
397
+ *
398
+ * Utility for tests and error handling
399
+ */
400
+ function findViolationByReason(result, reason) {
401
+ return result.violations.find((v) => v.details.reason === reason);
402
+ }
403
+ /**
404
+ * Check if result has a specific violation code
405
+ */
406
+ function hasViolationCode(result, code) {
407
+ return result.violations.some((v) => v.code === code);
408
+ }
409
+ //# sourceMappingURL=workflow-dag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-dag.js","sourceRoot":"","sources":["../src/workflow-dag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAmHH,8CA2NC;AAgLD,sDAKC;AAKD,4CAKC;AA1gBD,yCAIsB;AACtB,yCAA2C;AAE3C,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,sCAAsC;IACtC,QAAQ,EAAE,KAAK;IACf,6CAA6C;IAC7C,QAAQ,EAAE,GAAG;IACb,yDAAyD;IACzD,aAAa,EAAE,MAAM;CACb,CAAC;AAqEX,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,iBAAiB,CAAC,QAA2B;IAC3D,MAAM,UAAU,GAAmB,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;IACnD,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,4EAA4E;IAC5E,+CAA+C;IAC/C,4EAA4E;IAE5E,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,mCAAmC;QACnC,IAAI,CAAC,4BAAmB,CAAC,IAAI,CAA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AQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,GAAG,aAAa,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CAAC;QAC3B,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CACnC,MAA6B,EAC7B,MAAc;IAEd,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,MAA6B,EAC7B,IAAuB;IAEvB,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACxD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@peac/audit",
3
+ "version": "0.10.9",
4
+ "description": "Audit logging and case bundle generation for PEAC protocol disputes",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/peacprotocol/peac.git",
21
+ "directory": "packages/audit"
22
+ },
23
+ "author": "jithinraj <7850727+jithinraj@users.noreply.github.com>",
24
+ "license": "Apache-2.0",
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "dependencies": {
29
+ "yazl": "^2.5.1",
30
+ "yauzl": "^2.10.0",
31
+ "@peac/crypto": "0.10.9",
32
+ "@peac/kernel": "0.10.9",
33
+ "@peac/schema": "0.10.9"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^20.10.0",
37
+ "@types/yauzl": "^2.10.3",
38
+ "@types/yazl": "^2.4.5",
39
+ "typescript": "^5.3.3",
40
+ "vitest": "^1.6.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public",
44
+ "provenance": true
45
+ },
46
+ "sideEffects": false,
47
+ "scripts": {
48
+ "build": "tsc",
49
+ "typecheck": "tsc --noEmit",
50
+ "test": "vitest run",
51
+ "test:watch": "vitest",
52
+ "clean": "rm -rf dist"
53
+ }
54
+ }