@onekeyfe/hd-web-sdk 0.1.57 → 0.1.58

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.
@@ -6177,6 +6177,12 @@ const getPassphraseState = (features, commands) => __awaiter(void 0, void 0, voi
6177
6177
  const supportBatchPublicKey = features => {
6178
6178
  if (!features) return false;
6179
6179
  const currentVersion = getDeviceFirmwareVersion(features).join('.');
6180
+ const deviceType = getDeviceType(features);
6181
+
6182
+ if (deviceType === 'touch' || deviceType === 'pro') {
6183
+ return semver__default["default"].gte(currentVersion, '3.1.0');
6184
+ }
6185
+
6180
6186
  return semver__default["default"].gte(currentVersion, '2.6.0');
6181
6187
  };
6182
6188
 
@@ -16540,7 +16546,13 @@ class DeviceCommands {
16540
16546
  }
16541
16547
 
16542
16548
  _filterCommonTypes(res, callType) {
16543
- Log$6.debug('_filterCommonTypes: ', res);
16549
+ try {
16550
+ if (DataManager.getSettings('env') === 'react-native') {
16551
+ Log$6.debug('_filterCommonTypes: ', JSON.stringify(res));
16552
+ } else {
16553
+ Log$6.debug('_filterCommonTypes: ', res);
16554
+ }
16555
+ } catch (error) {}
16544
16556
 
16545
16557
  if (res.type === 'Failure') {
16546
16558
  const {
@@ -18257,7 +18269,7 @@ const getInfo = ({
18257
18269
  return findLatestRelease(releaseInfo);
18258
18270
  };
18259
18271
 
18260
- const Log$3 = getLogger(exports.d0.Device);
18272
+ getLogger(exports.d0.Device);
18261
18273
 
18262
18274
  const postConfirmationMessage = device => {
18263
18275
  var _a;
@@ -18394,12 +18406,7 @@ const updateResources = (typedCall, postMessage, device, source) => __awaiter(vo
18394
18406
 
18395
18407
  if (!file.dir && fileName.indexOf('__MACOSX') === -1 && name) {
18396
18408
  const data = yield file.async('arraybuffer');
18397
-
18398
- try {
18399
- yield updateResource(typedCall, name, data);
18400
- } catch (error) {
18401
- Log$3.error(error);
18402
- }
18409
+ yield updateResource(typedCall, name, data);
18403
18410
  }
18404
18411
 
18405
18412
  progress += stepProgress;
@@ -18485,6 +18492,8 @@ class FirmwareUpdate$1 extends BaseMethod {
18485
18492
 
18486
18493
  }
18487
18494
 
18495
+ const Log$3 = getLogger(exports.d0.Method);
18496
+
18488
18497
  class FirmwareUpdate extends BaseMethod {
18489
18498
  constructor() {
18490
18499
  super(...arguments);
@@ -18536,25 +18545,37 @@ class FirmwareUpdate extends BaseMethod {
18536
18545
  }
18537
18546
  }
18538
18547
 
18539
- checkDeviceToBootloader() {
18548
+ checkDeviceToBootloader(connectId) {
18540
18549
  this.checkPromise = hdShared.createDeferred();
18550
+ const env = DataManager.getSettings('env');
18551
+ const isBleReconnect = connectId && env === 'react-native';
18552
+ Log$3.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
18541
18553
  const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
18542
- var _a, _b, _c, _d;
18554
+ var _a, _b, _c, _d, _e, _f, _g;
18543
18555
 
18544
- const deviceDiff = yield (_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.enumerate();
18545
- const devicesDescriptor = (_b = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _b !== void 0 ? _b : [];
18546
- const {
18547
- deviceList
18548
- } = yield DevicePool.getDevices(devicesDescriptor, this.connectId);
18549
- console.log('device list: ', deviceList);
18556
+ if (isBleReconnect) {
18557
+ yield this.device.acquire();
18558
+ yield this.device.initialize();
18550
18559
 
18551
- if (deviceList.length === 1 && ((_c = deviceList[0].features) === null || _c === void 0 ? void 0 : _c.bootloader_mode)) {
18552
- this.device.updateFromCache(deviceList[0]);
18553
- this.device.commands.disposed = false;
18554
- clearInterval(intervalTimer);
18555
- (_d = this.checkPromise) === null || _d === void 0 ? void 0 : _d.resolve(true);
18560
+ if ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.bootloader_mode) {
18561
+ clearInterval(intervalTimer);
18562
+ (_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.resolve(true);
18563
+ }
18564
+ } else {
18565
+ const deviceDiff = yield (_c = this.device.deviceConnector) === null || _c === void 0 ? void 0 : _c.enumerate();
18566
+ const devicesDescriptor = (_d = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _d !== void 0 ? _d : [];
18567
+ const {
18568
+ deviceList
18569
+ } = yield DevicePool.getDevices(devicesDescriptor, connectId);
18570
+
18571
+ if (deviceList.length === 1 && ((_f = (_e = deviceList[0]) === null || _e === void 0 ? void 0 : _e.features) === null || _f === void 0 ? void 0 : _f.bootloader_mode)) {
18572
+ this.device.updateFromCache(deviceList[0]);
18573
+ this.device.commands.disposed = false;
18574
+ clearInterval(intervalTimer);
18575
+ (_g = this.checkPromise) === null || _g === void 0 ? void 0 : _g.resolve(true);
18576
+ }
18556
18577
  }
18557
- }), 2000);
18578
+ }), isBleReconnect ? 3000 : 2000);
18558
18579
  setTimeout(() => {
18559
18580
  if (this.checkPromise) {
18560
18581
  clearInterval(intervalTimer);
@@ -18618,7 +18639,7 @@ class FirmwareUpdate extends BaseMethod {
18618
18639
  this.postTipMessage('AutoRebootToBootloader');
18619
18640
  yield commands.typedCall('DeviceBackToBoot', 'Success');
18620
18641
  this.postTipMessage('GoToBootloaderSuccess');
18621
- this.checkDeviceToBootloader();
18642
+ this.checkDeviceToBootloader(this.payload.connectId);
18622
18643
 
18623
18644
  if (deviceType === 'classic') {
18624
18645
  DevicePool.clearDeviceCache(uuid);
@@ -22750,6 +22771,12 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
22750
22771
  const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
22751
22772
 
22752
22773
  if (semver__default["default"].valid(versionRange.min) && semver__default["default"].lt(currentVersion, versionRange.min)) {
22774
+ const newVersionUnReleased = DataManager.getFirmwareStatus(device.features);
22775
+
22776
+ if (newVersionUnReleased === 'none' || newVersionUnReleased === 'valid') {
22777
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NewFirmwareUnRelease);
22778
+ }
22779
+
22753
22780
  return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware, `Device firmware version is too low, please update to ${versionRange.min}`, {
22754
22781
  current: currentVersion,
22755
22782
  require: versionRange.min
@@ -24628,6 +24655,7 @@ const HardwareErrorCode = {
24628
24655
  FirmwareUpdateLimitOneDevice: 409,
24629
24656
  FirmwareUpdateManuallyEnterBoot: 410,
24630
24657
  FirmwareUpdateAutoEnterBootFailure: 411,
24658
+ NewFirmwareUnRelease: 412,
24631
24659
  NetworkError: 500,
24632
24660
  TransportNotConfigured: 600,
24633
24661
  TransportCallInProgress: 601,
@@ -24691,6 +24719,7 @@ const HardwareErrorCodeMessage = {
24691
24719
  [HardwareErrorCode.FirmwareUpdateLimitOneDevice]: 'Only one device can be connected during firmware upgrade',
24692
24720
  [HardwareErrorCode.FirmwareUpdateManuallyEnterBoot]: 'You need to manually enter boot',
24693
24721
  [HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure]: 'Description Failed to automatically enter boot',
24722
+ [HardwareErrorCode.NewFirmwareUnRelease]: 'new firmware has not been released yet',
24694
24723
  [HardwareErrorCode.NetworkError]: 'Network request error',
24695
24724
  [HardwareErrorCode.TransportNotConfigured]: 'Transport not configured',
24696
24725
  [HardwareErrorCode.TransportCallInProgress]: 'Transport call in progress',
@@ -46941,7 +46970,7 @@ try {
46941
46970
  /***/ ((module) => {
46942
46971
 
46943
46972
  "use strict";
46944
- module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.57","description":"> TODO: description","author":"OneKey","homepage":"https://github.com/OneKeyHQ/hardware-js-sdk#readme","license":"ISC","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/OneKeyHQ/hardware-js-sdk.git"},"publishConfig":{"access":"public"},"scripts":{"dev":"rimraf dist && rollup -c ../../build/rollup.config.js -w","build":"rimraf dist && rollup -c ../../build/rollup.config.js","lint":"eslint .","lint:fix":"eslint . --fix"},"bugs":{"url":"https://github.com/OneKeyHQ/hardware-js-sdk/issues"},"dependencies":{"@onekeyfe/hd-shared":"^0.1.57","@onekeyfe/hd-transport":"^0.1.57","axios":"^0.27.2","bignumber.js":"^9.0.2","jszip":"^3.10.1","parse-uri":"^1.0.7","semver":"^7.3.7"},"peerDependencies":{"@noble/hashes":"^1.1.3"},"devDependencies":{"@noble/hashes":"^1.1.3","@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9"}}');
46973
+ module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.58","description":"> TODO: description","author":"OneKey","homepage":"https://github.com/OneKeyHQ/hardware-js-sdk#readme","license":"ISC","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/OneKeyHQ/hardware-js-sdk.git"},"publishConfig":{"access":"public"},"scripts":{"dev":"rimraf dist && rollup -c ../../build/rollup.config.js -w","build":"rimraf dist && rollup -c ../../build/rollup.config.js","lint":"eslint .","lint:fix":"eslint . --fix"},"bugs":{"url":"https://github.com/OneKeyHQ/hardware-js-sdk/issues"},"dependencies":{"@onekeyfe/hd-shared":"^0.1.58","@onekeyfe/hd-transport":"^0.1.58","axios":"^0.27.2","bignumber.js":"^9.0.2","jszip":"^3.10.1","parse-uri":"^1.0.7","semver":"^7.3.7"},"peerDependencies":{"@noble/hashes":"^1.1.3"},"devDependencies":{"@noble/hashes":"^1.1.3","@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9"}}');
46945
46974
 
46946
46975
  /***/ })
46947
46976
 
@@ -49468,7 +49497,7 @@ const src_init = async settings => {
49468
49497
 
49469
49498
  try {
49470
49499
  await init({ ..._settings,
49471
- version: "0.1.57"
49500
+ version: "0.1.58"
49472
49501
  });
49473
49502
  return true;
49474
49503
  } catch (e) {