@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.
- package/__tests__/DeviceCommands.test.ts +47 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
- package/__tests__/protocol-v2.test.ts +146 -58
- package/__tests__/protocolV2FileWrite.test.ts +12 -0
- package/dist/api/FileWrite.d.ts +1 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +2 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.js +524 -168
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +1 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +0 -4
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +2 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FileWrite.ts +3 -1
- package/src/api/FirmwareUpdateV4.ts +46 -6
- package/src/api/UploadPortfolio.ts +3 -1
- package/src/api/cardano/CardanoSignMessage.ts +1 -1
- package/src/api/cardano/CardanoSignTransaction.ts +1 -1
- package/src/api/helpers/protocolV2FileWrite.ts +10 -6
- package/src/api/index.ts +0 -1
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +9 -3
- package/src/api/protocol-v2/helpers.ts +0 -3
- package/src/data/messages/messages-protocol-v2.json +422 -16
- package/src/data/messages/messages.json +0 -8
- package/src/device/Device.ts +7 -17
- package/src/device/DeviceCommands.ts +3 -1
- package/src/deviceProfile/buildDeviceFeatures.ts +8 -0
- package/src/inject.ts +0 -2
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +1 -11
- package/src/protocols/protocol-v2/walletSession.ts +25 -10
- package/src/types/api/index.ts +0 -2
- package/src/types/api/protocolV2.ts +0 -6
- package/src/types/device.ts +5 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- 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
|
-
"
|
|
12028
|
-
"
|
|
12029
|
-
"
|
|
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": {
|
package/src/device/Device.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
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
|
|
|
@@ -578,7 +578,9 @@ export class DeviceCommands {
|
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
if (code === 'Failure_ProcessError') {
|
|
581
|
-
|
|
581
|
+
const isLegacyProtocolV2LockedFailure =
|
|
582
|
+
this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(message?.trim() ?? '');
|
|
583
|
+
if (subcode === 9 || isLegacyProtocolV2LockedFailure) {
|
|
582
584
|
error = ERRORS.TypedError(HardwareErrorCode.DeviceLocked, message, {
|
|
583
585
|
failureCode: code,
|
|
584
586
|
subcode,
|
|
@@ -135,6 +135,7 @@ export const buildProtocolV1FeaturesPayload = (
|
|
|
135
135
|
const sessionId = features.session_id ?? previous?.sessionId ?? null;
|
|
136
136
|
|
|
137
137
|
return {
|
|
138
|
+
...features,
|
|
138
139
|
protocol: 'V1',
|
|
139
140
|
protocolVersion: features.protocol_version ?? previous?.protocolVersion ?? 1,
|
|
140
141
|
deviceType,
|
|
@@ -207,6 +208,7 @@ export const buildProtocolV1FeaturesPayload = (
|
|
|
207
208
|
se04BootHash: features.onekey_se04_boot_hash,
|
|
208
209
|
},
|
|
209
210
|
sessionId,
|
|
211
|
+
session_id: sessionId ?? undefined,
|
|
210
212
|
raw: {
|
|
211
213
|
protocolV1Features,
|
|
212
214
|
},
|
|
@@ -364,6 +366,12 @@ export const buildProtocolV2FeaturesPayload = (
|
|
|
364
366
|
se04BootHash: getImageHash(info?.se4?.bootloader) ?? previous?.verify?.se04BootHash,
|
|
365
367
|
},
|
|
366
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,
|
|
367
375
|
passphraseState: previous?.passphraseState,
|
|
368
376
|
unlockedAttachPin,
|
|
369
377
|
raw: {
|
package/src/inject.ts
CHANGED
|
@@ -207,8 +207,6 @@ export const createCoreApi = (
|
|
|
207
207
|
filesystemPathInfoQuery: (connectId, params) =>
|
|
208
208
|
call({ ...params, connectId, method: 'filesystemPathInfoQuery' }),
|
|
209
209
|
filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
|
|
210
|
-
filesystemDiskControl: (connectId, params) =>
|
|
211
|
-
call({ ...params, connectId, method: 'filesystemDiskControl' }),
|
|
212
210
|
deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
|
|
213
211
|
deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
|
|
214
212
|
deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
export function isDeviceLockedError(error: unknown): boolean {
|
|
4
|
+
return (
|
|
5
|
+
typeof error === 'object' &&
|
|
6
|
+
error !== null &&
|
|
7
|
+
'errorCode' in error &&
|
|
8
|
+
error.errorCode === HardwareErrorCode.DeviceLocked
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
1
|
import { LoggerNames, getLogger } from '../../utils';
|
|
2
|
+
import { isDeviceLockedError } from './lockedError';
|
|
4
3
|
|
|
5
4
|
import type { BaseMethod } from '../../api/BaseMethod';
|
|
6
5
|
import type { Device } from '../../device/Device';
|
|
@@ -10,15 +9,6 @@ const Log = getLogger(LoggerNames.Core);
|
|
|
10
9
|
type RunnableMethod = Pick<BaseMethod, 'run' | 'unlockPolicy'> & { name?: string };
|
|
11
10
|
type UnlockableDevice = Pick<Device, 'isProtocolV2' | 'unlockDevice'>;
|
|
12
11
|
|
|
13
|
-
function isDeviceLockedError(error: unknown): boolean {
|
|
14
|
-
return (
|
|
15
|
-
typeof error === 'object' &&
|
|
16
|
-
error !== null &&
|
|
17
|
-
'errorCode' in error &&
|
|
18
|
-
error.errorCode === HardwareErrorCode.DeviceLocked
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
12
|
export async function runMethodWithUnlockRetry(method: RunnableMethod, device: UnlockableDevice) {
|
|
23
13
|
try {
|
|
24
14
|
return await method.run();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
|
+
import { isDeviceLockedError } from './lockedError';
|
|
4
|
+
|
|
3
5
|
import type { Device } from '../../device/Device';
|
|
4
6
|
|
|
5
7
|
const getErrorText = (error: unknown) => {
|
|
@@ -31,15 +33,11 @@ export async function getProtocolV2WalletSession(
|
|
|
31
33
|
device: Device,
|
|
32
34
|
options?: { initSession?: boolean; expectedPassphraseState?: string }
|
|
33
35
|
) {
|
|
34
|
-
if (device.features?.unlocked === false) {
|
|
35
|
-
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Device is locked');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
36
|
if (options?.initSession) {
|
|
39
37
|
device.clearInternalState();
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
let sessionId =
|
|
43
41
|
typeof device.getInternalState === 'function' ? device.getInternalState() : undefined;
|
|
44
42
|
|
|
45
43
|
try {
|
|
@@ -50,13 +48,30 @@ export async function getProtocolV2WalletSession(
|
|
|
50
48
|
sessionId ? { session_id: sessionId } : {}
|
|
51
49
|
);
|
|
52
50
|
|
|
53
|
-
const
|
|
54
|
-
|
|
51
|
+
const requestWalletSession = async () => {
|
|
52
|
+
try {
|
|
53
|
+
return await requestDeviceSession(sessionId);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (!sessionId || !isProtocolV2InvalidSessionError(error)) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
device.clearInternalState();
|
|
59
|
+
sessionId = undefined;
|
|
60
|
+
return requestDeviceSession();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
let response;
|
|
65
|
+
try {
|
|
66
|
+
response = await requestWalletSession();
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (!isDeviceLockedError(error)) {
|
|
55
69
|
throw error;
|
|
56
70
|
}
|
|
57
|
-
device.
|
|
58
|
-
|
|
59
|
-
}
|
|
71
|
+
await device.unlockDevice();
|
|
72
|
+
response = await requestWalletSession();
|
|
73
|
+
}
|
|
74
|
+
const { message } = response;
|
|
60
75
|
|
|
61
76
|
if (
|
|
62
77
|
options?.expectedPassphraseState &&
|