@peac/kernel 0.10.14 → 0.11.1

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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=carrier.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carrier.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/carrier.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Evidence Carrier Contract types (DD-124)
3
+ *
4
+ * Pure TypeScript types for the universal evidence carry interface.
5
+ * Zero runtime dependencies: this module exports only types.
6
+ *
7
+ * The Evidence Carrier Contract defines how any protocol (MCP, A2A, ACP,
8
+ * UCP, x402, HTTP) carries PEAC receipts without kernel changes.
9
+ */
10
+ /**
11
+ * Canonical HTTP header name for PEAC receipts (DD-127).
12
+ *
13
+ * The wire token is exactly "PEAC-Receipt" (mixed-case, hyphenated).
14
+ * This is the only valid spelling in conformance fixtures and attach() output.
15
+ * HTTP header lookups SHOULD be case-insensitive per RFC 9110, but conformance
16
+ * fixtures and attach() output MUST use this exact spelling.
17
+ */
18
+ export declare const PEAC_RECEIPT_HEADER: "PEAC-Receipt";
19
+ /** Content-addressed receipt reference: SHA-256 of the compact JWS bytes */
20
+ export type ReceiptRef = `sha256:${string}`;
21
+ /** Carrier format: embed (inline) or reference (URL/pointer) */
22
+ export type CarrierFormat = 'embed' | 'reference';
23
+ /**
24
+ * Universal evidence carrier.
25
+ *
26
+ * Every protocol-specific adapter produces and consumes this shape.
27
+ * Fields marked optional are SHOULD or MAY per the carrier contract spec.
28
+ */
29
+ export interface PeacEvidenceCarrier {
30
+ /** Content-addressed receipt reference (MUST): sha256:<hex64> */
31
+ receipt_ref: ReceiptRef;
32
+ /** Compact JWS of the signed receipt (SHOULD for embed format) */
33
+ receipt_jws?: string;
34
+ /** Policy binding hash for verification (MAY) */
35
+ policy_binding?: string;
36
+ /** Actor binding identifier (MAY) */
37
+ actor_binding?: string;
38
+ /** Request nonce for replay protection (MAY) */
39
+ request_nonce?: string;
40
+ /** Reference to a verification report (MAY) */
41
+ verification_report_ref?: string;
42
+ /** Reference to a use policy (MAY) */
43
+ use_policy_ref?: string;
44
+ /** Reference to a representation (MAY) */
45
+ representation_ref?: string;
46
+ /** Reference to an attestation (MAY) */
47
+ attestation_ref?: string;
48
+ }
49
+ /**
50
+ * Transport-level metadata describing how a carrier is placed.
51
+ *
52
+ * Used by validateConstraints() to enforce transport-specific size limits
53
+ * and format requirements (DD-127).
54
+ */
55
+ export interface CarrierMeta {
56
+ /** Transport identifier (e.g. 'mcp', 'a2a', 'acp', 'ucp', 'x402', 'http') */
57
+ transport: string;
58
+ /** Carrier format: embed or reference */
59
+ format: CarrierFormat;
60
+ /** Maximum carrier size in bytes for this transport */
61
+ max_size: number;
62
+ /** Fields that have been redacted (MAY) */
63
+ redaction?: string[];
64
+ }
65
+ /** Result of carrier constraint validation */
66
+ export interface CarrierValidationResult {
67
+ valid: boolean;
68
+ violations: string[];
69
+ }
70
+ /**
71
+ * Protocol-specific carrier adapter (DD-124).
72
+ *
73
+ * Each protocol mapping implements this interface to attach/extract
74
+ * PEAC evidence carriers in the protocol's native format.
75
+ *
76
+ * @typeParam TInput - The protocol-specific input type (e.g. A2A TaskStatus)
77
+ * @typeParam TOutput - The protocol-specific output type
78
+ */
79
+ export interface CarrierAdapter<TInput, TOutput> {
80
+ /**
81
+ * Extract PEAC evidence carriers from a protocol message.
82
+ * Returns null if no carrier is present.
83
+ */
84
+ extract(input: TInput): {
85
+ receipts: PeacEvidenceCarrier[];
86
+ meta: CarrierMeta;
87
+ } | null;
88
+ /**
89
+ * Attach PEAC evidence carriers to a protocol message.
90
+ * Returns the modified output with carriers placed per protocol conventions.
91
+ */
92
+ attach(output: TOutput, carriers: PeacEvidenceCarrier[], meta?: CarrierMeta): TOutput;
93
+ /**
94
+ * Validate a carrier against transport-specific constraints (DD-127, DD-129).
95
+ * Takes CarrierMeta for transport-aware size and format validation.
96
+ */
97
+ validateConstraints(carrier: PeacEvidenceCarrier, meta: CarrierMeta): CarrierValidationResult;
98
+ }
99
+ //# sourceMappingURL=carrier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carrier.d.ts","sourceRoot":"","sources":["../src/carrier.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAG,cAAuB,CAAC;AAM3D,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,UAAU,MAAM,EAAE,CAAC;AAE5C,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,WAAW,CAAC;AAMlD;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,WAAW,EAAE,UAAU,CAAC;IACxB,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,sCAAsC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wCAAwC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAMD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAMD,8CAA8C;AAC9C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAMD;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc,CAAC,MAAM,EAAE,OAAO;IAC7C;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,GAAG,IAAI,CAAC;IAEtF;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;IAEtF;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,WAAW,GAAG,uBAAuB,CAAC;CAC/F"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * AUTO-GENERATED from specs/kernel/errors.json
5
5
  * DO NOT EDIT MANUALLY - run: npx tsx scripts/codegen-errors.ts
