@onekeyfe/hd-core 1.1.4-alpha.3 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +51 -8
- package/dist/utils/findDefectiveBatchDevice.d.ts +5 -0
- package/dist/utils/findDefectiveBatchDevice.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/core/index.ts +70 -12
- package/src/utils/findDefectiveBatchDevice.ts +29 -0
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;AAClC,OAAO,EAAY,6BAA6B,EAAoB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAY,6BAA6B,EAAoB,MAAM,wBAAwB,CAAC;AA4BnG,OAAO,EAAE,MAAM,EAAyC,MAAM,kBAAkB,CAAC;AAOjF,OAAO,EAEL,WAAW,EAWZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAMxD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAsC7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBA2DvE,CAAC;AAomBF,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SA+E9D,CAAC;AAsEF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AAsFF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,YAAY,CAAsB;IAG1C,OAAO,CAAC,qBAAqB,CAA4B;IAEzD,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,cAAc;IAkBhB,aAAa,CAAC,OAAO,EAAE,WAAW;IA0DxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAoBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
|
@@ -31,7 +31,7 @@ export declare const cancelDeviceInPrompt: (device: Device, expectResponse?: boo
|
|
|
31
31
|
};
|
|
32
32
|
} | {
|
|
33
33
|
success: boolean;
|
|
34
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
34
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
35
35
|
payload: {
|
|
36
36
|
message: string;
|
|
37
37
|
};
|
|
@@ -50,7 +50,7 @@ export declare const cancelDeviceWithInitialize: (device: Device) => Promise<{
|
|
|
50
50
|
};
|
|
51
51
|
} | {
|
|
52
52
|
success: boolean;
|
|
53
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
53
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
54
54
|
payload: {
|
|
55
55
|
message: string;
|
|
56
56
|
};
|
|
@@ -78,7 +78,7 @@ export declare class DeviceCommands {
|
|
|
78
78
|
};
|
|
79
79
|
} | {
|
|
80
80
|
success: boolean;
|
|
81
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
81
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
82
82
|
payload: {
|
|
83
83
|
message: string;
|
|
84
84
|
};
|
|
@@ -97,7 +97,7 @@ export declare class DeviceCommands {
|
|
|
97
97
|
};
|
|
98
98
|
} | {
|
|
99
99
|
success: boolean;
|
|
100
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
100
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
101
101
|
payload: {
|
|
102
102
|
message: string;
|
|
103
103
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2887,7 +2887,7 @@ declare class DeviceCommands {
|
|
|
2887
2887
|
};
|
|
2888
2888
|
} | {
|
|
2889
2889
|
success: boolean;
|
|
2890
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
2890
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
2891
2891
|
payload: {
|
|
2892
2892
|
message: string;
|
|
2893
2893
|
};
|
|
@@ -2906,7 +2906,7 @@ declare class DeviceCommands {
|
|
|
2906
2906
|
};
|
|
2907
2907
|
} | {
|
|
2908
2908
|
success: boolean;
|
|
2909
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
2909
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 900 | 901 | 902;
|
|
2910
2910
|
payload: {
|
|
2911
2911
|
message: string;
|
|
2912
2912
|
};
|
package/dist/index.js
CHANGED
|
@@ -25727,6 +25727,30 @@ const wait = (ms) => new Promise(resolve => {
|
|
|
25727
25727
|
setTimeout(resolve, ms);
|
|
25728
25728
|
});
|
|
25729
25729
|
|
|
25730
|
+
const findDefectiveBatchDevice = (features) => {
|
|
25731
|
+
if (!features)
|
|
25732
|
+
return;
|
|
25733
|
+
const { onekey_serial: onekeySerial, se_ver: seVer } = features;
|
|
25734
|
+
if (!onekeySerial)
|
|
25735
|
+
return;
|
|
25736
|
+
const versionNum = +onekeySerial.slice(5);
|
|
25737
|
+
if (Number.isNaN(versionNum))
|
|
25738
|
+
return;
|
|
25739
|
+
return versionNum >= 21032200001 && versionNum <= 21032201500 && seVer === '1.1.0.2';
|
|
25740
|
+
};
|
|
25741
|
+
const getDefectiveDeviceInfo = (features) => {
|
|
25742
|
+
if (!findDefectiveBatchDevice(features))
|
|
25743
|
+
return null;
|
|
25744
|
+
const serialNo = getDeviceUUID(features);
|
|
25745
|
+
const deviceType = getDeviceType(features);
|
|
25746
|
+
const seVersion = features.se_ver;
|
|
25747
|
+
return {
|
|
25748
|
+
serialNo,
|
|
25749
|
+
seVersion,
|
|
25750
|
+
deviceType: deviceType || 'Unknown',
|
|
25751
|
+
};
|
|
25752
|
+
};
|
|
25753
|
+
|
|
25730
25754
|
const CORE_EVENT = 'CORE_EVENT';
|
|
25731
25755
|
const parseMessage = (messageData) => {
|
|
25732
25756
|
const { data } = messageData;
|
|
@@ -38802,28 +38826,47 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
38802
38826
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
38803
38827
|
if (device.features) {
|
|
38804
38828
|
yield DataManager.checkAndReloadData();
|
|
38829
|
+
if (findDefectiveBatchDevice(device.features)) {
|
|
38830
|
+
const defectiveInfo = getDefectiveDeviceInfo(device.features);
|
|
38831
|
+
if (defectiveInfo) {
|
|
38832
|
+
throw hdShared.createDefectiveFirmwareError(defectiveInfo.serialNo, defectiveInfo.seVersion || 'Unknown', defectiveInfo.deviceType, method.connectId, method.deviceId);
|
|
38833
|
+
}
|
|
38834
|
+
}
|
|
38805
38835
|
const newVersionStatus = DataManager.getFirmwareStatus(device.features);
|
|
38806
38836
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
38837
|
+
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
38838
|
+
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|
|
38807
38839
|
if ((newVersionStatus === 'required' || bleVersionStatus === 'required') &&
|
|
38808
38840
|
method.skipForceUpdateCheck === false) {
|
|
38809
|
-
|
|
38841
|
+
const currentVersions = {
|
|
38842
|
+
firmware: currentFirmwareVersion,
|
|
38843
|
+
ble: currentBleVersion,
|
|
38844
|
+
};
|
|
38845
|
+
const requiredUpdates = [];
|
|
38846
|
+
if (newVersionStatus === 'required') {
|
|
38847
|
+
requiredUpdates.push('firmware');
|
|
38848
|
+
}
|
|
38849
|
+
if (bleVersionStatus === 'required') {
|
|
38850
|
+
requiredUpdates.push('ble');
|
|
38851
|
+
}
|
|
38852
|
+
throw hdShared.createNewFirmwareForceUpdateHardwareError(method.connectId, method.deviceId, requiredUpdates, currentVersions);
|
|
38810
38853
|
}
|
|
38811
38854
|
if (versionRange) {
|
|
38812
|
-
|
|
38813
|
-
|
|
38855
|
+
if (semver__default["default"].valid(versionRange.min) &&
|
|
38856
|
+
semver__default["default"].lt(currentFirmwareVersion, versionRange.min)) {
|
|
38814
38857
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
38815
|
-
throw hdShared.createNewFirmwareUnReleaseHardwareError(
|
|
38858
|
+
throw hdShared.createNewFirmwareUnReleaseHardwareError(currentFirmwareVersion, versionRange.min, method.name);
|
|
38816
38859
|
}
|
|
38817
|
-
return Promise.reject(hdShared.createNeedUpgradeFirmwareHardwareError(
|
|
38860
|
+
return Promise.reject(hdShared.createNeedUpgradeFirmwareHardwareError(currentFirmwareVersion, versionRange.min, method.name));
|
|
38818
38861
|
}
|
|
38819
38862
|
if (versionRange.max &&
|
|
38820
38863
|
semver__default["default"].valid(versionRange.max) &&
|
|
38821
|
-
semver__default["default"].gte(
|
|
38822
|
-
return Promise.reject(hdShared.createDeprecatedHardwareError(
|
|
38864
|
+
semver__default["default"].gte(currentFirmwareVersion, versionRange.max)) {
|
|
38865
|
+
return Promise.reject(hdShared.createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name));
|
|
38823
38866
|
}
|
|
38824
38867
|
}
|
|
38825
38868
|
else if (method.strictCheckDeviceSupport) {
|
|
38826
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod);
|
|
38869
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod, `Method '${method.name}' is not supported by this device`);
|
|
38827
38870
|
}
|
|
38828
38871
|
}
|
|
38829
38872
|
const unexpectedMode = device.hasUnexpectedMode(method.allowDeviceMode, method.requireDeviceMode);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { Features } from '../types';
|
|
2
2
|
export declare const findDefectiveBatchDevice: (features: Features) => boolean | undefined;
|
|
3
|
+
export declare const getDefectiveDeviceInfo: (features: Features) => {
|
|
4
|
+
serialNo: string;
|
|
5
|
+
seVersion: string | undefined;
|
|
6
|
+
deviceType: import("../types").IDeviceType;
|
|
7
|
+
} | null;
|
|
3
8
|
//# sourceMappingURL=findDefectiveBatchDevice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findDefectiveBatchDevice.d.ts","sourceRoot":"","sources":["../../src/utils/findDefectiveBatchDevice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findDefectiveBatchDevice.d.ts","sourceRoot":"","sources":["../../src/utils/findDefectiveBatchDevice.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAWzC,eAAO,MAAM,wBAAwB,aAAc,QAAQ,wBAU1D,CAAC;AAKF,eAAO,MAAM,sBAAsB,aAAc,QAAQ;;;;QAWxD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.1.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.6",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.6",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@noble/hashes": "^1.1.3",
|
|
39
|
-
"ripple-keypairs": "^1.1
|
|
39
|
+
"ripple-keypairs": "^1.3.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@noble/hashes": "^1.1.3",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/semver": "^7.3.9",
|
|
45
45
|
"@types/w3c-web-usb": "^1.0.10",
|
|
46
46
|
"@types/web-bluetooth": "^0.0.21",
|
|
47
|
-
"ripple-keypairs": "^1.1
|
|
47
|
+
"ripple-keypairs": "^1.3.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "e187d8cf8d616f5843dbc845543a96cc1d2ad93d"
|
|
50
50
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -3,17 +3,19 @@ import EventEmitter from 'events';
|
|
|
3
3
|
import { Features, LowlevelTransportSharedPlugin, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
|
|
4
4
|
import {
|
|
5
5
|
createDeferred,
|
|
6
|
-
createDeprecatedHardwareError,
|
|
7
|
-
createNeedUpgradeFirmwareHardwareError,
|
|
8
|
-
createNewFirmwareForceUpdateHardwareError,
|
|
9
|
-
createNewFirmwareUnReleaseHardwareError,
|
|
10
6
|
Deferred,
|
|
11
7
|
ERRORS,
|
|
12
8
|
HardwareError,
|
|
13
9
|
HardwareErrorCode,
|
|
10
|
+
createDeprecatedHardwareError,
|
|
11
|
+
createNeedUpgradeFirmwareHardwareError,
|
|
12
|
+
createNewFirmwareForceUpdateHardwareError,
|
|
13
|
+
createNewFirmwareUnReleaseHardwareError,
|
|
14
|
+
createDefectiveFirmwareError,
|
|
14
15
|
} from '@onekeyfe/hd-shared';
|
|
15
16
|
import {
|
|
16
17
|
getDeviceFirmwareVersion,
|
|
18
|
+
getDeviceBLEFirmwareVersion,
|
|
17
19
|
enableLog,
|
|
18
20
|
getLogger,
|
|
19
21
|
LoggerNames,
|
|
@@ -21,6 +23,10 @@ import {
|
|
|
21
23
|
wait,
|
|
22
24
|
getMethodVersionRange,
|
|
23
25
|
} from '../utils';
|
|
26
|
+
import {
|
|
27
|
+
findDefectiveBatchDevice,
|
|
28
|
+
getDefectiveDeviceInfo,
|
|
29
|
+
} from '../utils/findDefectiveBatchDevice';
|
|
24
30
|
import { supportNewPassphrase } from '../utils/deviceFeaturesUtils';
|
|
25
31
|
import { Device, DeviceEvents, InitOptions, RunOptions } from '../device/Device';
|
|
26
32
|
import { DeviceList } from '../device/DeviceList';
|
|
@@ -261,35 +267,87 @@ const onCallDevice = async (
|
|
|
261
267
|
|
|
262
268
|
if (device.features) {
|
|
263
269
|
await DataManager.checkAndReloadData();
|
|
270
|
+
|
|
271
|
+
// 检测故障固件设备
|
|
272
|
+
if (findDefectiveBatchDevice(device.features)) {
|
|
273
|
+
const defectiveInfo = getDefectiveDeviceInfo(device.features);
|
|
274
|
+
if (defectiveInfo) {
|
|
275
|
+
throw createDefectiveFirmwareError(
|
|
276
|
+
defectiveInfo.serialNo,
|
|
277
|
+
defectiveInfo.seVersion || 'Unknown',
|
|
278
|
+
defectiveInfo.deviceType,
|
|
279
|
+
method.connectId,
|
|
280
|
+
method.deviceId
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
264
285
|
const newVersionStatus = DataManager.getFirmwareStatus(device.features);
|
|
265
286
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
287
|
+
|
|
288
|
+
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
289
|
+
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|
|
266
290
|
if (
|
|
267
291
|
(newVersionStatus === 'required' || bleVersionStatus === 'required') &&
|
|
268
292
|
method.skipForceUpdateCheck === false
|
|
269
293
|
) {
|
|
270
|
-
|
|
294
|
+
// Get current version information for error reporting
|
|
295
|
+
const currentVersions = {
|
|
296
|
+
firmware: currentFirmwareVersion,
|
|
297
|
+
ble: currentBleVersion,
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// Provide more specific error message based on which version check failed
|
|
301
|
+
const requiredUpdates: ('firmware' | 'ble')[] = [];
|
|
302
|
+
if (newVersionStatus === 'required') {
|
|
303
|
+
requiredUpdates.push('firmware');
|
|
304
|
+
}
|
|
305
|
+
if (bleVersionStatus === 'required') {
|
|
306
|
+
requiredUpdates.push('ble');
|
|
307
|
+
}
|
|
308
|
+
throw createNewFirmwareForceUpdateHardwareError(
|
|
309
|
+
method.connectId,
|
|
310
|
+
method.deviceId,
|
|
311
|
+
requiredUpdates,
|
|
312
|
+
currentVersions
|
|
313
|
+
);
|
|
271
314
|
}
|
|
272
315
|
|
|
273
316
|
if (versionRange) {
|
|
274
|
-
|
|
275
|
-
|
|
317
|
+
if (
|
|
318
|
+
semver.valid(versionRange.min) &&
|
|
319
|
+
semver.lt(currentFirmwareVersion, versionRange.min)
|
|
320
|
+
) {
|
|
276
321
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
277
|
-
throw createNewFirmwareUnReleaseHardwareError(
|
|
322
|
+
throw createNewFirmwareUnReleaseHardwareError(
|
|
323
|
+
currentFirmwareVersion,
|
|
324
|
+
versionRange.min,
|
|
325
|
+
method.name
|
|
326
|
+
);
|
|
278
327
|
}
|
|
279
328
|
|
|
280
329
|
return Promise.reject(
|
|
281
|
-
createNeedUpgradeFirmwareHardwareError(
|
|
330
|
+
createNeedUpgradeFirmwareHardwareError(
|
|
331
|
+
currentFirmwareVersion,
|
|
332
|
+
versionRange.min,
|
|
333
|
+
method.name
|
|
334
|
+
)
|
|
282
335
|
);
|
|
283
336
|
}
|
|
284
337
|
if (
|
|
285
338
|
versionRange.max &&
|
|
286
339
|
semver.valid(versionRange.max) &&
|
|
287
|
-
semver.gte(
|
|
340
|
+
semver.gte(currentFirmwareVersion, versionRange.max)
|
|
288
341
|
) {
|
|
289
|
-
return Promise.reject(
|
|
342
|
+
return Promise.reject(
|
|
343
|
+
createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name)
|
|
344
|
+
);
|
|
290
345
|
}
|
|
291
346
|
} else if (method.strictCheckDeviceSupport) {
|
|
292
|
-
throw ERRORS.TypedError(
|
|
347
|
+
throw ERRORS.TypedError(
|
|
348
|
+
HardwareErrorCode.DeviceNotSupportMethod,
|
|
349
|
+
`Method '${method.name}' is not supported by this device`
|
|
350
|
+
);
|
|
293
351
|
}
|
|
294
352
|
}
|
|
295
353
|
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
+
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
1
2
|
import type { Features } from '../types';
|
|
3
|
+
import { getDeviceUUID, getDeviceType } from './deviceInfoUtils';
|
|
2
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 检测故障固件设备
|
|
7
|
+
* 检测规则:
|
|
8
|
+
* - 序列号范围:21032200001 到 21032201500 (从 onekey_serial 字段提取)
|
|
9
|
+
* - SE版本为 1.1.0.2
|
|
10
|
+
*
|
|
11
|
+
* 对齐之前版本的检测逻辑
|
|
12
|
+
*/
|
|
3
13
|
export const findDefectiveBatchDevice = (features: Features) => {
|
|
4
14
|
if (!features) return;
|
|
15
|
+
|
|
5
16
|
const { onekey_serial: onekeySerial, se_ver: seVer } = features;
|
|
6
17
|
if (!onekeySerial) return;
|
|
18
|
+
|
|
7
19
|
const versionNum = +onekeySerial.slice(5);
|
|
8
20
|
if (Number.isNaN(versionNum)) return;
|
|
21
|
+
|
|
9
22
|
return versionNum >= 21032200001 && versionNum <= 21032201500 && seVer === '1.1.0.2';
|
|
10
23
|
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 获取故障设备的详细信息
|
|
27
|
+
*/
|
|
28
|
+
export const getDefectiveDeviceInfo = (features: Features) => {
|
|
29
|
+
if (!findDefectiveBatchDevice(features)) return null;
|
|
30
|
+
const serialNo = getDeviceUUID(features);
|
|
31
|
+
const deviceType = getDeviceType(features);
|
|
32
|
+
const seVersion = features.se_ver;
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
serialNo,
|
|
36
|
+
seVersion,
|
|
37
|
+
deviceType: deviceType || 'Unknown',
|
|
38
|
+
};
|
|
39
|
+
};
|