@dexterai/x402 4.0.0 → 4.1.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,385 @@
|
|
|
1
|
+
Pricing
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
###
|
|
5
|
+
|
|
6
|
+
Text tokens
|
|
7
|
+
|
|
8
|
+
Prices per 1M tokens.
|
|
9
|
+
|
|
10
|
+
Batch
|
|
11
|
+
|
|
12
|
+
|Model|Input|Cached input|Output|
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
|gpt-5.2|$0.875|$0.0875|$7.00|
|
|
15
|
+
|gpt-5.1|$0.625|$0.0625|$5.00|
|
|
16
|
+
|gpt-5|$0.625|$0.0625|$5.00|
|
|
17
|
+
|gpt-5-mini|$0.125|$0.0125|$1.00|
|
|
18
|
+
|gpt-5-nano|$0.025|$0.0025|$0.20|
|
|
19
|
+
|gpt-5.2-pro|$10.50|-|$84.00|
|
|
20
|
+
|gpt-5-pro|$7.50|-|$60.00|
|
|
21
|
+
|gpt-4.1|$1.00|-|$4.00|
|
|
22
|
+
|gpt-4.1-mini|$0.20|-|$0.80|
|
|
23
|
+
|gpt-4.1-nano|$0.05|-|$0.20|
|
|
24
|
+
|gpt-4o|$1.25|-|$5.00|
|
|
25
|
+
|gpt-4o-2024-05-13|$2.50|-|$7.50|
|
|
26
|
+
|gpt-4o-mini|$0.075|-|$0.30|
|
|
27
|
+
|o1|$7.50|-|$30.00|
|
|
28
|
+
|o1-pro|$75.00|-|$300.00|
|
|
29
|
+
|o3-pro|$10.00|-|$40.00|
|
|
30
|
+
|o3|$1.00|-|$4.00|
|
|
31
|
+
|o3-deep-research|$5.00|-|$20.00|
|
|
32
|
+
|o4-mini|$0.55|-|$2.20|
|
|
33
|
+
|o4-mini-deep-research|$1.00|-|$4.00|
|
|
34
|
+
|o3-mini|$0.55|-|$2.20|
|
|
35
|
+
|o1-mini|$0.55|-|$2.20|
|
|
36
|
+
|computer-use-preview|$1.50|-|$6.00|
|
|
37
|
+
|
|
38
|
+
Flex
|
|
39
|
+
|
|
40
|
+
|Model|Input|Cached input|Output|
|
|
41
|
+
|---|---|---|---|
|
|
42
|
+
|gpt-5.2|$0.875|$0.0875|$7.00|
|
|
43
|
+
|gpt-5.1|$0.625|$0.0625|$5.00|
|
|
44
|
+
|gpt-5|$0.625|$0.0625|$5.00|
|
|
45
|
+
|gpt-5-mini|$0.125|$0.0125|$1.00|
|
|
46
|
+
|gpt-5-nano|$0.025|$0.0025|$0.20|
|
|
47
|
+
|o3|$1.00|$0.25|$4.00|
|
|
48
|
+
|o4-mini|$0.55|$0.138|$2.20|
|
|
49
|
+
|
|
50
|
+
Standard
|
|
51
|
+
|
|
52
|
+
|Model|Input|Cached input|Output|
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
|gpt-5.2|$1.75|$0.175|$14.00|
|
|
55
|
+
|gpt-5.1|$1.25|$0.125|$10.00|
|
|
56
|
+
|gpt-5|$1.25|$0.125|$10.00|
|
|
57
|
+
|gpt-5-mini|$0.25|$0.025|$2.00|
|
|
58
|
+
|gpt-5-nano|$0.05|$0.005|$0.40|
|
|
59
|
+
|gpt-5.2-chat-latest|$1.75|$0.175|$14.00|
|
|
60
|
+
|gpt-5.1-chat-latest|$1.25|$0.125|$10.00|
|
|
61
|
+
|gpt-5-chat-latest|$1.25|$0.125|$10.00|
|
|
62
|
+
|gpt-5.1-codex-max|$1.25|$0.125|$10.00|
|
|
63
|
+
|gpt-5.1-codex|$1.25|$0.125|$10.00|
|
|
64
|
+
|gpt-5-codex|$1.25|$0.125|$10.00|
|
|
65
|
+
|gpt-5.2-pro|$21.00|-|$168.00|
|
|
66
|
+
|gpt-5-pro|$15.00|-|$120.00|
|
|
67
|
+
|gpt-4.1|$2.00|$0.50|$8.00|
|
|
68
|
+
|gpt-4.1-mini|$0.40|$0.10|$1.60|
|
|
69
|
+
|gpt-4.1-nano|$0.10|$0.025|$0.40|
|
|
70
|
+
|gpt-4o|$2.50|$1.25|$10.00|
|
|
71
|
+
|gpt-4o-2024-05-13|$5.00|-|$15.00|
|
|
72
|
+
|gpt-4o-mini|$0.15|$0.075|$0.60|
|
|
73
|
+
|gpt-realtime|$4.00|$0.40|$16.00|
|
|
74
|
+
|gpt-realtime-mini|$0.60|$0.06|$2.40|
|
|
75
|
+
|gpt-4o-realtime-preview|$5.00|$2.50|$20.00|
|
|
76
|
+
|gpt-4o-mini-realtime-preview|$0.60|$0.30|$2.40|
|
|
77
|
+
|gpt-audio|$2.50|-|$10.00|
|
|
78
|
+
|gpt-audio-mini|$0.60|-|$2.40|
|
|
79
|
+
|gpt-4o-audio-preview|$2.50|-|$10.00|
|
|
80
|
+
|gpt-4o-mini-audio-preview|$0.15|-|$0.60|
|
|
81
|
+
|o1|$15.00|$7.50|$60.00|
|
|
82
|
+
|o1-pro|$150.00|-|$600.00|
|
|
83
|
+
|o3-pro|$20.00|-|$80.00|
|
|
84
|
+
|o3|$2.00|$0.50|$8.00|
|
|
85
|
+
|o3-deep-research|$10.00|$2.50|$40.00|
|
|
86
|
+
|o4-mini|$1.10|$0.275|$4.40|
|
|
87
|
+
|o4-mini-deep-research|$2.00|$0.50|$8.00|
|
|
88
|
+
|o3-mini|$1.10|$0.55|$4.40|
|
|
89
|
+
|o1-mini|$1.10|$0.55|$4.40|
|
|
90
|
+
|gpt-5.1-codex-mini|$0.25|$0.025|$2.00|
|
|
91
|
+
|codex-mini-latest|$1.50|$0.375|$6.00|
|
|
92
|
+
|gpt-5-search-api|$1.25|$0.125|$10.00|
|
|
93
|
+
|gpt-4o-mini-search-preview|$0.15|-|$0.60|
|
|
94
|
+
|gpt-4o-search-preview|$2.50|-|$10.00|
|
|
95
|
+
|computer-use-preview|$3.00|-|$12.00|
|
|
96
|
+
|gpt-image-1.5|$5.00|$1.25|$10.00|
|
|
97
|
+
|chatgpt-image-latest|$5.00|$1.25|$10.00|
|
|
98
|
+
|gpt-image-1|$5.00|$1.25|-|
|
|
99
|
+
|gpt-image-1-mini|$2.00|$0.20|-|
|
|
100
|
+
|
|
101
|
+
Priority
|
|
102
|
+
|
|
103
|
+
|Model|Input|Cached input|Output|
|
|
104
|
+
|---|---|---|---|
|
|
105
|
+
|gpt-5.2|$3.50|$0.35|$28.00|
|
|
106
|
+
|gpt-5.1|$2.50|$0.25|$20.00|
|
|
107
|
+
|gpt-5|$2.50|$0.25|$20.00|
|
|
108
|
+
|gpt-5-mini|$0.45|$0.045|$3.60|
|
|
109
|
+
|gpt-5.1-codex-max|$2.50|$0.25|$20.00|
|
|
110
|
+
|gpt-5.1-codex|$2.50|$0.25|$20.00|
|
|
111
|
+
|gpt-5-codex|$2.50|$0.25|$20.00|
|
|
112
|
+
|gpt-4.1|$3.50|$0.875|$14.00|
|
|
113
|
+
|gpt-4.1-mini|$0.70|$0.175|$2.80|
|
|
114
|
+
|gpt-4.1-nano|$0.20|$0.05|$0.80|
|
|
115
|
+
|gpt-4o|$4.25|$2.125|$17.00|
|
|
116
|
+
|gpt-4o-2024-05-13|$8.75|-|$26.25|
|
|
117
|
+
|gpt-4o-mini|$0.25|$0.125|$1.00|
|
|
118
|
+
|o3|$3.50|$0.875|$14.00|
|
|
119
|
+
|o4-mini|$2.00|$0.50|$8.00|
|
|
120
|
+
|
|
121
|
+
For faster processing of API requests, try the [priority processing service tier](https://platform.openai.com/docs/guides/priority-processing). For lower prices with higher latency, try the [flex processing tier](https://platform.openai.com/docs/guides/flex-processing).
|
|
122
|
+
|
|
123
|
+
Large numbers of API requests which are not time-sensitive can use the [Batch API](https://platform.openai.com/docs/guides/batch) for additional savings as well.
|
|
124
|
+
|
|
125
|
+
While reasoning tokens are not visible via the API, they still occupy space in the model's context window and are billed as output tokens.
|
|
126
|
+
|
|
127
|
+
For gpt-image-1.5, Text output tokens include model reasoning tokens.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
###
|
|
132
|
+
|
|
133
|
+
Image tokens
|
|
134
|
+
|
|
135
|
+
Prices per 1M tokens.
|
|
136
|
+
|
|
137
|
+
|Model|Input|Cached Input|Output|
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
|gpt-image-1.5|$8.00|$2.00|$32.00|
|
|
140
|
+
|chatgpt-image-latest|$8.00|$2.00|$32.00|
|
|
141
|
+
|gpt-image-1|$10.00|$2.50|$40.00|
|
|
142
|
+
|gpt-image-1-mini|$2.50|$0.25|$8.00|
|
|
143
|
+
|gpt-realtime|$5.00|$0.50|-|
|
|
144
|
+
|gpt-realtime-mini|$0.80|$0.08|-|
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
###
|
|
149
|
+
|
|
150
|
+
Audio tokens
|
|
151
|
+
|
|
152
|
+
Prices per 1M tokens.
|
|
153
|
+
|
|
154
|
+
|Model|Input|Cached Input|Output|
|
|
155
|
+
|---|---|---|---|
|
|
156
|
+
|gpt-realtime|$32.00|$0.40|$64.00|
|
|
157
|
+
|gpt-realtime-mini|$10.00|$0.30|$20.00|
|
|
158
|
+
|gpt-4o-realtime-preview|$40.00|$2.50|$80.00|
|
|
159
|
+
|gpt-4o-mini-realtime-preview|$10.00|$0.30|$20.00|
|
|
160
|
+
|gpt-audio|$32.00|-|$64.00|
|
|
161
|
+
|gpt-audio-mini|$10.00|-|$20.00|
|
|
162
|
+
|gpt-4o-audio-preview|$40.00|-|$80.00|
|
|
163
|
+
|gpt-4o-mini-audio-preview|$10.00|-|$20.00|
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
###
|
|
168
|
+
|
|
169
|
+
Video
|
|
170
|
+
|
|
171
|
+
Prices per second.
|
|
172
|
+
|
|
173
|
+
|Model|Size: Output resolution|Price per second|
|
|
174
|
+
|---|---|---|
|
|
175
|
+
|sora-2|Portrait: 720x1280 Landscape: 1280x720|$0.10|
|
|
176
|
+
|sora-2-pro|Portrait: 720x1280 Landscape: 1280x720|$0.30|
|
|
177
|
+
|sora-2-pro|Portrait: 1024x1792 Landscape: 1792x1024|$0.50|
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
###
|
|
182
|
+
|
|
183
|
+
Fine-tuning
|
|
184
|
+
|
|
185
|
+
Prices per 1M tokens.
|
|
186
|
+
|
|
187
|
+
Batch
|
|
188
|
+
|
|
189
|
+
|Model|Training|Input|Cached Input|Output|
|
|
190
|
+
|---|---|---|---|---|
|
|
191
|
+
|o4-mini-2025-04-16|$100.00 / hour|$2.00|$0.50|$8.00|
|
|
192
|
+
|o4-mini-2025-04-16with data sharing|$100.00 / hour|$1.00|$0.25|$4.00|
|
|
193
|
+
|gpt-4.1-2025-04-14|$25.00|$1.50|$0.50|$6.00|
|
|
194
|
+
|gpt-4.1-mini-2025-04-14|$5.00|$0.40|$0.10|$1.60|
|
|
195
|
+
|gpt-4.1-nano-2025-04-14|$1.50|$0.10|$0.025|$0.40|
|
|
196
|
+
|gpt-4o-2024-08-06|$25.00|$2.225|$0.90|$12.50|
|
|
197
|
+
|gpt-4o-mini-2024-07-18|$3.00|$0.15|$0.075|$0.60|
|
|
198
|
+
|gpt-3.5-turbo|$8.00|$1.50|-|$3.00|
|
|
199
|
+
|davinci-002|$6.00|$6.00|-|$6.00|
|
|
200
|
+
|babbage-002|$0.40|$0.80|-|$0.90|
|
|
201
|
+
|
|
202
|
+
Standard
|
|
203
|
+
|
|
204
|
+
|Model|Training|Input|Cached Input|Output|
|
|
205
|
+
|---|---|---|---|---|
|
|
206
|
+
|o4-mini-2025-04-16|$100.00 / hour|$4.00|$1.00|$16.00|
|
|
207
|
+
|o4-mini-2025-04-16with data sharing|$100.00 / hour|$2.00|$0.50|$8.00|
|
|
208
|
+
|gpt-4.1-2025-04-14|$25.00|$3.00|$0.75|$12.00|
|
|
209
|
+
|gpt-4.1-mini-2025-04-14|$5.00|$0.80|$0.20|$3.20|
|
|
210
|
+
|gpt-4.1-nano-2025-04-14|$1.50|$0.20|$0.05|$0.80|
|
|
211
|
+
|gpt-4o-2024-08-06|$25.00|$3.75|$1.875|$15.00|
|
|
212
|
+
|gpt-4o-mini-2024-07-18|$3.00|$0.30|$0.15|$1.20|
|
|
213
|
+
|gpt-3.5-turbo|$8.00|$3.00|-|$6.00|
|
|
214
|
+
|davinci-002|$6.00|$12.00|-|$12.00|
|
|
215
|
+
|babbage-002|$0.40|$1.60|-|$1.60|
|
|
216
|
+
|
|
217
|
+
Tokens used for model grading in reinforcement fine-tuning are billed at that model's per-token rate. Inference discounts are available if you enable data sharing when creating the fine-tune job. [Learn more](https://help.openai.com/en/articles/10306912-sharing-feedback-evaluation-and-fine-tuning-data-and-api-inputs-and-outputs-with-openai#h_c93188c569).
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
###
|
|
222
|
+
|
|
223
|
+
Built-in tools
|
|
224
|
+
|
|
225
|
+
|Tool|Cost|
|
|
226
|
+
|---|---|
|
|
227
|
+
|Code Interpreter|1 GB (default): $0.03 / container4 GB: $0.12 / container16 GB: $0.48 / container64 GB: $1.92 / container|
|
|
228
|
+
|File search storage|$0.10 / GB per day (1GB free)|
|
|
229
|
+
|File search tool callResponses API only|$2.50 / 1k calls|
|
|
230
|
+
|Web search (all models)[1]|$10.00 / 1k calls + search content tokens billed at model rates|
|
|
231
|
+
|Web search preview (reasoning models, including gpt-5, o-series)|$10.00 / 1k calls + search content tokens billed at model rates|
|
|
232
|
+
|Web search preview (non-reasoning models)|$25.00 / 1k calls + search content tokens are free|
|
|
233
|
+
|
|
234
|
+
The tokens used for built-in tools are billed at the chosen model's per-token rates. GB refers to binary gigabytes of storage (also known as gibibyte), where 1GB is 2^30 bytes.
|
|
235
|
+
|
|
236
|
+
**Web search:** There are two components that contribute to the cost of using the web search tool: (1) tool calls and (2) search content tokens. Tool calls are billed per 1000 calls, according to the tool version and model type. The billing dashboard and invoices will report these line items as “web search tool calls.”
|
|
237
|
+
|
|
238
|
+
Search content tokens are tokens retrieved from the search index and fed to the model alongside your prompt to generate an answer. These are billed at the model’s input token rate, unless otherwise specified.
|
|
239
|
+
|
|
240
|
+
\[1\] For `gpt-4o-mini` and `gpt-4.1-mini` with the web search non-preview tool, search content tokens are charged as a fixed block of 8,000 input tokens per call.
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
###
|
|
245
|
+
|
|
246
|
+
AgentKit
|
|
247
|
+
|
|
248
|
+
Build, deploy, and optimize production-grade agents with Agent Builder, ChatKit, and Evals. You pay only for the compute and data you actually use.
|
|
249
|
+
|
|
250
|
+
|Usage meter|Free tier (per account, per month)|Price beyond free tier|
|
|
251
|
+
|---|---|---|
|
|
252
|
+
|Storage for ChatKit File / Image Uploads|1 GB|$0.10 / GB-day|
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
###
|
|
257
|
+
|
|
258
|
+
Transcription and speech generation
|
|
259
|
+
|
|
260
|
+
Prices per 1M tokens.
|
|
261
|
+
|
|
262
|
+
#### Text tokens
|
|
263
|
+
|
|
264
|
+
|Model|Input|Output|Estimated cost|
|
|
265
|
+
|---|---|---|---|
|
|
266
|
+
|gpt-4o-mini-tts|$0.60|-|$0.015 / minute|
|
|
267
|
+
|gpt-4o-transcribe|$2.50|$10.00|$0.006 / minute|
|
|
268
|
+
|gpt-4o-transcribe-diarize|$2.50|$10.00|$0.006 / minute|
|
|
269
|
+
|gpt-4o-mini-transcribe|$1.25|$5.00|$0.003 / minute|
|
|
270
|
+
|
|
271
|
+
#### Audio tokens
|
|
272
|
+
|
|
273
|
+
|Model|Input|Output|Estimated cost|
|
|
274
|
+
|---|---|---|---|
|
|
275
|
+
|gpt-4o-mini-tts|-|$12.00|$0.015 / minute|
|
|
276
|
+
|gpt-4o-transcribe|$6.00|-|$0.006 / minute|
|
|
277
|
+
|gpt-4o-transcribe-diarize|$6.00|-|$0.006 / minute|
|
|
278
|
+
|gpt-4o-mini-transcribe|$3.00|-|$0.003 / minute|
|
|
279
|
+
|
|
280
|
+
#### Other models
|
|
281
|
+
|
|
282
|
+
|Model|Use case|Cost|
|
|
283
|
+
|---|---|---|
|
|
284
|
+
|Whisper|Transcription|$0.006 / minute|
|
|
285
|
+
|TTS|Speech generation|$15.00 / 1M characters|
|
|
286
|
+
|TTS HD|Speech generation|$30.00 / 1M characters|
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
###
|
|
291
|
+
|
|
292
|
+
Image generation
|
|
293
|
+
|
|
294
|
+
Prices per image.
|
|
295
|
+
|
|
296
|
+
|Model|Quality|1024 x 1024|1024 x 1536|1536 x 1024|
|
|
297
|
+
|---|---|---|---|---|
|
|
298
|
+
|GPT Image 1.5|Low|$0.009|$0.013|$0.013|
|
|
299
|
+
|Medium|$0.034|$0.05|$0.05|
|
|
300
|
+
|High|$0.133|$0.2|$0.2|
|
|
301
|
+
|GPT Image Latest|Low|$0.009|$0.013|$0.013|
|
|
302
|
+
|Medium|$0.034|$0.05|$0.05|
|
|
303
|
+
|High|$0.133|$0.2|$0.2|
|
|
304
|
+
|GPT Image 1|Low|$0.011|$0.016|$0.016|
|
|
305
|
+
|Medium|$0.042|$0.063|$0.063|
|
|
306
|
+
|High|$0.167|$0.25|$0.25|
|
|
307
|
+
|GPT Image 1 Mini|Low|$0.005|$0.006|$0.006|
|
|
308
|
+
|Medium|$0.011|$0.015|$0.015|
|
|
309
|
+
|High|$0.036|$0.052|$0.052|
|
|
310
|
+
||
|
|
311
|
+
||
|
|
312
|
+
|DALL·E 3|Standard|$0.04|$0.08|$0.08|
|
|
313
|
+
|HD|$0.08|$0.12|$0.12|
|
|
314
|
+
||
|
|
315
|
+
||
|
|
316
|
+
|DALL·E 2|Standard|$0.016|$0.018|$0.02|
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
###
|
|
321
|
+
|
|
322
|
+
Embeddings
|
|
323
|
+
|
|
324
|
+
Prices per 1M tokens.
|
|
325
|
+
|
|
326
|
+
|Model|Cost|Batch cost|
|
|
327
|
+
|---|---|---|
|
|
328
|
+
|text-embedding-3-small|$0.02|$0.01|
|
|
329
|
+
|text-embedding-3-large|$0.13|$0.065|
|
|
330
|
+
|text-embedding-ada-002|$0.10|$0.05|
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
### Moderation
|
|
335
|
+
|
|
336
|
+
Our `omni-moderation` models are made available free of charge ✌️
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
###
|
|
341
|
+
|
|
342
|
+
Legacy models
|
|
343
|
+
|
|
344
|
+
Prices per 1M tokens.
|
|
345
|
+
|
|
346
|
+
Batch
|
|
347
|
+
|
|
348
|
+
|Model|Input|Output|
|
|
349
|
+
|---|---|---|
|
|
350
|
+
|gpt-4-turbo-2024-04-09|$5.00|$15.00|
|
|
351
|
+
|gpt-4-0125-preview|$5.00|$15.00|
|
|
352
|
+
|gpt-4-1106-preview|$5.00|$15.00|
|
|
353
|
+
|gpt-4-1106-vision-preview|$5.00|$15.00|
|
|
354
|
+
|gpt-4-0613|$15.00|$30.00|
|
|
355
|
+
|gpt-4-0314|$15.00|$30.00|
|
|
356
|
+
|gpt-4-32k|$30.00|$60.00|
|
|
357
|
+
|gpt-3.5-turbo-0125|$0.25|$0.75|
|
|
358
|
+
|gpt-3.5-turbo-1106|$1.00|$2.00|
|
|
359
|
+
|gpt-3.5-turbo-0613|$1.50|$2.00|
|
|
360
|
+
|gpt-3.5-0301|$1.50|$2.00|
|
|
361
|
+
|gpt-3.5-turbo-16k-0613|$1.50|$2.00|
|
|
362
|
+
|davinci-002|$1.00|$1.00|
|
|
363
|
+
|babbage-002|$0.20|$0.20|
|
|
364
|
+
|
|
365
|
+
Standard
|
|
366
|
+
|
|
367
|
+
|Model|Input|Output|
|
|
368
|
+
|---|---|---|
|
|
369
|
+
|chatgpt-4o-latest|$5.00|$15.00|
|
|
370
|
+
|gpt-4-turbo-2024-04-09|$10.00|$30.00|
|
|
371
|
+
|gpt-4-0125-preview|$10.00|$30.00|
|
|
372
|
+
|gpt-4-1106-preview|$10.00|$30.00|
|
|
373
|
+
|gpt-4-1106-vision-preview|$10.00|$30.00|
|
|
374
|
+
|gpt-4-0613|$30.00|$60.00|
|
|
375
|
+
|gpt-4-0314|$30.00|$60.00|
|
|
376
|
+
|gpt-4-32k|$60.00|$120.00|
|
|
377
|
+
|gpt-3.5-turbo|$0.50|$1.50|
|
|
378
|
+
|gpt-3.5-turbo-0125|$0.50|$1.50|
|
|
379
|
+
|gpt-3.5-turbo-1106|$1.00|$2.00|
|
|
380
|
+
|gpt-3.5-turbo-0613|$1.50|$2.00|
|
|
381
|
+
|gpt-3.5-0301|$1.50|$2.00|
|
|
382
|
+
|gpt-3.5-turbo-instruct|$1.50|$2.00|
|
|
383
|
+
|gpt-3.5-turbo-16k-0613|$3.00|$4.00|
|
|
384
|
+
|davinci-002|$2.00|$2.00|
|
|
385
|
+
|babbage-002|$0.40|$0.40|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var te=Object.create;var f=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var oe=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ie(t))!se.call(e,r)&&r!==n&&f(e,r,{get:()=>t[r],enumerable:!(i=ne(t,r))||i.enumerable});return e};var L=(e,t,n)=>(n=e!=null?te(re(e)):{},V(t||!e||!e.__esModule?f(n,"default",{value:e,enumerable:!0}):n,e)),ae=e=>V(f({},"__esModule",{value:!0}),e);var Pe={};oe(Pe,{buildAdapterRegisterInstruction:()=>Q,createSolanaVaultAdapter:()=>he,deriveChannelId:()=>q,passkeySignerFromP256Keypair:()=>z});module.exports=ae(Pe);var c=require("@solana/web3.js"),Z=require("@solana/spl-token");var ce="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",pe="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",le="solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";var w="eip155:8453",U="eip155:84532",C="eip155:42161",R="eip155:137",O="eip155:10",D="eip155:43114",N="eip155:56",T="eip155:1187947933",_="eip155:324705682",I="eip155:1";var W="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";var ue="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",ye="0x55d398326f99059fF775485246999027B3197955",F="0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",Ee={[N]:F,[w]:ue,[U]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[C]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[R]:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",[O]:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",[D]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[T]:"0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",[_]:"0x2e08028E3C4c2356572E096d8EF835cD5C6030bD",[I]:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},Ke={[ye]:{symbol:"USDT",decimals:18},[F]:{symbol:"USDC",decimals:18}};var ve={[N]:56,[w]:8453,[U]:84532,[C]:42161,[R]:137,[O]:10,[D]:43114,[T]:1187947933,[_]:324705682,[I]:1},we={[ce]:"https://api.dexter.cash/api/solana/rpc",[pe]:"https://api.devnet.solana.com",[le]:"https://api.testnet.solana.com"},Ue={[N]:"https://api.dexter.cash/api/evm/bsc/rpc",[w]:"https://api.dexter.cash/api/base/rpc",[U]:"https://sepolia.base.org",[C]:"https://api.dexter.cash/api/evm/arbitrum/rpc",[R]:"https://api.dexter.cash/api/evm/polygon/rpc",[O]:"https://api.dexter.cash/api/evm/optimism/rpc",[D]:"https://api.dexter.cash/api/evm/avalanche/rpc",[T]:"https://skale-base.skalenodes.com/v1/base",[_]:"https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha",[I]:"https://eth.llamarpc.com"};var a=require("@dexterai/vault/instructions"),P=require("@dexterai/vault/precompile"),m=require("@dexterai/vault/constants");var s=require("@dexterai/vault/messages");var k=L(require("tweetnacl"),1);var $=require("@noble/hashes/sha256");function J(){let e=k.default.sign.keyPair();return{publicKey:e.publicKey,privateKey:e.secretKey}}function H(e,t,n){return{publicKey:e.publicKey,privateKey:e.privateKey,scope:t,registration:n}}function G(e,t,n){if(n.length!==32)throw new Error(`channelIdBytes must be 32 bytes, got ${n.length}`);let i=BigInt(t.cumulativeAmount),r=BigInt(e.scope.maxAmountAtomic);if(i>r)throw new Error(`voucher cumulative ${i} exceeds session cap ${r}`);let o=Math.floor(Date.now()/1e3);if(o>=e.scope.expiresAtUnix)throw new Error(`session expired at ${e.scope.expiresAtUnix}, now ${o}`);let p=(0,s.voucherPayloadMessage)({channelId:n,cumulativeAmount:i,sequenceNumber:t.sequenceNumber}),l=k.default.sign.detached(p,e.privateKey);return{payload:t,sessionPublicKey:e.publicKey,sessionRegistration:e.registration,sessionSignature:l}}function b(e){if(!/^\d+$/.test(e))throw new Error(`atomic amount must be a non-negative integer string, got "${e}"`);return BigInt(e)}function q(e){let t=new Uint8Array(8);new DataView(t.buffer).setBigUint64(0,e.nonce,!0);let n=new TextEncoder().encode(e.sellerUrl),i=$.sha256.create();return i.update(e.vaultPda.toBytes()),i.update(n),i.update(t),i.digest()}var d=require("@dexterai/vault/session"),g=require("@noble/hashes/sha256");var X=require("@noble/curves/p256"),E=require("@noble/hashes/sha256"),Y="dexter.cash";function me(e){return Buffer.from(e).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function de(e,t=`https://${Y}`){let i={type:"webauthn.get",challenge:me(e),origin:t,crossOrigin:!1};return new TextEncoder().encode(JSON.stringify(i))}function ge(e=1){let t=(0,E.sha256)(new TextEncoder().encode(Y)),n=new Uint8Array(37);return n.set(t,0),n[32]=5,new DataView(n.buffer).setUint32(33,e,!1),n}function Ae(e,t){let n=de(t),i=ge(1),r=new Uint8Array(i.length+32);r.set(i,0),r.set((0,E.sha256)(n),i.length);let o=(0,E.sha256)(r);return{signature:X.p256.sign(o,e.privateKey,{lowS:!0}).toCompactRawBytes(),clientDataJSON:n,authenticatorData:i}}function z(e){return{publicKey:e.publicKey,sign:async t=>Ae(e,t)}}function Q(e){let t=(0,a.deriveSwigWalletAddress)(e.swigAddress),n=(0,Z.getAssociatedTokenAddressSync)(new c.PublicKey(W),t,!0);return(0,a.buildRegisterSessionKeyInstruction)({vaultPda:e.vaultPda,sessionPubkey:e.sessionPubkey,maxAmount:e.maxAmount,maxRevolvingCapacity:e.maxRevolvingCapacity,expiresAt:e.expiresAt,allowedCounterparty:e.allowedCounterparty,nonce:e.nonce,swigAddress:e.swigAddress,vaultUsdcAta:n,clientDataJSON:e.clientDataJSON,authenticatorData:e.authenticatorData,payer:e.payer,siblingSessionPdas:e.siblingSessionPdas})}var B=class{network="solana:mainnet";swigAddress;vaultPda;connection;vaultPdaKey;passkey;feePayer;confirmOptions;constructor(t){this.connection=t.connection,this.swigAddress=typeof t.swigAddress=="string"?t.swigAddress:t.swigAddress.toBase58(),this.vaultPdaKey=typeof t.vaultPda=="string"?new c.PublicKey(t.vaultPda):t.vaultPda,this.vaultPda=this.vaultPdaKey.toBase58(),this.passkey=t.passkeySigner,this.feePayer=t.feePayer,this.confirmOptions=t.confirmOptions??{commitment:"confirmed"}}async authorizeSession(t){let n=new c.PublicKey(t.allowedCounterparty),i=b(t.revolvingCapacityAtomic??t.maxAmountAtomic),r=J(),o=Se(),p=(0,s.sessionRegisterMessage)({programId:m.DEXTER_VAULT_PROGRAM_ID,vaultPda:this.vaultPdaKey,sessionPubkey:r.publicKey,maxAmount:b(t.maxAmountAtomic),maxRevolvingCapacity:i,expiresAt:BigInt(t.expiresAtUnix),allowedCounterparty:n,nonce:o}),l=(0,g.sha256)(p),{signature:A,clientDataJSON:h,authenticatorData:S}=await this.passkey.sign(l),K=j(S,(0,g.sha256)(h)),u=(0,P.buildSecp256r1VerifyInstruction)(this.passkey.publicKey,A,K),x=(0,d.sessionPdasOf)(await(0,d.fetchVaultSessionAccounts)(this.connection,this.vaultPdaKey)),v=Q({vaultPda:this.vaultPdaKey,swigAddress:new c.PublicKey(this.swigAddress),sessionPubkey:r.publicKey,maxAmount:b(t.maxAmountAtomic),maxRevolvingCapacity:i,expiresAt:BigInt(t.expiresAtUnix),allowedCounterparty:n,nonce:o,clientDataJSON:h,authenticatorData:S,payer:this.feePayer.publicKey,siblingSessionPdas:x}),y=new c.Transaction().add(u,v);y.feePayer=this.feePayer.publicKey;let{blockhash:M}=await this.connection.getLatestBlockhash(this.confirmOptions.commitment);y.recentBlockhash=M,y.sign(this.feePayer);let ee=await this.connection.sendRawTransaction(y.serialize(),{skipPreflight:!1,preflightCommitment:this.confirmOptions.preflightCommitment??this.confirmOptions.commitment});return await this.connection.confirmTransaction({signature:ee,blockhash:M,lastValidBlockHeight:(await this.connection.getLatestBlockhash(this.confirmOptions.commitment)).lastValidBlockHeight},this.confirmOptions.commitment),await(0,d.waitForSession)(this.connection,this.vaultPdaKey,n,{expectedSessionPubkey:r.publicKey,timeoutMs:2e4}),H(r,t,p)}async signWithSession(t,n){let i=await xe(n.channelId);return G(t,n,i)}async signOpenTab(t,n){return t.registration}async signCloseTab(t,n,i){let r=(0,s.sessionRevokeMessage)({programId:m.DEXTER_VAULT_PROGRAM_ID,vaultPda:this.vaultPdaKey,sessionPubkey:t.publicKey}),o=(0,g.sha256)(r),{signature:p,clientDataJSON:l,authenticatorData:A}=await this.passkey.sign(o),h=j(A,(0,g.sha256)(l)),S=(0,P.buildSecp256r1VerifyInstruction)(this.passkey.publicKey,p,h),K=(0,a.buildRevokeSessionKeyInstruction)({vaultPda:this.vaultPdaKey,allowedCounterparty:new c.PublicKey(t.scope.allowedCounterparty),clientDataJSON:l,authenticatorData:A}),u=new c.Transaction().add(S,K);u.feePayer=this.feePayer.publicKey;let{blockhash:x,lastValidBlockHeight:v}=await this.connection.getLatestBlockhash(this.confirmOptions.commitment);u.recentBlockhash=x,u.sign(this.feePayer);let y=await this.connection.sendRawTransaction(u.serialize(),{skipPreflight:!1,preflightCommitment:this.confirmOptions.preflightCommitment??this.confirmOptions.commitment});return await this.connection.confirmTransaction({signature:y,blockhash:x,lastValidBlockHeight:v},this.confirmOptions.commitment),r}};function he(e){return new B(e)}function j(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function Se(){return Math.floor(Math.random()*4294967295)>>>0}async function xe(e){if(/^[0-9a-f]{64}$/i.test(e))return fe(e);let{sha256:t}=await import("@noble/hashes/sha256");return t(new TextEncoder().encode(e))}function fe(e){let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.substr(n*2,2),16);return t}0&&(module.exports={buildAdapterRegisterInstruction,createSolanaVaultAdapter,deriveChannelId,passkeySignerFromP256Keypair});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { PublicKey, Connection, Signer, ConfirmOptions } from '@solana/web3.js';
|
|
3
3
|
import { V as VaultAdapter } from '../../../types-DuoL3s8n.cjs';
|
|
4
|
+
import { PasskeySignerWithPublicKey } from '@dexterai/vault/signers';
|
|
5
|
+
export { PasskeySignerWithPublicKey as PasskeySigner } from '@dexterai/vault/signers';
|
|
4
6
|
import '@dexterai/vault/types';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -53,29 +55,22 @@ interface P256Keypair {
|
|
|
53
55
|
/** 32-byte raw scalar. NEVER persist this anywhere user-readable. */
|
|
54
56
|
privateKey: Uint8Array;
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
signature: Uint8Array;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface PasskeySigner {
|
|
68
|
-
/** 33-byte SEC1 compressed P-256 public key. The vault stores this on
|
|
69
|
-
* init; the on-chain verifier compares against it on every passkey-
|
|
70
|
-
* signed instruction. */
|
|
58
|
+
/**
|
|
59
|
+
* Build a unified `PasskeySignerWithPublicKey` (vault's canonical shape)
|
|
60
|
+
* from a locally-held P-256 keypair — the node/CLI path. Returns
|
|
61
|
+
* `{ publicKey, sign(challenge) }`; the adapter computes the challenge and
|
|
62
|
+
* rebuilds the precompile message. Drop-in equivalent to vault's
|
|
63
|
+
* DexterApiBrowserPasskeySigner.
|
|
64
|
+
*/
|
|
65
|
+
declare function passkeySignerFromP256Keypair(kp: P256Keypair): {
|
|
71
66
|
publicKey: Uint8Array;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
sign(challenge: Uint8Array): Promise<{
|
|
68
|
+
signature: Uint8Array;
|
|
69
|
+
clientDataJSON: Uint8Array;
|
|
70
|
+
authenticatorData: Uint8Array;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
|
|
79
74
|
interface CreateSolanaVaultAdapterOptions {
|
|
80
75
|
/** RPC the adapter uses to submit txs. The buyer can pass their own
|
|
81
76
|
* connection (browser wallet RPC, Helius URL, etc.) — the adapter has
|
|
@@ -89,7 +84,7 @@ interface CreateSolanaVaultAdapterOptions {
|
|
|
89
84
|
/** The buyer's vault PDA (gate account). */
|
|
90
85
|
vaultPda: string | PublicKey;
|
|
91
86
|
/** The passkey signing path. */
|
|
92
|
-
passkeySigner:
|
|
87
|
+
passkeySigner: PasskeySignerWithPublicKey;
|
|
93
88
|
/** Lamport-fee payer. In Phase 2 this is the buyer; later phases may
|
|
94
89
|
* route through a facilitator co-signer. Required because the buyer's
|
|
95
90
|
* vault account is not a signer for register/revoke (the passkey
|
|
@@ -121,4 +116,4 @@ declare function buildAdapterRegisterInstruction(p: AdapterRegisterIxParams): _s
|
|
|
121
116
|
/** Factory entry point. */
|
|
122
117
|
declare function createSolanaVaultAdapter(opts: CreateSolanaVaultAdapterOptions): VaultAdapter;
|
|
123
118
|
|
|
124
|
-
export { type AdapterRegisterIxParams, type CreateSolanaVaultAdapterOptions,
|
|
119
|
+
export { type AdapterRegisterIxParams, type CreateSolanaVaultAdapterOptions, buildAdapterRegisterInstruction, createSolanaVaultAdapter, deriveChannelId, passkeySignerFromP256Keypair };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { PublicKey, Connection, Signer, ConfirmOptions } from '@solana/web3.js';
|
|
3
3
|
import { V as VaultAdapter } from '../../../types-DuoL3s8n.js';
|
|
4
|
+
import { PasskeySignerWithPublicKey } from '@dexterai/vault/signers';
|
|
5
|
+
export { PasskeySignerWithPublicKey as PasskeySigner } from '@dexterai/vault/signers';
|
|
4
6
|
import '@dexterai/vault/types';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -53,29 +55,22 @@ interface P256Keypair {
|
|
|
53
55
|
/** 32-byte raw scalar. NEVER persist this anywhere user-readable. */
|
|
54
56
|
privateKey: Uint8Array;
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
signature: Uint8Array;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface PasskeySigner {
|
|
68
|
-
/** 33-byte SEC1 compressed P-256 public key. The vault stores this on
|
|
69
|
-
* init; the on-chain verifier compares against it on every passkey-
|
|
70
|
-
* signed instruction. */
|
|
58
|
+
/**
|
|
59
|
+
* Build a unified `PasskeySignerWithPublicKey` (vault's canonical shape)
|
|
60
|
+
* from a locally-held P-256 keypair — the node/CLI path. Returns
|
|
61
|
+
* `{ publicKey, sign(challenge) }`; the adapter computes the challenge and
|
|
62
|
+
* rebuilds the precompile message. Drop-in equivalent to vault's
|
|
63
|
+
* DexterApiBrowserPasskeySigner.
|
|
64
|
+
*/
|
|
65
|
+
declare function passkeySignerFromP256Keypair(kp: P256Keypair): {
|
|
71
66
|
publicKey: Uint8Array;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
sign(challenge: Uint8Array): Promise<{
|
|
68
|
+
signature: Uint8Array;
|
|
69
|
+
clientDataJSON: Uint8Array;
|
|
70
|
+
authenticatorData: Uint8Array;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
|
|
79
74
|
interface CreateSolanaVaultAdapterOptions {
|
|
80
75
|
/** RPC the adapter uses to submit txs. The buyer can pass their own
|
|
81
76
|
* connection (browser wallet RPC, Helius URL, etc.) — the adapter has
|
|
@@ -89,7 +84,7 @@ interface CreateSolanaVaultAdapterOptions {
|
|
|
89
84
|
/** The buyer's vault PDA (gate account). */
|
|
90
85
|
vaultPda: string | PublicKey;
|
|
91
86
|
/** The passkey signing path. */
|
|
92
|
-
passkeySigner:
|
|
87
|
+
passkeySigner: PasskeySignerWithPublicKey;
|
|
93
88
|
/** Lamport-fee payer. In Phase 2 this is the buyer; later phases may
|
|
94
89
|
* route through a facilitator co-signer. Required because the buyer's
|
|
95
90
|
* vault account is not a signer for register/revoke (the passkey
|
|
@@ -121,4 +116,4 @@ declare function buildAdapterRegisterInstruction(p: AdapterRegisterIxParams): _s
|
|
|
121
116
|
/** Factory entry point. */
|
|
122
117
|
declare function createSolanaVaultAdapter(opts: CreateSolanaVaultAdapterOptions): VaultAdapter;
|
|
123
118
|
|
|
124
|
-
export { type AdapterRegisterIxParams, type CreateSolanaVaultAdapterOptions,
|
|
119
|
+
export { type AdapterRegisterIxParams, type CreateSolanaVaultAdapterOptions, buildAdapterRegisterInstruction, createSolanaVaultAdapter, deriveChannelId, passkeySignerFromP256Keypair };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PublicKey as l,Transaction as
|
|
1
|
+
import{PublicKey as l,Transaction as q}from"@solana/web3.js";import{getAssociatedTokenAddressSync as pe}from"@solana/spl-token";var z="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",j="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Z="solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";var x="eip155:8453",f="eip155:84532",P="eip155:42161",b="eip155:137",E="eip155:10",K="eip155:43114",v="eip155:56",w="eip155:1187947933",U="eip155:324705682",C="eip155:1";var _="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";var Q="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",ee="0x55d398326f99059fF775485246999027B3197955",I="0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",he={[v]:I,[x]:Q,[f]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[P]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[b]:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",[E]:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",[K]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[w]:"0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",[U]:"0x2e08028E3C4c2356572E096d8EF835cD5C6030bD",[C]:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},Se={[ee]:{symbol:"USDT",decimals:18},[I]:{symbol:"USDC",decimals:18}};var xe={[v]:56,[x]:8453,[f]:84532,[P]:42161,[b]:137,[E]:10,[K]:43114,[w]:1187947933,[U]:324705682,[C]:1},fe={[z]:"https://api.dexter.cash/api/solana/rpc",[j]:"https://api.devnet.solana.com",[Z]:"https://api.testnet.solana.com"},Pe={[v]:"https://api.dexter.cash/api/evm/bsc/rpc",[x]:"https://api.dexter.cash/api/base/rpc",[f]:"https://sepolia.base.org",[P]:"https://api.dexter.cash/api/evm/arbitrum/rpc",[b]:"https://api.dexter.cash/api/evm/polygon/rpc",[E]:"https://api.dexter.cash/api/evm/optimism/rpc",[K]:"https://api.dexter.cash/api/evm/avalanche/rpc",[w]:"https://skale-base.skalenodes.com/v1/base",[U]:"https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha",[C]:"https://eth.llamarpc.com"};import{buildRegisterSessionKeyInstruction as k,buildRevokeSessionKeyInstruction as B,deriveSwigWalletAddress as M}from"@dexterai/vault/instructions";import{buildSecp256r1VerifyInstruction as R}from"@dexterai/vault/precompile";import{DEXTER_VAULT_PROGRAM_ID as O,SECP256R1_PROGRAM_ID as Ue,INSTRUCTIONS_SYSVAR_ID as Ce}from"@dexterai/vault/constants";import{sessionRegisterMessage as V,sessionRevokeMessage as L,voucherPayloadMessage as W,buildVoucherMessage as De}from"@dexterai/vault/messages";import F from"tweetnacl";import{sha256 as te}from"@noble/hashes/sha256";function J(){let e=F.sign.keyPair();return{publicKey:e.publicKey,privateKey:e.secretKey}}function H(e,t,n){return{publicKey:e.publicKey,privateKey:e.privateKey,scope:t,registration:n}}function G(e,t,n){if(n.length!==32)throw new Error(`channelIdBytes must be 32 bytes, got ${n.length}`);let i=BigInt(t.cumulativeAmount),r=BigInt(e.scope.maxAmountAtomic);if(i>r)throw new Error(`voucher cumulative ${i} exceeds session cap ${r}`);let s=Math.floor(Date.now()/1e3);if(s>=e.scope.expiresAtUnix)throw new Error(`session expired at ${e.scope.expiresAtUnix}, now ${s}`);let o=W({channelId:n,cumulativeAmount:i,sequenceNumber:t.sequenceNumber}),a=F.sign.detached(o,e.privateKey);return{payload:t,sessionPublicKey:e.publicKey,sessionRegistration:e.registration,sessionSignature:a}}function g(e){if(!/^\d+$/.test(e))throw new Error(`atomic amount must be a non-negative integer string, got "${e}"`);return BigInt(e)}function ne(e){let t=new Uint8Array(8);new DataView(t.buffer).setBigUint64(0,e.nonce,!0);let n=new TextEncoder().encode(e.sellerUrl),i=te.create();return i.update(e.vaultPda.toBytes()),i.update(n),i.update(t),i.digest()}import{fetchVaultSessionAccounts as le,sessionPdasOf as ue,waitForSession as ye}from"@dexterai/vault/session";import{sha256 as A}from"@noble/hashes/sha256";import{p256 as ie}from"@noble/curves/p256";import{sha256 as D}from"@noble/hashes/sha256";var $="dexter.cash";function re(e){return Buffer.from(e).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function se(e,t=`https://${$}`){let i={type:"webauthn.get",challenge:re(e),origin:t,crossOrigin:!1};return new TextEncoder().encode(JSON.stringify(i))}function oe(e=1){let t=D(new TextEncoder().encode($)),n=new Uint8Array(37);return n.set(t,0),n[32]=5,new DataView(n.buffer).setUint32(33,e,!1),n}function ae(e,t){let n=se(t),i=oe(1),r=new Uint8Array(i.length+32);r.set(i,0),r.set(D(n),i.length);let s=D(r);return{signature:ie.sign(s,e.privateKey,{lowS:!0}).toCompactRawBytes(),clientDataJSON:n,authenticatorData:i}}function ce(e){return{publicKey:e.publicKey,sign:async t=>ae(e,t)}}function me(e){let t=M(e.swigAddress),n=pe(new l(_),t,!0);return k({vaultPda:e.vaultPda,sessionPubkey:e.sessionPubkey,maxAmount:e.maxAmount,maxRevolvingCapacity:e.maxRevolvingCapacity,expiresAt:e.expiresAt,allowedCounterparty:e.allowedCounterparty,nonce:e.nonce,swigAddress:e.swigAddress,vaultUsdcAta:n,clientDataJSON:e.clientDataJSON,authenticatorData:e.authenticatorData,payer:e.payer,siblingSessionPdas:e.siblingSessionPdas})}var N=class{network="solana:mainnet";swigAddress;vaultPda;connection;vaultPdaKey;passkey;feePayer;confirmOptions;constructor(t){this.connection=t.connection,this.swigAddress=typeof t.swigAddress=="string"?t.swigAddress:t.swigAddress.toBase58(),this.vaultPdaKey=typeof t.vaultPda=="string"?new l(t.vaultPda):t.vaultPda,this.vaultPda=this.vaultPdaKey.toBase58(),this.passkey=t.passkeySigner,this.feePayer=t.feePayer,this.confirmOptions=t.confirmOptions??{commitment:"confirmed"}}async authorizeSession(t){let n=new l(t.allowedCounterparty),i=g(t.revolvingCapacityAtomic??t.maxAmountAtomic),r=J(),s=de(),o=V({programId:O,vaultPda:this.vaultPdaKey,sessionPubkey:r.publicKey,maxAmount:g(t.maxAmountAtomic),maxRevolvingCapacity:i,expiresAt:BigInt(t.expiresAtUnix),allowedCounterparty:n,nonce:s}),a=A(o),{signature:u,clientDataJSON:y,authenticatorData:m}=await this.passkey.sign(a),h=X(m,A(y)),c=R(this.passkey.publicKey,u,h),d=ue(await le(this.connection,this.vaultPdaKey)),S=me({vaultPda:this.vaultPdaKey,swigAddress:new l(this.swigAddress),sessionPubkey:r.publicKey,maxAmount:g(t.maxAmountAtomic),maxRevolvingCapacity:i,expiresAt:BigInt(t.expiresAtUnix),allowedCounterparty:n,nonce:s,clientDataJSON:y,authenticatorData:m,payer:this.feePayer.publicKey,siblingSessionPdas:d}),p=new q().add(c,S);p.feePayer=this.feePayer.publicKey;let{blockhash:T}=await this.connection.getLatestBlockhash(this.confirmOptions.commitment);p.recentBlockhash=T,p.sign(this.feePayer);let Y=await this.connection.sendRawTransaction(p.serialize(),{skipPreflight:!1,preflightCommitment:this.confirmOptions.preflightCommitment??this.confirmOptions.commitment});return await this.connection.confirmTransaction({signature:Y,blockhash:T,lastValidBlockHeight:(await this.connection.getLatestBlockhash(this.confirmOptions.commitment)).lastValidBlockHeight},this.confirmOptions.commitment),await ye(this.connection,this.vaultPdaKey,n,{expectedSessionPubkey:r.publicKey,timeoutMs:2e4}),H(r,t,o)}async signWithSession(t,n){let i=await ge(n.channelId);return G(t,n,i)}async signOpenTab(t,n){return t.registration}async signCloseTab(t,n,i){let r=L({programId:O,vaultPda:this.vaultPdaKey,sessionPubkey:t.publicKey}),s=A(r),{signature:o,clientDataJSON:a,authenticatorData:u}=await this.passkey.sign(s),y=X(u,A(a)),m=R(this.passkey.publicKey,o,y),h=B({vaultPda:this.vaultPdaKey,allowedCounterparty:new l(t.scope.allowedCounterparty),clientDataJSON:a,authenticatorData:u}),c=new q().add(m,h);c.feePayer=this.feePayer.publicKey;let{blockhash:d,lastValidBlockHeight:S}=await this.connection.getLatestBlockhash(this.confirmOptions.commitment);c.recentBlockhash=d,c.sign(this.feePayer);let p=await this.connection.sendRawTransaction(c.serialize(),{skipPreflight:!1,preflightCommitment:this.confirmOptions.preflightCommitment??this.confirmOptions.commitment});return await this.connection.confirmTransaction({signature:p,blockhash:d,lastValidBlockHeight:S},this.confirmOptions.commitment),r}};function Xe(e){return new N(e)}function X(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function de(){return Math.floor(Math.random()*4294967295)>>>0}async function ge(e){if(/^[0-9a-f]{64}$/i.test(e))return Ae(e);let{sha256:t}=await import("@noble/hashes/sha256");return t(new TextEncoder().encode(e))}function Ae(e){let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.substr(n*2,2),16);return t}export{me as buildAdapterRegisterInstruction,Xe as createSolanaVaultAdapter,ne as deriveChannelId,ce as passkeySignerFromP256Keypair};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexterai/x402",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Full-stack x402 SDK - add paid API monetization to any endpoint. Express middleware, React hooks, Access Pass, dynamic pricing. Solana, Base, Polygon, Arbitrum, Optimism, Avalanche, SKALE.",
|
|
5
5
|
"author": "Dexter",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"release:major": "npm version major && npm publish --access public"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@dexterai/vault": "^0.
|
|
79
|
+
"@dexterai/vault": "^0.13.0",
|
|
80
80
|
"@dexterai/x402-ads-types": "^0.2.0",
|
|
81
81
|
"@dexterai/x402-core": "^1.4.0",
|
|
82
82
|
"@noble/curves": "^1.9.7",
|