@onekeyfe/hd-core 0.1.54 → 0.1.55

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 (84) 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 +3 -0
  4. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  5. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  6. package/dist/api/aptos/AptosGetAddress.d.ts +7 -1
  7. package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
  8. package/dist/api/aptos/AptosGetPublicKey.d.ts +18 -0
  9. package/dist/api/aptos/AptosGetPublicKey.d.ts.map +1 -0
  10. package/dist/api/device/DeviceUpdateReboot.d.ts +2 -2
  11. package/dist/api/device/DeviceUpdateReboot.d.ts.map +1 -1
  12. package/dist/api/device/DeviceUploadResource.d.ts +18 -0
  13. package/dist/api/device/DeviceUploadResource.d.ts.map +1 -0
  14. package/dist/api/device/DeviceVerify.d.ts.map +1 -1
  15. package/dist/api/firmware/getBinary.d.ts +3 -11
  16. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  17. package/dist/api/firmware/releaseHelper.d.ts +2 -2
  18. package/dist/api/firmware/uploadFirmware.d.ts +5 -1
  19. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  20. package/dist/api/index.d.ts +2 -1
  21. package/dist/api/index.d.ts.map +1 -1
  22. package/dist/data-manager/DataManager.d.ts +3 -2
  23. package/dist/data-manager/DataManager.d.ts.map +1 -1
  24. package/dist/device/Device.d.ts +3 -1
  25. package/dist/device/Device.d.ts.map +1 -1
  26. package/dist/device/DeviceCommands.d.ts.map +1 -1
  27. package/dist/index.d.ts +42 -25
  28. package/dist/index.js +485 -131
  29. package/dist/inject.d.ts.map +1 -1
  30. package/dist/types/api/aptosGetPublicKey.d.ts +14 -0
  31. package/dist/types/api/aptosGetPublicKey.d.ts.map +1 -0
  32. package/dist/types/api/confluxSignTransaction.d.ts +1 -1
  33. package/dist/types/api/confluxSignTransaction.d.ts.map +1 -1
  34. package/dist/types/api/deviceUploadResource.d.ts +11 -0
  35. package/dist/types/api/deviceUploadResource.d.ts.map +1 -0
  36. package/dist/types/api/export.d.ts +3 -0
  37. package/dist/types/api/export.d.ts.map +1 -1
  38. package/dist/types/api/firmwareUpdate.d.ts +5 -5
  39. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  40. package/dist/types/api/index.d.ts +4 -2
  41. package/dist/types/api/index.d.ts.map +1 -1
  42. package/dist/types/settings.d.ts +1 -0
  43. package/dist/types/settings.d.ts.map +1 -1
  44. package/dist/utils/patch.d.ts +1 -1
  45. package/dist/utils/patch.d.ts.map +1 -1
  46. package/dist/utils/release.d.ts +4 -1
  47. package/dist/utils/release.d.ts.map +1 -1
  48. package/package.json +9 -6
  49. package/src/api/FirmwareUpdateV2.ts +62 -10
  50. package/src/api/GetPassphraseState.ts +3 -0
  51. package/src/api/aptos/AptosGetAddress.ts +16 -8
  52. package/src/api/aptos/AptosGetPublicKey.ts +60 -0
  53. package/src/api/aptos/AptosSignTransaction.ts +1 -1
  54. package/src/api/conflux/ConfluxSignMessage.ts +1 -1
  55. package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -1
  56. package/src/api/conflux/ConfluxSignTransaction.ts +2 -2
  57. package/src/api/device/DeviceUpdateReboot.ts +3 -3
  58. package/src/api/device/DeviceUploadResource.ts +104 -0
  59. package/src/api/device/DeviceVerify.ts +3 -2
  60. package/src/api/firmware/getBinary.ts +16 -3
  61. package/src/api/firmware/releaseHelper.ts +2 -2
  62. package/src/api/firmware/uploadFirmware.ts +100 -1
  63. package/src/api/helpers/hexUtils.ts +1 -1
  64. package/src/api/index.ts +2 -1
  65. package/src/data/coins/bitcoin.json +1 -0
  66. package/src/data/messages/messages.json +115 -13
  67. package/src/data-manager/DataManager.ts +35 -5
  68. package/src/device/Device.ts +30 -14
  69. package/src/device/DeviceCommands.ts +5 -2
  70. package/src/inject.ts +4 -6
  71. package/src/types/api/aptosGetPublicKey.ts +23 -0
  72. package/src/types/api/confluxSignTransaction.ts +1 -1
  73. package/src/types/api/deviceUploadResource.ts +15 -0
  74. package/src/types/api/export.ts +3 -0
  75. package/src/types/api/firmwareUpdate.ts +5 -5
  76. package/src/types/api/index.ts +4 -2
  77. package/src/types/settings.ts +2 -0
  78. package/src/utils/release.ts +18 -1
  79. package/dist/api/BatchGetPublicKey.d.ts +0 -11
  80. package/dist/api/BatchGetPublicKey.d.ts.map +0 -1
  81. package/dist/types/api/batchGetPublicKey.d.ts +0 -11
  82. package/dist/types/api/batchGetPublicKey.d.ts.map +0 -1
  83. package/src/api/BatchGetPublicKey.ts +0 -40
  84. package/src/types/api/batchGetPublicKey.ts +0 -18
