@hsuite/native-connect-angular 1.0.0

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 (276) hide show
  1. package/README.md +48 -0
  2. package/USAGE_EXAMPLES.md +476 -0
  3. package/assets/wallets/extension.svg +7 -0
  4. package/assets/wallets/hashpack.svg +6 -0
  5. package/assets/wallets/hsuite.svg +11 -0
  6. package/assets/wallets/kabila.svg +11 -0
  7. package/assets/wallets/walletconnect.svg +13 -0
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/coverage-summary.json +50 -0
  11. package/coverage/favicon.png +0 -0
  12. package/coverage/index.html +476 -0
  13. package/coverage/lcov-report/base.css +224 -0
  14. package/coverage/lcov-report/block-navigation.js +87 -0
  15. package/coverage/lcov-report/favicon.png +0 -0
  16. package/coverage/lcov-report/index.html +476 -0
  17. package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
  18. package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +116 -0
  19. package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
  20. package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +116 -0
  21. package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +685 -0
  22. package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +766 -0
  23. package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
  24. package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +116 -0
  25. package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +1495 -0
  26. package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +1588 -0
  27. package/coverage/lcov-report/lib/components/account-selector/index.html +161 -0
  28. package/coverage/lcov-report/lib/components/wallet-account-display/index.html +116 -0
  29. package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
  30. package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +116 -0
  31. package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
  32. package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +116 -0
  33. package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
  34. package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +116 -0
  35. package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
  36. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
  37. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
  38. package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +116 -0
  39. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
  40. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
  41. package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
  42. package/coverage/lcov-report/lib/components/wallet-session-display/index.html +116 -0
  43. package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
  44. package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +116 -0
  45. package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
  46. package/coverage/lcov-report/lib/directives/index.html +146 -0
  47. package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +670 -0
  48. package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +547 -0
  49. package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +781 -0
  50. package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +715 -0
  51. package/coverage/lcov-report/lib/index.html +116 -0
  52. package/coverage/lcov-report/lib/models/connection-config.model.ts.html +280 -0
  53. package/coverage/lcov-report/lib/models/index.html +131 -0
  54. package/coverage/lcov-report/lib/models/provider-types.ts.html +577 -0
  55. package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +1138 -0
  56. package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
  57. package/coverage/lcov-report/lib/providers/hsuite-native/index.html +116 -0
  58. package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +2347 -0
  59. package/coverage/lcov-report/lib/providers/index.html +146 -0
  60. package/coverage/lcov-report/lib/providers/p2p-native/index.html +131 -0
  61. package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
  62. package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
  63. package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +1132 -0
  64. package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +176 -0
  65. package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +673 -0
  66. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
  67. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
  68. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
  69. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
  70. package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
  71. package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +146 -0
  72. package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
  73. package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
  74. package/coverage/lcov-report/lib/services/index.html +191 -0
  75. package/coverage/lcov-report/lib/services/logger.service.ts.html +463 -0
  76. package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
  77. package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
  78. package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
  79. package/coverage/lcov-report/lib/services/transaction-builders/index.html +161 -0
  80. package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
  81. package/coverage/lcov-report/lib/services/transaction.service.ts.html +1123 -0
  82. package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +2641 -0
  83. package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +637 -0
  84. package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +643 -0
  85. package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +496 -0
  86. package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +823 -0
  87. package/coverage/lcov-report/lib/transports/index.html +116 -0
  88. package/coverage/lcov-report/lib/utils/index.html +116 -0
  89. package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +319 -0
  90. package/coverage/lcov-report/prettify.css +1 -0
  91. package/coverage/lcov-report/prettify.js +2 -0
  92. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  93. package/coverage/lcov-report/sorter.js +210 -0
  94. package/coverage/lcov.info +19252 -0
  95. package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
  96. package/coverage/lib/components/account-selector/account-actions/index.html +116 -0
  97. package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
  98. package/coverage/lib/components/account-selector/account-filter/index.html +116 -0
  99. package/coverage/lib/components/account-selector/account-formatting.service.ts.html +685 -0
  100. package/coverage/lib/components/account-selector/account-grouping.service.ts.html +766 -0
  101. package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
  102. package/coverage/lib/components/account-selector/account-list/index.html +116 -0
  103. package/coverage/lib/components/account-selector/account-selector.component.ts.html +1495 -0
  104. package/coverage/lib/components/account-selector/account-selector.service.ts.html +1588 -0
  105. package/coverage/lib/components/account-selector/index.html +161 -0
  106. package/coverage/lib/components/wallet-account-display/index.html +116 -0
  107. package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
  108. package/coverage/lib/components/wallet-connect-button/index.html +116 -0
  109. package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
  110. package/coverage/lib/components/wallet-connect-prompt/index.html +116 -0
  111. package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
  112. package/coverage/lib/components/wallet-connected-guard/index.html +116 -0
  113. package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
  114. package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
  115. package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
  116. package/coverage/lib/components/wallet-connection-modal/index.html +116 -0
  117. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
  118. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
  119. package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
  120. package/coverage/lib/components/wallet-session-display/index.html +116 -0
  121. package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
  122. package/coverage/lib/components/wallet-transaction-status/index.html +116 -0
  123. package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
  124. package/coverage/lib/directives/index.html +146 -0
  125. package/coverage/lib/directives/wallet-connected.directive.ts.html +670 -0
  126. package/coverage/lib/directives/wallet-context.directive.ts.html +547 -0
  127. package/coverage/lib/directives/wallet-events.directive.ts.html +781 -0
  128. package/coverage/lib/hsuite-wallet.module.ts.html +715 -0
  129. package/coverage/lib/index.html +116 -0
  130. package/coverage/lib/models/connection-config.model.ts.html +280 -0
  131. package/coverage/lib/models/index.html +131 -0
  132. package/coverage/lib/models/provider-types.ts.html +577 -0
  133. package/coverage/lib/providers/base-wallet-provider.ts.html +1138 -0
  134. package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
  135. package/coverage/lib/providers/hsuite-native/index.html +116 -0
  136. package/coverage/lib/providers/hsuite-native-provider.ts.html +2347 -0
  137. package/coverage/lib/providers/index.html +146 -0
  138. package/coverage/lib/providers/p2p-native/index.html +131 -0
  139. package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
  140. package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
  141. package/coverage/lib/providers/wallet-error-handler.ts.html +1132 -0
  142. package/coverage/lib/providers/walletconnect/core/index.html +176 -0
  143. package/coverage/lib/providers/walletconnect/core/session-health.ts.html +673 -0
  144. package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
  145. package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
  146. package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
  147. package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
  148. package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
  149. package/coverage/lib/providers/walletconnect/signers/index.html +146 -0
  150. package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
  151. package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
  152. package/coverage/lib/services/index.html +191 -0
  153. package/coverage/lib/services/logger.service.ts.html +463 -0
  154. package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
  155. package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
  156. package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
  157. package/coverage/lib/services/transaction-builders/index.html +161 -0
  158. package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
  159. package/coverage/lib/services/transaction.service.ts.html +1123 -0
  160. package/coverage/lib/services/unified-wallet.service.ts.html +2641 -0
  161. package/coverage/lib/services/wallet-context.service.ts.html +637 -0
  162. package/coverage/lib/services/wallet-event-bus.service.ts.html +643 -0
  163. package/coverage/lib/services/wallet-providers.service.ts.html +496 -0
  164. package/coverage/lib/transports/chrome-extension-transport.ts.html +823 -0
  165. package/coverage/lib/transports/index.html +116 -0
  166. package/coverage/lib/utils/index.html +116 -0
  167. package/coverage/lib/utils/ledger-icons.util.ts.html +319 -0
  168. package/coverage/prettify.css +1 -0
  169. package/coverage/prettify.js +2 -0
  170. package/coverage/sort-arrow-sprite.png +0 -0
  171. package/coverage/sorter.js +210 -0
  172. package/dist/README.md +48 -0
  173. package/dist/fesm2022/hsuite-native-connect-angular.mjs +14592 -0
  174. package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -0
  175. package/dist/index.d.ts +6949 -0
  176. package/examples/minimal-connect.ts +178 -0
  177. package/examples/multi-protocol.ts +495 -0
  178. package/examples/transaction-signing.ts +361 -0
  179. package/jest.config.json +45 -0
  180. package/karma.conf.js +42 -0
  181. package/ng-package.json +20 -0
  182. package/package.json +60 -0
  183. package/src/index.ts +203 -0
  184. package/src/lib/components/account-selector/account-actions/account-actions.component.ts +261 -0
  185. package/src/lib/components/account-selector/account-filter/account-filter.component.ts +401 -0
  186. package/src/lib/components/account-selector/account-formatting.service.ts +200 -0
  187. package/src/lib/components/account-selector/account-grouping.service.ts +227 -0
  188. package/src/lib/components/account-selector/account-list/account-list.component.ts +470 -0
  189. package/src/lib/components/account-selector/account-selector.component.html +135 -0
  190. package/src/lib/components/account-selector/account-selector.component.scss +2039 -0
  191. package/src/lib/components/account-selector/account-selector.component.ts +470 -0
  192. package/src/lib/components/account-selector/account-selector.service.ts +501 -0
  193. package/src/lib/components/wallet-account-display/wallet-account-display.component.html +34 -0
  194. package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +99 -0
  195. package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +140 -0
  196. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +14 -0
  197. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +272 -0
  198. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +240 -0
  199. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +24 -0
  200. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +50 -0
  201. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +108 -0
  202. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +24 -0
  203. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +73 -0
  204. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +56 -0
  205. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +218 -0
  206. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +117 -0
  207. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +94 -0
  208. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +272 -0
  209. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +734 -0
  210. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +197 -0
  211. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +678 -0
  212. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +730 -0
  213. package/src/lib/components/wallet-session-display/wallet-session-display.component.html +110 -0
  214. package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +179 -0
  215. package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +197 -0
  216. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +65 -0
  217. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +254 -0
  218. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +206 -0
  219. package/src/lib/directives/wallet-connected.directive.ts +195 -0
  220. package/src/lib/directives/wallet-context.directive.ts +154 -0
  221. package/src/lib/directives/wallet-events.directive.ts +232 -0
  222. package/src/lib/hsuite-wallet.module.ts +210 -0
  223. package/src/lib/models/connection-config.model.ts +65 -0
  224. package/src/lib/models/provider-types.ts +164 -0
  225. package/src/lib/models/unified-account.model.ts +76 -0
  226. package/src/lib/models/wallet-context.model.ts +121 -0
  227. package/src/lib/models/wallet-events.model.ts +158 -0
  228. package/src/lib/providers/base-wallet-provider.ts +351 -0
  229. package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +73 -0
  230. package/src/lib/providers/hsuite-native/channel-client.service.ts +862 -0
  231. package/src/lib/providers/hsuite-native/index.ts +8 -0
  232. package/src/lib/providers/hsuite-native-provider.ts +754 -0
  233. package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +19 -0
  234. package/src/lib/providers/p2p-native/index.ts +30 -0
  235. package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +523 -0
  236. package/src/lib/providers/p2p-native/p2p-native.provider.ts +723 -0
  237. package/src/lib/providers/p2p-native/p2p-session-manager.ts +695 -0
  238. package/src/lib/providers/wallet-error-handler.ts +349 -0
  239. package/src/lib/providers/walletconnect/core/base-signer.interface.ts +122 -0
  240. package/src/lib/providers/walletconnect/core/session-health.ts +196 -0
  241. package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +364 -0
  242. package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +348 -0
  243. package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +826 -0
  244. package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +273 -0
  245. package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +299 -0
  246. package/src/lib/providers/walletconnect/core/walletconnect-types.ts +48 -0
  247. package/src/lib/providers/walletconnect/index.ts +33 -0
  248. package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +367 -0
  249. package/src/lib/providers/walletconnect/signers/hedera-signer.ts +610 -0
  250. package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +62 -0
  251. package/src/lib/providers/walletconnect/signers/signer-factory.ts +120 -0
  252. package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +296 -0
  253. package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +478 -0
  254. package/src/lib/services/logger.service.ts +126 -0
  255. package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +585 -0
  256. package/src/lib/services/transaction-builders/hedera-amount-utils.ts +84 -0
  257. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +741 -0
  258. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +1285 -0
  259. package/src/lib/services/transaction-builders/index.ts +54 -0
  260. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +937 -0
  261. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +832 -0
  262. package/src/lib/services/transaction.service.ts +346 -0
  263. package/src/lib/services/unified-wallet.service.spec.ts +1382 -0
  264. package/src/lib/services/unified-wallet.service.ts +852 -0
  265. package/src/lib/services/wallet-context.service.ts +184 -0
  266. package/src/lib/services/wallet-event-bus.service.ts +186 -0
  267. package/src/lib/services/wallet-providers.service.ts +137 -0
  268. package/src/lib/transports/chrome-extension-transport.ts +246 -0
  269. package/src/lib/utils/index.ts +14 -0
  270. package/src/lib/utils/ledger-icons.util.ts +78 -0
  271. package/test/test-setup.ts +21 -0
  272. package/test-setup.ts +63 -0
  273. package/tsconfig.build.json +11 -0
  274. package/tsconfig.json +29 -0
  275. package/tsconfig.spec.json +15 -0
  276. package/vitest.config.ts +48 -0
