@hashgraphonline/standards-sdk 0.1.141-feat-hcs-21-flora-adapter.canary.053f0af.47 → 0.1.143-feat-adapter-registry.canary.fb173dc.54
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/dist/cjs/hcs-12/validation/schemas.d.ts +8 -8
- package/dist/cjs/hcs-21/types.d.ts +75 -75
- package/dist/cjs/services/registry-broker/client/adapters.d.ts +20 -0
- package/dist/cjs/services/registry-broker/client/adapters.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/agents.d.ts +16 -0
- package/dist/cjs/services/registry-broker/client/agents.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +57 -0
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/chat-history.d.ts +23 -0
- package/dist/cjs/services/registry-broker/client/chat-history.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/chat.d.ts +33 -0
- package/dist/cjs/services/registry-broker/client/chat.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/credits.d.ts +40 -0
- package/dist/cjs/services/registry-broker/client/credits.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/encrypted-chat-manager.d.ts +35 -0
- package/dist/cjs/services/registry-broker/client/encrypted-chat-manager.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/encryption.d.ts +33 -0
- package/dist/cjs/services/registry-broker/client/encryption.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/errors.d.ts +19 -0
- package/dist/cjs/services/registry-broker/client/errors.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/ledger-auth.d.ts +10 -0
- package/dist/cjs/services/registry-broker/client/ledger-auth.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/search.d.ts +19 -0
- package/dist/cjs/services/registry-broker/client/search.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/utils.d.ts +21 -0
- package/dist/cjs/services/registry-broker/client/utils.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client.d.ts +2 -205
- package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +1426 -154
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +44 -1
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/hcs-12/validation/schemas.d.ts +8 -8
- package/dist/es/hcs-21/types.d.ts +75 -75
- package/dist/es/services/registry-broker/client/adapters.d.ts +20 -0
- package/dist/es/services/registry-broker/client/adapters.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/agents.d.ts +16 -0
- package/dist/es/services/registry-broker/client/agents.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/base-client.d.ts +57 -0
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/chat-history.d.ts +23 -0
- package/dist/es/services/registry-broker/client/chat-history.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/chat.d.ts +33 -0
- package/dist/es/services/registry-broker/client/chat.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/credits.d.ts +40 -0
- package/dist/es/services/registry-broker/client/credits.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/encrypted-chat-manager.d.ts +35 -0
- package/dist/es/services/registry-broker/client/encrypted-chat-manager.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/encryption.d.ts +33 -0
- package/dist/es/services/registry-broker/client/encryption.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/errors.d.ts +19 -0
- package/dist/es/services/registry-broker/client/errors.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/ledger-auth.d.ts +10 -0
- package/dist/es/services/registry-broker/client/ledger-auth.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/search.d.ts +19 -0
- package/dist/es/services/registry-broker/client/search.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/utils.d.ts +21 -0
- package/dist/es/services/registry-broker/client/utils.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client.d.ts +2 -205
- package/dist/es/services/registry-broker/client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +1426 -154
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +44 -1
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +16 -7
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +1 -1
- package/dist/es/standards-sdk.es102.js +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es110.js +10 -3
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +5 -5
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es122.js +1 -1
- package/dist/es/standards-sdk.es123.js +5 -5
- package/dist/es/standards-sdk.es125.js +1 -1
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es128.js +138 -2174
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +200 -60
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es130.js +96 -79
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +115 -153
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +248 -8
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +169 -75
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +118 -61
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +327 -29
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +366 -766
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +13 -12270
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +68 -131
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +82 -37
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es140.js +152 -49
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +7 -82
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +81 -12
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +55 -162
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +28 -322
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +120 -328
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +40 -451
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +12223 -267
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +15 -74
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +59 -0
- package/dist/es/standards-sdk.es149.js.map +1 -0
- package/dist/es/standards-sdk.es150.js +85 -0
- package/dist/es/standards-sdk.es150.js.map +1 -0
- package/dist/es/standards-sdk.es151.js +175 -0
- package/dist/es/standards-sdk.es151.js.map +1 -0
- package/dist/es/standards-sdk.es152.js +325 -0
- package/dist/es/standards-sdk.es152.js.map +1 -0
- package/dist/es/standards-sdk.es153.js +349 -0
- package/dist/es/standards-sdk.es153.js.map +1 -0
- package/dist/es/standards-sdk.es154.js +456 -0
- package/dist/es/standards-sdk.es154.js.map +1 -0
- package/dist/es/standards-sdk.es155.js +334 -0
- package/dist/es/standards-sdk.es155.js.map +1 -0
- package/dist/es/standards-sdk.es156.js +79 -0
- package/dist/es/standards-sdk.es156.js.map +1 -0
- package/dist/es/standards-sdk.es157.js +874 -0
- package/dist/es/standards-sdk.es157.js.map +1 -0
- package/dist/es/standards-sdk.es158.js +242 -0
- package/dist/es/standards-sdk.es158.js.map +1 -0
- package/dist/es/standards-sdk.es159.js +247 -0
- package/dist/es/standards-sdk.es159.js.map +1 -0
- package/dist/es/standards-sdk.es17.js +10 -3
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +13 -6
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +11 -4
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es28.js +13 -6
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es36.js +11 -4
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +3 -3
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es5.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es57.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es61.js +11 -4
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +2 -2
- package/dist/es/standards-sdk.es69.js +2 -2
- package/dist/es/standards-sdk.es70.js +1 -1
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es77.js +1 -1
- package/dist/es/standards-sdk.es78.js +10 -3
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +1 -1
- package/dist/es/standards-sdk.es8.js +1 -1
- package/dist/es/standards-sdk.es82.js +1 -1
- package/dist/es/standards-sdk.es84.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/dist/es/standards-sdk.es93.js +1 -1
- package/dist/es/standards-sdk.es98.js +1 -1
- package/package.json +6 -10
|
@@ -1,769 +1,369 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
});
|
|
364
|
-
const adapterConnectionSchema = z.object({
|
|
365
|
-
id: z.string(),
|
|
366
|
-
agentId: z.string(),
|
|
367
|
-
protocol: z.string(),
|
|
368
|
-
endpoint: z.string(),
|
|
369
|
-
status: z.enum(["connected", "disconnected", "error"]),
|
|
370
|
-
metadata: z.record(jsonPrimitiveSchema).optional(),
|
|
371
|
-
createdAt: z.string()
|
|
372
|
-
});
|
|
373
|
-
const uaidConnectionStatusSchema = z.object({
|
|
374
|
-
connected: z.boolean(),
|
|
375
|
-
connection: adapterConnectionSchema.optional(),
|
|
376
|
-
adapter: z.string().optional(),
|
|
377
|
-
agentId: z.string().optional()
|
|
378
|
-
});
|
|
379
|
-
const dashboardStatsResponseSchema = z.object({
|
|
380
|
-
operatorId: z.string().optional(),
|
|
381
|
-
adapters: z.array(
|
|
382
|
-
z.object({
|
|
383
|
-
name: z.string(),
|
|
384
|
-
version: z.string(),
|
|
385
|
-
status: z.string(),
|
|
386
|
-
agentCount: z.number(),
|
|
387
|
-
lastDiscovery: z.string(),
|
|
388
|
-
registryType: z.string(),
|
|
389
|
-
health: z.string()
|
|
390
|
-
})
|
|
391
|
-
).optional(),
|
|
392
|
-
totalAgents: z.number().optional(),
|
|
393
|
-
elasticsearchDocumentCount: z.number().optional(),
|
|
394
|
-
agentsByAdapter: z.record(z.number()).optional(),
|
|
395
|
-
agentsByRegistry: z.record(z.number()).optional(),
|
|
396
|
-
systemInfo: z.object({
|
|
397
|
-
uptime: z.number().optional(),
|
|
398
|
-
version: z.string().optional(),
|
|
399
|
-
network: z.string().optional()
|
|
400
|
-
}).optional()
|
|
401
|
-
});
|
|
402
|
-
const registrationAgentSchema = z.object({
|
|
403
|
-
id: z.string(),
|
|
404
|
-
name: z.string(),
|
|
405
|
-
type: z.string(),
|
|
406
|
-
endpoint: z.string().optional(),
|
|
407
|
-
capabilities: z.array(capabilityValueSchema),
|
|
408
|
-
registry: z.string().optional(),
|
|
409
|
-
protocol: z.string().optional(),
|
|
410
|
-
profile: agentProfileSchema.optional(),
|
|
411
|
-
nativeId: z.string().optional(),
|
|
412
|
-
metadata: z.record(jsonValueSchema).optional()
|
|
413
|
-
});
|
|
414
|
-
const registrationProfileInfoSchema = z.object({
|
|
415
|
-
tId: z.string().nullable(),
|
|
416
|
-
sizeBytes: z.number().optional()
|
|
417
|
-
});
|
|
418
|
-
const profileRegistrySchema = z.object({
|
|
419
|
-
topicId: z.string().optional(),
|
|
420
|
-
sequenceNumber: z.number().optional(),
|
|
421
|
-
profileReference: z.string().optional(),
|
|
422
|
-
profileTopicId: z.string().optional()
|
|
423
|
-
}).passthrough().nullable().optional();
|
|
424
|
-
const additionalRegistryResultSchema = z.object({
|
|
425
|
-
registry: z.string(),
|
|
426
|
-
status: z.enum([
|
|
427
|
-
"created",
|
|
428
|
-
"duplicate",
|
|
429
|
-
"skipped",
|
|
430
|
-
"error",
|
|
431
|
-
"updated",
|
|
432
|
-
"pending"
|
|
433
|
-
]),
|
|
434
|
-
agentId: z.string().nullable().optional(),
|
|
435
|
-
agentUri: z.string().nullable().optional(),
|
|
436
|
-
error: z.string().optional(),
|
|
437
|
-
metadata: z.record(jsonValueSchema).optional(),
|
|
438
|
-
registryKey: z.string().optional(),
|
|
439
|
-
networkId: z.string().optional(),
|
|
440
|
-
networkName: z.string().optional(),
|
|
441
|
-
chainId: z.number().optional(),
|
|
442
|
-
estimatedCredits: z.number().nullable().optional(),
|
|
443
|
-
gasEstimateCredits: z.number().nullable().optional(),
|
|
444
|
-
gasEstimateUsd: z.number().nullable().optional(),
|
|
445
|
-
gasPriceGwei: z.number().nullable().optional(),
|
|
446
|
-
gasLimit: z.number().nullable().optional(),
|
|
447
|
-
creditMode: z.enum(["fixed", "gas"]).nullable().optional(),
|
|
448
|
-
minCredits: z.number().nullable().optional(),
|
|
449
|
-
consumedCredits: z.number().nullable().optional(),
|
|
450
|
-
cost: z.object({
|
|
451
|
-
credits: z.number(),
|
|
452
|
-
usd: z.number(),
|
|
453
|
-
eth: z.number(),
|
|
454
|
-
gasUsedWei: z.string(),
|
|
455
|
-
effectiveGasPriceWei: z.string().nullable().optional(),
|
|
456
|
-
transactions: z.array(
|
|
457
|
-
z.object({
|
|
458
|
-
hash: z.string(),
|
|
459
|
-
gasUsedWei: z.string(),
|
|
460
|
-
effectiveGasPriceWei: z.string().nullable().optional(),
|
|
461
|
-
costWei: z.string()
|
|
462
|
-
})
|
|
463
|
-
).optional()
|
|
464
|
-
}).optional()
|
|
465
|
-
});
|
|
466
|
-
const registrationCreditsSchema = z.object({
|
|
467
|
-
base: z.number(),
|
|
468
|
-
additional: z.number(),
|
|
469
|
-
total: z.number()
|
|
470
|
-
});
|
|
471
|
-
const hcs10RegistrySchema = z.object({
|
|
472
|
-
status: z.string(),
|
|
473
|
-
uaid: z.string().optional(),
|
|
474
|
-
transactionId: z.string().optional(),
|
|
475
|
-
consensusTimestamp: z.string().optional(),
|
|
476
|
-
registryTopicId: z.string().optional(),
|
|
477
|
-
topicSequenceNumber: z.number().optional(),
|
|
478
|
-
payloadHash: z.string().optional(),
|
|
479
|
-
profileReference: z.string().optional(),
|
|
480
|
-
tId: z.string().optional(),
|
|
481
|
-
profileSizeBytes: z.number().optional(),
|
|
482
|
-
error: z.string().optional()
|
|
483
|
-
}).passthrough();
|
|
484
|
-
const additionalRegistryNetworkSchema = z.object({
|
|
485
|
-
key: z.string(),
|
|
486
|
-
registryId: z.string().optional(),
|
|
487
|
-
networkId: z.string().optional(),
|
|
488
|
-
name: z.string().optional(),
|
|
489
|
-
chainId: z.number().optional(),
|
|
490
|
-
label: z.string().optional(),
|
|
491
|
-
estimatedCredits: z.number().nullable().optional(),
|
|
492
|
-
baseCredits: z.number().nullable().optional(),
|
|
493
|
-
gasPortionCredits: z.number().nullable().optional(),
|
|
494
|
-
gasPortionUsd: z.number().nullable().optional(),
|
|
495
|
-
gasEstimateCredits: z.number().nullable().optional(),
|
|
496
|
-
gasEstimateUsd: z.number().nullable().optional(),
|
|
497
|
-
gasPriceGwei: z.number().nullable().optional(),
|
|
498
|
-
gasLimit: z.number().nullable().optional(),
|
|
499
|
-
minCredits: z.number().nullable().optional(),
|
|
500
|
-
creditMode: z.string().nullable().optional()
|
|
501
|
-
}).passthrough();
|
|
502
|
-
const additionalRegistryDescriptorSchema = z.object({
|
|
503
|
-
id: z.string(),
|
|
504
|
-
label: z.string(),
|
|
505
|
-
networks: z.array(additionalRegistryNetworkSchema)
|
|
506
|
-
});
|
|
507
|
-
const additionalRegistryCatalogResponseSchema = z.object({
|
|
508
|
-
registries: z.array(additionalRegistryDescriptorSchema)
|
|
509
|
-
});
|
|
510
|
-
const registerAgentSuccessResponse = z.object({
|
|
511
|
-
success: z.literal(true),
|
|
512
|
-
status: z.enum(["created", "duplicate", "updated"]).optional(),
|
|
513
|
-
uaid: z.string(),
|
|
514
|
-
agentId: z.string(),
|
|
515
|
-
message: z.string().optional(),
|
|
516
|
-
registry: z.string().optional(),
|
|
517
|
-
attemptId: z.string().nullable().optional(),
|
|
518
|
-
agent: registrationAgentSchema,
|
|
519
|
-
openConvAI: z.object({
|
|
520
|
-
compatible: z.boolean(),
|
|
521
|
-
hcs11Profile: agentProfileSchema.optional(),
|
|
522
|
-
bridgeEndpoint: z.string().optional()
|
|
523
|
-
}).optional(),
|
|
524
|
-
profile: registrationProfileInfoSchema.optional(),
|
|
525
|
-
profileRegistry: profileRegistrySchema.nullable().optional(),
|
|
526
|
-
hcs10Registry: hcs10RegistrySchema.nullable().optional(),
|
|
527
|
-
credits: registrationCreditsSchema.optional(),
|
|
528
|
-
additionalRegistries: z.array(additionalRegistryResultSchema).optional(),
|
|
529
|
-
additionalRegistryCredits: z.array(additionalRegistryResultSchema).optional(),
|
|
530
|
-
additionalRegistryCostPerRegistry: z.number().optional()
|
|
531
|
-
});
|
|
532
|
-
const registerAgentPendingResponse = z.object({
|
|
533
|
-
success: z.literal(true),
|
|
534
|
-
status: z.literal("pending"),
|
|
535
|
-
message: z.string(),
|
|
536
|
-
uaid: z.string(),
|
|
537
|
-
agentId: z.string(),
|
|
538
|
-
registry: z.string().optional(),
|
|
539
|
-
attemptId: z.string().nullable(),
|
|
540
|
-
agent: registrationAgentSchema,
|
|
541
|
-
openConvAI: z.object({
|
|
542
|
-
compatible: z.boolean(),
|
|
543
|
-
hcs11Profile: agentProfileSchema.optional(),
|
|
544
|
-
bridgeEndpoint: z.string().optional()
|
|
545
|
-
}).optional(),
|
|
546
|
-
profile: registrationProfileInfoSchema.optional(),
|
|
547
|
-
profileRegistry: profileRegistrySchema.nullable().optional(),
|
|
548
|
-
hcs10Registry: hcs10RegistrySchema.nullable().optional(),
|
|
549
|
-
credits: registrationCreditsSchema,
|
|
550
|
-
additionalRegistries: z.array(additionalRegistryResultSchema),
|
|
551
|
-
additionalRegistryCredits: z.array(additionalRegistryResultSchema).optional(),
|
|
552
|
-
additionalRegistryCostPerRegistry: z.number().optional()
|
|
553
|
-
});
|
|
554
|
-
const registerAgentPartialResponse = z.object({
|
|
555
|
-
success: z.literal(false),
|
|
556
|
-
status: z.literal("partial"),
|
|
557
|
-
message: z.string(),
|
|
558
|
-
uaid: z.string(),
|
|
559
|
-
agentId: z.string(),
|
|
560
|
-
registry: z.string().optional(),
|
|
561
|
-
attemptId: z.string().nullable().optional(),
|
|
562
|
-
agent: registrationAgentSchema,
|
|
563
|
-
openConvAI: z.object({
|
|
564
|
-
compatible: z.boolean(),
|
|
565
|
-
hcs11Profile: agentProfileSchema.optional(),
|
|
566
|
-
bridgeEndpoint: z.string().optional()
|
|
567
|
-
}).optional(),
|
|
568
|
-
profile: registrationProfileInfoSchema.optional(),
|
|
569
|
-
profileRegistry: profileRegistrySchema.nullable().optional(),
|
|
570
|
-
hcs10Registry: hcs10RegistrySchema.nullable().optional(),
|
|
571
|
-
credits: registrationCreditsSchema.optional(),
|
|
572
|
-
additionalRegistries: z.array(additionalRegistryResultSchema).optional(),
|
|
573
|
-
additionalRegistryCredits: z.array(additionalRegistryResultSchema).optional(),
|
|
574
|
-
additionalRegistryCostPerRegistry: z.number().optional(),
|
|
575
|
-
errors: z.array(
|
|
576
|
-
z.object({
|
|
577
|
-
registry: z.string(),
|
|
578
|
-
registryKey: z.string().nullable().optional(),
|
|
579
|
-
error: z.string()
|
|
580
|
-
})
|
|
581
|
-
).min(1)
|
|
582
|
-
});
|
|
583
|
-
const registerAgentResponseSchema = z.union([
|
|
584
|
-
registerAgentSuccessResponse,
|
|
585
|
-
registerAgentPendingResponse,
|
|
586
|
-
registerAgentPartialResponse
|
|
587
|
-
]);
|
|
588
|
-
const registrationProgressAdditionalEntry = z.object({
|
|
589
|
-
registryId: z.string(),
|
|
590
|
-
registryKey: z.string(),
|
|
591
|
-
networkId: z.string().optional(),
|
|
592
|
-
networkName: z.string().optional(),
|
|
593
|
-
chainId: z.number().optional(),
|
|
594
|
-
label: z.string().optional(),
|
|
595
|
-
status: z.enum(["pending", "in_progress", "completed", "failed"]),
|
|
596
|
-
error: z.string().optional(),
|
|
597
|
-
credits: z.number().nullable().optional(),
|
|
598
|
-
agentId: z.string().nullable().optional(),
|
|
599
|
-
agentUri: z.string().nullable().optional(),
|
|
600
|
-
metadata: z.record(jsonValueSchema).optional(),
|
|
601
|
-
lastUpdated: z.string()
|
|
602
|
-
});
|
|
603
|
-
const registrationProgressRecord = z.object({
|
|
604
|
-
attemptId: z.string(),
|
|
605
|
-
mode: z.enum(["register", "update"]),
|
|
606
|
-
status: z.enum(["pending", "partial", "completed", "failed"]),
|
|
607
|
-
uaid: z.string().optional(),
|
|
608
|
-
agentId: z.string().optional(),
|
|
609
|
-
registryNamespace: z.string(),
|
|
610
|
-
accountId: z.string().optional(),
|
|
611
|
-
startedAt: z.string(),
|
|
612
|
-
completedAt: z.string().optional(),
|
|
613
|
-
primary: z.object({
|
|
614
|
-
status: z.enum(["pending", "completed", "failed"]),
|
|
615
|
-
finishedAt: z.string().optional(),
|
|
616
|
-
error: z.string().optional()
|
|
617
|
-
}),
|
|
618
|
-
additionalRegistries: z.record(
|
|
619
|
-
z.string(),
|
|
620
|
-
registrationProgressAdditionalEntry
|
|
621
|
-
),
|
|
622
|
-
errors: z.array(z.string()).optional()
|
|
623
|
-
});
|
|
624
|
-
const registrationProgressResponseSchema = z.object({
|
|
625
|
-
progress: registrationProgressRecord
|
|
626
|
-
});
|
|
627
|
-
const registrationQuoteResponseSchema = z.object({
|
|
628
|
-
accountId: z.string().nullable().optional(),
|
|
629
|
-
registry: z.string().optional(),
|
|
630
|
-
protocol: z.string().optional(),
|
|
631
|
-
requiredCredits: z.number(),
|
|
632
|
-
availableCredits: z.number().nullable().optional(),
|
|
633
|
-
shortfallCredits: z.number().nullable().optional(),
|
|
634
|
-
creditsPerHbar: z.number().nullable().optional(),
|
|
635
|
-
estimatedHbar: z.number().nullable().optional()
|
|
636
|
-
});
|
|
637
|
-
const creditPurchaseResponseSchema = z.object({
|
|
638
|
-
success: z.boolean().optional(),
|
|
639
|
-
purchaser: z.string(),
|
|
640
|
-
credits: z.number(),
|
|
641
|
-
hbarAmount: z.number(),
|
|
642
|
-
transactionId: z.string(),
|
|
643
|
-
consensusTimestamp: z.string().nullable().optional()
|
|
644
|
-
});
|
|
645
|
-
const x402SettlementSchema = z.object({
|
|
646
|
-
success: z.boolean().optional(),
|
|
647
|
-
transaction: z.string().optional(),
|
|
648
|
-
network: z.string().optional(),
|
|
649
|
-
payer: z.string().optional(),
|
|
650
|
-
errorReason: z.string().optional()
|
|
651
|
-
}).strict();
|
|
652
|
-
const x402CreditPurchaseResponseSchema = z.object({
|
|
653
|
-
success: z.boolean(),
|
|
654
|
-
accountId: z.string(),
|
|
655
|
-
creditedCredits: z.number(),
|
|
656
|
-
usdAmount: z.number(),
|
|
657
|
-
balance: z.number(),
|
|
658
|
-
payment: z.object({
|
|
659
|
-
payer: z.string().optional(),
|
|
660
|
-
requirement: z.record(jsonValueSchema).optional(),
|
|
661
|
-
settlement: x402SettlementSchema.optional()
|
|
662
|
-
}).optional()
|
|
663
|
-
});
|
|
664
|
-
const x402MinimumsResponseSchema = z.object({
|
|
665
|
-
minimums: z.record(
|
|
666
|
-
z.object({
|
|
667
|
-
network: z.string().optional(),
|
|
668
|
-
gasLimit: z.number().optional(),
|
|
669
|
-
gasPriceWei: z.string().optional(),
|
|
670
|
-
gasUsd: z.number().optional(),
|
|
671
|
-
minUsd: z.number().optional(),
|
|
672
|
-
ethUsd: z.number().optional(),
|
|
673
|
-
fetchedAt: z.string().optional(),
|
|
674
|
-
source: z.string().optional()
|
|
675
|
-
})
|
|
676
|
-
).optional(),
|
|
677
|
-
creditUnitUsd: z.number().optional()
|
|
678
|
-
});
|
|
679
|
-
const adaptersResponseSchema = z.object({
|
|
680
|
-
adapters: z.array(z.string())
|
|
681
|
-
});
|
|
682
|
-
const adapterChatProfileSchema = z.object({
|
|
683
|
-
supportsChat: z.boolean(),
|
|
684
|
-
delivery: z.string().optional(),
|
|
685
|
-
transport: z.string().optional(),
|
|
686
|
-
streaming: z.boolean().optional(),
|
|
687
|
-
requiresAuth: z.array(z.string()).optional(),
|
|
688
|
-
notes: z.string().optional()
|
|
689
|
-
});
|
|
690
|
-
const adapterCapabilitiesSchema = z.object({
|
|
691
|
-
discovery: z.boolean(),
|
|
692
|
-
routing: z.boolean(),
|
|
693
|
-
communication: z.boolean(),
|
|
694
|
-
translation: z.boolean(),
|
|
695
|
-
protocols: z.array(z.string())
|
|
696
|
-
});
|
|
697
|
-
const adapterDescriptorSchema = z.object({
|
|
698
|
-
id: z.string(),
|
|
699
|
-
name: z.string(),
|
|
700
|
-
version: z.string(),
|
|
701
|
-
author: z.string(),
|
|
702
|
-
description: z.string(),
|
|
703
|
-
supportedProtocols: z.array(z.string()),
|
|
704
|
-
registryType: z.enum(["web2", "web3", "hybrid"]),
|
|
705
|
-
chatProfile: adapterChatProfileSchema.optional(),
|
|
706
|
-
capabilities: adapterCapabilitiesSchema,
|
|
707
|
-
enabled: z.boolean(),
|
|
708
|
-
priority: z.number(),
|
|
709
|
-
status: z.enum(["running", "stopped"])
|
|
710
|
-
});
|
|
711
|
-
const adapterDetailsResponseSchema = z.object({
|
|
712
|
-
adapters: z.array(adapterDescriptorSchema)
|
|
713
|
-
});
|
|
714
|
-
const metadataFacetOptionSchema = z.object({
|
|
715
|
-
value: z.union([z.string(), z.number(), z.boolean()]),
|
|
716
|
-
label: z.string()
|
|
717
|
-
});
|
|
718
|
-
const searchFacetSchema = z.object({
|
|
719
|
-
key: z.string(),
|
|
720
|
-
label: z.string(),
|
|
721
|
-
description: z.string().optional(),
|
|
722
|
-
type: z.enum(["string", "boolean", "number"]),
|
|
723
|
-
adapters: z.array(z.string()).optional(),
|
|
724
|
-
options: z.array(metadataFacetOptionSchema).optional()
|
|
725
|
-
});
|
|
726
|
-
const searchFacetsResponseSchema = z.object({
|
|
727
|
-
facets: z.array(searchFacetSchema)
|
|
728
|
-
});
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { randomBytes, createHash, createCipheriv, createDecipheriv } from "node:crypto";
|
|
3
|
+
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
4
|
+
import { ZodError } from "zod";
|
|
5
|
+
import { DEFAULT_BASE_URL, normaliseBaseUrl, normaliseHeaderName, isBrowserRuntime, DEFAULT_USER_AGENT, JSON_CONTENT_TYPE, createAbortError, isJsonObject, DEFAULT_HISTORY_TOP_UP_HBAR } from "./standards-sdk.es158.js";
|
|
6
|
+
import { RegistryBrokerError, RegistryBrokerParseError } from "./standards-sdk.es137.js";
|
|
7
|
+
class RegistryBrokerClient {
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.encryptionBootstrapPromise = null;
|
|
10
|
+
const {
|
|
11
|
+
baseUrl = DEFAULT_BASE_URL,
|
|
12
|
+
fetchImplementation,
|
|
13
|
+
defaultHeaders,
|
|
14
|
+
apiKey,
|
|
15
|
+
ledgerApiKey,
|
|
16
|
+
registrationAutoTopUp,
|
|
17
|
+
historyAutoTopUp,
|
|
18
|
+
encryption
|
|
19
|
+
} = options;
|
|
20
|
+
this.baseUrl = normaliseBaseUrl(baseUrl);
|
|
21
|
+
this.fetchImpl = fetchImplementation ?? fetch;
|
|
22
|
+
this.defaultHeaders = {
|
|
23
|
+
...defaultHeaders ?? {}
|
|
24
|
+
};
|
|
25
|
+
Object.entries(this.defaultHeaders).forEach(([key, value]) => {
|
|
26
|
+
const headerName = normaliseHeaderName(key);
|
|
27
|
+
if (headerName !== key) {
|
|
28
|
+
delete this.defaultHeaders[key];
|
|
29
|
+
this.defaultHeaders[headerName] = value;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (apiKey) {
|
|
33
|
+
this.defaultHeaders["x-api-key"] = apiKey;
|
|
34
|
+
}
|
|
35
|
+
if (ledgerApiKey) {
|
|
36
|
+
this.defaultHeaders["x-ledger-api-key"] = ledgerApiKey;
|
|
37
|
+
}
|
|
38
|
+
this.registrationAutoTopUp = registrationAutoTopUp;
|
|
39
|
+
this.historyAutoTopUp = historyAutoTopUp;
|
|
40
|
+
this.encryptionOptions = encryption;
|
|
41
|
+
if (this.encryptionOptions) {
|
|
42
|
+
this.encryptionBootstrapPromise = this.initializeEncryptionBootstrap(
|
|
43
|
+
this.encryptionOptions
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
static async initializeAgent(options) {
|
|
48
|
+
const { uaid, ensureEncryptionKey = true, ...clientOptions } = options;
|
|
49
|
+
const client = new RegistryBrokerClient(clientOptions);
|
|
50
|
+
let encryption = null;
|
|
51
|
+
if (ensureEncryptionKey) {
|
|
52
|
+
const ensureOptions = typeof ensureEncryptionKey === "object" ? ensureEncryptionKey : { generateIfMissing: true };
|
|
53
|
+
encryption = await client.encryption.ensureAgentKey({
|
|
54
|
+
uaid,
|
|
55
|
+
...ensureOptions
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return { client, encryption };
|
|
59
|
+
}
|
|
60
|
+
setApiKey(apiKey) {
|
|
61
|
+
this.setDefaultHeader("x-api-key", apiKey);
|
|
62
|
+
}
|
|
63
|
+
setLedgerApiKey(apiKey) {
|
|
64
|
+
this.setDefaultHeader("x-ledger-api-key", apiKey);
|
|
65
|
+
}
|
|
66
|
+
setDefaultHeader(name, value) {
|
|
67
|
+
if (!name || name.trim().length === 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const headerName = normaliseHeaderName(name);
|
|
71
|
+
if (!value || value.trim().length === 0) {
|
|
72
|
+
delete this.defaultHeaders[headerName];
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this.defaultHeaders[headerName] = value.trim();
|
|
76
|
+
}
|
|
77
|
+
getDefaultHeaders() {
|
|
78
|
+
return { ...this.defaultHeaders };
|
|
79
|
+
}
|
|
80
|
+
async encryptionReady() {
|
|
81
|
+
if (!this.encryptionBootstrapPromise) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await this.encryptionBootstrapPromise;
|
|
85
|
+
}
|
|
86
|
+
buildUrl(path) {
|
|
87
|
+
const normalisedPath = path.startsWith("/") ? path : `/${path}`;
|
|
88
|
+
return `${this.baseUrl}${normalisedPath}`;
|
|
89
|
+
}
|
|
90
|
+
async request(path, config) {
|
|
91
|
+
const headers = new Headers();
|
|
92
|
+
Object.entries(this.defaultHeaders).forEach(([key, value]) => {
|
|
93
|
+
headers.set(key, value);
|
|
94
|
+
});
|
|
95
|
+
if (config.headers) {
|
|
96
|
+
Object.entries(config.headers).forEach(([key, value]) => {
|
|
97
|
+
headers.set(key, value);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (!headers.has("accept")) {
|
|
101
|
+
headers.set("accept", "application/json");
|
|
102
|
+
}
|
|
103
|
+
if (!headers.has("user-agent") && !isBrowserRuntime()) {
|
|
104
|
+
headers.set("user-agent", DEFAULT_USER_AGENT);
|
|
105
|
+
}
|
|
106
|
+
const init = {
|
|
107
|
+
method: config.method ?? "GET",
|
|
108
|
+
headers
|
|
109
|
+
};
|
|
110
|
+
if (config.body !== void 0) {
|
|
111
|
+
init.body = JSON.stringify(config.body);
|
|
112
|
+
if (!headers.has("content-type")) {
|
|
113
|
+
headers.set("content-type", "application/json");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const response = await this.fetchImpl(this.buildUrl(path), init);
|
|
117
|
+
if (response.ok) {
|
|
118
|
+
return response;
|
|
119
|
+
}
|
|
120
|
+
const errorBody = await this.extractErrorBody(response);
|
|
121
|
+
throw new RegistryBrokerError("Registry broker request failed", {
|
|
122
|
+
status: response.status,
|
|
123
|
+
statusText: response.statusText,
|
|
124
|
+
body: errorBody
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async requestJson(path, config) {
|
|
128
|
+
const response = await this.request(path, config);
|
|
129
|
+
const contentType = response.headers?.get("content-type") ?? "";
|
|
130
|
+
if (!JSON_CONTENT_TYPE.test(contentType)) {
|
|
131
|
+
const body = await response.text();
|
|
132
|
+
throw new RegistryBrokerParseError(
|
|
133
|
+
"Expected JSON response from registry broker",
|
|
134
|
+
body
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return await response.json();
|
|
138
|
+
}
|
|
139
|
+
async extractErrorBody(response) {
|
|
140
|
+
const contentType = response.headers?.get("content-type") ?? "";
|
|
141
|
+
if (JSON_CONTENT_TYPE.test(contentType)) {
|
|
142
|
+
try {
|
|
143
|
+
return await response.json();
|
|
144
|
+
} catch (error) {
|
|
145
|
+
return { parseError: String(error) };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
return await response.text();
|
|
150
|
+
} catch (error) {
|
|
151
|
+
return { parseError: String(error) };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
parseWithSchema(value, schema, context) {
|
|
155
|
+
try {
|
|
156
|
+
return schema.parse(value);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw new RegistryBrokerParseError(
|
|
159
|
+
`Failed to parse ${context}`,
|
|
160
|
+
error instanceof ZodError || error instanceof Error ? error : String(error),
|
|
161
|
+
value
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async delay(ms, signal) {
|
|
166
|
+
if (ms <= 0) {
|
|
167
|
+
if (signal?.aborted) {
|
|
168
|
+
throw createAbortError();
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
await new Promise((resolve, reject) => {
|
|
173
|
+
const timer = setTimeout(() => {
|
|
174
|
+
if (signal) {
|
|
175
|
+
signal.removeEventListener("abort", onAbort);
|
|
176
|
+
}
|
|
177
|
+
resolve();
|
|
178
|
+
}, ms);
|
|
179
|
+
const onAbort = () => {
|
|
180
|
+
clearTimeout(timer);
|
|
181
|
+
signal?.removeEventListener("abort", onAbort);
|
|
182
|
+
reject(createAbortError());
|
|
183
|
+
};
|
|
184
|
+
if (signal) {
|
|
185
|
+
if (signal.aborted) {
|
|
186
|
+
clearTimeout(timer);
|
|
187
|
+
reject(createAbortError());
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
assertNodeRuntime(feature) {
|
|
195
|
+
if (typeof process === "undefined" || !process.versions?.node) {
|
|
196
|
+
throw new Error(`${feature} is only available in Node.js environments`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
createEphemeralKeyPair() {
|
|
200
|
+
this.assertNodeRuntime("generateEphemeralKeyPair");
|
|
201
|
+
const privateKeyBytes = randomBytes(32);
|
|
202
|
+
const publicKey = secp256k1.getPublicKey(privateKeyBytes, true);
|
|
203
|
+
return {
|
|
204
|
+
privateKey: Buffer.from(privateKeyBytes).toString("hex"),
|
|
205
|
+
publicKey: Buffer.from(publicKey).toString("hex")
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
deriveSharedSecret(options) {
|
|
209
|
+
this.assertNodeRuntime("deriveSharedSecret");
|
|
210
|
+
const privateKey = this.hexToBuffer(options.privateKey);
|
|
211
|
+
const peerPublicKey = this.hexToBuffer(options.peerPublicKey);
|
|
212
|
+
const shared = secp256k1.getSharedSecret(privateKey, peerPublicKey, true);
|
|
213
|
+
return createHash("sha256").update(Buffer.from(shared)).digest();
|
|
214
|
+
}
|
|
215
|
+
buildCipherEnvelope(options) {
|
|
216
|
+
this.assertNodeRuntime("encryptCipherEnvelope");
|
|
217
|
+
const sharedSecret = this.normalizeSharedSecret(options.sharedSecret);
|
|
218
|
+
const iv = randomBytes(12);
|
|
219
|
+
const cipher = createCipheriv("aes-256-gcm", sharedSecret, iv);
|
|
220
|
+
const aadSource = options.associatedData ?? options.sessionId;
|
|
221
|
+
const associatedDataEncoded = aadSource ? Buffer.from(aadSource, "utf8").toString("base64") : void 0;
|
|
222
|
+
if (aadSource) {
|
|
223
|
+
cipher.setAAD(Buffer.from(aadSource, "utf8"));
|
|
224
|
+
}
|
|
225
|
+
const ciphertext = Buffer.concat([
|
|
226
|
+
cipher.update(Buffer.from(options.plaintext, "utf8")),
|
|
227
|
+
cipher.final()
|
|
228
|
+
]);
|
|
229
|
+
const tag = cipher.getAuthTag();
|
|
230
|
+
const payload = Buffer.concat([ciphertext, tag]);
|
|
231
|
+
return {
|
|
232
|
+
algorithm: "aes-256-gcm",
|
|
233
|
+
ciphertext: payload.toString("base64"),
|
|
234
|
+
nonce: iv.toString("base64"),
|
|
235
|
+
associatedData: associatedDataEncoded,
|
|
236
|
+
keyLocator: {
|
|
237
|
+
sessionId: options.sessionId,
|
|
238
|
+
revision: options.revision ?? 1
|
|
239
|
+
},
|
|
240
|
+
recipients: options.recipients.map((recipient) => ({
|
|
241
|
+
...recipient,
|
|
242
|
+
encryptedShare: ""
|
|
243
|
+
}))
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
openCipherEnvelope(options) {
|
|
247
|
+
this.assertNodeRuntime("decryptCipherEnvelope");
|
|
248
|
+
const sharedSecret = this.normalizeSharedSecret(options.sharedSecret);
|
|
249
|
+
const payload = Buffer.from(options.envelope.ciphertext, "base64");
|
|
250
|
+
const nonce = Buffer.from(options.envelope.nonce, "base64");
|
|
251
|
+
const ciphertext = payload.slice(0, payload.length - 16);
|
|
252
|
+
const tag = payload.slice(payload.length - 16);
|
|
253
|
+
const decipher = createDecipheriv("aes-256-gcm", sharedSecret, nonce);
|
|
254
|
+
if (options.envelope.associatedData) {
|
|
255
|
+
decipher.setAAD(Buffer.from(options.envelope.associatedData, "base64"));
|
|
256
|
+
}
|
|
257
|
+
decipher.setAuthTag(tag);
|
|
258
|
+
const plaintext = Buffer.concat([
|
|
259
|
+
decipher.update(ciphertext),
|
|
260
|
+
decipher.final()
|
|
261
|
+
]);
|
|
262
|
+
return plaintext.toString(options.encoding ?? "utf8");
|
|
263
|
+
}
|
|
264
|
+
normalizeSharedSecret(input) {
|
|
265
|
+
if (Buffer.isBuffer(input)) {
|
|
266
|
+
return Buffer.from(input);
|
|
267
|
+
}
|
|
268
|
+
if (input instanceof Uint8Array) {
|
|
269
|
+
return Buffer.from(input);
|
|
270
|
+
}
|
|
271
|
+
if (typeof input === "string") {
|
|
272
|
+
return this.bufferFromString(input);
|
|
273
|
+
}
|
|
274
|
+
throw new Error("Unsupported shared secret input");
|
|
275
|
+
}
|
|
276
|
+
bufferFromString(value) {
|
|
277
|
+
const trimmed = value.trim();
|
|
278
|
+
if (!trimmed) {
|
|
279
|
+
throw new Error("sharedSecret string cannot be empty");
|
|
280
|
+
}
|
|
281
|
+
const normalized = trimmed.startsWith("0x") ? trimmed.slice(2) : trimmed;
|
|
282
|
+
if (/^[0-9a-fA-F]+$/.test(normalized) && normalized.length % 2 === 0) {
|
|
283
|
+
return Buffer.from(normalized, "hex");
|
|
284
|
+
}
|
|
285
|
+
return Buffer.from(trimmed, "base64");
|
|
286
|
+
}
|
|
287
|
+
hexToBuffer(value) {
|
|
288
|
+
const normalized = value.startsWith("0x") ? value.slice(2) : value;
|
|
289
|
+
if (!/^[0-9a-fA-F]+$/.test(normalized) || normalized.length % 2 !== 0) {
|
|
290
|
+
throw new Error("Expected hex-encoded value");
|
|
291
|
+
}
|
|
292
|
+
return Buffer.from(normalized, "hex");
|
|
293
|
+
}
|
|
294
|
+
extractInsufficientCreditsDetails(error) {
|
|
295
|
+
if (!(error instanceof RegistryBrokerError) || error.status !== 402) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const body = error.body;
|
|
299
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
const maybeShortfall = body["shortfallCredits"];
|
|
303
|
+
if (typeof maybeShortfall !== "number" || maybeShortfall <= 0) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
return { shortfallCredits: maybeShortfall };
|
|
307
|
+
}
|
|
308
|
+
extractErrorMessage(body) {
|
|
309
|
+
if (typeof body === "string") {
|
|
310
|
+
return body;
|
|
311
|
+
}
|
|
312
|
+
if (isJsonObject(body) && typeof body.error === "string") {
|
|
313
|
+
return body.error;
|
|
314
|
+
}
|
|
315
|
+
if (isJsonObject(body) && typeof body.message === "string") {
|
|
316
|
+
return body.message;
|
|
317
|
+
}
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
shouldAutoTopUpHistory(payload, error) {
|
|
321
|
+
if (!this.historyAutoTopUp || payload.historyTtlSeconds === void 0) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
if (!(error instanceof RegistryBrokerError)) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
if (error.status !== 402) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
const message = this.extractErrorMessage(error.body);
|
|
331
|
+
if (!message) {
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
const normalised = message.toLowerCase();
|
|
335
|
+
return normalised.includes("history") || normalised.includes("chat history");
|
|
336
|
+
}
|
|
337
|
+
async executeHistoryAutoTopUp(reason) {
|
|
338
|
+
if (!this.historyAutoTopUp) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const hbarAmount = this.historyAutoTopUp.hbarAmount && this.historyAutoTopUp.hbarAmount > 0 ? this.historyAutoTopUp.hbarAmount : DEFAULT_HISTORY_TOP_UP_HBAR;
|
|
342
|
+
await this.purchaseCreditsWithHbar({
|
|
343
|
+
accountId: this.historyAutoTopUp.accountId,
|
|
344
|
+
privateKey: this.historyAutoTopUp.privateKey,
|
|
345
|
+
hbarAmount,
|
|
346
|
+
memo: this.historyAutoTopUp.memo ?? "registry-broker-client:chat-history-topup",
|
|
347
|
+
metadata: {
|
|
348
|
+
purpose: "chat-history",
|
|
349
|
+
reason
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
initializeEncryptionBootstrap(options) {
|
|
354
|
+
return this.bootstrapEncryptionOptions(options).then(() => void 0);
|
|
355
|
+
}
|
|
356
|
+
bootstrapEncryptionOptions(_options) {
|
|
357
|
+
return Promise.resolve(null);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const isPendingRegisterAgentResponse = (response) => response.status === "pending";
|
|
361
|
+
const isPartialRegisterAgentResponse = (response) => response.status === "partial" && response.success === false;
|
|
362
|
+
const isSuccessRegisterAgentResponse = (response) => response.success === true && response.status !== "pending";
|
|
729
363
|
export {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
adapterDetailsResponseSchema,
|
|
735
|
-
adaptersResponseSchema,
|
|
736
|
-
additionalRegistryCatalogResponseSchema,
|
|
737
|
-
chatHistoryCompactionResponseSchema,
|
|
738
|
-
chatHistorySnapshotResponseSchema,
|
|
739
|
-
createSessionResponseSchema,
|
|
740
|
-
creditPurchaseResponseSchema,
|
|
741
|
-
dashboardStatsResponseSchema,
|
|
742
|
-
detectProtocolResponseSchema,
|
|
743
|
-
encryptionHandshakeResponseSchema,
|
|
744
|
-
ledgerChallengeResponseSchema,
|
|
745
|
-
ledgerVerifyResponseSchema,
|
|
746
|
-
metricsSummaryResponseSchema,
|
|
747
|
-
popularResponseSchema,
|
|
748
|
-
protocolsResponseSchema,
|
|
749
|
-
registerAgentResponseSchema,
|
|
750
|
-
registerEncryptionKeyResponseSchema,
|
|
751
|
-
registrationProgressResponseSchema,
|
|
752
|
-
registrationQuoteResponseSchema,
|
|
753
|
-
registriesResponseSchema,
|
|
754
|
-
registrySearchByNamespaceSchema,
|
|
755
|
-
resolveResponseSchema,
|
|
756
|
-
searchFacetsResponseSchema,
|
|
757
|
-
searchResponseSchema,
|
|
758
|
-
searchStatusResponseSchema,
|
|
759
|
-
sendMessageResponseSchema,
|
|
760
|
-
sessionEncryptionStatusResponseSchema,
|
|
761
|
-
statsResponseSchema,
|
|
762
|
-
uaidConnectionStatusSchema,
|
|
763
|
-
uaidValidationResponseSchema,
|
|
764
|
-
vectorSearchResponseSchema,
|
|
765
|
-
websocketStatsResponseSchema,
|
|
766
|
-
x402CreditPurchaseResponseSchema,
|
|
767
|
-
x402MinimumsResponseSchema
|
|
364
|
+
RegistryBrokerClient,
|
|
365
|
+
isPartialRegisterAgentResponse,
|
|
366
|
+
isPendingRegisterAgentResponse,
|
|
367
|
+
isSuccessRegisterAgentResponse
|
|
768
368
|
};
|
|
769
369
|
//# sourceMappingURL=standards-sdk.es136.js.map
|