@hashgraphonline/standards-sdk 0.1.143-feat-solana-register.canary.1c6f446.78 → 0.1.144-feat-solana-register.canary.d5edcec.80

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 (340) hide show
  1. package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
  2. package/dist/cjs/hcs-14/issuers/hiero.d.ts.map +1 -1
  3. package/dist/cjs/index.d.ts.map +1 -1
  4. package/dist/cjs/services/registry-broker/schemas.d.ts +153 -153
  5. package/dist/cjs/standards-sdk.cjs +2 -2
  6. package/dist/cjs/standards-sdk.cjs.map +1 -1
  7. package/dist/cjs/utils/dynamic-import.d.ts +5 -1
  8. package/dist/cjs/utils/dynamic-import.d.ts.map +1 -1
  9. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  10. package/dist/es/hcs-14/issuers/hiero.d.ts.map +1 -1
  11. package/dist/es/index.d.ts.map +1 -1
  12. package/dist/es/services/registry-broker/schemas.d.ts +153 -153
  13. package/dist/es/standards-sdk.es.js +134 -135
  14. package/dist/es/standards-sdk.es.js.map +1 -1
  15. package/dist/es/standards-sdk.es10.js +70 -90
  16. package/dist/es/standards-sdk.es10.js.map +1 -1
  17. package/dist/es/standards-sdk.es100.js +229 -27
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +109 -228
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +15 -94
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +80 -30
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +27 -80
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +136 -25
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +27 -140
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +20 -27
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +156 -18
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es109.js +198 -148
  36. package/dist/es/standards-sdk.es109.js.map +1 -1
  37. package/dist/es/standards-sdk.es11.js +121 -45
  38. package/dist/es/standards-sdk.es11.js.map +1 -1
  39. package/dist/es/standards-sdk.es110.js +747 -167
  40. package/dist/es/standards-sdk.es110.js.map +1 -1
  41. package/dist/es/standards-sdk.es111.js +9 -786
  42. package/dist/es/standards-sdk.es111.js.map +1 -1
  43. package/dist/es/standards-sdk.es112.js +567 -13
  44. package/dist/es/standards-sdk.es112.js.map +1 -1
  45. package/dist/es/standards-sdk.es113.js +576 -541
  46. package/dist/es/standards-sdk.es113.js.map +1 -1
  47. package/dist/es/standards-sdk.es114.js +12 -601
  48. package/dist/es/standards-sdk.es114.js.map +1 -1
  49. package/dist/es/standards-sdk.es115.js +2 -13
  50. package/dist/es/standards-sdk.es115.js.map +1 -1
  51. package/dist/es/standards-sdk.es116.js +87 -2
  52. package/dist/es/standards-sdk.es116.js.map +1 -1
  53. package/dist/es/standards-sdk.es117.js +37 -84
  54. package/dist/es/standards-sdk.es117.js.map +1 -1
  55. package/dist/es/standards-sdk.es118.js +2 -40
  56. package/dist/es/standards-sdk.es118.js.map +1 -1
  57. package/dist/es/standards-sdk.es119.js +231 -2
  58. package/dist/es/standards-sdk.es119.js.map +1 -1
  59. package/dist/es/standards-sdk.es12.js +60 -159
  60. package/dist/es/standards-sdk.es12.js.map +1 -1
  61. package/dist/es/standards-sdk.es120.js +1110 -201
  62. package/dist/es/standards-sdk.es120.js.map +1 -1
  63. package/dist/es/standards-sdk.es121.js +225 -1059
  64. package/dist/es/standards-sdk.es121.js.map +1 -1
  65. package/dist/es/standards-sdk.es122.js +419 -303
  66. package/dist/es/standards-sdk.es122.js.map +1 -1
  67. package/dist/es/standards-sdk.es123.js +351 -418
  68. package/dist/es/standards-sdk.es123.js.map +1 -1
  69. package/dist/es/standards-sdk.es124.js +872 -347
  70. package/dist/es/standards-sdk.es124.js.map +1 -1
  71. package/dist/es/standards-sdk.es125.js +182 -854
  72. package/dist/es/standards-sdk.es125.js.map +1 -1
  73. package/dist/es/standards-sdk.es126.js +1512 -153
  74. package/dist/es/standards-sdk.es126.js.map +1 -1
  75. package/dist/es/standards-sdk.es127.js +157 -1547
  76. package/dist/es/standards-sdk.es127.js.map +1 -1
  77. package/dist/es/standards-sdk.es128.js +192 -162
  78. package/dist/es/standards-sdk.es128.js.map +1 -1
  79. package/dist/es/standards-sdk.es129.js +61 -164
  80. package/dist/es/standards-sdk.es129.js.map +1 -1
  81. package/dist/es/standards-sdk.es13.js +200 -60
  82. package/dist/es/standards-sdk.es13.js.map +1 -1
  83. package/dist/es/standards-sdk.es130.js +102 -85
  84. package/dist/es/standards-sdk.es130.js.map +1 -1
  85. package/dist/es/standards-sdk.es131.js +222 -96
  86. package/dist/es/standards-sdk.es131.js.map +1 -1
  87. package/dist/es/standards-sdk.es132.js +153 -220
  88. package/dist/es/standards-sdk.es132.js.map +1 -1
  89. package/dist/es/standards-sdk.es133.js +104 -162
  90. package/dist/es/standards-sdk.es133.js.map +1 -1
  91. package/dist/es/standards-sdk.es134.js +296 -92
  92. package/dist/es/standards-sdk.es134.js.map +1 -1
  93. package/dist/es/standards-sdk.es135.js +432 -294
  94. package/dist/es/standards-sdk.es135.js.map +1 -1
  95. package/dist/es/standards-sdk.es136.js +14 -461
  96. package/dist/es/standards-sdk.es136.js.map +1 -1
  97. package/dist/es/standards-sdk.es137.js +79 -15
  98. package/dist/es/standards-sdk.es137.js.map +1 -1
  99. package/dist/es/standards-sdk.es138.js +77 -71
  100. package/dist/es/standards-sdk.es138.js.map +1 -1
  101. package/dist/es/standards-sdk.es139.js +152 -80
  102. package/dist/es/standards-sdk.es139.js.map +1 -1
  103. package/dist/es/standards-sdk.es14.js +149 -178
  104. package/dist/es/standards-sdk.es14.js.map +1 -1
  105. package/dist/es/standards-sdk.es140.js +7 -159
  106. package/dist/es/standards-sdk.es140.js.map +1 -1
  107. package/dist/es/standards-sdk.es141.js +86 -7
  108. package/dist/es/standards-sdk.es141.js.map +1 -1
  109. package/dist/es/standards-sdk.es142.js +44 -65
  110. package/dist/es/standards-sdk.es142.js.map +1 -1
  111. package/dist/es/standards-sdk.es143.js +30 -65
  112. package/dist/es/standards-sdk.es143.js.map +1 -1
  113. package/dist/es/standards-sdk.es144.js +34 -30
  114. package/dist/es/standards-sdk.es144.js.map +1 -1
  115. package/dist/es/standards-sdk.es145.js +28 -34
  116. package/dist/es/standards-sdk.es145.js.map +1 -1
  117. package/dist/es/standards-sdk.es146.js +138 -28
  118. package/dist/es/standards-sdk.es146.js.map +1 -1
  119. package/dist/es/standards-sdk.es147.js +37 -133
  120. package/dist/es/standards-sdk.es147.js.map +1 -1
  121. package/dist/es/standards-sdk.es148.js +12280 -33
  122. package/dist/es/standards-sdk.es148.js.map +1 -1
  123. package/dist/es/standards-sdk.es149.js +1 -1
  124. package/dist/es/standards-sdk.es15.js +152 -151
  125. package/dist/es/standards-sdk.es15.js.map +1 -1
  126. package/dist/es/standards-sdk.es150.js +12 -12284
  127. package/dist/es/standards-sdk.es150.js.map +1 -1
  128. package/dist/es/standards-sdk.es151.js +54 -15
  129. package/dist/es/standards-sdk.es151.js.map +1 -1
  130. package/dist/es/standards-sdk.es152.js +72 -160
  131. package/dist/es/standards-sdk.es152.js.map +1 -1
  132. package/dist/es/standards-sdk.es153.js +139 -289
  133. package/dist/es/standards-sdk.es153.js.map +1 -1
  134. package/dist/es/standards-sdk.es154.js +274 -298
  135. package/dist/es/standards-sdk.es154.js.map +1 -1
  136. package/dist/es/standards-sdk.es155.js +262 -369
  137. package/dist/es/standards-sdk.es155.js.map +1 -1
  138. package/dist/es/standards-sdk.es156.js +316 -194
  139. package/dist/es/standards-sdk.es156.js.map +1 -1
  140. package/dist/es/standards-sdk.es157.js +319 -64
  141. package/dist/es/standards-sdk.es157.js.map +1 -1
  142. package/dist/es/standards-sdk.es158.js +69 -49
  143. package/dist/es/standards-sdk.es158.js.map +1 -1
  144. package/dist/es/standards-sdk.es159.js +222 -65
  145. package/dist/es/standards-sdk.es159.js.map +1 -1
  146. package/dist/es/standards-sdk.es16.js +917 -136
  147. package/dist/es/standards-sdk.es16.js.map +1 -1
  148. package/dist/es/standards-sdk.es160.js +223 -218
  149. package/dist/es/standards-sdk.es160.js.map +1 -1
  150. package/dist/es/standards-sdk.es17.js +23 -948
  151. package/dist/es/standards-sdk.es17.js.map +1 -1
  152. package/dist/es/standards-sdk.es18.js +2422 -24
  153. package/dist/es/standards-sdk.es18.js.map +1 -1
  154. package/dist/es/standards-sdk.es19.js +818 -2092
  155. package/dist/es/standards-sdk.es19.js.map +1 -1
  156. package/dist/es/standards-sdk.es2.js +654 -189
  157. package/dist/es/standards-sdk.es2.js.map +1 -1
  158. package/dist/es/standards-sdk.es20.js +205 -1092
  159. package/dist/es/standards-sdk.es20.js.map +1 -1
  160. package/dist/es/standards-sdk.es21.js +858 -221
  161. package/dist/es/standards-sdk.es21.js.map +1 -1
  162. package/dist/es/standards-sdk.es22.js +179 -903
  163. package/dist/es/standards-sdk.es22.js.map +1 -1
  164. package/dist/es/standards-sdk.es23.js +164 -179
  165. package/dist/es/standards-sdk.es23.js.map +1 -1
  166. package/dist/es/standards-sdk.es24.js +62 -118
  167. package/dist/es/standards-sdk.es24.js.map +1 -1
  168. package/dist/es/standards-sdk.es25.js +377 -57
  169. package/dist/es/standards-sdk.es25.js.map +1 -1
  170. package/dist/es/standards-sdk.es26.js +36 -394
  171. package/dist/es/standards-sdk.es26.js.map +1 -1
  172. package/dist/es/standards-sdk.es27.js +901 -50
  173. package/dist/es/standards-sdk.es27.js.map +1 -1
  174. package/dist/es/standards-sdk.es28.js +134 -922
  175. package/dist/es/standards-sdk.es28.js.map +1 -1
  176. package/dist/es/standards-sdk.es29.js +7 -134
  177. package/dist/es/standards-sdk.es29.js.map +1 -1
  178. package/dist/es/standards-sdk.es3.js +63 -680
  179. package/dist/es/standards-sdk.es3.js.map +1 -1
  180. package/dist/es/standards-sdk.es30.js +344 -7
  181. package/dist/es/standards-sdk.es30.js.map +1 -1
  182. package/dist/es/standards-sdk.es31.js +302 -287
  183. package/dist/es/standards-sdk.es31.js.map +1 -1
  184. package/dist/es/standards-sdk.es32.js +94 -322
  185. package/dist/es/standards-sdk.es32.js.map +1 -1
  186. package/dist/es/standards-sdk.es33.js +458 -101
  187. package/dist/es/standards-sdk.es33.js.map +1 -1
  188. package/dist/es/standards-sdk.es34.js +132 -451
  189. package/dist/es/standards-sdk.es34.js.map +1 -1
  190. package/dist/es/standards-sdk.es35.js +216 -130
  191. package/dist/es/standards-sdk.es35.js.map +1 -1
  192. package/dist/es/standards-sdk.es36.js +273 -196
  193. package/dist/es/standards-sdk.es36.js.map +1 -1
  194. package/dist/es/standards-sdk.es37.js +148 -87
  195. package/dist/es/standards-sdk.es37.js.map +1 -1
  196. package/dist/es/standards-sdk.es38.js +183 -320
  197. package/dist/es/standards-sdk.es38.js.map +1 -1
  198. package/dist/es/standards-sdk.es39.js +238 -161
  199. package/dist/es/standards-sdk.es39.js.map +1 -1
  200. package/dist/es/standards-sdk.es4.js +425 -63
  201. package/dist/es/standards-sdk.es4.js.map +1 -1
  202. package/dist/es/standards-sdk.es40.js +136 -254
  203. package/dist/es/standards-sdk.es40.js.map +1 -1
  204. package/dist/es/standards-sdk.es41.js +225 -176
  205. package/dist/es/standards-sdk.es41.js.map +1 -1
  206. package/dist/es/standards-sdk.es42.js +199 -261
  207. package/dist/es/standards-sdk.es42.js.map +1 -1
  208. package/dist/es/standards-sdk.es43.js +237 -199
  209. package/dist/es/standards-sdk.es43.js.map +1 -1
  210. package/dist/es/standards-sdk.es44.js +209 -201
  211. package/dist/es/standards-sdk.es44.js.map +1 -1
  212. package/dist/es/standards-sdk.es45.js +305 -201
  213. package/dist/es/standards-sdk.es45.js.map +1 -1
  214. package/dist/es/standards-sdk.es46.js +371 -261
  215. package/dist/es/standards-sdk.es46.js.map +1 -1
  216. package/dist/es/standards-sdk.es47.js +316 -372
  217. package/dist/es/standards-sdk.es47.js.map +1 -1
  218. package/dist/es/standards-sdk.es48.js +404 -336
  219. package/dist/es/standards-sdk.es48.js.map +1 -1
  220. package/dist/es/standards-sdk.es49.js +83 -449
  221. package/dist/es/standards-sdk.es49.js.map +1 -1
  222. package/dist/es/standards-sdk.es5.js +232 -354
  223. package/dist/es/standards-sdk.es5.js.map +1 -1
  224. package/dist/es/standards-sdk.es50.js +179 -89
  225. package/dist/es/standards-sdk.es50.js.map +1 -1
  226. package/dist/es/standards-sdk.es51.js +231 -165
  227. package/dist/es/standards-sdk.es51.js.map +1 -1
  228. package/dist/es/standards-sdk.es52.js +25 -262
  229. package/dist/es/standards-sdk.es52.js.map +1 -1
  230. package/dist/es/standards-sdk.es53.js +56 -26
  231. package/dist/es/standards-sdk.es53.js.map +1 -1
  232. package/dist/es/standards-sdk.es54.js +12 -57
  233. package/dist/es/standards-sdk.es54.js.map +1 -1
  234. package/dist/es/standards-sdk.es55.js +49 -12
  235. package/dist/es/standards-sdk.es55.js.map +1 -1
  236. package/dist/es/standards-sdk.es56.js +115 -43
  237. package/dist/es/standards-sdk.es56.js.map +1 -1
  238. package/dist/es/standards-sdk.es57.js +42 -115
  239. package/dist/es/standards-sdk.es57.js.map +1 -1
  240. package/dist/es/standards-sdk.es58.js +52 -43
  241. package/dist/es/standards-sdk.es58.js.map +1 -1
  242. package/dist/es/standards-sdk.es59.js +36 -50
  243. package/dist/es/standards-sdk.es59.js.map +1 -1
  244. package/dist/es/standards-sdk.es6.js +125 -246
  245. package/dist/es/standards-sdk.es6.js.map +1 -1
  246. package/dist/es/standards-sdk.es60.js +207 -39
  247. package/dist/es/standards-sdk.es60.js.map +1 -1
  248. package/dist/es/standards-sdk.es61.js +24 -201
  249. package/dist/es/standards-sdk.es61.js.map +1 -1
  250. package/dist/es/standards-sdk.es62.js +87 -25
  251. package/dist/es/standards-sdk.es62.js.map +1 -1
  252. package/dist/es/standards-sdk.es63.js +3 -51
  253. package/dist/es/standards-sdk.es63.js.map +1 -1
  254. package/dist/es/standards-sdk.es64.js +100 -3
  255. package/dist/es/standards-sdk.es64.js.map +1 -1
  256. package/dist/es/standards-sdk.es65.js +61 -62
  257. package/dist/es/standards-sdk.es65.js.map +1 -1
  258. package/dist/es/standards-sdk.es66.js +17 -98
  259. package/dist/es/standards-sdk.es66.js.map +1 -1
  260. package/dist/es/standards-sdk.es67.js +77 -19
  261. package/dist/es/standards-sdk.es67.js.map +1 -1
  262. package/dist/es/standards-sdk.es68.js +458 -77
  263. package/dist/es/standards-sdk.es68.js.map +1 -1
  264. package/dist/es/standards-sdk.es69.js +106 -240
  265. package/dist/es/standards-sdk.es69.js.map +1 -1
  266. package/dist/es/standards-sdk.es7.js +28 -183
  267. package/dist/es/standards-sdk.es7.js.map +1 -1
  268. package/dist/es/standards-sdk.es70.js +170 -286
  269. package/dist/es/standards-sdk.es70.js.map +1 -1
  270. package/dist/es/standards-sdk.es71.js +71 -207
  271. package/dist/es/standards-sdk.es71.js.map +1 -1
  272. package/dist/es/standards-sdk.es72.js +71 -72
  273. package/dist/es/standards-sdk.es72.js.map +1 -1
  274. package/dist/es/standards-sdk.es73.js +143 -71
  275. package/dist/es/standards-sdk.es73.js.map +1 -1
  276. package/dist/es/standards-sdk.es74.js +62 -136
  277. package/dist/es/standards-sdk.es74.js.map +1 -1
  278. package/dist/es/standards-sdk.es75.js +380 -45
  279. package/dist/es/standards-sdk.es75.js.map +1 -1
  280. package/dist/es/standards-sdk.es76.js +222 -130
  281. package/dist/es/standards-sdk.es76.js.map +1 -1
  282. package/dist/es/standards-sdk.es77.js +320 -444
  283. package/dist/es/standards-sdk.es77.js.map +1 -1
  284. package/dist/es/standards-sdk.es78.js +88 -371
  285. package/dist/es/standards-sdk.es78.js.map +1 -1
  286. package/dist/es/standards-sdk.es79.js +125 -89
  287. package/dist/es/standards-sdk.es79.js.map +1 -1
  288. package/dist/es/standards-sdk.es8.js +80 -29
  289. package/dist/es/standards-sdk.es8.js.map +1 -1
  290. package/dist/es/standards-sdk.es80.js +8 -125
  291. package/dist/es/standards-sdk.es80.js.map +1 -1
  292. package/dist/es/standards-sdk.es81.js +45 -6
  293. package/dist/es/standards-sdk.es81.js.map +1 -1
  294. package/dist/es/standards-sdk.es82.js +98 -44
  295. package/dist/es/standards-sdk.es82.js.map +1 -1
  296. package/dist/es/standards-sdk.es83.js +331 -84
  297. package/dist/es/standards-sdk.es83.js.map +1 -1
  298. package/dist/es/standards-sdk.es84.js +93 -160
  299. package/dist/es/standards-sdk.es84.js.map +1 -1
  300. package/dist/es/standards-sdk.es85.js +55 -275
  301. package/dist/es/standards-sdk.es85.js.map +1 -1
  302. package/dist/es/standards-sdk.es86.js +43 -55
  303. package/dist/es/standards-sdk.es86.js.map +1 -1
  304. package/dist/es/standards-sdk.es87.js +145 -44
  305. package/dist/es/standards-sdk.es87.js.map +1 -1
  306. package/dist/es/standards-sdk.es88.js +30 -113
  307. package/dist/es/standards-sdk.es88.js.map +1 -1
  308. package/dist/es/standards-sdk.es89.js +22 -59
  309. package/dist/es/standards-sdk.es89.js.map +1 -1
  310. package/dist/es/standards-sdk.es9.js +104 -80
  311. package/dist/es/standards-sdk.es9.js.map +1 -1
  312. package/dist/es/standards-sdk.es90.js +23 -28
  313. package/dist/es/standards-sdk.es90.js.map +1 -1
  314. package/dist/es/standards-sdk.es91.js +238 -23
  315. package/dist/es/standards-sdk.es91.js.map +1 -1
  316. package/dist/es/standards-sdk.es92.js +267 -225
  317. package/dist/es/standards-sdk.es92.js.map +1 -1
  318. package/dist/es/standards-sdk.es93.js +95 -220
  319. package/dist/es/standards-sdk.es93.js.map +1 -1
  320. package/dist/es/standards-sdk.es94.js +124 -136
  321. package/dist/es/standards-sdk.es94.js.map +1 -1
  322. package/dist/es/standards-sdk.es95.js +42 -138
  323. package/dist/es/standards-sdk.es95.js.map +1 -1
  324. package/dist/es/standards-sdk.es96.js +259 -43
  325. package/dist/es/standards-sdk.es96.js.map +1 -1
  326. package/dist/es/standards-sdk.es97.js +82 -245
  327. package/dist/es/standards-sdk.es97.js.map +1 -1
  328. package/dist/es/standards-sdk.es98.js +49 -50
  329. package/dist/es/standards-sdk.es98.js.map +1 -1
  330. package/dist/es/standards-sdk.es99.js +29 -100
  331. package/dist/es/standards-sdk.es99.js.map +1 -1
  332. package/dist/es/utils/dynamic-import.d.ts +5 -1
  333. package/dist/es/utils/dynamic-import.d.ts.map +1 -1
  334. package/package.json +4 -4
  335. package/dist/cjs/patches/topic-autorenew-patch.d.ts +0 -2
  336. package/dist/cjs/patches/topic-autorenew-patch.d.ts.map +0 -1
  337. package/dist/es/patches/topic-autorenew-patch.d.ts +0 -2
  338. package/dist/es/patches/topic-autorenew-patch.d.ts.map +0 -1
  339. package/dist/es/standards-sdk.es161.js +0 -247
  340. package/dist/es/standards-sdk.es161.js.map +0 -1
