@hsuite/native-connect-angular 2.1.1 → 2.1.2

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 (287) hide show
  1. package/LICENSE +146 -0
  2. package/package.json +30 -13
  3. package/USAGE_EXAMPLES.md +0 -476
  4. package/assets/wallets/extension.svg +0 -7
  5. package/assets/wallets/hashpack.svg +0 -6
  6. package/assets/wallets/hsuite.svg +0 -11
  7. package/assets/wallets/kabila.svg +0 -11
  8. package/assets/wallets/walletconnect.svg +0 -13
  9. package/coverage/base.css +0 -224
  10. package/coverage/block-navigation.js +0 -87
  11. package/coverage/coverage-summary.json +0 -54
  12. package/coverage/favicon.png +0 -0
  13. package/coverage/index.html +0 -476
  14. package/coverage/lcov-report/base.css +0 -224
  15. package/coverage/lcov-report/block-navigation.js +0 -87
  16. package/coverage/lcov-report/favicon.png +0 -0
  17. package/coverage/lcov-report/index.html +0 -476
  18. package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
  19. package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +0 -116
  20. package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
  21. package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +0 -116
  22. package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +0 -679
  23. package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +0 -766
  24. package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
  25. package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +0 -116
  26. package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +0 -1495
  27. package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +0 -1588
  28. package/coverage/lcov-report/lib/components/account-selector/index.html +0 -161
  29. package/coverage/lcov-report/lib/components/wallet-account-display/index.html +0 -116
  30. package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
  31. package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +0 -116
  32. package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
  33. package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +0 -116
  34. package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
  35. package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +0 -116
  36. package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
  37. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
  38. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
  39. package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +0 -116
  40. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
  41. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
  42. package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2518
  43. package/coverage/lcov-report/lib/components/wallet-session-display/index.html +0 -116
  44. package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
  45. package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +0 -116
  46. package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
  47. package/coverage/lcov-report/lib/directives/index.html +0 -146
  48. package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +0 -670
  49. package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +0 -547
  50. package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +0 -781
  51. package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +0 -715
  52. package/coverage/lcov-report/lib/index.html +0 -116
  53. package/coverage/lcov-report/lib/models/connection-config.model.ts.html +0 -280
  54. package/coverage/lcov-report/lib/models/index.html +0 -131
  55. package/coverage/lcov-report/lib/models/provider-types.ts.html +0 -583
  56. package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +0 -1138
  57. package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2674
  58. package/coverage/lcov-report/lib/providers/hsuite-native/index.html +0 -116
  59. package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +0 -2347
  60. package/coverage/lcov-report/lib/providers/index.html +0 -146
  61. package/coverage/lcov-report/lib/providers/p2p-native/index.html +0 -131
  62. package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
  63. package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2173
  64. package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +0 -1132
  65. package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +0 -176
  66. package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +0 -673
  67. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
  68. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2566
  69. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
  70. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
  71. package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
  72. package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +0 -146
  73. package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
  74. package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
  75. package/coverage/lcov-report/lib/services/hsuite-auth.interceptor.ts.html +0 -568
  76. package/coverage/lcov-report/lib/services/index.html +0 -221
  77. package/coverage/lcov-report/lib/services/logger.service.ts.html +0 -463
  78. package/coverage/lcov-report/lib/services/smart-session.service.ts.html +0 -1264
  79. package/coverage/lcov-report/lib/services/transaction-builders/active-account-source.ts.html +0 -250
  80. package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
  81. package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
  82. package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
  83. package/coverage/lcov-report/lib/services/transaction-builders/index.html +0 -176
  84. package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
  85. package/coverage/lcov-report/lib/services/transaction.service.ts.html +0 -1120
  86. package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +0 -2638
  87. package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +0 -637
  88. package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +0 -643
  89. package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +0 -493
  90. package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +0 -823
  91. package/coverage/lcov-report/lib/transports/index.html +0 -116
  92. package/coverage/lcov-report/lib/utils/index.html +0 -131
  93. package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +0 -412
  94. package/coverage/lcov-report/lib/utils/ledger-ui-registry.ts.html +0 -676
  95. package/coverage/lcov-report/prettify.css +0 -1
  96. package/coverage/lcov-report/prettify.js +0 -2
  97. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  98. package/coverage/lcov-report/sorter.js +0 -210
  99. package/coverage/lcov.info +0 -20366
  100. package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
  101. package/coverage/lib/components/account-selector/account-actions/index.html +0 -116
  102. package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
  103. package/coverage/lib/components/account-selector/account-filter/index.html +0 -116
  104. package/coverage/lib/components/account-selector/account-formatting.service.ts.html +0 -679
  105. package/coverage/lib/components/account-selector/account-grouping.service.ts.html +0 -766
  106. package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
  107. package/coverage/lib/components/account-selector/account-list/index.html +0 -116
  108. package/coverage/lib/components/account-selector/account-selector.component.ts.html +0 -1495
  109. package/coverage/lib/components/account-selector/account-selector.service.ts.html +0 -1588
  110. package/coverage/lib/components/account-selector/index.html +0 -161
  111. package/coverage/lib/components/wallet-account-display/index.html +0 -116
  112. package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
  113. package/coverage/lib/components/wallet-connect-button/index.html +0 -116
  114. package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
  115. package/coverage/lib/components/wallet-connect-prompt/index.html +0 -116
  116. package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
  117. package/coverage/lib/components/wallet-connected-guard/index.html +0 -116
  118. package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
  119. package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
  120. package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
  121. package/coverage/lib/components/wallet-connection-modal/index.html +0 -116
  122. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
  123. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
  124. package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2518
  125. package/coverage/lib/components/wallet-session-display/index.html +0 -116
  126. package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
  127. package/coverage/lib/components/wallet-transaction-status/index.html +0 -116
  128. package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
  129. package/coverage/lib/directives/index.html +0 -146
  130. package/coverage/lib/directives/wallet-connected.directive.ts.html +0 -670
  131. package/coverage/lib/directives/wallet-context.directive.ts.html +0 -547
  132. package/coverage/lib/directives/wallet-events.directive.ts.html +0 -781
  133. package/coverage/lib/hsuite-wallet.module.ts.html +0 -715
  134. package/coverage/lib/index.html +0 -116
  135. package/coverage/lib/models/connection-config.model.ts.html +0 -280
  136. package/coverage/lib/models/index.html +0 -131
  137. package/coverage/lib/models/provider-types.ts.html +0 -583
  138. package/coverage/lib/providers/base-wallet-provider.ts.html +0 -1138
  139. package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2674
  140. package/coverage/lib/providers/hsuite-native/index.html +0 -116
  141. package/coverage/lib/providers/hsuite-native-provider.ts.html +0 -2347
  142. package/coverage/lib/providers/index.html +0 -146
  143. package/coverage/lib/providers/p2p-native/index.html +0 -131
  144. package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
  145. package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2173
  146. package/coverage/lib/providers/wallet-error-handler.ts.html +0 -1132
  147. package/coverage/lib/providers/walletconnect/core/index.html +0 -176
  148. package/coverage/lib/providers/walletconnect/core/session-health.ts.html +0 -673
  149. package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
  150. package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2566
  151. package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
  152. package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
  153. package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
  154. package/coverage/lib/providers/walletconnect/signers/index.html +0 -146
  155. package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
  156. package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
  157. package/coverage/lib/services/hsuite-auth.interceptor.ts.html +0 -568
  158. package/coverage/lib/services/index.html +0 -221
  159. package/coverage/lib/services/logger.service.ts.html +0 -463
  160. package/coverage/lib/services/smart-session.service.ts.html +0 -1264
  161. package/coverage/lib/services/transaction-builders/active-account-source.ts.html +0 -250
  162. package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
  163. package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
  164. package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
  165. package/coverage/lib/services/transaction-builders/index.html +0 -176
  166. package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
  167. package/coverage/lib/services/transaction.service.ts.html +0 -1120
  168. package/coverage/lib/services/unified-wallet.service.ts.html +0 -2638
  169. package/coverage/lib/services/wallet-context.service.ts.html +0 -637
  170. package/coverage/lib/services/wallet-event-bus.service.ts.html +0 -643
  171. package/coverage/lib/services/wallet-providers.service.ts.html +0 -493
  172. package/coverage/lib/transports/chrome-extension-transport.ts.html +0 -823
  173. package/coverage/lib/transports/index.html +0 -116
  174. package/coverage/lib/utils/index.html +0 -131
  175. package/coverage/lib/utils/ledger-icons.util.ts.html +0 -412
  176. package/coverage/lib/utils/ledger-ui-registry.ts.html +0 -676
  177. package/coverage/prettify.css +0 -1
  178. package/coverage/prettify.js +0 -2
  179. package/coverage/sort-arrow-sprite.png +0 -0
  180. package/coverage/sorter.js +0 -210
  181. package/examples/minimal-connect.ts +0 -178
  182. package/examples/multi-protocol.ts +0 -495
  183. package/examples/transaction-signing.ts +0 -361
  184. package/jest.config.json +0 -45
  185. package/karma.conf.js +0 -42
  186. package/ng-package.json +0 -20
  187. package/src/index.ts +0 -229
  188. package/src/lib/components/account-selector/account-actions/account-actions.component.ts +0 -261
  189. package/src/lib/components/account-selector/account-filter/account-filter.component.ts +0 -401
  190. package/src/lib/components/account-selector/account-formatting.service.ts +0 -198
  191. package/src/lib/components/account-selector/account-grouping.service.ts +0 -227
  192. package/src/lib/components/account-selector/account-list/account-list.component.ts +0 -470
  193. package/src/lib/components/account-selector/account-selector.component.html +0 -135
  194. package/src/lib/components/account-selector/account-selector.component.scss +0 -2039
  195. package/src/lib/components/account-selector/account-selector.component.ts +0 -470
  196. package/src/lib/components/account-selector/account-selector.service.ts +0 -501
  197. package/src/lib/components/wallet-account-display/wallet-account-display.component.html +0 -34
  198. package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +0 -99
  199. package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +0 -140
  200. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +0 -14
  201. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +0 -272
  202. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.spec.ts +0 -89
  203. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +0 -248
  204. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +0 -24
  205. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +0 -50
  206. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +0 -108
  207. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +0 -24
  208. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +0 -73
  209. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +0 -56
  210. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +0 -218
  211. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +0 -117
  212. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +0 -94
  213. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +0 -272
  214. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +0 -734
  215. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +0 -192
  216. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +0 -678
  217. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.spec.ts +0 -173
  218. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +0 -811
  219. package/src/lib/components/wallet-session-display/wallet-session-display.component.html +0 -110
  220. package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +0 -179
  221. package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +0 -197
  222. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +0 -65
  223. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +0 -254
  224. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +0 -206
  225. package/src/lib/directives/wallet-connected.directive.ts +0 -195
  226. package/src/lib/directives/wallet-context.directive.ts +0 -154
  227. package/src/lib/directives/wallet-events.directive.ts +0 -232
  228. package/src/lib/hsuite-wallet.module.ts +0 -210
  229. package/src/lib/models/connection-config.model.ts +0 -65
  230. package/src/lib/models/provider-types.ts +0 -166
  231. package/src/lib/models/unified-account.model.ts +0 -79
  232. package/src/lib/models/wallet-context.model.ts +0 -121
  233. package/src/lib/models/wallet-events.model.ts +0 -158
  234. package/src/lib/providers/base-wallet-provider.ts +0 -351
  235. package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +0 -73
  236. package/src/lib/providers/hsuite-native/channel-client.service.ts +0 -863
  237. package/src/lib/providers/hsuite-native/index.ts +0 -8
  238. package/src/lib/providers/hsuite-native-provider.ts +0 -754
  239. package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +0 -19
  240. package/src/lib/providers/p2p-native/index.ts +0 -30
  241. package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +0 -523
  242. package/src/lib/providers/p2p-native/p2p-native.provider.ts +0 -723
  243. package/src/lib/providers/p2p-native/p2p-session-manager.ts +0 -696
  244. package/src/lib/providers/wallet-error-handler.ts +0 -349
  245. package/src/lib/providers/walletconnect/core/base-signer.interface.ts +0 -122
  246. package/src/lib/providers/walletconnect/core/session-health.ts +0 -196
  247. package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +0 -364
  248. package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +0 -348
  249. package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +0 -827
  250. package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +0 -273
  251. package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +0 -299
  252. package/src/lib/providers/walletconnect/core/walletconnect-types.ts +0 -48
  253. package/src/lib/providers/walletconnect/index.ts +0 -33
  254. package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +0 -367
  255. package/src/lib/providers/walletconnect/signers/hedera-signer.ts +0 -610
  256. package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +0 -62
  257. package/src/lib/providers/walletconnect/signers/signer-factory.ts +0 -120
  258. package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +0 -296
  259. package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +0 -478
  260. package/src/lib/services/hsuite-auth.interceptor.ts +0 -159
  261. package/src/lib/services/logger.service.ts +0 -126
  262. package/src/lib/services/smart-session.service.ts +0 -378
  263. package/src/lib/services/transaction-builders/active-account-source.spec.ts +0 -75
  264. package/src/lib/services/transaction-builders/active-account-source.ts +0 -55
  265. package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +0 -585
  266. package/src/lib/services/transaction-builders/hedera-amount-utils.ts +0 -84
  267. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +0 -741
  268. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +0 -1285
  269. package/src/lib/services/transaction-builders/index.ts +0 -55
  270. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +0 -937
  271. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +0 -832
  272. package/src/lib/services/transaction.service.ts +0 -349
  273. package/src/lib/services/unified-wallet.service.spec.ts +0 -1382
  274. package/src/lib/services/unified-wallet.service.ts +0 -851
  275. package/src/lib/services/wallet-context.service.ts +0 -184
  276. package/src/lib/services/wallet-event-bus.service.ts +0 -186
  277. package/src/lib/services/wallet-providers.service.ts +0 -136
  278. package/src/lib/transports/chrome-extension-transport.ts +0 -246
  279. package/src/lib/utils/index.ts +0 -15
  280. package/src/lib/utils/ledger-icons.util.ts +0 -109
  281. package/src/lib/utils/ledger-ui-registry.ts +0 -197
  282. package/test/test-setup.ts +0 -21
  283. package/test-setup.ts +0 -63
  284. package/tsconfig.build.json +0 -11
  285. package/tsconfig.json +0 -29
  286. package/tsconfig.spec.json +0 -15
  287. package/vitest.config.ts +0 -48
