@onekeyfe/hd-core 1.2.0-alpha.34 → 1.2.0-alpha.36
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__/AllNetworkGetAddressBase.tracing.test.ts +74 -0
- package/__tests__/DeviceCommands.test.ts +84 -0
- package/__tests__/DeviceEventRegistration.test.ts +6 -0
- package/__tests__/device-settings.test.ts +3 -0
- package/__tests__/device-wallet-session-store.test.ts +80 -7
- package/__tests__/evmSignTransaction.test.ts +69 -0
- package/__tests__/get-device-state.test.ts +180 -40
- package/__tests__/open-wallet-session.test.ts +314 -55
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +56 -0
- package/__tests__/protocol-v2.test.ts +768 -139
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/protocol.d.ts +3 -0
- package/dist/api/evm/protocol.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +2 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +25 -6
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +0 -1
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -1
- package/dist/events/device.d.ts +4 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +27 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +63 -12
- package/dist/index.js +1164 -904
- package/dist/protocols/protocol-v2/features.d.ts +17 -6
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +3 -3
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +5 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +1 -1
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +2 -2
- 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/deviceFeaturesUtils.d.ts +2 -0
- package/dist/utils/deviceFeaturesUtils.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/BaseMethod.ts +1 -1
- package/src/api/FirmwareUpdateV4.ts +39 -14
- package/src/api/GetPassphraseState.ts +17 -0
- package/src/api/OpenWalletSession.ts +31 -8
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +24 -2
- package/src/api/device/DeviceUnlock.ts +1 -1
- package/src/api/evm/EVMGetAddress.ts +2 -2
- package/src/api/evm/EVMGetPublicKey.ts +2 -2
- package/src/api/evm/EVMSignMessage.ts +2 -2
- package/src/api/evm/EVMSignTransaction.ts +2 -2
- package/src/api/evm/EVMSignTypedData.ts +35 -45
- package/src/api/evm/EVMVerifyMessage.ts +2 -2
- package/src/api/evm/protocol.ts +6 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +2 -2
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +1 -1
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +3 -1
- package/src/core/deviceEventRegistration.ts +4 -0
- package/src/core/index.ts +46 -4
- package/src/data/messages/messages-protocol-v2.json +408 -485
- package/src/device/Device.ts +266 -43
- package/src/device/DeviceCommands.ts +12 -2
- package/src/device/DeviceWalletSessionStore.ts +0 -14
- package/src/deviceProfile/buildDeviceFeatures.ts +1 -1
- package/src/events/device.ts +4 -0
- package/src/events/ui-request.ts +32 -2
- package/src/protocols/protocol-v2/features.ts +65 -16
- package/src/protocols/protocol-v2/index.ts +5 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +8 -3
- package/src/protocols/protocol-v2/uiInteraction.ts +31 -5
- package/src/protocols/protocol-v2/unlockRetry.ts +51 -18
- package/src/protocols/protocol-v2/walletSession.ts +172 -64
- package/src/types/api/openWalletSession.ts +1 -1
- package/src/types/api/protocolV2.ts +2 -2
- package/src/types/device.ts +2 -0
- package/src/utils/deviceFeaturesUtils.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -25880,8 +25880,6 @@ var nested = {
|
|
|
25880
25880
|
MessageType_ResetDevice: 14,
|
|
25881
25881
|
MessageType_SetBusy: 16,
|
|
25882
25882
|
MessageType_Features: 17,
|
|
25883
|
-
MessageType_PinMatrixRequest: 18,
|
|
25884
|
-
MessageType_PinMatrixAck: 19,
|
|
25885
25883
|
MessageType_Cancel: 20,
|
|
25886
25884
|
MessageType_LockDevice: 24,
|
|
25887
25885
|
MessageType_ApplySettings: 25,
|
|
@@ -25943,20 +25941,6 @@ var nested = {
|
|
|
25943
25941
|
MessageType_CosiSignature: 74,
|
|
25944
25942
|
MessageType_BatchGetPublickeys: 10016,
|
|
25945
25943
|
MessageType_EcdsaPublicKeys: 10017,
|
|
25946
|
-
MessageType_DebugLinkDecision: 100,
|
|
25947
|
-
MessageType_DebugLinkGetState: 101,
|
|
25948
|
-
MessageType_DebugLinkState: 102,
|
|
25949
|
-
MessageType_DebugLinkStop: 103,
|
|
25950
|
-
MessageType_DebugLinkLog: 104,
|
|
25951
|
-
MessageType_DebugLinkMemoryRead: 110,
|
|
25952
|
-
MessageType_DebugLinkMemory: 111,
|
|
25953
|
-
MessageType_DebugLinkMemoryWrite: 112,
|
|
25954
|
-
MessageType_DebugLinkFlashErase: 113,
|
|
25955
|
-
MessageType_DebugLinkLayout: 9001,
|
|
25956
|
-
MessageType_DebugLinkReseedRandom: 9002,
|
|
25957
|
-
MessageType_DebugLinkRecordScreen: 9003,
|
|
25958
|
-
MessageType_DebugLinkEraseSdCard: 9005,
|
|
25959
|
-
MessageType_DebugLinkWatchLayout: 9006,
|
|
25960
25944
|
MessageType_EthereumGetPublicKey: 450,
|
|
25961
25945
|
MessageType_EthereumPublicKey: 451,
|
|
25962
25946
|
MessageType_EthereumGetAddress: 56,
|
|
@@ -26220,13 +26204,6 @@ var nested = {
|
|
|
26220
26204
|
MessageType_TonSignProof: 11905,
|
|
26221
26205
|
MessageType_TonSignedProof: 11906,
|
|
26222
26206
|
MessageType_TonTxAck: 11907,
|
|
26223
|
-
MessageType_ScdoGetAddress: 12001,
|
|
26224
|
-
MessageType_ScdoAddress: 12002,
|
|
26225
|
-
MessageType_ScdoSignTx: 12003,
|
|
26226
|
-
MessageType_ScdoSignedTx: 12004,
|
|
26227
|
-
MessageType_ScdoTxAck: 12005,
|
|
26228
|
-
MessageType_ScdoSignMessage: 12006,
|
|
26229
|
-
MessageType_ScdoSignedMessage: 12007,
|
|
26230
26207
|
MessageType_AlephiumGetAddress: 12101,
|
|
26231
26208
|
MessageType_AlephiumAddress: 12102,
|
|
26232
26209
|
MessageType_AlephiumSignTx: 12103,
|
|
@@ -26249,11 +26226,6 @@ var nested = {
|
|
|
26249
26226
|
MessageType_NeoAddress: 12302,
|
|
26250
26227
|
MessageType_NeoSignTx: 12303,
|
|
26251
26228
|
MessageType_NeoSignedTx: 12304,
|
|
26252
|
-
MessageType_UiviewShowAddressRequest: 30200,
|
|
26253
|
-
MessageType_UiviewShowPublicKeyRequest: 30201,
|
|
26254
|
-
MessageType_UiviewConfirmTxRequest: 30202,
|
|
26255
|
-
MessageType_UiviewConfirmSignMessageRequest: 30203,
|
|
26256
|
-
MessageType_UiviewResponse: 30204,
|
|
26257
26229
|
MessageType_DeviceFactoryInfoSet: 60000,
|
|
26258
26230
|
MessageType_DeviceFactoryInfoGet: 60001,
|
|
26259
26231
|
MessageType_DeviceFactoryInfo: 60002,
|
|
@@ -26274,19 +26246,11 @@ var nested = {
|
|
|
26274
26246
|
MessageType_DeviceCertificateRead: 60422,
|
|
26275
26247
|
MessageType_DeviceCertificateSignature: 60423,
|
|
26276
26248
|
MessageType_DeviceCertificateSign: 60424,
|
|
26277
|
-
|
|
26278
|
-
MessageType_GetWallpaper: 60431,
|
|
26279
|
-
MessageType_Wallpaper: 60432,
|
|
26249
|
+
MessageType_DeviceMiscUsbMscControl: 60440,
|
|
26280
26250
|
MessageType_DeviceInfoGet: 60600,
|
|
26281
26251
|
MessageType_DeviceInfo: 60601,
|
|
26282
26252
|
MessageType_DeviceStatusGet: 60602,
|
|
26283
26253
|
MessageType_DeviceStatus: 60603,
|
|
26284
|
-
MessageType_DevGetOnboardingStatus: 60604,
|
|
26285
|
-
MessageType_DevOnboardingStatus: 60605,
|
|
26286
|
-
MessageType_DeviceSessionGet: 60606,
|
|
26287
|
-
MessageType_DeviceSession: 60607,
|
|
26288
|
-
MessageType_DeviceSessionAskPin: 60608,
|
|
26289
|
-
MessageType_DeviceSessionAskPassphrase: 60609,
|
|
26290
26254
|
MessageType_FilesystemPermissionFix: 60800,
|
|
26291
26255
|
MessageType_FilesystemPathInfo: 60801,
|
|
26292
26256
|
MessageType_FilesystemPathInfoQuery: 60802,
|
|
@@ -26302,7 +26266,13 @@ var nested = {
|
|
|
26302
26266
|
MessageType_DeviceFirmwareUpdateRequest: 61000,
|
|
26303
26267
|
MessageType_DeviceFirmwareUpdateStatusGet: 61001,
|
|
26304
26268
|
MessageType_DeviceFirmwareUpdateStatus: 61002,
|
|
26305
|
-
|
|
26269
|
+
MessageType_DeviceSessionGet: 61200,
|
|
26270
|
+
MessageType_DeviceSession: 61201,
|
|
26271
|
+
MessageType_DeviceSessionAskPin: 61202,
|
|
26272
|
+
MessageType_DeviceSessionAskPassphrase: 61203,
|
|
26273
|
+
MessageType_PortfolioUpdate: 61400,
|
|
26274
|
+
MessageType_OnboardingStatusGet: 61600,
|
|
26275
|
+
MessageType_OnboardingStatus: 61601
|
|
26306
26276
|
},
|
|
26307
26277
|
reserved: [
|
|
26308
26278
|
[
|
|
@@ -31779,30 +31749,6 @@ var nested = {
|
|
|
31779
31749
|
}
|
|
31780
31750
|
}
|
|
31781
31751
|
},
|
|
31782
|
-
InternalMyAddressRequest: {
|
|
31783
|
-
fields: {
|
|
31784
|
-
coin_type: {
|
|
31785
|
-
rule: "required",
|
|
31786
|
-
type: "uint32",
|
|
31787
|
-
id: 1
|
|
31788
|
-
},
|
|
31789
|
-
chain_id: {
|
|
31790
|
-
rule: "required",
|
|
31791
|
-
type: "uint32",
|
|
31792
|
-
id: 2
|
|
31793
|
-
},
|
|
31794
|
-
account_index: {
|
|
31795
|
-
rule: "required",
|
|
31796
|
-
type: "uint32",
|
|
31797
|
-
id: 3
|
|
31798
|
-
},
|
|
31799
|
-
derive_type: {
|
|
31800
|
-
rule: "required",
|
|
31801
|
-
type: "uint32",
|
|
31802
|
-
id: 4
|
|
31803
|
-
}
|
|
31804
|
-
}
|
|
31805
|
-
},
|
|
31806
31752
|
KaspaGetAddress: {
|
|
31807
31753
|
fields: {
|
|
31808
31754
|
address_n: {
|
|
@@ -32007,29 +31953,6 @@ var nested = {
|
|
|
32007
31953
|
}
|
|
32008
31954
|
}
|
|
32009
31955
|
},
|
|
32010
|
-
StartSession: {
|
|
32011
|
-
fields: {
|
|
32012
|
-
session_id: {
|
|
32013
|
-
type: "bytes",
|
|
32014
|
-
id: 1
|
|
32015
|
-
},
|
|
32016
|
-
_skip_passphrase: {
|
|
32017
|
-
type: "bool",
|
|
32018
|
-
id: 2,
|
|
32019
|
-
options: {
|
|
32020
|
-
deprecated: true
|
|
32021
|
-
}
|
|
32022
|
-
},
|
|
32023
|
-
derive_cardano: {
|
|
32024
|
-
type: "bool",
|
|
32025
|
-
id: 3
|
|
32026
|
-
}
|
|
32027
|
-
}
|
|
32028
|
-
},
|
|
32029
|
-
EndSession: {
|
|
32030
|
-
fields: {
|
|
32031
|
-
}
|
|
32032
|
-
},
|
|
32033
31956
|
GetFeatures: {
|
|
32034
31957
|
fields: {
|
|
32035
31958
|
}
|
|
@@ -33166,49 +33089,6 @@ var nested = {
|
|
|
33166
33089
|
}
|
|
33167
33090
|
}
|
|
33168
33091
|
},
|
|
33169
|
-
WallpaperTarget: {
|
|
33170
|
-
values: {
|
|
33171
|
-
Home: 0,
|
|
33172
|
-
Lock: 1
|
|
33173
|
-
}
|
|
33174
|
-
},
|
|
33175
|
-
SetWallpaper: {
|
|
33176
|
-
fields: {
|
|
33177
|
-
target: {
|
|
33178
|
-
rule: "required",
|
|
33179
|
-
type: "WallpaperTarget",
|
|
33180
|
-
id: 1
|
|
33181
|
-
},
|
|
33182
|
-
path: {
|
|
33183
|
-
rule: "required",
|
|
33184
|
-
type: "string",
|
|
33185
|
-
id: 2
|
|
33186
|
-
}
|
|
33187
|
-
}
|
|
33188
|
-
},
|
|
33189
|
-
GetWallpaper: {
|
|
33190
|
-
fields: {
|
|
33191
|
-
target: {
|
|
33192
|
-
rule: "required",
|
|
33193
|
-
type: "WallpaperTarget",
|
|
33194
|
-
id: 1
|
|
33195
|
-
}
|
|
33196
|
-
}
|
|
33197
|
-
},
|
|
33198
|
-
Wallpaper: {
|
|
33199
|
-
fields: {
|
|
33200
|
-
target: {
|
|
33201
|
-
rule: "required",
|
|
33202
|
-
type: "WallpaperTarget",
|
|
33203
|
-
id: 1
|
|
33204
|
-
},
|
|
33205
|
-
path: {
|
|
33206
|
-
rule: "required",
|
|
33207
|
-
type: "string",
|
|
33208
|
-
id: 2
|
|
33209
|
-
}
|
|
33210
|
-
}
|
|
33211
|
-
},
|
|
33212
33092
|
ResourceUpdate: {
|
|
33213
33093
|
fields: {
|
|
33214
33094
|
file_name: {
|
|
@@ -37379,162 +37259,6 @@ var nested = {
|
|
|
37379
37259
|
}
|
|
37380
37260
|
}
|
|
37381
37261
|
},
|
|
37382
|
-
ViewAmount: {
|
|
37383
|
-
fields: {
|
|
37384
|
-
is_unlimited: {
|
|
37385
|
-
rule: "required",
|
|
37386
|
-
type: "bool",
|
|
37387
|
-
id: 1
|
|
37388
|
-
},
|
|
37389
|
-
num: {
|
|
37390
|
-
rule: "required",
|
|
37391
|
-
type: "string",
|
|
37392
|
-
id: 2
|
|
37393
|
-
}
|
|
37394
|
-
}
|
|
37395
|
-
},
|
|
37396
|
-
ViewDetail: {
|
|
37397
|
-
fields: {
|
|
37398
|
-
key: {
|
|
37399
|
-
rule: "required",
|
|
37400
|
-
type: "uint32",
|
|
37401
|
-
id: 1
|
|
37402
|
-
},
|
|
37403
|
-
value: {
|
|
37404
|
-
rule: "required",
|
|
37405
|
-
type: "string",
|
|
37406
|
-
id: 2
|
|
37407
|
-
},
|
|
37408
|
-
is_overview: {
|
|
37409
|
-
rule: "required",
|
|
37410
|
-
type: "bool",
|
|
37411
|
-
id: 3
|
|
37412
|
-
},
|
|
37413
|
-
has_icon: {
|
|
37414
|
-
rule: "required",
|
|
37415
|
-
type: "bool",
|
|
37416
|
-
id: 4
|
|
37417
|
-
}
|
|
37418
|
-
}
|
|
37419
|
-
},
|
|
37420
|
-
ViewTipType: {
|
|
37421
|
-
values: {
|
|
37422
|
-
Default: 0,
|
|
37423
|
-
Highlight: 1,
|
|
37424
|
-
Recommend: 2,
|
|
37425
|
-
Warning: 3,
|
|
37426
|
-
Danger: 4
|
|
37427
|
-
}
|
|
37428
|
-
},
|
|
37429
|
-
ViewTip: {
|
|
37430
|
-
fields: {
|
|
37431
|
-
type: {
|
|
37432
|
-
rule: "required",
|
|
37433
|
-
type: "ViewTipType",
|
|
37434
|
-
id: 1
|
|
37435
|
-
},
|
|
37436
|
-
text: {
|
|
37437
|
-
rule: "required",
|
|
37438
|
-
type: "string",
|
|
37439
|
-
id: 2
|
|
37440
|
-
}
|
|
37441
|
-
}
|
|
37442
|
-
},
|
|
37443
|
-
ViewRawData: {
|
|
37444
|
-
fields: {
|
|
37445
|
-
initial_data: {
|
|
37446
|
-
rule: "required",
|
|
37447
|
-
type: "string",
|
|
37448
|
-
id: 1
|
|
37449
|
-
},
|
|
37450
|
-
placeholder: {
|
|
37451
|
-
rule: "required",
|
|
37452
|
-
type: "uint32",
|
|
37453
|
-
id: 2
|
|
37454
|
-
}
|
|
37455
|
-
}
|
|
37456
|
-
},
|
|
37457
|
-
ViewSignLayout: {
|
|
37458
|
-
values: {
|
|
37459
|
-
LayoutDefault: 0,
|
|
37460
|
-
LayoutSafeTxCreate: 1,
|
|
37461
|
-
LayoutFinalConfirm: 2,
|
|
37462
|
-
Layout7702: 3,
|
|
37463
|
-
LayoutFlat: 4,
|
|
37464
|
-
LayoutEthApprove: 5
|
|
37465
|
-
}
|
|
37466
|
-
},
|
|
37467
|
-
ViewSignPage: {
|
|
37468
|
-
fields: {
|
|
37469
|
-
title: {
|
|
37470
|
-
rule: "required",
|
|
37471
|
-
type: "string",
|
|
37472
|
-
id: 1
|
|
37473
|
-
},
|
|
37474
|
-
amount: {
|
|
37475
|
-
type: "ViewAmount",
|
|
37476
|
-
id: 2
|
|
37477
|
-
},
|
|
37478
|
-
general: {
|
|
37479
|
-
rule: "repeated",
|
|
37480
|
-
type: "ViewDetail",
|
|
37481
|
-
id: 3
|
|
37482
|
-
},
|
|
37483
|
-
tip: {
|
|
37484
|
-
type: "ViewTip",
|
|
37485
|
-
id: 4
|
|
37486
|
-
},
|
|
37487
|
-
raw_data: {
|
|
37488
|
-
type: "ViewRawData",
|
|
37489
|
-
id: 5
|
|
37490
|
-
},
|
|
37491
|
-
slide_to_confirm: {
|
|
37492
|
-
type: "bool",
|
|
37493
|
-
id: 6,
|
|
37494
|
-
options: {
|
|
37495
|
-
"default": true
|
|
37496
|
-
}
|
|
37497
|
-
},
|
|
37498
|
-
layout: {
|
|
37499
|
-
type: "ViewSignLayout",
|
|
37500
|
-
id: 7,
|
|
37501
|
-
options: {
|
|
37502
|
-
"default": "LayoutDefault"
|
|
37503
|
-
}
|
|
37504
|
-
}
|
|
37505
|
-
}
|
|
37506
|
-
},
|
|
37507
|
-
ViewVerifyPage: {
|
|
37508
|
-
fields: {
|
|
37509
|
-
title: {
|
|
37510
|
-
rule: "required",
|
|
37511
|
-
type: "string",
|
|
37512
|
-
id: 1
|
|
37513
|
-
},
|
|
37514
|
-
address: {
|
|
37515
|
-
rule: "required",
|
|
37516
|
-
type: "string",
|
|
37517
|
-
id: 2
|
|
37518
|
-
},
|
|
37519
|
-
path: {
|
|
37520
|
-
rule: "required",
|
|
37521
|
-
type: "string",
|
|
37522
|
-
id: 3
|
|
37523
|
-
},
|
|
37524
|
-
network: {
|
|
37525
|
-
type: "string",
|
|
37526
|
-
id: 4
|
|
37527
|
-
},
|
|
37528
|
-
derive_type: {
|
|
37529
|
-
type: "string",
|
|
37530
|
-
id: 5
|
|
37531
|
-
},
|
|
37532
|
-
value_key: {
|
|
37533
|
-
type: "uint32",
|
|
37534
|
-
id: 6
|
|
37535
|
-
}
|
|
37536
|
-
}
|
|
37537
|
-
},
|
|
37538
37262
|
WebAuthnListResidentCredentials: {
|
|
37539
37263
|
fields: {
|
|
37540
37264
|
}
|
|
@@ -37636,17 +37360,18 @@ var nested = {
|
|
|
37636
37360
|
type: "uint32",
|
|
37637
37361
|
id: 1
|
|
37638
37362
|
},
|
|
37363
|
+
build_fingerprint: {
|
|
37364
|
+
rule: "required",
|
|
37365
|
+
type: "string",
|
|
37366
|
+
id: 2
|
|
37367
|
+
},
|
|
37639
37368
|
supported_messages: {
|
|
37640
37369
|
rule: "repeated",
|
|
37641
37370
|
type: "uint32",
|
|
37642
|
-
id:
|
|
37371
|
+
id: 3,
|
|
37643
37372
|
options: {
|
|
37644
37373
|
packed: false
|
|
37645
37374
|
}
|
|
37646
|
-
},
|
|
37647
|
-
protobuf_definition: {
|
|
37648
|
-
type: "string",
|
|
37649
|
-
id: 3
|
|
37650
37375
|
}
|
|
37651
37376
|
}
|
|
37652
37377
|
},
|
|
@@ -37876,109 +37601,11 @@ var nested = {
|
|
|
37876
37601
|
}
|
|
37877
37602
|
}
|
|
37878
37603
|
},
|
|
37879
|
-
|
|
37880
|
-
values: {
|
|
37881
|
-
FW_MGMT_TARGET_INVALID: 0,
|
|
37882
|
-
FW_MGMT_TARGET_CRATE: 1,
|
|
37883
|
-
FW_MGMT_TARGET_ROMLOADER: 2,
|
|
37884
|
-
FW_MGMT_TARGET_BOOTLOADER: 3,
|
|
37885
|
-
FW_MGMT_TARGET_APPLICATION_P1: 4,
|
|
37886
|
-
FW_MGMT_TARGET_APPLICATION_P2: 5,
|
|
37887
|
-
FW_MGMT_TARGET_COPROCESSOR: 6,
|
|
37888
|
-
FW_MGMT_TARGET_SE01: 7,
|
|
37889
|
-
FW_MGMT_TARGET_SE02: 8,
|
|
37890
|
-
FW_MGMT_TARGET_SE03: 9,
|
|
37891
|
-
FW_MGMT_TARGET_SE04: 10
|
|
37892
|
-
}
|
|
37893
|
-
},
|
|
37894
|
-
DeviceFirmwareUpdateTaskStatus: {
|
|
37895
|
-
values: {
|
|
37896
|
-
FW_MGMT_UPDATER_TASK_STATUS_PENDING: 0,
|
|
37897
|
-
FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS: 1,
|
|
37898
|
-
FW_MGMT_UPDATER_TASK_STATUS_FINISHED: 2,
|
|
37899
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND: 3,
|
|
37900
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ: 4,
|
|
37901
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE: 5,
|
|
37902
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY: 6,
|
|
37903
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL: 7,
|
|
37904
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT: 8,
|
|
37905
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY: 9,
|
|
37906
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS: 10
|
|
37907
|
-
}
|
|
37908
|
-
},
|
|
37909
|
-
DeviceFirmwareTarget: {
|
|
37604
|
+
DeviceMiscUsbMscControl: {
|
|
37910
37605
|
fields: {
|
|
37911
|
-
|
|
37606
|
+
enable: {
|
|
37912
37607
|
rule: "required",
|
|
37913
|
-
type: "DeviceFirmwareTargetType",
|
|
37914
|
-
id: 1
|
|
37915
|
-
},
|
|
37916
|
-
path: {
|
|
37917
|
-
rule: "required",
|
|
37918
|
-
type: "string",
|
|
37919
|
-
id: 2
|
|
37920
|
-
}
|
|
37921
|
-
}
|
|
37922
|
-
},
|
|
37923
|
-
DeviceFirmwareUpdateRequest: {
|
|
37924
|
-
fields: {
|
|
37925
|
-
targets: {
|
|
37926
|
-
rule: "repeated",
|
|
37927
|
-
type: "DeviceFirmwareTarget",
|
|
37928
|
-
id: 1
|
|
37929
|
-
}
|
|
37930
|
-
}
|
|
37931
|
-
},
|
|
37932
|
-
DeviceFirmwareUpdateRecord: {
|
|
37933
|
-
fields: {
|
|
37934
|
-
target_id: {
|
|
37935
|
-
rule: "required",
|
|
37936
|
-
type: "DeviceFirmwareTargetType",
|
|
37937
|
-
id: 1
|
|
37938
|
-
},
|
|
37939
|
-
status: {
|
|
37940
|
-
type: "DeviceFirmwareUpdateTaskStatus",
|
|
37941
|
-
id: 10
|
|
37942
|
-
},
|
|
37943
|
-
payload_version: {
|
|
37944
|
-
type: "uint32",
|
|
37945
|
-
id: 20
|
|
37946
|
-
},
|
|
37947
|
-
path: {
|
|
37948
|
-
type: "string",
|
|
37949
|
-
id: 30
|
|
37950
|
-
}
|
|
37951
|
-
}
|
|
37952
|
-
},
|
|
37953
|
-
DeviceFirmwareUpdateRecordFields: {
|
|
37954
|
-
fields: {
|
|
37955
|
-
status: {
|
|
37956
37608
|
type: "bool",
|
|
37957
|
-
id: 10
|
|
37958
|
-
},
|
|
37959
|
-
payload_version: {
|
|
37960
|
-
type: "bool",
|
|
37961
|
-
id: 20
|
|
37962
|
-
},
|
|
37963
|
-
path: {
|
|
37964
|
-
type: "bool",
|
|
37965
|
-
id: 30
|
|
37966
|
-
}
|
|
37967
|
-
}
|
|
37968
|
-
},
|
|
37969
|
-
DeviceFirmwareUpdateStatusGet: {
|
|
37970
|
-
fields: {
|
|
37971
|
-
fields: {
|
|
37972
|
-
type: "DeviceFirmwareUpdateRecordFields",
|
|
37973
|
-
id: 1
|
|
37974
|
-
}
|
|
37975
|
-
}
|
|
37976
|
-
},
|
|
37977
|
-
DeviceFirmwareUpdateStatus: {
|
|
37978
|
-
fields: {
|
|
37979
|
-
records: {
|
|
37980
|
-
rule: "repeated",
|
|
37981
|
-
type: "DeviceFirmwareUpdateRecord",
|
|
37982
37609
|
id: 1
|
|
37983
37610
|
}
|
|
37984
37611
|
}
|
|
@@ -38083,6 +37710,113 @@ var nested = {
|
|
|
38083
37710
|
}
|
|
38084
37711
|
}
|
|
38085
37712
|
},
|
|
37713
|
+
DeviceFirmwareTargetType: {
|
|
37714
|
+
values: {
|
|
37715
|
+
FW_MGMT_TARGET_INVALID: 0,
|
|
37716
|
+
FW_MGMT_TARGET_CRATE: 1,
|
|
37717
|
+
FW_MGMT_TARGET_ROMLOADER: 2,
|
|
37718
|
+
FW_MGMT_TARGET_BOOTLOADER: 3,
|
|
37719
|
+
FW_MGMT_TARGET_APPLICATION_P1: 4,
|
|
37720
|
+
FW_MGMT_TARGET_APPLICATION_P2: 5,
|
|
37721
|
+
FW_MGMT_TARGET_COPROCESSOR: 6,
|
|
37722
|
+
FW_MGMT_TARGET_SE01: 7,
|
|
37723
|
+
FW_MGMT_TARGET_SE02: 8,
|
|
37724
|
+
FW_MGMT_TARGET_SE03: 9,
|
|
37725
|
+
FW_MGMT_TARGET_SE04: 10
|
|
37726
|
+
}
|
|
37727
|
+
},
|
|
37728
|
+
DeviceFirmwareUpdateTaskStatus: {
|
|
37729
|
+
values: {
|
|
37730
|
+
FW_MGMT_UPDATER_TASK_STATUS_PENDING: 0,
|
|
37731
|
+
FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS: 1,
|
|
37732
|
+
FW_MGMT_UPDATER_TASK_STATUS_FINISHED: 2,
|
|
37733
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND: 3,
|
|
37734
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ: 4,
|
|
37735
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE: 5,
|
|
37736
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY: 6,
|
|
37737
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL: 7,
|
|
37738
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT: 8,
|
|
37739
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY: 9,
|
|
37740
|
+
FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS: 10
|
|
37741
|
+
}
|
|
37742
|
+
},
|
|
37743
|
+
DeviceFirmwareTarget: {
|
|
37744
|
+
fields: {
|
|
37745
|
+
target_id: {
|
|
37746
|
+
rule: "required",
|
|
37747
|
+
type: "DeviceFirmwareTargetType",
|
|
37748
|
+
id: 1
|
|
37749
|
+
},
|
|
37750
|
+
path: {
|
|
37751
|
+
rule: "required",
|
|
37752
|
+
type: "string",
|
|
37753
|
+
id: 2
|
|
37754
|
+
}
|
|
37755
|
+
}
|
|
37756
|
+
},
|
|
37757
|
+
DeviceFirmwareUpdateRequest: {
|
|
37758
|
+
fields: {
|
|
37759
|
+
targets: {
|
|
37760
|
+
rule: "repeated",
|
|
37761
|
+
type: "DeviceFirmwareTarget",
|
|
37762
|
+
id: 1
|
|
37763
|
+
}
|
|
37764
|
+
}
|
|
37765
|
+
},
|
|
37766
|
+
DeviceFirmwareUpdateRecord: {
|
|
37767
|
+
fields: {
|
|
37768
|
+
target_id: {
|
|
37769
|
+
rule: "required",
|
|
37770
|
+
type: "DeviceFirmwareTargetType",
|
|
37771
|
+
id: 1
|
|
37772
|
+
},
|
|
37773
|
+
status: {
|
|
37774
|
+
type: "DeviceFirmwareUpdateTaskStatus",
|
|
37775
|
+
id: 10
|
|
37776
|
+
},
|
|
37777
|
+
payload_version: {
|
|
37778
|
+
type: "uint32",
|
|
37779
|
+
id: 20
|
|
37780
|
+
},
|
|
37781
|
+
path: {
|
|
37782
|
+
type: "string",
|
|
37783
|
+
id: 30
|
|
37784
|
+
}
|
|
37785
|
+
}
|
|
37786
|
+
},
|
|
37787
|
+
DeviceFirmwareUpdateRecordFields: {
|
|
37788
|
+
fields: {
|
|
37789
|
+
status: {
|
|
37790
|
+
type: "bool",
|
|
37791
|
+
id: 10
|
|
37792
|
+
},
|
|
37793
|
+
payload_version: {
|
|
37794
|
+
type: "bool",
|
|
37795
|
+
id: 20
|
|
37796
|
+
},
|
|
37797
|
+
path: {
|
|
37798
|
+
type: "bool",
|
|
37799
|
+
id: 30
|
|
37800
|
+
}
|
|
37801
|
+
}
|
|
37802
|
+
},
|
|
37803
|
+
DeviceFirmwareUpdateStatusGet: {
|
|
37804
|
+
fields: {
|
|
37805
|
+
fields: {
|
|
37806
|
+
type: "DeviceFirmwareUpdateRecordFields",
|
|
37807
|
+
id: 1
|
|
37808
|
+
}
|
|
37809
|
+
}
|
|
37810
|
+
},
|
|
37811
|
+
DeviceFirmwareUpdateStatus: {
|
|
37812
|
+
fields: {
|
|
37813
|
+
records: {
|
|
37814
|
+
rule: "repeated",
|
|
37815
|
+
type: "DeviceFirmwareUpdateRecord",
|
|
37816
|
+
id: 1
|
|
37817
|
+
}
|
|
37818
|
+
}
|
|
37819
|
+
},
|
|
38086
37820
|
DeviceType: {
|
|
38087
37821
|
values: {
|
|
38088
37822
|
CLASSIC1: 0,
|
|
@@ -38233,10 +37967,6 @@ var nested = {
|
|
|
38233
37967
|
se4: {
|
|
38234
37968
|
type: "bool",
|
|
38235
37969
|
id: 430
|
|
38236
|
-
},
|
|
38237
|
-
status: {
|
|
38238
|
-
type: "bool",
|
|
38239
|
-
id: 10000
|
|
38240
37970
|
}
|
|
38241
37971
|
}
|
|
38242
37972
|
},
|
|
@@ -38306,10 +38036,6 @@ var nested = {
|
|
|
38306
38036
|
se4: {
|
|
38307
38037
|
type: "DeviceSEInfo",
|
|
38308
38038
|
id: 430
|
|
38309
|
-
},
|
|
38310
|
-
status: {
|
|
38311
|
-
type: "DeviceStatus",
|
|
38312
|
-
id: 10000
|
|
38313
38039
|
}
|
|
38314
38040
|
}
|
|
38315
38041
|
},
|
|
@@ -38323,11 +38049,26 @@ var nested = {
|
|
|
38323
38049
|
DeviceSessionError_Busy: 5
|
|
38324
38050
|
}
|
|
38325
38051
|
},
|
|
38052
|
+
DeviceSessionSeedDomain: {
|
|
38053
|
+
values: {
|
|
38054
|
+
SeedDomain_Standard: 1,
|
|
38055
|
+
SeedDomain_Cardano: 2
|
|
38056
|
+
}
|
|
38057
|
+
},
|
|
38326
38058
|
DeviceSessionGet: {
|
|
38327
38059
|
fields: {
|
|
38328
38060
|
session_id: {
|
|
38329
38061
|
type: "bytes",
|
|
38330
38062
|
id: 1
|
|
38063
|
+
},
|
|
38064
|
+
btc_test_address: {
|
|
38065
|
+
type: "string",
|
|
38066
|
+
id: 2
|
|
38067
|
+
},
|
|
38068
|
+
seed_domains: {
|
|
38069
|
+
rule: "repeated",
|
|
38070
|
+
type: "DeviceSessionSeedDomain",
|
|
38071
|
+
id: 3
|
|
38331
38072
|
}
|
|
38332
38073
|
}
|
|
38333
38074
|
},
|
|
@@ -38365,6 +38106,7 @@ var nested = {
|
|
|
38365
38106
|
id: 1
|
|
38366
38107
|
},
|
|
38367
38108
|
on_device: {
|
|
38109
|
+
rule: "required",
|
|
38368
38110
|
type: "bool",
|
|
38369
38111
|
id: 2
|
|
38370
38112
|
}
|
|
@@ -38411,89 +38153,6 @@ var nested = {
|
|
|
38411
38153
|
fields: {
|
|
38412
38154
|
}
|
|
38413
38155
|
},
|
|
38414
|
-
DevOnboardingStep: {
|
|
38415
|
-
values: {
|
|
38416
|
-
DEV_ONBOARDING_STEP_UNKNOWN: 0,
|
|
38417
|
-
DEV_ONBOARDING_STEP_CHECKING: 1,
|
|
38418
|
-
DEV_ONBOARDING_STEP_PERSONALIZATION: 2,
|
|
38419
|
-
DEV_ONBOARDING_STEP_PIN: 3,
|
|
38420
|
-
DEV_ONBOARDING_STEP_SETUP: 4,
|
|
38421
|
-
DEV_ONBOARDING_STEP_DONE: 5
|
|
38422
|
-
}
|
|
38423
|
-
},
|
|
38424
|
-
DevOnboardingPhase: {
|
|
38425
|
-
values: {
|
|
38426
|
-
DEV_ONBOARDING_PHASE_UNKNOWN: 0,
|
|
38427
|
-
DEV_ONBOARDING_PHASE_SAFETY_CHECK: 1,
|
|
38428
|
-
DEV_ONBOARDING_PHASE_PIN_SETUP: 2,
|
|
38429
|
-
DEV_ONBOARDING_PHASE_FINGERPRINT_SETUP: 3,
|
|
38430
|
-
DEV_ONBOARDING_PHASE_SETUP_CHOICE: 4,
|
|
38431
|
-
DEV_ONBOARDING_PHASE_WALLET_CREATE_START: 5,
|
|
38432
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW: 6,
|
|
38433
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM: 7,
|
|
38434
|
-
DEV_ONBOARDING_PHASE_RESTORE_METHOD_CHOICE: 8,
|
|
38435
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE: 9,
|
|
38436
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_RESTORE: 10,
|
|
38437
|
-
DEV_ONBOARDING_PHASE_WALLET_READY: 11,
|
|
38438
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT: 12,
|
|
38439
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP: 13
|
|
38440
|
-
}
|
|
38441
|
-
},
|
|
38442
|
-
DevOnboardingSetupKind: {
|
|
38443
|
-
values: {
|
|
38444
|
-
DEV_ONBOARDING_SETUP_KIND_UNKNOWN: 0,
|
|
38445
|
-
DEV_ONBOARDING_SETUP_KIND_CHOICE: 1,
|
|
38446
|
-
DEV_ONBOARDING_SETUP_KIND_CREATE: 2,
|
|
38447
|
-
DEV_ONBOARDING_SETUP_KIND_RESTORE: 3
|
|
38448
|
-
}
|
|
38449
|
-
},
|
|
38450
|
-
DevOnboardingSetupMethod: {
|
|
38451
|
-
values: {
|
|
38452
|
-
DEV_ONBOARDING_SETUP_METHOD_UNKNOWN: 0,
|
|
38453
|
-
DEV_ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE: 1,
|
|
38454
|
-
DEV_ONBOARDING_SETUP_METHOD_SEEDCARD: 2
|
|
38455
|
-
}
|
|
38456
|
-
},
|
|
38457
|
-
DevOnboardingSetupStatus: {
|
|
38458
|
-
fields: {
|
|
38459
|
-
kind: {
|
|
38460
|
-
type: "DevOnboardingSetupKind",
|
|
38461
|
-
id: 1
|
|
38462
|
-
},
|
|
38463
|
-
method: {
|
|
38464
|
-
type: "DevOnboardingSetupMethod",
|
|
38465
|
-
id: 2
|
|
38466
|
-
}
|
|
38467
|
-
}
|
|
38468
|
-
},
|
|
38469
|
-
DevGetOnboardingStatus: {
|
|
38470
|
-
fields: {
|
|
38471
|
-
}
|
|
38472
|
-
},
|
|
38473
|
-
DevOnboardingStatus: {
|
|
38474
|
-
fields: {
|
|
38475
|
-
step: {
|
|
38476
|
-
type: "DevOnboardingStep",
|
|
38477
|
-
id: 1
|
|
38478
|
-
},
|
|
38479
|
-
phase: {
|
|
38480
|
-
type: "DevOnboardingPhase",
|
|
38481
|
-
id: 2
|
|
38482
|
-
},
|
|
38483
|
-
setup: {
|
|
38484
|
-
type: "DevOnboardingSetupStatus",
|
|
38485
|
-
id: 3
|
|
38486
|
-
},
|
|
38487
|
-
pin_set: {
|
|
38488
|
-
type: "bool",
|
|
38489
|
-
id: 4
|
|
38490
|
-
},
|
|
38491
|
-
wallet_initialized: {
|
|
38492
|
-
type: "bool",
|
|
38493
|
-
id: 5
|
|
38494
|
-
}
|
|
38495
|
-
}
|
|
38496
|
-
},
|
|
38497
38156
|
FilesystemPermissionFix: {
|
|
38498
38157
|
fields: {
|
|
38499
38158
|
}
|
|
@@ -38721,10 +38380,273 @@ var nested = {
|
|
|
38721
38380
|
}
|
|
38722
38381
|
}
|
|
38723
38382
|
},
|
|
38383
|
+
InternalMyAddressRequest: {
|
|
38384
|
+
fields: {
|
|
38385
|
+
coin_type: {
|
|
38386
|
+
rule: "required",
|
|
38387
|
+
type: "uint32",
|
|
38388
|
+
id: 1
|
|
38389
|
+
},
|
|
38390
|
+
chain_id: {
|
|
38391
|
+
rule: "required",
|
|
38392
|
+
type: "uint32",
|
|
38393
|
+
id: 2
|
|
38394
|
+
},
|
|
38395
|
+
account_index: {
|
|
38396
|
+
rule: "required",
|
|
38397
|
+
type: "uint32",
|
|
38398
|
+
id: 3
|
|
38399
|
+
},
|
|
38400
|
+
derive_type: {
|
|
38401
|
+
rule: "required",
|
|
38402
|
+
type: "uint32",
|
|
38403
|
+
id: 4
|
|
38404
|
+
}
|
|
38405
|
+
}
|
|
38406
|
+
},
|
|
38407
|
+
OnboardingStep: {
|
|
38408
|
+
values: {
|
|
38409
|
+
ONBOARDING_STEP_UNKNOWN: 0,
|
|
38410
|
+
ONBOARDING_STEP_CHECKING: 1,
|
|
38411
|
+
ONBOARDING_STEP_PERSONALIZATION: 2,
|
|
38412
|
+
ONBOARDING_STEP_PIN: 3,
|
|
38413
|
+
ONBOARDING_STEP_SETUP: 4,
|
|
38414
|
+
ONBOARDING_STEP_DONE: 5
|
|
38415
|
+
}
|
|
38416
|
+
},
|
|
38417
|
+
OnboardingPhase: {
|
|
38418
|
+
values: {
|
|
38419
|
+
ONBOARDING_PHASE_UNKNOWN: 0,
|
|
38420
|
+
ONBOARDING_PHASE_SAFETY_CHECK: 1,
|
|
38421
|
+
ONBOARDING_PHASE_PIN_SETUP: 2,
|
|
38422
|
+
ONBOARDING_PHASE_FINGERPRINT_SETUP: 3,
|
|
38423
|
+
ONBOARDING_PHASE_SETUP_CHOICE: 4,
|
|
38424
|
+
ONBOARDING_PHASE_WALLET_CREATE_START: 5,
|
|
38425
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW: 6,
|
|
38426
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM: 7,
|
|
38427
|
+
ONBOARDING_PHASE_RESTORE_METHOD_CHOICE: 8,
|
|
38428
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE: 9,
|
|
38429
|
+
ONBOARDING_PHASE_SEEDCARD_RESTORE: 10,
|
|
38430
|
+
ONBOARDING_PHASE_WALLET_READY: 11,
|
|
38431
|
+
ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT: 12,
|
|
38432
|
+
ONBOARDING_PHASE_SEEDCARD_BACKUP: 13
|
|
38433
|
+
}
|
|
38434
|
+
},
|
|
38435
|
+
OnboardingSetupKind: {
|
|
38436
|
+
values: {
|
|
38437
|
+
ONBOARDING_SETUP_KIND_UNKNOWN: 0,
|
|
38438
|
+
ONBOARDING_SETUP_KIND_CHOICE: 1,
|
|
38439
|
+
ONBOARDING_SETUP_KIND_CREATE: 2,
|
|
38440
|
+
ONBOARDING_SETUP_KIND_RESTORE: 3
|
|
38441
|
+
}
|
|
38442
|
+
},
|
|
38443
|
+
OnboardingSetupMethod: {
|
|
38444
|
+
values: {
|
|
38445
|
+
ONBOARDING_SETUP_METHOD_UNKNOWN: 0,
|
|
38446
|
+
ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE: 1,
|
|
38447
|
+
ONBOARDING_SETUP_METHOD_SEEDCARD: 2
|
|
38448
|
+
}
|
|
38449
|
+
},
|
|
38450
|
+
OnboardingSetupStatus: {
|
|
38451
|
+
fields: {
|
|
38452
|
+
kind: {
|
|
38453
|
+
type: "OnboardingSetupKind",
|
|
38454
|
+
id: 1
|
|
38455
|
+
},
|
|
38456
|
+
method: {
|
|
38457
|
+
type: "OnboardingSetupMethod",
|
|
38458
|
+
id: 2
|
|
38459
|
+
}
|
|
38460
|
+
}
|
|
38461
|
+
},
|
|
38462
|
+
OnboardingStatusGet: {
|
|
38463
|
+
fields: {
|
|
38464
|
+
}
|
|
38465
|
+
},
|
|
38466
|
+
OnboardingStatus: {
|
|
38467
|
+
fields: {
|
|
38468
|
+
step: {
|
|
38469
|
+
type: "OnboardingStep",
|
|
38470
|
+
id: 1
|
|
38471
|
+
},
|
|
38472
|
+
phase: {
|
|
38473
|
+
type: "OnboardingPhase",
|
|
38474
|
+
id: 2
|
|
38475
|
+
},
|
|
38476
|
+
setup: {
|
|
38477
|
+
type: "OnboardingSetupStatus",
|
|
38478
|
+
id: 3
|
|
38479
|
+
},
|
|
38480
|
+
pin_set: {
|
|
38481
|
+
type: "bool",
|
|
38482
|
+
id: 4
|
|
38483
|
+
},
|
|
38484
|
+
wallet_initialized: {
|
|
38485
|
+
type: "bool",
|
|
38486
|
+
id: 5
|
|
38487
|
+
}
|
|
38488
|
+
}
|
|
38489
|
+
},
|
|
38724
38490
|
PortfolioUpdate: {
|
|
38725
38491
|
fields: {
|
|
38726
38492
|
}
|
|
38727
38493
|
},
|
|
38494
|
+
ViewAmount: {
|
|
38495
|
+
fields: {
|
|
38496
|
+
is_unlimited: {
|
|
38497
|
+
rule: "required",
|
|
38498
|
+
type: "bool",
|
|
38499
|
+
id: 1
|
|
38500
|
+
},
|
|
38501
|
+
num: {
|
|
38502
|
+
rule: "required",
|
|
38503
|
+
type: "string",
|
|
38504
|
+
id: 2
|
|
38505
|
+
}
|
|
38506
|
+
}
|
|
38507
|
+
},
|
|
38508
|
+
ViewDetail: {
|
|
38509
|
+
fields: {
|
|
38510
|
+
key: {
|
|
38511
|
+
rule: "required",
|
|
38512
|
+
type: "uint32",
|
|
38513
|
+
id: 1
|
|
38514
|
+
},
|
|
38515
|
+
value: {
|
|
38516
|
+
rule: "required",
|
|
38517
|
+
type: "string",
|
|
38518
|
+
id: 2
|
|
38519
|
+
},
|
|
38520
|
+
is_overview: {
|
|
38521
|
+
rule: "required",
|
|
38522
|
+
type: "bool",
|
|
38523
|
+
id: 3
|
|
38524
|
+
},
|
|
38525
|
+
has_icon: {
|
|
38526
|
+
rule: "required",
|
|
38527
|
+
type: "bool",
|
|
38528
|
+
id: 4
|
|
38529
|
+
}
|
|
38530
|
+
}
|
|
38531
|
+
},
|
|
38532
|
+
ViewTipType: {
|
|
38533
|
+
values: {
|
|
38534
|
+
Default: 0,
|
|
38535
|
+
Highlight: 1,
|
|
38536
|
+
Recommend: 2,
|
|
38537
|
+
Warning: 3,
|
|
38538
|
+
Danger: 4
|
|
38539
|
+
}
|
|
38540
|
+
},
|
|
38541
|
+
ViewTip: {
|
|
38542
|
+
fields: {
|
|
38543
|
+
type: {
|
|
38544
|
+
rule: "required",
|
|
38545
|
+
type: "ViewTipType",
|
|
38546
|
+
id: 1
|
|
38547
|
+
},
|
|
38548
|
+
text: {
|
|
38549
|
+
rule: "required",
|
|
38550
|
+
type: "string",
|
|
38551
|
+
id: 2
|
|
38552
|
+
}
|
|
38553
|
+
}
|
|
38554
|
+
},
|
|
38555
|
+
ViewRawData: {
|
|
38556
|
+
fields: {
|
|
38557
|
+
initial_data: {
|
|
38558
|
+
rule: "required",
|
|
38559
|
+
type: "string",
|
|
38560
|
+
id: 1
|
|
38561
|
+
},
|
|
38562
|
+
placeholder: {
|
|
38563
|
+
rule: "required",
|
|
38564
|
+
type: "uint32",
|
|
38565
|
+
id: 2
|
|
38566
|
+
}
|
|
38567
|
+
}
|
|
38568
|
+
},
|
|
38569
|
+
ViewSignLayout: {
|
|
38570
|
+
values: {
|
|
38571
|
+
LayoutDefault: 0,
|
|
38572
|
+
LayoutSafeTxCreate: 1,
|
|
38573
|
+
LayoutFinalConfirm: 2,
|
|
38574
|
+
Layout7702: 3,
|
|
38575
|
+
LayoutFlat: 4,
|
|
38576
|
+
LayoutEthApprove: 5
|
|
38577
|
+
}
|
|
38578
|
+
},
|
|
38579
|
+
ViewSignPage: {
|
|
38580
|
+
fields: {
|
|
38581
|
+
title: {
|
|
38582
|
+
rule: "required",
|
|
38583
|
+
type: "string",
|
|
38584
|
+
id: 1
|
|
38585
|
+
},
|
|
38586
|
+
amount: {
|
|
38587
|
+
type: "ViewAmount",
|
|
38588
|
+
id: 2
|
|
38589
|
+
},
|
|
38590
|
+
general: {
|
|
38591
|
+
rule: "repeated",
|
|
38592
|
+
type: "ViewDetail",
|
|
38593
|
+
id: 3
|
|
38594
|
+
},
|
|
38595
|
+
tip: {
|
|
38596
|
+
type: "ViewTip",
|
|
38597
|
+
id: 4
|
|
38598
|
+
},
|
|
38599
|
+
raw_data: {
|
|
38600
|
+
type: "ViewRawData",
|
|
38601
|
+
id: 5
|
|
38602
|
+
},
|
|
38603
|
+
slide_to_confirm: {
|
|
38604
|
+
type: "bool",
|
|
38605
|
+
id: 6,
|
|
38606
|
+
options: {
|
|
38607
|
+
"default": true
|
|
38608
|
+
}
|
|
38609
|
+
},
|
|
38610
|
+
layout: {
|
|
38611
|
+
type: "ViewSignLayout",
|
|
38612
|
+
id: 7,
|
|
38613
|
+
options: {
|
|
38614
|
+
"default": "LayoutDefault"
|
|
38615
|
+
}
|
|
38616
|
+
}
|
|
38617
|
+
}
|
|
38618
|
+
},
|
|
38619
|
+
ViewVerifyPage: {
|
|
38620
|
+
fields: {
|
|
38621
|
+
title: {
|
|
38622
|
+
rule: "required",
|
|
38623
|
+
type: "string",
|
|
38624
|
+
id: 1
|
|
38625
|
+
},
|
|
38626
|
+
address: {
|
|
38627
|
+
rule: "required",
|
|
38628
|
+
type: "string",
|
|
38629
|
+
id: 2
|
|
38630
|
+
},
|
|
38631
|
+
path: {
|
|
38632
|
+
rule: "required",
|
|
38633
|
+
type: "string",
|
|
38634
|
+
id: 3
|
|
38635
|
+
},
|
|
38636
|
+
network: {
|
|
38637
|
+
type: "string",
|
|
38638
|
+
id: 4
|
|
38639
|
+
},
|
|
38640
|
+
derive_type: {
|
|
38641
|
+
type: "string",
|
|
38642
|
+
id: 5
|
|
38643
|
+
},
|
|
38644
|
+
value_key: {
|
|
38645
|
+
type: "uint32",
|
|
38646
|
+
id: 6
|
|
38647
|
+
}
|
|
38648
|
+
}
|
|
38649
|
+
},
|
|
38728
38650
|
google: {
|
|
38729
38651
|
nested: {
|
|
38730
38652
|
protobuf: {
|
|
@@ -40023,6 +39945,8 @@ const DEVICE = {
|
|
|
40023
39945
|
LOADING: 'device-loading',
|
|
40024
39946
|
BUTTON: 'button',
|
|
40025
39947
|
PIN: 'pin',
|
|
39948
|
+
PIN_ON_DEVICE: 'pin_on_device',
|
|
39949
|
+
PIN_ON_DEVICE_COMPLETE: 'pin_on_device_complete',
|
|
40026
39950
|
PASSPHRASE: 'passphrase',
|
|
40027
39951
|
PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
|
|
40028
39952
|
ATTACH_PIN_ON_DEVICE: 'attach_pin_on_device',
|
|
@@ -40144,14 +40068,11 @@ function assertCompleteDeviceSession(message) {
|
|
|
40144
40068
|
}
|
|
40145
40069
|
}
|
|
40146
40070
|
|
|
40147
|
-
function isDeviceLockedError(error) {
|
|
40148
|
-
return (typeof error === 'object' &&
|
|
40149
|
-
error !== null &&
|
|
40150
|
-
'errorCode' in error &&
|
|
40151
|
-
error.errorCode === hdShared.HardwareErrorCode.DeviceLocked);
|
|
40152
|
-
}
|
|
40153
|
-
|
|
40154
40071
|
const HOST_PASSPHRASE_MAX_BYTES = 50;
|
|
40072
|
+
const isWalletSessionInvalidError = (error) => typeof error === 'object' &&
|
|
40073
|
+
error !== null &&
|
|
40074
|
+
'errorCode' in error &&
|
|
40075
|
+
error.errorCode === hdShared.HardwareErrorCode.WalletSessionInvalid;
|
|
40155
40076
|
const utf8ByteLength = (value) => {
|
|
40156
40077
|
var _a;
|
|
40157
40078
|
let length = 0;
|
|
@@ -40182,42 +40103,46 @@ function refreshProtocolV2DeviceStatus(device) {
|
|
|
40182
40103
|
return device.updateProtocolV2Status(status);
|
|
40183
40104
|
});
|
|
40184
40105
|
}
|
|
40185
|
-
|
|
40186
|
-
|
|
40187
|
-
|
|
40106
|
+
function ensureProtocolV2WalletSessionUnlocked(device) {
|
|
40107
|
+
var _a, _b, _c;
|
|
40108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40109
|
+
if (!device.isProtocolV2() || ((_a = device.isBootloader) === null || _a === void 0 ? void 0 : _a.call(device)) || ((_b = device.isRomloader) === null || _b === void 0 ? void 0 : _b.call(device))) {
|
|
40110
|
+
return false;
|
|
40111
|
+
}
|
|
40112
|
+
yield refreshProtocolV2DeviceStatus(device);
|
|
40113
|
+
if (((_c = device.state) === null || _c === void 0 ? void 0 : _c.status.unlocked) !== false) {
|
|
40114
|
+
return false;
|
|
40115
|
+
}
|
|
40116
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main, {
|
|
40117
|
+
source: 'unlock-coordinator',
|
|
40118
|
+
reason: 'device-locked',
|
|
40119
|
+
deviceOnly: true,
|
|
40120
|
+
});
|
|
40121
|
+
return true;
|
|
40188
40122
|
});
|
|
40123
|
+
}
|
|
40124
|
+
const negotiateEventlessWalletSession = (device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40125
|
+
yield device.ensureProtocolV2RuntimeContext();
|
|
40189
40126
|
});
|
|
40190
|
-
const getDeviceSession = (device, request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40191
|
-
|
|
40192
|
-
|
|
40193
|
-
|
|
40194
|
-
|
|
40195
|
-
|
|
40196
|
-
|
|
40197
|
-
|
|
40198
|
-
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40199
|
-
return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
|
|
40200
|
-
}
|
|
40127
|
+
const getDeviceSession = (device, request, deriveCardano) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40128
|
+
const payload = deriveCardano === undefined
|
|
40129
|
+
? request
|
|
40130
|
+
: Object.assign(Object.assign({}, request), { seed_domains: [
|
|
40131
|
+
hdTransport.DeviceSessionSeedDomain.SeedDomain_Standard,
|
|
40132
|
+
...(deriveCardano ? [hdTransport.DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
|
|
40133
|
+
] });
|
|
40134
|
+
return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', payload);
|
|
40201
40135
|
});
|
|
40202
|
-
const askDevicePassphrase = (device,
|
|
40203
|
-
|
|
40204
|
-
try {
|
|
40205
|
-
yield request();
|
|
40206
|
-
}
|
|
40207
|
-
catch (error) {
|
|
40208
|
-
if (!isDeviceLockedError(error)) {
|
|
40209
|
-
throw error;
|
|
40210
|
-
}
|
|
40211
|
-
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40212
|
-
yield request();
|
|
40213
|
-
}
|
|
40136
|
+
const askDevicePassphrase = (device, requestPayload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40137
|
+
yield device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', requestPayload);
|
|
40214
40138
|
yield refreshProtocolV2DeviceStatus(device);
|
|
40215
40139
|
});
|
|
40216
|
-
const selectDeviceSession = (device, expectedPassphraseState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40217
|
-
var _a;
|
|
40140
|
+
const selectDeviceSession = (device, expectedPassphraseState, deriveCardano) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40141
|
+
var _a, _b, _c;
|
|
40218
40142
|
const existsAttachPinUser = ((_a = device.features) === null || _a === void 0 ? void 0 : _a.attachToPinEnabled) === true;
|
|
40219
40143
|
const metadata = Object.assign({ source: 'wallet-session-coordinator', reason: expectedPassphraseState ? 'session-recovery' : 'open-wallet' }, (expectedPassphraseState ? { expectedPassphraseState } : {}));
|
|
40220
|
-
const
|
|
40144
|
+
const passphraseInteraction = (_b = device.createProtocolV2UiPhaseMetadata) === null || _b === void 0 ? void 0 : _b.call(device, 'passphrase', 'start');
|
|
40145
|
+
const response = yield device.commands.promptPassphrase(Object.assign(Object.assign({ existsAttachPinUser, deviceOnly: false }, metadata), (passphraseInteraction ? { interaction: passphraseInteraction } : {})), { cancelDeviceOnReject: false });
|
|
40221
40146
|
const hostPassphrase = typeof response.passphrase === 'string' ? response.passphrase.normalize('NFKD') : undefined;
|
|
40222
40147
|
const hasHostPassphrase = typeof hostPassphrase === 'string' && hostPassphrase.length > 0;
|
|
40223
40148
|
const hostPassphraseByteLength = hasHostPassphrase ? utf8ByteLength(hostPassphrase) : undefined;
|
|
@@ -40239,22 +40164,30 @@ const selectDeviceSession = (device, expectedPassphraseState) => __awaiter(void
|
|
|
40239
40164
|
if (!existsAttachPinUser) {
|
|
40240
40165
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Attach PIN wallet selection is unavailable on this device.');
|
|
40241
40166
|
}
|
|
40242
|
-
device.
|
|
40243
|
-
|
|
40244
|
-
|
|
40167
|
+
const attachPinInteraction = (_c = device.createProtocolV2UiPhaseMetadata) === null || _c === void 0 ? void 0 : _c.call(device, 'pin', 'start');
|
|
40168
|
+
device.emit(DEVICE.ATTACH_PIN_ON_DEVICE, device, Object.assign(Object.assign({}, metadata), (attachPinInteraction ? { interaction: attachPinInteraction } : {})));
|
|
40169
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.AttachToPin, {
|
|
40170
|
+
emitUiEvent: false,
|
|
40171
|
+
interaction: attachPinInteraction,
|
|
40172
|
+
});
|
|
40173
|
+
return getDeviceSession(device, {}, deriveCardano);
|
|
40245
40174
|
}
|
|
40246
40175
|
if (hasHostPassphrase) {
|
|
40247
|
-
yield askDevicePassphrase(device,
|
|
40248
|
-
|
|
40176
|
+
yield askDevicePassphrase(device, {
|
|
40177
|
+
passphrase: hostPassphrase,
|
|
40178
|
+
on_device: false,
|
|
40179
|
+
});
|
|
40180
|
+
return getDeviceSession(device, {}, deriveCardano);
|
|
40249
40181
|
}
|
|
40250
|
-
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
40251
|
-
yield askDevicePassphrase(device);
|
|
40252
|
-
return getDeviceSession(device, {});
|
|
40182
|
+
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, Object.assign(Object.assign({}, metadata), (passphraseInteraction ? { interaction: passphraseInteraction } : {})));
|
|
40183
|
+
yield askDevicePassphrase(device, { on_device: true });
|
|
40184
|
+
return getDeviceSession(device, {}, deriveCardano);
|
|
40253
40185
|
});
|
|
40254
40186
|
function getProtocolV2WalletSession(device, options) {
|
|
40255
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
40187
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
40256
40188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40257
|
-
|
|
40189
|
+
const forceWalletSelection = (options === null || options === void 0 ? void 0 : options.forceWalletSelection) === true || (options === null || options === void 0 ? void 0 : options.initSession) === true;
|
|
40190
|
+
if (forceWalletSelection) {
|
|
40258
40191
|
if (options.onlyMainPin) {
|
|
40259
40192
|
(_a = device.clearStandardInternalState) === null || _a === void 0 ? void 0 : _a.call(device);
|
|
40260
40193
|
}
|
|
@@ -40278,36 +40211,89 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40278
40211
|
: undefined;
|
|
40279
40212
|
let response;
|
|
40280
40213
|
let resumed = false;
|
|
40214
|
+
let mainWalletSelected = false;
|
|
40215
|
+
const clearCurrentWalletSession = () => {
|
|
40216
|
+
var _a;
|
|
40217
|
+
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40218
|
+
(_a = device.clearStandardInternalState) === null || _a === void 0 ? void 0 : _a.call(device);
|
|
40219
|
+
}
|
|
40220
|
+
else {
|
|
40221
|
+
device.clearInternalState();
|
|
40222
|
+
}
|
|
40223
|
+
};
|
|
40224
|
+
const rejectMismatchedAttachPinWallet = () => __awaiter(this, void 0, void 0, function* () {
|
|
40225
|
+
const features = yield refreshProtocolV2DeviceStatus(device);
|
|
40226
|
+
if (features.unlockedAttachPin !== true) {
|
|
40227
|
+
return;
|
|
40228
|
+
}
|
|
40229
|
+
try {
|
|
40230
|
+
yield device.lockDevice();
|
|
40231
|
+
}
|
|
40232
|
+
catch (_h) {
|
|
40233
|
+
}
|
|
40234
|
+
clearCurrentWalletSession();
|
|
40235
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
40236
|
+
});
|
|
40237
|
+
const selectMainWallet = (force = false) => __awaiter(this, void 0, void 0, function* () {
|
|
40238
|
+
if (force || !mainWalletSelected) {
|
|
40239
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main, {
|
|
40240
|
+
source: 'wallet-session-coordinator',
|
|
40241
|
+
reason: expectedPassphraseState ? 'session-recovery' : 'open-wallet',
|
|
40242
|
+
deviceOnly: true,
|
|
40243
|
+
});
|
|
40244
|
+
mainWalletSelected = true;
|
|
40245
|
+
}
|
|
40246
|
+
});
|
|
40281
40247
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40282
40248
|
expectedPassphraseState = cachedStandardSession === null || cachedStandardSession === void 0 ? void 0 : cachedStandardSession.passphraseState;
|
|
40283
40249
|
if (cachedStandardSession) {
|
|
40284
40250
|
try {
|
|
40285
|
-
if (
|
|
40286
|
-
yield
|
|
40251
|
+
if (options === null || options === void 0 ? void 0 : options.selectMainWalletBeforeRestore) {
|
|
40252
|
+
yield selectMainWallet();
|
|
40287
40253
|
}
|
|
40288
40254
|
response = yield getDeviceSession(device, {
|
|
40289
40255
|
session_id: cachedStandardSession.sessionId,
|
|
40290
|
-
|
|
40256
|
+
btc_test_address: cachedStandardSession.passphraseState,
|
|
40257
|
+
}, options === null || options === void 0 ? void 0 : options.deriveCardano);
|
|
40291
40258
|
resumed = true;
|
|
40292
40259
|
}
|
|
40293
40260
|
catch (error) {
|
|
40294
|
-
(
|
|
40295
|
-
|
|
40261
|
+
(_d = device.clearStandardInternalState) === null || _d === void 0 ? void 0 : _d.call(device);
|
|
40262
|
+
if (!isWalletSessionInvalidError(error)) {
|
|
40263
|
+
throw error;
|
|
40264
|
+
}
|
|
40265
|
+
resumed = false;
|
|
40296
40266
|
}
|
|
40297
40267
|
}
|
|
40298
40268
|
if (!response) {
|
|
40299
|
-
yield
|
|
40300
|
-
response = yield getDeviceSession(device, {});
|
|
40269
|
+
yield selectMainWallet();
|
|
40270
|
+
response = yield getDeviceSession(device, {}, options === null || options === void 0 ? void 0 : options.deriveCardano);
|
|
40301
40271
|
}
|
|
40302
40272
|
}
|
|
40303
40273
|
else if (cachedSessionId && expectedPassphraseState) {
|
|
40304
40274
|
try {
|
|
40305
|
-
response = yield getDeviceSession(device, {
|
|
40275
|
+
response = yield getDeviceSession(device, {
|
|
40276
|
+
session_id: cachedSessionId,
|
|
40277
|
+
btc_test_address: expectedPassphraseState,
|
|
40278
|
+
}, options === null || options === void 0 ? void 0 : options.deriveCardano);
|
|
40306
40279
|
resumed = true;
|
|
40307
40280
|
}
|
|
40308
40281
|
catch (error) {
|
|
40309
40282
|
device.clearInternalState();
|
|
40310
|
-
|
|
40283
|
+
if ((options === null || options === void 0 ? void 0 : options.resumeOnly) || !isWalletSessionInvalidError(error)) {
|
|
40284
|
+
throw error;
|
|
40285
|
+
}
|
|
40286
|
+
resumed = false;
|
|
40287
|
+
}
|
|
40288
|
+
}
|
|
40289
|
+
else if (expectedPassphraseState) {
|
|
40290
|
+
try {
|
|
40291
|
+
response = yield getDeviceSession(device, { btc_test_address: expectedPassphraseState }, options === null || options === void 0 ? void 0 : options.deriveCardano);
|
|
40292
|
+
}
|
|
40293
|
+
catch (error) {
|
|
40294
|
+
if ((options === null || options === void 0 ? void 0 : options.resumeOnly) || !isWalletSessionInvalidError(error)) {
|
|
40295
|
+
throw error;
|
|
40296
|
+
}
|
|
40311
40297
|
}
|
|
40312
40298
|
}
|
|
40313
40299
|
if (!response) {
|
|
@@ -40315,7 +40301,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40315
40301
|
device.clearInternalState();
|
|
40316
40302
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
40317
40303
|
}
|
|
40318
|
-
response = yield selectDeviceSession(device, expectedPassphraseState);
|
|
40304
|
+
response = yield selectDeviceSession(device, expectedPassphraseState, options === null || options === void 0 ? void 0 : options.deriveCardano);
|
|
40319
40305
|
}
|
|
40320
40306
|
let { message } = response;
|
|
40321
40307
|
try {
|
|
@@ -40323,7 +40309,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40323
40309
|
}
|
|
40324
40310
|
catch (error) {
|
|
40325
40311
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40326
|
-
(
|
|
40312
|
+
(_e = device.clearStandardInternalState) === null || _e === void 0 ? void 0 : _e.call(device);
|
|
40327
40313
|
}
|
|
40328
40314
|
else {
|
|
40329
40315
|
device.clearInternalState();
|
|
@@ -40332,14 +40318,19 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40332
40318
|
}
|
|
40333
40319
|
if (expectedPassphraseState && expectedPassphraseState !== message.btc_test_address) {
|
|
40334
40320
|
resumed = false;
|
|
40321
|
+
yield rejectMismatchedAttachPinWallet();
|
|
40322
|
+
if (options === null || options === void 0 ? void 0 : options.resumeOnly) {
|
|
40323
|
+
device.clearInternalState();
|
|
40324
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
40325
|
+
}
|
|
40335
40326
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40336
|
-
(
|
|
40337
|
-
yield
|
|
40338
|
-
response = yield getDeviceSession(device, {});
|
|
40327
|
+
(_f = device.clearStandardInternalState) === null || _f === void 0 ? void 0 : _f.call(device);
|
|
40328
|
+
yield selectMainWallet(true);
|
|
40329
|
+
response = yield getDeviceSession(device, {}, options === null || options === void 0 ? void 0 : options.deriveCardano);
|
|
40339
40330
|
}
|
|
40340
40331
|
else {
|
|
40341
40332
|
device.clearInternalState();
|
|
40342
|
-
response = yield selectDeviceSession(device, expectedPassphraseState);
|
|
40333
|
+
response = yield selectDeviceSession(device, expectedPassphraseState, options === null || options === void 0 ? void 0 : options.deriveCardano);
|
|
40343
40334
|
}
|
|
40344
40335
|
message = response.message;
|
|
40345
40336
|
try {
|
|
@@ -40347,7 +40338,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40347
40338
|
}
|
|
40348
40339
|
catch (error) {
|
|
40349
40340
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40350
|
-
(
|
|
40341
|
+
(_g = device.clearStandardInternalState) === null || _g === void 0 ? void 0 : _g.call(device);
|
|
40351
40342
|
}
|
|
40352
40343
|
else {
|
|
40353
40344
|
device.clearInternalState();
|
|
@@ -40355,12 +40346,8 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40355
40346
|
throw error;
|
|
40356
40347
|
}
|
|
40357
40348
|
if (expectedPassphraseState !== message.btc_test_address) {
|
|
40358
|
-
|
|
40359
|
-
|
|
40360
|
-
}
|
|
40361
|
-
else {
|
|
40362
|
-
device.clearInternalState();
|
|
40363
|
-
}
|
|
40349
|
+
yield rejectMismatchedAttachPinWallet();
|
|
40350
|
+
clearCurrentWalletSession();
|
|
40364
40351
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
40365
40352
|
}
|
|
40366
40353
|
}
|
|
@@ -40369,7 +40356,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40369
40356
|
message.btc_test_address,
|
|
40370
40357
|
device.getCurrentDeviceId(),
|
|
40371
40358
|
message.session_id,
|
|
40372
|
-
|
|
40359
|
+
forceWalletSelection ? null : cachedSessionId !== null && cachedSessionId !== void 0 ? cachedSessionId : null,
|
|
40373
40360
|
];
|
|
40374
40361
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40375
40362
|
device.updateInternalState(...internalStateArgs, 'standard');
|
|
@@ -40380,16 +40367,17 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40380
40367
|
return {
|
|
40381
40368
|
passphraseState: message.btc_test_address,
|
|
40382
40369
|
newSession: message.session_id,
|
|
40383
|
-
unlockedAttachPin:
|
|
40370
|
+
unlockedAttachPin: mainWalletSelected ? false : undefined,
|
|
40384
40371
|
resumed,
|
|
40385
40372
|
};
|
|
40386
40373
|
});
|
|
40387
40374
|
}
|
|
40388
|
-
function restoreProtocolV2WalletSession(device, expectedPassphraseState) {
|
|
40375
|
+
function restoreProtocolV2WalletSession(device, expectedPassphraseState, deriveCardano) {
|
|
40389
40376
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40390
40377
|
return getProtocolV2WalletSession(device, {
|
|
40391
40378
|
expectedPassphraseState,
|
|
40392
40379
|
resumeOnly: true,
|
|
40380
|
+
deriveCardano,
|
|
40393
40381
|
});
|
|
40394
40382
|
});
|
|
40395
40383
|
}
|
|
@@ -40454,6 +40442,7 @@ const getPassphraseStateWithRefreshDeviceInfo = (device, options) => __awaiter(v
|
|
|
40454
40442
|
initSession: options === null || options === void 0 ? void 0 : options.initSession,
|
|
40455
40443
|
expectedPassphraseState: options === null || options === void 0 ? void 0 : options.expectPassphraseState,
|
|
40456
40444
|
onlyMainPin: options === null || options === void 0 ? void 0 : options.onlyMainPin,
|
|
40445
|
+
deriveCardano: options === null || options === void 0 ? void 0 : options.deriveCardano,
|
|
40457
40446
|
});
|
|
40458
40447
|
}
|
|
40459
40448
|
const { features } = device;
|
|
@@ -40496,6 +40485,7 @@ const getPassphraseState = (device, options) => __awaiter(void 0, void 0, void 0
|
|
|
40496
40485
|
initSession: options === null || options === void 0 ? void 0 : options.initSession,
|
|
40497
40486
|
expectedPassphraseState: options === null || options === void 0 ? void 0 : options.expectPassphraseState,
|
|
40498
40487
|
onlyMainPin: options === null || options === void 0 ? void 0 : options.onlyMainPin,
|
|
40488
|
+
deriveCardano: options === null || options === void 0 ? void 0 : options.deriveCardano,
|
|
40499
40489
|
});
|
|
40500
40490
|
}
|
|
40501
40491
|
const supportAttachPinCapability = existCapability(features, hdTransport.Enum_Capability.Capability_AttachToPin);
|
|
@@ -41944,18 +41934,18 @@ class DeviceCommands {
|
|
|
41944
41934
|
});
|
|
41945
41935
|
}
|
|
41946
41936
|
call(type, msg, options) {
|
|
41947
|
-
var _a;
|
|
41937
|
+
var _a, _b;
|
|
41948
41938
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41949
41939
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
41950
41940
|
if (!shouldReduceDebug) {
|
|
41951
|
-
Log$f.debug('[DeviceCommands] [call] Sending', type);
|
|
41941
|
+
Log$f.debug('[DeviceCommands] [call] Sending', type, hdTransport.getSafeTransportLogPayload(msg !== null && msg !== void 0 ? msg : {}, type));
|
|
41952
41942
|
}
|
|
41953
41943
|
try {
|
|
41954
41944
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
41955
41945
|
this.callPromise = promise;
|
|
41956
41946
|
const res = yield promise;
|
|
41957
41947
|
if (!shouldReduceDebug) {
|
|
41958
|
-
LogCore.debug('[DeviceCommands] [call] Received', res.type);
|
|
41948
|
+
LogCore.debug('[DeviceCommands] [call] Received', res.type, hdTransport.getSafeTransportLogPayload(res.message, res.type));
|
|
41959
41949
|
}
|
|
41960
41950
|
return res;
|
|
41961
41951
|
}
|
|
@@ -41963,6 +41953,7 @@ class DeviceCommands {
|
|
|
41963
41953
|
LogCore.debug('[DeviceCommands] [call] Received error', {
|
|
41964
41954
|
request: type,
|
|
41965
41955
|
errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
|
|
41956
|
+
response: hdTransport.getSafeTransportLogPayload((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data, type),
|
|
41966
41957
|
});
|
|
41967
41958
|
if (error.errorCode === hdShared.HardwareErrorCode.BleDeviceBondError) {
|
|
41968
41959
|
return {
|
|
@@ -41972,7 +41963,7 @@ class DeviceCommands {
|
|
|
41972
41963
|
},
|
|
41973
41964
|
};
|
|
41974
41965
|
}
|
|
41975
|
-
const responseData = (
|
|
41966
|
+
const responseData = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
41976
41967
|
let responseError = responseData === null || responseData === void 0 ? void 0 : responseData.error;
|
|
41977
41968
|
if (!responseError && responseData && typeof responseData === 'string') {
|
|
41978
41969
|
try {
|
|
@@ -42943,7 +42934,6 @@ class DeviceWalletSessionStore {
|
|
|
42943
42934
|
return (_a = this.walletSessions.get(deviceKey)) === null || _a === void 0 ? void 0 : _a.get(passphraseState);
|
|
42944
42935
|
}
|
|
42945
42936
|
set(deviceKey, passphraseState, sessionId) {
|
|
42946
|
-
var _a;
|
|
42947
42937
|
if (!deviceKey || !passphraseState || !sessionId)
|
|
42948
42938
|
return;
|
|
42949
42939
|
let deviceSessions = this.walletSessions.get(deviceKey);
|
|
@@ -42951,16 +42941,6 @@ class DeviceWalletSessionStore {
|
|
|
42951
42941
|
deviceSessions = new Map();
|
|
42952
42942
|
this.walletSessions.set(deviceKey, deviceSessions);
|
|
42953
42943
|
}
|
|
42954
|
-
if (!deviceSessions.has(passphraseState) &&
|
|
42955
|
-
deviceSessions.size >= DeviceWalletSessionStore.MAX_SESSIONS_PER_DEVICE) {
|
|
42956
|
-
const oldestPassphraseState = deviceSessions.keys().next().value;
|
|
42957
|
-
if (oldestPassphraseState) {
|
|
42958
|
-
deviceSessions.delete(oldestPassphraseState);
|
|
42959
|
-
if (((_a = this.standardWalletSessions.get(deviceKey)) === null || _a === void 0 ? void 0 : _a.passphraseState) === oldestPassphraseState) {
|
|
42960
|
-
this.standardWalletSessions.delete(deviceKey);
|
|
42961
|
-
}
|
|
42962
|
-
}
|
|
42963
|
-
}
|
|
42964
42944
|
deviceSessions.set(passphraseState, sessionId);
|
|
42965
42945
|
}
|
|
42966
42946
|
getStandard(deviceKey) {
|
|
@@ -43062,14 +43042,31 @@ class DeviceWalletSessionStore {
|
|
|
43062
43042
|
this.pendingSessions.clear();
|
|
43063
43043
|
}
|
|
43064
43044
|
}
|
|
43065
|
-
DeviceWalletSessionStore.MAX_SESSIONS_PER_DEVICE = 3;
|
|
43066
43045
|
const deviceWalletSessionStore = new DeviceWalletSessionStore();
|
|
43067
43046
|
|
|
43068
|
-
const
|
|
43069
|
-
if (
|
|
43047
|
+
const parseProtocolV2BuildFingerprint = (buildFingerprint) => {
|
|
43048
|
+
if (!buildFingerprint)
|
|
43049
|
+
return null;
|
|
43050
|
+
const [binary, version, commit, environment, buildType, ...extra] = buildFingerprint.split('__');
|
|
43051
|
+
if (extra.length > 0 ||
|
|
43052
|
+
(binary !== 'application' && binary !== 'bootloader' && binary !== 'romloader') ||
|
|
43053
|
+
!version ||
|
|
43054
|
+
!commit ||
|
|
43055
|
+
(environment !== 'PROD' && environment !== 'DEV') ||
|
|
43056
|
+
(buildType !== 'DEBUG' && buildType !== 'RELEASE')) {
|
|
43057
|
+
return null;
|
|
43058
|
+
}
|
|
43059
|
+
return { binary, version, commit, environment, buildType };
|
|
43060
|
+
};
|
|
43061
|
+
const getProtocolV2RuntimeMode = (protocolInfo) => {
|
|
43062
|
+
var _a;
|
|
43063
|
+
const binary = (_a = parseProtocolV2BuildFingerprint(protocolInfo.build_fingerprint)) === null || _a === void 0 ? void 0 : _a.binary;
|
|
43064
|
+
if (binary === 'application')
|
|
43070
43065
|
return 'normal';
|
|
43071
|
-
return
|
|
43066
|
+
return binary;
|
|
43072
43067
|
};
|
|
43068
|
+
const PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE = 60602;
|
|
43069
|
+
const supportsProtocolV2Message = (protocolInfo, messageType) => protocolInfo.supported_messages.includes(messageType);
|
|
43073
43070
|
const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
|
|
43074
43071
|
targets: {
|
|
43075
43072
|
hw: true,
|
|
@@ -43118,6 +43115,16 @@ const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
|
|
|
43118
43115
|
},
|
|
43119
43116
|
};
|
|
43120
43117
|
const PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS = 10 * 1000;
|
|
43118
|
+
function requestProtocolV2ProtocolInfo({ commands, timeoutMs, }) {
|
|
43119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43120
|
+
const response = timeoutMs === undefined
|
|
43121
|
+
? yield commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
43122
|
+
eventless_wallet_session: true,
|
|
43123
|
+
})
|
|
43124
|
+
: yield commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', { eventless_wallet_session: true }, { timeoutMs });
|
|
43125
|
+
return response.message;
|
|
43126
|
+
});
|
|
43127
|
+
}
|
|
43121
43128
|
function requestProtocolV2DeviceInfo({ commands, timeoutMs = PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS, request = PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST, }) {
|
|
43122
43129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43123
43130
|
const { message } = yield commands.typedCall('DeviceInfoGet', 'DeviceInfo', request, {
|
|
@@ -43142,6 +43149,22 @@ const parseRunOptions = (options) => {
|
|
|
43142
43149
|
return options;
|
|
43143
43150
|
};
|
|
43144
43151
|
const Log$e = getLogger(exports.LoggerNames.Device);
|
|
43152
|
+
const isProtocolV2DeviceStatusUnsupportedError = (error) => {
|
|
43153
|
+
var _a, _b, _c;
|
|
43154
|
+
if (error instanceof hdShared.HardwareError) {
|
|
43155
|
+
if (error.errorCode === hdShared.HardwareErrorCode.DeviceNotSupportMethod) {
|
|
43156
|
+
return true;
|
|
43157
|
+
}
|
|
43158
|
+
if (((_a = error.params) === null || _a === void 0 ? void 0 : _a.failureCode) === 'Failure_UnexpectedMessage') {
|
|
43159
|
+
return true;
|
|
43160
|
+
}
|
|
43161
|
+
}
|
|
43162
|
+
const message = error instanceof Error
|
|
43163
|
+
? error.message
|
|
43164
|
+
: String((_c = (_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error) !== null && _c !== void 0 ? _c : '');
|
|
43165
|
+
return (/^Failure_UnexpectedMessage(?:,|\b)/i.test(message) ||
|
|
43166
|
+
/\b(?:unsupported message|handler not registered|message handler not found)\b/i.test(message));
|
|
43167
|
+
};
|
|
43145
43168
|
function preloadSessionCache(deviceId, passphraseState, sessionId) {
|
|
43146
43169
|
deviceWalletSessionStore.set(deviceId, passphraseState, sessionId);
|
|
43147
43170
|
}
|
|
@@ -43174,6 +43197,7 @@ class Device extends events.exports {
|
|
|
43174
43197
|
this.deviceAcquired = false;
|
|
43175
43198
|
this.stateStore = new DeviceStateStore();
|
|
43176
43199
|
this.protocolV2StateNeedsReload = false;
|
|
43200
|
+
this.protocolV2UiInteractionCounter = 0;
|
|
43177
43201
|
this.externalState = [];
|
|
43178
43202
|
this.unavailableCapabilities = {};
|
|
43179
43203
|
this.instance = 0;
|
|
@@ -43647,14 +43671,7 @@ class Device extends events.exports {
|
|
|
43647
43671
|
if (options === null || options === void 0 ? void 0 : options.deriveCardano) {
|
|
43648
43672
|
payload.derive_cardano = true;
|
|
43649
43673
|
}
|
|
43650
|
-
|
|
43651
|
-
Boolean(internalState) ||
|
|
43652
|
-
Boolean(options === null || options === void 0 ? void 0 : options.passphraseState) ||
|
|
43653
|
-
(options === null || options === void 0 ? void 0 : options.deriveCardano) === true ||
|
|
43654
|
-
(options === null || options === void 0 ? void 0 : options.initSession) === true;
|
|
43655
|
-
if (requiresWalletInitialize) {
|
|
43656
|
-
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
43657
|
-
}
|
|
43674
|
+
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
43658
43675
|
}
|
|
43659
43676
|
catch (error) {
|
|
43660
43677
|
Log$e.error('Initialization failed:', error);
|
|
@@ -43739,11 +43756,7 @@ class Device extends events.exports {
|
|
|
43739
43756
|
}
|
|
43740
43757
|
}
|
|
43741
43758
|
if (refresh.has('status') && !initializedWithDeviceInfo) {
|
|
43742
|
-
|
|
43743
|
-
commands: this.commands,
|
|
43744
|
-
request: getProtocolV2DeviceInfoRequest(),
|
|
43745
|
-
}));
|
|
43746
|
-
yield this.probeProtocolV2RuntimeState(deviceInfo);
|
|
43759
|
+
yield this.probeProtocolV2RuntimeState(refreshedDeviceInfo);
|
|
43747
43760
|
}
|
|
43748
43761
|
if (refresh.has('settings') && ((_c = this.state) === null || _c === void 0 ? void 0 : _c.status.mode) === 'normal') {
|
|
43749
43762
|
const { message } = yield this.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
|
|
@@ -43803,8 +43816,68 @@ class Device extends events.exports {
|
|
|
43803
43816
|
this.updateState(mapFeaturesToState(normalized), source);
|
|
43804
43817
|
return this.features;
|
|
43805
43818
|
}
|
|
43819
|
+
ensureProtocolV2RuntimeContext(timeoutMs) {
|
|
43820
|
+
var _a, _b, _c, _d;
|
|
43821
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43822
|
+
const cachedProtocolInfo = (_a = this.protocolV2RuntimeContext) !== null && _a !== void 0 ? _a : (!this.protocolV2StateNeedsReload
|
|
43823
|
+
? (_d = (_c = (_b = this.state) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.protocolV2ProtocolInfo) !== null && _d !== void 0 ? _d : undefined
|
|
43824
|
+
: undefined);
|
|
43825
|
+
if (cachedProtocolInfo) {
|
|
43826
|
+
this.protocolV2RuntimeContext = cachedProtocolInfo;
|
|
43827
|
+
return cachedProtocolInfo;
|
|
43828
|
+
}
|
|
43829
|
+
if (this.protocolV2RuntimeContextPromise) {
|
|
43830
|
+
return this.protocolV2RuntimeContextPromise;
|
|
43831
|
+
}
|
|
43832
|
+
const requestToken = {};
|
|
43833
|
+
const pendingRequest = (() => __awaiter(this, void 0, void 0, function* () {
|
|
43834
|
+
const protocolInfo = yield requestProtocolV2ProtocolInfo({
|
|
43835
|
+
commands: this.commands,
|
|
43836
|
+
timeoutMs,
|
|
43837
|
+
});
|
|
43838
|
+
if (this.protocolV2RuntimeContextRequestToken !== requestToken) {
|
|
43839
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Protocol V2 runtime context was invalidated while loading.');
|
|
43840
|
+
}
|
|
43841
|
+
this.protocolV2RuntimeContext = protocolInfo;
|
|
43842
|
+
return protocolInfo;
|
|
43843
|
+
}))();
|
|
43844
|
+
this.protocolV2RuntimeContextRequestToken = requestToken;
|
|
43845
|
+
this.protocolV2RuntimeContextPromise = pendingRequest;
|
|
43846
|
+
try {
|
|
43847
|
+
return yield pendingRequest;
|
|
43848
|
+
}
|
|
43849
|
+
finally {
|
|
43850
|
+
if (this.protocolV2RuntimeContextPromise === pendingRequest) {
|
|
43851
|
+
this.protocolV2RuntimeContextPromise = undefined;
|
|
43852
|
+
}
|
|
43853
|
+
if (this.protocolV2RuntimeContextRequestToken === requestToken) {
|
|
43854
|
+
this.protocolV2RuntimeContextRequestToken = undefined;
|
|
43855
|
+
}
|
|
43856
|
+
}
|
|
43857
|
+
});
|
|
43858
|
+
}
|
|
43806
43859
|
probeProtocolV2RuntimeState(deviceInfo, timeoutMs) {
|
|
43860
|
+
var _a, _b, _c;
|
|
43807
43861
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43862
|
+
const protocolInfo = yield this.ensureProtocolV2RuntimeContext(timeoutMs);
|
|
43863
|
+
const runtimeMode = getProtocolV2RuntimeMode(protocolInfo);
|
|
43864
|
+
const runtimeDeviceInfo = deviceInfo !== null && deviceInfo !== void 0 ? deviceInfo : (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.protocolV2DeviceInfo;
|
|
43865
|
+
const protocolV2DeviceType = runtimeDeviceInfo
|
|
43866
|
+
? resolveProtocolV2DeviceIdentity((_c = runtimeDeviceInfo.hw) === null || _c === void 0 ? void 0 : _c.Device_type).deviceType
|
|
43867
|
+
: this.getCurrentDeviceType();
|
|
43868
|
+
if (runtimeMode === 'romloader' && protocolV2DeviceType !== hdShared.EDeviceType.Pro2) {
|
|
43869
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Protocol V2 romloader mode is only supported for Pro2.');
|
|
43870
|
+
}
|
|
43871
|
+
const deviceStatusSupported = supportsProtocolV2Message(protocolInfo, PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE);
|
|
43872
|
+
if (runtimeMode === 'bootloader' || runtimeMode === 'romloader') {
|
|
43873
|
+
return this.updateProtocolV2Features(deviceInfo, null, runtimeMode, protocolInfo);
|
|
43874
|
+
}
|
|
43875
|
+
if (!deviceStatusSupported) {
|
|
43876
|
+
if (runtimeMode === 'normal') {
|
|
43877
|
+
return this.updateProtocolV2Features(deviceInfo, null, runtimeMode, protocolInfo);
|
|
43878
|
+
}
|
|
43879
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Unknown Protocol V2 build fingerprint without DeviceStatusGet capability: ${protocolInfo.build_fingerprint}`);
|
|
43880
|
+
}
|
|
43808
43881
|
let deviceStatus;
|
|
43809
43882
|
try {
|
|
43810
43883
|
deviceStatus = yield requestProtocolV2DeviceStatus({
|
|
@@ -43813,28 +43886,24 @@ class Device extends events.exports {
|
|
|
43813
43886
|
});
|
|
43814
43887
|
}
|
|
43815
43888
|
catch (error) {
|
|
43816
|
-
|
|
43817
|
-
deviceInfo,
|
|
43818
|
-
|
|
43819
|
-
|
|
43820
|
-
Log$e.debug('Protocol V2 DeviceStatusGet unavailable; use temporary loader fallback', {
|
|
43821
|
-
runtimeMode,
|
|
43822
|
-
error: error instanceof Error ? error.message : String(error),
|
|
43823
|
-
});
|
|
43824
|
-
return this.updateProtocolV2Features(deviceInfo, null, runtimeMode);
|
|
43889
|
+
if (runtimeMode === undefined && isProtocolV2DeviceStatusUnsupportedError(error)) {
|
|
43890
|
+
return this.updateProtocolV2Features(deviceInfo, null, 'bootloader', protocolInfo);
|
|
43891
|
+
}
|
|
43892
|
+
throw error;
|
|
43825
43893
|
}
|
|
43826
|
-
return this.updateProtocolV2Features(deviceInfo, deviceStatus, 'normal');
|
|
43894
|
+
return this.updateProtocolV2Features(deviceInfo, deviceStatus, 'normal', protocolInfo);
|
|
43827
43895
|
});
|
|
43828
43896
|
}
|
|
43829
|
-
updateProtocolV2Features(deviceInfo, deviceStatus, runtimeMode) {
|
|
43897
|
+
updateProtocolV2Features(deviceInfo, deviceStatus, runtimeMode, protocolInfo) {
|
|
43830
43898
|
var _a;
|
|
43831
43899
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
43832
|
-
const resolvedMode = runtimeMode !== null && runtimeMode !== void 0 ? runtimeMode : (deviceStatus
|
|
43833
|
-
? getProtocolV2RuntimeMode({ deviceInfo, deviceStatusAvailable: true })
|
|
43834
|
-
: (_a = this.state) === null || _a === void 0 ? void 0 : _a.status.mode);
|
|
43900
|
+
const resolvedMode = runtimeMode !== null && runtimeMode !== void 0 ? runtimeMode : (deviceStatus ? 'normal' : (_a = this.state) === null || _a === void 0 ? void 0 : _a.status.mode);
|
|
43835
43901
|
if (deviceInfo) {
|
|
43836
43902
|
this.updateState(mapProtocolV2DeviceInfoToState(deviceInfo, resolvedMode), 'device-info');
|
|
43837
43903
|
}
|
|
43904
|
+
if (protocolInfo) {
|
|
43905
|
+
this.updateState({ raw: { protocolV2ProtocolInfo: protocolInfo } }, 'device-info');
|
|
43906
|
+
}
|
|
43838
43907
|
if (deviceStatus) {
|
|
43839
43908
|
this.updateState(mapProtocolV2DeviceStatusToState(deviceStatus), 'device-status');
|
|
43840
43909
|
}
|
|
@@ -43852,6 +43921,9 @@ class Device extends events.exports {
|
|
|
43852
43921
|
if (!this.isProtocolV2())
|
|
43853
43922
|
return;
|
|
43854
43923
|
this.protocolV2StateNeedsReload = true;
|
|
43924
|
+
this.protocolV2RuntimeContext = undefined;
|
|
43925
|
+
this.protocolV2RuntimeContextPromise = undefined;
|
|
43926
|
+
this.protocolV2RuntimeContextRequestToken = undefined;
|
|
43855
43927
|
this.clearPreInitialized();
|
|
43856
43928
|
}
|
|
43857
43929
|
invalidateAfterWipe() {
|
|
@@ -43859,9 +43931,14 @@ class Device extends events.exports {
|
|
|
43859
43931
|
if (deviceId) {
|
|
43860
43932
|
deviceWalletSessionStore.deleteDevice(deviceId);
|
|
43861
43933
|
}
|
|
43862
|
-
if (this.isProtocolV2()
|
|
43863
|
-
|
|
43934
|
+
if (this.isProtocolV2()) {
|
|
43935
|
+
if (this.originalDescriptor.path !== deviceId) {
|
|
43936
|
+
deviceWalletSessionStore.deleteDevice(this.originalDescriptor.path);
|
|
43937
|
+
}
|
|
43864
43938
|
this.protocolV2StateNeedsReload = true;
|
|
43939
|
+
this.protocolV2RuntimeContext = undefined;
|
|
43940
|
+
this.protocolV2RuntimeContextPromise = undefined;
|
|
43941
|
+
this.protocolV2RuntimeContextRequestToken = undefined;
|
|
43865
43942
|
}
|
|
43866
43943
|
this.passphraseState = undefined;
|
|
43867
43944
|
this.stateStore = new DeviceStateStore();
|
|
@@ -43872,6 +43949,9 @@ class Device extends events.exports {
|
|
|
43872
43949
|
if (!this.isProtocolV2())
|
|
43873
43950
|
return;
|
|
43874
43951
|
this.protocolV2StateNeedsReload = true;
|
|
43952
|
+
this.protocolV2RuntimeContext = undefined;
|
|
43953
|
+
this.protocolV2RuntimeContextPromise = undefined;
|
|
43954
|
+
this.protocolV2RuntimeContextRequestToken = undefined;
|
|
43875
43955
|
this.clearPreInitialized();
|
|
43876
43956
|
let loaderMode;
|
|
43877
43957
|
if (rebootType === hdTransport.DeviceRebootType.Bootloader) {
|
|
@@ -43897,13 +43977,13 @@ class Device extends events.exports {
|
|
|
43897
43977
|
attachToPinEnabled: null,
|
|
43898
43978
|
unlockedAttachPin: null,
|
|
43899
43979
|
},
|
|
43900
|
-
raw: { protocolV2DeviceStatus: null },
|
|
43980
|
+
raw: { protocolV2ProtocolInfo: null, protocolV2DeviceStatus: null },
|
|
43901
43981
|
}, 'transport-reconnect');
|
|
43902
43982
|
return;
|
|
43903
43983
|
}
|
|
43904
43984
|
this.updateState({
|
|
43905
43985
|
status: { mode: 'normal', unlocked: null },
|
|
43906
|
-
raw: { protocolV2DeviceStatus: null },
|
|
43986
|
+
raw: { protocolV2ProtocolInfo: null, protocolV2DeviceStatus: null },
|
|
43907
43987
|
}, 'transport-reconnect');
|
|
43908
43988
|
}
|
|
43909
43989
|
updateDescriptor(descriptor, forceUpdate = false) {
|
|
@@ -44110,7 +44190,14 @@ class Device extends events.exports {
|
|
|
44110
44190
|
isBootloader() {
|
|
44111
44191
|
if (!this.state)
|
|
44112
44192
|
return undefined;
|
|
44113
|
-
return this.state.status.mode === 'bootloader'
|
|
44193
|
+
return this.state.status.mode === 'bootloader';
|
|
44194
|
+
}
|
|
44195
|
+
isRomloader() {
|
|
44196
|
+
if (!this.state)
|
|
44197
|
+
return undefined;
|
|
44198
|
+
return (this.isProtocolV2() &&
|
|
44199
|
+
this.getCurrentDeviceType() === hdShared.EDeviceType.Pro2 &&
|
|
44200
|
+
this.state.status.mode === 'romloader');
|
|
44114
44201
|
}
|
|
44115
44202
|
isInitialized() {
|
|
44116
44203
|
if (!this.state)
|
|
@@ -44163,6 +44250,55 @@ class Device extends events.exports {
|
|
|
44163
44250
|
return res.message;
|
|
44164
44251
|
});
|
|
44165
44252
|
}
|
|
44253
|
+
beginProtocolV2UiInteraction() {
|
|
44254
|
+
if (!this.isProtocolV2())
|
|
44255
|
+
return;
|
|
44256
|
+
this.protocolV2UiInteraction = {
|
|
44257
|
+
interactionId: `${this.instanceId}:${Date.now()}:${++this.protocolV2UiInteractionCounter}`,
|
|
44258
|
+
phaseCounter: 0,
|
|
44259
|
+
sequence: 0,
|
|
44260
|
+
opened: false,
|
|
44261
|
+
};
|
|
44262
|
+
}
|
|
44263
|
+
createProtocolV2UiPhaseMetadata(phase, transition, options) {
|
|
44264
|
+
var _a;
|
|
44265
|
+
if (!this.isProtocolV2())
|
|
44266
|
+
return undefined;
|
|
44267
|
+
if (!this.protocolV2UiInteraction)
|
|
44268
|
+
this.beginProtocolV2UiInteraction();
|
|
44269
|
+
const interaction = this.protocolV2UiInteraction;
|
|
44270
|
+
if (!interaction)
|
|
44271
|
+
return undefined;
|
|
44272
|
+
const phaseId = (_a = options === null || options === void 0 ? void 0 : options.phaseId) !== null && _a !== void 0 ? _a : `${interaction.interactionId}:phase-${++interaction.phaseCounter}`;
|
|
44273
|
+
interaction.opened = true;
|
|
44274
|
+
interaction.sequence += 1;
|
|
44275
|
+
return Object.assign(Object.assign({ interactionId: interaction.interactionId, phaseId, sequence: interaction.sequence, phase,
|
|
44276
|
+
transition }, ((options === null || options === void 0 ? void 0 : options.outcome) ? { outcome: options.outcome } : {})), { protocol: 'V2' });
|
|
44277
|
+
}
|
|
44278
|
+
completeProtocolV2UiPhase(phase, outcome = 'succeeded') {
|
|
44279
|
+
return this.createProtocolV2UiPhaseMetadata(phase.phase, 'complete', {
|
|
44280
|
+
phaseId: phase.phaseId,
|
|
44281
|
+
outcome,
|
|
44282
|
+
});
|
|
44283
|
+
}
|
|
44284
|
+
finishProtocolV2UiInteraction(outcome = 'succeeded') {
|
|
44285
|
+
const interaction = this.protocolV2UiInteraction;
|
|
44286
|
+
if (!(interaction === null || interaction === void 0 ? void 0 : interaction.opened)) {
|
|
44287
|
+
this.protocolV2UiInteraction = undefined;
|
|
44288
|
+
return undefined;
|
|
44289
|
+
}
|
|
44290
|
+
const phaseId = `${interaction.interactionId}:phase-${Math.max(interaction.phaseCounter, 1)}`;
|
|
44291
|
+
const metadata = this.createProtocolV2UiPhaseMetadata('processing', 'finish', {
|
|
44292
|
+
phaseId,
|
|
44293
|
+
outcome,
|
|
44294
|
+
});
|
|
44295
|
+
this.protocolV2UiInteraction = undefined;
|
|
44296
|
+
return metadata;
|
|
44297
|
+
}
|
|
44298
|
+
hasOpenProtocolV2UiInteraction() {
|
|
44299
|
+
var _a;
|
|
44300
|
+
return ((_a = this.protocolV2UiInteraction) === null || _a === void 0 ? void 0 : _a.opened) === true;
|
|
44301
|
+
}
|
|
44166
44302
|
supportUnlockVersionRange() {
|
|
44167
44303
|
return {
|
|
44168
44304
|
pro: {
|
|
@@ -44170,28 +44306,50 @@ class Device extends events.exports {
|
|
|
44170
44306
|
},
|
|
44171
44307
|
};
|
|
44172
44308
|
}
|
|
44173
|
-
unlockDevice(pinType
|
|
44174
|
-
var _a, _b, _c, _d;
|
|
44309
|
+
unlockDevice(pinType, options) {
|
|
44310
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
44175
44311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44176
44312
|
if (this.isProtocolV2()) {
|
|
44313
|
+
const requestedPinType = pinType !== null && pinType !== void 0 ? pinType : hdTransport.DeviceSessionPinType.Main;
|
|
44314
|
+
const interaction = (_a = options === null || options === void 0 ? void 0 : options.interaction) !== null && _a !== void 0 ? _a : ((options === null || options === void 0 ? void 0 : options.emitUiEvent) === false
|
|
44315
|
+
? undefined
|
|
44316
|
+
: this.createProtocolV2UiPhaseMetadata('pin', 'start'));
|
|
44317
|
+
if ((options === null || options === void 0 ? void 0 : options.emitUiEvent) !== false) {
|
|
44318
|
+
this.emit(DEVICE.PIN_ON_DEVICE, this, requestedPinType, {
|
|
44319
|
+
source: (_b = options === null || options === void 0 ? void 0 : options.source) !== null && _b !== void 0 ? _b : 'unlock-coordinator',
|
|
44320
|
+
reason: (_c = options === null || options === void 0 ? void 0 : options.reason) !== null && _c !== void 0 ? _c : 'device-unlock',
|
|
44321
|
+
deviceOnly: (_d = options === null || options === void 0 ? void 0 : options.deviceOnly) !== null && _d !== void 0 ? _d : true,
|
|
44322
|
+
completion: options === null || options === void 0 ? void 0 : options.completion,
|
|
44323
|
+
method: options === null || options === void 0 ? void 0 : options.method,
|
|
44324
|
+
page: options === null || options === void 0 ? void 0 : options.page,
|
|
44325
|
+
operation: options === null || options === void 0 ? void 0 : options.operation,
|
|
44326
|
+
interaction: (_e = options === null || options === void 0 ? void 0 : options.interaction) !== null && _e !== void 0 ? _e : interaction,
|
|
44327
|
+
});
|
|
44328
|
+
}
|
|
44177
44329
|
try {
|
|
44178
|
-
yield this.commands.typedCall('DeviceSessionAskPin', 'Success', {
|
|
44330
|
+
yield this.commands.typedCall('DeviceSessionAskPin', 'Success', {
|
|
44331
|
+
type: requestedPinType,
|
|
44332
|
+
});
|
|
44179
44333
|
}
|
|
44180
44334
|
catch (error) {
|
|
44181
44335
|
const errorText = error instanceof Error
|
|
44182
44336
|
? `${error.name} ${error.message}`
|
|
44183
|
-
: String((
|
|
44337
|
+
: String((_g = (_f = error === null || error === void 0 ? void 0 : error.message) !== null && _f !== void 0 ? _f : error) !== null && _g !== void 0 ? _g : '');
|
|
44184
44338
|
if (errorText.includes('Failure_UnexpectedMessage')) {
|
|
44185
44339
|
throw hdShared.createDeviceNotSupportMethodError('deviceUnlock', this.getCurrentFirmwareType());
|
|
44186
44340
|
}
|
|
44187
44341
|
throw error;
|
|
44188
44342
|
}
|
|
44343
|
+
const completion = interaction ? this.completeProtocolV2UiPhase(interaction) : undefined;
|
|
44344
|
+
if (completion) {
|
|
44345
|
+
this.emit(DEVICE.PIN_ON_DEVICE_COMPLETE, this, completion);
|
|
44346
|
+
}
|
|
44189
44347
|
const status = yield requestProtocolV2DeviceStatus({ commands: this.commands });
|
|
44190
44348
|
return this.updateProtocolV2Status(status);
|
|
44191
44349
|
}
|
|
44192
|
-
const firmwareVersion = (
|
|
44350
|
+
const firmwareVersion = (_h = this.getCurrentFirmwareVersionString()) !== null && _h !== void 0 ? _h : '0.0.0';
|
|
44193
44351
|
const versionRange = this.getCurrentMethodVersionRange(type => this.supportUnlockVersionRange()[type]);
|
|
44194
|
-
const supportAttachPinCapability = (
|
|
44352
|
+
const supportAttachPinCapability = (_j = this.state) === null || _j === void 0 ? void 0 : _j.capabilities.includes(hdTransport.Enum_Capability.Capability_AttachToPin);
|
|
44195
44353
|
const supportUnlock = supportAttachPinCapability ||
|
|
44196
44354
|
(versionRange &&
|
|
44197
44355
|
semver__default["default"].valid(firmwareVersion) &&
|
|
@@ -44226,7 +44384,7 @@ class Device extends events.exports {
|
|
|
44226
44384
|
return Promise.resolve(features);
|
|
44227
44385
|
});
|
|
44228
44386
|
}
|
|
44229
|
-
checkPassphraseStateSafety(passphraseState, useEmptyPassphrase, skipPassphraseCheck) {
|
|
44387
|
+
checkPassphraseStateSafety(passphraseState, useEmptyPassphrase, skipPassphraseCheck, deriveCardano) {
|
|
44230
44388
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44231
44389
|
if (this.isUnacquired())
|
|
44232
44390
|
return false;
|
|
@@ -44234,6 +44392,7 @@ class Device extends events.exports {
|
|
|
44234
44392
|
const { passphraseState: newPassphraseState, unlockedAttachPin } = yield getPassphraseStateWithRefreshDeviceInfo(this, {
|
|
44235
44393
|
expectPassphraseState: expectedPassphraseState,
|
|
44236
44394
|
onlyMainPin: useEmptyPassphrase,
|
|
44395
|
+
deriveCardano,
|
|
44237
44396
|
});
|
|
44238
44397
|
const mainWalletUseAttachPin = unlockedAttachPin && useEmptyPassphrase;
|
|
44239
44398
|
const useErrorAttachPin = unlockedAttachPin &&
|
|
@@ -44915,12 +45074,26 @@ class GetPassphraseState extends BaseMethod {
|
|
|
44915
45074
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed);
|
|
44916
45075
|
}
|
|
44917
45076
|
const isProtocolV2 = this.device.isProtocolV2();
|
|
45077
|
+
if (isProtocolV2 && this.payload.useEmptyPassphrase !== true) {
|
|
45078
|
+
const features = yield refreshProtocolV2DeviceStatus(this.device);
|
|
45079
|
+
if (features.unlocked === false) {
|
|
45080
|
+
yield this.device.unlockDevice(hdTransport.DeviceSessionPinType.Main, {
|
|
45081
|
+
source: 'unlock-coordinator',
|
|
45082
|
+
reason: 'device-locked',
|
|
45083
|
+
deviceOnly: true,
|
|
45084
|
+
method: 'getPassphraseState',
|
|
45085
|
+
});
|
|
45086
|
+
}
|
|
45087
|
+
}
|
|
44918
45088
|
const { passphraseState } = yield getPassphraseStateWithRefreshDeviceInfo(this.device, isProtocolV2
|
|
44919
45089
|
? {
|
|
44920
45090
|
onlyMainPin: this.payload.useEmptyPassphrase === true,
|
|
44921
45091
|
initSession: this.payload.initSession === true,
|
|
44922
45092
|
}
|
|
44923
45093
|
: undefined);
|
|
45094
|
+
if (!isProtocolV2 && this.device.getCurrentPassphraseProtection() !== true) {
|
|
45095
|
+
return undefined;
|
|
45096
|
+
}
|
|
44924
45097
|
return passphraseState;
|
|
44925
45098
|
});
|
|
44926
45099
|
}
|
|
@@ -45167,7 +45340,6 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45167
45340
|
this.payload.useEmptyPassphrase = this.params.mode === OpenWalletSessionMode.Standard;
|
|
45168
45341
|
}
|
|
45169
45342
|
run() {
|
|
45170
|
-
var _a, _b;
|
|
45171
45343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45172
45344
|
const isProtocolV2 = this.device.isProtocolV2();
|
|
45173
45345
|
const state = yield this.device.getDeviceState({ refreshSections: ['status'] });
|
|
@@ -45183,11 +45355,25 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45183
45355
|
currentDeviceId = refreshedState.identity.deviceId;
|
|
45184
45356
|
return requireDeviceId();
|
|
45185
45357
|
});
|
|
45358
|
+
const unlockProtocolV2IfLocked = () => __awaiter(this, void 0, void 0, function* () {
|
|
45359
|
+
if (isProtocolV2 && state.status.unlocked === false) {
|
|
45360
|
+
yield this.device.unlockDevice(hdTransport.DeviceSessionPinType.Main, {
|
|
45361
|
+
source: 'unlock-coordinator',
|
|
45362
|
+
reason: 'device-locked',
|
|
45363
|
+
deviceOnly: true,
|
|
45364
|
+
method: 'openWalletSession',
|
|
45365
|
+
});
|
|
45366
|
+
}
|
|
45367
|
+
});
|
|
45186
45368
|
const protocol = isProtocolV2 ? 'V2' : 'V1';
|
|
45187
45369
|
if (this.params.mode === OpenWalletSessionMode.Standard) {
|
|
45188
45370
|
this.device.passphraseState = undefined;
|
|
45189
45371
|
const session = isProtocolV2
|
|
45190
|
-
? yield getProtocolV2WalletSession(this.device, {
|
|
45372
|
+
? yield getProtocolV2WalletSession(this.device, {
|
|
45373
|
+
onlyMainPin: true,
|
|
45374
|
+
deriveCardano: this.payload.deriveCardano,
|
|
45375
|
+
selectMainWalletBeforeRestore: state.status.unlocked === false || state.status.unlockedAttachPin === true,
|
|
45376
|
+
})
|
|
45191
45377
|
: yield getPassphraseStateWithRefreshDeviceInfo(this.device, {
|
|
45192
45378
|
onlyMainPin: true,
|
|
45193
45379
|
initSession: this.payload.initSession,
|
|
@@ -45197,7 +45383,7 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45197
45383
|
try {
|
|
45198
45384
|
yield this.device.lockDevice();
|
|
45199
45385
|
}
|
|
45200
|
-
catch (
|
|
45386
|
+
catch (_a) {
|
|
45201
45387
|
}
|
|
45202
45388
|
this.device.clearInternalState();
|
|
45203
45389
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
@@ -45206,15 +45392,13 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45206
45392
|
protocol,
|
|
45207
45393
|
walletType: 'standard',
|
|
45208
45394
|
deviceId,
|
|
45209
|
-
passphraseState:
|
|
45395
|
+
passphraseState: null,
|
|
45210
45396
|
resumed: wasResumed(session),
|
|
45211
45397
|
};
|
|
45212
45398
|
}
|
|
45213
45399
|
if (this.params.mode === OpenWalletSessionMode.ResumeHidden) {
|
|
45214
45400
|
if (isProtocolV2) {
|
|
45215
|
-
|
|
45216
|
-
yield this.device.unlockDevice();
|
|
45217
|
-
}
|
|
45401
|
+
yield unlockProtocolV2IfLocked();
|
|
45218
45402
|
const refreshedDeviceId = yield refreshProtocolV2DeviceId();
|
|
45219
45403
|
if (refreshedDeviceId !== this.params.deviceId) {
|
|
45220
45404
|
deviceWalletSessionStore.delete(this.params.deviceId, this.params.passphraseState);
|
|
@@ -45226,7 +45410,7 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45226
45410
|
}
|
|
45227
45411
|
this.device.passphraseState = this.params.passphraseState;
|
|
45228
45412
|
const cachedSessionId = deviceWalletSessionStore.get(this.params.deviceId, this.params.passphraseState);
|
|
45229
|
-
if (!cachedSessionId) {
|
|
45413
|
+
if (!cachedSessionId && !isProtocolV2) {
|
|
45230
45414
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
45231
45415
|
}
|
|
45232
45416
|
if (!isProtocolV2) {
|
|
@@ -45238,6 +45422,7 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45238
45422
|
const session = isProtocolV2
|
|
45239
45423
|
? yield getProtocolV2WalletSession(this.device, {
|
|
45240
45424
|
expectedPassphraseState: this.params.passphraseState,
|
|
45425
|
+
deriveCardano: this.payload.deriveCardano,
|
|
45241
45426
|
})
|
|
45242
45427
|
: yield getPassphraseStateWithRefreshDeviceInfo(this.device, {
|
|
45243
45428
|
expectPassphraseState: this.params.passphraseState,
|
|
@@ -45247,13 +45432,21 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45247
45432
|
this.device.clearInternalState();
|
|
45248
45433
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
45249
45434
|
}
|
|
45250
|
-
return Object.assign(Object.assign({ protocol, walletType: 'hidden', deviceId }, requireHiddenWalletResponse(session)), { resumed: wasResumed(session) || session.newSession === cachedSessionId });
|
|
45435
|
+
return Object.assign(Object.assign({ protocol, walletType: 'hidden', deviceId }, requireHiddenWalletResponse(session)), { resumed: wasResumed(session) || (!isProtocolV2 && session.newSession === cachedSessionId) });
|
|
45251
45436
|
}
|
|
45252
45437
|
this.device.passphraseState = undefined;
|
|
45438
|
+
yield unlockProtocolV2IfLocked();
|
|
45253
45439
|
const session = isProtocolV2
|
|
45254
|
-
? yield getProtocolV2WalletSession(this.device, {
|
|
45440
|
+
? yield getProtocolV2WalletSession(this.device, {
|
|
45441
|
+
forceWalletSelection: true,
|
|
45442
|
+
deriveCardano: this.payload.deriveCardano,
|
|
45443
|
+
})
|
|
45255
45444
|
: yield getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
|
|
45256
45445
|
const deviceId = isProtocolV2 ? yield refreshProtocolV2DeviceId() : requireDeviceId();
|
|
45446
|
+
if (isProtocolV2 && this.device.getCurrentPassphraseProtection() !== true) {
|
|
45447
|
+
this.device.clearInternalState();
|
|
45448
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
45449
|
+
}
|
|
45257
45450
|
const responseBase = {
|
|
45258
45451
|
protocol,
|
|
45259
45452
|
deviceId,
|
|
@@ -46061,12 +46254,16 @@ class DeviceReset extends BaseMethod {
|
|
|
46061
46254
|
}
|
|
46062
46255
|
}
|
|
46063
46256
|
|
|
46064
|
-
const
|
|
46257
|
+
const PROTOCOL_V2_LOCK_FREE_DEVICE_SETTINGS = [
|
|
46065
46258
|
'language',
|
|
46066
46259
|
'brightness',
|
|
46260
|
+
'animation_enable',
|
|
46261
|
+
'tap_to_wake',
|
|
46067
46262
|
'haptic_feedback',
|
|
46068
|
-
|
|
46069
|
-
|
|
46263
|
+
'device_name_display_enabled',
|
|
46264
|
+
];
|
|
46265
|
+
const lockFreeDeviceSettings = new Set(PROTOCOL_V2_LOCK_FREE_DEVICE_SETTINGS);
|
|
46266
|
+
const getProtocolV2SettingsUnlockPolicy = (settings) => Object.keys(settings).every(key => lockFreeDeviceSettings.has(key))
|
|
46070
46267
|
? 'none'
|
|
46071
46268
|
: 'unlock-before-run';
|
|
46072
46269
|
const getProtocolV2SettingsBehavior = (operation) => {
|
|
@@ -47516,7 +47713,7 @@ class DeviceUnlock extends BaseMethod {
|
|
|
47516
47713
|
}
|
|
47517
47714
|
run() {
|
|
47518
47715
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47519
|
-
return this.device.unlockDevice();
|
|
47716
|
+
return this.device.unlockDevice(undefined, { emitUiEvent: false });
|
|
47520
47717
|
});
|
|
47521
47718
|
}
|
|
47522
47719
|
}
|
|
@@ -49204,7 +49401,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49204
49401
|
if (binary.byteLength === 0) {
|
|
49205
49402
|
throw new Error(`Protocol V2 RESC bundle is empty: ${bundle.name}`);
|
|
49206
49403
|
}
|
|
49207
|
-
if (downloadedFromRemote
|
|
49404
|
+
if (downloadedFromRemote) {
|
|
49208
49405
|
const header = parseProtocolV2OkppHeader(toProtocolV2Bytes(binary));
|
|
49209
49406
|
if (!header || header.type !== 'RESC') {
|
|
49210
49407
|
throw new Error(`Invalid Protocol V2 RESC bundle header: ${bundle.name}`);
|
|
@@ -49302,17 +49499,31 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49302
49499
|
});
|
|
49303
49500
|
}
|
|
49304
49501
|
isProtocolV2BootloaderMode() {
|
|
49305
|
-
var _a;
|
|
49502
|
+
var _a, _b, _c;
|
|
49306
49503
|
if (typeof this.device.isBootloader === 'function') {
|
|
49307
49504
|
return this.device.isBootloader();
|
|
49308
49505
|
}
|
|
49309
|
-
return
|
|
49506
|
+
return (((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.mode) === 'bootloader' ||
|
|
49507
|
+
(((_b = this.device.features) === null || _b === void 0 ? void 0 : _b.mode) == null && !!((_c = this.device.features) === null || _c === void 0 ? void 0 : _c.bootloaderMode)));
|
|
49310
49508
|
}
|
|
49311
|
-
|
|
49509
|
+
isProtocolV2RomloaderMode() {
|
|
49312
49510
|
var _a;
|
|
49511
|
+
if (!this.device.isProtocolV2() || this.device.getCurrentDeviceType() !== hdShared.EDeviceType.Pro2) {
|
|
49512
|
+
return false;
|
|
49513
|
+
}
|
|
49514
|
+
if (typeof this.device.isRomloader === 'function') {
|
|
49515
|
+
return this.device.isRomloader();
|
|
49516
|
+
}
|
|
49517
|
+
return ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.mode) === 'romloader';
|
|
49518
|
+
}
|
|
49519
|
+
enterProtocolV2BootloaderMode() {
|
|
49313
49520
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49314
|
-
if (this.
|
|
49315
|
-
Log$5.debug('Protocol V2 device is
|
|
49521
|
+
if (this.isProtocolV2RomloaderMode()) {
|
|
49522
|
+
Log$5.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
49523
|
+
return false;
|
|
49524
|
+
}
|
|
49525
|
+
if (this.isProtocolV2BootloaderMode()) {
|
|
49526
|
+
Log$5.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
49316
49527
|
return false;
|
|
49317
49528
|
}
|
|
49318
49529
|
try {
|
|
@@ -49344,8 +49555,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49344
49555
|
timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
49345
49556
|
});
|
|
49346
49557
|
this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
|
|
49347
|
-
const features = this.device.
|
|
49348
|
-
if (features === null || features === void 0 ? void 0 : features.
|
|
49558
|
+
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
|
|
49559
|
+
if ((features === null || features === void 0 ? void 0 : features.mode) === 'bootloader') {
|
|
49349
49560
|
return features;
|
|
49350
49561
|
}
|
|
49351
49562
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
@@ -49482,14 +49693,22 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49482
49693
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, `Protocol V2 firmware target failed: target=${failedTarget.target_id} status=${(_a = failedTarget.status) !== null && _a !== void 0 ? _a : 'unknown'} payloadVersion=${(_b = failedTarget.payload_version) !== null && _b !== void 0 ? _b : 'unknown'} path=${(_c = failedTarget.path) !== null && _c !== void 0 ? _c : 'unknown'}`);
|
|
49483
49694
|
}
|
|
49484
49695
|
const matchingTargets = statusTargets.filter(target => { var _a; return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1); });
|
|
49485
|
-
const
|
|
49486
|
-
|
|
49696
|
+
const completedTargetIds = new Set();
|
|
49697
|
+
matchingTargets.forEach(target => {
|
|
49698
|
+
const targetId = normalizeProtocolV2TargetId(target.target_id);
|
|
49699
|
+
if (targetId !== undefined && isProtocolV2TargetStatusFinished(target.status)) {
|
|
49700
|
+
completedTargetIds.add(targetId);
|
|
49701
|
+
}
|
|
49702
|
+
});
|
|
49703
|
+
const allExpectedTargetsCompleted = expectedTargetIds.size > 0 &&
|
|
49704
|
+
Array.from(expectedTargetIds).every(targetId => completedTargetIds.has(targetId));
|
|
49705
|
+
if (allExpectedTargetsCompleted) {
|
|
49487
49706
|
this.postProgressMessage(100, 'installingFirmware');
|
|
49488
49707
|
return true;
|
|
49489
49708
|
}
|
|
49490
49709
|
if (expectedTargetIds.size > 0 && matchingTargets.length > 0) {
|
|
49491
49710
|
const hasInProgressTarget = matchingTargets.some(target => isProtocolV2TargetStatusInProgress(target.status));
|
|
49492
|
-
const completedProgress = Math.floor((
|
|
49711
|
+
const completedProgress = Math.floor((completedTargetIds.size / expectedTargetIds.size) * 100);
|
|
49493
49712
|
const progress = Math.min(99, Math.max(completedProgress, hasInProgressTarget ? 1 : 0));
|
|
49494
49713
|
this.postProgressMessage(progress, 'installingFirmware');
|
|
49495
49714
|
}
|
|
@@ -49892,7 +50111,7 @@ class DeviceGetOnboardingStatus extends BaseMethod {
|
|
|
49892
50111
|
}
|
|
49893
50112
|
run() {
|
|
49894
50113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49895
|
-
const { message } = yield this.device.commands.typedCall('
|
|
50114
|
+
const { message } = yield this.device.commands.typedCall('OnboardingStatusGet', 'OnboardingStatus', {});
|
|
49896
50115
|
return message;
|
|
49897
50116
|
});
|
|
49898
50117
|
}
|
|
@@ -50065,7 +50284,7 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
50065
50284
|
this.encoded = encodePro2Wallpaper({ width, height, rgba: rgbaBytes });
|
|
50066
50285
|
this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
|
|
50067
50286
|
this.params = { width, height, rgba: rgbaBytes, fileName, chunkSize };
|
|
50068
|
-
this.unlockPolicy = '
|
|
50287
|
+
this.unlockPolicy = 'none';
|
|
50069
50288
|
this.skipForceUpdateCheck = true;
|
|
50070
50289
|
this.useDevicePassphraseState = false;
|
|
50071
50290
|
}
|
|
@@ -50257,6 +50476,227 @@ class CipherKeyValue extends BaseMethod {
|
|
|
50257
50476
|
}
|
|
50258
50477
|
}
|
|
50259
50478
|
|
|
50479
|
+
function isDeviceLockedError(error) {
|
|
50480
|
+
return (typeof error === 'object' &&
|
|
50481
|
+
error !== null &&
|
|
50482
|
+
'errorCode' in error &&
|
|
50483
|
+
error.errorCode === hdShared.HardwareErrorCode.DeviceLocked);
|
|
50484
|
+
}
|
|
50485
|
+
|
|
50486
|
+
const isProtocolV2UiEnabled = (method) => method.protocolV2UiMode !== 'none';
|
|
50487
|
+
const getDisplayState = (value) => {
|
|
50488
|
+
const visited = new Set();
|
|
50489
|
+
let seen = false;
|
|
50490
|
+
let enabled = false;
|
|
50491
|
+
const visit = (current) => {
|
|
50492
|
+
if (current == null || typeof current !== 'object')
|
|
50493
|
+
return;
|
|
50494
|
+
if (visited.has(current))
|
|
50495
|
+
return;
|
|
50496
|
+
visited.add(current);
|
|
50497
|
+
if (Array.isArray(current)) {
|
|
50498
|
+
current.forEach(visit);
|
|
50499
|
+
return;
|
|
50500
|
+
}
|
|
50501
|
+
Object.entries(current).forEach(([key, item]) => {
|
|
50502
|
+
if ((key === 'show_display' || key === 'showOnOneKey') && typeof item === 'boolean') {
|
|
50503
|
+
seen = true;
|
|
50504
|
+
enabled || (enabled = item);
|
|
50505
|
+
return;
|
|
50506
|
+
}
|
|
50507
|
+
visit(item);
|
|
50508
|
+
});
|
|
50509
|
+
};
|
|
50510
|
+
visit(value);
|
|
50511
|
+
return { seen, enabled };
|
|
50512
|
+
};
|
|
50513
|
+
const createMethodInteraction = (reason, operation) => ({
|
|
50514
|
+
request: 'button',
|
|
50515
|
+
source: 'method-lifecycle',
|
|
50516
|
+
reason,
|
|
50517
|
+
completion: 'operation-completed',
|
|
50518
|
+
deviceOnly: true,
|
|
50519
|
+
operation,
|
|
50520
|
+
});
|
|
50521
|
+
const hasCipherConfirmation = (value) => {
|
|
50522
|
+
if (Array.isArray(value))
|
|
50523
|
+
return value.some(hasCipherConfirmation);
|
|
50524
|
+
if (value == null || typeof value !== 'object')
|
|
50525
|
+
return false;
|
|
50526
|
+
const params = value;
|
|
50527
|
+
return params.encrypt === true ? params.ask_on_encrypt === true : params.ask_on_decrypt === true;
|
|
50528
|
+
};
|
|
50529
|
+
const resolveProtocolV2UiInteraction = (method) => {
|
|
50530
|
+
if (method.protocolV2UiInteraction)
|
|
50531
|
+
return method.protocolV2UiInteraction;
|
|
50532
|
+
const operation = method.name;
|
|
50533
|
+
if (!operation)
|
|
50534
|
+
return undefined;
|
|
50535
|
+
const isAddress = /getAddress(?:ByLoop)?$/i.test(operation);
|
|
50536
|
+
const isPublicKey = /getPublicKey$/i.test(operation);
|
|
50537
|
+
if (isAddress || isPublicKey) {
|
|
50538
|
+
const paramsDisplay = getDisplayState(method.params);
|
|
50539
|
+
const payloadDisplay = getDisplayState(method.payload);
|
|
50540
|
+
const display = paramsDisplay.seen ? paramsDisplay : payloadDisplay;
|
|
50541
|
+
const shouldDisplay = display.seen ? display.enabled : isAddress;
|
|
50542
|
+
if (!shouldDisplay)
|
|
50543
|
+
return undefined;
|
|
50544
|
+
return createMethodInteraction(isAddress ? 'address-confirmation' : 'public-key-confirmation', operation);
|
|
50545
|
+
}
|
|
50546
|
+
if (/sign/i.test(operation) || /verifyMessage$/i.test(operation) || operation === 'lnurlAuth') {
|
|
50547
|
+
return createMethodInteraction('signing-confirmation', operation);
|
|
50548
|
+
}
|
|
50549
|
+
if (operation === 'nostrEncryptMessage' || operation === 'nostrDecryptMessage') {
|
|
50550
|
+
const display = getDisplayState(method.params);
|
|
50551
|
+
if (!display.enabled)
|
|
50552
|
+
return undefined;
|
|
50553
|
+
return createMethodInteraction('signing-confirmation', operation);
|
|
50554
|
+
}
|
|
50555
|
+
if (operation === 'cipherKeyValue' && hasCipherConfirmation(method.params)) {
|
|
50556
|
+
return createMethodInteraction('signing-confirmation', operation);
|
|
50557
|
+
}
|
|
50558
|
+
return undefined;
|
|
50559
|
+
};
|
|
50560
|
+
class ProtocolV2UiInteractionCoordinator {
|
|
50561
|
+
constructor(device, postMessage) {
|
|
50562
|
+
this.opened = false;
|
|
50563
|
+
this.closed = false;
|
|
50564
|
+
this.device = device;
|
|
50565
|
+
this.postMessage = postMessage;
|
|
50566
|
+
}
|
|
50567
|
+
enterMethodInteraction(interaction) {
|
|
50568
|
+
var _a, _b, _c, _d;
|
|
50569
|
+
this.methodInteraction = interaction;
|
|
50570
|
+
if (!interaction)
|
|
50571
|
+
return;
|
|
50572
|
+
const { request } = interaction, metadata = __rest(interaction, ["request"]);
|
|
50573
|
+
const interactionMeta = (_b = (_a = this.device).createProtocolV2UiPhaseMetadata) === null || _b === void 0 ? void 0 : _b.call(_a, request === 'pin' ? 'pin' : 'button', 'start');
|
|
50574
|
+
this.emit(request === 'pin' ? UI_REQUEST.REQUEST_PIN : UI_REQUEST.REQUEST_BUTTON, Object.assign(Object.assign({ device: this.device.toMessageObject() }, metadata), (interactionMeta ? { interaction: interactionMeta } : {})), `method:${request}:${interaction.reason}:${(_c = interaction.page) !== null && _c !== void 0 ? _c : ''}:${(_d = interaction.operation) !== null && _d !== void 0 ? _d : ''}`);
|
|
50575
|
+
}
|
|
50576
|
+
enterUnlockInteraction(method) {
|
|
50577
|
+
var _a, _b;
|
|
50578
|
+
const interaction = (_b = (_a = this.device).createProtocolV2UiPhaseMetadata) === null || _b === void 0 ? void 0 : _b.call(_a, 'pin', 'start');
|
|
50579
|
+
this.emit(UI_REQUEST.REQUEST_PIN, Object.assign({ device: this.device.toMessageObject(), source: 'unlock-coordinator', reason: 'device-locked', deviceOnly: true, method }, (interaction ? { interaction } : {})), `unlock:${method !== null && method !== void 0 ? method : ''}`);
|
|
50580
|
+
return interaction;
|
|
50581
|
+
}
|
|
50582
|
+
resumeMethodInteraction() {
|
|
50583
|
+
this.enterMethodInteraction(this.methodInteraction);
|
|
50584
|
+
}
|
|
50585
|
+
close() {
|
|
50586
|
+
var _a, _b, _c, _d;
|
|
50587
|
+
if (!this.device.isProtocolV2() ||
|
|
50588
|
+
(!this.opened && !((_b = (_a = this.device).hasOpenProtocolV2UiInteraction) === null || _b === void 0 ? void 0 : _b.call(_a))) ||
|
|
50589
|
+
this.closed)
|
|
50590
|
+
return;
|
|
50591
|
+
this.closed = true;
|
|
50592
|
+
const interaction = (_d = (_c = this.device).finishProtocolV2UiInteraction) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
50593
|
+
this.postMessage(interaction
|
|
50594
|
+
? createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW, interaction)
|
|
50595
|
+
: createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW));
|
|
50596
|
+
}
|
|
50597
|
+
emit(type, payload, phase) {
|
|
50598
|
+
if (!this.device.isProtocolV2() || this.closed || this.currentPhase === phase)
|
|
50599
|
+
return;
|
|
50600
|
+
this.currentPhase = phase;
|
|
50601
|
+
this.opened = true;
|
|
50602
|
+
const message = type === UI_REQUEST.REQUEST_BUTTON
|
|
50603
|
+
? createUiMessage(UI_REQUEST.REQUEST_BUTTON, payload)
|
|
50604
|
+
: createUiMessage(UI_REQUEST.REQUEST_PIN, payload);
|
|
50605
|
+
this.postMessage(message);
|
|
50606
|
+
}
|
|
50607
|
+
}
|
|
50608
|
+
|
|
50609
|
+
const Log$3 = getLogger(exports.LoggerNames.Core);
|
|
50610
|
+
const restoreExpectedWalletSessionAfterUnlock = (method, device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50611
|
+
var _a, _b, _c;
|
|
50612
|
+
const expectedPassphraseState = ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.useEmptyPassphrase)
|
|
50613
|
+
? undefined
|
|
50614
|
+
: (_c = (_b = method.payload) === null || _b === void 0 ? void 0 : _b.passphraseState) !== null && _c !== void 0 ? _c : device.passphraseState;
|
|
50615
|
+
if (!method.useDevicePassphraseState ||
|
|
50616
|
+
typeof expectedPassphraseState !== 'string' ||
|
|
50617
|
+
expectedPassphraseState.length === 0) {
|
|
50618
|
+
return;
|
|
50619
|
+
}
|
|
50620
|
+
yield restoreProtocolV2WalletSession(device, expectedPassphraseState);
|
|
50621
|
+
Log$3.debug('Protocol V2 wallet session restored after unlock', { method: method.name });
|
|
50622
|
+
});
|
|
50623
|
+
function runMethodWithUnlockRetry(method, device, uiCoordinator) {
|
|
50624
|
+
var _a, _b, _c, _d, _e;
|
|
50625
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50626
|
+
const shouldEmitUi = isProtocolV2UiEnabled(method);
|
|
50627
|
+
const shouldCoordinateUi = shouldEmitUi && uiCoordinator !== undefined;
|
|
50628
|
+
const isProtocolV2 = device.isProtocolV2();
|
|
50629
|
+
const requiresFreshStatus = isProtocolV2 &&
|
|
50630
|
+
method.unlockPolicy === 'unlock-before-run' &&
|
|
50631
|
+
!((_a = device.isBootloader) === null || _a === void 0 ? void 0 : _a.call(device)) &&
|
|
50632
|
+
!((_b = device.isRomloader) === null || _b === void 0 ? void 0 : _b.call(device));
|
|
50633
|
+
if (requiresFreshStatus) {
|
|
50634
|
+
yield refreshProtocolV2DeviceStatus(device);
|
|
50635
|
+
}
|
|
50636
|
+
const shouldUnlockBeforeRun = isProtocolV2 &&
|
|
50637
|
+
method.unlockPolicy !== 'none' &&
|
|
50638
|
+
!((_c = device.isBootloader) === null || _c === void 0 ? void 0 : _c.call(device)) &&
|
|
50639
|
+
!((_d = device.isRomloader) === null || _d === void 0 ? void 0 : _d.call(device)) &&
|
|
50640
|
+
((_e = device.features) === null || _e === void 0 ? void 0 : _e.unlocked) === false;
|
|
50641
|
+
if (shouldUnlockBeforeRun) {
|
|
50642
|
+
const unlockInteraction = shouldCoordinateUi
|
|
50643
|
+
? uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterUnlockInteraction(method.name)
|
|
50644
|
+
: undefined;
|
|
50645
|
+
yield device.unlockDevice(undefined, shouldCoordinateUi
|
|
50646
|
+
? { emitUiEvent: false, interaction: unlockInteraction }
|
|
50647
|
+
: {
|
|
50648
|
+
source: 'unlock-coordinator',
|
|
50649
|
+
reason: 'device-locked',
|
|
50650
|
+
deviceOnly: true,
|
|
50651
|
+
method: method.name,
|
|
50652
|
+
});
|
|
50653
|
+
Log$3.debug('Protocol V2 pre-unlock completed', { method: method.name });
|
|
50654
|
+
yield restoreExpectedWalletSessionAfterUnlock(method, device);
|
|
50655
|
+
if (shouldCoordinateUi) {
|
|
50656
|
+
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
|
|
50657
|
+
}
|
|
50658
|
+
return method.run();
|
|
50659
|
+
}
|
|
50660
|
+
if (shouldCoordinateUi) {
|
|
50661
|
+
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
|
|
50662
|
+
}
|
|
50663
|
+
try {
|
|
50664
|
+
return yield method.run();
|
|
50665
|
+
}
|
|
50666
|
+
catch (error) {
|
|
50667
|
+
if (!isProtocolV2 || method.unlockPolicy !== 'retry-on-locked' || !isDeviceLockedError(error)) {
|
|
50668
|
+
throw error;
|
|
50669
|
+
}
|
|
50670
|
+
Log$3.debug('Protocol V2 unlock retry triggered', { method: method.name });
|
|
50671
|
+
const unlockInteraction = shouldCoordinateUi
|
|
50672
|
+
? uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterUnlockInteraction(method.name)
|
|
50673
|
+
: undefined;
|
|
50674
|
+
yield device.unlockDevice(undefined, shouldCoordinateUi
|
|
50675
|
+
? { emitUiEvent: false, interaction: unlockInteraction }
|
|
50676
|
+
: {
|
|
50677
|
+
source: 'unlock-coordinator',
|
|
50678
|
+
reason: 'device-locked',
|
|
50679
|
+
deviceOnly: true,
|
|
50680
|
+
method: method.name,
|
|
50681
|
+
});
|
|
50682
|
+
Log$3.debug('Protocol V2 unlock completed', { method: method.name });
|
|
50683
|
+
yield restoreExpectedWalletSessionAfterUnlock(method, device);
|
|
50684
|
+
if (shouldCoordinateUi) {
|
|
50685
|
+
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.resumeMethodInteraction();
|
|
50686
|
+
}
|
|
50687
|
+
try {
|
|
50688
|
+
const response = yield method.run();
|
|
50689
|
+
Log$3.debug('Protocol V2 method retry completed', { method: method.name, success: true });
|
|
50690
|
+
return response;
|
|
50691
|
+
}
|
|
50692
|
+
catch (retryError) {
|
|
50693
|
+
Log$3.debug('Protocol V2 method retry completed', { method: method.name, success: false });
|
|
50694
|
+
throw retryError;
|
|
50695
|
+
}
|
|
50696
|
+
}
|
|
50697
|
+
});
|
|
50698
|
+
}
|
|
50699
|
+
|
|
50260
50700
|
const Mainnet = 'mainnet';
|
|
50261
50701
|
const networkAliases = {
|
|
50262
50702
|
tbtc: { name: 'btc', coin: 'Testnet' },
|
|
@@ -50541,7 +50981,16 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
50541
50981
|
this.temporarySafetyCheckPrompted = true;
|
|
50542
50982
|
}
|
|
50543
50983
|
}
|
|
50544
|
-
|
|
50984
|
+
if (this.device.isProtocolV2() && this.payload.passphraseState) {
|
|
50985
|
+
yield ensureProtocolV2WalletSessionUnlocked(this.device);
|
|
50986
|
+
const passphraseStateSafety = yield this.device.checkPassphraseStateSafety(this.payload.passphraseState, false, this.payload.skipPassphraseCheck);
|
|
50987
|
+
if (!passphraseStateSafety) {
|
|
50988
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
50989
|
+
}
|
|
50990
|
+
}
|
|
50991
|
+
const response = this.device.isProtocolV2()
|
|
50992
|
+
? yield runMethodWithUnlockRetry(method, this.device)
|
|
50993
|
+
: yield method.run();
|
|
50545
50994
|
if (!Array.isArray(response) || response.length === 0) {
|
|
50546
50995
|
throw new Error('No response');
|
|
50547
50996
|
}
|
|
@@ -50582,7 +51031,9 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
50582
51031
|
script_type: 'SPENDADDRESS',
|
|
50583
51032
|
show_display: false,
|
|
50584
51033
|
});
|
|
50585
|
-
this.
|
|
51034
|
+
if (!this.device.isProtocolV2()) {
|
|
51035
|
+
this.postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW));
|
|
51036
|
+
}
|
|
50586
51037
|
if (res.message.root_fingerprint == null) {
|
|
50587
51038
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter);
|
|
50588
51039
|
}
|
|
@@ -52227,6 +52678,8 @@ function getAddress ({ typedCall, param, }) {
|
|
|
52227
52678
|
});
|
|
52228
52679
|
}
|
|
52229
52680
|
|
|
52681
|
+
const shouldUseLegacyV1EvmMessages = (device) => !device.isProtocolV2() && TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema';
|
|
52682
|
+
|
|
52230
52683
|
class EvmGetAddress extends BaseMethod {
|
|
52231
52684
|
constructor() {
|
|
52232
52685
|
super(...arguments);
|
|
@@ -52261,7 +52714,7 @@ class EvmGetAddress extends BaseMethod {
|
|
|
52261
52714
|
}
|
|
52262
52715
|
getEvmAddress(param) {
|
|
52263
52716
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52264
|
-
if (
|
|
52717
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52265
52718
|
return getAddressLegacyV1({
|
|
52266
52719
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52267
52720
|
param,
|
|
@@ -52352,7 +52805,7 @@ class EVMGetPublicKey extends BaseMethod {
|
|
|
52352
52805
|
});
|
|
52353
52806
|
}
|
|
52354
52807
|
getEvmPublicKey(param) {
|
|
52355
|
-
if (
|
|
52808
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52356
52809
|
return getPublicKeyLegacyV1({
|
|
52357
52810
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52358
52811
|
param,
|
|
@@ -52441,7 +52894,7 @@ class EVMSignMessage$2 extends BaseMethod {
|
|
|
52441
52894
|
}
|
|
52442
52895
|
run() {
|
|
52443
52896
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52444
|
-
if (
|
|
52897
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52445
52898
|
return signMessageLegacyV1({
|
|
52446
52899
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52447
52900
|
params: this.params,
|
|
@@ -52761,7 +53214,7 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
52761
53214
|
const { addressN, isEIP1559, isEIP7702, formattedTx } = this;
|
|
52762
53215
|
if (formattedTx == null)
|
|
52763
53216
|
throw hdShared.ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
52764
|
-
if (
|
|
53217
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52765
53218
|
return signTransaction({
|
|
52766
53219
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52767
53220
|
addressN,
|
|
@@ -53122,28 +53575,24 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
53122
53575
|
const { addressN, data, metamaskV4Compat, chainId } = this.params;
|
|
53123
53576
|
let supportTrezor = false;
|
|
53124
53577
|
let response;
|
|
53125
|
-
|
|
53126
|
-
|
|
53127
|
-
|
|
53128
|
-
|
|
53129
|
-
|
|
53130
|
-
|
|
53131
|
-
|
|
53132
|
-
|
|
53133
|
-
|
|
53134
|
-
|
|
53135
|
-
|
|
53136
|
-
|
|
53137
|
-
|
|
53138
|
-
|
|
53139
|
-
|
|
53140
|
-
|
|
53141
|
-
|
|
53142
|
-
|
|
53143
|
-
metamaskV4Compat,
|
|
53144
|
-
chainId,
|
|
53145
|
-
});
|
|
53146
|
-
break;
|
|
53578
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
53579
|
+
supportTrezor = true;
|
|
53580
|
+
response = yield signTypedData$1({
|
|
53581
|
+
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
53582
|
+
addressN,
|
|
53583
|
+
data,
|
|
53584
|
+
metamaskV4Compat,
|
|
53585
|
+
chainId,
|
|
53586
|
+
});
|
|
53587
|
+
}
|
|
53588
|
+
else {
|
|
53589
|
+
response = yield signTypedData({
|
|
53590
|
+
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
53591
|
+
addressN,
|
|
53592
|
+
data,
|
|
53593
|
+
metamaskV4Compat,
|
|
53594
|
+
chainId,
|
|
53595
|
+
});
|
|
53147
53596
|
}
|
|
53148
53597
|
return this.handleSignTypedData({
|
|
53149
53598
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
@@ -53156,27 +53605,24 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
53156
53605
|
signTypedHash({ typedCall, addressN, chainId, domainHash, messageHash, }) {
|
|
53157
53606
|
if (!domainHash)
|
|
53158
53607
|
throw hdShared.ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
53159
|
-
|
|
53160
|
-
|
|
53161
|
-
|
|
53162
|
-
|
|
53163
|
-
|
|
53164
|
-
|
|
53165
|
-
|
|
53166
|
-
|
|
53167
|
-
|
|
53168
|
-
});
|
|
53169
|
-
case 'v1CurrentSchema':
|
|
53170
|
-
default:
|
|
53171
|
-
return signTypedHash({
|
|
53172
|
-
typedCall,
|
|
53173
|
-
addressN,
|
|
53174
|
-
domainHash,
|
|
53175
|
-
messageHash,
|
|
53176
|
-
chainId,
|
|
53177
|
-
device: this.device,
|
|
53178
|
-
});
|
|
53608
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
53609
|
+
return signTypedHash$1({
|
|
53610
|
+
typedCall,
|
|
53611
|
+
addressN,
|
|
53612
|
+
domainHash,
|
|
53613
|
+
messageHash,
|
|
53614
|
+
chainId,
|
|
53615
|
+
device: this.device,
|
|
53616
|
+
});
|
|
53179
53617
|
}
|
|
53618
|
+
return signTypedHash({
|
|
53619
|
+
typedCall,
|
|
53620
|
+
addressN,
|
|
53621
|
+
domainHash,
|
|
53622
|
+
messageHash,
|
|
53623
|
+
chainId,
|
|
53624
|
+
device: this.device,
|
|
53625
|
+
});
|
|
53180
53626
|
}
|
|
53181
53627
|
getVersionRange() {
|
|
53182
53628
|
return {
|
|
@@ -53433,7 +53879,7 @@ class EVMSignMessage$1 extends BaseMethod {
|
|
|
53433
53879
|
}
|
|
53434
53880
|
run() {
|
|
53435
53881
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53436
|
-
if (
|
|
53882
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
53437
53883
|
return verifyMessageLegacyV1({
|
|
53438
53884
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
53439
53885
|
params: this.params,
|
|
@@ -59901,7 +60347,7 @@ const resolveAfter = (msec, value) => new Promise(resolve => {
|
|
|
59901
60347
|
setTimeout(resolve, msec, value);
|
|
59902
60348
|
});
|
|
59903
60349
|
|
|
59904
|
-
const Log$
|
|
60350
|
+
const Log$2 = getLogger(exports.LoggerNames.DeviceConnector);
|
|
59905
60351
|
class DeviceConnector {
|
|
59906
60352
|
constructor() {
|
|
59907
60353
|
this.listenTimestamp = 0;
|
|
@@ -59932,7 +60378,7 @@ class DeviceConnector {
|
|
|
59932
60378
|
this.listening = true;
|
|
59933
60379
|
let descriptors;
|
|
59934
60380
|
try {
|
|
59935
|
-
Log$
|
|
60381
|
+
Log$2.debug('Start listening', current);
|
|
59936
60382
|
this.listenTimestamp = new Date().getTime();
|
|
59937
60383
|
descriptors = waitForEvent
|
|
59938
60384
|
? yield this.transport.listen(current)
|
|
@@ -59940,21 +60386,21 @@ class DeviceConnector {
|
|
|
59940
60386
|
if (!this.listening)
|
|
59941
60387
|
return;
|
|
59942
60388
|
this.upcoming = descriptors;
|
|
59943
|
-
Log$
|
|
60389
|
+
Log$2.debug('Listen result', descriptors);
|
|
59944
60390
|
this._reportDevicesChange();
|
|
59945
60391
|
if (this.listening)
|
|
59946
60392
|
this.listen();
|
|
59947
60393
|
}
|
|
59948
60394
|
catch (error) {
|
|
59949
60395
|
const time = new Date().getTime() - this.listenTimestamp;
|
|
59950
|
-
Log$
|
|
60396
|
+
Log$2.debug('Listen error', 'timestamp', time, typeof error);
|
|
59951
60397
|
if (time > 1100) {
|
|
59952
60398
|
yield resolveAfter(1000, null);
|
|
59953
60399
|
if (this.listening)
|
|
59954
60400
|
this.listen();
|
|
59955
60401
|
}
|
|
59956
60402
|
else {
|
|
59957
|
-
Log$
|
|
60403
|
+
Log$2.warn('Transport error');
|
|
59958
60404
|
}
|
|
59959
60405
|
}
|
|
59960
60406
|
});
|
|
@@ -59964,7 +60410,7 @@ class DeviceConnector {
|
|
|
59964
60410
|
}
|
|
59965
60411
|
acquire(path, session, forceCleanRunPromise, expectedProtocol, protocolHint) {
|
|
59966
60412
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59967
|
-
Log$
|
|
60413
|
+
Log$2.debug('acquire', path, session, expectedProtocol, protocolHint);
|
|
59968
60414
|
const env = DataManager.getSettings('env');
|
|
59969
60415
|
try {
|
|
59970
60416
|
let res;
|
|
@@ -59993,7 +60439,7 @@ class DeviceConnector {
|
|
|
59993
60439
|
return res;
|
|
59994
60440
|
}
|
|
59995
60441
|
catch (error) {
|
|
59996
|
-
Log$
|
|
60442
|
+
Log$2.error('acquire error: ', error.message);
|
|
59997
60443
|
safeThrowError(error);
|
|
59998
60444
|
}
|
|
59999
60445
|
});
|
|
@@ -60032,7 +60478,7 @@ class DeviceConnector {
|
|
|
60032
60478
|
}
|
|
60033
60479
|
}
|
|
60034
60480
|
|
|
60035
|
-
const Log$
|
|
60481
|
+
const Log$1 = getLogger(exports.LoggerNames.Core);
|
|
60036
60482
|
class RequestQueue {
|
|
60037
60483
|
constructor() {
|
|
60038
60484
|
this.requestQueue = new Map();
|
|
@@ -60065,7 +60511,7 @@ class RequestQueue {
|
|
|
60065
60511
|
abortRequest(requestId) {
|
|
60066
60512
|
const request = this.requestQueue.get(requestId);
|
|
60067
60513
|
if (request === null || request === void 0 ? void 0 : request.abortController) {
|
|
60068
|
-
Log$
|
|
60514
|
+
Log$1.debug(`Aborting request ${requestId}`);
|
|
60069
60515
|
request.abortController.abort();
|
|
60070
60516
|
return true;
|
|
60071
60517
|
}
|
|
@@ -60117,7 +60563,7 @@ class RequestQueue {
|
|
|
60117
60563
|
registerPendingCallbackTask(connectId, callbackPromise) {
|
|
60118
60564
|
this.pendingCallbackTasks.set(connectId, callbackPromise);
|
|
60119
60565
|
callbackPromise.promise.finally(() => {
|
|
60120
|
-
Log$
|
|
60566
|
+
Log$1.debug(`Callback task completed for connectId: ${connectId}`);
|
|
60121
60567
|
if (this.pendingCallbackTasks.get(connectId) === callbackPromise) {
|
|
60122
60568
|
this.pendingCallbackTasks.delete(connectId);
|
|
60123
60569
|
}
|
|
@@ -60127,7 +60573,7 @@ class RequestQueue {
|
|
|
60127
60573
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60128
60574
|
const pendingTask = this.pendingCallbackTasks.get(connectId);
|
|
60129
60575
|
if (pendingTask && pendingTask !== exceptTask) {
|
|
60130
|
-
Log$
|
|
60576
|
+
Log$1.debug(`Waiting for pending callback task to complete for connectId: ${connectId}`);
|
|
60131
60577
|
yield pendingTask.promise;
|
|
60132
60578
|
}
|
|
60133
60579
|
});
|
|
@@ -60142,6 +60588,8 @@ class RequestQueue {
|
|
|
60142
60588
|
|
|
60143
60589
|
function registerHardwareUiEventListeners(device, handlers) {
|
|
60144
60590
|
device.on(DEVICE.PIN, handlers.pin);
|
|
60591
|
+
device.on(DEVICE.PIN_ON_DEVICE, handlers.pinOnDevice);
|
|
60592
|
+
device.on(DEVICE.PIN_ON_DEVICE_COMPLETE, handlers.pinOnDeviceComplete);
|
|
60145
60593
|
device.on(DEVICE.BUTTON, handlers.button);
|
|
60146
60594
|
device.on(DEVICE.PASSPHRASE, handlers.passphrase);
|
|
60147
60595
|
device.on(DEVICE.PASSPHRASE_ON_DEVICE, handlers.passphraseOnDevice);
|
|
@@ -60171,191 +60619,6 @@ const getSynchronize = (mutex) => {
|
|
|
60171
60619
|
return (action, lockId) => lock(lockId).then(unlock => Promise.resolve().then(action).finally(unlock));
|
|
60172
60620
|
};
|
|
60173
60621
|
|
|
60174
|
-
const isProtocolV2UiEnabled = (method) => method.protocolV2UiMode !== 'none';
|
|
60175
|
-
const getDisplayState = (value) => {
|
|
60176
|
-
const visited = new Set();
|
|
60177
|
-
let seen = false;
|
|
60178
|
-
let enabled = false;
|
|
60179
|
-
const visit = (current) => {
|
|
60180
|
-
if (current == null || typeof current !== 'object')
|
|
60181
|
-
return;
|
|
60182
|
-
if (visited.has(current))
|
|
60183
|
-
return;
|
|
60184
|
-
visited.add(current);
|
|
60185
|
-
if (Array.isArray(current)) {
|
|
60186
|
-
current.forEach(visit);
|
|
60187
|
-
return;
|
|
60188
|
-
}
|
|
60189
|
-
Object.entries(current).forEach(([key, item]) => {
|
|
60190
|
-
if ((key === 'show_display' || key === 'showOnOneKey') && typeof item === 'boolean') {
|
|
60191
|
-
seen = true;
|
|
60192
|
-
enabled || (enabled = item);
|
|
60193
|
-
return;
|
|
60194
|
-
}
|
|
60195
|
-
visit(item);
|
|
60196
|
-
});
|
|
60197
|
-
};
|
|
60198
|
-
visit(value);
|
|
60199
|
-
return { seen, enabled };
|
|
60200
|
-
};
|
|
60201
|
-
const createMethodInteraction = (reason, operation) => ({
|
|
60202
|
-
request: 'button',
|
|
60203
|
-
source: 'method-lifecycle',
|
|
60204
|
-
reason,
|
|
60205
|
-
completion: 'operation-completed',
|
|
60206
|
-
deviceOnly: true,
|
|
60207
|
-
operation,
|
|
60208
|
-
});
|
|
60209
|
-
const hasCipherConfirmation = (value) => {
|
|
60210
|
-
if (Array.isArray(value))
|
|
60211
|
-
return value.some(hasCipherConfirmation);
|
|
60212
|
-
if (value == null || typeof value !== 'object')
|
|
60213
|
-
return false;
|
|
60214
|
-
const params = value;
|
|
60215
|
-
return params.encrypt === true ? params.ask_on_encrypt === true : params.ask_on_decrypt === true;
|
|
60216
|
-
};
|
|
60217
|
-
const resolveProtocolV2UiInteraction = (method) => {
|
|
60218
|
-
if (method.protocolV2UiInteraction)
|
|
60219
|
-
return method.protocolV2UiInteraction;
|
|
60220
|
-
const operation = method.name;
|
|
60221
|
-
if (!operation)
|
|
60222
|
-
return undefined;
|
|
60223
|
-
const isAddress = /getAddress(?:ByLoop)?$/i.test(operation);
|
|
60224
|
-
const isPublicKey = /getPublicKey$/i.test(operation);
|
|
60225
|
-
if (isAddress || isPublicKey) {
|
|
60226
|
-
const paramsDisplay = getDisplayState(method.params);
|
|
60227
|
-
const payloadDisplay = getDisplayState(method.payload);
|
|
60228
|
-
const display = paramsDisplay.seen ? paramsDisplay : payloadDisplay;
|
|
60229
|
-
const shouldDisplay = display.seen ? display.enabled : isAddress;
|
|
60230
|
-
if (!shouldDisplay)
|
|
60231
|
-
return undefined;
|
|
60232
|
-
return createMethodInteraction(isAddress ? 'address-confirmation' : 'public-key-confirmation', operation);
|
|
60233
|
-
}
|
|
60234
|
-
if (/sign/i.test(operation) || /verifyMessage$/i.test(operation) || operation === 'lnurlAuth') {
|
|
60235
|
-
return createMethodInteraction('signing-confirmation', operation);
|
|
60236
|
-
}
|
|
60237
|
-
if (operation === 'nostrEncryptMessage' || operation === 'nostrDecryptMessage') {
|
|
60238
|
-
const display = getDisplayState(method.params);
|
|
60239
|
-
if (!display.enabled)
|
|
60240
|
-
return undefined;
|
|
60241
|
-
return createMethodInteraction('signing-confirmation', operation);
|
|
60242
|
-
}
|
|
60243
|
-
if (operation === 'cipherKeyValue' && hasCipherConfirmation(method.params)) {
|
|
60244
|
-
return createMethodInteraction('signing-confirmation', operation);
|
|
60245
|
-
}
|
|
60246
|
-
return undefined;
|
|
60247
|
-
};
|
|
60248
|
-
class ProtocolV2UiInteractionCoordinator {
|
|
60249
|
-
constructor(device, postMessage) {
|
|
60250
|
-
this.opened = false;
|
|
60251
|
-
this.closed = false;
|
|
60252
|
-
this.device = device;
|
|
60253
|
-
this.postMessage = postMessage;
|
|
60254
|
-
}
|
|
60255
|
-
enterMethodInteraction(interaction) {
|
|
60256
|
-
var _a, _b;
|
|
60257
|
-
this.methodInteraction = interaction;
|
|
60258
|
-
if (!interaction)
|
|
60259
|
-
return;
|
|
60260
|
-
const { request } = interaction, metadata = __rest(interaction, ["request"]);
|
|
60261
|
-
this.emit(request === 'pin' ? UI_REQUEST.REQUEST_PIN : UI_REQUEST.REQUEST_BUTTON, Object.assign({ device: this.device.toMessageObject() }, metadata), `method:${request}:${interaction.reason}:${(_a = interaction.page) !== null && _a !== void 0 ? _a : ''}:${(_b = interaction.operation) !== null && _b !== void 0 ? _b : ''}`);
|
|
60262
|
-
}
|
|
60263
|
-
enterUnlockInteraction(method) {
|
|
60264
|
-
this.emit(UI_REQUEST.REQUEST_PIN, {
|
|
60265
|
-
device: this.device.toMessageObject(),
|
|
60266
|
-
source: 'unlock-coordinator',
|
|
60267
|
-
reason: 'device-locked',
|
|
60268
|
-
deviceOnly: true,
|
|
60269
|
-
method,
|
|
60270
|
-
}, `unlock:${method !== null && method !== void 0 ? method : ''}`);
|
|
60271
|
-
}
|
|
60272
|
-
resumeMethodInteraction() {
|
|
60273
|
-
this.enterMethodInteraction(this.methodInteraction);
|
|
60274
|
-
}
|
|
60275
|
-
close() {
|
|
60276
|
-
if (!this.device.isProtocolV2() || !this.opened || this.closed)
|
|
60277
|
-
return;
|
|
60278
|
-
this.closed = true;
|
|
60279
|
-
this.postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW));
|
|
60280
|
-
}
|
|
60281
|
-
emit(type, payload, phase) {
|
|
60282
|
-
if (!this.device.isProtocolV2() || this.closed || this.currentPhase === phase)
|
|
60283
|
-
return;
|
|
60284
|
-
this.currentPhase = phase;
|
|
60285
|
-
this.opened = true;
|
|
60286
|
-
const message = type === UI_REQUEST.REQUEST_BUTTON
|
|
60287
|
-
? createUiMessage(UI_REQUEST.REQUEST_BUTTON, payload)
|
|
60288
|
-
: createUiMessage(UI_REQUEST.REQUEST_PIN, payload);
|
|
60289
|
-
this.postMessage(message);
|
|
60290
|
-
}
|
|
60291
|
-
}
|
|
60292
|
-
|
|
60293
|
-
const Log$1 = getLogger(exports.LoggerNames.Core);
|
|
60294
|
-
const restoreExpectedWalletSessionAfterUnlock = (method, device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60295
|
-
var _a, _b, _c;
|
|
60296
|
-
const expectedPassphraseState = ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.useEmptyPassphrase)
|
|
60297
|
-
? undefined
|
|
60298
|
-
: (_c = (_b = method.payload) === null || _b === void 0 ? void 0 : _b.passphraseState) !== null && _c !== void 0 ? _c : device.passphraseState;
|
|
60299
|
-
if (!method.useDevicePassphraseState ||
|
|
60300
|
-
typeof expectedPassphraseState !== 'string' ||
|
|
60301
|
-
expectedPassphraseState.length === 0) {
|
|
60302
|
-
return;
|
|
60303
|
-
}
|
|
60304
|
-
yield restoreProtocolV2WalletSession(device, expectedPassphraseState);
|
|
60305
|
-
Log$1.debug('Protocol V2 wallet session restored after unlock', { method: method.name });
|
|
60306
|
-
});
|
|
60307
|
-
function runMethodWithUnlockRetry(method, device, uiCoordinator) {
|
|
60308
|
-
var _a;
|
|
60309
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60310
|
-
const shouldEmitUi = isProtocolV2UiEnabled(method);
|
|
60311
|
-
const shouldUnlockBeforeRun = device.isProtocolV2() && method.unlockPolicy !== 'none' && ((_a = device.features) === null || _a === void 0 ? void 0 : _a.unlocked) === false;
|
|
60312
|
-
if (shouldUnlockBeforeRun) {
|
|
60313
|
-
if (shouldEmitUi) {
|
|
60314
|
-
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterUnlockInteraction(method.name);
|
|
60315
|
-
}
|
|
60316
|
-
yield device.unlockDevice();
|
|
60317
|
-
Log$1.debug('Protocol V2 pre-unlock completed', { method: method.name });
|
|
60318
|
-
yield restoreExpectedWalletSessionAfterUnlock(method, device);
|
|
60319
|
-
if (shouldEmitUi) {
|
|
60320
|
-
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
|
|
60321
|
-
}
|
|
60322
|
-
return method.run();
|
|
60323
|
-
}
|
|
60324
|
-
if (shouldEmitUi) {
|
|
60325
|
-
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
|
|
60326
|
-
}
|
|
60327
|
-
try {
|
|
60328
|
-
return yield method.run();
|
|
60329
|
-
}
|
|
60330
|
-
catch (error) {
|
|
60331
|
-
if (!device.isProtocolV2() ||
|
|
60332
|
-
method.unlockPolicy !== 'retry-on-locked' ||
|
|
60333
|
-
!isDeviceLockedError(error)) {
|
|
60334
|
-
throw error;
|
|
60335
|
-
}
|
|
60336
|
-
Log$1.debug('Protocol V2 unlock retry triggered', { method: method.name });
|
|
60337
|
-
if (shouldEmitUi) {
|
|
60338
|
-
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterUnlockInteraction(method.name);
|
|
60339
|
-
}
|
|
60340
|
-
yield device.unlockDevice();
|
|
60341
|
-
Log$1.debug('Protocol V2 unlock completed', { method: method.name });
|
|
60342
|
-
yield restoreExpectedWalletSessionAfterUnlock(method, device);
|
|
60343
|
-
if (shouldEmitUi) {
|
|
60344
|
-
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.resumeMethodInteraction();
|
|
60345
|
-
}
|
|
60346
|
-
try {
|
|
60347
|
-
const response = yield method.run();
|
|
60348
|
-
Log$1.debug('Protocol V2 method retry completed', { method: method.name, success: true });
|
|
60349
|
-
return response;
|
|
60350
|
-
}
|
|
60351
|
-
catch (retryError) {
|
|
60352
|
-
Log$1.debug('Protocol V2 method retry completed', { method: method.name, success: false });
|
|
60353
|
-
throw retryError;
|
|
60354
|
-
}
|
|
60355
|
-
}
|
|
60356
|
-
});
|
|
60357
|
-
}
|
|
60358
|
-
|
|
60359
60622
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
60360
60623
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
60361
60624
|
const preWarmInflight = new Map();
|
|
@@ -60587,6 +60850,8 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60587
60850
|
}
|
|
60588
60851
|
registerHardwareUiEventListeners(device, {
|
|
60589
60852
|
pin: onDevicePinHandler,
|
|
60853
|
+
pinOnDevice: onEnterPinOnDeviceHandler,
|
|
60854
|
+
pinOnDeviceComplete: onPinOnDeviceCompleteHandler,
|
|
60590
60855
|
button: onDeviceButtonHandler,
|
|
60591
60856
|
passphrase: message.payload.useEmptyPassphrase
|
|
60592
60857
|
? onEmptyPassphraseHandler
|
|
@@ -60598,6 +60863,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60598
60863
|
device.on(DEVICE.STATE, onDeviceStateHandler);
|
|
60599
60864
|
device.on(DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE, onSelectDeviceInBootloaderForWebDeviceHandler);
|
|
60600
60865
|
const protocolV2UiCoordinator = new ProtocolV2UiInteractionCoordinator(device, postMessage);
|
|
60866
|
+
device.beginProtocolV2UiInteraction();
|
|
60601
60867
|
device.on(DEVICE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE, onSelectDeviceForSwitchFirmwareWebDeviceHandler);
|
|
60602
60868
|
try {
|
|
60603
60869
|
if (method.connectId) {
|
|
@@ -60693,13 +60959,16 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
60693
60959
|
require: support.require,
|
|
60694
60960
|
}));
|
|
60695
60961
|
}
|
|
60696
|
-
|
|
60962
|
+
yield ensureProtocolV2WalletSessionUnlocked(device);
|
|
60963
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_l = method.payload) === null || _l === void 0 ? void 0 : _l.passphraseState, (_m = method.payload) === null || _m === void 0 ? void 0 : _m.useEmptyPassphrase, (_o = method.payload) === null || _o === void 0 ? void 0 : _o.skipPassphraseCheck, hasDeriveCardano(method));
|
|
60697
60964
|
checkPassphraseEnableState(method, device.features);
|
|
60698
60965
|
if (!passphraseStateSafety) {
|
|
60699
60966
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
60700
60967
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError));
|
|
60701
60968
|
}
|
|
60702
|
-
|
|
60969
|
+
if (!device.isProtocolV2()) {
|
|
60970
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW));
|
|
60971
|
+
}
|
|
60703
60972
|
}
|
|
60704
60973
|
try {
|
|
60705
60974
|
yield method.checkSafetyLevelOnTestNet();
|
|
@@ -61208,15 +61477,7 @@ const onDeviceStateHandler = (...[_, stateEvent]) => {
|
|
|
61208
61477
|
const onDevicePassphraseHandler = (...[device, requestPayload, callback]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61209
61478
|
Log.debug('onDevicePassphraseHandler');
|
|
61210
61479
|
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
|
|
61211
|
-
postMessage(createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE, {
|
|
61212
|
-
device: device.toMessageObject(),
|
|
61213
|
-
passphraseState: device.passphraseState,
|
|
61214
|
-
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
61215
|
-
deviceOnly: requestPayload.deviceOnly,
|
|
61216
|
-
source: requestPayload.source,
|
|
61217
|
-
reason: requestPayload.reason,
|
|
61218
|
-
expectedPassphraseState: requestPayload.expectedPassphraseState,
|
|
61219
|
-
}));
|
|
61480
|
+
postMessage(createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE, Object.assign({ device: device.toMessageObject(), passphraseState: device.passphraseState, existsAttachPinUser: requestPayload.existsAttachPinUser, deviceOnly: requestPayload.deviceOnly, source: requestPayload.source, reason: requestPayload.reason, expectedPassphraseState: requestPayload.expectedPassphraseState }, (requestPayload.interaction ? { interaction: requestPayload.interaction } : {}))));
|
|
61220
61481
|
const uiResp = yield uiPromise.promise;
|
|
61221
61482
|
const { value, passphraseOnDevice, save, attachPinOnDevice } = uiResp.payload;
|
|
61222
61483
|
callback({
|
|
@@ -61231,20 +61492,19 @@ const onEmptyPassphraseHandler = (...[_, , callback]) => {
|
|
|
61231
61492
|
callback({ passphrase: '' });
|
|
61232
61493
|
};
|
|
61233
61494
|
const onEnterPassphraseOnDeviceHandler = (...[device, requestPayload]) => {
|
|
61234
|
-
postMessage(createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
61235
|
-
device: device.toMessageObject(),
|
|
61236
|
-
passphraseState: device.passphraseState,
|
|
61237
|
-
source: requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.source,
|
|
61238
|
-
reason: requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.reason,
|
|
61239
|
-
}));
|
|
61495
|
+
postMessage(createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, Object.assign({ device: device.toMessageObject(), passphraseState: device.passphraseState, source: requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.source, reason: requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.reason }, ((requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.interaction) ? { interaction: requestPayload.interaction } : {}))));
|
|
61240
61496
|
};
|
|
61241
61497
|
const onEnterAttachPinOnDeviceHandler = (...[device, requestPayload]) => {
|
|
61242
|
-
postMessage(createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
61243
|
-
|
|
61244
|
-
|
|
61245
|
-
|
|
61246
|
-
|
|
61247
|
-
|
|
61498
|
+
postMessage(createUiMessage(UI_REQUEST.REQUEST_PIN, Object.assign({ device: device.toMessageObject(), type: 'ButtonRequest_AttachPin', source: requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.source, reason: requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.reason }, ((requestPayload === null || requestPayload === void 0 ? void 0 : requestPayload.interaction) ? { interaction: requestPayload.interaction } : {}))));
|
|
61499
|
+
};
|
|
61500
|
+
const onEnterPinOnDeviceHandler = (...[device, pinType, metadata]) => {
|
|
61501
|
+
var _a;
|
|
61502
|
+
postMessage(createUiMessage(UI_REQUEST.REQUEST_PIN, Object.assign({ device: device.toMessageObject(), type: pinType === hdTransport.DeviceSessionPinType.AttachToPin
|
|
61503
|
+
? 'ButtonRequest_AttachPin'
|
|
61504
|
+
: 'ButtonRequest_PinEntry', source: metadata === null || metadata === void 0 ? void 0 : metadata.source, reason: metadata === null || metadata === void 0 ? void 0 : metadata.reason, deviceOnly: (_a = metadata === null || metadata === void 0 ? void 0 : metadata.deviceOnly) !== null && _a !== void 0 ? _a : true, completion: metadata === null || metadata === void 0 ? void 0 : metadata.completion, method: metadata === null || metadata === void 0 ? void 0 : metadata.method, page: metadata === null || metadata === void 0 ? void 0 : metadata.page, operation: metadata === null || metadata === void 0 ? void 0 : metadata.operation }, ((metadata === null || metadata === void 0 ? void 0 : metadata.interaction) ? { interaction: metadata.interaction } : {}))));
|
|
61505
|
+
};
|
|
61506
|
+
const onPinOnDeviceCompleteHandler = (...[_, metadata]) => {
|
|
61507
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW, metadata));
|
|
61248
61508
|
};
|
|
61249
61509
|
const onSelectDeviceInBootloaderForWebDeviceHandler = (...[device, callback]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61250
61510
|
Log.debug('onSelectDeviceInBootloaderForWebDeviceHandler');
|