@bosonprotocol/x402-core 0.1.0-alpha-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.
- package/LICENSE +201 -0
- package/README.md +26 -0
- package/dist/cjs/eip712/index.d.ts +142 -0
- package/dist/cjs/eip712/index.js +224 -0
- package/dist/cjs/eip712/index.js.map +1 -0
- package/dist/cjs/eip712/token-auth/index.d.ts +259 -0
- package/dist/cjs/eip712/token-auth/index.js +221 -0
- package/dist/cjs/eip712/token-auth/index.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/schemes/escrow/index.d.ts +1262 -0
- package/dist/cjs/schemes/escrow/index.js +228 -0
- package/dist/cjs/schemes/escrow/index.js.map +1 -0
- package/dist/cjs/state-machine/index.d.ts +86 -0
- package/dist/cjs/state-machine/index.js +146 -0
- package/dist/cjs/state-machine/index.js.map +1 -0
- package/dist/cjs/states-Q2FJASHh.d.ts +38 -0
- package/dist/esm/chunk-7IY3WEFZ.js +10 -0
- package/dist/esm/chunk-7IY3WEFZ.js.map +1 -0
- package/dist/esm/eip712/index.js +213 -0
- package/dist/esm/eip712/index.js.map +1 -0
- package/dist/esm/eip712/token-auth/index.js +189 -0
- package/dist/esm/eip712/token-auth/index.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/schemes/escrow/index.js +202 -0
- package/dist/esm/schemes/escrow/index.js.map +1 -0
- package/dist/esm/state-machine/index.js +127 -0
- package/dist/esm/state-machine/index.js.map +1 -0
- package/dist/schemas/next_actions.schema.json +87 -0
- package/dist/schemas/payment_payload.schema.json +156 -0
- package/dist/schemas/payment_requirements.schema.json +135 -0
- package/package.json +84 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://bosonprotocol.io/schemas/x402-core/payment_payload.schema.json",
|
|
4
|
+
"title": "x402B escrow PaymentPayload",
|
|
5
|
+
"description": "Wire-format PaymentPayload for the `escrow` scheme (carried base64-encoded in the `X-PAYMENT` header). Source: docs/boson-impl-01-escrow-scheme.md §3.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["x402Version", "scheme", "network", "payload"],
|
|
9
|
+
"definitions": {
|
|
10
|
+
"address": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
|
|
11
|
+
"hex": { "type": "string", "pattern": "^0x[a-fA-F0-9]+$" },
|
|
12
|
+
"hexBytes": { "type": "string", "pattern": "^0x[a-fA-F0-9]*$" },
|
|
13
|
+
"hex32": { "type": "string", "pattern": "^0x[a-fA-F0-9]{64}$" },
|
|
14
|
+
"decimalUint": { "type": "string", "pattern": "^(0|[1-9][0-9]*)$" },
|
|
15
|
+
"sig": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": false,
|
|
18
|
+
"required": ["v", "r", "s"],
|
|
19
|
+
"properties": {
|
|
20
|
+
"v": { "type": "integer" },
|
|
21
|
+
"r": { "$ref": "#/definitions/hex32" },
|
|
22
|
+
"s": { "$ref": "#/definitions/hex32" }
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"metaTx": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"additionalProperties": false,
|
|
28
|
+
"required": ["from", "nonce", "functionName", "functionSignature", "sig"],
|
|
29
|
+
"properties": {
|
|
30
|
+
"from": { "$ref": "#/definitions/address" },
|
|
31
|
+
"nonce": { "$ref": "#/definitions/decimalUint" },
|
|
32
|
+
"functionName": { "type": "string", "minLength": 1 },
|
|
33
|
+
"functionSignature": { "$ref": "#/definitions/hexBytes" },
|
|
34
|
+
"sig": { "$ref": "#/definitions/sig" }
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"erc3009Auth": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"additionalProperties": false,
|
|
40
|
+
"required": ["kind", "data"],
|
|
41
|
+
"properties": {
|
|
42
|
+
"kind": { "const": "erc3009" },
|
|
43
|
+
"data": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"required": ["from", "to", "value", "validAfter", "validBefore", "nonce", "v", "r", "s"],
|
|
47
|
+
"properties": {
|
|
48
|
+
"from": { "$ref": "#/definitions/address" },
|
|
49
|
+
"to": { "$ref": "#/definitions/address" },
|
|
50
|
+
"value": { "$ref": "#/definitions/decimalUint" },
|
|
51
|
+
"validAfter": { "type": "integer", "minimum": 0 },
|
|
52
|
+
"validBefore": { "type": "integer", "minimum": 0 },
|
|
53
|
+
"nonce": { "$ref": "#/definitions/hex32" },
|
|
54
|
+
"v": { "type": "integer" },
|
|
55
|
+
"r": { "$ref": "#/definitions/hex32" },
|
|
56
|
+
"s": { "$ref": "#/definitions/hex32" }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"permitAuth": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"required": ["kind", "data"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"kind": { "const": "permit" },
|
|
67
|
+
"data": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"additionalProperties": false,
|
|
70
|
+
"required": ["owner", "spender", "value", "deadline", "nonce", "v", "r", "s"],
|
|
71
|
+
"properties": {
|
|
72
|
+
"owner": { "$ref": "#/definitions/address" },
|
|
73
|
+
"spender": { "$ref": "#/definitions/address" },
|
|
74
|
+
"value": { "$ref": "#/definitions/decimalUint" },
|
|
75
|
+
"deadline": { "type": "integer", "minimum": 0 },
|
|
76
|
+
"nonce": { "$ref": "#/definitions/decimalUint" },
|
|
77
|
+
"v": { "type": "integer" },
|
|
78
|
+
"r": { "$ref": "#/definitions/hex32" },
|
|
79
|
+
"s": { "$ref": "#/definitions/hex32" }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"permit2Auth": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"additionalProperties": false,
|
|
87
|
+
"required": ["kind", "data"],
|
|
88
|
+
"properties": {
|
|
89
|
+
"kind": { "const": "permit2" },
|
|
90
|
+
"data": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"additionalProperties": false,
|
|
93
|
+
"required": ["permitted", "spender", "nonce", "deadline", "signature"],
|
|
94
|
+
"properties": {
|
|
95
|
+
"permitted": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"additionalProperties": false,
|
|
98
|
+
"required": ["token", "amount"],
|
|
99
|
+
"properties": {
|
|
100
|
+
"token": { "$ref": "#/definitions/address" },
|
|
101
|
+
"amount": { "$ref": "#/definitions/decimalUint" }
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"spender": { "$ref": "#/definitions/address" },
|
|
105
|
+
"nonce": { "$ref": "#/definitions/decimalUint" },
|
|
106
|
+
"deadline": { "type": "integer", "minimum": 0 },
|
|
107
|
+
"signature": { "$ref": "#/definitions/hex" }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"properties": {
|
|
114
|
+
"x402Version": { "type": "integer" },
|
|
115
|
+
"scheme": { "const": "escrow" },
|
|
116
|
+
"network": { "type": "string", "pattern": "^eip155:[1-9][0-9]*$" },
|
|
117
|
+
"payload": {
|
|
118
|
+
"type": "object",
|
|
119
|
+
"additionalProperties": false,
|
|
120
|
+
"required": ["action", "tokenAuthStrategy", "offerRef", "buyer", "metaTx"],
|
|
121
|
+
"properties": {
|
|
122
|
+
"action": { "type": "string", "minLength": 1 },
|
|
123
|
+
"tokenAuthStrategy": { "enum": ["none", "erc3009", "permit", "permit2"] },
|
|
124
|
+
"offerRef": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"additionalProperties": false,
|
|
127
|
+
"required": ["fullOffer", "sellerSig"],
|
|
128
|
+
"properties": {
|
|
129
|
+
"fullOffer": { "type": "object" },
|
|
130
|
+
"sellerSig": { "$ref": "#/definitions/hex" }
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"buyer": { "$ref": "#/definitions/address" },
|
|
134
|
+
"metaTx": { "$ref": "#/definitions/metaTx" },
|
|
135
|
+
"tokenAuth": {
|
|
136
|
+
"oneOf": [
|
|
137
|
+
{ "$ref": "#/definitions/erc3009Auth" },
|
|
138
|
+
{ "$ref": "#/definitions/permitAuth" },
|
|
139
|
+
{ "$ref": "#/definitions/permit2Auth" }
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"fulfillment": {
|
|
145
|
+
"type": "object",
|
|
146
|
+
"additionalProperties": false,
|
|
147
|
+
"required": ["option"],
|
|
148
|
+
"properties": {
|
|
149
|
+
"option": { "type": "string", "minLength": 1 },
|
|
150
|
+
"data": {
|
|
151
|
+
"oneOf": [{ "type": "object" }, { "type": "null" }]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://bosonprotocol.io/schemas/x402-core/payment_requirements.schema.json",
|
|
4
|
+
"title": "x402B escrow PaymentRequirements",
|
|
5
|
+
"description": "Wire-format PaymentRequirements for the `escrow` scheme. Source: docs/boson-impl-01-escrow-scheme.md §2.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"scheme",
|
|
10
|
+
"network",
|
|
11
|
+
"asset",
|
|
12
|
+
"amount",
|
|
13
|
+
"escrowAddress",
|
|
14
|
+
"recipientId",
|
|
15
|
+
"maxTimeoutSeconds",
|
|
16
|
+
"offer",
|
|
17
|
+
"tokenAuthStrategies",
|
|
18
|
+
"actions"
|
|
19
|
+
],
|
|
20
|
+
"properties": {
|
|
21
|
+
"scheme": { "const": "escrow" },
|
|
22
|
+
"network": { "type": "string", "pattern": "^eip155:[1-9][0-9]*$" },
|
|
23
|
+
"asset": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
|
|
24
|
+
"amount": { "type": "string", "pattern": "^(0|[1-9][0-9]*)$" },
|
|
25
|
+
"escrowAddress": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
|
|
26
|
+
"recipientId": { "type": "string", "minLength": 1 },
|
|
27
|
+
"maxTimeoutSeconds": { "type": "integer", "minimum": 1 },
|
|
28
|
+
"offer": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": false,
|
|
31
|
+
"required": ["fullOffer", "sellerSig", "creator"],
|
|
32
|
+
"properties": {
|
|
33
|
+
"fullOffer": { "type": "object" },
|
|
34
|
+
"sellerSig": { "type": "string", "pattern": "^0x[a-fA-F0-9]+$" },
|
|
35
|
+
"creator": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"tokenAuthStrategies": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"minItems": 1,
|
|
41
|
+
"uniqueItems": true,
|
|
42
|
+
"items": { "enum": ["none", "erc3009", "permit", "permit2"] }
|
|
43
|
+
},
|
|
44
|
+
"fulfillment": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"additionalProperties": false,
|
|
47
|
+
"required": ["required", "options"],
|
|
48
|
+
"properties": {
|
|
49
|
+
"required": { "type": "boolean" },
|
|
50
|
+
"options": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"additionalProperties": false,
|
|
55
|
+
"required": ["id", "schema"],
|
|
56
|
+
"properties": {
|
|
57
|
+
"id": { "type": "string", "minLength": 1 },
|
|
58
|
+
"schema": {
|
|
59
|
+
"oneOf": [{ "type": "object" }, { "type": "null" }]
|
|
60
|
+
},
|
|
61
|
+
"metadata": {}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"actions": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"additionalProperties": false,
|
|
70
|
+
"required": ["next"],
|
|
71
|
+
"properties": {
|
|
72
|
+
"next": {
|
|
73
|
+
"type": "array",
|
|
74
|
+
"minItems": 1,
|
|
75
|
+
"items": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"additionalProperties": false,
|
|
78
|
+
"required": ["id", "channels"],
|
|
79
|
+
"properties": {
|
|
80
|
+
"id": { "type": "string", "minLength": 1 },
|
|
81
|
+
"channels": {
|
|
82
|
+
"type": "array",
|
|
83
|
+
"minItems": 1,
|
|
84
|
+
"uniqueItems": true,
|
|
85
|
+
"items": {
|
|
86
|
+
"enum": ["server", "facilitator", "onchain", "mcp", "xmtp"]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"endpoints": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"additionalProperties": { "type": "string" }
|
|
92
|
+
},
|
|
93
|
+
"deadline": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"format": "date-time"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"fallback": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"additionalProperties": false,
|
|
103
|
+
"properties": {
|
|
104
|
+
"xmtp": { "type": "string" },
|
|
105
|
+
"mcp": { "type": "string" },
|
|
106
|
+
"onchainHints": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"additionalProperties": false,
|
|
109
|
+
"required": ["escrow", "metaTxFacet", "metaTxEntrypoints", "actionFacets"],
|
|
110
|
+
"properties": {
|
|
111
|
+
"escrow": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
|
|
112
|
+
"metaTxFacet": { "type": "string", "minLength": 1 },
|
|
113
|
+
"metaTxEntrypoints": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"additionalProperties": false,
|
|
116
|
+
"required": ["none", "erc3009", "permit", "permit2"],
|
|
117
|
+
"properties": {
|
|
118
|
+
"none": { "type": "string", "minLength": 1 },
|
|
119
|
+
"erc3009": { "type": "string", "minLength": 1 },
|
|
120
|
+
"permit": { "type": "string", "minLength": 1 },
|
|
121
|
+
"permit2": { "type": "string", "minLength": 1 }
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"actionFacets": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"additionalProperties": { "type": "string" }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bosonprotocol/x402-core",
|
|
3
|
+
"version": "0.1.0-alpha-0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Boson Protocol escrow scheme for x402 — JSON schemas, TypeScript types, EIP-712 builders, and exchange state machine.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bosonprotocol/x402B.git",
|
|
9
|
+
"directory": "typescript/packages/core"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/bosonprotocol/x402B/tree/main/typescript/packages/core",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/bosonprotocol/x402B/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"x402",
|
|
17
|
+
"boson-protocol",
|
|
18
|
+
"escrow",
|
|
19
|
+
"eip-712",
|
|
20
|
+
"web3",
|
|
21
|
+
"payments"
|
|
22
|
+
],
|
|
23
|
+
"main": "./dist/cjs/index.js",
|
|
24
|
+
"module": "./dist/esm/index.js",
|
|
25
|
+
"types": "./dist/cjs/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/cjs/index.d.ts",
|
|
29
|
+
"import": "./dist/esm/index.js",
|
|
30
|
+
"require": "./dist/cjs/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./eip712": {
|
|
33
|
+
"types": "./dist/cjs/eip712/index.d.ts",
|
|
34
|
+
"import": "./dist/esm/eip712/index.js",
|
|
35
|
+
"require": "./dist/cjs/eip712/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./eip712/token-auth": {
|
|
38
|
+
"types": "./dist/cjs/eip712/token-auth/index.d.ts",
|
|
39
|
+
"import": "./dist/esm/eip712/token-auth/index.js",
|
|
40
|
+
"require": "./dist/cjs/eip712/token-auth/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./schemes/escrow": {
|
|
43
|
+
"types": "./dist/cjs/schemes/escrow/index.d.ts",
|
|
44
|
+
"import": "./dist/esm/schemes/escrow/index.js",
|
|
45
|
+
"require": "./dist/cjs/schemes/escrow/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./schemas/*": "./dist/schemas/*",
|
|
48
|
+
"./state-machine": {
|
|
49
|
+
"types": "./dist/cjs/state-machine/index.d.ts",
|
|
50
|
+
"import": "./dist/esm/state-machine/index.js",
|
|
51
|
+
"require": "./dist/cjs/state-machine/index.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"files": [
|
|
55
|
+
"dist",
|
|
56
|
+
"README.md",
|
|
57
|
+
"LICENSE"
|
|
58
|
+
],
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@bosonprotocol/common": "1.33.0-alpha.7",
|
|
64
|
+
"@bosonprotocol/core-sdk": "1.48.0-alpha.6",
|
|
65
|
+
"@x402/evm": "^2.11.0",
|
|
66
|
+
"lodash": "^4.18.1",
|
|
67
|
+
"viem": "^2.39.3",
|
|
68
|
+
"zod": "^3.24.2"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/node": "^20.17.10",
|
|
72
|
+
"ajv": "^8.17.1",
|
|
73
|
+
"ajv-formats": "^3.0.1",
|
|
74
|
+
"tsup": "^8.3.5",
|
|
75
|
+
"typescript": "^5.7.2",
|
|
76
|
+
"vitest": "^2.1.8"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"build": "tsup && node scripts/postbuild.mjs",
|
|
80
|
+
"test": "vitest run",
|
|
81
|
+
"lint": "eslint src test --max-warnings 0",
|
|
82
|
+
"clean": "rm -rf dist .turbo"
|
|
83
|
+
}
|
|
84
|
+
}
|