@trezor/connect 10.0.0-alpha.1 → 10.0.0-beta.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 (432) hide show
  1. package/CHANGELOG.md +159 -63
  2. package/README.md +5 -3
  3. package/lib/exports.d.ts +1 -0
  4. package/lib/exports.js +1 -0
  5. package/lib/impl/core-in-module-native.d.ts +7 -0
  6. package/lib/impl/core-in-module-native.js +11 -0
  7. package/lib/impl/core-in-module-node.d.ts +8 -0
  8. package/lib/impl/core-in-module-node.js +12 -0
  9. package/lib/impl/core-in-module-web.d.ts +9 -0
  10. package/lib/impl/core-in-module-web.js +26 -0
  11. package/lib/index.browser.d.ts +7 -0
  12. package/lib/index.browser.js +10 -0
  13. package/lib/index.d.ts +4 -0
  14. package/lib/index.js +5 -0
  15. package/lib/index.native.d.ts +4 -0
  16. package/lib/index.native.js +5 -0
  17. package/package.json +30 -83
  18. package/libESM/api/applyFlags.d.mts +0 -20
  19. package/libESM/api/applyFlags.mjs +0 -36
  20. package/libESM/api/applySettings.d.mts +0 -20
  21. package/libESM/api/applySettings.mjs +0 -55
  22. package/libESM/api/authenticateDevice.d.mts +0 -9
  23. package/libESM/api/authenticateDevice.mjs +0 -108
  24. package/libESM/api/authorizeCoinjoin.d.mts +0 -11
  25. package/libESM/api/authorizeCoinjoin.mjs +0 -44
  26. package/libESM/api/backupDevice.d.mts +0 -19
  27. package/libESM/api/backupDevice.mjs +0 -36
  28. package/libESM/api/bitcoin/TransactionComposer.d.mts +0 -46
  29. package/libESM/api/bitcoin/TransactionComposer.mjs +0 -139
  30. package/libESM/api/bitcoin/createPendingTx.d.mts +0 -33
  31. package/libESM/api/bitcoin/createPendingTx.mjs +0 -54
  32. package/libESM/api/bitcoin/enhanceSignTx.d.mts +0 -2
  33. package/libESM/api/bitcoin/enhanceSignTx.mjs +0 -23
  34. package/libESM/api/bitcoin/index.d.mts +0 -9
  35. package/libESM/api/bitcoin/index.mjs +0 -9
  36. package/libESM/api/bitcoin/inputs.d.mts +0 -6
  37. package/libESM/api/bitcoin/inputs.mjs +0 -75
  38. package/libESM/api/bitcoin/outputs.d.mts +0 -5
  39. package/libESM/api/bitcoin/outputs.mjs +0 -128
  40. package/libESM/api/bitcoin/refTx.d.mts +0 -17
  41. package/libESM/api/bitcoin/refTx.mjs +0 -252
  42. package/libESM/api/bitcoin/signtx.d.mts +0 -22
  43. package/libESM/api/bitcoin/signtx.mjs +0 -213
  44. package/libESM/api/bitcoin/signtxLegacy.d.mts +0 -3
  45. package/libESM/api/bitcoin/signtxLegacy.mjs +0 -179
  46. package/libESM/api/bitcoin/signtxVerify.d.mts +0 -12
  47. package/libESM/api/bitcoin/signtxVerify.mjs +0 -86
  48. package/libESM/api/bitcoin/transactionBytes.d.mts +0 -3
  49. package/libESM/api/bitcoin/transactionBytes.mjs +0 -65
  50. package/libESM/api/bleUnpair.d.mts +0 -11
  51. package/libESM/api/bleUnpair.mjs +0 -35
  52. package/libESM/api/blockchainDisconnect.d.mts +0 -16
  53. package/libESM/api/blockchainDisconnect.mjs +0 -39
  54. package/libESM/api/blockchainEstimateFee.d.mts +0 -14
  55. package/libESM/api/blockchainEstimateFee.mjs +0 -106
  56. package/libESM/api/blockchainEvmRpcCall.d.mts +0 -17
  57. package/libESM/api/blockchainEvmRpcCall.mjs +0 -61
  58. package/libESM/api/blockchainGetAccountBalanceHistory.d.mts +0 -14
  59. package/libESM/api/blockchainGetAccountBalanceHistory.mjs +0 -64
  60. package/libESM/api/blockchainGetContractInfo.d.mts +0 -14
  61. package/libESM/api/blockchainGetContractInfo.mjs +0 -50
  62. package/libESM/api/blockchainGetCurrentFiatRates.d.mts +0 -18
  63. package/libESM/api/blockchainGetCurrentFiatRates.mjs +0 -53
  64. package/libESM/api/blockchainGetFiatRatesForTimestamps.d.mts +0 -21
  65. package/libESM/api/blockchainGetFiatRatesForTimestamps.mjs +0 -59
  66. package/libESM/api/blockchainGetInfo.d.mts +0 -13
  67. package/libESM/api/blockchainGetInfo.mjs +0 -41
  68. package/libESM/api/blockchainGetTransactions.d.mts +0 -15
  69. package/libESM/api/blockchainGetTransactions.mjs +0 -47
  70. package/libESM/api/blockchainSetCustomBackend.d.mts +0 -13
  71. package/libESM/api/blockchainSetCustomBackend.mjs +0 -41
  72. package/libESM/api/blockchainSubscribe.d.mts +0 -17
  73. package/libESM/api/blockchainSubscribe.mjs +0 -68
  74. package/libESM/api/blockchainSubscribeFiatRates.d.mts +0 -17
  75. package/libESM/api/blockchainSubscribeFiatRates.mjs +0 -47
  76. package/libESM/api/blockchainUnsubscribe.d.mts +0 -17
  77. package/libESM/api/blockchainUnsubscribe.mjs +0 -68
  78. package/libESM/api/blockchainUnsubscribeFiatRates.d.mts +0 -15
  79. package/libESM/api/blockchainUnsubscribeFiatRates.mjs +0 -41
  80. package/libESM/api/blockchainValidateEvmRpcUrl.d.mts +0 -17
  81. package/libESM/api/blockchainValidateEvmRpcUrl.mjs +0 -54
  82. package/libESM/api/cancelCoinjoinAuthorization.d.mts +0 -11
  83. package/libESM/api/cancelCoinjoinAuthorization.mjs +0 -31
  84. package/libESM/api/cardano/api/cardanoComposeTransaction.d.mts +0 -10
  85. package/libESM/api/cardano/api/cardanoComposeTransaction.mjs +0 -79
  86. package/libESM/api/cardano/api/cardanoGetAddress.d.mts +0 -30
  87. package/libESM/api/cardano/api/cardanoGetAddress.mjs +0 -116
  88. package/libESM/api/cardano/api/cardanoGetNativeScriptHash.d.mts +0 -12
  89. package/libESM/api/cardano/api/cardanoGetNativeScriptHash.mjs +0 -66
  90. package/libESM/api/cardano/api/cardanoGetPublicKey.d.mts +0 -20
  91. package/libESM/api/cardano/api/cardanoGetPublicKey.mjs +0 -72
  92. package/libESM/api/cardano/api/cardanoSignMessage.d.mts +0 -27
  93. package/libESM/api/cardano/api/cardanoSignMessage.mjs +0 -96
  94. package/libESM/api/cardano/api/cardanoSignTransaction.d.mts +0 -81
  95. package/libESM/api/cardano/api/cardanoSignTransaction.mjs +0 -298
  96. package/libESM/api/cardano/api/index.d.mts +0 -6
  97. package/libESM/api/cardano/api/index.mjs +0 -6
  98. package/libESM/api/cardano/cardanoAddressParameters.d.mts +0 -6
  99. package/libESM/api/cardano/cardanoAddressParameters.mjs +0 -79
  100. package/libESM/api/cardano/cardanoAuxiliaryData.d.mts +0 -4
  101. package/libESM/api/cardano/cardanoAuxiliaryData.mjs +0 -74
  102. package/libESM/api/cardano/cardanoCertificate.d.mts +0 -13
  103. package/libESM/api/cardano/cardanoCertificate.mjs +0 -142
  104. package/libESM/api/cardano/cardanoInputs.d.mts +0 -25
  105. package/libESM/api/cardano/cardanoInputs.mjs +0 -39
  106. package/libESM/api/cardano/cardanoOutputs.d.mts +0 -40
  107. package/libESM/api/cardano/cardanoOutputs.mjs +0 -70
  108. package/libESM/api/cardano/cardanoTokenBundle.d.mts +0 -12
  109. package/libESM/api/cardano/cardanoTokenBundle.mjs +0 -21
  110. package/libESM/api/cardano/cardanoUtils.d.mts +0 -9
  111. package/libESM/api/cardano/cardanoUtils.mjs +0 -101
  112. package/libESM/api/cardano/cardanoWitnesses.d.mts +0 -4
  113. package/libESM/api/cardano/cardanoWitnesses.mjs +0 -47
  114. package/libESM/api/changeLanguage.d.mts +0 -18
  115. package/libESM/api/changeLanguage.mjs +0 -47
  116. package/libESM/api/changePin.d.mts +0 -11
  117. package/libESM/api/changePin.mjs +0 -25
  118. package/libESM/api/changeWipeCode.d.mts +0 -11
  119. package/libESM/api/changeWipeCode.mjs +0 -27
  120. package/libESM/api/cipherKeyValue.d.mts +0 -15
  121. package/libESM/api/cipherKeyValue.mjs +0 -51
  122. package/libESM/api/common/AbstractMiscGetAddress.d.mts +0 -35
  123. package/libESM/api/common/AbstractMiscGetAddress.mjs +0 -102
  124. package/libESM/api/common/Discovery.d.mts +0 -33
  125. package/libESM/api/common/Discovery.mjs +0 -116
  126. package/libESM/api/common/paramsValidator.d.mts +0 -23
  127. package/libESM/api/common/paramsValidator.mjs +0 -134
  128. package/libESM/api/common/requestExistingAccounts.d.mts +0 -9
  129. package/libESM/api/common/requestExistingAccounts.mjs +0 -20
  130. package/libESM/api/composeTransaction.d.mts +0 -36
  131. package/libESM/api/composeTransaction.mjs +0 -386
  132. package/libESM/api/discoverAccounts.d.mts +0 -38
  133. package/libESM/api/discoverAccounts.mjs +0 -363
  134. package/libESM/api/ethereum/api/ethereumGetAddress.d.mts +0 -28
  135. package/libESM/api/ethereum/api/ethereumGetAddress.mjs +0 -135
  136. package/libESM/api/ethereum/api/ethereumGetPublicKey.d.mts +0 -48
  137. package/libESM/api/ethereum/api/ethereumGetPublicKey.mjs +0 -90
  138. package/libESM/api/ethereum/api/ethereumSignMessage.d.mts +0 -27
  139. package/libESM/api/ethereum/api/ethereumSignMessage.mjs +0 -64
  140. package/libESM/api/ethereum/api/ethereumSignTransaction.d.mts +0 -83
  141. package/libESM/api/ethereum/api/ethereumSignTransaction.mjs +0 -148
  142. package/libESM/api/ethereum/api/ethereumSignTypedData.d.mts +0 -116
  143. package/libESM/api/ethereum/api/ethereumSignTypedData.mjs +0 -202
  144. package/libESM/api/ethereum/api/ethereumVerifyMessage.d.mts +0 -12
  145. package/libESM/api/ethereum/api/ethereumVerifyMessage.mjs +0 -33
  146. package/libESM/api/ethereum/api/index.d.mts +0 -6
  147. package/libESM/api/ethereum/api/index.mjs +0 -6
  148. package/libESM/api/ethereum/ethereumDefinitions.d.mts +0 -46
  149. package/libESM/api/ethereum/ethereumDefinitions.mjs +0 -103
  150. package/libESM/api/ethereum/ethereumSignTx.d.mts +0 -20
  151. package/libESM/api/ethereum/ethereumSignTx.mjs +0 -131
  152. package/libESM/api/ethereum/ethereumSignTypedData.d.mts +0 -32
  153. package/libESM/api/ethereum/ethereumSignTypedData.mjs +0 -169
  154. package/libESM/api/evoluGetDelegatedIdentityKey.d.mts +0 -14
  155. package/libESM/api/evoluGetDelegatedIdentityKey.mjs +0 -26
  156. package/libESM/api/evoluGetNode.d.mts +0 -13
  157. package/libESM/api/evoluGetNode.mjs +0 -27
  158. package/libESM/api/evoluSignRegistrationRequest.d.mts +0 -15
  159. package/libESM/api/evoluSignRegistrationRequest.mjs +0 -31
  160. package/libESM/api/firmware/calculateFirmwareHash.d.mts +0 -13
  161. package/libESM/api/firmware/calculateFirmwareHash.mjs +0 -56
  162. package/libESM/api/firmware/calculateXPubHash.d.mts +0 -10
  163. package/libESM/api/firmware/calculateXPubHash.mjs +0 -14
  164. package/libESM/api/firmware/getBinary.d.mts +0 -10
  165. package/libESM/api/firmware/getBinary.mjs +0 -33
  166. package/libESM/api/firmware/index.d.mts +0 -6
  167. package/libESM/api/firmware/index.mjs +0 -6
  168. package/libESM/api/firmware/modifyFirmware.d.mts +0 -3
  169. package/libESM/api/firmware/modifyFirmware.mjs +0 -13
  170. package/libESM/api/firmware/parseFirmwareHeaders.d.mts +0 -4
  171. package/libESM/api/firmware/parseFirmwareHeaders.mjs +0 -26
  172. package/libESM/api/firmware/uploadFirmware.d.mts +0 -19
  173. package/libESM/api/firmware/uploadFirmware.mjs +0 -99
  174. package/libESM/api/firmware/verifyEntropy.d.mts +0 -18
  175. package/libESM/api/firmware/verifyEntropy.mjs +0 -107
  176. package/libESM/api/getAccountInfo.d.mts +0 -94
  177. package/libESM/api/getAccountInfo.mjs +0 -385
  178. package/libESM/api/getAddress.d.mts +0 -39
  179. package/libESM/api/getAddress.mjs +0 -142
  180. package/libESM/api/getCoinInfo.d.mts +0 -148
  181. package/libESM/api/getCoinInfo.mjs +0 -29
  182. package/libESM/api/getDeviceState.d.mts +0 -8
  183. package/libESM/api/getDeviceState.mjs +0 -16
  184. package/libESM/api/getFeatures.d.mts +0 -70
  185. package/libESM/api/getFeatures.mjs +0 -20
  186. package/libESM/api/getFirmwareHash.d.mts +0 -11
  187. package/libESM/api/getFirmwareHash.mjs +0 -27
  188. package/libESM/api/getNonce.d.mts +0 -10
  189. package/libESM/api/getNonce.mjs +0 -16
  190. package/libESM/api/getOwnershipId.d.mts +0 -15
  191. package/libESM/api/getOwnershipId.mjs +0 -79
  192. package/libESM/api/getOwnershipProof.d.mts +0 -15
  193. package/libESM/api/getOwnershipProof.mjs +0 -86
  194. package/libESM/api/getPublicKey.d.mts +0 -50
  195. package/libESM/api/getPublicKey.mjs +0 -88
  196. package/libESM/api/getSettings.d.mts +0 -8
  197. package/libESM/api/getSettings.mjs +0 -15
  198. package/libESM/api/index.d.mts +0 -59
  199. package/libESM/api/index.mjs +0 -59
  200. package/libESM/api/loadDevice.d.mts +0 -16
  201. package/libESM/api/loadDevice.mjs +0 -44
  202. package/libESM/api/monero/api/index.d.mts +0 -4
  203. package/libESM/api/monero/api/index.mjs +0 -4
  204. package/libESM/api/monero/api/moneroGetAddress.d.mts +0 -30
  205. package/libESM/api/monero/api/moneroGetAddress.mjs +0 -109
  206. package/libESM/api/monero/api/moneroGetWatchKey.d.mts +0 -14
  207. package/libESM/api/monero/api/moneroGetWatchKey.mjs +0 -44
  208. package/libESM/api/monero/api/moneroKeyImageSync.d.mts +0 -17
  209. package/libESM/api/monero/api/moneroKeyImageSync.mjs +0 -127
  210. package/libESM/api/monero/api/moneroSignTransaction.d.mts +0 -17
  211. package/libESM/api/monero/api/moneroSignTransaction.mjs +0 -202
  212. package/libESM/api/pingDevice.d.mts +0 -11
  213. package/libESM/api/pingDevice.mjs +0 -27
  214. package/libESM/api/pushTransaction.d.mts +0 -17
  215. package/libESM/api/pushTransaction.mjs +0 -42
  216. package/libESM/api/recoveryDevice.d.mts +0 -20
  217. package/libESM/api/recoveryDevice.mjs +0 -50
  218. package/libESM/api/requestLogin.d.mts +0 -14
  219. package/libESM/api/requestLogin.mjs +0 -48
  220. package/libESM/api/resetDevice.d.mts +0 -22
  221. package/libESM/api/resetDevice.mjs +0 -131
  222. package/libESM/api/ripple/api/index.d.mts +0 -2
  223. package/libESM/api/ripple/api/index.mjs +0 -2
  224. package/libESM/api/ripple/api/rippleGetAddress.d.mts +0 -15
  225. package/libESM/api/ripple/api/rippleGetAddress.mjs +0 -22
  226. package/libESM/api/ripple/api/rippleSignTransaction.d.mts +0 -13
  227. package/libESM/api/ripple/api/rippleSignTransaction.mjs +0 -52
  228. package/libESM/api/setBrightness.d.mts +0 -12
  229. package/libESM/api/setBrightness.mjs +0 -26
  230. package/libESM/api/setBusy.d.mts +0 -11
  231. package/libESM/api/setBusy.mjs +0 -32
  232. package/libESM/api/showDeviceTutorial.d.mts +0 -11
  233. package/libESM/api/showDeviceTutorial.mjs +0 -21
  234. package/libESM/api/signMessage.d.mts +0 -25
  235. package/libESM/api/signMessage.mjs +0 -71
  236. package/libESM/api/signTransaction.d.mts +0 -197
  237. package/libESM/api/signTransaction.mjs +0 -334
  238. package/libESM/api/solana/api/index.d.mts +0 -4
  239. package/libESM/api/solana/api/index.mjs +0 -4
  240. package/libESM/api/solana/api/solanaComposeTransaction.d.mts +0 -31
  241. package/libESM/api/solana/api/solanaComposeTransaction.mjs +0 -76
  242. package/libESM/api/solana/api/solanaGetAddress.d.mts +0 -15
  243. package/libESM/api/solana/api/solanaGetAddress.mjs +0 -22
  244. package/libESM/api/solana/api/solanaGetPublicKey.d.mts +0 -28
  245. package/libESM/api/solana/api/solanaGetPublicKey.mjs +0 -67
  246. package/libESM/api/solana/api/solanaSignTransaction.d.mts +0 -41
  247. package/libESM/api/solana/api/solanaSignTransaction.mjs +0 -203
  248. package/libESM/api/solana/solanaDefinitions.d.mts +0 -7
  249. package/libESM/api/solana/solanaDefinitions.mjs +0 -33
  250. package/libESM/api/stellar/api/index.d.mts +0 -2
  251. package/libESM/api/stellar/api/index.mjs +0 -2
  252. package/libESM/api/stellar/api/stellarGetAddress.d.mts +0 -15
  253. package/libESM/api/stellar/api/stellarGetAddress.mjs +0 -22
  254. package/libESM/api/stellar/api/stellarSignTransaction.d.mts +0 -26
  255. package/libESM/api/stellar/api/stellarSignTransaction.mjs +0 -66
  256. package/libESM/api/stellar/stellarSignTx.d.mts +0 -7
  257. package/libESM/api/stellar/stellarSignTx.mjs +0 -191
  258. package/libESM/api/telemetryGet.d.mts +0 -14
  259. package/libESM/api/telemetryGet.mjs +0 -24
  260. package/libESM/api/tezos/api/index.d.mts +0 -3
  261. package/libESM/api/tezos/api/index.mjs +0 -3
  262. package/libESM/api/tezos/api/tezosGetAddress.d.mts +0 -15
  263. package/libESM/api/tezos/api/tezosGetAddress.mjs +0 -22
  264. package/libESM/api/tezos/api/tezosGetPublicKey.d.mts +0 -24
  265. package/libESM/api/tezos/api/tezosGetPublicKey.mjs +0 -66
  266. package/libESM/api/tezos/api/tezosSignTransaction.d.mts +0 -14
  267. package/libESM/api/tezos/api/tezosSignTransaction.mjs +0 -30
  268. package/libESM/api/tezos/tezosSignTx.d.mts +0 -71
  269. package/libESM/api/tezos/tezosSignTx.mjs +0 -204
  270. package/libESM/api/thpGetCredentials.d.mts +0 -13
  271. package/libESM/api/thpGetCredentials.mjs +0 -28
  272. package/libESM/api/thpRemoveCredentials.d.mts +0 -15
  273. package/libESM/api/thpRemoveCredentials.mjs +0 -42
  274. package/libESM/api/tron/api/index.d.mts +0 -3
  275. package/libESM/api/tron/api/index.mjs +0 -3
  276. package/libESM/api/tron/api/tronComposeTransaction.d.mts +0 -17
  277. package/libESM/api/tron/api/tronComposeTransaction.mjs +0 -51
  278. package/libESM/api/tron/api/tronGetAddress.d.mts +0 -15
  279. package/libESM/api/tron/api/tronGetAddress.mjs +0 -20
  280. package/libESM/api/tron/api/tronSignTransaction.d.mts +0 -19
  281. package/libESM/api/tron/api/tronSignTransaction.mjs +0 -129
  282. package/libESM/api/tron/tronEncode.d.mts +0 -12
  283. package/libESM/api/tron/tronEncode.mjs +0 -77
  284. package/libESM/api/tron/tronProtobuf.d.mts +0 -5
  285. package/libESM/api/tron/tronProtobuf.mjs +0 -28
  286. package/libESM/api/unlockPath.d.mts +0 -12
  287. package/libESM/api/unlockPath.mjs +0 -31
  288. package/libESM/api/verifyMessage.d.mts +0 -16
  289. package/libESM/api/verifyMessage.mjs +0 -46
  290. package/libESM/api/wipeDevice.d.mts +0 -21
  291. package/libESM/api/wipeDevice.mjs +0 -47
  292. package/libESM/backend/BackendManager.d.mts +0 -24
  293. package/libESM/backend/BackendManager.mjs +0 -137
  294. package/libESM/backend/Blockchain.d.mts +0 -81
  295. package/libESM/backend/Blockchain.mjs +0 -232
  296. package/libESM/backend/BlockchainLink.d.mts +0 -9
  297. package/libESM/backend/BlockchainLink.mjs +0 -13
  298. package/libESM/backend/fees/BitcoinFeeLevels.d.mts +0 -19
  299. package/libESM/backend/fees/BitcoinFeeLevels.mjs +0 -43
  300. package/libESM/backend/fees/EthereumFeeLevels.d.mts +0 -17
  301. package/libESM/backend/fees/EthereumFeeLevels.mjs +0 -52
  302. package/libESM/backend/fees/MiscFeeLevels.d.mts +0 -18
  303. package/libESM/backend/fees/MiscFeeLevels.mjs +0 -25
  304. package/libESM/backend/fees/index.d.mts +0 -5
  305. package/libESM/backend/fees/index.mjs +0 -30
  306. package/libESM/core/AbstractMethod.d.mts +0 -65
  307. package/libESM/core/AbstractMethod.mjs +0 -153
  308. package/libESM/core/index.d.mts +0 -27
  309. package/libESM/core/index.mjs +0 -795
  310. package/libESM/core/method.d.mts +0 -3
  311. package/libESM/core/method.mjs +0 -19
  312. package/libESM/core/method.native.d.mts +0 -2
  313. package/libESM/core/method.native.mjs +0 -29
  314. package/libESM/core/onCallFirmwareUpdate.d.mts +0 -39
  315. package/libESM/core/onCallFirmwareUpdate.mjs +0 -436
  316. package/libESM/data/coinInfo.d.mts +0 -374
  317. package/libESM/data/coinInfo.mjs +0 -183
  318. package/libESM/data/config.d.mts +0 -8
  319. package/libESM/data/config.mjs +0 -265
  320. package/libESM/data/defaultFeeLevels.d.mts +0 -18
  321. package/libESM/data/defaultFeeLevels.mjs +0 -174
  322. package/libESM/data/firmwareInfo.d.mts +0 -41
  323. package/libESM/data/firmwareInfo.mjs +0 -411
  324. package/libESM/data/firmwareReleaseStore.d.mts +0 -10
  325. package/libESM/data/firmwareReleaseStore.mjs +0 -16
  326. package/libESM/data/localFirmwareStore.d.mts +0 -3
  327. package/libESM/data/localFirmwareStore.mjs +0 -8
  328. package/libESM/data/protobufLoader.d.mts +0 -1
  329. package/libESM/data/protobufLoader.mjs +0 -29
  330. package/libESM/data/settingsStore.d.mts +0 -6
  331. package/libESM/data/settingsStore.mjs +0 -21
  332. package/libESM/device/Device.d.mts +0 -237
  333. package/libESM/device/Device.mjs +0 -729
  334. package/libESM/device/DeviceCommands.d.mts +0 -77
  335. package/libESM/device/DeviceCommands.mjs +0 -245
  336. package/libESM/device/DeviceCurrentSession.d.mts +0 -3208
  337. package/libESM/device/DeviceCurrentSession.mjs +0 -240
  338. package/libESM/device/DeviceList.d.mts +0 -68
  339. package/libESM/device/DeviceList.mjs +0 -246
  340. package/libESM/device/TransportList.d.mts +0 -9
  341. package/libESM/device/TransportList.mjs +0 -41
  342. package/libESM/device/TransportManager.d.mts +0 -30
  343. package/libESM/device/TransportManager.mjs +0 -142
  344. package/libESM/device/calculateRevisionForDevice.d.mts +0 -7
  345. package/libESM/device/calculateRevisionForDevice.mjs +0 -19
  346. package/libESM/device/checkFirmwareRevision.d.mts +0 -12
  347. package/libESM/device/checkFirmwareRevision.mjs +0 -75
  348. package/libESM/device/resolveDescriptorForTaproot.d.mts +0 -14
  349. package/libESM/device/resolveDescriptorForTaproot.mjs +0 -25
  350. package/libESM/device/thp/handshake.d.mts +0 -3
  351. package/libESM/device/thp/handshake.mjs +0 -100
  352. package/libESM/device/thp/index.d.mts +0 -5
  353. package/libESM/device/thp/index.mjs +0 -65
  354. package/libESM/device/thp/pairing.d.mts +0 -16
  355. package/libESM/device/thp/pairing.mjs +0 -237
  356. package/libESM/device/thp/session.d.mts +0 -2
  357. package/libESM/device/thp/session.mjs +0 -27
  358. package/libESM/device/thp/thpCall.d.mts +0 -40
  359. package/libESM/device/thp/thpCall.mjs +0 -58
  360. package/libESM/device/validateMessageSize.d.mts +0 -2
  361. package/libESM/device/validateMessageSize.mjs +0 -9
  362. package/libESM/device/workflow/changeLanguage.d.mts +0 -14
  363. package/libESM/device/workflow/changeLanguage.mjs +0 -59
  364. package/libESM/device/workflow/checkFirmwareHash.d.mts +0 -9
  365. package/libESM/device/workflow/checkFirmwareHash.mjs +0 -86
  366. package/libESM/device/workflow/checkFirmwareHashWithRetries.d.mts +0 -8
  367. package/libESM/device/workflow/checkFirmwareHashWithRetries.mjs +0 -36
  368. package/libESM/device/workflow/handshake.d.mts +0 -9
  369. package/libESM/device/workflow/handshake.mjs +0 -55
  370. package/libESM/device/workflow/trezorPushNotification.d.mts +0 -2
  371. package/libESM/device/workflow/trezorPushNotification.mjs +0 -73
  372. package/libESM/device/workflow/validateState.d.mts +0 -2
  373. package/libESM/device/workflow/validateState.mjs +0 -153
  374. package/libESM/events/ui-promise.d.mts +0 -22
  375. package/libESM/events/ui-promise.mjs +0 -1
  376. package/libESM/exports.d.mts +0 -3
  377. package/libESM/exports.mjs +0 -3
  378. package/libESM/impl/core-in-module.d.mts +0 -27
  379. package/libESM/impl/core-in-module.mjs +0 -173
  380. package/libESM/index.browser.d.mts +0 -9
  381. package/libESM/index.browser.mjs +0 -50
  382. package/libESM/index.d.mts +0 -6
  383. package/libESM/index.mjs +0 -32
  384. package/libESM/index.renderer.d.mts +0 -6
  385. package/libESM/index.renderer.mjs +0 -19
  386. package/libESM/tsconfig.libESM.tsbuildinfo +0 -1
  387. package/libESM/types/idevice.d.mts +0 -109
  388. package/libESM/types/idevice.mjs +0 -1
  389. package/libESM/types/typed-call-provider.d.mts +0 -29
  390. package/libESM/types/typed-call-provider.mjs +0 -1
  391. package/libESM/types/workflow.d.mts +0 -16
  392. package/libESM/types/workflow.mjs +0 -1
  393. package/libESM/utils/accountUtils.d.mts +0 -10
  394. package/libESM/utils/accountUtils.mjs +0 -83
  395. package/libESM/utils/addressUtils.d.mts +0 -2
  396. package/libESM/utils/addressUtils.mjs +0 -24
  397. package/libESM/utils/assetUtils.d.mts +0 -13
  398. package/libESM/utils/assetUtils.mjs +0 -56
  399. package/libESM/utils/assets.browser.d.mts +0 -1
  400. package/libESM/utils/assets.browser.mjs +0 -1
  401. package/libESM/utils/assets.d.mts +0 -2
  402. package/libESM/utils/assets.mjs +0 -13
  403. package/libESM/utils/assets.native.d.mts +0 -2
  404. package/libESM/utils/assets.native.mjs +0 -23
  405. package/libESM/utils/assetsTypes.d.mts +0 -5
  406. package/libESM/utils/assetsTypes.mjs +0 -1
  407. package/libESM/utils/buildOutputDescriptor.d.mts +0 -12
  408. package/libESM/utils/buildOutputDescriptor.mjs +0 -67
  409. package/libESM/utils/deviceFeaturesUtils.d.mts +0 -7
  410. package/libESM/utils/deviceFeaturesUtils.mjs +0 -109
  411. package/libESM/utils/ethereumUtils.d.mts +0 -3
  412. package/libESM/utils/ethereumUtils.mjs +0 -7
  413. package/libESM/utils/firmwareReleaseConfigUtils.d.mts +0 -19
  414. package/libESM/utils/firmwareReleaseConfigUtils.mjs +0 -131
  415. package/libESM/utils/firmwareUtils.d.mts +0 -13
  416. package/libESM/utils/firmwareUtils.mjs +0 -54
  417. package/libESM/utils/formatUtils.d.mts +0 -15
  418. package/libESM/utils/formatUtils.mjs +0 -45
  419. package/libESM/utils/hdnodeUtils.d.mts +0 -6
  420. package/libESM/utils/hdnodeUtils.mjs +0 -62
  421. package/libESM/utils/pathUtils.d.mts +0 -17
  422. package/libESM/utils/pathUtils.mjs +0 -141
  423. package/libESM/utils/paymentRequest.d.mts +0 -8
  424. package/libESM/utils/paymentRequest.mjs +0 -25
  425. package/libESM/utils/uiPromiseManager.d.mts +0 -8
  426. package/libESM/utils/uiPromiseManager.mjs +0 -51
  427. package/libESM/workers/workers.browser.d.mts +0 -10
  428. package/libESM/workers/workers.browser.mjs +0 -16
  429. package/libESM/workers/workers.d.mts +0 -10
  430. package/libESM/workers/workers.mjs +0 -8
  431. package/libESM/workers/workers.native.d.mts +0 -7
  432. package/libESM/workers/workers.native.mjs +0 -7
