@onekeyfe/hd-core 1.1.27-alpha.30 → 1.1.27-alpha.31
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__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/protocol-v2.test.ts +189 -33
- package/dist/api/GetPassphraseState.d.ts +6 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +19 -19
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +4 -3
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +3 -3
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.d.ts +34 -27
- package/dist/index.js +231 -184
- package/dist/protocols/protocol-v2/features.d.ts +1 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +7 -7
- package/dist/types/api/getPassphraseState.d.ts +7 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +7 -6
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +16 -16
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +3 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +13 -13
- package/src/api/GetPassphraseState.ts +14 -2
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +15 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
- package/src/api/device/DeviceRebootToBootloader.ts +4 -4
- package/src/api/dynex/DnxGetAddress.ts +7 -0
- package/src/api/dynex/DnxSignTransaction.ts +7 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +6 -6
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/helpers/batchGetPublickeys.ts +4 -2
- package/src/api/index.ts +5 -5
- package/src/api/protocol-v2/{DevFirmwareUpdate.ts → DeviceFirmwareUpdate.ts} +3 -3
- package/src/api/protocol-v2/{DevGetDeviceInfo.ts → DeviceGetDeviceInfo.ts} +3 -3
- package/src/api/protocol-v2/{DevGetFirmwareUpdateStatus.ts → DeviceGetFirmwareUpdateStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevGetOnboardingStatus.ts → DeviceGetOnboardingStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevReboot.ts → DeviceReboot.ts} +3 -3
- package/src/api/protocol-v2/helpers.ts +38 -38
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +5 -1
- package/src/data/messages/messages-pro2.json +67 -63
- package/src/data-manager/DataManager.ts +7 -6
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +12 -12
- package/src/device/Device.ts +7 -3
- package/src/inject.ts +9 -9
- package/src/protocols/protocol-v2/features.ts +7 -6
- package/src/protocols/protocol-v2/firmware.ts +16 -16
- package/src/types/api/getPassphraseState.ts +10 -1
- package/src/types/api/index.ts +11 -10
- package/src/types/api/protocolV2.ts +27 -27
- package/src/utils/deviceFeaturesUtils.ts +33 -15
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts +0 -7
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts +0 -7
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
|
@@ -484,11 +484,11 @@
|
|
|
484
484
|
"MessageType_Ping": 60206,
|
|
485
485
|
"MessageType_Success": 60207,
|
|
486
486
|
"MessageType_Failure": 60208,
|
|
487
|
-
"
|
|
488
|
-
"
|
|
487
|
+
"MessageType_DeviceReboot": 60400,
|
|
488
|
+
"MessageType_DeviceGetDeviceInfo": 60600,
|
|
489
489
|
"MessageType_DeviceInfo": 60601,
|
|
490
|
-
"
|
|
491
|
-
"
|
|
490
|
+
"MessageType_DeviceGetOnboardingStatus": 60602,
|
|
491
|
+
"MessageType_DeviceOnboardingStatus": 60603,
|
|
492
492
|
"MessageType_FilesystemFixPermission": 60800,
|
|
493
493
|
"MessageType_FilesystemPathInfo": 60801,
|
|
494
494
|
"MessageType_FilesystemPathInfoQuery": 60802,
|
|
@@ -501,10 +501,10 @@
|
|
|
501
501
|
"MessageType_FilesystemDirMake": 60809,
|
|
502
502
|
"MessageType_FilesystemDirRemove": 60810,
|
|
503
503
|
"MessageType_FilesystemFormat": 60811,
|
|
504
|
-
"
|
|
505
|
-
"
|
|
506
|
-
"
|
|
507
|
-
"
|
|
504
|
+
"MessageType_DeviceFirmwareUpdate": 61000,
|
|
505
|
+
"MessageType_DeviceFirmwareInstallProgress": 61001,
|
|
506
|
+
"MessageType_DeviceGetFirmwareUpdateStatus": 61002,
|
|
507
|
+
"MessageType_DeviceFirmwareUpdateStatus": 61003
|
|
508
508
|
}
|
|
509
509
|
},
|
|
510
510
|
"AlephiumGetAddress": {
|
|
@@ -11790,18 +11790,18 @@
|
|
|
11790
11790
|
}
|
|
11791
11791
|
}
|
|
11792
11792
|
},
|
|
11793
|
-
"
|
|
11793
|
+
"DeviceRebootType": {
|
|
11794
11794
|
"values": {
|
|
11795
11795
|
"Normal": 0,
|
|
11796
11796
|
"Boardloader": 1,
|
|
11797
11797
|
"Bootloader": 2
|
|
11798
11798
|
}
|
|
11799
11799
|
},
|
|
11800
|
-
"
|
|
11800
|
+
"DeviceReboot": {
|
|
11801
11801
|
"fields": {
|
|
11802
11802
|
"reboot_type": {
|
|
11803
11803
|
"rule": "required",
|
|
11804
|
-
"type": "
|
|
11804
|
+
"type": "DeviceRebootType",
|
|
11805
11805
|
"id": 1
|
|
11806
11806
|
}
|
|
11807
11807
|
}
|
|
@@ -11816,20 +11816,20 @@
|
|
|
11816
11816
|
"CLASSIC1S_PURE": 6
|
|
11817
11817
|
}
|
|
11818
11818
|
},
|
|
11819
|
-
"
|
|
11819
|
+
"DeviceSeType": {
|
|
11820
11820
|
"values": {
|
|
11821
11821
|
"THD89": 0,
|
|
11822
11822
|
"SE608A": 1
|
|
11823
11823
|
}
|
|
11824
11824
|
},
|
|
11825
|
-
"
|
|
11825
|
+
"DeviceSEState": {
|
|
11826
11826
|
"values": {
|
|
11827
11827
|
"BOOT": 0,
|
|
11828
11828
|
"APP_FACTORY": 51,
|
|
11829
11829
|
"APP": 85
|
|
11830
11830
|
}
|
|
11831
11831
|
},
|
|
11832
|
-
"
|
|
11832
|
+
"DeviceFirmwareImageInfo": {
|
|
11833
11833
|
"fields": {
|
|
11834
11834
|
"version": {
|
|
11835
11835
|
"type": "string",
|
|
@@ -11845,9 +11845,9 @@
|
|
|
11845
11845
|
}
|
|
11846
11846
|
}
|
|
11847
11847
|
},
|
|
11848
|
-
"
|
|
11848
|
+
"DeviceHardwareInfo": {
|
|
11849
11849
|
"fields": {
|
|
11850
|
-
"
|
|
11850
|
+
"Device_type": {
|
|
11851
11851
|
"type": "DeviceType",
|
|
11852
11852
|
"id": 10
|
|
11853
11853
|
},
|
|
@@ -11865,30 +11865,30 @@
|
|
|
11865
11865
|
}
|
|
11866
11866
|
}
|
|
11867
11867
|
},
|
|
11868
|
-
"
|
|
11868
|
+
"DeviceMainMcuInfo": {
|
|
11869
11869
|
"fields": {
|
|
11870
11870
|
"board": {
|
|
11871
|
-
"type": "
|
|
11871
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11872
11872
|
"id": 10
|
|
11873
11873
|
},
|
|
11874
11874
|
"boot": {
|
|
11875
|
-
"type": "
|
|
11875
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11876
11876
|
"id": 20
|
|
11877
11877
|
},
|
|
11878
11878
|
"app": {
|
|
11879
|
-
"type": "
|
|
11879
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11880
11880
|
"id": 30
|
|
11881
11881
|
}
|
|
11882
11882
|
}
|
|
11883
11883
|
},
|
|
11884
|
-
"
|
|
11884
|
+
"DeviceBluetoothInfo": {
|
|
11885
11885
|
"fields": {
|
|
11886
11886
|
"boot": {
|
|
11887
|
-
"type": "
|
|
11887
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11888
11888
|
"id": 20
|
|
11889
11889
|
},
|
|
11890
11890
|
"app": {
|
|
11891
|
-
"type": "
|
|
11891
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11892
11892
|
"id": 30
|
|
11893
11893
|
},
|
|
11894
11894
|
"adv_name": {
|
|
@@ -11901,27 +11901,27 @@
|
|
|
11901
11901
|
}
|
|
11902
11902
|
}
|
|
11903
11903
|
},
|
|
11904
|
-
"
|
|
11904
|
+
"DeviceSEInfo": {
|
|
11905
11905
|
"fields": {
|
|
11906
11906
|
"boot": {
|
|
11907
|
-
"type": "
|
|
11907
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11908
11908
|
"id": 20
|
|
11909
11909
|
},
|
|
11910
11910
|
"app": {
|
|
11911
|
-
"type": "
|
|
11911
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11912
11912
|
"id": 30
|
|
11913
11913
|
},
|
|
11914
11914
|
"type": {
|
|
11915
|
-
"type": "
|
|
11915
|
+
"type": "DeviceSeType",
|
|
11916
11916
|
"id": 100
|
|
11917
11917
|
},
|
|
11918
11918
|
"state": {
|
|
11919
|
-
"type": "
|
|
11919
|
+
"type": "DeviceSEState",
|
|
11920
11920
|
"id": 110
|
|
11921
11921
|
}
|
|
11922
11922
|
}
|
|
11923
11923
|
},
|
|
11924
|
-
"
|
|
11924
|
+
"DeviceInfoTargets": {
|
|
11925
11925
|
"fields": {
|
|
11926
11926
|
"hw": {
|
|
11927
11927
|
"type": "bool",
|
|
@@ -11957,7 +11957,7 @@
|
|
|
11957
11957
|
}
|
|
11958
11958
|
}
|
|
11959
11959
|
},
|
|
11960
|
-
"
|
|
11960
|
+
"DeviceInfoTypes": {
|
|
11961
11961
|
"fields": {
|
|
11962
11962
|
"version": {
|
|
11963
11963
|
"type": "bool",
|
|
@@ -11977,7 +11977,7 @@
|
|
|
11977
11977
|
}
|
|
11978
11978
|
}
|
|
11979
11979
|
},
|
|
11980
|
-
"
|
|
11980
|
+
"DeviceStatus": {
|
|
11981
11981
|
"fields": {
|
|
11982
11982
|
"language": {
|
|
11983
11983
|
"type": "string",
|
|
@@ -12005,14 +12005,14 @@
|
|
|
12005
12005
|
}
|
|
12006
12006
|
}
|
|
12007
12007
|
},
|
|
12008
|
-
"
|
|
12008
|
+
"DeviceGetDeviceInfo": {
|
|
12009
12009
|
"fields": {
|
|
12010
12010
|
"targets": {
|
|
12011
|
-
"type": "
|
|
12011
|
+
"type": "DeviceInfoTargets",
|
|
12012
12012
|
"id": 1
|
|
12013
12013
|
},
|
|
12014
12014
|
"types": {
|
|
12015
|
-
"type": "
|
|
12015
|
+
"type": "DeviceInfoTypes",
|
|
12016
12016
|
"id": 2
|
|
12017
12017
|
}
|
|
12018
12018
|
}
|
|
@@ -12025,56 +12025,56 @@
|
|
|
12025
12025
|
"id": 1
|
|
12026
12026
|
},
|
|
12027
12027
|
"hw": {
|
|
12028
|
-
"type": "
|
|
12028
|
+
"type": "DeviceHardwareInfo",
|
|
12029
12029
|
"id": 100
|
|
12030
12030
|
},
|
|
12031
12031
|
"fw": {
|
|
12032
|
-
"type": "
|
|
12032
|
+
"type": "DeviceMainMcuInfo",
|
|
12033
12033
|
"id": 200
|
|
12034
12034
|
},
|
|
12035
12035
|
"bt": {
|
|
12036
|
-
"type": "
|
|
12036
|
+
"type": "DeviceBluetoothInfo",
|
|
12037
12037
|
"id": 300
|
|
12038
12038
|
},
|
|
12039
12039
|
"se1": {
|
|
12040
|
-
"type": "
|
|
12040
|
+
"type": "DeviceSEInfo",
|
|
12041
12041
|
"id": 400
|
|
12042
12042
|
},
|
|
12043
12043
|
"se2": {
|
|
12044
|
-
"type": "
|
|
12044
|
+
"type": "DeviceSEInfo",
|
|
12045
12045
|
"id": 410
|
|
12046
12046
|
},
|
|
12047
12047
|
"se3": {
|
|
12048
|
-
"type": "
|
|
12048
|
+
"type": "DeviceSEInfo",
|
|
12049
12049
|
"id": 420
|
|
12050
12050
|
},
|
|
12051
12051
|
"se4": {
|
|
12052
|
-
"type": "
|
|
12052
|
+
"type": "DeviceSEInfo",
|
|
12053
12053
|
"id": 430
|
|
12054
12054
|
},
|
|
12055
12055
|
"status": {
|
|
12056
|
-
"type": "
|
|
12056
|
+
"type": "DeviceStatus",
|
|
12057
12057
|
"id": 10000
|
|
12058
12058
|
}
|
|
12059
12059
|
}
|
|
12060
12060
|
},
|
|
12061
|
-
"
|
|
12061
|
+
"DeviceFirmwareTargetType": {
|
|
12062
12062
|
"values": {
|
|
12063
|
-
"
|
|
12064
|
-
"
|
|
12065
|
-
"
|
|
12066
|
-
"
|
|
12067
|
-
"
|
|
12068
|
-
"
|
|
12069
|
-
"
|
|
12063
|
+
"TARGET_INVALID": 0,
|
|
12064
|
+
"TARGET_ROMLOADER": 1,
|
|
12065
|
+
"TARGET_BOOTLOADER": 2,
|
|
12066
|
+
"TARGET_FIRMWARE_P1": 3,
|
|
12067
|
+
"TARGET_FIRMWARE_P2": 4,
|
|
12068
|
+
"TARGET_COPROCESSOR": 5,
|
|
12069
|
+
"TARGET_SE": 6,
|
|
12070
12070
|
"TARGET_RESOURCE": 10
|
|
12071
12071
|
}
|
|
12072
12072
|
},
|
|
12073
|
-
"
|
|
12073
|
+
"DeviceFirmwareTarget": {
|
|
12074
12074
|
"fields": {
|
|
12075
12075
|
"target_id": {
|
|
12076
12076
|
"rule": "required",
|
|
12077
|
-
"type": "
|
|
12077
|
+
"type": "DeviceFirmwareTargetType",
|
|
12078
12078
|
"id": 1
|
|
12079
12079
|
},
|
|
12080
12080
|
"path": {
|
|
@@ -12084,20 +12084,24 @@
|
|
|
12084
12084
|
}
|
|
12085
12085
|
}
|
|
12086
12086
|
},
|
|
12087
|
-
"
|
|
12087
|
+
"DeviceFirmwareUpdate": {
|
|
12088
12088
|
"fields": {
|
|
12089
12089
|
"targets": {
|
|
12090
12090
|
"rule": "repeated",
|
|
12091
|
-
"type": "
|
|
12091
|
+
"type": "DeviceFirmwareTarget",
|
|
12092
12092
|
"id": 1
|
|
12093
|
+
},
|
|
12094
|
+
"max_concurrent": {
|
|
12095
|
+
"type": "uint32",
|
|
12096
|
+
"id": 2
|
|
12093
12097
|
}
|
|
12094
12098
|
}
|
|
12095
12099
|
},
|
|
12096
|
-
"
|
|
12100
|
+
"DeviceFirmwareInstallProgress": {
|
|
12097
12101
|
"fields": {
|
|
12098
12102
|
"target_id": {
|
|
12099
12103
|
"rule": "required",
|
|
12100
|
-
"type": "
|
|
12104
|
+
"type": "DeviceFirmwareTargetType",
|
|
12101
12105
|
"id": 1
|
|
12102
12106
|
},
|
|
12103
12107
|
"progress": {
|
|
@@ -12111,11 +12115,11 @@
|
|
|
12111
12115
|
}
|
|
12112
12116
|
}
|
|
12113
12117
|
},
|
|
12114
|
-
"
|
|
12118
|
+
"DeviceFirmwareUpdateStatusEntry": {
|
|
12115
12119
|
"fields": {
|
|
12116
12120
|
"target_id": {
|
|
12117
12121
|
"rule": "required",
|
|
12118
|
-
"type": "
|
|
12122
|
+
"type": "DeviceFirmwareTargetType",
|
|
12119
12123
|
"id": 1
|
|
12120
12124
|
},
|
|
12121
12125
|
"status": {
|
|
@@ -12125,14 +12129,14 @@
|
|
|
12125
12129
|
}
|
|
12126
12130
|
}
|
|
12127
12131
|
},
|
|
12128
|
-
"
|
|
12132
|
+
"DeviceGetFirmwareUpdateStatus": {
|
|
12129
12133
|
"fields": {}
|
|
12130
12134
|
},
|
|
12131
|
-
"
|
|
12135
|
+
"DeviceFirmwareUpdateStatus": {
|
|
12132
12136
|
"fields": {
|
|
12133
12137
|
"targets": {
|
|
12134
12138
|
"rule": "repeated",
|
|
12135
|
-
"type": "
|
|
12139
|
+
"type": "DeviceFirmwareUpdateStatusEntry",
|
|
12136
12140
|
"id": 1
|
|
12137
12141
|
}
|
|
12138
12142
|
}
|
|
@@ -12399,10 +12403,10 @@
|
|
|
12399
12403
|
"FilesystemFormat": {
|
|
12400
12404
|
"fields": {}
|
|
12401
12405
|
},
|
|
12402
|
-
"
|
|
12406
|
+
"DeviceGetOnboardingStatus": {
|
|
12403
12407
|
"fields": {}
|
|
12404
12408
|
},
|
|
12405
|
-
"
|
|
12409
|
+
"DeviceOnboardingStatus": {
|
|
12406
12410
|
"fields": {
|
|
12407
12411
|
"page_index": {
|
|
12408
12412
|
"type": "uint32",
|
|
@@ -41,7 +41,8 @@ export const FIRMWARE_FIELDS = [
|
|
|
41
41
|
|
|
42
42
|
export type IFirmwareField = (typeof FIRMWARE_FIELDS)[number];
|
|
43
43
|
|
|
44
|
-
export type
|
|
44
|
+
export type ProtocolV1MessageSchema = 'protocolV1Current' | 'protocolV1Legacy';
|
|
45
|
+
export type ProtobufMessageSchema = ProtocolV1MessageSchema | 'protocolV2';
|
|
45
46
|
|
|
46
47
|
const FIRMWARE_FIELD_TYPE_MAP: Readonly<Record<IFirmwareField, EFirmwareType>> = {
|
|
47
48
|
firmware: EFirmwareType.Universal,
|
|
@@ -96,9 +97,9 @@ export default class DataManager {
|
|
|
96
97
|
|
|
97
98
|
static settings: ConnectSettings;
|
|
98
99
|
|
|
99
|
-
static messages: { [
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
static messages: { [schema in ProtobufMessageSchema]: JSON } = {
|
|
101
|
+
protocolV1Current: MessagesJSON as unknown as JSON,
|
|
102
|
+
protocolV1Legacy: MessagesLegacyV1JSON as unknown as JSON,
|
|
102
103
|
protocolV2: MessagesPro2JSON as unknown as JSON,
|
|
103
104
|
};
|
|
104
105
|
|
|
@@ -476,8 +477,8 @@ export default class DataManager {
|
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
|
|
479
|
-
static getProtobufMessages(
|
|
480
|
-
return this.messages[
|
|
480
|
+
static getProtobufMessages(schema: ProtobufMessageSchema = 'protocolV1Current'): JSON {
|
|
481
|
+
return this.messages[schema];
|
|
481
482
|
}
|
|
482
483
|
|
|
483
484
|
static getSettings(key?: undefined): ConnectSettings;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import type { IDeviceModel, IDeviceType } from '../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProtocolV1MessageSchema } from './DataManager';
|
|
3
3
|
|
|
4
4
|
type DeviceVersionConfig = {
|
|
5
5
|
[deviceType in IDeviceType | IDeviceModel]?: {
|
|
6
6
|
minVersion: string;
|
|
7
|
-
|
|
7
|
+
protocolV1MessageSchema: ProtocolV1MessageSchema;
|
|
8
8
|
}[];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const PROTOBUF_MESSAGE_CONFIG: DeviceVersionConfig = {
|
|
12
12
|
model_mini: [
|
|
13
|
-
// Classic1s starts from 3.5.0, so use
|
|
14
|
-
// Only use
|
|
15
|
-
{ minVersion: '3.3.0',
|
|
16
|
-
{ minVersion: '0.0.1',
|
|
17
|
-
// Fallback to
|
|
18
|
-
{ minVersion: '0.0.0',
|
|
13
|
+
// Classic1s starts from 3.5.0, so use the current Protocol V1 schema by default.
|
|
14
|
+
// Only use the legacy Protocol V1 schema for specific old versions (< 3.3.0).
|
|
15
|
+
{ minVersion: '3.3.0', protocolV1MessageSchema: 'protocolV1Current' },
|
|
16
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'protocolV1Legacy' },
|
|
17
|
+
// Fallback to current Protocol V1 schema for unknown versions (0.0.0).
|
|
18
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'protocolV1Current' },
|
|
19
19
|
],
|
|
20
20
|
model_touch: [
|
|
21
|
-
// Use
|
|
22
|
-
// Only use
|
|
23
|
-
{ minVersion: '4.5.0',
|
|
24
|
-
{ minVersion: '0.0.1',
|
|
25
|
-
// Fallback to
|
|
26
|
-
{ minVersion: '0.0.0',
|
|
21
|
+
// Use the current Protocol V1 schema by default for Touch/Pro.
|
|
22
|
+
// Only use the legacy Protocol V1 schema for specific old versions (< 4.5.0).
|
|
23
|
+
{ minVersion: '4.5.0', protocolV1MessageSchema: 'protocolV1Current' },
|
|
24
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'protocolV1Legacy' },
|
|
25
|
+
// Fallback to current Protocol V1 schema for unknown versions (0.0.0).
|
|
26
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'protocolV1Current' },
|
|
27
27
|
],
|
|
28
28
|
};
|
|
@@ -4,9 +4,9 @@ import DataManager from './DataManager';
|
|
|
4
4
|
import { LoggerNames, getLogger } from '../utils';
|
|
5
5
|
// eslint-disable-next-line import/no-cycle
|
|
6
6
|
import { DevicePool } from '../device/DevicePool';
|
|
7
|
-
import {
|
|
7
|
+
import { getSupportProtocolV1MessageSchema } from '../utils/deviceFeaturesUtils';
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { ProtocolV1MessageSchema } from './DataManager';
|
|
10
10
|
import type { LowlevelTransportSharedPlugin, Transport } from '@onekeyfe/hd-transport';
|
|
11
11
|
import type { Features } from '../types';
|
|
12
12
|
|
|
@@ -33,7 +33,7 @@ export default class TransportManager {
|
|
|
33
33
|
|
|
34
34
|
static reactNativeInit = false;
|
|
35
35
|
|
|
36
|
-
static
|
|
36
|
+
static protocolV1MessageSchema: ProtocolV1MessageSchema = 'protocolV1Current';
|
|
37
37
|
|
|
38
38
|
static plugin: LowlevelTransportSharedPlugin | null = null;
|
|
39
39
|
|
|
@@ -41,7 +41,7 @@ export default class TransportManager {
|
|
|
41
41
|
Log.debug('transport manager load');
|
|
42
42
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
43
43
|
this.currentMessages = this.defaultMessages;
|
|
44
|
-
this.
|
|
44
|
+
this.protocolV1MessageSchema = 'protocolV1Current';
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
static async configure() {
|
|
@@ -76,7 +76,7 @@ export default class TransportManager {
|
|
|
76
76
|
Log.debug('Configuring transports');
|
|
77
77
|
await this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
78
78
|
this.currentMessages = this.defaultMessages;
|
|
79
|
-
this.
|
|
79
|
+
this.protocolV1MessageSchema = 'protocolV1Current';
|
|
80
80
|
await this.configureProtocolV2Messages();
|
|
81
81
|
Log.debug('Configuring transports done');
|
|
82
82
|
} catch (error) {
|
|
@@ -90,8 +90,8 @@ export default class TransportManager {
|
|
|
90
90
|
/**
|
|
91
91
|
* Re-load the transport's main protobuf schema based on a device's reported features.
|
|
92
92
|
*
|
|
93
|
-
* This handles
|
|
94
|
-
* vs
|
|
93
|
+
* This handles protobuf schema compatibility within Protocol V1 (e.g. Touch's legacy
|
|
94
|
+
* vs current Protocol V1 schema). It is NOT used to switch between Protocol V1 and Protocol V2 —
|
|
95
95
|
* the transport already holds both schemas after initial configure(), and routes per
|
|
96
96
|
* device by `getProtocolType()`.
|
|
97
97
|
*/
|
|
@@ -100,18 +100,18 @@ export default class TransportManager {
|
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const {
|
|
103
|
+
const { protocolV1MessageSchema, messages } = getSupportProtocolV1MessageSchema(features);
|
|
104
104
|
|
|
105
105
|
if (this.currentMessages === messages || !messages) {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
Log.debug(`Reconfiguring transports
|
|
109
|
+
Log.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
|
|
110
110
|
|
|
111
111
|
try {
|
|
112
112
|
await this.transport.configure(JSON.stringify(messages));
|
|
113
113
|
this.currentMessages = messages;
|
|
114
|
-
this.
|
|
114
|
+
this.protocolV1MessageSchema = protocolV1MessageSchema;
|
|
115
115
|
} catch (error) {
|
|
116
116
|
throw ERRORS.TypedError(
|
|
117
117
|
HardwareErrorCode.TransportInvalidProtobuf,
|
|
@@ -164,7 +164,7 @@ export default class TransportManager {
|
|
|
164
164
|
return this.currentMessages;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
static
|
|
168
|
-
return this.
|
|
167
|
+
static getProtocolV1MessageSchema() {
|
|
168
|
+
return this.protocolV1MessageSchema;
|
|
169
169
|
}
|
|
170
170
|
}
|
package/src/device/Device.ts
CHANGED
|
@@ -543,8 +543,8 @@ export class Device extends EventEmitter {
|
|
|
543
543
|
/**
|
|
544
544
|
* Device initialization over Protocol V2.
|
|
545
545
|
*
|
|
546
|
-
* Protocol V2 不走传统 Initialize/GetFeatures
|
|
547
|
-
*
|
|
546
|
+
* Protocol V2 不走传统 Initialize/GetFeatures,当前仅通过 Ping 验证链路,
|
|
547
|
+
* 然后使用 descriptor 生成临时 Features 视图。
|
|
548
548
|
*/
|
|
549
549
|
private async _initializeProtocolV2() {
|
|
550
550
|
Log.debug('Initialize device via Protocol V2 feature adapter');
|
|
@@ -882,9 +882,13 @@ export class Device extends EventEmitter {
|
|
|
882
882
|
this.features,
|
|
883
883
|
Enum_Capability.Capability_AttachToPin
|
|
884
884
|
);
|
|
885
|
+
const isPro2 = getDeviceType(this.features) === EDeviceType.Pro2;
|
|
885
886
|
|
|
886
887
|
const supportUnlock =
|
|
887
|
-
supportAttachPinCapability ||
|
|
888
|
+
supportAttachPinCapability ||
|
|
889
|
+
// Pro2 V2 暂未从 features 暴露 capabilities,先直连该方法用于固件联调。
|
|
890
|
+
isPro2 ||
|
|
891
|
+
(versionRange && semver.gte(firmwareVersion, versionRange.min));
|
|
888
892
|
|
|
889
893
|
if (supportUnlock) {
|
|
890
894
|
const res = await this.commands.typedCall('UnLockDevice', 'UnLockDeviceResponse');
|
package/src/inject.ts
CHANGED
|
@@ -152,15 +152,15 @@ export const createCoreApi = (
|
|
|
152
152
|
// File system & device control API (Protocol V2 only)
|
|
153
153
|
getProtoVersion: (connectId, params) => call({ ...params, connectId, method: 'getProtoVersion' }),
|
|
154
154
|
ping: (connectId, params) => call({ ...params, connectId, method: 'ping' }),
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
call({ ...params, connectId, method: '
|
|
158
|
-
|
|
159
|
-
call({ ...params, connectId, method: '
|
|
160
|
-
|
|
161
|
-
call({ ...params, connectId, method: '
|
|
162
|
-
|
|
163
|
-
call({ ...params, connectId, method: '
|
|
155
|
+
deviceReboot: (connectId, params) => call({ ...params, connectId, method: 'deviceReboot' }),
|
|
156
|
+
deviceGetDeviceInfo: (connectId, params) =>
|
|
157
|
+
call({ ...params, connectId, method: 'deviceGetDeviceInfo' }),
|
|
158
|
+
deviceGetOnboardingStatus: (connectId, params) =>
|
|
159
|
+
call({ ...params, connectId, method: 'deviceGetOnboardingStatus' }),
|
|
160
|
+
deviceFirmwareUpdate: (connectId, params) =>
|
|
161
|
+
call({ ...params, connectId, method: 'deviceFirmwareUpdate' }),
|
|
162
|
+
deviceGetFirmwareUpdateStatus: (connectId, params) =>
|
|
163
|
+
call({ ...params, connectId, method: 'deviceGetFirmwareUpdateStatus' }),
|
|
164
164
|
factoryDeviceInfoSettings: (connectId, params) =>
|
|
165
165
|
call({ ...params, connectId, method: 'factoryDeviceInfoSettings' }),
|
|
166
166
|
factoryGetDeviceInfo: connectId => call({ connectId, method: 'factoryGetDeviceInfo' }),
|
|
@@ -22,6 +22,7 @@ type ProtocolV2SEInfo = {
|
|
|
22
22
|
type ProtocolV2DeviceInfo = {
|
|
23
23
|
protocol_version?: number;
|
|
24
24
|
hw?: {
|
|
25
|
+
Device_type?: number;
|
|
25
26
|
device_type?: number;
|
|
26
27
|
serial_no?: string;
|
|
27
28
|
hardware_version?: string;
|
|
@@ -130,7 +131,7 @@ function createBaseFeatures(descriptor: DeviceDescriptor): Features {
|
|
|
130
131
|
bootloader_mode: false,
|
|
131
132
|
device_id: descriptorId,
|
|
132
133
|
pin_protection: null,
|
|
133
|
-
passphrase_protection:
|
|
134
|
+
passphrase_protection: null,
|
|
134
135
|
language: null,
|
|
135
136
|
label: null,
|
|
136
137
|
initialized: false,
|
|
@@ -227,6 +228,7 @@ export function normalizeProtocolV2Features(
|
|
|
227
228
|
export async function getProtocolV2Features({
|
|
228
229
|
commands,
|
|
229
230
|
descriptor,
|
|
231
|
+
// onDeviceInfoError,
|
|
230
232
|
timeoutMs,
|
|
231
233
|
}: {
|
|
232
234
|
commands: DeviceCommands;
|
|
@@ -241,25 +243,24 @@ export async function getProtocolV2Features({
|
|
|
241
243
|
await commands.typedCall('Ping', 'Success', { message: 'init' });
|
|
242
244
|
}
|
|
243
245
|
|
|
244
|
-
//
|
|
245
|
-
// 固件支持后再恢复下面这段 DeviceInfo 读取,用于补全版本、序列号和状态字段。
|
|
246
|
+
// DeviceGetDeviceInfo 暂时关闭,避免初始化阶段依赖固件侧 DeviceInfo 支持。
|
|
246
247
|
// try {
|
|
247
248
|
// const { message } = callOptions
|
|
248
249
|
// ? await commands.typedCall(
|
|
249
|
-
// '
|
|
250
|
+
// 'DeviceGetDeviceInfo',
|
|
250
251
|
// 'DeviceInfo',
|
|
251
252
|
// PROTOCOL_V2_DEVICE_INFO_REQUEST,
|
|
252
253
|
// callOptions
|
|
253
254
|
// )
|
|
254
255
|
// : await commands.typedCall(
|
|
255
|
-
// '
|
|
256
|
+
// 'DeviceGetDeviceInfo',
|
|
256
257
|
// 'DeviceInfo',
|
|
257
258
|
// PROTOCOL_V2_DEVICE_INFO_REQUEST
|
|
258
259
|
// );
|
|
259
260
|
// return normalizeProtocolV2Features(descriptor, message as unknown as ProtocolV2DeviceInfo);
|
|
260
261
|
// } catch (error) {
|
|
261
262
|
// onDeviceInfoError?.(error);
|
|
262
|
-
//
|
|
263
|
+
// return normalizeProtocolV2Features(descriptor);
|
|
263
264
|
// }
|
|
264
265
|
|
|
265
266
|
return normalizeProtocolV2Features(descriptor);
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Protocol V2
|
|
2
|
+
* Protocol V2 DeviceFirmwareTargetType enum (from messages-pro2.json).
|
|
3
3
|
*/
|
|
4
4
|
export const ProtocolV2FirmwareTargetType = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
TARGET_INVALID: 0,
|
|
6
|
+
TARGET_ROMLOADER: 1,
|
|
7
|
+
TARGET_BOOTLOADER: 2,
|
|
8
|
+
TARGET_FIRMWARE_P1: 3,
|
|
9
|
+
TARGET_FIRMWARE_P2: 4,
|
|
10
|
+
TARGET_COPROCESSOR: 5,
|
|
11
|
+
TARGET_SE: 6,
|
|
12
12
|
TARGET_RESOURCE: 10,
|
|
13
13
|
} as const;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Map Protocol V2 firmware file name to
|
|
16
|
+
* Map Protocol V2 firmware file name to DeviceFirmwareUpdate target_id.
|
|
17
17
|
*/
|
|
18
18
|
export function protocolV2FileNameToTargetId(fileName: string): number {
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
return ProtocolV2FirmwareTargetType.
|
|
19
|
+
const normalized = fileName.toLowerCase();
|
|
20
|
+
if (normalized.includes('romloader')) return ProtocolV2FirmwareTargetType.TARGET_ROMLOADER;
|
|
21
|
+
if (normalized.includes('bootloader')) return ProtocolV2FirmwareTargetType.TARGET_BOOTLOADER;
|
|
22
|
+
if (normalized.includes('ble')) return ProtocolV2FirmwareTargetType.TARGET_COPROCESSOR;
|
|
23
|
+
if (normalized.includes('se')) return ProtocolV2FirmwareTargetType.TARGET_SE;
|
|
24
|
+
if (normalized.includes('p2')) return ProtocolV2FirmwareTargetType.TARGET_FIRMWARE_P2;
|
|
25
|
+
return ProtocolV2FirmwareTargetType.TARGET_FIRMWARE_P1;
|
|
26
26
|
}
|