@peac/schema 0.9.18
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.
- package/README.md +23 -0
- package/dist/constants.d.ts +28 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -0
- package/dist/control.d.ts +155 -0
- package/dist/control.d.ts.map +1 -0
- package/dist/control.js +9 -0
- package/dist/control.js.map +1 -0
- package/dist/envelope.d.ts +62 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +9 -0
- package/dist/envelope.js.map +1 -0
- package/dist/errors.d.ts +134 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +51 -0
- package/dist/errors.js.map +1 -0
- package/dist/evidence.d.ts +267 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +8 -0
- package/dist/evidence.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/normalize.d.ts +92 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +102 -0
- package/dist/normalize.js.map +1 -0
- package/dist/schemas.d.ts +3 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +7 -0
- package/dist/schemas.js.map +1 -0
- package/dist/subject.d.ts +111 -0
- package/dist/subject.d.ts.map +1 -0
- package/dist/subject.js +9 -0
- package/dist/subject.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/validators.d.ts +656 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +290 -0
- package/dist/validators.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Evidence Types
|
|
3
|
+
*
|
|
4
|
+
* Payment and attestation evidence for receipts.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Payment rail identifier (vendor-neutral string)
|
|
8
|
+
*
|
|
9
|
+
* Common rails (see docs/specs/registries.json):
|
|
10
|
+
* - "x402" - HTTP 402 paid calls
|
|
11
|
+
* - "l402" - Lightning HTTP 402 (LSAT)
|
|
12
|
+
* - "card-network" - Generic card networks
|
|
13
|
+
* - "upi" - Unified Payments Interface
|
|
14
|
+
*
|
|
15
|
+
* Rail identifiers are opaque strings. Vendor-specific details
|
|
16
|
+
* belong in payment.evidence or adapter packages (@peac/rails-*).
|
|
17
|
+
*/
|
|
18
|
+
export type PaymentRailId = string;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use PaymentRailId. Type renamed in v0.9.15. Will be removed in v0.9.17.
|
|
21
|
+
*/
|
|
22
|
+
export type PaymentScheme = PaymentRailId;
|
|
23
|
+
/**
|
|
24
|
+
* Payment split - allocation of payment to a party
|
|
25
|
+
*
|
|
26
|
+
* Used for marketplace/aggregator scenarios where a single payment
|
|
27
|
+
* is split among multiple parties (platform, merchant, affiliates, etc.)
|
|
28
|
+
*
|
|
29
|
+
* Invariants:
|
|
30
|
+
* - `party` is REQUIRED (identifies the recipient)
|
|
31
|
+
* - `amount` if present MUST be >= 0
|
|
32
|
+
* - `share` if present MUST be in [0,1]
|
|
33
|
+
* - At least one of `amount` or `share` MUST be specified
|
|
34
|
+
*
|
|
35
|
+
* Note: The sum of splits is NOT enforced to equal the total payment amount.
|
|
36
|
+
* This is by design - partial splits, fees, and platform-specific allocation
|
|
37
|
+
* logic are all valid use cases.
|
|
38
|
+
*/
|
|
39
|
+
export interface PaymentSplit {
|
|
40
|
+
/**
|
|
41
|
+
* Party identifier (REQUIRED)
|
|
42
|
+
*
|
|
43
|
+
* Identifies the recipient of this split. Examples:
|
|
44
|
+
* - "merchant" - Primary merchant
|
|
45
|
+
* - "platform" - Platform fee
|
|
46
|
+
* - "affiliate:partner_123" - Affiliate/referral
|
|
47
|
+
* - "tax" - Tax authority
|
|
48
|
+
*/
|
|
49
|
+
party: string;
|
|
50
|
+
/**
|
|
51
|
+
* Absolute amount in smallest currency unit (OPTIONAL)
|
|
52
|
+
*
|
|
53
|
+
* Must be >= 0 if specified.
|
|
54
|
+
* Examples: 1000 (for $10.00 in USD), 50000 (for 500.00 INR)
|
|
55
|
+
*/
|
|
56
|
+
amount?: number;
|
|
57
|
+
/**
|
|
58
|
+
* ISO 4217 currency code (OPTIONAL)
|
|
59
|
+
*
|
|
60
|
+
* Uppercase 3-letter code. Defaults to parent payment's currency if omitted.
|
|
61
|
+
*/
|
|
62
|
+
currency?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Fractional share of the total (OPTIONAL)
|
|
65
|
+
*
|
|
66
|
+
* Must be in [0,1] if specified.
|
|
67
|
+
* Examples: 0.8 (80%), 0.15 (15%), 0.05 (5%)
|
|
68
|
+
*/
|
|
69
|
+
share?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Payment rail for this split (OPTIONAL)
|
|
72
|
+
*
|
|
73
|
+
* If different from parent payment's rail.
|
|
74
|
+
*/
|
|
75
|
+
rail?: PaymentRailId;
|
|
76
|
+
/**
|
|
77
|
+
* Account reference for the recipient (OPTIONAL)
|
|
78
|
+
*
|
|
79
|
+
* Examples:
|
|
80
|
+
* - "acct_merchant_abc" - Merchant account
|
|
81
|
+
* - "upi:merchant@bank" - UPI VPA
|
|
82
|
+
* - "wallet_xyz" - Wallet ID
|
|
83
|
+
*/
|
|
84
|
+
account_ref?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Additional metadata (OPTIONAL)
|
|
87
|
+
*
|
|
88
|
+
* Rail-specific or application-specific data.
|
|
89
|
+
*/
|
|
90
|
+
metadata?: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Payment evidence - rail-agnostic normalized payment
|
|
94
|
+
*
|
|
95
|
+
* All payment rails MUST produce this normalized structure.
|
|
96
|
+
* Rail-specific details go in the `evidence` field.
|
|
97
|
+
*
|
|
98
|
+
* Invariants:
|
|
99
|
+
* - `asset` and `env` are REQUIRED
|
|
100
|
+
* - `network` is OPTIONAL but SHOULD be provided for crypto rails
|
|
101
|
+
* - `facilitator_ref` is OPTIONAL
|
|
102
|
+
* - `evidence` is opaque in v0.9; may become discriminated union in v1.0
|
|
103
|
+
*/
|
|
104
|
+
export interface PaymentEvidence {
|
|
105
|
+
/** Payment rail identifier */
|
|
106
|
+
rail: PaymentRailId;
|
|
107
|
+
/** Rail-specific payment reference/ID */
|
|
108
|
+
reference: string;
|
|
109
|
+
/** Amount in smallest currency unit (cents, sats, paise, etc.) */
|
|
110
|
+
amount: number;
|
|
111
|
+
/** ISO 4217 currency code (uppercase) */
|
|
112
|
+
currency: string;
|
|
113
|
+
/**
|
|
114
|
+
* Asset transferred (REQUIRED)
|
|
115
|
+
*
|
|
116
|
+
* Examples: "USD", "USDC", "BTC", "INR", "EUR"
|
|
117
|
+
*
|
|
118
|
+
* For crypto: use ticker symbol
|
|
119
|
+
* For fiat: use ISO 4217 code
|
|
120
|
+
*/
|
|
121
|
+
asset: string;
|
|
122
|
+
/**
|
|
123
|
+
* Environment (REQUIRED)
|
|
124
|
+
*
|
|
125
|
+
* - "live": Production/real money
|
|
126
|
+
* - "test": Sandbox/test mode
|
|
127
|
+
*/
|
|
128
|
+
env: 'live' | 'test';
|
|
129
|
+
/**
|
|
130
|
+
* Network/rail identifier (OPTIONAL, SHOULD for crypto)
|
|
131
|
+
*
|
|
132
|
+
* Examples:
|
|
133
|
+
* - "lightning" - Bitcoin Lightning Network
|
|
134
|
+
* - "base-mainnet" - Base (Coinbase L2)
|
|
135
|
+
* - "solana" - Solana mainnet
|
|
136
|
+
* - "upi" - Unified Payments Interface (India)
|
|
137
|
+
* - "ach" - ACH network (US)
|
|
138
|
+
*
|
|
139
|
+
* Not applicable for traditional payment processors.
|
|
140
|
+
*/
|
|
141
|
+
network?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Facilitator reference (OPTIONAL)
|
|
144
|
+
*
|
|
145
|
+
* Stable identifier for the PSP/facilitator processing this payment.
|
|
146
|
+
*
|
|
147
|
+
* Examples:
|
|
148
|
+
* - "acct_1234567890"
|
|
149
|
+
* - "facilitator_account_xyz"
|
|
150
|
+
* - "acc_ABC123"
|
|
151
|
+
*/
|
|
152
|
+
facilitator_ref?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Rail-specific evidence (opaque in v0.9)
|
|
155
|
+
*
|
|
156
|
+
* Structure varies by rail. Examples:
|
|
157
|
+
*
|
|
158
|
+
* x402/Lightning:
|
|
159
|
+
* {
|
|
160
|
+
* "preimage": "...",
|
|
161
|
+
* "invoice": "lnbc...",
|
|
162
|
+
* "settled_at": 1234567890,
|
|
163
|
+
* "node_id": "03..."
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* Traditional payment processor:
|
|
167
|
+
* {
|
|
168
|
+
* "payment_intent": "pi_...",
|
|
169
|
+
* "session_id": "cs_...",
|
|
170
|
+
* "payment_method": "pm_...",
|
|
171
|
+
* "customer_id": "cus_..."
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* UPI:
|
|
175
|
+
* {
|
|
176
|
+
* "vpa": "user@bank",
|
|
177
|
+
* "txn_id": "...",
|
|
178
|
+
* "approver": "..."
|
|
179
|
+
* }
|
|
180
|
+
*
|
|
181
|
+
* Future: May become discriminated union in v1.0.
|
|
182
|
+
*/
|
|
183
|
+
evidence: unknown;
|
|
184
|
+
/**
|
|
185
|
+
* Aggregator/marketplace identifier (OPTIONAL)
|
|
186
|
+
*
|
|
187
|
+
* Identifies the platform or aggregator processing this payment
|
|
188
|
+
* on behalf of sub-merchants. Examples:
|
|
189
|
+
* - "marketplace_abc" - Marketplace ID
|
|
190
|
+
* - "platform:uber" - Platform identifier
|
|
191
|
+
* - "aggregator_xyz" - Payment aggregator
|
|
192
|
+
*/
|
|
193
|
+
aggregator?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Payment splits (OPTIONAL)
|
|
196
|
+
*
|
|
197
|
+
* Allocation of payment among multiple parties.
|
|
198
|
+
* Used for marketplace scenarios, affiliate payouts,
|
|
199
|
+
* platform fees, tax withholding, etc.
|
|
200
|
+
*
|
|
201
|
+
* Note: Sum of splits is NOT required to equal total amount.
|
|
202
|
+
*/
|
|
203
|
+
splits?: PaymentSplit[];
|
|
204
|
+
/**
|
|
205
|
+
* Payment routing mode (OPTIONAL, rail-agnostic)
|
|
206
|
+
*
|
|
207
|
+
* Describes how the payment is routed between payer, aggregator, and merchant.
|
|
208
|
+
* This is a generic hint - specific rails populate it from their native formats.
|
|
209
|
+
*
|
|
210
|
+
* Values:
|
|
211
|
+
* - "direct": Direct payment to merchant (no intermediary)
|
|
212
|
+
* - "callback": Routed via callback URL / payment service
|
|
213
|
+
* - "role": Role-based routing (e.g., "publisher", "platform")
|
|
214
|
+
*
|
|
215
|
+
* Examples of producers:
|
|
216
|
+
* - x402 v2 `payTo.mode` -> routing
|
|
217
|
+
* - Stripe Connect `destination` -> routing = 'direct' or 'callback'
|
|
218
|
+
* - UPI `pa` (payee address) -> routing = 'direct'
|
|
219
|
+
*/
|
|
220
|
+
routing?: 'direct' | 'callback' | 'role';
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Attestation evidence - TEE/platform attestation
|
|
224
|
+
*
|
|
225
|
+
* Used for proving the execution environment or platform
|
|
226
|
+
* properties of the issuer/verifier.
|
|
227
|
+
*
|
|
228
|
+
* Examples:
|
|
229
|
+
* - TPM attestation
|
|
230
|
+
* - SGX attestation
|
|
231
|
+
* - AWS Nitro Enclaves
|
|
232
|
+
* - SEV-SNP attestation
|
|
233
|
+
*/
|
|
234
|
+
export interface AttestationEvidence {
|
|
235
|
+
/**
|
|
236
|
+
* Attestation format
|
|
237
|
+
*
|
|
238
|
+
* Well-known formats:
|
|
239
|
+
* - "tpm2.0" - TPM 2.0 attestation
|
|
240
|
+
* - "sgx" - Intel SGX attestation
|
|
241
|
+
* - "sev-snp" - AMD SEV-SNP attestation
|
|
242
|
+
* - "nitro" - AWS Nitro Enclaves
|
|
243
|
+
* - "custom" - Custom attestation format
|
|
244
|
+
*/
|
|
245
|
+
format: string;
|
|
246
|
+
/**
|
|
247
|
+
* Attestation-specific evidence
|
|
248
|
+
*
|
|
249
|
+
* Structure varies by format. Examples:
|
|
250
|
+
*
|
|
251
|
+
* TPM 2.0:
|
|
252
|
+
* {
|
|
253
|
+
* "pcr_values": {...},
|
|
254
|
+
* "quote": "...",
|
|
255
|
+
* "signature": "..."
|
|
256
|
+
* }
|
|
257
|
+
*
|
|
258
|
+
* SGX:
|
|
259
|
+
* {
|
|
260
|
+
* "quote": "...",
|
|
261
|
+
* "mrenclave": "...",
|
|
262
|
+
* "mrsigner": "..."
|
|
263
|
+
* }
|
|
264
|
+
*/
|
|
265
|
+
evidence: unknown;
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IAErB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,IAAI,EAAE,aAAa,CAAC;IAEpB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAElB,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;IAEf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IAExB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;CAC1C;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;OASG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
package/dist/evidence.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Protocol Schema Package
|
|
3
|
+
* Wire format frozen at peac.receipt/0.9 with v1.0-equivalent semantics
|
|
4
|
+
*/
|
|
5
|
+
export * from './envelope';
|
|
6
|
+
export * from './control';
|
|
7
|
+
export * from './evidence';
|
|
8
|
+
export * from './subject';
|
|
9
|
+
export * from './errors';
|
|
10
|
+
export * from './normalize';
|
|
11
|
+
export * from './constants';
|
|
12
|
+
export * from './types';
|
|
13
|
+
export { NormalizedPayment, Extensions, JWSHeader, ReceiptClaims, Subject as SubjectSchema, AIPREFSnapshot as AIPREFSnapshotSchema, VerifyRequest as VerifyRequestSchema, ControlPurposeSchema, ControlLicensingModeSchema, ControlDecisionSchema, ControlStepSchema, ControlBlockSchema, PaymentSplitSchema, PaymentEvidenceSchema, PaymentRoutingSchema, SubjectTypeSchema, SubjectProfileSchema, SubjectProfileSnapshotSchema, validateSubjectSnapshot, } from './validators';
|
|
14
|
+
export type { PEACEnvelope, AuthContext, EvidenceBlock, MetadataBlock, EnforcementContext, TransportBinding, ContextMetadata, } from './envelope';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAG5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,aAAa,EACb,OAAO,IAAI,aAAa,EACxB,cAAc,IAAI,oBAAoB,EACtC,aAAa,IAAI,mBAAmB,EAEpC,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAElB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EAEpB,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAE5B,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PEAC Protocol Schema Package
|
|
4
|
+
* Wire format frozen at peac.receipt/0.9 with v1.0-equivalent semantics
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.validateSubjectSnapshot = exports.SubjectProfileSnapshotSchema = exports.SubjectProfileSchema = exports.SubjectTypeSchema = exports.PaymentRoutingSchema = exports.PaymentEvidenceSchema = exports.PaymentSplitSchema = exports.ControlBlockSchema = exports.ControlStepSchema = exports.ControlDecisionSchema = exports.ControlLicensingModeSchema = exports.ControlPurposeSchema = exports.VerifyRequestSchema = exports.AIPREFSnapshotSchema = exports.SubjectSchema = exports.ReceiptClaims = exports.JWSHeader = exports.Extensions = exports.NormalizedPayment = void 0;
|
|
22
|
+
// Core envelope and types
|
|
23
|
+
__exportStar(require("./envelope"), exports);
|
|
24
|
+
__exportStar(require("./control"), exports);
|
|
25
|
+
__exportStar(require("./evidence"), exports);
|
|
26
|
+
__exportStar(require("./subject"), exports);
|
|
27
|
+
__exportStar(require("./errors"), exports);
|
|
28
|
+
__exportStar(require("./normalize"), exports);
|
|
29
|
+
// Legacy types (for backward compatibility in tests)
|
|
30
|
+
__exportStar(require("./constants"), exports);
|
|
31
|
+
__exportStar(require("./types"), exports);
|
|
32
|
+
// Validators (explicit exports to avoid name conflicts with types)
|
|
33
|
+
var validators_1 = require("./validators");
|
|
34
|
+
Object.defineProperty(exports, "NormalizedPayment", { enumerable: true, get: function () { return validators_1.NormalizedPayment; } });
|
|
35
|
+
Object.defineProperty(exports, "Extensions", { enumerable: true, get: function () { return validators_1.Extensions; } });
|
|
36
|
+
Object.defineProperty(exports, "JWSHeader", { enumerable: true, get: function () { return validators_1.JWSHeader; } });
|
|
37
|
+
Object.defineProperty(exports, "ReceiptClaims", { enumerable: true, get: function () { return validators_1.ReceiptClaims; } });
|
|
38
|
+
Object.defineProperty(exports, "SubjectSchema", { enumerable: true, get: function () { return validators_1.Subject; } });
|
|
39
|
+
Object.defineProperty(exports, "AIPREFSnapshotSchema", { enumerable: true, get: function () { return validators_1.AIPREFSnapshot; } });
|
|
40
|
+
Object.defineProperty(exports, "VerifyRequestSchema", { enumerable: true, get: function () { return validators_1.VerifyRequest; } });
|
|
41
|
+
// CAL validators (v0.9.16+)
|
|
42
|
+
Object.defineProperty(exports, "ControlPurposeSchema", { enumerable: true, get: function () { return validators_1.ControlPurposeSchema; } });
|
|
43
|
+
Object.defineProperty(exports, "ControlLicensingModeSchema", { enumerable: true, get: function () { return validators_1.ControlLicensingModeSchema; } });
|
|
44
|
+
Object.defineProperty(exports, "ControlDecisionSchema", { enumerable: true, get: function () { return validators_1.ControlDecisionSchema; } });
|
|
45
|
+
Object.defineProperty(exports, "ControlStepSchema", { enumerable: true, get: function () { return validators_1.ControlStepSchema; } });
|
|
46
|
+
Object.defineProperty(exports, "ControlBlockSchema", { enumerable: true, get: function () { return validators_1.ControlBlockSchema; } });
|
|
47
|
+
// Payment evidence validators (v0.9.16+)
|
|
48
|
+
Object.defineProperty(exports, "PaymentSplitSchema", { enumerable: true, get: function () { return validators_1.PaymentSplitSchema; } });
|
|
49
|
+
Object.defineProperty(exports, "PaymentEvidenceSchema", { enumerable: true, get: function () { return validators_1.PaymentEvidenceSchema; } });
|
|
50
|
+
Object.defineProperty(exports, "PaymentRoutingSchema", { enumerable: true, get: function () { return validators_1.PaymentRoutingSchema; } });
|
|
51
|
+
// Subject profile validators (v0.9.16+)
|
|
52
|
+
Object.defineProperty(exports, "SubjectTypeSchema", { enumerable: true, get: function () { return validators_1.SubjectTypeSchema; } });
|
|
53
|
+
Object.defineProperty(exports, "SubjectProfileSchema", { enumerable: true, get: function () { return validators_1.SubjectProfileSchema; } });
|
|
54
|
+
Object.defineProperty(exports, "SubjectProfileSnapshotSchema", { enumerable: true, get: function () { return validators_1.SubjectProfileSnapshotSchema; } });
|
|
55
|
+
// Subject snapshot validation helper (v0.9.17+)
|
|
56
|
+
Object.defineProperty(exports, "validateSubjectSnapshot", { enumerable: true, get: function () { return validators_1.validateSubjectSnapshot; } });
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,0BAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B;AAE5B,qDAAqD;AACrD,8CAA4B;AAC5B,0CAAwB;AAExB,mEAAmE;AACnE,2CAwBsB;AAvBpB,+GAAA,iBAAiB,OAAA;AACjB,wGAAA,UAAU,OAAA;AACV,uGAAA,SAAS,OAAA;AACT,2GAAA,aAAa,OAAA;AACb,2GAAA,OAAO,OAAiB;AACxB,kHAAA,cAAc,OAAwB;AACtC,iHAAA,aAAa,OAAuB;AACpC,4BAA4B;AAC5B,kHAAA,oBAAoB,OAAA;AACpB,wHAAA,0BAA0B,OAAA;AAC1B,mHAAA,qBAAqB,OAAA;AACrB,+GAAA,iBAAiB,OAAA;AACjB,gHAAA,kBAAkB,OAAA;AAClB,yCAAyC;AACzC,gHAAA,kBAAkB,OAAA;AAClB,mHAAA,qBAAqB,OAAA;AACrB,kHAAA,oBAAoB,OAAA;AACpB,wCAAwC;AACxC,+GAAA,iBAAiB,OAAA;AACjB,kHAAA,oBAAoB,OAAA;AACpB,0HAAA,4BAA4B,OAAA;AAC5B,gDAAgD;AAChD,qHAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Normalization
|
|
3
|
+
*
|
|
4
|
+
* Functions to normalize receipt claims to a canonical form for comparison.
|
|
5
|
+
* Produces byte-identical JCS output regardless of how the receipt was created.
|
|
6
|
+
*/
|
|
7
|
+
import type { PEACReceiptClaims, Subject } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Normalized core claims for comparison.
|
|
10
|
+
*
|
|
11
|
+
* This is the minimal set of fields that represent the semantic meaning
|
|
12
|
+
* of a receipt. All optional fields that are undefined are omitted.
|
|
13
|
+
*/
|
|
14
|
+
export interface CoreClaims {
|
|
15
|
+
/** Issuer URL */
|
|
16
|
+
iss: string;
|
|
17
|
+
/** Audience / resource URL */
|
|
18
|
+
aud: string;
|
|
19
|
+
/** Receipt ID */
|
|
20
|
+
rid: string;
|
|
21
|
+
/** Issued at timestamp */
|
|
22
|
+
iat: number;
|
|
23
|
+
/** Expiry timestamp (omitted if not present) */
|
|
24
|
+
exp?: number;
|
|
25
|
+
/** Amount in smallest currency unit */
|
|
26
|
+
amt: number;
|
|
27
|
+
/** Currency code (ISO 4217) */
|
|
28
|
+
cur: string;
|
|
29
|
+
/** Normalized payment evidence */
|
|
30
|
+
payment: NormalizedPayment;
|
|
31
|
+
/** Subject (omitted if not present) */
|
|
32
|
+
subject?: Subject;
|
|
33
|
+
/** Control block (omitted if not present) */
|
|
34
|
+
control?: NormalizedControl;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Normalized payment evidence for comparison.
|
|
38
|
+
*
|
|
39
|
+
* Only includes the semantic fields, not rail-specific evidence.
|
|
40
|
+
*/
|
|
41
|
+
export interface NormalizedPayment {
|
|
42
|
+
rail: string;
|
|
43
|
+
reference: string;
|
|
44
|
+
amount: number;
|
|
45
|
+
currency: string;
|
|
46
|
+
asset: string;
|
|
47
|
+
env: 'live' | 'test';
|
|
48
|
+
network?: string;
|
|
49
|
+
aggregator?: string;
|
|
50
|
+
routing?: 'direct' | 'callback' | 'role';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Normalized control block for comparison.
|
|
54
|
+
*/
|
|
55
|
+
export interface NormalizedControl {
|
|
56
|
+
chain: NormalizedControlStep[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Normalized control step for comparison.
|
|
60
|
+
*/
|
|
61
|
+
export interface NormalizedControlStep {
|
|
62
|
+
engine: string;
|
|
63
|
+
result: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract core claims from a receipt for comparison.
|
|
67
|
+
*
|
|
68
|
+
* This function produces a normalized object that can be JCS-canonicalized
|
|
69
|
+
* to produce byte-identical output regardless of how the receipt was created
|
|
70
|
+
* (via x402, TAP, RSL, ACP, or direct issuance).
|
|
71
|
+
*
|
|
72
|
+
* The output:
|
|
73
|
+
* - Contains only semantically meaningful fields
|
|
74
|
+
* - Omits undefined optional fields (not null, not empty string)
|
|
75
|
+
* - Uses consistent field ordering (JCS handles this)
|
|
76
|
+
* - Strips rail-specific evidence details
|
|
77
|
+
*
|
|
78
|
+
* @param claims - Receipt claims to normalize
|
|
79
|
+
* @returns Normalized core claims
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { toCoreClaims } from '@peac/schema';
|
|
84
|
+
* import { canonicalize } from '@peac/crypto';
|
|
85
|
+
*
|
|
86
|
+
* const core = toCoreClaims(receiptClaims);
|
|
87
|
+
* const canonical = canonicalize(core);
|
|
88
|
+
* // canonical is byte-identical regardless of source
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function toCoreClaims(claims: PEACReceiptClaims): CoreClaims;
|
|
92
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI7D;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,iBAAiB;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,qBAAqB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAmDD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAyBlE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Schema Normalization
|
|
4
|
+
*
|
|
5
|
+
* Functions to normalize receipt claims to a canonical form for comparison.
|
|
6
|
+
* Produces byte-identical JCS output regardless of how the receipt was created.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.toCoreClaims = toCoreClaims;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a payment evidence object.
|
|
12
|
+
*
|
|
13
|
+
* Extracts only the semantic fields, omitting rail-specific evidence
|
|
14
|
+
* and optional fields that are undefined.
|
|
15
|
+
*/
|
|
16
|
+
function normalizePayment(payment) {
|
|
17
|
+
const result = {
|
|
18
|
+
rail: payment.rail,
|
|
19
|
+
reference: payment.reference,
|
|
20
|
+
amount: payment.amount,
|
|
21
|
+
currency: payment.currency,
|
|
22
|
+
asset: payment.asset,
|
|
23
|
+
env: payment.env,
|
|
24
|
+
};
|
|
25
|
+
// Only include optional fields if defined
|
|
26
|
+
if (payment.network !== undefined) {
|
|
27
|
+
result.network = payment.network;
|
|
28
|
+
}
|
|
29
|
+
if (payment.aggregator !== undefined) {
|
|
30
|
+
result.aggregator = payment.aggregator;
|
|
31
|
+
}
|
|
32
|
+
if (payment.routing !== undefined) {
|
|
33
|
+
result.routing = payment.routing;
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Normalize a control step.
|
|
39
|
+
*/
|
|
40
|
+
function normalizeControlStep(step) {
|
|
41
|
+
return {
|
|
42
|
+
engine: step.engine,
|
|
43
|
+
result: step.result,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Normalize a control block.
|
|
48
|
+
*/
|
|
49
|
+
function normalizeControl(control) {
|
|
50
|
+
return {
|
|
51
|
+
chain: control.chain.map(normalizeControlStep),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Extract core claims from a receipt for comparison.
|
|
56
|
+
*
|
|
57
|
+
* This function produces a normalized object that can be JCS-canonicalized
|
|
58
|
+
* to produce byte-identical output regardless of how the receipt was created
|
|
59
|
+
* (via x402, TAP, RSL, ACP, or direct issuance).
|
|
60
|
+
*
|
|
61
|
+
* The output:
|
|
62
|
+
* - Contains only semantically meaningful fields
|
|
63
|
+
* - Omits undefined optional fields (not null, not empty string)
|
|
64
|
+
* - Uses consistent field ordering (JCS handles this)
|
|
65
|
+
* - Strips rail-specific evidence details
|
|
66
|
+
*
|
|
67
|
+
* @param claims - Receipt claims to normalize
|
|
68
|
+
* @returns Normalized core claims
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { toCoreClaims } from '@peac/schema';
|
|
73
|
+
* import { canonicalize } from '@peac/crypto';
|
|
74
|
+
*
|
|
75
|
+
* const core = toCoreClaims(receiptClaims);
|
|
76
|
+
* const canonical = canonicalize(core);
|
|
77
|
+
* // canonical is byte-identical regardless of source
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
function toCoreClaims(claims) {
|
|
81
|
+
const result = {
|
|
82
|
+
iss: claims.iss,
|
|
83
|
+
aud: claims.aud,
|
|
84
|
+
rid: claims.rid,
|
|
85
|
+
iat: claims.iat,
|
|
86
|
+
amt: claims.amt,
|
|
87
|
+
cur: claims.cur,
|
|
88
|
+
payment: normalizePayment(claims.payment),
|
|
89
|
+
};
|
|
90
|
+
// Only include optional fields if defined
|
|
91
|
+
if (claims.exp !== undefined) {
|
|
92
|
+
result.exp = claims.exp;
|
|
93
|
+
}
|
|
94
|
+
if (claims.subject !== undefined) {
|
|
95
|
+
result.subject = { uri: claims.subject.uri };
|
|
96
|
+
}
|
|
97
|
+
if (claims.ext?.control !== undefined) {
|
|
98
|
+
result.control = normalizeControl(claims.ext.control);
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA8IH,oCAyBC;AApGD;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAwB;IAChD,MAAM,MAAM,GAAsB;QAChC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC;IAEF,0CAA0C;IAC1C,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACzC,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAiB;IAC7C,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,OAAqB;IAC7C,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;KAC/C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,YAAY,CAAC,MAAyB;IACpD,MAAM,MAAM,GAAe;QACzB,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC;KAC1C,CAAC;IAEF,0CAA0C;IAC1C,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/C,CAAC;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,WAAe,CAAC;AACzC,eAAO,MAAM,cAAc,WAAe,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SCHEMA_VERSION = exports.PEAC_VERSION = void 0;
|
|
4
|
+
const version_1 = require("./version");
|
|
5
|
+
exports.PEAC_VERSION = version_1.WIRE_VERSION;
|
|
6
|
+
exports.SCHEMA_VERSION = version_1.WIRE_VERSION;
|
|
7
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAE5B,QAAA,YAAY,GAAG,sBAAY,CAAC;AAC5B,QAAA,cAAc,GAAG,sBAAY,CAAC"}
|