@hashgraphonline/standards-sdk 0.1.161 → 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 +21 -0
  14. package/dist/cjs/hcs-14/resolvers/registry.d.ts.map +1 -1
  15. package/dist/cjs/hcs-14/resolvers/types.d.ts +40 -5
  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 +23 -1
  22. package/dist/cjs/hcs-14/sdk.d.ts.map +1 -1
  23. package/dist/cjs/standards-sdk.cjs +2 -2
  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 +21 -0
  38. package/dist/es/hcs-14/resolvers/registry.d.ts.map +1 -1
  39. package/dist/es/hcs-14/resolvers/types.d.ts +40 -5
  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 +23 -1
  46. package/dist/es/hcs-14/sdk.d.ts.map +1 -1
  47. package/dist/es/standards-sdk.es.js +89 -86
  48. package/dist/es/standards-sdk.es.js.map +1 -1
  49. package/dist/es/standards-sdk.es100.js +136 -124
  50. package/dist/es/standards-sdk.es100.js.map +1 -1
  51. package/dist/es/standards-sdk.es101.js +138 -42
  52. package/dist/es/standards-sdk.es101.js.map +1 -1
  53. package/dist/es/standards-sdk.es102.js +43 -259
  54. package/dist/es/standards-sdk.es102.js.map +1 -1
  55. package/dist/es/standards-sdk.es103.js +245 -82
  56. package/dist/es/standards-sdk.es103.js.map +1 -1
  57. package/dist/es/standards-sdk.es104.js +50 -49
  58. package/dist/es/standards-sdk.es104.js.map +1 -1
  59. package/dist/es/standards-sdk.es105.js +100 -29
  60. package/dist/es/standards-sdk.es105.js.map +1 -1
  61. package/dist/es/standards-sdk.es106.js +27 -229
  62. package/dist/es/standards-sdk.es106.js.map +1 -1
  63. package/dist/es/standards-sdk.es107.js +228 -109
  64. package/dist/es/standards-sdk.es107.js.map +1 -1
  65. package/dist/es/standards-sdk.es108.js +94 -15
  66. package/dist/es/standards-sdk.es108.js.map +1 -1
  67. package/dist/es/standards-sdk.es109.js +30 -80
  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 -27
  71. package/dist/es/standards-sdk.es110.js.map +1 -1
  72. package/dist/es/standards-sdk.es111.js +27 -248
  73. package/dist/es/standards-sdk.es111.js.map +1 -1
  74. package/dist/es/standards-sdk.es112.js +246 -472
  75. package/dist/es/standards-sdk.es112.js.map +1 -1
  76. package/dist/es/standards-sdk.es113.js +458 -85
  77. package/dist/es/standards-sdk.es113.js.map +1 -1
  78. package/dist/es/standards-sdk.es114.js +96 -151
  79. package/dist/es/standards-sdk.es114.js.map +1 -1
  80. package/dist/es/standards-sdk.es115.js +155 -29
  81. package/dist/es/standards-sdk.es115.js.map +1 -1
  82. package/dist/es/standards-sdk.es116.js +26 -4
  83. package/dist/es/standards-sdk.es116.js.map +1 -1
  84. package/dist/es/standards-sdk.es117.js +10 -140
  85. package/dist/es/standards-sdk.es117.js.map +1 -1
  86. package/dist/es/standards-sdk.es118.js +140 -27
  87. package/dist/es/standards-sdk.es118.js.map +1 -1
  88. package/dist/es/standards-sdk.es119.js +27 -20
  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 +18 -156
  92. package/dist/es/standards-sdk.es120.js.map +1 -1
  93. package/dist/es/standards-sdk.es121.js +148 -191
  94. package/dist/es/standards-sdk.es121.js.map +1 -1
  95. package/dist/es/standards-sdk.es122.js +160 -747
  96. package/dist/es/standards-sdk.es122.js.map +1 -1
  97. package/dist/es/standards-sdk.es123.js +786 -9
  98. package/dist/es/standards-sdk.es123.js.map +1 -1
  99. package/dist/es/standards-sdk.es124.js +13 -567
  100. package/dist/es/standards-sdk.es124.js.map +1 -1
  101. package/dist/es/standards-sdk.es125.js +541 -576
  102. package/dist/es/standards-sdk.es125.js.map +1 -1
  103. package/dist/es/standards-sdk.es126.js +601 -12
  104. package/dist/es/standards-sdk.es126.js.map +1 -1
  105. package/dist/es/standards-sdk.es127.js +13 -2
  106. package/dist/es/standards-sdk.es127.js.map +1 -1
  107. package/dist/es/standards-sdk.es128.js +2 -87
  108. package/dist/es/standards-sdk.es128.js.map +1 -1
  109. package/dist/es/standards-sdk.es129.js +84 -37
  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 +40 -2
  113. package/dist/es/standards-sdk.es130.js.map +1 -1
  114. package/dist/es/standards-sdk.es131.js +2 -235
  115. package/dist/es/standards-sdk.es131.js.map +1 -1
  116. package/dist/es/standards-sdk.es132.js +204 -1109
  117. package/dist/es/standards-sdk.es132.js.map +1 -1
  118. package/dist/es/standards-sdk.es133.js +1059 -225
  119. package/dist/es/standards-sdk.es133.js.map +1 -1
  120. package/dist/es/standards-sdk.es134.js +303 -419
  121. package/dist/es/standards-sdk.es134.js.map +1 -1
  122. package/dist/es/standards-sdk.es135.js +418 -351
  123. package/dist/es/standards-sdk.es135.js.map +1 -1
  124. package/dist/es/standards-sdk.es136.js +347 -1108
  125. package/dist/es/standards-sdk.es136.js.map +1 -1
  126. package/dist/es/standards-sdk.es137.js +1088 -180
  127. package/dist/es/standards-sdk.es137.js.map +1 -1
  128. package/dist/es/standards-sdk.es138.js +153 -1512
  129. package/dist/es/standards-sdk.es138.js.map +1 -1
  130. package/dist/es/standards-sdk.es139.js +1567 -1255
  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 +1255 -17
  134. package/dist/es/standards-sdk.es140.js.map +1 -1
  135. package/dist/es/standards-sdk.es141.js +15 -85
  136. package/dist/es/standards-sdk.es141.js.map +1 -1
  137. package/dist/es/standards-sdk.es142.js +77 -71
  138. package/dist/es/standards-sdk.es142.js.map +1 -1
  139. package/dist/es/standards-sdk.es143.js +79 -891
  140. package/dist/es/standards-sdk.es143.js.map +1 -1
  141. package/dist/es/standards-sdk.es144.js +886 -53
  142. package/dist/es/standards-sdk.es144.js.map +1 -1
  143. package/dist/es/standards-sdk.es145.js +53 -152
  144. package/dist/es/standards-sdk.es145.js.map +1 -1
  145. package/dist/es/standards-sdk.es146.js +159 -7
  146. package/dist/es/standards-sdk.es146.js.map +1 -1
  147. package/dist/es/standards-sdk.es147.js +7 -86
  148. package/dist/es/standards-sdk.es147.js.map +1 -1
  149. package/dist/es/standards-sdk.es148.js +65 -44
  150. package/dist/es/standards-sdk.es148.js.map +1 -1
  151. package/dist/es/standards-sdk.es149.js +65 -30
  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 -34
  155. package/dist/es/standards-sdk.es150.js.map +1 -1
  156. package/dist/es/standards-sdk.es151.js +34 -45
  157. package/dist/es/standards-sdk.es151.js.map +1 -1
  158. package/dist/es/standards-sdk.es152.js +48 -138
  159. package/dist/es/standards-sdk.es152.js.map +1 -1
  160. package/dist/es/standards-sdk.es153.js +133 -37
  161. package/dist/es/standards-sdk.es153.js.map +1 -1
  162. package/dist/es/standards-sdk.es154.js +34 -12474
  163. package/dist/es/standards-sdk.es154.js.map +1 -1
  164. package/dist/es/standards-sdk.es155.js +12477 -12
  165. package/dist/es/standards-sdk.es155.js.map +1 -1
  166. package/dist/es/standards-sdk.es156.js +15 -54
  167. package/dist/es/standards-sdk.es156.js.map +1 -1
  168. package/dist/es/standards-sdk.es157.js +48 -76
  169. package/dist/es/standards-sdk.es157.js.map +1 -1
  170. package/dist/es/standards-sdk.es158.js +69 -66
  171. package/dist/es/standards-sdk.es158.js.map +1 -1
  172. package/dist/es/standards-sdk.es159.js +71 -63
  173. package/dist/es/standards-sdk.es159.js.map +1 -1
  174. package/dist/es/standards-sdk.es16.js +5 -5
  175. package/dist/es/standards-sdk.es160.js +188 -160
  176. package/dist/es/standards-sdk.es160.js.map +1 -1
  177. package/dist/es/standards-sdk.es161.js +65 -314
  178. package/dist/es/standards-sdk.es161.js.map +1 -1
  179. package/dist/es/standards-sdk.es162.js +232 -336
  180. package/dist/es/standards-sdk.es162.js.map +1 -1
  181. package/dist/es/standards-sdk.es163.js +129 -410
  182. package/dist/es/standards-sdk.es163.js.map +1 -1
  183. package/dist/es/standards-sdk.es164.js +200 -209
  184. package/dist/es/standards-sdk.es164.js.map +1 -1
  185. package/dist/es/standards-sdk.es165.js +334 -64
  186. package/dist/es/standards-sdk.es165.js.map +1 -1
  187. package/dist/es/standards-sdk.es166.js +442 -231
  188. package/dist/es/standards-sdk.es166.js.map +1 -1
  189. package/dist/es/standards-sdk.es167.js +317 -158
  190. package/dist/es/standards-sdk.es167.js.map +1 -1
  191. package/dist/es/standards-sdk.es168.js +61 -207
  192. package/dist/es/standards-sdk.es168.js.map +1 -1
  193. package/dist/es/standards-sdk.es169.js +155 -222
  194. package/dist/es/standards-sdk.es169.js.map +1 -1
  195. package/dist/es/standards-sdk.es170.js +178 -75
  196. package/dist/es/standards-sdk.es170.js.map +1 -1
  197. package/dist/es/standards-sdk.es171.js +226 -113
  198. package/dist/es/standards-sdk.es171.js.map +1 -1
  199. package/dist/es/standards-sdk.es172.js +77 -119
  200. package/dist/es/standards-sdk.es172.js.map +1 -1
  201. package/dist/es/standards-sdk.es173.js +103 -162
  202. package/dist/es/standards-sdk.es173.js.map +1 -1
  203. package/dist/es/standards-sdk.es174.js +141 -119
  204. package/dist/es/standards-sdk.es174.js.map +1 -1
  205. package/dist/es/standards-sdk.es175.js +152 -298
  206. package/dist/es/standards-sdk.es175.js.map +1 -1
  207. package/dist/es/standards-sdk.es176.js +120 -240
  208. package/dist/es/standards-sdk.es176.js.map +1 -1
  209. package/dist/es/standards-sdk.es177.js +298 -83
  210. package/dist/es/standards-sdk.es177.js.map +1 -1
  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 +12 -12
  216. package/dist/es/standards-sdk.es19.js +9 -9
  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 +12 -12
  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 +6 -6
  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 +37 -4
  243. package/dist/es/standards-sdk.es58.js.map +1 -1
  244. package/dist/es/standards-sdk.es59.js +17 -10
  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 +2 -1
  248. package/dist/es/standards-sdk.es60.js.map +1 -1
  249. package/dist/es/standards-sdk.es61.js +1 -0
  250. package/dist/es/standards-sdk.es61.js.map +1 -1
  251. package/dist/es/standards-sdk.es62.js +19 -5
  252. package/dist/es/standards-sdk.es62.js.map +1 -1
  253. package/dist/es/standards-sdk.es63.js +214 -153
  254. package/dist/es/standards-sdk.es63.js.map +1 -1
  255. package/dist/es/standards-sdk.es64.js +205 -84
  256. package/dist/es/standards-sdk.es64.js.map +1 -1
  257. package/dist/es/standards-sdk.es65.js +125 -40
  258. package/dist/es/standards-sdk.es65.js.map +1 -1
  259. package/dist/es/standards-sdk.es66.js +41 -261
  260. package/dist/es/standards-sdk.es66.js.map +1 -1
  261. package/dist/es/standards-sdk.es67.js +262 -24
  262. package/dist/es/standards-sdk.es67.js.map +1 -1
  263. package/dist/es/standards-sdk.es68.js +25 -87
  264. package/dist/es/standards-sdk.es68.js.map +1 -1
  265. package/dist/es/standards-sdk.es69.js +95 -3
  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 -100
  269. package/dist/es/standards-sdk.es70.js.map +1 -1
  270. package/dist/es/standards-sdk.es71.js +62 -61
  271. package/dist/es/standards-sdk.es71.js.map +1 -1
  272. package/dist/es/standards-sdk.es72.js +98 -17
  273. package/dist/es/standards-sdk.es72.js.map +1 -1
  274. package/dist/es/standards-sdk.es73.js +19 -77
  275. package/dist/es/standards-sdk.es73.js.map +1 -1
  276. package/dist/es/standards-sdk.es74.js +77 -458
  277. package/dist/es/standards-sdk.es74.js.map +1 -1
  278. package/dist/es/standards-sdk.es75.js +240 -106
  279. package/dist/es/standards-sdk.es75.js.map +1 -1
  280. package/dist/es/standards-sdk.es76.js +286 -170
  281. package/dist/es/standards-sdk.es76.js.map +1 -1
  282. package/dist/es/standards-sdk.es77.js +207 -71
  283. package/dist/es/standards-sdk.es77.js.map +1 -1
  284. package/dist/es/standards-sdk.es78.js +72 -71
  285. package/dist/es/standards-sdk.es78.js.map +1 -1
  286. package/dist/es/standards-sdk.es79.js +71 -143
  287. package/dist/es/standards-sdk.es79.js.map +1 -1
  288. package/dist/es/standards-sdk.es80.js +136 -62
  289. package/dist/es/standards-sdk.es80.js.map +1 -1
  290. package/dist/es/standards-sdk.es81.js +45 -380
  291. package/dist/es/standards-sdk.es81.js.map +1 -1
  292. package/dist/es/standards-sdk.es82.js +130 -222
  293. package/dist/es/standards-sdk.es82.js.map +1 -1
  294. package/dist/es/standards-sdk.es83.js +444 -313
  295. package/dist/es/standards-sdk.es83.js.map +1 -1
  296. package/dist/es/standards-sdk.es84.js +364 -88
  297. package/dist/es/standards-sdk.es84.js.map +1 -1
  298. package/dist/es/standards-sdk.es85.js +89 -125
  299. package/dist/es/standards-sdk.es85.js.map +1 -1
  300. package/dist/es/standards-sdk.es86.js +125 -8
  301. package/dist/es/standards-sdk.es86.js.map +1 -1
  302. package/dist/es/standards-sdk.es87.js +6 -45
  303. package/dist/es/standards-sdk.es87.js.map +1 -1
  304. package/dist/es/standards-sdk.es88.js +44 -98
  305. package/dist/es/standards-sdk.es88.js.map +1 -1
  306. package/dist/es/standards-sdk.es89.js +84 -331
  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 +160 -93
  310. package/dist/es/standards-sdk.es90.js.map +1 -1
  311. package/dist/es/standards-sdk.es91.js +275 -55
  312. package/dist/es/standards-sdk.es91.js.map +1 -1
  313. package/dist/es/standards-sdk.es92.js +55 -43
  314. package/dist/es/standards-sdk.es92.js.map +1 -1
  315. package/dist/es/standards-sdk.es93.js +44 -145
  316. package/dist/es/standards-sdk.es93.js.map +1 -1
  317. package/dist/es/standards-sdk.es94.js +113 -30
  318. package/dist/es/standards-sdk.es94.js.map +1 -1
  319. package/dist/es/standards-sdk.es95.js +59 -22
  320. package/dist/es/standards-sdk.es95.js.map +1 -1
  321. package/dist/es/standards-sdk.es96.js +28 -23
  322. package/dist/es/standards-sdk.es96.js.map +1 -1
  323. package/dist/es/standards-sdk.es97.js +23 -238
  324. package/dist/es/standards-sdk.es97.js.map +1 -1
  325. package/dist/es/standards-sdk.es98.js +225 -267
  326. package/dist/es/standards-sdk.es98.js.map +1 -1
  327. package/dist/es/standards-sdk.es99.js +220 -95
  328. package/dist/es/standards-sdk.es99.js.map +1 -1
  329. package/package.json +5 -1
