@peac/kernel 0.10.8 → 0.10.10

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 (42) hide show
  1. package/LICENSE +1 -1
  2. package/dist/constants.cjs +182 -0
  3. package/dist/constants.cjs.map +1 -0
  4. package/dist/constants.mjs +159 -0
  5. package/dist/constants.mjs.map +1 -0
  6. package/dist/errors.cjs +1330 -0
  7. package/dist/errors.cjs.map +1 -0
  8. package/dist/errors.generated.d.ts +3 -0
  9. package/dist/errors.generated.d.ts.map +1 -1
  10. package/dist/errors.mjs +1323 -0
  11. package/dist/errors.mjs.map +1 -0
  12. package/dist/index.cjs +1690 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.mjs +1647 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/dist/registries.cjs +139 -0
  17. package/dist/registries.cjs.map +1 -0
  18. package/dist/registries.mjs +129 -0
  19. package/dist/registries.mjs.map +1 -0
  20. package/dist/types.cjs +21 -0
  21. package/dist/types.cjs.map +1 -0
  22. package/dist/types.mjs +19 -0
  23. package/dist/types.mjs.map +1 -0
  24. package/package.json +23 -22
  25. package/dist/__tests__/http.test.js +0 -121
  26. package/dist/__tests__/http.test.js.map +0 -1
  27. package/dist/constants.js +0 -251
  28. package/dist/constants.js.map +0 -1
  29. package/dist/error-categories.generated.js +0 -30
  30. package/dist/error-categories.generated.js.map +0 -1
  31. package/dist/errors.generated.js +0 -1322
  32. package/dist/errors.generated.js.map +0 -1
  33. package/dist/errors.js +0 -18
  34. package/dist/errors.js.map +0 -1
  35. package/dist/http.js +0 -74
  36. package/dist/http.js.map +0 -1
  37. package/dist/index.js +0 -63
  38. package/dist/index.js.map +0 -1
  39. package/dist/registries.js +0 -170
  40. package/dist/registries.js.map +0 -1
  41. package/dist/types.js +0 -14
  42. package/dist/types.js.map +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,1690 @@
