@peac/schema 0.11.3 → 0.12.0-preview.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,152 @@
1
+ /**
2
+ * Wire 0.2 Zod schemas and types (v0.12.0-preview.1, DD-156)
3
+ *
4
+ * This file contains:
5
+ * - Wire02ClaimsSchema: the canonical Zod schema for Wire 0.2 envelopes
6
+ * - Wire02Claims: inferred TypeScript type (z.infer<typeof Wire02ClaimsSchema>)
7
+ * - Supporting schemas: EvidencePillarSchema, PillarsSchema, Wire02KindSchema,
8
+ * ReceiptTypeSchema, CanonicalIssSchema, PolicyBlockSchema
9
+ * - isCanonicalIss(): exported canonical-iss validator
10
+ * - isValidReceiptType(): exported type-grammar validator
11
+ * - checkOccurredAtSkew(): cross-field skew check helper
12
+ *
13
+ * Wire02Claims does NOT live in @peac/kernel (layer violation);
14
+ * it lives here because it references schema-layer types (Correction 4, DD-156).
15
+ */
16
+ import { z } from 'zod';
17
+ import type { VerificationWarning } from '@peac/kernel';
18
+ /**
19
+ * Validate that an issuer (iss) claim is in canonical form.
20
+ *
21
+ * Accepted schemes:
22
+ * - `https://`: ASCII origin (lowercase scheme+host, no explicit default port
23
+ * (:443 rejected), origin-only, no path/query/fragment/userinfo).
24
+ * Raw Unicode hosts are rejected; punycode (xn--...) is accepted.
25
+ * - `did:`: DID Core identifier (`did:<method>:<id>`) where method is
26
+ * `[a-z0-9]+` and the method-specific-id contains no `#`, `?`, or `/`.
27
+ *
28
+ * All other schemes produce E_ISS_NOT_CANONICAL.
29
+ *
30
+ * @param iss - Issuer claim value to validate
31
+ * @returns true if canonical form; false otherwise
32
+ */
33
+ export declare function isCanonicalIss(iss: string): boolean;
34
+ /**
35
+ * Validate that a type claim conforms to the Wire 0.2 type grammar.
36
+ *
37
+ * Accepted forms:
38
+ * - Reverse-DNS notation: `<domain>/<segment>` where `<domain>` has at
39
+ * least one dot (e.g., `org.peacprotocol/commerce`, `com.example/flow`)
40
+ * - Absolute URI: starts with `scheme://` (e.g., `https://example.com/type`)
41
+ *
42
+ * @param value - Type claim value to validate
43
+ * @returns true if valid type grammar; false otherwise
44
+ */
45
+ export declare function isValidReceiptType(value: string): boolean;
46
+ export declare const EvidencePillarSchema: z.ZodEnum<{
47
+ attribution: "attribution";
48
+ identity: "identity";
49
+ purpose: "purpose";
50
+ access: "access";
51
+ commerce: "commerce";
52
+ compliance: "compliance";
53
+ consent: "consent";
54
+ privacy: "privacy";
55
+ provenance: "provenance";
56
+ safety: "safety";
57
+ }>;
58
+ export declare const PillarsSchema: z.ZodArray<z.ZodEnum<{
59
+ attribution: "attribution";
60
+ identity: "identity";
61
+ purpose: "purpose";
62
+ access: "access";
63
+ commerce: "commerce";
64
+ compliance: "compliance";
65
+ consent: "consent";
66
+ privacy: "privacy";
67
+ provenance: "provenance";
68
+ safety: "safety";
69
+ }>>;
70
+ export declare const Wire02KindSchema: z.ZodEnum<{
71
+ evidence: "evidence";
72
+ challenge: "challenge";
73
+ }>;
74
+ export declare const ReceiptTypeSchema: z.ZodString;
75
+ export declare const CanonicalIssSchema: z.ZodString;
76
+ export declare const PolicyBlockSchema: z.ZodObject<{
77
+ digest: z.ZodString;
78
+ uri: z.ZodOptional<z.ZodString>;
79
+ version: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>;
81
+ export declare const Wire02ClaimsSchema: z.ZodObject<{
82
+ peac_version: z.ZodLiteral<"0.2">;
83
+ kind: z.ZodEnum<{
84
+ evidence: "evidence";
85
+ challenge: "challenge";
86
+ }>;
87
+ type: z.ZodString;
88
+ iss: z.ZodString;
89
+ iat: z.ZodNumber;
90
+ jti: z.ZodString;
91
+ sub: z.ZodOptional<z.ZodString>;
92
+ pillars: z.ZodOptional<z.ZodArray<z.ZodEnum<{
93
+ attribution: "attribution";
94
+ identity: "identity";
95
+ purpose: "purpose";
96
+ access: "access";
97
+ commerce: "commerce";
98
+ compliance: "compliance";
99
+ consent: "consent";
100
+ privacy: "privacy";
101
+ provenance: "provenance";
102
+ safety: "safety";
103
+ }>>>;
104
+ actor: z.ZodOptional<z.ZodObject<{
105
+ id: z.ZodString;
106
+ proof_type: z.ZodEnum<{
107
+ "ed25519-cert-chain": "ed25519-cert-chain";
108
+ "eat-passport": "eat-passport";
109
+ "eat-background-check": "eat-background-check";
110
+ "sigstore-oidc": "sigstore-oidc";
111
+ did: "did";
112
+ spiffe: "spiffe";
113
+ "x509-pki": "x509-pki";
114
+ custom: "custom";
115
+ }>;
116
+ proof_ref: z.ZodOptional<z.ZodString>;
117
+ origin: z.ZodString;
118
+ intent_hash: z.ZodOptional<z.ZodString>;
119
+ }, z.core.$strict>>;
120
+ policy: z.ZodOptional<z.ZodObject<{
121
+ digest: z.ZodString;
122
+ uri: z.ZodOptional<z.ZodString>;
123
+ version: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>>;
125
+ representation: z.ZodOptional<z.ZodObject<{
126
+ content_hash: z.ZodOptional<z.ZodString>;
127
+ content_type: z.ZodOptional<z.ZodString>;
128
+ content_length: z.ZodOptional<z.ZodNumber>;
129
+ }, z.core.$strict>>;
130
+ occurred_at: z.ZodOptional<z.ZodString>;
131
+ purpose_declared: z.ZodOptional<z.ZodString>;
132
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
133
+ }, z.core.$strict>;
134
+ /** Inferred type for Wire 0.2 receipt claims */
135
+ export type Wire02Claims = z.infer<typeof Wire02ClaimsSchema>;
136
+ /**
137
+ * Check the occurred_at field for temporal consistency.
138
+ *
139
+ * Rules (evidence kind only; caller must not call for challenge kind):
140
+ * - If occurred_at > now + tolerance: hard error (E_OCCURRED_AT_FUTURE)
141
+ * - If occurred_at > iat (within tolerance): warning (occurred_at_skew)
142
+ * - If occurred_at <= iat: valid, no warning
143
+ * - If occurred_at is undefined: no check performed
144
+ *
145
+ * @param occurredAt - Value of the occurred_at claim, or undefined
146
+ * @param iat - iat claim value (Unix seconds)
147
+ * @param now - Current time (Unix seconds)
148
+ * @param tolerance - Allowed future skew in seconds (default: OCCURRED_AT_TOLERANCE_SECONDS)
149
+ * @returns 'future_error' for hard error, VerificationWarning for skew warning, null for valid
150
+ */
151
+ export declare function checkOccurredAtSkew(occurredAt: string | undefined, iat: number, now: number, tolerance?: number): VerificationWarning | 'future_error' | null;
152
+ //# sourceMappingURL=wire-02-envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-02-envelope.d.ts","sourceRoot":"","sources":["../src/wire-02-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,KAAK,EAAkB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAwBxE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAmCnD;AASD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CA4BzD;AAoBD,eAAO,MAAM,oBAAoB;;;;;;;;;;;EAEhC,CAAC;AAMF,eAAO,MAAM,aAAa;;;;;;;;;;;GAUtB,CAAC;AAML,eAAO,MAAM,gBAAgB;;;EAAoC,CAAC;AAMlE,eAAO,MAAM,iBAAiB,aAE5B,CAAC;AAMH,eAAO,MAAM,kBAAkB,aAE7B,CAAC;AAMH,eAAO,MAAM,iBAAiB;;;;iBAgB5B,CAAC;AAQH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0CpB,CAAC;AAEZ,gDAAgD;AAChD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAM9D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,MAAsC,GAChD,mBAAmB,GAAG,cAAc,GAAG,IAAI,CAiB7C"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Wire 0.2 Typed Extension Group Schemas and Accessors (DD-153 revised)
3
+ *
4
+ * This file contains:
5
+ * - EXTENSION_LIMITS: centralized bounds for extension field lengths
6
+ * - isValidExtensionKey(): grammar validator for reverse-DNS extension keys
7
+ * - 5 extension group Zod schemas (.strict()):
8
+ * CommerceExtensionSchema, AccessExtensionSchema, ChallengeExtensionSchema,
9
+ * IdentityExtensionSchema, CorrelationExtensionSchema
10
+ * - 5 extension key constants (org.peacprotocol/*)
11
+ * - 5 typed accessor helpers (getCommerceExtension, etc.)
12
+ * - validateKnownExtensions(): superRefine helper for Wire02ClaimsSchema
13
+ *
14
+ * Schema validates known extension groups against their Zod schemas and rejects
15
+ * malformed extension key grammar with hard Zod issues. Schema does NOT emit
16
+ * warnings; the unknown_extension_preserved warning belongs in
17
+ * @peac/protocol.verifyLocal() (Layer 3).
18
+ *
19
+ * All 5 group schemas use .strict() (reject unknown keys). The RFC 9457
20
+ * problem nested object uses .passthrough() per RFC 9457 Section 6.2.
21
+ *
22
+ * Layer 1 (@peac/schema): pure Zod validation, zero I/O (DD-141).
23
+ */
24
+ import { z } from 'zod';
25
+ /**
26
+ * Normative bounds for Wire 0.2 extension group fields.
27
+ *
28
+ * Centralised to prevent magic numbers and allow external reference.
29
+ * Follows repo _LIMITS convention.
30
+ */
31
+ export declare const EXTENSION_LIMITS: {
32
+ readonly maxExtensionKeyLength: 512;
33
+ readonly maxDnsLabelLength: 63;
34
+ readonly maxDnsDomainLength: 253;
35
+ readonly maxPaymentRailLength: 128;
36
+ readonly maxCurrencyLength: 16;
37
+ readonly maxAmountMinorLength: 64;
38
+ readonly maxReferenceLength: 256;
39
+ readonly maxAssetLength: 256;
40
+ readonly maxResourceLength: 2048;
41
+ readonly maxActionLength: 256;
42
+ readonly maxProblemTypeLength: 2048;
43
+ readonly maxProblemTitleLength: 256;
44
+ readonly maxProblemDetailLength: 4096;
45
+ readonly maxProblemInstanceLength: 2048;
46
+ readonly maxProofRefLength: 256;
47
+ readonly maxTraceIdLength: 32;
48
+ readonly maxSpanIdLength: 16;
49
+ readonly maxWorkflowIdLength: 256;
50
+ readonly maxParentJtiLength: 256;
51
+ readonly maxDependsOnLength: 64;
52
+ };
53
+ /**
54
+ * Validate that an extension key conforms to the Wire 0.2 extension key
55
+ * grammar: `<domain>/<segment>`.
56
+ *
57
+ * Domain rules:
58
+ * - At least one dot (distinguishes from single-label paths)
59
+ * - Each label matches [a-z0-9]([a-z0-9-]*[a-z0-9])? (lowercase only)
60
+ * - No uppercase letters anywhere in the domain
61
+ *
62
+ * Segment rules:
63
+ * - Matches [a-z0-9][a-z0-9_-]* (lowercase only)
64
+ * - Underscores are permitted (for extension names like credential_event)
65
+ *
66
+ * @param key - Extension key to validate
67
+ * @returns true if valid extension key grammar; false otherwise
68
+ */
69
+ export declare function isValidExtensionKey(key: string): boolean;
70
+ export declare const COMMERCE_EXTENSION_KEY: "org.peacprotocol/commerce";
71
+ export declare const ACCESS_EXTENSION_KEY: "org.peacprotocol/access";
72
+ export declare const CHALLENGE_EXTENSION_KEY: "org.peacprotocol/challenge";
73
+ export declare const IDENTITY_EXTENSION_KEY: "org.peacprotocol/identity";
74
+ export declare const CORRELATION_EXTENSION_KEY: "org.peacprotocol/correlation";
75
+ export declare const CommerceExtensionSchema: z.ZodObject<{
76
+ payment_rail: z.ZodString;
77
+ amount_minor: z.ZodString;
78
+ currency: z.ZodString;
79
+ reference: z.ZodOptional<z.ZodString>;
80
+ asset: z.ZodOptional<z.ZodString>;
81
+ env: z.ZodOptional<z.ZodEnum<{
82
+ live: "live";
83
+ test: "test";
84
+ }>>;
85
+ }, z.core.$strict>;
86
+ export type CommerceExtension = z.infer<typeof CommerceExtensionSchema>;
87
+ export declare const AccessExtensionSchema: z.ZodObject<{
88
+ resource: z.ZodString;
89
+ action: z.ZodString;
90
+ decision: z.ZodEnum<{
91
+ allow: "allow";
92
+ deny: "deny";
93
+ review: "review";
94
+ }>;
95
+ }, z.core.$strict>;
96
+ export type AccessExtension = z.infer<typeof AccessExtensionSchema>;
97
+ /**
98
+ * Challenge type values (7 total, P0-6).
99
+ * Includes purpose_disallowed (reviewer fix: 7 not 6).
100
+ */
101
+ export declare const CHALLENGE_TYPES: readonly ["payment_required", "identity_required", "consent_required", "attestation_required", "rate_limited", "purpose_disallowed", "custom"];
102
+ export declare const ChallengeTypeSchema: z.ZodEnum<{
103
+ custom: "custom";
104
+ payment_required: "payment_required";
105
+ identity_required: "identity_required";
106
+ consent_required: "consent_required";
107
+ attestation_required: "attestation_required";
108
+ rate_limited: "rate_limited";
109
+ purpose_disallowed: "purpose_disallowed";
110
+ }>;
111
+ export type ChallengeType = z.infer<typeof ChallengeTypeSchema>;
112
+ /**
113
+ * RFC 9457 Problem Details schema (P0-5).
114
+ *
115
+ * Uses .passthrough() for extension members per RFC 9457 Section 6.2.
116
+ * Required fields: status (HTTP status code), type (problem type URI).
117
+ * Optional fields: title, detail, instance.
118
+ */
119
+ export declare const ProblemDetailsSchema: z.ZodObject<{
120
+ status: z.ZodNumber;
121
+ type: z.ZodString;
122
+ title: z.ZodOptional<z.ZodString>;
123
+ detail: z.ZodOptional<z.ZodString>;
124
+ instance: z.ZodOptional<z.ZodString>;
125
+ }, z.core.$loose>;
126
+ export declare const ChallengeExtensionSchema: z.ZodObject<{
127
+ challenge_type: z.ZodEnum<{
128
+ custom: "custom";
129
+ payment_required: "payment_required";
130
+ identity_required: "identity_required";
131
+ consent_required: "consent_required";
132
+ attestation_required: "attestation_required";
133
+ rate_limited: "rate_limited";
134
+ purpose_disallowed: "purpose_disallowed";
135
+ }>;
136
+ problem: z.ZodObject<{
137
+ status: z.ZodNumber;
138
+ type: z.ZodString;
139
+ title: z.ZodOptional<z.ZodString>;
140
+ detail: z.ZodOptional<z.ZodString>;
141
+ instance: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$loose>;
143
+ resource: z.ZodOptional<z.ZodString>;
144
+ action: z.ZodOptional<z.ZodString>;
145
+ requirements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
146
+ }, z.core.$strict>;
147
+ export type ChallengeExtension = z.infer<typeof ChallengeExtensionSchema>;
148
+ export declare const IdentityExtensionSchema: z.ZodObject<{
149
+ proof_ref: z.ZodOptional<z.ZodString>;
150
+ }, z.core.$strict>;
151
+ export type IdentityExtension = z.infer<typeof IdentityExtensionSchema>;
152
+ export declare const CorrelationExtensionSchema: z.ZodObject<{
153
+ trace_id: z.ZodOptional<z.ZodString>;
154
+ span_id: z.ZodOptional<z.ZodString>;
155
+ workflow_id: z.ZodOptional<z.ZodString>;
156
+ parent_jti: z.ZodOptional<z.ZodString>;
157
+ depends_on: z.ZodOptional<z.ZodArray<z.ZodString>>;
158
+ }, z.core.$strict>;
159
+ export type CorrelationExtension = z.infer<typeof CorrelationExtensionSchema>;
160
+ /**
161
+ * Get the commerce extension group from a Wire 0.2 receipt's extensions.
162
+ *
163
+ * @param extensions - Wire 0.2 extensions record (or undefined)
164
+ * @returns Parsed CommerceExtension, or undefined if key absent
165
+ * @throws PEACError with RFC 6901 pointer if present but invalid
166
+ */
167
+ export declare function getCommerceExtension(extensions?: Record<string, unknown>): CommerceExtension | undefined;
168
+ /**
169
+ * Get the access extension group from a Wire 0.2 receipt's extensions.
170
+ *
171
+ * @param extensions - Wire 0.2 extensions record (or undefined)
172
+ * @returns Parsed AccessExtension, or undefined if key absent
173
+ * @throws PEACError with RFC 6901 pointer if present but invalid
174
+ */
175
+ export declare function getAccessExtension(extensions?: Record<string, unknown>): AccessExtension | undefined;
176
+ /**
177
+ * Get the challenge extension group from a Wire 0.2 receipt's extensions.
178
+ *
179
+ * @param extensions - Wire 0.2 extensions record (or undefined)
180
+ * @returns Parsed ChallengeExtension, or undefined if key absent
181
+ * @throws PEACError with RFC 6901 pointer if present but invalid
182
+ */
183
+ export declare function getChallengeExtension(extensions?: Record<string, unknown>): ChallengeExtension | undefined;
184
+ /**
185
+ * Get the identity extension group from a Wire 0.2 receipt's extensions.
186
+ *
187
+ * @param extensions - Wire 0.2 extensions record (or undefined)
188
+ * @returns Parsed IdentityExtension, or undefined if key absent
189
+ * @throws PEACError with RFC 6901 pointer if present but invalid
190
+ */
191
+ export declare function getIdentityExtension(extensions?: Record<string, unknown>): IdentityExtension | undefined;
192
+ /**
193
+ * Get the correlation extension group from a Wire 0.2 receipt's extensions.
194
+ *
195
+ * @param extensions - Wire 0.2 extensions record (or undefined)
196
+ * @returns Parsed CorrelationExtension, or undefined if key absent
197
+ * @throws PEACError with RFC 6901 pointer if present but invalid
198
+ */
199
+ export declare function getCorrelationExtension(extensions?: Record<string, unknown>): CorrelationExtension | undefined;
200
+ /**
201
+ * Validate extensions record in Wire02ClaimsSchema.superRefine().
202
+ *
203
+ * For each key in the extensions record:
204
+ * 1. Check key grammar via isValidExtensionKey(): if malformed,
205
+ * add hard Zod issue (ERROR_CODES.E_INVALID_EXTENSION_KEY)
206
+ * 2. If key matches a known group, validate value against its schema;
207
+ * if invalid, add Zod issue with message from first schema error
208
+ *
209
+ * Schema does NOT emit unknown_extension_preserved warning for
210
+ * unrecognized keys (that belongs in @peac/protocol.verifyLocal()).
211
+ *
212
+ * @param extensions - The extensions record from Wire 0.2 claims
213
+ * @param ctx - Zod refinement context
214
+ */
215
+ export declare function validateKnownExtensions(extensions: Record<string, unknown> | undefined, ctx: z.RefinementCtx): void;
216
+ //# sourceMappingURL=wire-02-extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-02-extensions.d.ts","sourceRoot":"","sources":["../src/wire-02-extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;CA2BnB,CAAC;AAkBX;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CA0BxD;AAMD,eAAO,MAAM,sBAAsB,EAAG,2BAAoC,CAAC;AAC3E,eAAO,MAAM,oBAAoB,EAAG,yBAAkC,CAAC;AACvE,eAAO,MAAM,uBAAuB,EAAG,4BAAqC,CAAC;AAC7E,eAAO,MAAM,sBAAsB,EAAG,2BAAoC,CAAC;AAC3E,eAAO,MAAM,yBAAyB,EAAG,8BAAuC,CAAC;AAkCjF,eAAO,MAAM,uBAAuB;;;;;;;;;;kBA0BzB,CAAC;AAEZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAMxE,eAAO,MAAM,qBAAqB;;;;;;;;kBASvB,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMpE;;;GAGG;AACH,eAAO,MAAM,eAAe,gJAQlB,CAAC;AAEX,eAAO,MAAM,mBAAmB;;;;;;;;EAA0B,CAAC;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;iBAajB,CAAC;AAEjB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;kBAa1B,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAM1E,eAAO,MAAM,uBAAuB;;kBAKzB,CAAC;AAEZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAYxE,eAAO,MAAM,0BAA0B;;;;;;kBAwB5B,CAAC;AAEZ,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAuD9E;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,iBAAiB,GAAG,SAAS,CAE/B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,eAAe,GAAG,SAAS,CAE7B;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,kBAAkB,GAAG,SAAS,CAEhC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,iBAAiB,GAAG,SAAS,CAE/B;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,oBAAoB,GAAG,SAAS,CAElC;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC/C,GAAG,EAAE,CAAC,CAAC,aAAa,GACnB,IAAI,CA8BN"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Wire 0.2 recommended receipt type and extension group registries.
3
+ *
4
+ * These are pure constants derived from the single source of truth:
5
+ * specs/kernel/registries.json
6
+ *
7
+ * Used by @peac/protocol.verifyLocal() to emit type_unregistered and
8
+ * unknown_extension_preserved warnings for valid-but-unrecognized values.
9
+ */
10
+ /**
11
+ * Recommended receipt type values from the receipt_types registry.
12
+ * A type NOT in this set triggers a type_unregistered warning (not an error).
13
+ */
14
+ export declare const REGISTERED_RECEIPT_TYPES: ReadonlySet<string>;
15
+ /**
16
+ * Core extension group keys that have typed schemas in @peac/schema.
17
+ * An extension key NOT in this set (but passing grammar validation)
18
+ * triggers an unknown_extension_preserved warning (not an error).
19
+ */
20
+ export declare const REGISTERED_EXTENSION_GROUP_KEYS: ReadonlySet<string>;
21
+ //# sourceMappingURL=wire-02-registries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-02-registries.d.ts","sourceRoot":"","sources":["../src/wire-02-registries.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,MAAM,CAWvD,CAAC;AAMH;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAE,WAAW,CAAC,MAAM,CAM9D,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Wire 0.2 RepresentationFields schema (DD-152)
3
+ *
4
+ * Records metadata about the content representation that was observed or served,
5
+ * enabling reproducible content drift detection.
6
+ *
7
+ * Layer 1 (@peac/schema): pure Zod validation, zero I/O (DD-141).
8
+ *
9
+ * content_hash validation uses stringToFingerprintRef() as the parser gate
10
+ * and additionally requires alg === 'sha256'. The hmac-sha256 algorithm is
11
+ * not permitted for representation hashes (sha256-only by design).
12
+ */
13
+ import { z } from 'zod';
14
+ /**
15
+ * Normative bounds for Wire 0.2 representation fields.
16
+ *
17
+ * Centralised to prevent magic numbers and allow external reference.
18
+ */
19
+ export declare const REPRESENTATION_LIMITS: {
20
+ /** Max content_hash string length (sha256:<64 hex> = 71 chars, capped at FingerprintRef max) */
21
+ readonly maxContentHashLength: 76;
22
+ /** Max content_type string length */
23
+ readonly maxContentTypeLength: 256;
24
+ };
25
+ /**
26
+ * Zod schema for Wire 0.2 representation fields (DD-152).
27
+ *
28
+ * All fields are optional; an empty object is valid.
29
+ * Unknown keys are rejected (.strict()).
30
+ *
31
+ * Bounds:
32
+ * - content_hash: max 76 chars (MAX_FINGERPRINT_REF_LENGTH), sha256-only
33
+ * - content_type: max 256 chars, conservative MIME pattern
34
+ * - content_length: non-negative integer, <= Number.MAX_SAFE_INTEGER
35
+ */
36
+ export declare const Wire02RepresentationFieldsSchema: z.ZodObject<{
37
+ content_hash: z.ZodOptional<z.ZodString>;
38
+ content_type: z.ZodOptional<z.ZodString>;
39
+ content_length: z.ZodOptional<z.ZodNumber>;
40
+ }, z.core.$strict>;
41
+ /** Inferred type for Wire 0.2 representation fields */
42
+ export type Wire02RepresentationFields = z.infer<typeof Wire02RepresentationFieldsSchema>;
43
+ /**
44
+ * Public export alias.
45
+ * Internal name is Wire02RepresentationFieldsSchema to prevent wire-version
46
+ * collisions; exported as RepresentationFieldsSchema for ergonomic use.
47
+ */
48
+ export { Wire02RepresentationFieldsSchema as RepresentationFieldsSchema };
49
+ //# sourceMappingURL=wire-02-representation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-02-representation.d.ts","sourceRoot":"","sources":["../src/wire-02-representation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4CxB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;IAChC,gGAAgG;;IAEhG,qCAAqC;;CAE7B,CAAC;AAMX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gCAAgC;;;;kBA+BlC,CAAC;AAEZ,uDAAuD;AACvD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F;;;;GAIG;AACH,OAAO,EAAE,gCAAgC,IAAI,0BAA0B,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Wire 0.2 verification warning codes and collector (v0.12.0-preview.1, DD-155)
3
+ *
4
+ * Warning codes are append-only stable string literals. Warnings do NOT affect
5
+ * the allow/deny decision unless caller policy requires it.
6
+ *
7
+ * Warnings MUST be sorted by (pointer ascending, code ascending);
8
+ * undefined pointer sorts before any string value.
9
+ *
10
+ * RFC 6901 JSON Pointer escaping: '/' in keys is escaped as '~1', '~' as '~0'.
11
+ */
12
+ import type { VerificationWarning } from '@peac/kernel';
13
+ /** type claim does not match any registered type in the receipt_types registry */
14
+ export declare const WARNING_TYPE_UNREGISTERED: "type_unregistered";
15
+ /** Unknown extension key was encountered and preserved (no schema validation) */
16
+ export declare const WARNING_UNKNOWN_EXTENSION: "unknown_extension_preserved";
17
+ /** occurred_at is after iat by more than zero but within the tolerance window */
18
+ export declare const WARNING_OCCURRED_AT_SKEW: "occurred_at_skew";
19
+ /** JWS typ header was absent; interop mode accepted the token without typ */
20
+ export declare const WARNING_TYP_MISSING: "typ_missing";
21
+ /**
22
+ * Sort warnings by (pointer ascending, code ascending).
23
+ * Warnings with undefined pointer sort before those with a defined pointer.
24
+ *
25
+ * @param warnings - Array of VerificationWarning objects to sort
26
+ * @returns New array sorted in canonical order
27
+ */
28
+ export declare function sortWarnings(warnings: VerificationWarning[]): VerificationWarning[];
29
+ //# sourceMappingURL=wire-02-warnings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-02-warnings.d.ts","sourceRoot":"","sources":["../src/wire-02-warnings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMxD,kFAAkF;AAClF,eAAO,MAAM,yBAAyB,EAAG,mBAA4B,CAAC;AAEtE,iFAAiF;AACjF,eAAO,MAAM,yBAAyB,EAAG,6BAAsC,CAAC;AAEhF,iFAAiF;AACjF,eAAO,MAAM,wBAAwB,EAAG,kBAA2B,CAAC;AAEpE,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,EAAG,aAAsB,CAAC;AAM1D;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,EAAE,CAkBnF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peac/schema",
3
- "version": "0.11.3",
3
+ "version": "0.12.0-preview.1",
4
4
  "description": "PEAC Protocol JSON schemas, OpenAPI specs, and TypeScript types",
5
5
  "main": "dist/index.cjs",
6
6
  "types": "dist/index.d.ts",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "zod": "^4.3.6",
66
- "@peac/kernel": "0.11.3"
66
+ "@peac/kernel": "0.12.0-preview.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/node": "^22.19.11",