@hashgraphonline/standards-sdk 0.1.160 → 0.1.162

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/dist/cjs/hcs-14/index.d.ts +1 -0
  2. package/dist/cjs/hcs-14/index.d.ts.map +1 -1
  3. package/dist/cjs/hcs-14/resolvers/aid-dns-web-profile.d.ts +1 -0
  4. package/dist/cjs/hcs-14/resolvers/aid-dns-web-profile.d.ts.map +1 -1
  5. package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts +23 -0
  6. package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts.map +1 -0
  7. package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile.d.ts +32 -0
  8. package/dist/cjs/hcs-14/resolvers/ans-dns-web-profile.d.ts.map +1 -0
  9. package/dist/cjs/hcs-14/resolvers/hcs-11-profile.d.ts +1 -0
  10. package/dist/cjs/hcs-14/resolvers/hcs-11-profile.d.ts.map +1 -1
  11. package/dist/cjs/hcs-14/resolvers/hiero.d.ts +1 -0
  12. package/dist/cjs/hcs-14/resolvers/hiero.d.ts.map +1 -1
  13. package/dist/cjs/hcs-14/resolvers/registry.d.ts +39 -1
  14. package/dist/cjs/hcs-14/resolvers/registry.d.ts.map +1 -1
  15. package/dist/cjs/hcs-14/resolvers/types.d.ts +52 -0
  16. package/dist/cjs/hcs-14/resolvers/types.d.ts.map +1 -1
  17. package/dist/cjs/hcs-14/resolvers/uaid-did-resolution-profile.d.ts +1 -0
  18. package/dist/cjs/hcs-14/resolvers/uaid-did-resolution-profile.d.ts.map +1 -1
  19. package/dist/cjs/hcs-14/resolvers/uaid-dns-web-profile.d.ts +1 -0
  20. package/dist/cjs/hcs-14/resolvers/uaid-dns-web-profile.d.ts.map +1 -1
  21. package/dist/cjs/hcs-14/sdk.d.ts +46 -13
  22. package/dist/cjs/hcs-14/sdk.d.ts.map +1 -1
  23. package/dist/cjs/standards-sdk.cjs +3 -3
  24. package/dist/cjs/standards-sdk.cjs.map +1 -1
  25. package/dist/es/hcs-14/index.d.ts +1 -0
  26. package/dist/es/hcs-14/index.d.ts.map +1 -1
  27. package/dist/es/hcs-14/resolvers/aid-dns-web-profile.d.ts +1 -0
  28. package/dist/es/hcs-14/resolvers/aid-dns-web-profile.d.ts.map +1 -1
  29. package/dist/es/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts +23 -0
  30. package/dist/es/hcs-14/resolvers/ans-dns-web-profile-utils.d.ts.map +1 -0
  31. package/dist/es/hcs-14/resolvers/ans-dns-web-profile.d.ts +32 -0
  32. package/dist/es/hcs-14/resolvers/ans-dns-web-profile.d.ts.map +1 -0
  33. package/dist/es/hcs-14/resolvers/hcs-11-profile.d.ts +1 -0
  34. package/dist/es/hcs-14/resolvers/hcs-11-profile.d.ts.map +1 -1
  35. package/dist/es/hcs-14/resolvers/hiero.d.ts +1 -0
  36. package/dist/es/hcs-14/resolvers/hiero.d.ts.map +1 -1
  37. package/dist/es/hcs-14/resolvers/registry.d.ts +39 -1
  38. package/dist/es/hcs-14/resolvers/registry.d.ts.map +1 -1
  39. package/dist/es/hcs-14/resolvers/types.d.ts +52 -0
  40. package/dist/es/hcs-14/resolvers/types.d.ts.map +1 -1
  41. package/dist/es/hcs-14/resolvers/uaid-did-resolution-profile.d.ts +1 -0
  42. package/dist/es/hcs-14/resolvers/uaid-did-resolution-profile.d.ts.map +1 -1
  43. package/dist/es/hcs-14/resolvers/uaid-dns-web-profile.d.ts +1 -0
  44. package/dist/es/hcs-14/resolvers/uaid-dns-web-profile.d.ts.map +1 -1
  45. package/dist/es/hcs-14/sdk.d.ts +46 -13
  46. package/dist/es/hcs-14/sdk.d.ts.map +1 -1
  47. package/dist/es/standards-sdk.es.js +97 -90
  48. package/dist/es/standards-sdk.es.js.map +1 -1
  49. package/dist/es/standards-sdk.es100.js +151 -43
  50. package/dist/es/standards-sdk.es100.js.map +1 -1
  51. package/dist/es/standards-sdk.es101.js +114 -234
  52. package/dist/es/standards-sdk.es101.js.map +1 -1
  53. package/dist/es/standards-sdk.es102.js +43 -96
  54. package/dist/es/standards-sdk.es102.js.map +1 -1
  55. package/dist/es/standards-sdk.es103.js +244 -80
  56. package/dist/es/standards-sdk.es103.js.map +1 -1
  57. package/dist/es/standards-sdk.es104.js +101 -29
  58. package/dist/es/standards-sdk.es104.js.map +1 -1
  59. package/dist/es/standards-sdk.es105.js +94 -225
  60. package/dist/es/standards-sdk.es105.js.map +1 -1
  61. package/dist/es/standards-sdk.es106.js +29 -112
  62. package/dist/es/standards-sdk.es106.js.map +1 -1
  63. package/dist/es/standards-sdk.es107.js +224 -26
  64. package/dist/es/standards-sdk.es107.js.map +1 -1
  65. package/dist/es/standards-sdk.es108.js +109 -80
  66. package/dist/es/standards-sdk.es108.js.map +1 -1
  67. package/dist/es/standards-sdk.es109.js +29 -26
  68. package/dist/es/standards-sdk.es109.js.map +1 -1
  69. package/dist/es/standards-sdk.es11.js +1 -1
  70. package/dist/es/standards-sdk.es110.js +80 -248
  71. package/dist/es/standards-sdk.es110.js.map +1 -1
  72. package/dist/es/standards-sdk.es111.js +28 -475
  73. package/dist/es/standards-sdk.es111.js.map +1 -1
  74. package/dist/es/standards-sdk.es112.js +244 -97
  75. package/dist/es/standards-sdk.es112.js.map +1 -1
  76. package/dist/es/standards-sdk.es113.js +451 -133
  77. package/dist/es/standards-sdk.es113.js.map +1 -1
  78. package/dist/es/standards-sdk.es114.js +98 -27
  79. package/dist/es/standards-sdk.es114.js.map +1 -1
  80. package/dist/es/standards-sdk.es115.js +156 -8
  81. package/dist/es/standards-sdk.es115.js.map +1 -1
  82. package/dist/es/standards-sdk.es116.js +31 -139
  83. package/dist/es/standards-sdk.es116.js.map +1 -1
  84. package/dist/es/standards-sdk.es117.js +10 -27
  85. package/dist/es/standards-sdk.es117.js.map +1 -1
  86. package/dist/es/standards-sdk.es118.js +139 -19
  87. package/dist/es/standards-sdk.es118.js.map +1 -1
  88. package/dist/es/standards-sdk.es119.js +27 -158
  89. package/dist/es/standards-sdk.es119.js.map +1 -1
  90. package/dist/es/standards-sdk.es12.js +1 -1
  91. package/dist/es/standards-sdk.es120.js +16 -197
  92. package/dist/es/standards-sdk.es120.js.map +1 -1
  93. package/dist/es/standards-sdk.es121.js +133 -763
  94. package/dist/es/standards-sdk.es121.js.map +1 -1
  95. package/dist/es/standards-sdk.es122.js +200 -10
  96. package/dist/es/standards-sdk.es122.js.map +1 -1
  97. package/dist/es/standards-sdk.es123.js +762 -539
  98. package/dist/es/standards-sdk.es123.js.map +1 -1
  99. package/dist/es/standards-sdk.es124.js +10 -599
  100. package/dist/es/standards-sdk.es124.js.map +1 -1
  101. package/dist/es/standards-sdk.es125.js +567 -13
  102. package/dist/es/standards-sdk.es125.js.map +1 -1
  103. package/dist/es/standards-sdk.es126.js +602 -2
  104. package/dist/es/standards-sdk.es126.js.map +1 -1
  105. package/dist/es/standards-sdk.es127.js +12 -86
  106. package/dist/es/standards-sdk.es127.js.map +1 -1
  107. package/dist/es/standards-sdk.es128.js +2 -40
  108. package/dist/es/standards-sdk.es128.js.map +1 -1
  109. package/dist/es/standards-sdk.es129.js +87 -2
  110. package/dist/es/standards-sdk.es129.js.map +1 -1
  111. package/dist/es/standards-sdk.es13.js +1 -1
  112. package/dist/es/standards-sdk.es130.js +37 -232
  113. package/dist/es/standards-sdk.es130.js.map +1 -1
  114. package/dist/es/standards-sdk.es131.js +2 -1140
  115. package/dist/es/standards-sdk.es131.js.map +1 -1
  116. package/dist/es/standards-sdk.es132.js +213 -284
  117. package/dist/es/standards-sdk.es132.js.map +1 -1
  118. package/dist/es/standards-sdk.es133.js +1138 -420
  119. package/dist/es/standards-sdk.es133.js.map +1 -1
  120. package/dist/es/standards-sdk.es134.js +301 -350
  121. package/dist/es/standards-sdk.es134.js.map +1 -1
  122. package/dist/es/standards-sdk.es135.js +417 -1111
  123. package/dist/es/standards-sdk.es135.js.map +1 -1
  124. package/dist/es/standards-sdk.es136.js +348 -201
  125. package/dist/es/standards-sdk.es136.js.map +1 -1
  126. package/dist/es/standards-sdk.es137.js +1029 -1480
  127. package/dist/es/standards-sdk.es137.js.map +1 -1
  128. package/dist/es/standards-sdk.es138.js +207 -1254
  129. package/dist/es/standards-sdk.es138.js.map +1 -1
  130. package/dist/es/standards-sdk.es139.js +1564 -14
  131. package/dist/es/standards-sdk.es139.js.map +1 -1
  132. package/dist/es/standards-sdk.es14.js +1 -1
  133. package/dist/es/standards-sdk.es140.js +1253 -85
  134. package/dist/es/standards-sdk.es140.js.map +1 -1
  135. package/dist/es/standards-sdk.es141.js +15 -79
  136. package/dist/es/standards-sdk.es141.js.map +1 -1
  137. package/dist/es/standards-sdk.es142.js +83 -889
  138. package/dist/es/standards-sdk.es142.js.map +1 -1
  139. package/dist/es/standards-sdk.es143.js +73 -52
  140. package/dist/es/standards-sdk.es143.js.map +1 -1
  141. package/dist/es/standards-sdk.es144.js +877 -143
  142. package/dist/es/standards-sdk.es144.js.map +1 -1
  143. package/dist/es/standards-sdk.es145.js +60 -7
  144. package/dist/es/standards-sdk.es145.js.map +1 -1
  145. package/dist/es/standards-sdk.es146.js +138 -65
  146. package/dist/es/standards-sdk.es146.js.map +1 -1
  147. package/dist/es/standards-sdk.es147.js +7 -65
  148. package/dist/es/standards-sdk.es147.js.map +1 -1
  149. package/dist/es/standards-sdk.es148.js +86 -30
  150. package/dist/es/standards-sdk.es148.js.map +1 -1
  151. package/dist/es/standards-sdk.es149.js +65 -34
  152. package/dist/es/standards-sdk.es149.js.map +1 -1
  153. package/dist/es/standards-sdk.es15.js +1 -1
  154. package/dist/es/standards-sdk.es150.js +30 -41
  155. package/dist/es/standards-sdk.es150.js.map +1 -1
  156. package/dist/es/standards-sdk.es151.js +34 -138
  157. package/dist/es/standards-sdk.es151.js.map +1 -1
  158. package/dist/es/standards-sdk.es152.js +48 -42
  159. package/dist/es/standards-sdk.es152.js.map +1 -1
  160. package/dist/es/standards-sdk.es153.js +106 -12450
  161. package/dist/es/standards-sdk.es153.js.map +1 -1
  162. package/dist/es/standards-sdk.es154.js +38 -168
  163. package/dist/es/standards-sdk.es154.js.map +1 -1
  164. package/dist/es/standards-sdk.es155.js +12423 -263
  165. package/dist/es/standards-sdk.es155.js.map +1 -1
  166. package/dist/es/standards-sdk.es156.js +13 -342
  167. package/dist/es/standards-sdk.es156.js.map +1 -1
  168. package/dist/es/standards-sdk.es157.js +55 -452
  169. package/dist/es/standards-sdk.es157.js.map +1 -1
  170. package/dist/es/standards-sdk.es158.js +70 -317
  171. package/dist/es/standards-sdk.es158.js.map +1 -1
  172. package/dist/es/standards-sdk.es159.js +70 -65
  173. package/dist/es/standards-sdk.es159.js.map +1 -1
  174. package/dist/es/standards-sdk.es16.js +4 -4
  175. package/dist/es/standards-sdk.es160.js +197 -14
  176. package/dist/es/standards-sdk.es160.js.map +1 -1
  177. package/dist/es/standards-sdk.es161.js +60 -229
  178. package/dist/es/standards-sdk.es161.js.map +1 -1
  179. package/dist/es/standards-sdk.es162.js +237 -51
  180. package/dist/es/standards-sdk.es162.js.map +1 -1
  181. package/dist/es/standards-sdk.es163.js +160 -72
  182. package/dist/es/standards-sdk.es163.js.map +1 -1
  183. package/dist/es/standards-sdk.es164.js +312 -71
  184. package/dist/es/standards-sdk.es164.js.map +1 -1
  185. package/dist/es/standards-sdk.es165.js +337 -64
  186. package/dist/es/standards-sdk.es165.js.map +1 -1
  187. package/dist/es/standards-sdk.es166.js +436 -155
  188. package/dist/es/standards-sdk.es166.js.map +1 -1
  189. package/dist/es/standards-sdk.es167.js +319 -210
  190. package/dist/es/standards-sdk.es167.js.map +1 -1
  191. package/dist/es/standards-sdk.es168.js +68 -231
  192. package/dist/es/standards-sdk.es168.js.map +1 -1
  193. package/dist/es/standards-sdk.es169.js +154 -101
  194. package/dist/es/standards-sdk.es169.js.map +1 -1
  195. package/dist/es/standards-sdk.es170.js +200 -104
  196. package/dist/es/standards-sdk.es170.js.map +1 -1
  197. package/dist/es/standards-sdk.es171.js +225 -147
  198. package/dist/es/standards-sdk.es171.js.map +1 -1
  199. package/dist/es/standards-sdk.es172.js +100 -166
  200. package/dist/es/standards-sdk.es172.js.map +1 -1
  201. package/dist/es/standards-sdk.es173.js +110 -123
  202. package/dist/es/standards-sdk.es173.js.map +1 -1
  203. package/dist/es/standards-sdk.es174.js +122 -292
  204. package/dist/es/standards-sdk.es174.js.map +1 -1
  205. package/dist/es/standards-sdk.es175.js +166 -240
  206. package/dist/es/standards-sdk.es175.js.map +1 -1
  207. package/dist/es/standards-sdk.es176.js +125 -102
  208. package/dist/es/standards-sdk.es176.js.map +1 -1
  209. package/dist/es/standards-sdk.es177.js +334 -0
  210. package/dist/es/standards-sdk.es177.js.map +1 -0
  211. package/dist/es/standards-sdk.es178.js +262 -0
  212. package/dist/es/standards-sdk.es178.js.map +1 -0
  213. package/dist/es/standards-sdk.es179.js +119 -0
  214. package/dist/es/standards-sdk.es179.js.map +1 -0
  215. package/dist/es/standards-sdk.es18.js +11 -11
  216. package/dist/es/standards-sdk.es19.js +8 -8
  217. package/dist/es/standards-sdk.es2.js +2 -2
  218. package/dist/es/standards-sdk.es20.js +1 -1
  219. package/dist/es/standards-sdk.es21.js +1 -1
  220. package/dist/es/standards-sdk.es22.js +1 -1
  221. package/dist/es/standards-sdk.es23.js +1 -1
  222. package/dist/es/standards-sdk.es24.js +1 -1
  223. package/dist/es/standards-sdk.es25.js +1 -1
  224. package/dist/es/standards-sdk.es26.js +1 -1
  225. package/dist/es/standards-sdk.es27.js +11 -11
  226. package/dist/es/standards-sdk.es30.js +2 -2
  227. package/dist/es/standards-sdk.es31.js +4 -4
  228. package/dist/es/standards-sdk.es32.js +1 -1
  229. package/dist/es/standards-sdk.es35.js +5 -5
  230. package/dist/es/standards-sdk.es36.js +4 -4
  231. package/dist/es/standards-sdk.es37.js +2 -2
  232. package/dist/es/standards-sdk.es38.js +2 -2
  233. package/dist/es/standards-sdk.es39.js +1 -1
  234. package/dist/es/standards-sdk.es4.js +2 -2
  235. package/dist/es/standards-sdk.es40.js +1 -1
  236. package/dist/es/standards-sdk.es41.js +2 -2
  237. package/dist/es/standards-sdk.es46.js +1 -1
  238. package/dist/es/standards-sdk.es5.js +2 -2
  239. package/dist/es/standards-sdk.es51.js +1 -1
  240. package/dist/es/standards-sdk.es53.js +1 -1
  241. package/dist/es/standards-sdk.es56.js +2 -2
  242. package/dist/es/standards-sdk.es58.js +39 -231
  243. package/dist/es/standards-sdk.es58.js.map +1 -1
  244. package/dist/es/standards-sdk.es59.js +328 -35
  245. package/dist/es/standards-sdk.es59.js.map +1 -1
  246. package/dist/es/standards-sdk.es6.js +2 -2
  247. package/dist/es/standards-sdk.es60.js +33 -101
  248. package/dist/es/standards-sdk.es60.js.map +1 -1
  249. package/dist/es/standards-sdk.es61.js +87 -156
  250. package/dist/es/standards-sdk.es61.js.map +1 -1
  251. package/dist/es/standards-sdk.es62.js +126 -153
  252. package/dist/es/standards-sdk.es62.js.map +1 -1
  253. package/dist/es/standards-sdk.es63.js +234 -81
  254. package/dist/es/standards-sdk.es63.js.map +1 -1
  255. package/dist/es/standards-sdk.es64.js +244 -39
  256. package/dist/es/standards-sdk.es64.js.map +1 -1
  257. package/dist/es/standards-sdk.es65.js +122 -247
  258. package/dist/es/standards-sdk.es65.js.map +1 -1
  259. package/dist/es/standards-sdk.es66.js +41 -28
  260. package/dist/es/standards-sdk.es66.js.map +1 -1
  261. package/dist/es/standards-sdk.es67.js +266 -90
  262. package/dist/es/standards-sdk.es67.js.map +1 -1
  263. package/dist/es/standards-sdk.es68.js +33 -3
  264. package/dist/es/standards-sdk.es68.js.map +1 -1
  265. package/dist/es/standards-sdk.es69.js +84 -89
  266. package/dist/es/standards-sdk.es69.js.map +1 -1
  267. package/dist/es/standards-sdk.es7.js +1 -1
  268. package/dist/es/standards-sdk.es70.js +3 -99
  269. package/dist/es/standards-sdk.es70.js.map +1 -1
  270. package/dist/es/standards-sdk.es71.js +99 -17
  271. package/dist/es/standards-sdk.es71.js.map +1 -1
  272. package/dist/es/standards-sdk.es72.js +100 -77
  273. package/dist/es/standards-sdk.es72.js.map +1 -1
  274. package/dist/es/standards-sdk.es73.js +19 -458
  275. package/dist/es/standards-sdk.es73.js.map +1 -1
  276. package/dist/es/standards-sdk.es74.js +77 -324
  277. package/dist/es/standards-sdk.es74.js.map +1 -1
  278. package/dist/es/standards-sdk.es75.js +420 -170
  279. package/dist/es/standards-sdk.es75.js.map +1 -1
  280. package/dist/es/standards-sdk.es76.js +323 -71
  281. package/dist/es/standards-sdk.es76.js.map +1 -1
  282. package/dist/es/standards-sdk.es77.js +208 -71
  283. package/dist/es/standards-sdk.es77.js.map +1 -1
  284. package/dist/es/standards-sdk.es78.js +67 -138
  285. package/dist/es/standards-sdk.es78.js.map +1 -1
  286. package/dist/es/standards-sdk.es79.js +71 -69
  287. package/dist/es/standards-sdk.es79.js.map +1 -1
  288. package/dist/es/standards-sdk.es80.js +132 -393
  289. package/dist/es/standards-sdk.es80.js.map +1 -1
  290. package/dist/es/standards-sdk.es81.js +44 -471
  291. package/dist/es/standards-sdk.es81.js.map +1 -1
  292. package/dist/es/standards-sdk.es82.js +361 -322
  293. package/dist/es/standards-sdk.es82.js.map +1 -1
  294. package/dist/es/standards-sdk.es83.js +495 -88
  295. package/dist/es/standards-sdk.es83.js.map +1 -1
  296. package/dist/es/standards-sdk.es84.js +365 -125
  297. package/dist/es/standards-sdk.es84.js.map +1 -1
  298. package/dist/es/standards-sdk.es85.js +88 -7
  299. package/dist/es/standards-sdk.es85.js.map +1 -1
  300. package/dist/es/standards-sdk.es86.js +125 -47
  301. package/dist/es/standards-sdk.es86.js.map +1 -1
  302. package/dist/es/standards-sdk.es87.js +6 -99
  303. package/dist/es/standards-sdk.es87.js.map +1 -1
  304. package/dist/es/standards-sdk.es88.js +43 -344
  305. package/dist/es/standards-sdk.es88.js.map +1 -1
  306. package/dist/es/standards-sdk.es89.js +73 -253
  307. package/dist/es/standards-sdk.es89.js.map +1 -1
  308. package/dist/es/standards-sdk.es9.js +2 -2
  309. package/dist/es/standards-sdk.es90.js +340 -53
  310. package/dist/es/standards-sdk.es90.js.map +1 -1
  311. package/dist/es/standards-sdk.es91.js +280 -48
  312. package/dist/es/standards-sdk.es91.js.map +1 -1
  313. package/dist/es/standards-sdk.es92.js +54 -143
  314. package/dist/es/standards-sdk.es92.js.map +1 -1
  315. package/dist/es/standards-sdk.es93.js +44 -62
  316. package/dist/es/standards-sdk.es93.js.map +1 -1
  317. package/dist/es/standards-sdk.es94.js +140 -20
  318. package/dist/es/standards-sdk.es94.js.map +1 -1
  319. package/dist/es/standards-sdk.es95.js +65 -23
  320. package/dist/es/standards-sdk.es95.js.map +1 -1
  321. package/dist/es/standards-sdk.es96.js +26 -236
  322. package/dist/es/standards-sdk.es96.js.map +1 -1
  323. package/dist/es/standards-sdk.es97.js +23 -280
  324. package/dist/es/standards-sdk.es97.js.map +1 -1
  325. package/dist/es/standards-sdk.es98.js +229 -146
  326. package/dist/es/standards-sdk.es98.js.map +1 -1
  327. package/dist/es/standards-sdk.es99.js +254 -117
  328. package/dist/es/standards-sdk.es99.js.map +1 -1
  329. package/package.json +8 -1
