@onekeyfe/hd-core 1.1.27-alpha.30 → 1.1.27-alpha.32

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.
Files changed (111) hide show
  1. package/__tests__/evmSignTransaction.test.ts +1 -1
  2. package/__tests__/evmSignTypedData.test.ts +1 -1
  3. package/__tests__/protocol-v2.test.ts +503 -37
  4. package/dist/api/DirList.d.ts.map +1 -1
  5. package/dist/api/DirMake.d.ts.map +1 -1
  6. package/dist/api/DirRemove.d.ts.map +1 -1
  7. package/dist/api/FileDelete.d.ts.map +1 -1
  8. package/dist/api/FileRead.d.ts.map +1 -1
  9. package/dist/api/FileWrite.d.ts.map +1 -1
  10. package/dist/api/GetPassphraseState.d.ts +6 -1
  11. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  12. package/dist/api/PathInfo.d.ts.map +1 -1
  13. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  14. package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
  15. package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
  16. package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
  17. package/dist/api/helpers/filesystemValidation.d.ts +7 -0
  18. package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
  19. package/dist/api/index.d.ts +5 -5
  20. package/dist/api/index.d.ts.map +1 -1
  21. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
  22. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
  23. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +7 -0
  24. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
  25. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
  26. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
  27. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
  28. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
  29. package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
  30. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
  31. package/dist/api/protocol-v2/helpers.d.ts +19 -19
  32. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  33. package/dist/core/index.d.ts.map +1 -1
  34. package/dist/data-manager/DataManager.d.ts +4 -3
  35. package/dist/data-manager/DataManager.d.ts.map +1 -1
  36. package/dist/data-manager/MessagesConfig.d.ts +2 -2
  37. package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
  38. package/dist/data-manager/TransportManager.d.ts +3 -3
  39. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  40. package/dist/device/Device.d.ts.map +1 -1
  41. package/dist/index.d.ts +37 -27
  42. package/dist/index.js +385 -236
  43. package/dist/protocols/protocol-v2/features.d.ts +2 -1
  44. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  45. package/dist/protocols/protocol-v2/firmware.d.ts +7 -7
  46. package/dist/types/api/getPassphraseState.d.ts +10 -1
  47. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  48. package/dist/types/api/index.d.ts +7 -6
  49. package/dist/types/api/index.d.ts.map +1 -1
  50. package/dist/types/api/protocolV2.d.ts +16 -16
  51. package/dist/types/api/protocolV2.d.ts.map +1 -1
  52. package/dist/utils/deviceFeaturesUtils.d.ts +5 -3
  53. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  54. package/dist/utils/patch.d.ts +1 -1
  55. package/dist/utils/patch.d.ts.map +1 -1
  56. package/package.json +4 -4
  57. package/src/api/DirList.ts +6 -2
  58. package/src/api/DirMake.ts +2 -1
  59. package/src/api/DirRemove.ts +2 -1
  60. package/src/api/FileDelete.ts +2 -1
  61. package/src/api/FileRead.ts +12 -5
  62. package/src/api/FileWrite.ts +19 -7
  63. package/src/api/FirmwareUpdateV4.ts +13 -13
  64. package/src/api/GetPassphraseState.ts +18 -2
  65. package/src/api/PathInfo.ts +2 -1
  66. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +15 -0
  67. package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
  68. package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
  69. package/src/api/device/DeviceRebootToBootloader.ts +4 -4
  70. package/src/api/dynex/DnxGetAddress.ts +7 -0
  71. package/src/api/dynex/DnxSignTransaction.ts +7 -0
  72. package/src/api/evm/EVMGetAddress.ts +1 -1
  73. package/src/api/evm/EVMGetPublicKey.ts +1 -1
  74. package/src/api/evm/EVMSignMessage.ts +1 -1
  75. package/src/api/evm/EVMSignTransaction.ts +1 -1
  76. package/src/api/evm/EVMSignTypedData.ts +6 -6
  77. package/src/api/evm/EVMVerifyMessage.ts +1 -1
  78. package/src/api/helpers/batchGetPublickeys.ts +4 -2
  79. package/src/api/helpers/filesystemValidation.ts +51 -0
  80. package/src/api/index.ts +5 -5
  81. package/src/api/protocol-v2/{DevFirmwareUpdate.ts → DeviceFirmwareUpdate.ts} +5 -4
  82. package/src/api/protocol-v2/{DevGetDeviceInfo.ts → DeviceGetDeviceInfo.ts} +3 -3
  83. package/src/api/protocol-v2/{DevGetFirmwareUpdateStatus.ts → DeviceGetFirmwareUpdateStatus.ts} +3 -3
  84. package/src/api/protocol-v2/{DevGetOnboardingStatus.ts → DeviceGetOnboardingStatus.ts} +3 -3
  85. package/src/api/protocol-v2/{DevReboot.ts → DeviceReboot.ts} +3 -3
  86. package/src/api/protocol-v2/helpers.ts +68 -45
  87. package/src/api/tron/TronSignMessage.ts +1 -1
  88. package/src/api/xrp/XrpSignTransaction.ts +1 -1
  89. package/src/core/index.ts +13 -1
  90. package/src/data/messages/{messages-pro2.json → messages-protocol-v2.json} +67 -63
  91. package/src/data-manager/DataManager.ts +9 -8
  92. package/src/data-manager/MessagesConfig.ts +14 -14
  93. package/src/data-manager/TransportManager.ts +13 -13
  94. package/src/device/Device.ts +7 -3
  95. package/src/inject.ts +9 -9
  96. package/src/protocols/protocol-v2/features.ts +39 -41
  97. package/src/protocols/protocol-v2/firmware.ts +16 -16
  98. package/src/types/api/getPassphraseState.ts +15 -2
  99. package/src/types/api/index.ts +11 -10
  100. package/src/types/api/protocolV2.ts +27 -27
  101. package/src/utils/deviceFeaturesUtils.ts +53 -19
  102. package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts +0 -7
  103. package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts.map +0 -1
  104. package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts +0 -7
  105. package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts.map +0 -1
  106. package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts +0 -6
  107. package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts.map +0 -1
  108. package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts +0 -6
  109. package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts.map +0 -1
  110. package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
  111. package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
