@onekeyfe/hd-web-sdk 0.0.7 → 0.0.10

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.
@@ -4023,12 +4023,12 @@ __webpack_unused_export__ = ({
4023
4023
  value: true
4024
4024
  });
4025
4025
 
4026
+ var semver = __webpack_require__(7699);
4027
+
4026
4028
  var hdTransport = __webpack_require__(7495);
4027
4029
 
4028
4030
  var axios = __webpack_require__(9644);
4029
4031
 
4030
- var semver = __webpack_require__(7699);
4031
-
4032
4032
  var BigNumber = __webpack_require__(6391);
4033
4033
 
4034
4034
  function _interopDefaultLegacy(e) {
@@ -4037,10 +4037,10 @@ function _interopDefaultLegacy(e) {
4037
4037
  };
4038
4038
  }
4039
4039
 
4040
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
4041
-
4042
4040
  var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver);
4043
4041
 
4042
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
4043
+
4044
4044
  var BigNumber__default = /*#__PURE__*/_interopDefaultLegacy(BigNumber);
4045
4045
 
4046
4046
  const inject = ({
@@ -4084,6 +4084,10 @@ const inject = ({
4084
4084
  checkTransportRelease: () => call({
4085
4085
  method: 'checkTransportRelease'
4086
4086
  }),
4087
+ cipherKeyValue: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4088
+ connectId,
4089
+ method: 'cipherKeyValue'
4090
+ })),
4087
4091
  deviceBackup: connectId => call({
4088
4092
  connectId,
4089
4093
  method: 'deviceBackup'
@@ -4187,6 +4191,30 @@ const inject = ({
4187
4191
  starcoinVerifyMessage: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4188
4192
  connectId,
4189
4193
  method: 'starcoinVerifyMessage'
4194
+ })),
4195
+ nemGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4196
+ connectId,
4197
+ method: 'nemGetAddress'
4198
+ })),
4199
+ nemSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4200
+ connectId,
4201
+ method: 'nemSignTransaction'
4202
+ })),
4203
+ solGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4204
+ connectId,
4205
+ method: 'solGetAddress'
4206
+ })),
4207
+ solSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4208
+ connectId,
4209
+ method: 'solSignTransaction'
4210
+ })),
4211
+ stellarGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4212
+ connectId,
4213
+ method: 'stellarGetAddress'
4214
+ })),
4215
+ stellarSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4216
+ connectId,
4217
+ method: 'stellarSignTransaction'
4190
4218
  }))
4191
4219
  };
4192
4220
  return api;
@@ -4207,6 +4235,17 @@ PERFORMANCE OF THIS SOFTWARE.
4207
4235
  ***************************************************************************** */
4208
4236
 
4209
4237
 