@@ -1,896 +1,84 @@
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.es139.js";
6
- import { fetchHistorySnapshot, attachDecryptedHistory, registerConversationContextForEncryption, resolveDecryptionContext, decryptHistoryEntryFromContext } from "./standards-sdk.es174.js";
7
- import { createChatApi, createSession, startChat, startConversation, acceptConversation, compactHistory, fetchEncryptionStatus, postEncryptionHandshake, sendMessage, endSession, createPlaintextConversationHandle } from "./standards-sdk.es175.js";
8
- import { EncryptedChatManager } from "./standards-sdk.es176.js";
9
- import { createEncryptionApi, generateEncryptionKeyPair, bootstrapEncryptionOptions } from "./standards-sdk.es167.js";
10
- import { adapters, adaptersDetailed, adapterRegistryCategories, adapterRegistryAdapters, createAdapterRegistryCategory, submitAdapterRegistryAdapter, adapterRegistrySubmissionStatus } from "./standards-sdk.es170.js";
11
- import { resolveUaid, getRegistrationQuote, updateAgent, getRegistrationProgress, waitForRegistrationCompletion, validateUaid, getUaidConnectionStatus, closeUaidConnection, dashboardStats } from "./standards-sdk.es172.js";
12
- import { getRegisterStatus, registerOwnedMoltbookAgent, getVerificationStatus, createVerificationChallenge, getVerificationChallenge, verifyVerificationChallenge, getVerificationOwnership, verifySenderOwnership } from "./standards-sdk.es177.js";
13
- import { purchaseCreditsWithHbar, getX402Minimums, purchaseCreditsWithX402, buyCreditsWithX402 } from "./standards-sdk.es171.js";
14
- import { createLedgerChallenge, verifyLedgerChallenge, authenticateWithLedger, authenticateWithLedgerCredentials } from "./standards-sdk.es173.js";
15
- import { search, stats, registries, getAdditionalRegistries, popularSearches, listProtocols, detectProtocol, registrySearchByNamespace, vectorSearch, searchStatus, websocketStats, metricsSummary, facets } from "./standards-sdk.es168.js";
16
- import { skillsConfig, listSkills, listSkillVersions, listMySkills, getMySkillsList, quoteSkillPublish, publishSkill, getSkillPublishJob, getSkillOwnership, getSkillVoteStatus, setSkillVote, requestSkillVerification, getSkillVerificationStatus } from "./standards-sdk.es166.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.es169.js";
18
- import { RegistryBrokerError, RegistryBrokerParseError } from "./standards-sdk.es140.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");
863
- }
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
- });
879
- }
880
- initializeEncryptionBootstrap(options) {
881
- return this.bootstrapEncryptionOptions(options).then(() => void 0);
1
+ import { optionalImportSync, optionalImport } from "./standards-sdk.es158.js";
2
+ const unsupported = (method) => new Error(`${method} is not supported by the in-memory signer`);
3
+ let cachedSdk = null;
4
+ const loadHashgraphSdk = () => {
5
+ if (cachedSdk) {
6
+ return cachedSdk;
7
+ }
8
+ const resolved = optionalImportSync("@hashgraph/sdk");
9
+ if (resolved) {
10
+ cachedSdk = resolved;
11
+ return resolved;
12
+ }
13
+ const message = "@hashgraph/sdk is required for ledger signing. Install it as a dependency to enable createPrivateKeySigner.";
14
+ throw new Error(message);
15
+ };
16
+ const loadHashgraphSdkAsync = async () => {
17
+ if (cachedSdk) {
18
+ return cachedSdk;
882
19
  }
883
- bootstrapEncryptionOptions(options) {
884
- return bootstrapEncryptionOptions(this, options);
20
+ const resolved = await optionalImport("@hashgraph/sdk");
21
+ if (resolved) {
22
+ cachedSdk = resolved;
23
+ return resolved;
885
24
  }
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";
25
+ const message = "@hashgraph/sdk is required for ledger signing. Install it as a dependency to enable createPrivateKeySigner.";
26
+ throw new Error(message);
27
+ };
28
+ const buildSigner = (sdk, options) => {
29
+ const { AccountId, LedgerId, PrivateKey, SignerSignature } = sdk;
30
+ if (!options.privateKey) {
31
+ throw new Error("privateKey is required to create a ledger signer.");
32
+ }
33
+ if (!options.accountId) {
34
+ throw new Error("accountId is required to create a ledger signer.");
35
+ }
36
+ const accountId = AccountId.fromString(options.accountId);
37
+ const privateKey = PrivateKey.fromString(options.privateKey);
38
+ const ledgerId = LedgerId.fromString(options.network);
39
+ return {
40
+ getLedgerId: () => ledgerId,
41
+ getAccountId: () => accountId,
42
+ getAccountKey: () => privateKey.publicKey,
43
+ getNetwork: () => ({}),
44
+ getMirrorNetwork: () => [],
45
+ sign: async (messages) => Promise.all(
46
+ messages.map(async (message) => {
47
+ const signature = await privateKey.sign(message);
48
+ return new SignerSignature({
49
+ publicKey: privateKey.publicKey,
50
+ signature,
51
+ accountId
52
+ });
53
+ })
54
+ ),
55
+ getAccountBalance: async () => {
56
+ throw unsupported("getAccountBalance");
57
+ },
58
+ getAccountInfo: async () => {
59
+ throw unsupported("getAccountInfo");
60
+ },
61
+ getAccountRecords: async () => {
62
+ throw unsupported("getAccountRecords");
63
+ },
64
+ signTransaction: async (_) => {
65
+ throw unsupported("signTransaction");
66
+ },
67
+ checkTransaction: async (_) => {
68
+ throw unsupported("checkTransaction");
69
+ },
70
+ populateTransaction: async (_) => {
71
+ throw unsupported("populateTransaction");
72
+ },
73
+ call: async (_request) => {
74
+ throw unsupported("call");
75
+ }
76
+ };
77
+ };
78
+ const createPrivateKeySigner = (options) => buildSigner(loadHashgraphSdk(), options);
79
+ const createPrivateKeySignerAsync = async (options) => buildSigner(await loadHashgraphSdkAsync(), options);
890
80
  export {
891
- RegistryBrokerClient,
892
- isPartialRegisterAgentResponse,
893
- isPendingRegisterAgentResponse,
894
- isSuccessRegisterAgentResponse
81
+ createPrivateKeySigner,
82
+ createPrivateKeySignerAsync
895
83
  };
896
84
  //# sourceMappingURL=standards-sdk.es143.js.map