@envarai/envarpay 0.1.0-alpha.3 → 0.2.0-alpha.2

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 (60) hide show
  1. package/README.md +56 -146
  2. package/dist/commerce/buyer-store.d.ts +101 -0
  3. package/dist/commerce/buyer-store.js +168 -0
  4. package/dist/commerce/buyer.d.ts +132 -0
  5. package/dist/commerce/buyer.js +755 -0
  6. package/dist/commerce/card.d.ts +5 -0
  7. package/dist/commerce/card.js +29 -0
  8. package/dist/commerce/chain.d.ts +24 -0
  9. package/dist/commerce/chain.js +146 -0
  10. package/dist/commerce/cli.d.ts +2 -0
  11. package/dist/commerce/cli.js +274 -0
  12. package/dist/commerce/client-runtime.d.ts +8 -0
  13. package/dist/commerce/client-runtime.js +7 -0
  14. package/dist/commerce/config.d.ts +7 -0
  15. package/dist/commerce/config.js +182 -0
  16. package/dist/commerce/envar-runtime.d.ts +46 -0
  17. package/dist/commerce/envar-runtime.js +256 -0
  18. package/dist/commerce/envar.d.ts +126 -0
  19. package/dist/commerce/envar.js +647 -0
  20. package/dist/commerce/http.d.ts +2 -0
  21. package/dist/commerce/http.js +34 -0
  22. package/dist/commerce/index.d.ts +4 -0
  23. package/dist/commerce/index.js +4 -0
  24. package/dist/commerce/management.d.ts +14 -0
  25. package/dist/commerce/management.js +138 -0
  26. package/dist/commerce/mpp-client.d.ts +59 -0
  27. package/dist/commerce/mpp-client.js +24 -0
  28. package/dist/commerce/mpp-runtime.d.ts +3 -0
  29. package/dist/commerce/mpp-runtime.js +3 -0
  30. package/dist/commerce/mpp.d.ts +53 -0
  31. package/dist/commerce/mpp.js +163 -0
  32. package/dist/commerce/operations.d.ts +16 -0
  33. package/dist/commerce/operations.js +33 -0
  34. package/dist/commerce/peer-proxy.d.ts +44 -0
  35. package/dist/commerce/peer-proxy.js +673 -0
  36. package/dist/commerce/pricing.d.ts +12 -0
  37. package/dist/commerce/pricing.js +60 -0
  38. package/dist/commerce/runtime.d.ts +8 -0
  39. package/dist/commerce/runtime.js +8 -0
  40. package/dist/commerce/server.d.ts +59 -0
  41. package/dist/commerce/server.js +499 -0
  42. package/dist/commerce/store.d.ts +88 -0
  43. package/dist/commerce/store.js +473 -0
  44. package/dist/commerce/stripe-provider.d.ts +9 -0
  45. package/dist/commerce/stripe-provider.js +97 -0
  46. package/dist/commerce/types.d.ts +134 -0
  47. package/dist/commerce/types.js +8 -0
  48. package/dist/commerce/upstream.d.ts +6 -0
  49. package/dist/commerce/upstream.js +103 -0
  50. package/dist/commerce/vault.d.ts +8 -0
  51. package/dist/commerce/vault.js +55 -0
  52. package/dist/commerce/x402.d.ts +37 -0
  53. package/dist/commerce/x402.js +174 -0
  54. package/examples/buyer-policy.json +18 -0
  55. package/examples/envar-integration-policy.json +18 -0
  56. package/examples/seller.json +52 -0
  57. package/package.json +75 -10
  58. package/schemas/buyer-policy.schema.json +253 -0
  59. package/schemas/envarpay.config.schema.json +376 -0
  60. package/schemas/quote.schema.json +91 -0
