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

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 (130) hide show
  1. package/__tests__/protocol-v2.test.ts +140 -45
  2. package/dist/api/BaseMethod.d.ts.map +1 -1
  3. package/dist/api/GetDeviceInfo.d.ts +9 -0
  4. package/dist/api/GetDeviceInfo.d.ts.map +1 -0
  5. package/dist/api/GetFeatures.d.ts +1 -1
  6. package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
  7. package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
  8. package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
  9. package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
  10. package/dist/api/alephium/AlephiumSignTransaction.d.ts +2 -5
  11. package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
  12. package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
  13. package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
  14. package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
  15. package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
  16. package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
  17. package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
  18. package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
  19. package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
  20. package/dist/api/btc/BTCGetAddress.d.ts +1 -11
  21. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
  22. package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
  23. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
  24. package/dist/api/btc/BTCSignMessage.d.ts +1 -15
  25. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  26. package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
  27. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  28. package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
  29. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
  30. package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
  31. package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
  32. package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
  33. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  34. package/dist/api/evm/latest/signTypedData.d.ts +1 -1
  35. package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
  36. package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
  37. package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
  38. package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
  39. package/dist/api/helpers/deviceInfo.d.ts +15 -0
  40. package/dist/api/helpers/deviceInfo.d.ts.map +1 -0
  41. package/dist/api/index.d.ts +2 -0
  42. package/dist/api/index.d.ts.map +1 -1
  43. package/dist/api/neo/NeoGetAddress.d.ts +2 -8
  44. package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
  45. package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
  46. package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
  47. package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
  48. package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
  49. package/dist/api/nervos/NervosSignTransaction.d.ts +2 -9
  50. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  51. package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
  52. package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
  53. package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
  54. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  55. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
  56. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +10 -0
  57. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +1 -0
  58. package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
  59. package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
  60. package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
  61. package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
  62. package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
  63. package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
  64. package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
  65. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
  66. package/dist/api/stellar/StellarSignTransaction.d.ts +2 -1
  67. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  68. package/dist/api/sui/SuiSignTransaction.d.ts +2 -2
  69. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  70. package/dist/index.d.ts +94 -4
  71. package/dist/index.js +404 -58
  72. package/dist/inject.d.ts.map +1 -1
  73. package/dist/protocols/protocol-v2/features.d.ts +20 -3
  74. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  75. package/dist/types/api/getDeviceInfo.d.ts +84 -0
  76. package/dist/types/api/getDeviceInfo.d.ts.map +1 -0
  77. package/dist/types/api/index.d.ts +5 -1
  78. package/dist/types/api/index.d.ts.map +1 -1
  79. package/dist/types/api/protocolV2.d.ts +4 -0
  80. package/dist/types/api/protocolV2.d.ts.map +1 -1
  81. package/dist/types/device.d.ts +5 -1
  82. package/dist/types/device.d.ts.map +1 -1
  83. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  84. package/dist/utils/deviceInfoUtils.d.ts +1 -1
  85. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  86. package/dist/utils/index.d.ts +1 -1
  87. package/dist/utils/index.d.ts.map +1 -1
  88. package/dist/utils/patch.d.ts +1 -1
  89. package/dist/utils/patch.d.ts.map +1 -1
  90. package/package.json +4 -4
  91. package/src/api/BaseMethod.ts +5 -10
  92. package/src/api/GetDeviceInfo.ts +153 -0
  93. package/src/api/alephium/AlephiumGetAddress.ts +6 -2
  94. package/src/api/alephium/AlephiumSignMessage.ts +6 -1
  95. package/src/api/alephium/AlephiumSignTransaction.ts +6 -2
  96. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +13 -20
  97. package/src/api/benfen/BenfenGetAddress.ts +6 -2
  98. package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
  99. package/src/api/benfen/BenfenSignMessage.ts +6 -1
  100. package/src/api/benfen/BenfenSignTransaction.ts +6 -1
  101. package/src/api/btc/helpers/versionLimit.ts +7 -1
  102. package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
  103. package/src/api/helpers/batchGetPublickeys.ts +2 -4
  104. package/src/api/helpers/deviceInfo.ts +205 -0
  105. package/src/api/index.ts +2 -0
  106. package/src/api/neo/NeoGetAddress.ts +6 -1
  107. package/src/api/neo/NeoSignTransaction.ts +6 -1
  108. package/src/api/nervos/NervosGetAddress.ts +6 -2
  109. package/src/api/nervos/NervosSignTransaction.ts +6 -2
  110. package/src/api/nexa/NexaGetAddress.ts +6 -2
  111. package/src/api/nexa/NexaSignTransaction.ts +6 -2
  112. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +17 -1
  113. package/src/api/protocol-v2/FilesystemDiskControl.ts +34 -0
  114. package/src/api/scdo/ScdoGetAddress.ts +6 -2
  115. package/src/api/scdo/ScdoSignMessage.ts +6 -1
  116. package/src/api/scdo/ScdoSignTransaction.ts +6 -2
  117. package/src/api/stellar/StellarGetAddress.ts +10 -1
  118. package/src/api/stellar/StellarSignTransaction.ts +14 -1
  119. package/src/api/sui/SuiSignTransaction.ts +12 -9
  120. package/src/core/index.ts +7 -7
  121. package/src/data/messages/messages-protocol-v2.json +10 -0
  122. package/src/inject.ts +3 -0
  123. package/src/protocols/protocol-v2/features.ts +35 -21
  124. package/src/types/api/getDeviceInfo.ts +97 -0
  125. package/src/types/api/index.ts +16 -0
  126. package/src/types/api/protocolV2.ts +5 -0
  127. package/src/types/device.ts +30 -1
  128. package/src/utils/deviceFeaturesUtils.ts +9 -2
  129. package/src/utils/deviceInfoUtils.ts +5 -7
  130. package/src/utils/index.ts +1 -1
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
4
4
  import { validateParams, validateResult } from '../helpers/paramsValidator';