@@ -1,23 +1,25 @@
1
- import { DevRebootType } from '@onekeyfe/hd-transport';
1
+ import { DeviceRebootType } from '@onekeyfe/hd-transport';
2
+
3
+ import { invalidParameter, validateNonEmptyString } from '../helpers/filesystemValidation';
2
4
 
3
5
  import type {
4
- DevFirmwareTarget,
5
- DevFirmwareTargetType,
6
- DevInfoTargets,
7
- DevInfoTypes,
6
+ DeviceFirmwareTarget,
7
+ DeviceFirmwareTargetType,
8
+ DeviceInfoTargets,
9
+ DeviceInfoTypes,
8
10
  TransportCallOptions,
9
11
  } from '@onekeyfe/hd-transport';
10
12
 
11
- export type RebootTypeInput = DevRebootType | keyof typeof DevRebootType | string | number;
13
+ export type RebootTypeInput = DeviceRebootType | keyof typeof DeviceRebootType | string | number;
12
14
 
13
- export type DevRebootParams = {
15
+ export type DeviceRebootParams = {
14
16
  rebootType?: RebootTypeInput;
15
17
  reboot_type?: RebootTypeInput;
16
18
  };
17
19
 
18
- export type DevGetDeviceInfoParams = {
19
- targets?: DevInfoTargets;
20
- types?: DevInfoTypes;
20
+ export type DeviceGetDeviceInfoParams = {
21
+ targets?: DeviceInfoTargets;
22
+ types?: DeviceInfoTypes;
21
23
  targetHw?: boolean;
22
24
  targetFw?: boolean;
23
25
  targetBt?: boolean;
@@ -32,18 +34,18 @@ export type DevGetDeviceInfoParams = {
32
34
  includeSpecific?: boolean;
33
35
  };
34
36
 
35
- export type DevFirmwareTargetInput =
36
- | DevFirmwareTarget
37
+ export type DeviceFirmwareTargetInput =
38
+ | DeviceFirmwareTarget
37
39
  | {
38
- targetId?: DevFirmwareTargetType | string | number;
39
- target_id?: DevFirmwareTargetType | string | number;
40
+ targetId?: DeviceFirmwareTargetType | string | number;
41
+ target_id?: DeviceFirmwareTargetType | string | number;
40
42
  path: string;
41
43
  };
42
44
 
43
- export type DevFirmwareUpdateParams = {
44
- targets?: DevFirmwareTargetInput[];
45
- targetId?: DevFirmwareTargetType | string | number;
46
- target_id?: DevFirmwareTargetType | string | number;
45
+ export type DeviceFirmwareUpdateParams = {
46
+ targets?: DeviceFirmwareTargetInput[];
47
+ targetId?: DeviceFirmwareTargetType | string | number;
48
+ target_id?: DeviceFirmwareTargetType | string | number;
47
49
  path?: string;
48
50
  };
49
51
 
@@ -56,42 +58,53 @@ export type FactoryDeviceInfoSettingsParams = {
56
58
  preFirmware?: string;
57
59
  };
58
60
 
59
- const DEV_REBOOT_TYPES: Record<string, DevRebootType> = {
60
- Normal: DevRebootType.Normal,
61
- normal: DevRebootType.Normal,
62
- Boardloader: DevRebootType.Boardloader,
63
- boardloader: DevRebootType.Boardloader,
64
- Bootloader: DevRebootType.Bootloader,
65
- bootloader: DevRebootType.Bootloader,
61
+ const DEVICE_REBOOT_TYPES: Record<string, DeviceRebootType> = {
62
+ Normal: DeviceRebootType.Normal,
63
+ normal: DeviceRebootType.Normal,
64
+ Boardloader: DeviceRebootType.Boardloader,
65
+ boardloader: DeviceRebootType.Boardloader,
66
+ Bootloader: DeviceRebootType.Bootloader,
67
+ bootloader: DeviceRebootType.Bootloader,
66
68
  };
67
69
 
68
70
  export const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS: TransportCallOptions = {
69
- intermediateTypes: ['DevFirmwareInstallProgress'],
71
+ intermediateTypes: ['DeviceFirmwareInstallProgress'],
70
72
  };
71
73
 
72
- export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: ('Success' | 'DevFirmwareUpdateStatus')[] =
73
- ['Success', 'DevFirmwareUpdateStatus'];
74
+ export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: (
75
+ | 'Success'
76
+ | 'DeviceFirmwareUpdateStatus'
77
+ )[] = ['Success', 'DeviceFirmwareUpdateStatus'];
74
78
 
75
- export function normalizeRebootType(value: RebootTypeInput | undefined): DevRebootType {
79
+ export function normalizeRebootType(value: RebootTypeInput | undefined): DeviceRebootType {
76
80
  if (typeof value === 'number') return value;
77
81
  if (typeof value === 'string') {
78
82
  const numeric = Number(value);
79
83
  if (Number.isFinite(numeric)) return numeric;
80
- if (value in DEV_REBOOT_TYPES) return DEV_REBOOT_TYPES[value];
84
+ if (value in DEVICE_REBOOT_TYPES) return DEVICE_REBOOT_TYPES[value];
81
85
  }
82
- return DevRebootType.Normal;
86
+ return DeviceRebootType.Normal;
83
87
  }
84
88
 
85
89
  function normalizeTargetId(
86
- value: DevFirmwareTargetType | string | number | undefined
87
- ): DevFirmwareTargetType {
88
- if (typeof value === 'number') return value;
90
+ value: DeviceFirmwareTargetType | string | number | undefined,
91
+ name: string
92
+ ): DeviceFirmwareTargetType {
93
+ if (value === undefined || value === null) {
94
+ throw invalidParameter(`Missing required parameter: ${name}`);
95
+ }
96
+ if (typeof value === 'number') {
97
+ if (Number.isSafeInteger(value) && value > 0) return value;
98
+ throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
99
+ }
89
100
  const numeric = Number(value);
90
- if (Number.isFinite(numeric)) return numeric;
91
- return 0;
101
+ if (Number.isSafeInteger(numeric) && numeric > 0) return numeric;
102
+ throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
92
103
  }
93
104
 
94
- export function normalizeFirmwareTargets(params: DevFirmwareUpdateParams): DevFirmwareTarget[] {
105
+ export function normalizeFirmwareTargets(
106
+ params: DeviceFirmwareUpdateParams
107
+ ): DeviceFirmwareTarget[] {
95
108
  const targets =
96
109
  params.targets ??
97
110
  (params.path
@@ -103,16 +116,26 @@ export function normalizeFirmwareTargets(params: DevFirmwareUpdateParams): DevFi
103
116
  ]
104
117
  : []);
105
118
 
106
- return targets.map(target => ({
107
- target_id: normalizeTargetId('target_id' in target ? target.target_id : target.targetId),
108
- path: target.path,
109
- }));
119
+ if (!Array.isArray(targets) || targets.length === 0) {
120
+ throw invalidParameter('Parameter [targets] must contain at least one firmware target.');
121
+ }
122
+
123
+ return targets.map((target, index) => {
124
+ if (!target || typeof target !== 'object') {
125
+ throw invalidParameter(`Parameter [targets.${index}] must be an object.`);
126
+ }
127
+ const targetId = target.target_id ?? target.targetId;
128
+ return {
129
+ target_id: normalizeTargetId(targetId, `targets.${index}.target_id`),
130
+ path: validateNonEmptyString(target.path, `targets.${index}.path`),
131
+ };
132
+ });
110
133
  }
111
134
 
112
- export function buildTargets(params: DevGetDeviceInfoParams): DevInfoTargets | undefined {
135
+ export function buildTargets(params: DeviceGetDeviceInfoParams): DeviceInfoTargets | undefined {
113
136
  if (params.targets) return params.targets;
114
137
 
115
- const targets: DevInfoTargets = {
138
+ const targets: DeviceInfoTargets = {
116
139
  hw: params.targetHw,
117
140
  fw: params.targetFw,
118
141
  bt: params.targetBt,
@@ -125,10 +148,10 @@ export function buildTargets(params: DevGetDeviceInfoParams): DevInfoTargets | u
125
148
  return Object.values(targets).some(value => value !== undefined) ? targets : undefined;
126
149
  }
127
150
 
128
- export function buildTypes(params: DevGetDeviceInfoParams): DevInfoTypes | undefined {
151
+ export function buildTypes(params: DeviceGetDeviceInfoParams): DeviceInfoTypes | undefined {
129
152
  if (params.types) return params.types;
130
153
 
131
- const types: DevInfoTypes = {
154
+ const types: DeviceInfoTypes = {
132
155
  version: params.includeVersion,
133
156
  build_id: params.includeBuildId,
134
157
  hash: params.includeHash,
@@ -28,7 +28,7 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
28
28
  if (this.payload.messageType === 'V1' || this.payload.messageType == null) {
29
29
  throw createDeviceNotSupportMethodError(
30
30
  'TronSignMessage',
31
- getFirmwareType(this.device.features)
31
+ getFirmwareType(this.device?.features)
32
32
  );
33
33
  }
34
34
 
@@ -29,7 +29,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
29
29
  { name: 'payment', type: 'object' },
30
30
  ]);
31
31
  validateParams(transaction.payment, [
32
- { name: 'amount', type: 'number', required: true },
32
+ { name: 'amount', type: 'uint', required: true },
33
33
  { name: 'destination', type: 'string', required: true },
34
34
  { name: 'destinationTag', type: 'number' },
35
35
  ]);
package/src/core/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import semver from 'semver';
2
2
  import EventEmitter from 'events';
3
3
  import {
4
+ EDeviceType,
4
5
  ERRORS,
5
6
  ERROR_CODES_REQUIRE_RELEASE,
6
7
  HardwareError,
@@ -19,6 +20,7 @@ import {
19
20
  enableLog,
20
21
  getDeviceBLEFirmwareVersion,
21
22
  getDeviceFirmwareVersion,
23
+ getDeviceType,
22
24
  getFirmwareType,
23
25
  getLogger,
24
26
  getMethodVersionRange,
@@ -477,7 +479,7 @@ const onCallDevice = async (
477
479
  // Check to see if it is safe to use Passphrase
478
480
  checkPassphraseEnableState(method, device.features);
479
481
 
480
- if (device.hasUsePassphrase() && method.useDevicePassphraseState) {
482
+ if (shouldCheckPassphraseState(method, device)) {
481
483
  // check version
482
484
  const support = supportNewPassphrase(device.features);
483
485
  if (!support.support) {
@@ -1010,6 +1012,16 @@ const checkPassphraseEnableState = (method: BaseMethod, features?: Features) =>
1010
1012
  }
1011
1013
  };
1012
1014
 
1015
+ const shouldCheckPassphraseState = (method: BaseMethod, device: Device) => {
1016
+ if (!method.useDevicePassphraseState) return false;
1017
+
1018
+ const isPro2 = getDeviceType(device.features) === EDeviceType.Pro2;
1019
+ const pro2ExplicitWalletSelection =
1020
+ isPro2 && (!!method.payload?.passphraseState || !!method.payload?.useEmptyPassphrase);
1021
+
1022
+ return device.hasUsePassphrase() || pro2ExplicitWalletSelection;
1023
+ };
1024
+
1013
1025
  const cleanup = () => {
1014
1026
  _uiPromises = [];
1015
1027
  Log.debug('Cleanup...');
@@ -484,11 +484,11 @@
484
484
  "MessageType_Ping": 60206,
485
485
  "MessageType_Success": 60207,
486
486
  "MessageType_Failure": 60208,
487
- "MessageType_DevReboot": 60400,
488
- "MessageType_DevGetDeviceInfo": 60600,
487
+ "MessageType_DeviceReboot": 60400,
488
+ "MessageType_DeviceGetDeviceInfo": 60600,
489
489
  "MessageType_DeviceInfo": 60601,
490
- "MessageType_DevGetOnboardingStatus": 60602,
491
- "MessageType_DevOnboardingStatus": 60603,
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
- "MessageType_DevFirmwareUpdate": 61000,
505
- "MessageType_DevFirmwareInstallProgress": 61001,
506
- "MessageType_DevGetFirmwareUpdateStatus": 61002,
507
- "MessageType_DevFirmwareUpdateStatus": 61003
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
- "DevRebootType": {
11793
+ "DeviceRebootType": {
11794
11794
  "values": {
11795
11795
  "Normal": 0,
11796
11796
  "Boardloader": 1,
11797
11797
  "Bootloader": 2
11798
11798
  }
11799
11799
  },
11800
- "DevReboot": {
11800
+ "DeviceReboot": {
11801
11801
  "fields": {
11802
11802
  "reboot_type": {
11803
11803
  "rule": "required",
11804
- "type": "DevRebootType",
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
- "DevSeType": {
11819
+ "DeviceSeType": {
11820
11820
  "values": {
11821
11821
  "THD89": 0,
11822
11822
  "SE608A": 1
11823
11823
  }
11824
11824
  },
11825
- "DevSEState": {
11825
+ "DeviceSEState": {
11826
11826
  "values": {
11827
11827
  "BOOT": 0,
11828
11828
  "APP_FACTORY": 51,
11829
11829
  "APP": 85
11830
11830
  }
11831
11831
  },
11832
- "DevFirmwareImageInfo": {
11832
+ "DeviceFirmwareImageInfo": {
11833
11833
  "fields": {
11834
11834
  "version": {
11835
11835
  "type": "string",
@@ -11845,9 +11845,9 @@
11845
11845
  }
11846
11846
  }
11847
11847
  },
11848
- "DevHardwareInfo": {
11848
+ "DeviceHardwareInfo": {
11849
11849
  "fields": {
11850
- "device_type": {
11850
+ "Device_type": {
11851
11851
  "type": "DeviceType",
11852
11852
  "id": 10
11853
11853
  },
@@ -11865,30 +11865,30 @@
11865
11865
  }
11866
11866
  }
11867
11867
  },
11868
- "DevMainMcuInfo": {
11868
+ "DeviceMainMcuInfo": {
11869
11869
  "fields": {
11870
11870
  "board": {
11871
- "type": "DevFirmwareImageInfo",
11871
+ "type": "DeviceFirmwareImageInfo",
11872
11872
  "id": 10
11873
11873
  },
11874
11874
  "boot": {
11875
- "type": "DevFirmwareImageInfo",
11875
+ "type": "DeviceFirmwareImageInfo",
11876
11876
  "id": 20
11877
11877
  },
11878
11878
  "app": {
11879
- "type": "DevFirmwareImageInfo",
11879
+ "type": "DeviceFirmwareImageInfo",
11880
11880
  "id": 30
11881
11881
  }
11882
11882
  }
11883
11883
  },
11884
- "DevBluetoothInfo": {
11884
+ "DeviceBluetoothInfo": {
11885
11885
  "fields": {
11886
11886
  "boot": {
11887
- "type": "DevFirmwareImageInfo",
11887
+ "type": "DeviceFirmwareImageInfo",
11888
11888
  "id": 20
11889
11889
  },
11890
11890
  "app": {
11891
- "type": "DevFirmwareImageInfo",
11891
+ "type": "DeviceFirmwareImageInfo",
11892
11892
  "id": 30
11893
11893
  },
11894
11894
  "adv_name": {
@@ -11901,27 +11901,27 @@
11901
11901
  }
11902
11902
  }
11903
11903
  },
11904
- "DevSEInfo": {
11904
+ "DeviceSEInfo": {
11905
11905
  "fields": {
11906
11906
  "boot": {
11907
- "type": "DevFirmwareImageInfo",
11907
+ "type": "DeviceFirmwareImageInfo",
11908
11908
  "id": 20
11909
11909
  },
11910
11910
  "app": {
11911
- "type": "DevFirmwareImageInfo",
11911
+ "type": "DeviceFirmwareImageInfo",
11912
11912
  "id": 30
11913
11913
  },
11914
11914
  "type": {
11915
- "type": "DevSeType",
11915
+ "type": "DeviceSeType",
11916
11916
  "id": 100
11917
11917
  },
11918
11918
  "state": {
11919
- "type": "DevSEState",
11919
+ "type": "DeviceSEState",
11920
11920
  "id": 110
11921
11921
  }
11922
11922
  }
11923
11923
  },
11924
- "DevInfoTargets": {
11924
+ "DeviceInfoTargets": {
11925
11925
  "fields": {
11926
11926
  "hw": {
11927
11927
  "type": "bool",
@@ -11957,7 +11957,7 @@
11957
11957
  }
11958
11958
  }
11959
11959
  },
11960
- "DevInfoTypes": {
11960
+ "DeviceInfoTypes": {
11961
11961
  "fields": {
11962
11962
  "version": {
11963
11963
  "type": "bool",
@@ -11977,7 +11977,7 @@
11977
11977
  }
11978
11978
  }
11979
11979
  },
11980
- "DevStatus": {
11980
+ "DeviceStatus": {
11981
11981
  "fields": {
11982
11982
  "language": {
11983
11983
  "type": "string",
@@ -12005,14 +12005,14 @@
12005
12005
  }
12006
12006
  }
12007
12007
  },
12008
- "DevGetDeviceInfo": {
12008
+ "DeviceGetDeviceInfo": {
12009
12009
  "fields": {
12010
12010
  "targets": {
12011
- "type": "DevInfoTargets",
12011
+ "type": "DeviceInfoTargets",
12012
12012
  "id": 1
12013
12013
  },
12014
12014
  "types": {
12015
- "type": "DevInfoTypes",
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": "DevHardwareInfo",
12028
+ "type": "DeviceHardwareInfo",
12029
12029
  "id": 100
12030
12030
  },
12031
12031
  "fw": {
12032
- "type": "DevMainMcuInfo",
12032
+ "type": "DeviceMainMcuInfo",
12033
12033
  "id": 200
12034
12034
  },
12035
12035
  "bt": {
12036
- "type": "DevBluetoothInfo",
12036
+ "type": "DeviceBluetoothInfo",
12037
12037
  "id": 300
12038
12038
  },
12039
12039
  "se1": {
12040
- "type": "DevSEInfo",
12040
+ "type": "DeviceSEInfo",
12041
12041
  "id": 400
12042
12042
  },
12043
12043
  "se2": {
12044
- "type": "DevSEInfo",
12044
+ "type": "DeviceSEInfo",
12045
12045
  "id": 410
12046
12046
  },
12047
12047
  "se3": {
12048
- "type": "DevSEInfo",
12048
+ "type": "DeviceSEInfo",
12049
12049
  "id": 420
12050
12050
  },
12051
12051
  "se4": {
12052
- "type": "DevSEInfo",
12052
+ "type": "DeviceSEInfo",
12053
12053
  "id": 430
12054
12054
  },
12055
12055
  "status": {
12056
- "type": "DevStatus",
12056
+ "type": "DeviceStatus",
12057
12057
  "id": 10000
12058
12058
  }
12059
12059
  }
12060
12060
  },
12061
- "DevFirmwareTargetType": {
12061
+ "DeviceFirmwareTargetType": {
12062
12062
  "values": {
12063
- "TARGET_MAIN_APP": 0,
12064
- "TARGET_MAIN_BOOT": 1,
12065
- "TARGET_BT": 2,
12066
- "TARGET_SE1": 3,
12067
- "TARGET_SE2": 4,
12068
- "TARGET_SE3": 5,
12069
- "TARGET_SE4": 6,
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
- "DevFirmwareTarget": {
12073
+ "DeviceFirmwareTarget": {
12074
12074
  "fields": {
12075
12075
  "target_id": {
12076
12076
  "rule": "required",
12077
- "type": "DevFirmwareTargetType",
12077
+ "type": "DeviceFirmwareTargetType",
12078
12078
  "id": 1
12079
12079
  },
12080
12080
  "path": {
@@ -12084,20 +12084,24 @@
12084
12084
  }
12085
12085
  }
12086
12086
  },
12087
- "DevFirmwareUpdate": {
12087
+ "DeviceFirmwareUpdate": {
12088
12088
  "fields": {
12089
12089
  "targets": {
12090
12090
  "rule": "repeated",
12091
- "type": "DevFirmwareTarget",
12091
+ "type": "DeviceFirmwareTarget",
12092
12092
  "id": 1
12093
+ },
12094
+ "max_concurrent": {
12095
+ "type": "uint32",
12096
+ "id": 2
12093
12097
  }
12094
12098
  }
12095
12099
  },
12096
- "DevFirmwareInstallProgress": {
12100
+ "DeviceFirmwareInstallProgress": {
12097
12101
  "fields": {
12098
12102
  "target_id": {
12099
12103
  "rule": "required",
12100
- "type": "DevFirmwareTargetType",
12104
+ "type": "DeviceFirmwareTargetType",
12101
12105
  "id": 1
12102
12106
  },
12103
12107
  "progress": {
@@ -12111,11 +12115,11 @@
12111
12115
  }
12112
12116
  }
12113
12117
  },
12114
- "DevFirmwareUpdateStatusEntry": {
12118
+ "DeviceFirmwareUpdateStatusEntry": {
12115
12119
  "fields": {
12116
12120
  "target_id": {
12117
12121
  "rule": "required",
12118
- "type": "DevFirmwareTargetType",
12122
+ "type": "DeviceFirmwareTargetType",
12119
12123
  "id": 1
12120
12124
  },
12121
12125
  "status": {
@@ -12125,14 +12129,14 @@
12125
12129
  }
12126
12130
  }
12127
12131
  },
12128
- "DevGetFirmwareUpdateStatus": {
12132
+ "DeviceGetFirmwareUpdateStatus": {
12129
12133
  "fields": {}
12130
12134
  },
12131
- "DevFirmwareUpdateStatus": {
12135
+ "DeviceFirmwareUpdateStatus": {
12132
12136
  "fields": {
12133
12137
  "targets": {
12134
12138
  "rule": "repeated",
12135
- "type": "DevFirmwareUpdateStatusEntry",
12139
+ "type": "DeviceFirmwareUpdateStatusEntry",
12136
12140
  "id": 1
12137
12141
  }
12138
12142
  }
@@ -12399,10 +12403,10 @@
12399
12403
  "FilesystemFormat": {
12400
12404
  "fields": {}
12401
12405
  },
12402
- "DevGetOnboardingStatus": {
12406
+ "DeviceGetOnboardingStatus": {
12403
12407
  "fields": {}
12404
12408
  },
12405
- "DevOnboardingStatus": {
12409
+ "DeviceOnboardingStatus": {
12406
12410
  "fields": {
12407
12411
  "page_index": {
12408
12412
  "type": "uint32",
@@ -4,7 +4,7 @@ import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
4
4
 
5
5
  import MessagesJSON from '../data/messages/messages.json';
6
6
  import MessagesLegacyV1JSON from '../data/messages/messages_legacy_v1.json';
7
- import MessagesPro2JSON from '../data/messages/messages-pro2.json';
7
+ import MessagesProtocolV2JSON from '../data/messages/messages-protocol-v2.json';
8
8
  import {
9
9
  LoggerNames,
10
10
  getDeviceBLEFirmwareVersion,
@@ -41,7 +41,8 @@ export const FIRMWARE_FIELDS = [
41
41
 
42
42
  export type IFirmwareField = (typeof FIRMWARE_FIELDS)[number];
43
43
 
44
- export type MessageVersion = 'latest' | 'v1' | 'protocolV2';
44
+ export type ProtocolV1MessageSchema = 'v1CurrentSchema' | 'v1LegacySchema';
45
+ export type ProtobufMessageSchema = ProtocolV1MessageSchema | 'v2Schema';
45
46
 
46
47
  const FIRMWARE_FIELD_TYPE_MAP: Readonly<Record<IFirmwareField, EFirmwareType>> = {
47
48
  firmware: EFirmwareType.Universal,
@@ -96,10 +97,10 @@ export default class DataManager {
96
97
 
97
98
  static settings: ConnectSettings;
98
99
 
99
- static messages: { [version in MessageVersion]: JSON } = {
100
- latest: MessagesJSON as unknown as JSON,
101
- v1: MessagesLegacyV1JSON as unknown as JSON,
102
- protocolV2: MessagesPro2JSON as unknown as JSON,
100
+ static messages: { [schema in ProtobufMessageSchema]: JSON } = {
101
+ v1CurrentSchema: MessagesJSON as unknown as JSON,
102
+ v1LegacySchema: MessagesLegacyV1JSON as unknown as JSON,
103
+ v2Schema: MessagesProtocolV2JSON as unknown as JSON,
103
104
  };
104
105
 
105
106
  static lastCheckTimestamp = 0;
@@ -476,8 +477,8 @@ export default class DataManager {
476
477
  }
477
478
  }
478
479
 
479
- static getProtobufMessages(messageVersion: MessageVersion = 'latest'): JSON {
480
- return this.messages[messageVersion];
480
+ static getProtobufMessages(schema: ProtobufMessageSchema = 'v1CurrentSchema'): 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 { MessageVersion } from './DataManager';
2
+ import type { ProtocolV1MessageSchema } from './DataManager';
3
3
 
4
4
  type DeviceVersionConfig = {
5
5
  [deviceType in IDeviceType | IDeviceModel]?: {
6
6
  minVersion: string;
7
- messageVersion: MessageVersion;
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 latest by default
14
- // Only use v1 for specific old versions (< 3.3.0)
15
- { minVersion: '3.3.0', messageVersion: 'latest' },
16
- { minVersion: '0.0.1', messageVersion: 'v1' },
17
- // Fallback to latest for unknown versions (0.0.0) to prevent device type detection issues
18
- { minVersion: '0.0.0', messageVersion: 'latest' },
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: 'v1CurrentSchema' },
16
+ { minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
17
+ // Fallback to current Protocol V1 schema for unknown versions (0.0.0).
18
+ { minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
19
19
  ],
20
20
  model_touch: [
21
- // Use latest by default for Touch/Pro
22
- // Only use v1 for specific old versions (< 4.5.0)
23
- { minVersion: '4.5.0', messageVersion: 'latest' },
24
- { minVersion: '0.0.1', messageVersion: 'v1' },
25
- // Fallback to latest for unknown versions (0.0.0)
26
- { minVersion: '0.0.0', messageVersion: 'latest' },
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: 'v1CurrentSchema' },
24
+ { minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
25
+ // Fallback to current Protocol V1 schema for unknown versions (0.0.0).
26
+ { minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
27
27
  ],
28
28
  };