@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
package/dist/index.js
CHANGED
|
@@ -172,7 +172,6 @@ const createCoreApi = (call) => ({
|
|
|
172
172
|
filesystemDirRemove: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDirRemove' })),
|
|
173
173
|
filesystemPathInfoQuery: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemPathInfoQuery' })),
|
|
174
174
|
filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
|
|
175
|
-
filesystemDiskControl: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDiskControl' })),
|
|
176
175
|
deviceRecovery: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceRecovery' })),
|
|
177
176
|
deviceReset: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceReset' })),
|
|
178
177
|
deviceSettings: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettings' })),
|
|
@@ -9288,14 +9287,6 @@ var nested$2 = {
|
|
|
9288
9287
|
passphrase_state: {
|
|
9289
9288
|
type: "string",
|
|
9290
9289
|
id: 1
|
|
9291
|
-
},
|
|
9292
|
-
_only_main_pin: {
|
|
9293
|
-
type: "bool",
|
|
9294
|
-
id: 2
|
|
9295
|
-
},
|
|
9296
|
-
allow_create_attach_pin: {
|
|
9297
|
-
type: "bool",
|
|
9298
|
-
id: 3
|
|
9299
9290
|
}
|
|
9300
9291
|
}
|
|
9301
9292
|
},
|
|
@@ -25791,7 +25782,6 @@ var nested = {
|
|
|
25791
25782
|
MessageType_DeviceSessionGet: 60606,
|
|
25792
25783
|
MessageType_DeviceSession: 60607,
|
|
25793
25784
|
MessageType_DeviceSessionAskPin: 60608,
|
|
25794
|
-
MessageType_DeviceSessionPinResult: 60609,
|
|
25795
25785
|
MessageType_FilesystemPermissionFix: 60800,
|
|
25796
25786
|
MessageType_FilesystemPathInfo: 60801,
|
|
25797
25787
|
MessageType_FilesystemPathInfoQuery: 60802,
|
|
@@ -31485,6 +31475,33 @@ var nested = {
|
|
|
31485
31475
|
PromptTemporarily: 2
|
|
31486
31476
|
}
|
|
31487
31477
|
},
|
|
31478
|
+
Initialize: {
|
|
31479
|
+
fields: {
|
|
31480
|
+
session_id: {
|
|
31481
|
+
type: "bytes",
|
|
31482
|
+
id: 1
|
|
31483
|
+
},
|
|
31484
|
+
_skip_passphrase: {
|
|
31485
|
+
type: "bool",
|
|
31486
|
+
id: 2,
|
|
31487
|
+
options: {
|
|
31488
|
+
deprecated: true
|
|
31489
|
+
}
|
|
31490
|
+
},
|
|
31491
|
+
derive_cardano: {
|
|
31492
|
+
type: "bool",
|
|
31493
|
+
id: 3
|
|
31494
|
+
},
|
|
31495
|
+
passphrase_state: {
|
|
31496
|
+
type: "string",
|
|
31497
|
+
id: 8000
|
|
31498
|
+
},
|
|
31499
|
+
is_contains_attach: {
|
|
31500
|
+
type: "bool",
|
|
31501
|
+
id: 8001
|
|
31502
|
+
}
|
|
31503
|
+
}
|
|
31504
|
+
},
|
|
31488
31505
|
StartSession: {
|
|
31489
31506
|
fields: {
|
|
31490
31507
|
session_id: {
|
|
@@ -31508,6 +31525,14 @@ var nested = {
|
|
|
31508
31525
|
fields: {
|
|
31509
31526
|
}
|
|
31510
31527
|
},
|
|
31528
|
+
GetFeatures: {
|
|
31529
|
+
fields: {
|
|
31530
|
+
}
|
|
31531
|
+
},
|
|
31532
|
+
OnekeyGetFeatures: {
|
|
31533
|
+
fields: {
|
|
31534
|
+
}
|
|
31535
|
+
},
|
|
31511
31536
|
OneKeyDeviceType: {
|
|
31512
31537
|
values: {
|
|
31513
31538
|
CLASSIC: 0,
|
|
@@ -31529,6 +31554,388 @@ var nested = {
|
|
|
31529
31554
|
APP: 1
|
|
31530
31555
|
}
|
|
31531
31556
|
},
|
|
31557
|
+
Features: {
|
|
31558
|
+
fields: {
|
|
31559
|
+
vendor: {
|
|
31560
|
+
type: "string",
|
|
31561
|
+
id: 1
|
|
31562
|
+
},
|
|
31563
|
+
major_version: {
|
|
31564
|
+
rule: "required",
|
|
31565
|
+
type: "uint32",
|
|
31566
|
+
id: 2
|
|
31567
|
+
},
|
|
31568
|
+
minor_version: {
|
|
31569
|
+
rule: "required",
|
|
31570
|
+
type: "uint32",
|
|
31571
|
+
id: 3
|
|
31572
|
+
},
|
|
31573
|
+
patch_version: {
|
|
31574
|
+
rule: "required",
|
|
31575
|
+
type: "uint32",
|
|
31576
|
+
id: 4
|
|
31577
|
+
},
|
|
31578
|
+
bootloader_mode: {
|
|
31579
|
+
type: "bool",
|
|
31580
|
+
id: 5
|
|
31581
|
+
},
|
|
31582
|
+
device_id: {
|
|
31583
|
+
type: "string",
|
|
31584
|
+
id: 6
|
|
31585
|
+
},
|
|
31586
|
+
pin_protection: {
|
|
31587
|
+
type: "bool",
|
|
31588
|
+
id: 7
|
|
31589
|
+
},
|
|
31590
|
+
passphrase_protection: {
|
|
31591
|
+
type: "bool",
|
|
31592
|
+
id: 8
|
|
31593
|
+
},
|
|
31594
|
+
language: {
|
|
31595
|
+
type: "string",
|
|
31596
|
+
id: 9
|
|
31597
|
+
},
|
|
31598
|
+
label: {
|
|
31599
|
+
type: "string",
|
|
31600
|
+
id: 10
|
|
31601
|
+
},
|
|
31602
|
+
initialized: {
|
|
31603
|
+
type: "bool",
|
|
31604
|
+
id: 12
|
|
31605
|
+
},
|
|
31606
|
+
revision: {
|
|
31607
|
+
type: "bytes",
|
|
31608
|
+
id: 13
|
|
31609
|
+
},
|
|
31610
|
+
bootloader_hash: {
|
|
31611
|
+
type: "bytes",
|
|
31612
|
+
id: 14
|
|
31613
|
+
},
|
|
31614
|
+
imported: {
|
|
31615
|
+
type: "bool",
|
|
31616
|
+
id: 15
|
|
31617
|
+
},
|
|
31618
|
+
unlocked: {
|
|
31619
|
+
type: "bool",
|
|
31620
|
+
id: 16
|
|
31621
|
+
},
|
|
31622
|
+
_passphrase_cached: {
|
|
31623
|
+
type: "bool",
|
|
31624
|
+
id: 17,
|
|
31625
|
+
options: {
|
|
31626
|
+
deprecated: true
|
|
31627
|
+
}
|
|
31628
|
+
},
|
|
31629
|
+
firmware_present: {
|
|
31630
|
+
type: "bool",
|
|
31631
|
+
id: 18
|
|
31632
|
+
},
|
|
31633
|
+
needs_backup: {
|
|
31634
|
+
type: "bool",
|
|
31635
|
+
id: 19
|
|
31636
|
+
},
|
|
31637
|
+
flags: {
|
|
31638
|
+
type: "uint32",
|
|
31639
|
+
id: 20
|
|
31640
|
+
},
|
|
31641
|
+
model: {
|
|
31642
|
+
type: "string",
|
|
31643
|
+
id: 21
|
|
31644
|
+
},
|
|
31645
|
+
fw_major: {
|
|
31646
|
+
type: "uint32",
|
|
31647
|
+
id: 22
|
|
31648
|
+
},
|
|
31649
|
+
fw_minor: {
|
|
31650
|
+
type: "uint32",
|
|
31651
|
+
id: 23
|
|
31652
|
+
},
|
|
31653
|
+
fw_patch: {
|
|
31654
|
+
type: "uint32",
|
|
31655
|
+
id: 24
|
|
31656
|
+
},
|
|
31657
|
+
fw_vendor: {
|
|
31658
|
+
type: "string",
|
|
31659
|
+
id: 25
|
|
31660
|
+
},
|
|
31661
|
+
unfinished_backup: {
|
|
31662
|
+
type: "bool",
|
|
31663
|
+
id: 27
|
|
31664
|
+
},
|
|
31665
|
+
no_backup: {
|
|
31666
|
+
type: "bool",
|
|
31667
|
+
id: 28
|
|
31668
|
+
},
|
|
31669
|
+
recovery_mode: {
|
|
31670
|
+
type: "bool",
|
|
31671
|
+
id: 29
|
|
31672
|
+
},
|
|
31673
|
+
capabilities: {
|
|
31674
|
+
rule: "repeated",
|
|
31675
|
+
type: "Capability",
|
|
31676
|
+
id: 30,
|
|
31677
|
+
options: {
|
|
31678
|
+
packed: false
|
|
31679
|
+
}
|
|
31680
|
+
},
|
|
31681
|
+
backup_type: {
|
|
31682
|
+
type: "BackupType",
|
|
31683
|
+
id: 31
|
|
31684
|
+
},
|
|
31685
|
+
sd_card_present: {
|
|
31686
|
+
type: "bool",
|
|
31687
|
+
id: 32
|
|
31688
|
+
},
|
|
31689
|
+
sd_protection: {
|
|
31690
|
+
type: "bool",
|
|
31691
|
+
id: 33
|
|
31692
|
+
},
|
|
31693
|
+
wipe_code_protection: {
|
|
31694
|
+
type: "bool",
|
|
31695
|
+
id: 34
|
|
31696
|
+
},
|
|
31697
|
+
session_id: {
|
|
31698
|
+
type: "bytes",
|
|
31699
|
+
id: 35
|
|
31700
|
+
},
|
|
31701
|
+
passphrase_always_on_device: {
|
|
31702
|
+
type: "bool",
|
|
31703
|
+
id: 36
|
|
31704
|
+
},
|
|
31705
|
+
safety_checks: {
|
|
31706
|
+
type: "SafetyCheckLevel",
|
|
31707
|
+
id: 37
|
|
31708
|
+
},
|
|
31709
|
+
auto_lock_delay_ms: {
|
|
31710
|
+
type: "uint32",
|
|
31711
|
+
id: 38
|
|
31712
|
+
},
|
|
31713
|
+
display_rotation: {
|
|
31714
|
+
type: "uint32",
|
|
31715
|
+
id: 39
|
|
31716
|
+
},
|
|
31717
|
+
experimental_features: {
|
|
31718
|
+
type: "bool",
|
|
31719
|
+
id: 40
|
|
31720
|
+
},
|
|
31721
|
+
offset: {
|
|
31722
|
+
type: "uint32",
|
|
31723
|
+
id: 500
|
|
31724
|
+
},
|
|
31725
|
+
coprocessor_bt_name: {
|
|
31726
|
+
type: "string",
|
|
31727
|
+
id: 501
|
|
31728
|
+
},
|
|
31729
|
+
coprocessor_version: {
|
|
31730
|
+
type: "string",
|
|
31731
|
+
id: 502
|
|
31732
|
+
},
|
|
31733
|
+
coprocessor_bt_enable: {
|
|
31734
|
+
type: "bool",
|
|
31735
|
+
id: 503
|
|
31736
|
+
},
|
|
31737
|
+
se_enable: {
|
|
31738
|
+
type: "bool",
|
|
31739
|
+
id: 504
|
|
31740
|
+
},
|
|
31741
|
+
se_ver: {
|
|
31742
|
+
type: "string",
|
|
31743
|
+
id: 506
|
|
31744
|
+
},
|
|
31745
|
+
backup_only: {
|
|
31746
|
+
type: "bool",
|
|
31747
|
+
id: 507
|
|
31748
|
+
},
|
|
31749
|
+
onekey_version: {
|
|
31750
|
+
type: "string",
|
|
31751
|
+
id: 508
|
|
31752
|
+
},
|
|
31753
|
+
onekey_serial: {
|
|
31754
|
+
type: "string",
|
|
31755
|
+
id: 509
|
|
31756
|
+
},
|
|
31757
|
+
bootloader_version: {
|
|
31758
|
+
type: "string",
|
|
31759
|
+
id: 510
|
|
31760
|
+
},
|
|
31761
|
+
serial_no: {
|
|
31762
|
+
type: "string",
|
|
31763
|
+
id: 511
|
|
31764
|
+
},
|
|
31765
|
+
spi_flash: {
|
|
31766
|
+
type: "string",
|
|
31767
|
+
id: 512
|
|
31768
|
+
},
|
|
31769
|
+
initstates: {
|
|
31770
|
+
type: "uint32",
|
|
31771
|
+
id: 513
|
|
31772
|
+
},
|
|
31773
|
+
NFT_voucher: {
|
|
31774
|
+
type: "bytes",
|
|
31775
|
+
id: 514
|
|
31776
|
+
},
|
|
31777
|
+
cpu_info: {
|
|
31778
|
+
type: "string",
|
|
31779
|
+
id: 515
|
|
31780
|
+
},
|
|
31781
|
+
pre_firmware: {
|
|
31782
|
+
type: "string",
|
|
31783
|
+
id: 516
|
|
31784
|
+
},
|
|
31785
|
+
coin_switch: {
|
|
31786
|
+
type: "uint32",
|
|
31787
|
+
id: 517
|
|
31788
|
+
},
|
|
31789
|
+
build_id: {
|
|
31790
|
+
type: "bytes",
|
|
31791
|
+
id: 518
|
|
31792
|
+
},
|
|
31793
|
+
romloader_version: {
|
|
31794
|
+
type: "string",
|
|
31795
|
+
id: 519
|
|
31796
|
+
},
|
|
31797
|
+
busy: {
|
|
31798
|
+
type: "bool",
|
|
31799
|
+
id: 41
|
|
31800
|
+
},
|
|
31801
|
+
onekey_device_type: {
|
|
31802
|
+
type: "OneKeyDeviceType",
|
|
31803
|
+
id: 600
|
|
31804
|
+
},
|
|
31805
|
+
onekey_se_type: {
|
|
31806
|
+
type: "OneKeySeType",
|
|
31807
|
+
id: 601
|
|
31808
|
+
},
|
|
31809
|
+
onekey_romloader_version: {
|
|
31810
|
+
type: "string",
|
|
31811
|
+
id: 602
|
|
31812
|
+
},
|
|
31813
|
+
onekey_romloader_hash: {
|
|
31814
|
+
type: "bytes",
|
|
31815
|
+
id: 603
|
|
31816
|
+
},
|
|
31817
|
+
onekey_bootloader_version: {
|
|
31818
|
+
type: "string",
|
|
31819
|
+
id: 604
|
|
31820
|
+
},
|
|
31821
|
+
onekey_bootloader_hash: {
|
|
31822
|
+
type: "bytes",
|
|
31823
|
+
id: 605
|
|
31824
|
+
},
|
|
31825
|
+
onekey_se01_version: {
|
|
31826
|
+
type: "string",
|
|
31827
|
+
id: 606
|
|
31828
|
+
},
|
|
31829
|
+
onekey_se01_hash: {
|
|
31830
|
+
type: "bytes",
|
|
31831
|
+
id: 607
|
|
31832
|
+
},
|
|
31833
|
+
onekey_se01_build_id: {
|
|
31834
|
+
type: "string",
|
|
31835
|
+
id: 608
|
|
31836
|
+
},
|
|
31837
|
+
onekey_firmware_version: {
|
|
31838
|
+
type: "string",
|
|
31839
|
+
id: 609
|
|
31840
|
+
},
|
|
31841
|
+
onekey_firmware_hash: {
|
|
31842
|
+
type: "bytes",
|
|
31843
|
+
id: 610
|
|
31844
|
+
},
|
|
31845
|
+
onekey_firmware_build_id: {
|
|
31846
|
+
type: "string",
|
|
31847
|
+
id: 611
|
|
31848
|
+
},
|
|
31849
|
+
onekey_serial_no: {
|
|
31850
|
+
type: "string",
|
|
31851
|
+
id: 612
|
|
31852
|
+
},
|
|
31853
|
+
onekey_bootloader_build_id: {
|
|
31854
|
+
type: "string",
|
|
31855
|
+
id: 613
|
|
31856
|
+
},
|
|
31857
|
+
onekey_coprocessor_bt_name: {
|
|
31858
|
+
type: "string",
|
|
31859
|
+
id: 614
|
|
31860
|
+
},
|
|
31861
|
+
onekey_coprocessor_version: {
|
|
31862
|
+
type: "string",
|
|
31863
|
+
id: 615
|
|
31864
|
+
},
|
|
31865
|
+
onekey_coprocessor_build_id: {
|
|
31866
|
+
type: "string",
|
|
31867
|
+
id: 616
|
|
31868
|
+
},
|
|
31869
|
+
onekey_coprocessor_hash: {
|
|
31870
|
+
type: "bytes",
|
|
31871
|
+
id: 617
|
|
31872
|
+
},
|
|
31873
|
+
onekey_se02_version: {
|
|
31874
|
+
type: "string",
|
|
31875
|
+
id: 618
|
|
31876
|
+
},
|
|
31877
|
+
onekey_se03_version: {
|
|
31878
|
+
type: "string",
|
|
31879
|
+
id: 619
|
|
31880
|
+
},
|
|
31881
|
+
onekey_se04_version: {
|
|
31882
|
+
type: "string",
|
|
31883
|
+
id: 620
|
|
31884
|
+
},
|
|
31885
|
+
onekey_se01_state: {
|
|
31886
|
+
type: "OneKeySEState",
|
|
31887
|
+
id: 621
|
|
31888
|
+
},
|
|
31889
|
+
onekey_se02_state: {
|
|
31890
|
+
type: "OneKeySEState",
|
|
31891
|
+
id: 622
|
|
31892
|
+
},
|
|
31893
|
+
onekey_se03_state: {
|
|
31894
|
+
type: "OneKeySEState",
|
|
31895
|
+
id: 623
|
|
31896
|
+
},
|
|
31897
|
+
onekey_se04_state: {
|
|
31898
|
+
type: "OneKeySEState",
|
|
31899
|
+
id: 624
|
|
31900
|
+
},
|
|
31901
|
+
attach_to_pin_user: {
|
|
31902
|
+
type: "bool",
|
|
31903
|
+
id: 625
|
|
31904
|
+
},
|
|
31905
|
+
unlocked_attach_pin: {
|
|
31906
|
+
type: "bool",
|
|
31907
|
+
id: 626
|
|
31908
|
+
}
|
|
31909
|
+
},
|
|
31910
|
+
nested: {
|
|
31911
|
+
Capability: {
|
|
31912
|
+
options: {
|
|
31913
|
+
"(has_bitcoin_only_values)": true
|
|
31914
|
+
},
|
|
31915
|
+
values: {
|
|
31916
|
+
Capability_Bitcoin: 1,
|
|
31917
|
+
Capability_Bitcoin_like: 2,
|
|
31918
|
+
Capability_Binance: 3,
|
|
31919
|
+
Capability_Cardano: 4,
|
|
31920
|
+
Capability_Crypto: 5,
|
|
31921
|
+
Capability_EOS: 6,
|
|
31922
|
+
Capability_Ethereum: 7,
|
|
31923
|
+
Capability_Lisk: 8,
|
|
31924
|
+
Capability_Monero: 9,
|
|
31925
|
+
Capability_NEM: 10,
|
|
31926
|
+
Capability_Ripple: 11,
|
|
31927
|
+
Capability_Stellar: 12,
|
|
31928
|
+
Capability_Tezos: 13,
|
|
31929
|
+
Capability_U2F: 14,
|
|
31930
|
+
Capability_Shamir: 15,
|
|
31931
|
+
Capability_ShamirGroups: 16,
|
|
31932
|
+
Capability_PassphraseEntry: 17,
|
|
31933
|
+
Capability_AttachToPin: 18,
|
|
31934
|
+
Capability_EthereumTypedData: 1000
|
|
31935
|
+
}
|
|
31936
|
+
}
|
|
31937
|
+
}
|
|
31938
|
+
},
|
|
31532
31939
|
OnekeyFeatures: {
|
|
31533
31940
|
fields: {
|
|
31534
31941
|
onekey_device_type: {
|
|
@@ -36518,7 +36925,10 @@ var nested = {
|
|
|
36518
36925
|
ViewSignLayout: {
|
|
36519
36926
|
values: {
|
|
36520
36927
|
LayoutDefault: 0,
|
|
36521
|
-
LayoutSafeTxCreate: 1
|
|
36928
|
+
LayoutSafeTxCreate: 1,
|
|
36929
|
+
LayoutFinalConfirm: 2,
|
|
36930
|
+
Layout7702: 3,
|
|
36931
|
+
LayoutFlat: 4
|
|
36522
36932
|
}
|
|
36523
36933
|
},
|
|
36524
36934
|
ViewSignPage: {
|
|
@@ -37379,20 +37789,9 @@ var nested = {
|
|
|
37379
37789
|
fields: {
|
|
37380
37790
|
}
|
|
37381
37791
|
},
|
|
37382
|
-
|
|
37383
|
-
|
|
37384
|
-
|
|
37385
|
-
type: "bool",
|
|
37386
|
-
id: 1
|
|
37387
|
-
},
|
|
37388
|
-
unlocked_attach_pin: {
|
|
37389
|
-
type: "bool",
|
|
37390
|
-
id: 2
|
|
37391
|
-
},
|
|
37392
|
-
passphrase_protection: {
|
|
37393
|
-
type: "bool",
|
|
37394
|
-
id: 3
|
|
37395
|
-
}
|
|
37792
|
+
DeviceSessionAskPin_FailureSubCodes: {
|
|
37793
|
+
values: {
|
|
37794
|
+
UserCancel: 1
|
|
37396
37795
|
}
|
|
37397
37796
|
},
|
|
37398
37797
|
DeviceStatus: {
|
|
@@ -38851,6 +39250,13 @@ const PROTOBUF_MESSAGE_CONFIG = {
|
|
|
38851
39250
|
],
|
|
38852
39251
|
};
|
|
38853
39252
|
|
|
39253
|
+
function isDeviceLockedError(error) {
|
|
39254
|
+
return (typeof error === 'object' &&
|
|
39255
|
+
error !== null &&
|
|
39256
|
+
'errorCode' in error &&
|
|
39257
|
+
error.errorCode === hdShared.HardwareErrorCode.DeviceLocked);
|
|
39258
|
+
}
|
|
39259
|
+
|
|
38854
39260
|
const getErrorText = (error) => {
|
|
38855
39261
|
if (error instanceof Error)
|
|
38856
39262
|
return `${error.name} ${error.message}`;
|
|
@@ -38878,24 +39284,39 @@ function refreshProtocolV2DeviceStatus(device) {
|
|
|
38878
39284
|
});
|
|
38879
39285
|
}
|
|
38880
39286
|
function getProtocolV2WalletSession(device, options) {
|
|
38881
|
-
var _a, _b, _c, _d
|
|
39287
|
+
var _a, _b, _c, _d;
|
|
38882
39288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38883
|
-
if (((_a = device.features) === null || _a === void 0 ? void 0 : _a.unlocked) === false) {
|
|
38884
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device is locked');
|
|
38885
|
-
}
|
|
38886
39289
|
if (options === null || options === void 0 ? void 0 : options.initSession) {
|
|
38887
39290
|
device.clearInternalState();
|
|
38888
39291
|
}
|
|
38889
|
-
|
|
39292
|
+
let sessionId = typeof device.getInternalState === 'function' ? device.getInternalState() : undefined;
|
|
38890
39293
|
try {
|
|
38891
39294
|
const requestDeviceSession = (sessionId) => device.commands.typedCall('DeviceSessionGet', 'DeviceSession', sessionId ? { session_id: sessionId } : {});
|
|
38892
|
-
const
|
|
38893
|
-
|
|
39295
|
+
const requestWalletSession = () => __awaiter(this, void 0, void 0, function* () {
|
|
39296
|
+
try {
|
|
39297
|
+
return yield requestDeviceSession(sessionId);
|
|
39298
|
+
}
|
|
39299
|
+
catch (error) {
|
|
39300
|
+
if (!sessionId || !isProtocolV2InvalidSessionError(error)) {
|
|
39301
|
+
throw error;
|
|
39302
|
+
}
|
|
39303
|
+
device.clearInternalState();
|
|
39304
|
+
sessionId = undefined;
|
|
39305
|
+
return requestDeviceSession();
|
|
39306
|
+
}
|
|
39307
|
+
});
|
|
39308
|
+
let response;
|
|
39309
|
+
try {
|
|
39310
|
+
response = yield requestWalletSession();
|
|
39311
|
+
}
|
|
39312
|
+
catch (error) {
|
|
39313
|
+
if (!isDeviceLockedError(error)) {
|
|
38894
39314
|
throw error;
|
|
38895
39315
|
}
|
|
38896
|
-
device.
|
|
38897
|
-
|
|
38898
|
-
}
|
|
39316
|
+
yield device.unlockDevice();
|
|
39317
|
+
response = yield requestWalletSession();
|
|
39318
|
+
}
|
|
39319
|
+
const { message } = response;
|
|
38899
39320
|
if ((options === null || options === void 0 ? void 0 : options.expectedPassphraseState) &&
|
|
38900
39321
|
options.expectedPassphraseState !== message.btc_test_address) {
|
|
38901
39322
|
device.clearInternalState();
|
|
@@ -38904,11 +39325,11 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
38904
39325
|
if (message.btc_test_address && device.getCurrentPassphraseProtection() !== true) {
|
|
38905
39326
|
yield refreshProtocolV2DeviceStatus(device);
|
|
38906
39327
|
}
|
|
38907
|
-
device.updateInternalState(((
|
|
39328
|
+
device.updateInternalState(((_a = device.getCurrentPassphraseProtection()) !== null && _a !== void 0 ? _a : false) || Boolean(message.btc_test_address), message.btc_test_address, device.getCurrentDeviceId(), message.session_id, (options === null || options === void 0 ? void 0 : options.initSession) ? null : (_b = device.features) === null || _b === void 0 ? void 0 : _b.sessionId);
|
|
38908
39329
|
return {
|
|
38909
39330
|
passphraseState: message.btc_test_address,
|
|
38910
39331
|
newSession: message.session_id,
|
|
38911
|
-
unlockedAttachPin: (
|
|
39332
|
+
unlockedAttachPin: (_d = (_c = device.features) === null || _c === void 0 ? void 0 : _c.unlockedAttachPin) !== null && _d !== void 0 ? _d : undefined,
|
|
38912
39333
|
};
|
|
38913
39334
|
}
|
|
38914
39335
|
catch (error) {
|
|
@@ -40713,6 +41134,7 @@ class DeviceCommands {
|
|
|
40713
41134
|
});
|
|
40714
41135
|
}
|
|
40715
41136
|
_filterCommonTypes(res, callType, options) {
|
|
41137
|
+
var _a;
|
|
40716
41138
|
try {
|
|
40717
41139
|
if (shouldReduceDebugForCall(callType)) {
|
|
40718
41140
|
}
|
|
@@ -40762,7 +41184,8 @@ class DeviceCommands {
|
|
|
40762
41184
|
}
|
|
40763
41185
|
}
|
|
40764
41186
|
if (code === 'Failure_ProcessError') {
|
|
40765
|
-
|
|
41187
|
+
const isLegacyProtocolV2LockedFailure = this.device.isProtocolV2() && /^device (?:is )?locked$/i.test((_a = message === null || message === void 0 ? void 0 : message.trim()) !== null && _a !== void 0 ? _a : '');
|
|
41188
|
+
if (subcode === 9 || isLegacyProtocolV2LockedFailure) {
|
|
40766
41189
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceLocked, message, {
|
|
40767
41190
|
failureCode: code,
|
|
40768
41191
|
subcode,
|
|
@@ -41391,53 +41814,10 @@ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
|
|
|
41391
41814
|
const bleName = features.onekey_ble_name || features.ble_name || null;
|
|
41392
41815
|
const deviceType = getProtocolV1DeviceType(features);
|
|
41393
41816
|
const sessionId = (_b = (_a = features.session_id) !== null && _a !== void 0 ? _a : previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _b !== void 0 ? _b : null;
|
|
41394
|
-
return {
|
|
41395
|
-
protocol: 'V1',
|
|
41396
|
-
protocolVersion: (_d = (_c = features.protocol_version) !== null && _c !== void 0 ? _c : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _d !== void 0 ? _d : 1,
|
|
41397
|
-
deviceType,
|
|
41398
|
-
firmwareType: getProtocolV1FirmwareType(features),
|
|
41399
|
-
model: (_e = features.model) !== null && _e !== void 0 ? _e : null,
|
|
41400
|
-
vendor: (_f = features.vendor) !== null && _f !== void 0 ? _f : null,
|
|
41401
|
-
deviceId: (_g = features.device_id) !== null && _g !== void 0 ? _g : null,
|
|
41402
|
-
serialNo,
|
|
41403
|
-
label: getProtocolV1Label(features, deviceType, bleName),
|
|
41404
|
-
bleName,
|
|
41405
|
-
capabilities: (_h = features.capabilities) !== null && _h !== void 0 ? _h : [],
|
|
41406
|
-
mode: getProtocolV1Mode(features),
|
|
41407
|
-
initialized: (_j = features.initialized) !== null && _j !== void 0 ? _j : null,
|
|
41408
|
-
bootloaderMode: (_k = features.bootloader_mode) !== null && _k !== void 0 ? _k : null,
|
|
41409
|
-
unlocked: (_l = features.unlocked) !== null && _l !== void 0 ? _l : true,
|
|
41410
|
-
firmwarePresent: (_m = features.firmware_present) !== null && _m !== void 0 ? _m : null,
|
|
41411
|
-
passphraseProtection: (_o = features.passphrase_protection) !== null && _o !== void 0 ? _o : null,
|
|
41412
|
-
pinProtection: (_p = features.pin_protection) !== null && _p !== void 0 ? _p : null,
|
|
41413
|
-
backupRequired: (_q = features.needs_backup) !== null && _q !== void 0 ? _q : null,
|
|
41414
|
-
noBackup: (_r = features.no_backup) !== null && _r !== void 0 ? _r : null,
|
|
41415
|
-
unfinishedBackup: (_s = features.unfinished_backup) !== null && _s !== void 0 ? _s : null,
|
|
41416
|
-
recoveryMode: (_t = features.recovery_mode) !== null && _t !== void 0 ? _t : null,
|
|
41417
|
-
language: (_u = features.language) !== null && _u !== void 0 ? _u : null,
|
|
41418
|
-
bleEnabled: (_v = features.ble_enable) !== null && _v !== void 0 ? _v : null,
|
|
41419
|
-
sdCardPresent: (_w = features.sd_card_present) !== null && _w !== void 0 ? _w : null,
|
|
41420
|
-
sdProtection: (_x = features.sd_protection) !== null && _x !== void 0 ? _x : null,
|
|
41421
|
-
wipeCodeProtection: (_y = features.wipe_code_protection) !== null && _y !== void 0 ? _y : null,
|
|
41422
|
-
passphraseAlwaysOnDevice: (_z = features.passphrase_always_on_device) !== null && _z !== void 0 ? _z : null,
|
|
41423
|
-
safetyChecks: (_0 = features.safety_checks) !== null && _0 !== void 0 ? _0 : null,
|
|
41424
|
-
autoLockDelayMs: (_1 = features.auto_lock_delay_ms) !== null && _1 !== void 0 ? _1 : null,
|
|
41425
|
-
displayRotation: (_2 = features.display_rotation) !== null && _2 !== void 0 ? _2 : null,
|
|
41426
|
-
experimentalFeatures: (_3 = features.experimental_features) !== null && _3 !== void 0 ? _3 : null,
|
|
41427
|
-
firmwareVersion,
|
|
41817
|
+
return Object.assign(Object.assign({}, features), { protocol: 'V1', protocolVersion: (_d = (_c = features.protocol_version) !== null && _c !== void 0 ? _c : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _d !== void 0 ? _d : 1, deviceType, firmwareType: getProtocolV1FirmwareType(features), model: (_e = features.model) !== null && _e !== void 0 ? _e : null, vendor: (_f = features.vendor) !== null && _f !== void 0 ? _f : null, deviceId: (_g = features.device_id) !== null && _g !== void 0 ? _g : null, serialNo, label: getProtocolV1Label(features, deviceType, bleName), bleName, capabilities: (_h = features.capabilities) !== null && _h !== void 0 ? _h : [], mode: getProtocolV1Mode(features), initialized: (_j = features.initialized) !== null && _j !== void 0 ? _j : null, bootloaderMode: (_k = features.bootloader_mode) !== null && _k !== void 0 ? _k : null, unlocked: (_l = features.unlocked) !== null && _l !== void 0 ? _l : true, firmwarePresent: (_m = features.firmware_present) !== null && _m !== void 0 ? _m : null, passphraseProtection: (_o = features.passphrase_protection) !== null && _o !== void 0 ? _o : null, pinProtection: (_p = features.pin_protection) !== null && _p !== void 0 ? _p : null, backupRequired: (_q = features.needs_backup) !== null && _q !== void 0 ? _q : null, noBackup: (_r = features.no_backup) !== null && _r !== void 0 ? _r : null, unfinishedBackup: (_s = features.unfinished_backup) !== null && _s !== void 0 ? _s : null, recoveryMode: (_t = features.recovery_mode) !== null && _t !== void 0 ? _t : null, language: (_u = features.language) !== null && _u !== void 0 ? _u : null, bleEnabled: (_v = features.ble_enable) !== null && _v !== void 0 ? _v : null, sdCardPresent: (_w = features.sd_card_present) !== null && _w !== void 0 ? _w : null, sdProtection: (_x = features.sd_protection) !== null && _x !== void 0 ? _x : null, wipeCodeProtection: (_y = features.wipe_code_protection) !== null && _y !== void 0 ? _y : null, passphraseAlwaysOnDevice: (_z = features.passphrase_always_on_device) !== null && _z !== void 0 ? _z : null, safetyChecks: (_0 = features.safety_checks) !== null && _0 !== void 0 ? _0 : null, autoLockDelayMs: (_1 = features.auto_lock_delay_ms) !== null && _1 !== void 0 ? _1 : null, displayRotation: (_2 = features.display_rotation) !== null && _2 !== void 0 ? _2 : null, experimentalFeatures: (_3 = features.experimental_features) !== null && _3 !== void 0 ? _3 : null, firmwareVersion,
|
|
41428
41818
|
bootloaderVersion,
|
|
41429
41819
|
boardVersion,
|
|
41430
|
-
bleVersion,
|
|
41431
|
-
se01Version: firstMeaningfulVersion(features.onekey_se01_version),
|
|
41432
|
-
se02Version: firstMeaningfulVersion(features.onekey_se02_version),
|
|
41433
|
-
se03Version: firstMeaningfulVersion(features.onekey_se03_version),
|
|
41434
|
-
se04Version: firstMeaningfulVersion(features.onekey_se04_version),
|
|
41435
|
-
se01BootVersion: firstMeaningfulVersion(features.onekey_se01_boot_version),
|
|
41436
|
-
se02BootVersion: firstMeaningfulVersion(features.onekey_se02_boot_version),
|
|
41437
|
-
se03BootVersion: firstMeaningfulVersion(features.onekey_se03_boot_version),
|
|
41438
|
-
se04BootVersion: firstMeaningfulVersion(features.onekey_se04_boot_version),
|
|
41439
|
-
seVersion: (_4 = features.se_ver) !== null && _4 !== void 0 ? _4 : null,
|
|
41440
|
-
verify: {
|
|
41820
|
+
bleVersion, se01Version: firstMeaningfulVersion(features.onekey_se01_version), se02Version: firstMeaningfulVersion(features.onekey_se02_version), se03Version: firstMeaningfulVersion(features.onekey_se03_version), se04Version: firstMeaningfulVersion(features.onekey_se04_version), se01BootVersion: firstMeaningfulVersion(features.onekey_se01_boot_version), se02BootVersion: firstMeaningfulVersion(features.onekey_se02_boot_version), se03BootVersion: firstMeaningfulVersion(features.onekey_se03_boot_version), se04BootVersion: firstMeaningfulVersion(features.onekey_se04_boot_version), seVersion: (_4 = features.se_ver) !== null && _4 !== void 0 ? _4 : null, verify: {
|
|
41441
41821
|
firmwareBuildId: features.onekey_firmware_build_id,
|
|
41442
41822
|
firmwareHash: features.onekey_firmware_hash,
|
|
41443
41823
|
bootloaderBuildId: features.onekey_boot_build_id,
|
|
@@ -41462,15 +41842,12 @@ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
|
|
|
41462
41842
|
se03BootHash: features.onekey_se03_boot_hash,
|
|
41463
41843
|
se04BootBuildId: features.onekey_se04_boot_build_id,
|
|
41464
41844
|
se04BootHash: features.onekey_se04_boot_hash,
|
|
41465
|
-
},
|
|
41466
|
-
sessionId,
|
|
41467
|
-
raw: {
|
|
41845
|
+
}, sessionId, session_id: sessionId !== null && sessionId !== void 0 ? sessionId : undefined, raw: {
|
|
41468
41846
|
protocolV1Features,
|
|
41469
|
-
}
|
|
41470
|
-
};
|
|
41847
|
+
} });
|
|
41471
41848
|
};
|
|
41472
41849
|
const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
|
|
41473
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69;
|
|
41850
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70;
|
|
41474
41851
|
const info = deviceInfo;
|
|
41475
41852
|
const fwApplication = (_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application;
|
|
41476
41853
|
const fwBootloader = (_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.bootloader;
|
|
@@ -41582,6 +41959,12 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
|
|
|
41582
41959
|
se04BootHash: (_67 = getImageHash((_66 = info === null || info === void 0 ? void 0 : info.se4) === null || _66 === void 0 ? void 0 : _66.bootloader)) !== null && _67 !== void 0 ? _67 : (_68 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _68 === void 0 ? void 0 : _68.se04BootHash,
|
|
41583
41960
|
},
|
|
41584
41961
|
sessionId: (_69 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _69 !== void 0 ? _69 : null,
|
|
41962
|
+
device_id: deviceId !== null && deviceId !== void 0 ? deviceId : undefined,
|
|
41963
|
+
session_id: (_70 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _70 !== void 0 ? _70 : undefined,
|
|
41964
|
+
ble_name: bleName !== null && bleName !== void 0 ? bleName : undefined,
|
|
41965
|
+
onekey_device_type: 'PRO2',
|
|
41966
|
+
passphrase_protection: passphraseProtection !== null && passphraseProtection !== void 0 ? passphraseProtection : undefined,
|
|
41967
|
+
bootloader_mode: bootloaderMode,
|
|
41585
41968
|
passphraseState: previous === null || previous === void 0 ? void 0 : previous.passphraseState,
|
|
41586
41969
|
unlockedAttachPin,
|
|
41587
41970
|
raw: {
|
|
@@ -42310,7 +42693,7 @@ class Device extends events.exports {
|
|
|
42310
42693
|
}
|
|
42311
42694
|
hasUnexpectedMode(allow, require) {
|
|
42312
42695
|
if (!this.isUnacquired()) {
|
|
42313
|
-
if (this.isBootloader() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
42696
|
+
if (this.isBootloader() && !this.isProtocolV2() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
42314
42697
|
return UI_REQUEST.BOOTLOADER;
|
|
42315
42698
|
}
|
|
42316
42699
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -42356,9 +42739,8 @@ class Device extends events.exports {
|
|
|
42356
42739
|
var _a, _b, _c;
|
|
42357
42740
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42358
42741
|
if (this.isProtocolV2()) {
|
|
42359
|
-
let pinResult;
|
|
42360
42742
|
try {
|
|
42361
|
-
|
|
42743
|
+
yield this.commands.typedCall('DeviceSessionAskPin', 'Success');
|
|
42362
42744
|
}
|
|
42363
42745
|
catch (error) {
|
|
42364
42746
|
const errorText = error instanceof Error
|
|
@@ -42369,16 +42751,7 @@ class Device extends events.exports {
|
|
|
42369
42751
|
}
|
|
42370
42752
|
throw error;
|
|
42371
42753
|
}
|
|
42372
|
-
const status = {};
|
|
42373
|
-
if (pinResult.unlocked != null) {
|
|
42374
|
-
status.unlocked = pinResult.unlocked;
|
|
42375
|
-
}
|
|
42376
|
-
if (pinResult.unlocked_attach_pin != null) {
|
|
42377
|
-
status.unlocked_by_attach_to_pin = pinResult.unlocked_attach_pin;
|
|
42378
|
-
}
|
|
42379
|
-
if (pinResult.passphrase_protection != null) {
|
|
42380
|
-
status.passphrase_enabled = pinResult.passphrase_protection;
|
|
42381
|
-
}
|
|
42754
|
+
const { message: status } = yield this.commands.typedCall('DeviceStatusGet', 'DeviceStatus', {});
|
|
42382
42755
|
return this.updateProtocolV2Status(status);
|
|
42383
42756
|
}
|
|
42384
42757
|
const firmwareVersion = (_c = this.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
|
|
@@ -45988,9 +46361,6 @@ const isProtocolV2DeviceDisconnectedError = (error) => {
|
|
|
45988
46361
|
message.includes('connection has timed out unexpectedly') ||
|
|
45989
46362
|
message.includes('connection error has occured') ||
|
|
45990
46363
|
message.includes('connection error has occurred') ||
|
|
45991
|
-
message.includes('transferIn') ||
|
|
45992
|
-
message.includes('transferin') ||
|
|
45993
|
-
message.includes('usbdevice') ||
|
|
45994
46364
|
message.includes('multiplatformbleadapter') ||
|
|
45995
46365
|
message.includes('multipalformebleadapter') ||
|
|
45996
46366
|
compactMessage.includes('rxerrorerror6') ||
|
|
@@ -46286,6 +46656,16 @@ const parseProtocolV2OkppHeader = (bytes) => {
|
|
|
46286
46656
|
headerHash: bytesToHex(bytes.slice(PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET, PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET + PROTOCOL_V2_OKPP_HASH_SIZE)),
|
|
46287
46657
|
};
|
|
46288
46658
|
};
|
|
46659
|
+
const assertProtocolV2ReconnectIdentity = (expectedDeviceId, actualDeviceId) => {
|
|
46660
|
+
if (!expectedDeviceId)
|
|
46661
|
+
return;
|
|
46662
|
+
if (!actualDeviceId) {
|
|
46663
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 reconnect identity unavailable');
|
|
46664
|
+
}
|
|
46665
|
+
if (actualDeviceId !== expectedDeviceId) {
|
|
46666
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, `Protocol V2 reconnect identity mismatch: expected ${expectedDeviceId}, received ${actualDeviceId}`);
|
|
46667
|
+
}
|
|
46668
|
+
};
|
|
46289
46669
|
class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
46290
46670
|
init() {
|
|
46291
46671
|
this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -46362,11 +46742,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46362
46742
|
});
|
|
46363
46743
|
}
|
|
46364
46744
|
runProtocolV2() {
|
|
46365
|
-
var _a, _b;
|
|
46745
|
+
var _a, _b, _c;
|
|
46366
46746
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46367
46747
|
const deviceFeatures = yield this.getProtocolV2DeviceFeatures();
|
|
46748
|
+
this.protocolV2ExpectedDeviceId = (_a = deviceFeatures.deviceId) !== null && _a !== void 0 ? _a : undefined;
|
|
46368
46749
|
const deviceFirmwareType = getFirmwareType(deviceFeatures);
|
|
46369
|
-
const firmwareType = (
|
|
46750
|
+
const firmwareType = (_b = this.params.firmwareType) !== null && _b !== void 0 ? _b : deviceFirmwareType;
|
|
46370
46751
|
let fwBinaryMap = [];
|
|
46371
46752
|
let bootloaderBinary = null;
|
|
46372
46753
|
let installItems;
|
|
@@ -46383,7 +46764,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46383
46764
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
|
|
46384
46765
|
}
|
|
46385
46766
|
catch (err) {
|
|
46386
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (
|
|
46767
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_c = err.message) !== null && _c !== void 0 ? _c : err);
|
|
46387
46768
|
}
|
|
46388
46769
|
const resourceBundles = this.prepareProtocolV2ResourceBundles(firmwareType, deviceFeatures);
|
|
46389
46770
|
if (!bootloaderBinary && fwBinaryMap.length === 0 && !(resourceBundles === null || resourceBundles === void 0 ? void 0 : resourceBundles.length)) {
|
|
@@ -46712,6 +47093,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46712
47093
|
});
|
|
46713
47094
|
}
|
|
46714
47095
|
waitForProtocolV2BootloaderMode(timeout = PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT, retryInterval = 1000) {
|
|
47096
|
+
var _a;
|
|
46715
47097
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46716
47098
|
const startTime = Date.now();
|
|
46717
47099
|
let lastError;
|
|
@@ -46723,6 +47105,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46723
47105
|
timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
46724
47106
|
});
|
|
46725
47107
|
const features = this.device.updateProtocolV2Features(deviceInfo);
|
|
47108
|
+
assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, (_a = features.deviceId) !== null && _a !== void 0 ? _a : undefined);
|
|
46726
47109
|
if (features === null || features === void 0 ? void 0 : features.bootloaderMode) {
|
|
46727
47110
|
return features;
|
|
46728
47111
|
}
|
|
@@ -46858,6 +47241,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46858
47241
|
return !!features && !features.bootloaderMode && features.mode !== 'bootloader';
|
|
46859
47242
|
}
|
|
46860
47243
|
probeProtocolV2NormalMode() {
|
|
47244
|
+
var _a;
|
|
46861
47245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46862
47246
|
const deviceInfo = yield requestProtocolV2DeviceInfo({
|
|
46863
47247
|
commands: this.device.getCommands(),
|
|
@@ -46865,6 +47249,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46865
47249
|
request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
|
|
46866
47250
|
});
|
|
46867
47251
|
const features = this.device.updateProtocolV2Features(deviceInfo);
|
|
47252
|
+
assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, (_a = features.deviceId) !== null && _a !== void 0 ? _a : undefined);
|
|
46868
47253
|
if (this.isProtocolV2NormalModeFeatures(features)) {
|
|
46869
47254
|
Log$5.log('Protocol V2 firmware install finished; device is back in normal mode');
|
|
46870
47255
|
return true;
|
|
@@ -46984,6 +47369,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46984
47369
|
});
|
|
46985
47370
|
}
|
|
46986
47371
|
waitForProtocolV2ReconnectAndFeatures(timeout) {
|
|
47372
|
+
var _a;
|
|
46987
47373
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46988
47374
|
const startTime = Date.now();
|
|
46989
47375
|
let lastError;
|
|
@@ -46996,6 +47382,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
46996
47382
|
request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
|
|
46997
47383
|
});
|
|
46998
47384
|
const features = this.device.updateProtocolV2Features(deviceInfo);
|
|
47385
|
+
assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, (_a = features.deviceId) !== null && _a !== void 0 ? _a : undefined);
|
|
46999
47386
|
if (features.bootloaderMode || features.mode === 'bootloader') {
|
|
47000
47387
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
|
|
47001
47388
|
}
|
|
@@ -47026,6 +47413,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
47026
47413
|
this.device.commands.disposed = false;
|
|
47027
47414
|
this.device.getCommands().mainId = (_c = this.device.mainId) !== null && _c !== void 0 ? _c : '';
|
|
47028
47415
|
yield this.device.initialize();
|
|
47416
|
+
assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, this.device.getCurrentDeviceId());
|
|
47029
47417
|
return;
|
|
47030
47418
|
}
|
|
47031
47419
|
const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, undefined, {
|
|
@@ -47040,6 +47428,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
47040
47428
|
this.device.commands.disposed = false;
|
|
47041
47429
|
this.device.getCommands().mainId = (_d = this.device.mainId) !== null && _d !== void 0 ? _d : '';
|
|
47042
47430
|
yield this.device.initialize();
|
|
47431
|
+
assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, this.device.getCurrentDeviceId());
|
|
47043
47432
|
});
|
|
47044
47433
|
}
|
|
47045
47434
|
protocolV2CommonUpdateProcess(params) {
|
|
@@ -47078,11 +47467,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
47078
47467
|
const overwrite = offset === 0;
|
|
47079
47468
|
const progress = getProtocolV2DeviceTransferProgress((processedSize !== null && processedSize !== void 0 ? processedSize : 0) + offset, (processedSize !== null && processedSize !== void 0 ? processedSize : 0) + chunkEnd, totalSize !== null && totalSize !== void 0 ? totalSize : payload.byteLength);
|
|
47080
47469
|
const writeRes = yield this.fileWriteChunk(filePath, payload.byteLength, offset, chunk, overwrite, progress);
|
|
47081
|
-
const
|
|
47082
|
-
const
|
|
47083
|
-
|
|
47084
|
-
|
|
47085
|
-
if (nextOffset <= offset || nextOffset > payload.byteLength) {
|
|
47470
|
+
const rawProcessedByte = writeRes.message.processed_byte;
|
|
47471
|
+
const processedByte = Number(rawProcessedByte);
|
|
47472
|
+
const nextOffset = rawProcessedByte === undefined ? offset + chunkLength : processedByte;
|
|
47473
|
+
if (!Number.isFinite(nextOffset) || nextOffset <= offset || nextOffset > chunkEnd) {
|
|
47086
47474
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, `invalid processed_byte ${writeRes.message.processed_byte} for offset ${offset}`);
|
|
47087
47475
|
}
|
|
47088
47476
|
offset = nextOffset;
|
|
@@ -47721,14 +48109,16 @@ function writeProtocolV2File(options) {
|
|
|
47721
48109
|
}, { timeoutMs: options.timeoutMs });
|
|
47722
48110
|
(_g = options.throwIfAborted) === null || _g === void 0 ? void 0 : _g.call(options);
|
|
47723
48111
|
lastMessage = response.message;
|
|
47724
|
-
const
|
|
47725
|
-
|
|
47726
|
-
|
|
47727
|
-
|
|
47728
|
-
|
|
47729
|
-
|
|
48112
|
+
const rawProcessedByte = (_h = response.message) === null || _h === void 0 ? void 0 : _h.processed_byte;
|
|
48113
|
+
const processedByte = Number(rawProcessedByte);
|
|
48114
|
+
if (rawProcessedByte !== undefined &&
|
|
48115
|
+
(!Number.isFinite(processedByte) ||
|
|
48116
|
+
processedByte <= offset ||
|
|
48117
|
+
processedByte > offset + chunk.byteLength)) {
|
|
47730
48118
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite invalid processed_byte ${processedByte}`);
|
|
47731
48119
|
}
|
|
48120
|
+
written =
|
|
48121
|
+
rawProcessedByte === undefined ? written + chunk.byteLength : processedByte - startOffset;
|
|
47732
48122
|
chunks += 1;
|
|
47733
48123
|
const elapsedMs = Date.now() - startTime;
|
|
47734
48124
|
const transferredBytes = Math.min(written, dataLength);
|
|
@@ -47803,7 +48193,7 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
47803
48193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47804
48194
|
if (this.uploaded)
|
|
47805
48195
|
return;
|
|
47806
|
-
const encoded = this
|
|
48196
|
+
const { encoded } = this;
|
|
47807
48197
|
if (!encoded)
|
|
47808
48198
|
throw invalidParameter('Wallpaper data has not been initialized.');
|
|
47809
48199
|
yield writeProtocolV2File({
|
|
@@ -47815,6 +48205,11 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
47815
48205
|
overwrite: true,
|
|
47816
48206
|
append: false,
|
|
47817
48207
|
throwIfAborted: () => this.throwIfAborted(),
|
|
48208
|
+
onProgress: payload => {
|
|
48209
|
+
if (typeof this.postMessage === 'function') {
|
|
48210
|
+
this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, payload));
|
|
48211
|
+
}
|
|
48212
|
+
},
|
|
47818
48213
|
});
|
|
47819
48214
|
this.uploaded = true;
|
|
47820
48215
|
});
|
|
@@ -47822,7 +48217,7 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
47822
48217
|
run() {
|
|
47823
48218
|
var _a;
|
|
47824
48219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47825
|
-
const encoded = this
|
|
48220
|
+
const { encoded } = this;
|
|
47826
48221
|
if (!encoded)
|
|
47827
48222
|
throw invalidParameter('Wallpaper data has not been initialized.');
|
|
47828
48223
|
yield this.ensureDirectory();
|
|
@@ -47873,40 +48268,6 @@ class FilesystemFormat extends BaseMethod {
|
|
|
47873
48268
|
}
|
|
47874
48269
|
}
|
|
47875
48270
|
|
|
47876
|
-
function normalizeDiskControlEnable(value) {
|
|
47877
|
-
if (value === undefined || value === null)
|
|
47878
|
-
return 0;
|
|
47879
|
-
if (typeof value === 'boolean')
|
|
47880
|
-
return value ? 1 : 0;
|
|
47881
|
-
if (value === 0 || value === '0')
|
|
47882
|
-
return 0;
|
|
47883
|
-
if (value === 1 || value === '1')
|
|
47884
|
-
return 1;
|
|
47885
|
-
throw invalidParameter('Parameter [enable] must be a boolean or 0 | 1.');
|
|
47886
|
-
}
|
|
47887
|
-
class FilesystemDiskControl extends BaseMethod {
|
|
47888
|
-
init() {
|
|
47889
|
-
this.requireProtocolV2 = true;
|
|
47890
|
-
this.skipForceUpdateCheck = true;
|
|
47891
|
-
this.useDevicePassphraseState = false;
|
|
47892
|
-
this.params = {
|
|
47893
|
-
enable: normalizeDiskControlEnable(this.payload.enable),
|
|
47894
|
-
timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
|
|
47895
|
-
};
|
|
47896
|
-
}
|
|
47897
|
-
run() {
|
|
47898
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47899
|
-
const typedCall = this.device.commands.typedCall;
|
|
47900
|
-
const res = yield typedCall('FilesystemDiskControl', 'Success', {
|
|
47901
|
-
enable: this.params.enable,
|
|
47902
|
-
}, {
|
|
47903
|
-
timeoutMs: this.params.timeoutMs,
|
|
47904
|
-
});
|
|
47905
|
-
return Promise.resolve(res.message);
|
|
47906
|
-
});
|
|
47907
|
-
}
|
|
47908
|
-
}
|
|
47909
|
-
|
|
47910
48271
|
const MIN_FILE_READ_CHUNK_SIZE = 64;
|
|
47911
48272
|
function getProtocolV2FileReadChunkLimit() {
|
|
47912
48273
|
const env = DataManager.getSettings('env');
|
|
@@ -48038,7 +48399,7 @@ class FileRead extends BaseMethod {
|
|
|
48038
48399
|
|
|
48039
48400
|
class FileWrite extends BaseMethod {
|
|
48040
48401
|
init() {
|
|
48041
|
-
var _a, _b;
|
|
48402
|
+
var _a, _b, _c;
|
|
48042
48403
|
this.requireProtocolV2 = true;
|
|
48043
48404
|
this.skipForceUpdateCheck = true;
|
|
48044
48405
|
this.useDevicePassphraseState = false;
|
|
@@ -48054,6 +48415,7 @@ class FileWrite extends BaseMethod {
|
|
|
48054
48415
|
chunkLen: validateOptionalNonNegativeInteger(this.payload.chunkLen, 'chunkLen'),
|
|
48055
48416
|
overwrite: (_a = this.payload.overwrite) !== null && _a !== void 0 ? _a : offset === 0,
|
|
48056
48417
|
append: (_b = this.payload.append) !== null && _b !== void 0 ? _b : false,
|
|
48418
|
+
emitProgress: (_c = this.payload.emitProgress) !== null && _c !== void 0 ? _c : true,
|
|
48057
48419
|
uiPercentage: validateOptionalPercentage(this.payload.uiPercentage, 'uiPercentage'),
|
|
48058
48420
|
timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
|
|
48059
48421
|
};
|
|
@@ -48074,7 +48436,7 @@ class FileWrite extends BaseMethod {
|
|
|
48074
48436
|
timeoutMs: this.params.timeoutMs === undefined ? undefined : Number(this.params.timeoutMs),
|
|
48075
48437
|
throwIfAborted: () => this.throwIfAborted(),
|
|
48076
48438
|
onProgress: payload => {
|
|
48077
|
-
if (typeof this.postMessage === 'function') {
|
|
48439
|
+
if (this.params.emitProgress && typeof this.postMessage === 'function') {
|
|
48078
48440
|
this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, payload));
|
|
48079
48441
|
}
|
|
48080
48442
|
},
|
|
@@ -48178,13 +48540,14 @@ class PathInfo extends BaseMethod {
|
|
|
48178
48540
|
}
|
|
48179
48541
|
}
|
|
48180
48542
|
|
|
48181
|
-
const PORTFOLIO_PENDING_PATH = 'vol1:/portfolio/portfolio.
|
|
48543
|
+
const PORTFOLIO_PENDING_PATH = 'vol1:/portfolio/portfolio.okpkg.pending';
|
|
48182
48544
|
const PORTFOLIO_CHUNK_SIZE = 2048;
|
|
48183
48545
|
class UploadPortfolio extends FileWrite {
|
|
48184
48546
|
init() {
|
|
48185
48547
|
const { packageBytes, timeoutMs } = this.payload;
|
|
48186
|
-
this.payload = Object.assign(Object.assign({}, this.payload), { path: PORTFOLIO_PENDING_PATH, offset: 0, data: packageBytes, chunkSize: PORTFOLIO_CHUNK_SIZE, overwrite: true, append: false, timeoutMs });
|
|
48548
|
+
this.payload = Object.assign(Object.assign({}, this.payload), { path: PORTFOLIO_PENDING_PATH, offset: 0, data: packageBytes, chunkSize: PORTFOLIO_CHUNK_SIZE, overwrite: true, append: false, emitProgress: false, timeoutMs });
|
|
48187
48549
|
super.init();
|
|
48550
|
+
this.unlockPolicy = 'retry-on-locked';
|
|
48188
48551
|
}
|
|
48189
48552
|
run() {
|
|
48190
48553
|
const _super = Object.create(null, {
|
|
@@ -54465,7 +54828,7 @@ class CardanoSignTransaction extends BaseMethod {
|
|
|
54465
54828
|
var _a;
|
|
54466
54829
|
this.checkDeviceId = true;
|
|
54467
54830
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
54468
|
-
this.allowUsePreInitialize =
|
|
54831
|
+
this.allowUsePreInitialize = false;
|
|
54469
54832
|
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
54470
54833
|
const { payload } = this;
|
|
54471
54834
|
if (payload.auxiliaryData && payload.auxiliaryData.governanceRegistrationParameters) {
|
|
@@ -54701,7 +55064,7 @@ class CardanoSignMessage extends BaseMethod {
|
|
|
54701
55064
|
init() {
|
|
54702
55065
|
this.checkDeviceId = true;
|
|
54703
55066
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
54704
|
-
this.allowUsePreInitialize =
|
|
55067
|
+
this.allowUsePreInitialize = false;
|
|
54705
55068
|
const { payload } = this;
|
|
54706
55069
|
validateParams(payload, [
|
|
54707
55070
|
{ name: 'path', type: 'string', required: true },
|
|
@@ -57428,7 +57791,6 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
57428
57791
|
deviceUploadWallpaper: DeviceUploadWallpaper,
|
|
57429
57792
|
filesystemPermissionFix: FilesystemPermissionFix,
|
|
57430
57793
|
filesystemFormat: FilesystemFormat,
|
|
57431
|
-
filesystemDiskControl: FilesystemDiskControl,
|
|
57432
57794
|
fileRead: FileRead,
|
|
57433
57795
|
fileWrite: FileWrite,
|
|
57434
57796
|
fileDelete: FileDelete,
|
|
@@ -57830,12 +58192,6 @@ const getSynchronize = (mutex) => {
|
|
|
57830
58192
|
};
|
|
57831
58193
|
|
|
57832
58194
|
const Log$1 = getLogger(exports.LoggerNames.Core);
|
|
57833
|
-
function isDeviceLockedError(error) {
|
|
57834
|
-
return (typeof error === 'object' &&
|
|
57835
|
-
error !== null &&
|
|
57836
|
-
'errorCode' in error &&
|
|
57837
|
-
error.errorCode === hdShared.HardwareErrorCode.DeviceLocked);
|
|
57838
|
-
}
|
|
57839
58195
|
function runMethodWithUnlockRetry(method, device) {
|
|
57840
58196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57841
58197
|
try {
|