@onekeyfe/hd-core 0.2.15 → 0.2.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 (52) hide show
  1. package/dist/api/FirmwareUpdateV2.d.ts +2 -1
  2. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  3. package/dist/api/cardano/helper/cardanoInputs.d.ts.map +1 -1
  4. package/dist/api/device/DeviceRebootToBoardloader.d.ts +15 -0
  5. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -0
  6. package/dist/api/filecoin/FilecoinGetAddress.d.ts +17 -0
  7. package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -0
  8. package/dist/api/filecoin/FilecoinSignTransaction.d.ts +19 -0
  9. package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -0
  10. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  11. package/dist/api/index.d.ts +3 -0
  12. package/dist/api/index.d.ts.map +1 -1
  13. package/dist/data-manager/DataManager.d.ts +2 -1
  14. package/dist/data-manager/DataManager.d.ts.map +1 -1
  15. package/dist/index.d.ts +41 -4
  16. package/dist/index.js +472 -277
  17. package/dist/inject.d.ts.map +1 -1
  18. package/dist/types/api/cardano.d.ts.map +1 -1
  19. package/dist/types/api/deviceRebootToBoardloader.d.ts +5 -0
  20. package/dist/types/api/deviceRebootToBoardloader.d.ts.map +1 -0
  21. package/dist/types/api/export.d.ts +2 -0
  22. package/dist/types/api/export.d.ts.map +1 -1
  23. package/dist/types/api/filecoinGetAddress.d.ts +14 -0
  24. package/dist/types/api/filecoinGetAddress.d.ts.map +1 -0
  25. package/dist/types/api/filecoinSignTransaction.d.ts +14 -0
  26. package/dist/types/api/filecoinSignTransaction.d.ts.map +1 -0
  27. package/dist/types/api/firmwareUpdate.d.ts +7 -0
  28. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  29. package/dist/types/api/index.d.ts +8 -2
  30. package/dist/types/api/index.d.ts.map +1 -1
  31. package/dist/types/settings.d.ts +1 -0
  32. package/dist/types/settings.d.ts.map +1 -1
  33. package/dist/utils/patch.d.ts +1 -1
  34. package/dist/utils/patch.d.ts.map +1 -1
  35. package/package.json +4 -4
  36. package/src/api/FirmwareUpdateV2.ts +25 -2
  37. package/src/api/device/DeviceRebootToBoardloader.ts +28 -0
  38. package/src/api/filecoin/FilecoinGetAddress.ts +71 -0
  39. package/src/api/filecoin/FilecoinSignTransaction.ts +54 -0
  40. package/src/api/firmware/getBinary.ts +12 -2
  41. package/src/api/index.ts +4 -0
  42. package/src/data/messages/messages.json +463 -419
  43. package/src/data-manager/DataManager.ts +17 -5
  44. package/src/inject.ts +7 -0
  45. package/src/types/api/cardano.ts +0 -1
  46. package/src/types/api/deviceRebootToBoardloader.ts +6 -0
  47. package/src/types/api/export.ts +3 -0
  48. package/src/types/api/filecoinGetAddress.ts +23 -0
  49. package/src/types/api/filecoinSignTransaction.ts +23 -0
  50. package/src/types/api/firmwareUpdate.ts +12 -0
  51. package/src/types/api/index.ts +13 -2
  52. package/src/types/settings.ts +1 -0
@@ -17,6 +17,7 @@ import type {
17
17
  IDeviceFirmwareStatus,
18
18
  IDeviceBLEFirmwareStatus,
19
19
  ITransportStatus,
20
+ IDeviceType,
20
21
  } from '../types';
21
22
  import { getReleaseChangelog, getReleaseStatus, findLatestRelease } from '../utils/release';
22
23
 
@@ -48,6 +49,12 @@ export default class DataManager {
48
49
  default: MessagesJSON as unknown as JSON,
49
50
  };
50
51
 