@@ -1,907 +1,183 @@
1
- import { Logger } from "./standards-sdk.es106.js";
2
- class ConnectionsManager {
3
- /**
4
- * Creates a new ConnectionsManager instance
5
- */
6
- constructor(options) {
7
- this.connections = /* @__PURE__ */ new Map();
8
- this.pendingRequests = /* @__PURE__ */ new Map();
9
- this.profileCache = /* @__PURE__ */ new Map();
10
- this.filterPendingAccountIds = /* @__PURE__ */ new Set();
11
- const loggerOptions = {
12
- module: "ConnectionsManager",
13
- level: options?.logLevel || "info",
14
- prettyPrint: true,
15
- silent: options?.silent
16
- };
17
- this.logger = Logger.getInstance(loggerOptions);
18
- if (options?.filterPendingAccountIds) {
19
- this.filterPendingAccountIds = new Set(options.filterPendingAccountIds);
20
- }
21
- if (!options.baseClient) {
22
- throw new Error("ConnectionsManager requires a baseClient to operate");
23
- }
24
- this.baseClient = options.baseClient;
25
- }
26
- /**
27
- * Fetches and processes connection data using the configured client
28
- * @param accountId - The account ID to fetch connection data for
29
- * @returns A promise that resolves to an array of Connection objects
30
- */
31
- async fetchConnectionData(accountId) {
32
- try {
33
- const topicInfo = await this.baseClient.retrieveCommunicationTopics(accountId);
34
- const isValidTopicId = (topicId) => {
35
- return Boolean(topicId) && !topicId.includes(":");
36
- };
37
- if (!isValidTopicId(topicInfo?.inboundTopic) || !isValidTopicId(topicInfo?.outboundTopic)) {
38
- this.logger.warn(
39
- "Invalid topic IDs detected in retrieved communication topics"
40
- );
41
- return this.getAllConnections();
42
- }
43
- const [outboundMessagesResult, inboundMessagesResult] = await Promise.all(
44
- [
45
- this.baseClient.getMessages(topicInfo?.outboundTopic),
46
- this.baseClient.getMessages(topicInfo?.inboundTopic)
47
- ]
48
- );
49
- this.processOutboundMessages(
50
- outboundMessagesResult.messages || [],
51
- accountId
52
- );
53
- this.processInboundMessages(inboundMessagesResult.messages || []);
54
- const pendingCount = Array.from(this.connections.values()).filter(
55
- (conn) => conn.status === "pending" || conn.isPending
56
- ).length;
57
- this.logger.debug(
58
- `Processed ${outboundMessagesResult.messages?.length || 0} outbound and ${inboundMessagesResult.messages?.length || 0} inbound messages. Found ${pendingCount} pending connections.`
59
- );
60
- await this.checkTargetInboundTopicsForConfirmations();
61
- await this.checkOutboundRequestsForConfirmations();
62
- await this.fetchProfilesForConnections();
63
- await this.fetchConnectionActivity();
64
- return this.getAllConnections();
65
- } catch (error) {
66
- this.logger.error("Error fetching connection data:", error);
67
- return this.getAllConnections();
68
- }
69
- }
70
- /**
71
- * Checks target agent inbound topics to find confirmations for pending requests
72
- * that might not be visible in our local messages
73
- */
74
- async checkTargetInboundTopicsForConfirmations() {
75
- const pendingConnections = Array.from(this.connections.values()).filter(
76
- (conn) => (conn.isPending || conn.status === "pending") && conn.targetInboundTopicId
77
- );
78
- if (pendingConnections.length === 0) {
79
- return;
80
- }
81
- const pendingRequestsByTarget = /* @__PURE__ */ new Map();
82
- pendingConnections.forEach((conn) => {
83
- if (conn.targetInboundTopicId) {
84
- const requests = pendingRequestsByTarget.get(conn.targetInboundTopicId) || [];
85
- requests.push(conn);
86
- pendingRequestsByTarget.set(conn.targetInboundTopicId, requests);
87
- }
88
- });
89
- const MAX_FETCH_ATTEMPTS = 2;
90
- const FETCH_DELAY_MS = 500;
91
- for (const [
92
- targetInboundTopicId,
93
- requests
94
- ] of pendingRequestsByTarget.entries()) {
95
- for (let attempt = 1; attempt <= MAX_FETCH_ATTEMPTS; attempt++) {
96
- try {
97
- const targetMessagesResult = await this.baseClient.getMessages(targetInboundTopicId);
98
- const targetMessages = targetMessagesResult.messages || [];
99
- let confirmedAny = false;
100
- for (const conn of requests) {
101
- const requestId = conn.connectionRequestId;
102
- if (!requestId) {
103
- continue;
104
- }
105
- const confirmationMsg = targetMessages.find((msg) => {
106
- if (msg.op !== "connection_created" || !msg.connection_topic_id) {
107
- return false;
108
- }
109
- if (msg.connection_id !== requestId) {
110
- return false;
111
- }
112
- if (conn.uniqueRequestKey) {
113
- const keyParts = conn.uniqueRequestKey.split(":");
114
- if (keyParts.length > 1) {
115
- const operatorIdPart = keyParts[1];
116
- if (msg.operator_id && msg.operator_id === operatorIdPart) {
117
- return true;
118
- }
119
- if (msg.connected_account_id === conn.targetAccountId) {
120
- return true;
121
- }
122
- }
123
- }
124
- return true;
125
- });
126
- if (confirmationMsg?.connection_topic_id) {
127
- confirmedAny = true;
128
- const connectionTopicId = confirmationMsg.connection_topic_id;
129
- let pendingKey = conn.uniqueRequestKey;
130
- const newConnection = {
131
- connectionTopicId,
132
- targetAccountId: conn.targetAccountId,
133
- targetAgentName: conn.targetAgentName,
134
- targetInboundTopicId: conn.targetInboundTopicId,
135
- status: "established",
136
- isPending: false,
137
- needsConfirmation: false,
138
- created: new Date(confirmationMsg.created || conn.created),
139
- profileInfo: conn.profileInfo,
140
- connectionRequestId: requestId,
141
- uniqueRequestKey: conn.uniqueRequestKey,
142
- originTopicId: conn.originTopicId,
143
- processed: conn.processed,
144
- memo: conn.memo
145
- };
146
- this.connections.set(connectionTopicId, newConnection);
147
- if (pendingKey) {
148
- this.connections.delete(pendingKey);
149
- }
150
- this.logger.debug(
151
- `Confirmed connection in target inbound topic: ${connectionTopicId}`
152
- );
153
- }
154
- }
155
- if (confirmedAny || attempt === MAX_FETCH_ATTEMPTS) {
156
- break;
157
- }
158
- await new Promise((resolve) => setTimeout(resolve, FETCH_DELAY_MS));
159
- } catch (error) {
160
- this.logger.debug(
161
- `Error fetching target inbound topic ${targetInboundTopicId}:`,
162
- error
163
- );
164
- if (attempt === MAX_FETCH_ATTEMPTS) {
165
- break;
166
- }
167
- await new Promise((resolve) => setTimeout(resolve, FETCH_DELAY_MS));
168
- }
169
- }
170
- }
171
- }
172
- /**
173
- * Checks target agents' inbound topics for confirmations of our outbound connection requests
174
- * This complements checkTargetInboundTopicsForConfirmations by looking for confirmations
175
- * that might have been sent to the target agent's inbound topic rather than our own
176
- */
177
- async checkOutboundRequestsForConfirmations() {
178
- const allConnections = Array.from(this.connections.values());
179
- this.logger.info(`Total connections in map: ${allConnections.length}`);
180
- const pendingByStatus = allConnections.filter(
181
- (conn) => conn.status === "pending"
182
- );
183
- this.logger.info(
184
- `Connections with status='pending': ${pendingByStatus.length}`
185
- );
186
- const pendingConnections = allConnections.filter(
187
- (conn) => conn.status === "pending"
188
- );
189
- if (!Boolean(pendingConnections?.length)) {
190
- this.logger.info("No pending connections found");
191
- return;
192
- }
193
- for (const conn of pendingConnections) {
194
- this.logger.debug(
195
- `Processing pending connection: ${conn.connectionTopicId}`
196
- );
197
- if (!conn.targetAccountId) {
198
- this.logger.debug(
199
- `Skipping connection ${conn.connectionTopicId} - no targetAccountId`
200
- );
201
- continue;
202
- }
203
- let targetInboundTopicId = conn.targetInboundTopicId;
204
- if (!targetInboundTopicId) {
205
- try {
206
- const profileResponse = await this.baseClient.retrieveProfile(
207
- conn.targetAccountId
208
- );
209
- if (profileResponse?.profile?.inboundTopicId) {
210
- targetInboundTopicId = profileResponse.profile.inboundTopicId;
211
- this.connections.set(conn.connectionTopicId, {
212
- ...conn,
213
- targetInboundTopicId
214
- });
215
- this.logger.debug(
216
- `Updated connection ${conn.connectionTopicId} with inbound topic ID: ${targetInboundTopicId}`
217
- );
218
- } else {
219
- this.logger.debug(
220
- `Couldn't get inbound topic ID for account ${conn.targetAccountId}`
221
- );
222
- continue;
223
- }
224
- } catch (error) {
225
- this.logger.debug(
226
- `Error fetching profile for ${conn.targetAccountId}: ${error}`
227
- );
228
- continue;
229
- }
230
- }
231
- if (!targetInboundTopicId || targetInboundTopicId.includes(":")) {
232
- this.logger.debug(
233
- `Skipping invalid inbound topic format: ${targetInboundTopicId}`
234
- );
235
- continue;
236
- }
237
- const requestId = conn.connectionRequestId || conn.inboundRequestId;
238
- if (!requestId) {
239
- this.logger.debug(
240
- `Skipping connection ${conn.connectionTopicId} - no request ID`
241
- );
242
- continue;
243
- }
244
- try {
245
- this.logger.debug(
246
- `Checking for confirmations on topic ${targetInboundTopicId} for request ID ${requestId}`
247
- );
248
- const targetMessagesResult = await this.baseClient.getMessages(targetInboundTopicId);
249
- const targetMessages = targetMessagesResult.messages || [];
250
- const confirmationMsg = targetMessages.find(
251
- (msg) => msg.op === "connection_created" && msg.connection_id === requestId && msg.connection_topic_id
252
- );
253
- if (confirmationMsg?.connection_topic_id) {
254
- const connectionTopicId = confirmationMsg.connection_topic_id;
255
- this.logger.info(
256
- `Found confirmation for request #${requestId} to ${conn.targetAccountId} on their inbound topic`
257
- );
258
- const newConnection = {
259
- connectionTopicId,
260
- targetAccountId: conn.targetAccountId,
261
- targetAgentName: conn.targetAgentName,
262
- targetInboundTopicId: conn.targetInboundTopicId,
263
- targetOutboundTopicId: conn.targetOutboundTopicId,
264
- status: "established",
265
- isPending: false,
266
- needsConfirmation: false,
267
- created: new Date(confirmationMsg.created || conn.created),
268
- lastActivity: new Date(confirmationMsg.created || conn.created),
269
- profileInfo: conn.profileInfo,
270
- connectionRequestId: conn.connectionRequestId,
271
- confirmedRequestId: conn.confirmedRequestId,
272
- requesterOutboundTopicId: conn.requesterOutboundTopicId,
273
- inboundRequestId: conn.inboundRequestId,
274
- closedReason: conn.closedReason,
275
- closeMethod: conn.closeMethod,
276
- uniqueRequestKey: conn.uniqueRequestKey,
277
- originTopicId: conn.originTopicId,
278
- processed: conn.processed,
279
- memo: conn.memo
280
- };
281
- this.connections.set(connectionTopicId, newConnection);
282
- if (conn.connectionTopicId) {
283
- this.connections.delete(conn.connectionTopicId);
284
- }
285
- } else {
286
- this.logger.debug(
287
- `No confirmation found for request ID ${requestId} on topic ${targetInboundTopicId}`
288
- );
289
- }
290
- } catch (error) {
291
- this.logger.warn(
292
- `Error checking for confirmations on target inbound topic for ${conn.targetAccountId}: ${error}`
293
- );
294
- }
295
- }
296
- }
297
- /**
298
- * Fetches profiles for all connected accounts
299
- * @param accountId - The account ID making the request
300
- */
301
- async fetchProfilesForConnections() {
302
- const targetAccountIds = /* @__PURE__ */ new Set();
303
- for (const connection of this.connections.values()) {
304
- if (connection.targetAccountId && !this.profileCache.has(connection.targetAccountId)) {
305
- targetAccountIds.add(connection.targetAccountId);
306
- }
307
- }
308
- const accountIdPromises = Array.from(targetAccountIds).map(
309
- async (targetId) => {
310
- try {
311
- const profileResponse = await this.baseClient.retrieveProfile(targetId);
312
- if (profileResponse.success && profileResponse.profile) {
313
- this.addProfileInfo(targetId, profileResponse.profile);
314
- this.updatePendingConnectionsWithProfileInfo(
315
- targetId,
316
- profileResponse.profile
317
- );
318
- }
319
- } catch (error) {
320
- this.logger.debug(`Failed to fetch profile for ${targetId}:`, error);
321
- }
322
- }
323
- );
324
- await Promise.allSettled(accountIdPromises);
325
- }
326
- /**
327
- * Updates pending connections with inbound topic IDs from profile info
328
- * @param accountId - The account ID to update connections for
329
- * @param profile - The profile containing the inbound topic ID
330
- */
331
- updatePendingConnectionsWithProfileInfo(accountId, profile) {
332
- const pendingConnections = Array.from(this.connections.values()).filter(
333
- (conn) => conn.targetAccountId === accountId && (conn.isPending || conn.needsConfirmation) && !conn.targetInboundTopicId
334
- );
335
- if (pendingConnections.length > 0 && profile.inboundTopicId) {
336
- for (const conn of pendingConnections) {
337
- const updatedConn = {
338
- ...conn,
339
- targetInboundTopicId: profile.inboundTopicId
340
- };
341
- this.connections.set(conn.connectionTopicId, updatedConn);
342
- }
343
- }
344
- }
345
- /**
346
- * Fetches activity from active connection topics
347
- * Updates the lastActivity timestamp for each connection based on latest messages
348
- * @returns Promise that resolves when all activity has been fetched
349
- */
350
- async fetchConnectionActivity() {
351
- const activeConnections = this.getActiveConnections();
352
- const validConnections = activeConnections.filter((connection) => {
353
- const topicId = connection.connectionTopicId;
354
- if (!topicId || topicId.includes(":") || !topicId.match(/^0\.0\.\d+$/)) {
355
- this.logger.debug(
356
- `Skipping activity fetch for invalid topic ID format: ${topicId}`
357
- );
358
- return false;
359
- }
360
- return true;
361
- });
362
- const activityPromises = validConnections.map(async (connection) => {
363
- try {
364
- const topicId = connection.connectionTopicId;
365
- const messagesResult = await this.baseClient.getMessages(topicId);
366
- if (messagesResult?.messages?.length > 0) {
367
- this.processConnectionMessages(topicId, messagesResult.messages);
368
- }
369
- } catch (error) {
370
- this.logger.debug(
371
- `Failed to fetch activity for ${connection.connectionTopicId}:`,
372
- error
373
- );
374
- }
375
- });
376
- await Promise.allSettled(activityPromises);
377
- }
378
- /**
379
- * Checks if an account should be filtered, taking into account existing established connections
380
- * @param accountId - The account ID to check
381
- * @returns True if the account should be filtered, false otherwise
382
- */
383
- shouldFilterAccount(accountId) {
384
- if (!this.filterPendingAccountIds.has(accountId)) {
385
- return false;
386
- }
387
- if (this.hasEstablishedConnectionWithAccount(accountId)) {
388
- return false;
389
- }
390
- return true;
391
- }
392
- /**
393
- * Process outbound messages to track connection requests and confirmations
394
- * @param messages - The messages to process
395
- * @param accountId - The account ID that sent the messages
396
- * @returns Array of connections after processing
397
- */
398
- processOutboundMessages(messages, accountId) {
399
- if (!Boolean(messages?.length)) {
400
- return Array.from(this.connections.values());
401
- }
402
- const requestMessages = messages.filter(
403
- (msg) => msg.op === "connection_request" && msg.connection_request_id
404
- );
405
- for (const msg of requestMessages) {
406
- const requestId = msg.connection_request_id;
407
- const operatorId = msg.operator_id || "";
408
- const targetAccountId = this.baseClient.extractAccountFromOperatorId(operatorId);
409
- const targetInboundTopicId = this.baseClient.extractTopicFromOperatorId(operatorId);
410
- if (this.shouldFilterAccount(targetAccountId)) {
411
- this.logger.debug(
412
- `Filtering out outbound request to account: ${targetAccountId}`
413
- );
414
- continue;
415
- }
416
- const isAlreadyConfirmed = Array.from(this.connections.values()).some(
417
- (conn) => conn.connectionRequestId === requestId && !conn.isPending && conn.targetAccountId === targetAccountId
418
- );
419
- const pendingKey = `req-${requestId}:${operatorId}`;
420
- if (!isAlreadyConfirmed && !this.pendingRequests.has(pendingKey)) {
421
- const pendingRequest = {
422
- id: requestId,
423
- requesterId: accountId,
424
- requesterTopicId: msg.outbound_topic_id || "",
425
- targetAccountId,
426
- targetTopicId: targetInboundTopicId,
427
- operatorId,
428
- sequenceNumber: msg.sequence_number,
429
- created: msg.created || /* @__PURE__ */ new Date(),
430
- memo: msg.m,
431
- status: "pending"
432
- };
433
- this.pendingRequests.set(pendingKey, pendingRequest);
434
- if (!this.connections.has(pendingKey)) {
435
- const pendingConnection = {
436
- connectionTopicId: pendingKey,
437
- targetAccountId,
438
- targetInboundTopicId,
439
- status: "pending",
440
- isPending: true,
441
- needsConfirmation: false,
442
- created: msg.created || /* @__PURE__ */ new Date(),
443
- connectionRequestId: requestId,
444
- uniqueRequestKey: pendingKey,
445
- originTopicId: msg.outbound_topic_id || "",
446
- processed: false,
447
- memo: msg.m
448
- };
449
- this.connections.set(pendingKey, pendingConnection);
450
- }
451
- }
452
- }
453
- const confirmationMessages = messages.filter(
454
- (msg) => msg.op === "connection_created" && msg.connection_topic_id && msg.connection_request_id
455
- );
456
- for (const msg of confirmationMessages) {
457
- const requestId = msg.connection_request_id;
458
- const connectionTopicId = msg.connection_topic_id;
459
- const targetAccountId = this.baseClient.extractAccountFromOperatorId(
460
- msg.operator_id || ""
461
- );
462
- if (this.shouldFilterAccount(targetAccountId)) {
463
- this.logger.debug(
464
- `Filtering out outbound confirmation to account: ${targetAccountId}`
465
- );
466
- continue;
467
- }
468
- const pendingKey = `req-${requestId}:${msg.operator_id}`;
469
- const pendingRequest = this.pendingRequests.get(pendingKey);
470
- if (pendingRequest) {
471
- pendingRequest.status = "confirmed";
472
- }
473
- if (this.connections.has(pendingKey)) {
474
- this.connections.delete(pendingKey);
475
- }
476
- if (!this.connections.has(connectionTopicId)) {
477
- this.connections.set(connectionTopicId, {
478
- connectionTopicId,
479
- targetAccountId,
480
- status: "established",
481
- isPending: false,
482
- needsConfirmation: false,
483
- created: msg.created || /* @__PURE__ */ new Date(),
484
- connectionRequestId: requestId,
485
- confirmedRequestId: msg.confirmed_request_id,
486
- requesterOutboundTopicId: msg.outbound_topic_id,
487
- uniqueRequestKey: pendingKey,
488
- originTopicId: msg.outbound_topic_id || "",
489
- processed: false,
490
- memo: msg.m
491
- });
492
- } else {
493
- const conn = this.connections.get(connectionTopicId);
494
- this.connections.set(connectionTopicId, {
495
- ...conn,
496
- status: "established",
497
- isPending: false,
498
- needsConfirmation: false,
499
- connectionRequestId: requestId,
500
- confirmedRequestId: msg.confirmed_request_id,
501
- requesterOutboundTopicId: msg.outbound_topic_id,
502
- uniqueRequestKey: pendingKey,
503
- originTopicId: msg.outbound_topic_id || "",
504
- processed: false,
505
- memo: msg.m
506
- });
507
- }
508
- }
509
- const closedMessages = messages.filter(
510
- (msg) => msg.op === "connection_closed" || msg.op === "close_connection" && msg.connection_topic_id
511
- );
512
- for (const msg of closedMessages) {
513
- const connectionTopicId = msg.connection_topic_id;
514
- if (this.connections.has(connectionTopicId)) {
515
- const conn = this.connections.get(connectionTopicId);
516
- if (this.shouldFilterAccount(conn.targetAccountId) && conn.status !== "established") {
517
- continue;
518
- }
519
- const uniqueKey = msg.connection_request_id && msg.operator_id ? `req-${msg.connection_request_id}:${msg.operator_id}` : void 0;
520
- this.connections.set(connectionTopicId, {
521
- ...conn,
522
- status: "closed",
523
- isPending: false,
524
- needsConfirmation: false,
525
- lastActivity: msg.created || /* @__PURE__ */ new Date(),
526
- closedReason: msg.reason,
527
- closeMethod: msg.close_method,
528
- uniqueRequestKey: uniqueKey,
529
- originTopicId: conn.originTopicId,
530
- processed: false,
531
- memo: msg.m
532
- });
533
- }
534
- }
535
- return Array.from(this.connections.values()).filter(
536
- (conn) => conn.status === "established" || conn.status === "closed" || !this.filterPendingAccountIds.has(conn.targetAccountId)
537
- );
538
- }
539
- /**
540
- * Process inbound messages to track connection requests and confirmations
541
- * @param messages - The messages to process
542
- * @returns Array of connections after processing
543
- */
544
- processInboundMessages(messages) {
545
- if (!Boolean(messages?.length)) {
546
- return Array.from(this.connections.values());
547
- }
548
- const requestMessages = messages.filter(
549
- (msg) => msg.op === "connection_request" && msg.sequence_number
550
- );
551
- const confirmationMessages = messages.filter(
552
- (msg) => msg.op === "connection_created" && msg.connection_topic_id && msg.connection_id
553
- );
554
- for (const msg of requestMessages) {
555
- const sequenceNumber = msg.sequence_number;
556
- const operatorId = msg.operator_id || "";
557
- const requestorAccountId = this.baseClient.extractAccountFromOperatorId(operatorId);
558
- const requestorTopicId = this.baseClient.extractTopicFromOperatorId(operatorId);
559
- if (this.shouldFilterAccount(requestorAccountId)) {
560
- this.logger.debug(
561
- `Filtering out request from account: ${requestorAccountId}`
562
- );
563
- continue;
564
- }
565
- const needsConfirmKey = `inb-${sequenceNumber}:${operatorId}`;
566
- const hasCreated = confirmationMessages.some(
567
- (m) => m.connection_id === sequenceNumber
568
- );
569
- if (hasCreated) {
570
- this.logger.debug(
571
- `Skipping request from ${requestorAccountId} as it has already been confirmed`
572
- );
573
- continue;
574
- }
575
- if (!this.connections.has(needsConfirmKey)) {
576
- this.connections.set(needsConfirmKey, {
577
- connectionTopicId: needsConfirmKey,
578
- targetAccountId: requestorAccountId,
579
- targetInboundTopicId: requestorTopicId,
580
- status: "needs_confirmation",
581
- isPending: false,
582
- needsConfirmation: true,
583
- created: msg.created || /* @__PURE__ */ new Date(),
584
- inboundRequestId: sequenceNumber,
585
- uniqueRequestKey: needsConfirmKey,
586
- originTopicId: requestorTopicId,
587
- processed: false,
588
- memo: msg.m
589
- });
590
- }
591
- }
592
- for (const msg of confirmationMessages) {
593
- const sequenceNumber = msg.connection_id;
594
- const connectionTopicId = msg.connection_topic_id;
595
- const connectedAccountId = msg.connected_account_id || "";
596
- const operatorId = msg.operator_id || "";
597
- if (this.shouldFilterAccount(connectedAccountId)) {
598
- this.logger.debug(
599
- `Filtering out confirmation for account: ${connectedAccountId}`
600
- );
601
- continue;
602
- }
603
- const needsConfirmKey = `inb-${sequenceNumber}:${operatorId}`;
604
- if (this.connections.has(needsConfirmKey)) {
605
- this.connections.delete(needsConfirmKey);
606
- }
607
- if (!this.connections.has(connectionTopicId)) {
608
- this.connections.set(connectionTopicId, {
609
- connectionTopicId,
610
- targetAccountId: connectedAccountId,
611
- status: "established",
612
- isPending: false,
613
- needsConfirmation: false,
614
- created: msg.created || /* @__PURE__ */ new Date(),
615
- inboundRequestId: sequenceNumber,
616
- uniqueRequestKey: needsConfirmKey,
617
- originTopicId: msg.connection_topic_id,
618
- processed: false,
619
- memo: msg.m
620
- });
621
- } else {
622
- const conn = this.connections.get(connectionTopicId);
623
- this.connections.set(connectionTopicId, {
624
- ...conn,
625
- status: "established",
626
- isPending: false,
627
- needsConfirmation: false,
628
- inboundRequestId: sequenceNumber,
629
- uniqueRequestKey: needsConfirmKey,
630
- originTopicId: msg.connection_topic_id,
631
- processed: false,
632
- memo: msg.m
633
- });
634
- }
635
- }
636
- return Array.from(this.connections.values()).filter(
637
- (conn) => conn.status === "established" || conn.status === "closed" || !this.filterPendingAccountIds.has(conn.targetAccountId)
638
- );
639
- }
640
- /**
641
- * Process connection topic messages to update last activity time
642
- * @param connectionTopicId - The topic ID of the connection
643
- * @param messages - The messages to process
644
- * @returns The updated connection or undefined if not found
645
- */
646
- processConnectionMessages(connectionTopicId, messages) {
647
- if (!messages || messages.length === 0 || !this.connections.has(connectionTopicId)) {
648
- return this.connections.get(connectionTopicId);
649
- }
650
- const latestMessage = messages.filter((m) => m.created).sort((a, b) => {
651
- const dateA = a.created ? new Date(a.created).getTime() : 0;
652
- const dateB = b.created ? new Date(b.created).getTime() : 0;
653
- return dateB - dateA;
654
- })[0];
655
- if (latestMessage?.created) {
656
- const conn = this.connections.get(connectionTopicId);
657
- this.connections.set(connectionTopicId, {
658
- ...conn,
659
- lastActivity: latestMessage.created
660
- });
661
- }
662
- const closeMessage = messages.find((msg) => msg.op === "close_connection");
663
- if (closeMessage) {
664
- const conn = this.connections.get(connectionTopicId);
665
- this.connections.set(connectionTopicId, {
666
- ...conn,
667
- status: "closed",
668
- lastActivity: closeMessage.created || /* @__PURE__ */ new Date(),
669
- closedReason: closeMessage.reason,
670
- closeMethod: "explicit"
671
- });
672
- }
673
- return this.connections.get(connectionTopicId);
674
- }
675
- /**
676
- * Adds or updates profile information for a connection
677
- * @param accountId - The account ID to add profile info for
678
- * @param profile - The profile information
679
- */
680
- addProfileInfo(accountId, profile) {
681
- this.profileCache.set(accountId, profile);
682
- const matchingConnections = Array.from(this.connections.values()).filter(
683
- (conn) => conn.targetAccountId === accountId
684
- );
685
- for (const conn of matchingConnections) {
686
- this.connections.set(conn.connectionTopicId, {
687
- ...conn,
688
- profileInfo: profile,
689
- targetAgentName: profile.display_name,
690
- targetInboundTopicId: profile.inboundTopicId,
691
- targetOutboundTopicId: profile.outboundTopicId
692
- });
693
- }
694
- }
695
- /**
696
- * Gets all connections
697
- * @returns Array of all connections that should be visible
698
- */
699
- getAllConnections() {
700
- const connections = Array.from(this.connections.values()).filter(
701
- (conn) => conn.status === "established" || conn.status === "closed" || !this.filterPendingAccountIds.has(conn.targetAccountId)
702
- );
703
- return connections;
704
- }
705
- /**
706
- * Gets all pending connection requests
707
- * @returns Array of pending connection requests
708
- */
709
- getPendingRequests() {
710
- const pendingConnections = Array.from(this.connections.values()).filter(
711
- (conn) => {
712
- return conn.isPending && !this.filterPendingAccountIds.has(conn.targetAccountId);
713
- }
714
- );
715
- return pendingConnections;
716
- }
717
- /**
718
- * Helper method to check if there's an established connection with an account
719
- * @param accountId - The account ID to check
720
- * @returns True if there's an established connection, false otherwise
721
- */
722
- hasEstablishedConnectionWithAccount(accountId) {
723
- return Array.from(this.connections.values()).some(
724
- (conn) => conn.targetAccountId === accountId && conn.status === "established"
725
- );
726
- }
727
- /**
728
- * Gets all active (established) connections
729
- * @returns Array of active connections
730
- */
731
- getActiveConnections() {
732
- return Array.from(this.connections.values()).filter(
733
- (conn) => conn.status === "established"
734
- );
735
- }
736
- /**
737
- * Gets all connections needing confirmation
738
- * @returns Array of connections needing confirmation
739
- */
740
- getConnectionsNeedingConfirmation() {
741
- return Array.from(this.connections.values()).filter(
742
- (conn) => conn.needsConfirmation && !this.filterPendingAccountIds.has(conn.targetAccountId)
743
- );
744
- }
745
- /**
746
- * Gets a connection by its topic ID
747
- * @param connectionTopicId - The topic ID to look up
748
- * @returns The connection with the given topic ID, or undefined if not found
749
- */
750
- getConnectionByTopicId(connectionTopicId) {
751
- return this.connections.get(connectionTopicId);
752
- }
753
- /**
754
- * Gets a connection by account ID
755
- * @param accountId - The account ID to look up
756
- * @returns The connection with the given account ID, or undefined if not found
757
- */
758
- getConnectionByAccountId(accountId) {
759
- return Array.from(this.connections.values()).find(
760
- (conn) => conn.targetAccountId === accountId && conn.status === "established"
761
- );
762
- }
763
- /**
764
- * Gets all connections for a specific account ID
765
- * @param accountId - The account ID to look up
766
- * @returns Array of connections for the given account ID
767
- */
768
- getConnectionsByAccountId(accountId) {
769
- return Array.from(this.connections.values()).filter(
770
- (conn) => conn.targetAccountId === accountId
771
- );
772
- }
773
- /**
774
- * Updates or adds a connection
775
- * @param connection - The connection to update or add
776
- */
777
- updateOrAddConnection(connection) {
778
- this.connections.set(connection.connectionTopicId, connection);
779
- }
780
- /**
781
- * Clears all tracked connections and requests
782
- */
783
- clearAll() {
784
- this.connections.clear();
785
- this.pendingRequests.clear();
786
- }
787
- /**
788
- * Checks if a given connection request has been processed already
789
- * This uses a combination of topic ID and request ID to uniquely identify requests
790
- *
791
- * @param inboundTopicId - The inbound topic ID where the request was received
792
- * @param requestId - The sequence number (request ID)
793
- * @returns True if this specific request has been processed, false otherwise
794
- */
795
- isConnectionRequestProcessed(inboundTopicId, requestId) {
796
- for (const conn of this.connections.values()) {
797
- if (conn.originTopicId === inboundTopicId && conn.inboundRequestId === requestId && conn.processed) {
798
- return true;
799
- }
800
- if (conn.originTopicId === inboundTopicId && conn.connectionRequestId === requestId && conn.processed) {
801
- return true;
802
- }
803
- }
804
- return false;
805
- }
806
- /**
807
- * Marks a specific connection request as processed
808
- *
809
- * @param inboundTopicId - The inbound topic ID where the request was received
810
- * @param requestId - The sequence number (request ID)
811
- * @returns True if a matching connection was found and marked, false otherwise
812
- */
813
- markConnectionRequestProcessed(inboundTopicId, requestId) {
814
- let found = false;
815
- for (const [key, conn] of this.connections.entries()) {
816
- if (conn.originTopicId === inboundTopicId && conn.inboundRequestId === requestId) {
817
- this.connections.set(key, {
818
- ...conn,
819
- processed: true
820
- });
821
- found = true;
822
- this.logger.debug(
823
- `Marked inbound connection request #${requestId} on topic ${inboundTopicId} as processed`
824
- );
825
- }
826
- if (conn.originTopicId === inboundTopicId && conn.connectionRequestId === requestId) {
827
- this.connections.set(key, {
828
- ...conn,
829
- processed: true
830
- });
831
- found = true;
832
- this.logger.debug(
833
- `Marked outbound connection request #${requestId} on topic ${inboundTopicId} as processed`
834
- );
835
- }
836
- }
837
- return found;
838
- }
839
- /**
840
- * Gets pending transactions from a specific connection
841
- * @param connectionTopicId - The connection topic ID to check for transactions
842
- * @param options - Optional filtering and retrieval options
843
- * @returns Array of pending transaction messages sorted by timestamp (newest first)
844
- */
845
- async getPendingTransactions(connectionTopicId, options) {
846
- try {
847
- const transactMessages = await this.baseClient.getTransactionRequests(
848
- connectionTopicId,
849
- options ? { ...options } : void 0
850
- );
851
- const pendingTransactions = [];
852
- for (const transaction of transactMessages) {
853
- try {
854
- const status = await this.baseClient.mirrorNode.getScheduledTransactionStatus(
855
- transaction.schedule_id
856
- );
857
- if (!status.executed && !status.deleted) {
858
- pendingTransactions.push(transaction);
859
- }
860
- } catch (error) {
861
- this.logger.error(`Error checking transaction status: ${error}`);
862
- pendingTransactions.push(transaction);
863
- }
864
- }
865
- return pendingTransactions;
866
- } catch (error) {
867
- this.logger.error(`Error getting pending transactions: ${error}`);
868
- return [];
869
- }
870
- }
871
- /**
872
- * Gets the status of a scheduled transaction
873
- * @param scheduleId - The schedule ID to check
874
- * @returns Status of the scheduled transaction
875
- */
876
- getScheduledTransactionStatus(scheduleId) {
877
- return this.baseClient.mirrorNode.getScheduledTransactionStatus(scheduleId);
878
- }
879
- /**
880
- * Gets the timestamp of the last message sent by the specified operator on the connection topic
881
- * @param connectionTopicId - The topic ID to check
882
- * @param operatorAccountId - The account ID of the operator
883
- * @returns The timestamp of the last message or undefined if no messages found
884
- */
885
- async getLastOperatorActivity(connectionTopicId, operatorAccountId) {
886
- try {
887
- const messages = await this.baseClient.getMessageStream(connectionTopicId);
888
- const filteredMessages = messages.messages.filter(
889
- (msg) => msg.operator_id && msg.operator_id.includes(operatorAccountId) && msg.created
890
- );
891
- if (filteredMessages.length === 0) {
892
- return void 0;
893
- }
894
- filteredMessages.sort(
895
- (a, b) => b.created.getTime() - a.created.getTime()
896
- );
897
- return filteredMessages[0].created;
898
- } catch (error) {
899
- this.logger.error(`Error getting last operator activity: ${error}`);
900
- return void 0;
901
- }
902
- }
1
+ import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.es147.js";
2
+ function memoInbound(ttl, accountId) {
3
+ return `hcs-10:0:${ttl}:0:${accountId}`;
4
+ }
5
+ function memoOutbound(ttl) {
6
+ return `hcs-10:0:${ttl}:1`;
7
+ }
8
+ function memoConnection(ttl, inboundTopicId, connectionId) {
9
+ return `hcs-10:1:${ttl}:2:${inboundTopicId}:${connectionId}`;
10
+ }
11
+ function memoRegistry(ttl, metadataTopicId) {
12
+ return metadataTopicId ? `hcs-10:0:${ttl}:3:${metadataTopicId}` : `hcs-10:0:${ttl}:3`;
13
+ }
14
+ function analyticsMemo(opEnum, topicTypeEnum) {
15
+ return `hcs-10:op:${opEnum}:${topicTypeEnum}`;
16
+ }
17
+ function buildHcs10CreateInboundTopicTx(params) {
18
+ const memo = params.memoOverride ?? memoInbound(params.ttl, params.accountId);
19
+ return buildTopicCreateTx({
20
+ memo,
21
+ adminKey: params.adminKey,
22
+ submitKey: params.submitKey,
23
+ operatorPublicKey: params.operatorPublicKey
24
+ });
25
+ }
26
+ function buildHcs10CreateOutboundTopicTx(params) {
27
+ const memo = params.memoOverride ?? memoOutbound(params.ttl);
28
+ return buildTopicCreateTx({
29
+ memo,
30
+ adminKey: params.adminKey,
31
+ submitKey: params.submitKey,
32
+ operatorPublicKey: params.operatorPublicKey
33
+ });
34
+ }
35
+ function buildHcs10CreateConnectionTopicTx(params) {
36
+ const memo = params.memoOverride ?? memoConnection(params.ttl, params.inboundTopicId, params.connectionId);
37
+ return buildTopicCreateTx({
38
+ memo,
39
+ adminKey: params.adminKey,
40
+ submitKey: params.submitKey,
41
+ operatorPublicKey: params.operatorPublicKey
42
+ });
43
+ }
44
+ function buildHcs10CreateRegistryTopicTx(params) {
45
+ const memo = params.memoOverride ?? memoRegistry(params.ttl, params.metadataTopicId);
46
+ return buildTopicCreateTx({
47
+ memo,
48
+ adminKey: params.adminKey,
49
+ submitKey: params.submitKey,
50
+ operatorPublicKey: params.operatorPublicKey
51
+ });
52
+ }
53
+ function buildHcs10SubmitConnectionRequestTx(params) {
54
+ const payload = {
55
+ p: "hcs-10",
56
+ op: "connection_request",
57
+ operator_id: params.operatorId,
58
+ m: params.memo
59
+ };
60
+ return buildMessageTx({
61
+ topicId: params.inboundTopicId,
62
+ message: JSON.stringify(payload),
63
+ transactionMemo: analyticsMemo(3, 1)
64
+ });
65
+ }
66
+ function buildHcs10ConfirmConnectionTx(params) {
67
+ const payload = {
68
+ p: "hcs-10",
69
+ op: "connection_created",
70
+ connection_topic_id: params.connectionTopicId,
71
+ connected_account_id: params.connectedAccountId,
72
+ operator_id: params.operatorId,
73
+ connection_id: params.connectionId,
74
+ m: params.memo
75
+ };
76
+ return buildMessageTx({
77
+ topicId: params.inboundTopicId,
78
+ message: JSON.stringify(payload),
79
+ transactionMemo: analyticsMemo(4, 1)
80
+ });
81
+ }
82
+ function buildHcs10OutboundConnectionRequestRecordTx(params) {
83
+ const payload = {
84
+ p: "hcs-10",
85
+ op: "connection_request",
86
+ operator_id: params.operatorId,
87
+ outbound_topic_id: params.outboundTopicId,
88
+ connection_request_id: params.connectionRequestId,
89
+ m: params.memo
90
+ };
91
+ return buildMessageTx({
92
+ topicId: params.outboundTopicId,
93
+ message: JSON.stringify(payload),
94
+ transactionMemo: analyticsMemo(3, 2)
95
+ });
96
+ }
97
+ function buildHcs10OutboundConnectionCreatedRecordTx(params) {
98
+ const payload = {
99
+ p: "hcs-10",
100
+ op: "connection_created",
101
+ connection_topic_id: params.connectionTopicId,
102
+ outbound_topic_id: params.outboundTopicId,
103
+ requestor_outbound_topic_id: params.requestorOutboundTopicId,
104
+ confirmed_request_id: params.confirmedRequestId,
105
+ connection_request_id: params.connectionRequestId,
106
+ operator_id: params.operatorId,
107
+ m: params.memo
108
+ };
109
+ return buildMessageTx({
110
+ topicId: params.outboundTopicId,
111
+ message: JSON.stringify(payload),
112
+ transactionMemo: analyticsMemo(4, 2)
113
+ });
114
+ }
115
+ function buildHcs10SendMessageTx(params) {
116
+ const payload = {
117
+ p: "hcs-10",
118
+ op: "message",
119
+ operator_id: params.operatorId,
120
+ data: params.data,
121
+ m: params.memo
122
+ };
123
+ return buildMessageTx({
124
+ topicId: params.connectionTopicId,
125
+ message: JSON.stringify(payload),
126
+ transactionMemo: analyticsMemo(6, 3)
127
+ });
128
+ }
129
+ function buildHcs10RegistryRegisterTx(params) {
130
+ const payload = {
131
+ p: "hcs-10",
132
+ op: "register",
133
+ account_id: params.accountId,
134
+ ...params.inboundTopicId ? { inbound_topic_id: params.inboundTopicId } : {},
135
+ m: params.memo
136
+ };
137
+ return buildMessageTx({
138
+ topicId: params.registryTopicId,
139
+ message: JSON.stringify(payload),
140
+ transactionMemo: analyticsMemo(0, 0)
141
+ });
142
+ }
143
+ function buildHcs10RegistryDeleteTx(params) {
144
+ const payload = {
145
+ p: "hcs-10",
146
+ op: "delete",
147
+ uid: params.uid,
148
+ m: params.memo
149
+ };
150
+ return buildMessageTx({
151
+ topicId: params.registryTopicId,
152
+ message: JSON.stringify(payload),
153
+ transactionMemo: analyticsMemo(1, 0)
154
+ });
155
+ }
156
+ function buildHcs10RegistryMigrateTx(params) {
157
+ const payload = {
158
+ p: "hcs-10",
159
+ op: "migrate",
160
+ t_id: params.targetTopicId,
161
+ m: params.memo
162
+ };
163
+ return buildMessageTx({
164
+ topicId: params.registryTopicId,
165
+ message: JSON.stringify(payload),
166
+ transactionMemo: analyticsMemo(2, 0)
167
+ });
903
168
  }
904
169
  export {
905
- ConnectionsManager
170
+ buildHcs10ConfirmConnectionTx,
171
+ buildHcs10CreateConnectionTopicTx,
172
+ buildHcs10CreateInboundTopicTx,
173
+ buildHcs10CreateOutboundTopicTx,
174
+ buildHcs10CreateRegistryTopicTx,
175
+ buildHcs10OutboundConnectionCreatedRecordTx,
176
+ buildHcs10OutboundConnectionRequestRecordTx,
177
+ buildHcs10RegistryDeleteTx,
178
+ buildHcs10RegistryMigrateTx,
179
+ buildHcs10RegistryRegisterTx,
180
+ buildHcs10SendMessageTx,
181
+ buildHcs10SubmitConnectionRequestTx
906
182
  };
907
183
  //# sourceMappingURL=standards-sdk.es22.js.map