@onekeyfe/hd-web-sdk 0.1.41 → 0.1.44

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.
@@ -27041,21 +27041,13 @@ var HardwareError$1 = /*#__PURE__*/Object.freeze({
27041
27041
  CreateErrorByMessage: CreateErrorByMessage
27042
27042
  });
27043
27043
 
27044
- // EXTERNAL MODULE: ../../node_modules/axios/index.js
27045
- var axios = __webpack_require__(9644);
27046
- var axios_default = /*#__PURE__*/__webpack_require__.n(axios);
27047
- // EXTERNAL MODULE: ../../node_modules/bignumber.js/bignumber.js
27048
- var bignumber = __webpack_require__(6391);
27049
- var bignumber_default = /*#__PURE__*/__webpack_require__.n(bignumber);
27050
- // EXTERNAL MODULE: ../../node_modules/js-sha256/src/sha256.js
27051
- var sha256 = __webpack_require__(1965);
27052
- var sha256_default = /*#__PURE__*/__webpack_require__.n(sha256);
27053
27044
  // EXTERNAL MODULE: ../../node_modules/protobufjs/light.js
27054
27045
  var light = __webpack_require__(3448);
27055
27046
  // EXTERNAL MODULE: ../../node_modules/long/src/long.js
27056
27047
  var src_long = __webpack_require__(7808);
27057
27048
  // EXTERNAL MODULE: ../../node_modules/bytebuffer/dist/bytebuffer.js
27058
- var bytebuffer = __webpack_require__(9396);
27049
+ var dist_bytebuffer = __webpack_require__(9396);
27050
+ var bytebuffer_default = /*#__PURE__*/__webpack_require__.n(dist_bytebuffer);
27059
27051
  // EXTERNAL MODULE: ../../node_modules/buffer/index.js
27060
27052
  var buffer = __webpack_require__(8834);
27061
27053
  ;// CONCATENATED MODULE: ../hd-transport/dist/index.js
@@ -27089,11 +27081,6 @@ function __rest(s, e) {
27089
27081
  return t;
27090
27082
  }
27091
27083
 
27092
- function getDefaultExportFromNamespaceIfPresent(n) {
27093
- return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n.default : n;
27094
- }
27095
-
27096
- const ByteBuffer = getDefaultExportFromNamespaceIfPresent(bytebuffer);
27097
27084
  const primitiveTypes = ['bool', 'string', 'bytes', 'int32', 'int64', 'uint32', 'uint64', 'sint32', 'sint64', 'fixed32', 'fixed64', 'sfixed32', 'sfixed64', 'double', 'float'];
27098
27085
 
27099
27086
  const isPrimitiveField = field => primitiveTypes.includes(field);
@@ -27104,7 +27091,7 @@ const transform$1 = (field, value) => {
27104
27091
  }
27105
27092
 
27106
27093
  if (field.type === 'bytes') {
27107
- return ByteBuffer.wrap(value).toString('hex');
27094
+ return bytebuffer_default().wrap(value).toString('hex');
27108
27095
  }
27109
27096
 
27110
27097
  if (field.long) {
@@ -27214,7 +27201,7 @@ const encode$1 = (Message, data) => {
27214
27201
  const payload = patch(Message, data);
27215
27202
  const message = Message.fromObject(payload);
27216
27203
  const buffer = Message.encode(message).finish();
27217
- const bytebuffer = new ByteBuffer(buffer.byteLength);
27204
+ const bytebuffer = new (bytebuffer_default())(buffer.byteLength);
27218
27205
  bytebuffer.append(buffer);
27219
27206
  bytebuffer.reset();
27220
27207
  return bytebuffer;
@@ -27292,7 +27279,7 @@ const decode = byteBuffer => {
27292
27279
  };
27293
27280
 
27294
27281
  const decodeChunked = bytes => {
27295
- const byteBuffer = ByteBuffer.wrap(bytes, undefined, undefined, true);
27282
+ const byteBuffer = bytebuffer_default().wrap(bytes, undefined, undefined, true);
27296
27283
  const {
27297
27284
  sharp1,
27298
27285
  sharp2,
@@ -27324,7 +27311,7 @@ function encode(data, options) {
27324
27311
  messageType
27325
27312
  } = options;
27326
27313
  const fullSize = (addTrezorHeaders ? HEADER_SIZE : HEADER_SIZE - 2) + data.limit;
27327
- const encodedByteBuffer = new ByteBuffer(fullSize);
27314
+ const encodedByteBuffer = new (bytebuffer_default())(fullSize);
27328
27315
 
27329
27316
  if (addTrezorHeaders) {
27330
27317
  encodedByteBuffer.writeByte(MESSAGE_HEADER_BYTE);
@@ -27386,7 +27373,7 @@ const buildBuffers = (messages, name, data) => {
27386
27373
  const outBuffers = [];
27387
27374
 
27388
27375
  for (const buf of encodeBuffers) {
27389
- const chunkBuffer = new ByteBuffer(BUFFER_SIZE + 1);
27376
+ const chunkBuffer = new (bytebuffer_default())(BUFFER_SIZE + 1);
27390
27377
  chunkBuffer.writeByte(MESSAGE_TOP_CHAR);
27391
27378
  chunkBuffer.append(buf);
27392
27379
  chunkBuffer.reset();
@@ -27397,7 +27384,7 @@ const buildBuffers = (messages, name, data) => {
27397
27384
  };
27398
27385
 
27399
27386
  function receiveOne(messages, data) {
27400
- const bytebuffer = ByteBuffer.wrap(data, 'hex');
27387
+ const bytebuffer = bytebuffer_default().wrap(data, 'hex');
27401
27388
  const {
27402
27389
  typeId,
27403
27390
  buffer
@@ -27615,7 +27602,6 @@ var Enum_RequestType;
27615
27602
  Enum_RequestType[Enum_RequestType["TXEXTRADATA"] = 4] = "TXEXTRADATA";
27616
27603
  Enum_RequestType[Enum_RequestType["TXORIGINPUT"] = 5] = "TXORIGINPUT";
27617
27604
  Enum_RequestType[Enum_RequestType["TXORIGOUTPUT"] = 6] = "TXORIGOUTPUT";
27618
- Enum_RequestType[Enum_RequestType["TXPAYMENTREQ"] = 7] = "TXPAYMENTREQ";
27619
27605
  })(Enum_RequestType || (Enum_RequestType = {}));
27620
27606
 
27621
27607
  var CardanoDerivationType;
@@ -27691,7 +27677,6 @@ var CardanoTxSigningMode;
27691
27677
  CardanoTxSigningMode[CardanoTxSigningMode["ORDINARY_TRANSACTION"] = 0] = "ORDINARY_TRANSACTION";
27692
27678
  CardanoTxSigningMode[CardanoTxSigningMode["POOL_REGISTRATION_AS_OWNER"] = 1] = "POOL_REGISTRATION_AS_OWNER";
27693
27679
  CardanoTxSigningMode[CardanoTxSigningMode["MULTISIG_TRANSACTION"] = 2] = "MULTISIG_TRANSACTION";
27694
- CardanoTxSigningMode[CardanoTxSigningMode["PLUTUS_TRANSACTION"] = 3] = "PLUTUS_TRANSACTION";
27695
27680
  })(CardanoTxSigningMode || (CardanoTxSigningMode = {}));
27696
27681
 
27697
27682
  var CardanoTxWitnessType;
@@ -27754,16 +27739,10 @@ var Enum_PinMatrixRequestType;
27754
27739
  Enum_PinMatrixRequestType[Enum_PinMatrixRequestType["PinMatrixRequestType_NewSecond"] = 3] = "PinMatrixRequestType_NewSecond";
27755
27740
  Enum_PinMatrixRequestType[Enum_PinMatrixRequestType["PinMatrixRequestType_WipeCodeFirst"] = 4] = "PinMatrixRequestType_WipeCodeFirst";
27756
27741
  Enum_PinMatrixRequestType[Enum_PinMatrixRequestType["PinMatrixRequestType_WipeCodeSecond"] = 5] = "PinMatrixRequestType_WipeCodeSecond";
27742
+ Enum_PinMatrixRequestType[Enum_PinMatrixRequestType["PinMatrixRequestType_BackupFirst"] = 6] = "PinMatrixRequestType_BackupFirst";
27743
+ Enum_PinMatrixRequestType[Enum_PinMatrixRequestType["PinMatrixRequestType_BackupSecond"] = 7] = "PinMatrixRequestType_BackupSecond";
27757
27744
  })(Enum_PinMatrixRequestType || (Enum_PinMatrixRequestType = {}));
27758
27745
 
27759
- var DebugButton;
27760
-
27761
- (function (DebugButton) {
27762
- DebugButton[DebugButton["NO"] = 0] = "NO";
27763
- DebugButton[DebugButton["YES"] = 1] = "YES";
27764
- DebugButton[DebugButton["INFO"] = 2] = "INFO";
27765
- })(DebugButton || (DebugButton = {}));
27766
-
27767
27746
  var EthereumDataType;
27768
27747
 
27769
27748
  (function (EthereumDataType) {
@@ -27815,6 +27794,14 @@ var Enum_Capability;
27815
27794
  Enum_Capability[Enum_Capability["Capability_PassphraseEntry"] = 17] = "Capability_PassphraseEntry";
27816
27795
  })(Enum_Capability || (Enum_Capability = {}));
27817
27796
 
27797
+ var ExportType;
27798
+
27799
+ (function (ExportType) {
27800
+ ExportType[ExportType["SeedEncExportType_NO"] = 0] = "SeedEncExportType_NO";
27801
+ ExportType[ExportType["SeedEncExportType_YES"] = 1] = "SeedEncExportType_YES";
27802
+ ExportType[ExportType["MnemonicPlainExportType_YES"] = 2] = "MnemonicPlainExportType_YES";
27803
+ })(ExportType || (ExportType = {}));
27804
+
27818
27805
  var SdProtectOperationType;
27819
27806
 
27820
27807
  (function (SdProtectOperationType) {
@@ -27838,6 +27825,22 @@ var Enum_WordRequestType;
27838
27825
  Enum_WordRequestType[Enum_WordRequestType["WordRequestType_Matrix6"] = 2] = "WordRequestType_Matrix6";
27839
27826
  })(Enum_WordRequestType || (Enum_WordRequestType = {}));
27840
27827
 
27828
+ var SeedRequestType;
27829
+
27830
+ (function (SeedRequestType) {
27831
+ SeedRequestType[SeedRequestType["SeedRequestType_Gen"] = 0] = "SeedRequestType_Gen";
27832
+ SeedRequestType[SeedRequestType["SeedRequestType_EncExport"] = 1] = "SeedRequestType_EncExport";
27833
+ SeedRequestType[SeedRequestType["SeedRequestType_EncImport"] = 2] = "SeedRequestType_EncImport";
27834
+ })(SeedRequestType || (SeedRequestType = {}));
27835
+
27836
+ var WL_OperationType;
27837
+
27838
+ (function (WL_OperationType) {
27839
+ WL_OperationType[WL_OperationType["WL_OperationType_Add"] = 0] = "WL_OperationType_Add";
27840
+ WL_OperationType[WL_OperationType["WL_OperationType_Delete"] = 1] = "WL_OperationType_Delete";
27841
+ WL_OperationType[WL_OperationType["WL_OperationType_Inquire"] = 2] = "WL_OperationType_Inquire";
27842
+ })(WL_OperationType || (WL_OperationType = {}));
27843
+
27841
27844
  var NEMMosaicLevy;
27842
27845
 
27843
27846
  (function (NEMMosaicLevy) {
@@ -27907,6 +27910,13 @@ var TezosBallotType;
27907
27910
  TezosBallotType[TezosBallotType["Pass"] = 2] = "Pass";
27908
27911
  })(TezosBallotType || (TezosBallotType = {}));
27909
27912
 
27913
+ var CommandFlags;
27914
+
27915
+ (function (CommandFlags) {
27916
+ CommandFlags[CommandFlags["Default"] = 0] = "Default";
27917
+ CommandFlags[CommandFlags["Factory_Only"] = 1] = "Factory_Only";
27918
+ })(CommandFlags || (CommandFlags = {}));
27919
+
27910
27920
  var messages = /*#__PURE__*/Object.freeze({
27911
27921
  __proto__: null,
27912
27922
 
@@ -27990,10 +28000,6 @@ var messages = /*#__PURE__*/Object.freeze({
27990
28000
  return Enum_PinMatrixRequestType;
27991
28001
  },
27992
28002
 
27993
- get DebugButton() {
27994
- return DebugButton;
27995
- },
27996
-
27997
28003
  get EthereumDataType() {
27998
28004
  return EthereumDataType;
27999
28005
  },
@@ -28010,6 +28016,10 @@ var messages = /*#__PURE__*/Object.freeze({
28010
28016
  return Enum_Capability;
28011
28017
  },
28012
28018
 
28019
+ get ExportType() {
28020
+ return ExportType;
28021
+ },
28022
+
28013
28023
  get SdProtectOperationType() {
28014
28024
  return SdProtectOperationType;
28015
28025
  },
@@ -28022,6 +28032,14 @@ var messages = /*#__PURE__*/Object.freeze({
28022
28032
  return Enum_WordRequestType;
28023
28033
  },
28024
28034
 
28035
+ get SeedRequestType() {
28036
+ return SeedRequestType;
28037
+ },
28038
+
28039
+ get WL_OperationType() {
28040
+ return WL_OperationType;
28041
+ },
28042
+
28025
28043
  get NEMMosaicLevy() {
28026
28044
  return NEMMosaicLevy;
28027
28045
  },
@@ -28056,6 +28074,10 @@ var messages = /*#__PURE__*/Object.freeze({
28056
28074
 
28057
28075
  get TezosBallotType() {
28058
28076
  return TezosBallotType;
28077
+ },
28078
+
28079
+ get CommandFlags() {
28080
+ return CommandFlags;
28059
28081
  }
28060
28082
 
28061
28083
  });
@@ -28071,6 +28093,15 @@ var index = {
28071
28093
  decodeProtocol
28072
28094
  };
28073
28095
 
28096
+ // EXTERNAL MODULE: ../../node_modules/axios/index.js
28097
+ var axios = __webpack_require__(9644);
28098
+ var axios_default = /*#__PURE__*/__webpack_require__.n(axios);
28099
+ // EXTERNAL MODULE: ../../node_modules/bignumber.js/bignumber.js
28100
+ var bignumber = __webpack_require__(6391);
28101
+ var bignumber_default = /*#__PURE__*/__webpack_require__.n(bignumber);
28102
+ // EXTERNAL MODULE: ../../node_modules/js-sha256/src/sha256.js
28103
+ var sha256 = __webpack_require__(1965);
28104
+ var sha256_default = /*#__PURE__*/__webpack_require__.n(sha256);
28074
28105
  ;// CONCATENATED MODULE: ../core/dist/index.js
28075
28106
 
28076
28107
 
@@ -28301,7 +28332,62 @@ const inject = ({
28301
28332
  })),
28302
28333
  requestWebUsbDevice: () => call({
28303
28334
  method: 'requestWebUsbDevice'
28304
- })
28335
+ }),
28336
+ tronGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28337
+ connectId,
28338
+ deviceId,
28339
+ method: 'tronGetAddress'
28340
+ })),
28341
+ tronSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28342
+ connectId,
28343
+ deviceId,
28344
+ method: 'tronSignMessage'
28345
+ })),
28346
+ tronSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28347
+ connectId,
28348
+ deviceId,
28349
+ method: 'tronSignTransaction'
28350
+ })),
28351
+ confluxGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28352
+ connectId,
28353
+ deviceId,
28354
+ method: 'confluxGetAddress'
28355
+ })),
28356
+ confluxSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28357
+ connectId,
28358
+ deviceId,
28359
+ method: 'confluxSignMessage'
28360
+ })),
28361
+ confluxSignMessageCIP23: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28362
+ connectId,
28363
+ deviceId,
28364
+ method: 'confluxSignMessageCIP23'
28365
+ })),
28366
+ confluxSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28367
+ connectId,
28368
+ deviceId,
28369
+ method: 'confluxSignTransaction'
28370
+ })),
28371
+ nearGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28372
+ connectId,
28373
+ deviceId,
28374
+ method: 'nearGetAddress'
28375
+ })),
28376
+ nearSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28377
+ connectId,
28378
+ deviceId,
28379
+ method: 'nearSignTransaction'
28380
+ })),
28381
+ aptosGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28382
+ connectId,
28383
+ deviceId,
28384
+ method: 'aptosGetAddress'
28385
+ })),
28386
+ aptosSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
28387
+ connectId,
28388
+ deviceId,
28389
+ method: 'aptosSignTransaction'
28390
+ }))
28305
28391
  };
28306
28392
  return api;
28307
28393
  };
