@onekeyfe/hd-core 1.2.0-alpha.100 → 1.2.0-alpha.102
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__/bridgeBinaryPayload.test.ts +173 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +2 -0
- package/__tests__/device-pool-state.test.ts +29 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +59 -55
- package/__tests__/get-device-state.test.ts +102 -13
- package/__tests__/protocol-v2-legacy-recovery.test.ts +29 -0
- package/__tests__/protocol-v2.test.ts +234 -1
- package/__tests__/refresh-device-state.test.ts +4 -1
- package/__tests__/search-devices.test.ts +2 -0
- package/__tests__/ton-sign-message.test.ts +84 -0
- package/dist/api/FirmwareUpdateV4.d.ts +3 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/firmware/protocolV2Release.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/protocolV2LegacyRecovery.d.ts +5 -0
- package/dist/core/protocolV2LegacyRecovery.d.ts.map +1 -0
- package/dist/device/Device.d.ts +9 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/index.d.ts +14 -4
- package/dist/index.js +263 -71
- package/dist/protocols/protocol-v2/features.d.ts +8 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdatePlan.d.ts +2 -2
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -1
- package/dist/types/api/getDeviceState.d.ts +1 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -1
- package/dist/utils/bridgeBinaryPayload.d.ts +3 -0
- package/dist/utils/bridgeBinaryPayload.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +70 -23
- package/src/api/GetDeviceState.ts +1 -0
- package/src/api/SearchDevices.ts +2 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +37 -36
- package/src/api/firmware/protocolV2Release.ts +1 -0
- package/src/api/ton/TonSignMessage.ts +5 -3
- package/src/api/utils.ts +5 -2
- package/src/core/index.ts +4 -0
- package/src/core/protocolV2LegacyRecovery.ts +12 -0
- package/src/device/Device.ts +78 -20
- package/src/device/DevicePool.ts +17 -5
- package/src/protocols/protocol-v2/features.ts +10 -0
- package/src/protocols/protocol-v2/index.ts +2 -0
- package/src/topLevelInject.ts +4 -2
- package/src/types/api/firmwareUpdatePlan.ts +2 -2
- package/src/types/api/getDeviceState.ts +2 -0
- package/src/utils/bridgeBinaryPayload.ts +137 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/features.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AACrC,YAAY,EAAE,uBAAuB,IAAI,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrG,YAAY,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,aAAa,GAAG,KAAK,CAAC;AAoBpE,eAAO,MAAM,oBAAoB,Q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@@
|
|
|
1
|
-
export { PROTOCOL_V2_DEVICE_INFO_REQUEST, PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS, PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE, PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST, PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST, getProtocolV2RuntimeMode, getProtocolV2SeState, getProtocolV2SeType, parseProtocolV2BuildFingerprint, requestProtocolV2ProtocolInfo, supportsProtocolV2Message, } from './features';
|
|
2
|
-
export type { ProtocolV2BuildFingerprint, ProtocolV2DeviceInfo, ProtocolV2FirmwareImageInfo, ProtocolV2SEInfo, ProtocolV2SeStateLabel, ProtocolV2RuntimeMode, } from './features';
|
|
1
|
+
export { PROTOCOL_V2_DEVICE_INFO_REQUEST, PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS, PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE, PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST, PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST, getProtocolV2RuntimeMode, getProtocolV2SeState, getProtocolV2SeType, isLegacyProtocolV2ProtocolInfo, parseProtocolV2BuildFingerprint, requestProtocolV2ProtocolInfo, supportsProtocolV2Message, } from './features';
|
|
2
|
+
export type { ProtocolV2BuildFingerprint, ProtocolV2DeviceInfo, ProtocolV2FirmwareImageInfo, ProtocolV2SEInfo, ProtocolV2SeStateLabel, ProtocolV2RuntimeMode, ProtocolV2ProtocolInfo, } from './features';
|
|
3
3
|
export * from './firmware';
|
|
4
4
|
export * from './walletSession';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,EAClC,0CAA0C,EAC1C,wCAAwC,EACxC,wCAAwC,EACxC,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAC/B,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,EAClC,0CAA0C,EAC1C,wCAAwC,EACxC,wCAAwC,EACxC,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,+BAA+B,EAC/B,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topLevelInject.d.ts","sourceRoot":"","sources":["../src/topLevelInject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"topLevelInject.d.ts","sourceRoot":"","sources":["../src/topLevelInject.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACvB;AAID,eAAO,MAAM,cAAc,eAqD1B,CAAC"}
|
|
@@ -10,8 +10,8 @@ export interface FirmwareUpdatePlanArtifact {
|
|
|
10
10
|
url: string;
|
|
11
11
|
container: 'raw' | 'zip';
|
|
12
12
|
logicalName?: string;
|
|
13
|
-
expectedSize
|
|
14
|
-
expectedSha256
|
|
13
|
+
expectedSize?: number;
|
|
14
|
+
expectedSha256?: string;
|
|
15
15
|
targetVersion?: string;
|
|
16
16
|
}
|
|
17
17
|
export interface FirmwareUpdatePlan {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firmwareUpdatePlan.d.ts","sourceRoot":"","sources":["../../../src/types/api/firmwareUpdatePlan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GACtC,UAAU,GACV,KAAK,GACL,YAAY,GACZ,UAAU,GACV,WAAW,GACX,gBAAgB,CAAC;AAErB,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,sBAAsB,CAAC;AAElG,MAAM,MAAM,6BAA6B,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,UAAU,CAAC;AAE3F,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,8BAA8B,CAAC;IACrC,MAAM,EAAE,wBAAwB,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"firmwareUpdatePlan.d.ts","sourceRoot":"","sources":["../../../src/types/api/firmwareUpdatePlan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GACtC,UAAU,GACV,KAAK,GACL,YAAY,GACZ,UAAU,GACV,WAAW,GACX,gBAAgB,CAAC;AAErB,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,sBAAsB,CAAC;AAElG,MAAM,MAAM,6BAA6B,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,UAAU,CAAC;AAE3F,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,8BAA8B,CAAC;IACrC,MAAM,EAAE,wBAAwB,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,CAAC,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,aAAa,CAAC;IAC5B,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,WAAW,CAAC;IAC7D,SAAS,EAAE,0BAA0B,EAAE,CAAC;IACxC,eAAe,EAAE,wBAAwB,EAAE,CAAC;CAC7C"}
|
|
@@ -7,6 +7,7 @@ export type GetDeviceStateParams = CommonParams & {
|
|
|
7
7
|
export type DeviceStateReadOptions = {
|
|
8
8
|
refreshSections?: DeviceStateSection[];
|
|
9
9
|
includeRaw?: boolean;
|
|
10
|
+
allowLegacyProtocolV2ProtocolInfo?: boolean;
|
|
10
11
|
};
|
|
11
12
|
export declare function getDeviceState(connectId?: string, params?: GetDeviceStateParams): Response<DeviceState>;
|
|
12
13
|
//# sourceMappingURL=getDeviceState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDeviceState.d.ts","sourceRoot":"","sources":["../../../src/types/api/getDeviceState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG;IAChD,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAGF,MAAM,MAAM,sBAAsB,GAAG;IACnC,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"getDeviceState.d.ts","sourceRoot":"","sources":["../../../src/types/api/getDeviceState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG;IAChD,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAGF,MAAM,MAAM,sBAAsB,GAAG;IACnC,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,iCAAiC,CAAC,EAAE,OAAO,CAAC;CAC7C,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,oBAAoB,GAC5B,QAAQ,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridgeBinaryPayload.d.ts","sourceRoot":"","sources":["../../src/utils/bridgeBinaryPayload.ts"],"names":[],"mappings":"AAkIA,wBAAsB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhF;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEjE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.102",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
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.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.102",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.102",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "49f939a3fa496be9bd6763737a98b3ade81a2a45"
|
|
48
48
|
}
|
|
@@ -28,6 +28,7 @@ import { DevicePool } from '../device/DevicePool';
|
|
|
28
28
|
import {
|
|
29
29
|
PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
|
|
30
30
|
ProtocolV2FirmwareTargetType,
|
|
31
|
+
isLegacyProtocolV2ProtocolInfo,
|
|
31
32
|
} from '../protocols/protocol-v2';
|
|
32
33
|
import { requestProtocolV2DeviceInfo } from '../protocols/protocol-v2/features';
|
|
33
34
|
import {
|
|
@@ -393,6 +394,13 @@ const isProtocolV2FirmwareStatusEndpointUnavailable = (error: unknown) => {
|
|
|
393
394
|
);
|
|
394
395
|
};
|
|
395
396
|
|
|
397
|
+
const isProtocolV2FirmwareUpdateEndpointUnavailable = (error: unknown) => {
|
|
398
|
+
const message = getProtocolV2UnknownErrorText(error).toLowerCase();
|
|
399
|
+
return (
|
|
400
|
+
message.includes('handler not registered') || message.includes('message handler not found')
|
|
401
|
+
);
|
|
402
|
+
};
|
|
403
|
+
|
|
396
404
|
const isProtocolV2TerminalInstallStatusError = (error: unknown) =>
|
|
397
405
|
error instanceof HardwareError &&
|
|
398
406
|
(error.errorCode === HardwareErrorCode.FirmwareError ||
|
|
@@ -587,6 +595,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
587
595
|
|
|
588
596
|
private protocolV2ExecutionInLoader = false;
|
|
589
597
|
|
|
598
|
+
private protocolV2LegacyDirectUpdate = false;
|
|
599
|
+
|
|
590
600
|
private protocolV2BootResourceStagingSafe = false;
|
|
591
601
|
|
|
592
602
|
private protocolV2CompletedTargetVersions = new Map<number, number>();
|
|
@@ -2067,21 +2077,12 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2067
2077
|
return this.device.features?.mode === 'romloader';
|
|
2068
2078
|
}
|
|
2069
2079
|
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
Log.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
2075
|
-
this.protocolV2ExecutionInLoader = true;
|
|
2076
|
-
return false;
|
|
2077
|
-
}
|
|
2078
|
-
if (this.isProtocolV2BootloaderMode()) {
|
|
2079
|
-
Log.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
2080
|
-
this.protocolV2ExecutionInLoader = true;
|
|
2081
|
-
this.postTipMessage(FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
2082
|
-
return false;
|
|
2083
|
-
}
|
|
2080
|
+
private isLegacyProtocolV2Runtime() {
|
|
2081
|
+
const protocolInfo = this.device.state?.raw?.protocolV2ProtocolInfo;
|
|
2082
|
+
return protocolInfo ? isLegacyProtocolV2ProtocolInfo(protocolInfo) : false;
|
|
2083
|
+
}
|
|
2084
2084
|
|
|
2085
|
+
private async rebootProtocolV2ToBootloader() {
|
|
2085
2086
|
try {
|
|
2086
2087
|
this.postTipMessage(FirmwareUpdateTipMessage.AutoRebootToBootloader);
|
|
2087
2088
|
await this.protocolV2Reboot(DeviceRebootType.Bootloader);
|
|
@@ -2099,6 +2100,27 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2099
2100
|
}
|
|
2100
2101
|
}
|
|
2101
2102
|
|
|
2103
|
+
async enterProtocolV2BootloaderMode() {
|
|
2104
|
+
this.protocolV2LegacyDirectUpdate = false;
|
|
2105
|
+
// romloader is the first update environment and forwards targets to bootloader.
|
|
2106
|
+
// It rejects DeviceRebootType.Bootloader, so reuse the current connection.
|
|
2107
|
+
if (this.isProtocolV2RomloaderMode()) {
|
|
2108
|
+
Log.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
2109
|
+
this.protocolV2LegacyDirectUpdate = this.isLegacyProtocolV2Runtime();
|
|
2110
|
+
this.protocolV2ExecutionInLoader = true;
|
|
2111
|
+
return false;
|
|
2112
|
+
}
|
|
2113
|
+
if (this.isProtocolV2BootloaderMode()) {
|
|
2114
|
+
Log.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
2115
|
+
this.protocolV2LegacyDirectUpdate = this.isLegacyProtocolV2Runtime();
|
|
2116
|
+
this.protocolV2ExecutionInLoader = true;
|
|
2117
|
+
this.postTipMessage(FirmwareUpdateTipMessage.GoToBootloaderSuccess);
|
|
2118
|
+
return false;
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
return this.rebootProtocolV2ToBootloader();
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2102
2124
|
private async waitForProtocolV2BootloaderMode(
|
|
2103
2125
|
timeout = PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT,
|
|
2104
2126
|
retryInterval = 1000
|
|
@@ -2120,7 +2142,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2120
2142
|
this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
|
|
2121
2143
|
const features = await this.device.probeProtocolV2RuntimeState(
|
|
2122
2144
|
deviceInfo,
|
|
2123
|
-
PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT
|
|
2145
|
+
PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
2146
|
+
{ allowLegacyProtocolV2ProtocolInfo: true }
|
|
2124
2147
|
);
|
|
2125
2148
|
if (features?.mode === 'bootloader') {
|
|
2126
2149
|
return features;
|
|
@@ -2809,7 +2832,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2809
2832
|
private async probeProtocolV2NormalMode(deviceInfo: ProtocolV2DeviceInfo) {
|
|
2810
2833
|
const features = await this.device.probeProtocolV2RuntimeState(
|
|
2811
2834
|
deviceInfo,
|
|
2812
|
-
PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT
|
|
2835
|
+
PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
2836
|
+
{ allowLegacyProtocolV2ProtocolInfo: true }
|
|
2813
2837
|
);
|
|
2814
2838
|
return features.mode === 'normal' && !features.bootloaderMode;
|
|
2815
2839
|
}
|
|
@@ -2871,7 +2895,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2871
2895
|
this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
|
|
2872
2896
|
const features = await this.device.probeProtocolV2RuntimeState(
|
|
2873
2897
|
deviceInfo,
|
|
2874
|
-
PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT
|
|
2898
|
+
PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
2899
|
+
{ allowLegacyProtocolV2ProtocolInfo: true }
|
|
2875
2900
|
);
|
|
2876
2901
|
if (features.mode === 'normal' && !features.bootloaderMode) {
|
|
2877
2902
|
return features;
|
|
@@ -3044,12 +3069,34 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
3044
3069
|
targets: Array<{ target_id: number; path: string }>;
|
|
3045
3070
|
}) {
|
|
3046
3071
|
const commands = this.device.getCommands();
|
|
3047
|
-
const
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3072
|
+
const startUpdate = () =>
|
|
3073
|
+
commands.typedCall(
|
|
3074
|
+
'DeviceFirmwareUpdateRequest',
|
|
3075
|
+
'Success',
|
|
3076
|
+
{ targets },
|
|
3077
|
+
{ timeoutMs: PROTOCOL_V2_START_UPDATE_TIMEOUT }
|
|
3078
|
+
);
|
|
3079
|
+
let response: ProtocolV2FirmwareUpdateStartResponse;
|
|
3080
|
+
try {
|
|
3081
|
+
response = await startUpdate();
|
|
3082
|
+
} catch (error) {
|
|
3083
|
+
if (
|
|
3084
|
+
!this.protocolV2LegacyDirectUpdate ||
|
|
3085
|
+
!isProtocolV2FirmwareUpdateEndpointUnavailable(error)
|
|
3086
|
+
) {
|
|
3087
|
+
throw error;
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
// Both legacy loaders register this request. A missing handler therefore identifies
|
|
3091
|
+
// a legacy App before dispatch, so it is safe to reboot and retry the unhandled request.
|
|
3092
|
+
this.protocolV2LegacyDirectUpdate = false;
|
|
3093
|
+
Log.debug(
|
|
3094
|
+
'[FirmwareUpdateV4] legacy App does not expose DeviceFirmwareUpdateRequest; rebooting to bootloader'
|
|
3095
|
+
);
|
|
3096
|
+
await this.rebootProtocolV2ToBootloader();
|
|
3097
|
+
response = await startUpdate();
|
|
3098
|
+
}
|
|
3099
|
+
this.protocolV2LegacyDirectUpdate = false;
|
|
3053
3100
|
// Success acknowledges that the device accepted installation. End confirmation
|
|
3054
3101
|
// and begin status polling only after receiving this ACK.
|
|
3055
3102
|
this.postTipMessage(FirmwareUpdateTipMessage.FirmwareUpdating);
|
|
@@ -43,6 +43,7 @@ export default class GetDeviceState extends BaseMethod<
|
|
|
43
43
|
async run() {
|
|
44
44
|
const state = await this.device.getDeviceState({
|
|
45
45
|
refreshSections: SCOPE_SECTIONS[this.params.scope],
|
|
46
|
+
...(this.params.scope === 'firmware' ? { allowLegacyProtocolV2ProtocolInfo: true } : {}),
|
|
46
47
|
});
|
|
47
48
|
if (
|
|
48
49
|
this.params.scope === 'settings' &&
|
package/src/api/SearchDevices.ts
CHANGED
|
@@ -63,6 +63,8 @@ export default class SearchDevices extends BaseMethod {
|
|
|
63
63
|
connectProtocol: undefined,
|
|
64
64
|
forceProtocolDetection: true,
|
|
65
65
|
refreshRuntimeState: true,
|
|
66
|
+
// Old loader firmware predates build_fingerprint. Keep this recovery-only.
|
|
67
|
+
allowLegacyProtocolV2ProtocolInfo: true,
|
|
66
68
|
});
|
|
67
69
|
deviceList.push(...result.deviceList);
|
|
68
70
|
} catch (error) {
|
|
@@ -328,8 +328,8 @@ export const assertFirmwareUpdatePlan = (value: unknown): FirmwareUpdatePlan =>
|
|
|
328
328
|
}
|
|
329
329
|
assertExactKeys(
|
|
330
330
|
artifact,
|
|
331
|
-
['artifactId', 'role', 'target', 'url', 'container'
|
|
332
|
-
['logicalName', 'targetVersion']
|
|
331
|
+
['artifactId', 'role', 'target', 'url', 'container'],
|
|
332
|
+
['logicalName', 'expectedSize', 'expectedSha256', 'targetVersion']
|
|
333
333
|
);
|
|
334
334
|
const artifactId = assertBoundedString(artifact.artifactId, 'artifact id', 160);
|
|
335
335
|
if (artifactIds.has(artifactId)) {
|
|
@@ -348,15 +348,25 @@ export const assertFirmwareUpdatePlan = (value: unknown): FirmwareUpdatePlan =>
|
|
|
348
348
|
if (artifact.logicalName !== undefined) {
|
|
349
349
|
assertBoundedString(artifact.logicalName, 'logical name', 256);
|
|
350
350
|
}
|
|
351
|
-
if (
|
|
351
|
+
if (
|
|
352
|
+
artifact.expectedSize !== undefined &&
|
|
353
|
+
(!Number.isSafeInteger(artifact.expectedSize) || (artifact.expectedSize as number) <= 0)
|
|
354
|
+
) {
|
|
352
355
|
return planError('Firmware update plan artifact size is invalid');
|
|
353
356
|
}
|
|
354
357
|
if (
|
|
355
|
-
|
|
356
|
-
|
|
358
|
+
artifact.expectedSha256 !== undefined &&
|
|
359
|
+
(typeof artifact.expectedSha256 !== 'string' ||
|
|
360
|
+
!/^[a-f0-9]{64}$/u.test(artifact.expectedSha256))
|
|
357
361
|
) {
|
|
358
362
|
return planError('Firmware update plan artifact digest is invalid');
|
|
359
363
|
}
|
|
364
|
+
if (
|
|
365
|
+
plan.executor === 'v4' &&
|
|
366
|
+
(artifact.expectedSize === undefined || artifact.expectedSha256 === undefined)
|
|
367
|
+
) {
|
|
368
|
+
return planError('Protocol V2 firmware artifact integrity metadata is invalid');
|
|
369
|
+
}
|
|
360
370
|
if (artifact.targetVersion !== undefined) {
|
|
361
371
|
assertBoundedString(artifact.targetVersion, 'target version', 64);
|
|
362
372
|
}
|
|
@@ -822,13 +832,10 @@ export const buildFirmwareUpdatePlan = ({
|
|
|
822
832
|
} else {
|
|
823
833
|
if (isUpgrade(bootloader) || forcedTargets.has('bootloader')) {
|
|
824
834
|
const bootloaderRelease = asRelease(bootloader);
|
|
825
|
-
const integrity =
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
},
|
|
830
|
-
'Bootloader release'
|
|
831
|
-
);
|
|
835
|
+
const integrity = asIntegrity({
|
|
836
|
+
size: bootloaderRelease?.bootloaderExpectedSize,
|
|
837
|
+
sha256: bootloaderRelease?.bootloaderFingerprint,
|
|
838
|
+
});
|
|
832
839
|
artifacts.push({
|
|
833
840
|
artifactId: 'bootloader',
|
|
834
841
|
role: 'bootloader',
|
|
@@ -850,10 +857,10 @@ export const buildFirmwareUpdatePlan = ({
|
|
|
850
857
|
});
|
|
851
858
|
}
|
|
852
859
|
if (shouldUpdateFirmware) {
|
|
853
|
-
const integrity =
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
);
|
|
860
|
+
const integrity = asIntegrity({
|
|
861
|
+
size: firmwareRelease.expectedSize,
|
|
862
|
+
sha256: firmwareRelease.fingerprint,
|
|
863
|
+
});
|
|
857
864
|
artifacts.push({
|
|
858
865
|
artifactId: 'firmware',
|
|
859
866
|
role: 'firmware',
|
|
@@ -873,19 +880,16 @@ export const buildFirmwareUpdatePlan = ({
|
|
|
873
880
|
platform,
|
|
874
881
|
});
|
|
875
882
|
if (resourceUrl) {
|
|
876
|
-
const integrity =
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
},
|
|
887
|
-
'Legacy resource archive'
|
|
888
|
-
);
|
|
883
|
+
const integrity = asIntegrity({
|
|
884
|
+
size:
|
|
885
|
+
resourceUrl === asString(firmwareRelease.fullResource)
|
|
886
|
+
? firmwareRelease.fullResourceExpectedSize
|
|
887
|
+
: firmwareRelease.resourceExpectedSize,
|
|
888
|
+
sha256:
|
|
889
|
+
resourceUrl === asString(firmwareRelease.fullResource)
|
|
890
|
+
? firmwareRelease.fullResourceFingerprint
|
|
891
|
+
: firmwareRelease.resourceFingerprint,
|
|
892
|
+
});
|
|
889
893
|
artifacts.push({
|
|
890
894
|
artifactId: 'resource',
|
|
891
895
|
role: 'resource',
|
|
@@ -899,13 +903,10 @@ export const buildFirmwareUpdatePlan = ({
|
|
|
899
903
|
}
|
|
900
904
|
if (isUpgrade(ble) || isRecoveryInstall(ble) || forcedTargets.has('ble')) {
|
|
901
905
|
const bleRelease = asRelease(ble);
|
|
902
|
-
const integrity =
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
},
|
|
907
|
-
'BLE release'
|
|
908
|
-
);
|
|
906
|
+
const integrity = asIntegrity({
|
|
907
|
+
size: bleRelease?.expectedSize,
|
|
908
|
+
sha256: bleRelease?.fingerprintWeb ?? bleRelease?.fingerprint,
|
|
909
|
+
});
|
|
909
910
|
artifacts.push({
|
|
910
911
|
artifactId: 'ble',
|
|
911
912
|
role: 'ble',
|
|
@@ -60,6 +60,7 @@ export async function loadProtocolV2FirmwareReleaseContext({
|
|
|
60
60
|
refreshSections: checkFirmwareHash
|
|
61
61
|
? ['identity', 'versions', 'verification']
|
|
62
62
|
: ['identity', 'versions'],
|
|
63
|
+
allowLegacyProtocolV2ProtocolInfo: true,
|
|
63
64
|
});
|
|
64
65
|
if (state.identity.deviceType !== 'pro2' && state.identity.deviceType !== 'neo') {
|
|
65
66
|
throw ERRORS.TypedError(
|
|
@@ -174,12 +174,14 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
|
|
|
174
174
|
if (!request.init_data_length) {
|
|
175
175
|
const deviceType = this.device.getCurrentDeviceType();
|
|
176
176
|
const hasClassic = DeviceModelToTypes.model_classic1s.includes(deviceType);
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
const signingMessage = request.signing_message ?? request.signning_message;
|
|
178
|
+
// Blind signing omits the signing message in both protocol schemas.
|
|
179
|
+
const shouldSkipValidation = signingMessage == null;
|
|
179
180
|
|
|
180
181
|
return Promise.resolve({
|
|
181
182
|
...request,
|
|
182
|
-
|
|
183
|
+
signing_message: signingMessage,
|
|
184
|
+
skip_validate: hasClassic || shouldSkipValidation,
|
|
183
185
|
});
|
|
184
186
|
}
|
|
185
187
|
|
package/src/api/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import * as ApiMethods from './index';
|
|
4
|
+
import { decodeBridgeBinaryPayload } from '../utils/bridgeBinaryPayload';
|
|
4
5
|
|
|
5
6
|
import type { BaseMethod } from './BaseMethod';
|
|
6
7
|
import type { IFrameCallMessage } from '../events';
|
|
@@ -11,14 +12,16 @@ type MethodConstructor = new (message: IFrameCallMessage & { id?: number }) => B
|
|
|
11
12
|
const publicMethodRegistry = ApiMethods as unknown as Record<string, MethodConstructor>;
|
|
12
13
|
|
|
13
14
|
export function findMethod(message: IFrameCallMessage & { id?: number }): BaseMethod<any> {
|
|
14
|
-
const
|
|
15
|
+
const payload = decodeBridgeBinaryPayload(message.payload) as IFrameCallMessage['payload'];
|
|
16
|
+
const normalizedMessage = payload === message.payload ? message : { ...message, payload };
|
|
17
|
+
const { method } = payload;
|
|
15
18
|
if (typeof method !== 'string') {
|
|
16
19
|
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'Method is not set');
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
const MethodConstructor = publicMethodRegistry[method];
|
|
20
23
|
if (MethodConstructor) {
|
|
21
|
-
return new MethodConstructor(
|
|
24
|
+
return new MethodConstructor(normalizedMessage);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
throw ERRORS.TypedError(
|
package/src/core/index.ts
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
isProtocolV2UiEnabled,
|
|
65
65
|
} from '../protocols/protocol-v2/uiInteraction';
|
|
66
66
|
import { createUiProgressMessageFilter } from '../utils/uiProgressThrottle';
|
|
67
|
+
import { isLegacyProtocolV2FirmwareRecoveryMethod } from './protocolV2LegacyRecovery';
|
|
67
68
|
|
|
68
69
|
import type { ConnectSettings, Features, KnownDevice } from '../types';
|
|
69
70
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
@@ -109,6 +110,9 @@ const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
|
109
110
|
connectProtocol: method?.payload.connectProtocol,
|
|
110
111
|
forceProtocolDetection: method?.payload.forceProtocolDetection,
|
|
111
112
|
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
113
|
+
...(isLegacyProtocolV2FirmwareRecoveryMethod(method)
|
|
114
|
+
? { allowLegacyProtocolV2ProtocolInfo: true }
|
|
115
|
+
: {}),
|
|
112
116
|
});
|
|
113
117
|
|
|
114
118
|
let _core: Core | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BaseMethod } from '../api/BaseMethod';
|
|
2
|
+
|
|
3
|
+
type CoreMethodDescriptor = Pick<BaseMethod, 'name' | 'payload'>;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TEMPORARY COMPATIBILITY: Legacy ProtocolInfo is accepted only by the
|
|
7
|
+
* firmware recovery entry points used before and during Protocol V2 updates.
|
|
8
|
+
*/
|
|
9
|
+
export const isLegacyProtocolV2FirmwareRecoveryMethod = (method?: CoreMethodDescriptor): boolean =>
|
|
10
|
+
method?.name === 'firmwareUpdateV4' ||
|
|
11
|
+
method?.name === 'checkAllFirmwareRelease' ||
|
|
12
|
+
(method?.name === 'getDeviceState' && method.payload.scope === 'firmware');
|