@trezor/connect 9.4.7 → 9.4.8-beta.1

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 (291) hide show
  1. package/CHANGELOG.md +55 -8
  2. package/README.md +1 -1
  3. package/lib/api/applyFlags.d.ts +1 -1
  4. package/lib/api/applyFlags.js +1 -1
  5. package/lib/api/applySettings.d.ts +1 -1
  6. package/lib/api/authenticateDevice.js +1 -1
  7. package/lib/api/authorizeCoinjoin.d.ts +1 -1
  8. package/lib/api/authorizeCoinjoin.js +1 -1
  9. package/lib/api/backupDevice.d.ts +1 -1
  10. package/lib/api/backupDevice.js +1 -1
  11. package/lib/api/binance/api/binanceGetAddress.d.ts +1 -1
  12. package/lib/api/binance/api/binanceGetAddress.js +3 -3
  13. package/lib/api/binance/api/binanceGetPublicKey.d.ts +1 -1
  14. package/lib/api/binance/api/binanceGetPublicKey.js +2 -2
  15. package/lib/api/binance/api/binanceSignTransaction.js +2 -2
  16. package/lib/api/binance/binanceSignTx.d.ts +1 -1
  17. package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
  18. package/lib/api/bitcoin/inputs.d.ts +1 -1
  19. package/lib/api/bitcoin/inputs.js +1 -1
  20. package/lib/api/bitcoin/outputs.js +2 -2
  21. package/lib/api/bitcoin/refTx.d.ts +2 -2
  22. package/lib/api/bitcoin/refTx.js +4 -4
  23. package/lib/api/bitcoin/signtx.d.ts +2 -2
  24. package/lib/api/bitcoin/signtxLegacy.d.ts +1 -1
  25. package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
  26. package/lib/api/blockchainDisconnect.js +2 -2
  27. package/lib/api/blockchainEstimateFee.d.ts +1 -1
  28. package/lib/api/blockchainEstimateFee.js +3 -2
  29. package/lib/api/blockchainEvmRpcCall.js +2 -2
  30. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
  31. package/lib/api/blockchainGetAccountBalanceHistory.js +1 -1
  32. package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
  33. package/lib/api/blockchainGetCurrentFiatRates.js +1 -1
  34. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
  35. package/lib/api/blockchainGetFiatRatesForTimestamps.js +1 -1
  36. package/lib/api/blockchainGetInfo.js +1 -1
  37. package/lib/api/blockchainGetTransactions.js +1 -1
  38. package/lib/api/blockchainSetCustomBackend.js +1 -1
  39. package/lib/api/blockchainSubscribe.d.ts +1 -1
  40. package/lib/api/blockchainSubscribe.js +1 -1
  41. package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -1
  42. package/lib/api/blockchainSubscribeFiatRates.js +1 -1
  43. package/lib/api/blockchainUnsubscribe.d.ts +1 -1
  44. package/lib/api/blockchainUnsubscribe.js +1 -1
  45. package/lib/api/blockchainUnsubscribeFiatRates.js +1 -1
  46. package/lib/api/cancelCoinjoinAuthorization.d.ts +1 -1
  47. package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +1 -1
  48. package/lib/api/cardano/api/cardanoComposeTransaction.js +3 -11
  49. package/lib/api/cardano/api/cardanoGetAddress.d.ts +1 -1
  50. package/lib/api/cardano/api/cardanoGetAddress.js +4 -4
  51. package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +2 -2
  52. package/lib/api/cardano/api/cardanoGetPublicKey.js +2 -2
  53. package/lib/api/cardano/api/cardanoSignTransaction.d.ts +3 -3
  54. package/lib/api/cardano/api/cardanoSignTransaction.js +4 -4
  55. package/lib/api/cardano/cardanoAddressParameters.js +1 -1
  56. package/lib/api/cardano/cardanoAuxiliaryData.js +1 -1
  57. package/lib/api/cardano/cardanoCertificate.js +1 -1
  58. package/lib/api/cardano/cardanoInputs.js +1 -1
  59. package/lib/api/cardano/cardanoUtils.js +30 -0
  60. package/lib/api/changePin.d.ts +1 -1
  61. package/lib/api/changePin.js +1 -1
  62. package/lib/api/changeWipeCode.d.ts +1 -1
  63. package/lib/api/cipherKeyValue.d.ts +1 -1
  64. package/lib/api/cipherKeyValue.js +3 -3
  65. package/lib/api/common/Discovery.d.ts +2 -2
  66. package/lib/api/common/paramsValidator.js +1 -1
  67. package/lib/api/composeTransaction.d.ts +3 -3
  68. package/lib/api/composeTransaction.js +9 -9
  69. package/lib/api/eos/api/eosGetPublicKey.d.ts +1 -1
  70. package/lib/api/eos/api/eosGetPublicKey.js +2 -2
  71. package/lib/api/eos/api/eosSignTransaction.d.ts +1 -1
  72. package/lib/api/eos/api/eosSignTransaction.js +2 -2
  73. package/lib/api/eos/eosSignTx.d.ts +3 -3
  74. package/lib/api/ethereum/api/ethereumGetAddress.d.ts +3 -3
  75. package/lib/api/ethereum/api/ethereumGetAddress.js +6 -6
  76. package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +1 -1
  77. package/lib/api/ethereum/api/ethereumGetPublicKey.js +3 -3
  78. package/lib/api/ethereum/api/ethereumSignMessage.d.ts +1 -1
  79. package/lib/api/ethereum/api/ethereumSignMessage.js +3 -3
  80. package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +2 -2
  81. package/lib/api/ethereum/api/ethereumSignTransaction.js +4 -4
  82. package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -1
  83. package/lib/api/ethereum/api/ethereumSignTypedData.js +6 -6
  84. package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +1 -1
  85. package/lib/api/ethereum/api/ethereumVerifyMessage.js +2 -2
  86. package/lib/api/ethereum/ethereumDefinitions.d.ts +2 -2
  87. package/lib/api/ethereum/ethereumDefinitions.js +1 -0
  88. package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +2 -2
  89. package/lib/api/firmware/parseFirmwareHeaders.d.ts +2 -1
  90. package/lib/api/firmware/uploadFirmware.d.ts +1 -1
  91. package/lib/api/firmware/uploadFirmware.js +1 -1
  92. package/lib/api/firmware/verifyAuthenticityProof.d.ts +1 -1
  93. package/lib/api/firmware/verifyEntropy.d.ts +19 -0
  94. package/lib/api/firmware/verifyEntropy.js +112 -0
  95. package/lib/api/getAccountDescriptor.js +4 -4
  96. package/lib/api/getAccountInfo.d.ts +21 -1
  97. package/lib/api/getAccountInfo.js +7 -7
  98. package/lib/api/getAddress.d.ts +1 -1
  99. package/lib/api/getAddress.js +3 -3
  100. package/lib/api/getCoinInfo.d.ts +3 -0
  101. package/lib/api/getCoinInfo.js +1 -1
  102. package/lib/api/getDeviceState.js +1 -1
  103. package/lib/api/getFirmwareHash.d.ts +1 -1
  104. package/lib/api/getFirmwareHash.js +1 -1
  105. package/lib/api/getOwnershipId.d.ts +1 -1
  106. package/lib/api/getOwnershipId.js +2 -2
  107. package/lib/api/getOwnershipProof.d.ts +1 -1
  108. package/lib/api/getOwnershipProof.js +2 -2
  109. package/lib/api/getPublicKey.d.ts +1 -1
  110. package/lib/api/getPublicKey.js +4 -4
  111. package/lib/api/loadDevice.d.ts +1 -1
  112. package/lib/api/loadDevice.js +1 -1
  113. package/lib/api/nem/api/nemGetAddress.d.ts +1 -1
  114. package/lib/api/nem/api/nemGetAddress.js +3 -3
  115. package/lib/api/nem/api/nemSignTransaction.d.ts +1 -1
  116. package/lib/api/nem/api/nemSignTransaction.js +2 -2
  117. package/lib/api/pushTransaction.js +2 -2
  118. package/lib/api/recoveryDevice.d.ts +1 -1
  119. package/lib/api/requestLogin.d.ts +1 -1
  120. package/lib/api/requestLogin.js +2 -2
  121. package/lib/api/resetDevice.d.ts +3 -1
  122. package/lib/api/resetDevice.js +58 -3
  123. package/lib/api/ripple/api/rippleGetAddress.d.ts +1 -1
  124. package/lib/api/ripple/api/rippleGetAddress.js +3 -3
  125. package/lib/api/ripple/api/rippleSignTransaction.d.ts +1 -1
  126. package/lib/api/ripple/api/rippleSignTransaction.js +2 -2
  127. package/lib/api/setBrightness.d.ts +1 -1
  128. package/lib/api/setBrightness.js +1 -1
  129. package/lib/api/setBusy.d.ts +1 -1
  130. package/lib/api/setBusy.js +1 -1
  131. package/lib/api/setProxy.js +1 -1
  132. package/lib/api/showDeviceTutorial.d.ts +1 -1
  133. package/lib/api/showDeviceTutorial.js +1 -1
  134. package/lib/api/signMessage.d.ts +1 -1
  135. package/lib/api/signMessage.js +2 -2
  136. package/lib/api/signTransaction.d.ts +2 -2
  137. package/lib/api/signTransaction.js +3 -3
  138. package/lib/api/solana/api/index.d.ts +1 -0
  139. package/lib/api/solana/api/index.js +3 -1
  140. package/lib/api/solana/api/solanaComposeTransaction.d.ts +25 -0
  141. package/lib/api/solana/api/solanaComposeTransaction.js +61 -0
  142. package/lib/api/solana/api/solanaGetAddress.js +2 -2
  143. package/lib/api/solana/api/solanaGetPublicKey.js +2 -2
  144. package/lib/api/solana/api/solanaSignTransaction.d.ts +9 -1
  145. package/lib/api/solana/api/solanaSignTransaction.js +20 -2
  146. package/lib/api/solana/solanaUtils.d.ts +48 -0
  147. package/lib/api/solana/solanaUtils.js +213 -0
  148. package/lib/api/stellar/api/stellarGetAddress.d.ts +1 -1
  149. package/lib/api/stellar/api/stellarGetAddress.js +3 -3
  150. package/lib/api/stellar/api/stellarSignTransaction.js +3 -3
  151. package/lib/api/tezos/api/tezosGetAddress.d.ts +1 -1
  152. package/lib/api/tezos/api/tezosGetAddress.js +3 -3
  153. package/lib/api/tezos/api/tezosGetPublicKey.d.ts +1 -1
  154. package/lib/api/tezos/api/tezosGetPublicKey.js +2 -2
  155. package/lib/api/tezos/api/tezosSignTransaction.d.ts +1 -1
  156. package/lib/api/tezos/api/tezosSignTransaction.js +2 -2
  157. package/lib/api/tezos/tezosSignTx.d.ts +17 -17
  158. package/lib/api/unlockPath.d.ts +1 -1
  159. package/lib/api/verifyMessage.d.ts +1 -1
  160. package/lib/api/verifyMessage.js +3 -3
  161. package/lib/backend/BackendManager.d.ts +1 -1
  162. package/lib/backend/BackendManager.js +1 -1
  163. package/lib/backend/Blockchain.d.ts +2 -2
  164. package/lib/backend/Blockchain.js +4 -7
  165. package/lib/constants/errors.d.ts +2 -0
  166. package/lib/constants/errors.js +4 -0
  167. package/lib/core/AbstractMethod.d.ts +2 -2
  168. package/lib/core/AbstractMethod.js +2 -1
  169. package/lib/core/index.d.ts +3 -3
  170. package/lib/core/index.js +44 -48
  171. package/lib/core/onCallFirmwareUpdate.d.ts +3 -8
  172. package/lib/core/onCallFirmwareUpdate.js +63 -21
  173. package/lib/data/DataManager.js +1 -5
  174. package/lib/data/coinInfo.d.ts +15 -131
  175. package/lib/data/coinInfo.js +8 -8
  176. package/lib/data/config.d.ts +23 -0
  177. package/lib/data/config.js +4 -0
  178. package/lib/data/connectSettings.js +1 -1
  179. package/lib/data/defaultFeeLevels.d.ts +2 -2
  180. package/lib/data/defaultFeeLevels.js +34 -14
  181. package/lib/data/deviceAuthenticityConfigTypes.d.ts +1 -0
  182. package/lib/data/deviceAuthenticityConfigTypes.js +2 -2
  183. package/lib/data/firmwareInfo.js +1 -1
  184. package/lib/data/models.js +5 -1
  185. package/lib/data/transportInfo.d.ts +0 -1
  186. package/lib/data/transportInfo.js +41 -28
  187. package/lib/data/udevInfo.d.ts +0 -1
  188. package/lib/data/udevInfo.js +2 -5
  189. package/lib/data/version.d.ts +1 -1
  190. package/lib/data/version.js +1 -1
  191. package/lib/device/Device.d.ts +11 -10
  192. package/lib/device/Device.js +39 -17
  193. package/lib/device/DeviceCommands.d.ts +2 -2
  194. package/lib/device/DeviceCommands.js +42 -27
  195. package/lib/device/DeviceList.d.ts +27 -22
  196. package/lib/device/DeviceList.js +222 -133
  197. package/lib/device/StateStorage.js +11 -13
  198. package/lib/device/prompts.js +28 -36
  199. package/lib/device/resolveDescriptorForTaproot.d.ts +2 -2
  200. package/lib/device/resolveDescriptorForTaproot.js +5 -13
  201. package/lib/events/blockchain.d.ts +1 -1
  202. package/lib/events/call.d.ts +1 -1
  203. package/lib/events/core.d.ts +3 -3
  204. package/lib/events/device.d.ts +11 -1
  205. package/lib/events/device.js +1 -0
  206. package/lib/events/popup.d.ts +2 -2
  207. package/lib/events/transport.d.ts +15 -9
  208. package/lib/events/transport.js +10 -1
  209. package/lib/events/ui-promise.d.ts +1 -1
  210. package/lib/events/ui-request.d.ts +3 -3
  211. package/lib/factory.d.ts +3 -2
  212. package/lib/factory.js +3 -1
  213. package/lib/impl/core-in-module.d.ts +4 -2
  214. package/lib/impl/core-in-module.js +9 -1
  215. package/lib/impl/dynamic.d.ts +4 -2
  216. package/lib/impl/dynamic.js +5 -4
  217. package/lib/index-browser.js +1 -0
  218. package/lib/index.js +11 -3
  219. package/lib/types/account.d.ts +1 -1
  220. package/lib/types/api/authenticateDevice.d.ts +1 -0
  221. package/lib/types/api/authorizeCoinjoin.d.ts +1 -1
  222. package/lib/types/api/authorizeCoinjoin.js +1 -1
  223. package/lib/types/api/binanceGetAddress.d.ts +1 -1
  224. package/lib/types/api/binanceGetPublicKey.d.ts +1 -1
  225. package/lib/types/api/blockchainEstimateFee.d.ts +1 -1
  226. package/lib/types/api/blockchainSetCustomBackend.d.ts +1 -1
  227. package/lib/types/api/blockchainSubscribe.d.ts +1 -1
  228. package/lib/types/api/cardanoComposeTransaction.d.ts +112 -6
  229. package/lib/types/api/cardanoComposeTransaction.js +77 -0
  230. package/lib/types/api/cardanoGetAddress.d.ts +1 -1
  231. package/lib/types/api/cardanoGetPublicKey.d.ts +1 -1
  232. package/lib/types/api/changeLanguage.d.ts +1 -1
  233. package/lib/types/api/cipherKeyValue.d.ts +1 -1
  234. package/lib/types/api/composeTransaction.d.ts +1 -1
  235. package/lib/types/api/eosGetPublicKey.d.ts +1 -1
  236. package/lib/types/api/ethereumGetAddress.d.ts +1 -1
  237. package/lib/types/api/ethereumGetPublicKey.d.ts +1 -1
  238. package/lib/types/api/ethereumSignTypedData.d.ts +1 -1
  239. package/lib/types/api/firmwareUpdate.d.ts +11 -2
  240. package/lib/types/api/getAccountDescriptor.d.ts +1 -1
  241. package/lib/types/api/getAccountInfo.d.ts +1 -1
  242. package/lib/types/api/getAddress.d.ts +2 -1
  243. package/lib/types/api/getCoinInfo.d.ts +1 -1
  244. package/lib/types/api/getDeviceState.d.ts +1 -1
  245. package/lib/types/api/getFeatures.d.ts +1 -1
  246. package/lib/types/api/getOwnershipId.d.ts +2 -1
  247. package/lib/types/api/getOwnershipProof.d.ts +2 -1
  248. package/lib/types/api/getPublicKey.d.ts +1 -1
  249. package/lib/types/api/index.d.ts +7 -3
  250. package/lib/types/api/nem/index.d.ts +1 -1
  251. package/lib/types/api/nemGetAddress.d.ts +1 -1
  252. package/lib/types/api/on.d.ts +1 -1
  253. package/lib/types/api/recoveryDevice.d.ts +1 -1
  254. package/lib/types/api/rippleGetAddress.d.ts +1 -1
  255. package/lib/types/api/setTransports.d.ts +4 -0
  256. package/lib/types/api/setTransports.js +3 -0
  257. package/lib/types/api/solana/index.d.ts +41 -0
  258. package/lib/types/api/solana/index.js +31 -1
  259. package/lib/types/api/solanaComposeTransaction.d.ts +4 -0
  260. package/lib/types/api/solanaComposeTransaction.js +3 -0
  261. package/lib/types/api/solanaGetAddress.d.ts +1 -1
  262. package/lib/types/api/solanaGetPublicKey.d.ts +1 -1
  263. package/lib/types/api/stellarGetAddress.d.ts +1 -1
  264. package/lib/types/api/tezosGetAddress.d.ts +1 -1
  265. package/lib/types/api/tezosGetPublicKey.d.ts +1 -1
  266. package/lib/types/api/unlockPath.d.ts +1 -1
  267. package/lib/types/coinInfo.d.ts +33 -0
  268. package/lib/types/coinInfo.js +8 -2
  269. package/lib/types/params.d.ts +1 -1
  270. package/lib/utils/abortablePromise.d.ts +5 -0
  271. package/lib/utils/abortablePromise.js +17 -0
  272. package/lib/utils/accountUtils.d.ts +1 -1
  273. package/lib/utils/accountUtils.js +1 -1
  274. package/lib/utils/assetUtils.js +1 -2
  275. package/lib/utils/assets-browser.d.ts +1 -1
  276. package/lib/utils/assets.js +1 -1
  277. package/lib/utils/assets.native.d.ts +1 -1
  278. package/lib/utils/deviceFeaturesUtils.d.ts +1 -1
  279. package/lib/utils/deviceFeaturesUtils.js +6 -12
  280. package/lib/utils/ethereumUtils.d.ts +3 -2
  281. package/lib/utils/firmwareUtils.d.ts +1 -1
  282. package/lib/utils/firmwareUtils.js +11 -4
  283. package/lib/utils/pathUtils.d.ts +1 -1
  284. package/lib/utils/urlUtils.js +2 -0
  285. package/lib/workers/workers-browser.d.ts +2 -2
  286. package/lib/workers/workers-browser.js +2 -2
  287. package/lib/workers/workers.native.d.ts +1 -1
  288. package/lib/workers/workers.native.js +2 -2
  289. package/package.json +22 -12
  290. package/lib/utils/promiseUtils.d.ts +0 -5
  291. package/lib/utils/promiseUtils.js +0 -14
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceList = exports.assertDeviceListConnected = void 0;
4
- const utils_1 = require("@trezor/utils");
5
4
  const transport_1 = require("@trezor/transport");
