@trezor/connect 9.1.4 → 9.1.6

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 (184) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +1 -1
  3. package/lib/api/authenticateDevice.d.ts +7 -0
  4. package/lib/api/authenticateDevice.js +51 -0
  5. package/lib/api/{binanceGetAddress.d.ts → binance/api/binanceGetAddress.d.ts} +3 -3
  6. package/lib/api/{binanceGetAddress.js → binance/api/binanceGetAddress.js} +6 -6
  7. package/lib/api/{binanceGetPublicKey.d.ts → binance/api/binanceGetPublicKey.d.ts} +3 -3
  8. package/lib/api/{binanceGetPublicKey.js → binance/api/binanceGetPublicKey.js} +5 -5
  9. package/lib/api/{binanceSignTransaction.d.ts → binance/api/binanceSignTransaction.d.ts} +2 -2
  10. package/lib/api/{binanceSignTransaction.js → binance/api/binanceSignTransaction.js} +5 -5
  11. package/lib/api/binance/api/index.d.ts +4 -0
  12. package/lib/api/binance/api/index.js +13 -0
  13. package/lib/api/bitcoin/TransactionComposer.d.ts +4 -4
  14. package/lib/api/bitcoin/TransactionComposer.js +4 -18
  15. package/lib/api/bitcoin/inputs.d.ts +2 -2
  16. package/lib/api/bitcoin/inputs.js +4 -5
  17. package/lib/api/bitcoin/outputs.d.ts +4 -4
  18. package/lib/api/bitcoin/outputs.js +14 -23
  19. package/lib/api/blockchainEstimateFee.d.ts +2 -2
  20. package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +8 -0
  21. package/lib/api/cardano/api/cardanoComposeTransaction.js +69 -0
  22. package/lib/api/{cardanoGetAddress.d.ts → cardano/api/cardanoGetAddress.d.ts} +3 -3
  23. package/lib/api/{cardanoGetAddress.js → cardano/api/cardanoGetAddress.js} +7 -7
  24. package/lib/api/{cardanoGetNativeScriptHash.d.ts → cardano/api/cardanoGetNativeScriptHash.d.ts} +3 -3
  25. package/lib/api/{cardanoGetNativeScriptHash.js → cardano/api/cardanoGetNativeScriptHash.js} +5 -5
  26. package/lib/api/{cardanoGetPublicKey.d.ts → cardano/api/cardanoGetPublicKey.d.ts} +3 -3
  27. package/lib/api/{cardanoGetPublicKey.js → cardano/api/cardanoGetPublicKey.js} +6 -6
  28. package/lib/api/{cardanoSignTransaction.d.ts → cardano/api/cardanoSignTransaction.d.ts} +18 -8
  29. package/lib/api/{cardanoSignTransaction.js → cardano/api/cardanoSignTransaction.js} +30 -13
  30. package/lib/api/cardano/api/index.d.ts +6 -0
  31. package/lib/api/cardano/api/index.js +17 -0
  32. package/lib/api/cardano/cardanoUtils.d.ts +6 -0
  33. package/lib/api/cardano/cardanoUtils.js +64 -1
  34. package/lib/api/checkFirmwareAuthenticity.js +7 -5
  35. package/lib/api/common/paramsValidator.js +45 -51
  36. package/lib/api/composeTransaction.d.ts +5 -5
  37. package/lib/api/composeTransaction.js +14 -19
  38. package/lib/api/eos/api/eosGetPublicKey.d.ts +11 -0
  39. package/lib/api/{eosGetPublicKey.js → eos/api/eosGetPublicKey.js} +5 -5
  40. package/lib/api/{eosSignTransaction.d.ts → eos/api/eosSignTransaction.d.ts} +2 -2
  41. package/lib/api/{eosSignTransaction.js → eos/api/eosSignTransaction.js} +5 -5
  42. package/lib/api/eos/api/index.d.ts +3 -0
  43. package/lib/api/eos/api/index.js +11 -0
  44. package/lib/api/{ethereumGetAddress.d.ts → ethereum/api/ethereumGetAddress.d.ts} +4 -4
  45. package/lib/api/{ethereumGetAddress.js → ethereum/api/ethereumGetAddress.js} +9 -9
  46. package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +16 -0
  47. package/lib/api/{ethereumGetPublicKey.js → ethereum/api/ethereumGetPublicKey.js} +6 -6
  48. package/lib/api/{ethereumSignMessage.d.ts → ethereum/api/ethereumSignMessage.d.ts} +3 -3
  49. package/lib/api/{ethereumSignMessage.js → ethereum/api/ethereumSignMessage.js} +7 -7
  50. package/lib/api/{ethereumSignTransaction.d.ts → ethereum/api/ethereumSignTransaction.d.ts} +11 -9
  51. package/lib/api/{ethereumSignTransaction.js → ethereum/api/ethereumSignTransaction.js} +36 -43
  52. package/lib/api/{ethereumSignTypedData.d.ts → ethereum/api/ethereumSignTypedData.d.ts} +3 -3
  53. package/lib/api/{ethereumSignTypedData.js → ethereum/api/ethereumSignTypedData.js} +10 -10
  54. package/lib/api/{ethereumVerifyMessage.d.ts → ethereum/api/ethereumVerifyMessage.d.ts} +2 -2
  55. package/lib/api/{ethereumVerifyMessage.js → ethereum/api/ethereumVerifyMessage.js} +3 -3
  56. package/lib/api/ethereum/api/index.d.ts +7 -0
  57. package/lib/api/ethereum/api/index.js +19 -0
  58. package/lib/api/ethereum/ethereumDefinitions.js +3 -2
  59. package/lib/api/ethereum/ethereumSignTx.d.ts +2 -0
  60. package/lib/api/ethereum/ethereumSignTx.js +15 -1
  61. package/lib/api/firmware/getBinary.js +1 -1
  62. package/lib/api/firmware/verifyAuthenticityProof.d.ts +14 -0
  63. package/lib/api/firmware/verifyAuthenticityProof.js +103 -0
  64. package/lib/api/firmware/x509certificate.d.ts +74 -0
  65. package/lib/api/firmware/x509certificate.js +235 -0
  66. package/lib/api/firmwareUpdate.js +2 -1
  67. package/lib/api/getAccountDescriptor.d.ts +20 -0
  68. package/lib/api/getAccountDescriptor.js +162 -0
  69. package/lib/api/getAccountInfo.d.ts +2 -0
  70. package/lib/api/getAccountInfo.js +1 -5
  71. package/lib/api/getFirmwareHash.js +1 -4
  72. package/lib/api/index.d.ts +2 -24
  73. package/lib/api/index.js +5 -50
  74. package/lib/api/nem/api/index.d.ts +3 -0
  75. package/lib/api/nem/api/index.js +11 -0
  76. package/lib/api/{nemGetAddress.d.ts → nem/api/nemGetAddress.d.ts} +3 -3
  77. package/lib/api/{nemGetAddress.js → nem/api/nemGetAddress.js} +6 -6
  78. package/lib/api/{nemSignTransaction.d.ts → nem/api/nemSignTransaction.d.ts} +2 -2
  79. package/lib/api/{nemSignTransaction.js → nem/api/nemSignTransaction.js} +5 -5
  80. package/lib/api/rebootToBootloader.js +1 -4
  81. package/lib/api/ripple/api/index.d.ts +3 -0
  82. package/lib/api/ripple/api/index.js +11 -0
  83. package/lib/api/{rippleGetAddress.d.ts → ripple/api/rippleGetAddress.d.ts} +3 -3
  84. package/lib/api/{rippleGetAddress.js → ripple/api/rippleGetAddress.js} +6 -6
  85. package/lib/api/{rippleSignTransaction.d.ts → ripple/api/rippleSignTransaction.d.ts} +2 -2
  86. package/lib/api/{rippleSignTransaction.js → ripple/api/rippleSignTransaction.js} +4 -4
  87. package/lib/api/solana/api/index.d.ts +4 -0
  88. package/lib/api/solana/api/index.js +13 -0
  89. package/lib/api/solana/api/solanaGetAddress.d.ts +23 -0
  90. package/lib/api/solana/api/solanaGetAddress.js +131 -0
  91. package/lib/api/solana/api/solanaGetPublicKey.d.ts +12 -0
  92. package/lib/api/solana/api/solanaGetPublicKey.js +84 -0
  93. package/lib/api/solana/api/solanaSignTransaction.d.ts +10 -0
  94. package/lib/api/solana/api/solanaSignTransaction.js +33 -0
  95. package/lib/api/stellar/api/index.d.ts +3 -0
  96. package/lib/api/stellar/api/index.js +11 -0
  97. package/lib/api/{stellarGetAddress.d.ts → stellar/api/stellarGetAddress.d.ts} +3 -3
  98. package/lib/api/{stellarGetAddress.js → stellar/api/stellarGetAddress.js} +6 -6
  99. package/lib/api/{stellarSignTransaction.d.ts → stellar/api/stellarSignTransaction.d.ts} +2 -2
  100. package/lib/api/{stellarSignTransaction.js → stellar/api/stellarSignTransaction.js} +6 -6
  101. package/lib/api/tezos/api/index.d.ts +4 -0
  102. package/lib/api/tezos/api/index.js +13 -0
  103. package/lib/api/{tezosGetAddress.d.ts → tezos/api/tezosGetAddress.d.ts} +3 -3
  104. package/lib/api/{tezosGetAddress.js → tezos/api/tezosGetAddress.js} +6 -6
  105. package/lib/api/{tezosGetPublicKey.d.ts → tezos/api/tezosGetPublicKey.d.ts} +3 -3
  106. package/lib/api/{tezosGetPublicKey.js → tezos/api/tezosGetPublicKey.js} +5 -5
  107. package/lib/api/{tezosSignTransaction.d.ts → tezos/api/tezosSignTransaction.d.ts} +2 -2
  108. package/lib/api/{tezosSignTransaction.js → tezos/api/tezosSignTransaction.js} +5 -5
  109. package/lib/backend/Blockchain.js +2 -0
  110. package/lib/constants/cardano.js +2 -2
  111. package/lib/constants/nem.js +3 -3
  112. package/lib/constants/network.d.ts +3 -0
  113. package/lib/constants/network.js +13 -1
  114. package/lib/core/AbstractMethod.d.ts +1 -0
  115. package/lib/core/AbstractMethod.js +11 -10
  116. package/lib/core/index.d.ts +5 -2
  117. package/lib/core/index.js +28 -7
  118. package/lib/core/method.d.ts +2 -2
  119. package/lib/core/method.js +8 -2
  120. package/lib/core/method.native.d.ts +5 -0
  121. package/lib/core/method.native.js +34 -0
  122. package/lib/data/DataManager.d.ts +64 -7
  123. package/lib/data/DataManager.js +4 -2
  124. package/lib/data/config.d.ts +63 -6
  125. package/lib/data/config.js +39 -23
  126. package/lib/data/connectSettings.js +7 -0
  127. package/lib/data/defaultFeeLevels.js +8 -0
  128. package/lib/data/deviceAuthenticityConfig.d.ts +15 -0
  129. package/lib/data/deviceAuthenticityConfig.js +26 -0
  130. package/lib/data/firmwareInfo.d.ts +3 -2
  131. package/lib/data/firmwareInfo.js +17 -8
  132. package/lib/data/models.d.ts +4 -1
  133. package/lib/data/models.js +6 -3
  134. package/lib/data/version.d.ts +1 -1
  135. package/lib/data/version.js +1 -1
  136. package/lib/device/Device.d.ts +2 -2
  137. package/lib/device/Device.js +22 -13
  138. package/lib/device/DeviceCommands.js +9 -0
  139. package/lib/device/DeviceList.d.ts +1 -0
  140. package/lib/device/DeviceList.js +8 -4
  141. package/lib/events/iframe.d.ts +7 -1
  142. package/lib/events/iframe.js +1 -0
  143. package/lib/events/popup.d.ts +19 -3
  144. package/lib/events/popup.js +3 -0
  145. package/lib/factory.js +6 -0
  146. package/lib/types/api/authenticateDevice.d.ts +21 -0
  147. package/lib/types/api/authenticateDevice.js +3 -0
  148. package/lib/types/api/cardanoComposeTransaction.d.ts +44 -0
  149. package/lib/types/api/cardanoComposeTransaction.js +3 -0
  150. package/lib/types/api/cardanoSignTransaction.d.ts +9 -0
  151. package/lib/types/api/composeTransaction.d.ts +28 -54
  152. package/lib/types/api/ethereum/index.d.ts +1 -0
  153. package/lib/types/api/getAccountDescriptor.d.ts +16 -0
  154. package/lib/types/api/getAccountDescriptor.js +3 -0
  155. package/lib/types/api/index.d.ts +12 -0
  156. package/lib/types/api/solana/index.d.ts +12 -0
  157. package/lib/types/api/solana/index.js +3 -0
  158. package/lib/types/api/solanaGetAddress.d.ts +4 -0
  159. package/lib/types/api/solanaGetAddress.js +3 -0
  160. package/lib/types/api/solanaGetPublicKey.d.ts +5 -0
  161. package/lib/types/api/solanaGetPublicKey.js +3 -0
  162. package/lib/types/api/solanaSignTransaction.d.ts +4 -0
  163. package/lib/types/api/solanaSignTransaction.js +3 -0
  164. package/lib/types/coinInfo.d.ts +5 -15
  165. package/lib/types/device.js +1 -1
  166. package/lib/types/firmware.d.ts +6 -2
  167. package/lib/types/index.d.ts +4 -1
  168. package/lib/types/index.js +1 -0
  169. package/lib/types/settings.d.ts +1 -0
  170. package/lib/utils/assetUtils.js +6 -4
  171. package/lib/utils/debug.d.ts +10 -5
  172. package/lib/utils/debug.js +55 -17
  173. package/lib/utils/deviceFeaturesUtils.js +5 -3
  174. package/lib/utils/formatUtils.d.ts +2 -0
  175. package/lib/utils/formatUtils.js +19 -1
  176. package/lib/workers/workers-browser.d.ts +2 -1
  177. package/lib/workers/workers-browser.js +3 -1
  178. package/lib/workers/workers-react-native.d.ts +2 -1
  179. package/lib/workers/workers-react-native.js +3 -1
  180. package/lib/workers/workers.d.ts +8 -5
  181. package/lib/workers/workers.js +34 -10
  182. package/package.json +25 -18
  183. package/lib/api/eosGetPublicKey.d.ts +0 -11
  184. package/lib/api/ethereumGetPublicKey.d.ts +0 -16
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const AbstractMethod_1 = require("../core/AbstractMethod");
4
- const paramsValidator_1 = require("./common/paramsValidator");
5
- const coinInfo_1 = require("../data/coinInfo");
6
- const pathUtils_1 = require("../utils/pathUtils");
7
- const constants_1 = require("../constants");
8
- const events_1 = require("../events");
3
+ const AbstractMethod_1 = require("../../../core/AbstractMethod");
4
+ const paramsValidator_1 = require("../../common/paramsValidator");
5
+ const coinInfo_1 = require("../../../data/coinInfo");
6
+ const pathUtils_1 = require("../../../utils/pathUtils");
7
+ const constants_1 = require("../../../constants");
8
+ const events_1 = require("../../../events");
9
9
  class TezosGetAddress extends AbstractMethod_1.AbstractMethod {
10
10
  constructor() {
11
11
  super(...arguments);
@@ -1,11 +1,11 @@
1
- import { AbstractMethod } from '../core/AbstractMethod';
2
- import type { PROTO } from '../constants';
1
+ import { AbstractMethod } from '../../../core/AbstractMethod';
2
+ import type { PROTO } from '../../../constants';
3
3
  export default class TezosGetPublicKey extends AbstractMethod<'tezosGetPublicKey', PROTO.TezosGetPublicKey[]> {
4
4
  hasBundle?: boolean;
5
5
  confirmed?: boolean;
6
6
  init(): void;
7
7
  get info(): string;
8
8
  confirmation(): Promise<boolean>;
9
- run(): Promise<import("..").PublicKey | import("..").PublicKey[]>;
9
+ run(): Promise<import("../../..").PublicKey | import("../../..").PublicKey[]>;
10
10
  }
11
11
  //# sourceMappingURL=tezosGetPublicKey.d.ts.map
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const AbstractMethod_1 = require("../core/AbstractMethod");
4
- const paramsValidator_1 = require("./common/paramsValidator");
5
- const coinInfo_1 = require("../data/coinInfo");
6
- const pathUtils_1 = require("../utils/pathUtils");
7
- const events_1 = require("../events");
3
+ const AbstractMethod_1 = require("../../../core/AbstractMethod");
4
+ const paramsValidator_1 = require("../../common/paramsValidator");
5
+ const coinInfo_1 = require("../../../data/coinInfo");
6
+ const pathUtils_1 = require("../../../utils/pathUtils");
7
+ const events_1 = require("../../../events");
8
8
  class TezosGetPublicKey extends AbstractMethod_1.AbstractMethod {
9
9
  init() {
10
10
  this.requiredPermissions = ['read'];
@@ -1,5 +1,5 @@
1
- import { AbstractMethod } from '../core/AbstractMethod';
2
- import type { PROTO } from '../constants';
1
+ import { AbstractMethod } from '../../../core/AbstractMethod';
2
+ import type { PROTO } from '../../../constants';
3
3
  export default class TezosSignTransaction extends AbstractMethod<'tezosSignTransaction', PROTO.TezosSignTx> {
4
4
  init(): void;
5
5
  get info(): string;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const AbstractMethod_1 = require("../core/AbstractMethod");
5
- const paramsValidator_1 = require("./common/paramsValidator");
6
- const coinInfo_1 = require("../data/coinInfo");
7
- const pathUtils_1 = require("../utils/pathUtils");
8
- const helper = tslib_1.__importStar(require("./tezos/tezosSignTx"));
4
+ const AbstractMethod_1 = require("../../../core/AbstractMethod");
5
+ const paramsValidator_1 = require("../../common/paramsValidator");
6
+ const coinInfo_1 = require("../../../data/coinInfo");
7
+ const pathUtils_1 = require("../../../utils/pathUtils");
8
+ const helper = tslib_1.__importStar(require("../tezosSignTx"));
9
9
  class TezosSignTransaction extends AbstractMethod_1.AbstractMethod {
10
10
  init() {
11
11
  this.requiredPermissions = ['read', 'write'];
@@ -16,6 +16,8 @@ const getWorker = (type) => {
16
16
  return workers_1.BlockfrostWorker;
17
17
  case 'electrum':
18
18
  return workers_1.ElectrumWorker;
19
+ case 'solana':
20
+ return workers_1.SolanaWorker;
19
21
  default:
20
22
  return null;
21
23
  }
@@ -7,10 +7,10 @@ var PROTOCOL_MAGICS;
7
7
  PROTOCOL_MAGICS[PROTOCOL_MAGICS["testnet_preprod"] = 1] = "testnet_preprod";
8
8
  PROTOCOL_MAGICS[PROTOCOL_MAGICS["testnet_preview"] = 2] = "testnet_preview";
9
9
  PROTOCOL_MAGICS[PROTOCOL_MAGICS["testnet_legacy"] = 1097911063] = "testnet_legacy";
10
- })(PROTOCOL_MAGICS = exports.PROTOCOL_MAGICS || (exports.PROTOCOL_MAGICS = {}));
10
+ })(PROTOCOL_MAGICS || (exports.PROTOCOL_MAGICS = PROTOCOL_MAGICS = {}));
11
11
  var NETWORK_IDS;
12
12
  (function (NETWORK_IDS) {
13
13
  NETWORK_IDS[NETWORK_IDS["mainnet"] = 1] = "mainnet";
14
14
  NETWORK_IDS[NETWORK_IDS["testnet"] = 0] = "testnet";
15
- })(NETWORK_IDS = exports.NETWORK_IDS || (exports.NETWORK_IDS = {}));
15
+ })(NETWORK_IDS || (exports.NETWORK_IDS = NETWORK_IDS = {}));
16
16
  //# sourceMappingURL=cardano.js.map
@@ -6,7 +6,7 @@ var Networks;
6
6
  Networks[Networks["mainnet"] = 104] = "mainnet";
7
7
  Networks[Networks["testnet"] = 152] = "testnet";
8
8
  Networks[Networks["mijin"] = 96] = "mijin";
9
- })(Networks = exports.Networks || (exports.Networks = {}));
9
+ })(Networks || (exports.Networks = Networks = {}));
10
10
  var TxType;
