@onekeyfe/hd-core 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.
- package/dist/api/FirmwareUpdateV2.d.ts +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.js +46 -21
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV2.ts +36 -18
- package/src/api/firmware/uploadFirmware.ts +1 -5
- package/src/core/index.ts +5 -0
- package/src/device/DeviceCommands.ts +10 -1
- package/src/utils/deviceFeaturesUtils.ts +5 -7
|
@@ -10,7 +10,7 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
10
10
|
checkPromise: Deferred<any> | null;
|
|
11
11
|
init(): void;
|
|
12
12
|
postTipMessage: (message: string) => void;
|
|
13
|
-
checkDeviceToBootloader(): void;
|
|
13
|
+
checkDeviceToBootloader(connectId: string | undefined): void;
|
|
14
14
|
isEnteredManuallyBoot(features: Features): boolean;
|
|
15
15
|
isSupportResourceUpdate(features: Features, updateType: string): boolean;
|
|
16
16
|
run(): Promise<import("packages/hd-transport/dist").Success>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV2.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItD,aAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;CAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV2.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItD,aAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;CAChC,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC5D,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI;IAoCJ,cAAc,YAAa,MAAM,UAS/B;IAEF,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IA6CrD,qBAAqB,CAAC,QAAQ,EAAE,QAAQ;IAUxC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM;IAUxD,GAAG;CA4FV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFirmware.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/uploadFirmware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAU,WAAW,EAA+B,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,6BAA6B,CAAC;AAyCnF,eAAO,MAAM,cAAc,eAAsB,MAAM,kBAKtD,CAAC;AAEF,eAAO,MAAM,cAAc,eACb,UAAU,GAAG,KAAK,aACnB,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM,eACD,MAAM,cAAc,qBAgDlC,CAAC;AAmCF,eAAO,MAAM,cAAc,cAAqB,SAAS,YAAY,MAAM,QAAQ,WAAW,qBAY7F,CAAC;AAEF,eAAO,MAAM,eAAe,cACf,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM,UACN,WAAW,
|
|
1
|
+
{"version":3,"file":"uploadFirmware.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/uploadFirmware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAU,WAAW,EAA+B,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,6BAA6B,CAAC;AAyCnF,eAAO,MAAM,cAAc,eAAsB,MAAM,kBAKtD,CAAC;AAEF,eAAO,MAAM,cAAc,eACb,UAAU,GAAG,KAAK,aACnB,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM,eACD,MAAM,cAAc,qBAgDlC,CAAC;AAmCF,eAAO,MAAM,cAAc,cAAqB,SAAS,YAAY,MAAM,QAAQ,WAAW,qBAY7F,CAAC;AAEF,eAAO,MAAM,eAAe,cACf,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM,UACN,WAAW,qBAwBpB,CAAC"}
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA2BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA2BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA+PjD,CAAC;AAgLF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AA8IF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA8CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCommands.d.ts","sourceRoot":"","sources":["../../src/device/DeviceCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAe,MAAM,wBAAwB,CAAC;AAK/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,aAAK,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;AACxC,aAAK,UAAU,GAAG,MAAM,WAAW,CAAC;AACpC,oBAAY,oBAAoB,CAAC,CAAC,SAAS,UAAU,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CACzB,CAAC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AE/B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAOpC,OAAO,CAAC,aAAa,EAAE,OAAO;IAU9B,IAAI,CACR,IAAI,EAAE,UAAU,EAChB,GAAG,GAAE,sBAAsB,CAAC,SAAS,CAAM,GAC1C,OAAO,CAAC,sBAAsB,CAAC;IAkBlC,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EAAE,EACpD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,CAAC,EACV,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3C,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EAClD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,CAAC,EACV,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAuC7B,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC;IAK3E,kBAAkB,CAChB,GAAG,EAAE,sBAAsB,EAC3B,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,sBAAsB,CAAC;IAgHlC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,oBAAoB;IAwB/C,iBAAiB;CA2BlB;AAED,oBAAY,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -842,6 +842,10 @@ const supportBatchPublicKey = (features) => {
|
|
|
842
842
|
if (!features)
|
|
843
843
|
return false;
|
|
844
844
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
845
|
+
const deviceType = getDeviceType(features);
|
|
846
|
+
if (deviceType === 'touch' || deviceType === 'pro') {
|
|
847
|
+
return semver__default["default"].gte(currentVersion, '3.1.0');
|
|
848
|
+
}
|
|
845
849
|
return semver__default["default"].gte(currentVersion, '2.6.0');
|
|
846
850
|
};
|
|
847
851
|
|
|
@@ -11088,7 +11092,16 @@ class DeviceCommands {
|
|
|
11088
11092
|
});
|
|
11089
11093
|
}
|
|
11090
11094
|
_filterCommonTypes(res, callType) {
|
|
11091
|
-
|
|
11095
|
+
try {
|
|
11096
|
+
if (DataManager.getSettings('env') === 'react-native') {
|
|
11097
|
+
Log$6.debug('_filterCommonTypes: ', JSON.stringify(res));
|
|
11098
|
+
}
|
|
11099
|
+
else {
|
|
11100
|
+
Log$6.debug('_filterCommonTypes: ', res);
|
|
11101
|
+
}
|
|
11102
|
+
}
|
|
11103
|
+
catch (error) {
|
|
11104
|
+
}
|
|
11092
11105
|
if (res.type === 'Failure') {
|
|
11093
11106
|
const { code, message } = res.message;
|
|
11094
11107
|
let error = null;
|
|
@@ -12458,7 +12471,7 @@ const getInfo = ({ features, updateType }) => {
|
|
|
12458
12471
|
return findLatestRelease(releaseInfo);
|
|
12459
12472
|
};
|
|
12460
12473
|
|
|
12461
|
-
|
|
12474
|
+
getLogger(exports.LoggerNames.Device);
|
|
12462
12475
|
const postConfirmationMessage = (device) => {
|
|
12463
12476
|
var _a;
|
|
12464
12477
|
if ((_a = device.features) === null || _a === void 0 ? void 0 : _a.firmware_present) {
|
|
@@ -12562,12 +12575,7 @@ const updateResources = (typedCall, postMessage, device, source) => __awaiter(vo
|
|
|
12562
12575
|
const name = fileName.split('/').pop();
|
|
12563
12576
|
if (!file.dir && fileName.indexOf('__MACOSX') === -1 && name) {
|
|
12564
12577
|
const data = yield file.async('arraybuffer');
|
|
12565
|
-
|
|
12566
|
-
yield updateResource(typedCall, name, data);
|
|
12567
|
-
}
|
|
12568
|
-
catch (error) {
|
|
12569
|
-
Log$3.error(error);
|
|
12570
|
-
}
|
|
12578
|
+
yield updateResource(typedCall, name, data);
|
|
12571
12579
|
}
|
|
12572
12580
|
progress += stepProgress;
|
|
12573
12581
|
postProgressMessage(device, Math.floor(progress), postMessage);
|
|
@@ -12627,6 +12635,7 @@ class FirmwareUpdate$1 extends BaseMethod {
|
|
|
12627
12635
|
}
|
|
12628
12636
|
}
|
|
12629
12637
|
|
|
12638
|
+
const Log$3 = getLogger(exports.LoggerNames.Method);
|
|
12630
12639
|
class FirmwareUpdate extends BaseMethod {
|
|
12631
12640
|
constructor() {
|
|
12632
12641
|
super(...arguments);
|
|
@@ -12660,21 +12669,33 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
12660
12669
|
this.params = Object.assign(Object.assign({}, this.params), { binary: payload.binary });
|
|
12661
12670
|
}
|
|
12662
12671
|
}
|
|
12663
|
-
checkDeviceToBootloader() {
|
|
12672
|
+
checkDeviceToBootloader(connectId) {
|
|
12664
12673
|
this.checkPromise = hdShared.createDeferred();
|
|
12674
|
+
const env = DataManager.getSettings('env');
|
|
12675
|
+
const isBleReconnect = connectId && env === 'react-native';
|
|
12676
|
+
Log$3.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
12665
12677
|
const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
12666
|
-
var _a, _b, _c, _d;
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
clearInterval(intervalTimer);
|
|
12675
|
-
(_d = this.checkPromise) === null || _d === void 0 ? void 0 : _d.resolve(true);
|
|
12678
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12679
|
+
if (isBleReconnect) {
|
|
12680
|
+
yield this.device.acquire();
|
|
12681
|
+
yield this.device.initialize();
|
|
12682
|
+
if ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.bootloader_mode) {
|
|
12683
|
+
clearInterval(intervalTimer);
|
|
12684
|
+
(_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.resolve(true);
|
|
12685
|
+
}
|
|
12676
12686
|
}
|
|
12677
|
-
|
|
12687
|
+
else {
|
|
12688
|
+
const deviceDiff = yield ((_c = this.device.deviceConnector) === null || _c === void 0 ? void 0 : _c.enumerate());
|
|
12689
|
+
const devicesDescriptor = (_d = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _d !== void 0 ? _d : [];
|
|
12690
|
+
const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, connectId);
|
|
12691
|
+
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)) {
|
|
12692
|
+
this.device.updateFromCache(deviceList[0]);
|
|
12693
|
+
this.device.commands.disposed = false;
|
|
12694
|
+
clearInterval(intervalTimer);
|
|
12695
|
+
(_g = this.checkPromise) === null || _g === void 0 ? void 0 : _g.resolve(true);
|
|
12696
|
+
}
|
|
12697
|
+
}
|
|
12698
|
+
}), isBleReconnect ? 3000 : 2000);
|
|
12678
12699
|
setTimeout(() => {
|
|
12679
12700
|
if (this.checkPromise) {
|
|
12680
12701
|
clearInterval(intervalTimer);
|
|
@@ -12725,7 +12746,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
12725
12746
|
this.postTipMessage('AutoRebootToBootloader');
|
|
12726
12747
|
yield commands.typedCall('DeviceBackToBoot', 'Success');
|
|
12727
12748
|
this.postTipMessage('GoToBootloaderSuccess');
|
|
12728
|
-
this.checkDeviceToBootloader();
|
|
12749
|
+
this.checkDeviceToBootloader(this.payload.connectId);
|
|
12729
12750
|
if (deviceType === 'classic') {
|
|
12730
12751
|
DevicePool.clearDeviceCache(uuid);
|
|
12731
12752
|
}
|
|
@@ -15741,6 +15762,10 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
15741
15762
|
if (versionRange && device.features) {
|
|
15742
15763
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
15743
15764
|
if (semver__default["default"].valid(versionRange.min) && semver__default["default"].lt(currentVersion, versionRange.min)) {
|
|
15765
|
+
const newVersionUnReleased = DataManager.getFirmwareStatus(device.features);
|
|
15766
|
+
if (newVersionUnReleased === 'none' || newVersionUnReleased === 'valid') {
|
|
15767
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NewFirmwareUnRelease);
|
|
15768
|
+
}
|
|
15744
15769
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware, `Device firmware version is too low, please update to ${versionRange.min}`, { current: currentVersion, require: versionRange.min }));
|
|
15745
15770
|
}
|
|
15746
15771
|
if (versionRange.max &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,cAAc,4EAA0B,YAUpD,CAAC;AAEF,eAAO,MAAM,aAAa,4EAA0B,WAUnD,CAAC;AAEF,eAAO,MAAM,yBAAyB,4EAA0B,WACvC,CAAC;AAE1B,eAAO,MAAM,sBAAsB,iCAAoB,WAAW,GAAG,IAKpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qCAAwB,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,WAM/C,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,WAOhD,CAAC;AAKF,eAAO,MAAM,wBAAwB,aAAc,QAAQ,GAAG,SAAS,kBAOtE,CAAC;AAKF,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,aAAa,GAAG,IAQhF,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,4EAA0B,kBAW1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,aAAoB,QAAQ,YAAY,cAAc,4BAUpF,CAAC;AAEF,eAAO,MAAM,qBAAqB,4EAA0B,
|
|
1
|
+
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,cAAc,4EAA0B,YAUpD,CAAC;AAEF,eAAO,MAAM,aAAa,4EAA0B,WAUnD,CAAC;AAEF,eAAO,MAAM,yBAAyB,4EAA0B,WACvC,CAAC;AAE1B,eAAO,MAAM,sBAAsB,iCAAoB,WAAW,GAAG,IAKpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qCAAwB,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,WAM/C,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,WAOhD,CAAC;AAKF,eAAO,MAAM,wBAAwB,aAAc,QAAQ,GAAG,SAAS,kBAOtE,CAAC;AAKF,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,aAAa,GAAG,IAQhF,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,4EAA0B,kBAW1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,aAAoB,QAAQ,YAAY,cAAc,4BAUpF,CAAC;AAEF,eAAO,MAAM,qBAAqB,4EAA0B,OAU3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.1.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.1.58",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.1.58",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"jszip": "^3.10.1",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@types/parse-uri": "^1.0.0",
|
|
41
41
|
"@types/semver": "^7.3.9"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "bf3eba53bcfdb27466f20a7392970764bcb9237b"
|
|
44
44
|
}
|
|
@@ -12,7 +12,7 @@ import { validateParams } from './helpers/paramsValidator';
|
|
|
12
12
|
import { DevicePool } from '../device/DevicePool';
|
|
13
13
|
import { getBinary, getSysResourceBinary } from './firmware/getBinary';
|
|
14
14
|
import { updateResources, uploadFirmware } from './firmware/uploadFirmware';
|
|
15
|
-
import { getDeviceType, getDeviceUUID, wait } from '../utils';
|
|
15
|
+
import { getDeviceType, getDeviceUUID, wait, getLogger, LoggerNames } from '../utils';
|
|
16
16
|
import { createUiMessage } from '../events/ui-request';
|
|
17
17
|
import type { KnownDevice, Features } from '../types';
|
|
18
18
|
import { DataManager } from '../data-manager';
|
|
@@ -24,6 +24,8 @@ type Params = {
|
|
|
24
24
|
updateType: 'firmware' | 'ble';
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
const Log = getLogger(LoggerNames.Method);
|
|
28
|
+
|
|
27
29
|
export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
28
30
|
checkPromise: Deferred<any> | null = null;
|
|
29
31
|
|
|
@@ -74,25 +76,41 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
74
76
|
);
|
|
75
77
|
};
|
|
76
78
|
|
|
77
|
-
checkDeviceToBootloader() {
|
|
79
|
+
checkDeviceToBootloader(connectId: string | undefined) {
|
|
78
80
|
this.checkPromise = createDeferred();
|
|
81
|
+
const env = DataManager.getSettings('env');
|
|
82
|
+
const isBleReconnect = connectId && env === 'react-native';
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(async () => {
|
|
82
|
-
const deviceDiff = await this.device.deviceConnector?.enumerate();
|
|
83
|
-
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
84
|
-
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, this.connectId);
|
|
85
|
-
console.log('device list: ', deviceList);
|
|
86
|
-
if (deviceList.length === 1 && deviceList[0].features?.bootloader_mode) {
|
|
87
|
-
// should update current device from cache
|
|
88
|
-
// because device was reboot and had some new requests
|
|
89
|
-
this.device.updateFromCache(deviceList[0]);
|
|
90
|
-
this.device.commands.disposed = false;
|
|
84
|
+
Log.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
91
85
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
// check device goto bootloader mode
|
|
87
|
+
const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(
|
|
88
|
+
async () => {
|
|
89
|
+
if (isBleReconnect) {
|
|
90
|
+
await this.device.acquire();
|
|
91
|
+
await this.device.initialize();
|
|
92
|
+
if (this.device.features?.bootloader_mode) {
|
|
93
|
+
clearInterval(intervalTimer);
|
|
94
|
+
this.checkPromise?.resolve(true);
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
const deviceDiff = await this.device.deviceConnector?.enumerate();
|
|
98
|
+
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
99
|
+
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId);
|
|
100
|
+
|
|
101
|
+
if (deviceList.length === 1 && deviceList[0]?.features?.bootloader_mode) {
|
|
102
|
+
// should update current device from cache
|
|
103
|
+
// because device was reboot and had some new requests
|
|
104
|
+
this.device.updateFromCache(deviceList[0]);
|
|
105
|
+
this.device.commands.disposed = false;
|
|
106
|
+
|
|
107
|
+
clearInterval(intervalTimer);
|
|
108
|
+
this.checkPromise?.resolve(true);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
isBleReconnect ? 3000 : 2000
|
|
113
|
+
);
|
|
96
114
|
|
|
97
115
|
// check goto bootloader mode timeout and throw error
|
|
98
116
|
setTimeout(() => {
|
|
@@ -159,7 +177,7 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
159
177
|
this.postTipMessage('AutoRebootToBootloader');
|
|
160
178
|
await commands.typedCall('DeviceBackToBoot', 'Success');
|
|
161
179
|
this.postTipMessage('GoToBootloaderSuccess');
|
|
162
|
-
this.checkDeviceToBootloader();
|
|
180
|
+
this.checkDeviceToBootloader(this.payload.connectId);
|
|
163
181
|
|
|
164
182
|
// force clean classic device cache so that the device can initialize again
|
|
165
183
|
if (deviceType === 'classic') {
|
|
@@ -174,11 +174,7 @@ export const updateResources = async (
|
|
|
174
174
|
const name = fileName.split('/').pop();
|
|
175
175
|
if (!file.dir && fileName.indexOf('__MACOSX') === -1 && name) {
|
|
176
176
|
const data = await file.async('arraybuffer');
|
|
177
|
-
|
|
178
|
-
await updateResource(typedCall, name, data);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
Log.error(error);
|
|
181
|
-
}
|
|
177
|
+
await updateResource(typedCall, name, data);
|
|
182
178
|
}
|
|
183
179
|
|
|
184
180
|
progress += stepProgress;
|
package/src/core/index.ts
CHANGED
|
@@ -150,6 +150,11 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
150
150
|
if (versionRange && device.features) {
|
|
151
151
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
152
152
|
if (semver.valid(versionRange.min) && semver.lt(currentVersion, versionRange.min)) {
|
|
153
|
+
const newVersionUnReleased = DataManager.getFirmwareStatus(device.features);
|
|
154
|
+
if (newVersionUnReleased === 'none' || newVersionUnReleased === 'valid') {
|
|
155
|
+
throw ERRORS.TypedError(HardwareErrorCode.NewFirmwareUnRelease);
|
|
156
|
+
}
|
|
157
|
+
|
|
153
158
|
return Promise.reject(
|
|
154
159
|
ERRORS.TypedError(
|
|
155
160
|
HardwareErrorCode.CallMethodNeedUpgradeFirmware,
|
|
@@ -144,7 +144,16 @@ export class DeviceCommands {
|
|
|
144
144
|
res: DefaultMessageResponse,
|
|
145
145
|
callType: MessageKey
|
|
146
146
|
): Promise<DefaultMessageResponse> {
|
|
147
|
-
|
|
147
|
+
try {
|
|
148
|
+
if (DataManager.getSettings('env') === 'react-native') {
|
|
149
|
+
Log.debug('_filterCommonTypes: ', JSON.stringify(res));
|
|
150
|
+
} else {
|
|
151
|
+
Log.debug('_filterCommonTypes: ', res);
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
// ignore
|
|
155
|
+
}
|
|
156
|
+
|
|
148
157
|
if (res.type === 'Failure') {
|
|
149
158
|
const { code, message } = res.message as {
|
|
150
159
|
code?: string | FailureType;
|
|
@@ -134,14 +134,12 @@ export const getPassphraseState = async (features: Features, commands: DeviceCom
|
|
|
134
134
|
|
|
135
135
|
export const supportBatchPublicKey = (features?: Features): boolean => {
|
|
136
136
|
if (!features) return false;
|
|
137
|
-
|
|
138
|
-
// TODO: support batch public key for touch
|
|
139
|
-
// const deviceType = getDeviceType(features);
|
|
140
|
-
// if (deviceType === 'touch' || deviceType === 'pro') {
|
|
141
|
-
// return true;
|
|
142
|
-
// }
|
|
143
|
-
|
|
144
137
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
145
138
|
|
|
139
|
+
const deviceType = getDeviceType(features);
|
|
140
|
+
if (deviceType === 'touch' || deviceType === 'pro') {
|
|
141
|
+
return semver.gte(currentVersion, '3.1.0');
|
|
142
|
+
}
|
|
143
|
+
|
|
146
144
|
return semver.gte(currentVersion, '2.6.0');
|
|
147
145
|
};
|