@onekeyfe/hd-core 1.1.4-alpha.1 → 1.1.4-alpha.2
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 +52 -8
- package/dist/utils/findDefectiveBatchDevice.d.ts +5 -0
- package/dist/utils/findDefectiveBatchDevice.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/index.ts +79 -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;AAmCnG,OAAO,EAEL,WAAW,EAWZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAMxD,KAAK,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAsCtD,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBA2DvE,CAAC;AAkmBF,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SA2E9D,CAAC;AA2KF,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;IAWhB,aAAa,CAAC,OAAO,EAAE,WAAW;IAqDxC,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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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
|
@@ -2863,7 +2863,7 @@ declare class DeviceCommands {
|
|
|
2863
2863
|
};
|
|
2864
2864
|
} | {
|
|
2865
2865
|
success: boolean;
|
|
2866
|
-
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 | 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;
|
|
2866
|
+
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;
|
|
2867
2867
|
payload: {
|
|
2868
2868
|
message: string;
|
|
2869
2869
|
};
|
|
@@ -2882,7 +2882,7 @@ declare class DeviceCommands {
|
|
|
2882
2882
|
};
|
|
2883
2883
|
} | {
|
|
2884
2884
|
success: boolean;
|
|
2885
|
-
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 | 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;
|
|
2885
|
+
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;
|
|
2886
2886
|
payload: {
|
|
2887
2887
|
message: string;
|
|
2888
2888
|
};
|
package/dist/index.js
CHANGED
|
@@ -25699,6 +25699,30 @@ const wait = (ms) => new Promise(resolve => {
|
|
|
25699
25699
|
setTimeout(resolve, ms);
|
|
25700
25700
|
});
|
|
25701
25701
|
|
|
25702
|
+
const findDefectiveBatchDevice = (features) => {
|
|
25703
|
+
if (!features)
|
|
25704
|
+
return;
|
|
25705
|
+
const { onekey_serial: onekeySerial, se_ver: seVer } = features;
|
|
25706
|
+
if (!onekeySerial)
|
|
25707
|
+
return;
|
|
25708
|
+
const versionNum = +onekeySerial.slice(5);
|
|
25709
|
+
if (Number.isNaN(versionNum))
|
|
25710
|
+
return;
|
|
25711
|
+
return versionNum >= 21032200001 && versionNum <= 21032201500 && seVer === '1.1.0.2';
|
|
25712
|
+
};
|
|
25713
|
+
const getDefectiveDeviceInfo = (features) => {
|
|
25714
|
+
if (!findDefectiveBatchDevice(features))
|
|
25715
|
+
return null;
|
|
25716
|
+
const serialNo = getDeviceUUID(features);
|
|
25717
|
+
const deviceType = getDeviceType(features);
|
|
25718
|
+
const seVersion = features.se_ver;
|
|
25719
|
+
return {
|
|
25720
|
+
serialNo,
|
|
25721
|
+
seVersion,
|
|
25722
|
+
deviceType: deviceType || 'Unknown',
|
|
25723
|
+
};
|
|
25724
|
+
};
|
|
25725
|
+
|
|
25702
25726
|
const CORE_EVENT = 'CORE_EVENT';
|
|
25703
25727
|
const parseMessage = (messageData) => {
|
|
25704
25728
|
const { data } = messageData;
|
|
@@ -38559,28 +38583,48 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
38559
38583
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
38560
38584
|
if (device.features) {
|
|
38561
38585
|
yield DataManager.checkAndReloadData();
|
|
38586
|
+
if (findDefectiveBatchDevice(device.features)) {
|
|
38587
|
+
const defectiveInfo = getDefectiveDeviceInfo(device.features);
|
|
38588
|
+
if (defectiveInfo) {
|
|
38589
|
+
throw hdShared.createDefectiveFirmwareError(defectiveInfo.serialNo, defectiveInfo.seVersion || 'Unknown', defectiveInfo.deviceType, method.connectId, method.deviceId);
|
|
38590
|
+
}
|
|
38591
|
+
}
|
|
38562
38592
|
const newVersionStatus = DataManager.getFirmwareStatus(device.features);
|
|
38563
38593
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
38594
|
+
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
38595
|
+
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|
|
38564
38596
|
if ((newVersionStatus === 'required' || bleVersionStatus === 'required') &&
|
|
38565
38597
|
method.skipForceUpdateCheck === false) {
|
|
38566
|
-
|
|
38598
|
+
const currentVersions = {
|
|
38599
|
+
firmware: currentFirmwareVersion,
|
|
38600
|
+
ble: currentBleVersion,
|
|
38601
|
+
};
|
|
38602
|
+
if (newVersionStatus === 'required' && bleVersionStatus === 'required') {
|
|
38603
|
+
throw hdShared.createNewFirmwareForceUpdateHardwareError(method.connectId, method.deviceId, 'both', currentVersions);
|
|
38604
|
+
}
|
|
38605
|
+
else if (newVersionStatus === 'required') {
|
|
38606
|
+
throw hdShared.createNewFirmwareForceUpdateHardwareError(method.connectId, method.deviceId, 'firmware', currentVersions);
|
|
38607
|
+
}
|
|
38608
|
+
else {
|
|
38609
|
+
throw hdShared.createNewFirmwareForceUpdateHardwareError(method.connectId, method.deviceId, 'ble', currentVersions);
|
|
38610
|
+
}
|
|
38567
38611
|
}
|
|
38568
38612
|
if (versionRange) {
|
|
38569
|
-
|
|
38570
|
-
|
|
38613
|
+
if (semver__default["default"].valid(versionRange.min) &&
|
|
38614
|
+
semver__default["default"].lt(currentFirmwareVersion, versionRange.min)) {
|
|
38571
38615
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
38572
|
-
throw hdShared.createNewFirmwareUnReleaseHardwareError(
|
|
38616
|
+
throw hdShared.createNewFirmwareUnReleaseHardwareError(currentFirmwareVersion, versionRange.min, method.name);
|
|
38573
38617
|
}
|
|
38574
|
-
return Promise.reject(hdShared.createNeedUpgradeFirmwareHardwareError(
|
|
38618
|
+
return Promise.reject(hdShared.createNeedUpgradeFirmwareHardwareError(currentFirmwareVersion, versionRange.min, method.name));
|
|
38575
38619
|
}
|
|
38576
38620
|
if (versionRange.max &&
|
|
38577
38621
|
semver__default["default"].valid(versionRange.max) &&
|
|
38578
|
-
semver__default["default"].gte(
|
|
38579
|
-
return Promise.reject(hdShared.createDeprecatedHardwareError(
|
|
38622
|
+
semver__default["default"].gte(currentFirmwareVersion, versionRange.max)) {
|
|
38623
|
+
return Promise.reject(hdShared.createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name));
|
|
38580
38624
|
}
|
|
38581
38625
|
}
|
|
38582
38626
|
else if (method.strictCheckDeviceSupport) {
|
|
38583
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod);
|
|
38627
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod, `Method '${method.name}' is not supported by this device`);
|
|
38584
38628
|
}
|
|
38585
38629
|
}
|
|
38586
38630
|
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.4-alpha.
|
|
3
|
+
"version": "1.1.4-alpha.2",
|
|
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.4-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "^1.1.
|
|
28
|
+
"@onekeyfe/hd-shared": "^1.1.4-alpha.2",
|
|
29
|
+
"@onekeyfe/hd-transport": "^1.1.2",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/web-bluetooth": "^0.0.21",
|
|
47
47
|
"ripple-keypairs": "^1.1.4"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "90589e2c51eb9bd54651d77da60695f4e5a2aa50"
|
|
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';
|
|
@@ -251,35 +257,96 @@ const onCallDevice = async (
|
|
|
251
257
|
|
|
252
258
|
if (device.features) {
|
|
253
259
|
await DataManager.checkAndReloadData();
|
|
260
|
+
|
|
261
|
+
// 检测故障固件设备
|
|
262
|
+
if (findDefectiveBatchDevice(device.features)) {
|
|
263
|
+
const defectiveInfo = getDefectiveDeviceInfo(device.features);
|
|
264
|
+
if (defectiveInfo) {
|
|
265
|
+
throw createDefectiveFirmwareError(
|
|
266
|
+
defectiveInfo.serialNo,
|
|
267
|
+
defectiveInfo.seVersion || 'Unknown',
|
|
268
|
+
defectiveInfo.deviceType,
|
|
269
|
+
method.connectId,
|
|
270
|
+
method.deviceId
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
254
275
|
const newVersionStatus = DataManager.getFirmwareStatus(device.features);
|
|
255
276
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
277
|
+
|
|
278
|
+
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
279
|
+
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|
|
256
280
|
if (
|
|
257
281
|
(newVersionStatus === 'required' || bleVersionStatus === 'required') &&
|
|
258
282
|
method.skipForceUpdateCheck === false
|
|
259
283
|
) {
|
|
260
|
-
|
|
284
|
+
// Get current version information for error reporting
|
|
285
|
+
const currentVersions = {
|
|
286
|
+
firmware: currentFirmwareVersion,
|
|
287
|
+
ble: currentBleVersion,
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// Provide more specific error message based on which version check failed
|
|
291
|
+
if (newVersionStatus === 'required' && bleVersionStatus === 'required') {
|
|
292
|
+
throw createNewFirmwareForceUpdateHardwareError(
|
|
293
|
+
method.connectId,
|
|
294
|
+
method.deviceId,
|
|
295
|
+
'both',
|
|
296
|
+
currentVersions
|
|
297
|
+
);
|
|
298
|
+
} else if (newVersionStatus === 'required') {
|
|
299
|
+
throw createNewFirmwareForceUpdateHardwareError(
|
|
300
|
+
method.connectId,
|
|
301
|
+
method.deviceId,
|
|
302
|
+
'firmware',
|
|
303
|
+
currentVersions
|
|
304
|
+
);
|
|
305
|
+
} else {
|
|
306
|
+
throw createNewFirmwareForceUpdateHardwareError(
|
|
307
|
+
method.connectId,
|
|
308
|
+
method.deviceId,
|
|
309
|
+
'ble',
|
|
310
|
+
currentVersions
|
|
311
|
+
);
|
|
312
|
+
}
|
|
261
313
|
}
|
|
262
314
|
|
|
263
315
|
if (versionRange) {
|
|
264
|
-
|
|
265
|
-
|
|
316
|
+
if (
|
|
317
|
+
semver.valid(versionRange.min) &&
|
|
318
|
+
semver.lt(currentFirmwareVersion, versionRange.min)
|
|
319
|
+
) {
|
|
266
320
|
if (newVersionStatus === 'none' || newVersionStatus === 'valid') {
|
|
267
|
-
throw createNewFirmwareUnReleaseHardwareError(
|
|
321
|
+
throw createNewFirmwareUnReleaseHardwareError(
|
|
322
|
+
currentFirmwareVersion,
|
|
323
|
+
versionRange.min,
|
|
324
|
+
method.name
|
|
325
|
+
);
|
|
268
326
|
}
|
|
269
327
|
|
|
270
328
|
return Promise.reject(
|
|
271
|
-
createNeedUpgradeFirmwareHardwareError(
|
|
329
|
+
createNeedUpgradeFirmwareHardwareError(
|
|
330
|
+
currentFirmwareVersion,
|
|
331
|
+
versionRange.min,
|
|
332
|
+
method.name
|
|
333
|
+
)
|
|
272
334
|
);
|
|
273
335
|
}
|
|
274
336
|
if (
|
|
275
337
|
versionRange.max &&
|
|
276
338
|
semver.valid(versionRange.max) &&
|
|
277
|
-
semver.gte(
|
|
339
|
+
semver.gte(currentFirmwareVersion, versionRange.max)
|
|
278
340
|
) {
|
|
279
|
-
return Promise.reject(
|
|
341
|
+
return Promise.reject(
|
|
342
|
+
createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name)
|
|
343
|
+
);
|
|
280
344
|
}
|
|
281
345
|
} else if (method.strictCheckDeviceSupport) {
|
|
282
|
-
throw ERRORS.TypedError(
|
|
346
|
+
throw ERRORS.TypedError(
|
|
347
|
+
HardwareErrorCode.DeviceNotSupportMethod,
|
|
348
|
+
`Method '${method.name}' is not supported by this device`
|
|
349
|
+
);
|
|
283
350
|
}
|
|
284
351
|
}
|
|
285
352
|
|
|
@@ -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
|
+
};
|