5
5
 
6
6
  import type { ScdoGetAddress as HardwareScdoGetAddress } from '@onekeyfe/hd-transport';
7
- import type { ScdoAddress, ScdoGetAddressParams } from '../../types';
7
+ import type { DeviceFirmwareRange, ScdoAddress, ScdoGetAddressParams } from '../../types';
8
8
 
9
9
  export default class ScdoGetAddress extends BaseMethod<HardwareScdoGetAddress[]> {
10
10
  hasBundle = false;
@@ -38,8 +38,12 @@ export default class ScdoGetAddress extends BaseMethod<HardwareScdoGetAddress[]>
38
38
  });
39
39
  }
40
40
 
41
- getVersionRange() {
41
+ getVersionRange(): DeviceFirmwareRange {
42
42
  return {
43
+ pro2: {
44
+ min: '0.0.0',
45
+ unsupported: true,
46
+ },
43
47
  model_touch: {
44
48
  min: '4.10.0',
45
49
  },
@@ -5,6 +5,7 @@ import { validateParams } from '../helpers/paramsValidator';
5
5
  import { stripHexPrefix } from '../helpers/hexUtils';
6
6
 
7
7
  import type { ScdoSignMessage as HardwareScdoSignMessage } from '@onekeyfe/hd-transport';
8
+ import type { DeviceFirmwareRange } from '../../types';
8
9
 
9
10
  export default class ScdoSignMessage extends BaseMethod<HardwareScdoSignMessage> {
10
11
  init() {
@@ -27,8 +28,12 @@ export default class ScdoSignMessage extends BaseMethod<HardwareScdoSignMessage>
27
28
  };
28
29
  }
29
30
 
30
- getVersionRange() {
31
+ getVersionRange(): DeviceFirmwareRange {
31
32
  return {
33
+ pro2: {
34
+ min: '0.0.0',
35
+ unsupported: true,
36
+ },
32
37
  model_touch: {
33
38
  min: '4.10.0',
34
39
  },
@@ -6,7 +6,7 @@ import { BaseMethod } from '../BaseMethod';
6
6
  import { validateParams } from '../helpers/paramsValidator';
7
7
  import { formatAnyHex, stripHexStartZeroes } from '../helpers/hexUtils';
8
8
 
9
- import type { ScdoSignTransactionParams } from '../../types';
9
+ import type { DeviceFirmwareRange, ScdoSignTransactionParams } from '../../types';
10
10
  import type {
11
11
  ScdoSignTx as HardwareScdoSignTx,
12
12
  ScdoSignedTx,
@@ -50,8 +50,12 @@ export default class ScdoSignTransaction extends BaseMethod<HardwareScdoSignTx>
50
50
  };
51
51
  }
52
52
 
53
- getVersionRange() {
53
+ getVersionRange(): DeviceFirmwareRange {
54
54
  return {
55
+ pro2: {
56
+ min: '0.0.0',
57
+ unsupported: true,
58
+ },
55
59
  model_touch: {
56
60
  min: '4.10.0',
57
61
  },
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
4
4
  import { validateParams, validateResult } from '../helpers/paramsValidator';
5
5
 
6
6
  import type { StellarGetAddress as HardwareStellarGetAddress } from '@onekeyfe/hd-transport';
7
- import type { StellarAddress, StellarGetAddressParams } from '../../types';
7
+ import type { DeviceFirmwareRange, StellarAddress, StellarGetAddressParams } from '../../types';
8
8
 
9
9
  export default class StellarGetAddress extends BaseMethod<HardwareStellarGetAddress[]> {
10
10
  hasBundle = false;
@@ -38,6 +38,15 @@ export default class StellarGetAddress extends BaseMethod<HardwareStellarGetAddr
38
38
  });
39
39
  }
40
40
 
41
+ getVersionRange(): DeviceFirmwareRange {
42
+ return {
43
+ pro2: {
44
+ min: '0.0.0',
45
+ unsupported: true,
46
+ },
47
+ };
48
+ }
49
+
41
50
  async run() {
42
51
  const responses: StellarAddress[] = [];
43
52
 
@@ -10,7 +10,11 @@ import type {
10
10
  StellarSignTx as HardwareStellarSignTx,
11
11
  StellarSignedTx,
12
12
  } from '@onekeyfe/hd-transport';
13
- import type { StellarOperation, StellarSignTransactionParams } from '../../types';
13
+ import type {
14
+ DeviceFirmwareRange,
15
+ StellarOperation,
16
+ StellarSignTransactionParams,
17
+ } from '../../types';
14
18
 
15
19
  // Firmware accepts up to 1024 bytes per chunk; 1 byte = 2 hex chars
16
20
  const SOROBAN_CHUNK_BYTES = 1024;
@@ -28,6 +32,15 @@ export default class StellarSignTransaction extends BaseMethod<HardwareStellarSi
28
32
  extSent: number;
29
33
  };
30
34
 
35
+ getVersionRange(): DeviceFirmwareRange {
36
+ return {
37
+ pro2: {
38
+ min: '0.0.0',
39
+ unsupported: true,
40
+ },
41
+ };
42
+ }
43
+
31
44
  parseOperation = (op: StellarOperation) => {
32
45
  switch (op.type) {
33
46
  case 'createAccount':
@@ -1,5 +1,6 @@
1
1
  import semver from 'semver';
2
2
  import { bytesToHex } from '@noble/hashes/utils';
3
+ import { EDeviceType } from '@onekeyfe/hd-shared';
3
4
 
4
5
  import { UI_REQUEST } from '../../constants/ui-request';
5
6
  import { validatePath } from '../helpers/pathUtils';
@@ -9,12 +10,8 @@ import { formatAnyHex } from '../helpers/hexUtils';
9
10
  import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
10
11
  import { DeviceModelToTypes } from '../../types';
11
12
 
12
- import type {
13
- SuiSignTx as HardwareSuiSignTx,
14
- SuiSignedTx,
15
- TypedCall,
16
- } from '@onekeyfe/hd-transport';
17
- import type { TypedResponseMessage } from '../../device/DeviceCommands';
13
+ import type { SuiSignTx as HardwareSuiSignTx, SuiSignedTx } from '@onekeyfe/hd-transport';
14
+ import type { TypedCall, TypedResponseMessage } from '../../device/DeviceCommands';
18
15
 
19
16
  type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx;
20
17
 
@@ -52,6 +49,13 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
52
49
  }
53
50
 
54
51
  supportChunkTransfer() {
52
+ if (
53
+ this.device.originalDescriptor?.protocolType === 'V2' ||
54
+ getDeviceType(this.device.features) === EDeviceType.Pro2
55
+ ) {
56
+ return true;
57
+ }
58
+
55
59
  const deviceType = getDeviceType(this.device.features);
56
60
  const deviceFirmwareVersion = getDeviceFirmwareVersion(this.device.features).join('.');
57
61
 
@@ -84,7 +88,7 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
84
88
 
85
89
  if (!data_length) {
86
90
  // sign Done
87
- return res.message;
91
+ return res.message as SuiSignedTx;
88
92
  }
89
93
 
90
94
  const payload = data.subarray(offset, offset + data_length);
@@ -103,7 +107,7 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
103
107
  async run() {
104
108
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
105
109
  let offset = 0;
106
- let data: Buffer;
110
+ let data = Buffer.alloc(0);
107
111
 
108
112
  if (this.supportChunkTransfer()) {
109
113
  offset = this.chunkByteSize;
@@ -120,7 +124,6 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
120
124
  ...this.params,
121
125
  });
122
126
 
123
- // @ts-expect-error
124
127
  return this.processTxRequest(typedCall, res, data, offset);
125
128
  }
126
129
  }
package/src/core/index.ts CHANGED
@@ -24,8 +24,8 @@ import {
24
24
  getFirmwareType,
25
25
  getLogger,
26
26
  getMethodVersionRange,
27
+ isMethodVersionRangeUnsupported,
27
28
  setLoggerPostMessage,
28
- shouldSkipMethodSupportCheck,
29
29
  wait,
30
30
  } from '../utils';
31
31
  import {
@@ -346,10 +346,6 @@ const onCallDevice = async (
346
346
  device.features,
347
347
  type => method.getVersionRange()[type]
348
348
  );
349
- const skipMethodSupportCheck = shouldSkipMethodSupportCheck(
350
- device.features,
351
- device.originalDescriptor?.protocolType
352
- );
353
349
 
354
350
  if (device.features) {
355
351
  await DataManager.checkAndReloadData();
@@ -400,7 +396,11 @@ const onCallDevice = async (
400
396
  );
401
397
  }
402
398
 
403
- if (!skipMethodSupportCheck && versionRange) {
399
+ if (isMethodVersionRangeUnsupported(versionRange)) {
400
+ throw createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
401
+ }
402
+
403
+ if (versionRange) {
404
404
  if (
405
405
  semver.valid(versionRange.min) &&
406
406
  semver.lt(currentFirmwareVersion, versionRange.min)
@@ -432,7 +432,7 @@ const onCallDevice = async (
432
432
  createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name)
433
433
  );
434
434
  }
435
- } else if (!skipMethodSupportCheck && method.strictCheckDeviceSupport) {
435
+ } else if (method.strictCheckDeviceSupport) {
436
436
  throw createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
437
437
  }
438
438
  }
@@ -501,6 +501,7 @@
501
501
  "MessageType_FilesystemDirMake": 60809,
502
502
  "MessageType_FilesystemDirRemove": 60810,
503
503
  "MessageType_FilesystemFormat": 60811,
504
+ "MessageType_FilesystemDiskControl": 60812,
504
505
  "MessageType_DeviceFirmwareUpdate": 61000,
505
506
  "MessageType_DeviceFirmwareInstallProgress": 61001,
506
507
  "MessageType_DeviceGetFirmwareUpdateStatus": 61002,
@@ -12403,6 +12404,15 @@
12403
12404
  "FilesystemFormat": {
12404
12405
  "fields": {}
12405
12406
  },
12407
+ "FilesystemDiskControl": {
12408
+ "fields": {
12409
+ "enable": {
12410
+ "rule": "required",
12411
+ "type": "uint32",
12412
+ "id": 1
12413
+ }
12414
+ }
12415
+ },
12406
12416
  "DeviceGetOnboardingStatus": {
12407
12417
  "fields": {}
12408
12418
  },
package/src/inject.ts CHANGED
@@ -109,6 +109,7 @@ export const createCoreApi = (
109
109
  * 获取设备信息
110
110
  */
111
111
  getFeatures: (connectId, params) => call({ ...params, connectId, method: 'getFeatures' }),
112
+ getDeviceInfo: (connectId, params) => call({ ...params, connectId, method: 'getDeviceInfo' }),
112
113
  getOnekeyFeatures: (connectId, params) =>
113
114
  call({ ...params, connectId, method: 'getOnekeyFeatures' }),
114
115
 
@@ -187,6 +188,8 @@ export const createCoreApi = (
187
188
  filesystemPathInfoQuery: (connectId, params) =>
188
189
  call({ ...params, connectId, method: 'filesystemPathInfoQuery' }),
189
190
  filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
191
+ filesystemDiskControl: (connectId, params) =>
192
+ call({ ...params, connectId, method: 'filesystemDiskControl' }),
190
193
  deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
191
194
  deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
192
195
  deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
@@ -53,7 +53,7 @@ type ProtocolV2DeviceInfo = {
53
53
  };
54
54
  };
55
55
 
56
- const PROTOCOL_V2_DEVICE_INFO_REQUEST = {
56
+ export const PROTOCOL_V2_DEVICE_INFO_REQUEST = {
57
57
  targets: {
58
58
  hw: true,
59
59
  fw: true,
@@ -161,6 +161,7 @@ function createBaseFeatures(descriptor: DeviceDescriptor): Features {
161
161
  auto_lock_delay_ms: null,
162
162
  display_rotation: null,
163
163
  experimental_features: null,
164
+ protocol_version: null,
164
165
  onekey_device_type: EDeviceType.Pro2,
165
166
  onekey_serial_no: descriptorId,
166
167
  serial_no: descriptorId,
@@ -190,6 +191,7 @@ export function normalizeProtocolV2Features(
190
191
  device_id: serialNo,
191
192
  serial_no: serialNo,
192
193
  onekey_serial_no: serialNo,
194
+ protocol_version: deviceInfo.protocol_version ?? features.protocol_version,
193
195
  label: deviceInfo.status?.label ?? features.label,
194
196
  language: deviceInfo.status?.language ?? features.language,
195
197
  initialized: deviceInfo.status?.init_states ?? features.initialized,
@@ -207,6 +209,7 @@ export function normalizeProtocolV2Features(
207
209
  onekey_boot_build_id: getImageBuildId(deviceInfo.fw?.boot),
208
210
  onekey_boot_hash: getImageHash(deviceInfo.fw?.boot),
209
211
  onekey_board_version: getImageVersion(deviceInfo.fw?.board),
212
+ onekey_board_build_id: getImageBuildId(deviceInfo.fw?.board),
210
213
  onekey_board_hash: getImageHash(deviceInfo.fw?.board),
211
214
  onekey_ble_version: getImageVersion(deviceInfo.bt?.app),
212
215
  ble_ver: getImageVersion(deviceInfo.bt?.app),
@@ -215,12 +218,30 @@ export function normalizeProtocolV2Features(
215
218
  onekey_se01_version: getImageVersion(deviceInfo.se1?.app),
216
219
  onekey_se01_hash: getImageHash(deviceInfo.se1?.app),
217
220
  onekey_se01_build_id: getImageBuildId(deviceInfo.se1?.app),
221
+ onekey_se01_boot_version: getImageVersion(deviceInfo.se1?.boot),
222
+ onekey_se01_boot_hash: getImageHash(deviceInfo.se1?.boot),
223
+ onekey_se01_boot_build_id: getImageBuildId(deviceInfo.se1?.boot),
218
224
  onekey_se01_state: getSeState(deviceInfo.se1),
219
225
  onekey_se02_version: getImageVersion(deviceInfo.se2?.app),
226
+ onekey_se02_hash: getImageHash(deviceInfo.se2?.app),
227
+ onekey_se02_build_id: getImageBuildId(deviceInfo.se2?.app),
228
+ onekey_se02_boot_version: getImageVersion(deviceInfo.se2?.boot),
229
+ onekey_se02_boot_hash: getImageHash(deviceInfo.se2?.boot),
230
+ onekey_se02_boot_build_id: getImageBuildId(deviceInfo.se2?.boot),
220
231
  onekey_se02_state: getSeState(deviceInfo.se2),
221
232
  onekey_se03_version: getImageVersion(deviceInfo.se3?.app),
233
+ onekey_se03_hash: getImageHash(deviceInfo.se3?.app),
234
+ onekey_se03_build_id: getImageBuildId(deviceInfo.se3?.app),
235
+ onekey_se03_boot_version: getImageVersion(deviceInfo.se3?.boot),
236
+ onekey_se03_boot_hash: getImageHash(deviceInfo.se3?.boot),
237
+ onekey_se03_boot_build_id: getImageBuildId(deviceInfo.se3?.boot),
222
238
  onekey_se03_state: getSeState(deviceInfo.se3),
223
239
  onekey_se04_version: getImageVersion(deviceInfo.se4?.app),
240
+ onekey_se04_hash: getImageHash(deviceInfo.se4?.app),
241
+ onekey_se04_build_id: getImageBuildId(deviceInfo.se4?.app),
242
+ onekey_se04_boot_version: getImageVersion(deviceInfo.se4?.boot),
243
+ onekey_se04_boot_hash: getImageHash(deviceInfo.se4?.boot),
244
+ onekey_se04_boot_build_id: getImageBuildId(deviceInfo.se4?.boot),
224
245
  onekey_se04_state: getSeState(deviceInfo.se4),
225
246
  };
226
247
  }
@@ -228,12 +249,10 @@ export function normalizeProtocolV2Features(
228
249
  export async function getProtocolV2Features({
229
250
  commands,
230
251
  descriptor,
231
- onDeviceInfoError,
232
252
  timeoutMs,
233
253
  }: {
234
254
  commands: DeviceCommands;
235
255
  descriptor: DeviceDescriptor;
236
- onDeviceInfoError?: (error: unknown) => void;
237
256
  timeoutMs?: number;
238
257
  }) {
239
258
  const callOptions = timeoutMs ? { timeoutMs } : undefined;
@@ -243,22 +262,17 @@ export async function getProtocolV2Features({
243
262
  await commands.typedCall('Ping', 'Success', { message: 'init' });
244
263
  }
245
264
 
246
- try {
247
- const { message } = callOptions
248
- ? await commands.typedCall(
249
- 'DeviceGetDeviceInfo',
250
- 'DeviceInfo',
251
- PROTOCOL_V2_DEVICE_INFO_REQUEST,
252
- callOptions
253
- )
254
- : await commands.typedCall(
255
- 'DeviceGetDeviceInfo',
256
- 'DeviceInfo',
257
- PROTOCOL_V2_DEVICE_INFO_REQUEST
258
- );
259
- return normalizeProtocolV2Features(descriptor, message as unknown as ProtocolV2DeviceInfo);
260
- } catch (error) {
261
- onDeviceInfoError?.(error);
262
- return normalizeProtocolV2Features(descriptor);
263
- }
265
+ const { message } = callOptions
266
+ ? await commands.typedCall(
267
+ 'DeviceGetDeviceInfo',
268
+ 'DeviceInfo',
269
+ PROTOCOL_V2_DEVICE_INFO_REQUEST,
270
+ callOptions
271
+ )
272
+ : await commands.typedCall(
273
+ 'DeviceGetDeviceInfo',
274
+ 'DeviceInfo',
275
+ PROTOCOL_V2_DEVICE_INFO_REQUEST
276
+ );
277
+ return normalizeProtocolV2Features(descriptor, message as unknown as ProtocolV2DeviceInfo);
264
278
  }
@@ -0,0 +1,97 @@
1
+ import type { CommonParams, Response } from '../params';
2
+ import type { Features, IDeviceType, OnekeyFeatures } from '../device';
3
+ import type { EFirmwareType } from '@onekeyfe/hd-shared';
4
+ import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
5
+
6
+ export type DeviceInfoProtocol = 'V1' | 'V2' | 'unknown';
7
+
8
+ export type DeviceInfoSource = 'features' | 'onekeyFeatures' | 'deviceGetDeviceInfo';
9
+
10
+ export type DeviceInfoScope = 'basic' | 'versions' | 'verify' | 'full';
11
+
12
+ export type GetDeviceInfoParams = {
13
+ scope?: DeviceInfoScope;
14
+ refresh?: boolean;
15
+ includeRaw?: boolean;
16
+ };
17
+
18
+ export type DeviceInfoMode = 'normal' | 'bootloader' | 'notInitialized' | 'unknown';
19
+
20
+ export type DeviceInfoStatus = {
21
+ mode: DeviceInfoMode;
22
+ initialized: boolean | null;
23
+ bootloaderMode: boolean | null;
24
+ unlocked: boolean | null;
25
+ passphraseProtection: boolean | null;
26
+ backupRequired: boolean | null;
27
+ language: string | null;
28
+ bleEnabled?: boolean | null;
29
+ };
30
+
31
+ export type UnifiedDeviceInfoVersions = {
32
+ firmware: string | null;
33
+ bootloader: string | null;
34
+ board: string | null;
35
+ ble: string | null;
36
+ se01?: string | null;
37
+ se02?: string | null;
38
+ se03?: string | null;
39
+ se04?: string | null;
40
+ se01Boot?: string | null;
41
+ se02Boot?: string | null;
42
+ se03Boot?: string | null;
43
+ se04Boot?: string | null;
44
+ };
45
+
46
+ export type UnifiedDeviceInfoVerify = {
47
+ firmwareBuildId?: string;
48
+ firmwareHash?: string;
49
+ bootloaderBuildId?: string;
50
+ bootloaderHash?: string;
51
+ boardBuildId?: string;
52
+ boardHash?: string;
53
+ bleBuildId?: string;
54
+ bleHash?: string;
55
+ se01BuildId?: string;
56
+ se01Hash?: string;
57
+ se02BuildId?: string;
58
+ se02Hash?: string;
59
+ se03BuildId?: string;
60
+ se03Hash?: string;
61
+ se04BuildId?: string;
62
+ se04Hash?: string;
63
+ se01BootBuildId?: string;
64
+ se01BootHash?: string;
65
+ se02BootBuildId?: string;
66
+ se02BootHash?: string;
67
+ se03BootBuildId?: string;
68
+ se03BootHash?: string;
69
+ se04BootBuildId?: string;
70
+ se04BootHash?: string;
71
+ };
72
+
73
+ export type UnifiedDeviceInfoRaw = {
74
+ features?: Features;
75
+ onekeyFeatures?: OnekeyFeatures;
76
+ protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
77
+ };
78
+
79
+ export type UnifiedDeviceInfo = {
80
+ protocol: DeviceInfoProtocol;
81
+ sources: DeviceInfoSource[];
82
+ deviceType: IDeviceType;
83
+ firmwareType: EFirmwareType;
84
+ deviceId: string;
85
+ serialNo: string;
86
+ label: string | null;
87
+ bleName: string | null;
88
+ status: DeviceInfoStatus;
89
+ versions: UnifiedDeviceInfoVersions;
90
+ verify?: UnifiedDeviceInfoVerify;
91
+ raw?: UnifiedDeviceInfoRaw;
92
+ };
93
+
94
+ export declare function getDeviceInfo(
95
+ connectId?: string,
96
+ params?: CommonParams & GetDeviceInfoParams
97
+ ): Response<UnifiedDeviceInfo>;
@@ -15,6 +15,7 @@ import type {
15
15
  filesystemDirList,
16
16
  filesystemDirMake,
17
17
  filesystemDirRemove,
18
+ filesystemDiskControl,
18
19
  filesystemFileDelete,
19
20
  filesystemFileRead,
20
21
  filesystemFileWrite,
@@ -37,6 +38,7 @@ import type { checkAllFirmwareRelease } from './checkAllFirmwareRelease';
37
38
  import type { checkFirmwareTypeAvailable } from './checkFirmwareTypeAvailable';
38
39
  import type { searchDevices } from './searchDevices';
39
40
  import type { getFeatures } from './getFeatures';
41
+ import type { getDeviceInfo } from './getDeviceInfo';
40
42
  import type { getOnekeyFeatures } from './getOnekeyFeatures';
41
43
  import type { getPassphraseState } from './getPassphraseState';
42
44
  import type { checkFirmwareRelease } from './checkFirmwareRelease';
@@ -162,6 +164,18 @@ import type { neoSignTransaction } from './neoSignTransaction';
162
164
  import type { ConnectSettings } from '../settings';
163
165
 
164
166
  export * from './export';
167
+ export type {
168
+ DeviceInfoMode,
169
+ DeviceInfoProtocol,
170
+ DeviceInfoScope,
171
+ DeviceInfoSource,
172
+ DeviceInfoStatus,
173
+ GetDeviceInfoParams,
174
+ UnifiedDeviceInfo,
175
+ UnifiedDeviceInfoRaw,
176
+ UnifiedDeviceInfoVerify,
177
+ UnifiedDeviceInfoVersions,
178
+ } from './getDeviceInfo';
165
179
  export type { GetPassphraseStateParams, GetPassphraseStatePayload } from './getPassphraseState';
166
180
 
167
181
  export type CoreApi = {
@@ -201,6 +215,7 @@ export type CoreApi = {
201
215
  searchDevices: typeof searchDevices;
202
216
  promptWebDeviceAccess: typeof promptWebDeviceAccess;
203
217
  getFeatures: typeof getFeatures;
218
+ getDeviceInfo: typeof getDeviceInfo;
204
219
  getOnekeyFeatures: typeof getOnekeyFeatures;
205
220
  getPassphraseState: typeof getPassphraseState;
206
221
  deviceBackup: typeof deviceBackup;
@@ -259,6 +274,7 @@ export type CoreApi = {
259
274
  filesystemDirRemove: typeof filesystemDirRemove;
260
275
  filesystemPathInfoQuery: typeof filesystemPathInfoQuery;
261
276
  filesystemFormat: typeof filesystemFormat;
277
+ filesystemDiskControl: typeof filesystemDiskControl;
262
278
 
263
279
  /**
264
280
  * All network function
@@ -219,3 +219,8 @@ export declare function filesystemPathInfoQuery(
219
219
  ): ReturnType<typeof pathInfo>;
220
220
 
221
221
  export declare function filesystemFormat(connectId: string): Response<Success>;
222
+
223
+ export declare function filesystemDiskControl(
224
+ connectId: string,
225
+ params: CommonParams & { enable: number | string; timeoutMs?: number | string }
226
+ ): Response<Success>;
@@ -85,7 +85,35 @@ export type SearchDevice = {
85
85
 
86
86
  export type Device = KnownDevice;
87
87
 
88
- export type Features = PROTO.Features;
88
+ type OnekeyFeatureExtensions = Partial<
89
+ Pick<
90
+ PROTO.OnekeyFeatures,
91
+ | 'onekey_board_build_id'
92
+ | 'onekey_se02_hash'
93
+ | 'onekey_se03_hash'
94
+ | 'onekey_se04_hash'
95
+ | 'onekey_se02_build_id'
96
+ | 'onekey_se03_build_id'
97
+ | 'onekey_se04_build_id'
98
+ | 'onekey_se01_boot_version'
99
+ | 'onekey_se02_boot_version'
100
+ | 'onekey_se03_boot_version'
101
+ | 'onekey_se04_boot_version'
102
+ | 'onekey_se01_boot_hash'
103
+ | 'onekey_se02_boot_hash'
104
+ | 'onekey_se03_boot_hash'
105
+ | 'onekey_se04_boot_hash'
106
+ | 'onekey_se01_boot_build_id'
107
+ | 'onekey_se02_boot_build_id'
108
+ | 'onekey_se03_boot_build_id'
109
+ | 'onekey_se04_boot_build_id'
110
+ >
111
+ >;
112
+
113
+ export type Features = PROTO.Features &
114
+ OnekeyFeatureExtensions & {
115
+ protocol_version?: number | null;
116
+ };
89
117
 
90
118
  export type OnekeyFeatures = PROTO.OnekeyFeatures;
91
119
 
@@ -138,6 +166,7 @@ export type ITransportStatus = 'valid' | 'outdated';
138
166
  export type IVersionRange = {
139
167
  min: string;
140
168
  max?: string;
169
+ unsupported?: boolean;
141
170
  };
142
171
 
143
172
  export type DeviceFirmwareRange = {
@@ -231,7 +231,10 @@ export const supportBatchPublicKey = (
231
231
 
232
232
  const deviceType = getDeviceType(features);
233
233
  // btc batch get public key
234
- if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
234
+ if (
235
+ !!options?.includeNode &&
236
+ (deviceType === EDeviceType.Pro || deviceType === EDeviceType.Pro2)
237
+ ) {
235
238
  return semver.gte(currentVersion, '4.14.0');
236
239
  }
237
240
  if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
@@ -248,7 +251,11 @@ export const supportBatchPublicKey = (
248
251
  }
249
252
 
250
253
  // support batch get public key
251
- if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
254
+ if (
255
+ deviceType === EDeviceType.Touch ||
256
+ deviceType === EDeviceType.Pro ||
257
+ deviceType === EDeviceType.Pro2
258
+ ) {
252
259
  return semver.gte(currentVersion, '3.1.0');
253
260
  }
254
261
 
@@ -132,8 +132,8 @@ export const getMethodVersionRange = (
132
132
  getVersionRange: (deviceModel: IDeviceType | IDeviceModel) => IVersionRange | undefined
133
133
  ): IVersionRange | undefined => {
134
134
  const deviceType = getDeviceType(features);
135
- let versionRange: IVersionRange | undefined = getVersionRange(deviceType);
136
135
 
136
+ const versionRange = getVersionRange(deviceType);
137
137
  if (versionRange) {
138
138
  return versionRange;
139
139
  }
@@ -146,20 +146,18 @@ export const getMethodVersionRange = (
146
146
  ];
147
147
  for (const model of modelFallbacks) {
148
148
  if (DeviceModelToTypes[model].includes(deviceType)) {
149
- versionRange = getVersionRange(model);
149
+ const versionRange = getVersionRange(model);
150
150
  if (versionRange) {
151
151
  return versionRange;
152
152
  }
153
153
  }
154
154
  }
155
155
 
156
- return versionRange;
156
+ return undefined;
157
157
  };
158
158
 
159
- export const shouldSkipMethodSupportCheck = (
160
- features: Features | undefined,
161
- protocolType?: string
162
- ): boolean => protocolType === 'V2' || getDeviceType(features) === EDeviceType.Pro2;
159
+ export const isMethodVersionRangeUnsupported = (versionRange?: IVersionRange): boolean =>
160
+ versionRange?.unsupported === true;
163
161
 
164
162
  export const getFirmwareType = (features: Features | undefined) => {
165
163
  if (!features) {
@@ -11,7 +11,7 @@ export {
11
11
  getDeviceUUID,
12
12
  getDeviceLabel,
13
13
  getMethodVersionRange,
14
- shouldSkipMethodSupportCheck,
14
+ isMethodVersionRangeUnsupported,
15
15
  getFirmwareType,
16
16
  } from './deviceInfoUtils';
17
17
  export {