@@ -5011,7 +5011,7 @@
5011
5011
  }
5012
5012
  }
5013
5013
  },
5014
- "BixinReboot": {
5014
+ "DeviceBackToBoot": {
5015
5015
  "fields": {}
5016
5016
  },
5017
5017
  "BixinBackupRequest": {
@@ -5281,6 +5281,104 @@
5281
5281
  }
5282
5282
  }
5283
5283
  },
5284
+ "ResourceUpload": {
5285
+ "fields": {
5286
+ "extension": {
5287
+ "rule": "required",
5288
+ "type": "string",
5289
+ "id": 1
5290
+ },
5291
+ "data_length": {
5292
+ "rule": "required",
5293
+ "type": "uint32",
5294
+ "id": 2
5295
+ },
5296
+ "res_type": {
5297
+ "rule": "required",
5298
+ "type": "ResourceType",
5299
+ "id": 3
5300
+ },
5301
+ "zoom_data_length": {
5302
+ "rule": "required",
5303
+ "type": "uint32",
5304
+ "id": 5
5305
+ },
5306
+ "nft_meta_data": {
5307
+ "type": "bytes",
5308
+ "id": 4
5309
+ }
5310
+ },
5311
+ "nested": {
5312
+ "ResourceType": {
5313
+ "values": {
5314
+ "WallPaper": 0,
5315
+ "Nft": 1
5316
+ }
5317
+ }
5318
+ }
5319
+ },
5320
+ "ZoomRequest": {
5321
+ "fields": {
5322
+ "offset": {
5323
+ "type": "uint32",
5324
+ "id": 1
5325
+ },
5326
+ "data_length": {
5327
+ "rule": "required",
5328
+ "type": "uint32",
5329
+ "id": 2
5330
+ }
5331
+ }
5332
+ },
5333
+ "ResourceRequest": {
5334
+ "fields": {
5335
+ "offset": {
5336
+ "type": "uint32",
5337
+ "id": 1
5338
+ },
5339
+ "data_length": {
5340
+ "rule": "required",
5341
+ "type": "uint32",
5342
+ "id": 2
5343
+ }
5344
+ }
5345
+ },
5346
+ "ResourceAck": {
5347
+ "fields": {
5348
+ "data_chunk": {
5349
+ "rule": "required",
5350
+ "type": "bytes",
5351
+ "id": 1
5352
+ },
5353
+ "hash": {
5354
+ "type": "bytes",
5355
+ "id": 2
5356
+ }
5357
+ }
5358
+ },
5359
+ "ResourceUpdate": {
5360
+ "fields": {
5361
+ "file_name": {
5362
+ "rule": "required",
5363
+ "type": "string",
5364
+ "id": 1
5365
+ },
5366
+ "data_length": {
5367
+ "rule": "required",
5368
+ "type": "uint32",
5369
+ "id": 2
5370
+ },
5371
+ "initial_data_chunk": {
5372
+ "rule": "required",
5373
+ "type": "bytes",
5374
+ "id": 3
5375
+ },
5376
+ "hash": {
5377
+ "type": "bytes",
5378
+ "id": 4
5379
+ }
5380
+ }
5381
+ },
5284
5382
  "NFTWriteInfo": {
5285
5383
  "fields": {
5286
5384
  "index": {
@@ -6277,6 +6375,7 @@
6277
6375
  }
6278
6376
  },
6279
6377
  "raw_tx": {
6378
+ "rule": "required",
6280
6379
  "type": "bytes",
6281
6380
  "id": 2
6282
6381
  }
@@ -8405,16 +8504,6 @@
8405
8504
  "MessageType_StarcoinSignMessage": 10306,
8406
8505
  "MessageType_StarcoinMessageSignature": 10307,
8407
8506
  "MessageType_StarcoinVerifyMessage": 10308,
8408
- "MessageType_ConfluxGetAddress": 10401,
8409
- "MessageType_ConfluxAddress": 10402,
8410
- "MessageType_ConfluxSignTx": 10403,
8411
- "MessageType_ConfluxTxRequest": 10404,
8412
- "MessageType_ConfluxTxAck": 10405,
8413
- "MessageType_ConfluxSignMessage": 10406,
8414
- "MessageType_ConfluxSignMessageCIP23": 10407,
8415
- "MessageType_ConfluxMessageSignature": 10408,
8416
- "MessageType_ConfluxVerifyMessage": 10409,
8417
- "MessageType_ConfluxVerifyMessageCIP23": 10410,
8418
8507
  "MessageType_AptosGetAddress": 10600,
8419
8508
  "MessageType_AptosAddress": 10601,
8420
8509
  "MessageType_AptosSignTx": 10602,
@@ -8425,7 +8514,6 @@
8425
8514
  "MessageType_WebAuthnRemoveResidentCredential": 803,
8426
8515
  "MessageType_BixinSeedOperate": 901,
8427
8516
  "MessageType_BixinMessageSE": 902,
8428
- "MessageType_BixinReboot": 903,
8429
8517
  "MessageType_BixinOutMessageSE": 904,
8430
8518
  "MessageType_BixinBackupRequest": 905,
8431
8519
  "MessageType_BixinBackupAck": 906,
@@ -8442,6 +8530,14 @@
8442
8530
  "MessageType_EthereumSignMessageEIP712": 10200,
8443
8531
  "MessageType_GetPublicKeyMultiple": 10210,
8444
8532
  "MessageType_PublicKeyMultiple": 10211,
8533
+ "MessageType_ConfluxGetAddress": 10112,
8534
+ "MessageType_ConfluxAddress": 10113,
8535
+ "MessageType_ConfluxSignTx": 10114,
8536
+ "MessageType_ConfluxTxRequest": 10115,
8537
+ "MessageType_ConfluxTxAck": 10116,
8538
+ "MessageType_ConfluxSignMessage": 10117,
8539
+ "MessageType_ConfluxSignMessageCIP23": 10118,
8540
+ "MessageType_ConfluxMessageSignature": 10119,
8445
8541
  "MessageType_TronGetAddress": 10501,
8446
8542
  "MessageType_TronAddress": 10502,
8447
8543
  "MessageType_TronSignTx": 10503,
@@ -8452,6 +8548,7 @@
8452
8548
  "MessageType_NearAddress": 10702,
8453
8549
  "MessageType_NearSignTx": 10703,
8454
8550
  "MessageType_NearSignedTx": 10704,
8551
+ "MessageType_DeviceBackToBoot": 903,
8455
8552
  "MessageType_DeviceInfoSettings": 10001,
8456
8553
  "MessageType_GetDeviceInfo": 10002,
8457
8554
  "MessageType_DeviceInfo": 10003,
@@ -8466,7 +8563,12 @@
8466
8563
  "MessageType_SESignMessage": 10012,
8467
8564
  "MessageType_SEMessageSignature": 10013,
8468
8565
  "MessageType_NFTWriteInfo": 10014,
8469
- "MessageType_NFTWriteData": 10015
8566
+ "MessageType_NFTWriteData": 10015,
8567
+ "MessageType_ResourceUpload": 10018,
8568
+ "MessageType_ZoomRequest": 10019,
8569
+ "MessageType_ResourceRequest": 10020,
8570
+ "MessageType_ResourceAck": 10021,
8571
+ "MessageType_ResourceUpdate": 10022
8470
8572
  }