@@ -1,896 +1,90 @@
1
- import { Buffer } from "buffer";
2
- import { randomBytes, createHash, createCipheriv, createDecipheriv } from "crypto";
3
- import { secp256k1 } from "@noble/curves/secp256k1.js";
4
- import { ZodError } from "zod";
5
- import { agentFeedbackResponseSchema, agentFeedbackIndexResponseSchema, agentFeedbackEntriesIndexResponseSchema, agentFeedbackEligibilityResponseSchema, agentFeedbackSubmissionResponseSchema, registerAgentResponseSchema } from "./standards-sdk.es138.js";
6
- import { fetchHistorySnapshot, attachDecryptedHistory, registerConversationContextForEncryption, resolveDecryptionContext, decryptHistoryEntryFromContext } from "./standards-sdk.es173.js";
7
- import { createChatApi, createSession, startChat, startConversation, acceptConversation, compactHistory, fetchEncryptionStatus, postEncryptionHandshake, sendMessage, endSession, createPlaintextConversationHandle } from "./standards-sdk.es174.js";
8
- import { EncryptedChatManager } from "./standards-sdk.es175.js";
9
- import { createEncryptionApi, generateEncryptionKeyPair, bootstrapEncryptionOptions } from "./standards-sdk.es166.js";
10
- import { adapters, adaptersDetailed, adapterRegistryCategories, adapterRegistryAdapters, createAdapterRegistryCategory, submitAdapterRegistryAdapter, adapterRegistrySubmissionStatus } from "./standards-sdk.es169.js";
11
- import { resolveUaid, getRegistrationQuote, updateAgent, getRegistrationProgress, waitForRegistrationCompletion, validateUaid, getUaidConnectionStatus, closeUaidConnection, dashboardStats } from "./standards-sdk.es171.js";
12
- import { getRegisterStatus, registerOwnedMoltbookAgent, getVerificationStatus, createVerificationChallenge, getVerificationChallenge, verifyVerificationChallenge, getVerificationOwnership, verifySenderOwnership } from "./standards-sdk.es176.js";
13
- import { purchaseCreditsWithHbar, getX402Minimums, purchaseCreditsWithX402, buyCreditsWithX402 } from "./standards-sdk.es170.js";
14
- import { createLedgerChallenge, verifyLedgerChallenge, authenticateWithLedger, authenticateWithLedgerCredentials } from "./standards-sdk.es172.js";
15
- import { search, stats, registries, getAdditionalRegistries, popularSearches, listProtocols, detectProtocol, registrySearchByNamespace, vectorSearch, searchStatus, websocketStats, metricsSummary, facets } from "./standards-sdk.es167.js";
16
- import { skillsConfig, listSkills, listSkillVersions, listMySkills, getMySkillsList, quoteSkillPublish, publishSkill, getSkillPublishJob, getSkillOwnership, getSkillVoteStatus, setSkillVote, requestSkillVerification, getSkillVerificationStatus } from "./standards-sdk.es161.js";
17
- import { DEFAULT_BASE_URL, normaliseBaseUrl, normaliseHeaderName, isBrowserRuntime, DEFAULT_USER_AGENT, JSON_CONTENT_TYPE, serialiseAgentRegistrationRequest, MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS, createAbortError, isJsonObject, DEFAULT_HISTORY_TOP_UP_HBAR } from "./standards-sdk.es168.js";
18
- import { RegistryBrokerError, RegistryBrokerParseError } from "./standards-sdk.es139.js";
19
- class RegistryBrokerClient {
20
- constructor(options = {}) {
21
- this.encryptionBootstrapPromise = null;
22
- this.chatApi = null;
23
- this.encryptedChatManager = null;
24
- this.encryptionApi = null;
25
- this.conversationContexts = /* @__PURE__ */ new Map();
26
- const {
27
- baseUrl = DEFAULT_BASE_URL,
28
- fetchImplementation,
29
- defaultHeaders,
30
- apiKey,
31
- accountId,
32
- ledgerApiKey,
33
- registrationAutoTopUp,
34
- historyAutoTopUp,
35
- encryption
36
- } = options;
37
- this.baseUrl = normaliseBaseUrl(baseUrl);
38
- const resolvedFetch = fetchImplementation ?? (typeof globalThis.fetch === "function" ? globalThis.fetch : null);
39
- if (!resolvedFetch) {
40
- throw new Error(
41
- "A fetch implementation is required for RegistryBrokerClient"
42
- );
43
- }
44
- this.fetchImpl = resolvedFetch;
45
- this.defaultHeaders = {
46
- ...defaultHeaders ?? {}
47
- };
48
- Object.entries(this.defaultHeaders).forEach(([key, value]) => {
49
- const headerName = normaliseHeaderName(key);
50
- if (headerName !== key) {
51
- delete this.defaultHeaders[key];
52
- this.defaultHeaders[headerName] = value;
53
- }
54
- });
55
- const existingLedgerHeader = this.defaultHeaders["x-ledger-api-key"]?.trim();
56
- if (!this.defaultHeaders["x-api-key"] && existingLedgerHeader) {
57
- this.defaultHeaders["x-api-key"] = existingLedgerHeader;
58
- }
59
- if (apiKey) {
60
- this.defaultHeaders["x-api-key"] = apiKey;
61
- }
62
- if (typeof accountId === "string" && accountId.trim().length > 0) {
63
- this.defaultHeaders["x-account-id"] = accountId.trim();
64
- }
65
- if (ledgerApiKey) {
66
- if (!this.defaultHeaders["x-api-key"]) {
67
- this.defaultHeaders["x-api-key"] = ledgerApiKey;
68
- }
69
- }
70
- this.registrationAutoTopUp = registrationAutoTopUp;
71
- this.historyAutoTopUp = historyAutoTopUp;
72
- this.encryptionOptions = encryption;
73
- if (this.encryptionOptions) {
74
- this.encryptionBootstrapPromise = this.initializeEncryptionBootstrap(
75
- this.encryptionOptions
76
- );
77
- }
78
- }
79
- static async initializeAgent(options) {
80
- const { uaid, ensureEncryptionKey = true, ...clientOptions } = options;
81
- const client = new RegistryBrokerClient(clientOptions);
82
- let encryption = null;
83
- if (ensureEncryptionKey) {
84
- const ensureOptions = typeof ensureEncryptionKey === "object" ? ensureEncryptionKey : { generateIfMissing: true };
85
- encryption = await client.encryption.ensureAgentKey({
86
- uaid,
87
- ...ensureOptions
88
- });
89
- }
90
- return { client, encryption };
91
- }
92
- get chat() {
93
- if (this.chatApi) {
94
- return this.chatApi;
95
- }
96
- const api = createChatApi(this, this.getEncryptedChatManager());
97
- this.chatApi = api;
98
- return api;
99
- }
100
- get encryption() {
101
- if (this.encryptionApi) {
102
- return this.encryptionApi;
103
- }
104
- const api = createEncryptionApi(this);
105
- this.encryptionApi = api;
106
- return api;
107
- }
108
- setApiKey(apiKey) {
109
- this.setDefaultHeader("x-api-key", apiKey);
110
- }
111
- setLedgerApiKey(apiKey) {
112
- this.setDefaultHeader("x-api-key", apiKey);
113
- delete this.defaultHeaders["x-ledger-api-key"];
114
- }
115
- setDefaultHeader(name, value) {
116
- if (!name || name.trim().length === 0) {
117
- return;
118
- }
119
- const headerName = normaliseHeaderName(name);
120
- if (!value || value.trim().length === 0) {
121
- delete this.defaultHeaders[headerName];
122
- return;
123
- }
124
- this.defaultHeaders[headerName] = value.trim();
125
- }
126
- getDefaultHeaders() {
127
- return { ...this.defaultHeaders };
128
- }
129
- async encryptionReady() {
130
- if (!this.encryptionBootstrapPromise) {
131
- return;
132
- }
133
- await this.encryptionBootstrapPromise;
134
- }
135
- buildUrl(path) {
136
- const normalisedPath = path.startsWith("/") ? path : `/${path}`;
137
- return `${this.baseUrl}${normalisedPath}`;
138
- }
139
- async request(path, config) {
140
- const headers = new Headers();
141
- Object.entries(this.defaultHeaders).forEach(([key, value]) => {
142
- headers.set(key, value);
143
- });
144
- if (config.headers) {
145
- Object.entries(config.headers).forEach(([key, value]) => {
146
- headers.set(key, value);
147
- });
148
- }
149
- if (!headers.has("accept")) {
150
- headers.set("accept", "application/json");
151
- }
152
- if (!headers.has("user-agent") && !isBrowserRuntime()) {
153
- headers.set("user-agent", DEFAULT_USER_AGENT);
154
- }
155
- const init = {
156
- method: config.method ?? "GET",
157
- headers
158
- };
159
- if (config.body !== void 0) {
160
- init.body = JSON.stringify(config.body);
161
- if (!headers.has("content-type")) {
162
- headers.set("content-type", "application/json");
163
- }
164
- }
165
- const response = await this.fetchImpl(this.buildUrl(path), init);
166
- if (response.ok) {
167
- return response;
168
- }
169
- const errorBody = await this.extractErrorBody(response);
170
- throw new RegistryBrokerError("Registry broker request failed", {
171
- status: response.status,
172
- statusText: response.statusText,
173
- body: errorBody
174
- });
175
- }
176
- async requestJson(path, config) {
177
- const response = await this.request(path, config);
178
- const contentType = response.headers?.get("content-type") ?? "";
179
- if (!JSON_CONTENT_TYPE.test(contentType)) {
180
- const body = await response.text();
181
- throw new RegistryBrokerParseError(
182
- "Expected JSON response from registry broker",
183
- body
184
- );
185
- }
186
- return await response.json();
187
- }
188
- async getAgentFeedback(uaid, options = {}) {
189
- const normalized = uaid.trim();
190
- if (!normalized) {
191
- throw new Error("uaid is required");
192
- }
193
- const query = options.includeRevoked === true ? "?includeRevoked=true" : "";
194
- const raw = await this.requestJson(
195
- `/agents/${encodeURIComponent(normalized)}/feedback${query}`,
196
- { method: "GET" }
197
- );
198
- return this.parseWithSchema(
199
- raw,
200
- agentFeedbackResponseSchema,
201
- "agent feedback response"
202
- );
203
- }
204
- async listAgentFeedbackIndex(options = {}) {
205
- const params = new URLSearchParams();
206
- if (typeof options.page === "number" && Number.isFinite(options.page)) {
207
- params.set("page", String(Math.trunc(options.page)));
208
- }
209
- if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
210
- params.set("limit", String(Math.trunc(options.limit)));
211
- }
212
- if (options.registries?.length) {
213
- params.set("registry", options.registries.join(","));
214
- }
215
- const suffix = params.size > 0 ? `?${params.toString()}` : "";
216
- const raw = await this.requestJson(`/agents/feedback${suffix}`, {
217
- method: "GET"
218
- });
219
- return this.parseWithSchema(
220
- raw,
221
- agentFeedbackIndexResponseSchema,
222
- "agent feedback index response"
223
- );
224
- }
225
- async listAgentFeedbackEntriesIndex(options = {}) {
226
- const params = new URLSearchParams();
227
- if (typeof options.page === "number" && Number.isFinite(options.page)) {
228
- params.set("page", String(Math.trunc(options.page)));
229
- }
230
- if (typeof options.limit === "number" && Number.isFinite(options.limit)) {
231
- params.set("limit", String(Math.trunc(options.limit)));
232
- }
233
- if (options.registries?.length) {
234
- params.set("registry", options.registries.join(","));
235
- }
236
- const suffix = params.size > 0 ? `?${params.toString()}` : "";
237
- const raw = await this.requestJson(
238
- `/agents/feedback/entries${suffix}`,
239
- { method: "GET" }
240
- );
241
- return this.parseWithSchema(
242
- raw,
243
- agentFeedbackEntriesIndexResponseSchema,
244
- "agent feedback entries index response"
245
- );
246
- }
247
- async checkAgentFeedbackEligibility(uaid, payload) {
248
- const normalized = uaid.trim();
249
- if (!normalized) {
250
- throw new Error("uaid is required");
251
- }
252
- const raw = await this.requestJson(
253
- `/agents/${encodeURIComponent(normalized)}/feedback/eligibility`,
254
- {
255
- method: "POST",
256
- body: payload,
257
- headers: { "content-type": "application/json" }
258
- }
259
- );
260
- return this.parseWithSchema(
261
- raw,
262
- agentFeedbackEligibilityResponseSchema,
263
- "agent feedback eligibility response"
264
- );
265
- }
266
- async submitAgentFeedback(uaid, payload) {
267
- const normalized = uaid.trim();
268
- if (!normalized) {
269
- throw new Error("uaid is required");
270
- }
271
- const raw = await this.requestJson(
272
- `/agents/${encodeURIComponent(normalized)}/feedback`,
273
- {
274
- method: "POST",
275
- body: payload,
276
- headers: { "content-type": "application/json" }
277
- }
278
- );
279
- return this.parseWithSchema(
280
- raw,
281
- agentFeedbackSubmissionResponseSchema,
282
- "agent feedback submission response"
283
- );
284
- }
285
- async search(params = {}) {
286
- return search(this, params);
287
- }
288
- async searchErc8004ByAgentId(params) {
289
- const chainId = Math.floor(params.chainId);
290
- if (!Number.isFinite(chainId) || chainId <= 0) {
291
- throw new Error("chainId must be a positive integer");
292
- }
293
- const rawAgentId = typeof params.agentId === "bigint" ? params.agentId.toString() : String(params.agentId);
294
- const agentId = rawAgentId.trim();
295
- if (!agentId) {
296
- throw new Error("agentId is required");
297
- }
298
- const nativeId = `${chainId}:${agentId}`;
299
- return search(this, {
300
- registries: ["erc-8004"],
301
- limit: params.limit ?? 1,
302
- ...typeof params.page === "number" ? { page: params.page } : {},
303
- ...typeof params.sortBy === "string" ? { sortBy: params.sortBy } : {},
304
- ...typeof params.sortOrder === "string" ? { sortOrder: params.sortOrder } : {},
305
- metadata: {
306
- nativeId: [nativeId],
307
- networkKey: [`eip155:${chainId}`]
308
- }
309
- });
310
- }
311
- async stats() {
312
- return stats(this);
313
- }
314
- async registries() {
315
- return registries(this);
316
- }
317
- async getAdditionalRegistries() {
318
- return getAdditionalRegistries(this);
319
- }
320
- async popularSearches() {
321
- return popularSearches(this);
322
- }
323
- async listProtocols() {
324
- return listProtocols(this);
325
- }
326
- async detectProtocol(message) {
327
- return detectProtocol(this, message);
328
- }
329
- async registrySearchByNamespace(registry, query) {
330
- return registrySearchByNamespace(this, registry, query);
331
- }
332
- async vectorSearch(request) {
333
- return vectorSearch(this, request);
334
- }
335
- async searchStatus() {
336
- return searchStatus(this);
337
- }
338
- async websocketStats() {
339
- return websocketStats(this);
340
- }
341
- async metricsSummary() {
342
- return metricsSummary(this);
343
- }
344
- async facets(adapter) {
345
- return facets(this, adapter);
346
- }
347
- async adapters() {
348
- return adapters(this);
349
- }
350
- async skillsConfig() {
351
- return skillsConfig(this);
352
- }
353
- async listSkills(options) {
354
- return listSkills(this, options);
355
- }
356
- async listSkillVersions(params) {
357
- return listSkillVersions(this, params);
358
- }
359
- async listMySkills(params) {
360
- return listMySkills(this, params);
361
- }
362
- async getMySkillsList(params) {
363
- return getMySkillsList(this, params);
364
- }
365
- async quoteSkillPublish(payload) {
366
- return quoteSkillPublish(this, payload);
367
- }
368
- async publishSkill(payload) {
369
- return publishSkill(this, payload);
370
- }
371
- async getSkillPublishJob(jobId, params) {
372
- return getSkillPublishJob(this, jobId, params);
373
- }
374
- async getSkillOwnership(params) {
375
- return getSkillOwnership(this, params);
376
- }
377
- async getSkillVoteStatus(params) {
378
- return getSkillVoteStatus(this, params);
379
- }
380
- async setSkillVote(payload) {
381
- return setSkillVote(this, payload);
382
- }
383
- async requestSkillVerification(payload) {
384
- return requestSkillVerification(this, payload);
385
- }
386
- async getSkillVerificationStatus(params) {
387
- return getSkillVerificationStatus(this, params);
388
- }
389
- async adaptersDetailed() {
390
- return adaptersDetailed(this);
391
- }
392
- async adapterRegistryCategories() {
393
- return adapterRegistryCategories(this);
394
- }
395
- async adapterRegistryAdapters(filters) {
396
- return adapterRegistryAdapters(this, filters);
397
- }
398
- async createAdapterRegistryCategory(payload) {
399
- return createAdapterRegistryCategory(this, payload);
400
- }
401
- async submitAdapterRegistryAdapter(payload) {
402
- return submitAdapterRegistryAdapter(this, payload);
403
- }
404
- async adapterRegistrySubmissionStatus(submissionId) {
405
- return adapterRegistrySubmissionStatus(this, submissionId);
406
- }
407
- async resolveUaid(uaid) {
408
- return resolveUaid(this, uaid);
409
- }
410
- async performRegisterAgent(payload) {
411
- const raw = await this.requestJson("/register", {
412
- method: "POST",
413
- body: serialiseAgentRegistrationRequest(payload),
414
- headers: { "content-type": "application/json" }
415
- });
416
- return this.parseWithSchema(
417
- raw,
418
- registerAgentResponseSchema,
419
- "register agent response"
420
- );
421
- }
422
- calculateHbarAmount(creditsToPurchase, creditsPerHbar) {
423
- if (creditsPerHbar <= 0) {
424
- throw new Error("creditsPerHbar must be positive");
425
- }
426
- if (creditsToPurchase <= 0) {
427
- throw new Error("creditsToPurchase must be positive");
428
- }
429
- const rawHbar = creditsToPurchase / creditsPerHbar;
430
- const tinybars = Math.ceil(rawHbar * 1e8);
431
- return tinybars / 1e8;
432
- }
433
- resolveCreditsToPurchase(shortfallCredits) {
434
- if (!Number.isFinite(shortfallCredits) || shortfallCredits <= 0) {
435
- return 0;
436
- }
437
- return Math.max(
438
- Math.ceil(shortfallCredits),
439
- MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS
440
- );
441
- }
442
- async ensureCreditsForRegistration(payload, autoTopUp) {
443
- const details = autoTopUp ?? null;
444
- if (!details) {
445
- return;
446
- }
447
- if (!details.accountId || !details.accountId.trim()) {
448
- throw new Error("autoTopUp.accountId is required");
449
- }
450
- if (!details.privateKey || !details.privateKey.trim()) {
451
- throw new Error("autoTopUp.privateKey is required");
452
- }
453
- for (let attempt = 0; attempt < 3; attempt += 1) {
454
- const quote = await this.getRegistrationQuote(payload);
455
- const shortfall = quote.shortfallCredits ?? 0;
456
- if (shortfall <= 0) {
457
- return;
458
- }
459
- const creditsToPurchase = this.resolveCreditsToPurchase(shortfall);
460
- if (creditsToPurchase <= 0) {
461
- return;
462
- }
463
- const creditsPerHbar = quote.creditsPerHbar ?? null;
464
- if (!creditsPerHbar || creditsPerHbar <= 0) {
465
- throw new Error("Unable to determine credits per HBAR for auto top-up");
466
- }
467
- const hbarAmount = this.calculateHbarAmount(
468
- creditsToPurchase,
469
- creditsPerHbar
470
- );
471
- await this.purchaseCreditsWithHbar({
472
- accountId: details.accountId.trim(),
473
- privateKey: details.privateKey.trim(),
474
- hbarAmount,
475
- memo: details.memo ?? "Registry Broker auto top-up",
476
- metadata: {
477
- shortfallCredits: shortfall,
478
- requiredCredits: quote.requiredCredits,
479
- purchasedCredits: creditsToPurchase
480
- }
481
- });
482
- }
483
- const finalQuote = await this.getRegistrationQuote(payload);
484
- if ((finalQuote.shortfallCredits ?? 0) > 0) {
485
- throw new Error("Unable to purchase sufficient credits for registration");
486
- }
487
- }
488
- async registerAgent(payload, options) {
489
- const autoTopUp = options?.autoTopUp ?? this.registrationAutoTopUp;
490
- if (!autoTopUp) {
491
- return this.performRegisterAgent(payload);
492
- }
493
- await this.ensureCreditsForRegistration(payload, autoTopUp);
494
- let retried = false;
495
- while (true) {
496
- try {
497
- return await this.performRegisterAgent(payload);
498
- } catch (error) {
499
- const shortfall = this.extractInsufficientCreditsDetails(error);
500
- if (shortfall && !retried) {
501
- await this.ensureCreditsForRegistration(payload, autoTopUp);
502
- retried = true;
503
- continue;
504
- }
505
- throw error;
506
- }
507
- }
508
- }
509
- async getRegistrationQuote(payload) {
510
- return getRegistrationQuote(this, payload);
511
- }
512
- async updateAgent(uaid, payload) {
513
- return updateAgent(this, uaid, payload);
514
- }
515
- async getRegisterStatus(uaid) {
516
- return getRegisterStatus(this, uaid);
517
- }
518
- async registerOwnedMoltbookAgent(uaid, payload) {
519
- return registerOwnedMoltbookAgent(this, uaid, payload);
520
- }
521
- async getRegistrationProgress(attemptId) {
522
- return getRegistrationProgress(this, attemptId);
523
- }
524
- async waitForRegistrationCompletion(attemptId, options) {
525
- return waitForRegistrationCompletion(this, attemptId, options);
526
- }
527
- async validateUaid(uaid) {
528
- return validateUaid(this, uaid);
529
- }
530
- async getUaidConnectionStatus(uaid) {
531
- return getUaidConnectionStatus(this, uaid);
532
- }
533
- async closeUaidConnection(uaid) {
534
- return closeUaidConnection(this, uaid);
535
- }
536
- async dashboardStats() {
537
- return dashboardStats(this);
538
- }
539
- async purchaseCreditsWithHbar(params) {
540
- return purchaseCreditsWithHbar(this, params);
541
- }
542
- async getX402Minimums() {
543
- return getX402Minimums(this);
544
- }
545
- async purchaseCreditsWithX402(params) {
546
- return purchaseCreditsWithX402(this, params);
547
- }
548
- async buyCreditsWithX402(params) {
549
- return buyCreditsWithX402(this, params);
550
- }
551
- async generateEncryptionKeyPair(options = {}) {
552
- return generateEncryptionKeyPair(this, options);
553
- }
554
- async createLedgerChallenge(payload) {
555
- return createLedgerChallenge(this, payload);
556
- }
557
- async verifyLedgerChallenge(payload) {
558
- return verifyLedgerChallenge(this, payload);
559
- }
560
- async authenticateWithLedger(options) {
561
- return authenticateWithLedger(this, options);
562
- }
563
- async authenticateWithLedgerCredentials(options) {
564
- return authenticateWithLedgerCredentials(this, options);
565
- }
566
- async getVerificationStatus(uaid) {
567
- return getVerificationStatus(this, uaid);
568
- }
569
- async createVerificationChallenge(uaid) {
570
- return createVerificationChallenge(this, uaid);
571
- }
572
- async getVerificationChallenge(challengeId) {
573
- return getVerificationChallenge(this, challengeId);
574
- }
575
- async verifyVerificationChallenge(params) {
576
- return verifyVerificationChallenge(this, params);
577
- }
578
- async getVerificationOwnership(uaid) {
579
- return getVerificationOwnership(this, uaid);
580
- }
581
- async verifySenderOwnership(uaid) {
582
- return verifySenderOwnership(this, uaid);
583
- }
584
- async fetchHistorySnapshot(sessionId, options) {
585
- return fetchHistorySnapshot(
586
- this.conversationContexts,
587
- this,
588
- sessionId,
589
- options
590
- );
591
- }
592
- attachDecryptedHistory(sessionId, snapshot, options) {
593
- return attachDecryptedHistory(
594
- this.conversationContexts,
595
- this,
596
- sessionId,
597
- snapshot,
598
- options
599
- );
600
- }
601
- registerConversationContextForEncryption(context) {
602
- registerConversationContextForEncryption(
603
- this.conversationContexts,
604
- context
605
- );
606
- }
607
- resolveDecryptionContext(sessionId, options) {
608
- return resolveDecryptionContext(
609
- this.conversationContexts,
610
- this,
611
- sessionId,
612
- options
613
- );
614
- }
615
- decryptHistoryEntryFromContext(_sessionId, entry, context) {
616
- return decryptHistoryEntryFromContext(this, entry, context);
617
- }
618
- async createSession(payload, allowHistoryAutoTopUp = true) {
619
- return createSession(this, payload, allowHistoryAutoTopUp);
620
- }
621
- async startChat(options) {
622
- return startChat(this, this.getEncryptedChatManager(), options);
623
- }
624
- async startConversation(options) {
625
- return startConversation(this, this.getEncryptedChatManager(), options);
626
- }
627
- async acceptConversation(options) {
628
- return acceptConversation(
629
- this,
630
- this.getEncryptedChatManager(),
631
- options
632
- );
633
- }
634
- compactHistory(payload) {
635
- return compactHistory(this, payload);
636
- }
637
- fetchEncryptionStatus(sessionId) {
638
- return fetchEncryptionStatus(this, sessionId);
639
- }
640
- postEncryptionHandshake(sessionId, payload) {
641
- return postEncryptionHandshake(this, sessionId, payload);
642
- }
643
- sendMessage(payload) {
644
- return sendMessage(this, payload);
645
- }
646
- endSession(sessionId) {
647
- return endSession(this, sessionId);
648
- }
649
- createPlaintextConversationHandle(sessionId, summary, defaultAuth, context) {
650
- return createPlaintextConversationHandle(
651
- this,
652
- sessionId,
653
- summary,
654
- defaultAuth,
655
- context
656
- );
657
- }
658
- getEncryptedChatManager() {
659
- if (this.encryptedChatManager) {
660
- return this.encryptedChatManager;
661
- }
662
- const manager = new EncryptedChatManager(this);
663
- this.encryptedChatManager = manager;
664
- return manager;
665
- }
666
- async extractErrorBody(response) {
667
- const contentType = response.headers?.get("content-type") ?? "";
668
- if (JSON_CONTENT_TYPE.test(contentType)) {
669
- try {
670
- return await response.json();
671
- } catch (error) {
672
- return { parseError: String(error) };
673
- }
674
- }
675
- try {
676
- return await response.text();
677
- } catch (error) {
678
- return { parseError: String(error) };
679
- }
680
- }
681
- parseWithSchema(value, schema, context) {
682
- try {
683
- return schema.parse(value);
684
- } catch (error) {
685
- throw new RegistryBrokerParseError(
686
- `Failed to parse ${context}`,
687
- error instanceof ZodError || error instanceof Error ? error : String(error),
688
- value
689
- );
690
- }
691
- }
692
- async delay(ms, signal) {
693
- if (ms <= 0) {
694
- if (signal?.aborted) {
695
- throw createAbortError();
696
- }
697
- return;
698
- }
699
- await new Promise((resolve, reject) => {
700
- const timer = setTimeout(() => {
701
- if (signal) {
702
- signal.removeEventListener("abort", onAbort);
703
- }
704
- resolve();
705
- }, ms);
706
- const onAbort = () => {
707
- clearTimeout(timer);
708
- signal?.removeEventListener("abort", onAbort);
709
- reject(createAbortError());
710
- };
711
- if (signal) {
712
- if (signal.aborted) {
713
- clearTimeout(timer);
714
- reject(createAbortError());
715
- return;
716
- }
717
- signal.addEventListener("abort", onAbort, { once: true });
718
- }
719
- });
720
- }
721
- assertNodeRuntime(feature) {
722
- if (typeof process === "undefined" || !process.versions?.node) {
723
- throw new Error(`${feature} is only available in Node.js environments`);
724
- }
725
- }
726
- createEphemeralKeyPair() {
727
- this.assertNodeRuntime("generateEphemeralKeyPair");
728
- const privateKeyBytes = randomBytes(32);
729
- const publicKey = secp256k1.getPublicKey(privateKeyBytes, true);
730
- return {
731
- privateKey: Buffer.from(privateKeyBytes).toString("hex"),
732
- publicKey: Buffer.from(publicKey).toString("hex")
733
- };
734
- }
735
- deriveSharedSecret(options) {
736
- this.assertNodeRuntime("deriveSharedSecret");
737
- const privateKey = this.hexToBuffer(options.privateKey);
738
- const peerPublicKey = this.hexToBuffer(options.peerPublicKey);
739
- const shared = secp256k1.getSharedSecret(privateKey, peerPublicKey, true);
740
- return createHash("sha256").update(Buffer.from(shared)).digest();
741
- }
742
- buildCipherEnvelope(options) {
743
- this.assertNodeRuntime("encryptCipherEnvelope");
744
- const sharedSecret = this.normalizeSharedSecret(options.sharedSecret);
745
- const iv = randomBytes(12);
746
- const cipher = createCipheriv("aes-256-gcm", sharedSecret, iv);
747
- const aadSource = options.associatedData ?? options.sessionId;
748
- const associatedDataEncoded = aadSource ? Buffer.from(aadSource, "utf8").toString("base64") : void 0;
749
- if (aadSource) {
750
- cipher.setAAD(Buffer.from(aadSource, "utf8"));
751
- }
752
- const ciphertext = Buffer.concat([
753
- cipher.update(Buffer.from(options.plaintext, "utf8")),
754
- cipher.final()
755
- ]);
756
- const tag = cipher.getAuthTag();
757
- const payload = Buffer.concat([ciphertext, tag]);
758
- return {
759
- algorithm: "aes-256-gcm",
760
- ciphertext: payload.toString("base64"),
761
- nonce: iv.toString("base64"),
762
- associatedData: associatedDataEncoded,
763
- keyLocator: {
764
- sessionId: options.sessionId,
765
- revision: options.revision ?? 1
766
- },
767
- recipients: options.recipients.map((recipient) => ({
768
- ...recipient,
769
- encryptedShare: ""
770
- }))
771
- };
772
- }
773
- openCipherEnvelope(options) {
774
- this.assertNodeRuntime("decryptCipherEnvelope");
775
- const sharedSecret = this.normalizeSharedSecret(options.sharedSecret);
776
- const payload = Buffer.from(options.envelope.ciphertext, "base64");
777
- const nonce = Buffer.from(options.envelope.nonce, "base64");
778
- const ciphertext = payload.slice(0, payload.length - 16);
779
- const tag = payload.slice(payload.length - 16);
780
- const decipher = createDecipheriv("aes-256-gcm", sharedSecret, nonce);
781
- if (options.envelope.associatedData) {
782
- decipher.setAAD(Buffer.from(options.envelope.associatedData, "base64"));
783
- }
784
- decipher.setAuthTag(tag);
785
- const plaintext = Buffer.concat([
786
- decipher.update(ciphertext),
787
- decipher.final()
788
- ]);
789
- return plaintext.toString(options.encoding ?? "utf8");
790
- }
791
- normalizeSharedSecret(input) {
792
- if (Buffer.isBuffer(input)) {
793
- return Buffer.from(input);
794
- }
795
- if (input instanceof Uint8Array) {
796
- return Buffer.from(input);
797
- }
798
- if (typeof input === "string") {
799
- return this.bufferFromString(input);
800
- }
801
- throw new Error("Unsupported shared secret input");
802
- }
803
- bufferFromString(value) {
804
- const trimmed = value.trim();
805
- if (!trimmed) {
806
- throw new Error("sharedSecret string cannot be empty");
807
- }
808
- const normalized = trimmed.startsWith("0x") ? trimmed.slice(2) : trimmed;
809
- if (/^[0-9a-fA-F]+$/.test(normalized) && normalized.length % 2 === 0) {
810
- return Buffer.from(normalized, "hex");
811
- }
812
- return Buffer.from(trimmed, "base64");
813
- }
814
- hexToBuffer(value) {
815
- const normalized = value.startsWith("0x") ? value.slice(2) : value;
816
- if (!/^[0-9a-fA-F]+$/.test(normalized) || normalized.length % 2 !== 0) {
817
- throw new Error("Expected hex-encoded value");
818
- }
819
- return Buffer.from(normalized, "hex");
820
- }
821
- extractInsufficientCreditsDetails(error) {
822
- if (!(error instanceof RegistryBrokerError) || error.status !== 402) {
823
- return null;
824
- }
825
- const body = error.body;
826
- if (!body || typeof body !== "object" || Array.isArray(body)) {
827
- return null;
828
- }
829
- const maybeShortfall = body["shortfallCredits"];
830
- if (typeof maybeShortfall !== "number" || maybeShortfall <= 0) {
831
- return null;
832
- }
833
- return { shortfallCredits: maybeShortfall };
834
- }
835
- extractErrorMessage(body) {
836
- if (typeof body === "string") {
837
- return body;
838
- }
839
- if (isJsonObject(body) && typeof body.error === "string") {
840
- return body.error;
841
- }
842
- if (isJsonObject(body) && typeof body.message === "string") {
843
- return body.message;
844
- }
845
- return void 0;
846
- }
847
- shouldAutoTopUpHistory(payload, error) {
848
- if (!this.historyAutoTopUp || payload.historyTtlSeconds === void 0) {
849
- return false;
850
- }
851
- if (!(error instanceof RegistryBrokerError)) {
852
- return false;
853
- }
854
- if (error.status !== 402) {
855
- return false;
856
- }
857
- const message = this.extractErrorMessage(error.body);
858
- if (!message) {
859
- return true;
860
- }
861
- const normalised = message.toLowerCase();
862
- return normalised.includes("history") || normalised.includes("chat history");
1
+ const normalise = (value) => value.trim().toLowerCase();
2
+ const HEDERA_NETWORK_ALIASES = /* @__PURE__ */ new Map([
3
+ ["hedera:mainnet", { canonical: "hedera:mainnet", hederaNetwork: "mainnet" }],
4
+ ["mainnet", { canonical: "hedera:mainnet", hederaNetwork: "mainnet" }],
5
+ ["hedera-mainnet", { canonical: "hedera:mainnet", hederaNetwork: "mainnet" }],
6
+ ["hedera_mainnet", { canonical: "hedera:mainnet", hederaNetwork: "mainnet" }],
7
+ ["hedera:testnet", { canonical: "hedera:testnet", hederaNetwork: "testnet" }],
8
+ ["testnet", { canonical: "hedera:testnet", hederaNetwork: "testnet" }],
9
+ ["hedera-testnet", { canonical: "hedera:testnet", hederaNetwork: "testnet" }],
10
+ ["hedera_testnet", { canonical: "hedera:testnet", hederaNetwork: "testnet" }]
11
+ ]);
12
+ const EVM_NETWORK_CHAIN_IDS = {
13
+ abstract: 2741,
14
+ "abstract-testnet": 11124,
15
+ base: 8453,
16
+ "base-sepolia": 84532,
17
+ avalanche: 43114,
18
+ "avalanche-fuji": 43113,
19
+ iotex: 4689,
20
+ sei: 1329,
21
+ "sei-testnet": 1328,
22
+ polygon: 137,
23
+ "polygon-amoy": 80002,
24
+ peaq: 3338
25
+ };
26
+ const CHAIN_ID_TO_ALIAS = new Map(
27
+ Object.entries(EVM_NETWORK_CHAIN_IDS).map(([alias, id]) => [id, alias])
28
+ );
29
+ const parseChainId = (value) => {
30
+ if (/^eip155:\d+$/i.test(value)) {
31
+ return Number.parseInt(value.split(":")[1], 10);
863
32
  }
864
- async executeHistoryAutoTopUp(reason) {
865
- if (!this.historyAutoTopUp) {
866
- return;
867
- }
868
- const hbarAmount = this.historyAutoTopUp.hbarAmount && this.historyAutoTopUp.hbarAmount > 0 ? this.historyAutoTopUp.hbarAmount : DEFAULT_HISTORY_TOP_UP_HBAR;
869
- await this.purchaseCreditsWithHbar({
870
- accountId: this.historyAutoTopUp.accountId,
871
- privateKey: this.historyAutoTopUp.privateKey,
872
- hbarAmount,
873
- memo: this.historyAutoTopUp.memo ?? "registry-broker-client:chat-history-topup",
874
- metadata: {
875
- purpose: "chat-history",
876
- reason
877
- }
878
- });
33
+ if (/^\d+$/.test(value)) {
34
+ return Number.parseInt(value, 10);
879
35
  }
880
- initializeEncryptionBootstrap(options) {
881
- return this.bootstrapEncryptionOptions(options).then(() => void 0);
36
+ return void 0;
37
+ };
38
+ const normaliseEvmNetwork = (value) => {
39
+ const trimmed = normalise(value);
40
+ let chainId = parseChainId(trimmed);
41
+ let alias;
42
+ if (chainId === void 0) {
43
+ const mapped = EVM_NETWORK_CHAIN_IDS[trimmed];
44
+ if (mapped !== void 0) {
45
+ chainId = mapped;
46
+ alias = trimmed;
47
+ }
48
+ } else if (CHAIN_ID_TO_ALIAS.has(chainId)) {
49
+ alias = CHAIN_ID_TO_ALIAS.get(chainId);
50
+ }
51
+ if (chainId === void 0) {
52
+ throw new Error(
53
+ 'Unsupported EVM ledger network. Provide an alias like "base-sepolia" or a canonical eip155:<chainId> string.'
54
+ );
55
+ }
56
+ return {
57
+ canonical: `eip155:${chainId}`,
58
+ kind: "evm",
59
+ chainId,
60
+ legacyName: alias
61
+ };
62
+ };
63
+ const normaliseHederaNetwork = (value) => {
64
+ const trimmed = normalise(value);
65
+ const mapping = HEDERA_NETWORK_ALIASES.get(trimmed);
66
+ if (!mapping) {
67
+ throw new Error(
68
+ 'Unsupported Hedera network. Use hedera:mainnet or hedera:testnet (legacy "mainnet"/"testnet" also accepted).'
69
+ );
70
+ }
71
+ return {
72
+ canonical: mapping.canonical,
73
+ kind: "hedera",
74
+ hederaNetwork: mapping.hederaNetwork
75
+ };
76
+ };
77
+ const canonicalizeLedgerNetwork = (network) => {
78
+ if (typeof network !== "string" || network.trim().length === 0) {
79
+ throw new Error("Ledger network is required.");
882
80
  }
883
- bootstrapEncryptionOptions(options) {
884
- return bootstrapEncryptionOptions(this, options);
81
+ const trimmed = normalise(network);
82
+ if (trimmed.startsWith("hedera:") || trimmed.includes("hedera-") || trimmed.includes("hedera_") || trimmed === "mainnet" || trimmed === "testnet") {
83
+ return normaliseHederaNetwork(trimmed);
885
84
  }
886
- }
887
- const isPendingRegisterAgentResponse = (response) => response.status === "pending";
888
- const isPartialRegisterAgentResponse = (response) => response.status === "partial" && response.success === false;
889
- const isSuccessRegisterAgentResponse = (response) => response.success === true && response.status !== "pending";
85
+ return normaliseEvmNetwork(trimmed);
86
+ };
890
87
  export {
891
- RegistryBrokerClient,
892
- isPartialRegisterAgentResponse,
893
- isPendingRegisterAgentResponse,
894
- isSuccessRegisterAgentResponse
88
+ canonicalizeLedgerNetwork
895
89
  };
896
90
  //# sourceMappingURL=standards-sdk.es142.js.map