5
+ const utils_1 = require("@trezor/utils");
6
6
  const constants_1 = require("../constants");
7
7
  const events_1 = require("../events");
8
8
  const Device_1 = require("./Device");
9
- const types_1 = require("../types");
10
9
  const transportInfo_1 = require("../data/transportInfo");
11
- const debug_1 = require("../utils/debug");
12
- const promiseUtils_1 = require("../utils/promiseUtils");
10
+ const types_1 = require("../types");
13
11
  const utils_2 = require("../types/utils");
14
- const _log = (0, debug_1.initLog)('DeviceList');
12
+ const abortablePromise_1 = require("../utils/abortablePromise");
13
+ const debug_1 = require("../utils/debug");
15
14
  const createAuthPenaltyManager = (priority) => {
16
15
  const penalizedDevices = {};
17
16
  const get = () => 100 * priority +
@@ -32,22 +31,81 @@ const createAuthPenaltyManager = (priority) => {
32
31
  const clear = () => Object.keys(penalizedDevices).forEach(key => delete penalizedDevices[key]);
33
32
  return { get, add, remove, clear };
34
33
  };
34
+ const createDeviceCollection = () => {
35
+ let devices = [];
36
+ const isEqual = (a) => (b) => a.transport === b.transport && a.transportPath === b.transportPath;
37
+ const get = (transportPath, transport) => devices.find(isEqual({ transport, transportPath }));
38
+ const all = () => devices;
39
+ const add = (device) => {
40
+ const index = devices.findIndex(isEqual(device));
41
+ if (index >= 0)
42
+ devices[index] = device;
43
+ else
44
+ devices.push(device);
45
+ };
46
+ const remove = (transportPath, transport) => {
47
+ const index = devices.findIndex(isEqual({ transport, transportPath }));
48
+ const [removed] = index >= 0 ? devices.splice(index, 1) : [undefined];
49
+ return removed;
50
+ };
51
+ const clear = (transport) => {
52
+ let removed;
53
+ [removed, devices] = (0, utils_1.arrayPartition)(devices, d => !transport || d.transport === transport);
54
+ return removed;
55
+ };
56
+ return { get, all, add, remove, clear };
57
+ };
58
+ const getTransportInfo = (transport) => ({
59
+ apiType: transport.apiType,
60
+ type: transport.name,
61
+ version: transport.version,
62
+ outdated: transport.isOutdated,
63
+ });
35
64
  const assertDeviceListConnected = deviceList => {
36
- if (!deviceList.isConnected())
65
+ if (!deviceList.isConnected()) {
37
66
  throw constants_1.ERRORS.TypedError('Transport_Missing');
67
+ }
38
68
  };
39
69
  exports.assertDeviceListConnected = assertDeviceListConnected;
40
70
  class DeviceList extends utils_1.TypedEmitter {
41
71
  isConnected() {
42
- return !!this.transport;
72
+ return !!Object.keys(this.transport).length;
43
73
  }
44
74
  pendingConnection() {
45
- return this.initPromise;
75
+ const pending = Object.values(this.locks)
76
+ .map(({ promise }) => promise)
77
+ .filter(utils_1.isNotUndefined);
78
+ if (pending.length)
79
+ return Promise.all(pending).then(() => { });
80
+ }
81
+ getActiveTransports() {
82
+ return Object.values(this.transport).map(getTransportInfo);
83
+ }
84
+ async transportLock(apiType, abortMessage, action) {
85
+ var _a, _b;
86
+ const lock = (_a = this.locks[apiType]) !== null && _a !== void 0 ? _a : (this.locks[apiType] = { sequence: 0 });
87
+ lock.abortMessage = abortMessage;
88
+ const sequence = ++lock.sequence;
89
+ while (lock.promise) {
90
+ (_b = lock.abort) === null || _b === void 0 ? void 0 : _b.abort(new Error(abortMessage));
91
+ await lock.promise.catch(() => { });
92
+ }
93
+ if (sequence !== lock.sequence)
94
+ return Promise.reject(new Error(lock.abortMessage));
95
+ lock.abort = new AbortController();
96
+ lock.promise = action(lock.abort.signal).finally(() => {
97
+ delete lock.abort;
98
+ delete lock.promise;
99
+ });
100
+ return lock.promise;
46
101
  }
47
102
  constructor({ messages, priority, debug, _sessionsBackgroundUrl, manifest, }) {
48
103
  super();
49
- this.devices = {};
104
+ this.transport = {};
105
+ this.transports = [];
106
+ this.devices = createDeviceCollection();
50
107
  this.deviceCounter = Date.now();
108
+ this.locks = {};
51
109
  const transportLogger = (0, debug_1.initLog)('@trezor/transport', debug);
52
110
  this.handshakeLock = (0, utils_1.getSynchronize)();
53
111
  this.authPenaltyManager = createAuthPenaltyManager(priority);
@@ -57,16 +115,17 @@ class DeviceList extends utils_1.TypedEmitter {
57
115
  sessionsBackgroundUrl: _sessionsBackgroundUrl,
58
116
  id: (manifest === null || manifest === void 0 ? void 0 : manifest.appUrl) || 'unknown app',
59
117
  };
60
- this.transports = [
61
- new transport_1.BridgeTransport({
62
- latestVersion: (0, transportInfo_1.getBridgeInfo)().version.join('.'),
63
- ...this.transportCommonArgs,
64
- }),
65
- ];
66
118
  }
67
- createTransport(transportType) {
119
+ tryGetTransport(name) {
120
+ return this.transports.find(t => t.name === name);
121
+ }
122
+ getOrCreateTransport(transportType) {
123
+ var _a;
68
124
  const { transportCommonArgs } = this;
69
125
  if (typeof transportType === 'string') {
126
+ const existing = this.tryGetTransport(transportType);
127
+ if (existing)
128
+ return existing;
70
129
  switch (transportType) {
71
130
  case 'WebUsbTransport':
72
131
  return new transport_1.WebUsbTransport(transportCommonArgs);
@@ -84,10 +143,13 @@ class DeviceList extends utils_1.TypedEmitter {
84
143
  else if (typeof transportType === 'function' && 'prototype' in transportType) {
85
144
  const transportInstance = new transportType(transportCommonArgs);
86
145
  if ((0, transport_1.isTransportInstance)(transportInstance)) {
87
- return transportInstance;
146
+ return (_a = this.tryGetTransport(transportInstance.name)) !== null && _a !== void 0 ? _a : transportInstance;
88
147
  }
89
148
  }
90
149
  else if ((0, transport_1.isTransportInstance)(transportType)) {
150
+ if (this.tryGetTransport(transportType.name)) {
151
+ return transportType;
152
+ }
91
153
  if (!transportType.getMessage()) {
92
154
  transportType.updateMessages(transportCommonArgs.messages);
93
155
  }
@@ -95,185 +157,212 @@ class DeviceList extends utils_1.TypedEmitter {
95
157
  }
96
158
  throw constants_1.ERRORS.TypedError('Runtime', `DeviceList.init: transports[] of unexpected type: ${transportType}`);
97
159
  }
98
- setTransports(transports) {
160
+ createTransports(transports) {
99
161
  const transportTypes = (transports === null || transports === void 0 ? void 0 : transports.length) ? transports : ['BridgeTransport'];
100
- this.transports = transportTypes.map(this.createTransport.bind(this));
162
+ return transportTypes.map(this.getOrCreateTransport.bind(this));
101
163
  }
102
164
  onDeviceConnected(descriptor, transport) {
103
- const { path } = descriptor;
104
165
  const id = (this.deviceCounter++).toString(16).slice(-8);
105
166
  const device = new Device_1.Device({
106
167
  id: (0, types_1.DeviceUniquePath)(id),
107
168
  transport,
108
169
  descriptor,
109
- listener: lifecycle => this.emit(lifecycle, device.toMessageObject()),
170
+ listener: lifecycle => this.emit(lifecycle, device),
110
171
  });
111
- this.devices[path] = device;
172
+ this.devices.add(device);
112
173
  const penalty = this.authPenaltyManager.get();
113
174
  this.handshakeLock(async () => {
114
- if (this.devices[path]) {
175
+ if (this.devices.get(descriptor.path, transport)) {
115
176
  await device.handshake(penalty);
116
177
  }
117
178
  });
118
179
  }
119
- onDeviceDisconnected(descriptor) {
120
- const { path } = descriptor;
121
- const device = this.devices[path];
122
- if (device) {
123
- device.disconnect();
124
- delete this.devices[path];
125
- }
180
+ onDeviceDisconnected(descriptor, transport) {
181
+ const device = this.devices.remove(descriptor.path, transport);
182
+ device === null || device === void 0 ? void 0 : device.disconnect();
126
183
  }
127
- onDeviceSessionChanged(descriptor) {
128
- const device = this.devices[descriptor.path];
129
- if (device) {
130
- device.updateDescriptor(descriptor);
131
- }
184
+ onDeviceSessionChanged(descriptor, transport) {
185
+ const device = this.devices.get(descriptor.path, transport);
186
+ device === null || device === void 0 ? void 0 : device.updateDescriptor(descriptor);
132
187
  }
133
- onDeviceRequestRelease(descriptor) {
134
- var _a;
135
- (_a = this.devices[descriptor.path]) === null || _a === void 0 ? void 0 : _a.usedElsewhere();
188
+ onDeviceRequestRelease(descriptor, transport) {
189
+ const device = this.devices.get(descriptor.path, transport);
190
+ device === null || device === void 0 ? void 0 : device.usedElsewhere();
136
191
  }
137
- init(initParams = {}) {
138
- if (!this.initPromise) {
139
- _log.debug('Initializing transports');
140
- this.initPromise = this.createInitPromise(initParams);
141
- }
142
- return this.initPromise;
192
+ async init(initParams = {}) {
193
+ this.transports = this.createTransports(initParams.transports);
194
+ const promises = this.transports
195
+ .map(t => t.apiType)
196
+ .concat((0, utils_2.typedObjectKeys)(this.transport))
197
+ .concat((0, utils_2.typedObjectKeys)(this.locks))
198
+ .filter(utils_1.arrayDistinct)
199
+ .map(apiType => this.transportLock(apiType, 'New init', signal => this.createInitPromise(apiType, initParams, signal)));
200
+ await Promise.all(promises);
143
201
  }
144
- createInitPromise(initParams) {
145
- return this.selectTransport(this.transports)
146
- .then(transport => this.initializeTransport(transport, initParams))
147
- .then(transport => {
148
- this.transport = transport;
149
- this.emit(transport_1.TRANSPORT.START, this.getTransportInfo());
150
- this.initPromise = undefined;
151
- })
152
- .catch(error => {
153
- this.cleanup();
154
- this.emit(transport_1.TRANSPORT.ERROR, error);
155
- this.initPromise = initParams.transportReconnect
156
- ? this.createReconnectPromise(initParams)
202
+ async createInitPromise(apiType, initParams, abortSignal) {
203
+ try {
204
+ const transports = this.transports.filter(t => t.apiType === apiType);
205
+ const transport = transports.length
206
+ ? await this.selectTransport(transports, abortSignal)
157
207
  : undefined;
158
- });
208
+ const oldTransport = this.transport[apiType];
209
+ if (oldTransport !== transport) {
210
+ if (oldTransport) {
211
+ delete this.transport[apiType];
212
+ await this.stopTransport(oldTransport);
213
+ if (!transport) {
214
+ this.emit(transport_1.TRANSPORT.ERROR, { apiType, error: 'Transport disabled' });
215
+ }
216
+ }
217
+ if (transport) {
218
+ try {
219
+ await this.initializeTransport(transport, initParams, abortSignal);
220
+ }
221
+ catch (error) {
222
+ await this.stopTransport(transport);
223
+ throw error;
224
+ }
225
+ transport.on(transport_1.TRANSPORT.ERROR, error => {
226
+ this.emit(transport_1.TRANSPORT.ERROR, { apiType, error });
227
+ this.transportLock(apiType, 'Transport error', async (signal) => {
228
+ delete this.transport[apiType];
229
+ await this.stopTransport(transport);
230
+ if (initParams.transportReconnect) {
231
+ await this.createReconnectDelay(signal);
232
+ await this.createInitPromise(apiType, initParams, signal);
233
+ }
234
+ }).catch(() => { });
235
+ });
236
+ this.transport[apiType] = transport;
237
+ this.emit(transport_1.TRANSPORT.START, getTransportInfo(transport));
238
+ }
239
+ }
240
+ }
241
+ catch (error) {
242
+ this.emit(transport_1.TRANSPORT.ERROR, { apiType, error: error === null || error === void 0 ? void 0 : error.message });
243
+ if (initParams.transportReconnect && !abortSignal.aborted) {
244
+ this.transportLock(apiType, 'Reconnecting', async (signal) => {
245
+ await this.createReconnectDelay(signal);
246
+ await this.createInitPromise(apiType, initParams, signal);
247
+ }).catch(() => { });
248
+ }
249
+ }
159
250
  }
160
- createReconnectPromise(initParams) {
161
- const { promise, reject } = (0, promiseUtils_1.resolveAfter)(1000, initParams);
162
- this.rejectPending = reject;
163
- return promise
164
- .then(this.createInitPromise.bind(this))
165
- .catch(() => { })
166
- .finally(() => {
167
- this.rejectPending = undefined;
168
- });
251
+ createReconnectDelay(signal) {
252
+ const { promise, resolve } = (0, abortablePromise_1.abortablePromise)(signal);
253
+ const timeout = setTimeout(resolve, 1000);
254
+ return promise.finally(() => clearTimeout(timeout));
169
255
  }
170
- async selectTransport([transport, ...rest]) {
171
- const result = await transport.init();
256
+ async selectTransport([transport, ...rest], signal) {
257
+ if (signal.aborted)
258
+ throw new Error(signal.reason);
259
+ if (transport === this.transport[transport.apiType])
260
+ return transport;
261
+ const result = await transport.init({ signal });
172
262
  if (result.success)
173
263
  return transport;
174
264
  else if (rest.length)
175
- return this.selectTransport(rest);
265
+ return this.selectTransport(rest, signal);
176
266
  else
177
267
  throw new Error(result.error);
178
268
  }
179
- async initializeTransport(transport, initParams) {
269
+ async initializeTransport(transport, initParams, signal) {
180
270
  transport.on(transport_1.TRANSPORT.DEVICE_CONNECTED, d => this.onDeviceConnected(d, transport));
181
- transport.on(transport_1.TRANSPORT.DEVICE_DISCONNECTED, this.onDeviceDisconnected.bind(this));
182
- transport.on(transport_1.TRANSPORT.DEVICE_SESSION_CHANGED, this.onDeviceSessionChanged.bind(this));
183
- transport.on(transport_1.TRANSPORT.DEVICE_REQUEST_RELEASE, this.onDeviceRequestRelease.bind(this));
184
- transport.on(transport_1.TRANSPORT.ERROR, error => {
185
- this.cleanup();
186
- this.emit(transport_1.TRANSPORT.ERROR, error);
187
- if (initParams.transportReconnect) {
188
- this.initPromise = this.createReconnectPromise(initParams);
189
- }
190
- });
191
- const enumerateResult = await transport.enumerate();
271
+ transport.on(transport_1.TRANSPORT.DEVICE_DISCONNECTED, d => this.onDeviceDisconnected(d, transport));
272
+ transport.on(transport_1.TRANSPORT.DEVICE_SESSION_CHANGED, d => this.onDeviceSessionChanged(d, transport));
273
+ transport.on(transport_1.TRANSPORT.DEVICE_REQUEST_RELEASE, d => this.onDeviceRequestRelease(d, transport));
274
+ const enumerateResult = await transport.enumerate({ signal });
192
275
  if (!enumerateResult.success) {
193
276
  throw new Error(enumerateResult.error);
194
277
  }
195
278
  const descriptors = enumerateResult.payload;
196
279
  const waitForDevicesPromise = initParams.pendingTransportEvent && descriptors.length
197
- ? this.waitForDevices(descriptors.length, 10000)
280
+ ? this.waitForDevices(transport, descriptors, signal)
198
281
  : Promise.resolve();
199
282
  transport.handleDescriptorsChange(descriptors);
200
283
  transport.listen();
201
284
  await waitForDevicesPromise;
202
- return transport;
203
285
  }
204
- waitForDevices(deviceCount, autoResolveMs) {
205
- const { promise, resolve, reject } = (0, utils_1.createDeferred)();
206
- let transportStartPending = deviceCount;
207
- const autoResolveTransportEventTimeout = setTimeout(resolve, autoResolveMs);
208
- this.rejectPending = reject;
209
- const onDeviceConnect = () => {
210
- transportStartPending--;
211
- if (transportStartPending === 0) {
286
+ waitForDevices(transport, descriptors, signal) {
287
+ const { promise, reject, resolve } = (0, utils_1.createDeferred)();
288
+ const onAbort = () => reject(signal.reason);
289
+ signal.addEventListener('abort', onAbort);
290
+ const onError = (error) => reject(new Error(error));
291
+ transport.once(transport_1.TRANSPORT.ERROR, onError);
292
+ const autoResolveTransportEventTimeout = setTimeout(resolve, 10000);
293
+ const remaining = descriptors.slice();
294
+ const onDeviceEvent = (device) => {
295
+ const index = remaining.findIndex(d => d.path === device.transportPath && transport === device.transport);
296
+ if (index >= 0)
297
+ remaining.splice(index, 1);
298
+ if (!remaining.length)
212
299
  resolve();
213
- }
214
300
  };
215
- this.on(events_1.DEVICE.CONNECT, onDeviceConnect);
216
- this.on(events_1.DEVICE.CONNECT_UNACQUIRED, onDeviceConnect);
301
+ this.on(events_1.DEVICE.CONNECT, onDeviceEvent);
302
+ this.on(events_1.DEVICE.CONNECT_UNACQUIRED, onDeviceEvent);
303
+ this.on(events_1.DEVICE.DISCONNECT, onDeviceEvent);
217
304
  return promise.finally(() => {
218
- this.rejectPending = undefined;
305
+ transport.off(transport_1.TRANSPORT.ERROR, onError);
306
+ signal.removeEventListener('abort', onAbort);
219
307
  clearTimeout(autoResolveTransportEventTimeout);
220
- this.off(events_1.DEVICE.CONNECT, onDeviceConnect);
221
- this.off(events_1.DEVICE.CONNECT_UNACQUIRED, onDeviceConnect);
308
+ this.off(events_1.DEVICE.CONNECT, onDeviceEvent);
309
+ this.off(events_1.DEVICE.CONNECT_UNACQUIRED, onDeviceEvent);
310
+ this.off(events_1.DEVICE.DISCONNECT, onDeviceEvent);
222
311
  });
223
312
  }
224
313
  getDeviceCount() {
225
- return Object.keys(this.devices).length;
314
+ return this.devices.all().length;
226
315
  }
227
316
  getAllDevices() {
228
- return (0, utils_2.typedObjectKeys)(this.devices).map(key => this.devices[key]);
317
+ return this.devices.all();
229
318
  }
230
319
  getOnlyDevice() {
231
- return this.getDeviceCount() === 1 ? Object.values(this.devices)[0] : undefined;
320
+ return this.getDeviceCount() === 1 ? this.devices.all()[0] : undefined;
232
321
  }
233
322
  getDeviceByPath(path) {
234
- return this.getAllDevices().find(d => d.getUniquePath() === path);
323
+ return this.devices.all().find(d => d.getUniquePath() === path);
235
324
  }
236
325
  getDeviceByStaticState(state) {
237
326
  const deviceId = state.split('@')[1].split(':')[0];
238
- return this.getAllDevices().find(d => { var _a; return ((_a = d.features) === null || _a === void 0 ? void 0 : _a.device_id) === deviceId; });
239
- }
240
- transportType() {
241
- return this.transport.name;
242
- }
243
- getTransportInfo() {
244
- return {
245
- type: this.transportType(),
246
- version: this.transport.version,
247
- outdated: this.transport.isOutdated,
248
- };
327
+ return this.devices.all().find(d => { var _a; return ((_a = d.features) === null || _a === void 0 ? void 0 : _a.device_id) === deviceId; });
249
328
  }
250
- dispose() {
329
+ async dispose() {
251
330
  this.removeAllListeners();
252
- return this.cleanup();
331
+ const promises = (0, utils_2.typedObjectKeys)(this.transport)
332
+ .concat((0, utils_2.typedObjectKeys)(this.locks))
333
+ .filter(utils_1.arrayDistinct)
334
+ .map(apiType => this.transportLock(apiType, 'Disposing', async () => {
335
+ const transport = this.transport[apiType];
336
+ if (transport) {
337
+ delete this.transport[apiType];
338
+ await this.stopTransport(transport);
339
+ }
340
+ }));
341
+ await Promise.all(promises);
253
342
  }
254
- async cleanup() {
255
- var _a;
256
- const { transport } = this;
257
- const devices = this.getAllDevices();
258
- this.transport = undefined;
259
- this.authPenaltyManager.clear();
260
- (0, utils_2.typedObjectKeys)(this.devices).forEach(key => delete this.devices[key]);
261
- (_a = this.rejectPending) === null || _a === void 0 ? void 0 : _a.call(this, new Error('Disposed'));
343
+ async stopTransport(transport) {
344
+ const devices = this.devices.clear(transport);
262
345
  devices.forEach(device => {
263
- this.emit(events_1.DEVICE.DISCONNECT, device.toMessageObject());
346
+ this.emit(events_1.DEVICE.DISCONNECT, device);
264
347
  });
265
- await Promise.all(devices.map(device => device.dispose()));
348
+ await Promise.all(devices.map(async (device) => {
349
+ this.authPenaltyManager.remove(device);
350
+ await device.dispose();
351
+ }));
266
352
  transport === null || transport === void 0 ? void 0 : transport.stop();
267
353
  }
268
- async enumerate(transport = this.transport) {
269
- const res = await transport.enumerate();
270
- if (!res.success) {
271
- return;
272
- }
273
- res.payload.forEach(d => {
274
- var _a;
275
- (_a = this.devices[d.path]) === null || _a === void 0 ? void 0 : _a.updateDescriptor(d);
354
+ async enumerate() {
355
+ const promises = Object.values(this.transport).map(async (transport) => {
356
+ const res = await transport.enumerate();
357
+ if (!res.success) {
358
+ return;
359
+ }
360
+ res.payload.forEach(d => {
361
+ var _a;
362
+ (_a = this.devices.get(d.path, transport)) === null || _a === void 0 ? void 0 : _a.updateDescriptor(d);
363
+ });
276
364
  });
365
+ await Promise.all(promises);
277
366
  }
278
367
  addAuthPenalty(device) {
279
368
  return this.authPenaltyManager.add(device);
@@ -21,19 +21,17 @@ class WebextensionStateStorage {
21
21
  saveState(device, state) {
22
22
  var _a;
23
23
  const expirationDelay = Math.max(1000 * 60 * 15, (_a = device.features.auto_lock_delay_ms) !== null && _a !== void 0 ? _a : 0);
24
- connect_common_1.storage.saveForOrigin(store => {
25
- return {
26
- ...store,
27
- preferredDevice: store.preferredDevice
28
- ? {
29
- ...store.preferredDevice,
30
- state: state.staticSessionId,
31
- internalState: state.sessionId,
32
- internalStateExpiration: Date.now() + expirationDelay,
33
- }
34
- : undefined,
35
- };
36
- }, this.origin);
24
+ connect_common_1.storage.saveForOrigin(store => ({
25
+ ...store,
26
+ preferredDevice: store.preferredDevice
27
+ ? {
28
+ ...store.preferredDevice,
29
+ state: state.staticSessionId,
30
+ internalState: state.sessionId,
31
+ internalStateExpiration: Date.now() + expirationDelay,
32
+ }
33
+ : undefined,
34
+ }), this.origin);
37
35
  }
38
36
  }
39
37
  exports.WebextensionStateStorage = WebextensionStateStorage;
@@ -21,44 +21,36 @@ const cancelPrompt = (device, expectResponse = true) => {
21
21
  return expectResponse ? device.transport.call(cancelArgs) : device.transport.send(cancelArgs);
22
22
  };
23
23
  exports.cancelPrompt = cancelPrompt;
24
- const prompt = (event, ...[device, ...args]) => {
25
- return new Promise((resolve, reject) => {
26
- const cancelAndReject = (error) => (0, exports.cancelPrompt)(device).then(onCancel => {
27
- var _a;
28
- return reject(error ||
29
- new Error(onCancel.success
30
- ? (_a = onCancel.payload) === null || _a === void 0 ? void 0 : _a.message.message
31
- : onCancel.error));
32
- });
33
- if (device.listenerCount(event) > 0) {
34
- device.setCancelableAction(cancelAndReject);
35
- const callback = (...[response, error]) => {
36
- device.clearCancelableAction();
37
- if (error || response == null) {
38
- cancelAndReject(error);
39
- }
40
- else {
41
- resolve(response);
42
- }
43
- };
44
- const emitArgs = [event, device, ...args, callback];
45
- device.emit(...emitArgs);
46
- }
47
- else {
48
- cancelAndReject(constants_1.ERRORS.TypedError('Runtime', `${event} callback not configured`));
49
- }
24
+ const prompt = (event, ...[device, ...args]) => new Promise((resolve, reject) => {
25
+ const cancelAndReject = (error) => (0, exports.cancelPrompt)(device).then(onCancel => {
26
+ var _a;
27
+ return reject(error ||
28
+ new Error(onCancel.success
29
+ ? (_a = onCancel.payload) === null || _a === void 0 ? void 0 : _a.message.message
30
+ : onCancel.error));
50
31
  });
51
- };
52
- const promptPassphrase = (device) => {
53
- return prompt(events_1.DEVICE.PASSPHRASE, device);
54
- };
32
+ if (device.listenerCount(event) > 0) {
33
+ device.setCancelableAction(cancelAndReject);
34
+ const callback = (...[response, error]) => {
35
+ device.clearCancelableAction();
36
+ if (error || response == null) {
37
+ cancelAndReject(error);
38
+ }
39
+ else {
40
+ resolve(response);
41
+ }
42
+ };
43
+ const emitArgs = [event, device, ...args, callback];
44
+ device.emit(...emitArgs);
45
+ }
46
+ else {
47
+ cancelAndReject(constants_1.ERRORS.TypedError('Runtime', `${event} callback not configured`));
48
+ }
49
+ });
50
+ const promptPassphrase = (device) => prompt(events_1.DEVICE.PASSPHRASE, device);
55
51
  exports.promptPassphrase = promptPassphrase;
56
- const promptPin = (device, type) => {
57
- return prompt(events_1.DEVICE.PIN, device, type);
58
- };
52
+ const promptPin = (device, type) => prompt(events_1.DEVICE.PIN, device, type);
59
53
  exports.promptPin = promptPin;
60
- const promptWord = (device, type) => {
61
- return prompt(events_1.DEVICE.WORD, device, type);
62
- };
54
+ const promptWord = (device, type) => prompt(events_1.DEVICE.WORD, device, type);
63
55
  exports.promptWord = promptWord;
64
56
  //# sourceMappingURL=prompts.js.map
@@ -1,10 +1,10 @@
1
1
  import { MessagesSchema as Messages } from '@trezor/protobuf';
2
2
  import { HDNodeResponse } from '../types/api/getPublicKey';
3
- interface Params {
3
+ interface ResolveDescriptorForTaprootParams {
4
4
  response: HDNodeResponse;
5
5
  publicKey: Messages.PublicKey;
6
6
  }
7
- export declare const resolveDescriptorForTaproot: ({ response, publicKey }: Params) => {
7
+ export declare const resolveDescriptorForTaproot: ({ response, publicKey, }: ResolveDescriptorForTaprootParams) => {
8
8
  xpub: string;
9
9
  checksum: string;
10
10
  } | {
@@ -1,21 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveDescriptorForTaproot = void 0;
4
- const resolveDescriptorForTaproot = ({ response, publicKey }) => {
4
+ const utils_1 = require("@trezor/utils");
5
+ const resolveDescriptorForTaproot = ({ response, publicKey, }) => {
5
6
  if (publicKey.descriptor !== null && publicKey.descriptor !== undefined) {
6
7
  const [xpub, checksum] = publicKey.descriptor.split('#');
7
- const openingSquareBracketSplit = xpub.split('[');
8
- if (openingSquareBracketSplit.length === 2) {
9
- const [beforeOpeningBracket, afterOpeningBracket] = openingSquareBracketSplit;
10
- const closingSquareBracketSplit = afterOpeningBracket.split(']');
11
- if (closingSquareBracketSplit.length === 2) {
12
- const [path, afterClosingBracket] = closingSquareBracketSplit;
13
- const correctedPath = path.replace(/h/g, "'");
14
- return {
15
- xpub: `${beforeOpeningBracket}[${correctedPath}]${afterClosingBracket}`,
16
- checksum,
17
- };
18
- }
8
+ const correctedXpub = (0, utils_1.convertTaprootXpub)({ xpub, direction: 'h-to-apostrophe' });
9
+ if (correctedXpub !== null) {
10
+ return { xpub: correctedXpub, checksum };
19
11
  }
20
12
  }
21
13
  const fingerprint = Number(publicKey.root_fingerprint || 0)
@@ -1,4 +1,4 @@
1
- import type { ServerInfo, BlockEvent, FiatRatesBySymbol, NotificationEvent } from '@trezor/blockchain-link';
1
+ import type { BlockEvent, FiatRatesBySymbol, NotificationEvent, ServerInfo } from '@trezor/blockchain-link';
2
2
  import type { CoinInfo } from '../types/coinInfo';
3
3
  import type { MessageFactoryFn } from '../types/utils';
4
4
  export declare const BLOCKCHAIN_EVENT = "BLOCKCHAIN_EVENT";
@@ -1,7 +1,7 @@
1
1
  import type { IFRAME } from './iframe';
2
+ import { Device } from '../device/Device';
2
3
  import type { TrezorConnect } from '../types/api';
3
4
  import type { CommonParams, DeviceIdentity } from '../types/params';
4
- import { Device } from '../device/Device';
5
5
  type UnwrappedResponse<Response> = Response extends Promise<infer R> ? R extends {
6
6
  success: true;
7
7
  payload: infer P;