@@ -1,240 +0,0 @@
1
- import { DEVICE } from "@trezor/connect-common";
2
- import { ERRORS } from "@trezor/connect-common/libESM/constants/index.mjs";
3
- import { initLog } from "@trezor/connect-common/libESM/utils/debug.mjs";
4
- import { MessagesSchema as Messages } from "@trezor/protobuf";
5
- import { Assert } from "@trezor/schema-utils";
6
- import { TRANSPORT } from "@trezor/transport";
7
- import { isErrorWithoutDeviceInteraction } from "@trezor/transport/libESM/errors-groups.mjs";
8
- import { scheduleAction } from "@trezor/utils";
9
- const blacklist = {
10
- PassphraseAck: ['passphrase'],
11
- CipheredKeyValue: ['value'],
12
- GetPublicKey: ['address_n'],
13
- PublicKey: ['node', 'xpub'],
14
- DecryptedMessage: ['message', 'address'],
15
- Features: true
16
- };
17
- const allowedCallsBeforeInitialize = ['Cancel', 'Initialize', 'GetFeatures', 'GetFirmwareHash', 'ChangeLanguage', 'DataChunkAck', 'RebootToBootloader', 'FirmwareErase', 'FirmwareUpload', 'RecoveryDevice', 'WipeDevice'];
18
- const filterForLog = (type, msg) => blacklist[type] === true ? '(redacted...)' : (blacklist[type] ?? []).reduce((prev, cur) => ({
19
- ...prev,
20
- [cur]: '(redacted...)'
21
- }), msg);
22
- const logger = initLog('DeviceCommands');
23
- const isExpectedResponse = (response, expected) => (Array.isArray(expected) ? expected : expected.split('|')).includes(response.type);
24
- const success = payload => ({
25
- success: true,
26
- payload
27
- });
28
- const error = error => ({
29
- success: false,
30
- error
31
- });
32
- const nestedError = cause => error(ERRORS.nestError(cause));
33
- const fail = msg => error(isErrorWithoutDeviceInteraction(msg) ? new ERRORS.TransportError(msg) : new Error(msg));
34
- export class DeviceCurrentSession {
35
- device;
36
- transport;
37
- session;
38
- disposed;
39
- callPromise;
40
- abortController;
41
- constructor(device, transport, session) {
42
- this.device = device;
43
- this.transport = transport;
44
- this.session = session;
45
- transport.deviceEvents.once(device.transportPath, e => {
46
- if (!this.disposed) {
47
- this.disposed = ERRORS.TypedError(e.type === TRANSPORT.DEVICE_DISCONNECTED ? 'Device_Disconnected' : 'Device_UsedElsewhere');
48
- this.abortController?.abort(this.disposed);
49
- }
50
- });
51
- }
52
- isDisposed() {
53
- return !!this.disposed;
54
- }
55
- async typedCall(type, expectedType, msg = {}) {
56
- const deviceSessionId = this.device.getThpState()?.sessionId || this.device?.features?.session_id;
57
- if (!allowedCallsBeforeInitialize.includes(type) && !deviceSessionId) {
58
- console.error('Runtime', `typedCall: Device not initialized when calling ${type}. call Initialize first`);
59
- }
60
- Assert(Messages.MessageType.properties[type], msg);
61
- this.abortController = new AbortController();
62
- const {
63
- signal
64
- } = this.abortController;
65
- const abortPromise = new Promise(resolve => signal.addEventListener('abort', () => resolve(signal.reason)));
66
- const callPromise = this.callLoop(type, msg, abortPromise);
67
- this.callPromise = callPromise;
68
- const response = await callPromise;
69
- this.callPromise = undefined;
70
- this.abortController = undefined;
71
- if (!response.success) throw response.error;
72
- const {
73
- payload
74
- } = response;
75
- const receivedType = payload.type;
76
- if (isExpectedResponse(payload, expectedType)) {
77
- return payload;
78
- } else {
79
- await scheduleAction(abort => this.transport.receive({
80
- session: this.session,
81
- protocol: this.device.protocol,
82
- thpState: this.device.getThpState(),
83
- signal: abort
84
- }), {
85
- timeout: 500
86
- }).catch(() => {});
87
- throw ERRORS.TypedError('Runtime', `assertType: Response of unexpected type: ${receivedType}. Should be ${expectedType}`);
88
- }
89
- }
90
- async callLoop(type, msg, abortPromise) {
91
- let [name, data] = [type, msg];
92
- let pinUnlocked = false;
93
- while (true) {
94
- const timeout = this.device.possibleT1 && name === 'GetFeatures' ? 3_000 : undefined;
95
- const callPromise = this.call(name, data, {
96
- timeout
97
- });
98
- const [abortedDuringCall, response] = await Promise.race([callPromise.then(res => [false, res]), abortPromise.then(res => [true, nestedError(res)])]);
99
- if (name === 'ButtonAck' && abortedDuringCall && !this.disposed) {
100
- this.device.getThpState()?.sync('send', 'Cancel');
101
- await this.send('Cancel', {});
102
- }
103
- await callPromise;
104
- if (this.disposed) return nestedError(this.disposed);
105
- if (!response.success) return response;
106
- const res = response.payload;
107
- switch (res.type) {
108
- case 'Failure':
109
- {
110
- const {
111
- code,
112
- message
113
- } = res.message;
114
- if (name === 'GetFeatures' && code === 'Failure_UnexpectedMessage') {
115
- [name, data] = ['Initialize', {}];
116
- break;
117
- }
118
- const err = message || code === 'Failure_FirmwareError' && 'Firmware installation failed' || code === 'Failure_ActionCancelled' && 'Action cancelled by user' || 'Failure_UnknownMessage';
119
- return error(new ERRORS.TrezorError(code || 'Failure_UnknownCode', err));
120
- }
121
- case 'ButtonRequest':
122
- {
123
- if (res.message.code === 'ButtonRequest_PassphraseEntry') {
124
- this.device.emit(DEVICE.PASSPHRASE_ON_DEVICE);
125
- } else {
126
- this.device.emit(DEVICE.BUTTON, {
127
- device: this.device,
128
- payload: res.message
129
- });
130
- }
131
- [name, data] = ['ButtonAck', {}];
132
- break;
133
- }
134
- case 'PinMatrixRequest':
135
- {
136
- const promptRes = await Promise.race([this.device.prompt(DEVICE.PIN, {
137
- type: res.message.type
138
- }), abortPromise.then(nestedError)]);
139
- if (!promptRes.success) {
140
- const cancelRes = await this.call('Cancel', {});
141
- return cancelRes.success ? promptRes : cancelRes;
142
- }
143
- pinUnlocked = true;
144
- [name, data] = ['PinMatrixAck', {
145
- pin: promptRes.payload
146
- }];
147
- break;
148
- }
149
- case 'PassphraseRequest':
150
- {
151
- const promptRes = await Promise.race([this.device.prompt(DEVICE.PASSPHRASE, {}), abortPromise.then(nestedError)]);
152
- if (!promptRes.success) {
153
- const cancelRes = await this.call('Cancel', {});
154
- return cancelRes.success ? promptRes : cancelRes;
155
- }
156
- const payload = promptRes.payload.passphraseOnDevice ? {
157
- on_device: true
158
- } : {
159
- passphrase: promptRes.payload.value.normalize('NFKD')
160
- };
161
- [name, data] = ['PassphraseAck', payload];
162
- break;
163
- }
164
- case 'WordRequest':
165
- {
166
- const promptRes = await Promise.race([this.device.prompt(DEVICE.WORD, {
167
- type: res.message.type
168
- }), abortPromise.then(nestedError)]);
169
- if (!promptRes.success) {
170
- const cancelRes = await this.call('Cancel', {});
171
- return cancelRes.success ? promptRes : cancelRes;
172
- }
173
- [name, data] = ['WordAck', {
174
- word: promptRes.payload
175
- }];
176
- break;
177
- }
178
- default:
179
- {
180
- if (!this.disposed && pinUnlocked && !this.device.features.unlocked) {
181
- await this.device.getFeatures().catch(() => {});
182
- }
183
- return success(res);
184
- }
185
- }
186
- }
187
- }
188
- async call(name, data, options = {}) {
189
- if (this.disposed) return Promise.resolve(nestedError(this.disposed));
190
- logger.debug('Sending', name, filterForLog(name, data));
191
- const result = await this.transport.call({
192
- name,
193
- data,
194
- session: this.session,
195
- protocol: this.device.protocol,
196
- thpState: this.device.getThpState(),
197
- ...options
198
- });
199
- if (result.success) {
200
- const {
201
- type,
202
- message
203
- } = result.payload;
204
- logger.debug('Received', type, filterForLog(type, message));
205
- } else {
206
- logger.warn('Received transport error', result.error.code, result.error.message);
207
- }
208
- return result.success ? success(result.payload) : fail(result.error.message || result.error.code);
209
- }
210
- async send(name, data, options = {}) {
211
- if (this.disposed) return Promise.resolve(nestedError(this.disposed));
212
- const result = await this.transport.send({
213
- name,
214
- data,
215
- session: this.session,
216
- protocol: this.device.protocol,
217
- thpState: this.device.getThpState(),
218
- ...options
219
- });
220
- return result.success ? success(result.payload) : fail(result.error.message || result.error.code);
221
- }
222
- async receive(options = {}) {
223
- if (this.disposed) return Promise.resolve(nestedError(this.disposed));
224
- const result = await this.transport.receive({
225
- session: this.session,
226
- protocol: this.device.protocol,
227
- thpState: this.device.getThpState(),
228
- ...options
229
- });
230
- return result.success ? success(result.payload) : fail(result.error.message || result.error.code);
231
- }
232
- cancelCall() {
233
- return this.call('Cancel', {});
234
- }
235
- async abort(reason) {
236
- this.abortController?.abort(reason);
237
- await this.callPromise;
238
- this.disposed = reason;
239
- }
240
- }
@@ -1,68 +0,0 @@
1
- import { DEVICE } from '@trezor/connect-common';
2
- import type { ConnectSettings, DecodedTrezorPushNotification, DeviceUniquePath, StaticSessionId, TransportError, TransportInfo } from '@trezor/connect-common';
3
- import { TRANSPORT } from '@trezor/transport';
4
- import type { Descriptor } from '@trezor/transport/libESM/types';
5
- import { TypedEmitter } from '@trezor/utils';
6
- import { Device } from './Device';
7
- interface DeviceListEvents {
8
- [TRANSPORT.START]: TransportInfo;
9
- [TRANSPORT.ERROR]: TransportError;
10
- [DEVICE.CONNECT]: Device;
11
- [DEVICE.CONNECT_UNACQUIRED]: Device;
12
- [DEVICE.TREZOR_PUSH_NOTIFICATION]: DecodedTrezorPushNotification & {
13
- device: Device;
14
- };
15
- [DEVICE.DISCONNECT]: Device;
16
- [DEVICE.CHANGED]: Device;
17
- }
18
- export interface IDeviceList {
19
- isConnected(): this is DeviceList;
20
- pendingConnection(): Promise<void> | undefined;
21
- addAuthPenalty: DeviceList['addAuthPenalty'];
22
- removeAuthPenalty: DeviceList['removeAuthPenalty'];
23
- on: DeviceList['on'];
24
- once: DeviceList['once'];
25
- init: DeviceList['init'];
26
- dispose: DeviceList['dispose'];
27
- }
28
- export declare const assertDeviceListConnected: (deviceList: IDeviceList) => asserts deviceList is DeviceList;
29
- type ConstructorParams = Pick<ConnectSettings, 'priority' | 'debug' | 'manifest'>;
30
- type InitParams = Pick<ConnectSettings, 'transports' | 'pendingTransportEvent' | 'transportReconnect'>;
31
- export declare class DeviceList extends TypedEmitter<DeviceListEvents> implements IDeviceList {
32
- private readonly transportManagers;
33
- private transports;
34
- private devices;
35
- private deviceCounter;
36
- private readonly handshakeLock;
37
- private readonly authPenaltyManager;
38
- private updateTransports;
39
- private getConnectedTransports;
40
- isConnected(): this is DeviceList;
41
- pendingConnection(): Promise<void> | undefined;
42
- getActiveTransports(): {
43
- apiType: "usb" | "bluetooth" | "udp";
44
- type: "BridgeTransport" | "NodeUsbTransport" | "WebUsbTransport" | "UdpTransport" | "NativeUsbTransport" | "BluetoothTransport" | "NativeBluetoothTransport";
45
- version: string;
46
- outdated: boolean;
47
- }[];
48
- constructor({ priority, debug, manifest }: ConstructorParams);
49
- private getSimilarDevices;
50
- private onDeviceConnected;
51
- private onPushNotification;
52
- private onBatteryLevel;
53
- private getOrCreateTransportManager;
54
- init({ transports, transportReconnect, pendingTransportEvent }?: InitParams): Promise<void>;
55
- private initializeTransport;
56
- private waitForDevices;
57
- getDeviceCount(): number;
58
- getPrioritizedDevices(): Device[];
59
- getAllDevices(): readonly Device[];
60
- getOnlyDevice(apiType?: Descriptor['apiType']): Device | undefined;
61
- getDeviceByPath(path: DeviceUniquePath): Device | undefined;
62
- getDeviceByStaticState(state: StaticSessionId): Device | undefined;
63
- dispose(): Promise<void>;
64
- enumerate(): Promise<void>;
65
- addAuthPenalty(device: Device): void;
66
- removeAuthPenalty(device: Device): void;
67
- }
68
- export {};
@@ -1,246 +0,0 @@
1
- import { DEVICE, asDeviceUniquePath } from "@trezor/connect-common";
2
- import { ERRORS } from "@trezor/connect-common/libESM/constants/index.mjs";
3
- import { initLog } from "@trezor/connect-common/libESM/utils/debug.mjs";
4
- import { parseStaticSessionId } from "@trezor/device-utils";
5
- import { TRANSPORT } from "@trezor/transport";
6
- import { TypedEmitter, arrayDistinct, createDeferred, getSynchronize, isNotUndefined, resolveAfter, typedObjectKeys } from "@trezor/utils";
7
- import { Device } from "./Device.mjs";
8
- import { createTransportList } from "./TransportList.mjs";
9
- import { TransportManager } from "./TransportManager.mjs";
10
- import { trezorPushNotificationHandler } from "./workflow/trezorPushNotification.mjs";
11
- const createAuthPenaltyManager = priority => {
12
- const penalizedDevices = {};
13
- const get = () => 100 * priority + Object.keys(penalizedDevices).reduce((penalty, key) => Math.max(penalty, penalizedDevices[key]), 0);
14
- const add = device => {
15
- if (!device.isInitialized() || device.isBootloader() || !device.features.device_id) return;
16
- const deviceID = device.features.device_id;
17
- const penalty = penalizedDevices[deviceID] ? penalizedDevices[deviceID] + 500 : 2000;
18
- penalizedDevices[deviceID] = Math.min(penalty, 5000);
19
- };
20
- const remove = device => {
21
- if (!device.isInitialized() || device.isBootloader() || !device.features.device_id) return;
22
- const deviceID = device.features.device_id;
23
- delete penalizedDevices[deviceID];
24
- };
25
- return {
26
- get,
27
- add,
28
- remove
29
- };
30
- };
31
- const getTransportInfo = transport => ({
32
- apiType: transport.apiType,
33
- type: transport.name,
34
- version: transport.version,
35
- outdated: transport.isOutdated
36
- });
37
- export const assertDeviceListConnected = deviceList => {
38
- if (!deviceList.isConnected()) {
39
- throw ERRORS.TypedError('Transport_Missing');
40
- }
41
- };
42
- export class DeviceList extends TypedEmitter {
43
- transportManagers = {};
44
- transports = [];
45
- devices = [];
46
- deviceCounter = Date.now();
47
- handshakeLock;
48
- authPenaltyManager;
49
- updateTransports;
50
- getConnectedTransports() {
51
- return Object.values(this.transportManagers).map(manager => manager.get()).filter(isNotUndefined);
52
- }
53
- isConnected() {
54
- return !!this.getConnectedTransports().length;
55
- }
56
- pendingConnection() {
57
- const pending = Object.values(this.transportManagers).map(manager => manager.pending()).filter(isNotUndefined);
58
- if (pending.length) return Promise.all(pending).then(() => {});
59
- }
60
- getActiveTransports() {
61
- return this.getConnectedTransports().map(getTransportInfo);
62
- }
63
- constructor({
64
- priority,
65
- debug,
66
- manifest
67
- }) {
68
- super();
69
- const transportLogger = initLog('@trezor/transport', debug);
70
- this.handshakeLock = getSynchronize();
71
- this.authPenaltyManager = createAuthPenaltyManager(priority);
72
- this.updateTransports = createTransportList({
73
- logger: transportLogger,
74
- id: manifest?.appName || manifest?.appUrl || 'unknown app'
75
- });
76
- }
77
- getSimilarDevices(device) {
78
- return this.devices.filter(d => {
79
- if (d.descriptor.apiType === device.transport.apiType) {
80
- return false;
81
- }
82
- if (device.descriptor.id && d.features?.device_id === device.descriptor.id) {
83
- return true;
84
- }
85
- if (device.descriptor.model && d.descriptor.model === device.descriptor.model) {
86
- return true;
87
- }
88
- return false;
89
- });
90
- }
91
- async onDeviceConnected(descriptor, transport) {
92
- const id = (this.deviceCounter++).toString(16).slice(-8);
93
- const device = new Device({
94
- id: asDeviceUniquePath(id),
95
- transport,
96
- descriptor
97
- });
98
- const similarUsedDevices = this.getSimilarDevices(device).some(d => d.isUsed() || d.getBusy() === 'rebooting');
99
- if (!similarUsedDevices) {
100
- const penalty = this.authPenaltyManager.get();
101
- const stillConnected = await this.handshakeLock(() => resolveAfter(penalty && penalty + 501).then(() => device.handshake()));
102
- if (!stillConnected) {
103
- return;
104
- }
105
- }
106
- if (descriptor.id && descriptor.apiType === 'bluetooth') {
107
- transport.subscribe({
108
- path: device.descriptor.id,
109
- channels: ['battery-level', 'trezor-push-notification']
110
- });
111
- }
112
- this.devices.push(device);
113
- device.lifecycle.on(DEVICE.CONNECT, () => this.emit(DEVICE.CONNECT, device));
114
- device.lifecycle.on(DEVICE.CHANGED, () => this.emit(DEVICE.CHANGED, device));
115
- device.lifecycle.on(DEVICE.CONNECT_UNACQUIRED, () => this.emit(DEVICE.CONNECT_UNACQUIRED, device));
116
- device.lifecycle.on(DEVICE.TREZOR_PUSH_NOTIFICATION, payload => {
117
- this.emit(DEVICE.TREZOR_PUSH_NOTIFICATION, {
118
- device,
119
- ...payload
120
- });
121
- });
122
- device.lifecycle.on(DEVICE.DISCONNECT, () => {
123
- device.lifecycle.removeAllListeners();
124
- this.authPenaltyManager.remove(device);
125
- const index = this.devices.indexOf(device);
126
- if (index >= 0) this.devices.splice(index, 1);
127
- this.emit(DEVICE.DISCONNECT, device);
128
- });
129
- this.emit(device.isUnacquired() ? DEVICE.CONNECT_UNACQUIRED : DEVICE.CONNECT, device);
130
- }
131
- onPushNotification(event) {
132
- const device = this.devices.find(d => d.descriptor.id === event.id);
133
- if (device) {
134
- trezorPushNotificationHandler({
135
- device,
136
- message: event.data
137
- });
138
- }
139
- }
140
- onBatteryLevel(event) {
141
- const device = this.devices.find(d => d.descriptor.id === event.id);
142
- device?.updateFeature('soc', event.data[0]);
143
- }
144
- getOrCreateTransportManager(apiType) {
145
- if (!this.transportManagers[apiType]) {
146
- const manager = new TransportManager(this.initializeTransport.bind(this));
147
- manager.on(TRANSPORT.START, transport => this.emit(TRANSPORT.START, getTransportInfo(transport)));
148
- manager.on(TRANSPORT.ERROR, error => this.emit(TRANSPORT.ERROR, {
149
- apiType,
150
- error
151
- }));
152
- this.transportManagers[apiType] = manager;
153
- }
154
- return this.transportManagers[apiType];
155
- }
156
- async init({
157
- transports,
158
- transportReconnect,
159
- pendingTransportEvent
160
- } = {}) {
161
- this.transports = this.updateTransports(this.transports, transports);
162
- const promises = this.transports.map(t => t.apiType).concat(typedObjectKeys(this.transportManagers)).filter(arrayDistinct).map(apiType => this.getOrCreateTransportManager(apiType).init({
163
- transports: this.transports.filter(t => t.apiType === apiType),
164
- transportReconnect,
165
- pendingTransportEvent
166
- }));
167
- await Promise.all(promises);
168
- }
169
- async initializeTransport(transport, pendingTransportEvent, signal) {
170
- transport.on(TRANSPORT.DEVICE_CONNECTED, d => this.onDeviceConnected(d, transport));
171
- transport.on(TRANSPORT.TREZOR_PUSH_NOTIFICATION, this.onPushNotification.bind(this));
172
- transport.on(TRANSPORT.BATTERY_LEVEL, this.onBatteryLevel.bind(this));
173
- const enumerateResult = await transport.enumerate({
174
- signal
175
- });
176
- if (!enumerateResult.success) {
177
- throw new Error(enumerateResult.error.message || enumerateResult.error.code);
178
- }
179
- const descriptors = enumerateResult.payload;
180
- transport.handleDescriptorsChange(descriptors);
181
- transport.listen();
182
- if (pendingTransportEvent && descriptors.length) {
183
- await this.waitForDevices(transport, signal);
184
- }
185
- }
186
- waitForDevices(transport, signal) {
187
- const {
188
- promise,
189
- reject,
190
- resolve
191
- } = createDeferred();
192
- const onAbort = () => reject(signal.reason);
193
- signal.addEventListener('abort', onAbort);
194
- const onError = error => reject(new Error(error));
195
- transport.once(TRANSPORT.ERROR, onError);
196
- const autoResolveTransportEventTimeout = setTimeout(resolve, 10000);
197
- this.handshakeLock(resolve);
198
- return promise.finally(() => {
199
- transport.off(TRANSPORT.ERROR, onError);
200
- signal.removeEventListener('abort', onAbort);
201
- clearTimeout(autoResolveTransportEventTimeout);
202
- });
203
- }
204
- getDeviceCount() {
205
- return this.devices.length;
206
- }
207
- getPrioritizedDevices() {
208
- return [...this.devices].sort((a, b) => (a.descriptor.apiType === 'bluetooth' ? 1 : 0) - (b.descriptor.apiType === 'bluetooth' ? 1 : 0));
209
- }
210
- getAllDevices() {
211
- return this.getPrioritizedDevices();
212
- }
213
- getOnlyDevice(apiType) {
214
- const devices = apiType ? this.devices.filter(d => d.descriptor.apiType === apiType) : this.devices;
215
- return devices.length === 1 ? devices[0] : undefined;
216
- }
217
- getDeviceByPath(path) {
218
- return this.getPrioritizedDevices().find(d => d.getUniquePath() === path);
219
- }
220
- getDeviceByStaticState(state) {
221
- const {
222
- deviceId
223
- } = parseStaticSessionId(state);
224
- return this.getPrioritizedDevices().find(d => d.features?.device_id === deviceId);
225
- }
226
- async dispose() {
227
- this.removeAllListeners();
228
- const promises = Object.values(this.transportManagers).map(manager => manager.dispose());
229
- await Promise.all(promises);
230
- }
231
- async enumerate() {
232
- const promises = this.getConnectedTransports().map(async transport => {
233
- const res = await transport.enumerate();
234
- if (res.success) {
235
- transport.handleDescriptorsChange(res.payload);
236
- }
237
- });
238
- await Promise.all(promises);
239
- }
240
- addAuthPenalty(device) {
241
- return this.authPenaltyManager.add(device);
242
- }
243
- removeAuthPenalty(device) {
244
- return this.authPenaltyManager.remove(device);
245
- }
246
- }
@@ -1,9 +0,0 @@
1
- import type { ConnectSettingsTransport } from '@trezor/connect-common/libESM/types/settings';
2
- import type { Transport } from '@trezor/transport';
3
- import { NodeUsbTransport, UdpTransport } from '@trezor/transport';
4
- import type { AbstractTransportParams } from '@trezor/transport/libESM/transports/abstract';
5
- type Params = AbstractTransportParams & {
6
- sessionsBackgroundUrl?: string | null;
7
- };
8
- export declare const createTransportList: (params: Params) => (existing: Transport[], transports?: ConnectSettingsTransport[]) => (Transport | NodeUsbTransport | UdpTransport)[];
9
- export {};
@@ -1,41 +0,0 @@
1
- import { ERRORS } from "@trezor/connect-common/libESM/constants/index.mjs";
2
- import { BridgeTransport, NodeUsbTransport, UdpTransport, WebUsbTransport, isTransportInstance } from "@trezor/transport";
3
- const tryGetTransport = (transports, name) => transports.find(t => t.name === name);
4
- const getOrCreateTransport = (transports, transportType, params) => {
5
- if (transportType === 'BridgeTransport') {
6
- const existing = transports.filter(t => t.name === transportType);
7
- return existing.length ? existing : [new BridgeTransport({
8
- ...params,
9
- port: 21328
10
- }), new BridgeTransport(params)];
11
- }
12
- if (typeof transportType === 'string') {
13
- const existing = tryGetTransport(transports, transportType);
14
- if (existing) return existing;
15
- switch (transportType) {
16
- case 'WebUsbTransport':
17
- return new WebUsbTransport(params);
18
- case 'NodeUsbTransport':
19
- return new NodeUsbTransport(params);
20
- case 'UdpTransport':
21
- return new UdpTransport(params);
22
- }
23
- } else if (typeof transportType === 'function' && 'prototype' in transportType) {
24
- const transportInstance = new transportType(params);
25
- if (isTransportInstance(transportInstance)) {
26
- return tryGetTransport(transports, transportInstance.name) ?? transportInstance;
27
- }
28
- } else if (isTransportInstance(transportType)) {
29
- const existing = tryGetTransport(transports, transportType.name);
30
- if (existing) {
31
- return existing;
32
- }
33
- return transportType;
34
- }
35
- throw ERRORS.TypedError('Runtime', `DeviceList.init: transports[] of unexpected type: ${transportType}`);
36
- };
37
- const createTransports = (existing, transports = [], params) => {
38
- const transportTypes = transports?.length ? transports : ['BridgeTransport'];
39
- return transportTypes.flatMap(type => getOrCreateTransport(existing, type, params));
40
- };
41
- export const createTransportList = params => (existing, transports) => createTransports(existing, transports, params);
@@ -1,30 +0,0 @@
1
- import type { Transport } from '@trezor/transport';
2
- import { TRANSPORT } from '@trezor/transport';
3
- import { TypedEmitter } from '@trezor/utils';
4
- type TransportManagerEvents = {
5
- [TRANSPORT.START]: Transport;
6
- [TRANSPORT.ERROR]: string;
7
- };
8
- type StartTransport = (transport: Transport, pendingTransportEvent: boolean, signal: AbortSignal) => Promise<void>;
9
- type InitParams = {
10
- transports: Transport[];
11
- transportReconnect?: boolean;
12
- pendingTransportEvent?: boolean;
13
- };
14
- export declare class TransportManager extends TypedEmitter<TransportManagerEvents> {
15
- private lock;
16
- private transports;
17
- private activeTransport?;
18
- private transportReconnect;
19
- private upgradeTimeout?;
20
- private readonly startTransport;
21
- constructor(startTransport: StartTransport);
22
- pending(): Promise<void> | undefined;
23
- get(): Transport | undefined;
24
- init({ transports, transportReconnect, pendingTransportEvent }: InitParams): Promise<void>;
25
- dispose(): Promise<void>;
26
- private selectTransport;
27
- private scheduleUpgradeCheck;
28
- private createInitPromise;
29
- }
30
- export {};