@onekeyfe/hd-core 0.1.55 → 0.1.56

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 (55) hide show
  1. package/dist/api/CheckBLEFirmwareRelease.d.ts +1 -1
  2. package/dist/api/CheckFirmwareRelease.d.ts +1 -1
  3. package/dist/api/FirmwareUpdateV2.d.ts +0 -3
  4. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  5. package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
  6. package/dist/api/device/DeviceVerify.d.ts.map +1 -1
  7. package/dist/api/firmware/getBinary.d.ts +11 -3
  8. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  9. package/dist/api/firmware/releaseHelper.d.ts +2 -2
  10. package/dist/api/firmware/uploadFirmware.d.ts +1 -5
  11. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  12. package/dist/api/index.d.ts +0 -1
  13. package/dist/api/index.d.ts.map +1 -1
  14. package/dist/data-manager/DataManager.d.ts +2 -3
  15. package/dist/data-manager/DataManager.d.ts.map +1 -1
  16. package/dist/index.d.ts +12 -24
  17. package/dist/index.js +66 -279
  18. package/dist/inject.d.ts.map +1 -1
  19. package/dist/types/api/confluxSignTransaction.d.ts +1 -1
  20. package/dist/types/api/confluxSignTransaction.d.ts.map +1 -1
  21. package/dist/types/api/export.d.ts +0 -2
  22. package/dist/types/api/export.d.ts.map +1 -1
  23. package/dist/types/api/firmwareUpdate.d.ts +5 -5
  24. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  25. package/dist/types/api/index.d.ts +0 -2
  26. package/dist/types/api/index.d.ts.map +1 -1
  27. package/dist/types/settings.d.ts +0 -1
  28. package/dist/types/settings.d.ts.map +1 -1
  29. package/dist/utils/release.d.ts +1 -4
  30. package/dist/utils/release.d.ts.map +1 -1
  31. package/package.json +8 -8
  32. package/src/api/FirmwareUpdateV2.ts +10 -62
  33. package/src/api/aptos/AptosGetAddress.ts +3 -4
  34. package/src/api/conflux/ConfluxSignMessage.ts +1 -1
  35. package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -1
  36. package/src/api/conflux/ConfluxSignTransaction.ts +2 -2
  37. package/src/api/device/DeviceVerify.ts +2 -3
  38. package/src/api/firmware/getBinary.ts +3 -16
  39. package/src/api/firmware/releaseHelper.ts +2 -2
  40. package/src/api/firmware/uploadFirmware.ts +1 -100
  41. package/src/api/index.ts +0 -1
  42. package/src/data-manager/DataManager.ts +5 -35
  43. package/src/inject.ts +0 -2
  44. package/src/types/api/confluxSignTransaction.ts +1 -1
  45. package/src/types/api/export.ts +0 -2
  46. package/src/types/api/firmwareUpdate.ts +5 -5
  47. package/src/types/api/index.ts +0 -2
  48. package/src/types/settings.ts +0 -2
  49. package/src/utils/release.ts +1 -18
  50. package/dist/api/device/DeviceUploadResource.d.ts +0 -18
  51. package/dist/api/device/DeviceUploadResource.d.ts.map +0 -1
  52. package/dist/types/api/deviceUploadResource.d.ts +0 -11
  53. package/dist/types/api/deviceUploadResource.d.ts.map +0 -1
  54. package/src/api/device/DeviceUploadResource.ts +0 -104
  55. package/src/types/api/deviceUploadResource.ts +0 -15
@@ -18,7 +18,7 @@ import type {
18
18
  IDeviceBLEFirmwareStatus,
19
19
  ITransportStatus,
20
20
  } from '../types';
21
- import { getReleaseChangelog, getReleaseStatus, findLatestRelease } from '../utils/release';
21
+ import { getReleaseChangelog, getReleaseStatus } from '../utils/release';
22
22
 