4238
+ function __rest(s, e) {
4239
+ var t = {};
4240
+
4241
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
4242
+
4243
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
4244
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
4245
+ }
4246
+ return t;
4247
+ }
4248
+
4210
4249
  function __awaiter(thisArg, _arguments, P, generator) {
4211
4250
  function adopt(value) {
4212
4251
  return value instanceof P ? value : new P(function (resolve) {
@@ -4998,6 +5037,18 @@ function create(arg, data) {
4998
5037
  };
4999
5038
  }
5000
5039
 
5040
+ const getDeviceModel = features => {
5041
+ if (!features || typeof features !== 'object') {
5042
+ return 'model_mini';
5043
+ }
5044
+
5045
+ if (features.model === '1') {
5046
+ return 'model_mini';
5047
+ }
5048
+
5049
+ return 'model_touch';
5050
+ };
5051
+
5001
5052
  const getDeviceType = features => {
5002
5053
  if (!features || typeof features !== 'object' || !features.serial_no) {
5003
5054
  return 'classic';
@@ -5048,6 +5099,8 @@ const getDeviceLabel = features => {
5048
5099
  };
5049
5100
 
5050
5101
  const getDeviceFirmwareVersion = features => {
5102
+ if (!features) return [0, 0, 0];
5103
+
5051
5104
  if (features.onekey_version) {
5052
5105
  return features.onekey_version.split('.');
5053
5106
  }
@@ -14313,7 +14366,7 @@ const UI_REQUEST = {
14313
14366
  NOT_USE_ONEKEY_DEVICE: 'ui-device_please_use_onekey_device'
14314
14367
  };
14315
14368
  const VERSION = '1.0.0-alpha.1';
14316
- const DEFAULT_DOMAIN = `https://localhost:8088/`;
14369
+ const DEFAULT_DOMAIN = `https://hardware-sdk.onekey.so/`;
14317
14370
  const DEFAULT_PRIORITY = 2;
14318
14371
  const initialSettings = {
14319
14372
  configSrc: './data/config.json',
@@ -14829,6 +14882,10 @@ class BaseMethod {
14829
14882
  this.requireDeviceMode = [];
14830
14883
  }
14831
14884
 
14885
+ getVersionRange() {
14886
+ return {};
14887
+ }
14888
+
14832
14889
  setDevice(device) {
14833
14890
  this.device = device;
14834
14891
  this.connectId = device.originalDescriptor.path;
@@ -14953,7 +15010,6 @@ const formatAnyHex = value => {
14953
15010
  return modifyValues(value, value => formatAnyHex(value));
14954
15011
  }
14955
15012
 
14956
- console.log('unexpected value', value);
14957
15013
  return value;
14958
15014
  };
14959
15015
 
@@ -15022,6 +15078,79 @@ const validateParams = (values, fields) => {
15022
15078
  });
15023
15079
  };
15024
15080
 
15081
+ class CipherKeyValue extends BaseMethod {
15082
+ constructor() {
15083
+ super(...arguments);
15084
+ this.hasBundle = false;
15085
+ }
15086
+
15087
+ init() {
15088
+ var _a;
15089
+
15090
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15091
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
15092
+ const payload = this.hasBundle ? this.payload : {
15093
+ bundle: [this.payload]
15094
+ };
15095
+ validateParams(payload, [{
15096
+ name: 'bundle',
15097
+ type: 'array'
15098
+ }]);
15099
+ this.params = [];
15100
+ payload.bundle.forEach(batch => {
15101
+ const addressN = validatePath(batch.path);
15102
+ validateParams(batch, [{
15103
+ name: 'path',
15104
+ required: true
15105
+ }, {
15106
+ name: 'key',
15107
+ type: 'string'
15108
+ }, {
15109
+ name: 'value',
15110
+ type: 'hexString'
15111
+ }, {
15112
+ name: 'encrypt',
15113
+ type: 'boolean'
15114
+ }, {
15115
+ name: 'askOnEncrypt',
15116
+ type: 'boolean'
15117
+ }, {
15118
+ name: 'askOnDecrypt',
15119
+ type: 'boolean'
15120
+ }, {
15121
+ name: 'iv',
15122
+ type: 'hexString'
15123
+ }]);
15124
+ this.params.push({
15125
+ address_n: addressN,
15126
+ key: batch.key,
15127
+ value: formatAnyHex(batch.value),
15128
+ encrypt: batch.encrypt,
15129
+ ask_on_encrypt: batch.askOnEncrypt,
15130
+ ask_on_decrypt: batch.askOnDecrypt,
15131
+ iv: formatAnyHex(batch.iv)
15132
+ });
15133
+ });
15134
+ }
15135
+
15136
+ run() {
15137
+ return __awaiter(this, void 0, void 0, function* () {
15138
+ const responses = [];
15139
+
15140
+ for (let i = 0; i < this.params.length; i++) {
15141
+ const param = this.params[i];
15142
+ const res = yield this.device.commands.typedCall('CipherKeyValue', 'CipheredKeyValue', Object.assign({}, param));
15143
+ responses.push(Object.assign({
15144
+ path: serializedPath(param.address_n)
15145
+ }, res.message));
15146
+ }
15147
+
15148
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
15149
+ });
15150
+ }
15151
+
15152
+ }
15153
+
15025
15154
  var bitcoin = [{
15026
15155
  name: "Bitcoin",
15027
15156
  label: "BTC",
@@ -16187,6 +16316,17 @@ class DeviceFlags extends BaseMethod {
16187
16316
  class DeviceRebootToBootloader extends BaseMethod {
16188
16317
  init() {}
16189
16318
 
16319
+ getVersionRange() {
16320
+ return {
16321
+ classic: {
16322
+ min: '2.1.11'
16323
+ },
16324
+ mini: {
16325
+ min: '2.1.11'
16326
+ }
16327
+ };
16328
+ }
16329
+
16190
16330
  run() {
16191
16331
  return __awaiter(this, void 0, void 0, function* () {
16192
16332
  const res = yield this.device.commands.typedCall('RebootToBootloader', 'Success');
@@ -16531,7 +16671,7 @@ class EVMSignMessage$2 extends BaseMethod {
16531
16671
 
16532
16672
  }
16533
16673
 
16534
- class EVMSignMessageEIP712$1 extends BaseMethod {
16674
+ class EVMSignMessageEIP712 extends BaseMethod {
16535
16675
  init() {
16536
16676
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16537
16677
  validateParams(this.payload, [{
@@ -16559,6 +16699,14 @@ class EVMSignMessageEIP712$1 extends BaseMethod {
16559
16699
  };
16560
16700
  }
16561
16701
 
16702
+ getVersionRange() {
16703
+ return {
16704
+ model_mini: {
16705
+ min: '2.1.9'
16706
+ }
16707
+ };
16708
+ }
16709
+
16562
16710
  run() {
16563
16711
  return __awaiter(this, void 0, void 0, function* () {
16564
16712
  const res = yield this.device.commands.typedCall('EthereumSignMessageEIP712', 'EthereumMessageSignature', Object.assign({}, this.params));
@@ -16756,6 +16904,22 @@ class EVMSignTransaction extends BaseMethod {
16756
16904
  this.formattedTx = formatAnyHex(tx);
16757
16905
  }
16758
16906
 
16907
+ getVersionRange() {
16908
+ if (this.isEIP1559) {
16909
+ return {
16910
+ model_mini: {
16911
+ min: '2.1.11'
16912
+ }
16913
+ };
16914
+ }
16915
+
16916
+ return {
16917
+ model_mini: {
16918
+ min: '1.0.0'
16919
+ }
16920
+ };
16921
+ }
16922
+
16759
16923
  run() {
16760
16924
  return __awaiter(this, void 0, void 0, function* () {
16761
16925
  const {
@@ -16770,7 +16934,7 @@ class EVMSignTransaction extends BaseMethod {
16770
16934
 
16771
16935
  }
16772
16936
 
16773
- class EVMSignMessageEIP712 extends BaseMethod {
16937
+ class EVMSignTypedData extends BaseMethod {
16774
16938
  init() {
16775
16939
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16776
16940
  validateParams(this.payload, [{
@@ -16778,12 +16942,10 @@ class EVMSignMessageEIP712 extends BaseMethod {
16778
16942
  required: true
16779
16943
  }, {
16780
16944
  name: 'metamaskV4Compat',
16781
- type: 'boolean',
16782
- required: true
16945
+ type: 'boolean'
16783
16946
  }, {
16784
16947
  name: 'data',
16785
- type: 'object',
16786
- required: true
16948
+ type: 'object'
16787
16949
  }, {
16788
16950
  name: 'domainHash',
16789
16951
  type: 'hexString'
@@ -16810,12 +16972,35 @@ class EVMSignMessageEIP712 extends BaseMethod {
16810
16972
 
16811
16973
  if (messageHash) {
16812
16974
  this.params.messageHash = formatAnyHex(messageHash);
16813
- } else if (!data.primaryType || data.primaryType !== 'EIP712Domain') {
16975
+ } else if (!!data && (!data.primaryType || data.primaryType !== 'EIP712Domain')) {
16814
16976
  throw TypedError('Method_InvalidParameter', 'message_hash should only be empty when data.primaryType=EIP712Domain');
16815
16977
  }
16816
16978
  }
16817
16979
  }
16818
16980
 
16981
+ getVersionRange() {
16982
+ return {
16983
+ model_mini: {
16984
+ min: '2.1.9'
16985
+ }
16986
+ };
16987
+ }
16988
+
16989
+ supportSignTyped() {
16990
+ const deviceType = getDeviceType(this.device.features);
16991
+
16992
+ if (deviceType === 'classic' || deviceType === 'mini') {
16993
+ const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
16994
+ const supportSignTypedVersion = '2.2.0';
16995
+
16996
+ if (semver__default["default"].lt(currentVersion, supportSignTypedVersion)) {
16997
+ return false;
16998
+ }
16999
+ }
17000
+
17001
+ return true;
17002
+ }
17003
+
16819
17004
  run() {
16820
17005
  return __awaiter(this, void 0, void 0, function* () {
16821
17006
  if (!this.device.features) {
@@ -16825,25 +17010,38 @@ class EVMSignMessageEIP712 extends BaseMethod {
16825
17010
  const {
16826
17011
  addressN
16827
17012
  } = this.params;
17013
+ const deviceType = getDeviceType(this.device.features);
16828
17014
 
16829
- if (this.device.features.model === '1') {
17015
+ if (deviceType === 'classic' || deviceType === 'mini') {
16830
17016
  validateParams(this.params, [{
16831
17017
  name: 'domainHash',
16832
17018
  type: 'hexString',
16833
17019
  required: true
16834
17020
  }, {
16835
17021
  name: 'messageHash',
16836
- type: 'hexString'
17022
+ type: 'hexString',
17023
+ required: true
16837
17024
  }]);
16838
17025
  const {
16839
17026
  domainHash,
16840
17027
  messageHash
16841
17028
  } = this.params;
16842
- const response = yield this.device.commands.typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', {
16843
- address_n: addressN,
16844
- domain_separator_hash: domainHash !== null && domainHash !== void 0 ? domainHash : '',
16845
- message_hash: messageHash
16846
- });
17029
+ let response;
17030
+
17031
+ if (this.supportSignTyped()) {
17032
+ response = yield this.device.commands.typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', {
17033
+ address_n: addressN,
17034
+ domain_separator_hash: domainHash !== null && domainHash !== void 0 ? domainHash : '',
17035
+ message_hash: messageHash
17036
+ });
17037
+ } else {
17038
+ response = yield this.device.commands.typedCall('EthereumSignMessageEIP712', 'EthereumMessageSignature', {
17039
+ address_n: addressN,
17040
+ domain_hash: domainHash !== null && domainHash !== void 0 ? domainHash : '',
17041
+ message_hash: messageHash !== null && messageHash !== void 0 ? messageHash : ''
17042
+ });
17043
+ }
17044
+
16847
17045
  return Promise.resolve(response.message);
16848
17046
  }
16849
17047
 
@@ -17101,73 +17299,803 @@ class EVMSignMessage extends BaseMethod {
17101
17299
 
17102
17300
  }
17103
17301
 
17104
- var ApiMethods = /*#__PURE__*/Object.freeze({
17105
- __proto__: null,
17106
- searchDevices: SearchDevices,
17107
- getFeatures: GetFeatures,
17108
- btcGetAddress: BTCGetAddress,
17109
- btcGetPublicKey: BTCGetPublicKey,
17110
- btcSignMessage: BTCSignMessage,
17111
- btcSignTransaction: BTCSignTransaction,
17112
- btcVerifyMessage: BTCVerifyMessage,
17113
- checkFirmwareRelease: CheckFirmwareRelease,
17114
- checkBLEFirmwareRelease: CheckBLEFirmwareRelease,
17115
- checkTransportRelease: CheckTransportRelease,
17116
- deviceBackup: DeviceBackup,
17117
- deviceChangePin: DeviceChangePin,
17118
- deviceFlags: DeviceFlags,
17119
- deviceRebootToBootloader: DeviceRebootToBootloader,
17120
- deviceRecovery: DeviceRecovery,
17121
- deviceReset: DeviceReset,
17122
- deviceSettings: DeviceSettings,
17123
- deviceUpdateReboot: DeviceUpdateReboot,
17124
- deviceWipe: DeviceWipe,
17125
- evmGetAddress: EvmGetAddress,
17126
- evmGetPublicKey: EVMGetPublicKey,
17127
- evmSignMessage: EVMSignMessage$2,
17128
- evmSignMessageEIP712: EVMSignMessageEIP712$1,
17129
- evmSignTransaction: EVMSignTransaction,
17130
- evmSignTypedData: EVMSignMessageEIP712,
17131
- evmVerifyMessage: EVMSignMessage$1,
17132
- starcoinGetAddress: StarcoinGetAddress,
17133
- starcoinGetPublicKey: StarcoinGetPublicKey,
17134
- starcoinSignMessage: StarcoinSignMessage,
17135
- starcoinSignTransaction: StarcoinSignTransaction,
17136
- starcoinVerifyMessage: EVMSignMessage
17137
- });
17138
-
17139
- function findMethod(message) {
17140
- const {
17141
- method
17142
- } = message.payload;
17302
+ const MAINNET = 0x68;
17143
17303
 
17144
- if (typeof method !== 'string') {
17145
- throw TypedError('Method_InvalidParameter', 'Method is not set');
17304
+ class NEMGetAddress extends BaseMethod {
17305
+ constructor() {
17306
+ super(...arguments);
17307
+ this.hasBundle = false;
17146
17308
  }
17147
17309
 
17148
- const MethodConstructor = ApiMethods[method];
17310
+ init() {
17311
+ var _a;
17149
17312
 
17150
- if (MethodConstructor) {
17151
- return new MethodConstructor(message);
17313
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17314
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17315
+ const payload = this.hasBundle ? this.payload : {
17316
+ bundle: [this.payload]
17317
+ };
17318
+ validateParams(payload, [{
17319
+ name: 'bundle',
17320
+ type: 'array'
17321
+ }]);
17322
+ this.params = [];
17323
+ payload.bundle.forEach(batch => {
17324
+ var _a;
17325
+
17326
+ const addressN = validatePath(batch.path, 3);
17327
+ validateParams(batch, [{
17328
+ name: 'path',
17329
+ required: true
17330
+ }, {
17331
+ name: 'network',
17332
+ type: 'number'
17333
+ }, {
17334
+ name: 'showOnOneKey',
17335
+ type: 'boolean'
17336
+ }]);
17337
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
17338
+ this.params.push({
17339
+ address_n: addressN,
17340
+ network: batch.network || MAINNET,
17341
+ show_display: showOnOneKey
17342
+ });
17343
+ });
17152
17344
  }
17153
17345
 
17154
- throw TypedError('Method_InvalidParameter', `Method ${method} is not set`);
17155
- }
17346
+ run() {
17347
+ return __awaiter(this, void 0, void 0, function* () {
17348
+ const responses = [];
17156
17349
 
17157
- const resolveAfter = (msec, value) => new Promise(resolve => {
17158
- setTimeout(resolve, msec, value);
17159
- });
17350
+ for (let i = 0; i < this.params.length; i++) {
17351
+ const param = this.params[i];
17352
+ const res = yield this.device.commands.typedCall('NEMGetAddress', 'NEMAddress', Object.assign({}, param));
17353
+ responses.push(Object.assign({
17354
+ path: serializedPath(param.address_n)
17355
+ }, res.message));
17356
+ }
17160
17357
 
17161
- const Log$1 = initLog('DeviceConnector');
17358
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
17359
+ });
17360
+ }
17162
17361
 
17163
- const getDiff = (current, descriptors) => {
17164
- const env = DataManager.getSettings('env');
17362
+ }
17165
17363
 
17166
- if (env === 'react-native') {
17167
- return {
17168
- descriptors
17364
+ const NEM_TRANSFER = 0x0101;
17365
+ const NEM_COSIGNING = 0x0102;
17366
+ const NEM_IMPORTANCE_TRANSFER = 0x0801;
17367
+ const NEM_AGGREGATE_MODIFICATION = 0x1001;
17368
+ const NEM_MULTISIG_SIGNATURE = 0x1002;
17369
+ const NEM_MULTISIG = 0x1004;
17370
+ const NEM_PROVISION_NAMESPACE = 0x2001;
17371
+ const NEM_MOSAIC_CREATION = 0x4001;
17372
+ const NEM_SUPPLY_CHANGE = 0x4002;
17373
+
17374
+ class NEMSignTransaction extends BaseMethod {
17375
+ constructor() {
17376
+ super(...arguments);
17377
+ this.NEM_MOSAIC_LEVY_TYPES = {
17378
+ 1: 'MosaicLevy_Absolute',
17379
+ 2: 'MosaicLevy_Percentile'
17380
+ };
17381
+ this.NEM_SUPPLY_CHANGE_TYPES = {
17382
+ 1: 'SupplyChange_Increase',
17383
+ 2: 'SupplyChange_Decrease'
17384
+ };
17385
+ this.NEM_AGGREGATE_MODIFICATION_TYPES = {
17386
+ 1: 'CosignatoryModification_Add',
17387
+ 2: 'CosignatoryModification_Delete'
17388
+ };
17389
+ this.NEM_IMPORTANCE_TRANSFER_MODES = {
17390
+ 1: 'ImportanceTransfer_Activate',
17391
+ 2: 'ImportanceTransfer_Deactivate'
17169
17392
  };
17170
- }
17393
+
17394
+ this.getCommon = (tx, address_n) => {
17395
+ var _a;
17396
+
17397
+ return {
17398
+ address_n,
17399
+ network: tx.version >> 24 & 0xff,
17400
+ timestamp: tx.timeStamp,
17401
+ fee: tx.fee,
17402
+ deadline: (_a = tx.deadline) !== null && _a !== void 0 ? _a : 0,
17403
+ signer: address_n ? undefined : tx.signer
17404
+ };
17405
+ };
17406
+
17407
+ this.transferMessage = tx => {
17408
+ const mosaics = tx.mosaics ? tx.mosaics.map(mosaic => ({
17409
+ namespace: mosaic.mosaicId.namespaceId,
17410
+ mosaic: mosaic.mosaicId.name,
17411
+ quantity: mosaic.quantity
17412
+ })) : undefined;
17413
+ return {
17414
+ recipient: tx.recipient,
17415
+ amount: tx.amount,
17416
+ payload: tx.message ? tx.message.payload : undefined,
17417
+ public_key: tx.message && tx.message.type === 0x02 ? tx.message.publicKey : undefined,
17418
+ mosaics
17419
+ };
17420
+ };
17421
+
17422
+ this.importanceTransferMessage = tx => ({
17423
+ mode: this.NEM_IMPORTANCE_TRANSFER_MODES[tx.importanceTransfer.mode],
17424
+ public_key: tx.importanceTransfer.publicKey
17425
+ });
17426
+
17427
+ this.aggregateModificationMessage = tx => {
17428
+ const modifications = tx.modifications ? tx.modifications.map(modification => ({
17429
+ type: this.NEM_AGGREGATE_MODIFICATION_TYPES[modification.modificationType],
17430
+ public_key: modification.cosignatoryAccount
17431
+ })) : undefined;
17432
+ return {
17433
+ modifications,
17434
+ relative_change: tx.minCosignatories.relativeChange
17435
+ };
17436
+ };
17437
+
17438
+ this.provisionNamespaceMessage = tx => {
17439
+ var _a, _b, _c;
17440
+
17441
+ return {
17442
+ namespace: (_a = tx.newPart) !== null && _a !== void 0 ? _a : '',
17443
+ parent: tx.parent || undefined,
17444
+ sink: (_b = tx.rentalFeeSink) !== null && _b !== void 0 ? _b : '',
17445
+ fee: (_c = tx.rentalFee) !== null && _c !== void 0 ? _c : 0
17446
+ };
17447
+ };
17448
+
17449
+ this.mosaicCreationMessage = tx => {
17450
+ var _a, _b;
17451
+
17452
+ const {
17453
+ levy
17454
+ } = tx.mosaicDefinition;
17455
+ const definition = {
17456
+ namespace: tx.mosaicDefinition.id.namespaceId,
17457
+ mosaic: tx.mosaicDefinition.id.name,
17458
+ levy: levy && levy.type ? this.NEM_MOSAIC_LEVY_TYPES[levy.type] : undefined,
17459
+ fee: levy && levy.fee,
17460
+ levy_address: levy && levy.recipient,
17461
+ levy_namespace: levy && levy.mosaicId && levy.mosaicId.namespaceId,
17462
+ levy_mosaic: levy && levy.mosaicId && levy.mosaicId.name,
17463
+ description: tx.mosaicDefinition.description
17464
+ };
17465
+ const {
17466
+ properties
17467
+ } = tx.mosaicDefinition;
17468
+
17469
+ if (Array.isArray(properties)) {
17470
+ properties.forEach(property => {
17471
+ const {
17472
+ name,
17473
+ value
17474
+ } = property;
17475
+
17476
+ switch (name) {
17477
+ case 'divisibility':
17478
+ definition.divisibility = parseInt(value);
17479
+ break;
17480
+
17481
+ case 'initialSupply':
17482
+ definition.supply = parseInt(value);
17483
+ break;
17484
+
17485
+ case 'supplyMutable':
17486
+ definition.mutable_supply = value === 'true';
17487
+ break;
17488
+
17489
+ case 'transferable':
17490
+ definition.transferable = value === 'true';
17491
+ break;
17492
+ }
17493
+ });
17494
+ }
17495
+
17496
+ return {
17497
+ definition,
17498
+ sink: (_a = tx.creationFeeSink) !== null && _a !== void 0 ? _a : '',
17499
+ fee: (_b = tx.creationFee) !== null && _b !== void 0 ? _b : 0
17500
+ };
17501
+ };
17502
+
17503
+ this.supplyChangeMessage = tx => {
17504
+ var _a;
17505
+
17506
+ return {
17507
+ namespace: tx.mosaicId.namespaceId,
17508
+ mosaic: tx.mosaicId.name,
17509
+ type: this.NEM_SUPPLY_CHANGE_TYPES[tx.supplyType],
17510
+ delta: (_a = tx.delta) !== null && _a !== void 0 ? _a : 0
17511
+ };
17512
+ };
17513
+
17514
+ this.parseTx = (tx, address_n) => {
17515
+ let transaction = tx;
17516
+ const message = {
17517
+ transaction: this.getCommon(tx, address_n),
17518
+ transfer: undefined,
17519
+ importance_transfer: undefined,
17520
+ aggregate_modification: undefined,
17521
+ provision_namespace: undefined,
17522
+ mosaic_creation: undefined,
17523
+ supply_change: undefined
17524
+ };
17525
+
17526
+ if (tx.type === NEM_COSIGNING || tx.type === NEM_MULTISIG || tx.type === NEM_MULTISIG_SIGNATURE) {
17527
+ message.cosigning = tx.type === NEM_COSIGNING || tx.type === NEM_MULTISIG_SIGNATURE;
17528
+ transaction = tx.otherTrans;
17529
+ message.multisig = this.getCommon(transaction);
17530
+ }
17531
+
17532
+ switch (transaction.type) {
17533
+ case NEM_TRANSFER:
17534
+ message.transfer = this.transferMessage(transaction);
17535
+ break;
17536
+
17537
+ case NEM_IMPORTANCE_TRANSFER:
17538
+ message.importance_transfer = this.importanceTransferMessage(transaction);
17539
+ break;
17540
+
17541
+ case NEM_AGGREGATE_MODIFICATION:
17542
+ message.aggregate_modification = this.aggregateModificationMessage(transaction);
17543
+ break;
17544
+
17545
+ case NEM_PROVISION_NAMESPACE:
17546
+ message.provision_namespace = this.provisionNamespaceMessage(transaction);
17547
+ break;
17548
+
17549
+ case NEM_MOSAIC_CREATION:
17550
+ message.mosaic_creation = this.mosaicCreationMessage(transaction);
17551
+ break;
17552
+
17553
+ case NEM_SUPPLY_CHANGE:
17554
+ message.supply_change = this.supplyChangeMessage(transaction);
17555
+ break;
17556
+
17557
+ default:
17558
+ throw TypedError('Method_InvalidParameter', 'Unknown transaction type');
17559
+ }
17560
+
17561
+ return message;
17562
+ };
17563
+ }
17564
+
17565
+ init() {
17566
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17567
+ validateParams(this.payload, [{
17568
+ name: 'path',
17569
+ required: true
17570
+ }, {
17571
+ name: 'transaction',
17572
+ type: 'object',
17573
+ required: true
17574
+ }]);
17575
+ const {
17576
+ path,
17577
+ transaction
17578
+ } = this.payload;
17579
+ const addressN = validatePath(path, 3);
17580
+ this.params = this.parseTx(transaction, addressN);
17581
+ }
17582
+
17583
+ run() {
17584
+ return __awaiter(this, void 0, void 0, function* () {
17585
+ const res = yield this.device.commands.typedCall('NEMSignTx', 'NEMSignedTx', Object.assign({}, this.params));
17586
+ return Promise.resolve(res);
17587
+ });
17588
+ }
17589
+
17590
+ }
17591
+
17592
+ class SolGetAddress extends BaseMethod {
17593
+ constructor() {
17594
+ super(...arguments);
17595
+ this.hasBundle = false;
17596
+ }
17597
+
17598
+ init() {
17599
+ var _a;
17600
+
17601
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17602
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17603
+ const payload = this.hasBundle ? this.payload : {
17604
+ bundle: [this.payload]
17605
+ };
17606
+ validateParams(payload, [{
17607
+ name: 'bundle',
17608
+ type: 'array'
17609
+ }]);
17610
+ this.params = [];
17611
+ payload.bundle.forEach(batch => {
17612
+ var _a;
17613
+
17614
+ const addressN = validatePath(batch.path, 3);
17615
+ validateParams(batch, [{
17616
+ name: 'path',
17617
+ required: true
17618
+ }, {
17619
+ name: 'showOnOneKey',
17620
+ type: 'boolean'
17621
+ }]);
17622
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
17623
+ this.params.push({
17624
+ address_n: addressN,
17625
+ show_display: showOnOneKey
17626
+ });
17627
+ });
17628
+ }
17629
+
17630
+ run() {
17631
+ return __awaiter(this, void 0, void 0, function* () {
17632
+ const responses = [];
17633
+
17634
+ for (let i = 0; i < this.params.length; i++) {
17635
+ const param = this.params[i];
17636
+ const res = yield this.device.commands.typedCall('SolanaGetAddress', 'SolanaAddress', Object.assign({}, param));
17637
+ const {
17638
+ address
17639
+ } = res.message;
17640
+ responses.push({
17641
+ path: serializedPath(param.address_n),
17642
+ address
17643
+ });
17644
+ }
17645
+
17646
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
17647
+ });
17648
+ }
17649
+
17650
+ }
17651
+
17652
+ class SolSignTransaction extends BaseMethod {
17653
+ constructor() {
17654
+ super(...arguments);
17655
+ this.hasBundle = false;
17656
+ }
17657
+
17658
+ init() {
17659
+ var _a;
17660
+
17661
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17662
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17663
+ const payload = this.hasBundle ? this.payload : {
17664
+ bundle: [this.payload]
17665
+ };
17666
+ validateParams(payload, [{
17667
+ name: 'bundle',
17668
+ type: 'array'
17669
+ }]);
17670
+ this.params = [];
17671
+ payload.bundle.forEach(batch => {
17672
+ const addressN = validatePath(batch.path, 3);
17673
+ validateParams(batch, [{
17674
+ name: 'path',
17675
+ required: true
17676
+ }, {
17677
+ name: 'rawTx',
17678
+ type: 'hexString',
17679
+ required: true
17680
+ }]);
17681
+ this.params.push({
17682
+ address_n: addressN,
17683
+ raw_tx: formatAnyHex(batch.rawTx)
17684
+ });
17685
+ });
17686
+ }
17687
+
17688
+ getVersionRange() {
17689
+ return {
17690
+ classic: {
17691
+ min: '2.1.9'
17692
+ },
17693
+ mini: {
17694
+ min: '2.1.9'
17695
+ }
17696
+ };
17697
+ }
17698
+
17699
+ run() {
17700
+ return __awaiter(this, void 0, void 0, function* () {
17701
+ const responses = [];
17702
+
17703
+ for (let i = 0; i < this.params.length; i++) {
17704
+ const param = this.params[i];
17705
+ const res = yield this.device.commands.typedCall('SolanaSignTx', 'SolanaSignedTx', Object.assign({}, param));
17706
+ const {
17707
+ signature
17708
+ } = res.message;
17709
+ responses.push({
17710
+ path: serializedPath(param.address_n),
17711
+ signature
17712
+ });
17713
+ }
17714
+
17715
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
17716
+ });
17717
+ }
17718
+
17719
+ }
17720
+
17721
+ class StellarGetAddress extends BaseMethod {
17722
+ constructor() {
17723
+ super(...arguments);
17724
+ this.hasBundle = false;
17725
+ }
17726
+
17727
+ init() {
17728
+ var _a;
17729
+
17730
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17731
+ this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17732
+ const payload = this.hasBundle ? this.payload : {
17733
+ bundle: [this.payload]
17734
+ };
17735
+ validateParams(payload, [{
17736
+ name: 'bundle',
17737
+ type: 'array'
17738
+ }]);
17739
+ this.params = [];
17740
+ payload.bundle.forEach(batch => {
17741
+ var _a;
17742
+
17743
+ const addressN = validatePath(batch.path, 3);
17744
+ validateParams(batch, [{
17745
+ name: 'path',
17746
+ required: true
17747
+ }, {
17748
+ name: 'showOnOneKey',
17749
+ type: 'boolean'
17750
+ }]);
17751
+ const showOnOneKey = (_a = batch.showOnOneKey) !== null && _a !== void 0 ? _a : true;
17752
+ this.params.push({
17753
+ address_n: addressN,
17754
+ show_display: showOnOneKey
17755
+ });
17756
+ });
17757
+ }
17758
+
17759
+ run() {
17760
+ return __awaiter(this, void 0, void 0, function* () {
17761
+ const responses = [];
17762
+
17763
+ for (let i = 0; i < this.params.length; i++) {
17764
+ const param = this.params[i];
17765
+ const res = yield this.device.commands.typedCall('StellarGetAddress', 'StellarAddress', Object.assign({}, param));
17766
+ const {
17767
+ address
17768
+ } = res.message;
17769
+ responses.push({
17770
+ path: serializedPath(param.address_n),
17771
+ address
17772
+ });
17773
+ }
17774
+
17775
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
17776
+ });
17777
+ }
17778
+
17779
+ }
17780
+
17781
+ class StellarSignTransaction extends BaseMethod {
17782
+ constructor() {
17783
+ super(...arguments);
17784
+ this.operations = [];
17785
+
17786
+ this.parseOperation = op => {
17787
+ switch (op.type) {
17788
+ case 'createAccount':
17789
+ validateParams(op, [{
17790
+ name: 'destination',
17791
+ type: 'string',
17792
+ required: true
17793
+ }, {
17794
+ name: 'startingBalance',
17795
+ type: 'bigNumber',
17796
+ required: true
17797
+ }]);
17798
+ return {
17799
+ type: 'StellarCreateAccountOp',
17800
+ source_account: op.source,
17801
+ new_account: op.destination,
17802
+ starting_balance: op.startingBalance
17803
+ };
17804
+
17805
+ case 'payment':
17806
+ validateParams(op, [{
17807
+ name: 'destination',
17808
+ type: 'string',
17809
+ required: true
17810
+ }, {
17811
+ name: 'amount',
17812
+ type: 'bigNumber',
17813
+ required: true
17814
+ }, {
17815
+ name: 'asset',
17816
+ required: true
17817
+ }]);
17818
+ return {
17819
+ type: 'StellarPaymentOp',
17820
+ source_account: op.source,
17821
+ destination_account: op.destination,
17822
+ asset: op.asset,
17823
+ amount: op.amount
17824
+ };
17825
+
17826
+ case 'pathPayment':
17827
+ validateParams(op, [{
17828
+ name: 'destAmount',
17829
+ type: 'bigNumber',
17830
+ required: true
17831
+ }]);
17832
+ return {
17833
+ type: 'StellarPathPaymentOp',
17834
+ source_account: op.source,
17835
+ send_asset: op.sendAsset,
17836
+ send_max: op.sendMax,
17837
+ destination_account: op.destination,
17838
+ destination_asset: op.destAsset,
17839
+ destination_amount: op.destAmount,
17840
+ paths: op.path
17841
+ };
17842
+
17843
+ case 'createPassiveOffer':
17844
+ validateParams(op, [{
17845
+ name: 'amount',
17846
+ type: 'bigNumber',
17847
+ required: true
17848
+ }]);
17849
+ return {
17850
+ type: 'StellarCreatePassiveOfferOp',
17851
+ source_account: op.source,
17852
+ buying_asset: op.buying,
17853
+ selling_asset: op.selling,
17854
+ amount: op.amount,
17855
+ price_n: op.price.n,
17856
+ price_d: op.price.d
17857
+ };
17858
+
17859
+ case 'manageOffer':
17860
+ validateParams(op, [{
17861
+ name: 'amount',
17862
+ type: 'bigNumber',
17863
+ required: true
17864
+ }]);
17865
+ return {
17866
+ type: 'StellarManageOfferOp',
17867
+ source_account: op.source,
17868
+ buying_asset: op.buying,
17869
+ selling_asset: op.selling,
17870
+ amount: op.amount,
17871
+ offer_id: op.offerId,
17872
+ price_n: op.price.n,
17873
+ price_d: op.price.d
17874
+ };
17875
+
17876
+ case 'setOptions':
17877
+ {
17878
+ const signer = op.signer ? {
17879
+ signer_type: op.signer.type,
17880
+ signer_key: op.signer.key,
17881
+ signer_weight: op.signer.weight
17882
+ } : undefined;
17883
+ return Object.assign({
17884
+ type: 'StellarSetOptionsOp',
17885
+ source_account: op.source,
17886
+ clear_flags: op.clearFlags,
17887
+ set_flags: op.setFlags,
17888
+ master_weight: op.masterWeight,
17889
+ low_threshold: op.lowThreshold,
17890
+ medium_threshold: op.medThreshold,
17891
+ high_threshold: op.highThreshold,
17892
+ home_domain: op.homeDomain,
17893
+ inflation_destination_account: op.inflationDest
17894
+ }, signer);
17895
+ }
17896
+
17897
+ case 'changeTrust':
17898
+ validateParams(op, [{
17899
+ name: 'limit',
17900
+ type: 'bigNumber'
17901
+ }]);
17902
+ return {
17903
+ type: 'StellarChangeTrustOp',
17904
+ source_account: op.source,
17905
+ asset: op.line,
17906
+ limit: op.limit
17907
+ };
17908
+
17909
+ case 'allowTrust':
17910
+ return {
17911
+ type: 'StellarAllowTrustOp',
17912
+ source_account: op.source,
17913
+ trusted_account: op.trustor,
17914
+ asset_type: op.assetType,
17915
+ asset_code: op.assetCode,
17916
+ is_authorized: op.authorize ? 1 : 0
17917
+ };
17918
+
17919
+ case 'accountMerge':
17920
+ return {
17921
+ type: 'StellarAccountMergeOp',
17922
+ source_account: op.source,
17923
+ destination_account: op.destination
17924
+ };
17925
+
17926
+ case 'manageData':
17927
+ return {
17928
+ type: 'StellarManageDataOp',
17929
+ source_account: op.source,
17930
+ key: op.name,
17931
+ value: op.value
17932
+ };
17933
+
17934
+ case 'bumpSequence':
17935
+ return {
17936
+ type: 'StellarBumpSequenceOp',
17937
+ source_account: op.source,
17938
+ bump_to: op.bumpTo
17939
+ };
17940
+
17941
+ default:
17942
+ return {};
17943
+ }
17944
+ };
17945
+
17946
+ this.processTxRequest = (operations, index) => __awaiter(this, void 0, void 0, function* () {
17947
+ const isLastOp = index + 1 >= operations.length;
17948
+
17949
+ const _a = operations[index],
17950
+ {
17951
+ type
17952
+ } = _a,
17953
+ op = __rest(_a, ["type"]);
17954
+
17955
+ if (isLastOp) {
17956
+ const response = yield this.device.commands.typedCall(type, 'StellarSignedTx', op);
17957
+ return response.message;
17958
+ }
17959
+
17960
+ yield this.device.commands.typedCall(type, 'StellarTxOpRequest', op);
17961
+ return this.processTxRequest(operations, index + 1);
17962
+ });
17963
+ }
17964
+
17965
+ init() {
17966
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17967
+ validateParams(this.payload, [{
17968
+ name: 'path',
17969
+ required: true
17970
+ }, {
17971
+ name: 'networkPassphrase',
17972
+ type: 'string',
17973
+ required: true
17974
+ }, {
17975
+ name: 'transaction',
17976
+ type: 'object',
17977
+ required: true
17978
+ }]);
17979
+ const addressN = validatePath(this.payload.path, 3);
17980
+ const {
17981
+ transaction,
17982
+ networkPassphrase
17983
+ } = this.payload;
17984
+ this.params = {
17985
+ address_n: addressN,
17986
+ network_passphrase: networkPassphrase,
17987
+ source_account: transaction.source,
17988
+ fee: transaction.fee,
17989
+ sequence_number: transaction.sequence,
17990
+ num_operations: transaction.operations.length
17991
+ };
17992
+
17993
+ if (transaction.timebounds) {
17994
+ this.params.timebounds_start = transaction.timebounds.minTime;
17995
+ this.params.timebounds_end = transaction.timebounds.maxTime;
17996
+ }
17997
+
17998
+ if (transaction.memo) {
17999
+ this.params.memo_type = transaction.memo.type;
18000
+ this.params.memo_text = transaction.memo.text;
18001
+ this.params.memo_id = transaction.memo.id;
18002
+ this.params.memo_hash = transaction.memo.hash;
18003
+ }
18004
+
18005
+ transaction.operations.forEach(op => {
18006
+ const transformed = this.parseOperation(op);
18007
+
18008
+ if (transformed) {
18009
+ this.operations.push(transformed);
18010
+ }
18011
+ });
18012
+ console.log('StellarSignTransactionParams', this.params);
18013
+ console.log('StellarSignTransactionOperations', this.operations);
18014
+ }
18015
+
18016
+ run() {
18017
+ return __awaiter(this, void 0, void 0, function* () {
18018
+ yield this.device.commands.typedCall('StellarSignTx', 'StellarTxOpRequest', Object.assign({}, this.params));
18019
+ return this.processTxRequest(this.operations, 0);
18020
+ });
18021
+ }
18022
+
18023
+ }
18024
+
18025
+ var ApiMethods = /*#__PURE__*/Object.freeze({
18026
+ __proto__: null,
18027
+ searchDevices: SearchDevices,
18028
+ getFeatures: GetFeatures,
18029
+ cipherKeyValue: CipherKeyValue,
18030
+ btcGetAddress: BTCGetAddress,
18031
+ btcGetPublicKey: BTCGetPublicKey,
18032
+ btcSignMessage: BTCSignMessage,
18033
+ btcSignTransaction: BTCSignTransaction,
18034
+ btcVerifyMessage: BTCVerifyMessage,
18035
+ checkFirmwareRelease: CheckFirmwareRelease,
18036
+ checkBLEFirmwareRelease: CheckBLEFirmwareRelease,
18037
+ checkTransportRelease: CheckTransportRelease,
18038
+ deviceBackup: DeviceBackup,
18039
+ deviceChangePin: DeviceChangePin,
18040
+ deviceFlags: DeviceFlags,
18041
+ deviceRebootToBootloader: DeviceRebootToBootloader,
18042
+ deviceRecovery: DeviceRecovery,
18043
+ deviceReset: DeviceReset,
18044
+ deviceSettings: DeviceSettings,
18045
+ deviceUpdateReboot: DeviceUpdateReboot,
18046
+ deviceWipe: DeviceWipe,
18047
+ evmGetAddress: EvmGetAddress,
18048
+ evmGetPublicKey: EVMGetPublicKey,
18049
+ evmSignMessage: EVMSignMessage$2,
18050
+ evmSignMessageEIP712: EVMSignMessageEIP712,
18051
+ evmSignTransaction: EVMSignTransaction,
18052
+ evmSignTypedData: EVMSignTypedData,
18053
+ evmVerifyMessage: EVMSignMessage$1,
18054
+ starcoinGetAddress: StarcoinGetAddress,
18055
+ starcoinGetPublicKey: StarcoinGetPublicKey,
18056
+ starcoinSignMessage: StarcoinSignMessage,
18057
+ starcoinSignTransaction: StarcoinSignTransaction,
18058
+ starcoinVerifyMessage: EVMSignMessage,
18059
+ nemGetAddress: NEMGetAddress,
18060
+ nemSignTransaction: NEMSignTransaction,
18061
+ solGetAddress: SolGetAddress,
18062
+ solSignTransaction: SolSignTransaction,
18063
+ stellarGetAddress: StellarGetAddress,
18064
+ stellarSignTransaction: StellarSignTransaction
18065
+ });
18066
+
18067
+ function findMethod(message) {
18068
+ const {
18069
+ method
18070
+ } = message.payload;
18071
+
18072
+ if (typeof method !== 'string') {
18073
+ throw TypedError('Method_InvalidParameter', 'Method is not set');
18074
+ }
18075
+
18076
+ const MethodConstructor = ApiMethods[method];
18077
+
18078
+ if (MethodConstructor) {
18079
+ return new MethodConstructor(message);
18080
+ }
18081
+
18082
+ throw TypedError('Method_InvalidParameter', `Method ${method} is not set`);
18083
+ }
18084
+
18085
+ const resolveAfter = (msec, value) => new Promise(resolve => {
18086
+ setTimeout(resolve, msec, value);
18087
+ });
18088
+
18089
+ const Log$1 = initLog('DeviceConnector');
18090
+
18091
+ const getDiff = (current, descriptors) => {
18092
+ const env = DataManager.getSettings('env');
18093
+
18094
+ if (env === 'react-native') {
18095
+ return {
18096
+ descriptors
18097
+ };
18098
+ }
17171
18099
 
17172
18100
  const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
17173
18101
  const disconnected = current.filter(d => descriptors.find(x => x.path === d.path) === undefined);
@@ -17384,6 +18312,24 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
17384
18312
 
17385
18313
  try {
17386
18314
  const inner = () => __awaiter(void 0, void 0, void 0, function* () {
18315
+ const deviceType = getDeviceType(device.features);
18316
+ const deviceModel = getDeviceModel(device.features);
18317
+ const versionRangeType = method.getVersionRange()[deviceType];
18318
+ const versionRangeModel = method.getVersionRange()[deviceModel];
18319
+ const versionRange = versionRangeType !== null && versionRangeType !== void 0 ? versionRangeType : versionRangeModel;
18320
+
18321
+ if (versionRange && device.features) {
18322
+ const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
18323
+
18324
+ if (semver__default["default"].valid(versionRange.min) && semver__default["default"].lt(currentVersion, versionRange.min)) {
18325
+ return Promise.reject(TypedError('Device_FwException', `Device firmware version is too low, please update to ${versionRange.min}`));
18326
+ }
18327
+
18328
+ if (versionRange.max && semver__default["default"].valid(versionRange.max) && semver__default["default"].gt(currentVersion, versionRange.max)) {
18329
+ return Promise.reject(TypedError('Device_FwException', `Device firmware version is too high, this method has been deprecated in ${versionRange.max}`));
18330
+ }
18331
+ }
18332
+
17387
18333
  const unexpectedMode = device.hasUnexpectedMode(method.allowDeviceMode, method.requireDeviceMode);
17388
18334
 
17389
18335
  if (unexpectedMode) {
@@ -17421,6 +18367,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
17421
18367
  } catch (error) {
17422
18368
  messageResponse = createResponseMessage(method.responseID, false, error);
17423
18369
  _callPromise === null || _callPromise === void 0 ? void 0 : _callPromise.reject(TypedError('Call_API', error));
18370
+ Log.debug('Call API - Run Error: ', error);
17424
18371
  } finally {
17425
18372
  const response = messageResponse;
17426
18373
 
@@ -17519,9 +18466,17 @@ const onDeviceButtonHandler = (...[device, request]) => {
17519
18466
  postMessage(createDeviceMessage(DEVICE.BUTTON, Object.assign(Object.assign({}, request), {
17520
18467
  device: device.toMessageObject()
17521
18468
  })));
17522
- postMessage(createUiMessage(UI_REQUEST$1.REQUEST_BUTTON, {
17523
- device: device.toMessageObject()
17524
- }));
18469
+
18470
+ if (request.code === 'ButtonRequest_PinEntry') {
18471
+ postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PIN, {
18472
+ device: device.toMessageObject(),
18473
+ type: 'ButtonRequest_PinEntry'
18474
+ }));
18475
+ } else {
18476
+ postMessage(createUiMessage(UI_REQUEST$1.REQUEST_BUTTON, {
18477
+ device: device.toMessageObject()
18478
+ }));
18479
+ }
17525
18480
  };
17526
18481
 
17527
18482
  const postMessage = message => {