52
+ /**
53
+ * Since 3.5.0, Touch uses the firmware-v2 field to get firmware release info
54
+ */
55
+ static getFirmwareUpdateField = (deviceType: IDeviceType) =>
56
+ deviceType === 'touch' ? 'firmware-v2' : 'firmware';
57
+
51
58
  static getFirmwareStatus = (features: Features): IDeviceFirmwareStatus => {
52
59
  const deviceType = getDeviceType(features);
53
60
  const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
@@ -59,7 +66,8 @@ export default class DataManager {
59
66
  return 'unknown';
60
67
  }
61
68
 
62
- const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
69
+ const firmwareUpdateField = this.getFirmwareUpdateField(deviceType);
70
+ const targetDeviceConfigList = this.deviceMap[deviceType]?.[firmwareUpdateField] ?? [];
63
71
  const currentVersion = deviceFirmwareVersion.join('.');
64
72
  return getReleaseStatus(targetDeviceConfigList, currentVersion);
65
73
  };
@@ -74,7 +82,8 @@ export default class DataManager {
74
82
 
75
83
  if (deviceType !== 'pro' && deviceType !== 'touch') return undefined;
76
84
 
77
- const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
85
+ const firmwareUpdateField = this.getFirmwareUpdateField(deviceType);
86
+ const targetDeviceConfigList = this.deviceMap[deviceType]?.[firmwareUpdateField] ?? [];
78
87
  const currentVersion = deviceFirmwareVersion.join('.');
79
88
  const targetDeviceConfig = targetDeviceConfigList.filter(item =>
80
89
  forcedUpdateRes
@@ -94,7 +103,8 @@ export default class DataManager {
94
103
 
95
104
  if (deviceType !== 'pro' && deviceType !== 'touch') return undefined;
96
105
 
97
- const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
106
+ const firmwareUpdateField = this.getFirmwareUpdateField(deviceType);
107
+ const targetDeviceConfigList = this.deviceMap[deviceType]?.[firmwareUpdateField] ?? [];
98
108
  const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.fullResource);
99
109
 
100
110
  return findLatestRelease(targetDeviceConfig)?.fullResource;
@@ -111,14 +121,16 @@ export default class DataManager {
111
121
  return [];
112
122
  }
113
123
 
114
- const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
124
+ const firmwareUpdateField = this.getFirmwareUpdateField(deviceType);
125
+ const targetDeviceConfigList = this.deviceMap[deviceType]?.[firmwareUpdateField] ?? [];
115
126
  const currentVersion = deviceFirmwareVersion.join('.');
116
127
  return getReleaseChangelog(targetDeviceConfigList, currentVersion);
117
128
  };
118
129
 
119
130
  static getFirmwareLatestRelease = (features: Features) => {
120
131
  const deviceType = getDeviceType(features);
121
- const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
132
+ const firmwareUpdateField = this.getFirmwareUpdateField(deviceType);
133
+ const targetDeviceConfigList = this.deviceMap[deviceType]?.[firmwareUpdateField] ?? [];
122
134
 
123
135
  const target = findLatestRelease(targetDeviceConfigList);
124
136
  if (!target) return target;
package/src/inject.ts CHANGED
@@ -80,6 +80,8 @@ export const inject = ({
80
80
  deviceChangePin: (connectId, params) =>
81
81
  call({ ...params, connectId, method: 'deviceChangePin' }),
82
82
  deviceFlags: (connectId, params) => call({ ...params, connectId, method: 'deviceFlags' }),
83
+ deviceRebootToBoardloader: connectId =>
84
+ call({ connectId, method: 'deviceRebootToBoardloader' }),
83
85
  deviceRebootToBootloader: connectId => call({ connectId, method: 'deviceRebootToBootloader' }),
84
86
  deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
85
87
  deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
@@ -212,6 +214,11 @@ export const inject = ({
212
214
  call({ ...params, connectId, deviceId, method: 'cardanoGetPublicKey' }),
213
215
  cardanoSignTransaction: (connectId, deviceId, params) =>
214
216
  call({ ...params, connectId, deviceId, method: 'cardanoSignTransaction' }),
217
+
218
+ filecoinGetAddress: (connectId, deviceId, params) =>
219
+ call({ ...params, connectId, deviceId, method: 'filecoinGetAddress' }),
220
+ filecoinSignTransaction: (connectId, deviceId, params) =>
221
+ call({ ...params, connectId, deviceId, method: 'filecoinSignTransaction' }),
215
222
  };
216
223
  return api;
217
224
  };
@@ -99,7 +99,6 @@ export type CardanoOutput = (
99
99
  amount: string;
100
100
  tokenBundle?: CardanoAssetGroup[];
101
101
  datumHash?: string;
102
- // @ts-expect-error
103
102
  format?: PROTO.CardanoTxOutputSerializationFormat;
104
103
  inlineDatum?: string;
105
104
  referenceScript?: string;
@@ -0,0 +1,6 @@
1
+ import { Success, RebootToBoardloader } from '@onekeyfe/hd-transport';
2
+ import type { Response } from '../params';
3
+
4
+ export type RebootToBoardloaderParams = RebootToBoardloader;
5
+
6
+ export declare function deviceRebootToBoardloader(connectId: string): Response<Success>;
@@ -118,3 +118,6 @@ export type {
118
118
  } from './cardanoGetAddress';
119
119
 
120
120
  export type { CardanoSignTransaction, CardanoSignedTxData } from './cardano';
121
+
122
+ export type { FilecoinAddress, FilecoinGetAddressParams } from './filecoinGetAddress';
123
+ export type { FilecoinSignTransactionParams, FilecoinSignedTx } from './filecoinSignTransaction';
@@ -0,0 +1,23 @@
1
+ import { FilecoinAddress as HardwareFilecoinAddress } from '@onekeyfe/hd-transport';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type FilecoinAddress = {
5
+ path: string;
6
+ } & HardwareFilecoinAddress;
7
+
8
+ export type FilecoinGetAddressParams = {
9
+ path: string | number[];
10
+ showOnOneKey?: boolean;
11
+ };
12
+
13
+ export declare function filecoinGetAddress(
14
+ connectId: string,
15
+ deviceId: string,
16
+ params: CommonParams & FilecoinGetAddressParams
17
+ ): Response<FilecoinAddress>;
18
+
19
+ export declare function filecoinGetAddress(
20
+ connectId: string,
21
+ deviceId: string,
22
+ params: CommonParams & { bundle?: FilecoinGetAddressParams[] }
23
+ ): Response<Array<FilecoinAddress>>;
@@ -0,0 +1,23 @@
1
+ import { FilecoinSignedTx as HardwareFilecoinSignedTx } from '@onekeyfe/hd-transport';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type FilecoinSignedTx = {
5
+ path: string;
6
+ } & HardwareFilecoinSignedTx;
7
+
8
+ export type FilecoinSignTransactionParams = {
9
+ path: string | number[];
10
+ rawTx?: string;
11
+ };
12
+
13
+ export declare function filecoinSignTransaction(
14
+ connectId: string,
15
+ deviceId: string,
16
+ params: CommonParams & FilecoinSignTransactionParams
17
+ ): Response<FilecoinSignedTx>;
18
+
19
+ export declare function filecoinSignTransaction(
20
+ connectId: string,
21
+ deviceId: string,
22
+ params: CommonParams & { bundle?: FilecoinSignTransactionParams[] }
23
+ ): Response<Array<FilecoinSignedTx>>;
@@ -20,3 +20,15 @@ export declare function firmwareUpdate(
20
20
  connectId: string | undefined,
21
21
  params: Params<FirmwareUpdateBinaryParams>
22
22
  ): Response<PROTO.Success>;
23
+
24
+ type IPlatform = 'native' | 'desktop' | 'ext' | 'web' | 'webEmbed';
25
+ type Platform = { platform: IPlatform };
26
+
27
+ export declare function firmwareUpdateV2(
28
+ connectId: string | undefined,
29
+ params: Params<FirmwareUpdateParams & Platform>
30
+ ): Response<PROTO.Success>;
31
+ export declare function firmwareUpdateV2(
32
+ connectId: string | undefined,
33
+ params: Params<FirmwareUpdateBinaryParams & Platform>
34
+ ): Response<PROTO.Success>;
@@ -11,7 +11,7 @@ import { getFeatures } from './getFeatures';
11
11
  import { getPassphraseState } from './getPassphraseState';
12
12
  import { checkFirmwareRelease } from './checkFirmwareRelease';
13
13
  import { checkBLEFirmwareRelease } from './checkBLEFirmwareRelease';
14
- import { firmwareUpdate } from './firmwareUpdate';
14
+ import { firmwareUpdate, firmwareUpdateV2 } from './firmwareUpdate';
15
15
  import { requestWebUsbDevice } from './requestWebUsbDevice';
16
16
 
17
17
  import { deviceReset } from './deviceReset';
@@ -19,6 +19,7 @@ import { deviceRecovery } from './deviceRecovery';
19
19
  import { deviceVerify } from './deviceVerify';
20
20
  import { deviceWipe } from './deviceWipe';
21
21
  import { deviceRebootToBootloader } from './deviceRebootToBootloader';
22
+ import { deviceRebootToBoardloader } from './deviceRebootToBoardloader';
22
23
  import { deviceBackup } from './deviceBackup';
23
24
  import { deviceChangePin } from './deviceChangePin';
24
25
  import { deviceSettings } from './deviceSettings';
@@ -94,6 +95,9 @@ import { cardanoGetAddress } from './cardanoGetAddress';
94
95
  import { cardanoGetPublicKey } from './cardanoGetPublicKey';
95
96
  import { cardanoSignTransaction } from './cardanoSignTransaction';
96
97
 
98
+ import { filecoinGetAddress } from './filecoinGetAddress';
99
+ import { filecoinSignTransaction } from './filecoinSignTransaction';
100
+
97
101
  export * from './export';
98
102
 
99
103
  export type CoreApi = {
@@ -126,6 +130,7 @@ export type CoreApi = {
126
130
  deviceBackup: typeof deviceBackup;
127
131
  deviceChangePin: typeof deviceChangePin;
128
132
  deviceFlags: typeof deviceFlags;
133
+ deviceRebootToBoardloader: typeof deviceRebootToBoardloader;
129
134
  deviceRebootToBootloader: typeof deviceRebootToBootloader;
130
135
  deviceRecovery: typeof deviceRecovery;
131
136
  deviceReset: typeof deviceReset;
@@ -139,7 +144,7 @@ export type CoreApi = {
139
144
  checkFirmwareRelease: typeof checkFirmwareRelease;
140
145
  checkBLEFirmwareRelease: typeof checkBLEFirmwareRelease;
141
146
  firmwareUpdate: typeof firmwareUpdate;
142
- firmwareUpdateV2: typeof firmwareUpdate;
147
+ firmwareUpdateV2: typeof firmwareUpdateV2;
143
148
 
144
149
  cipherKeyValue: typeof cipherKeyValue;
145
150
 
@@ -251,4 +256,10 @@ export type CoreApi = {
251
256
  cardanoGetAddress: typeof cardanoGetAddress;
252
257
  cardanoGetPublicKey: typeof cardanoGetPublicKey;
253
258
  cardanoSignTransaction: typeof cardanoSignTransaction;
259
+
260
+ /**
261
+ * Filecoin function
262
+ */
263
+ filecoinGetAddress: typeof filecoinGetAddress;
264
+ filecoinSignTransaction: typeof filecoinSignTransaction;
254
265
  };
@@ -56,6 +56,7 @@ export type IBLEFirmwareReleaseInfo = {
56
56
  export type DeviceTypeMap = {
57
57
  [k in IDeviceType]: {
58
58
  firmware: IFirmwareReleaseInfo[];
59
+ 'firmware-v2'?: IFirmwareReleaseInfo[];
59
60
  ble: IBLEFirmwareReleaseInfo[];
60
61
  };
61
62
  };