@perkos/schema-validation 1.0.0

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,361 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * @perkos/validators/payment
5
+ * Payment and x402 protocol validators using Zod
6
+ */
7
+
8
+ declare const networkSchema: z.ZodEnum<["avalanche", "base", "celo", "avalanche-fuji", "base-sepolia", "celo-alfajores"]>;
9
+ declare const caip2NetworkSchema: z.ZodString;
10
+ declare const ethereumAddressSchema: z.ZodString;
11
+ declare const transactionHashSchema: z.ZodString;
12
+ declare const signatureSchema: z.ZodString;
13
+ declare const paymentEnvelopeSchema: z.ZodObject<{
14
+ payload: z.ZodObject<{
15
+ from: z.ZodString;
16
+ to: z.ZodString;
17
+ value: z.ZodString;
18
+ validAfter: z.ZodNumber;
19
+ validBefore: z.ZodNumber;
20
+ nonce: z.ZodString;
21
+ network: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ value: string;
24
+ from: string;
25
+ to: string;
26
+ validAfter: number;
27
+ validBefore: number;
28
+ nonce: string;
29
+ network: string;
30
+ }, {
31
+ value: string;
32
+ from: string;
33
+ to: string;
34
+ validAfter: number;
35
+ validBefore: number;
36
+ nonce: string;
37
+ network: string;
38
+ }>;
39
+ signature: z.ZodString;
40
+ }, "strip", z.ZodTypeAny, {
41
+ payload: {
42
+ value: string;
43
+ from: string;
44
+ to: string;
45
+ validAfter: number;
46
+ validBefore: number;
47
+ nonce: string;
48
+ network: string;
49
+ };
50
+ signature: string;
51
+ }, {
52
+ payload: {
53
+ value: string;
54
+ from: string;
55
+ to: string;
56
+ validAfter: number;
57
+ validBefore: number;
58
+ nonce: string;
59
+ network: string;
60
+ };
61
+ signature: string;
62
+ }>;
63
+ declare const paymentHeaderSchema: z.ZodString;
64
+ declare const priceSchema: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
65
+ declare const paymentConfigSchema: z.ZodObject<{
66
+ recipientAddress: z.ZodString;
67
+ network: z.ZodEnum<["avalanche", "base", "celo", "avalanche-fuji", "base-sepolia", "celo-alfajores"]>;
68
+ tokenAddress: z.ZodOptional<z.ZodString>;
69
+ prices: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
70
+ }, "strip", z.ZodTypeAny, {
71
+ network: "avalanche" | "base" | "celo" | "avalanche-fuji" | "base-sepolia" | "celo-alfajores";
72
+ recipientAddress: string;
73
+ prices: Record<string, string | number>;
74
+ tokenAddress?: string | undefined;
75
+ }, {
76
+ network: "avalanche" | "base" | "celo" | "avalanche-fuji" | "base-sepolia" | "celo-alfajores";
77
+ recipientAddress: string;
78
+ prices: Record<string, string | number>;
79
+ tokenAddress?: string | undefined;
80
+ }>;
81
+ declare const routeConfigSchema: z.ZodObject<{
82
+ path: z.ZodString;
83
+ price: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
84
+ description: z.ZodOptional<z.ZodString>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ path: string;
87
+ price: string | number;
88
+ description?: string | undefined;
89
+ }, {
90
+ path: string;
91
+ price: string | number;
92
+ description?: string | undefined;
93
+ }>;
94
+ declare const paymentRequestSchema: z.ZodObject<{
95
+ amount: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
96
+ recipient: z.ZodString;
97
+ network: z.ZodEnum<["avalanche", "base", "celo", "avalanche-fuji", "base-sepolia", "celo-alfajores"]>;
98
+ memo: z.ZodOptional<z.ZodString>;
99
+ expiresAt: z.ZodOptional<z.ZodNumber>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ network: "avalanche" | "base" | "celo" | "avalanche-fuji" | "base-sepolia" | "celo-alfajores";
102
+ amount: string | number;
103
+ recipient: string;
104
+ memo?: string | undefined;
105
+ expiresAt?: number | undefined;
106
+ }, {
107
+ network: "avalanche" | "base" | "celo" | "avalanche-fuji" | "base-sepolia" | "celo-alfajores";
108
+ amount: string | number;
109
+ recipient: string;
110
+ memo?: string | undefined;
111
+ expiresAt?: number | undefined;
112
+ }>;
113
+ declare const paymentVerificationSchema: z.ZodObject<{
114
+ envelope: z.ZodObject<{
115
+ payload: z.ZodObject<{
116
+ from: z.ZodString;
117
+ to: z.ZodString;
118
+ value: z.ZodString;
119
+ validAfter: z.ZodNumber;
120
+ validBefore: z.ZodNumber;
121
+ nonce: z.ZodString;
122
+ network: z.ZodString;
123
+ }, "strip", z.ZodTypeAny, {
124
+ value: string;
125
+ from: string;
126
+ to: string;
127
+ validAfter: number;
128
+ validBefore: number;
129
+ nonce: string;
130
+ network: string;
131
+ }, {
132
+ value: string;
133
+ from: string;
134
+ to: string;
135
+ validAfter: number;
136
+ validBefore: number;
137
+ nonce: string;
138
+ network: string;
139
+ }>;
140
+ signature: z.ZodString;
141
+ }, "strip", z.ZodTypeAny, {
142
+ payload: {
143
+ value: string;
144
+ from: string;
145
+ to: string;
146
+ validAfter: number;
147
+ validBefore: number;
148
+ nonce: string;
149
+ network: string;
150
+ };
151
+ signature: string;
152
+ }, {
153
+ payload: {
154
+ value: string;
155
+ from: string;
156
+ to: string;
157
+ validAfter: number;
158
+ validBefore: number;
159
+ nonce: string;
160
+ network: string;
161
+ };
162
+ signature: string;
163
+ }>;
164
+ expectedAmount: z.ZodString;
165
+ expectedRecipient: z.ZodString;
166
+ tolerance: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ envelope: {
169
+ payload: {
170
+ value: string;
171
+ from: string;
172
+ to: string;
173
+ validAfter: number;
174
+ validBefore: number;
175
+ nonce: string;
176
+ network: string;
177
+ };
178
+ signature: string;
179
+ };
180
+ expectedAmount: string;
181
+ expectedRecipient: string;
182
+ tolerance: number;
183
+ }, {
184
+ envelope: {
185
+ payload: {
186
+ value: string;
187
+ from: string;
188
+ to: string;
189
+ validAfter: number;
190
+ validBefore: number;
191
+ nonce: string;
192
+ network: string;
193
+ };
194
+ signature: string;
195
+ };
196
+ expectedAmount: string;
197
+ expectedRecipient: string;
198
+ tolerance?: number | undefined;
199
+ }>;
200
+ declare const tokenInfoSchema: z.ZodObject<{
201
+ address: z.ZodString;
202
+ name: z.ZodString;
203
+ symbol: z.ZodString;
204
+ decimals: z.ZodNumber;
205
+ chainId: z.ZodNumber;
206
+ }, "strip", z.ZodTypeAny, {
207
+ symbol: string;
208
+ address: string;
209
+ name: string;
210
+ decimals: number;
211
+ chainId: number;
212
+ }, {
213
+ symbol: string;
214
+ address: string;
215
+ name: string;
216
+ decimals: number;
217
+ chainId: number;
218
+ }>;
219
+ declare const eip712DomainSchema: z.ZodObject<{
220
+ name: z.ZodString;
221
+ version: z.ZodString;
222
+ chainId: z.ZodNumber;
223
+ verifyingContract: z.ZodString;
224
+ }, "strip", z.ZodTypeAny, {
225
+ name: string;
226
+ chainId: number;
227
+ version: string;
228
+ verifyingContract: string;
229
+ }, {
230
+ name: string;
231
+ chainId: number;
232
+ version: string;
233
+ verifyingContract: string;
234
+ }>;
235
+ declare const settlementRequestSchema: z.ZodObject<{
236
+ envelope: z.ZodObject<{
237
+ payload: z.ZodObject<{
238
+ from: z.ZodString;
239
+ to: z.ZodString;
240
+ value: z.ZodString;
241
+ validAfter: z.ZodNumber;
242
+ validBefore: z.ZodNumber;
243
+ nonce: z.ZodString;
244
+ network: z.ZodString;
245
+ }, "strip", z.ZodTypeAny, {
246
+ value: string;
247
+ from: string;
248
+ to: string;
249
+ validAfter: number;
250
+ validBefore: number;
251
+ nonce: string;
252
+ network: string;
253
+ }, {
254
+ value: string;
255
+ from: string;
256
+ to: string;
257
+ validAfter: number;
258
+ validBefore: number;
259
+ nonce: string;
260
+ network: string;
261
+ }>;
262
+ signature: z.ZodString;
263
+ }, "strip", z.ZodTypeAny, {
264
+ payload: {
265
+ value: string;
266
+ from: string;
267
+ to: string;
268
+ validAfter: number;
269
+ validBefore: number;
270
+ nonce: string;
271
+ network: string;
272
+ };
273
+ signature: string;
274
+ }, {
275
+ payload: {
276
+ value: string;
277
+ from: string;
278
+ to: string;
279
+ validAfter: number;
280
+ validBefore: number;
281
+ nonce: string;
282
+ network: string;
283
+ };
284
+ signature: string;
285
+ }>;
286
+ privateKey: z.ZodOptional<z.ZodString>;
287
+ }, "strip", z.ZodTypeAny, {
288
+ envelope: {
289
+ payload: {
290
+ value: string;
291
+ from: string;
292
+ to: string;
293
+ validAfter: number;
294
+ validBefore: number;
295
+ nonce: string;
296
+ network: string;
297
+ };
298
+ signature: string;
299
+ };
300
+ privateKey?: string | undefined;
301
+ }, {
302
+ envelope: {
303
+ payload: {
304
+ value: string;
305
+ from: string;
306
+ to: string;
307
+ validAfter: number;
308
+ validBefore: number;
309
+ nonce: string;
310
+ network: string;
311
+ };
312
+ signature: string;
313
+ };
314
+ privateKey?: string | undefined;
315
+ }>;
316
+ declare const settlementResultSchema: z.ZodObject<{
317
+ success: z.ZodBoolean;
318
+ transactionHash: z.ZodOptional<z.ZodString>;
319
+ error: z.ZodOptional<z.ZodString>;
320
+ gasUsed: z.ZodOptional<z.ZodString>;
321
+ }, "strip", z.ZodTypeAny, {
322
+ success: boolean;
323
+ error?: string | undefined;
324
+ transactionHash?: string | undefined;
325
+ gasUsed?: string | undefined;
326
+ }, {
327
+ success: boolean;
328
+ error?: string | undefined;
329
+ transactionHash?: string | undefined;
330
+ gasUsed?: string | undefined;
331
+ }>;
332
+ declare const paymentErrorSchema: z.ZodObject<{
333
+ error: z.ZodString;
334
+ code: z.ZodEnum<["MISSING_PAYMENT", "INVALID_SIGNATURE", "INVALID_AMOUNT", "EXPIRED_PAYMENT", "INSUFFICIENT_BALANCE", "SETTLEMENT_FAILED", "NETWORK_MISMATCH"]>;
335
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
336
+ }, "strip", z.ZodTypeAny, {
337
+ code: "MISSING_PAYMENT" | "INVALID_SIGNATURE" | "INVALID_AMOUNT" | "EXPIRED_PAYMENT" | "INSUFFICIENT_BALANCE" | "SETTLEMENT_FAILED" | "NETWORK_MISMATCH";
338
+ error: string;
339
+ details?: Record<string, unknown> | undefined;
340
+ }, {
341
+ code: "MISSING_PAYMENT" | "INVALID_SIGNATURE" | "INVALID_AMOUNT" | "EXPIRED_PAYMENT" | "INSUFFICIENT_BALANCE" | "SETTLEMENT_FAILED" | "NETWORK_MISMATCH";
342
+ error: string;
343
+ details?: Record<string, unknown> | undefined;
344
+ }>;
345
+ type Network = z.infer<typeof networkSchema>;
346
+ type CAIP2Network = z.infer<typeof caip2NetworkSchema>;
347
+ type EthereumAddress = z.infer<typeof ethereumAddressSchema>;
348
+ type TransactionHash = z.infer<typeof transactionHashSchema>;
349
+ type Signature = z.infer<typeof signatureSchema>;
350
+ type PaymentEnvelope = z.infer<typeof paymentEnvelopeSchema>;
351
+ type PaymentConfig = z.infer<typeof paymentConfigSchema>;
352
+ type RouteConfig = z.infer<typeof routeConfigSchema>;
353
+ type PaymentRequest = z.infer<typeof paymentRequestSchema>;
354
+ type PaymentVerification = z.infer<typeof paymentVerificationSchema>;
355
+ type TokenInfo = z.infer<typeof tokenInfoSchema>;
356
+ type EIP712Domain = z.infer<typeof eip712DomainSchema>;
357
+ type SettlementRequest = z.infer<typeof settlementRequestSchema>;
358
+ type SettlementResult = z.infer<typeof settlementResultSchema>;
359
+ type PaymentError = z.infer<typeof paymentErrorSchema>;
360
+
361
+ export { type CAIP2Network, type EIP712Domain, type EthereumAddress, type Network, type PaymentConfig, type PaymentEnvelope, type PaymentError, type PaymentRequest, type PaymentVerification, type RouteConfig, type SettlementRequest, type SettlementResult, type Signature, type TokenInfo, type TransactionHash, caip2NetworkSchema, eip712DomainSchema, ethereumAddressSchema, networkSchema, paymentConfigSchema, paymentEnvelopeSchema, paymentErrorSchema, paymentHeaderSchema, paymentRequestSchema, paymentVerificationSchema, priceSchema, routeConfigSchema, settlementRequestSchema, settlementResultSchema, signatureSchema, tokenInfoSchema, transactionHashSchema };