@onekeyfe/hd-core 1.2.0-alpha.11 → 1.2.0-alpha.13

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 (59) hide show
  1. package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
  2. package/__tests__/protocol-v2.test.ts +240 -82
  3. package/__tests__/protocolV2FileWrite.test.ts +67 -0
  4. package/dist/api/FileWrite.d.ts.map +1 -1
  5. package/dist/api/FirmwareUpdateV4.d.ts +2 -0
  6. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  7. package/dist/api/helpers/protocolV2FileWrite.d.ts +32 -0
  8. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
  9. package/dist/api/index.d.ts +1 -1
  10. package/dist/api/index.d.ts.map +1 -1
  11. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
  12. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
  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/deviceProfile/buildDeviceFeatures.d.ts +2 -2
  17. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  18. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  19. package/dist/index.d.ts +9 -11
  20. package/dist/index.js +736 -391
  21. package/dist/protocols/protocol-v2/features.d.ts +1 -0
  22. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  23. package/dist/protocols/protocol-v2/index.d.ts +1 -1
  24. package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
  25. package/dist/types/api/getDeviceInfo.d.ts +1 -1
  26. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  27. package/dist/types/api/index.d.ts +2 -2
  28. package/dist/types/api/index.d.ts.map +1 -1
  29. package/dist/types/api/protocolV2.d.ts +2 -5
  30. package/dist/types/api/protocolV2.d.ts.map +1 -1
  31. package/dist/types/device.d.ts +3 -2
  32. package/dist/types/device.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/FileWrite.ts +18 -186
  37. package/src/api/FirmwareUpdateV4.ts +46 -6
  38. package/src/api/cardano/CardanoSignMessage.ts +1 -1
  39. package/src/api/cardano/CardanoSignTransaction.ts +1 -1
  40. package/src/api/helpers/protocolV2FileWrite.ts +168 -0
  41. package/src/api/index.ts +1 -1
  42. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
  43. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +22 -52
  44. package/src/api/protocol-v2/helpers.ts +0 -3
  45. package/src/data/messages/messages-protocol-v2.json +422 -16
  46. package/src/data/messages/messages.json +0 -8
  47. package/src/device/Device.ts +7 -17
  48. package/src/deviceProfile/buildDeviceFeatures.ts +28 -12
  49. package/src/deviceProfile/buildDeviceProfile.ts +8 -6
  50. package/src/inject.ts +2 -2
  51. package/src/protocols/protocol-v2/features.ts +19 -1
  52. package/src/protocols/protocol-v2/index.ts +2 -0
  53. package/src/types/api/getDeviceInfo.ts +1 -1
  54. package/src/types/api/index.ts +2 -2
  55. package/src/types/api/protocolV2.ts +6 -6
  56. package/src/types/device.ts +6 -1
  57. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
  58. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
  59. package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
@@ -485,7 +485,6 @@
485
485
  "MessageType_DeviceSessionGet": 60606,
486
486
  "MessageType_DeviceSession": 60607,
487
487
  "MessageType_DeviceSessionAskPin": 60608,
488
- "MessageType_DeviceSessionPinResult": 60609,
489
488
  "MessageType_FilesystemPermissionFix": 60800,
490
489
  "MessageType_FilesystemPathInfo": 60801,
491
490
  "MessageType_FilesystemPathInfoQuery": 60802,
@@ -6161,6 +6160,33 @@
6161
6160
  "PromptTemporarily": 2
6162
6161
  }
6163
6162
  },
