@hashgraphonline/standards-sdk 0.1.144 → 0.1.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hcs-10/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-10/sdk.d.ts +8 -0
- package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-11/client.d.ts +2 -2
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/person-builder.d.ts +1 -0
- package/dist/cjs/hcs-11/person-builder.d.ts.map +1 -1
- package/dist/cjs/hcs-11/types.d.ts +1 -0
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/hcs-12/rendering/resource-manager.d.ts.map +1 -1
- package/dist/cjs/hcs-14/issuers/hiero.d.ts.map +1 -1
- package/dist/cjs/hcs-15/browser.d.ts +2 -0
- package/dist/cjs/hcs-15/browser.d.ts.map +1 -1
- package/dist/cjs/hcs-15/sdk.d.ts +7 -1
- package/dist/cjs/hcs-15/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-15/tx.d.ts +4 -0
- package/dist/cjs/hcs-15/tx.d.ts.map +1 -1
- package/dist/cjs/hcs-15/types.d.ts +16 -1
- package/dist/cjs/hcs-15/types.d.ts.map +1 -1
- package/dist/cjs/hcs-16/browser.d.ts +11 -2
- package/dist/cjs/hcs-16/browser.d.ts.map +1 -1
- package/dist/cjs/hcs-16/sdk.d.ts +62 -1
- package/dist/cjs/hcs-16/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-16/tx.d.ts +21 -3
- package/dist/cjs/hcs-16/tx.d.ts.map +1 -1
- package/dist/cjs/hcs-17/base-client.d.ts +1 -0
- package/dist/cjs/hcs-17/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-17/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-17/tx.d.ts +2 -0
- package/dist/cjs/hcs-17/tx.d.ts.map +1 -1
- package/dist/cjs/hcs-17/types.d.ts +4 -0
- package/dist/cjs/hcs-17/types.d.ts.map +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +14 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/feedback.d.ts +2 -0
- package/dist/cjs/services/registry-broker/client/feedback.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/private-key-signer.d.ts +1 -0
- package/dist/cjs/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +998 -577
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +20 -1
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/cjs/utils/crypto-abstraction.d.ts.map +1 -1
- package/dist/cjs/utils/crypto-env.d.ts.map +1 -1
- package/dist/cjs/utils/dynamic-import.d.ts +5 -1
- package/dist/cjs/utils/dynamic-import.d.ts.map +1 -1
- package/dist/cjs/utils/hash-adapter.d.ts.map +1 -1
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts +8 -0
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts +2 -2
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/person-builder.d.ts +1 -0
- package/dist/es/hcs-11/person-builder.d.ts.map +1 -1
- package/dist/es/hcs-11/types.d.ts +1 -0
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/hcs-12/rendering/resource-manager.d.ts.map +1 -1
- package/dist/es/hcs-14/issuers/hiero.d.ts.map +1 -1
- package/dist/es/hcs-15/browser.d.ts +2 -0
- package/dist/es/hcs-15/browser.d.ts.map +1 -1
- package/dist/es/hcs-15/sdk.d.ts +7 -1
- package/dist/es/hcs-15/sdk.d.ts.map +1 -1
- package/dist/es/hcs-15/tx.d.ts +4 -0
- package/dist/es/hcs-15/tx.d.ts.map +1 -1
- package/dist/es/hcs-15/types.d.ts +16 -1
- package/dist/es/hcs-15/types.d.ts.map +1 -1
- package/dist/es/hcs-16/browser.d.ts +11 -2
- package/dist/es/hcs-16/browser.d.ts.map +1 -1
- package/dist/es/hcs-16/sdk.d.ts +62 -1
- package/dist/es/hcs-16/sdk.d.ts.map +1 -1
- package/dist/es/hcs-16/tx.d.ts +21 -3
- package/dist/es/hcs-16/tx.d.ts.map +1 -1
- package/dist/es/hcs-17/base-client.d.ts +1 -0
- package/dist/es/hcs-17/base-client.d.ts.map +1 -1
- package/dist/es/hcs-17/sdk.d.ts.map +1 -1
- package/dist/es/hcs-17/tx.d.ts +2 -0
- package/dist/es/hcs-17/tx.d.ts.map +1 -1
- package/dist/es/hcs-17/types.d.ts +4 -0
- package/dist/es/hcs-17/types.d.ts.map +1 -1
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts +14 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/feedback.d.ts +2 -0
- package/dist/es/services/registry-broker/client/feedback.d.ts.map +1 -0
- package/dist/es/services/registry-broker/private-key-signer.d.ts +1 -0
- package/dist/es/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +998 -577
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +20 -1
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +141 -135
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es10.js +70 -90
- package/dist/es/standards-sdk.es10.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +229 -26
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +109 -228
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +15 -94
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +80 -30
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +27 -80
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +136 -25
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +27 -140
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +20 -27
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +156 -18
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +198 -148
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es11.js +121 -45
- package/dist/es/standards-sdk.es11.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +747 -166
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +9 -786
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +567 -13
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +576 -541
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +12 -601
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +2 -13
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +87 -2
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +37 -80
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +2 -39
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +231 -2
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es12.js +60 -159
- package/dist/es/standards-sdk.es12.js.map +1 -1
- package/dist/es/standards-sdk.es120.js +1110 -193
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +225 -1059
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +419 -303
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +351 -418
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +872 -347
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +182 -854
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +1512 -153
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +157 -1547
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +192 -162
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +61 -164
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +200 -60
- package/dist/es/standards-sdk.es13.js.map +1 -1
- package/dist/es/standards-sdk.es130.js +102 -85
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +222 -96
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +153 -220
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +104 -162
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +296 -92
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +432 -294
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +14 -363
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +79 -15
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +79 -59
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +152 -80
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es14.js +149 -178
- package/dist/es/standards-sdk.es14.js.map +1 -1
- package/dist/es/standards-sdk.es140.js +7 -159
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +86 -7
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +44 -65
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +30 -65
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +34 -28
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +28 -138
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +133 -37
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +34 -12281
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +12284 -12
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +958 -56
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es15.js +152 -151
- package/dist/es/standards-sdk.es15.js.map +1 -1
- package/dist/es/standards-sdk.es150.js +48 -74
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +72 -160
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +13 -318
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +120 -294
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +191 -322
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +294 -279
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +440 -63
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +331 -871
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +68 -231
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +218 -223
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +917 -136
- package/dist/es/standards-sdk.es16.js.map +1 -1
- package/dist/es/standards-sdk.es160.js +247 -0
- package/dist/es/standards-sdk.es160.js.map +1 -0
- package/dist/es/standards-sdk.es17.js +23 -944
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +2422 -24
- package/dist/es/standards-sdk.es18.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +817 -2071
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es2.js +654 -189
- package/dist/es/standards-sdk.es2.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +205 -1091
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +858 -221
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +179 -903
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +164 -179
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +62 -118
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +377 -52
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +36 -394
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +901 -50
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +134 -902
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +7 -134
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es3.js +63 -680
- package/dist/es/standards-sdk.es3.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +344 -7
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +302 -287
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +94 -322
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +458 -101
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +132 -451
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +216 -130
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +273 -195
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +148 -87
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +183 -320
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +238 -161
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +425 -63
- package/dist/es/standards-sdk.es4.js.map +1 -1
- package/dist/es/standards-sdk.es40.js +136 -254
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +225 -176
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +199 -261
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +237 -199
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +209 -201
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +305 -201
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +371 -261
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +316 -371
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +404 -336
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +83 -449
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +232 -354
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +179 -89
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +231 -165
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +25 -262
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +56 -26
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +12 -57
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +49 -12
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +115 -43
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +42 -115
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +52 -43
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +36 -50
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es6.js +125 -246
- package/dist/es/standards-sdk.es6.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +207 -39
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +24 -200
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +87 -25
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +3 -51
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +100 -3
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +61 -62
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +17 -98
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +77 -19
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +458 -77
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +106 -240
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +28 -183
- package/dist/es/standards-sdk.es7.js.map +1 -1
- package/dist/es/standards-sdk.es70.js +170 -286
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +71 -207
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +71 -72
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +143 -71
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +62 -136
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +380 -45
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +222 -130
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +320 -444
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +88 -370
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +125 -89
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +80 -29
- package/dist/es/standards-sdk.es8.js.map +1 -1
- package/dist/es/standards-sdk.es80.js +8 -125
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +45 -6
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +98 -44
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +331 -84
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +93 -160
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +55 -275
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +43 -55
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +145 -22
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +34 -47
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +22 -57
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +104 -80
- package/dist/es/standards-sdk.es9.js.map +1 -1
- package/dist/es/standards-sdk.es90.js +23 -28
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +238 -23
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +265 -152
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +95 -68
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +124 -136
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +42 -138
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +259 -42
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +82 -243
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +48 -47
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +29 -100
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/crypto-abstraction.d.ts.map +1 -1
- package/dist/es/utils/crypto-env.d.ts.map +1 -1
- package/dist/es/utils/dynamic-import.d.ts +5 -1
- package/dist/es/utils/dynamic-import.d.ts.map +1 -1
- package/dist/es/utils/hash-adapter.d.ts.map +1 -1
- package/package.json +8 -7
- package/dist/cjs/patches/topic-autorenew-patch.d.ts +0 -2
- package/dist/cjs/patches/topic-autorenew-patch.d.ts.map +0 -1
- package/dist/es/patches/topic-autorenew-patch.d.ts +0 -2
- package/dist/es/patches/topic-autorenew-patch.d.ts.map +0 -1
|
@@ -1,270 +1,907 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
class Registration {
|
|
1
|
+
import { Logger } from "./standards-sdk.es105.js";
|
|
2
|
+
class ConnectionsManager {
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param transactionId - The transaction ID of the registration.
|
|
8
|
-
* @param network - The network to use for the registration.
|
|
9
|
-
* @param baseUrl - The base URL of the guarded registry.
|
|
10
|
-
* @param logger - The logger to use for logging.
|
|
11
|
-
* @returns A promise that resolves to the registration status response.
|
|
4
|
+
* Creates a new ConnectionsManager instance
|
|
12
5
|
*/
|
|
13
|
-
|
|
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) {
|
|
14
32
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const error = `Failed to confirm registration: ${response.statusText}`;
|
|
25
|
-
if (logger) {
|
|
26
|
-
logger.error(error);
|
|
27
|
-
}
|
|
28
|
-
throw new Error(error);
|
|
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();
|
|
29
42
|
}
|
|
30
|
-
|
|
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();
|
|
31
65
|
} catch (error) {
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
34
169
|
}
|
|
35
|
-
throw error;
|
|
36
170
|
}
|
|
37
171
|
}
|
|
38
172
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @param network - The network to use for the registration.
|
|
43
|
-
* @param baseUrl - The base URL of the guarded registry.
|
|
44
|
-
* @param maxAttempts - The maximum number of attempts to check the registration status.
|
|
45
|
-
* @param delayMs - The delay in milliseconds between attempts.
|
|
46
|
-
* @param logger - The logger to use for logging.
|
|
47
|
-
* @returns A promise that resolves to true if the registration is confirmed, false otherwise.
|
|
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
|
|
48
176
|
*/
|
|
49
|
-
async
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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`
|
|
55
200
|
);
|
|
201
|
+
continue;
|
|
56
202
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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;
|
|
66
229
|
}
|
|
67
|
-
return true;
|
|
68
230
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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;
|
|
74
243
|
}
|
|
75
|
-
|
|
76
|
-
logger.
|
|
77
|
-
`
|
|
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}`
|
|
78
293
|
);
|
|
79
294
|
}
|
|
80
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
81
|
-
attempts++;
|
|
82
295
|
}
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
}
|
|
85
307
|
}
|
|
86
|
-
|
|
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);
|
|
87
325
|
}
|
|
88
326
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @param
|
|
92
|
-
* @param network - The network to use for the registration.
|
|
93
|
-
* @param baseUrl - The base URL of the guarded registry.
|
|
94
|
-
* @param logger - The logger to use for logging.
|
|
95
|
-
* @returns A promise that resolves to the registration result.
|
|
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
|
|
96
330
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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);
|
|
101
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) => {
|
|
102
363
|
try {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
|
109
373
|
);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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}`
|
|
114
413
|
);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
|
148
448
|
};
|
|
449
|
+
this.connections.set(pendingKey, pendingConnection);
|
|
149
450
|
}
|
|
150
|
-
if (logger) {
|
|
151
|
-
logger.info(
|
|
152
|
-
`Profile validation successful. Inbound topic: ${profileResult.profile.inboundTopicId}, Outbound topic: ${profileResult.profile.outboundTopicId}`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
} catch (profileError) {
|
|
156
|
-
if (logger) {
|
|
157
|
-
logger.error(`Error validating profile: ${profileError.message}`);
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
error: `Error validating profile: ${profileError.message}`,
|
|
161
|
-
success: false
|
|
162
|
-
};
|
|
163
451
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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;
|
|
186
518
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
+
});
|
|
191
533
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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}`
|
|
195
562
|
);
|
|
563
|
+
continue;
|
|
196
564
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
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
|
+
});
|
|
207
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);
|
|
208
752
|
}
|
|
209
753
|
/**
|
|
210
|
-
*
|
|
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
|
|
211
808
|
*
|
|
212
|
-
* @param
|
|
213
|
-
* @param
|
|
214
|
-
* @returns
|
|
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
|
|
215
812
|
*/
|
|
216
|
-
|
|
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) {
|
|
217
846
|
try {
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
Accept: "*/*",
|
|
231
|
-
"Accept-Language": "en;q=0.5",
|
|
232
|
-
Origin: baseUrl,
|
|
233
|
-
Referer: `${baseUrl}/`
|
|
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);
|
|
234
859
|
}
|
|
860
|
+
} catch (error) {
|
|
861
|
+
this.logger.error(`Error checking transaction status: ${error}`);
|
|
862
|
+
pendingTransactions.push(transaction);
|
|
235
863
|
}
|
|
236
|
-
);
|
|
237
|
-
if (!response.ok) {
|
|
238
|
-
const error = await response.text();
|
|
239
|
-
return {
|
|
240
|
-
registrations: [],
|
|
241
|
-
error: error || "Failed to fetch registrations",
|
|
242
|
-
success: false
|
|
243
|
-
};
|
|
244
864
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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;
|
|
252
893
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
} catch (
|
|
258
|
-
|
|
259
|
-
return
|
|
260
|
-
registrations: [],
|
|
261
|
-
error: `Error fetching registrations: ${error.message}`,
|
|
262
|
-
success: false
|
|
263
|
-
};
|
|
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;
|
|
264
901
|
}
|
|
265
902
|
}
|
|
266
903
|
}
|
|
267
904
|
export {
|
|
268
|
-
|
|
905
|
+
ConnectionsManager
|
|
269
906
|
};
|
|
270
907
|
//# sourceMappingURL=standards-sdk.es21.js.map
|