@onekeyfe/hd-core 1.2.0-alpha.15 → 1.2.0-alpha.17

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 (118) hide show
  1. package/__tests__/DeviceCommands.test.ts +77 -0
  2. package/__tests__/DeviceEventRegistration.test.ts +8 -3
  3. package/__tests__/deviceFeaturesUtils.test.ts +27 -0
  4. package/__tests__/evmLedgerLegacySafety.test.ts +3 -0
  5. package/__tests__/homescreen.test.ts +24 -0
  6. package/__tests__/protocol-v2.test.ts +1006 -204
  7. package/__tests__/protocolV2FileWrite.test.ts +28 -3
  8. package/__tests__/protocolV2UiInteraction.test.ts +266 -0
  9. package/dist/api/BaseMethod.d.ts +4 -0
  10. package/dist/api/BaseMethod.d.ts.map +1 -1
  11. package/dist/api/FirmwareUpdateV4.d.ts +3 -3
  12. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  13. package/dist/api/GetDeviceInfo.d.ts.map +1 -1
  14. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  15. package/dist/api/UploadPortfolio.d.ts.map +1 -1
  16. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  17. package/dist/api/device/DeviceCancel.d.ts.map +1 -1
  18. package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
  19. package/dist/api/device/DeviceLock.d.ts.map +1 -1
  20. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  21. package/dist/api/device/DeviceWipe.d.ts.map +1 -1
  22. package/dist/api/helpers/protocolV2FileWrite.d.ts +1 -0
  23. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  24. package/dist/api/index.d.ts +1 -1
  25. package/dist/api/index.d.ts.map +1 -1
  26. package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
  27. package/dist/api/protocol-v2/DeviceSessionOpen.d.ts +28 -0
  28. package/dist/api/protocol-v2/DeviceSessionOpen.d.ts.map +1 -0
  29. package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +1 -1
  30. package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +1 -1
  31. package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -1
  32. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  33. package/dist/core/deviceEventRegistration.d.ts +2 -2
  34. package/dist/core/deviceEventRegistration.d.ts.map +1 -1
  35. package/dist/core/index.d.ts.map +1 -1
  36. package/dist/device/Device.d.ts +3 -3
  37. package/dist/device/Device.d.ts.map +1 -1
  38. package/dist/device/DeviceCommands.d.ts +3 -1
  39. package/dist/device/DeviceCommands.d.ts.map +1 -1
  40. package/dist/device/DevicePool.d.ts +2 -2
  41. package/dist/device/DevicePool.d.ts.map +1 -1
  42. package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -2
  43. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  44. package/dist/deviceProfile/buildDeviceProfile.d.ts +3 -2
  45. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  46. package/dist/events/device.d.ts +4 -0
  47. package/dist/events/device.d.ts.map +1 -1
  48. package/dist/events/ui-request.d.ts +18 -2
  49. package/dist/events/ui-request.d.ts.map +1 -1
  50. package/dist/index.d.ts +56 -11
  51. package/dist/index.js +1014 -559
  52. package/dist/protocols/protocol-v2/features.d.ts +6 -18
  53. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  54. package/dist/protocols/protocol-v2/index.d.ts +1 -1
  55. package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
  56. package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
  57. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
  58. package/dist/protocols/protocol-v2/unlockRetry.d.ts +5 -3
  59. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
  60. package/dist/protocols/protocol-v2/walletSession.d.ts +2 -1
  61. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  62. package/dist/types/api/getDeviceInfo.d.ts +2 -1
  63. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  64. package/dist/types/api/index.d.ts +2 -2
  65. package/dist/types/api/index.d.ts.map +1 -1
  66. package/dist/types/api/protocolV2.d.ts +4 -2
  67. package/dist/types/api/protocolV2.d.ts.map +1 -1
  68. package/dist/types/device.d.ts +2 -1
  69. package/dist/types/device.d.ts.map +1 -1
  70. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  71. package/dist/utils/homescreen.d.ts.map +1 -1
  72. package/dist/utils/patch.d.ts +1 -1
  73. package/dist/utils/patch.d.ts.map +1 -1
  74. package/package.json +4 -4
  75. package/src/api/BaseMethod.ts +10 -2
  76. package/src/api/FirmwareUpdateV4.ts +27 -73
  77. package/src/api/GetDeviceInfo.ts +9 -2
  78. package/src/api/GetPassphraseState.ts +5 -2
  79. package/src/api/UploadPortfolio.ts +2 -0
  80. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +8 -13
  81. package/src/api/device/DeviceCancel.ts +1 -0
  82. package/src/api/device/DeviceChangePin.ts +23 -0
  83. package/src/api/device/DeviceLock.ts +1 -0
  84. package/src/api/device/DeviceUnlock.ts +9 -0
  85. package/src/api/device/DeviceWipe.ts +18 -0
  86. package/src/api/helpers/protocolV2FileWrite.ts +35 -11
  87. package/src/api/index.ts +1 -1
  88. package/src/api/protocol-v2/DeviceInfoGet.ts +0 -1
  89. package/src/api/protocol-v2/DeviceSessionOpen.ts +100 -0
  90. package/src/api/protocol-v2/DeviceSettingsPageShow.ts +9 -1
  91. package/src/api/protocol-v2/DeviceSettingsSet.ts +11 -1
  92. package/src/api/protocol-v2/DeviceStatusGet.ts +1 -0
  93. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +2 -1
  94. package/src/core/deviceEventRegistration.ts +3 -8
  95. package/src/core/index.ts +36 -3
  96. package/src/data/messages/messages-protocol-v2.json +122 -23
  97. package/src/device/Device.ts +33 -41
  98. package/src/device/DeviceCommands.ts +22 -4
  99. package/src/device/DevicePool.ts +14 -6
  100. package/src/deviceProfile/buildDeviceFeatures.ts +21 -9
  101. package/src/deviceProfile/buildDeviceProfile.ts +27 -11
  102. package/src/events/device.ts +4 -0
  103. package/src/events/ui-request.ts +24 -2
  104. package/src/inject.ts +2 -2
  105. package/src/protocols/protocol-v2/features.ts +27 -20
  106. package/src/protocols/protocol-v2/index.ts +0 -1
  107. package/src/protocols/protocol-v2/uiInteraction.ts +209 -0
  108. package/src/protocols/protocol-v2/unlockRetry.ts +43 -3
  109. package/src/protocols/protocol-v2/walletSession.ts +122 -31
  110. package/src/types/api/getDeviceInfo.ts +6 -1
  111. package/src/types/api/index.ts +2 -2
  112. package/src/types/api/protocolV2.ts +5 -3
  113. package/src/types/device.ts +6 -1
  114. package/src/utils/deviceFeaturesUtils.ts +13 -0
  115. package/src/utils/homescreen.ts +10 -0
  116. package/dist/api/protocol-v2/DeviceSessionGet.d.ts +0 -6
  117. package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +0 -1
  118. package/src/api/protocol-v2/DeviceSessionGet.ts +0 -15