8471
8573
  },
8472
8574
  "google": {
@@ -18,7 +18,7 @@ import type {
18
18
  IDeviceBLEFirmwareStatus,
19
19
  ITransportStatus,
20
20
  } from '../types';
21
- import { getReleaseChangelog, getReleaseStatus } from '../utils/release';
21
+ import { getReleaseChangelog, getReleaseStatus, findLatestRelease } from '../utils/release';
22
22
 
23
23
  export default class DataManager {
24
24
  static deviceMap: DeviceTypeMap = {
@@ -64,6 +64,25 @@ 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
+
67
86
  static getFirmwareChangelog = (features: Features) => {
68
87
  const deviceType = getDeviceType(features);
69
88
  const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
@@ -80,10 +99,21 @@ export default class DataManager {
80
99
  return getReleaseChangelog(targetDeviceConfigList, currentVersion);
81
100
  };
82
101
 
83
- static getFirmwareLeatestRelease = (features: Features) => {
102
+ static getFirmwareLatestRelease = (features: Features) => {
84
103
  const deviceType = getDeviceType(features);
85
104
  const targetDeviceConfigList = this.deviceMap[deviceType]?.firmware ?? [];
86
- return targetDeviceConfigList[targetDeviceConfigList.length - 1];
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;
87
117
  };
88
118
 
89
119
  static getBLEFirmwareStatus = (features: Features): IDeviceBLEFirmwareStatus => {
@@ -113,10 +143,10 @@ export default class DataManager {
113
143
  return getReleaseChangelog(targetDeviceConfigList, currentVersion);
114
144
  };
115
145
 
116
- static getBleFirmwareLeatestRelease = (features: Features) => {
146
+ static getBleFirmwareLatestRelease = (features: Features) => {
117
147
  const deviceType = getDeviceType(features);
118
148
  const targetDeviceConfigList = this.deviceMap[deviceType]?.ble ?? [];
119
- return targetDeviceConfigList[targetDeviceConfigList.length - 1];
149
+ return findLatestRelease(targetDeviceConfigList);
120
150
  };
121
151
 
122
152
  static getTransportStatus = (localVersion: string): ITransportStatus => {
@@ -251,6 +251,13 @@ export class Device extends EventEmitter {
251
251
  return this.commands;
252
252
  }
253
253
 
254
+ private generateStateKey(deviceId: string, passphraseState?: string) {
255
+ if (passphraseState) {
256
+ return `${deviceId}@${passphraseState}`;
257
+ }
258
+ return deviceId;
259
+ }
260
+
254
261
  getInternalState(_deviceId?: string) {
255
262
  Log.debug(
256
263
  'getInternalState session param: ',
@@ -264,19 +271,27 @@ export class Device extends EventEmitter {
264
271
  if (!deviceId) return undefined;
265
272
  if (!this.passphraseState) return undefined;
266
273
 
267
- const usePassKey = `${deviceId}@${this.passphraseState}`;
274
+ const usePassKey = this.generateStateKey(deviceId, this.passphraseState);
275
+ return deviceSessionCache[usePassKey];
276
+ }
268
277
 
269
- if (!deviceSessionCache[usePassKey]) {
270
- const key = `${deviceId}`;
271
- if (deviceSessionCache[key]) {
272
- deviceSessionCache[usePassKey] = deviceSessionCache[key];
273
- }
274
- }
278
+ tryFixInternalState(state: string, deviceId: string) {
279
+ Log.debug(
280
+ 'tryFixInternalState session param: ',
281
+ `device_id: ${deviceId}`,
282
+ `passphraseState: ${state}`
283
+ );
275
284
 
276
- return deviceSessionCache[usePassKey];
285
+ const key = `${deviceId}`;
286
+ const session = deviceSessionCache[key];
287
+ if (session) {
288
+ deviceSessionCache[this.generateStateKey(deviceId, state)] = session;
289
+ delete deviceSessionCache[key];
290
+ }
291
+ Log.debug('tryFixInternalState session cache: ', deviceSessionCache);
277
292
  }
278
293
 
279
- setInternalState(state: string, initSession?: boolean) {
294
+ private setInternalState(state: string, initSession?: boolean) {
280
295
  Log.debug(
281
296
  'setInternalState session param: ',
282
297
  `state: ${state}`,
@@ -288,10 +303,11 @@ export class Device extends EventEmitter {
288
303
  if (!this.features) return;
289
304
  if (!this.passphraseState && !initSession) return;
290
305
 
291
- let key = `${this.features.device_id}`;
292
- if (this.passphraseState) {
293
- key += `@${this.passphraseState}`;
294
- }
306
+ const deviceId = this.features?.device_id;
307
+ if (!deviceId) return;
308
+
309
+ const key = this.generateStateKey(deviceId, this.passphraseState);
310
+
295
311
  if (state) {
296
312
  deviceSessionCache[key] = state;
297
313
  }
@@ -307,7 +323,7 @@ export class Device extends EventEmitter {
307
323
  delete deviceSessionCache[key];
308
324
 
309
325
  if (this.passphraseState) {
310
- const usePassKey = `${deviceId}@${this.passphraseState}`;
326
+ const usePassKey = this.generateStateKey(deviceId, this.passphraseState);
311
327
  delete deviceSessionCache[usePassKey];
312
328
  }
313
329
  }
@@ -1,4 +1,4 @@
1
- import type { Transport, Messages } from '@onekeyfe/hd-transport';
1
+ import type { Transport, Messages, FailureType } from '@onekeyfe/hd-transport';
2
2
  import { ERRORS, HardwareError, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
3
  import TransportManager from '../data-manager/TransportManager';
4
4
  import DataManager from '../data-manager/DataManager';
@@ -146,7 +146,10 @@ export class DeviceCommands {
146
146
  ): Promise<DefaultMessageResponse> {
147
147
  Log.debug('_filterCommonTypes: ', res);
148
148
  if (res.type === 'Failure') {
149
- const { code, message } = res.message;
149
+ const { code, message } = res.message as {
150
+ code?: string | FailureType;
151
+ message?: string;
152
+ };
150
153
  let error: HardwareError | null = null;
151
154
  // Model One does not send any message in firmware update
152
155
  if (code === 'Failure_FirmwareError' && !message) {
package/src/inject.ts CHANGED
@@ -53,12 +53,6 @@ export const inject = ({
53
53
  */
54
54
  getFeatures: connectId => call({ connectId, method: 'getFeatures' }),
55
55
 
56
- /**
57
- * 批量获取公钥
58
- */
59
- batchGetPublicKey: (connectId, deviceId, params) =>
60
- call({ ...params, connectId, deviceId, method: 'batchGetPublicKey' }),
61
-
62
56
  /**
63
57
  * 检查固件版本
64
58
  */
@@ -91,6 +85,8 @@ export const inject = ({
91
85
  deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
92
86
  deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
93
87
  deviceUpdateReboot: connectId => call({ connectId, method: 'deviceUpdateReboot' }),
88
+ deviceUploadResource: (connectId, params) =>
89
+ call({ ...params, connectId, method: 'deviceUploadResource' }),
94
90
  deviceSupportFeatures: connectId => call({ connectId, method: 'deviceSupportFeatures' }),
95
91
  deviceVerify: (connectId, params) => call({ ...params, connectId, method: 'deviceVerify' }),
96
92
  deviceWipe: connectId => call({ connectId, method: 'deviceWipe' }),
@@ -177,6 +173,8 @@ export const inject = ({
177
173
 
178
174
  aptosGetAddress: (connectId, deviceId, params) =>
179
175
  call({ ...params, connectId, deviceId, method: 'aptosGetAddress' }),
176
+ aptosGetPublicKey: (connectId, deviceId, params) =>
177
+ call({ ...params, connectId, deviceId, method: 'aptosGetPublicKey' }),
180
178
  aptosSignTransaction: (connectId, deviceId, params) =>
181
179
  call({ ...params, connectId, deviceId, method: 'aptosSignTransaction' }),
182
180
  };
@@ -0,0 +1,23 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type AptosPublicKey = {
4
+ path: string;
5
+ publicKey: string;
6
+ };
7
+
8
+ export type AptosGetPublicKeyParams = {
9
+ path: string | number[];
10
+ showOnOneKey?: boolean;
11
+ };
12
+
13
+ export declare function aptosGetPublicKey(
14
+ connectId: string,
15
+ deviceId: string,
16
+ params: CommonParams & AptosGetPublicKeyParams
17
+ ): Response<AptosPublicKey>;
18
+
19
+ export declare function aptosGetPublicKey(
20
+ connectId: string,
21
+ deviceId: string,
22
+ params: CommonParams & { bundle?: AptosGetPublicKeyParams[] }
23
+ ): Response<Array<AptosPublicKey>>;
@@ -28,5 +28,5 @@ export type ConfluxSignTransactionParams = {
28
28
  export declare function confluxSignTransaction(
29
29
  connectId: string,
30
30
  deviceId: string,
31
- params: CommonParams & ConfluxTransaction
31
+ params: CommonParams & ConfluxSignTransactionParams
32
32
  ): Response<ConfluxSignedTx>;
@@ -0,0 +1,15 @@
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>;
@@ -20,6 +20,8 @@ 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';
23
25
 
24
26
  export type { EVMAddress, EVMGetAddressParams } from './evmGetAddress';
25
27
  export type { EVMPublicKey, EVMGetPublicKeyParams } from './evmGetPublicKey';
@@ -94,4 +96,5 @@ export type { NearAddress, NearGetAddressParams } from './nearGetAddress';
94
96
  export type { NearSignTransactionParams } from './nearSignTransaction';
95
97
 
96
98
  export type { AptosAddress, AptosGetAddressParams } from './aptosGetAddress';
99
+ export type { AptosPublicKey, AptosGetPublicKeyParams } from './aptosGetPublicKey';
97
100
  export type { AptosSignedTx, AptosSignTransactionParams } from './aptosSignTransaction';
@@ -1,21 +1,21 @@
1
1
  import type { PROTO } from '../../constants';
2
2
  import type { Params, Response } from '../params';
3
3
 
4
- export interface FirmwareUpdateBinary {
4
+ export interface FirmwareUpdateBinaryParams {
5
5
  binary: ArrayBuffer;
6
6
  }
7
7
 
8
- export interface FirmwareUpdate {
9
- version: number[];
8
+ export interface FirmwareUpdateParams {
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<FirmwareUpdate>
16
+ params: Params<FirmwareUpdateParams>
17
17
  ): Response<PROTO.Success>;
18
18
  export declare function firmwareUpdate(
19
19
  connectId: string | undefined,
20
- params: Params<FirmwareUpdateBinary>
20
+ params: Params<FirmwareUpdateBinaryParams>
21
21
  ): Response<PROTO.Success>;
@@ -24,9 +24,9 @@ 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';
27
28
  import { deviceSupportFeatures } from './deviceSupportFeatures';
28
29
 
29
- import { batchGetPublicKey } from './batchGetPublicKey';
30
30
  import { cipherKeyValue } from './cipherKeyValue';
31
31
 
32
32
  import { evmGetAddress } from './evmGetAddress';
@@ -71,6 +71,7 @@ import { nearGetAddress } from './nearGetAddress';
71
71
  import { nearSignTransaction } from './nearSignTransaction';
72
72
 
73
73
  import { aptosGetAddress } from './aptosGetAddress';
74
+ import { aptosGetPublicKey } from './aptosGetPublicKey';
74
75
  import { aptosSignTransaction } from './aptosSignTransaction';
75
76
 
76
77
  export * from './export';
@@ -110,6 +111,7 @@ export type CoreApi = {
110
111
  deviceReset: typeof deviceReset;
111
112
  deviceSettings: typeof deviceSettings;
112
113
  deviceUpdateReboot: typeof deviceUpdateReboot;
114
+ deviceUploadResource: typeof deviceUploadResource;
113
115
  deviceSupportFeatures: typeof deviceSupportFeatures;
114
116
  deviceVerify: typeof deviceVerify;
115
117
  deviceWipe: typeof deviceWipe;
@@ -118,7 +120,6 @@ export type CoreApi = {
118
120
  firmwareUpdate: typeof firmwareUpdate;
119
121
  firmwareUpdateV2: typeof firmwareUpdate;
120
122
 
121
- batchGetPublicKey: typeof batchGetPublicKey;
122
123
  cipherKeyValue: typeof cipherKeyValue;
123
124
 
124
125
  /**
@@ -193,5 +194,6 @@ export type CoreApi = {
193
194
  * Aptos function
194
195
  */
195
196
  aptosGetAddress: typeof aptosGetAddress;
197
+ aptosGetPublicKey: typeof aptosGetPublicKey;
196
198
  aptosSignTransaction: typeof aptosSignTransaction;
197
199
  };
@@ -27,6 +27,8 @@ 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;
30
32
  fingerprint: string;
31
33
  version: IVersionArray;
32
34
  changelog: {
@@ -1,5 +1,10 @@
1
1
  import semver from 'semver';
2
- import { IBLEFirmwareReleaseInfo, IDeviceFirmwareStatus, IFirmwareReleaseInfo } from '../types';
2
+ import {
3
+ IBLEFirmwareReleaseInfo,
4
+ IDeviceFirmwareStatus,
5
+ IFirmwareReleaseInfo,
6
+ IVersionArray,
7
+ } from '../types';
3
8
 
4
9
  export const getReleaseStatus = (
5
10
  releases: (IFirmwareReleaseInfo | IBLEFirmwareReleaseInfo)[],
@@ -22,3 +27,15 @@ export const getReleaseChangelog = (
22
27
  const newVersions = releases.filter(r => semver.gt(r.version.join('.'), currentVersion));
23
28
  return newVersions.map(r => r.changelog);
24
29
  };
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,11 +0,0 @@
1
- import { BaseMethod } from './BaseMethod';
2
- export default class BatchGetPublicKey extends BaseMethod {
3
- init(): void;
4
- getVersionRange(): {
5
- model_mini: {
6
- min: string;
7
- };
8
- };
9
- run(): Promise<any>;
10
- }
11
- //# sourceMappingURL=BatchGetPublicKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BatchGetPublicKey.d.ts","sourceRoot":"","sources":["../../src/api/BatchGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU;IACvD,IAAI;IAaJ,eAAe;;;;;IAQT,GAAG;CAaV"}
@@ -1,11 +0,0 @@
1
- import type { CommonParams, Response } from '../params';
2
- export declare type BatchGetPublicKeyParams = {
3
- paths: string[];
4
- ecdsaCurveName: 'secp256k1' | 'ed25519';
5
- };
6
- export declare type BatchGetPublicKeyResponse = {
7
- path: string;
8
- publicKey: string;
9
- }[];
10
- export declare function batchGetPublicKey(connectId: string, deviceId: string, params: CommonParams & BatchGetPublicKeyParams): Response<BatchGetPublicKeyResponse>;
11
- //# sourceMappingURL=batchGetPublicKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"batchGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/types/api/batchGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,oBAAY,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,EAAE,CAAC;IAKhB,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC;AAE9E,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,uBAAuB,GAC7C,QAAQ,CAAC,yBAAyB,CAAC,CAAC"}
@@ -1,40 +0,0 @@
1
- import { BaseMethod } from './BaseMethod';
2
- import { validateParams } from './helpers/paramsValidator';
3
- import { validatePath, serializedPath } from './helpers/pathUtils';
4
-
5
- export default class BatchGetPublicKey extends BaseMethod {
6
- init() {
7
- this.checkDeviceId = true;
8
- validateParams(this.payload, [
9
- { name: 'paths', type: 'array' },
10
- { name: 'ecdsaCurveName', type: 'string' },
11
- ]);
12
-
13
- this.params = this.payload.paths.map((path: string) => {
14
- const addressN = validatePath(path, 1);
15
- return { address_n: addressN };
16
- });
17
- }
18
-
19
- getVersionRange() {
20
- return {
21
- model_mini: {
22
- min: '2.6.0',
23
- },
24
- };
25
- }
26
-
27
- async run() {
28
- // @ts-expect-error
29
- const res = await this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
30
- paths: this.params,
31
- ecdsa_curve_name: this.payload.ecdsaCurveName ?? 'secp256k1',
32
- });
33
- // @ts-expect-error
34
- const result = res.message.public_keys.map((publicKey: string, index: number) => ({
35
- path: serializedPath((this.params as unknown as any[])[index].address_n),
36
- publicKey,
37
- }));
38
- return Promise.resolve(result);
39
- }
40
- }
@@ -1,18 +0,0 @@
1
- import type { CommonParams, Response } from '../params';
2
-
3
- export type BatchGetPublicKeyParams = {
4
- paths: string[];
5
- /**
6
- * secp256k1 for eth and btc
7
- * ed25519 for sol, stc, aptos
8
- */
9
- ecdsaCurveName: 'secp256k1' | 'ed25519';
10
- };
11
-
12
- export type BatchGetPublicKeyResponse = { path: string; publicKey: string }[];
13
-
14
- export declare function batchGetPublicKey(
15
- connectId: string,
16
- deviceId: string,
17
- params: CommonParams & BatchGetPublicKeyParams
18
- ): Response<BatchGetPublicKeyResponse>;