@@ -0,0 +1,351 @@
1
+ /**
2
+ * @file Abstract base class for wallet connection providers.
3
+ * @module providers/base-wallet-provider
4
+ *
5
+ * @description
6
+ * BaseWalletProvider defines the common interface that all wallet providers must implement.
7
+ * It ensures consistency across different wallet connection protocols while allowing
8
+ * provider-specific implementations.
9
+ *
10
+ * The Angular SDK includes three built-in providers:
11
+ * - **HsuiteNativeProvider**: HSuite Native Connect protocol
12
+ * - **WalletConnectV2Provider**: WalletConnect v2 protocol
13
+ * - **P2PNativeProvider**: Direct P2P connections via WebRTC
14
+ *
15
+ * Custom providers can extend this class to integrate additional wallet types.
16
+ *
17
+ * @Injectable({ providedIn: 'root' })
18
+ * export class MyCustomProvider extends BaseWalletProvider {
19
+ * readonly id = 'my-custom-wallet';
20
+ *
21
+ * readonly metadata: ProviderMetadata = {
22
+ * id: this.id,
23
+ * name: 'My Custom Wallet',
24
+ * type: 'custom',
25
+ * description: 'Custom wallet integration',
26
+ * supportsMultipleAccounts: false,
27
+ * };
28
+ *
29
+ * readonly status = signal<ConnectionStatus>('disconnected');
30
+ * readonly accounts = signal<UnifiedAccount[]>([]);
31
+ * readonly error = signal<string | null>(null);
32
+ *
33
+ * async connect(config: ConnectionConfig): Promise<void> {
34
+ * // Implementation
35
+ * }
36
+ *
37
+ * async disconnect(): Promise<void> {
38
+ * // Implementation
39
+ * }
40
+ *
41
+ * // ... other abstract methods
42
+ * }
43
+ * ```
44
+ */
45
+
46
+ import type { Signal } from '@angular/core';
47
+
48
+ import type { ConnectionConfig } from '../models/connection-config.model';
49
+ import type { ConnectionStatus, ProviderMetadata } from '../models/provider-types';
50
+ import type { UnifiedAccount } from '../models/unified-account.model';
51
+
52
+ /**
53
+ * Options for signing a blockchain transaction.
54
+ *
55
+ * @description
56
+ * Configuration object passed to {@link BaseWalletProvider.signTransaction}.
57
+ */
58
+ export interface SignTransactionOptions {
59
+ /** The account address to sign with (e.g., '0.0.123456' for Hedera) */
60
+ accountAddress: string;
61
+ /** Serialized transaction payload (format depends on ledger type) */
62
+ payload: string;
63
+ /** Ledger identifier (e.g., 'hedera', 'xrpl') */
64
+ ledgerId?: string;
65
+ /** Network identifier (e.g., 'mainnet', 'testnet') */
66
+ networkId?: string;
67
+ }
68
+
69
+ /**
70
+ * Options for submitting a transaction to the blockchain.
71
+ *
72
+ * @description
73
+ * Extends {@link SignTransactionOptions} with batch transaction support.
74
+ * Configuration object passed to {@link BaseWalletProvider.submitTransaction}.
75
+ */
76
+ export interface SubmitTransactionOptions extends SignTransactionOptions {
77
+ /** Whether this is a batch/atomic transaction */
78
+ isBatch?: boolean;
79
+ /** Unique identifier for batch grouping */
80
+ batchKey?: string;
81
+ /** Inner transactions within the batch */
82
+ innerTransactions?: Array<{ payload: string; description?: string }>;
83
+ }
84
+
85
+ /**
86
+ * Result of a transaction signing operation.
87
+ *
88
+ * @description
89
+ * Returned by {@link BaseWalletProvider.signTransaction} upon successful signing.
90
+ */
91
+ export interface SignResult {
92
+ /** The transaction payload with signature applied */
93
+ signedPayload: string;
94
+ /** Raw signature bytes (optional, format depends on ledger) */
95
+ signature?: string;
96
+ /** Additional metadata from the wallet */
97
+ metadata?: Record<string, unknown>;
98
+ }
99
+
100
+ /**
101
+ * Result of a transaction submission.
102
+ *
103
+ * @description
104
+ * Returned by {@link BaseWalletProvider.submitTransaction} upon successful submission.
105
+ */
106
+ export interface SubmitResult {
107
+ /** Ledger-specific transaction identifier (e.g., '0.0.123@1234567890.123' for Hedera) */
108
+ transactionId: string;
109
+ /** Transaction hash/ID on the blockchain */
110
+ transactionHash?: string;
111
+ /** Additional metadata from the wallet */
112
+ metadata?: Record<string, unknown>;
113
+ }
114
+
115
+ /**
116
+ * Options for signing an arbitrary message.
117
+ *
118
+ * @description
119
+ * Configuration object passed to {@link BaseWalletProvider.signMessage}.
120
+ * Used for authentication, DAO voting, and other non-transaction signatures.
121
+ */
122
+ export interface SignMessageOptions {
123
+ /** The account address to sign with */
124
+ accountAddress: string;
125
+ /** The message to sign (plain text or base64 encoded) */
126
+ message: string;
127
+ /** Encoding of the message: 'utf-8' (default) or 'base64' */
128
+ encoding?: 'utf-8' | 'base64';
129
+ /** Ledger identifier (e.g., 'hedera', 'xrpl') */
130
+ ledgerId?: string;
131
+ /** Network identifier (e.g., 'mainnet', 'testnet') */
132
+ networkId?: string;
133
+ }
134
+
135
+ /**
136
+ * Result of a message signing operation.
137
+ *
138
+ * @description
139
+ * Returned by {@link BaseWalletProvider.signMessage} upon successful signing.
140
+ */
141
+ export interface SignMessageResult {
142
+ /** The signature over the domain-separated message (hex, format depends on ledger). */
143
+ signature: string;
144
+ /** The public key used for signing (for verification). */
145
+ publicKey?: string;
146
+ /**
147
+ * Algorithm label (§21.3 — added for deterministic verification across
148
+ * chains). Absent on legacy responses from older wallets.
149
+ */
150
+ algorithm?: 'ed25519' | 'ecdsa_secp256k1' | 'secp256k1';
151
+ /**
152
+ * Echo of the request's encoding. Callers use it to decode `message`
153
+ * back into bytes when reconstructing the signed blob for verification.
154
+ */
155
+ encoding?: 'utf-8' | 'base64';
156
+ /**
157
+ * CAIP-2 chain identifier that was embedded in the signed blob. Enables
158
+ * third-party verifiers to reconstruct the exact signed bytes without
159
+ * extra network context.
160
+ */
161
+ caipChainId?: string;
162
+ /**
163
+ * Decoded message byte length (NOT character count). Prevents truncation
164
+ * ambiguity when verifying the signature.
165
+ */
166
+ messageLength?: number;
167
+ /** Additional metadata from the wallet. */
168
+ metadata?: Record<string, unknown>;
169
+ }
170
+
171
+ /**
172
+ * Abstract base class that all wallet providers must implement.
173
+ *
174
+ * @description
175
+ * BaseWalletProvider defines the contract for wallet integrations. All providers
176
+ * (HSuite Native, WalletConnect, P2P, etc.) extend this class to ensure a
177
+ * consistent API for dApp developers.
178
+ *
179
+ * Key responsibilities:
180
+ * - Managing connection state via reactive signals
181
+ * - Exposing connected accounts
182
+ * - Handling transaction signing and submission
183
+ * - Message signing for authentication
184
+ *
185
+ * Implementers must provide:
186
+ * - Unique `id` and `metadata` for identification
187
+ * - Reactive `status`, `accounts`, and `error` signals
188
+ * - `connect()` and `disconnect()` lifecycle methods
189
+ * - `signTransaction()`, `submitTransaction()`, and `signMessage()` for operations
190
+ * - `isAvailable()` to check if the wallet type is available
191
+ *
192
+ * @publicApi
193
+ */
194
+ export abstract class BaseWalletProvider {
195
+ /**
196
+ * Unique identifier for this provider instance.
197
+ *
198
+ * @description
199
+ * Used to identify the provider in the registry. Must be unique across
200
+ * all registered providers.
201
+ */
202
+ abstract readonly id: string;
203
+
204
+ /**
205
+ * Provider metadata for display and identification.
206
+ *
207
+ * @description
208
+ * Contains display information (name, description, icon) and feature flags
209
+ * for the provider.
210
+ */
211
+ abstract readonly metadata: ProviderMetadata;
212
+
213
+ /**
214
+ * Current connection status as a reactive Angular signal.
215
+ *
216
+ * @description
217
+ * Tracks the lifecycle state of the wallet connection. UI components can
218
+ * use this signal to reactively update based on connection state.
219
+ *
220
+ * Possible values:
221
+ * - `'idle'`: Not connected, no connection attempt in progress
222
+ * - `'connecting'`: Connection attempt in progress
223
+ * - `'connected'`: Successfully connected to wallet
224
+ * - `'disconnected'`: Previously connected, now disconnected
225
+ * - `'error'`: Connection failed (check `error` signal for details)
226
+ */
227
+ abstract readonly status: Signal<ConnectionStatus>;
228
+
229
+ /**
230
+ * Connected accounts as a reactive Angular signal.
231
+ *
232
+ * @description
233
+ * List of accounts available from the connected wallet. Empty when
234
+ * disconnected. Updates automatically when wallet accounts change.
235
+ */
236
+ abstract readonly accounts: Signal<UnifiedAccount[]>;
237
+
238
+ /**
239
+ * Error message if status is 'error', as a reactive Angular signal.
240
+ *
241
+ * @description
242
+ * Contains human-readable error message when connection fails.
243
+ * Null when no error has occurred.
244
+ */
245
+ abstract readonly error: Signal<string | null>;
246
+
247
+ /**
248
+ * Connects to the wallet with the given configuration.
249
+ *
250
+ * @description
251
+ * Initiates a connection to the wallet. The connection flow varies by
252
+ * provider type (QR code, popup, deep link, etc.).
253
+ *
254
+ * @param config - Provider-specific connection configuration
255
+ *
256
+ * @throws {Error} If connection fails or times out
257
+ */
258
+ abstract connect(config: ConnectionConfig): Promise<void>;
259
+
260
+ /**
261
+ * Disconnects from the wallet.
262
+ *
263
+ * @description
264
+ * Terminates the wallet connection and clears account state.
265
+ */
266
+ abstract disconnect(): Promise<void>;
267
+
268
+ /**
269
+ * Signs a transaction without submitting it.
270
+ *
271
+ * @description
272
+ * Requests the wallet to sign the transaction payload. The signed
273
+ * transaction can later be submitted to the network.
274
+ *
275
+ * @param options - Transaction signing options
276
+ *
277
+ * @returns Promise resolving to the signing result
278
+ *
279
+ * @throws {Error} If user rejects or signing fails
280
+ */
281
+ abstract signTransaction(options: SignTransactionOptions): Promise<SignResult>;
282
+
283
+ /**
284
+ * Signs and submits a transaction to the network.
285
+ *
286
+ * @description
287
+ * Performs a complete transaction lifecycle: sign and submit to the
288
+ * blockchain network.
289
+ *
290
+ * @param options - Transaction submission options
291
+ *
292
+ * @returns Promise resolving to the submission result
293
+ *
294
+ * @throws {Error} If user rejects, signing fails, or submission fails
295
+ */
296
+ abstract submitTransaction(options: SubmitTransactionOptions): Promise<SubmitResult>;
297
+
298
+ /**
299
+ * Signs an arbitrary message.
300
+ *
301
+ * @description
302
+ * Requests the wallet to sign a non-transaction message, typically used
303
+ * for authentication challenges, DAO voting, or proof-of-ownership.
304
+ *
305
+ * @param options - Message signing options
306
+ *
307
+ * @returns Promise resolving to the signature result
308
+ *
309
+ * @throws {Error} If user rejects or signing fails
310
+ */
311
+ abstract signMessage(options: SignMessageOptions): Promise<SignMessageResult>;
312
+
313
+ /**
314
+ * Checks if this provider is available in the current environment.
315
+ *
316
+ * @description
317
+ * Determines if the wallet type can be used. For example:
318
+ * - Browser extension providers check if the extension is installed
319
+ * - WebRTC providers check for RTCPeerConnection support
320
+ * - Native providers typically return true
321
+ *
322
+ * @returns Promise resolving to true if provider can be used
323
+ */
324
+ abstract isAvailable(): Promise<boolean>;
325
+
326
+ /**
327
+ * Gets the primary (first) connected account.
328
+ *
329
+ * @description
330
+ * Convenience method to retrieve the first account from the connected
331
+ * wallet. Returns null if no accounts are connected.
332
+ *
333
+ * @returns The first connected account, or null if none
334
+ */
335
+ getPrimaryAccount(): UnifiedAccount | null {
336
+ const accts = this.accounts();
337
+ return accts.length > 0 ? accts[0] : null;
338
+ }
339
+
340
+ /**
341
+ * Checks if the provider is currently connected.
342
+ *
343
+ * @description
344
+ * Convenience method that checks if `status()` equals `'connected'`.
345
+ *
346
+ * @returns true if provider is connected, false otherwise
347
+ */
348
+ isConnected(): boolean {
349
+ return this.status() === 'connected';
350
+ }
351
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * HSuite Native Connect
3
+ * Copyright 2024-2025 HSuite (https://hsuite.finance)
4
+ *
5
+ * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
6
+ *
7
+ * This file is part of HSuite Native Connect. For commercial licensing,
8
+ * visit https://hsuite.finance/licensing
9
+ */
10
+
11
+ /**
12
+ * @fileoverview Regression tests for the default wallet URL used when a
13
+ * consuming dApp connects without supplying its own `walletUrl`.
14
+ *
15
+ * Guards against the regression where the SDK opened the wallet on
16
+ * `http://localhost:8100` (a dev value) instead of the production wallet,
17
+ * causing dApps in production to point users at localhost.
18
+ */
19
+
20
+ import { describe, it, expect, beforeEach } from 'vitest';
21
+ import { TestBed } from '@angular/core/testing';
22
+ import type { ChannelInvite } from '@hsuite/native-connect-sdk';
23
+ import { ChannelClientService } from './channel-client.service';
24
+ import { DEFAULT_WALLET_URL } from '../../models/provider-types';
25
+
26
+ /** Minimal, valid session invite sufficient for invite-URL generation. */
27
+ function makeInvite(): ChannelInvite {
28
+ return {
29
+ v: 2,
30
+ id: 'test-channel-id',
31
+ type: 'session',
32
+ key: 'dGVzdC1lbmNyeXB0aW9uLWtleQ',
33
+ relays: ['wss://nostr.hsuite.network'],
34
+ app: { id: 'test-dapp', name: 'Test dApp' },
35
+ context: { ledgerId: 'hedera', networkId: 'testnet' },
36
+ };
37
+ }
38
+
39
+ describe('wallet URL default (regression: dApp opened wallet on localhost)', () => {
40
+ describe('DEFAULT_WALLET_URL', () => {
41
+ it('points at the production wallet origin', () => {
42
+ expect(DEFAULT_WALLET_URL).toBe('https://wallet.hsuite.app');
43
+ });
44
+
45
+ it('is a production-safe https origin, never localhost', () => {
46
+ const url = new URL(DEFAULT_WALLET_URL);
47
+ expect(url.protocol).toBe('https:');
48
+ expect(url.hostname).toBe('wallet.hsuite.app');
49
+ expect(DEFAULT_WALLET_URL).not.toMatch(/localhost|127\.0\.0\.1/);
50
+ });
51
+ });
52
+
53
+ describe('ChannelClientService.getWalletInviteUrl', () => {
54
+ let service: ChannelClientService;
55
+
56
+ beforeEach(() => {
57
+ TestBed.configureTestingModule({});
58
+ service = TestBed.inject(ChannelClientService);
59
+ });
60
+
61
+ it('defaults to the production wallet origin when no walletUrl is given', () => {
62
+ const url = service.getWalletInviteUrl(makeInvite());
63
+ expect(new URL(url).origin).toBe('https://wallet.hsuite.app');
64
+ expect(url).not.toMatch(/localhost|wallet\.hsuite\.network/);
65
+ expect(url).toContain('?hsuite_invite=');
66
+ });
67
+
68
+ it('still honors an explicit walletUrl (e.g. a local dev server)', () => {
69
+ const url = service.getWalletInviteUrl(makeInvite(), 'http://localhost:8100');
70
+ expect(new URL(url).origin).toBe('http://localhost:8100');
71
+ });
72
+ });
73
+ });