@@ -2,7 +2,11 @@ import { EDeviceType, type EFirmwareType } from '@onekeyfe/hd-shared';
2
2
 
3
3
  import type { IVersionArray } from './settings';
4
4
  import type { PROTO } from '../constants';
5
- import type { OneKeyDeviceCommType, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
5
+ import type {
6
+ DeviceStatus as ProtocolV2DeviceStatus,
7
+ OneKeyDeviceCommType,
8
+ ProtocolV2DeviceInfo,
9
+ } from '@onekeyfe/hd-transport';
6
10
 
7
11
  export type DeviceStatus = 'available' | 'occupied' | 'used';
8
12
 
@@ -127,6 +131,7 @@ export type DeviceFeaturesRaw = {
127
131
  protocolV1Features?: PROTO.Features;
128
132
  protocolV1OneKeyFeatures?: OnekeyFeatures;
129
133
  protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
134
+ protocolV2DeviceStatus?: ProtocolV2DeviceStatus;
130
135
  };
131
136
 
132
137
  export type NormalizedFeatures = {
@@ -30,6 +30,17 @@ export const getSupportProtocolV1MessageSchema = (
30
30
  const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
31
31
  const deviceType = getDeviceType(features);
32
32
 
33
+ if (
34
+ features.bootloaderMode === true &&
35
+ features.firmwarePresent === false &&
36
+ DeviceModelToTypes.model_mini.includes(deviceType)
37
+ ) {
38
+ return {
39
+ messages: DataManager.messages.v1CurrentSchema,
40
+ protocolV1MessageSchema: 'v1CurrentSchema',
41
+ };
42
+ }
43
+
33
44
  const deviceVersionConfigs =
34
45
  PROTOBUF_MESSAGE_CONFIG[deviceType] ||
35
46
  (DeviceTypeToModels[deviceType] &&
@@ -104,6 +115,7 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
104
115
  return getProtocolV2WalletSession(device, {
105
116
  initSession: options?.initSession,
106
117
  expectedPassphraseState: options?.expectPassphraseState,
118
+ onlyMainPin: options?.onlyMainPin,
107
119
  });
108
120
  }
109
121
 
@@ -183,6 +195,7 @@ export const getPassphraseState = async (
183
195
  return getProtocolV2WalletSession(device, {
184
196
  initSession: options?.initSession,
185
197
  expectedPassphraseState: options?.expectPassphraseState,
198
+ onlyMainPin: options?.onlyMainPin,
186
199
  });
187
200
  }
188
201
 
@@ -3,6 +3,7 @@ import { EDeviceType } from '@onekeyfe/hd-shared';
3
3
 
4
4
  import { getDeviceType } from './deviceInfoUtils';
5
5
  import { getDeviceFirmwareVersion } from './deviceVersionUtils';
6
+ import { PRO2_WALLPAPER_HEIGHT, PRO2_WALLPAPER_WIDTH } from './pro2Wallpaper';
6
7
 
7
8
  import type { Features, IDeviceType } from '../types';
8
9
 
@@ -310,6 +311,15 @@ export const getHomeScreenSize = ({
310
311
  homeScreenType: 'WallPaper' | 'Nft';
311
312
  thumbnail?: boolean;
312
313
  }) => {
314
+ if (deviceType === EDeviceType.Pro2) {
315
+ return thumbnail
316
+ ? undefined
317
+ : {
318
+ width: PRO2_WALLPAPER_WIDTH,
319
+ height: PRO2_WALLPAPER_HEIGHT,
320
+ };
321
+ }
322
+
313
323
  const sizes: Partial<
314
324
  Record<
315
325
  IDeviceType,
@@ -1,6 +0,0 @@
1
- import { BaseMethod } from '../BaseMethod';
2
- export default class DeviceSessionGet extends BaseMethod {
3
- init(): void;
4
- run(): Promise<import("packages/hd-transport/dist").DeviceSession>;
5
- }
6
- //# sourceMappingURL=DeviceSessionGet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeviceSessionGet.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceSessionGet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU;IACtD,IAAI;IAOE,GAAG;CAIV"}
@@ -1,15 +0,0 @@
1
- import { BaseMethod } from '../BaseMethod';
2
-
3
- export default class DeviceSessionGet extends BaseMethod {
4
- init() {
5
- this.requireProtocolV2 = true;
6
- this.useDevicePassphraseState = false;
7
- this.skipForceUpdateCheck = true;
8
- this.params = undefined;
9
- }
10
-
11
- async run() {
12
- const { message } = await this.device.commands.typedCall('DeviceSessionGet', 'DeviceSession', {});
13
- return message;
14
- }
15
- }