11
11
  (function (TxType) {
12
12
  TxType[TxType["TRANSFER"] = 257] = "TRANSFER";
@@ -18,11 +18,11 @@ var TxType;
18
18
  TxType[TxType["PROVISION_NAMESPACE"] = 8193] = "PROVISION_NAMESPACE";
19
19
  TxType[TxType["MOSAIC_CREATION"] = 16385] = "MOSAIC_CREATION";
20
20
  TxType[TxType["SUPPLY_CHANGE"] = 16386] = "SUPPLY_CHANGE";
21
- })(TxType = exports.TxType || (exports.TxType = {}));
21
+ })(TxType || (exports.TxType = TxType = {}));
22
22
  var TxVersion;
23
23
  (function (TxVersion) {
24
24
  TxVersion[TxVersion["mainnet"] = 1744830464] = "mainnet";
25
25
  TxVersion[TxVersion["testnet"] = -1744830464] = "testnet";
26
26
  TxVersion[TxVersion["mijin"] = 1610612736] = "mijin";
27
- })(TxVersion = exports.TxVersion || (exports.TxVersion = {}));
27
+ })(TxVersion || (exports.TxVersion = TxVersion = {}));
28
28
  //# sourceMappingURL=nem.js.map
@@ -8,6 +8,9 @@ export declare const TYPES: {
8
8
  readonly ripple: "Ripple";
9
9
  readonly tezos: "Tezos";
10
10
  readonly binance: "Binance";
11
+ readonly solana: "Solana";
11
12
  };