23
23
  export default class DataManager {
24
24
  static deviceMap: DeviceTypeMap = {
@@ -64,25 +64,6 @@ export default class DataManager {
64
64
  return getReleaseStatus(targetDeviceConfigList, currentVersion);
65
65
  };
66
66
 
67
- /**
68
- * Touch、Pro System UI Resource Update
69
- * ** Interval upgrade is not considered **
70
- */
71
- static getSysResourcesLatestRelease = (features: Features) => {
72
- const deviceType = getDeviceType(features);
73
- const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
74
-
75
- if (deviceType !== 'pro' && deviceType !== 'touch') return undefined;
76
-
77
- const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
78
- const currentVersion = deviceFirmwareVersion.join('.');
79
- const targetDeviceConfig = targetDeviceConfigList.filter(
80
- item => semver.gt(item.version.join('.'), currentVersion) && !!item.resource
81
- );
82
-
83
- return findLatestRelease(targetDeviceConfig)?.resource;
84
- };
85
-
86
67
  static getFirmwareChangelog = (features: Features) => {
87
68
  const deviceType = getDeviceType(features);
88
69
  const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
@@ -99,21 +80,10 @@ export default class DataManager {
99
80
  return getReleaseChangelog(targetDeviceConfigList, currentVersion);
100
81
  };
101
82
 
102
- static getFirmwareLatestRelease = (features: Features) => {
83
+ static getFirmwareLeatestRelease = (features: Features) => {
103
84
  const deviceType = getDeviceType(features);
104
85
  const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
105
-
106
- const target = findLatestRelease(targetDeviceConfigList);
107
- if (!target) return target;
108
-
109
- if (!target.resource) {
110
- const resource = this.getSysResourcesLatestRelease(features);
111
- return {
112
- ...target,
113
- resource,
114
- };
115
- }
116
- return target;
86
+ return targetDeviceConfigList[targetDeviceConfigList.length - 1];
117
87
  };
118
88
 
119
89
  static getBLEFirmwareStatus = (features: Features): IDeviceBLEFirmwareStatus => {
@@ -143,10 +113,10 @@ export default class DataManager {
143
113
  return getReleaseChangelog(targetDeviceConfigList, currentVersion);
144
114
  };
145
115
 
146
- static getBleFirmwareLatestRelease = (features: Features) => {
116
+ static getBleFirmwareLeatestRelease = (features: Features) => {
147
117
  const deviceType = getDeviceType(features);
148
118
  const targetDeviceConfigList = this.deviceMap[deviceType]?.ble ?? [];
149
- return findLatestRelease(targetDeviceConfigList);
119
+ return targetDeviceConfigList[targetDeviceConfigList.length - 1];
150
120
  };
151
121
 
152
122
  static getTransportStatus = (localVersion: string): ITransportStatus => {
package/src/inject.ts CHANGED
@@ -85,8 +85,6 @@ export const inject = ({
85
85
  deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
86
86
  deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
87
87
  deviceUpdateReboot: connectId => call({ connectId, method: 'deviceUpdateReboot' }),
88
- deviceUploadResource: (connectId, params) =>
89
- call({ ...params, connectId, method: 'deviceUploadResource' }),
90
88
  deviceSupportFeatures: connectId => call({ connectId, method: 'deviceSupportFeatures' }),
91
89
  deviceVerify: (connectId, params) => call({ ...params, connectId, method: 'deviceVerify' }),
92
90
  deviceWipe: connectId => call({ connectId, method: 'deviceWipe' }),
@@ -28,5 +28,5 @@ export type ConfluxSignTransactionParams = {
28
28
  export declare function confluxSignTransaction(
29
29
  connectId: string,
30
30
  deviceId: string,
31
- params: CommonParams & ConfluxSignTransactionParams
31
+ params: CommonParams & ConfluxTransaction
32
32
  ): Response<ConfluxSignedTx>;
@@ -20,8 +20,6 @@ export type { DeviceResetParams } from './deviceReset';
20
20
  export type { DeviceSettingsParams } from './deviceSettings';
21
21
  export type { DeviceVerifyParams, DeviceVerifySignature } from './deviceVerify';
22
22
  export type { DeviceSupportFeatures } from './deviceSupportFeatures';
23
- export type { DeviceUploadResourceParams } from './deviceUploadResource';
24
- export type { FirmwareUpdateParams, FirmwareUpdateBinaryParams } from './firmwareUpdate';
25
23
 
26
24
  export type { EVMAddress, EVMGetAddressParams } from './evmGetAddress';
27
25
  export type { EVMPublicKey, EVMGetPublicKeyParams } from './evmGetPublicKey';
@@ -1,21 +1,21 @@
1
1
  import type { PROTO } from '../../constants';
2
2
  import type { Params, Response } from '../params';
3
3
 
4
- export interface FirmwareUpdateBinaryParams {
4
+ export interface FirmwareUpdateBinary {
5
5
  binary: ArrayBuffer;
6
6
  }
7
7
 
8
- export interface FirmwareUpdateParams {
9
- version?: number[];
8
+ export interface FirmwareUpdate {
9
+ version: number[];
10
10
  btcOnly?: boolean;
11
11
  updateType: 'firmware' | 'ble';
12
12
  }
13
13
 
14
14
  export declare function firmwareUpdate(
15
15
  connectId: string | undefined,
16
- params: Params<FirmwareUpdateParams>
16
+ params: Params<FirmwareUpdate>
17
17
  ): Response<PROTO.Success>;
18
18
  export declare function firmwareUpdate(
19
19
  connectId: string | undefined,
20
- params: Params<FirmwareUpdateBinaryParams>
20
+ params: Params<FirmwareUpdateBinary>
21
21
  ): Response<PROTO.Success>;
@@ -24,7 +24,6 @@ import { deviceChangePin } from './deviceChangePin';
24
24
  import { deviceSettings } from './deviceSettings';
25
25
  import { deviceFlags } from './deviceFlags';
26
26
  import { deviceUpdateReboot } from './deviceUpdateReboot';
27
- import { deviceUploadResource } from './deviceUploadResource';
28
27
  import { deviceSupportFeatures } from './deviceSupportFeatures';
29
28
 
30
29
  import { cipherKeyValue } from './cipherKeyValue';
@@ -111,7 +110,6 @@ export type CoreApi = {
111
110
  deviceReset: typeof deviceReset;
112
111
  deviceSettings: typeof deviceSettings;
113
112
  deviceUpdateReboot: typeof deviceUpdateReboot;
114
- deviceUploadResource: typeof deviceUploadResource;
115
113
  deviceSupportFeatures: typeof deviceSupportFeatures;
116
114
  deviceVerify: typeof deviceVerify;
117
115
  deviceWipe: typeof deviceWipe;
@@ -27,8 +27,6 @@ export type ILocale = 'zh-CN' | 'en-US';
27
27
  export type IFirmwareReleaseInfo = {
28
28
  required: boolean;
29
29
  url: string;
30
- /** Firmware UI resource */
31
- resource?: string;
32
30
  fingerprint: string;
33
31
  version: IVersionArray;
34
32
  changelog: {
@@ -1,10 +1,5 @@
1
1
  import semver from 'semver';
2
- import {
3
- IBLEFirmwareReleaseInfo,
4
- IDeviceFirmwareStatus,
5
- IFirmwareReleaseInfo,
6
- IVersionArray,
7
- } from '../types';
2
+ import { IBLEFirmwareReleaseInfo, IDeviceFirmwareStatus, IFirmwareReleaseInfo } from '../types';
8
3
 
9
4
  export const getReleaseStatus = (
10
5
  releases: (IFirmwareReleaseInfo | IBLEFirmwareReleaseInfo)[],
@@ -27,15 +22,3 @@ export const getReleaseChangelog = (
27
22
  const newVersions = releases.filter(r => semver.gt(r.version.join('.'), currentVersion));
28
23
  return newVersions.map(r => r.changelog);
29
24
  };
30
-
31
- export const findLatestRelease = <T extends { version: IVersionArray }>(
32
- releases: T[]
33
- ): T | undefined => {
34
- let leastRelease = releases[0];
35
- releases.forEach(release => {
36
- if (semver.gt(release.version.join('.'), leastRelease.version.join('.'))) {
37
- leastRelease = release;
38
- }
39
- });
40
- return leastRelease;
41
- };
@@ -1,18 +0,0 @@
1
- import { ResourceUpload, Success } from '@onekeyfe/hd-transport';
2
- import { TypedResponseMessage } from '../../device/DeviceCommands';
3
- import { BaseMethod } from '../BaseMethod';
4
- export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
5
- paramsData: {
6
- data: Uint8Array;
7
- thumbnailData: Uint8Array;
8
- };
9
- getVersionRange(): {
10
- model_touch: {
11
- min: string;
12
- };
13
- };
14
- init(): void;
15
- processResourceRequest: (res: TypedResponseMessage<'ResourceRequest'> | TypedResponseMessage<'ZoomRequest'> | TypedResponseMessage<'Success'>) => Promise<Success>;
16
- run(): Promise<Success>;
17
- }
18
- //# sourceMappingURL=DeviceUploadResource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeviceUploadResource.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceUploadResource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,cAAc,CAAC;IAC1E,UAAU;;;MAGR;IAEF,eAAe;;;;;IAQf,IAAI;IA8BJ,sBAAsB,QAEhB,qBAAqB,iBAAiB,CAAC,GACvC,qBAAqB,aAAa,CAAC,GACnC,qBAAqB,SAAS,CAAC,KAClC,QAAQ,OAAO,CAAC,CAkCjB;IAEI,GAAG;CASV"}
@@ -1,11 +0,0 @@
1
- import { ResourceType, Success } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
- export declare type DeviceUploadResourceParams = {
4
- suffix: string;
5
- dataHex: string;
6
- thumbnailDataHex: string;
7
- resType: ResourceType;
8
- nftMetaData: string;
9
- };
10
- export declare function deviceUploadResource(connectId: string, params: CommonParams & DeviceUploadResourceParams): Response<Success>;
11
- //# sourceMappingURL=deviceUploadResource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deviceUploadResource.d.ts","sourceRoot":"","sources":["../../../src/types/api/deviceUploadResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,oBAAY,0BAA0B,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,GAAG,0BAA0B,GAChD,QAAQ,CAAC,OAAO,CAAC,CAAC"}
@@ -1,104 +0,0 @@
1
- import { bytesToHex } from '@noble/hashes/utils';
2
- import { ResourceUpload, Success } from '@onekeyfe/hd-transport';
3
- import { blake2s } from '@noble/hashes/blake2s';
4
- import { TypedResponseMessage } from '../../device/DeviceCommands';
5
- import { DeviceUploadResourceParams } from '../../types';
6
- import { BaseMethod } from '../BaseMethod';
7
- import { validateParams } from '../helpers/paramsValidator';
8
- import { hexToBytes } from '../helpers/hexUtils';
9
-
10
- export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
11
- paramsData = {
12
- data: new Uint8Array(),
13
- thumbnailData: new Uint8Array(),
14
- };
15
-
16
- getVersionRange() {
17
- return {
18
- model_touch: {
19
- min: '3.2.0',
20
- },
21
- };
22
- }
23
-
24
- init() {
25
- this.useDevicePassphraseState = false;
26
-
27
- // check payload
28
- validateParams(this.payload, [
29
- { name: 'suffix', type: 'string', required: true },
30
- { name: 'dataHex', type: 'string', required: true },
31
- { name: 'thumbnailDataHex', type: 'string', required: true },
32
- { name: 'resType', type: 'number', required: true },
33
- { name: 'nftMetaData', type: 'string' },
34
- ]);
35
-
36
- const { suffix, dataHex, thumbnailDataHex, resType, nftMetaData } = this
37
- .payload as DeviceUploadResourceParams;
38
-
39
- // init params
40
- this.paramsData = {
41
- data: hexToBytes(dataHex),
42
- thumbnailData: hexToBytes(thumbnailDataHex),
43
- };
44
-
45
- this.params = {
46
- extension: suffix,
47
- data_length: this.paramsData.data.byteLength,
48
- zoom_data_length: this.paramsData.thumbnailData.byteLength,
49
- res_type: resType,
50
- nft_meta_data: nftMetaData,
51
- };
52
- }
53
-
54
- processResourceRequest = async (
55
- res:
56
- | TypedResponseMessage<'ResourceRequest'>
57
- | TypedResponseMessage<'ZoomRequest'>
58
- | TypedResponseMessage<'Success'>
59
- ): Promise<Success> => {
60
- if (res.type === 'Success') {
61
- return res.message;
62
- }
63
-
64
- const { offset, data_length } = res.message;
65
- const { data, thumbnailData } = this.paramsData;
66
-
67
- if (offset === undefined) {
68
- throw new Error('offset is undefined');
69
- }
70
-
71
- let payload: Uint8Array;
72
- if (res.type === 'ResourceRequest') {
73
- payload = new Uint8Array(data.slice(offset, Math.min(offset + data_length, data.byteLength)));
74
- } else {
75
- payload = new Uint8Array(
76
- thumbnailData.slice(offset, Math.min(offset + data_length, thumbnailData.byteLength))
77
- );
78
- }
79
-
80
- const digest = blake2s(payload);
81
-
82
- const resourceAckParams = {
83
- data_chunk: bytesToHex(payload),
84
- hash: bytesToHex(digest),
85
- };
86
-
87
- const response = await this.device.commands.typedCall(
88
- 'ResourceAck',
89
- ['ResourceRequest', 'ZoomRequest', 'Success'],
90
- resourceAckParams
91
- );
92
- return this.processResourceRequest(response);
93
- };
94
-
95
- async run() {
96
- const res = await this.device.commands.typedCall(
97
- 'ResourceUpload',
98
- ['ResourceRequest', 'ZoomRequest', 'Success'],
99
- this.params
100
- );
101
-
102
- return this.processResourceRequest(res);
103
- }
104
- }
@@ -1,15 +0,0 @@
1
- import { ResourceType, Success } from '@onekeyfe/hd-transport';
2
- import type { CommonParams, Response } from '../params';
3
-
4
- export type DeviceUploadResourceParams = {
5
- suffix: string;
6
- dataHex: string;
7
- thumbnailDataHex: string;
8
- resType: ResourceType;
9
- nftMetaData: string;
10
- };
11
-
12
- export declare function deviceUploadResource(
13
- connectId: string,
14
- params: CommonParams & DeviceUploadResourceParams
15
- ): Response<Success>;