@onekeyfe/hd-core 1.2.0-alpha.12 → 1.2.0-alpha.14

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 (57) hide show
  1. package/__tests__/DeviceCommands.test.ts +47 -0
  2. package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
  3. package/__tests__/protocol-v2.test.ts +146 -58
  4. package/__tests__/protocolV2FileWrite.test.ts +12 -0
  5. package/dist/api/FileWrite.d.ts +1 -0
  6. package/dist/api/FileWrite.d.ts.map +1 -1
  7. package/dist/api/FirmwareUpdateV4.d.ts +2 -0
  8. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  9. package/dist/api/UploadPortfolio.d.ts.map +1 -1
  10. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  11. package/dist/api/index.d.ts +0 -1
  12. package/dist/api/index.d.ts.map +1 -1
  13. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  14. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  15. package/dist/device/Device.d.ts.map +1 -1
  16. package/dist/device/DeviceCommands.d.ts.map +1 -1
  17. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  18. package/dist/index.d.ts +4 -8
  19. package/dist/index.js +524 -168
  20. package/dist/inject.d.ts.map +1 -1
  21. package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
  22. package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
  23. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
  24. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  25. package/dist/types/api/index.d.ts +1 -2
  26. package/dist/types/api/index.d.ts.map +1 -1
  27. package/dist/types/api/protocolV2.d.ts +0 -4
  28. package/dist/types/api/protocolV2.d.ts.map +1 -1
  29. package/dist/types/device.d.ts +2 -1
  30. package/dist/types/device.d.ts.map +1 -1
  31. package/dist/utils/patch.d.ts +1 -1
  32. package/dist/utils/patch.d.ts.map +1 -1
  33. package/package.json +4 -4
  34. package/src/api/FileWrite.ts +3 -1
  35. package/src/api/FirmwareUpdateV4.ts +46 -6
  36. package/src/api/UploadPortfolio.ts +3 -1
  37. package/src/api/cardano/CardanoSignMessage.ts +1 -1
  38. package/src/api/cardano/CardanoSignTransaction.ts +1 -1
  39. package/src/api/helpers/protocolV2FileWrite.ts +10 -6
  40. package/src/api/index.ts +0 -1
  41. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +9 -3
  42. package/src/api/protocol-v2/helpers.ts +0 -3
  43. package/src/data/messages/messages-protocol-v2.json +422 -16
  44. package/src/data/messages/messages.json +0 -8
  45. package/src/device/Device.ts +7 -17
  46. package/src/device/DeviceCommands.ts +3 -1
  47. package/src/deviceProfile/buildDeviceFeatures.ts +8 -0
  48. package/src/inject.ts +0 -2
  49. package/src/protocols/protocol-v2/lockedError.ts +10 -0
  50. package/src/protocols/protocol-v2/unlockRetry.ts +1 -11
  51. package/src/protocols/protocol-v2/walletSession.ts +25 -10
  52. package/src/types/api/index.ts +0 -2
  53. package/src/types/api/protocolV2.ts +0 -6
  54. package/src/types/device.ts +5 -1
  55. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
  56. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
  57. package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