1
+ 'use strict';
2
+
3
+ // src/error-categories.generated.ts
4
+ var ERROR_CATEGORIES = [
5
+ "attribution",
6
+ "bundle",
7
+ "control",
8
+ "dispute",
9
+ "identity",
10
+ "infrastructure",
11
+ "interaction",
12
+ "ucp",
13
+ "validation",
14
+ "verification",
15
+ "verifier",
16
+ "workflow"
17
+ ];
18
+
19
+ // src/constants.ts
20
+ var WIRE_TYPE = "peac-receipt/0.1";
21
+ var WIRE_VERSION = "0.1";
22
+ var ALGORITHMS = {
23
+ supported: ["EdDSA"],
24
+ default: "EdDSA"
25
+ };
26
+ var HEADERS = {
27
+ receipt: "PEAC-Receipt",
28
+ receiptPointer: "PEAC-Receipt-Pointer",
29
+ dpop: "DPoP",
30
+ // Purpose headers (v0.9.24+)
31
+ purpose: "PEAC-Purpose",
32
+ purposeApplied: "PEAC-Purpose-Applied",
33
+ purposeReason: "PEAC-Purpose-Reason"
34
+ };
35
+ var POLICY = {
36
+ manifestPath: "/.well-known/peac.txt",
37
+ fallbackPath: "/peac.txt",
38
+ manifestVersion: "peac-policy/0.1",
39
+ cacheTtlSeconds: 3600,
40
+ maxBytes: 262144,
41
+ // 256 KiB
42
+ maxDepth: 8
43
+ };
44
+ var ISSUER_CONFIG = {
45
+ configPath: "/.well-known/peac-issuer.json",
46
+ configVersion: "peac-issuer/0.1",
47
+ cacheTtlSeconds: 3600,
48
+ maxBytes: 65536,
49
+ // 64 KiB
50
+ maxDepth: 4,
51
+ fetchTimeoutMs: 1e4
52
+ };
53
+ var DISCOVERY = {
54
+ manifestPath: POLICY.manifestPath,
55
+ manifestVersion: "peac/0.9",
56
+ cacheTtlSeconds: POLICY.cacheTtlSeconds
57
+ };
58
+ var JWKS = {
59
+ rotationDays: 90,
60
+ overlapDays: 7,
61
+ emergencyRevocationHours: 24
62
+ };
63
+ var RECEIPT = {
64
+ minReceiptIdLength: 16,
65
+ maxReceiptIdLength: 64,
66
+ defaultTtlSeconds: 86400
67
+ // 24 hours
68
+ };
69
+ var LIMITS = {
70
+ maxAmountCents: 999999999999,
71
+ minAmountCents: 1
72
+ };
73
+ var BUNDLE_VERSION = "peac-bundle/0.1";
74
+ var VERIFICATION_REPORT_VERSION = "peac-verification-report/0.1";
75
+ var HASH = {
76
+ /** Canonical hash algorithm */
77
+ algorithm: "sha256",
78
+ /** Hash prefix pattern */
79
+ prefix: "sha256:",
80
+ /** Valid hash regex: sha256:<64 lowercase hex> */
81
+ pattern: /^sha256:[0-9a-f]{64}$/,
82
+ /** Hex-only pattern for legacy comparison */
83
+ hexPattern: /^[0-9a-f]{64}$/
84
+ };
85
+ function parseHash(hash) {
86
+ if (!HASH.pattern.test(hash)) {
87
+ return null;
88
+ }
89
+ return {
90
+ alg: "sha256",
91
+ hex: hash.slice(7)
92
+ // Remove 'sha256:' prefix
93
+ };
94
+ }
95
+ function formatHash(hex) {
96
+ if (!HASH.hexPattern.test(hex)) {
97
+ return null;
98
+ }
99
+ return `sha256:${hex}`;
100
+ }
101
+ function isValidHash(hash) {
102
+ return HASH.pattern.test(hash);
103
+ }
104
+ var VERIFIER_LIMITS = {
105
+ /** Maximum receipt size in bytes (256 KB) */
106
+ maxReceiptBytes: 262144,
107
+ /** Maximum number of claims in a receipt */
108
+ maxClaimsCount: 100,
109
+ /** Maximum extension size in bytes (64 KB) */
110
+ maxExtensionBytes: 65536,
111
+ /** Maximum string length for individual claims (64 KB) */
112
+ maxStringLength: 65536,
113
+ /** Maximum JWKS document size in bytes (64 KB) */
114
+ maxJwksBytes: 65536,
115
+ /** Maximum number of keys in a JWKS */
116
+ maxJwksKeys: 20,
117
+ /** Maximum individual key size in bytes */
118
+ maxKeySize: 4096,
119
+ /** Network fetch timeout in milliseconds */
120
+ fetchTimeoutMs: 5e3,
121
+ /** Maximum number of redirects to follow */
122
+ maxRedirects: 3,
123
+ /** Maximum network response size in bytes (256 KB) */
124
+ maxResponseBytes: 262144
125
+ };
126
+ var VERIFIER_NETWORK = {
127
+ /** Only allow HTTPS URLs */
128
+ httpsOnly: true,
129
+ /** Block requests to private IP ranges */
130
+ blockPrivateIps: true,
131
+ /** Default redirect policy (false = no redirects) */
132
+ allowRedirects: false
133
+ };
134
+ var PRIVATE_IP_RANGES = {
135
+ /** RFC 1918 private ranges */
136
+ rfc1918: ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"],
137
+ /** Link-local addresses */
138
+ linkLocal: ["169.254.0.0/16"],
139
+ /** Loopback addresses */
140
+ loopback: ["127.0.0.0/8"],
141
+ /** IPv6 loopback */
142
+ ipv6Loopback: ["::1/128"],
143
+ /** IPv6 link-local */
144
+ ipv6LinkLocal: ["fe80::/10"]
145
+ };
146
+ var VERIFIER_POLICY_VERSION = "peac-verifier-policy/0.1";
147
+ var VERIFICATION_MODES = {
148
+ /** All verification in browser/client, may fetch JWKS */
149
+ clientSide: "client_side",
150
+ /** No network access, uses bundled/pinned keys */
151
+ offlineOnly: "offline_only",
152
+ /** Prefer offline, fallback to network */
153
+ offlinePreferred: "offline_preferred",
154
+ /** Allow network fetches for key discovery */
155
+ networkAllowed: "network_allowed"
156
+ };
157
+ var CONSTANTS = {
158
+ WIRE_TYPE,
159
+ WIRE_VERSION,
160
+ ALGORITHMS,
161
+ HEADERS,
162
+ DISCOVERY,
163
+ JWKS,
164
+ RECEIPT,
165
+ LIMITS,
166
+ BUNDLE_VERSION,
167
+ VERIFICATION_REPORT_VERSION,
168
+ HASH,
169
+ VERIFIER_LIMITS,
170
+ VERIFIER_NETWORK,
171
+ VERIFIER_POLICY_VERSION,
172
+ VERIFICATION_MODES
173
+ };
174
+
175
+ // src/errors.generated.ts
176
+ var ERROR_CODES = {
177
+ // Attribution error codes
178
+ E_ATTRIBUTION_CHAIN_TOO_DEEP: "E_ATTRIBUTION_CHAIN_TOO_DEEP",
179
+ E_ATTRIBUTION_CIRCULAR_CHAIN: "E_ATTRIBUTION_CIRCULAR_CHAIN",
180
+ E_ATTRIBUTION_EXPIRED: "E_ATTRIBUTION_EXPIRED",
181
+ E_ATTRIBUTION_HASH_INVALID: "E_ATTRIBUTION_HASH_INVALID",
182
+ E_ATTRIBUTION_INVALID_FORMAT: "E_ATTRIBUTION_INVALID_FORMAT",
183
+ E_ATTRIBUTION_INVALID_REF: "E_ATTRIBUTION_INVALID_REF",
184
+ E_ATTRIBUTION_INVALID_WEIGHT: "E_ATTRIBUTION_INVALID_WEIGHT",
185
+ E_ATTRIBUTION_MISSING_SOURCES: "E_ATTRIBUTION_MISSING_SOURCES",
186
+ E_ATTRIBUTION_NOT_YET_VALID: "E_ATTRIBUTION_NOT_YET_VALID",
187
+ E_ATTRIBUTION_RESOLUTION_FAILED: "E_ATTRIBUTION_RESOLUTION_FAILED",
188
+ E_ATTRIBUTION_RESOLUTION_TIMEOUT: "E_ATTRIBUTION_RESOLUTION_TIMEOUT",
189
+ E_ATTRIBUTION_SIZE_EXCEEDED: "E_ATTRIBUTION_SIZE_EXCEEDED",
190
+ E_ATTRIBUTION_TOO_MANY_SOURCES: "E_ATTRIBUTION_TOO_MANY_SOURCES",
191
+ E_ATTRIBUTION_UNKNOWN_USAGE: "E_ATTRIBUTION_UNKNOWN_USAGE",
192
+ // Bundle error codes
193
+ E_BUNDLE_DUPLICATE_RECEIPT: "E_BUNDLE_DUPLICATE_RECEIPT",
194
+ E_BUNDLE_HASH_MISMATCH: "E_BUNDLE_HASH_MISMATCH",
195
+ E_BUNDLE_INVALID_FORMAT: "E_BUNDLE_INVALID_FORMAT",
196
+ E_BUNDLE_KEY_MISSING: "E_BUNDLE_KEY_MISSING",
197
+ E_BUNDLE_MANIFEST_INVALID: "E_BUNDLE_MANIFEST_INVALID",
198
+ E_BUNDLE_MANIFEST_MISSING: "E_BUNDLE_MANIFEST_MISSING",
199
+ E_BUNDLE_MISSING_KEYS: "E_BUNDLE_MISSING_KEYS",
200
+ E_BUNDLE_MISSING_RECEIPTS: "E_BUNDLE_MISSING_RECEIPTS",
201
+ E_BUNDLE_PATH_TRAVERSAL: "E_BUNDLE_PATH_TRAVERSAL",
202
+ E_BUNDLE_POLICY_HASH_MISMATCH: "E_BUNDLE_POLICY_HASH_MISMATCH",
203
+ E_BUNDLE_RECEIPTS_UNORDERED: "E_BUNDLE_RECEIPTS_UNORDERED",
204
+ E_BUNDLE_RECEIPT_INVALID: "E_BUNDLE_RECEIPT_INVALID",
205
+ E_BUNDLE_SIGNATURE_INVALID: "E_BUNDLE_SIGNATURE_INVALID",
206
+ E_BUNDLE_SIZE_EXCEEDED: "E_BUNDLE_SIZE_EXCEEDED",
207
+ E_BUNDLE_TIME_RANGE_INVALID: "E_BUNDLE_TIME_RANGE_INVALID",
208
+ // Control error codes
209
+ E_CONTROL_DENIED: "E_CONTROL_DENIED",
210
+ E_CONTROL_REVIEW_REQUIRED: "E_CONTROL_REVIEW_REQUIRED",
211
+ // Dispute error codes
212
+ E_DISPUTE_DUPLICATE: "E_DISPUTE_DUPLICATE",
213
+ E_DISPUTE_EXPIRED: "E_DISPUTE_EXPIRED",
214
+ E_DISPUTE_INVALID_FORMAT: "E_DISPUTE_INVALID_FORMAT",
215
+ E_DISPUTE_INVALID_GROUNDS: "E_DISPUTE_INVALID_GROUNDS",
216
+ E_DISPUTE_INVALID_ID: "E_DISPUTE_INVALID_ID",
217
+ E_DISPUTE_INVALID_STATE: "E_DISPUTE_INVALID_STATE",
218
+ E_DISPUTE_INVALID_TARGET_TYPE: "E_DISPUTE_INVALID_TARGET_TYPE",
219
+ E_DISPUTE_INVALID_TRANSITION: "E_DISPUTE_INVALID_TRANSITION",
220
+ E_DISPUTE_INVALID_TYPE: "E_DISPUTE_INVALID_TYPE",
221
+ E_DISPUTE_MISSING_RESOLUTION: "E_DISPUTE_MISSING_RESOLUTION",
222
+ E_DISPUTE_NOT_YET_VALID: "E_DISPUTE_NOT_YET_VALID",
223
+ E_DISPUTE_OTHER_REQUIRES_DESCRIPTION: "E_DISPUTE_OTHER_REQUIRES_DESCRIPTION",
224
+ E_DISPUTE_RESOLUTION_NOT_ALLOWED: "E_DISPUTE_RESOLUTION_NOT_ALLOWED",
225
+ E_DISPUTE_TARGET_NOT_FOUND: "E_DISPUTE_TARGET_NOT_FOUND",
226
+ // Identity error codes
227
+ E_IDENTITY_BINDING_FUTURE: "E_IDENTITY_BINDING_FUTURE",
228
+ E_IDENTITY_BINDING_MISMATCH: "E_IDENTITY_BINDING_MISMATCH",
229
+ E_IDENTITY_BINDING_STALE: "E_IDENTITY_BINDING_STALE",
230
+ E_IDENTITY_DIRECTORY_UNAVAILABLE: "E_IDENTITY_DIRECTORY_UNAVAILABLE",
231
+ E_IDENTITY_EXPIRED: "E_IDENTITY_EXPIRED",
232
+ E_IDENTITY_INVALID_FORMAT: "E_IDENTITY_INVALID_FORMAT",
233
+ E_IDENTITY_KEY_EXPIRED: "E_IDENTITY_KEY_EXPIRED",
234
+ E_IDENTITY_KEY_REVOKED: "E_IDENTITY_KEY_REVOKED",
235
+ E_IDENTITY_KEY_UNKNOWN: "E_IDENTITY_KEY_UNKNOWN",
236
+ E_IDENTITY_MISSING: "E_IDENTITY_MISSING",
237
+ E_IDENTITY_NOT_YET_VALID: "E_IDENTITY_NOT_YET_VALID",
238
+ E_IDENTITY_PROOF_UNSUPPORTED: "E_IDENTITY_PROOF_UNSUPPORTED",
239
+ E_IDENTITY_SIG_INVALID: "E_IDENTITY_SIG_INVALID",
240
+ // Infrastructure error codes
241
+ E_CIRCUIT_BREAKER_OPEN: "E_CIRCUIT_BREAKER_OPEN",
242
+ E_INTERNAL: "E_INTERNAL",
243
+ E_JWKS_FETCH_FAILED: "E_JWKS_FETCH_FAILED",
244
+ E_RATE_LIMITED: "E_RATE_LIMITED",
245
+ // Interaction error codes
246
+ E_INTERACTION_INVALID_DIGEST: "E_INTERACTION_INVALID_DIGEST",
247
+ E_INTERACTION_INVALID_DIGEST_ALG: "E_INTERACTION_INVALID_DIGEST_ALG",
248
+ E_INTERACTION_INVALID_EXTENSION_KEY: "E_INTERACTION_INVALID_EXTENSION_KEY",
249
+ E_INTERACTION_INVALID_FORMAT: "E_INTERACTION_INVALID_FORMAT",
250
+ E_INTERACTION_INVALID_KIND_FORMAT: "E_INTERACTION_INVALID_KIND_FORMAT",
251
+ E_INTERACTION_INVALID_TIMING: "E_INTERACTION_INVALID_TIMING",
252
+ E_INTERACTION_KIND_RESERVED: "E_INTERACTION_KIND_RESERVED",
253
+ E_INTERACTION_MISSING_ERROR_DETAIL: "E_INTERACTION_MISSING_ERROR_DETAIL",
254
+ E_INTERACTION_MISSING_EXECUTOR: "E_INTERACTION_MISSING_EXECUTOR",
255
+ E_INTERACTION_MISSING_ID: "E_INTERACTION_MISSING_ID",
256
+ E_INTERACTION_MISSING_KIND: "E_INTERACTION_MISSING_KIND",
257
+ E_INTERACTION_MISSING_RESULT: "E_INTERACTION_MISSING_RESULT",
258
+ E_INTERACTION_MISSING_STARTED_AT: "E_INTERACTION_MISSING_STARTED_AT",
259
+ E_INTERACTION_MISSING_TARGET: "E_INTERACTION_MISSING_TARGET",
260
+ // Ucp error codes
261
+ E_UCP_EVIDENCE_SERIALIZATION_FAILED: "E_UCP_EVIDENCE_SERIALIZATION_FAILED",
262
+ E_UCP_KEY_ALGORITHM_MISMATCH: "E_UCP_KEY_ALGORITHM_MISMATCH",
263
+ E_UCP_KEY_CURVE_MISMATCH: "E_UCP_KEY_CURVE_MISMATCH",
264
+ E_UCP_KEY_NOT_FOUND: "E_UCP_KEY_NOT_FOUND",
265
+ E_UCP_ORDER_INVALID: "E_UCP_ORDER_INVALID",
266
+ E_UCP_ORDER_MISSING_ID: "E_UCP_ORDER_MISSING_ID",
267
+ E_UCP_ORDER_MISSING_LINE_ITEMS: "E_UCP_ORDER_MISSING_LINE_ITEMS",
268
+ E_UCP_ORDER_MISSING_TOTALS: "E_UCP_ORDER_MISSING_TOTALS",
269
+ E_UCP_PAYLOAD_EMPTY: "E_UCP_PAYLOAD_EMPTY",
270
+ E_UCP_PAYLOAD_NOT_JSON: "E_UCP_PAYLOAD_NOT_JSON",
271
+ E_UCP_PAYLOAD_TOO_LARGE: "E_UCP_PAYLOAD_TOO_LARGE",
272
+ E_UCP_PROFILE_FETCH_FAILED: "E_UCP_PROFILE_FETCH_FAILED",
273
+ E_UCP_PROFILE_INVALID: "E_UCP_PROFILE_INVALID",
274
+ E_UCP_PROFILE_NO_SIGNING_KEYS: "E_UCP_PROFILE_NO_SIGNING_KEYS",
275
+ E_UCP_SIGNATURE_ALGORITHM_UNSUPPORTED: "E_UCP_SIGNATURE_ALGORITHM_UNSUPPORTED",
276
+ E_UCP_SIGNATURE_B64_INVALID: "E_UCP_SIGNATURE_B64_INVALID",
277
+ E_UCP_SIGNATURE_INVALID: "E_UCP_SIGNATURE_INVALID",
278
+ E_UCP_SIGNATURE_MALFORMED: "E_UCP_SIGNATURE_MALFORMED",
279
+ E_UCP_SIGNATURE_MISSING: "E_UCP_SIGNATURE_MISSING",
280
+ E_UCP_VERIFICATION_FAILED: "E_UCP_VERIFICATION_FAILED",
281
+ // Validation error codes
282
+ E_EVIDENCE_NOT_JSON: "E_EVIDENCE_NOT_JSON",
283
+ E_EXPIRED: "E_EXPIRED",
284
+ E_INVALID_AMOUNT: "E_INVALID_AMOUNT",
285
+ E_INVALID_AUDIENCE: "E_INVALID_AUDIENCE",
286
+ E_INVALID_CURRENCY: "E_INVALID_CURRENCY",
287
+ E_INVALID_FORMAT: "E_INVALID_FORMAT",
288
+ E_INVALID_ISSUER: "E_INVALID_ISSUER",
289
+ E_INVALID_RAIL: "E_INVALID_RAIL",
290
+ E_INVALID_RECEIPT_ID: "E_INVALID_RECEIPT_ID",
291
+ E_INVALID_SUBJECT: "E_INVALID_SUBJECT",
292
+ E_MISSING_EXP: "E_MISSING_EXP",
293
+ E_MISSING_REQUIRED_CLAIM: "E_MISSING_REQUIRED_CLAIM",
294
+ E_NOT_YET_VALID: "E_NOT_YET_VALID",
295
+ E_PARSE_ATTESTATION_INVALID: "E_PARSE_ATTESTATION_INVALID",
296
+ E_PARSE_COMMERCE_INVALID: "E_PARSE_COMMERCE_INVALID",
297
+ E_PARSE_INVALID_INPUT: "E_PARSE_INVALID_INPUT",
298
+ // Verification error codes
299
+ E_INVALID_SIGNATURE: "E_INVALID_SIGNATURE",
300
+ E_KEY_NOT_FOUND: "E_KEY_NOT_FOUND",
301
+ // Verifier error codes
302
+ E_VERIFY_EXTENSION_TOO_LARGE: "E_VERIFY_EXTENSION_TOO_LARGE",
303
+ E_VERIFY_INVALID_TRANSPORT: "E_VERIFY_INVALID_TRANSPORT",
304
+ E_VERIFY_ISSUER_NOT_ALLOWED: "E_VERIFY_ISSUER_NOT_ALLOWED",
305
+ E_VERIFY_JWKS_TOO_LARGE: "E_VERIFY_JWKS_TOO_LARGE",
306
+ E_VERIFY_JWKS_TOO_MANY_KEYS: "E_VERIFY_JWKS_TOO_MANY_KEYS",
307
+ E_VERIFY_KEY_FETCH_BLOCKED: "E_VERIFY_KEY_FETCH_BLOCKED",
308
+ E_VERIFY_KEY_FETCH_FAILED: "E_VERIFY_KEY_FETCH_FAILED",
309
+ E_VERIFY_KEY_FETCH_TIMEOUT: "E_VERIFY_KEY_FETCH_TIMEOUT",
310
+ E_VERIFY_MALFORMED_RECEIPT: "E_VERIFY_MALFORMED_RECEIPT",
311
+ E_VERIFY_POINTER_DIGEST_MISMATCH: "E_VERIFY_POINTER_DIGEST_MISMATCH",
312
+ E_VERIFY_POINTER_FETCH_BLOCKED: "E_VERIFY_POINTER_FETCH_BLOCKED",
313
+ E_VERIFY_POINTER_FETCH_FAILED: "E_VERIFY_POINTER_FETCH_FAILED",
314
+ E_VERIFY_POINTER_FETCH_TIMEOUT: "E_VERIFY_POINTER_FETCH_TIMEOUT",
315
+ E_VERIFY_POINTER_FETCH_TOO_LARGE: "E_VERIFY_POINTER_FETCH_TOO_LARGE",
316
+ E_VERIFY_POLICY_VIOLATION: "E_VERIFY_POLICY_VIOLATION",
317
+ E_VERIFY_RECEIPT_TOO_LARGE: "E_VERIFY_RECEIPT_TOO_LARGE",
318
+ E_VERIFY_SCHEMA_INVALID: "E_VERIFY_SCHEMA_INVALID",
319
+ // Workflow error codes
320
+ E_WORKFLOW_CONTEXT_INVALID: "E_WORKFLOW_CONTEXT_INVALID",
321
+ E_WORKFLOW_CYCLE_DETECTED: "E_WORKFLOW_CYCLE_DETECTED",
322
+ E_WORKFLOW_DAG_INVALID: "E_WORKFLOW_DAG_INVALID",
323
+ E_WORKFLOW_ID_INVALID: "E_WORKFLOW_ID_INVALID",
324
+ E_WORKFLOW_LIMIT_EXCEEDED: "E_WORKFLOW_LIMIT_EXCEEDED",
325
+ E_WORKFLOW_PARENT_NOT_FOUND: "E_WORKFLOW_PARENT_NOT_FOUND",
326
+ E_WORKFLOW_STEP_ID_INVALID: "E_WORKFLOW_STEP_ID_INVALID",
327
+ E_WORKFLOW_SUMMARY_INVALID: "E_WORKFLOW_SUMMARY_INVALID"
328
+ };
329
+ var ERRORS = {
330
+ // Attribution error codes
331
+ E_ATTRIBUTION_CHAIN_TOO_DEEP: {
332
+ code: "E_ATTRIBUTION_CHAIN_TOO_DEEP",
333
+ http_status: 400,
334
+ title: "Attribution Chain Too Deep",
335
+ description: "Attribution chain exceeds maximum allowed depth (8)",
336
+ retriable: false,
337
+ category: "attribution"
338
+ },
339
+ E_ATTRIBUTION_CIRCULAR_CHAIN: {
340
+ code: "E_ATTRIBUTION_CIRCULAR_CHAIN",
341
+ http_status: 400,
342
+ title: "Attribution Circular Chain",
343
+ description: "Circular reference detected in attribution chain",
344
+ retriable: false,
345
+ category: "attribution"
346
+ },
347
+ E_ATTRIBUTION_EXPIRED: {
348
+ code: "E_ATTRIBUTION_EXPIRED",
349
+ http_status: 401,
350
+ title: "Attribution Expired",
351
+ description: "Attribution attestation has exceeded its expiration time",
352
+ retriable: false,
353
+ category: "attribution"
354
+ },
355
+ E_ATTRIBUTION_HASH_INVALID: {
356
+ code: "E_ATTRIBUTION_HASH_INVALID",
357
+ http_status: 400,
358
+ title: "Attribution Hash Invalid",
359
+ description: "Content hash structure is invalid (wrong algorithm, encoding, or value length)",
360
+ retriable: false,
361
+ category: "attribution"
362
+ },
363
+ E_ATTRIBUTION_INVALID_FORMAT: {
364
+ code: "E_ATTRIBUTION_INVALID_FORMAT",
365
+ http_status: 400,
366
+ title: "Attribution Invalid Format",
367
+ description: "Attribution attestation does not conform to schema",
368
+ retriable: false,
369
+ category: "attribution"
370
+ },
371
+ E_ATTRIBUTION_INVALID_REF: {
372
+ code: "E_ATTRIBUTION_INVALID_REF",
373
+ http_status: 400,
374
+ title: "Attribution Invalid Reference",
375
+ description: "Receipt reference format is invalid (must be jti:{id}, URL, or URN)",
376
+ retriable: false,
377
+ category: "attribution"
378
+ },
379
+ E_ATTRIBUTION_INVALID_WEIGHT: {
380
+ code: "E_ATTRIBUTION_INVALID_WEIGHT",
381
+ http_status: 400,
382
+ title: "Attribution Invalid Weight",
383
+ description: "Attribution weight is out of valid range (must be 0.0-1.0)",
384
+ retriable: false,
385
+ category: "attribution"
386
+ },
387
+ E_ATTRIBUTION_MISSING_SOURCES: {
388
+ code: "E_ATTRIBUTION_MISSING_SOURCES",
389
+ http_status: 400,
390
+ title: "Attribution Missing Sources",
391
+ description: "Attribution attestation has empty sources array",
392
+ retriable: false,
393
+ category: "attribution"
394
+ },
395
+ E_ATTRIBUTION_NOT_YET_VALID: {
396
+ code: "E_ATTRIBUTION_NOT_YET_VALID",
397
+ http_status: 401,
398
+ title: "Attribution Not Yet Valid",
399
+ description: "Attribution attestation issued_at time is in the future",
400
+ retriable: true,
401
+ category: "attribution"
402
+ },
403
+ E_ATTRIBUTION_RESOLUTION_FAILED: {
404
+ code: "E_ATTRIBUTION_RESOLUTION_FAILED",
405
+ http_status: 502,
406
+ title: "Attribution Resolution Failed",
407
+ description: "Failed to resolve receipt reference in attribution chain",
408
+ retriable: true,
409
+ category: "attribution"
410
+ },
411
+ E_ATTRIBUTION_RESOLUTION_TIMEOUT: {
412
+ code: "E_ATTRIBUTION_RESOLUTION_TIMEOUT",
413
+ http_status: 504,
414
+ title: "Attribution Resolution Timeout",
415
+ description: "Timeout while resolving receipt reference in attribution chain",
416
+ retriable: true,
417
+ category: "attribution"
418
+ },
419
+ E_ATTRIBUTION_SIZE_EXCEEDED: {
420
+ code: "E_ATTRIBUTION_SIZE_EXCEEDED",
421
+ http_status: 400,
422
+ title: "Attribution Size Exceeded",
423
+ description: "Attribution attestation exceeds maximum size (64KB)",
424
+ retriable: false,
425
+ category: "attribution"
426
+ },
427
+ E_ATTRIBUTION_TOO_MANY_SOURCES: {
428
+ code: "E_ATTRIBUTION_TOO_MANY_SOURCES",
429
+ http_status: 400,
430
+ title: "Attribution Too Many Sources",
431
+ description: "Attribution has too many sources (maximum 100)",
432
+ retriable: false,
433
+ category: "attribution"
434
+ },
435
+ E_ATTRIBUTION_UNKNOWN_USAGE: {
436
+ code: "E_ATTRIBUTION_UNKNOWN_USAGE",
437
+ http_status: 400,
438
+ title: "Attribution Unknown Usage",
439
+ description: "Attribution usage type is not recognized",
440
+ retriable: false,
441
+ category: "attribution"
442
+ },
443
+ // Bundle error codes
444
+ E_BUNDLE_DUPLICATE_RECEIPT: {
445
+ code: "E_BUNDLE_DUPLICATE_RECEIPT",
446
+ http_status: 400,
447
+ title: "Bundle Duplicate Receipt",
448
+ description: "Bundle contains multiple receipts with the same ID",
449
+ retriable: false,
450
+ category: "bundle"
451
+ },
452
+ E_BUNDLE_HASH_MISMATCH: {
453
+ code: "E_BUNDLE_HASH_MISMATCH",
454
+ http_status: 400,
455
+ title: "Bundle Hash Mismatch",
456
+ description: "File hash does not match value declared in manifest.json",
457
+ retriable: false,
458
+ category: "bundle"
459
+ },
460
+ E_BUNDLE_INVALID_FORMAT: {
461
+ code: "E_BUNDLE_INVALID_FORMAT",
462
+ http_status: 400,
463
+ title: "Bundle Invalid Format",
464
+ description: "Bundle archive structure is invalid (not a valid ZIP or missing required files)",
465
+ retriable: false,
466
+ category: "bundle"
467
+ },
468
+ E_BUNDLE_KEY_MISSING: {
469
+ code: "E_BUNDLE_KEY_MISSING",
470
+ http_status: 400,
471
+ title: "Bundle Key Missing",
472
+ description: "Required signing key not found in bundle (offline verification mode)",
473
+ retriable: false,
474
+ category: "bundle"
475
+ },
476
+ E_BUNDLE_MANIFEST_INVALID: {
477
+ code: "E_BUNDLE_MANIFEST_INVALID",
478
+ http_status: 400,
479
+ title: "Bundle Manifest Invalid",
480
+ description: "manifest.json does not conform to schema or contains invalid values",
481
+ retriable: false,
482
+ category: "bundle"
483
+ },
484
+ E_BUNDLE_MANIFEST_MISSING: {
485
+ code: "E_BUNDLE_MANIFEST_MISSING",
486
+ http_status: 400,
487
+ title: "Bundle Manifest Missing",
488
+ description: "manifest.json not found at bundle archive root",
489
+ retriable: false,
490
+ category: "bundle"
491
+ },
492
+ E_BUNDLE_MISSING_KEYS: {
493
+ code: "E_BUNDLE_MISSING_KEYS",
494
+ http_status: 400,
495
+ title: "Bundle Missing Keys",
496
+ description: "No verification keys provided in bundle JWKS",
497
+ retriable: false,
498
+ category: "bundle"
499
+ },
500
+ E_BUNDLE_MISSING_RECEIPTS: {
501
+ code: "E_BUNDLE_MISSING_RECEIPTS",
502
+ http_status: 400,
503
+ title: "Bundle Missing Receipts",
504
+ description: "No receipts provided when creating bundle",
505
+ retriable: false,
506
+ category: "bundle"
507
+ },
508
+ E_BUNDLE_PATH_TRAVERSAL: {
509
+ code: "E_BUNDLE_PATH_TRAVERSAL",
510
+ http_status: 400,
511
+ title: "Bundle Path Traversal",
512
+ description: "Bundle contains path traversal attack (zip-slip vulnerability)",
513
+ retriable: false,
514
+ category: "bundle"
515
+ },
516
+ E_BUNDLE_POLICY_HASH_MISMATCH: {
517
+ code: "E_BUNDLE_POLICY_HASH_MISMATCH",
518
+ http_status: 400,
519
+ title: "Bundle Policy Hash Mismatch",
520
+ description: "Policy snapshot hash does not match policy used to evaluate receipts",
521
+ retriable: false,
522
+ category: "bundle"
523
+ },
524
+ E_BUNDLE_RECEIPTS_UNORDERED: {
525
+ code: "E_BUNDLE_RECEIPTS_UNORDERED",
526
+ http_status: 400,
527
+ title: "Bundle Receipts Unordered",
528
+ description: "receipts.ndjson is not in deterministic order (issued_at, receipt_id, receipt_hash)",
529
+ retriable: false,
530
+ category: "bundle"
531
+ },
532
+ E_BUNDLE_RECEIPT_INVALID: {
533
+ code: "E_BUNDLE_RECEIPT_INVALID",
534
+ http_status: 400,
535
+ title: "Bundle Receipt Invalid",
536
+ description: "Receipt JWS in bundle is malformed or missing required claims",
537
+ retriable: false,
538
+ category: "bundle"
539
+ },
540
+ E_BUNDLE_SIGNATURE_INVALID: {
541
+ code: "E_BUNDLE_SIGNATURE_INVALID",
542
+ http_status: 400,
543
+ title: "Bundle Signature Invalid",
544
+ description: "bundle.sig JWS verification failed over manifest hash",
545
+ retriable: false,
546
+ category: "bundle"
547
+ },
548
+ E_BUNDLE_SIZE_EXCEEDED: {
549
+ code: "E_BUNDLE_SIZE_EXCEEDED",
550
+ http_status: 400,
551
+ title: "Bundle Size Exceeded",
552
+ description: "Bundle exceeds size limits (entry count, entry size, or total size)",
553
+ retriable: false,
554
+ category: "bundle"
555
+ },
556
+ E_BUNDLE_TIME_RANGE_INVALID: {
557
+ code: "E_BUNDLE_TIME_RANGE_INVALID",
558
+ http_status: 400,
559
+ title: "Bundle Time Range Invalid",
560
+ description: "Receipt issued_at is outside the bundle declared time_range",
561
+ retriable: false,
562
+ category: "bundle"
563
+ },
564
+ // Control error codes
565
+ E_CONTROL_DENIED: {
566
+ code: "E_CONTROL_DENIED",
567
+ http_status: 403,
568
+ title: "Control Decision Denied",
569
+ description: "Control engine denied authorization",
570
+ retriable: false,
571
+ category: "control"
572
+ },
573
+ E_CONTROL_REVIEW_REQUIRED: {
574
+ code: "E_CONTROL_REVIEW_REQUIRED",
575
+ http_status: 202,
576
+ title: "Review Required",
577
+ description: "Control engine requires manual review",
578
+ retriable: true,
579
+ category: "control"
580
+ },
581
+ // Dispute error codes
582
+ E_DISPUTE_DUPLICATE: {
583
+ code: "E_DISPUTE_DUPLICATE",
584
+ http_status: 409,
585
+ title: "Dispute Duplicate",
586
+ description: "A dispute with this ID already exists",
587
+ retriable: false,
588
+ category: "dispute"
589
+ },
590
+ E_DISPUTE_EXPIRED: {
591
+ code: "E_DISPUTE_EXPIRED",
592
+ http_status: 401,
593
+ title: "Dispute Expired",
594
+ description: "Dispute attestation has exceeded its expiration time",
595
+ retriable: false,
596
+ category: "dispute"
597
+ },
598
+ E_DISPUTE_INVALID_FORMAT: {
599
+ code: "E_DISPUTE_INVALID_FORMAT",
600
+ http_status: 400,
601
+ title: "Dispute Invalid Format",
602
+ description: "Dispute attestation does not conform to schema",
603
+ retriable: false,
604
+ category: "dispute"
605
+ },
606
+ E_DISPUTE_INVALID_GROUNDS: {
607
+ code: "E_DISPUTE_INVALID_GROUNDS",
608
+ http_status: 400,
609
+ title: "Dispute Invalid Grounds",
610
+ description: "Dispute grounds code is not recognized",
611
+ retriable: false,
612
+ category: "dispute"
613
+ },
614
+ E_DISPUTE_INVALID_ID: {
615
+ code: "E_DISPUTE_INVALID_ID",
616
+ http_status: 400,
617
+ title: "Dispute Invalid ID",
618
+ description: "Dispute ID is not a valid ULID format (26 uppercase alphanumeric characters)",
619
+ retriable: false,
620
+ category: "dispute"
621
+ },
622
+ E_DISPUTE_INVALID_STATE: {
623
+ code: "E_DISPUTE_INVALID_STATE",
624
+ http_status: 400,
625
+ title: "Dispute Invalid State",
626
+ description: "Dispute state is not recognized",
627
+ retriable: false,
628
+ category: "dispute"
629
+ },
630
+ E_DISPUTE_INVALID_TARGET_TYPE: {
631
+ code: "E_DISPUTE_INVALID_TARGET_TYPE",
632
+ http_status: 400,
633
+ title: "Dispute Invalid Target Type",
634
+ description: "Dispute target type is not recognized (must be receipt, attribution, identity, or policy)",
635
+ retriable: false,
636
+ category: "dispute"
637
+ },
638
+ E_DISPUTE_INVALID_TRANSITION: {
639
+ code: "E_DISPUTE_INVALID_TRANSITION",
640
+ http_status: 400,
641
+ title: "Dispute Invalid Transition",
642
+ description: "Invalid state transition for dispute lifecycle",
643
+ retriable: false,
644
+ category: "dispute"
645
+ },
646
+ E_DISPUTE_INVALID_TYPE: {
647
+ code: "E_DISPUTE_INVALID_TYPE",
648
+ http_status: 400,
649
+ title: "Dispute Invalid Type",
650
+ description: "Dispute type is not recognized",
651
+ retriable: false,
652
+ category: "dispute"
653
+ },
654
+ E_DISPUTE_MISSING_RESOLUTION: {
655
+ code: "E_DISPUTE_MISSING_RESOLUTION",
656
+ http_status: 400,
657
+ title: "Dispute Missing Resolution",
658
+ description: "Resolution is required for terminal states (resolved, rejected, final)",
659
+ retriable: false,
660
+ category: "dispute"
661
+ },
662
+ E_DISPUTE_NOT_YET_VALID: {
663
+ code: "E_DISPUTE_NOT_YET_VALID",
664
+ http_status: 401,
665
+ title: "Dispute Not Yet Valid",
666
+ description: "Dispute attestation issued_at time is in the future",
667
+ retriable: true,
668
+ category: "dispute"
669
+ },
670
+ E_DISPUTE_OTHER_REQUIRES_DESCRIPTION: {
671
+ code: "E_DISPUTE_OTHER_REQUIRES_DESCRIPTION",
672
+ http_status: 400,
673
+ title: "Dispute Other Requires Description",
674
+ description: "Dispute type 'other' requires description of at least 50 characters",
675
+ retriable: false,
676
+ category: "dispute"
677
+ },
678
+ E_DISPUTE_RESOLUTION_NOT_ALLOWED: {
679
+ code: "E_DISPUTE_RESOLUTION_NOT_ALLOWED",
680
+ http_status: 400,
681
+ title: "Dispute Resolution Not Allowed",
682
+ description: "Resolution is only valid for terminal states",
683
+ retriable: false,
684
+ category: "dispute"
685
+ },
686
+ E_DISPUTE_TARGET_NOT_FOUND: {
687
+ code: "E_DISPUTE_TARGET_NOT_FOUND",
688
+ http_status: 404,
689
+ title: "Dispute Target Not Found",
690
+ description: "The target receipt, attribution, or identity being disputed was not found",
691
+ retriable: true,
692
+ category: "dispute"
693
+ },
694
+ // Identity error codes
695
+ E_IDENTITY_BINDING_FUTURE: {
696
+ code: "E_IDENTITY_BINDING_FUTURE",
697
+ http_status: 400,
698
+ title: "Identity Binding Future",
699
+ description: "Identity binding signed_at timestamp is in the future",
700
+ retriable: false,
701
+ category: "identity"
702
+ },
703
+ E_IDENTITY_BINDING_MISMATCH: {
704
+ code: "E_IDENTITY_BINDING_MISMATCH",
705
+ http_status: 400,
706
+ title: "Identity Binding Mismatch",
707
+ description: "Identity binding does not match the request being verified",
708
+ retriable: false,
709
+ category: "identity"
710
+ },
711
+ E_IDENTITY_BINDING_STALE: {
712
+ code: "E_IDENTITY_BINDING_STALE",
713
+ http_status: 401,
714
+ title: "Identity Binding Stale",
715
+ description: "Identity binding is too old and requires fresh binding",
716
+ retriable: true,
717
+ category: "identity"
718
+ },
719
+ E_IDENTITY_DIRECTORY_UNAVAILABLE: {
720
+ code: "E_IDENTITY_DIRECTORY_UNAVAILABLE",
721
+ http_status: 503,
722
+ title: "Identity Directory Unavailable",
723
+ description: "Failed to fetch agent key directory",
724
+ retriable: true,
725
+ category: "identity"
726
+ },
727
+ E_IDENTITY_EXPIRED: {
728
+ code: "E_IDENTITY_EXPIRED",
729
+ http_status: 401,
730
+ title: "Identity Expired",
731
+ description: "Agent identity attestation has exceeded its expiration time",
732
+ retriable: false,
733
+ category: "identity"
734
+ },
735
+ E_IDENTITY_INVALID_FORMAT: {
736
+ code: "E_IDENTITY_INVALID_FORMAT",
737
+ http_status: 400,
738
+ title: "Identity Invalid Format",
739
+ description: "Agent identity attestation does not conform to schema",
740
+ retriable: false,
741
+ category: "identity"
742
+ },
743
+ E_IDENTITY_KEY_EXPIRED: {
744
+ code: "E_IDENTITY_KEY_EXPIRED",
745
+ http_status: 401,
746
+ title: "Identity Key Expired",
747
+ description: "Agent signing key has expired per directory metadata",
748
+ retriable: false,
749
+ category: "identity"
750
+ },
751
+ E_IDENTITY_KEY_REVOKED: {
752
+ code: "E_IDENTITY_KEY_REVOKED",
753
+ http_status: 401,
754
+ title: "Identity Key Revoked",
755
+ description: "Agent signing key has been explicitly revoked",
756
+ retriable: false,
757
+ category: "identity"
758
+ },
759
+ E_IDENTITY_KEY_UNKNOWN: {
760
+ code: "E_IDENTITY_KEY_UNKNOWN",
761
+ http_status: 401,
762
+ title: "Identity Key Unknown",
763
+ description: "Key ID not found in agent key directory",
764
+ retriable: true,
765
+ category: "identity"
766
+ },
767
+ E_IDENTITY_MISSING: {
768
+ code: "E_IDENTITY_MISSING",
769
+ http_status: 401,
770
+ title: "Identity Missing",
771
+ description: "No agent identity attestation provided in request",
772
+ retriable: false,
773
+ category: "identity"
774
+ },
775
+ E_IDENTITY_NOT_YET_VALID: {
776
+ code: "E_IDENTITY_NOT_YET_VALID",
777
+ http_status: 401,
778
+ title: "Identity Not Yet Valid",
779
+ description: "Agent identity attestation issued_at time is in the future",
780
+ retriable: true,
781
+ category: "identity"
782
+ },
783
+ E_IDENTITY_PROOF_UNSUPPORTED: {
784
+ code: "E_IDENTITY_PROOF_UNSUPPORTED",
785
+ http_status: 400,
786
+ title: "Identity Proof Unsupported",
787
+ description: "Agent identity proof method is not supported",
788
+ retriable: false,
789
+ category: "identity"
790
+ },
791
+ E_IDENTITY_SIG_INVALID: {
792
+ code: "E_IDENTITY_SIG_INVALID",
793
+ http_status: 401,
794
+ title: "Identity Signature Invalid",
795
+ description: "Agent identity proof signature verification failed",
796
+ retriable: false,
797
+ category: "identity"
798
+ },
799
+ // Infrastructure error codes
800
+ E_CIRCUIT_BREAKER_OPEN: {
801
+ code: "E_CIRCUIT_BREAKER_OPEN",
802
+ http_status: 503,
803
+ title: "Circuit Breaker Open",
804
+ description: "Service temporarily unavailable due to circuit breaker",
805
+ retriable: true,
806
+ category: "infrastructure"
807
+ },
808
+ E_INTERNAL: {
809
+ code: "E_INTERNAL",
810
+ http_status: 500,
811
+ title: "Internal Error",
812
+ description: "An unexpected internal error occurred during verification",
813
+ retriable: true,
814
+ category: "infrastructure"
815
+ },
816
+ E_JWKS_FETCH_FAILED: {
817
+ code: "E_JWKS_FETCH_FAILED",
818
+ http_status: 503,
819
+ title: "JWKS Fetch Failed",
820
+ description: "Failed to fetch public keys from JWKS endpoint",
821
+ retriable: true,
822
+ category: "infrastructure"
823
+ },
824
+ E_RATE_LIMITED: {
825
+ code: "E_RATE_LIMITED",
826
+ http_status: 429,
827
+ title: "Rate Limited",
828
+ description: "Too many requests, please retry later",
829
+ retriable: true,
830
+ category: "infrastructure"
831
+ },
832
+ // Interaction error codes
833
+ E_INTERACTION_INVALID_DIGEST: {
834
+ code: "E_INTERACTION_INVALID_DIGEST",
835
+ http_status: 400,
836
+ title: "Interaction Invalid Digest",
837
+ description: "Digest structure is invalid (wrong value format or missing bytes)",
838
+ retriable: false,
839
+ category: "interaction"
840
+ },
841
+ E_INTERACTION_INVALID_DIGEST_ALG: {
842
+ code: "E_INTERACTION_INVALID_DIGEST_ALG",
843
+ http_status: 400,
844
+ title: "Interaction Invalid Digest Algorithm",
845
+ description: "Digest algorithm is not in the canonical set (sha-256, sha-256:trunc-64k, sha-256:trunc-1m)",
846
+ retriable: false,
847
+ category: "interaction"
848
+ },
849
+ E_INTERACTION_INVALID_EXTENSION_KEY: {
850
+ code: "E_INTERACTION_INVALID_EXTENSION_KEY",
851
+ http_status: 400,
852
+ title: "Interaction Invalid Extension Key",
853
+ description: "Extension key does not match required format (reverse-DNS/name[@version])",
854
+ retriable: false,
855
+ category: "interaction"
856
+ },
857
+ E_INTERACTION_INVALID_FORMAT: {
858
+ code: "E_INTERACTION_INVALID_FORMAT",
859
+ http_status: 400,
860
+ title: "Interaction Invalid Format",
861
+ description: "Interaction evidence does not conform to InteractionEvidenceV01 schema",
862
+ retriable: false,
863
+ category: "interaction"
864
+ },
865
+ E_INTERACTION_INVALID_KIND_FORMAT: {
866
+ code: "E_INTERACTION_INVALID_KIND_FORMAT",
867
+ http_status: 400,
868
+ title: "Interaction Invalid Kind Format",
869
+ description: "Interaction kind does not match required format (lowercase, 2-128 chars, starts with letter)",
870
+ retriable: false,
871
+ category: "interaction"
872
+ },
873
+ E_INTERACTION_INVALID_TIMING: {
874
+ code: "E_INTERACTION_INVALID_TIMING",
875
+ http_status: 400,
876
+ title: "Interaction Invalid Timing",
877
+ description: "Timing constraint violated (completed_at < started_at or invalid datetime format)",
878
+ retriable: false,
879
+ category: "interaction"
880
+ },
881
+ E_INTERACTION_KIND_RESERVED: {
882
+ code: "E_INTERACTION_KIND_RESERVED",
883
+ http_status: 400,
884
+ title: "Interaction Kind Reserved",
885
+ description: "Interaction kind uses reserved prefix (peac.*, org.peacprotocol.*) but is not in the well-known registry",
886
+ retriable: false,
887
+ category: "interaction"
888
+ },
889
+ E_INTERACTION_MISSING_ERROR_DETAIL: {
890
+ code: "E_INTERACTION_MISSING_ERROR_DETAIL",
891
+ http_status: 400,
892
+ title: "Interaction Missing Error Detail",
893
+ description: "error_code or extensions required when result.status is error",
894
+ retriable: false,
895
+ category: "interaction"
896
+ },
897
+ E_INTERACTION_MISSING_EXECUTOR: {
898
+ code: "E_INTERACTION_MISSING_EXECUTOR",
899
+ http_status: 400,
900
+ title: "Interaction Missing Executor",
901
+ description: "Interaction evidence is missing required executor or executor.platform field",
902
+ retriable: false,
903
+ category: "interaction"
904
+ },
905
+ E_INTERACTION_MISSING_ID: {
906
+ code: "E_INTERACTION_MISSING_ID",
907
+ http_status: 400,
908
+ title: "Interaction Missing ID",
909
+ description: "Interaction evidence is missing required interaction_id field",
910
+ retriable: false,
911
+ category: "interaction"
912
+ },
913
+ E_INTERACTION_MISSING_KIND: {
914
+ code: "E_INTERACTION_MISSING_KIND",
915
+ http_status: 400,
916
+ title: "Interaction Missing Kind",
917
+ description: "Interaction evidence is missing required kind field",
918
+ retriable: false,
919
+ category: "interaction"
920
+ },
921
+ E_INTERACTION_MISSING_RESULT: {
922
+ code: "E_INTERACTION_MISSING_RESULT",
923
+ http_status: 400,
924
+ title: "Interaction Missing Result",
925
+ description: "result.status is required when output is present",
926
+ retriable: false,
927
+ category: "interaction"
928
+ },
929
+ E_INTERACTION_MISSING_STARTED_AT: {
930
+ code: "E_INTERACTION_MISSING_STARTED_AT",
931
+ http_status: 400,
932
+ title: "Interaction Missing Started At",
933
+ description: "Interaction evidence is missing required started_at field",
934
+ retriable: false,
935
+ category: "interaction"
936
+ },
937
+ E_INTERACTION_MISSING_TARGET: {
938
+ code: "E_INTERACTION_MISSING_TARGET",
939
+ http_status: 400,
940
+ title: "Interaction Missing Target",
941
+ description: "Kind prefix requires matching target field (tool.* needs tool, http.*/fs.* need resource)",
942
+ retriable: false,
943
+ category: "interaction"
944
+ },
945
+ // Ucp error codes
946
+ E_UCP_EVIDENCE_SERIALIZATION_FAILED: {
947
+ code: "E_UCP_EVIDENCE_SERIALIZATION_FAILED",
948
+ http_status: 500,
949
+ title: "UCP Evidence Serialization Failed",
950
+ description: "Failed to serialize UCP evidence to YAML format",
951
+ retriable: false,
952
+ category: "ucp"
953
+ },
954
+ E_UCP_KEY_ALGORITHM_MISMATCH: {
955
+ code: "E_UCP_KEY_ALGORITHM_MISMATCH",
956
+ http_status: 401,
957
+ title: "UCP Key Algorithm Mismatch",
958
+ description: "Key type is not EC as required for ECDSA signatures",
959
+ retriable: false,
960
+ category: "ucp"
961
+ },
962
+ E_UCP_KEY_CURVE_MISMATCH: {
963
+ code: "E_UCP_KEY_CURVE_MISMATCH",
964
+ http_status: 401,
965
+ title: "UCP Key Curve Mismatch",
966
+ description: "Key curve does not match signature algorithm (ES256=P-256, ES384=P-384, ES512=P-521)",
967
+ retriable: false,
968
+ category: "ucp"
969
+ },
970
+ E_UCP_KEY_NOT_FOUND: {
971
+ code: "E_UCP_KEY_NOT_FOUND",
972
+ http_status: 401,
973
+ title: "UCP Key Not Found",
974
+ description: "Key ID from signature not found in business UCP profile",
975
+ retriable: true,
976
+ category: "ucp"
977
+ },
978
+ E_UCP_ORDER_INVALID: {
979
+ code: "E_UCP_ORDER_INVALID",
980
+ http_status: 400,
981
+ title: "UCP Order Invalid",
982
+ description: "UCP order object does not conform to expected schema",
983
+ retriable: false,
984
+ category: "ucp"
985
+ },
986
+ E_UCP_ORDER_MISSING_ID: {
987
+ code: "E_UCP_ORDER_MISSING_ID",
988
+ http_status: 400,
989
+ title: "UCP Order Missing ID",
990
+ description: "UCP order is missing required id field",
991
+ retriable: false,
992
+ category: "ucp"
993
+ },
994
+ E_UCP_ORDER_MISSING_LINE_ITEMS: {
995
+ code: "E_UCP_ORDER_MISSING_LINE_ITEMS",
996
+ http_status: 400,
997
+ title: "UCP Order Missing Line Items",
998
+ description: "UCP order is missing required line_items array",
999
+ retriable: false,
1000
+ category: "ucp"
1001
+ },
1002
+ E_UCP_ORDER_MISSING_TOTALS: {
1003
+ code: "E_UCP_ORDER_MISSING_TOTALS",
1004
+ http_status: 400,
1005
+ title: "UCP Order Missing Totals",
1006
+ description: "UCP order is missing required totals array or total entry",
1007
+ retriable: false,
1008
+ category: "ucp"
1009
+ },
1010
+ E_UCP_PAYLOAD_EMPTY: {
1011
+ code: "E_UCP_PAYLOAD_EMPTY",
1012
+ http_status: 400,
1013
+ title: "UCP Payload Empty",
1014
+ description: "Webhook request body is empty",
1015
+ retriable: false,
1016
+ category: "ucp"
1017
+ },
1018
+ E_UCP_PAYLOAD_NOT_JSON: {
1019
+ code: "E_UCP_PAYLOAD_NOT_JSON",
1020
+ http_status: 400,
1021
+ title: "UCP Payload Not JSON",
1022
+ description: "Webhook request body is not valid JSON",
1023
+ retriable: false,
1024
+ category: "ucp"
1025
+ },
1026
+ E_UCP_PAYLOAD_TOO_LARGE: {
1027
+ code: "E_UCP_PAYLOAD_TOO_LARGE",
1028
+ http_status: 400,
1029
+ title: "UCP Payload Too Large",
1030
+ description: "Webhook request body exceeds maximum allowed size",
1031
+ retriable: false,
1032
+ category: "ucp"
1033
+ },
1034
+ E_UCP_PROFILE_FETCH_FAILED: {
1035
+ code: "E_UCP_PROFILE_FETCH_FAILED",
1036
+ http_status: 502,
1037
+ title: "UCP Profile Fetch Failed",
1038
+ description: "Failed to fetch business UCP profile from /.well-known/ucp",
1039
+ retriable: true,
1040
+ category: "ucp"
1041
+ },
1042
+ E_UCP_PROFILE_INVALID: {
1043
+ code: "E_UCP_PROFILE_INVALID",
1044
+ http_status: 502,
1045
+ title: "UCP Profile Invalid",
1046
+ description: "Business UCP profile does not conform to expected schema",
1047
+ retriable: false,
1048
+ category: "ucp"
1049
+ },
1050
+ E_UCP_PROFILE_NO_SIGNING_KEYS: {
1051
+ code: "E_UCP_PROFILE_NO_SIGNING_KEYS",
1052
+ http_status: 502,
1053
+ title: "UCP Profile No Signing Keys",
1054
+ description: "Business UCP profile has empty or missing signing_keys array",
1055
+ retriable: false,
1056
+ category: "ucp"
1057
+ },
1058
+ E_UCP_SIGNATURE_ALGORITHM_UNSUPPORTED: {
1059
+ code: "E_UCP_SIGNATURE_ALGORITHM_UNSUPPORTED",
1060
+ http_status: 400,
1061
+ title: "UCP Signature Algorithm Unsupported",
1062
+ description: "Signature algorithm is not ES256, ES384, or ES512",
1063
+ retriable: false,
1064
+ category: "ucp"
1065
+ },
1066
+ E_UCP_SIGNATURE_B64_INVALID: {
1067
+ code: "E_UCP_SIGNATURE_B64_INVALID",
1068
+ http_status: 400,
1069
+ title: "UCP Signature b64 Invalid",
1070
+ description: "b64=false requires 'b64' in 'crit' array per RFC 7797",
1071
+ retriable: false,
1072
+ category: "ucp"
1073
+ },
1074
+ E_UCP_SIGNATURE_INVALID: {
1075
+ code: "E_UCP_SIGNATURE_INVALID",
1076
+ http_status: 401,
1077
+ title: "UCP Signature Invalid",
1078
+ description: "Webhook signature verification failed against payload",
1079
+ retriable: false,
1080
+ category: "ucp"
1081
+ },
1082
+ E_UCP_SIGNATURE_MALFORMED: {
1083
+ code: "E_UCP_SIGNATURE_MALFORMED",
1084
+ http_status: 400,
1085
+ title: "UCP Signature Malformed",
1086
+ description: "Request-Signature header is not a valid detached JWS (RFC 7797)",
1087
+ retriable: false,
1088
+ category: "ucp"
1089
+ },
1090
+ E_UCP_SIGNATURE_MISSING: {
1091
+ code: "E_UCP_SIGNATURE_MISSING",
1092
+ http_status: 400,
1093
+ title: "UCP Signature Missing",
1094
+ description: "Request-Signature header is missing from UCP webhook request",
1095
+ retriable: false,
1096
+ category: "ucp"
1097
+ },
1098
+ E_UCP_VERIFICATION_FAILED: {
1099
+ code: "E_UCP_VERIFICATION_FAILED",
1100
+ http_status: 401,
1101
+ title: "UCP Verification Failed",
1102
+ description: "All verification attempts failed (raw and JCS canonicalized)",
1103
+ retriable: false,
1104
+ category: "ucp"
1105
+ },
1106
+ // Validation error codes
1107
+ E_EVIDENCE_NOT_JSON: {
1108
+ code: "E_EVIDENCE_NOT_JSON",
1109
+ http_status: 400,
1110
+ title: "Evidence Not JSON-Safe",
1111
+ description: "Evidence contains non-JSON-safe values (NaN, Infinity, undefined, BigInt, Date, Map, Set, functions, symbols, class instances, or cycles)",
1112
+ retriable: false,
1113
+ category: "validation"
1114
+ },
1115
+ E_EXPIRED: {
1116
+ code: "E_EXPIRED",
1117
+ http_status: 400,
1118
+ title: "Receipt Expired",
1119
+ description: "Receipt has exceeded its expiration time",
1120
+ retriable: false,
1121
+ category: "validation"
1122
+ },
1123
+ E_INVALID_AMOUNT: {
1124
+ code: "E_INVALID_AMOUNT",
1125
+ http_status: 400,
1126
+ title: "Invalid Amount",
1127
+ description: "Payment amount is invalid or out of allowed range",
1128
+ retriable: false,
1129
+ category: "validation"
1130
+ },
1131
+ E_INVALID_AUDIENCE: {
1132
+ code: "E_INVALID_AUDIENCE",
1133
+ http_status: 400,
1134
+ title: "Invalid Audience",
1135
+ description: "Receipt audience claim does not match expected value",
1136
+ retriable: false,
1137
+ category: "validation"
1138
+ },
1139
+ E_INVALID_CURRENCY: {
1140
+ code: "E_INVALID_CURRENCY",
1141
+ http_status: 400,
1142
+ title: "Invalid Currency",
1143
+ description: "Currency code is not a valid ISO 4217 code",
1144
+ retriable: false,
1145
+ category: "validation"
1146
+ },
1147
+ E_INVALID_FORMAT: {
1148
+ code: "E_INVALID_FORMAT",
1149
+ http_status: 400,
1150
+ title: "Invalid Format",
1151
+ description: "Receipt does not conform to JWS format",
1152
+ retriable: false,
1153
+ category: "validation"
1154
+ },
1155
+ E_INVALID_ISSUER: {
1156
+ code: "E_INVALID_ISSUER",
1157
+ http_status: 400,
1158
+ title: "Invalid Issuer",
1159
+ description: "Receipt issuer claim is invalid or untrusted",
1160
+ retriable: false,
1161
+ category: "validation"
1162
+ },
1163
+ E_INVALID_RAIL: {
1164
+ code: "E_INVALID_RAIL",
1165
+ http_status: 400,
1166
+ title: "Invalid Payment Rail",
1167
+ description: "Payment rail identifier is not recognized",
1168
+ retriable: false,
1169
+ category: "validation"
1170
+ },
1171
+ E_INVALID_RECEIPT_ID: {
1172
+ code: "E_INVALID_RECEIPT_ID",
1173
+ http_status: 400,
1174
+ title: "Invalid Receipt ID",
1175
+ description: "Receipt ID (rid) does not match expected value",
1176
+ retriable: false,
1177
+ category: "validation"
1178
+ },
1179
+ E_INVALID_SUBJECT: {
1180
+ code: "E_INVALID_SUBJECT",
1181
+ http_status: 400,
1182
+ title: "Invalid Subject",
1183
+ description: "Receipt subject claim does not match expected value",
1184
+ retriable: false,
1185
+ category: "validation"
1186
+ },
1187
+ E_MISSING_EXP: {
1188
+ code: "E_MISSING_EXP",
1189
+ http_status: 400,
1190
+ title: "Missing Expiration",
1191
+ description: "Receipt is missing required exp claim",
1192
+ retriable: false,
1193
+ category: "validation"
1194
+ },
1195
+ E_MISSING_REQUIRED_CLAIM: {
1196
+ code: "E_MISSING_REQUIRED_CLAIM",
1197
+ http_status: 400,
1198
+ title: "Missing Required Claim",
1199
+ description: "Receipt is missing a required JWT claim",
1200
+ retriable: false,
1201
+ category: "validation"
1202
+ },
1203
+ E_NOT_YET_VALID: {
1204
+ code: "E_NOT_YET_VALID",
1205
+ http_status: 400,
1206
+ title: "Not Yet Valid",
1207
+ description: "Receipt nbf (not before) time is in the future",
1208
+ retriable: true,
1209
+ category: "validation"
1210
+ },
1211
+ E_PARSE_ATTESTATION_INVALID: {
1212
+ code: "E_PARSE_ATTESTATION_INVALID",
1213
+ http_status: 400,
1214
+ title: "Attestation Receipt Invalid",
1215
+ description: "Receipt classified as attestation but fails attestation schema validation",
1216
+ retriable: false,
1217
+ category: "validation"
1218
+ },
1219
+ E_PARSE_COMMERCE_INVALID: {
1220
+ code: "E_PARSE_COMMERCE_INVALID",
1221
+ http_status: 400,
1222
+ title: "Commerce Receipt Invalid",
1223
+ description: "Receipt has commerce fields (amt/cur/payment) but fails commerce schema validation",
1224
+ retriable: false,
1225
+ category: "validation"
1226
+ },
1227
+ E_PARSE_INVALID_INPUT: {
1228
+ code: "E_PARSE_INVALID_INPUT",
1229
+ http_status: 400,
1230
+ title: "Parse Invalid Input",
1231
+ description: "Input to receipt parser is not a non-null object",
1232
+ retriable: false,
1233
+ category: "validation"
1234
+ },
1235
+ // Verification error codes
1236
+ E_INVALID_SIGNATURE: {
1237
+ code: "E_INVALID_SIGNATURE",
1238
+ http_status: 400,
1239
+ title: "Invalid Signature",
1240
+ description: "Receipt signature verification failed",
1241
+ retriable: false,
1242
+ category: "verification"
1243
+ },
1244
+ E_KEY_NOT_FOUND: {
1245
+ code: "E_KEY_NOT_FOUND",
1246
+ http_status: 400,
1247
+ title: "Key Not Found",
1248
+ description: "Public key with specified kid not found in JWKS",
1249
+ retriable: false,
1250
+ category: "verification"
1251
+ },
1252
+ // Verifier error codes
1253
+ E_VERIFY_EXTENSION_TOO_LARGE: {
1254
+ code: "E_VERIFY_EXTENSION_TOO_LARGE",
1255
+ http_status: 400,
1256
+ title: "Extension Too Large",
1257
+ description: "Receipt extension data exceeds maximum size limit (64 KB)",
1258
+ retriable: false,
1259
+ category: "verifier"
1260
+ },
1261
+ E_VERIFY_INVALID_TRANSPORT: {
1262
+ code: "E_VERIFY_INVALID_TRANSPORT",
1263
+ http_status: 400,
1264
+ title: "Invalid Transport",
1265
+ description: "Multiple PEAC-Receipt or PEAC-Receipt-Pointer headers detected (ambiguous transport)",
1266
+ retriable: false,
1267
+ category: "verifier"
1268
+ },
1269
+ E_VERIFY_ISSUER_NOT_ALLOWED: {
1270
+ code: "E_VERIFY_ISSUER_NOT_ALLOWED",
1271
+ http_status: 403,
1272
+ title: "Issuer Not Allowed",
1273
+ description: "Receipt issuer is not in the verifier policy allowlist",
1274
+ retriable: false,
1275
+ category: "verifier"
1276
+ },
1277
+ E_VERIFY_JWKS_TOO_LARGE: {
1278
+ code: "E_VERIFY_JWKS_TOO_LARGE",
1279
+ http_status: 400,
1280
+ title: "JWKS Too Large",
1281
+ description: "JWKS response exceeds maximum size limit (64 KB)",
1282
+ retriable: false,
1283
+ category: "verifier"
1284
+ },
1285
+ E_VERIFY_JWKS_TOO_MANY_KEYS: {
1286
+ code: "E_VERIFY_JWKS_TOO_MANY_KEYS",
1287
+ http_status: 400,
1288
+ title: "JWKS Too Many Keys",
1289
+ description: "JWKS contains more than maximum allowed keys (20)",
1290
+ retriable: false,
1291
+ category: "verifier"
1292
+ },
1293
+ E_VERIFY_KEY_FETCH_BLOCKED: {
1294
+ code: "E_VERIFY_KEY_FETCH_BLOCKED",
1295
+ http_status: 403,
1296
+ title: "Key Fetch Blocked",
1297
+ description: "JWKS discovery blocked by SSRF protection (private IP, non-HTTPS, or blocked redirect)",
1298
+ retriable: false,
1299
+ category: "verifier"
1300
+ },
1301
+ E_VERIFY_KEY_FETCH_FAILED: {
1302
+ code: "E_VERIFY_KEY_FETCH_FAILED",
1303
+ http_status: 502,
1304
+ title: "Key Fetch Failed",
1305
+ description: "Network error while fetching JWKS from issuer",
1306
+ retriable: true,
1307
+ category: "verifier"
1308
+ },
1309
+ E_VERIFY_KEY_FETCH_TIMEOUT: {
1310
+ code: "E_VERIFY_KEY_FETCH_TIMEOUT",
1311
+ http_status: 504,
1312
+ title: "Key Fetch Timeout",
1313
+ description: "JWKS discovery timed out (5 second limit)",
1314
+ retriable: true,
1315
+ category: "verifier"
1316
+ },
1317
+ E_VERIFY_MALFORMED_RECEIPT: {
1318
+ code: "E_VERIFY_MALFORMED_RECEIPT",
1319
+ http_status: 400,
1320
+ title: "Malformed Receipt",
1321
+ description: "Cannot parse receipt as JWS Compact Serialization",
1322
+ retriable: false,
1323
+ category: "verifier"
1324
+ },
1325
+ E_VERIFY_POINTER_DIGEST_MISMATCH: {
1326
+ code: "E_VERIFY_POINTER_DIGEST_MISMATCH",
1327
+ http_status: 400,
1328
+ title: "Pointer Digest Mismatch",
1329
+ description: "Fetched receipt SHA-256 digest does not match pointer declaration",
1330
+ retriable: false,
1331
+ category: "verifier"
1332
+ },
1333
+ E_VERIFY_POINTER_FETCH_BLOCKED: {
1334
+ code: "E_VERIFY_POINTER_FETCH_BLOCKED",
1335
+ http_status: 403,
1336
+ title: "Pointer Fetch Blocked",
1337
+ description: "Pointer URL fetch blocked by SSRF protection (private IP, non-HTTPS, or blocked redirect)",
1338
+ retriable: false,
1339
+ category: "verifier"
1340
+ },
1341
+ E_VERIFY_POINTER_FETCH_FAILED: {
1342
+ code: "E_VERIFY_POINTER_FETCH_FAILED",
1343
+ http_status: 502,
1344
+ title: "Pointer Fetch Failed",
1345
+ description: "Network error while fetching receipt from pointer URL",
1346
+ retriable: true,
1347
+ category: "verifier"
1348
+ },
1349
+ E_VERIFY_POINTER_FETCH_TIMEOUT: {
1350
+ code: "E_VERIFY_POINTER_FETCH_TIMEOUT",
1351
+ http_status: 504,
1352
+ title: "Pointer Fetch Timeout",
1353
+ description: "Pointer URL fetch timed out (5 second limit)",
1354
+ retriable: true,
1355
+ category: "verifier"
1356
+ },
1357
+ E_VERIFY_POINTER_FETCH_TOO_LARGE: {
1358
+ code: "E_VERIFY_POINTER_FETCH_TOO_LARGE",
1359
+ http_status: 413,
1360
+ title: "Pointer Fetch Too Large",
1361
+ description: "Pointer URL response exceeds maximum size limit (256 KB)",
1362
+ retriable: false,
1363
+ category: "verifier"
1364
+ },
1365
+ E_VERIFY_POLICY_VIOLATION: {
1366
+ code: "E_VERIFY_POLICY_VIOLATION",
1367
+ http_status: 403,
1368
+ title: "Policy Violation",
1369
+ description: "Receipt violates verifier trust policy",
1370
+ retriable: false,
1371
+ category: "verifier"
1372
+ },
1373
+ E_VERIFY_RECEIPT_TOO_LARGE: {
1374
+ code: "E_VERIFY_RECEIPT_TOO_LARGE",
1375
+ http_status: 413,
1376
+ title: "Receipt Too Large",
1377
+ description: "Receipt exceeds maximum size limit (256 KB)",
1378
+ retriable: false,
1379
+ category: "verifier"
1380
+ },
1381
+ E_VERIFY_SCHEMA_INVALID: {
1382
+ code: "E_VERIFY_SCHEMA_INVALID",
1383
+ http_status: 400,
1384
+ title: "Schema Invalid",
1385
+ description: "Receipt claims do not conform to expected schema",
1386
+ retriable: false,
1387
+ category: "verifier"
1388
+ },
1389
+ // Workflow error codes
1390
+ E_WORKFLOW_CONTEXT_INVALID: {
1391
+ code: "E_WORKFLOW_CONTEXT_INVALID",
1392
+ http_status: 400,
1393
+ title: "Invalid Workflow Context",
1394
+ description: "Workflow context does not conform to WorkflowContextSchema",
1395
+ retriable: false,
1396
+ category: "workflow"
1397
+ },
1398
+ E_WORKFLOW_CYCLE_DETECTED: {
1399
+ code: "E_WORKFLOW_CYCLE_DETECTED",
1400
+ http_status: 400,
1401
+ title: "Workflow Cycle Detected",
1402
+ description: "Workflow DAG contains a cycle (not acyclic)",
1403
+ retriable: false,
1404
+ category: "workflow"
1405
+ },
1406
+ E_WORKFLOW_DAG_INVALID: {
1407
+ code: "E_WORKFLOW_DAG_INVALID",
1408
+ http_status: 400,
1409
+ title: "Invalid Workflow DAG",
1410
+ description: "Workflow DAG semantics violated (self-parent, duplicate parents, or cycle detected)",
1411
+ retriable: false,
1412
+ category: "workflow"
1413
+ },
1414
+ E_WORKFLOW_ID_INVALID: {
1415
+ code: "E_WORKFLOW_ID_INVALID",
1416
+ http_status: 400,
1417
+ title: "Invalid Workflow ID",
1418
+ description: "Workflow ID does not match required format (wf_{ulid|uuid})",
1419
+ retriable: false,
1420
+ category: "workflow"
1421
+ },
1422
+ E_WORKFLOW_LIMIT_EXCEEDED: {
1423
+ code: "E_WORKFLOW_LIMIT_EXCEEDED",
1424
+ http_status: 400,
1425
+ title: "Workflow Limit Exceeded",
1426
+ description: "Workflow exceeds defined limits (parent count, ID length, etc.)",
1427
+ retriable: false,
1428
+ category: "workflow"
1429
+ },
1430
+ E_WORKFLOW_PARENT_NOT_FOUND: {
1431
+ code: "E_WORKFLOW_PARENT_NOT_FOUND",
1432
+ http_status: 400,
1433
+ title: "Parent Step Not Found",
1434
+ description: "Referenced parent step ID does not exist in the workflow",
1435
+ retriable: false,
1436
+ category: "workflow"
1437
+ },
1438
+ E_WORKFLOW_STEP_ID_INVALID: {
1439
+ code: "E_WORKFLOW_STEP_ID_INVALID",
1440
+ http_status: 400,
1441
+ title: "Invalid Step ID",
1442
+ description: "Step ID does not match required format (step_{ulid|uuid})",
1443
+ retriable: false,
1444
+ category: "workflow"
1445
+ },
1446
+ E_WORKFLOW_SUMMARY_INVALID: {
1447
+ code: "E_WORKFLOW_SUMMARY_INVALID",
1448
+ http_status: 400,
1449
+ title: "Invalid Workflow Summary",
1450
+ description: "Workflow summary attestation does not conform to schema",
1451
+ retriable: false,
1452
+ category: "workflow"
1453
+ }
1454
+ };
1455
+ function getError(code) {
1456
+ return ERRORS[code];
1457
+ }
1458
+ function isRetriable(code) {
1459
+ return ERRORS[code]?.retriable ?? false;
1460
+ }
1461
+ var BUNDLE_ERRORS = {
1462
+ DUPLICATE_RECEIPT: "E_BUNDLE_DUPLICATE_RECEIPT",
1463
+ HASH_MISMATCH: "E_BUNDLE_HASH_MISMATCH",
1464
+ INVALID_FORMAT: "E_BUNDLE_INVALID_FORMAT",
1465
+ KEY_MISSING: "E_BUNDLE_KEY_MISSING",
1466
+ MANIFEST_INVALID: "E_BUNDLE_MANIFEST_INVALID",
1467
+ MANIFEST_MISSING: "E_BUNDLE_MANIFEST_MISSING",
1468
+ MISSING_KEYS: "E_BUNDLE_MISSING_KEYS",
1469
+ MISSING_RECEIPTS: "E_BUNDLE_MISSING_RECEIPTS",
1470
+ PATH_TRAVERSAL: "E_BUNDLE_PATH_TRAVERSAL",
1471
+ POLICY_HASH_MISMATCH: "E_BUNDLE_POLICY_HASH_MISMATCH",
1472
+ RECEIPTS_UNORDERED: "E_BUNDLE_RECEIPTS_UNORDERED",
1473
+ RECEIPT_INVALID: "E_BUNDLE_RECEIPT_INVALID",
1474
+ SIGNATURE_INVALID: "E_BUNDLE_SIGNATURE_INVALID",
1475
+ SIZE_EXCEEDED: "E_BUNDLE_SIZE_EXCEEDED",
1476
+ TIME_RANGE_INVALID: "E_BUNDLE_TIME_RANGE_INVALID"
1477
+ };
1478
+ var DISPUTE_ERRORS = {
1479
+ DUPLICATE: "E_DISPUTE_DUPLICATE",
1480
+ EXPIRED: "E_DISPUTE_EXPIRED",
1481
+ INVALID_FORMAT: "E_DISPUTE_INVALID_FORMAT",
1482
+ INVALID_GROUNDS: "E_DISPUTE_INVALID_GROUNDS",
1483
+ INVALID_ID: "E_DISPUTE_INVALID_ID",
1484
+ INVALID_STATE: "E_DISPUTE_INVALID_STATE",
1485
+ INVALID_TARGET_TYPE: "E_DISPUTE_INVALID_TARGET_TYPE",
1486
+ INVALID_TRANSITION: "E_DISPUTE_INVALID_TRANSITION",
1487
+ INVALID_TYPE: "E_DISPUTE_INVALID_TYPE",
1488
+ MISSING_RESOLUTION: "E_DISPUTE_MISSING_RESOLUTION",
1489
+ NOT_YET_VALID: "E_DISPUTE_NOT_YET_VALID",
1490
+ OTHER_REQUIRES_DESCRIPTION: "E_DISPUTE_OTHER_REQUIRES_DESCRIPTION",
1491
+ RESOLUTION_NOT_ALLOWED: "E_DISPUTE_RESOLUTION_NOT_ALLOWED",
1492
+ TARGET_NOT_FOUND: "E_DISPUTE_TARGET_NOT_FOUND"
1493
+ };
1494
+
1495
+ // src/registries.ts
1496
+ var PAYMENT_RAILS = [
1497
+ {
1498
+ id: "x402",
1499
+ category: "agentic-payment",
1500
+ description: "HTTP 402-based paid call receipts",
1501
+ reference: "https://www.x402.org/",
1502
+ status: "informational"
1503
+ },
1504
+ {
1505
+ id: "l402",
1506
+ category: "agentic-payment",
1507
+ description: "Lightning HTTP 402 Protocol (LSAT-based)",
1508
+ reference: "https://docs.lightning.engineering/the-lightning-network/l402",
1509
+ status: "informational"
1510
+ },
1511
+ {
1512
+ id: "card-network",
1513
+ category: "card",
1514
+ description: "Generic card network authorizations/clearing",
1515
+ reference: null,
1516
+ status: "informational"
1517
+ },
1518
+ {
1519
+ id: "upi",
1520
+ category: "account-to-account",
1521
+ description: "Unified Payments Interface",
1522
+ reference: "https://www.npci.org.in/",
1523
+ status: "informational"
1524
+ }
1525
+ ];
1526
+ var CONTROL_ENGINES = [
1527
+ {
1528
+ id: "spend-control-service",
1529
+ category: "limits",
1530
+ description: "Generic spend control decisions (per-tx, daily, monthly limits)",
1531
+ reference: null,
1532
+ status: "informational"
1533
+ },
1534
+ {
1535
+ id: "risk-engine",
1536
+ category: "fraud",
1537
+ description: "Generic risk/fraud scoring engine",
1538
+ reference: null,
1539
+ status: "informational"
1540
+ },
1541
+ {
1542
+ id: "mandate-service",
1543
+ category: "mandate",
1544
+ description: "Generic enterprise mandate/approval chain evaluator",
1545
+ reference: null,
1546
+ status: "informational"
1547
+ }
1548
+ ];
1549
+ var TRANSPORT_METHODS = [
1550
+ {
1551
+ id: "dpop",
1552
+ category: "proof-of-possession",
1553
+ description: "Demonstrating Proof-of-Possession at the Application Layer",
1554
+ reference: "https://www.rfc-editor.org/rfc/rfc9449",
1555
+ status: "informational"
1556
+ },
1557
+ {
1558
+ id: "http-signature",
1559
+ category: "message-signature",
1560
+ description: "HTTP Message Signatures",
1561
+ reference: "https://www.rfc-editor.org/rfc/rfc9421",
1562
+ status: "informational"
1563
+ },
1564
+ {
1565
+ id: "none",
1566
+ category: "none",
1567
+ description: "No transport binding",
1568
+ reference: null,
1569
+ status: "informational"
1570
+ }
1571
+ ];
1572
+ var AGENT_PROTOCOLS = [
1573
+ {
1574
+ id: "mcp",
1575
+ category: "tool-protocol",
1576
+ description: "Model Context Protocol (MCP)",
1577
+ reference: "https://modelcontextprotocol.io/",
1578
+ status: "informational"
1579
+ },
1580
+ {
1581
+ id: "acp",
1582
+ category: "commerce-protocol",
1583
+ description: "Agentic Commerce Protocol",
1584
+ reference: null,
1585
+ status: "informational"
1586
+ },
1587
+ {
1588
+ id: "ap2",
1589
+ category: "agent-protocol",
1590
+ description: "Google Agent Protocol v2",
1591
+ reference: null,
1592
+ status: "informational"
1593
+ },
1594
+ {
1595
+ id: "tap",
1596
+ category: "card-protocol",
1597
+ description: "Trusted Agent Protocol (Visa TAP)",
1598
+ reference: "https://developer.visa.com/",
1599
+ status: "informational"
1600
+ }
1601
+ ];
1602
+ var REGISTRIES = {
1603
+ payment_rails: PAYMENT_RAILS,
1604
+ control_engines: CONTROL_ENGINES,
1605
+ transport_methods: TRANSPORT_METHODS,
1606
+ agent_protocols: AGENT_PROTOCOLS
1607
+ };
1608
+ function findPaymentRail(id) {
1609
+ return PAYMENT_RAILS.find((rail) => rail.id === id);
1610
+ }
1611
+ function findControlEngine(id) {
1612
+ return CONTROL_ENGINES.find((engine) => engine.id === id);
1613
+ }
1614
+ function findTransportMethod(id) {
1615
+ return TRANSPORT_METHODS.find((method) => method.id === id);
1616
+ }
1617
+ function findAgentProtocol(id) {
1618
+ return AGENT_PROTOCOLS.find((protocol) => protocol.id === id);
1619
+ }
1620
+
1621
+ // src/http.ts
1622
+ var VARY_HEADERS = [HEADERS.purpose, HEADERS.receipt];
1623
+ function applyPurposeVary(headers) {
1624
+ const purposeHeader = HEADERS.purpose;
1625
+ if ("append" in headers && typeof headers.append === "function") {
1626
+ const existing = headers.get("Vary") || "";
1627
+ if (!existing.toLowerCase().includes(purposeHeader.toLowerCase())) {
1628
+ headers.append("Vary", purposeHeader);
1629
+ }
1630
+ } else if ("setHeader" in headers && typeof headers.setHeader === "function") {
1631
+ const existing = headers.getHeader?.("Vary");
1632
+ const existingStr = Array.isArray(existing) ? existing.join(", ") : String(existing || "");
1633
+ if (!existingStr.toLowerCase().includes(purposeHeader.toLowerCase())) {
1634
+ headers.setHeader("Vary", existingStr ? `${existingStr}, ${purposeHeader}` : purposeHeader);
1635
+ }
1636
+ } else if ("set" in headers && typeof headers.set === "function") {
1637
+ headers.set("Vary", purposeHeader);
1638
+ }
1639
+ }
1640
+ function getPeacVaryHeaders() {
1641
+ return VARY_HEADERS.join(", ");
1642
+ }
1643
+ function needsPurposeVary(purposeEnforced) {
1644
+ return purposeEnforced;
1645
+ }
1646
+
1647
+ exports.AGENT_PROTOCOLS = AGENT_PROTOCOLS;
1648
+ exports.ALGORITHMS = ALGORITHMS;
1649
+ exports.BUNDLE_ERRORS = BUNDLE_ERRORS;
1650
+ exports.BUNDLE_VERSION = BUNDLE_VERSION;
1651
+ exports.CONSTANTS = CONSTANTS;
1652
+ exports.CONTROL_ENGINES = CONTROL_ENGINES;
1653
+ exports.DISCOVERY = DISCOVERY;
1654
+ exports.DISPUTE_ERRORS = DISPUTE_ERRORS;
1655
+ exports.ERRORS = ERRORS;
1656
+ exports.ERROR_CATEGORIES = ERROR_CATEGORIES;
1657
+ exports.ERROR_CODES = ERROR_CODES;
1658
+ exports.HASH = HASH;
1659
+ exports.HEADERS = HEADERS;
1660
+ exports.ISSUER_CONFIG = ISSUER_CONFIG;
1661
+ exports.JWKS = JWKS;
1662
+ exports.LIMITS = LIMITS;
1663
+ exports.PAYMENT_RAILS = PAYMENT_RAILS;
1664
+ exports.POLICY = POLICY;
1665
+ exports.PRIVATE_IP_RANGES = PRIVATE_IP_RANGES;
1666
+ exports.RECEIPT = RECEIPT;
1667
+ exports.REGISTRIES = REGISTRIES;
1668
+ exports.TRANSPORT_METHODS = TRANSPORT_METHODS;
1669
+ exports.VARY_HEADERS = VARY_HEADERS;
1670
+ exports.VERIFICATION_MODES = VERIFICATION_MODES;
1671
+ exports.VERIFICATION_REPORT_VERSION = VERIFICATION_REPORT_VERSION;
1672
+ exports.VERIFIER_LIMITS = VERIFIER_LIMITS;
1673
+ exports.VERIFIER_NETWORK = VERIFIER_NETWORK;
1674
+ exports.VERIFIER_POLICY_VERSION = VERIFIER_POLICY_VERSION;
1675
+ exports.WIRE_TYPE = WIRE_TYPE;
1676
+ exports.WIRE_VERSION = WIRE_VERSION;
1677
+ exports.applyPurposeVary = applyPurposeVary;
1678
+ exports.findAgentProtocol = findAgentProtocol;
1679
+ exports.findControlEngine = findControlEngine;
1680
+ exports.findPaymentRail = findPaymentRail;
1681
+ exports.findTransportMethod = findTransportMethod;
1682
+ exports.formatHash = formatHash;
1683
+ exports.getError = getError;
1684
+ exports.getPeacVaryHeaders = getPeacVaryHeaders;
1685
+ exports.isRetriable = isRetriable;
1686
+ exports.isValidHash = isValidHash;
1687
+ exports.needsPurposeVary = needsPurposeVary;
1688
+ exports.parseHash = parseHash;
1689
+ //# sourceMappingURL=index.cjs.map
1690
+ //# sourceMappingURL=index.cjs.map