@@ -0,0 +1,376 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:envarpay:config:1",
4
+ "title": "EnvarPay A2A commerce MVP configuration",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "configVersion",
9
+ "agent",
10
+ "paymentProfiles",
11
+ "services"
12
+ ],
13
+ "properties": {
14
+ "configVersion": {
15
+ "const": 1
16
+ },
17
+ "agent": {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": [
21
+ "id",
22
+ "name"
23
+ ],
24
+ "properties": {
25
+ "id": {
26
+ "$ref": "#/$defs/id"
27
+ },
28
+ "name": {
29
+ "type": "string",
30
+ "minLength": 1,
31
+ "maxLength": 120
32
+ }
33
+ }
34
+ },
35
+ "paymentProfiles": {
36
+ "type": "object",
37
+ "maxProperties": 16,
38
+ "propertyNames": {
39
+ "$ref": "#/$defs/id"
40
+ },
41
+ "additionalProperties": {
42
+ "oneOf": [
43
+ {
44
+ "$ref": "#/$defs/x402"
45
+ },
46
+ {
47
+ "$ref": "#/$defs/mpp"
48
+ }
49
+ ]
50
+ }
51
+ },
52
+ "services": {
53
+ "type": "array",
54
+ "minItems": 1,
55
+ "maxItems": 64,
56
+ "items": {
57
+ "$ref": "#/$defs/service"
58
+ }
59
+ }
60
+ },
61
+ "$defs": {
62
+ "id": {
63
+ "type": "string",
64
+ "pattern": "^[a-z][a-z0-9-]{0,63}$"
65
+ },
66
+ "amount": {
67
+ "type": "string",
68
+ "pattern": "^[1-9][0-9]{0,77}$"
69
+ },
70
+ "address": {
71
+ "type": "string",
72
+ "pattern": "^0x[0-9a-fA-F]{40}$"
73
+ },
74
+ "httpUrl": {
75
+ "type": "string",
76
+ "format": "uri",
77
+ "pattern": "^https?://",
78
+ "maxLength": 2048
79
+ },
80
+ "x402": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": [
84
+ "adapter",
85
+ "scheme",
86
+ "network",
87
+ "asset",
88
+ "payTo",
89
+ "facilitatorUrl"
90
+ ],
91
+ "properties": {
92
+ "adapter": {
93
+ "const": "x402"
94
+ },
95
+ "scheme": {
96
+ "const": "exact"
97
+ },
98
+ "network": {
99
+ "type": "string",
100
+ "pattern": "^eip155:[1-9][0-9]*$"
101
+ },
102
+ "asset": {
103
+ "$ref": "#/$defs/address"
104
+ },
105
+ "payTo": {
106
+ "$ref": "#/$defs/address"
107
+ },
108
+ "facilitatorUrl": {
109
+ "type": "string",
110
+ "format": "uri",
111
+ "pattern": "^https://"
112
+ }
113
+ }
114
+ },
115
+ "mpp": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "required": [
119
+ "adapter",
120
+ "method",
121
+ "intent",
122
+ "currency",
123
+ "accountRef"
124
+ ],
125
+ "properties": {
126
+ "adapter": {
127
+ "const": "mpp"
128
+ },
129
+ "method": {
130
+ "const": "stripe"
131
+ },
132
+ "intent": {
133
+ "const": "charge"
134
+ },
135
+ "currency": {
136
+ "const": "usd"
137
+ },
138
+ "accountRef": {
139
+ "$ref": "#/$defs/id"
140
+ }
141
+ }
142
+ },
143
+ "service": {
144
+ "type": "object",
145
+ "additionalProperties": false,
146
+ "required": [
147
+ "id",
148
+ "name",
149
+ "revision",
150
+ "execution",
151
+ "contract",
152
+ "offers"
153
+ ],
154
+ "properties": {
155
+ "id": {
156
+ "$ref": "#/$defs/id"
157
+ },
158
+ "name": {
159
+ "type": "string",
160
+ "minLength": 1
161
+ },
162
+ "revision": {
163
+ "type": "integer",
164
+ "minimum": 1,
165
+ "maximum": 2147483647
166
+ },
167
+ "execution": {
168
+ "type": "object",
169
+ "additionalProperties": false,
170
+ "required": [
171
+ "type",
172
+ "cardUrl"
173
+ ],
174
+ "properties": {
175
+ "type": {
176
+ "const": "a2a"
177
+ },
178
+ "cardUrl": {
179
+ "$ref": "#/$defs/httpUrl"
180
+ }
181
+ }
182
+ },
183
+ "contract": {
184
+ "type": "object",
185
+ "additionalProperties": false,
186
+ "required": [
187
+ "inputSchema",
188
+ "deliverables",
189
+ "targetDurationSeconds",
190
+ "includedRevisions"
191
+ ],
192
+ "properties": {
193
+ "inputSchema": {
194
+ "type": "object"
195
+ },
196
+ "deliverables": {
197
+ "type": "array",
198
+ "minItems": 1,
199
+ "uniqueItems": true,
200
+ "items": {
201
+ "type": "string",
202
+ "minLength": 1
203
+ }
204
+ },
205
+ "targetDurationSeconds": {
206
+ "type": "integer",
207
+ "minimum": 1,
208
+ "maximum": 86400
209
+ },
210
+ "includedRevisions": {
211
+ "const": 0
212
+ }
213
+ }
214
+ },
215
+ "offers": {
216
+ "type": "array",
217
+ "minItems": 1,
218
+ "maxItems": 16,
219
+ "items": {
220
+ "$ref": "#/$defs/offer"
221
+ }
222
+ }
223
+ }
224
+ },
225
+ "free": {
226
+ "type": "object",
227
+ "additionalProperties": false,
228
+ "required": [
229
+ "kind"
230
+ ],
231
+ "properties": {
232
+ "kind": {
233
+ "const": "free"
234
+ }
235
+ }
236
+ },
237
+ "fixed": {
238
+ "type": "object",
239
+ "additionalProperties": false,
240
+ "required": [
241
+ "kind",
242
+ "amount"
243
+ ],
244
+ "properties": {
245
+ "kind": {
246
+ "const": "fixed"
247
+ },
248
+ "amount": {
249
+ "$ref": "#/$defs/amount"
250
+ }
251
+ }
252
+ },
253
+ "quantity": {
254
+ "type": "object",
255
+ "additionalProperties": false,
256
+ "required": [
257
+ "kind",
258
+ "unit",
259
+ "unitAmount",
260
+ "quantity"
261
+ ],
262
+ "properties": {
263
+ "kind": {
264
+ "const": "quantity"
265
+ },
266
+ "unit": {
267
+ "$ref": "#/$defs/id"
268
+ },
269
+ "unitAmount": {
270
+ "$ref": "#/$defs/amount"
271
+ },
272
+ "quantity": {
273
+ "type": "object",
274
+ "additionalProperties": false,
275
+ "required": [
276
+ "pointer",
277
+ "measure",
278
+ "min",
279
+ "max"
280
+ ],
281
+ "properties": {
282
+ "pointer": {
283
+ "type": "string",
284
+ "pattern": "^(/([^~/]|~[01])*)+$"
285
+ },
286
+ "measure": {
287
+ "const": "count"
288
+ },
289
+ "min": {
290
+ "type": "integer",
291
+ "minimum": 1
292
+ },
293
+ "max": {
294
+ "type": "integer",
295
+ "minimum": 1,
296
+ "maximum": 10000
297
+ }
298
+ }
299
+ }
300
+ }
301
+ },
302
+ "offer": {
303
+ "oneOf": [
304
+ {
305
+ "type": "object",
306
+ "additionalProperties": false,
307
+ "required": [
308
+ "id",
309
+ "pricing",
310
+ "collection"
311
+ ],
312
+ "properties": {
313
+ "id": {
314
+ "$ref": "#/$defs/id"
315
+ },
316
+ "pricing": {
317
+ "$ref": "#/$defs/free"
318
+ },
319
+ "collection": {
320
+ "type": "object",
321
+ "additionalProperties": false,
322
+ "required": [
323
+ "kind"
324
+ ],
325
+ "properties": {
326
+ "kind": {
327
+ "const": "none"
328
+ }
329
+ }
330
+ }
331
+ }
332
+ },
333
+ {
334
+ "type": "object",
335
+ "additionalProperties": false,
336
+ "required": [
337
+ "id",
338
+ "pricing",
339
+ "collection",
340
+ "paymentProfile"
341
+ ],
342
+ "properties": {
343
+ "id": {
344
+ "$ref": "#/$defs/id"
345
+ },
346
+ "pricing": {
347
+ "oneOf": [
348
+ {
349
+ "$ref": "#/$defs/fixed"
350
+ },
351
+ {
352
+ "$ref": "#/$defs/quantity"
353
+ }
354
+ ]
355
+ },
356
+ "collection": {
357
+ "type": "object",
358
+ "additionalProperties": false,
359
+ "required": [
360
+ "kind"
361
+ ],
362
+ "properties": {
363
+ "kind": {
364
+ "const": "upfront"
365
+ }
366
+ }
367
+ },
368
+ "paymentProfile": {
369
+ "$ref": "#/$defs/id"
370
+ }
371
+ }
372
+ }
373
+ ]
374
+ }
375
+ }
376
+ }
@@ -0,0 +1,91 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:envarpay:price-quote:1",
4
+ "title": "Immutable price quote before payment challenge construction",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "quoteVersion",
9
+ "quoteId",
10
+ "caller",
11
+ "serviceId",
12
+ "serviceRevision",
13
+ "offerId",
14
+ "messageId",
15
+ "inputDigest",
16
+ "termsDigest",
17
+ "issuedAt",
18
+ "expiresAt",
19
+ "amount",
20
+ "currency",
21
+ "recipient",
22
+ "paymentProfile"
23
+ ],
24
+ "properties": {
25
+ "quoteVersion": {
26
+ "const": 1
27
+ },
28
+ "quoteId": {
29
+ "type": "string",
30
+ "format": "uuid"
31
+ },
32
+ "caller": {
33
+ "type": "string",
34
+ "minLength": 1
35
+ },
36
+ "serviceId": {
37
+ "type": "string",
38
+ "minLength": 1
39
+ },
40
+ "serviceRevision": {
41
+ "type": "integer",
42
+ "minimum": 1
43
+ },
44
+ "offerId": {
45
+ "type": "string",
46
+ "minLength": 1
47
+ },
48
+ "messageId": {
49
+ "type": "string",
50
+ "minLength": 1
51
+ },
52
+ "inputDigest": {
53
+ "type": "string",
54
+ "pattern": "^[0-9a-f]{64}$"
55
+ },
56
+ "termsDigest": {
57
+ "type": "string",
58
+ "pattern": "^[0-9a-f]{64}$"
59
+ },
60
+ "issuedAt": {
61
+ "type": "string",
62
+ "format": "date-time"
63
+ },
64
+ "expiresAt": {
65
+ "type": "string",
66
+ "format": "date-time"
67
+ },
68
+ "amount": {
69
+ "type": "string",
70
+ "pattern": "^(0|[1-9][0-9]{0,77})$"
71
+ },
72
+ "currency": {
73
+ "type": [
74
+ "string",
75
+ "null"
76
+ ]
77
+ },
78
+ "recipient": {
79
+ "type": [
80
+ "string",
81
+ "null"
82
+ ]
83
+ },
84
+ "paymentProfile": {
85
+ "type": [
86
+ "object",
87
+ "null"
88
+ ]
89
+ }
90
+ }
91
+ }