@onekeyfe/hd-core 1.2.5 → 1.2.6-alpha.1
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/__tests__/DeviceCommands.test.ts +66 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +64 -0
- package/__tests__/device-state-mapper.test.ts +27 -3
- package/__tests__/firmware-update/firmware-update-v4-install-poll.test.ts +300 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +31 -2
- package/__tests__/protocol-v2.test.ts +131 -11
- package/__tests__/refresh-device-state.test.ts +19 -17
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +79 -45
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +101 -50
- package/src/api/GetDeviceState.ts +2 -5
- package/src/device/Device.ts +1 -1
- package/src/device/DeviceCommands.ts +15 -1
- package/src/device/DeviceStateMapper.ts +5 -3
|
@@ -549,6 +549,16 @@ export class DeviceCommands {
|
|
|
549
549
|
this.device.isProtocolV2() &&
|
|
550
550
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
551
551
|
subcode === DeviceErrorCode.DeviceError_Busy;
|
|
552
|
+
const isProtocolV2PinCancelledBusyFailure =
|
|
553
|
+
this.device.isProtocolV2() &&
|
|
554
|
+
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
555
|
+
subcode === DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
556
|
+
/^pin cancelled$/i.test(normalizedMessage);
|
|
557
|
+
const isProtocolV2FirmwareUpdateBusyFailure =
|
|
558
|
+
this.device.isProtocolV2() &&
|
|
559
|
+
/^requested command not allowed while a firmware update is in progress$/i.test(
|
|
560
|
+
normalizedMessage
|
|
561
|
+
);
|
|
552
562
|
const isLegacyProtocolV2LockedFailure =
|
|
553
563
|
this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
554
564
|
if (
|
|
@@ -606,7 +616,11 @@ export class DeviceCommands {
|
|
|
606
616
|
subcode,
|
|
607
617
|
firmwareMessage: message,
|
|
608
618
|
});
|
|
609
|
-
} else if (
|
|
619
|
+
} else if (
|
|
620
|
+
isProtocolV2DeviceBusyFailure ||
|
|
621
|
+
isProtocolV2PinCancelledBusyFailure ||
|
|
622
|
+
isProtocolV2FirmwareUpdateBusyFailure
|
|
623
|
+
) {
|
|
610
624
|
error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy, message, {
|
|
611
625
|
failureCode: code,
|
|
612
626
|
subcode,
|
|
@@ -271,7 +271,8 @@ export const mapProtocolV2DeviceInfoToState = (
|
|
|
271
271
|
versions: definedEntries({
|
|
272
272
|
firmware: imageVersion(info.main_mcu?.application),
|
|
273
273
|
applicationP1: imageVersion(info.main_mcu?.application),
|
|
274
|
-
|
|
274
|
+
// The running application does not report P2; discard a loader-era version.
|
|
275
|
+
applicationP2: mode === 'normal' ? null : imageVersion(info.main_mcu?.application_data),
|
|
275
276
|
bootloader: imageVersion(info.main_mcu?.bootloader),
|
|
276
277
|
board: imageVersion(info.main_mcu?.romloader),
|
|
277
278
|
ble: imageVersion(info.coprocessor?.application),
|
|
@@ -289,8 +290,9 @@ export const mapProtocolV2DeviceInfoToState = (
|
|
|
289
290
|
firmwareHash: imageHash(info.main_mcu?.application),
|
|
290
291
|
applicationP1BuildId: imageBuildId(info.main_mcu?.application),
|
|
291
292
|
applicationP1Hash: imageHash(info.main_mcu?.application),
|
|
292
|
-
applicationP2BuildId:
|
|
293
|
-
|
|
293
|
+
applicationP2BuildId:
|
|
294
|
+
mode === 'normal' ? null : imageBuildId(info.main_mcu?.application_data),
|
|
295
|
+
applicationP2Hash: mode === 'normal' ? null : imageHash(info.main_mcu?.application_data),
|
|
294
296
|
bootloaderBuildId: imageBuildId(info.main_mcu?.bootloader),
|
|
295
297
|
bootloaderHash: imageHash(info.main_mcu?.bootloader),
|
|
296
298
|
boardBuildId: imageBuildId(info.main_mcu?.romloader),
|