6163
+ "Initialize": {
6164
+ "fields": {
6165
+ "session_id": {
6166
+ "type": "bytes",
6167
+ "id": 1
6168
+ },
6169
+ "_skip_passphrase": {
6170
+ "type": "bool",
6171
+ "id": 2,
6172
+ "options": {
6173
+ "deprecated": true
6174
+ }
6175
+ },
6176
+ "derive_cardano": {
6177
+ "type": "bool",
6178
+ "id": 3
6179
+ },
6180
+ "passphrase_state": {
6181
+ "type": "string",
6182
+ "id": 8000
6183
+ },
6184
+ "is_contains_attach": {
6185
+ "type": "bool",
6186
+ "id": 8001
6187
+ }
6188
+ }
6189
+ },
6164
6190
  "StartSession": {
6165
6191
  "fields": {
6166
6192
  "session_id": {
@@ -6183,6 +6209,12 @@
6183
6209
  "EndSession": {
6184
6210
  "fields": {}
6185
6211
  },
6212
+ "GetFeatures": {
6213
+ "fields": {}
6214
+ },
6215
+ "OnekeyGetFeatures": {
6216
+ "fields": {}
6217
+ },
6186
6218
  "OneKeyDeviceType": {
6187
6219
  "values": {
6188
6220
  "CLASSIC": 0,
@@ -6204,6 +6236,388 @@
6204
6236
  "APP": 1
6205
6237
  }
6206
6238
  },
6239
+ "Features": {
6240
+ "fields": {
6241
+ "vendor": {
6242
+ "type": "string",
6243
+ "id": 1
6244
+ },
6245
+ "major_version": {
6246
+ "rule": "required",
6247
+ "type": "uint32",
6248
+ "id": 2
6249
+ },
6250
+ "minor_version": {
6251
+ "rule": "required",
6252
+ "type": "uint32",
6253
+ "id": 3
6254
+ },
6255
+ "patch_version": {
6256
+ "rule": "required",
6257
+ "type": "uint32",
6258
+ "id": 4
6259
+ },
6260
+ "bootloader_mode": {
6261
+ "type": "bool",
6262
+ "id": 5
6263
+ },
6264
+ "device_id": {
6265
+ "type": "string",
6266
+ "id": 6
6267
+ },
6268
+ "pin_protection": {
6269
+ "type": "bool",
6270
+ "id": 7
6271
+ },
6272
+ "passphrase_protection": {
6273
+ "type": "bool",
6274
+ "id": 8
6275
+ },
6276
+ "language": {
6277
+ "type": "string",
6278
+ "id": 9
6279
+ },
6280
+ "label": {
6281
+ "type": "string",
6282
+ "id": 10
6283
+ },
6284
+ "initialized": {
6285
+ "type": "bool",
6286
+ "id": 12
6287
+ },
6288
+ "revision": {
6289
+ "type": "bytes",
6290
+ "id": 13
6291
+ },
6292
+ "bootloader_hash": {
6293
+ "type": "bytes",
6294
+ "id": 14
6295
+ },
6296
+ "imported": {
6297
+ "type": "bool",
6298
+ "id": 15
6299
+ },
6300
+ "unlocked": {
6301
+ "type": "bool",
6302
+ "id": 16
6303
+ },
6304
+ "_passphrase_cached": {
6305
+ "type": "bool",
6306
+ "id": 17,
6307
+ "options": {
6308
+ "deprecated": true
6309
+ }
6310
+ },
6311
+ "firmware_present": {
6312
+ "type": "bool",
6313
+ "id": 18
6314
+ },
6315
+ "needs_backup": {
6316
+ "type": "bool",
6317
+ "id": 19
6318
+ },
6319
+ "flags": {
6320
+ "type": "uint32",
6321
+ "id": 20
6322
+ },
6323
+ "model": {
6324
+ "type": "string",
6325
+ "id": 21
6326
+ },
6327
+ "fw_major": {
6328
+ "type": "uint32",
6329
+ "id": 22
6330
+ },
6331
+ "fw_minor": {
6332
+ "type": "uint32",
6333
+ "id": 23
6334
+ },
6335
+ "fw_patch": {
6336
+ "type": "uint32",
6337
+ "id": 24
6338
+ },
6339
+ "fw_vendor": {
6340
+ "type": "string",
6341
+ "id": 25
6342
+ },
6343
+ "unfinished_backup": {
6344
+ "type": "bool",
6345
+ "id": 27
6346
+ },
6347
+ "no_backup": {
6348
+ "type": "bool",
6349
+ "id": 28
6350
+ },
6351
+ "recovery_mode": {
6352
+ "type": "bool",
6353
+ "id": 29
6354
+ },
6355
+ "capabilities": {
6356
+ "rule": "repeated",
6357
+ "type": "Capability",
6358
+ "id": 30,
6359
+ "options": {
6360
+ "packed": false
6361
+ }
6362
+ },
6363
+ "backup_type": {
6364
+ "type": "BackupType",
6365
+ "id": 31
6366
+ },
6367
+ "sd_card_present": {
6368
+ "type": "bool",
6369
+ "id": 32
6370
+ },
6371
+ "sd_protection": {
6372
+ "type": "bool",
6373
+ "id": 33
6374
+ },
6375
+ "wipe_code_protection": {
6376
+ "type": "bool",
6377
+ "id": 34
6378
+ },
6379
+ "session_id": {
6380
+ "type": "bytes",
6381
+ "id": 35
6382
+ },
6383
+ "passphrase_always_on_device": {
6384
+ "type": "bool",
6385
+ "id": 36
6386
+ },
6387
+ "safety_checks": {
6388
+ "type": "SafetyCheckLevel",
6389
+ "id": 37
6390
+ },
6391
+ "auto_lock_delay_ms": {
6392
+ "type": "uint32",
6393
+ "id": 38
6394
+ },
6395
+ "display_rotation": {
6396
+ "type": "uint32",
6397
+ "id": 39
6398
+ },
6399
+ "experimental_features": {
6400
+ "type": "bool",
6401
+ "id": 40
6402
+ },
6403
+ "offset": {
6404
+ "type": "uint32",
6405
+ "id": 500
6406
+ },
6407
+ "coprocessor_bt_name": {
6408
+ "type": "string",
6409
+ "id": 501
6410
+ },
6411
+ "coprocessor_version": {
6412
+ "type": "string",
6413
+ "id": 502
6414
+ },
6415
+ "coprocessor_bt_enable": {
6416
+ "type": "bool",
6417
+ "id": 503
6418
+ },
6419
+ "se_enable": {
6420
+ "type": "bool",
6421
+ "id": 504
6422
+ },
6423
+ "se_ver": {
6424
+ "type": "string",
6425
+ "id": 506
6426
+ },
6427
+ "backup_only": {
6428
+ "type": "bool",
6429
+ "id": 507
6430
+ },
6431
+ "onekey_version": {
6432
+ "type": "string",
6433
+ "id": 508
6434
+ },
6435
+ "onekey_serial": {
6436
+ "type": "string",
6437
+ "id": 509
6438
+ },
6439
+ "bootloader_version": {
6440
+ "type": "string",
6441
+ "id": 510
6442
+ },
6443
+ "serial_no": {
6444
+ "type": "string",
6445
+ "id": 511
6446
+ },
6447
+ "spi_flash": {
6448
+ "type": "string",
6449
+ "id": 512
6450
+ },
6451
+ "initstates": {
6452
+ "type": "uint32",
6453
+ "id": 513
6454
+ },
6455
+ "NFT_voucher": {
6456
+ "type": "bytes",
6457
+ "id": 514
6458
+ },
6459
+ "cpu_info": {
6460
+ "type": "string",
6461
+ "id": 515
6462
+ },
6463
+ "pre_firmware": {
6464
+ "type": "string",
6465
+ "id": 516
6466
+ },
6467
+ "coin_switch": {
6468
+ "type": "uint32",
6469
+ "id": 517
6470
+ },
6471
+ "build_id": {
6472
+ "type": "bytes",
6473
+ "id": 518
6474
+ },
6475
+ "romloader_version": {
6476
+ "type": "string",
6477
+ "id": 519
6478
+ },
6479
+ "busy": {
6480
+ "type": "bool",
6481
+ "id": 41
6482
+ },
6483
+ "onekey_device_type": {
6484
+ "type": "OneKeyDeviceType",
6485
+ "id": 600
6486
+ },
6487
+ "onekey_se_type": {
6488
+ "type": "OneKeySeType",
6489
+ "id": 601
6490
+ },
6491
+ "onekey_romloader_version": {
6492
+ "type": "string",
6493
+ "id": 602
6494
+ },
6495
+ "onekey_romloader_hash": {
6496
+ "type": "bytes",
6497
+ "id": 603
6498
+ },
6499
+ "onekey_bootloader_version": {
6500
+ "type": "string",
6501
+ "id": 604
6502
+ },
6503
+ "onekey_bootloader_hash": {
6504
+ "type": "bytes",
6505
+ "id": 605
6506
+ },
6507
+ "onekey_se01_version": {
6508
+ "type": "string",
6509
+ "id": 606
6510
+ },
6511
+ "onekey_se01_hash": {
6512
+ "type": "bytes",
6513
+ "id": 607
6514
+ },
6515
+ "onekey_se01_build_id": {
6516
+ "type": "string",
6517
+ "id": 608
6518
+ },
6519
+ "onekey_firmware_version": {
6520
+ "type": "string",
6521
+ "id": 609
6522
+ },
6523
+ "onekey_firmware_hash": {
6524
+ "type": "bytes",
6525
+ "id": 610
6526
+ },
6527
+ "onekey_firmware_build_id": {
6528
+ "type": "string",
6529
+ "id": 611
6530
+ },
6531
+ "onekey_serial_no": {
6532
+ "type": "string",
6533
+ "id": 612
6534
+ },
6535
+ "onekey_bootloader_build_id": {
6536
+ "type": "string",
6537
+ "id": 613
6538
+ },
6539
+ "onekey_coprocessor_bt_name": {
6540
+ "type": "string",
6541
+ "id": 614
6542
+ },
6543
+ "onekey_coprocessor_version": {
6544
+ "type": "string",
6545
+ "id": 615
6546
+ },
6547
+ "onekey_coprocessor_build_id": {
6548
+ "type": "string",
6549
+ "id": 616
6550
+ },
6551
+ "onekey_coprocessor_hash": {
6552
+ "type": "bytes",
6553
+ "id": 617
6554
+ },
6555
+ "onekey_se02_version": {
6556
+ "type": "string",
6557
+ "id": 618
6558
+ },
6559
+ "onekey_se03_version": {
6560
+ "type": "string",
6561
+ "id": 619
6562
+ },
6563
+ "onekey_se04_version": {
6564
+ "type": "string",
6565
+ "id": 620
6566
+ },
6567
+ "onekey_se01_state": {
6568
+ "type": "OneKeySEState",
6569
+ "id": 621
6570
+ },
6571
+ "onekey_se02_state": {
6572
+ "type": "OneKeySEState",
6573
+ "id": 622
6574
+ },
6575
+ "onekey_se03_state": {
6576
+ "type": "OneKeySEState",
6577
+ "id": 623
6578
+ },
6579
+ "onekey_se04_state": {
6580
+ "type": "OneKeySEState",
6581
+ "id": 624
6582
+ },
6583
+ "attach_to_pin_user": {
6584
+ "type": "bool",
6585
+ "id": 625
6586
+ },
6587
+ "unlocked_attach_pin": {
6588
+ "type": "bool",
6589
+ "id": 626
6590
+ }
6591
+ },
6592
+ "nested": {
6593
+ "Capability": {
6594
+ "options": {
6595
+ "(has_bitcoin_only_values)": true
6596
+ },
6597
+ "values": {
6598
+ "Capability_Bitcoin": 1,
6599
+ "Capability_Bitcoin_like": 2,
6600
+ "Capability_Binance": 3,
6601
+ "Capability_Cardano": 4,
6602
+ "Capability_Crypto": 5,
6603
+ "Capability_EOS": 6,
6604
+ "Capability_Ethereum": 7,
6605
+ "Capability_Lisk": 8,
6606
+ "Capability_Monero": 9,
6607
+ "Capability_NEM": 10,
6608
+ "Capability_Ripple": 11,
6609
+ "Capability_Stellar": 12,
6610
+ "Capability_Tezos": 13,
6611
+ "Capability_U2F": 14,
6612
+ "Capability_Shamir": 15,
6613
+ "Capability_ShamirGroups": 16,
6614
+ "Capability_PassphraseEntry": 17,
6615
+ "Capability_AttachToPin": 18,
6616
+ "Capability_EthereumTypedData": 1000
6617
+ }
6618
+ }
6619
+ }
6620
+ },
6207
6621
  "OnekeyFeatures": {
6208
6622
  "fields": {
6209
6623
  "onekey_device_type": {
@@ -11169,7 +11583,10 @@
11169
11583
  "ViewSignLayout": {
11170
11584
  "values": {
11171
11585
  "LayoutDefault": 0,
11172
- "LayoutSafeTxCreate": 1
11586
+ "LayoutSafeTxCreate": 1,
11587
+ "LayoutFinalConfirm": 2,
11588
+ "Layout7702": 3,
11589
+ "LayoutFlat": 4
11173
11590
  }
11174
11591
  },
11175
11592
  "ViewSignPage": {
@@ -12024,20 +12441,9 @@
12024
12441
  "DeviceSessionAskPin": {
12025
12442
  "fields": {}
12026
12443
  },
12027
- "DeviceSessionPinResult": {
12028
- "fields": {
12029
- "unlocked": {
12030
- "type": "bool",
12031
- "id": 1
12032
- },
12033
- "unlocked_attach_pin": {
12034
- "type": "bool",
12035
- "id": 2
12036
- },
12037
- "passphrase_protection": {
12038
- "type": "bool",
12039
- "id": 3
12040
- }
12444
+ "DeviceSessionAskPin_FailureSubCodes": {
12445
+ "values": {
12446
+ "UserCancel": 1
12041
12447
  }
12042
12448
  },
12043
12449
  "DeviceStatus": {
@@ -7784,14 +7784,6 @@
7784
7784
  "passphrase_state": {
7785
7785
  "type": "string",
7786
7786
  "id": 1
7787
- },
7788
- "_only_main_pin": {
7789
- "type": "bool",
7790
- "id": 2
7791
- },
7792
- "allow_create_attach_pin": {
7793
- "type": "bool",
7794
- "id": 3
7795
7787
  }
7796
7788
  }
7797
7789
  },
@@ -67,7 +67,6 @@ import type { PassphrasePromptResponse } from './DeviceCommands';
67
67
  import type { Deferred, HardwareConnectProtocol } from '@onekeyfe/hd-shared';
68
68
  import type {
69
69
  OneKeyDeviceInfo as DeviceDescriptor,
70
- DeviceSessionPinResult,
71
70
  DeviceStatus,
72
71
  ProtocolV2DeviceInfo,
73
72
  Success,
@@ -1139,7 +1138,7 @@ export class Device extends EventEmitter {
1139
1138
  // both allow and require cases might generate single unexpected mode
1140
1139
  if (!this.isUnacquired()) {
1141
1140
  // allow cases
1142
- if (this.isBootloader() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
1141
+ if (this.isBootloader() && !this.isProtocolV2() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
1143
1142
  return UI_REQUEST.BOOTLOADER;
1144
1143
  }
1145
1144
  if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
@@ -1190,12 +1189,8 @@ export class Device extends EventEmitter {
1190
1189
 
1191
1190
  async unlockDevice() {
1192
1191
  if (this.isProtocolV2()) {
1193
- let pinResult: DeviceSessionPinResult;
1194
1192
  try {
1195
- ({ message: pinResult } = await this.commands.typedCall(
1196
- 'DeviceSessionAskPin',
1197
- 'DeviceSessionPinResult'
1198
- ));
1193
+ await this.commands.typedCall('DeviceSessionAskPin', 'Success');
1199
1194
  } catch (error) {
1200
1195
  const errorText =
1201
1196
  error instanceof Error
@@ -1207,16 +1202,11 @@ export class Device extends EventEmitter {
1207
1202
  throw error;
1208
1203
  }
1209
1204
 
1210
- const status: DeviceStatus = {};
1211
- if (pinResult.unlocked != null) {
1212
- status.unlocked = pinResult.unlocked;
1213
- }
1214
- if (pinResult.unlocked_attach_pin != null) {
1215
- status.unlocked_by_attach_to_pin = pinResult.unlocked_attach_pin;
1216
- }
1217
- if (pinResult.passphrase_protection != null) {
1218
- status.passphrase_enabled = pinResult.passphrase_protection;
1219
- }
1205
+ const { message: status } = await this.commands.typedCall(
1206
+ 'DeviceStatusGet',
1207
+ 'DeviceStatus',
1208
+ {}
1209
+ );
1220
1210
  return this.updateProtocolV2Status(status);
1221
1211
  }
1222
1212
 
@@ -1,9 +1,13 @@
1
1
  import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
2
2
 
3
- import type { Features } from '../types';
4
- import type { PROTO } from '../constants';
3
+ import {
4
+ isProtocolV2BootloaderDeviceInfo,
5
+ isProtocolV2RomloaderDeviceInfo,
6
+ } from '../protocols/protocol-v2/features';
7
+
5
8
  import type { DeviceFirmwareImageInfo, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
6
- import { isProtocolV2BootloaderDeviceInfo } from '../protocols/protocol-v2/features';
9
+ import type { PROTO } from '../constants';
10
+ import type { DeviceFeaturesMode, Features } from '../types';
7
11
 
8
12
  type ProtocolV1FeaturesCompat = PROTO.Features &
9
13
  Partial<PROTO.OnekeyFeatures> & {
@@ -131,6 +135,7 @@ export const buildProtocolV1FeaturesPayload = (
131
135
  const sessionId = features.session_id ?? previous?.sessionId ?? null;
132
136
 
133
137
  return {
138
+ ...features,
134
139
  protocol: 'V1',
135
140
  protocolVersion: features.protocol_version ?? previous?.protocolVersion ?? 1,
136
141
  deviceType,
@@ -203,8 +208,9 @@ export const buildProtocolV1FeaturesPayload = (
203
208
  se04BootHash: features.onekey_se04_boot_hash,
204
209
  },
205
210
  sessionId,
211
+ session_id: sessionId ?? undefined,
206
212
  raw: {
207
- protocolV1Features: protocolV1Features,
213
+ protocolV1Features,
208
214
  },
209
215
  };
210
216
  };
@@ -223,7 +229,7 @@ export const buildProtocolV2FeaturesPayload = (
223
229
  const info = deviceInfo;
224
230
  const fwApplication = info?.fw?.application;
225
231
  const fwBootloader = info?.fw?.bootloader;
226
- const fwBoard = firstValue(info?.fw?.application_data, info?.fw?.romloader);
232
+ const fwBoard = info?.fw?.romloader;
227
233
  const bleApplication = info?.coprocessor?.application;
228
234
  const status = info?.status;
229
235
 
@@ -249,14 +255,18 @@ export const buildProtocolV2FeaturesPayload = (
249
255
  const unlocked = firstValue(status?.unlocked, previous?.unlocked) ?? null;
250
256
  const attachToPinEnabled = status?.attach_to_pin_enabled ?? null;
251
257
  const unlockedAttachPin = status?.unlocked_by_attach_to_pin ?? undefined;
258
+ const romloaderMode = isProtocolV2RomloaderDeviceInfo(info);
252
259
  const bootloaderMode = isProtocolV2BootloaderDeviceInfo(info);
253
- const mode = bootloaderMode
254
- ? 'bootloader'
255
- : initialized === false
256
- ? 'notInitialized'
257
- : initialized === true
258
- ? 'normal'
259
- : 'unknown';
260
+ let mode: DeviceFeaturesMode = 'unknown';
261
+ if (romloaderMode) {
262
+ mode = 'romloader';
263
+ } else if (bootloaderMode) {
264
+ mode = 'bootloader';
265
+ } else if (initialized === false) {
266
+ mode = 'notInitialized';
267
+ } else if (initialized === true) {
268
+ mode = 'normal';
269
+ }
260
270
 
261
271
  return {
262
272
  protocol: 'V2',
@@ -356,6 +366,12 @@ export const buildProtocolV2FeaturesPayload = (
356
366
  se04BootHash: getImageHash(info?.se4?.bootloader) ?? previous?.verify?.se04BootHash,
357
367
  },
358
368
  sessionId: previous?.sessionId ?? null,
369
+ device_id: deviceId ?? undefined,
370
+ session_id: previous?.sessionId ?? undefined,
371
+ ble_name: bleName ?? undefined,
372
+ onekey_device_type: 'PRO2',
373
+ passphrase_protection: passphraseProtection ?? undefined,
374
+ bootloader_mode: bootloaderMode,
359
375
  passphraseState: previous?.passphraseState,
360
376
  unlockedAttachPin,
361
377
  raw: {
@@ -13,6 +13,10 @@ import {
13
13
  getDeviceUUID,
14
14
  getFirmwareType,
15
15
  } from '../utils/deviceInfoUtils';
16
+ import {
17
+ isProtocolV2BootloaderDeviceInfo,
18
+ isProtocolV2RomloaderDeviceInfo,
19
+ } from '../protocols/protocol-v2/features';
16
20
 
17
21
  import type {
18
22
  DeviceInfoProtocol,
@@ -26,7 +30,6 @@ import type {
26
30
  } from '../types/api/getDeviceInfo';
27
31
  import type { Features, OnekeyFeatures } from '../types';
28
32
  import type { DeviceFirmwareImageInfo, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
29
- import { isProtocolV2BootloaderDeviceInfo } from '../protocols/protocol-v2/features';
30
33
 
31
34
  type BuildProtocolV1ProfileParams = {
32
35
  protocol?: DeviceInfoProtocol;
@@ -87,6 +90,7 @@ const getDeviceMode = (features?: Features): DeviceInfoStatus['mode'] => {
87
90
  };
88
91
 
89
92
  const getProtocolV2Mode = (deviceInfo?: ProtocolV2DeviceInfo): DeviceInfoStatus['mode'] => {
93
+ if (isProtocolV2RomloaderDeviceInfo(deviceInfo)) return 'romloader';
90
94
  if (isProtocolV2BootloaderDeviceInfo(deviceInfo)) return 'bootloader';
91
95
  const initialized = deviceInfo?.status?.init_states;
92
96
  if (initialized === false) return 'notInitialized';
@@ -154,9 +158,7 @@ const normalizeV2Versions = (deviceInfo?: ProtocolV2DeviceInfo): DeviceProfileVe
154
158
  return {
155
159
  firmware: firstMeaningfulVersion(getImageVersion(info?.fw?.application)),
156
160
  bootloader: firstMeaningfulVersion(getImageVersion(info?.fw?.bootloader)),
157
- board: firstMeaningfulVersion(
158
- getImageVersion(info?.fw?.application_data ?? info?.fw?.romloader)
159
- ),
161
+ board: firstMeaningfulVersion(getImageVersion(info?.fw?.romloader)),
160
162
  ble: firstMeaningfulVersion(getImageVersion(info?.coprocessor?.application)),
161
163
  se01: firstMeaningfulVersion(getImageVersion(info?.se1?.application)),
162
164
  se02: firstMeaningfulVersion(getImageVersion(info?.se2?.application)),
@@ -245,8 +247,8 @@ const normalizeV2Verify = (deviceInfo?: ProtocolV2DeviceInfo): DeviceProfileVeri
245
247
  firmwareHash: getImageHash(info?.fw?.application),
246
248
  bootloaderBuildId: getImageBuildId(info?.fw?.bootloader),
247
249
  bootloaderHash: getImageHash(info?.fw?.bootloader),
248
- boardBuildId: getImageBuildId(info?.fw?.application_data ?? info?.fw?.romloader),
249
- boardHash: getImageHash(info?.fw?.application_data ?? info?.fw?.romloader),
250
+ boardBuildId: getImageBuildId(info?.fw?.romloader),
251
+ boardHash: getImageHash(info?.fw?.romloader),
250
252
  bleBuildId: getImageBuildId(info?.coprocessor?.application),
251
253
  bleHash: getImageHash(info?.coprocessor?.application),
252
254
  se01BuildId: getImageBuildId(info?.se1?.application),
package/src/inject.ts CHANGED
@@ -162,6 +162,8 @@ export const createCoreApi = (
162
162
  deviceReboot: (connectId, params) => call({ ...params, connectId, method: 'deviceReboot' }),
163
163
  deviceInfoGet: (connectId, params) => call({ ...params, connectId, method: 'deviceInfoGet' }),
164
164
  deviceStatusGet: (connectId, params) => call({ ...params, connectId, method: 'deviceStatusGet' }),
165
+ deviceGetOnboardingStatus: (connectId, params) =>
166
+ call({ ...params, connectId, method: 'deviceGetOnboardingStatus' }),
165
167
  deviceSessionGet: (connectId, params) =>
166
168
  call({ ...params, connectId, method: 'deviceSessionGet' }),
167
169
  deviceFirmwareUpdate: (connectId, params) =>
@@ -205,8 +207,6 @@ export const createCoreApi = (
205
207
  filesystemPathInfoQuery: (connectId, params) =>
206
208
  call({ ...params, connectId, method: 'filesystemPathInfoQuery' }),
207
209
  filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
208
- filesystemDiskControl: (connectId, params) =>
209
- call({ ...params, connectId, method: 'filesystemDiskControl' }),
210
210
  deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
211
211
  deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
212
212
  deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),