12
13
  export type NetworkType = keyof typeof TYPES;
14
+ export declare const MODULES: readonly ["binance", "cardano", "eos", "ethereum", "nem", "ripple", "solana", "stellar", "tezos"];
15
+ export type ModuleName = (typeof MODULES)[number];
13
16
  //# sourceMappingURL=network.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TYPES = void 0;
3
+ exports.MODULES = exports.TYPES = void 0;
4
4
  exports.TYPES = {
5
5
  bitcoin: 'Bitcoin',
6
6
  ethereum: 'Ethereum',
@@ -11,5 +11,17 @@ exports.TYPES = {
11
11
  ripple: 'Ripple',
12
12
  tezos: 'Tezos',
13
13
  binance: 'Binance',
14
+ solana: 'Solana',
14
15
  };
16
+ exports.MODULES = [
17
+ 'binance',
18
+ 'cardano',
19
+ 'eos',
20
+ 'ethereum',
21
+ 'nem',
22
+ 'ripple',
23
+ 'solana',
24
+ 'stellar',
25
+ 'tezos',
26
+ ];
15
27
  //# sourceMappingURL=network.js.map
@@ -9,6 +9,7 @@ export type Payload<M> = Extract<CallMethodPayload, {
9
9
  override?: boolean;
10
10
  };
11
11
  export type MethodReturnType<M extends CallMethodPayload['method']> = CallMethodResponse<M>;
12
+ export declare const DEFAULT_FIRMWARE_RANGE: FirmwareRange;
12
13
  export declare abstract class AbstractMethod<Name extends CallMethodPayload['method'], Params = undefined> {
13
14
  responseID: number;
14
15
  device: Device;
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractMethod = void 0;
3
+ exports.AbstractMethod = exports.DEFAULT_FIRMWARE_RANGE = void 0;
4
4
  const connect_common_1 = require("@trezor/connect-common");
5
5
  const utils_1 = require("@trezor/utils");
6
6
  const DataManager_1 = require("../data/DataManager");
7
7
  const constants_1 = require("../constants");
8
8
  const events_1 = require("../events");
9
9
  const urlUtils_1 = require("../utils/urlUtils");
10
+ exports.DEFAULT_FIRMWARE_RANGE = {
11
+ T1B1: { min: '1.0.0', max: '0' },
12
+ T2T1: { min: '2.0.0', max: '0' },
13
+ T2B1: { min: '2.6.1', max: '0' },
14
+ };
10
15
  class AbstractMethod {
11
16
  get info() {
12
17
  return '';
@@ -44,10 +49,7 @@ class AbstractMethod {
44
49
  this.network = key;
45
50
  }
46
51
  });
47
- this.firmwareRange = {
48
- '1': { min: '1.0.0', max: '0' },
49
- '2': { min: '2.0.0', max: '0' },
50
- };
52
+ this.firmwareRange = exports.DEFAULT_FIRMWARE_RANGE;
51
53
  this.requiredPermissions = [];
52
54
  this.useDevice = true;
53
55
  this.useDeviceState = true;
@@ -130,20 +132,19 @@ class AbstractMethod {
130
132
  const { device } = this;
131
133
  if (!device.features)
132
134
  return;
133
- const version = device.getVersion();
134
- const model = version[0];
135
- const range = this.firmwareRange[model];
135
+ const range = this.firmwareRange[device.features.internal_model];
136
136
  if (device.firmwareStatus === 'none') {
137
137
  return events_1.UI.FIRMWARE_NOT_INSTALLED;
138
138
  }
139
139
  if (range.min === '0') {
140
140
  return events_1.UI.FIRMWARE_NOT_SUPPORTED;
141
141
  }
142
+ const version = device.getVersion().join('.');
142
143
  if (device.firmwareStatus === 'required' ||
143
- !utils_1.versionUtils.isNewerOrEqual(version.join('.'), range.min)) {
144
+ !utils_1.versionUtils.isNewerOrEqual(version, range.min)) {
144
145
  return events_1.UI.FIRMWARE_OLD;
145
146
  }
146
- if (range.max !== '0' && utils_1.versionUtils.isNewer(version.join('.'), range.max)) {
147
+ if (range.max !== '0' && utils_1.versionUtils.isNewer(version, range.max)) {
147
148
  if (isUsingPopup) {
148
149
  await this.getPopupPromise().promise;
149
150
  const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
@@ -1,15 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  import EventEmitter from 'events';
3
3
  import { TransportInfo, CoreMessage } from '../events';
4
+ import { AbstractMethod } from './AbstractMethod';
5
+ import { LogWriter } from '../utils/debug';
4
6
  import type { ConnectSettings } from '../types';
5
7
  export declare const handleMessage: (message: CoreMessage) => void;
6
8
  export declare const onCall: (message: CoreMessage) => Promise<void>;
7
9
  export declare class Core extends EventEmitter {
8
10
  handleMessage(message: any): void;
9
11
  dispose(): Promise<void>;
10
- getCurrentMethod(): (import("../api").applyFlags | import("../api").applySettings | import("../api").authorizeCoinjoin | import("../api").cancelCoinjoinAuthorization | import("../api").showDeviceTutorial | import("../api").backupDevice | import("../api").binanceGetAddress | import("../api").binanceGetPublicKey | import("../api").binanceSignTransaction | import("../api").blockchainDisconnect | import("../api").blockchainEstimateFee | import("../api").blockchainGetAccountBalanceHistory | import("../api").blockchainGetCurrentFiatRates | import("../api").blockchainGetFiatRatesForTimestamps | import("../api").blockchainGetTransactions | import("../api").blockchainSetCustomBackend | import("../api").blockchainSubscribe | import("../api").blockchainSubscribeFiatRates | import("../api").blockchainUnsubscribe | import("../api").blockchainUnsubscribeFiatRates | import("../api").cardanoGetAddress | import("../api").cardanoGetNativeScriptHash | import("../api").cardanoGetPublicKey | import("../api").cardanoSignTransaction | import("../api").changePin | import("../api").cipherKeyValue | import("../api").composeTransaction | import("../api").eosGetPublicKey | import("../api").eosSignTransaction | import("../api").ethereumGetAddress | import("../api").ethereumGetPublicKey | import("../api").ethereumSignMessage | import("../api").ethereumSignTransaction | import("../api").ethereumSignTypedData | import("../api").ethereumVerifyMessage | import("../api").firmwareUpdate | import("../api").getAccountInfo | import("../api").getAddress | import("../api").getCoinInfo | import("../api").getDeviceState | import("../api").getFeatures | import("../api").getFirmwareHash | import("../api").getOwnershipId | import("../api").getOwnershipProof | import("../api").getPublicKey | import("../api").getSettings | import("../api").nemGetAddress | import("../api").nemSignTransaction | import("../api").pushTransaction | import("../api").rebootToBootloader | import("../api").recoveryDevice | import("../api").requestLogin | import("../api").resetDevice | import("../api").rippleGetAddress | import("../api").rippleSignTransaction | import("../api").setBusy | import("../api").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").unlockPath | import("../api").verifyMessage | import("../api").wipeDevice | import("../api").checkFirmwareAuthenticity)[];
12
+ getCurrentMethod(): Promise<AbstractMethod<any, undefined>>;
11
13
  getTransportInfo(): TransportInfo | undefined;
14
+ enumerate(): void;
12
15
  }
13
- export declare const initCore: (settings: ConnectSettings) => Promise<Core>;
16
+ export declare const initCore: (settings: ConnectSettings, logWriterFactory?: () => LogWriter | undefined) => Promise<Core>;
14
17
  export declare const initTransport: (settings: ConnectSettings) => Promise<void>;
15
18
  //# sourceMappingURL=index.d.ts.map
package/lib/core/index.js CHANGED
@@ -19,11 +19,12 @@ let _core;
19
19
  let _deviceList;
20
20
  let _popupPromise;
21
21
  const _uiPromises = [];
22
- const _callMethods = [];
23
22
  let _preferredDevice;
23
+ const _callMethods = [];
24
24
  let _interactionTimeout;
25
25
  let _deviceListInitTimeout;
26
26
  let _overridePromise;
27
+ let _getMethodPromise;
27
28
  const _log = (0, debug_1.initLog)('Core');
28
29
  const postMessage = (message) => {
29
30
  if (message.event === events_2.RESPONSE_EVENT) {
@@ -103,6 +104,7 @@ const initDevice = async (method) => {
103
104
  if (!_deviceList) {
104
105
  throw constants_1.ERRORS.TypedError('Transport_Missing');
105
106
  }
107
+ await _deviceList.transportFirstEventPromise;
106
108
  const isWebUsb = _deviceList.transportType() === 'WebUsbTransport';
107
109
  let device;
108
110
  let showDeviceSelection = isWebUsb;
@@ -164,7 +166,10 @@ const onCall = async (message) => {
164
166
  let method;
165
167
  let messageResponse;
166
168
  try {
167
- method = (0, method_1.getMethod)(message);
169
+ _log.debug('loading method...');
170
+ _getMethodPromise = (0, method_1.getMethod)(message);
171
+ method = await _getMethodPromise;
172
+ _log.debug('method selected', method.name);
168
173
  method.postMessage = postMessage;
169
174
  method.getPopupPromise = getPopupPromise;
170
175
  method.createUiPromise = createUiPromise;
@@ -339,7 +344,7 @@ const onCall = async (message) => {
339
344
  }
340
345
  }
341
346
  catch (error) {
342
- if (error.message === 'PIN invalid' && PIN_TRIES < MAX_PIN_TRIES) {
347
+ if (error.message.includes('PIN invalid') && PIN_TRIES < MAX_PIN_TRIES) {
343
348
  PIN_TRIES++;
344
349
  postMessage((0, events_2.createUiMessage)(events_2.UI.INVALID_PIN, { device: device.toMessageObject() }));
345
350
  return inner();
@@ -393,7 +398,11 @@ const onCall = async (message) => {
393
398
  if (response) {
394
399
  if (method.name === 'rebootToBootloader' && response.success) {
395
400
  await (0, promiseUtils_1.resolveAfter)(1000).promise;
396
- await device.run(() => Promise.resolve(), { skipFinalReload: true });
401
+ try {
402
+ await device.run(() => Promise.resolve(), { skipFinalReload: true });
403
+ }
404
+ catch (err) {
405
+ }
397
406
  }
398
407
  await device.cleanup();
399
408
  closePopup();
@@ -617,8 +626,11 @@ class Core extends events_1.default {
617
626
  await _deviceList.dispose();
618
627
  }
619
628
  }
620
- getCurrentMethod() {
621
- return _callMethods;
629
+ async getCurrentMethod() {
630
+ if (_getMethodPromise) {
631
+ await _getMethodPromise;
632
+ }
633
+ return _callMethods[0];
622
634
  }
623
635
  getTransportInfo() {
624
636
  if (!_deviceList) {
@@ -626,9 +638,18 @@ class Core extends events_1.default {
626
638
  }
627
639
  return _deviceList.getTransportInfo();
628
640
  }
641
+ enumerate() {
642
+ if (!_deviceList) {
643
+ return;
644
+ }
645
+ _deviceList.enumerate();
646
+ }
629
647
  }
630
648
  exports.Core = Core;
631
- const initCore = async (settings) => {
649
+ const initCore = async (settings, logWriterFactory) => {
650
+ if (logWriterFactory) {
651
+ (0, debug_1.setLogWriter)(logWriterFactory);
652
+ }
632
653
  try {
633
654
  await DataManager_1.DataManager.load(settings);
634
655
  (0, debug_1.enableLog)(DataManager_1.DataManager.getSettings('debug'));
@@ -1,6 +1,6 @@
1
- import * as Methods from '../api';
2
1
  import type { IFrameCallMessage } from '../events';
2
+ import type { AbstractMethod } from './AbstractMethod';
3
3
  export declare const getMethod: (message: IFrameCallMessage & {
4
4
  id?: number;
5
- }) => Methods.applyFlags | Methods.applySettings | Methods.authorizeCoinjoin | Methods.cancelCoinjoinAuthorization | Methods.showDeviceTutorial | Methods.backupDevice | Methods.binanceGetAddress | Methods.binanceGetPublicKey | Methods.binanceSignTransaction | Methods.blockchainDisconnect | Methods.blockchainEstimateFee | Methods.blockchainGetAccountBalanceHistory | Methods.blockchainGetCurrentFiatRates | Methods.blockchainGetFiatRatesForTimestamps | Methods.blockchainGetTransactions | Methods.blockchainSetCustomBackend | Methods.blockchainSubscribe | Methods.blockchainSubscribeFiatRates | Methods.blockchainUnsubscribe | Methods.blockchainUnsubscribeFiatRates | Methods.cardanoGetAddress | Methods.cardanoGetNativeScriptHash | Methods.cardanoGetPublicKey | Methods.cardanoSignTransaction | Methods.changePin | Methods.cipherKeyValue | Methods.composeTransaction | Methods.eosGetPublicKey | Methods.eosSignTransaction | Methods.ethereumGetAddress | Methods.ethereumGetPublicKey | Methods.ethereumSignMessage | Methods.ethereumSignTransaction | Methods.ethereumSignTypedData | Methods.ethereumVerifyMessage | Methods.firmwareUpdate | Methods.getAccountInfo | Methods.getAddress | Methods.getCoinInfo | Methods.getDeviceState | Methods.getFeatures | Methods.getFirmwareHash | Methods.getOwnershipId | Methods.getOwnershipProof | Methods.getPublicKey | Methods.getSettings | Methods.nemGetAddress | Methods.nemSignTransaction | Methods.pushTransaction | Methods.rebootToBootloader | Methods.recoveryDevice | Methods.requestLogin | Methods.resetDevice | Methods.rippleGetAddress | Methods.rippleSignTransaction | Methods.setBusy | Methods.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.unlockPath | Methods.verifyMessage | Methods.wipeDevice | Methods.checkFirmwareAuthenticity;
5
+ }) => Promise<AbstractMethod<any>>;
6
6
  //# sourceMappingURL=method.d.ts.map
@@ -4,12 +4,18 @@ exports.getMethod = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Methods = tslib_1.__importStar(require("../api"));
6
6
  const errors_1 = require("../constants/errors");
7
- const getMethod = (message) => {
7
+ const network_1 = require("../constants/network");
8
+ const getMethodModule = (method) => network_1.MODULES.find(module => method.startsWith(module));
9
+ const getMethod = async (message) => {
8
10
  const { method } = message.payload;
9
11
  if (typeof method !== 'string') {
10
12
  throw (0, errors_1.TypedError)('Method_InvalidParameter', 'Message method is not set');
11
13
  }
12
- const MethodConstructor = Methods[method];
14
+ const methodModule = getMethodModule(method);
15
+ const methods = methodModule
16
+ ? await Promise.resolve(`${`../api/${methodModule}/api`}`).then(s => tslib_1.__importStar(require(s)))
17
+ : Methods;
18
+ const MethodConstructor = methods[method];
13
19
  if (MethodConstructor) {
14
20
  return new MethodConstructor(message);
15
21
  }
@@ -0,0 +1,5 @@
1
+ import type { IFrameCallMessage } from '../events';
2
+ export declare const getMethod: (message: IFrameCallMessage & {
3
+ id?: number;
4
+ }) => Promise<any>;
5
+ //# sourceMappingURL=method.native.d.ts.map
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMethod = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Methods = tslib_1.__importStar(require("../api"));
6
+ const errors_1 = require("../constants/errors");
7
+ const network_1 = require("../constants/network");
8
+ const moduleMethods = {
9
+ binance: require('../api/binance/api'),
10
+ cardano: require('../api/cardano/api'),
11
+ eos: require('../api/eos/api'),
12
+ ethereum: require('../api/ethereum/api'),
13
+ nem: require('../api/nem/api'),
14
+ ripple: require('../api/ripple/api'),
15
+ solana: require('../api/solana/api'),
16
+ stellar: require('../api/stellar/api'),
17
+ tezos: require('../api/tezos/api'),
18
+ };
19
+ const getMethodModule = (method) => network_1.MODULES.find(module => method.startsWith(module));
20
+ const getMethod = async (message) => {
21
+ const { method } = message.payload;
22
+ if (typeof method !== 'string') {
23
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', 'Message method is not set');
24
+ }
25
+ const methodModule = getMethodModule(method);
26
+ const methods = methodModule ? moduleMethods[methodModule] : Methods;
27
+ const MethodConstructor = methods[method];
28
+ if (MethodConstructor) {
29
+ return new MethodConstructor(message);
30
+ }
31
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', `Method ${method} not found`);
32
+ };
33
+ exports.getMethod = getMethod;
34
+ //# sourceMappingURL=method.native.js.map
@@ -1,4 +1,4 @@
1
- import type { ConnectSettings } from '../types';
1
+ import { ConnectSettings } from '../types';
2
2
  type AssetCollection = {
3
3
  [key: string]: JSON;
4
4
  };
@@ -60,27 +60,43 @@ export declare class DataManager {
60
60
  supportedFirmware: ({
61
61
  coin: string[];
62
62
  methods: string[];
63
- min: string[];
63
+ min: {
64
+ T1B1: string;
65
+ T2T1: string;
66
+ T2B1?: undefined;
67
+ };
64
68
  max: undefined;
65
69
  comment: string[];
66
70
  capabilities?: undefined;
67
71
  } | {
68
72
  coin: string[];
69
- min: string[];
73
+ min: {
74
+ T1B1: string;
75
+ T2T1: string;
76
+ T2B1?: undefined;
77
+ };
70
78
  comment: string[];
71
79
  methods?: undefined;
72
80
  max?: undefined;
73
81
  capabilities?: undefined;
74
82
  } | {
75
83
  methods: string[];
76
- min: string[];
84
+ min: {
85
+ T1B1: string;
86
+ T2T1: string;
87
+ T2B1?: undefined;
88
+ };
77
89
  comment: string[];
78
90
  coin?: undefined;
79
91
  max?: undefined;
80
92
  capabilities?: undefined;
81
93
  } | {
82
94
  capabilities: string[];
83
- min: string[];
95
+ min: {
96
+ T1B1: string;
97
+ T2T1: string;
98
+ T2B1?: undefined;
99
+ };
84
100
  comment: string[];
85
101
  coin?: undefined;
86
102
  methods?: undefined;
@@ -88,17 +104,58 @@ export declare class DataManager {
88
104
  } | {
89
105
  coin: string[];
90
106
  methods: string[];
91
- min: string[];
107
+ min: {
108
+ T1B1: string;
109
+ T2T1: string;
110
+ T2B1?: undefined;
111
+ };
92
112
  comment: string[];
93
113
  max?: undefined;
94
114
  capabilities?: undefined;
95
115
  } | {
96
116
  capabilities: string[];
97
117
  methods: string[];
98
- min: string[];
118
+ min: {
119
+ T1B1: string;
120
+ T2T1: string;
121
+ T2B1?: undefined;
122
+ };
99
123
  coin?: undefined;
100
124
  max?: undefined;
101
125
  comment?: undefined;
126
+ } | {
127
+ methods: string[];
128
+ min: {
129
+ T1B1: string;
130
+ T2T1: string;
131
+ T2B1: string;
132
+ };
133
+ comment: string[];
134
+ coin?: undefined;
135
+ max?: undefined;
136
+ capabilities?: undefined;
137
+ } | {
138
+ methods: string[];
139
+ min: {
140
+ T1B1: string;
141
+ T2T1: string;
142
+ T2B1?: undefined;
143
+ };
144
+ coin?: undefined;
145
+ max?: undefined;
146
+ comment?: undefined;
147
+ capabilities?: undefined;
148
+ } | {
149
+ methods: string[];
150
+ min: {
151
+ T1B1: string;
152
+ T2T1: string;
153
+ T2B1: string;
154
+ };
155
+ coin?: undefined;
156
+ max?: undefined;
157
+ comment?: undefined;
158
+ capabilities?: undefined;
102
159
  })[];
103
160
  };
104
161
  }
@@ -6,6 +6,7 @@ const coinInfo_1 = require("./coinInfo");
6
6
  const firmwareInfo_1 = require("./firmwareInfo");
7
7
  const transportInfo_1 = require("./transportInfo");
8
8
  const config_1 = require("./config");
9
+ const types_1 = require("../types");
9
10
  class DataManager {
10
11
  static async load(settings, withAssets = true) {
11
12
  const ts = settings.env === 'web' ? `?r=${settings.timestamp}` : '';
@@ -23,8 +24,9 @@ class DataManager {
23
24
  ...this.assets.coins,
24
25
  eth: this.assets.coinsEth,
25
26
  });
26
- (0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t1'], 1);
27
- (0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t2'], 2);
27
+ (0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t1b1'], types_1.DeviceModelInternal.T1B1);
28
+ (0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t2t1'], types_1.DeviceModelInternal.T2T1);
29
+ (0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t2b1'], types_1.DeviceModelInternal.T2B1);
28
30
  }
29
31
  static getProtobufMessages() {
30
32
  return this.messages;