@@ -29018,13 +29104,15 @@ const getDeviceTypeByDeviceId = deviceId => {
29018
29104
  };
29019
29105
 
29020
29106
  const getDeviceUUID = features => {
29107
+ var _a, _b;
29108
+
29021
29109
  const deviceType = getDeviceType(features);
29022
29110
 
29023
29111
  if (deviceType === 'classic') {
29024
- return features.onekey_serial;
29112
+ return (_a = features.onekey_serial) !== null && _a !== void 0 ? _a : '';
29025
29113
  }
29026
29114
 
29027
- return features.serial_no;
29115
+ return (_b = features.serial_no) !== null && _b !== void 0 ? _b : '';
29028
29116
  };
29029
29117
 
29030
29118
  const getDeviceLabel = features => {
@@ -29111,6 +29199,61 @@ const getPassphraseState = (features, commands) => dist_awaiter(void 0, void 0,
29111
29199
  });
29112
29200
 
29113
29201
  var nested = {
29202
+ AptosGetAddress: {
29203
+ fields: {
29204
+ address_n: {
29205
+ rule: "repeated",
29206
+ type: "uint32",
29207
+ id: 1,
29208
+ options: {
29209
+ packed: false
29210
+ }
29211
+ },
29212
+ show_display: {
29213
+ type: "bool",
29214
+ id: 2
29215
+ }
29216
+ }
29217
+ },
29218
+ AptosAddress: {
29219
+ fields: {
29220
+ address: {
29221
+ type: "string",
29222
+ id: 1
29223
+ }
29224
+ }
29225
+ },
29226
+ AptosSignTx: {
29227
+ fields: {
29228
+ address_n: {
29229
+ rule: "repeated",
29230
+ type: "uint32",
29231
+ id: 1,
29232
+ options: {
29233
+ packed: false
29234
+ }
29235
+ },
29236
+ raw_tx: {
29237
+ rule: "required",
29238
+ type: "bytes",
29239
+ id: 2
29240
+ }
29241
+ }
29242
+ },
29243
+ AptosSignedTx: {
29244
+ fields: {
29245
+ public_key: {
29246
+ rule: "required",
29247
+ type: "bytes",
29248
+ id: 1
29249
+ },
29250
+ signature: {
29251
+ rule: "required",
29252
+ type: "bytes",
29253
+ id: 2
29254
+ }
29255
+ }
29256
+ },
29114
29257
  BinanceGetAddress: {
29115
29258
  fields: {
29116
29259
  address_n: {
@@ -31727,7 +31870,7 @@ var nested = {
31727
31870
  BixinPinInputOnDevice: {
31728
31871
  fields: {}
31729
31872
  },
31730
- CipherKeyValue: {
31873
+ ConfluxGetAddress: {
31731
31874
  fields: {
31732
31875
  address_n: {
31733
31876
  rule: "repeated",
@@ -31737,127 +31880,283 @@ var nested = {
31737
31880
  packed: false
31738
31881
  }
31739
31882
  },
31740
- key: {
31741
- rule: "required",
31742
- type: "string",
31883
+ show_display: {
31884
+ type: "bool",
31743
31885
  id: 2
31744
31886
  },
31745
- value: {
31746
- rule: "required",
31747
- type: "bytes",
31887
+ chain_id: {
31888
+ type: "uint32",
31748
31889
  id: 3
31749
- },
31750
- encrypt: {
31751
- type: "bool",
31752
- id: 4
31753
- },
31754
- ask_on_encrypt: {
31755
- type: "bool",
31756
- id: 5
31757
- },
31758
- ask_on_decrypt: {
31759
- type: "bool",
31760
- id: 6
31761
- },
31762
- iv: {
31763
- type: "bytes",
31764
- id: 7
31765
31890
  }
31766
31891
  }
31767
31892
  },
31768
- CipheredKeyValue: {
31893
+ ConfluxAddress: {
31769
31894
  fields: {
31770
- value: {
31771
- rule: "required",
31772
- type: "bytes",
31895
+ address: {
31896
+ type: "string",
31773
31897
  id: 1
31774
31898
  }
31775
31899
  }
31776
31900
  },
31777
- IdentityType: {
31901
+ ConfluxSignTx: {
31778
31902
  fields: {
31779
- proto: {
31780
- type: "string",
31781
- id: 1
31903
+ address_n: {
31904
+ rule: "repeated",
31905
+ type: "uint32",
31906
+ id: 1,
31907
+ options: {
31908
+ packed: false
31909
+ }
31782
31910
  },
31783
- user: {
31784
- type: "string",
31911
+ nonce: {
31912
+ type: "bytes",
31785
31913
  id: 2
31786
31914
  },
31787
- host: {
31788
- type: "string",
31915
+ gas_price: {
31916
+ type: "bytes",
31789
31917
  id: 3
31790
31918
  },
31791
- port: {
31792
- type: "string",
31919
+ gas_limit: {
31920
+ type: "bytes",
31793
31921
  id: 4
31794
31922
  },
31795
- path: {
31923
+ to: {
31796
31924
  type: "string",
31797
31925
  id: 5
31798
31926
  },
31799
- index: {
31800
- type: "uint32",
31801
- id: 6,
31802
- options: {
31803
- "default": 0
31804
- }
31805
- }
31806
- }
31807
- },
31808
- SignIdentity: {
31809
- fields: {
31810
- identity: {
31811
- rule: "required",
31812
- type: "IdentityType",
31813
- id: 1
31927
+ value: {
31928
+ type: "bytes",
31929
+ id: 6
31814
31930
  },
31815
- challenge_hidden: {
31931
+ epoch_height: {
31816
31932
  type: "bytes",
31817
- id: 2,
31818
- options: {
31819
- "default": ""
31820
- }
31933
+ id: 7
31821
31934
  },
31822
- challenge_visual: {
31823
- type: "string",
31824
- id: 3,
31825
- options: {
31826
- "default": ""
31827
- }
31935
+ storage_limit: {
31936
+ type: "bytes",
31937
+ id: 8
31828
31938
  },
31829
- ecdsa_curve_name: {
31830
- type: "string",
31831
- id: 4
31939
+ data_initial_chunk: {
31940
+ type: "bytes",
31941
+ id: 9
31942
+ },
31943
+ data_length: {
31944
+ type: "uint32",
31945
+ id: 10
31946
+ },
31947
+ chain_id: {
31948
+ type: "uint32",
31949
+ id: 11
31832
31950
  }
31833
31951
  }
31834
31952
  },
31835
- SignedIdentity: {
31953
+ ConfluxTxRequest: {
31836
31954
  fields: {
31837
- address: {
31838
- type: "string",
31955
+ data_length: {
31956
+ type: "uint32",
31839
31957
  id: 1
31840
31958
  },
31841
- public_key: {
31842
- rule: "required",
31843
- type: "bytes",
31959
+ signature_v: {
31960
+ type: "uint32",
31844
31961
  id: 2
31845
31962
  },
31846
- signature: {
31847
- rule: "required",
31963
+ signature_r: {
31848
31964
  type: "bytes",
31849
31965
  id: 3
31966
+ },
31967
+ signature_s: {
31968
+ type: "bytes",
31969
+ id: 4
31850
31970
  }
31851
31971
  }
31852
31972
  },
31853
- GetECDHSessionKey: {
31973
+ ConfluxTxAck: {
31854
31974
  fields: {
31855
- identity: {
31856
- rule: "required",
31857
- type: "IdentityType",
31975
+ data_chunk: {
31976
+ type: "bytes",
31858
31977
  id: 1
31859
- },
31860
- peer_public_key: {
31978
+ }
31979
+ }
31980
+ },
31981
+ ConfluxSignMessage: {
31982
+ fields: {
31983
+ address_n: {
31984
+ rule: "repeated",
31985
+ type: "uint32",
31986
+ id: 1,
31987
+ options: {
31988
+ packed: false
31989
+ }
31990
+ },
31991
+ message: {
31992
+ type: "bytes",
31993
+ id: 2
31994
+ }
31995
+ }
31996
+ },
31997
+ ConfluxMessageSignature: {
31998
+ fields: {
31999
+ signature: {
32000
+ type: "bytes",
32001
+ id: 2
32002
+ },
32003
+ address: {
32004
+ type: "string",
32005
+ id: 3
32006
+ }
32007
+ }
32008
+ },
32009
+ ConfluxSignMessageCIP23: {
32010
+ fields: {
32011
+ address_n: {
32012
+ rule: "repeated",
32013
+ type: "uint32",
32014
+ id: 1,
32015
+ options: {
32016
+ packed: false
32017
+ }
32018
+ },
32019
+ domain_hash: {
32020
+ type: "bytes",
32021
+ id: 2
32022
+ },
32023
+ message_hash: {
32024
+ type: "bytes",
32025
+ id: 3
32026
+ }
32027
+ }
32028
+ },
32029
+ CipherKeyValue: {
32030
+ fields: {
32031
+ address_n: {
32032
+ rule: "repeated",
32033
+ type: "uint32",
32034
+ id: 1,
32035
+ options: {
32036
+ packed: false
32037
+ }
32038
+ },
32039
+ key: {
32040
+ rule: "required",
32041
+ type: "string",
32042
+ id: 2
32043
+ },
32044
+ value: {
32045
+ rule: "required",
32046
+ type: "bytes",
32047
+ id: 3
32048
+ },
32049
+ encrypt: {
32050
+ type: "bool",
32051
+ id: 4
32052
+ },
32053
+ ask_on_encrypt: {
32054
+ type: "bool",
32055
+ id: 5
32056
+ },
32057
+ ask_on_decrypt: {
32058
+ type: "bool",
32059
+ id: 6
32060
+ },
32061
+ iv: {
32062
+ type: "bytes",
32063
+ id: 7
32064
+ }
32065
+ }
32066
+ },
32067
+ CipheredKeyValue: {
32068
+ fields: {
32069
+ value: {
32070
+ rule: "required",
32071
+ type: "bytes",
32072
+ id: 1
32073
+ }
32074
+ }
32075
+ },
32076
+ IdentityType: {
32077
+ fields: {
32078
+ proto: {
32079
+ type: "string",
32080
+ id: 1
32081
+ },
32082
+ user: {
32083
+ type: "string",
32084
+ id: 2
32085
+ },
32086
+ host: {
32087
+ type: "string",
32088
+ id: 3
32089
+ },
32090
+ port: {
32091
+ type: "string",
32092
+ id: 4
32093
+ },
32094
+ path: {
32095
+ type: "string",
32096
+ id: 5
32097
+ },
32098
+ index: {
32099
+ type: "uint32",
32100
+ id: 6,
32101
+ options: {
32102
+ "default": 0
32103
+ }
32104
+ }
32105
+ }
32106
+ },
32107
+ SignIdentity: {
32108
+ fields: {
32109
+ identity: {
32110
+ rule: "required",
32111
+ type: "IdentityType",
32112
+ id: 1
32113
+ },
32114
+ challenge_hidden: {
32115
+ type: "bytes",
32116
+ id: 2,
32117
+ options: {
32118
+ "default": ""
32119
+ }
32120
+ },
32121
+ challenge_visual: {
32122
+ type: "string",
32123
+ id: 3,
32124
+ options: {
32125
+ "default": ""
32126
+ }
32127
+ },
32128
+ ecdsa_curve_name: {
32129
+ type: "string",
32130
+ id: 4
32131
+ }
32132
+ }
32133
+ },
32134
+ SignedIdentity: {
32135
+ fields: {
32136
+ address: {
32137
+ type: "string",
32138
+ id: 1
32139
+ },
32140
+ public_key: {
32141
+ rule: "required",
32142
+ type: "bytes",
32143
+ id: 2
32144
+ },
32145
+ signature: {
32146
+ rule: "required",
32147
+ type: "bytes",
32148
+ id: 3
32149
+ }
32150
+ }
32151
+ },
32152
+ GetECDHSessionKey: {
32153
+ fields: {
32154
+ identity: {
32155
+ rule: "required",
32156
+ type: "IdentityType",
32157
+ id: 1
32158
+ },
32159
+ peer_public_key: {
31861
32160
  rule: "required",
31862
32161
  type: "bytes",
31863
32162
  id: 2
@@ -33411,6 +33710,10 @@ var nested = {
33411
33710
  coin_switch: {
33412
33711
  type: "uint32",
33413
33712
  id: 517
33713
+ },
33714
+ build_id: {
33715
+ type: "string",
33716
+ id: 518
33414
33717
  }
33415
33718
  },
33416
33719
  nested: {
@@ -35099,6 +35402,55 @@ var nested = {
35099
35402
  }
35100
35403
  }
35101
35404
  },
35405
+ NearGetAddress: {
35406
+ fields: {
35407
+ address_n: {
35408
+ rule: "repeated",
35409
+ type: "uint32",
35410
+ id: 1,
35411
+ options: {
35412
+ packed: false
35413
+ }
35414
+ },
35415
+ show_display: {
35416
+ type: "bool",
35417
+ id: 2
35418
+ }
35419
+ }
35420
+ },
35421
+ NearAddress: {
35422
+ fields: {
35423
+ address: {
35424
+ type: "string",
35425
+ id: 1
35426
+ }
35427
+ }
35428
+ },
35429
+ NearSignTx: {
35430
+ fields: {
35431
+ address_n: {
35432
+ rule: "repeated",
35433
+ type: "uint32",
35434
+ id: 1,
35435
+ options: {
35436
+ packed: false
35437
+ }
35438
+ },
35439
+ raw_tx: {
35440
+ type: "bytes",
35441
+ id: 2
35442
+ }
35443
+ }
35444
+ },
35445
+ NearSignedTx: {
35446
+ fields: {
35447
+ signature: {
35448
+ rule: "required",
35449
+ type: "bytes",
35450
+ id: 1
35451
+ }
35452
+ }
35453
+ },
35102
35454
  NEMGetAddress: {
35103
35455
  fields: {
35104
35456
  address_n: {
@@ -35615,6 +35967,7 @@ var nested = {
35615
35967
  }
35616
35968
  },
35617
35969
  raw_tx: {
35970
+ rule: "required",
35618
35971
  type: "bytes",
35619
35972
  id: 2
35620
35973
  }
@@ -36651,32 +37004,197 @@ var nested = {
36651
37004
  }
36652
37005
  }
36653
37006
  },
36654
- WebAuthnListResidentCredentials: {
36655
- fields: {}
36656
- },
36657
- WebAuthnAddResidentCredential: {
37007
+ TronGetAddress: {
36658
37008
  fields: {
36659
- credential_id: {
36660
- type: "bytes",
36661
- id: 1
37009
+ address_n: {
37010
+ rule: "repeated",
37011
+ type: "uint32",
37012
+ id: 1,
37013
+ options: {
37014
+ packed: false
37015
+ }
37016
+ },
37017
+ show_display: {
37018
+ type: "bool",
37019
+ id: 2
36662
37020
  }
36663
37021
  }
36664
37022
  },
36665
- WebAuthnRemoveResidentCredential: {
37023
+ TronAddress: {
36666
37024
  fields: {
36667
- index: {
36668
- type: "uint32",
37025
+ address: {
37026
+ type: "string",
36669
37027
  id: 1
36670
37028
  }
36671
37029
  }
36672
37030
  },
36673
- WebAuthnCredentials: {
37031
+ TronSignTx: {
36674
37032
  fields: {
36675
- credentials: {
37033
+ address_n: {
36676
37034
  rule: "repeated",
36677
- type: "WebAuthnCredential",
36678
- id: 1
36679
- }
37035
+ type: "uint32",
37036
+ id: 1,
37037
+ options: {
37038
+ packed: false
37039
+ }
37040
+ },
37041
+ ref_block_bytes: {
37042
+ rule: "required",
37043
+ type: "bytes",
37044
+ id: 2
37045
+ },
37046
+ ref_block_hash: {
37047
+ rule: "required",
37048
+ type: "bytes",
37049
+ id: 3
37050
+ },
37051
+ expiration: {
37052
+ rule: "required",
37053
+ type: "uint64",
37054
+ id: 4
37055
+ },
37056
+ data: {
37057
+ type: "string",
37058
+ id: 5
37059
+ },
37060
+ contract: {
37061
+ rule: "required",
37062
+ type: "TronContract",
37063
+ id: 6
37064
+ },
37065
+ timestamp: {
37066
+ rule: "required",
37067
+ type: "uint64",
37068
+ id: 7
37069
+ },
37070
+ fee_limit: {
37071
+ type: "uint64",
37072
+ id: 8
37073
+ }
37074
+ },
37075
+ nested: {
37076
+ TronContract: {
37077
+ fields: {
37078
+ transfer_contract: {
37079
+ type: "TronTransferContract",
37080
+ id: 2
37081
+ },
37082
+ trigger_smart_contract: {
37083
+ type: "TronTriggerSmartContract",
37084
+ id: 31
37085
+ }
37086
+ },
37087
+ nested: {
37088
+ TronTransferContract: {
37089
+ fields: {
37090
+ to_address: {
37091
+ type: "string",
37092
+ id: 2
37093
+ },
37094
+ amount: {
37095
+ type: "uint64",
37096
+ id: 3
37097
+ }
37098
+ }
37099
+ },
37100
+ TronTriggerSmartContract: {
37101
+ fields: {
37102
+ contract_address: {
37103
+ type: "string",
37104
+ id: 2
37105
+ },
37106
+ call_value: {
37107
+ type: "uint64",
37108
+ id: 3
37109
+ },
37110
+ data: {
37111
+ type: "bytes",
37112
+ id: 4
37113
+ },
37114
+ call_token_value: {
37115
+ type: "uint64",
37116
+ id: 5
37117
+ },
37118
+ asset_id: {
37119
+ type: "uint64",
37120
+ id: 6
37121
+ }
37122
+ }
37123
+ }
37124
+ }
37125
+ }
37126
+ }
37127
+ },
37128
+ TronSignedTx: {
37129
+ fields: {
37130
+ signature: {
37131
+ rule: "required",
37132
+ type: "bytes",
37133
+ id: 1
37134
+ },
37135
+ serialized_tx: {
37136
+ type: "bytes",
37137
+ id: 2
37138
+ }
37139
+ }
37140
+ },
37141
+ TronSignMessage: {
37142
+ fields: {
37143
+ address_n: {
37144
+ rule: "repeated",
37145
+ type: "uint32",
37146
+ id: 1,
37147
+ options: {
37148
+ packed: false
37149
+ }
37150
+ },
37151
+ message: {
37152
+ rule: "required",
37153
+ type: "bytes",
37154
+ id: 2
37155
+ }
37156
+ }
37157
+ },
37158
+ TronMessageSignature: {
37159
+ fields: {
37160
+ address: {
37161
+ rule: "required",
37162
+ type: "bytes",
37163
+ id: 1
37164
+ },
37165
+ signature: {
37166
+ rule: "required",
37167
+ type: "bytes",
37168
+ id: 2
37169
+ }
37170
+ }
37171
+ },
37172
+ WebAuthnListResidentCredentials: {
37173
+ fields: {}
37174
+ },
37175
+ WebAuthnAddResidentCredential: {
37176
+ fields: {
37177
+ credential_id: {
37178
+ type: "bytes",
37179
+ id: 1
37180
+ }
37181
+ }
37182
+ },
37183
+ WebAuthnRemoveResidentCredential: {
37184
+ fields: {
37185
+ index: {
37186
+ type: "uint32",
37187
+ id: 1
37188
+ }
37189
+ }
37190
+ },
37191
+ WebAuthnCredentials: {
37192
+ fields: {
37193
+ credentials: {
37194
+ rule: "repeated",
37195
+ type: "WebAuthnCredential",
37196
+ id: 1
37197
+ }
36680
37198
  },
36681
37199
  nested: {
36682
37200
  WebAuthnCredential: {
@@ -37045,6 +37563,20 @@ var nested = {
37045
37563
  MessageType_StarcoinSignMessage: 10306,
37046
37564
  MessageType_StarcoinMessageSignature: 10307,
37047
37565
  MessageType_StarcoinVerifyMessage: 10308,
37566
+ MessageType_ConfluxGetAddress: 10401,
37567
+ MessageType_ConfluxAddress: 10402,
37568
+ MessageType_ConfluxSignTx: 10403,
37569
+ MessageType_ConfluxTxRequest: 10404,
37570
+ MessageType_ConfluxTxAck: 10405,
37571
+ MessageType_ConfluxSignMessage: 10406,
37572
+ MessageType_ConfluxSignMessageCIP23: 10407,
37573
+ MessageType_ConfluxMessageSignature: 10408,
37574
+ MessageType_ConfluxVerifyMessage: 10409,
37575
+ MessageType_ConfluxVerifyMessageCIP23: 10410,
37576
+ MessageType_AptosGetAddress: 10600,
37577
+ MessageType_AptosAddress: 10601,
37578
+ MessageType_AptosSignTx: 10602,
37579
+ MessageType_AptosSignedTx: 10603,
37048
37580
  MessageType_WebAuthnListResidentCredentials: 800,
37049
37581
  MessageType_WebAuthnCredentials: 801,
37050
37582
  MessageType_WebAuthnAddResidentCredential: 802,
@@ -37068,6 +37600,16 @@ var nested = {
37068
37600
  MessageType_EthereumSignMessageEIP712: 10200,
37069
37601
  MessageType_GetPublicKeyMultiple: 10210,
37070
37602
  MessageType_PublicKeyMultiple: 10211,
37603
+ MessageType_TronGetAddress: 10501,
37604
+ MessageType_TronAddress: 10502,
37605
+ MessageType_TronSignTx: 10503,
37606
+ MessageType_TronSignedTx: 10504,
37607
+ MessageType_TronSignMessage: 10505,
37608
+ MessageType_TronMessageSignature: 10506,
37609
+ MessageType_NearGetAddress: 10701,
37610
+ MessageType_NearAddress: 10702,
37611
+ MessageType_NearSignTx: 10703,
37612
+ MessageType_NearSignedTx: 10704,
37071
37613
  MessageType_DeviceInfoSettings: 10001,
37072
37614
  MessageType_GetDeviceInfo: 10002,
37073
37615
  MessageType_DeviceInfo: 10003,
@@ -38844,23 +39386,23 @@ class DeviceCommands {
38844
39386
  } = res.message;
38845
39387
  let error = null;
38846
39388
 
38847
- if (code === 'Failure_FirmwareError' && !message) {
39389
+ if (code === FailureType.Failure_FirmwareError && !message) {
38848
39390
  error = HardwareError$1.TypedError(dist_HardwareErrorCode.FirmwareError);
38849
39391
  }
38850
39392
 
38851
- if (code === 'Failure_ActionCancelled') {
39393
+ if (code === FailureType.Failure_ActionCancelled) {
38852
39394
  error = HardwareError$1.TypedError(dist_HardwareErrorCode.ActionCancelled);
38853
39395
  }
38854
39396
 
38855
- if (code === 'Failure_PinInvalid') {
39397
+ if (code === FailureType.Failure_PinInvalid) {
38856
39398
  error = HardwareError$1.TypedError(dist_HardwareErrorCode.PinInvalid, message);
38857
39399
  }
38858
39400
 
38859
- if (code === 'Failure_PinCancelled') {
39401
+ if (code === FailureType.Failure_PinCancelled) {
38860
39402
  error = HardwareError$1.TypedError(dist_HardwareErrorCode.PinCancelled);
38861
39403
  }
38862
39404
 
38863
- if (code === 'Failure_DataError' && message === 'Please confirm the BlindSign enabled') {
39405
+ if (code === FailureType.Failure_DataError && message === 'Please confirm the BlindSign enabled') {
38864
39406
  error = HardwareError$1.TypedError(dist_HardwareErrorCode.BlindSignDisabled);
38865
39407
  }
38866
39408
 
@@ -38949,7 +39491,7 @@ const UI_REQUEST = {
38949
39491
  FIRMWARE_NOT_INSTALLED: 'ui-device_firmware_not_installed',
38950
39492
  NOT_USE_ONEKEY_DEVICE: 'ui-device_please_use_onekey_device'
38951
39493
  };
38952
- const DEFAULT_DOMAIN = `https://jssdk.onekey.so/${"0.1.41"}/`;
39494
+ const DEFAULT_DOMAIN = `https://jssdk.onekey.so/${"0.1.44"}/`;
38953
39495
  const DEFAULT_PRIORITY = 2;
38954
39496
  const initialSettings = {
38955
39497
  configSrc: './data/config.json',
@@ -39653,7 +40195,7 @@ class BaseMethod {
39653
40195
  if (deviceType !== 'touch') return;
39654
40196
  let checkFlag = false;
39655
40197
 
39656
- if (this.name === 'evmSignTransaction' && Number((_b = (_a = this.payload) === null || _a === void 0 ? void 0 : _a.transaction) === null || _b === void 0 ? void 0 : _b.chainId) !== 1) {
40198
+ if (this.name === 'evmSignTransaction' && [3, 4, 5, 42].includes(Number((_b = (_a = this.payload) === null || _a === void 0 ? void 0 : _a.transaction) === null || _b === void 0 ? void 0 : _b.chainId))) {
39657
40199
  checkFlag = true;
39658
40200
  }
39659
40201
 
@@ -39717,80 +40259,222 @@ class GetFeatures extends BaseMethod {
39717
40259
 
39718
40260
  }
39719
40261
 
39720
- const hasHexPrefix = str => str.slice(0, 2).toLowerCase() === '0x';
40262
+ class GetPassphraseState extends BaseMethod {
40263
+ init() {
40264
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
40265
+ this.useDevicePassphraseState = false;
40266
+ }
39721
40267
 
39722
- const stripHexPrefix = str => hasHexPrefix(str) ? str.slice(2) : str;
40268
+ run() {
40269
+ var _a, _b;
39723
40270
 
39724
- const addHexPrefix = str => hasHexPrefix(str) ? str : `0x${str}`;
40271
+ return dist_awaiter(this, void 0, void 0, function* () {
40272
+ if (!this.device.features) return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.DeviceInitializeFailed));
40273
+ let {
40274
+ features
40275
+ } = this.device;
40276
+ const locked = ((_b = (_a = this.device) === null || _a === void 0 ? void 0 : _a.features) === null || _b === void 0 ? void 0 : _b.unlocked) === true;
40277
+ const passphraseState = yield getPassphraseState(this.device.features, this.device.commands);
40278
+ const isModeT = getDeviceType(features) === 'touch' || getDeviceType(features) === 'pro';
39725
40279
 
39726
- const isHexString = (value, length) => {
39727
- if (typeof value !== 'string' || !value.match(/^(0x|0X)?[0-9A-Fa-f]*$/)) {
39728
- return false;
39729
- }
40280
+ if (isModeT && locked) {
40281
+ const {
40282
+ message
40283
+ } = yield this.device.commands.typedCall('GetFeatures', 'Features', {});
40284
+ features = message;
40285
+ }
39730
40286
 
39731
- if (length && value.length !== 2 + 2 * length) {
39732
- return false;
40287
+ if (features && features.passphrase_protection === true) {
40288
+ return Promise.resolve(passphraseState);
40289
+ }
40290
+
40291
+ return Promise.resolve(undefined);
40292
+ });
39733
40293
  }
39734
40294
 
39735
- return true;
39736
- };
40295
+ }
39737
40296
 
39738
- const stripHexStartZeroes = str => {
39739
- while (/^00/.test(str)) {
39740
- str = str.slice(2);
40297
+ class CheckBridgeStatus$1 extends BaseMethod {
40298
+ init() {
40299
+ this.useDevice = false;
40300
+ this.useDevicePassphraseState = false;
39741
40301
  }
39742
40302
 
39743
- return str;
39744
- };
40303
+ run() {
40304
+ return dist_awaiter(this, void 0, void 0, function* () {
40305
+ const logs = getLog();
40306
+ return Promise.resolve(logs);
40307
+ });
40308
+ }
39745
40309
 
39746
- const modifyValues = (object, transformer) => Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transformer(value, key)]));
40310
+ }
39747
40311
 
39748
- const formatAnyHex = value => {
39749
- if (typeof value === 'string') {
39750
- let stripped = stripHexPrefix(value);
40312
+ class CheckFirmwareRelease extends BaseMethod {
40313
+ init() {
40314
+ this.useDevicePassphraseState = false;
40315
+ }
39751
40316
 
39752
- if (stripped.length % 2 !== 0) {
39753
- stripped = `0${stripped}`;
40317
+ run() {
40318
+ if (this.device.features) {
40319
+ const releaseInfo = getFirmwareReleaseInfo(this.device.features);
40320
+ return Promise.resolve(releaseInfo);
39754
40321
  }
39755
40322
 
39756
- return stripped;
40323
+ return Promise.resolve(null);
39757
40324
  }
39758
40325
 
39759
- if (Array.isArray(value)) {
39760
- return value.map(formatAnyHex);
39761
- }
40326
+ }
39762
40327
 
39763
- if (typeof value === 'object') {
39764
- return modifyValues(value, value => formatAnyHex(value));
40328
+ class CheckBLEFirmwareRelease extends BaseMethod {
40329
+ init() {
40330
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.BOOTLOADER];
40331
+ this.checkDeviceId = true;
40332
+ this.useDevicePassphraseState = false;
39765
40333
  }
39766
40334
 
39767
- return value;
39768
- };
39769
-
39770
- const invalidParameter = message => HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, message);
39771
-
39772
- const validateParams = (values, fields) => {
39773
- fields.forEach(field => {
39774
- const existsProp = Object.prototype.hasOwnProperty.call(values, field.name);
39775
-
39776
- if (!existsProp && field.required) {
39777
- throw invalidParameter(`Missing required parameter: ${field.name}`);
40335
+ run() {
40336
+ if (this.device.features) {
40337
+ const releaseInfo = getBleFirmwareReleaseInfo(this.device.features);
40338
+ return Promise.resolve(releaseInfo);
39778
40339
  }
39779
40340
 
39780
- const value = values[field.name];
40341
+ return Promise.resolve(null);
40342
+ }
39781
40343
 
39782
- if (value && field.type) {
39783
- switch (field.type) {
39784
- case 'array':
39785
- if (!Array.isArray(value)) {
39786
- throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
39787
- } else if (!field.allowEmpty && value.length < 1) {
39788
- throw invalidParameter(`Parameter "${field.name}" is empty.`);
39789
- }
40344
+ }
39790
40345
 
39791
- break;
40346
+ class CheckTransportRelease extends BaseMethod {
40347
+ init() {
40348
+ this.useDevice = false;
40349
+ this.useDevicePassphraseState = false;
40350
+ }
39792
40351
 
39793
- case 'bigNumber':
40352
+ run() {
40353
+ return dist_awaiter(this, void 0, void 0, function* () {
40354
+ const transport = TransportManager.getTransport();
40355
+ const localVersion = yield transport.init();
40356
+ const response = DataManager.getTransportStatus(localVersion);
40357
+ return Promise.resolve(response);
40358
+ });
40359
+ }
40360
+
40361
+ }
40362
+
40363
+ class CheckBridgeStatus extends BaseMethod {
40364
+ init() {
40365
+ this.useDevice = false;
40366
+ this.useDevicePassphraseState = false;
40367
+ }
40368
+
40369
+ run() {
40370
+ return dist_awaiter(this, void 0, void 0, function* () {
40371
+ return new Promise((resolve, reject) => {
40372
+ axios_default().request({
40373
+ url: 'http://localhost:21320',
40374
+ method: 'POST',
40375
+ withCredentials: false,
40376
+ timeout: 3000
40377
+ }).then(() => resolve(true)).catch(e => {
40378
+ if (e.code === 'ECONNABORTED') {
40379
+ reject(HardwareError$1.TypedError(dist_HardwareErrorCode.BridgeTimeoutError));
40380
+ } else {
40381
+ resolve(false);
40382
+ }
40383
+ });
40384
+ });
40385
+ });
40386
+ }
40387
+
40388
+ }
40389
+
40390
+ class DeviceBackup extends BaseMethod {
40391
+ init() {
40392
+ this.useDevicePassphraseState = false;
40393
+ }
40394
+
40395
+ run() {
40396
+ return dist_awaiter(this, void 0, void 0, function* () {
40397
+ const res = yield this.device.commands.typedCall('BackupDevice', 'Success');
40398
+ return Promise.resolve(res.message);
40399
+ });
40400
+ }
40401
+
40402
+ }
40403
+
40404
+ const hasHexPrefix = str => str.slice(0, 2).toLowerCase() === '0x';
40405
+
40406
+ const stripHexPrefix = str => hasHexPrefix(str) ? str.slice(2) : str;
40407
+
40408
+ const addHexPrefix = str => hasHexPrefix(str) ? str : `0x${str}`;
40409
+
40410
+ const isHexString = (value, length) => {
40411
+ if (typeof value !== 'string' || !value.match(/^(0x|0X)?[0-9A-Fa-f]*$/)) {
40412
+ return false;
40413
+ }
40414
+
40415
+ if (length && value.length !== 2 + 2 * length) {
40416
+ return false;
40417
+ }
40418
+
40419
+ return true;
40420
+ };
40421
+
40422
+ const stripHexStartZeroes = str => {
40423
+ while (/^00/.test(str)) {
40424
+ str = str.slice(2);
40425
+ }
40426
+
40427
+ return str;
40428
+ };
40429
+
40430
+ const modifyValues = (object, transformer) => Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transformer(value, key)]));
40431
+
40432
+ const formatAnyHex = value => {
40433
+ if (typeof value === 'string') {
40434
+ let stripped = stripHexPrefix(value);
40435
+
40436
+ if (stripped.length % 2 !== 0) {
40437
+ stripped = `0${stripped}`;
40438
+ }
40439
+
40440
+ return stripped;
40441
+ }
40442
+
40443
+ if (Array.isArray(value)) {
40444
+ return value.map(formatAnyHex);
40445
+ }
40446
+
40447
+ if (typeof value === 'object') {
40448
+ return modifyValues(value, value => formatAnyHex(value));
40449
+ }
40450
+
40451
+ return value;
40452
+ };
40453
+
40454
+ const invalidParameter = message => HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, message);
40455
+
40456
+ const validateParams = (values, fields) => {
40457
+ fields.forEach(field => {
40458
+ const existsProp = Object.prototype.hasOwnProperty.call(values, field.name);
40459
+
40460
+ if (!existsProp && field.required) {
40461
+ throw invalidParameter(`Missing required parameter: ${field.name}`);
40462
+ }
40463
+
40464
+ const value = values[field.name];
40465
+
40466
+ if (value && field.type) {
40467
+ switch (field.type) {
40468
+ case 'array':
40469
+ if (!Array.isArray(value)) {
40470
+ throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
40471
+ } else if (!field.allowEmpty && value.length < 1) {
40472
+ throw invalidParameter(`Parameter "${field.name}" is empty.`);
40473
+ }
40474
+
40475
+ break;
40476
+
40477
+ case 'bigNumber':
39794
40478
  if (typeof value !== 'string') {
39795
40479
  throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [string].`);
39796
40480
  }
@@ -39832,101 +40516,656 @@ const validateParams = (values, fields) => {
39832
40516
  });
39833
40517
  };
39834
40518
 
39835
- class CipherKeyValue extends BaseMethod {
39836
- constructor() {
39837
- super(...arguments);
39838
- this.hasBundle = false;
40519
+ class DeviceChangePin extends BaseMethod {
40520
+ init() {
40521
+ this.useDevicePassphraseState = false;
40522
+ validateParams(this.payload, [{
40523
+ name: 'remove',
40524
+ type: 'boolean'
40525
+ }]);
40526
+ this.params = {
40527
+ remove: this.payload.remove
40528
+ };
39839
40529
  }
39840
40530
 
39841
- init() {
39842
- var _a;
40531
+ run() {
40532
+ return dist_awaiter(this, void 0, void 0, function* () {
40533
+ const res = yield this.device.commands.typedCall('ChangePin', 'Success', Object.assign({}, this.params));
40534
+ return Promise.resolve(res.message);
40535
+ });
40536
+ }
39843
40537
 
39844
- this.checkDeviceId = true;
39845
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
39846
- this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
39847
- const payload = this.hasBundle ? this.payload : {
39848
- bundle: [this.payload]
39849
- };
39850
- validateParams(payload, [{
39851
- name: 'bundle',
39852
- type: 'array'
40538
+ }
40539
+
40540
+ class DeviceFlags extends BaseMethod {
40541
+ init() {
40542
+ this.useDevicePassphraseState = false;
40543
+ validateParams(this.payload, [{
40544
+ name: 'flags',
40545
+ type: 'number'
39853
40546
  }]);
39854
- this.params = [];
39855
- payload.bundle.forEach(batch => {
39856
- const addressN = validatePath(batch.path);
39857
- validateParams(batch, [{
39858
- name: 'path',
39859
- required: true
39860
- }, {
39861
- name: 'key',
39862
- type: 'string'
39863
- }, {
39864
- name: 'value',
39865
- type: 'hexString'
39866
- }, {
39867
- name: 'encrypt',
39868
- type: 'boolean'
39869
- }, {
39870
- name: 'askOnEncrypt',
39871
- type: 'boolean'
39872
- }, {
39873
- name: 'askOnDecrypt',
39874
- type: 'boolean'
39875
- }, {
39876
- name: 'iv',
39877
- type: 'hexString'
39878
- }]);
39879
- this.params.push({
39880
- address_n: addressN,
39881
- key: batch.key,
39882
- value: formatAnyHex(batch.value),
39883
- encrypt: batch.encrypt,
39884
- ask_on_encrypt: batch.askOnEncrypt,
39885
- ask_on_decrypt: batch.askOnDecrypt,
39886
- iv: formatAnyHex(batch.iv)
39887
- });
39888
- });
40547
+ this.params = {
40548
+ flags: this.payload.flags
40549
+ };
39889
40550
  }
39890
40551
 
39891
40552
  run() {
39892
40553
  return dist_awaiter(this, void 0, void 0, function* () {
39893
- const responses = [];
40554
+ const res = yield this.device.commands.typedCall('ApplyFlags', 'Success', Object.assign({}, this.params));
40555
+ return Promise.resolve(res.message);
40556
+ });
40557
+ }
39894
40558
 
39895
- for (let i = 0; i < this.params.length; i++) {
39896
- const param = this.params[i];
39897
- const res = yield this.device.commands.typedCall('CipherKeyValue', 'CipheredKeyValue', Object.assign({}, param));
39898
- responses.push(Object.assign({
39899
- path: serializedPath(param.address_n)
39900
- }, res.message));
40559
+ }
40560
+
40561
+ class DeviceRebootToBootloader extends BaseMethod {
40562
+ init() {
40563
+ this.useDevicePassphraseState = false;
40564
+ }
40565
+
40566
+ getVersionRange() {
40567
+ return {
40568
+ classic: {
40569
+ min: '2.1.11'
40570
+ },
40571
+ mini: {
40572
+ min: '2.1.11'
39901
40573
  }
40574
+ };
40575
+ }
39902
40576
 
39903
- return Promise.resolve(this.hasBundle ? responses : responses[0]);
40577
+ run() {
40578
+ return dist_awaiter(this, void 0, void 0, function* () {
40579
+ const res = yield this.device.commands.typedCall('RebootToBootloader', 'Success');
40580
+ return Promise.resolve(res.message);
39904
40581
  });
39905
40582
  }
39906
40583
 
39907
40584
  }
39908
40585
 
39909
- var bitcoin = [{
39910
- name: "Bitcoin",
39911
- label: "BTC",
39912
- slip44: 0
39913
- }, {
39914
- name: "Regtest",
39915
- label: "REGTEST",
39916
- slip44: 1
39917
- }, {
39918
- name: "Testnet",
39919
- label: "TEST",
39920
- slip44: 1
39921
- }, {
39922
- name: "Actinium",
39923
- label: "ACM",
39924
- slip44: 228
39925
- }, {
39926
- name: "Axe",
39927
- label: "AXE",
39928
- slip44: 4242
39929
- }, {
40586
+ class DeviceRecovery extends BaseMethod {
40587
+ init() {
40588
+ this.useDevicePassphraseState = false;
40589
+ validateParams(this.payload, [{
40590
+ name: 'wordCount',
40591
+ type: 'number'
40592
+ }, {
40593
+ name: 'passphraseProtection',
40594
+ type: 'boolean'
40595
+ }, {
40596
+ name: 'pinProtection',
40597
+ type: 'boolean'
40598
+ }, {
40599
+ name: 'language',
40600
+ type: 'string'
40601
+ }, {
40602
+ name: 'label',
40603
+ type: 'string'
40604
+ }, {
40605
+ name: 'enforceWordlist',
40606
+ type: 'boolean'
40607
+ }, {
40608
+ name: 'type',
40609
+ type: 'object'
40610
+ }, {
40611
+ name: 'u2fCounter',
40612
+ type: 'number'
40613
+ }, {
40614
+ name: 'dryRun',
40615
+ type: 'boolean'
40616
+ }]);
40617
+ this.params = {
40618
+ word_count: this.payload.wordCount,
40619
+ passphrase_protection: this.payload.passphraseProtection,
40620
+ pin_protection: this.payload.pinProtection,
40621
+ language: this.payload.language,
40622
+ label: this.payload.label,
40623
+ enforce_wordlist: this.payload.enforceWordlist,
40624
+ type: this.payload.type,
40625
+ u2f_counter: this.payload.u2fCounter || Math.floor(Date.now() / 1000),
40626
+ dry_run: this.payload.dryRun
40627
+ };
40628
+ }
40629
+
40630
+ run() {
40631
+ return dist_awaiter(this, void 0, void 0, function* () {
40632
+ const res = yield this.device.commands.typedCall('RecoveryDevice', 'Success', Object.assign({}, this.params));
40633
+ return Promise.resolve(res.message);
40634
+ });
40635
+ }
40636
+
40637
+ }
40638
+
40639
+ class DeviceReset extends BaseMethod {
40640
+ init() {
40641
+ this.useDevicePassphraseState = false;
40642
+ validateParams(this.payload, [{
40643
+ name: 'displayRandom',
40644
+ type: 'boolean'
40645
+ }, {
40646
+ name: 'strength',
40647
+ type: 'number'
40648
+ }, {
40649
+ name: 'passphraseProtection',
40650
+ type: 'boolean'
40651
+ }, {
40652
+ name: 'pinProtection',
40653
+ type: 'boolean'
40654
+ }, {
40655
+ name: 'language',
40656
+ type: 'string'
40657
+ }, {
40658
+ name: 'label',
40659
+ type: 'string'
40660
+ }, {
40661
+ name: 'u2fCounter',
40662
+ type: 'number'
40663
+ }, {
40664
+ name: 'skipBackup',
40665
+ type: 'boolean'
40666
+ }, {
40667
+ name: 'noBackup',
40668
+ type: 'boolean'
40669
+ }, {
40670
+ name: 'backupType'
40671
+ }]);
40672
+ this.params = {
40673
+ display_random: this.payload.displayRandom,
40674
+ strength: this.payload.strength || 256,
40675
+ passphrase_protection: this.payload.passphraseProtection,
40676
+ pin_protection: this.payload.pinProtection,
40677
+ language: this.payload.language,
40678
+ label: this.payload.label,
40679
+ u2f_counter: this.payload.u2fCounter || Math.floor(Date.now() / 1000),
40680
+ skip_backup: this.payload.skipBackup,
40681
+ no_backup: this.payload.noBackup,
40682
+ backup_type: this.payload.backupType
40683
+ };
40684
+ }
40685
+
40686
+ run() {
40687
+ return dist_awaiter(this, void 0, void 0, function* () {
40688
+ const res = yield this.device.commands.typedCall('ResetDevice', 'Success', Object.assign({}, this.params));
40689
+ return Promise.resolve(res.message);
40690
+ });
40691
+ }
40692
+
40693
+ }
40694
+
40695
+ class DeviceSettings extends BaseMethod {
40696
+ init() {
40697
+ this.useDevicePassphraseState = false;
40698
+ validateParams(this.payload, [{
40699
+ name: 'language',
40700
+ type: 'string'
40701
+ }, {
40702
+ name: 'label',
40703
+ type: 'string'
40704
+ }, {
40705
+ name: 'usePassphrase',
40706
+ type: 'boolean'
40707
+ }, {
40708
+ name: 'homescreen',
40709
+ type: 'string'
40710
+ }, {
40711
+ name: 'passphraseSource',
40712
+ type: 'number'
40713
+ }, {
40714
+ name: 'autoLockDelayMs',
40715
+ type: 'number'
40716
+ }, {
40717
+ name: 'displayRotation',
40718
+ type: 'number'
40719
+ }, {
40720
+ name: 'passphraseAlwaysOnDevice',
40721
+ type: 'boolean'
40722
+ }, {
40723
+ name: 'safetyChecks',
40724
+ type: 'number'
40725
+ }, {
40726
+ name: 'experimentalFeatures',
40727
+ type: 'boolean'
40728
+ }]);
40729
+ this.params = {
40730
+ language: this.payload.language,
40731
+ label: this.payload.label,
40732
+ use_passphrase: this.payload.usePassphrase,
40733
+ homescreen: this.payload.homescreen,
40734
+ _passphrase_source: this.payload.passphraseSource,
40735
+ auto_lock_delay_ms: this.payload.autoLockDelayMs,
40736
+ display_rotation: this.payload.displayRotation,
40737
+ passphrase_always_on_device: this.payload.passphraseAlwaysOnDevice,
40738
+ safety_checks: this.payload.safetyChecks,
40739
+ experimental_features: this.payload.experimentalFeatures
40740
+ };
40741
+ }
40742
+
40743
+ getVersionRange() {
40744
+ if (this.payload.usePassphrase) {
40745
+ return {
40746
+ model_mini: {
40747
+ min: '2.4.0'
40748
+ }
40749
+ };
40750
+ }
40751
+
40752
+ return {};
40753
+ }
40754
+
40755
+ run() {
40756
+ return dist_awaiter(this, void 0, void 0, function* () {
40757
+ const res = yield this.device.commands.typedCall('ApplySettings', 'Success', Object.assign({}, this.params));
40758
+ return Promise.resolve(res.message);
40759
+ });
40760
+ }
40761
+
40762
+ }
40763
+
40764
+ class DeviceUpdateReboot extends BaseMethod {
40765
+ init() {
40766
+ this.useDevicePassphraseState = false;
40767
+ }
40768
+
40769
+ run() {
40770
+ return dist_awaiter(this, void 0, void 0, function* () {
40771
+ const res = yield this.device.commands.typedCall('BixinReboot', 'Success');
40772
+ return Promise.resolve(res.message);
40773
+ });
40774
+ }
40775
+
40776
+ }
40777
+
40778
+ class DeviceSupportFeatures extends BaseMethod {
40779
+ init() {
40780
+ this.useDevicePassphraseState = false;
40781
+ }
40782
+
40783
+ run() {
40784
+ if (!this.device.features) return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Device not initialized'));
40785
+ const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
40786
+ return Promise.resolve({
40787
+ inputPinOnSoftware,
40788
+ device: this.device.toMessageObject()
40789
+ });
40790
+ }
40791
+
40792
+ }
40793
+
40794
+ class DeviceVerify extends BaseMethod {
40795
+ init() {
40796
+ this.useDevicePassphraseState = false;
40797
+ validateParams(this.payload, [{
40798
+ name: 'dataHex',
40799
+ type: 'hexString'
40800
+ }]);
40801
+ this.params = {
40802
+ data: formatAnyHex(this.payload.dataHex)
40803
+ };
40804
+ }
40805
+
40806
+ run() {
40807
+ return dist_awaiter(this, void 0, void 0, function* () {
40808
+ const deviceType = getDeviceType(this.device.features);
40809
+ let response;
40810
+
40811
+ if (deviceType === 'classic') {
40812
+ const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign(Object.assign({}, this.params), {
40813
+ data: sha256_default().sha256(this.params.data)
40814
+ }));
40815
+ response = res.message;
40816
+ } else {
40817
+ const signatureRes = yield this.device.commands.typedCall('SESignMessage', 'SEMessageSignature', {
40818
+ message: this.params.data
40819
+ });
40820
+ const certRes = yield this.device.commands.typedCall('ReadSEPublicCert', 'SEPublicCert');
40821
+ response = {
40822
+ cert: certRes.message.public_cert,
40823
+ signature: signatureRes.message.signature
40824
+ };
40825
+ }
40826
+
40827
+ if (response) return Promise.resolve(response);
40828
+ return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Device not support verify'));
40829
+ });
40830
+ }
40831
+
40832
+ }
40833
+
40834
+ class DeviceWipe extends BaseMethod {
40835
+ init() {
40836
+ this.useDevicePassphraseState = false;
40837
+ }
40838
+
40839
+ run() {
40840
+ return dist_awaiter(this, void 0, void 0, function* () {
40841
+ const res = yield this.device.commands.typedCall('WipeDevice', 'Success');
40842
+ return Promise.resolve(res.message);
40843
+ });
40844
+ }
40845
+
40846
+ }
40847
+
40848
+ const getBinary = ({
40849
+ features,
40850
+ updateType,
40851
+ version
40852
+ }) => dist_awaiter(void 0, void 0, void 0, function* () {
40853
+ const releaseInfo = getInfo({
40854
+ features,
40855
+ updateType
40856
+ });
40857
+
40858
+ if (!releaseInfo) {
40859
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'no firmware found for this device');
40860
+ }
40861
+
40862
+ if (version && !semver_default().eq(releaseInfo.version, version)) {
40863
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'firmware version mismatch');
40864
+ }
40865
+
40866
+ const url = updateType === 'ble' ? releaseInfo.webUpdate : releaseInfo.url;
40867
+ let fw;
40868
+
40869
+ try {
40870
+ fw = yield httpRequest(url, 'binary');
40871
+ } catch (_a) {
40872
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Method_FirmwareUpdate_DownloadFailed');
40873
+ }
40874
+
40875
+ return Object.assign(Object.assign({}, releaseInfo), {
40876
+ binary: fw
40877
+ });
40878
+ });
40879
+
40880
+ const getInfo = ({
40881
+ features,
40882
+ updateType
40883
+ }) => {
40884
+ var _a, _b, _c;
40885
+
40886
+ const deviceType = getDeviceType(features);
40887
+ const {
40888
+ deviceMap
40889
+ } = DataManager;
40890
+ const releaseInfo = (_c = (_b = (_a = deviceMap === null || deviceMap === void 0 ? void 0 : deviceMap[deviceType]) === null || _a === void 0 ? void 0 : _a[updateType]) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : null;
40891
+ return releaseInfo;
40892
+ };
40893
+
40894
+ const postConfirmationMessage = device => {
40895
+ var _a;
40896
+
40897
+ if ((_a = device.features) === null || _a === void 0 ? void 0 : _a.firmware_present) {
40898
+ device.emit(DEVICE.BUTTON, device, {
40899
+ code: 'ButtonRequest_FirmwareUpdate'
40900
+ });
40901
+ }
40902
+ };
40903
+
40904
+ const postProgressMessage = (device, progress, postMessage) => {
40905
+ postMessage(createUiMessage(UI_REQUEST$1.FIRMWARE_PROGRESS, {
40906
+ device: device.toMessageObject(),
40907
+ progress
40908
+ }));
40909
+ };
40910
+
40911
+ const uploadFirmware = (updateType, typedCall, postMessage, device, {
40912
+ payload
40913
+ }) => dist_awaiter(void 0, void 0, void 0, function* () {
40914
+ var _a, _b;
40915
+
40916
+ if (((_a = device.features) === null || _a === void 0 ? void 0 : _a.major_version) === 1) {
40917
+ postConfirmationMessage(device);
40918
+ const eraseCommand = updateType === 'firmware' ? 'FirmwareErase' : 'FirmwareErase_ex';
40919
+ yield typedCall(eraseCommand, 'Success', {});
40920
+ postProgressMessage(device, 0, postMessage);
40921
+ const {
40922
+ message
40923
+ } = yield typedCall('FirmwareUpload', 'Success', {
40924
+ payload
40925
+ });
40926
+ postProgressMessage(device, 100, postMessage);
40927
+ return message;
40928
+ }
40929
+
40930
+ if (((_b = device.features) === null || _b === void 0 ? void 0 : _b.major_version) === 2) {
40931
+ postConfirmationMessage(device);
40932
+ const length = payload.byteLength;
40933
+ let response = yield typedCall('FirmwareErase', ['FirmwareRequest', 'Success'], {
40934
+ length
40935
+ });
40936
+
40937
+ while (response.type !== 'Success') {
40938
+ const start = response.message.offset;
40939
+ const end = response.message.offset + response.message.length;
40940
+ const chunk = payload.slice(start, end);
40941
+
40942
+ if (start > 0) {
40943
+ postProgressMessage(device, Math.round(start / length * 100), postMessage);
40944
+ }
40945
+
40946
+ response = yield typedCall('FirmwareUpload', ['FirmwareRequest', 'Success'], {
40947
+ payload: chunk
40948
+ });
40949
+ }
40950
+
40951
+ postProgressMessage(device, 100, postMessage);
40952
+ return response.message;
40953
+ }
40954
+
40955
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'uploadFirmware: unknown major_version');
40956
+ });
40957
+
40958
+ class FirmwareUpdate extends BaseMethod {
40959
+ init() {
40960
+ this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.INITIALIZE];
40961
+ this.requireDeviceMode = [UI_REQUEST.BOOTLOADER];
40962
+ this.useDevicePassphraseState = false;
40963
+ const {
40964
+ payload
40965
+ } = this;
40966
+ validateParams(payload, [{
40967
+ name: 'version',
40968
+ type: 'array'
40969
+ }, {
40970
+ name: 'binary',
40971
+ type: 'buffer'
40972
+ }]);
40973
+
40974
+ if (!payload.updateType) {
40975
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, 'updateType is required');
40976
+ }
40977
+
40978
+ this.params = {
40979
+ updateType: payload.updateType
40980
+ };
40981
+
40982
+ if ('version' in payload) {
40983
+ this.params = Object.assign(Object.assign({}, this.params), {
40984
+ version: payload.version
40985
+ });
40986
+ }
40987
+
40988
+ if ('binary' in payload) {
40989
+ this.params = Object.assign(Object.assign({}, this.params), {
40990
+ binary: payload.binary
40991
+ });
40992
+ }
40993
+ }
40994
+
40995
+ run() {
40996
+ var _a;
40997
+
40998
+ return dist_awaiter(this, void 0, void 0, function* () {
40999
+ const {
41000
+ device,
41001
+ params
41002
+ } = this;
41003
+ let binary;
41004
+
41005
+ try {
41006
+ if (params.binary) {
41007
+ binary = this.params.binary;
41008
+ } else {
41009
+ if (!device.features) {
41010
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'no features found for this device');
41011
+ }
41012
+
41013
+ const firmware = yield getBinary({
41014
+ features: device.features,
41015
+ version: params.version,
41016
+ updateType: params.updateType
41017
+ });
41018
+ binary = firmware.binary;
41019
+ }
41020
+ } catch (err) {
41021
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.FirmwareUpdateDownloadFailed, (_a = err.message) !== null && _a !== void 0 ? _a : err);
41022
+ }
41023
+
41024
+ return uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, {
41025
+ payload: binary
41026
+ });
41027
+ });
41028
+ }
41029
+
41030
+ }
41031
+
41032
+ const Log$2 = getLogger(LoggerNames.Method);
41033
+
41034
+ class RequestWebUsbDevice extends BaseMethod {
41035
+ init() {
41036
+ this.useDevice = false;
41037
+ this.useDevicePassphraseState = false;
41038
+ }
41039
+
41040
+ run() {
41041
+ var _a, _b;
41042
+
41043
+ return dist_awaiter(this, void 0, void 0, function* () {
41044
+ yield TransportManager.configure();
41045
+ const env = DataManager.getSettings('env');
41046
+
41047
+ if (env !== 'webusb') {
41048
+ return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Not webusb environment'));
41049
+ }
41050
+
41051
+ try {
41052
+ const deviceDiff = yield (_a = this.connector) === null || _a === void 0 ? void 0 : _a.enumerate();
41053
+ const devicesDescriptor = (_b = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _b !== void 0 ? _b : [];
41054
+ const {
41055
+ deviceList
41056
+ } = yield DevicePool.getDevices(devicesDescriptor);
41057
+
41058
+ if (deviceList.length > 0) {
41059
+ return {
41060
+ device: deviceList[0].toMessageObject()
41061
+ };
41062
+ }
41063
+
41064
+ return yield Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
41065
+ } catch (error) {
41066
+ Log$2.debug(error);
41067
+ return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
41068
+ }
41069
+ });
41070
+ }
41071
+
41072
+ }
41073
+
41074
+ class CipherKeyValue extends BaseMethod {
41075
+ constructor() {
41076
+ super(...arguments);
41077
+ this.hasBundle = false;
41078
+ }
41079
+
41080
+ init() {
41081
+ var _a;
41082
+
41083
+ this.checkDeviceId = true;
41084
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
41085
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
41086
+ const payload = this.hasBundle ? this.payload : {
41087
+ bundle: [this.payload]
41088
+ };
41089
+ validateParams(payload, [{
41090
+ name: 'bundle',
41091
+ type: 'array'
41092
+ }]);
41093
+ this.params = [];
41094
+ payload.bundle.forEach(batch => {
41095
+ const addressN = validatePath(batch.path);
41096
+ validateParams(batch, [{
41097
+ name: 'path',
41098
+ required: true
41099
+ }, {
41100
+ name: 'key',
41101
+ type: 'string'
41102
+ }, {
41103
+ name: 'value',
41104
+ type: 'hexString'
41105
+ }, {
41106
+ name: 'encrypt',
41107
+ type: 'boolean'
41108
+ }, {
41109
+ name: 'askOnEncrypt',
41110
+ type: 'boolean'
41111
+ }, {
41112
+ name: 'askOnDecrypt',
41113
+ type: 'boolean'
41114
+ }, {
41115
+ name: 'iv',
41116
+ type: 'hexString'
41117
+ }]);
41118
+ this.params.push({
41119
+ address_n: addressN,
41120
+ key: batch.key,
41121
+ value: formatAnyHex(batch.value),
41122
+ encrypt: batch.encrypt,
41123
+ ask_on_encrypt: batch.askOnEncrypt,
41124
+ ask_on_decrypt: batch.askOnDecrypt,
41125
+ iv: formatAnyHex(batch.iv)
41126
+ });
41127
+ });
41128
+ }
41129
+
41130
+ run() {
41131
+ return dist_awaiter(this, void 0, void 0, function* () {
41132
+ const responses = [];
41133
+
41134
+ for (let i = 0; i < this.params.length; i++) {
41135
+ const param = this.params[i];
41136
+ const res = yield this.device.commands.typedCall('CipherKeyValue', 'CipheredKeyValue', Object.assign({}, param));
41137
+ responses.push(Object.assign({
41138
+ path: serializedPath(param.address_n)
41139
+ }, res.message));
41140
+ }
41141
+
41142
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
41143
+ });
41144
+ }
41145
+
41146
+ }
41147
+
41148
+ var bitcoin = [{
41149
+ name: "Bitcoin",
41150
+ label: "BTC",
41151
+ slip44: 0
41152
+ }, {
41153
+ name: "Regtest",
41154
+ label: "REGTEST",
41155
+ slip44: 1
41156
+ }, {
41157
+ name: "Testnet",
41158
+ label: "TEST",
41159
+ slip44: 1
41160
+ }, {
41161
+ name: "Actinium",
41162
+ label: "ACM",
41163
+ slip44: 228
41164
+ }, {
41165
+ name: "Axe",
41166
+ label: "AXE",
41167
+ slip44: 4242
41168
+ }, {
39930
41169
  name: "Bitcore",
39931
41170
  label: "BTX",
39932
41171
  slip44: 160
@@ -40870,527 +42109,417 @@ class BTCSignTransaction extends BaseMethod {
40870
42109
  }, {
40871
42110
  name: 'op_return_data',
40872
42111
  type: 'string'
40873
- }, {
40874
- name: 'multisig',
40875
- type: 'object'
40876
- }]);
40877
-
40878
- if (Object.prototype.hasOwnProperty.call(output, 'address_n') && Object.prototype.hasOwnProperty.call(output, 'address')) {
40879
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, 'Cannot use address and address_n in one output');
40880
- }
40881
-
40882
- if (output.address_n) {
40883
- const scriptType = getOutputScriptType(output.address_n);
40884
- if (output.script_type !== scriptType) throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, `Output change script_type should be set to ${scriptType}`);
40885
- }
40886
- });
40887
- const {
40888
- inputs,
40889
- outputs,
40890
- refTxs,
40891
- account,
40892
- coin
40893
- } = this.payload;
40894
- const coinName = getCoinInfo(undefined, coin).name;
40895
- this.params = {
40896
- inputs,
40897
- outputs,
40898
- refTxs,
40899
- addresses: account ? account.addresses : undefined,
40900
- options: {
40901
- lock_time: this.payload.locktime,
40902
- timestamp: this.payload.timestamp,
40903
- version: this.payload.version,
40904
- expiry: this.payload.expiry,
40905
- overwintered: this.payload.overwintered,
40906
- version_group_id: this.payload.versionGroupId,
40907
- branch_id: this.payload.branchId
40908
- },
40909
- coinName
40910
- };
40911
- }
40912
-
40913
- run() {
40914
- return dist_awaiter(this, void 0, void 0, function* () {
40915
- const {
40916
- device,
40917
- params
40918
- } = this;
40919
- const useLegacySignProcess = device.unavailableCapabilities.replaceTransaction;
40920
- const {
40921
- refTxs
40922
- } = params;
40923
- const signTxMethod = !useLegacySignProcess ? signtx : signtxLegacy;
40924
- const response = yield signTxMethod(device.commands.typedCall.bind(device.commands), params.inputs, params.outputs, refTxs, params.options, params.coinName);
40925
- return response;
40926
- });
40927
- }
40928
-
40929
- }
40930
-
40931
- class BTCVerifyMessage extends BaseMethod {
40932
- init() {
40933
- this.checkDeviceId = true;
40934
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
40935
- validateParams(this.payload, [{
40936
- name: 'address',
40937
- type: 'string',
40938
- required: true
40939
- }, {
40940
- name: 'messageHex',
40941
- type: 'hexString',
40942
- required: true
40943
- }, {
40944
- name: 'signature',
40945
- type: 'hexString',
40946
- required: true
40947
- }, {
40948
- name: 'coin',
40949
- type: 'string',
40950
- required: true
40951
- }]);
40952
- const {
40953
- coin
40954
- } = this.payload;
40955
- const {
40956
- address,
40957
- messageHex,
40958
- signature
40959
- } = formatAnyHex(this.payload);
40960
- const coinName = getCoinInfo(undefined, coin).name;
40961
- this.params = {
40962
- address,
40963
- message: messageHex,
40964
- signature,
40965
- coin_name: coinName
40966
- };
40967
- }
40968
-
40969
- run() {
40970
- return dist_awaiter(this, void 0, void 0, function* () {
40971
- const res = yield this.device.commands.typedCall('VerifyMessage', 'Success', Object.assign({}, this.params));
40972
- return Promise.resolve(res.message);
40973
- });
40974
- }
40975
-
40976
- }
40977
-
40978
- class CheckFirmwareRelease extends BaseMethod {
40979
- init() {
40980
- this.useDevicePassphraseState = false;
40981
- }
40982
-
40983
- run() {
40984
- if (this.device.features) {
40985
- const releaseInfo = getFirmwareReleaseInfo(this.device.features);
40986
- return Promise.resolve(releaseInfo);
40987
- }
40988
-
40989
- return Promise.resolve(null);
40990
- }
40991
-
40992
- }
40993
-
40994
- class CheckBLEFirmwareRelease extends BaseMethod {
40995
- init() {
40996
- this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.BOOTLOADER];
40997
- this.checkDeviceId = true;
40998
- this.useDevicePassphraseState = false;
40999
- }
41000
-
41001
- run() {
41002
- if (this.device.features) {
41003
- const releaseInfo = getBleFirmwareReleaseInfo(this.device.features);
41004
- return Promise.resolve(releaseInfo);
41005
- }
41006
-
41007
- return Promise.resolve(null);
41008
- }
41009
-
41010
- }
41011
-
41012
- class CheckTransportRelease extends BaseMethod {
41013
- init() {
41014
- this.useDevice = false;
41015
- this.useDevicePassphraseState = false;
41016
- }
41017
-
41018
- run() {
41019
- return dist_awaiter(this, void 0, void 0, function* () {
41020
- const transport = TransportManager.getTransport();
41021
- const localVersion = yield transport.init();
41022
- const response = DataManager.getTransportStatus(localVersion);
41023
- return Promise.resolve(response);
41024
- });
41025
- }
41026
-
41027
- }
41028
-
41029
- class CheckBridgeStatus$1 extends BaseMethod {
41030
- init() {
41031
- this.useDevice = false;
41032
- this.useDevicePassphraseState = false;
41033
- }
41034
-
41035
- run() {
41036
- return dist_awaiter(this, void 0, void 0, function* () {
41037
- return new Promise((resolve, reject) => {
41038
- axios_default().request({
41039
- url: 'http://localhost:21320',
41040
- method: 'POST',
41041
- withCredentials: false,
41042
- timeout: 3000
41043
- }).then(() => resolve(true)).catch(e => {
41044
- if (e.code === 'ECONNABORTED') {
41045
- reject(HardwareError$1.TypedError(dist_HardwareErrorCode.BridgeTimeoutError));
41046
- } else {
41047
- resolve(false);
41048
- }
41049
- });
41050
- });
41051
- });
41052
- }
41053
-
41054
- }
41055
-
41056
- class DeviceBackup extends BaseMethod {
41057
- init() {
41058
- this.useDevicePassphraseState = false;
41059
- }
41060
-
41061
- run() {
41062
- return dist_awaiter(this, void 0, void 0, function* () {
41063
- const res = yield this.device.commands.typedCall('BackupDevice', 'Success');
41064
- return Promise.resolve(res.message);
41065
- });
41066
- }
42112
+ }, {
42113
+ name: 'multisig',
42114
+ type: 'object'
42115
+ }]);
41067
42116
 
41068
- }
42117
+ if (Object.prototype.hasOwnProperty.call(output, 'address_n') && Object.prototype.hasOwnProperty.call(output, 'address')) {
42118
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, 'Cannot use address and address_n in one output');
42119
+ }
41069
42120
 
41070
- class DeviceChangePin extends BaseMethod {
41071
- init() {
41072
- this.useDevicePassphraseState = false;
41073
- validateParams(this.payload, [{
41074
- name: 'remove',
41075
- type: 'boolean'
41076
- }]);
42121
+ if (output.address_n) {
42122
+ const scriptType = getOutputScriptType(output.address_n);
42123
+ if (output.script_type !== scriptType) throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, `Output change script_type should be set to ${scriptType}`);
42124
+ }
42125
+ });
42126
+ const {
42127
+ inputs,
42128
+ outputs,
42129
+ refTxs,
42130
+ account,
42131
+ coin
42132
+ } = this.payload;
42133
+ const coinName = getCoinInfo(undefined, coin).name;
41077
42134
  this.params = {
41078
- remove: this.payload.remove
42135
+ inputs,
42136
+ outputs,
42137
+ refTxs,
42138
+ addresses: account ? account.addresses : undefined,
42139
+ options: {
42140
+ lock_time: this.payload.locktime,
42141
+ timestamp: this.payload.timestamp,
42142
+ version: this.payload.version,
42143
+ expiry: this.payload.expiry,
42144
+ overwintered: this.payload.overwintered,
42145
+ version_group_id: this.payload.versionGroupId,
42146
+ branch_id: this.payload.branchId
42147
+ },
42148
+ coinName
41079
42149
  };
41080
42150
  }
41081
42151
 
41082
42152
  run() {
41083
42153
  return dist_awaiter(this, void 0, void 0, function* () {
41084
- const res = yield this.device.commands.typedCall('ChangePin', 'Success', Object.assign({}, this.params));
41085
- return Promise.resolve(res.message);
42154
+ const {
42155
+ device,
42156
+ params
42157
+ } = this;
42158
+ const useLegacySignProcess = device.unavailableCapabilities.replaceTransaction;
42159
+ const {
42160
+ refTxs
42161
+ } = params;
42162
+ const signTxMethod = !useLegacySignProcess ? signtx : signtxLegacy;
42163
+ const response = yield signTxMethod(device.commands.typedCall.bind(device.commands), params.inputs, params.outputs, refTxs, params.options, params.coinName);
42164
+ return response;
41086
42165
  });
41087
42166
  }
41088
42167
 
41089
42168
  }
41090
42169
 
41091
- class DeviceFlags extends BaseMethod {
42170
+ class BTCVerifyMessage extends BaseMethod {
41092
42171
  init() {
41093
- this.useDevicePassphraseState = false;
42172
+ this.checkDeviceId = true;
42173
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
41094
42174
  validateParams(this.payload, [{
41095
- name: 'flags',
41096
- type: 'number'
42175
+ name: 'address',
42176
+ type: 'string',
42177
+ required: true
42178
+ }, {
42179
+ name: 'messageHex',
42180
+ type: 'hexString',
42181
+ required: true
42182
+ }, {
42183
+ name: 'signature',
42184
+ type: 'hexString',
42185
+ required: true
42186
+ }, {
42187
+ name: 'coin',
42188
+ type: 'string',
42189
+ required: true
41097
42190
  }]);
42191
+ const {
42192
+ coin
42193
+ } = this.payload;
42194
+ const {
42195
+ address,
42196
+ messageHex,
42197
+ signature
42198
+ } = formatAnyHex(this.payload);
42199
+ const coinName = getCoinInfo(undefined, coin).name;
41098
42200
  this.params = {
41099
- flags: this.payload.flags
42201
+ address,
42202
+ message: messageHex,
42203
+ signature,
42204
+ coin_name: coinName
41100
42205
  };
41101
42206
  }
41102
42207
 
41103
42208
  run() {
41104
42209
  return dist_awaiter(this, void 0, void 0, function* () {
41105
- const res = yield this.device.commands.typedCall('ApplyFlags', 'Success', Object.assign({}, this.params));
42210
+ const res = yield this.device.commands.typedCall('VerifyMessage', 'Success', Object.assign({}, this.params));
41106
42211
  return Promise.resolve(res.message);
41107
42212
  });
41108
42213
  }
41109
42214
 
41110
42215
  }
41111
42216
 
41112
- class DeviceRebootToBootloader extends BaseMethod {
42217
+ class ConfluxGetAddress extends BaseMethod {
42218
+ constructor() {
42219
+ super(...arguments);
42220
+ this.hasBundle = false;
42221
+ }
42222
+
41113
42223
  init() {
41114
- this.useDevicePassphraseState = false;
42224
+ var _a;
42225
+
42226
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
42227
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
42228
+ const payload = this.hasBundle ? this.payload : {
42229
+ bundle: [this.payload]
42230
+ };
42231
+ validateParams(payload, [{
42232
+ name: 'bundle',
42233
+ type: 'array'
42234
+ }]);
42235
+ this.params = [];
42236
+ payload.bundle.forEach(batch => {
42237
+ var _a;
42238
+
42239
+ const addressN = validatePath(batch.path, 3);
42240
+ validateParams(batch, [{
42241
+ name: 'path',
42242
+ required: true
42243
+ }, {
42244
+ name: 'chainId',
42245
+ type: 'number'
42246
+ }, {
42247
+ name: 'showOnOneKey',
42248
+ type: 'boolean'
42249
+ }]);
42250
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
42251
+ this.params.push({
42252
+ address_n: addressN,
42253
+ chain_id: batch.chainId,
42254
+ show_display: showOnOneKey
42255
+ });
42256
+ });
41115
42257
  }
41116
42258
 
41117
42259
  getVersionRange() {
41118
42260
  return {
41119
- classic: {
41120
- min: '2.1.11'
41121
- },
41122
- mini: {
41123
- min: '2.1.11'
42261
+ model_mini: {
42262
+ min: '2.4.0'
41124
42263
  }
41125
42264
  };
41126
42265
  }
41127
42266
 
41128
42267
  run() {
41129
42268
  return dist_awaiter(this, void 0, void 0, function* () {
41130
- const res = yield this.device.commands.typedCall('RebootToBootloader', 'Success');
41131
- return Promise.resolve(res.message);
42269
+ const responses = [];
42270
+
42271
+ for (let i = 0; i < this.params.length; i++) {
42272
+ const param = this.params[i];
42273
+ const res = yield this.device.commands.typedCall('ConfluxGetAddress', 'ConfluxAddress', Object.assign({}, param));
42274
+ responses.push(Object.assign({
42275
+ path: serializedPath(param.address_n)
42276
+ }, res.message));
42277
+ }
42278
+
42279
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
41132
42280
  });
41133
42281
  }
41134
42282
 
41135
42283
  }
41136
42284
 
41137
- class DeviceRecovery extends BaseMethod {
42285
+ class ConfluxSignMessage extends BaseMethod {
41138
42286
  init() {
41139
- this.useDevicePassphraseState = false;
42287
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
41140
42288
  validateParams(this.payload, [{
41141
- name: 'wordCount',
41142
- type: 'number'
41143
- }, {
41144
- name: 'passphraseProtection',
41145
- type: 'boolean'
41146
- }, {
41147
- name: 'pinProtection',
41148
- type: 'boolean'
41149
- }, {
41150
- name: 'language',
41151
- type: 'string'
41152
- }, {
41153
- name: 'label',
41154
- type: 'string'
41155
- }, {
41156
- name: 'enforceWordlist',
41157
- type: 'boolean'
41158
- }, {
41159
- name: 'type',
41160
- type: 'object'
41161
- }, {
41162
- name: 'u2fCounter',
41163
- type: 'number'
42289
+ name: 'path',
42290
+ required: true
41164
42291
  }, {
41165
- name: 'dryRun',
41166
- type: 'boolean'
42292
+ name: 'messageHex',
42293
+ type: 'hexString',
42294
+ required: true
41167
42295
  }]);
42296
+ const {
42297
+ path,
42298
+ messageHex
42299
+ } = this.payload;
42300
+ const addressN = validatePath(path, 3);
41168
42301
  this.params = {
41169
- word_count: this.payload.wordCount,
41170
- passphrase_protection: this.payload.passphraseProtection,
41171
- pin_protection: this.payload.pinProtection,
41172
- language: this.payload.language,
41173
- label: this.payload.label,
41174
- enforce_wordlist: this.payload.enforceWordlist,
41175
- type: this.payload.type,
41176
- u2f_counter: this.payload.u2fCounter || Math.floor(Date.now() / 1000),
41177
- dry_run: this.payload.dryRun
42302
+ address_n: addressN,
42303
+ message: formatAnyHex(messageHex)
41178
42304
  };
41179
42305
  }
41180
42306
 
41181
- run() {
41182
- return dist_awaiter(this, void 0, void 0, function* () {
41183
- const res = yield this.device.commands.typedCall('RecoveryDevice', 'Success', Object.assign({}, this.params));
41184
- return Promise.resolve(res.message);
41185
- });
41186
- }
41187
-
41188
- }
41189
-
41190
- class DeviceReset extends BaseMethod {
41191
- init() {
41192
- this.useDevicePassphraseState = false;
41193
- validateParams(this.payload, [{
41194
- name: 'displayRandom',
41195
- type: 'boolean'
41196
- }, {
41197
- name: 'strength',
41198
- type: 'number'
41199
- }, {
41200
- name: 'passphraseProtection',
41201
- type: 'boolean'
41202
- }, {
41203
- name: 'pinProtection',
41204
- type: 'boolean'
41205
- }, {
41206
- name: 'language',
41207
- type: 'string'
41208
- }, {
41209
- name: 'label',
41210
- type: 'string'
41211
- }, {
41212
- name: 'u2fCounter',
41213
- type: 'number'
41214
- }, {
41215
- name: 'skipBackup',
41216
- type: 'boolean'
41217
- }, {
41218
- name: 'noBackup',
41219
- type: 'boolean'
41220
- }, {
41221
- name: 'backupType'
41222
- }]);
41223
- this.params = {
41224
- display_random: this.payload.displayRandom,
41225
- strength: this.payload.strength || 256,
41226
- passphrase_protection: this.payload.passphraseProtection,
41227
- pin_protection: this.payload.pinProtection,
41228
- language: this.payload.language,
41229
- label: this.payload.label,
41230
- u2f_counter: this.payload.u2fCounter || Math.floor(Date.now() / 1000),
41231
- skip_backup: this.payload.skipBackup,
41232
- no_backup: this.payload.noBackup,
41233
- backup_type: this.payload.backupType
42307
+ getVersionRange() {
42308
+ return {
42309
+ model_mini: {
42310
+ min: '2.4.0'
42311
+ }
41234
42312
  };
41235
42313
  }
41236
42314
 
41237
42315
  run() {
41238
42316
  return dist_awaiter(this, void 0, void 0, function* () {
41239
- const res = yield this.device.commands.typedCall('ResetDevice', 'Success', Object.assign({}, this.params));
42317
+ const res = yield this.device.commands.typedCall('ConfluxSignMessage', 'ConfluxMessageSignature', Object.assign({}, this.params));
41240
42318
  return Promise.resolve(res.message);
41241
42319
  });
41242
42320
  }
41243
42321
 
41244
42322
  }
41245
42323
 
41246
- class DeviceSettings extends BaseMethod {
42324
+ class ConfluxSignMessageCIP23 extends BaseMethod {
41247
42325
  init() {
41248
- this.useDevicePassphraseState = false;
42326
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
41249
42327
  validateParams(this.payload, [{
41250
- name: 'language',
41251
- type: 'string'
41252
- }, {
41253
- name: 'label',
41254
- type: 'string'
41255
- }, {
41256
- name: 'usePassphrase',
41257
- type: 'boolean'
41258
- }, {
41259
- name: 'homescreen',
41260
- type: 'string'
41261
- }, {
41262
- name: 'passphraseSource',
41263
- type: 'number'
41264
- }, {
41265
- name: 'autoLockDelayMs',
41266
- type: 'number'
41267
- }, {
41268
- name: 'displayRotation',
41269
- type: 'number'
41270
- }, {
41271
- name: 'passphraseAlwaysOnDevice',
41272
- type: 'boolean'
42328
+ name: 'path',
42329
+ required: true
41273
42330
  }, {
41274
- name: 'safetyChecks',
41275
- type: 'number'
42331
+ name: 'domainHash',
42332
+ type: 'hexString',
42333
+ required: true
41276
42334
  }, {
41277
- name: 'experimentalFeatures',
41278
- type: 'boolean'
42335
+ name: 'messageHash',
42336
+ type: 'hexString',
42337
+ required: true
41279
42338
  }]);
42339
+ const {
42340
+ path,
42341
+ domainHash,
42342
+ messageHash
42343
+ } = this.payload;
42344
+ const addressN = validatePath(path, 3);
41280
42345
  this.params = {
41281
- language: this.payload.language,
41282
- label: this.payload.label,
41283
- use_passphrase: this.payload.usePassphrase,
41284
- homescreen: this.payload.homescreen,
41285
- _passphrase_source: this.payload.passphraseSource,
41286
- auto_lock_delay_ms: this.payload.autoLockDelayMs,
41287
- display_rotation: this.payload.displayRotation,
41288
- passphrase_always_on_device: this.payload.passphraseAlwaysOnDevice,
41289
- safety_checks: this.payload.safetyChecks,
41290
- experimental_features: this.payload.experimentalFeatures
42346
+ address_n: addressN,
42347
+ domain_hash: formatAnyHex(domainHash),
42348
+ message_hash: formatAnyHex(messageHash)
41291
42349
  };
41292
42350
  }
41293
42351
 
41294
42352
  getVersionRange() {
41295
- if (this.payload.usePassphrase) {
41296
- return {
41297
- model_mini: {
41298
- min: '2.4.0'
41299
- }
41300
- };
41301
- }
41302
-
41303
- return {};
42353
+ return {
42354
+ model_mini: {
42355
+ min: '2.4.0'
42356
+ }
42357
+ };
41304
42358
  }
41305
42359
 
41306
42360
  run() {
41307
42361
  return dist_awaiter(this, void 0, void 0, function* () {
41308
- const res = yield this.device.commands.typedCall('ApplySettings', 'Success', Object.assign({}, this.params));
42362
+ const res = yield this.device.commands.typedCall('ConfluxSignMessageCIP23', 'ConfluxMessageSignature', Object.assign({}, this.params));
41309
42363
  return Promise.resolve(res.message);
41310
42364
  });
41311
42365
  }
41312
42366
 
41313
42367
  }
41314
42368
 
41315
- class DeviceUpdateReboot extends BaseMethod {
41316
- init() {
41317
- this.useDevicePassphraseState = false;
42369
+ const cutString = (str, cutLen) => {
42370
+ if (!str) {
42371
+ return ['', ''];
41318
42372
  }
41319
42373
 
41320
- run() {
41321
- return dist_awaiter(this, void 0, void 0, function* () {
41322
- const res = yield this.device.commands.typedCall('BixinReboot', 'Success');
41323
- return Promise.resolve(res.message);
41324
- });
41325
- }
42374
+ const first = str.slice(0, cutLen);
42375
+ const second = str.slice(cutLen);
42376
+ return [first, second];
42377
+ };
41326
42378
 
41327
- }
42379
+ class ConfluxSignTransaction extends BaseMethod {
42380
+ constructor() {
42381
+ super(...arguments);
42382
+ this.addressN = [];
41328
42383
 
41329
- class DeviceSupportFeatures extends BaseMethod {
41330
- init() {
41331
- this.useDevicePassphraseState = false;
41332
- }
42384
+ this.processTxRequest = (request, data) => dist_awaiter(this, void 0, void 0, function* () {
42385
+ if (!request.data_length) {
42386
+ const v = request.signature_v;
42387
+ const r = request.signature_r;
42388
+ const s = request.signature_s;
41333
42389
 
41334
- run() {
41335
- if (!this.device.features) return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Device not initialized'));
41336
- const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
41337
- return Promise.resolve({
41338
- inputPinOnSoftware,
41339
- device: this.device.toMessageObject()
41340
- });
41341
- }
42390
+ if (v == null || r == null || s == null) {
42391
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodError, 'sign transaction failed');
42392
+ }
41342
42393
 
41343
- }
42394
+ return Promise.resolve({
42395
+ v: `0x${v.toString(16)}`,
42396
+ r: `0x${r}`,
42397
+ s: `0x${s}`
42398
+ });
42399
+ }
41344
42400
 
41345
- class DeviceVerify extends BaseMethod {
41346
- init() {
41347
- this.useDevicePassphraseState = false;
41348
- validateParams(this.payload, [{
41349
- name: 'dataHex',
41350
- type: 'hexString'
41351
- }]);
41352
- this.params = {
41353
- data: formatAnyHex(this.payload.dataHex)
41354
- };
41355
- }
42401
+ const [first, rest] = cutString(data, request.data_length * 2);
42402
+ const response = yield this.device.commands.typedCall('ConfluxTxAck', 'ConfluxTxRequest', {
42403
+ data_chunk: first
42404
+ });
42405
+ return this.processTxRequest(response.message, rest);
42406
+ });
41356
42407
 
41357
- run() {
41358
- return dist_awaiter(this, void 0, void 0, function* () {
41359
- const deviceType = getDeviceType(this.device.features);
41360
- let response;
42408
+ this.evmSignTx = (addressN, tx) => dist_awaiter(this, void 0, void 0, function* () {
42409
+ const {
42410
+ to,
42411
+ value,
42412
+ gasPrice,
42413
+ gasLimit,
42414
+ nonce,
42415
+ data,
42416
+ chainId,
42417
+ epochHeight,
42418
+ storageLimit
42419
+ } = tx;
42420
+ const length = data == null ? 0 : data.length / 2;
42421
+ const [first, rest] = cutString(data, 1024 * 2);
42422
+ let message = {
42423
+ address_n: addressN,
42424
+ nonce: stripHexStartZeroes(nonce),
42425
+ gas_price: stripHexStartZeroes(gasPrice),
42426
+ gas_limit: stripHexStartZeroes(gasLimit),
42427
+ to,
42428
+ value: stripHexStartZeroes(value),
42429
+ epoch_height: stripHexStartZeroes(epochHeight),
42430
+ storage_limit: stripHexStartZeroes(storageLimit),
42431
+ chain_id: chainId
42432
+ };
41361
42433
 
41362
- if (deviceType === 'classic') {
41363
- const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign(Object.assign({}, this.params), {
41364
- data: sha256_default().sha256(this.params.data)
41365
- }));
41366
- response = res.message;
41367
- } else {
41368
- const signatureRes = yield this.device.commands.typedCall('SESignMessage', 'SEMessageSignature', {
41369
- message: this.params.data
42434
+ if (length !== 0) {
42435
+ message = Object.assign(Object.assign({}, message), {
42436
+ data_length: length,
42437
+ data_initial_chunk: first
41370
42438
  });
41371
- const certRes = yield this.device.commands.typedCall('ReadSEPublicCert', 'SEPublicCert');
41372
- response = {
41373
- cert: certRes.message.public_cert,
41374
- signature: signatureRes.message.signature
41375
- };
41376
42439
  }
41377
42440
 
41378
- if (response) return Promise.resolve(response);
41379
- return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Device not support verify'));
42441
+ const response = yield this.device.commands.typedCall('ConfluxSignTx', 'ConfluxTxRequest', message);
42442
+ return this.processTxRequest(response.message, rest);
41380
42443
  });
41381
42444
  }
41382
42445
 
41383
- }
41384
-
41385
- class DeviceWipe extends BaseMethod {
41386
42446
  init() {
41387
- this.useDevicePassphraseState = false;
42447
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
42448
+ validateParams(this.payload, [{
42449
+ name: 'path',
42450
+ required: true
42451
+ }, {
42452
+ name: 'transaction',
42453
+ type: 'object',
42454
+ required: true
42455
+ }]);
42456
+ const {
42457
+ path,
42458
+ transaction
42459
+ } = this.payload;
42460
+ this.addressN = validatePath(path, 3);
42461
+ const tx = transaction;
42462
+ const schema = [{
42463
+ name: 'to',
42464
+ type: 'hexString',
42465
+ required: true
42466
+ }, {
42467
+ name: 'value',
42468
+ type: 'hexString',
42469
+ required: true
42470
+ }, {
42471
+ name: 'gasLimit',
42472
+ type: 'hexString',
42473
+ required: true
42474
+ }, {
42475
+ name: 'gasPrice',
42476
+ type: 'hexString',
42477
+ required: true
42478
+ }, {
42479
+ name: 'nonce',
42480
+ type: 'hexString',
42481
+ required: true
42482
+ }, {
42483
+ name: 'epochHeight',
42484
+ type: 'hexString',
42485
+ required: true
42486
+ }, {
42487
+ name: 'storageLimit',
42488
+ type: 'hexString',
42489
+ required: true
42490
+ }, {
42491
+ name: 'chainId',
42492
+ type: 'number',
42493
+ required: true
42494
+ }, {
42495
+ name: 'data',
42496
+ type: 'hexString'
42497
+ }];
42498
+ validateParams(tx, schema);
42499
+ this.formattedTx = formatAnyHex(tx);
42500
+ }
42501
+
42502
+ getVersionRange() {
42503
+ return {
42504
+ model_mini: {
42505
+ min: '2.4.0'
42506
+ }
42507
+ };
41388
42508
  }
41389
42509
 
41390
42510
  run() {
41391
42511
  return dist_awaiter(this, void 0, void 0, function* () {
41392
- const res = yield this.device.commands.typedCall('WipeDevice', 'Success');
41393
- return Promise.resolve(res.message);
42512
+ const {
42513
+ addressN,
42514
+ formattedTx
42515
+ } = this;
42516
+
42517
+ if (formattedTx == null) {
42518
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, 'ConfluxSignTransaction: format tx error');
42519
+ }
42520
+
42521
+ const signedTx = yield this.evmSignTx(addressN, formattedTx);
42522
+ return Promise.resolve(signedTx);
41394
42523
  });
41395
42524
  }
41396
42525
 
@@ -41587,20 +42716,10 @@ class EVMSignMessageEIP712 extends BaseMethod {
41587
42716
  return dist_awaiter(this, void 0, void 0, function* () {
41588
42717
  const res = yield this.device.commands.typedCall('EthereumSignMessageEIP712', 'EthereumMessageSignature', Object.assign({}, this.params));
41589
42718
  return Promise.resolve(res.message);
41590
- });
41591
- }
41592
-
41593
- }
41594
-
41595
- const cutString = (str, cutLen) => {
41596
- if (!str) {
41597
- return ['', ''];
42719
+ });
41598
42720
  }
41599
42721
 
41600
- const first = str.slice(0, cutLen);
41601
- const second = str.slice(cutLen);
41602
- return [first, second];
41603
- };
42722
+ }
41604
42723
 
41605
42724
  class EVMSignTransaction extends BaseMethod {
41606
42725
  constructor() {
@@ -43113,25 +44232,28 @@ class StellarSignTransaction extends BaseMethod {
43113
44232
  type: 'object',
43114
44233
  required: true
43115
44234
  }]);
43116
- const addressN = validatePath(this.payload.path, 3);
43117
44235
  const {
43118
44236
  transaction,
43119
44237
  networkPassphrase
43120
44238
  } = this.payload;
44239
+
44240
+ if (!transaction.timebounds) {
44241
+ throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, 'timebounds is required');
44242
+ }
44243
+
44244
+ const addressN = validatePath(this.payload.path, 3);
43121
44245
  this.params = {
43122
44246
  address_n: addressN,
43123
44247
  network_passphrase: networkPassphrase,
43124
44248
  source_account: transaction.source,
43125
44249
  fee: transaction.fee,
43126
44250
  sequence_number: transaction.sequence,
43127
- num_operations: transaction.operations.length
44251
+ num_operations: transaction.operations.length,
44252
+ memo_type: StellarMemoType.NONE,
44253
+ timebounds_start: transaction.timebounds.minTime,
44254
+ timebounds_end: transaction.timebounds.maxTime
43128
44255
  };
43129
44256
 
43130
- if (transaction.timebounds) {
43131
- this.params.timebounds_start = transaction.timebounds.minTime;
43132
- this.params.timebounds_end = transaction.timebounds.maxTime;
43133
- }
43134
-
43135
44257
  if (transaction.memo) {
43136
44258
  this.params.memo_type = transaction.memo.type;
43137
44259
  this.params.memo_text = transaction.memo.text;
@@ -43159,277 +44281,416 @@ class StellarSignTransaction extends BaseMethod {
43159
44281
 
43160
44282
  }
43161
44283
 
43162
- const getBinary = ({
43163
- features,
43164
- updateType,
43165
- version
43166
- }) => dist_awaiter(void 0, void 0, void 0, function* () {
43167
- const releaseInfo = getInfo({
43168
- features,
43169
- updateType
43170
- });
43171
-
43172
- if (!releaseInfo) {
43173
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'no firmware found for this device');
44284
+ class TronGetAddress extends BaseMethod {
44285
+ constructor() {
44286
+ super(...arguments);
44287
+ this.hasBundle = false;
43174
44288
  }
43175
44289
 
43176
- if (version && !semver_default().eq(releaseInfo.version, version)) {
43177
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'firmware version mismatch');
43178
- }
44290
+ init() {
44291
+ var _a;
43179
44292
 
43180
- const url = updateType === 'ble' ? releaseInfo.webUpdate : releaseInfo.url;
43181
- let fw;
44293
+ this.checkDeviceId = true;
44294
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
44295
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
44296
+ const payload = this.hasBundle ? this.payload : {
44297
+ bundle: [this.payload]
44298
+ };
44299
+ validateParams(payload, [{
44300
+ name: 'bundle',
44301
+ type: 'array'
44302
+ }]);
44303
+ this.params = [];
44304
+ payload.bundle.forEach(batch => {
44305
+ var _a;
43182
44306
 
43183
- try {
43184
- fw = yield httpRequest(url, 'binary');
43185
- } catch (_a) {
43186
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Method_FirmwareUpdate_DownloadFailed');
44307
+ const addressN = validatePath(batch.path, 3);
44308
+ validateParams(batch, [{
44309
+ name: 'path',
44310
+ required: true
44311
+ }, {
44312
+ name: 'showOnOneKey',
44313
+ type: 'boolean'
44314
+ }]);
44315
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
44316
+ this.params.push({
44317
+ address_n: addressN,
44318
+ show_display: showOnOneKey
44319
+ });
44320
+ });
43187
44321
  }
43188
44322
 
43189
- return Object.assign(Object.assign({}, releaseInfo), {
43190
- binary: fw
43191
- });
43192
- });
43193
-
43194
- const getInfo = ({
43195
- features,
43196
- updateType
43197
- }) => {
43198
- var _a, _b, _c;
44323
+ getVersionRange() {
44324
+ return {
44325
+ model_mini: {
44326
+ min: '2.4.0'
44327
+ }
44328
+ };
44329
+ }
43199
44330
 
43200
- const deviceType = getDeviceType(features);
43201
- const {
43202
- deviceMap
43203
- } = DataManager;
43204
- const releaseInfo = (_c = (_b = (_a = deviceMap === null || deviceMap === void 0 ? void 0 : deviceMap[deviceType]) === null || _a === void 0 ? void 0 : _a[updateType]) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : null;
43205
- return releaseInfo;
43206
- };
44331
+ run() {
44332
+ return dist_awaiter(this, void 0, void 0, function* () {
44333
+ const responses = [];
43207
44334
 
43208
- const postConfirmationMessage = device => {
43209
- var _a;
44335
+ for (let i = 0; i < this.params.length; i++) {
44336
+ const param = this.params[i];
44337
+ const res = yield this.device.commands.typedCall('TronGetAddress', 'TronAddress', Object.assign({}, param));
44338
+ const {
44339
+ address
44340
+ } = res.message;
44341
+ responses.push({
44342
+ path: serializedPath(param.address_n),
44343
+ address
44344
+ });
44345
+ }
43210
44346
 
43211
- if ((_a = device.features) === null || _a === void 0 ? void 0 : _a.firmware_present) {
43212
- device.emit(DEVICE.BUTTON, device, {
43213
- code: 'ButtonRequest_FirmwareUpdate'
44347
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
43214
44348
  });
43215
44349
  }
43216
- };
43217
-
43218
- const postProgressMessage = (device, progress, postMessage) => {
43219
- postMessage(createUiMessage(UI_REQUEST$1.FIRMWARE_PROGRESS, {
43220
- device: device.toMessageObject(),
43221
- progress
43222
- }));
43223
- };
43224
44350
 
43225
- const uploadFirmware = (updateType, typedCall, postMessage, device, {
43226
- payload
43227
- }) => dist_awaiter(void 0, void 0, void 0, function* () {
43228
- var _a, _b;
44351
+ }
43229
44352
 
43230
- if (((_a = device.features) === null || _a === void 0 ? void 0 : _a.major_version) === 1) {
43231
- postConfirmationMessage(device);
43232
- const eraseCommand = updateType === 'firmware' ? 'FirmwareErase' : 'FirmwareErase_ex';
43233
- yield typedCall(eraseCommand, 'Success', {});
43234
- postProgressMessage(device, 0, postMessage);
44353
+ class TronSignMessage extends BaseMethod {
44354
+ init() {
44355
+ this.checkDeviceId = true;
44356
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
44357
+ validateParams(this.payload, [{
44358
+ name: 'path',
44359
+ required: true
44360
+ }, {
44361
+ name: 'messageHex',
44362
+ type: 'hexString',
44363
+ required: true
44364
+ }]);
43235
44365
  const {
43236
- message
43237
- } = yield typedCall('FirmwareUpload', 'Success', {
43238
- payload
43239
- });
43240
- postProgressMessage(device, 100, postMessage);
43241
- return message;
44366
+ path,
44367
+ messageHex
44368
+ } = this.payload;
44369
+ const addressN = validatePath(path, 3);
44370
+ this.params = {
44371
+ address_n: addressN,
44372
+ message: stripHexPrefix(messageHex)
44373
+ };
43242
44374
  }
43243
44375
 
43244
- if (((_b = device.features) === null || _b === void 0 ? void 0 : _b.major_version) === 2) {
43245
- postConfirmationMessage(device);
43246
- const length = payload.byteLength;
43247
- let response = yield typedCall('FirmwareErase', ['FirmwareRequest', 'Success'], {
43248
- length
44376
+ getVersionRange() {
44377
+ return {
44378
+ model_mini: {
44379
+ min: '2.4.0'
44380
+ }
44381
+ };
44382
+ }
44383
+
44384
+ run() {
44385
+ return dist_awaiter(this, void 0, void 0, function* () {
44386
+ const response = yield this.device.commands.typedCall('TronSignMessage', 'TronMessageSignature', Object.assign({}, this.params));
44387
+ return Promise.resolve(response.message);
43249
44388
  });
44389
+ }
43250
44390
 
43251
- while (response.type !== 'Success') {
43252
- const start = response.message.offset;
43253
- const end = response.message.offset + response.message.length;
43254
- const chunk = payload.slice(start, end);
44391
+ }
43255
44392
 
43256
- if (start > 0) {
43257
- postProgressMessage(device, Math.round(start / length * 100), postMessage);
44393
+ class TronSignTransaction extends BaseMethod {
44394
+ parseTx(tx, address_n) {
44395
+ const unSignTx = {
44396
+ address_n,
44397
+ data: tx.data,
44398
+ timestamp: tx.timestamp,
44399
+ fee_limit: tx.feeLimit,
44400
+ ref_block_bytes: tx.refBlockBytes,
44401
+ ref_block_hash: tx.refBlockHash,
44402
+ expiration: tx.expiration,
44403
+ contract: {}
44404
+ };
44405
+
44406
+ if (tx.contract) {
44407
+ if (tx.contract.transferContract) {
44408
+ unSignTx.contract = {
44409
+ transfer_contract: {
44410
+ to_address: tx.contract.transferContract.toAddress,
44411
+ amount: tx.contract.transferContract.amount
44412
+ }
44413
+ };
43258
44414
  }
43259
44415
 
43260
- response = yield typedCall('FirmwareUpload', ['FirmwareRequest', 'Success'], {
43261
- payload: chunk
43262
- });
44416
+ if (tx.contract.triggerSmartContract) {
44417
+ unSignTx.contract = {
44418
+ trigger_smart_contract: {
44419
+ contract_address: tx.contract.triggerSmartContract.contractAddress,
44420
+ call_value: tx.contract.triggerSmartContract.callValue,
44421
+ data: tx.contract.triggerSmartContract.data,
44422
+ call_token_value: tx.contract.triggerSmartContract.callTokenValue,
44423
+ asset_id: tx.contract.triggerSmartContract.assetId
44424
+ }
44425
+ };
44426
+ }
43263
44427
  }
43264
44428
 
43265
- postProgressMessage(device, 100, postMessage);
43266
- return response.message;
44429
+ return unSignTx;
43267
44430
  }
43268
44431
 
43269
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'uploadFirmware: unknown major_version');
43270
- });
43271
-
43272
- class FirmwareUpdate extends BaseMethod {
43273
44432
  init() {
43274
- this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.INITIALIZE];
43275
- this.requireDeviceMode = [UI_REQUEST.BOOTLOADER];
43276
- this.useDevicePassphraseState = false;
44433
+ this.checkDeviceId = true;
44434
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
44435
+ validateParams(this.payload, [{
44436
+ name: 'path',
44437
+ required: true
44438
+ }, {
44439
+ name: 'transaction',
44440
+ type: 'object',
44441
+ required: true
44442
+ }]);
43277
44443
  const {
43278
- payload
43279
- } = this;
43280
- validateParams(payload, [{
43281
- name: 'version',
43282
- type: 'array'
44444
+ path,
44445
+ transaction
44446
+ } = this.payload;
44447
+ const addressN = validatePath(path, 3);
44448
+ validateParams(transaction, [{
44449
+ name: 'refBlockBytes',
44450
+ type: 'hexString',
44451
+ required: true
43283
44452
  }, {
43284
- name: 'binary',
43285
- type: 'buffer'
44453
+ name: 'refBlockHash',
44454
+ type: 'hexString',
44455
+ required: true
44456
+ }, {
44457
+ name: 'expiration',
44458
+ type: 'number',
44459
+ required: true
44460
+ }, {
44461
+ name: 'timestamp',
44462
+ type: 'number',
44463
+ required: true
44464
+ }, {
44465
+ name: 'contract',
44466
+ type: 'object',
44467
+ required: true
43286
44468
  }]);
44469
+ this.params = this.parseTx(formatAnyHex(transaction), addressN);
44470
+ }
43287
44471
 
43288
- if (!payload.updateType) {
43289
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.CallMethodInvalidParameter, 'updateType is required');
43290
- }
44472
+ getVersionRange() {
44473
+ return {
44474
+ model_mini: {
44475
+ min: '2.4.0'
44476
+ }
44477
+ };
44478
+ }
43291
44479
 
43292
- this.params = {
43293
- updateType: payload.updateType
44480
+ run() {
44481
+ return dist_awaiter(this, void 0, void 0, function* () {
44482
+ const response = yield this.device.commands.typedCall('TronSignTx', 'TronSignedTx', Object.assign({}, this.params));
44483
+ return Promise.resolve(response.message);
44484
+ });
44485
+ }
44486
+
44487
+ }
44488
+
44489
+ class NearGetAddress extends BaseMethod {
44490
+ constructor() {
44491
+ super(...arguments);
44492
+ this.hasBundle = false;
44493
+ }
44494
+
44495
+ init() {
44496
+ var _a;
44497
+
44498
+ this.checkDeviceId = true;
44499
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
44500
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
44501
+ const payload = this.hasBundle ? this.payload : {
44502
+ bundle: [this.payload]
43294
44503
  };
44504
+ validateParams(payload, [{
44505
+ name: 'bundle',
44506
+ type: 'array'
44507
+ }]);
44508
+ this.params = [];
44509
+ payload.bundle.forEach(batch => {
44510
+ var _a;
43295
44511
 
43296
- if ('version' in payload) {
43297
- this.params = Object.assign(Object.assign({}, this.params), {
43298
- version: payload.version
44512
+ const addressN = validatePath(batch.path, 3);
44513
+ validateParams(batch, [{
44514
+ name: 'path',
44515
+ required: true
44516
+ }, {
44517
+ name: 'showOnOneKey',
44518
+ type: 'boolean'
44519
+ }]);
44520
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
44521
+ this.params.push({
44522
+ address_n: addressN,
44523
+ show_display: showOnOneKey
43299
44524
  });
43300
- }
44525
+ });
44526
+ }
43301
44527
 
43302
- if ('binary' in payload) {
43303
- this.params = Object.assign(Object.assign({}, this.params), {
43304
- binary: payload.binary
43305
- });
43306
- }
44528
+ getVersionRange() {
44529
+ return {
44530
+ model_mini: {
44531
+ min: '2.4.0'
44532
+ }
44533
+ };
43307
44534
  }
43308
44535
 
43309
44536
  run() {
43310
- var _a;
43311
-
43312
44537
  return dist_awaiter(this, void 0, void 0, function* () {
43313
- const {
43314
- device,
43315
- params
43316
- } = this;
43317
- let binary;
43318
-
43319
- try {
43320
- if (params.binary) {
43321
- binary = this.params.binary;
43322
- } else {
43323
- if (!device.features) {
43324
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'no features found for this device');
43325
- }
44538
+ const responses = [];
43326
44539
 
43327
- const firmware = yield getBinary({
43328
- features: device.features,
43329
- version: params.version,
43330
- updateType: params.updateType
43331
- });
43332
- binary = firmware.binary;
43333
- }
43334
- } catch (err) {
43335
- throw HardwareError$1.TypedError(dist_HardwareErrorCode.FirmwareUpdateDownloadFailed, (_a = err.message) !== null && _a !== void 0 ? _a : err);
44540
+ for (let i = 0; i < this.params.length; i++) {
44541
+ const param = this.params[i];
44542
+ const res = yield this.device.commands.typedCall('NearGetAddress', 'NearAddress', Object.assign({}, param));
44543
+ const {
44544
+ address
44545
+ } = res.message;
44546
+ responses.push({
44547
+ path: serializedPath(param.address_n),
44548
+ address
44549
+ });
43336
44550
  }
43337
44551
 
43338
- return uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, {
43339
- payload: binary
43340
- });
44552
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
43341
44553
  });
43342
44554
  }
43343
44555
 
43344
44556
  }
43345
44557
 
43346
- const Log$2 = getLogger(LoggerNames.Method);
43347
-
43348
- class RequestWebUsbDevice extends BaseMethod {
44558
+ class NearSignTransaction extends BaseMethod {
43349
44559
  init() {
43350
- this.useDevice = false;
43351
- this.useDevicePassphraseState = false;
44560
+ this.checkDeviceId = true;
44561
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
44562
+ validateParams(this.payload, [{
44563
+ name: 'path',
44564
+ required: true
44565
+ }, {
44566
+ name: 'rawTx',
44567
+ type: 'hexString',
44568
+ required: true
44569
+ }]);
44570
+ const {
44571
+ path,
44572
+ rawTx
44573
+ } = this.payload;
44574
+ const addressN = validatePath(path, 3);
44575
+ this.params = {
44576
+ address_n: addressN,
44577
+ raw_tx: formatAnyHex(rawTx)
44578
+ };
43352
44579
  }
43353
44580
 
43354
- run() {
43355
- var _a, _b;
43356
-
43357
- return dist_awaiter(this, void 0, void 0, function* () {
43358
- yield TransportManager.configure();
43359
- const env = DataManager.getSettings('env');
43360
-
43361
- if (env !== 'webusb') {
43362
- return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Not webusb environment'));
44581
+ getVersionRange() {
44582
+ return {
44583
+ model_mini: {
44584
+ min: '2.4.0'
43363
44585
  }
44586
+ };
44587
+ }
43364
44588
 
43365
- try {
43366
- const deviceDiff = yield (_a = this.connector) === null || _a === void 0 ? void 0 : _a.enumerate();
43367
- const devicesDescriptor = (_b = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _b !== void 0 ? _b : [];
43368
- const {
43369
- deviceList
43370
- } = yield DevicePool.getDevices(devicesDescriptor);
43371
-
43372
- if (deviceList.length > 0) {
43373
- return {
43374
- device: deviceList[0].toMessageObject()
43375
- };
43376
- }
43377
-
43378
- return yield Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
43379
- } catch (error) {
43380
- Log$2.debug(error);
43381
- return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
43382
- }
44589
+ run() {
44590
+ return dist_awaiter(this, void 0, void 0, function* () {
44591
+ const res = yield this.device.commands.typedCall('NearSignTx', 'NearSignedTx', Object.assign({}, this.params));
44592
+ return Promise.resolve(res.message);
43383
44593
  });
43384
44594
  }
43385
44595
 
43386
44596
  }
43387
44597
 
43388
- class GetPassphraseState extends BaseMethod {
44598
+ class AptosGetAddress extends BaseMethod {
44599
+ constructor() {
44600
+ super(...arguments);
44601
+ this.hasBundle = false;
44602
+ }
44603
+
43389
44604
  init() {
44605
+ var _a;
44606
+
44607
+ this.checkDeviceId = true;
43390
44608
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
43391
- this.useDevicePassphraseState = false;
44609
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
44610
+ const payload = this.hasBundle ? this.payload : {
44611
+ bundle: [this.payload]
44612
+ };
44613
+ validateParams(payload, [{
44614
+ name: 'bundle',
44615
+ type: 'array'
44616
+ }]);
44617
+ this.params = [];
44618
+ payload.bundle.forEach(batch => {
44619
+ var _a;
44620
+
44621
+ const addressN = validatePath(batch.path, 3);
44622
+ validateParams(batch, [{
44623
+ name: 'path',
44624
+ required: true
44625
+ }, {
44626
+ name: 'showOnOneKey',
44627
+ type: 'boolean'
44628
+ }]);
44629
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
44630
+ this.params.push({
44631
+ address_n: addressN,
44632
+ show_display: showOnOneKey
44633
+ });
44634
+ });
43392
44635
  }
43393
44636
 
43394
44637
  run() {
43395
- var _a, _b;
43396
-
43397
44638
  return dist_awaiter(this, void 0, void 0, function* () {
43398
- if (!this.device.features) return Promise.reject(HardwareError$1.TypedError(dist_HardwareErrorCode.DeviceInitializeFailed));
43399
- let {
43400
- features
43401
- } = this.device;
43402
- const locked = ((_b = (_a = this.device) === null || _a === void 0 ? void 0 : _a.features) === null || _b === void 0 ? void 0 : _b.unlocked) === true;
43403
- const passphraseState = yield getPassphraseState(this.device.features, this.device.commands);
43404
- const isModeT = getDeviceType(features) === 'touch' || getDeviceType(features) === 'pro';
44639
+ const responses = [];
43405
44640
 
43406
- if (isModeT && locked) {
44641
+ for (let i = 0; i < this.params.length; i++) {
44642
+ const param = this.params[i];
44643
+ const res = yield this.device.commands.typedCall('AptosGetAddress', 'AptosAddress', Object.assign({}, param));
43407
44644
  const {
43408
- message
43409
- } = yield this.device.commands.typedCall('GetFeatures', 'Features', {});
43410
- features = message;
43411
- }
43412
-
43413
- if (features && features.passphrase_protection === true) {
43414
- return Promise.resolve(passphraseState);
44645
+ address
44646
+ } = res.message;
44647
+ responses.push({
44648
+ path: serializedPath(param.address_n),
44649
+ address
44650
+ });
43415
44651
  }
43416
44652
 
43417
- return Promise.resolve(undefined);
44653
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
43418
44654
  });
43419
44655
  }
43420
44656
 
43421
44657
  }
43422
44658
 
43423
- class CheckBridgeStatus extends BaseMethod {
44659
+ class AptosSignTransaction extends BaseMethod {
43424
44660
  init() {
43425
- this.useDevice = false;
43426
- this.useDevicePassphraseState = false;
44661
+ this.checkDeviceId = true;
44662
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
44663
+ validateParams(this.payload, [{
44664
+ name: 'path',
44665
+ required: true
44666
+ }, {
44667
+ name: 'rawTx',
44668
+ type: 'hexString',
44669
+ required: true
44670
+ }]);
44671
+ const {
44672
+ path,
44673
+ rawTx
44674
+ } = this.payload;
44675
+ const addressN = validatePath(path, 3);
44676
+ this.params = {
44677
+ address_n: addressN,
44678
+ raw_tx: formatAnyHex(rawTx)
44679
+ };
44680
+ }
44681
+
44682
+ getVersionRange() {
44683
+ return {
44684
+ model_mini: {
44685
+ min: '2.4.0'
44686
+ }
44687
+ };
43427
44688
  }
43428
44689
 
43429
44690
  run() {
43430
44691
  return dist_awaiter(this, void 0, void 0, function* () {
43431
- const logs = getLog();
43432
- return Promise.resolve(logs);
44692
+ const res = yield this.device.commands.typedCall('AptosSignTx', 'AptosSignedTx', Object.assign({}, this.params));
44693
+ return Promise.resolve(res.message);
43433
44694
  });
43434
44695
  }
43435
44696
 
@@ -43439,16 +44700,12 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
43439
44700
  __proto__: null,
43440
44701
  searchDevices: SearchDevices,
43441
44702
  getFeatures: GetFeatures,
43442
- cipherKeyValue: CipherKeyValue,
43443
- btcGetAddress: BTCGetAddress,
43444
- btcGetPublicKey: BTCGetPublicKey,
43445
- btcSignMessage: BTCSignMessage,
43446
- btcSignTransaction: BTCSignTransaction,
43447
- btcVerifyMessage: BTCVerifyMessage,
44703
+ getPassphraseState: GetPassphraseState,
44704
+ getLogs: CheckBridgeStatus$1,
43448
44705
  checkFirmwareRelease: CheckFirmwareRelease,
43449
44706
  checkBLEFirmwareRelease: CheckBLEFirmwareRelease,
43450
44707
  checkTransportRelease: CheckTransportRelease,
43451
- checkBridgeStatus: CheckBridgeStatus$1,
44708
+ checkBridgeStatus: CheckBridgeStatus,
43452
44709
  deviceBackup: DeviceBackup,
43453
44710
  deviceChangePin: DeviceChangePin,
43454
44711
  deviceFlags: DeviceFlags,
@@ -43460,6 +44717,18 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
43460
44717
  deviceSupportFeatures: DeviceSupportFeatures,
43461
44718
  deviceVerify: DeviceVerify,
43462
44719
  deviceWipe: DeviceWipe,
44720
+ firmwareUpdate: FirmwareUpdate,
44721
+ requestWebUsbDevice: RequestWebUsbDevice,
44722
+ cipherKeyValue: CipherKeyValue,
44723
+ btcGetAddress: BTCGetAddress,
44724
+ btcGetPublicKey: BTCGetPublicKey,
44725
+ btcSignMessage: BTCSignMessage,
44726
+ btcSignTransaction: BTCSignTransaction,
44727
+ btcVerifyMessage: BTCVerifyMessage,
44728
+ confluxGetAddress: ConfluxGetAddress,
44729
+ confluxSignMessage: ConfluxSignMessage,
44730
+ confluxSignMessageCIP23: ConfluxSignMessageCIP23,
44731
+ confluxSignTransaction: ConfluxSignTransaction,
43463
44732
  evmGetAddress: EvmGetAddress,
43464
44733
  evmGetPublicKey: EVMGetPublicKey,
43465
44734
  evmSignMessage: EVMSignMessage$2,
@@ -43478,10 +44747,13 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
43478
44747
  solSignTransaction: SolSignTransaction,
43479
44748
  stellarGetAddress: StellarGetAddress,
43480
44749
  stellarSignTransaction: StellarSignTransaction,
43481
- firmwareUpdate: FirmwareUpdate,
43482
- requestWebUsbDevice: RequestWebUsbDevice,
43483
- getPassphraseState: GetPassphraseState,
43484
- getLogs: CheckBridgeStatus
44750
+ tronGetAddress: TronGetAddress,
44751
+ tronSignMessage: TronSignMessage,
44752
+ tronSignTransaction: TronSignTransaction,
44753
+ nearGetAddress: NearGetAddress,
44754
+ nearSignTransaction: NearSignTransaction,
44755
+ aptosGetAddress: AptosGetAddress,
44756
+ aptosSignTransaction: AptosSignTransaction
43485
44757
  });
43486
44758
 
43487
44759
  function findMethod(message) {
@@ -44158,6 +45430,8 @@ const removeUiPromise = promise => {
44158
45430
 
44159
45431
  class Core extends dist_events.exports {
44160
45432
  handleMessage(message) {
45433
+ var _a, _b, _c, _d;
45434
+
44161
45435
  return dist_awaiter(this, void 0, void 0, function* () {
44162
45436
  switch (message.type) {
44163
45437
  case UI_RESPONSE.RECEIVE_PIN:
@@ -44182,7 +45456,21 @@ class Core extends dist_events.exports {
44182
45456
  case IFRAME.CALL:
44183
45457
  {
44184
45458
  const response = yield callAPI(message);
44185
- return response;
45459
+ const {
45460
+ success,
45461
+ payload
45462
+ } = response;
45463
+
45464
+ if (success) {
45465
+ return response;
45466
+ }
45467
+
45468
+ return Object.assign(Object.assign({}, response), {
45469
+ payload: Object.assign(Object.assign({}, payload), {
45470
+ connectId: (_b = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.connectId) !== null && _b !== void 0 ? _b : '',
45471
+ deviceId: (_d = (_c = message.payload) === null || _c === void 0 ? void 0 : _c.deviceId) !== null && _d !== void 0 ? _d : ''
45472
+ })
45473
+ });
44186
45474
  }
44187
45475
 
44188
45476
  case IFRAME.CANCEL:
@@ -46692,7 +47980,7 @@ const src_init = async settings => {
46692
47980
 
46693
47981
  try {
46694
47982
  await builder_init({ ..._settings,
46695
- version: "0.1.41"
47983
+ version: "0.1.44"
46696
47984
  });
46697
47985
  return true;
46698
47986
  } catch (e) {