6
- * Spec version: 0.10.7
6
+ * Spec version: 0.11.0
7
7
  */
8
8
  /**
9
9
  * Canonical error categories derived from specs/kernel/errors.json.
package/dist/errors.cjs CHANGED
@@ -107,6 +107,7 @@ var ERROR_CODES = {
107
107
  E_UCP_SIGNATURE_MISSING: "E_UCP_SIGNATURE_MISSING",
108
108
  E_UCP_VERIFICATION_FAILED: "E_UCP_VERIFICATION_FAILED",
109
109
  // Validation error codes
110
+ E_CONSTRAINT_VIOLATION: "E_CONSTRAINT_VIOLATION",
110
111
  E_EVIDENCE_NOT_JSON: "E_EVIDENCE_NOT_JSON",
111
112
  E_EXPIRED: "E_EXPIRED",
112
113
  E_INVALID_AMOUNT: "E_INVALID_AMOUNT",
@@ -128,10 +129,16 @@ var ERROR_CODES = {
128
129
  E_KEY_NOT_FOUND: "E_KEY_NOT_FOUND",
129
130
  // Verifier error codes
130
131
  E_VERIFY_EXTENSION_TOO_LARGE: "E_VERIFY_EXTENSION_TOO_LARGE",
132
+ E_VERIFY_INSECURE_SCHEME_BLOCKED: "E_VERIFY_INSECURE_SCHEME_BLOCKED",
131
133
  E_VERIFY_INVALID_TRANSPORT: "E_VERIFY_INVALID_TRANSPORT",
134
+ E_VERIFY_ISSUER_CONFIG_INVALID: "E_VERIFY_ISSUER_CONFIG_INVALID",
135
+ E_VERIFY_ISSUER_CONFIG_MISSING: "E_VERIFY_ISSUER_CONFIG_MISSING",
136
+ E_VERIFY_ISSUER_MISMATCH: "E_VERIFY_ISSUER_MISMATCH",
132
137
  E_VERIFY_ISSUER_NOT_ALLOWED: "E_VERIFY_ISSUER_NOT_ALLOWED",
138
+ E_VERIFY_JWKS_INVALID: "E_VERIFY_JWKS_INVALID",
133
139
  E_VERIFY_JWKS_TOO_LARGE: "E_VERIFY_JWKS_TOO_LARGE",
134
140
  E_VERIFY_JWKS_TOO_MANY_KEYS: "E_VERIFY_JWKS_TOO_MANY_KEYS",
141
+ E_VERIFY_JWKS_URI_INVALID: "E_VERIFY_JWKS_URI_INVALID",
135
142
  E_VERIFY_KEY_FETCH_BLOCKED: "E_VERIFY_KEY_FETCH_BLOCKED",
136
143
  E_VERIFY_KEY_FETCH_FAILED: "E_VERIFY_KEY_FETCH_FAILED",
137
144
  E_VERIFY_KEY_FETCH_TIMEOUT: "E_VERIFY_KEY_FETCH_TIMEOUT",
@@ -932,6 +939,14 @@ var ERRORS = {
932
939
  category: "ucp"
933
940
  },
934
941
  // Validation error codes
942
+ E_CONSTRAINT_VIOLATION: {
943
+ code: "E_CONSTRAINT_VIOLATION",
944
+ http_status: 400,
945
+ title: "Kernel Constraint Violation",
946
+ description: "Receipt claims exceed a kernel constraint (max keys, max depth, max string length, max evidence bytes, or similar structural limit)",
947
+ retriable: false,
948
+ category: "validation"
949
+ },
935
950
  E_EVIDENCE_NOT_JSON: {
936
951
  code: "E_EVIDENCE_NOT_JSON",
937
952
  http_status: 400,
@@ -1086,6 +1101,14 @@ var ERRORS = {
1086
1101
  retriable: false,
1087
1102
  category: "verifier"
1088
1103
  },
1104
+ E_VERIFY_INSECURE_SCHEME_BLOCKED: {
1105
+ code: "E_VERIFY_INSECURE_SCHEME_BLOCKED",
1106
+ http_status: 403,
1107
+ title: "Insecure Scheme Blocked",
1108
+ description: "Non-HTTPS URL encountered during issuer discovery (issuer URL or jwks_uri)",
1109
+ retriable: false,
1110
+ category: "verifier"
1111
+ },
1089
1112
  E_VERIFY_INVALID_TRANSPORT: {
1090
1113
  code: "E_VERIFY_INVALID_TRANSPORT",
1091
1114
  http_status: 400,
@@ -1094,6 +1117,30 @@ var ERRORS = {
1094
1117
  retriable: false,
1095
1118
  category: "verifier"
1096
1119
  },
1120
+ E_VERIFY_ISSUER_CONFIG_INVALID: {
1121
+ code: "E_VERIFY_ISSUER_CONFIG_INVALID",
1122
+ http_status: 502,
1123
+ title: "Issuer Config Invalid",
1124
+ description: "peac-issuer.json is not valid JSON or does not conform to issuer config schema",
1125
+ retriable: false,
1126
+ category: "verifier"
1127
+ },
1128
+ E_VERIFY_ISSUER_CONFIG_MISSING: {
1129
+ code: "E_VERIFY_ISSUER_CONFIG_MISSING",
1130
+ http_status: 502,
1131
+ title: "Issuer Config Missing",
1132
+ description: "peac-issuer.json not found or not fetchable at issuer origin",
1133
+ retriable: true,
1134
+ category: "verifier"
1135
+ },
1136
+ E_VERIFY_ISSUER_MISMATCH: {
1137
+ code: "E_VERIFY_ISSUER_MISMATCH",
1138
+ http_status: 403,
1139
+ title: "Issuer Mismatch",
1140
+ description: "issuer field in peac-issuer.json does not match the expected issuer origin",
1141
+ retriable: false,
1142
+ category: "verifier"
1143
+ },
1097
1144
  E_VERIFY_ISSUER_NOT_ALLOWED: {
1098
1145
  code: "E_VERIFY_ISSUER_NOT_ALLOWED",
1099
1146
  http_status: 403,
@@ -1102,6 +1149,14 @@ var ERRORS = {
1102
1149
  retriable: false,
1103
1150
  category: "verifier"
1104
1151
  },
1152
+ E_VERIFY_JWKS_INVALID: {
1153
+ code: "E_VERIFY_JWKS_INVALID",
1154
+ http_status: 502,
1155
+ title: "JWKS Invalid",
1156
+ description: "JWKS response is not valid JSON or missing required keys array",
1157
+ retriable: false,
1158
+ category: "verifier"
1159
+ },
1105
1160
  E_VERIFY_JWKS_TOO_LARGE: {
1106
1161
  code: "E_VERIFY_JWKS_TOO_LARGE",
1107
1162
  http_status: 400,
@@ -1118,6 +1173,14 @@ var ERRORS = {
1118
1173
  retriable: false,
1119
1174
  category: "verifier"
1120
1175
  },
1176
+ E_VERIFY_JWKS_URI_INVALID: {
1177
+ code: "E_VERIFY_JWKS_URI_INVALID",
1178
+ http_status: 502,
1179
+ title: "JWKS URI Invalid",
1180
+ description: "jwks_uri in peac-issuer.json is not a valid HTTPS URL",
1181
+ retriable: false,
1182
+ category: "verifier"
1183
+ },
1121
1184
  E_VERIFY_KEY_FETCH_BLOCKED: {
1122
1185
  code: "E_VERIFY_KEY_FETCH_BLOCKED",
1123
1186
  http_status: 403,