@@ -1,754 +0,0 @@
1
- /**
2
- * @file Provider implementation for HSuite Native Connect protocol.
3
- * @module providers/hsuite-native-provider
4
- *
5
- * @description
6
- * HsuiteNativeProvider implements the {@link BaseWalletProvider} interface for the
7
- * HSuite Native Connect protocol. This provider enables secure communication between
8
- * dApps and HSuite Wallet using the `hsc:` protocol over Nostr relays with automatic
9
- * WebRTC P2P upgrade.
10
- *
11
- * Key Features:
12
- * - **Local-First Discovery**: Uses BroadcastChannel for instant same-browser wallet detection
13
- * - **Nostr Communication**: Uses Nostr relays for encrypted channel messaging
14
- * - **Automatic P2P Upgrade**: Upgrades to direct WebRTC when possible for lower latency
15
- * - **Session Persistence**: Supports automatic reconnection after page reload
16
- * - **Cross-Platform**: Works with desktop browsers, mobile browsers, and native apps
17
- *
18
- * Connection Flow:
19
- * ```
20
- * 1. dApp calls connect() with configuration
21
- * 2. Provider checks local discovery for same-browser wallets (instant!)
22
- * 3. If wallet found -> sends invite via BroadcastChannel (<1ms)
23
- * 4. If not found -> opens wallet tab/window with invite URL
24
- * 5. Wallet receives invite and establishes channel via Nostr relay
25
- * 6. User approves connection in wallet
26
- * 7. Channel becomes active, accounts are available
27
- * 8. P2P upgrade happens automatically in background
28
- * ```
29
- */
30
-
31
- import { Injectable, signal, computed, inject, effect, NgZone } from '@angular/core';
32
- import { getLogger, LocalDiscoveryService } from '@hsuite/native-connect-sdk';
33
-
34
- import type {
35
- ConnectionStatus,
36
- ProviderMetadata,
37
- ConnectionConfig,
38
- HsuiteNativeConfig,
39
- } from '../models/provider-types';
40
- import { DEFAULT_WALLET_URL } from '../models/provider-types';
41
- import type { UnifiedAccount } from '../models/unified-account.model';
42
- import { WalletEventBus } from '../services/wallet-event-bus.service';
43
-
44
- import {
45
- BaseWalletProvider,
46
- SignTransactionOptions,
47
- SubmitTransactionOptions,
48
- SignResult,
49
- SubmitResult,
50
- SignMessageOptions,
51
- SignMessageResult,
52
- } from './base-wallet-provider';
53
- import { ChannelClientService } from './hsuite-native/channel-client.service';
54
-
55
- const logger = getLogger().scoped?.('HsuiteNativeProvider') ?? getLogger();
56
-
57
- /**
58
- * HSuite Native Connect Provider.
59
- *
60
- * @description
61
- * Angular injectable service that manages wallet connections via the HSuite Native
62
- * Connect protocol. This provider uses the unified channel system for secure,
63
- * encrypted communication between dApps and the HSuite Wallet.
64
- *
65
- * Architecture:
66
- * - Uses {@link ChannelClientService} for unified channel-based communication
67
- * - Implements {@link BaseWalletProvider} interface for integration with {@link UnifiedWalletService}
68
- * - Supports both session (1:1 dApp-wallet) and party (N:N multisig) channels
69
- * - Auto-registers with UnifiedWalletService on injection
70
- *
71
- * Transport States (exposed via `transportState` signal):
72
- * - `'idle'` - No active connection
73
- * - `'nostr-only'` - Connected via Nostr relay only
74
- * - `'upgrading'` - P2P upgrade in progress
75
- * - `'p2p-connected'` - Direct P2P connection established
76
- * - `'p2p-failed'` - P2P upgrade failed, using Nostr fallback
77
- *
78
- * @Component({
79
- * template: `
80
- * <ion-badge [color]="transportColor()">
81
- * {{ transportState() }}
82
- * </ion-badge>
83
- * `
84
- * })
85
- * export class ConnectionStatus {
86
- * private provider = inject(HsuiteNativeProvider);
87
- *
88
- * transportState = this.provider.transportState;
89
- *
90
- * transportColor = computed(() => {
91
- * const state = this.transportState();
92
- * return state === 'p2p-connected' ? 'success' : 'warning';
93
- * });
94
- * }
95
- * ```
96
- *
97
- * @publicApi
98
- */
99
- @Injectable({ providedIn: 'root' })
100
- export class HsuiteNativeProvider extends BaseWalletProvider {
101
- private readonly eventBus = inject(WalletEventBus);
102
- private readonly zone = inject(NgZone);
103
- private readonly channelService = inject(ChannelClientService);
104
-
105
- readonly id = 'hsuite-native';
106
-
107
- readonly metadata: ProviderMetadata = {
108
- id: this.id,
109
- name: 'HSuite Native',
110
- type: 'hsuite-native',
111
- description: 'Connect via HSuite Native Connect protocol',
112
- supportsMultipleAccounts: true,
113
- };
114
-
115
- /**
116
- * Error signal (reactive)
117
- */
118
- readonly error = signal<string | null>(null);
119
-
120
- // Track previous connection state for disconnect detection
121
- private previouslyConnected = false;
122
-
123
- /**
124
- * Local discovery service instance.
125
- * Uses BroadcastChannel for instant, private, same-browser wallet discovery.
126
- */
127
- private localDiscoveryService: LocalDiscoveryService | null = null;
128
-
129
- /**
130
- *
131
- */
132
- constructor() {
133
- super();
134
-
135
- // Initialize local discovery service for same-browser wallet detection
136
- this.initializeLocalDiscovery();
137
-
138
- // Synchronize error state from channel service
139
- effect(() => {
140
- const channelError = this.channelService.error();
141
- if (channelError) {
142
- this.error.set(channelError);
143
- }
144
- });
145
-
146
- // Listen to channel state changes to detect wallet-initiated disconnects
147
- effect(() => {
148
- const status = this.status();
149
- const isConnected = this.channelService.isConnected();
150
-
151
- // If we were connected but now disconnected, emit disconnect event
152
- if (this.previouslyConnected && !isConnected && status === 'disconnected') {
153
- logger.info('[HsuiteNativeProvider] Channel terminated');
154
- this.eventBus.disconnected.emit({
155
- providerId: this.id,
156
- providerType: 'hsuite-native',
157
- reason: 'session_terminated',
158
- timestamp: Date.now(),
159
- });
160
- }
161
-
162
- // Update tracking state
163
- this.previouslyConnected = isConnected;
164
- });
165
-
166
- // Attempt automatic reconnect when session exists after reload
167
- void this.attemptReconnect().catch((error) => {
168
- logger.debug('[HsuiteNativeProvider] Auto-reconnect skipped', { error });
169
- });
170
- }
171
-
172
- /**
173
- * Initialize local discovery for same-browser wallet detection.
174
- * Uses BroadcastChannel for instant, private discovery.
175
- * Cross-device connections use QR/URL flow (no discovery needed).
176
- */
177
- private initializeLocalDiscovery(): void {
178
- this.localDiscoveryService = LocalDiscoveryService.getDAppInstance();
179
- this.localDiscoveryService.start();
180
- }
181
-
182
- /**
183
- * Maps the internal channel state to the provider connection status.
184
- *
185
- * @description
186
- * Computed signal that translates ChannelClientService states to
187
- * standard ConnectionStatus values for UI binding.
188
- *
189
- * @returns Current connection status
190
- */
191
- readonly status = computed<ConnectionStatus>(() => {
192
- const state = this.channelService.state();
193
-
194
- switch (state) {
195
- case 'idle':
196
- return 'idle';
197
- case 'connecting':
198
- case 'pending':
199
- return 'connecting';
200
- case 'active':
201
- case 'approved':
202
- return 'connected';
203
- case 'disconnected':
204
- return 'disconnected';
205
- case 'error':
206
- return 'error';
207
- default:
208
- return 'idle';
209
- }
210
- });
211
-
212
- /**
213
- * Current transport state (nostr-only, upgrading, p2p-connected, p2p-failed).
214
- * Use this to show users whether they're connected via Nostr relay or P2P.
215
- */
216
- readonly transportState = computed(() => this.channelService.transportState());
217
-
218
- /**
219
- * Connected accounts from the wallet in UnifiedAccount format.
220
- *
221
- * @description
222
- * Computed signal that exposes wallet accounts from the channel service
223
- * in the standard UnifiedAccount format for UI binding.
224
- *
225
- * @returns Array of connected accounts (empty when disconnected)
226
- */
227
- readonly accounts = computed<UnifiedAccount[]>(() => {
228
- return this.channelService.unifiedAccounts();
229
- });
230
-
231
- /**
232
- * Check if provider is connected
233
- */
234
- override isConnected(): boolean {
235
- return this.channelService.isConnected();
236
- }
237
-
238
- /**
239
- * Connects to HSuite Wallet via the Native Connect protocol.
240
- *
241
- * @description
242
- * Initiates a connection to HSuite Wallet using the optimal method for the
243
- * current platform:
244
- *
245
- * **Desktop Browsers**:
246
- * 1. Checks if wallet is already online via Nostr discovery (instant!)
247
- * 2. If found, sends invite directly via relay
248
- * 3. If not found, opens wallet in new tab/window
249
- *
250
- * **Mobile Browsers**:
251
- * 1. Tries hsuite: deep link to open native wallet app
252
- * 2. Falls back to opening wallet in same tab (PWA) or new tab
253
- *
254
- * The connection completes when the wallet user approves the session.
255
- *
256
- * @param config - HSuite Native connection configuration
257
- *
258
- * @throws {Error} If configuration is invalid
259
- * @throws {Error} If connection times out (default 120 seconds)
260
- * @throws {Error} If popup is blocked and wallet cannot be opened
261
- */
262
- override async connect(config: ConnectionConfig): Promise<void> {
263
- if (!this.isHsuiteNativeConfig(config)) {
264
- throw new Error('Invalid HSuite Native configuration');
265
- }
266
-
267
- // Guard: Don't start a new connection if already connecting
268
- const currentStatus = this.status();
269
- if (currentStatus === 'connecting') {
270
- logger.warn('Connection already in progress, ignoring duplicate request');
271
- return;
272
- }
273
-
274
- logger.info('Connecting to HSuite Wallet via unified channel protocol', { config });
275
-
276
- try {
277
- const invite = await this.channelService.connect({
278
- type: 'session',
279
- appId: config.appId || 'hsuite-dapp',
280
- appName: config.appName || 'HSuite dApp',
281
- ledgerId: config.ledgerId,
282
- networkId: config.networkId,
283
- walletUrl: config.walletUrl || DEFAULT_WALLET_URL,
284
- });
285
-
286
- // Open wallet with invite URL
287
- const walletUrl = config.walletUrl || DEFAULT_WALLET_URL;
288
- const inviteUrl = this.channelService.getWalletInviteUrl(invite, walletUrl);
289
-
290
- // Open wallet using Nostr-based discovery (works cross-origin, cross-port)
291
- await this.openWalletWindow(inviteUrl, walletUrl, config);
292
-
293
- // Wait for connection to be established
294
- await this.waitForConnection();
295
-
296
- // Run in NgZone to trigger Angular change detection
297
- this.zone.run(() => {
298
- const accounts = this.accounts();
299
- this.eventBus.connected.emit({
300
- providerId: this.id,
301
- providerType: 'hsuite-native',
302
- accounts,
303
- timestamp: Date.now(),
304
- });
305
-
306
- logger.info('Connected successfully via unified channel', {
307
- channelId: invite.id.slice(0, 8),
308
- accountCount: accounts.length,
309
- });
310
- });
311
- } catch (error) {
312
- logger.error('Connection failed', { error });
313
- throw error;
314
- }
315
- }
316
-
317
- /**
318
- * Open wallet window with LOCAL-FIRST discovery.
319
- *
320
- * LOCAL DISCOVERY MODEL:
321
- * 1. Check if wallet is online in same browser via BroadcastChannel (instant!)
322
- * 2. If not immediately found, wait briefly (500ms) for wallet heartbeat
323
- * 3. If wallet found → send invite via BroadcastChannel (<1ms), focus existing tab
324
- * 4. If not found → open wallet tab or use QR/deep link
325
- *
326
- * Cross-device connections use QR/URL flow - the invite is self-contained,
327
- * no discovery needed.
328
- *
329
- * @param inviteUrl - Full URL with invite parameter
330
- * @param walletBaseUrl - Base URL of the wallet
331
- * @param config - Connection configuration with app metadata
332
- */
333
- private async openWalletWindow(
334
- inviteUrl: string,
335
- walletBaseUrl: string,
336
- config?: HsuiteNativeConfig,
337
- ): Promise<void> {
338
- const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
339
-
340
- // LOCAL-FIRST DISCOVERY
341
- // Wait briefly for wallet heartbeat before opening new tab
342
- if (this.localDiscoveryService?.active) {
343
- // Wait up to 500ms for a wallet to announce itself
344
- const wallet = await this.localDiscoveryService.waitForWallet({
345
- timeoutMs: 500,
346
- ledgerId: config?.ledgerId,
347
- });
348
-
349
- if (wallet) {
350
- // Send invite directly via BroadcastChannel - instant, no network!
351
- this.localDiscoveryService.sendInvite(
352
- wallet.fingerprint,
353
- inviteUrl,
354
- config?.appId,
355
- config?.appName,
356
- );
357
- logger.info('[HsuiteNativeProvider] Sent invite via local discovery', {
358
- wallet: wallet.fingerprint.slice(0, 8),
359
- });
360
- return;
361
- }
362
- }
363
-
364
- // MOBILE: Prefer same-tab navigation for PWA wallet
365
- if (isMobile) {
366
- const isSameOrigin = this.isSameOrigin(walletBaseUrl);
367
-
368
- if (isSameOrigin) {
369
- window.location.href = inviteUrl;
370
- return;
371
- } else {
372
- // Try deep link first
373
- const deepLinkUrl = inviteUrl.replace(/^https?:/, 'hsuite:');
374
- try {
375
- window.location.href = deepLinkUrl;
376
- await new Promise((resolve) => setTimeout(resolve, 500));
377
- } catch {
378
- // Deep link failed, continue to open tab
379
- }
380
- }
381
- }
382
-
383
- // FALLBACK: Open wallet in a new tab (for same-browser) or show QR (cross-device)
384
- // §29.8 SOC2 CC6.1: noopener,noreferrer prevents a compromised dApp-supplied
385
- // inviteUrl from hijacking the dApp tab via window.opener. A side effect is
386
- // that window.open() returns null, so we can no longer use the return value
387
- // to detect popup-blocked; modern browsers surface that via their own UI
388
- // and the caller's waitForConnection() timeout will error out if the user
389
- // dismissed the popup dialog without allowing.
390
- const walletWindow = window.open(inviteUrl, 'hsuite-wallet', 'noopener,noreferrer');
391
- // .focus() is a no-op with noopener (walletWindow === null); fresh tabs
392
- // are already focused in every mainstream browser.
393
- void walletWindow;
394
- }
395
-
396
- /**
397
- * Check if a URL is same origin as current page.
398
- * @param url
399
- */
400
- private isSameOrigin(url: string): boolean {
401
- try {
402
- const walletOrigin = new URL(url).origin;
403
- return walletOrigin === window.location.origin;
404
- } catch {
405
- return false;
406
- }
407
- }
408
-
409
- /**
410
- * Wait for channel connection to be established
411
- * @param timeoutMs
412
- */
413
- private async waitForConnection(timeoutMs = 120000): Promise<void> {
414
- const startTime = Date.now();
415
-
416
- return new Promise((resolve, reject) => {
417
- const checkConnection = () => {
418
- if (this.channelService.isConnected()) {
419
- resolve();
420
- return;
421
- }
422
-
423
- const state = this.channelService.state();
424
- if (state === 'error') {
425
- reject(new Error(this.channelService.error() || 'Connection failed'));
426
- return;
427
- }
428
-
429
- // Also handle disconnected state (wallet rejected or terminated)
430
- if (state === 'disconnected') {
431
- reject(new Error(this.channelService.error() || 'Connection rejected by wallet'));
432
- return;
433
- }
434
-
435
- if (Date.now() - startTime > timeoutMs) {
436
- reject(new Error('Connection timeout'));
437
- return;
438
- }
439
-
440
- setTimeout(checkConnection, 100);
441
- };
442
-
443
- checkConnection();
444
- });
445
- }
446
-
447
- /**
448
- * Disconnects from the HSuite Wallet.
449
- *
450
- * @description
451
- * Terminates the channel connection and clears session state. The wallet
452
- * is notified of the disconnection. Emits a 'disconnected' event via
453
- * WalletEventBus regardless of success or failure.
454
- *
455
- * @throws {Error} If disconnection fails (event still emitted)
456
- */
457
- override async disconnect(): Promise<void> {
458
- logger.info('Disconnecting from HSuite Wallet');
459
-
460
- try {
461
- await this.channelService.disconnect();
462
-
463
- // Emit disconnection event
464
- this.eventBus.disconnected.emit({
465
- providerId: this.id,
466
- providerType: 'hsuite-native',
467
- reason: 'user_initiated',
468
- timestamp: Date.now(),
469
- });
470
-
471
- logger.info('Disconnected successfully');
472
- } catch (error) {
473
- logger.error('Disconnection failed', { error });
474
- // Still emit event even if disconnect fails
475
- this.eventBus.disconnected.emit({
476
- providerId: this.id,
477
- providerType: 'hsuite-native',
478
- reason: 'error',
479
- timestamp: Date.now(),
480
- });
481
- throw error;
482
- }
483
- }
484
-
485
- /**
486
- * Signs a transaction without submitting it to the network.
487
- *
488
- * @description
489
- * Sends the transaction payload to the wallet for signing. The wallet
490
- * displays the transaction details and prompts the user for approval.
491
- * If approved, the signed transaction is returned.
492
- *
493
- * @param options - Transaction signing options
494
- *
495
- * @returns Promise resolving to the signing result with signed payload
496
- *
497
- * @throws {Error} If user rejects the signing request
498
- * @throws {Error} If wallet is not connected
499
- * @throws {Error} If channel communication fails
500
- */
501
- override async signTransaction(options: SignTransactionOptions): Promise<SignResult> {
502
- logger.info('Signing transaction', { options });
503
-
504
- try {
505
- const response = await this.channelService.signTransaction({
506
- accountAddress: options.accountAddress,
507
- payload: options.payload,
508
- ledgerId: options.ledgerId,
509
- networkId: options.networkId,
510
- });
511
-
512
- logger.info('Transaction signed');
513
-
514
- return {
515
- signedPayload: response.signedPayload || '',
516
- signature: response.signature,
517
- metadata: response.metadata,
518
- };
519
- } catch (error) {
520
- logger.error('Transaction signing failed', { error });
521
- throw error;
522
- }
523
- }
524
-
525
- /**
526
- * Signs and executes a transaction atomically in a single prompt.
527
- *
528
- * @description
529
- * Performs sign and submit as a single atomic operation with one user
530
- * approval prompt. This is the recommended method for transaction submission
531
- * as it provides better UX and matches WalletConnect's behavior.
532
- *
533
- * Called by {@link UnifiedWalletService.signAndExecuteTransaction} to ensure
534
- * consistent single-prompt behavior across all provider types.
535
- *
536
- * @param options - Transaction submission options
537
- *
538
- * @returns Promise resolving to submission result with transaction ID
539
- *
540
- * @throws {Error} If user rejects the transaction
541
- * @throws {Error} If wallet is not connected
542
- * @throws {Error} If transaction submission fails
543
- */
544
- async signAndExecuteTransaction(options: SubmitTransactionOptions): Promise<SubmitResult> {
545
- logger.info('signAndExecuteTransaction called (single prompt)', {
546
- accountAddress: options.accountAddress,
547
- ledgerId: options.ledgerId,
548
- networkId: options.networkId,
549
- });
550
-
551
- return this.submitTransactionInternal(options);
552
- }
553
-
554
- /**
555
- * Signs and submits a transaction to the blockchain.
556
- *
557
- * @description
558
- * The **preferred method** for submitting transactions. Performs sign and
559
- * submit as a single atomic operation requiring only ONE user approval.
560
- *
561
- * Advantages over separate sign/submit:
562
- * - Single wallet prompt (better UX)
563
- * - Matches WalletConnect's `hedera_signAndExecuteTransaction` behavior
564
- * - Atomic operation (no partial state)
565
- *
566
- * @param options - Transaction submission options
567
- *
568
- * @returns Promise resolving to submission result with transaction ID
569
- *
570
- * @throws {Error} If user rejects the transaction
571
- * @throws {Error} If wallet is not connected
572
- * @throws {Error} If transaction submission fails
573
- */
574
- override async submitTransaction(options: SubmitTransactionOptions): Promise<SubmitResult> {
575
- return this.submitTransactionInternal(options);
576
- }
577
-
578
- /**
579
- * Internal implementation of sign and submit.
580
- * Both submitTransaction() and signAndExecuteTransaction() delegate here.
581
- *
582
- * @param options
583
- */
584
- private async submitTransactionInternal(
585
- options: SubmitTransactionOptions,
586
- ): Promise<SubmitResult> {
587
- logger.info('Signing and submitting transaction (single prompt)', {
588
- accountAddress: options.accountAddress,
589
- ledgerId: options.ledgerId,
590
- networkId: options.networkId,
591
- });
592
-
593
- try {
594
- const response = await this.channelService.signAndSubmitTransaction({
595
- accountAddress: options.accountAddress,
596
- payload: options.payload,
597
- ledgerId: options.ledgerId,
598
- networkId: options.networkId,
599
- // Pass batch transaction fields if present
600
- ...(options.isBatch && {
601
- isBatch: options.isBatch,
602
- batchKey: options.batchKey,
603
- innerTransactions: options.innerTransactions,
604
- }),
605
- });
606
-
607
- logger.info('Transaction signed and submitted successfully', {
608
- transactionId: response.transactionId,
609
- transactionHash: response.transactionHash?.substring(0, 16),
610
- });
611
-
612
- return {
613
- transactionId: response.transactionId,
614
- transactionHash: response.transactionHash,
615
- metadata: response.metadata,
616
- };
617
- } catch (error) {
618
- logger.error('Transaction sign+submit failed', { error });
619
- throw error;
620
- }
621
- }
622
-
623
- /**
624
- * Signs an arbitrary message for authentication or verification.
625
- *
626
- * @description
627
- * Requests the wallet to sign a non-transaction message. Common use cases:
628
- * - Authentication challenges (prove account ownership)
629
- * - DAO voting
630
- * - Off-chain signatures
631
- * - Message verification
632
- *
633
- * @param options - Message signing options
634
- *
635
- * @returns Promise resolving to signature result
636
- *
637
- * @throws {Error} If user rejects the signing request
638
- * @throws {Error} If wallet is not connected
639
- */
640
- override async signMessage(options: SignMessageOptions): Promise<SignMessageResult> {
641
- logger.info('Signing message', {
642
- accountAddress: options.accountAddress,
643
- encoding: options.encoding,
644
- messageLength: options.message?.length,
645
- });
646
-
647
- try {
648
- const response = await this.channelService.request<{
649
- signature?: string;
650
- publicKey?: string;
651
- // §21.3 extended shape — new wallets include these fields.
652
- // Older wallets (pre-§21.3) omit them; the optional chain below
653
- // keeps us backwards-compatible with both.
654
- algorithm?: 'ed25519' | 'ecdsa_secp256k1' | 'secp256k1';
655
- encoding?: 'utf-8' | 'base64';
656
- caipChainId?: string;
657
- messageLength?: number;
658
- metadata?: Record<string, unknown>;
659
- }>('ledger/signMessage', {
660
- accountAddress: options.accountAddress,
661
- message: options.message,
662
- encoding: options.encoding || 'utf-8',
663
- ledgerId: options.ledgerId,
664
- networkId: options.networkId,
665
- });
666
-
667
- logger.info('Message signed successfully', {
668
- algorithm: response.algorithm,
669
- caipChainId: response.caipChainId,
670
- });
671
-
672
- // Pass ALL fields through so the dApp's TransactionService sees the
673
- // full MessageSignResult shape (§21.3 strict end-to-end contract).
674
- return {
675
- signature: response.signature || '',
676
- publicKey: response.publicKey,
677
- algorithm: response.algorithm,
678
- encoding: response.encoding,
679
- caipChainId: response.caipChainId,
680
- messageLength: response.messageLength,
681
- metadata: response.metadata,
682
- };
683
- } catch (error) {
684
- logger.error('Message signing failed', { error });
685
- throw error;
686
- }
687
- }
688
-
689
- /**
690
- * Checks if HSuite Native provider is available.
691
- *
692
- * @description
693
- * HSuite Native is always available because it can use either:
694
- * - Direct Nostr relay connection (if wallet is online)
695
- * - Opening wallet in a new browser tab/window
696
- * - Deep linking to native app on mobile
697
- *
698
- * @returns Promise always resolving to true
699
- */
700
- override async isAvailable(): Promise<boolean> {
701
- // HSuite Native is always available (can open wallet window or use extension)
702
- return true;
703
- }
704
-
705
- /**
706
- * Attempts to restore a previous session and reconnect automatically.
707
- *
708
- * @description
709
- * Checks for stored session data and attempts to re-establish the wallet
710
- * connection without requiring user interaction. This is called automatically
711
- * on provider initialization.
712
- *
713
- * If successful, emits a 'sessionRestored' event via WalletEventBus.
714
- *
715
- * @returns Promise resolving to true if reconnection succeeded, false otherwise
716
- */
717
- async attemptReconnect(): Promise<boolean> {
718
- logger.info('Attempting reconnect via unified channel');
719
-
720
- try {
721
- const success = await this.channelService.attemptRestore();
722
-
723
- if (success) {
724
- const accounts = this.accounts();
725
- const invite = this.channelService.currentInvite();
726
-
727
- this.eventBus.sessionRestored.emit({
728
- providerId: this.id,
729
- sessionKey: invite?.id || '',
730
- accounts,
731
- metadata: { autoReconnected: true },
732
- timestamp: Date.now(),
733
- });
734
-
735
- logger.info('Reconnect successful');
736
- } else {
737
- logger.warn('Reconnect failed - no session or unable to connect');
738
- }
739
-
740
- return success;
741
- } catch (error) {
742
- logger.error('Reconnect failed', { error });
743
- return false;
744
- }
745
- }
746
-
747
- /**
748
- * Type guard for HSuite Native config
749
- * @param config
750
- */
751
- private isHsuiteNativeConfig(config: ConnectionConfig): config is HsuiteNativeConfig {
752
- return config.type === 'hsuite-native';
753
- }
754
- }