@@ -21,7 +21,6 @@ import type {
21
21
  filesystemDirList,
22
22
  filesystemDirMake,
23
23
  filesystemDirRemove,
24
- filesystemDiskControl,
25
24
  filesystemFileDelete,
26
25
  filesystemFileRead,
27
26
  filesystemFileWrite,
@@ -294,7 +293,6 @@ export type CoreApi = {
294
293
  filesystemDirRemove: typeof filesystemDirRemove;
295
294
  filesystemPathInfoQuery: typeof filesystemPathInfoQuery;
296
295
  filesystemFormat: typeof filesystemFormat;
297
- filesystemDiskControl: typeof filesystemDiskControl;
298
296
 
299
297
  /**
300
298
  * All network function
@@ -237,9 +237,3 @@ export declare const filesystemDirRemove: typeof dirRemove;
237
237
  export declare const filesystemPathInfoQuery: typeof pathInfo;
238
238
 
239
239
  export declare function filesystemFormat(connectId: string): Response<Success>;
240
-
241
- export declare function filesystemDiskControl(
242
- connectId: string,
243
- // enable 收紧为 boolean | 0 | 1(兼容历史的 '0' / '1' 字符串输入,内部归一化为 0/1)
244
- params: CommonParams & { enable: boolean | 0 | 1; timeoutMs?: number | string }
245
- ): Response<Success>;
@@ -129,7 +129,7 @@ export type DeviceFeaturesRaw = {
129
129
  protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
130
130
  };
131
131
 
132
- export type Features = {
132
+ export type NormalizedFeatures = {
133
133
  protocol: DeviceFeaturesProtocol;
134
134
  protocolVersion?: number | null;
135
135
  deviceType: IDeviceType;
@@ -183,6 +183,10 @@ export type Features = {
183
183
  raw?: DeviceFeaturesRaw;
184
184
  };
185
185
 
186
+ export type Features = NormalizedFeatures &
187
+ Partial<Omit<PROTO.Features, keyof NormalizedFeatures>> &
188
+ Partial<Omit<PROTO.OnekeyFeatures, keyof NormalizedFeatures | keyof PROTO.Features>>;
189
+
186
190
  export type OnekeyFeatures = PROTO.OnekeyFeatures;
187
191
 
188
192
  export type IDeviceType =
@@ -1,13 +0,0 @@
1
- import { BaseMethod } from '../BaseMethod';
2
- export type FilesystemDiskControlParams = {
3
- enable?: boolean | 0 | 1;
4
- timeoutMs?: number | string;
5
- };
6
- export default class FilesystemDiskControl extends BaseMethod<{
7
- enable: 0 | 1;
8
- timeoutMs?: number;
9
- }> {
10
- init(): void;
11
- run(): Promise<any>;
12
- }
13
- //# sourceMappingURL=FilesystemDiskControl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilesystemDiskControl.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/FilesystemDiskControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,MAAM,MAAM,2BAA2B,GAAG;IAExC,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B,CAAC;AAUF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC;IAC5D,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;IACA,IAAI;IAWE,GAAG;CAcV"}
@@ -1,50 +0,0 @@
1
- import { BaseMethod } from '../BaseMethod';
2
- import {
3
- invalidParameter,
4
- validateOptionalNonNegativeInteger,
5
- } from '../helpers/filesystemValidation';
6
-
7
- export type FilesystemDiskControlParams = {
8
- // 收紧为 boolean | 0 | 1;'0' / '1' 字符串仅作为历史输入向后兼容,内部归一化为 0/1
9
- enable?: boolean | 0 | 1;
10
- timeoutMs?: number | string;
11
- };
12
-
13
- function normalizeDiskControlEnable(value: unknown): 0 | 1 {
14
- if (value === undefined || value === null) return 0;
15
- if (typeof value === 'boolean') return value ? 1 : 0;
16
- if (value === 0 || value === '0') return 0;
17
- if (value === 1 || value === '1') return 1;
18
- throw invalidParameter('Parameter [enable] must be a boolean or 0 | 1.');
19
- }
20
-
21
- export default class FilesystemDiskControl extends BaseMethod<{
22
- enable: 0 | 1;
23
- timeoutMs?: number;
24
- }> {
25
- init() {
26
- // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
27
- this.requireProtocolV2 = true;
28
- this.skipForceUpdateCheck = true;
29
- this.useDevicePassphraseState = false;
30
- this.params = {
31
- enable: normalizeDiskControlEnable(this.payload.enable),
32
- timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
33
- };
34
- }
35
-
36
- async run() {
37
- const typedCall = this.device.commands.typedCall as any;
38
- const res = await typedCall(
39
- 'FilesystemDiskControl',
40
- 'Success',
41
- {
42
- enable: this.params.enable,
43
- },
44
- {
45
- timeoutMs: this.params.timeoutMs,
46
- }
47
- );
48
- return Promise.resolve(res.message);
49
- }
50
- }