@onekeyfe/hd-core 1.2.0-alpha.33 → 1.2.0-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/DeviceCommands.test.ts +84 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +31 -0
- package/__tests__/core-dispose.test.ts +3 -3
- package/__tests__/device-lifecycle-events.test.ts +52 -0
- package/__tests__/device-pool-state.test.ts +14 -2
- package/__tests__/device-settings.test.ts +25 -0
- package/__tests__/device-state-mapper.test.ts +13 -2
- package/__tests__/device-state-projector.test.ts +2 -2
- package/__tests__/device-utils.test.ts +1 -0
- package/__tests__/device-wallet-session-store.test.ts +137 -17
- package/__tests__/evmSignTransaction.test.ts +69 -0
- package/__tests__/get-device-state.test.ts +78 -30
- package/__tests__/kaspaSignTransaction.test.ts +9 -0
- package/__tests__/known-device-public-types.type-test.ts +3 -0
- package/__tests__/logBlockEvent.test.ts +89 -5
- package/__tests__/open-wallet-session.test.ts +499 -60
- package/__tests__/pro2Wallpaper.test.ts +1 -1
- package/__tests__/protocol-v2.test.ts +1180 -169
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +2 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.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/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +10 -4
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +1 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts +1 -0
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts.map +1 -1
- package/dist/device/DeviceStateProjector.d.ts.map +1 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +7 -0
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts +7 -0
- package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts.map +1 -0
- package/dist/events/logBlockEvent.d.ts +2 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +25 -11
- package/dist/index.js +1037 -838
- 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/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -10
- package/dist/protocols/protocol-v2/walletSession.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 +6 -3
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -5
- 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/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +11 -81
- package/src/api/FirmwareUpdateV4.ts +59 -25
- package/src/api/GetPassphraseState.ts +11 -2
- package/src/api/OpenWalletSession.ts +16 -8
- package/src/api/device/DeviceSettings.ts +8 -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/kaspa/KaspaSignTransaction.ts +7 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +2 -2
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +1 -1
- package/src/core/index.ts +7 -5
- package/src/data/messages/messages-protocol-v2.json +393 -485
- package/src/device/Device.ts +98 -44
- package/src/device/DeviceCommands.ts +12 -2
- package/src/device/DeviceConnector.ts +10 -7
- package/src/device/DevicePool.ts +5 -3
- package/src/device/DeviceStateMapper.ts +5 -3
- package/src/device/DeviceStateProjector.ts +0 -7
- package/src/device/DeviceWalletSessionStore.ts +43 -4
- package/src/deviceProfile/buildDeviceFeatures.ts +11 -4
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +32 -0
- package/src/events/logBlockEvent.ts +84 -1
- package/src/protocols/protocol-v2/deviceSession.ts +1 -1
- package/src/protocols/protocol-v2/features.ts +58 -16
- package/src/protocols/protocol-v2/index.ts +5 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +8 -3
- package/src/protocols/protocol-v2/unlockRetry.ts +18 -7
- package/src/protocols/protocol-v2/walletSession.ts +144 -62
- package/src/types/api/protocolV2.ts +2 -2
- package/src/types/device.ts +8 -2
- package/src/types/params.ts +2 -1
- package/src/utils/deviceFeaturesCompat.ts +8 -1
- package/src/utils/pro2Wallpaper.ts +3 -9
- package/tsconfig.type-tests.json +5 -1
package/dist/index.js
CHANGED
|
@@ -1473,10 +1473,14 @@ const resolveDeviceBleName = (features) => {
|
|
|
1473
1473
|
return ((_a = firstNonEmptyString(compatible.bleName, compatible.onekey_ble_name, compatible.ble_name)) !== null && _a !== void 0 ? _a : null);
|
|
1474
1474
|
};
|
|
1475
1475
|
const resolveDeviceFirmwareVersion = (features) => {
|
|
1476
|
+
var _a;
|
|
1476
1477
|
if (!features)
|
|
1477
1478
|
return null;
|
|
1478
1479
|
const compatible = asCompatibleFeatures(features);
|
|
1479
|
-
|
|
1480
|
+
const bootloaderMode = (_a = compatible.bootloaderMode) !== null && _a !== void 0 ? _a : compatible.bootloader_mode;
|
|
1481
|
+
return firstMeaningfulVersion$1(compatible.firmwareVersion, compatible.onekey_firmware_version, compatible.onekey_version, bootloaderMode
|
|
1482
|
+
? null
|
|
1483
|
+
: versionFromParts(compatible.major_version, compatible.minor_version, compatible.patch_version));
|
|
1480
1484
|
};
|
|
1481
1485
|
const resolveDeviceBootloaderVersion = (features) => {
|
|
1482
1486
|
var _a;
|
|
@@ -25876,8 +25880,6 @@ var nested = {
|
|
|
25876
25880
|
MessageType_ResetDevice: 14,
|
|
25877
25881
|
MessageType_SetBusy: 16,
|
|
25878
25882
|
MessageType_Features: 17,
|
|
25879
|
-
MessageType_PinMatrixRequest: 18,
|
|
25880
|
-
MessageType_PinMatrixAck: 19,
|
|
25881
25883
|
MessageType_Cancel: 20,
|
|
25882
25884
|
MessageType_LockDevice: 24,
|
|
25883
25885
|
MessageType_ApplySettings: 25,
|
|
@@ -25939,20 +25941,6 @@ var nested = {
|
|
|
25939
25941
|
MessageType_CosiSignature: 74,
|
|
25940
25942
|
MessageType_BatchGetPublickeys: 10016,
|
|
25941
25943
|
MessageType_EcdsaPublicKeys: 10017,
|
|
25942
|
-
MessageType_DebugLinkDecision: 100,
|
|
25943
|
-
MessageType_DebugLinkGetState: 101,
|
|
25944
|
-
MessageType_DebugLinkState: 102,
|
|
25945
|
-
MessageType_DebugLinkStop: 103,
|
|
25946
|
-
MessageType_DebugLinkLog: 104,
|
|
25947
|
-
MessageType_DebugLinkMemoryRead: 110,
|
|
25948
|
-
MessageType_DebugLinkMemory: 111,
|
|
25949
|
-
MessageType_DebugLinkMemoryWrite: 112,
|
|
25950
|
-
MessageType_DebugLinkFlashErase: 113,
|
|
25951
|
-
MessageType_DebugLinkLayout: 9001,
|
|
25952
|
-
MessageType_DebugLinkReseedRandom: 9002,
|
|
25953
|
-
MessageType_DebugLinkRecordScreen: 9003,
|
|
25954
|
-
MessageType_DebugLinkEraseSdCard: 9005,
|
|
25955
|
-
MessageType_DebugLinkWatchLayout: 9006,
|
|
25956
25944
|
MessageType_EthereumGetPublicKey: 450,
|
|
25957
25945
|
MessageType_EthereumPublicKey: 451,
|
|
25958
25946
|
MessageType_EthereumGetAddress: 56,
|
|
@@ -26216,13 +26204,6 @@ var nested = {
|
|
|
26216
26204
|
MessageType_TonSignProof: 11905,
|
|
26217
26205
|
MessageType_TonSignedProof: 11906,
|
|
26218
26206
|
MessageType_TonTxAck: 11907,
|
|
26219
|
-
MessageType_ScdoGetAddress: 12001,
|
|
26220
|
-
MessageType_ScdoAddress: 12002,
|
|
26221
|
-
MessageType_ScdoSignTx: 12003,
|
|
26222
|
-
MessageType_ScdoSignedTx: 12004,
|
|
26223
|
-
MessageType_ScdoTxAck: 12005,
|
|
26224
|
-
MessageType_ScdoSignMessage: 12006,
|
|
26225
|
-
MessageType_ScdoSignedMessage: 12007,
|
|
26226
26207
|
MessageType_AlephiumGetAddress: 12101,
|
|
26227
26208
|
MessageType_AlephiumAddress: 12102,
|
|
26228
26209
|
MessageType_AlephiumSignTx: 12103,
|
|
@@ -26245,11 +26226,6 @@ var nested = {
|
|
|
26245
26226
|
MessageType_NeoAddress: 12302,
|
|
26246
26227
|
MessageType_NeoSignTx: 12303,
|
|
26247
26228
|
MessageType_NeoSignedTx: 12304,
|
|
26248
|
-
MessageType_UiviewShowAddressRequest: 30200,
|
|
26249
|
-
MessageType_UiviewShowPublicKeyRequest: 30201,
|
|
26250
|
-
MessageType_UiviewConfirmTxRequest: 30202,
|
|
26251
|
-
MessageType_UiviewConfirmSignMessageRequest: 30203,
|
|
26252
|
-
MessageType_UiviewResponse: 30204,
|
|
26253
26229
|
MessageType_DeviceFactoryInfoSet: 60000,
|
|
26254
26230
|
MessageType_DeviceFactoryInfoGet: 60001,
|
|
26255
26231
|
MessageType_DeviceFactoryInfo: 60002,
|
|
@@ -26270,19 +26246,11 @@ var nested = {
|
|
|
26270
26246
|
MessageType_DeviceCertificateRead: 60422,
|
|
26271
26247
|
MessageType_DeviceCertificateSignature: 60423,
|
|
26272
26248
|
MessageType_DeviceCertificateSign: 60424,
|
|
26273
|
-
|
|
26274
|
-
MessageType_GetWallpaper: 60431,
|
|
26275
|
-
MessageType_Wallpaper: 60432,
|
|
26249
|
+
MessageType_DeviceMiscUsbMscControl: 60440,
|
|
26276
26250
|
MessageType_DeviceInfoGet: 60600,
|
|
26277
26251
|
MessageType_DeviceInfo: 60601,
|
|
26278
26252
|
MessageType_DeviceStatusGet: 60602,
|
|
26279
26253
|
MessageType_DeviceStatus: 60603,
|
|
26280
|
-
MessageType_DevGetOnboardingStatus: 60604,
|
|
26281
|
-
MessageType_DevOnboardingStatus: 60605,
|
|
26282
|
-
MessageType_DeviceSessionGet: 60606,
|
|
26283
|
-
MessageType_DeviceSession: 60607,
|
|
26284
|
-
MessageType_DeviceSessionAskPin: 60608,
|
|
26285
|
-
MessageType_DeviceSessionAskPassphrase: 60609,
|
|
26286
26254
|
MessageType_FilesystemPermissionFix: 60800,
|
|
26287
26255
|
MessageType_FilesystemPathInfo: 60801,
|
|
26288
26256
|
MessageType_FilesystemPathInfoQuery: 60802,
|
|
@@ -26298,7 +26266,13 @@ var nested = {
|
|
|
26298
26266
|
MessageType_DeviceFirmwareUpdateRequest: 61000,
|
|
26299
26267
|
MessageType_DeviceFirmwareUpdateStatusGet: 61001,
|
|
26300
26268
|
MessageType_DeviceFirmwareUpdateStatus: 61002,
|
|
26301
|
-
|
|
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
|
|
26302
26276
|
},
|
|
26303
26277
|
reserved: [
|
|
26304
26278
|
[
|
|
@@ -31775,30 +31749,6 @@ var nested = {
|
|
|
31775
31749
|
}
|
|
31776
31750
|
}
|
|
31777
31751
|
},
|
|
31778
|
-
InternalMyAddressRequest: {
|
|
31779
|
-
fields: {
|
|
31780
|
-
coin_type: {
|
|
31781
|
-
rule: "required",
|
|
31782
|
-
type: "uint32",
|
|
31783
|
-
id: 1
|
|
31784
|
-
},
|
|
31785
|
-
chain_id: {
|
|
31786
|
-
rule: "required",
|
|
31787
|
-
type: "uint32",
|
|
31788
|
-
id: 2
|
|
31789
|
-
},
|
|
31790
|
-
account_index: {
|
|
31791
|
-
rule: "required",
|
|
31792
|
-
type: "uint32",
|
|
31793
|
-
id: 3
|
|
31794
|
-
},
|
|
31795
|
-
derive_type: {
|
|
31796
|
-
rule: "required",
|
|
31797
|
-
type: "uint32",
|
|
31798
|
-
id: 4
|
|
31799
|
-
}
|
|
31800
|
-
}
|
|
31801
|
-
},
|
|
31802
31752
|
KaspaGetAddress: {
|
|
31803
31753
|
fields: {
|
|
31804
31754
|
address_n: {
|
|
@@ -32003,29 +31953,6 @@ var nested = {
|
|
|
32003
31953
|
}
|
|
32004
31954
|
}
|
|
32005
31955
|
},
|
|
32006
|
-
StartSession: {
|
|
32007
|
-
fields: {
|
|
32008
|
-
session_id: {
|
|
32009
|
-
type: "bytes",
|
|
32010
|
-
id: 1
|
|
32011
|
-
},
|
|
32012
|
-
_skip_passphrase: {
|
|
32013
|
-
type: "bool",
|
|
32014
|
-
id: 2,
|
|
32015
|
-
options: {
|
|
32016
|
-
deprecated: true
|
|
32017
|
-
}
|
|
32018
|
-
},
|
|
32019
|
-
derive_cardano: {
|
|
32020
|
-
type: "bool",
|
|
32021
|
-
id: 3
|
|
32022
|
-
}
|
|
32023
|
-
}
|
|
32024
|
-
},
|
|
32025
|
-
EndSession: {
|
|
32026
|
-
fields: {
|
|
32027
|
-
}
|
|
32028
|
-
},
|
|
32029
31956
|
GetFeatures: {
|
|
32030
31957
|
fields: {
|
|
32031
31958
|
}
|
|
@@ -33162,49 +33089,6 @@ var nested = {
|
|
|
33162
33089
|
}
|
|
33163
33090
|
}
|
|
33164
33091
|
},
|
|
33165
|
-
WallpaperTarget: {
|
|
33166
|
-
values: {
|
|
33167
|
-
Home: 0,
|
|
33168
|
-
Lock: 1
|
|
33169
|
-
}
|
|
33170
|
-
},
|
|
33171
|
-
SetWallpaper: {
|
|
33172
|
-
fields: {
|
|
33173
|
-
target: {
|
|
33174
|
-
rule: "required",
|
|
33175
|
-
type: "WallpaperTarget",
|
|
33176
|
-
id: 1
|
|
33177
|
-
},
|
|
33178
|
-
path: {
|
|
33179
|
-
rule: "required",
|
|
33180
|
-
type: "string",
|
|
33181
|
-
id: 2
|
|
33182
|
-
}
|
|
33183
|
-
}
|
|
33184
|
-
},
|
|
33185
|
-
GetWallpaper: {
|
|
33186
|
-
fields: {
|
|
33187
|
-
target: {
|
|
33188
|
-
rule: "required",
|
|
33189
|
-
type: "WallpaperTarget",
|
|
33190
|
-
id: 1
|
|
33191
|
-
}
|
|
33192
|
-
}
|
|
33193
|
-
},
|
|
33194
|
-
Wallpaper: {
|
|
33195
|
-
fields: {
|
|
33196
|
-
target: {
|
|
33197
|
-
rule: "required",
|
|
33198
|
-
type: "WallpaperTarget",
|
|
33199
|
-
id: 1
|
|
33200
|
-
},
|
|
33201
|
-
path: {
|
|
33202
|
-
rule: "required",
|
|
33203
|
-
type: "string",
|
|
33204
|
-
id: 2
|
|
33205
|
-
}
|
|
33206
|
-
}
|
|
33207
|
-
},
|
|
33208
33092
|
ResourceUpdate: {
|
|
33209
33093
|
fields: {
|
|
33210
33094
|
file_name: {
|
|
@@ -37375,162 +37259,6 @@ var nested = {
|
|
|
37375
37259
|
}
|
|
37376
37260
|
}
|
|
37377
37261
|
},
|
|
37378
|
-
ViewAmount: {
|
|
37379
|
-
fields: {
|
|
37380
|
-
is_unlimited: {
|
|
37381
|
-
rule: "required",
|
|
37382
|
-
type: "bool",
|
|
37383
|
-
id: 1
|
|
37384
|
-
},
|
|
37385
|
-
num: {
|
|
37386
|
-
rule: "required",
|
|
37387
|
-
type: "string",
|
|
37388
|
-
id: 2
|
|
37389
|
-
}
|
|
37390
|
-
}
|
|
37391
|
-
},
|
|
37392
|
-
ViewDetail: {
|
|
37393
|
-
fields: {
|
|
37394
|
-
key: {
|
|
37395
|
-
rule: "required",
|
|
37396
|
-
type: "uint32",
|
|
37397
|
-
id: 1
|
|
37398
|
-
},
|
|
37399
|
-
value: {
|
|
37400
|
-
rule: "required",
|
|
37401
|
-
type: "string",
|
|
37402
|
-
id: 2
|
|
37403
|
-
},
|
|
37404
|
-
is_overview: {
|
|
37405
|
-
rule: "required",
|
|
37406
|
-
type: "bool",
|
|
37407
|
-
id: 3
|
|
37408
|
-
},
|
|
37409
|
-
has_icon: {
|
|
37410
|
-
rule: "required",
|
|
37411
|
-
type: "bool",
|
|
37412
|
-
id: 4
|
|
37413
|
-
}
|
|
37414
|
-
}
|
|
37415
|
-
},
|
|
37416
|
-
ViewTipType: {
|
|
37417
|
-
values: {
|
|
37418
|
-
Default: 0,
|
|
37419
|
-
Highlight: 1,
|
|
37420
|
-
Recommend: 2,
|
|
37421
|
-
Warning: 3,
|
|
37422
|
-
Danger: 4
|
|
37423
|
-
}
|
|
37424
|
-
},
|
|
37425
|
-
ViewTip: {
|
|
37426
|
-
fields: {
|
|
37427
|
-
type: {
|
|
37428
|
-
rule: "required",
|
|
37429
|
-
type: "ViewTipType",
|
|
37430
|
-
id: 1
|
|
37431
|
-
},
|
|
37432
|
-
text: {
|
|
37433
|
-
rule: "required",
|
|
37434
|
-
type: "string",
|
|
37435
|
-
id: 2
|
|
37436
|
-
}
|
|
37437
|
-
}
|
|
37438
|
-
},
|
|
37439
|
-
ViewRawData: {
|
|
37440
|
-
fields: {
|
|
37441
|
-
initial_data: {
|
|
37442
|
-
rule: "required",
|
|
37443
|
-
type: "string",
|
|
37444
|
-
id: 1
|
|
37445
|
-
},
|
|
37446
|
-
placeholder: {
|
|
37447
|
-
rule: "required",
|
|
37448
|
-
type: "uint32",
|
|
37449
|
-
id: 2
|
|
37450
|
-
}
|
|
37451
|
-
}
|
|
37452
|
-
},
|
|
37453
|
-
ViewSignLayout: {
|
|
37454
|
-
values: {
|
|
37455
|
-
LayoutDefault: 0,
|
|
37456
|
-
LayoutSafeTxCreate: 1,
|
|
37457
|
-
LayoutFinalConfirm: 2,
|
|
37458
|
-
Layout7702: 3,
|
|
37459
|
-
LayoutFlat: 4,
|
|
37460
|
-
LayoutEthApprove: 5
|
|
37461
|
-
}
|
|
37462
|
-
},
|
|
37463
|
-
ViewSignPage: {
|
|
37464
|
-
fields: {
|
|
37465
|
-
title: {
|
|
37466
|
-
rule: "required",
|
|
37467
|
-
type: "string",
|
|
37468
|
-
id: 1
|
|
37469
|
-
},
|
|
37470
|
-
amount: {
|
|
37471
|
-
type: "ViewAmount",
|
|
37472
|
-
id: 2
|
|
37473
|
-
},
|
|
37474
|
-
general: {
|
|
37475
|
-
rule: "repeated",
|
|
37476
|
-
type: "ViewDetail",
|
|
37477
|
-
id: 3
|
|
37478
|
-
},
|
|
37479
|
-
tip: {
|
|
37480
|
-
type: "ViewTip",
|
|
37481
|
-
id: 4
|
|
37482
|
-
},
|
|
37483
|
-
raw_data: {
|
|
37484
|
-
type: "ViewRawData",
|
|
37485
|
-
id: 5
|
|
37486
|
-
},
|
|
37487
|
-
slide_to_confirm: {
|
|
37488
|
-
type: "bool",
|
|
37489
|
-
id: 6,
|
|
37490
|
-
options: {
|
|
37491
|
-
"default": true
|
|
37492
|
-
}
|
|
37493
|
-
},
|
|
37494
|
-
layout: {
|
|
37495
|
-
type: "ViewSignLayout",
|
|
37496
|
-
id: 7,
|
|
37497
|
-
options: {
|
|
37498
|
-
"default": "LayoutDefault"
|
|
37499
|
-
}
|
|
37500
|
-
}
|
|
37501
|
-
}
|
|
37502
|
-
},
|
|
37503
|
-
ViewVerifyPage: {
|
|
37504
|
-
fields: {
|
|
37505
|
-
title: {
|
|
37506
|
-
rule: "required",
|
|
37507
|
-
type: "string",
|
|
37508
|
-
id: 1
|
|
37509
|
-
},
|
|
37510
|
-
address: {
|
|
37511
|
-
rule: "required",
|
|
37512
|
-
type: "string",
|
|
37513
|
-
id: 2
|
|
37514
|
-
},
|
|
37515
|
-
path: {
|
|
37516
|
-
rule: "required",
|
|
37517
|
-
type: "string",
|
|
37518
|
-
id: 3
|
|
37519
|
-
},
|
|
37520
|
-
network: {
|
|
37521
|
-
type: "string",
|
|
37522
|
-
id: 4
|
|
37523
|
-
},
|
|
37524
|
-
derive_type: {
|
|
37525
|
-
type: "string",
|
|
37526
|
-
id: 5
|
|
37527
|
-
},
|
|
37528
|
-
value_key: {
|
|
37529
|
-
type: "uint32",
|
|
37530
|
-
id: 6
|
|
37531
|
-
}
|
|
37532
|
-
}
|
|
37533
|
-
},
|
|
37534
37262
|
WebAuthnListResidentCredentials: {
|
|
37535
37263
|
fields: {
|
|
37536
37264
|
}
|
|
@@ -37632,17 +37360,18 @@ var nested = {
|
|
|
37632
37360
|
type: "uint32",
|
|
37633
37361
|
id: 1
|
|
37634
37362
|
},
|
|
37363
|
+
build_fingerprint: {
|
|
37364
|
+
rule: "required",
|
|
37365
|
+
type: "string",
|
|
37366
|
+
id: 2
|
|
37367
|
+
},
|
|
37635
37368
|
supported_messages: {
|
|
37636
37369
|
rule: "repeated",
|
|
37637
37370
|
type: "uint32",
|
|
37638
|
-
id:
|
|
37371
|
+
id: 3,
|
|
37639
37372
|
options: {
|
|
37640
37373
|
packed: false
|
|
37641
37374
|
}
|
|
37642
|
-
},
|
|
37643
|
-
protobuf_definition: {
|
|
37644
|
-
type: "string",
|
|
37645
|
-
id: 3
|
|
37646
37375
|
}
|
|
37647
37376
|
}
|
|
37648
37377
|
},
|
|
@@ -37872,109 +37601,11 @@ var nested = {
|
|
|
37872
37601
|
}
|
|
37873
37602
|
}
|
|
37874
37603
|
},
|
|
37875
|
-
|
|
37876
|
-
values: {
|
|
37877
|
-
FW_MGMT_TARGET_INVALID: 0,
|
|
37878
|
-
FW_MGMT_TARGET_CRATE: 1,
|
|
37879
|
-
FW_MGMT_TARGET_ROMLOADER: 2,
|
|
37880
|
-
FW_MGMT_TARGET_BOOTLOADER: 3,
|
|
37881
|
-
FW_MGMT_TARGET_APPLICATION_P1: 4,
|
|
37882
|
-
FW_MGMT_TARGET_APPLICATION_P2: 5,
|
|
37883
|
-
FW_MGMT_TARGET_COPROCESSOR: 6,
|
|
37884
|
-
FW_MGMT_TARGET_SE01: 7,
|
|
37885
|
-
FW_MGMT_TARGET_SE02: 8,
|
|
37886
|
-
FW_MGMT_TARGET_SE03: 9,
|
|
37887
|
-
FW_MGMT_TARGET_SE04: 10
|
|
37888
|
-
}
|
|
37889
|
-
},
|
|
37890
|
-
DeviceFirmwareUpdateTaskStatus: {
|
|
37891
|
-
values: {
|
|
37892
|
-
FW_MGMT_UPDATER_TASK_STATUS_PENDING: 0,
|
|
37893
|
-
FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS: 1,
|
|
37894
|
-
FW_MGMT_UPDATER_TASK_STATUS_FINISHED: 2,
|
|
37895
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND: 3,
|
|
37896
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ: 4,
|
|
37897
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE: 5,
|
|
37898
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY: 6,
|
|
37899
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL: 7,
|
|
37900
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT: 8,
|
|
37901
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY: 9,
|
|
37902
|
-
FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS: 10
|
|
37903
|
-
}
|
|
37904
|
-
},
|
|
37905
|
-
DeviceFirmwareTarget: {
|
|
37906
|
-
fields: {
|
|
37907
|
-
target_id: {
|
|
37908
|
-
rule: "required",
|
|
37909
|
-
type: "DeviceFirmwareTargetType",
|
|
37910
|
-
id: 1
|
|
37911
|
-
},
|
|
37912
|
-
path: {
|
|
37913
|
-
rule: "required",
|
|
37914
|
-
type: "string",
|
|
37915
|
-
id: 2
|
|
37916
|
-
}
|
|
37917
|
-
}
|
|
37918
|
-
},
|
|
37919
|
-
DeviceFirmwareUpdateRequest: {
|
|
37920
|
-
fields: {
|
|
37921
|
-
targets: {
|
|
37922
|
-
rule: "repeated",
|
|
37923
|
-
type: "DeviceFirmwareTarget",
|
|
37924
|
-
id: 1
|
|
37925
|
-
}
|
|
37926
|
-
}
|
|
37927
|
-
},
|
|
37928
|
-
DeviceFirmwareUpdateRecord: {
|
|
37604
|
+
DeviceMiscUsbMscControl: {
|
|
37929
37605
|
fields: {
|
|
37930
|
-
|
|
37606
|
+
enable: {
|
|
37931
37607
|
rule: "required",
|
|
37932
|
-
type: "DeviceFirmwareTargetType",
|
|
37933
|
-
id: 1
|
|
37934
|
-
},
|
|
37935
|
-
status: {
|
|
37936
|
-
type: "DeviceFirmwareUpdateTaskStatus",
|
|
37937
|
-
id: 10
|
|
37938
|
-
},
|
|
37939
|
-
payload_version: {
|
|
37940
|
-
type: "uint32",
|
|
37941
|
-
id: 20
|
|
37942
|
-
},
|
|
37943
|
-
path: {
|
|
37944
|
-
type: "string",
|
|
37945
|
-
id: 30
|
|
37946
|
-
}
|
|
37947
|
-
}
|
|
37948
|
-
},
|
|
37949
|
-
DeviceFirmwareUpdateRecordFields: {
|
|
37950
|
-
fields: {
|
|
37951
|
-
status: {
|
|
37952
|
-
type: "bool",
|
|
37953
|
-
id: 10
|
|
37954
|
-
},
|
|
37955
|
-
payload_version: {
|
|
37956
|
-
type: "bool",
|
|
37957
|
-
id: 20
|
|
37958
|
-
},
|
|
37959
|
-
path: {
|
|
37960
37608
|
type: "bool",
|
|
37961
|
-
id: 30
|
|
37962
|
-
}
|
|
37963
|
-
}
|
|
37964
|
-
},
|
|
37965
|
-
DeviceFirmwareUpdateStatusGet: {
|
|
37966
|
-
fields: {
|
|
37967
|
-
fields: {
|
|
37968
|
-
type: "DeviceFirmwareUpdateRecordFields",
|
|
37969
|
-
id: 1
|
|
37970
|
-
}
|
|
37971
|
-
}
|
|
37972
|
-
},
|
|
37973
|
-
DeviceFirmwareUpdateStatus: {
|
|
37974
|
-
fields: {
|
|
37975
|
-
records: {
|
|
37976
|
-
rule: "repeated",
|
|
37977
|
-
type: "DeviceFirmwareUpdateRecord",
|
|
37978
37609
|
id: 1
|
|
37979
37610
|
}
|
|
37980
37611
|
}
|
|
@@ -38079,6 +37710,113 @@ var nested = {
|
|
|
38079
37710
|
}
|
|
38080
37711
|
}
|
|
38081
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
|
+
},
|
|
38082
37820
|
DeviceType: {
|
|
38083
37821
|
values: {
|
|
38084
37822
|
CLASSIC1: 0,
|
|
@@ -38229,10 +37967,6 @@ var nested = {
|
|
|
38229
37967
|
se4: {
|
|
38230
37968
|
type: "bool",
|
|
38231
37969
|
id: 430
|
|
38232
|
-
},
|
|
38233
|
-
status: {
|
|
38234
|
-
type: "bool",
|
|
38235
|
-
id: 10000
|
|
38236
37970
|
}
|
|
38237
37971
|
}
|
|
38238
37972
|
},
|
|
@@ -38302,10 +38036,6 @@ var nested = {
|
|
|
38302
38036
|
se4: {
|
|
38303
38037
|
type: "DeviceSEInfo",
|
|
38304
38038
|
id: 430
|
|
38305
|
-
},
|
|
38306
|
-
status: {
|
|
38307
|
-
type: "DeviceStatus",
|
|
38308
|
-
id: 10000
|
|
38309
38039
|
}
|
|
38310
38040
|
}
|
|
38311
38041
|
},
|
|
@@ -38361,6 +38091,7 @@ var nested = {
|
|
|
38361
38091
|
id: 1
|
|
38362
38092
|
},
|
|
38363
38093
|
on_device: {
|
|
38094
|
+
rule: "required",
|
|
38364
38095
|
type: "bool",
|
|
38365
38096
|
id: 2
|
|
38366
38097
|
}
|
|
@@ -38407,89 +38138,6 @@ var nested = {
|
|
|
38407
38138
|
fields: {
|
|
38408
38139
|
}
|
|
38409
38140
|
},
|
|
38410
|
-
DevOnboardingStep: {
|
|
38411
|
-
values: {
|
|
38412
|
-
DEV_ONBOARDING_STEP_UNKNOWN: 0,
|
|
38413
|
-
DEV_ONBOARDING_STEP_CHECKING: 1,
|
|
38414
|
-
DEV_ONBOARDING_STEP_PERSONALIZATION: 2,
|
|
38415
|
-
DEV_ONBOARDING_STEP_PIN: 3,
|
|
38416
|
-
DEV_ONBOARDING_STEP_SETUP: 4,
|
|
38417
|
-
DEV_ONBOARDING_STEP_DONE: 5
|
|
38418
|
-
}
|
|
38419
|
-
},
|
|
38420
|
-
DevOnboardingPhase: {
|
|
38421
|
-
values: {
|
|
38422
|
-
DEV_ONBOARDING_PHASE_UNKNOWN: 0,
|
|
38423
|
-
DEV_ONBOARDING_PHASE_SAFETY_CHECK: 1,
|
|
38424
|
-
DEV_ONBOARDING_PHASE_PIN_SETUP: 2,
|
|
38425
|
-
DEV_ONBOARDING_PHASE_FINGERPRINT_SETUP: 3,
|
|
38426
|
-
DEV_ONBOARDING_PHASE_SETUP_CHOICE: 4,
|
|
38427
|
-
DEV_ONBOARDING_PHASE_WALLET_CREATE_START: 5,
|
|
38428
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW: 6,
|
|
38429
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM: 7,
|
|
38430
|
-
DEV_ONBOARDING_PHASE_RESTORE_METHOD_CHOICE: 8,
|
|
38431
|
-
DEV_ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE: 9,
|
|
38432
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_RESTORE: 10,
|
|
38433
|
-
DEV_ONBOARDING_PHASE_WALLET_READY: 11,
|
|
38434
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT: 12,
|
|
38435
|
-
DEV_ONBOARDING_PHASE_SEEDCARD_BACKUP: 13
|
|
38436
|
-
}
|
|
38437
|
-
},
|
|
38438
|
-
DevOnboardingSetupKind: {
|
|
38439
|
-
values: {
|
|
38440
|
-
DEV_ONBOARDING_SETUP_KIND_UNKNOWN: 0,
|
|
38441
|
-
DEV_ONBOARDING_SETUP_KIND_CHOICE: 1,
|
|
38442
|
-
DEV_ONBOARDING_SETUP_KIND_CREATE: 2,
|
|
38443
|
-
DEV_ONBOARDING_SETUP_KIND_RESTORE: 3
|
|
38444
|
-
}
|
|
38445
|
-
},
|
|
38446
|
-
DevOnboardingSetupMethod: {
|
|
38447
|
-
values: {
|
|
38448
|
-
DEV_ONBOARDING_SETUP_METHOD_UNKNOWN: 0,
|
|
38449
|
-
DEV_ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE: 1,
|
|
38450
|
-
DEV_ONBOARDING_SETUP_METHOD_SEEDCARD: 2
|
|
38451
|
-
}
|
|
38452
|
-
},
|
|
38453
|
-
DevOnboardingSetupStatus: {
|
|
38454
|
-
fields: {
|
|
38455
|
-
kind: {
|
|
38456
|
-
type: "DevOnboardingSetupKind",
|
|
38457
|
-
id: 1
|
|
38458
|
-
},
|
|
38459
|
-
method: {
|
|
38460
|
-
type: "DevOnboardingSetupMethod",
|
|
38461
|
-
id: 2
|
|
38462
|
-
}
|
|
38463
|
-
}
|
|
38464
|
-
},
|
|
38465
|
-
DevGetOnboardingStatus: {
|
|
38466
|
-
fields: {
|
|
38467
|
-
}
|
|
38468
|
-
},
|
|
38469
|
-
DevOnboardingStatus: {
|
|
38470
|
-
fields: {
|
|
38471
|
-
step: {
|
|
38472
|
-
type: "DevOnboardingStep",
|
|
38473
|
-
id: 1
|
|
38474
|
-
},
|
|
38475
|
-
phase: {
|
|
38476
|
-
type: "DevOnboardingPhase",
|
|
38477
|
-
id: 2
|
|
38478
|
-
},
|
|
38479
|
-
setup: {
|
|
38480
|
-
type: "DevOnboardingSetupStatus",
|
|
38481
|
-
id: 3
|
|
38482
|
-
},
|
|
38483
|
-
pin_set: {
|
|
38484
|
-
type: "bool",
|
|
38485
|
-
id: 4
|
|
38486
|
-
},
|
|
38487
|
-
wallet_initialized: {
|
|
38488
|
-
type: "bool",
|
|
38489
|
-
id: 5
|
|
38490
|
-
}
|
|
38491
|
-
}
|
|
38492
|
-
},
|
|
38493
38141
|
FilesystemPermissionFix: {
|
|
38494
38142
|
fields: {
|
|
38495
38143
|
}
|
|
@@ -38717,10 +38365,273 @@ var nested = {
|
|
|
38717
38365
|
}
|
|
38718
38366
|
}
|
|
38719
38367
|
},
|
|
38368
|
+
InternalMyAddressRequest: {
|
|
38369
|
+
fields: {
|
|
38370
|
+
coin_type: {
|
|
38371
|
+
rule: "required",
|
|
38372
|
+
type: "uint32",
|
|
38373
|
+
id: 1
|
|
38374
|
+
},
|
|
38375
|
+
chain_id: {
|
|
38376
|
+
rule: "required",
|
|
38377
|
+
type: "uint32",
|
|
38378
|
+
id: 2
|
|
38379
|
+
},
|
|
38380
|
+
account_index: {
|
|
38381
|
+
rule: "required",
|
|
38382
|
+
type: "uint32",
|
|
38383
|
+
id: 3
|
|
38384
|
+
},
|
|
38385
|
+
derive_type: {
|
|
38386
|
+
rule: "required",
|
|
38387
|
+
type: "uint32",
|
|
38388
|
+
id: 4
|
|
38389
|
+
}
|
|
38390
|
+
}
|
|
38391
|
+
},
|
|
38392
|
+
OnboardingStep: {
|
|
38393
|
+
values: {
|
|
38394
|
+
ONBOARDING_STEP_UNKNOWN: 0,
|
|
38395
|
+
ONBOARDING_STEP_CHECKING: 1,
|
|
38396
|
+
ONBOARDING_STEP_PERSONALIZATION: 2,
|
|
38397
|
+
ONBOARDING_STEP_PIN: 3,
|
|
38398
|
+
ONBOARDING_STEP_SETUP: 4,
|
|
38399
|
+
ONBOARDING_STEP_DONE: 5
|
|
38400
|
+
}
|
|
38401
|
+
},
|
|
38402
|
+
OnboardingPhase: {
|
|
38403
|
+
values: {
|
|
38404
|
+
ONBOARDING_PHASE_UNKNOWN: 0,
|
|
38405
|
+
ONBOARDING_PHASE_SAFETY_CHECK: 1,
|
|
38406
|
+
ONBOARDING_PHASE_PIN_SETUP: 2,
|
|
38407
|
+
ONBOARDING_PHASE_FINGERPRINT_SETUP: 3,
|
|
38408
|
+
ONBOARDING_PHASE_SETUP_CHOICE: 4,
|
|
38409
|
+
ONBOARDING_PHASE_WALLET_CREATE_START: 5,
|
|
38410
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_VIEW: 6,
|
|
38411
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_CONFIRM: 7,
|
|
38412
|
+
ONBOARDING_PHASE_RESTORE_METHOD_CHOICE: 8,
|
|
38413
|
+
ONBOARDING_PHASE_RECOVERY_PHRASE_RESTORE: 9,
|
|
38414
|
+
ONBOARDING_PHASE_SEEDCARD_RESTORE: 10,
|
|
38415
|
+
ONBOARDING_PHASE_WALLET_READY: 11,
|
|
38416
|
+
ONBOARDING_PHASE_SEEDCARD_BACKUP_PROMPT: 12,
|
|
38417
|
+
ONBOARDING_PHASE_SEEDCARD_BACKUP: 13
|
|
38418
|
+
}
|
|
38419
|
+
},
|
|
38420
|
+
OnboardingSetupKind: {
|
|
38421
|
+
values: {
|
|
38422
|
+
ONBOARDING_SETUP_KIND_UNKNOWN: 0,
|
|
38423
|
+
ONBOARDING_SETUP_KIND_CHOICE: 1,
|
|
38424
|
+
ONBOARDING_SETUP_KIND_CREATE: 2,
|
|
38425
|
+
ONBOARDING_SETUP_KIND_RESTORE: 3
|
|
38426
|
+
}
|
|
38427
|
+
},
|
|
38428
|
+
OnboardingSetupMethod: {
|
|
38429
|
+
values: {
|
|
38430
|
+
ONBOARDING_SETUP_METHOD_UNKNOWN: 0,
|
|
38431
|
+
ONBOARDING_SETUP_METHOD_RECOVERY_PHRASE: 1,
|
|
38432
|
+
ONBOARDING_SETUP_METHOD_SEEDCARD: 2
|
|
38433
|
+
}
|
|
38434
|
+
},
|
|
38435
|
+
OnboardingSetupStatus: {
|
|
38436
|
+
fields: {
|
|
38437
|
+
kind: {
|
|
38438
|
+
type: "OnboardingSetupKind",
|
|
38439
|
+
id: 1
|
|
38440
|
+
},
|
|
38441
|
+
method: {
|
|
38442
|
+
type: "OnboardingSetupMethod",
|
|
38443
|
+
id: 2
|
|
38444
|
+
}
|
|
38445
|
+
}
|
|
38446
|
+
},
|
|
38447
|
+
OnboardingStatusGet: {
|
|
38448
|
+
fields: {
|
|
38449
|
+
}
|
|
38450
|
+
},
|
|
38451
|
+
OnboardingStatus: {
|
|
38452
|
+
fields: {
|
|
38453
|
+
step: {
|
|
38454
|
+
type: "OnboardingStep",
|
|
38455
|
+
id: 1
|
|
38456
|
+
},
|
|
38457
|
+
phase: {
|
|
38458
|
+
type: "OnboardingPhase",
|
|
38459
|
+
id: 2
|
|
38460
|
+
},
|
|
38461
|
+
setup: {
|
|
38462
|
+
type: "OnboardingSetupStatus",
|
|
38463
|
+
id: 3
|
|
38464
|
+
},
|
|
38465
|
+
pin_set: {
|
|
38466
|
+
type: "bool",
|
|
38467
|
+
id: 4
|
|
38468
|
+
},
|
|
38469
|
+
wallet_initialized: {
|
|
38470
|
+
type: "bool",
|
|
38471
|
+
id: 5
|
|
38472
|
+
}
|
|
38473
|
+
}
|
|
38474
|
+
},
|
|
38720
38475
|
PortfolioUpdate: {
|
|
38721
38476
|
fields: {
|
|
38722
38477
|
}
|
|
38723
38478
|
},
|
|
38479
|
+
ViewAmount: {
|
|
38480
|
+
fields: {
|
|
38481
|
+
is_unlimited: {
|
|
38482
|
+
rule: "required",
|
|
38483
|
+
type: "bool",
|
|
38484
|
+
id: 1
|
|
38485
|
+
},
|
|
38486
|
+
num: {
|
|
38487
|
+
rule: "required",
|
|
38488
|
+
type: "string",
|
|
38489
|
+
id: 2
|
|
38490
|
+
}
|
|
38491
|
+
}
|
|
38492
|
+
},
|
|
38493
|
+
ViewDetail: {
|
|
38494
|
+
fields: {
|
|
38495
|
+
key: {
|
|
38496
|
+
rule: "required",
|
|
38497
|
+
type: "uint32",
|
|
38498
|
+
id: 1
|
|
38499
|
+
},
|
|
38500
|
+
value: {
|
|
38501
|
+
rule: "required",
|
|
38502
|
+
type: "string",
|
|
38503
|
+
id: 2
|
|
38504
|
+
},
|
|
38505
|
+
is_overview: {
|
|
38506
|
+
rule: "required",
|
|
38507
|
+
type: "bool",
|
|
38508
|
+
id: 3
|
|
38509
|
+
},
|
|
38510
|
+
has_icon: {
|
|
38511
|
+
rule: "required",
|
|
38512
|
+
type: "bool",
|
|
38513
|
+
id: 4
|
|
38514
|
+
}
|
|
38515
|
+
}
|
|
38516
|
+
},
|
|
38517
|
+
ViewTipType: {
|
|
38518
|
+
values: {
|
|
38519
|
+
Default: 0,
|
|
38520
|
+
Highlight: 1,
|
|
38521
|
+
Recommend: 2,
|
|
38522
|
+
Warning: 3,
|
|
38523
|
+
Danger: 4
|
|
38524
|
+
}
|
|
38525
|
+
},
|
|
38526
|
+
ViewTip: {
|
|
38527
|
+
fields: {
|
|
38528
|
+
type: {
|
|
38529
|
+
rule: "required",
|
|
38530
|
+
type: "ViewTipType",
|
|
38531
|
+
id: 1
|
|
38532
|
+
},
|
|
38533
|
+
text: {
|
|
38534
|
+
rule: "required",
|
|
38535
|
+
type: "string",
|
|
38536
|
+
id: 2
|
|
38537
|
+
}
|
|
38538
|
+
}
|
|
38539
|
+
},
|
|
38540
|
+
ViewRawData: {
|
|
38541
|
+
fields: {
|
|
38542
|
+
initial_data: {
|
|
38543
|
+
rule: "required",
|
|
38544
|
+
type: "string",
|
|
38545
|
+
id: 1
|
|
38546
|
+
},
|
|
38547
|
+
placeholder: {
|
|
38548
|
+
rule: "required",
|
|
38549
|
+
type: "uint32",
|
|
38550
|
+
id: 2
|
|
38551
|
+
}
|
|
38552
|
+
}
|
|
38553
|
+
},
|
|
38554
|
+
ViewSignLayout: {
|
|
38555
|
+
values: {
|
|
38556
|
+
LayoutDefault: 0,
|
|
38557
|
+
LayoutSafeTxCreate: 1,
|
|
38558
|
+
LayoutFinalConfirm: 2,
|
|
38559
|
+
Layout7702: 3,
|
|
38560
|
+
LayoutFlat: 4,
|
|
38561
|
+
LayoutEthApprove: 5
|
|
38562
|
+
}
|
|
38563
|
+
},
|
|
38564
|
+
ViewSignPage: {
|
|
38565
|
+
fields: {
|
|
38566
|
+
title: {
|
|
38567
|
+
rule: "required",
|
|
38568
|
+
type: "string",
|
|
38569
|
+
id: 1
|
|
38570
|
+
},
|
|
38571
|
+
amount: {
|
|
38572
|
+
type: "ViewAmount",
|
|
38573
|
+
id: 2
|
|
38574
|
+
},
|
|
38575
|
+
general: {
|
|
38576
|
+
rule: "repeated",
|
|
38577
|
+
type: "ViewDetail",
|
|
38578
|
+
id: 3
|
|
38579
|
+
},
|
|
38580
|
+
tip: {
|
|
38581
|
+
type: "ViewTip",
|
|
38582
|
+
id: 4
|
|
38583
|
+
},
|
|
38584
|
+
raw_data: {
|
|
38585
|
+
type: "ViewRawData",
|
|
38586
|
+
id: 5
|
|
38587
|
+
},
|
|
38588
|
+
slide_to_confirm: {
|
|
38589
|
+
type: "bool",
|
|
38590
|
+
id: 6,
|
|
38591
|
+
options: {
|
|
38592
|
+
"default": true
|
|
38593
|
+
}
|
|
38594
|
+
},
|
|
38595
|
+
layout: {
|
|
38596
|
+
type: "ViewSignLayout",
|
|
38597
|
+
id: 7,
|
|
38598
|
+
options: {
|
|
38599
|
+
"default": "LayoutDefault"
|
|
38600
|
+
}
|
|
38601
|
+
}
|
|
38602
|
+
}
|
|
38603
|
+
},
|
|
38604
|
+
ViewVerifyPage: {
|
|
38605
|
+
fields: {
|
|
38606
|
+
title: {
|
|
38607
|
+
rule: "required",
|
|
38608
|
+
type: "string",
|
|
38609
|
+
id: 1
|
|
38610
|
+
},
|
|
38611
|
+
address: {
|
|
38612
|
+
rule: "required",
|
|
38613
|
+
type: "string",
|
|
38614
|
+
id: 2
|
|
38615
|
+
},
|
|
38616
|
+
path: {
|
|
38617
|
+
rule: "required",
|
|
38618
|
+
type: "string",
|
|
38619
|
+
id: 3
|
|
38620
|
+
},
|
|
38621
|
+
network: {
|
|
38622
|
+
type: "string",
|
|
38623
|
+
id: 4
|
|
38624
|
+
},
|
|
38625
|
+
derive_type: {
|
|
38626
|
+
type: "string",
|
|
38627
|
+
id: 5
|
|
38628
|
+
},
|
|
38629
|
+
value_key: {
|
|
38630
|
+
type: "uint32",
|
|
38631
|
+
id: 6
|
|
38632
|
+
}
|
|
38633
|
+
}
|
|
38634
|
+
},
|
|
38724
38635
|
google: {
|
|
38725
38636
|
nested: {
|
|
38726
38637
|
protobuf: {
|
|
@@ -40047,9 +39958,60 @@ const createFirmwareMessage = (type, payload) => ({
|
|
|
40047
39958
|
});
|
|
40048
39959
|
|
|
40049
39960
|
const LogBlockEvent = new Set([
|
|
39961
|
+
UI_REQUEST.REQUEST_PASSPHRASE,
|
|
39962
|
+
UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE,
|
|
40050
39963
|
UI_RESPONSE.RECEIVE_PIN,
|
|
40051
39964
|
UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
40052
39965
|
]);
|
|
39966
|
+
const LogLabelMethod = new Set([
|
|
39967
|
+
'openWalletSession',
|
|
39968
|
+
'deviceUploadWallpaper',
|
|
39969
|
+
'uploadPortfolio',
|
|
39970
|
+
'fileWrite',
|
|
39971
|
+
'fileRead',
|
|
39972
|
+
]);
|
|
39973
|
+
const SensitiveLogKeys = new Set([
|
|
39974
|
+
'devicestate',
|
|
39975
|
+
'entropy',
|
|
39976
|
+
'expectedpassphrasestate',
|
|
39977
|
+
'mnemonic',
|
|
39978
|
+
'passphrase',
|
|
39979
|
+
'passphrasestate',
|
|
39980
|
+
'password',
|
|
39981
|
+
'pin',
|
|
39982
|
+
'privatekey',
|
|
39983
|
+
'seed',
|
|
39984
|
+
'session',
|
|
39985
|
+
'sessionid',
|
|
39986
|
+
'walletsessionid',
|
|
39987
|
+
'xprv',
|
|
39988
|
+
]);
|
|
39989
|
+
const normalizeLogKey = (key) => key.replace(/[_-]/g, '').toLowerCase();
|
|
39990
|
+
const isSigningMethod = (methodName) => /sign/i.test(methodName);
|
|
39991
|
+
const redactLogValue = (value, seen) => {
|
|
39992
|
+
if (ArrayBuffer.isView(value)) {
|
|
39993
|
+
return `[BINARY:${value.byteLength}]`;
|
|
39994
|
+
}
|
|
39995
|
+
if (value instanceof ArrayBuffer) {
|
|
39996
|
+
return `[BINARY:${value.byteLength}]`;
|
|
39997
|
+
}
|
|
39998
|
+
if (Array.isArray(value)) {
|
|
39999
|
+
return value.map(item => redactLogValue(item, seen));
|
|
40000
|
+
}
|
|
40001
|
+
if (!value || typeof value !== 'object')
|
|
40002
|
+
return value;
|
|
40003
|
+
if (seen.has(value))
|
|
40004
|
+
return '[CIRCULAR]';
|
|
40005
|
+
seen.add(value);
|
|
40006
|
+
const redacted = Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
40007
|
+
key,
|
|
40008
|
+
SensitiveLogKeys.has(normalizeLogKey(key)) && item !== null && item !== undefined
|
|
40009
|
+
? '[REDACTED]'
|
|
40010
|
+
: redactLogValue(item, seen),
|
|
40011
|
+
]));
|
|
40012
|
+
seen.delete(value);
|
|
40013
|
+
return redacted;
|
|
40014
|
+
};
|
|
40053
40015
|
function getLogBlockLabel(message) {
|
|
40054
40016
|
if (!message || typeof message !== 'object')
|
|
40055
40017
|
return undefined;
|
|
@@ -40058,7 +40020,26 @@ function getLogBlockLabel(message) {
|
|
|
40058
40020
|
return type;
|
|
40059
40021
|
}
|
|
40060
40022
|
const methodName = method !== null && method !== void 0 ? method : payload === null || payload === void 0 ? void 0 : payload.method;
|
|
40061
|
-
|
|
40023
|
+
if (methodName && (LogLabelMethod.has(methodName) || isSigningMethod(methodName))) {
|
|
40024
|
+
return methodName;
|
|
40025
|
+
}
|
|
40026
|
+
return undefined;
|
|
40027
|
+
}
|
|
40028
|
+
function getSafeLogPayload(value, blockLabel) {
|
|
40029
|
+
if (blockLabel && (LogBlockEvent.has(blockLabel) || isSigningMethod(blockLabel))) {
|
|
40030
|
+
return { method: blockLabel, payload: '[REDACTED]' };
|
|
40031
|
+
}
|
|
40032
|
+
const redactedValue = redactLogValue(value, new WeakSet());
|
|
40033
|
+
if (blockLabel &&
|
|
40034
|
+
redactedValue &&
|
|
40035
|
+
typeof redactedValue === 'object' &&
|
|
40036
|
+
!Array.isArray(redactedValue)) {
|
|
40037
|
+
return Object.assign(Object.assign({}, redactedValue), { method: blockLabel });
|
|
40038
|
+
}
|
|
40039
|
+
return redactedValue;
|
|
40040
|
+
}
|
|
40041
|
+
function formatLogMethodLabel(label, methodName) {
|
|
40042
|
+
return methodName ? `${label} [${methodName}]` : label;
|
|
40062
40043
|
}
|
|
40063
40044
|
|
|
40064
40045
|
function assertCompleteDeviceSession(message) {
|
|
@@ -40066,56 +40047,69 @@ function assertCompleteDeviceSession(message) {
|
|
|
40066
40047
|
!message.session_id ||
|
|
40067
40048
|
typeof message.btc_test_address !== 'string' ||
|
|
40068
40049
|
!message.btc_test_address) {
|
|
40069
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, '
|
|
40050
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device returned an incomplete DeviceSession response.');
|
|
40070
40051
|
}
|
|
40071
40052
|
}
|
|
40072
40053
|
|
|
40073
|
-
|
|
40074
|
-
|
|
40075
|
-
|
|
40076
|
-
|
|
40077
|
-
|
|
40054
|
+
const HOST_PASSPHRASE_MAX_BYTES = 50;
|
|
40055
|
+
const isWalletSessionInvalidError = (error) => typeof error === 'object' &&
|
|
40056
|
+
error !== null &&
|
|
40057
|
+
'errorCode' in error &&
|
|
40058
|
+
error.errorCode === hdShared.HardwareErrorCode.WalletSessionInvalid;
|
|
40059
|
+
const utf8ByteLength = (value) => {
|
|
40060
|
+
var _a;
|
|
40061
|
+
let length = 0;
|
|
40062
|
+
for (const character of value) {
|
|
40063
|
+
const codePoint = (_a = character.codePointAt(0)) !== null && _a !== void 0 ? _a : 0;
|
|
40064
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdfff)
|
|
40065
|
+
return undefined;
|
|
40066
|
+
if (codePoint <= 0x7f)
|
|
40067
|
+
length += 1;
|
|
40068
|
+
else if (codePoint <= 0x7ff)
|
|
40069
|
+
length += 2;
|
|
40070
|
+
else if (codePoint <= 0xffff)
|
|
40071
|
+
length += 3;
|
|
40072
|
+
else
|
|
40073
|
+
length += 4;
|
|
40074
|
+
}
|
|
40075
|
+
return length;
|
|
40076
|
+
};
|
|
40077
|
+
function requestProtocolV2DeviceStatus$1(device) {
|
|
40078
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40079
|
+
const { message } = yield device.commands.typedCall('DeviceStatusGet', 'DeviceStatus', {});
|
|
40080
|
+
return message;
|
|
40081
|
+
});
|
|
40082
|
+
}
|
|
40083
|
+
function refreshProtocolV2DeviceStatus(device) {
|
|
40084
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40085
|
+
const status = yield requestProtocolV2DeviceStatus$1(device);
|
|
40086
|
+
return device.updateProtocolV2Status(status);
|
|
40087
|
+
});
|
|
40078
40088
|
}
|
|
40079
|
-
|
|
40080
40089
|
const negotiateEventlessWalletSession = (device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40081
40090
|
yield device.commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
40082
40091
|
eventless_wallet_session: true,
|
|
40083
40092
|
});
|
|
40084
40093
|
});
|
|
40085
|
-
const getDeviceSession = (device, request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40086
|
-
|
|
40087
|
-
|
|
40088
|
-
|
|
40089
|
-
catch (error) {
|
|
40090
|
-
if (!isDeviceLockedError(error)) {
|
|
40091
|
-
throw error;
|
|
40092
|
-
}
|
|
40093
|
-
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40094
|
-
return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
|
|
40095
|
-
}
|
|
40096
|
-
});
|
|
40097
|
-
const askDevicePassphrase = (device, passphrase) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40098
|
-
const request = () => device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', passphrase ? { passphrase, on_device: false } : { on_device: true });
|
|
40099
|
-
try {
|
|
40100
|
-
return yield request();
|
|
40101
|
-
}
|
|
40102
|
-
catch (error) {
|
|
40103
|
-
if (!isDeviceLockedError(error)) {
|
|
40104
|
-
throw error;
|
|
40105
|
-
}
|
|
40106
|
-
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40107
|
-
return request();
|
|
40108
|
-
}
|
|
40094
|
+
const getDeviceSession = (device, request) => __awaiter(void 0, void 0, void 0, function* () { return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request); });
|
|
40095
|
+
const askDevicePassphrase = (device, requestPayload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40096
|
+
yield device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', requestPayload);
|
|
40097
|
+
yield refreshProtocolV2DeviceStatus(device);
|
|
40109
40098
|
});
|
|
40110
|
-
const selectDeviceSession = (device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40099
|
+
const selectDeviceSession = (device, expectedPassphraseState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40111
40100
|
var _a;
|
|
40112
40101
|
const existsAttachPinUser = ((_a = device.features) === null || _a === void 0 ? void 0 : _a.attachToPinEnabled) === true;
|
|
40113
|
-
const metadata = {
|
|
40114
|
-
source: 'wallet-session-coordinator',
|
|
40115
|
-
reason: 'open-wallet',
|
|
40116
|
-
};
|
|
40102
|
+
const metadata = Object.assign({ source: 'wallet-session-coordinator', reason: expectedPassphraseState ? 'session-recovery' : 'open-wallet' }, (expectedPassphraseState ? { expectedPassphraseState } : {}));
|
|
40117
40103
|
const response = yield device.commands.promptPassphrase(Object.assign({ existsAttachPinUser, deviceOnly: false }, metadata), { cancelDeviceOnReject: false });
|
|
40118
|
-
const
|
|
40104
|
+
const hostPassphrase = typeof response.passphrase === 'string' ? response.passphrase.normalize('NFKD') : undefined;
|
|
40105
|
+
const hasHostPassphrase = typeof hostPassphrase === 'string' && hostPassphrase.length > 0;
|
|
40106
|
+
const hostPassphraseByteLength = hasHostPassphrase ? utf8ByteLength(hostPassphrase) : undefined;
|
|
40107
|
+
if (hasHostPassphrase &&
|
|
40108
|
+
(hostPassphrase.includes('\0') ||
|
|
40109
|
+
hostPassphraseByteLength === undefined ||
|
|
40110
|
+
hostPassphraseByteLength > HOST_PASSPHRASE_MAX_BYTES)) {
|
|
40111
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Host passphrase must contain 1 to ${HOST_PASSPHRASE_MAX_BYTES} valid UTF-8 bytes without NUL.`);
|
|
40112
|
+
}
|
|
40119
40113
|
const selections = [
|
|
40120
40114
|
hasHostPassphrase,
|
|
40121
40115
|
response.passphraseOnDevice === true,
|
|
@@ -40133,49 +40127,80 @@ const selectDeviceSession = (device) => __awaiter(void 0, void 0, void 0, functi
|
|
|
40133
40127
|
return getDeviceSession(device, {});
|
|
40134
40128
|
}
|
|
40135
40129
|
if (hasHostPassphrase) {
|
|
40136
|
-
yield askDevicePassphrase(device,
|
|
40130
|
+
yield askDevicePassphrase(device, {
|
|
40131
|
+
passphrase: hostPassphrase,
|
|
40132
|
+
on_device: false,
|
|
40133
|
+
});
|
|
40137
40134
|
return getDeviceSession(device, {});
|
|
40138
40135
|
}
|
|
40139
40136
|
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
40140
|
-
yield askDevicePassphrase(device);
|
|
40137
|
+
yield askDevicePassphrase(device, { on_device: true });
|
|
40141
40138
|
return getDeviceSession(device, {});
|
|
40142
40139
|
});
|
|
40143
40140
|
function getProtocolV2WalletSession(device, options) {
|
|
40144
|
-
var _a, _b, _c, _d, _e, _f;
|
|
40141
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
40145
40142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40146
|
-
|
|
40147
|
-
|
|
40143
|
+
const forceWalletSelection = (options === null || options === void 0 ? void 0 : options.forceWalletSelection) === true || (options === null || options === void 0 ? void 0 : options.initSession) === true;
|
|
40144
|
+
if (forceWalletSelection) {
|
|
40145
|
+
if (options.onlyMainPin) {
|
|
40146
|
+
(_a = device.clearStandardInternalState) === null || _a === void 0 ? void 0 : _a.call(device);
|
|
40147
|
+
}
|
|
40148
|
+
else {
|
|
40149
|
+
device.clearInternalState();
|
|
40150
|
+
}
|
|
40148
40151
|
device.passphraseState = undefined;
|
|
40149
40152
|
}
|
|
40150
40153
|
yield negotiateEventlessWalletSession(device);
|
|
40151
40154
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40152
40155
|
device.passphraseState = undefined;
|
|
40153
40156
|
}
|
|
40154
|
-
|
|
40157
|
+
let expectedPassphraseState = (options === null || options === void 0 ? void 0 : options.onlyMainPin)
|
|
40155
40158
|
? undefined
|
|
40156
|
-
: (
|
|
40157
|
-
|
|
40158
|
-
|
|
40159
|
-
|
|
40160
|
-
|
|
40161
|
-
|
|
40162
|
-
|
|
40163
|
-
newSession: undefined,
|
|
40164
|
-
unlockedAttachPin: (_d = (_c = device.features) === null || _c === void 0 ? void 0 : _c.unlockedAttachPin) !== null && _d !== void 0 ? _d : false,
|
|
40165
|
-
resumed: false,
|
|
40166
|
-
};
|
|
40167
|
-
}
|
|
40168
|
-
const cachedSessionId = typeof device.getInternalState === 'function' ? device.getInternalState() : undefined;
|
|
40159
|
+
: (_b = options === null || options === void 0 ? void 0 : options.expectedPassphraseState) !== null && _b !== void 0 ? _b : device.passphraseState;
|
|
40160
|
+
const cachedStandardSession = (options === null || options === void 0 ? void 0 : options.onlyMainPin)
|
|
40161
|
+
? (_c = device.getStandardInternalState) === null || _c === void 0 ? void 0 : _c.call(device)
|
|
40162
|
+
: undefined;
|
|
40163
|
+
const cachedSessionId = !(options === null || options === void 0 ? void 0 : options.onlyMainPin) && typeof device.getInternalState === 'function'
|
|
40164
|
+
? device.getInternalState()
|
|
40165
|
+
: undefined;
|
|
40169
40166
|
let response;
|
|
40170
40167
|
let resumed = false;
|
|
40171
|
-
if (
|
|
40168
|
+
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40169
|
+
expectedPassphraseState = cachedStandardSession === null || cachedStandardSession === void 0 ? void 0 : cachedStandardSession.passphraseState;
|
|
40170
|
+
if (cachedStandardSession) {
|
|
40171
|
+
try {
|
|
40172
|
+
if (((_d = device.features) === null || _d === void 0 ? void 0 : _d.unlockedAttachPin) === true) {
|
|
40173
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40174
|
+
}
|
|
40175
|
+
response = yield getDeviceSession(device, {
|
|
40176
|
+
session_id: cachedStandardSession.sessionId,
|
|
40177
|
+
});
|
|
40178
|
+
resumed = true;
|
|
40179
|
+
}
|
|
40180
|
+
catch (error) {
|
|
40181
|
+
(_e = device.clearStandardInternalState) === null || _e === void 0 ? void 0 : _e.call(device);
|
|
40182
|
+
if (!isWalletSessionInvalidError(error)) {
|
|
40183
|
+
throw error;
|
|
40184
|
+
}
|
|
40185
|
+
resumed = false;
|
|
40186
|
+
}
|
|
40187
|
+
}
|
|
40188
|
+
if (!response) {
|
|
40189
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40190
|
+
response = yield getDeviceSession(device, {});
|
|
40191
|
+
}
|
|
40192
|
+
}
|
|
40193
|
+
else if (cachedSessionId && expectedPassphraseState) {
|
|
40172
40194
|
try {
|
|
40173
40195
|
response = yield getDeviceSession(device, { session_id: cachedSessionId });
|
|
40174
40196
|
resumed = true;
|
|
40175
40197
|
}
|
|
40176
40198
|
catch (error) {
|
|
40177
40199
|
device.clearInternalState();
|
|
40178
|
-
|
|
40200
|
+
if ((options === null || options === void 0 ? void 0 : options.resumeOnly) || !isWalletSessionInvalidError(error)) {
|
|
40201
|
+
throw error;
|
|
40202
|
+
}
|
|
40203
|
+
resumed = false;
|
|
40179
40204
|
}
|
|
40180
40205
|
}
|
|
40181
40206
|
if (!response) {
|
|
@@ -40183,25 +40208,76 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40183
40208
|
device.clearInternalState();
|
|
40184
40209
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
40185
40210
|
}
|
|
40186
|
-
response = yield selectDeviceSession(device);
|
|
40211
|
+
response = yield selectDeviceSession(device, expectedPassphraseState);
|
|
40187
40212
|
}
|
|
40188
|
-
|
|
40213
|
+
let { message } = response;
|
|
40189
40214
|
try {
|
|
40190
40215
|
assertCompleteDeviceSession(message);
|
|
40191
40216
|
}
|
|
40192
40217
|
catch (error) {
|
|
40193
|
-
|
|
40218
|
+
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40219
|
+
(_f = device.clearStandardInternalState) === null || _f === void 0 ? void 0 : _f.call(device);
|
|
40220
|
+
}
|
|
40221
|
+
else {
|
|
40222
|
+
device.clearInternalState();
|
|
40223
|
+
}
|
|
40194
40224
|
throw error;
|
|
40195
40225
|
}
|
|
40196
40226
|
if (expectedPassphraseState && expectedPassphraseState !== message.btc_test_address) {
|
|
40197
|
-
|
|
40198
|
-
|
|
40227
|
+
resumed = false;
|
|
40228
|
+
if (options === null || options === void 0 ? void 0 : options.resumeOnly) {
|
|
40229
|
+
device.clearInternalState();
|
|
40230
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
40231
|
+
}
|
|
40232
|
+
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40233
|
+
(_g = device.clearStandardInternalState) === null || _g === void 0 ? void 0 : _g.call(device);
|
|
40234
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40235
|
+
response = yield getDeviceSession(device, {});
|
|
40236
|
+
}
|
|
40237
|
+
else {
|
|
40238
|
+
device.clearInternalState();
|
|
40239
|
+
response = yield selectDeviceSession(device, expectedPassphraseState);
|
|
40240
|
+
}
|
|
40241
|
+
message = response.message;
|
|
40242
|
+
try {
|
|
40243
|
+
assertCompleteDeviceSession(message);
|
|
40244
|
+
}
|
|
40245
|
+
catch (error) {
|
|
40246
|
+
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40247
|
+
(_h = device.clearStandardInternalState) === null || _h === void 0 ? void 0 : _h.call(device);
|
|
40248
|
+
}
|
|
40249
|
+
else {
|
|
40250
|
+
device.clearInternalState();
|
|
40251
|
+
}
|
|
40252
|
+
throw error;
|
|
40253
|
+
}
|
|
40254
|
+
if (expectedPassphraseState !== message.btc_test_address) {
|
|
40255
|
+
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40256
|
+
(_j = device.clearStandardInternalState) === null || _j === void 0 ? void 0 : _j.call(device);
|
|
40257
|
+
}
|
|
40258
|
+
else {
|
|
40259
|
+
device.clearInternalState();
|
|
40260
|
+
}
|
|
40261
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
40262
|
+
}
|
|
40263
|
+
}
|
|
40264
|
+
const internalStateArgs = [
|
|
40265
|
+
true,
|
|
40266
|
+
message.btc_test_address,
|
|
40267
|
+
device.getCurrentDeviceId(),
|
|
40268
|
+
message.session_id,
|
|
40269
|
+
forceWalletSelection ? null : cachedSessionId !== null && cachedSessionId !== void 0 ? cachedSessionId : null,
|
|
40270
|
+
];
|
|
40271
|
+
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40272
|
+
device.updateInternalState(...internalStateArgs, 'standard');
|
|
40273
|
+
}
|
|
40274
|
+
else {
|
|
40275
|
+
device.updateInternalState(...internalStateArgs);
|
|
40199
40276
|
}
|
|
40200
|
-
device.updateInternalState(true, message.btc_test_address, device.getCurrentDeviceId(), message.session_id, (options === null || options === void 0 ? void 0 : options.initSession) ? null : cachedSessionId !== null && cachedSessionId !== void 0 ? cachedSessionId : null);
|
|
40201
40277
|
return {
|
|
40202
40278
|
passphraseState: message.btc_test_address,
|
|
40203
40279
|
newSession: message.session_id,
|
|
40204
|
-
unlockedAttachPin: (
|
|
40280
|
+
unlockedAttachPin: (_l = (_k = device.features) === null || _k === void 0 ? void 0 : _k.unlockedAttachPin) !== null && _l !== void 0 ? _l : undefined,
|
|
40205
40281
|
resumed,
|
|
40206
40282
|
};
|
|
40207
40283
|
});
|
|
@@ -40849,15 +40925,9 @@ function encodePro2Wallpaper(options) {
|
|
|
40849
40925
|
for (let x = 0; x < width; x += 1) {
|
|
40850
40926
|
const sourceOffset = (y * width + x) * 4;
|
|
40851
40927
|
const thresholdIndex = ((y & 7) << 3) + (x & 7);
|
|
40852
|
-
|
|
40853
|
-
|
|
40854
|
-
|
|
40855
|
-
if (!hasTransparency) {
|
|
40856
|
-
const alpha = rgba[sourceOffset + 3];
|
|
40857
|
-
red = (red * alpha) >> 8;
|
|
40858
|
-
green = (green * alpha) >> 8;
|
|
40859
|
-
blue = (blue * alpha) >> 8;
|
|
40860
|
-
}
|
|
40928
|
+
const red = Math.min(rgba[sourceOffset] + RED_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
40929
|
+
const green = Math.min(rgba[sourceOffset + 1] + GREEN_THRESHOLD[thresholdIndex], 0xff) & 0xfc;
|
|
40930
|
+
const blue = Math.min(rgba[sourceOffset + 2] + BLUE_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
40861
40931
|
const rgb565 = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);
|
|
40862
40932
|
const rgbOffset = 12 + y * stride + x * 2;
|
|
40863
40933
|
data[rgbOffset] = rgb565 & 0xff;
|
|
@@ -41453,9 +41523,12 @@ class DevicePool extends events.exports {
|
|
|
41453
41523
|
this.connectedPool = [];
|
|
41454
41524
|
this.disconnectPool = [];
|
|
41455
41525
|
this.devicesCache = {};
|
|
41456
|
-
this.emitter.removeAllListeners();
|
|
41457
41526
|
Log$h.debug('DevicePool state has been reset');
|
|
41458
41527
|
}
|
|
41528
|
+
static dispose() {
|
|
41529
|
+
this.resetState();
|
|
41530
|
+
this.emitter.removeAllListeners();
|
|
41531
|
+
}
|
|
41459
41532
|
}
|
|
41460
41533
|
DevicePool.current = null;
|
|
41461
41534
|
DevicePool.upcoming = [];
|
|
@@ -41768,18 +41841,18 @@ class DeviceCommands {
|
|
|
41768
41841
|
});
|
|
41769
41842
|
}
|
|
41770
41843
|
call(type, msg, options) {
|
|
41771
|
-
var _a;
|
|
41844
|
+
var _a, _b;
|
|
41772
41845
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41773
41846
|
const shouldReduceDebug = shouldReduceDebugForCall(type);
|
|
41774
41847
|
if (!shouldReduceDebug) {
|
|
41775
|
-
Log$f.debug('[DeviceCommands] [call] Sending', type);
|
|
41848
|
+
Log$f.debug('[DeviceCommands] [call] Sending', type, hdTransport.getSafeTransportLogPayload(msg !== null && msg !== void 0 ? msg : {}, type));
|
|
41776
41849
|
}
|
|
41777
41850
|
try {
|
|
41778
41851
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
41779
41852
|
this.callPromise = promise;
|
|
41780
41853
|
const res = yield promise;
|
|
41781
41854
|
if (!shouldReduceDebug) {
|
|
41782
|
-
LogCore.debug('[DeviceCommands] [call] Received', res.type);
|
|
41855
|
+
LogCore.debug('[DeviceCommands] [call] Received', res.type, hdTransport.getSafeTransportLogPayload(res.message, res.type));
|
|
41783
41856
|
}
|
|
41784
41857
|
return res;
|
|
41785
41858
|
}
|
|
@@ -41787,6 +41860,7 @@ class DeviceCommands {
|
|
|
41787
41860
|
LogCore.debug('[DeviceCommands] [call] Received error', {
|
|
41788
41861
|
request: type,
|
|
41789
41862
|
errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
|
|
41863
|
+
response: hdTransport.getSafeTransportLogPayload((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data, type),
|
|
41790
41864
|
});
|
|
41791
41865
|
if (error.errorCode === hdShared.HardwareErrorCode.BleDeviceBondError) {
|
|
41792
41866
|
return {
|
|
@@ -41796,7 +41870,7 @@ class DeviceCommands {
|
|
|
41796
41870
|
},
|
|
41797
41871
|
};
|
|
41798
41872
|
}
|
|
41799
|
-
const responseData = (
|
|
41873
|
+
const responseData = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
41800
41874
|
let responseError = responseData === null || responseData === void 0 ? void 0 : responseData.error;
|
|
41801
41875
|
if (!responseError && responseData && typeof responseData === 'string') {
|
|
41802
41876
|
try {
|
|
@@ -42159,6 +42233,34 @@ function mergeDeviceFeaturesPatch(previous, patch) {
|
|
|
42159
42233
|
return next;
|
|
42160
42234
|
}
|
|
42161
42235
|
|
|
42236
|
+
const resolveProtocolV2DeviceIdentity = (deviceType) => {
|
|
42237
|
+
switch (deviceType) {
|
|
42238
|
+
case hdTransport.DeviceType.CLASSIC1:
|
|
42239
|
+
case 'CLASSIC1':
|
|
42240
|
+
return { deviceType: hdShared.EDeviceType.Classic, model: 'classic' };
|
|
42241
|
+
case hdTransport.DeviceType.CLASSIC1S:
|
|
42242
|
+
case 'CLASSIC1S':
|
|
42243
|
+
return { deviceType: hdShared.EDeviceType.Classic1s, model: 'classic1s' };
|
|
42244
|
+
case hdTransport.DeviceType.CLASSIC1S_PURE:
|
|
42245
|
+
case 'CLASSIC1S_PURE':
|
|
42246
|
+
return { deviceType: hdShared.EDeviceType.ClassicPure, model: 'classicpure' };
|
|
42247
|
+
case hdTransport.DeviceType.MINI:
|
|
42248
|
+
case 'MINI':
|
|
42249
|
+
return { deviceType: hdShared.EDeviceType.Mini, model: 'mini' };
|
|
42250
|
+
case hdTransport.DeviceType.TOUCH:
|
|
42251
|
+
case 'TOUCH':
|
|
42252
|
+
return { deviceType: hdShared.EDeviceType.Touch, model: 'touch' };
|
|
42253
|
+
case hdTransport.DeviceType.PRO:
|
|
42254
|
+
case 'PRO':
|
|
42255
|
+
return { deviceType: hdShared.EDeviceType.Pro, model: 'pro' };
|
|
42256
|
+
case hdTransport.DeviceType.PRO2:
|
|
42257
|
+
case 'PRO2':
|
|
42258
|
+
return { deviceType: hdShared.EDeviceType.Pro2, model: 'pro2' };
|
|
42259
|
+
default:
|
|
42260
|
+
return { deviceType: hdShared.EDeviceType.Unknown, model: null };
|
|
42261
|
+
}
|
|
42262
|
+
};
|
|
42263
|
+
|
|
42162
42264
|
const firstMeaningfulVersion = (...versions) => { var _a; return (_a = versions.find(version => Boolean(version && version !== '0.0.0'))) !== null && _a !== void 0 ? _a : null; };
|
|
42163
42265
|
const getProtocolV1Mode = (features) => {
|
|
42164
42266
|
if (features.bootloader_mode === true)
|
|
@@ -42229,7 +42331,7 @@ const sanitizeRawFeatures = (features) => {
|
|
|
42229
42331
|
return raw;
|
|
42230
42332
|
};
|
|
42231
42333
|
const imageVersion = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.version) !== null && _a !== void 0 ? _a : undefined; };
|
|
42232
|
-
const bytesToHex$
|
|
42334
|
+
const bytesToHex$2 = (value) => {
|
|
42233
42335
|
if (!value)
|
|
42234
42336
|
return undefined;
|
|
42235
42337
|
if (typeof value === 'string')
|
|
@@ -42242,7 +42344,7 @@ const bytesToHex$3 = (value) => {
|
|
|
42242
42344
|
return undefined;
|
|
42243
42345
|
};
|
|
42244
42346
|
const imageBuildId = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.build_id) !== null && _a !== void 0 ? _a : undefined; };
|
|
42245
|
-
const imageHash = (image) => bytesToHex$
|
|
42347
|
+
const imageHash = (image) => bytesToHex$2(image === null || image === void 0 ? void 0 : image.hash);
|
|
42246
42348
|
const getFeaturesMode = (features) => {
|
|
42247
42349
|
if (features.mode !== undefined && features.mode !== null)
|
|
42248
42350
|
return features.mode;
|
|
@@ -42384,18 +42486,19 @@ const mapProtocolV1OnekeyFeaturesToState = (features) => {
|
|
|
42384
42486
|
}) }, (Object.keys(verification).length > 0 ? { verification } : {})), { raw: { protocolV1OneKeyFeatures: features } });
|
|
42385
42487
|
};
|
|
42386
42488
|
const mapProtocolV2DeviceInfoToState = (info, mode = 'unknown') => {
|
|
42387
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
42489
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
|
|
42388
42490
|
const loader = mode === 'bootloader' || mode === 'romloader';
|
|
42491
|
+
const identity = resolveProtocolV2DeviceIdentity((_a = info.hw) === null || _a === void 0 ? void 0 : _a.Device_type);
|
|
42389
42492
|
return {
|
|
42390
42493
|
protocol: 'V2',
|
|
42391
42494
|
protocolVersion: info.protocol_version,
|
|
42392
42495
|
identity: definedEntries({
|
|
42393
|
-
deviceType:
|
|
42496
|
+
deviceType: identity.deviceType,
|
|
42394
42497
|
firmwareType: hdShared.EFirmwareType.Universal,
|
|
42395
|
-
model:
|
|
42498
|
+
model: identity.model,
|
|
42396
42499
|
vendor: 'onekey.so',
|
|
42397
|
-
serialNo: (
|
|
42398
|
-
bleName: (
|
|
42500
|
+
serialNo: (_b = info.hw) === null || _b === void 0 ? void 0 : _b.serial_no,
|
|
42501
|
+
bleName: (_c = info.coprocessor) === null || _c === void 0 ? void 0 : _c.bt_adv_name,
|
|
42399
42502
|
deviceId: loader ? null : undefined,
|
|
42400
42503
|
}),
|
|
42401
42504
|
status: loader
|
|
@@ -42415,50 +42518,50 @@ const mapProtocolV2DeviceInfoToState = (info, mode = 'unknown') => {
|
|
|
42415
42518
|
}
|
|
42416
42519
|
: { mode },
|
|
42417
42520
|
versions: definedEntries({
|
|
42418
|
-
firmware: imageVersion((
|
|
42419
|
-
applicationP1: imageVersion((
|
|
42420
|
-
applicationP2: imageVersion((
|
|
42421
|
-
bootloader: imageVersion((
|
|
42422
|
-
board: imageVersion((
|
|
42423
|
-
ble: imageVersion((
|
|
42424
|
-
se01: imageVersion((
|
|
42425
|
-
se02: imageVersion((
|
|
42426
|
-
se03: imageVersion((
|
|
42427
|
-
se04: imageVersion((
|
|
42428
|
-
se01Boot: imageVersion((
|
|
42429
|
-
se02Boot: imageVersion((
|
|
42430
|
-
se03Boot: imageVersion((
|
|
42431
|
-
se04Boot: imageVersion((
|
|
42521
|
+
firmware: imageVersion((_d = info.fw) === null || _d === void 0 ? void 0 : _d.application),
|
|
42522
|
+
applicationP1: imageVersion((_e = info.fw) === null || _e === void 0 ? void 0 : _e.application),
|
|
42523
|
+
applicationP2: imageVersion((_f = info.fw) === null || _f === void 0 ? void 0 : _f.application_data),
|
|
42524
|
+
bootloader: imageVersion((_g = info.fw) === null || _g === void 0 ? void 0 : _g.bootloader),
|
|
42525
|
+
board: imageVersion((_h = info.fw) === null || _h === void 0 ? void 0 : _h.romloader),
|
|
42526
|
+
ble: imageVersion((_j = info.coprocessor) === null || _j === void 0 ? void 0 : _j.application),
|
|
42527
|
+
se01: imageVersion((_k = info.se1) === null || _k === void 0 ? void 0 : _k.application),
|
|
42528
|
+
se02: imageVersion((_l = info.se2) === null || _l === void 0 ? void 0 : _l.application),
|
|
42529
|
+
se03: imageVersion((_m = info.se3) === null || _m === void 0 ? void 0 : _m.application),
|
|
42530
|
+
se04: imageVersion((_o = info.se4) === null || _o === void 0 ? void 0 : _o.application),
|
|
42531
|
+
se01Boot: imageVersion((_p = info.se1) === null || _p === void 0 ? void 0 : _p.bootloader),
|
|
42532
|
+
se02Boot: imageVersion((_q = info.se2) === null || _q === void 0 ? void 0 : _q.bootloader),
|
|
42533
|
+
se03Boot: imageVersion((_r = info.se3) === null || _r === void 0 ? void 0 : _r.bootloader),
|
|
42534
|
+
se04Boot: imageVersion((_s = info.se4) === null || _s === void 0 ? void 0 : _s.bootloader),
|
|
42432
42535
|
}),
|
|
42433
42536
|
verification: definedEntries({
|
|
42434
|
-
firmwareBuildId: imageBuildId((
|
|
42435
|
-
firmwareHash: imageHash((
|
|
42436
|
-
applicationP1BuildId: imageBuildId((
|
|
42437
|
-
applicationP1Hash: imageHash((
|
|
42438
|
-
applicationP2BuildId: imageBuildId((
|
|
42439
|
-
applicationP2Hash: imageHash((
|
|
42440
|
-
bootloaderBuildId: imageBuildId((
|
|
42441
|
-
bootloaderHash: imageHash((
|
|
42442
|
-
boardBuildId: imageBuildId((
|
|
42443
|
-
boardHash: imageHash((
|
|
42444
|
-
bleBuildId: imageBuildId((
|
|
42445
|
-
bleHash: imageHash((
|
|
42446
|
-
se01BuildId: imageBuildId((
|
|
42447
|
-
se01Hash: imageHash((
|
|
42448
|
-
se02BuildId: imageBuildId((
|
|
42449
|
-
se02Hash: imageHash((
|
|
42450
|
-
se03BuildId: imageBuildId((
|
|
42451
|
-
se03Hash: imageHash((
|
|
42452
|
-
se04BuildId: imageBuildId((
|
|
42453
|
-
se04Hash: imageHash((
|
|
42454
|
-
se01BootBuildId: imageBuildId((
|
|
42455
|
-
se01BootHash: imageHash((
|
|
42456
|
-
se02BootBuildId: imageBuildId((
|
|
42457
|
-
se02BootHash: imageHash((
|
|
42458
|
-
se03BootBuildId: imageBuildId((
|
|
42459
|
-
se03BootHash: imageHash((
|
|
42460
|
-
se04BootBuildId: imageBuildId((
|
|
42461
|
-
se04BootHash: imageHash((
|
|
42537
|
+
firmwareBuildId: imageBuildId((_t = info.fw) === null || _t === void 0 ? void 0 : _t.application),
|
|
42538
|
+
firmwareHash: imageHash((_u = info.fw) === null || _u === void 0 ? void 0 : _u.application),
|
|
42539
|
+
applicationP1BuildId: imageBuildId((_v = info.fw) === null || _v === void 0 ? void 0 : _v.application),
|
|
42540
|
+
applicationP1Hash: imageHash((_w = info.fw) === null || _w === void 0 ? void 0 : _w.application),
|
|
42541
|
+
applicationP2BuildId: imageBuildId((_x = info.fw) === null || _x === void 0 ? void 0 : _x.application_data),
|
|
42542
|
+
applicationP2Hash: imageHash((_y = info.fw) === null || _y === void 0 ? void 0 : _y.application_data),
|
|
42543
|
+
bootloaderBuildId: imageBuildId((_z = info.fw) === null || _z === void 0 ? void 0 : _z.bootloader),
|
|
42544
|
+
bootloaderHash: imageHash((_0 = info.fw) === null || _0 === void 0 ? void 0 : _0.bootloader),
|
|
42545
|
+
boardBuildId: imageBuildId((_1 = info.fw) === null || _1 === void 0 ? void 0 : _1.romloader),
|
|
42546
|
+
boardHash: imageHash((_2 = info.fw) === null || _2 === void 0 ? void 0 : _2.romloader),
|
|
42547
|
+
bleBuildId: imageBuildId((_3 = info.coprocessor) === null || _3 === void 0 ? void 0 : _3.application),
|
|
42548
|
+
bleHash: imageHash((_4 = info.coprocessor) === null || _4 === void 0 ? void 0 : _4.application),
|
|
42549
|
+
se01BuildId: imageBuildId((_5 = info.se1) === null || _5 === void 0 ? void 0 : _5.application),
|
|
42550
|
+
se01Hash: imageHash((_6 = info.se1) === null || _6 === void 0 ? void 0 : _6.application),
|
|
42551
|
+
se02BuildId: imageBuildId((_7 = info.se2) === null || _7 === void 0 ? void 0 : _7.application),
|
|
42552
|
+
se02Hash: imageHash((_8 = info.se2) === null || _8 === void 0 ? void 0 : _8.application),
|
|
42553
|
+
se03BuildId: imageBuildId((_9 = info.se3) === null || _9 === void 0 ? void 0 : _9.application),
|
|
42554
|
+
se03Hash: imageHash((_10 = info.se3) === null || _10 === void 0 ? void 0 : _10.application),
|
|
42555
|
+
se04BuildId: imageBuildId((_11 = info.se4) === null || _11 === void 0 ? void 0 : _11.application),
|
|
42556
|
+
se04Hash: imageHash((_12 = info.se4) === null || _12 === void 0 ? void 0 : _12.application),
|
|
42557
|
+
se01BootBuildId: imageBuildId((_13 = info.se1) === null || _13 === void 0 ? void 0 : _13.bootloader),
|
|
42558
|
+
se01BootHash: imageHash((_14 = info.se1) === null || _14 === void 0 ? void 0 : _14.bootloader),
|
|
42559
|
+
se02BootBuildId: imageBuildId((_15 = info.se2) === null || _15 === void 0 ? void 0 : _15.bootloader),
|
|
42560
|
+
se02BootHash: imageHash((_16 = info.se2) === null || _16 === void 0 ? void 0 : _16.bootloader),
|
|
42561
|
+
se03BootBuildId: imageBuildId((_17 = info.se3) === null || _17 === void 0 ? void 0 : _17.bootloader),
|
|
42562
|
+
se03BootHash: imageHash((_18 = info.se3) === null || _18 === void 0 ? void 0 : _18.bootloader),
|
|
42563
|
+
se04BootBuildId: imageBuildId((_19 = info.se4) === null || _19 === void 0 ? void 0 : _19.bootloader),
|
|
42564
|
+
se04BootHash: imageHash((_20 = info.se4) === null || _20 === void 0 ? void 0 : _20.bootloader),
|
|
42462
42565
|
}),
|
|
42463
42566
|
raw: Object.assign({ protocolV2DeviceInfo: info }, (loader ? { protocolV2DeviceStatus: null } : {})),
|
|
42464
42567
|
};
|
|
@@ -42568,13 +42671,11 @@ const projectFeatures = (state) => {
|
|
|
42568
42671
|
delete publicRawFeatures.session_id;
|
|
42569
42672
|
delete publicRawFeatures.sessionId;
|
|
42570
42673
|
delete publicRawFeatures.passphraseState;
|
|
42571
|
-
const publicRaw = snapshot.raw
|
|
42572
|
-
? Object.assign(Object.assign({}, snapshot.raw), { protocolV1Features: publicRawFeatures }) : undefined;
|
|
42573
42674
|
const rawOneKeyFeatures = (_d = (_c = snapshot.raw) === null || _c === void 0 ? void 0 : _c.protocolV1OneKeyFeatures) !== null && _d !== void 0 ? _d : {};
|
|
42574
42675
|
const bootloaderMode = snapshot.protocol === 'V1'
|
|
42575
42676
|
? (_e = rawFeatures.bootloader_mode) !== null && _e !== void 0 ? _e : null
|
|
42576
42677
|
: getBootloaderMode(snapshot);
|
|
42577
|
-
return Object.assign(Object.assign(Object.assign({}, publicRawFeatures), rawOneKeyFeatures), { protocol: snapshot.protocol, protocolVersion: (_f = snapshot.protocolVersion) !== null && _f !== void 0 ? _f : (snapshot.protocol === 'V1' ? 1 : null), deviceType: snapshot.identity.deviceType, firmwareType: snapshot.identity.firmwareType, model: snapshot.identity.model, vendor: snapshot.identity.vendor, deviceId: snapshot.identity.deviceId, serialNo: snapshot.identity.serialNo, label: snapshot.identity.label, bleName: snapshot.identity.bleName, capabilities: snapshot.capabilities, mode: snapshot.status.mode, initialized: snapshot.status.initialized, bootloaderMode, unlocked: snapshot.status.unlocked, firmwarePresent: snapshot.status.firmwarePresent, passphraseProtection: snapshot.status.passphraseProtection, pinProtection: snapshot.status.pinProtection, backupRequired: snapshot.status.backupRequired, noBackup: snapshot.status.noBackup, unfinishedBackup: snapshot.status.unfinishedBackup, recoveryMode: snapshot.status.recoveryMode, attachToPinEnabled: snapshot.status.attachToPinEnabled, unlockedAttachPin: (_g = snapshot.status.unlockedAttachPin) !== null && _g !== void 0 ? _g : undefined, language: snapshot.settings.language, bleEnabled: snapshot.settings.bleEnabled, sdCardPresent: snapshot.settings.sdCardPresent, sdProtection: snapshot.settings.sdProtection, wipeCodeProtection: snapshot.settings.wipeCodeProtection, passphraseAlwaysOnDevice: snapshot.settings.passphraseAlwaysOnDevice, safetyChecks: snapshot.settings.safetyChecks, autoLockDelayMs: snapshot.settings.autoLockDelayMs, autoShutdownDelayMs: snapshot.settings.autoShutdownDelayMs, displayRotation: snapshot.settings.displayRotation, experimentalFeatures: snapshot.settings.experimentalFeatures, wallpaperPath: snapshot.settings.wallpaperPath, brightness: snapshot.settings.brightness, animationEnabled: snapshot.settings.animationEnabled, tapToWake: snapshot.settings.tapToWake, hapticFeedback: snapshot.settings.hapticFeedback, deviceNameDisplayEnabled: snapshot.settings.deviceNameDisplayEnabled, airgapMode: snapshot.settings.airgapMode, fidoEnabled: snapshot.settings.fidoEnabled, usbLockEnabled: snapshot.settings.usbLockEnabled, randomKeypad: snapshot.settings.randomKeypad, firmwareVersion: snapshot.versions.firmware, bootloaderVersion: snapshot.versions.bootloader, boardVersion: snapshot.versions.board, bleVersion: snapshot.versions.ble, se01Version: snapshot.versions.se01, se02Version: snapshot.versions.se02, se03Version: snapshot.versions.se03, se04Version: snapshot.versions.se04, se01BootVersion: snapshot.versions.se01Boot, se02BootVersion: snapshot.versions.se02Boot, se03BootVersion: snapshot.versions.se03Boot, se04BootVersion: snapshot.versions.se04Boot, seVersion: (_h = snapshot.versions.se) !== null && _h !== void 0 ? _h : null, verify: snapshot.verification,
|
|
42678
|
+
return Object.assign(Object.assign(Object.assign({}, publicRawFeatures), rawOneKeyFeatures), { protocol: snapshot.protocol, protocolVersion: (_f = snapshot.protocolVersion) !== null && _f !== void 0 ? _f : (snapshot.protocol === 'V1' ? 1 : null), deviceType: snapshot.identity.deviceType, firmwareType: snapshot.identity.firmwareType, model: snapshot.identity.model, vendor: snapshot.identity.vendor, deviceId: snapshot.identity.deviceId, serialNo: snapshot.identity.serialNo, label: snapshot.identity.label, bleName: snapshot.identity.bleName, capabilities: snapshot.capabilities, mode: snapshot.status.mode, initialized: snapshot.status.initialized, bootloaderMode, unlocked: snapshot.status.unlocked, firmwarePresent: snapshot.status.firmwarePresent, passphraseProtection: snapshot.status.passphraseProtection, pinProtection: snapshot.status.pinProtection, backupRequired: snapshot.status.backupRequired, noBackup: snapshot.status.noBackup, unfinishedBackup: snapshot.status.unfinishedBackup, recoveryMode: snapshot.status.recoveryMode, attachToPinEnabled: snapshot.status.attachToPinEnabled, unlockedAttachPin: (_g = snapshot.status.unlockedAttachPin) !== null && _g !== void 0 ? _g : undefined, language: snapshot.settings.language, bleEnabled: snapshot.settings.bleEnabled, sdCardPresent: snapshot.settings.sdCardPresent, sdProtection: snapshot.settings.sdProtection, wipeCodeProtection: snapshot.settings.wipeCodeProtection, passphraseAlwaysOnDevice: snapshot.settings.passphraseAlwaysOnDevice, safetyChecks: snapshot.settings.safetyChecks, autoLockDelayMs: snapshot.settings.autoLockDelayMs, autoShutdownDelayMs: snapshot.settings.autoShutdownDelayMs, displayRotation: snapshot.settings.displayRotation, experimentalFeatures: snapshot.settings.experimentalFeatures, wallpaperPath: snapshot.settings.wallpaperPath, brightness: snapshot.settings.brightness, animationEnabled: snapshot.settings.animationEnabled, tapToWake: snapshot.settings.tapToWake, hapticFeedback: snapshot.settings.hapticFeedback, deviceNameDisplayEnabled: snapshot.settings.deviceNameDisplayEnabled, airgapMode: snapshot.settings.airgapMode, fidoEnabled: snapshot.settings.fidoEnabled, usbLockEnabled: snapshot.settings.usbLockEnabled, randomKeypad: snapshot.settings.randomKeypad, firmwareVersion: snapshot.versions.firmware, bootloaderVersion: snapshot.versions.bootloader, boardVersion: snapshot.versions.board, bleVersion: snapshot.versions.ble, se01Version: snapshot.versions.se01, se02Version: snapshot.versions.se02, se03Version: snapshot.versions.se03, se04Version: snapshot.versions.se04, se01BootVersion: snapshot.versions.se01Boot, se02BootVersion: snapshot.versions.se02Boot, se03BootVersion: snapshot.versions.se03Boot, se04BootVersion: snapshot.versions.se04Boot, seVersion: (_h = snapshot.versions.se) !== null && _h !== void 0 ? _h : null, verify: snapshot.verification, device_id: (_j = snapshot.identity.deviceId) !== null && _j !== void 0 ? _j : undefined, ble_name: (_k = snapshot.identity.bleName) !== null && _k !== void 0 ? _k : undefined, passphrase_protection: (_l = snapshot.status.passphraseProtection) !== null && _l !== void 0 ? _l : undefined, bootloader_mode: bootloaderMode, sessionId: null, session_id: null });
|
|
42578
42679
|
};
|
|
42579
42680
|
|
|
42580
42681
|
function createEmptyDeviceState(identity = {}) {
|
|
@@ -42730,6 +42831,7 @@ const createPublicDeviceState = (state) => {
|
|
|
42730
42831
|
class DeviceWalletSessionStore {
|
|
42731
42832
|
constructor() {
|
|
42732
42833
|
this.walletSessions = new Map();
|
|
42834
|
+
this.standardWalletSessions = new Map();
|
|
42733
42835
|
this.pendingSessions = new Map();
|
|
42734
42836
|
}
|
|
42735
42837
|
get(deviceKey, passphraseState) {
|
|
@@ -42748,6 +42850,17 @@ class DeviceWalletSessionStore {
|
|
|
42748
42850
|
}
|
|
42749
42851
|
deviceSessions.set(passphraseState, sessionId);
|
|
42750
42852
|
}
|
|
42853
|
+
getStandard(deviceKey) {
|
|
42854
|
+
if (!deviceKey)
|
|
42855
|
+
return undefined;
|
|
42856
|
+
return this.standardWalletSessions.get(deviceKey);
|
|
42857
|
+
}
|
|
42858
|
+
setStandard(deviceKey, passphraseState, sessionId) {
|
|
42859
|
+
if (!deviceKey || !passphraseState || !sessionId)
|
|
42860
|
+
return;
|
|
42861
|
+
this.set(deviceKey, passphraseState, sessionId);
|
|
42862
|
+
this.standardWalletSessions.set(deviceKey, { passphraseState, sessionId });
|
|
42863
|
+
}
|
|
42751
42864
|
setPending(deviceKey, sessionId) {
|
|
42752
42865
|
if (!deviceKey || !sessionId)
|
|
42753
42866
|
return;
|
|
@@ -42761,6 +42874,10 @@ class DeviceWalletSessionStore {
|
|
|
42761
42874
|
delete(deviceKey, passphraseState) {
|
|
42762
42875
|
if (!deviceKey || !passphraseState)
|
|
42763
42876
|
return;
|
|
42877
|
+
const standardWalletSession = this.standardWalletSessions.get(deviceKey);
|
|
42878
|
+
if ((standardWalletSession === null || standardWalletSession === void 0 ? void 0 : standardWalletSession.passphraseState) === passphraseState) {
|
|
42879
|
+
this.standardWalletSessions.delete(deviceKey);
|
|
42880
|
+
}
|
|
42764
42881
|
const deviceSessions = this.walletSessions.get(deviceKey);
|
|
42765
42882
|
if (!deviceSessions)
|
|
42766
42883
|
return;
|
|
@@ -42769,6 +42886,15 @@ class DeviceWalletSessionStore {
|
|
|
42769
42886
|
this.walletSessions.delete(deviceKey);
|
|
42770
42887
|
}
|
|
42771
42888
|
}
|
|
42889
|
+
deleteStandard(deviceKey) {
|
|
42890
|
+
if (!deviceKey)
|
|
42891
|
+
return;
|
|
42892
|
+
const standardWalletSession = this.standardWalletSessions.get(deviceKey);
|
|
42893
|
+
this.standardWalletSessions.delete(deviceKey);
|
|
42894
|
+
if (standardWalletSession) {
|
|
42895
|
+
this.delete(deviceKey, standardWalletSession.passphraseState);
|
|
42896
|
+
}
|
|
42897
|
+
}
|
|
42772
42898
|
deletePending(deviceKey) {
|
|
42773
42899
|
if (!deviceKey)
|
|
42774
42900
|
return;
|
|
@@ -42778,23 +42904,28 @@ class DeviceWalletSessionStore {
|
|
|
42778
42904
|
if (!deviceKey)
|
|
42779
42905
|
return;
|
|
42780
42906
|
this.walletSessions.delete(deviceKey);
|
|
42907
|
+
this.standardWalletSessions.delete(deviceKey);
|
|
42781
42908
|
this.pendingSessions.delete(deviceKey);
|
|
42782
42909
|
}
|
|
42783
42910
|
migrateTemporaryDeviceKey(from, to) {
|
|
42784
|
-
var _a;
|
|
42785
42911
|
if (!from || !to || from === to)
|
|
42786
42912
|
return;
|
|
42787
42913
|
const sourceSessions = this.walletSessions.get(from);
|
|
42788
42914
|
if (sourceSessions) {
|
|
42789
|
-
const targetSessions = (_a = this.walletSessions.get(to)) !== null && _a !== void 0 ? _a : new Map();
|
|
42790
|
-
this.walletSessions.set(to, targetSessions);
|
|
42791
42915
|
sourceSessions.forEach((sessionId, passphraseState) => {
|
|
42792
|
-
if (!
|
|
42793
|
-
|
|
42916
|
+
if (!this.get(to, passphraseState)) {
|
|
42917
|
+
this.set(to, passphraseState, sessionId);
|
|
42794
42918
|
}
|
|
42795
42919
|
});
|
|
42796
42920
|
this.walletSessions.delete(from);
|
|
42797
42921
|
}
|
|
42922
|
+
const standardWalletSession = this.standardWalletSessions.get(from);
|
|
42923
|
+
if (standardWalletSession &&
|
|
42924
|
+
!this.standardWalletSessions.has(to) &&
|
|
42925
|
+
this.get(to, standardWalletSession.passphraseState) === standardWalletSession.sessionId) {
|
|
42926
|
+
this.standardWalletSessions.set(to, standardWalletSession);
|
|
42927
|
+
}
|
|
42928
|
+
this.standardWalletSessions.delete(from);
|
|
42798
42929
|
const pendingSession = this.pendingSessions.get(from);
|
|
42799
42930
|
if (pendingSession && !this.pendingSessions.has(to)) {
|
|
42800
42931
|
this.pendingSessions.set(to, pendingSession);
|
|
@@ -42814,16 +42945,35 @@ class DeviceWalletSessionStore {
|
|
|
42814
42945
|
}
|
|
42815
42946
|
clear() {
|
|
42816
42947
|
this.walletSessions.clear();
|
|
42948
|
+
this.standardWalletSessions.clear();
|
|
42817
42949
|
this.pendingSessions.clear();
|
|
42818
42950
|
}
|
|
42819
42951
|
}
|
|
42820
42952
|
const deviceWalletSessionStore = new DeviceWalletSessionStore();
|
|
42821
42953
|
|
|
42822
|
-
const
|
|
42823
|
-
if (
|
|
42954
|
+
const parseProtocolV2BuildFingerprint = (buildFingerprint) => {
|
|
42955
|
+
if (!buildFingerprint)
|
|
42956
|
+
return null;
|
|
42957
|
+
const [binary, version, commit, environment, buildType, ...extra] = buildFingerprint.split('__');
|
|
42958
|
+
if (extra.length > 0 ||
|
|
42959
|
+
(binary !== 'application' && binary !== 'bootloader' && binary !== 'romloader') ||
|
|
42960
|
+
!version ||
|
|
42961
|
+
!commit ||
|
|
42962
|
+
(environment !== 'PROD' && environment !== 'DEV') ||
|
|
42963
|
+
(buildType !== 'DEBUG' && buildType !== 'RELEASE')) {
|
|
42964
|
+
return null;
|
|
42965
|
+
}
|
|
42966
|
+
return { binary, version, commit, environment, buildType };
|
|
42967
|
+
};
|
|
42968
|
+
const getProtocolV2RuntimeMode = (protocolInfo) => {
|
|
42969
|
+
var _a;
|
|
42970
|
+
const binary = (_a = parseProtocolV2BuildFingerprint(protocolInfo.build_fingerprint)) === null || _a === void 0 ? void 0 : _a.binary;
|
|
42971
|
+
if (binary === 'application')
|
|
42824
42972
|
return 'normal';
|
|
42825
|
-
return
|
|
42973
|
+
return binary;
|
|
42826
42974
|
};
|
|
42975
|
+
const PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE = 60602;
|
|
42976
|
+
const supportsProtocolV2Message = (protocolInfo, messageType) => protocolInfo.supported_messages.includes(messageType);
|
|
42827
42977
|
const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
|
|
42828
42978
|
targets: {
|
|
42829
42979
|
hw: true,
|
|
@@ -42872,6 +43022,14 @@ const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
|
|
|
42872
43022
|
},
|
|
42873
43023
|
};
|
|
42874
43024
|
const PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS = 10 * 1000;
|
|
43025
|
+
function requestProtocolV2ProtocolInfo({ commands, timeoutMs, }) {
|
|
43026
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43027
|
+
const response = timeoutMs === undefined
|
|
43028
|
+
? yield commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {})
|
|
43029
|
+
: yield commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {}, { timeoutMs });
|
|
43030
|
+
return response.message;
|
|
43031
|
+
});
|
|
43032
|
+
}
|
|
42875
43033
|
function requestProtocolV2DeviceInfo({ commands, timeoutMs = PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS, request = PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST, }) {
|
|
42876
43034
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42877
43035
|
const { message } = yield commands.typedCall('DeviceInfoGet', 'DeviceInfo', request, {
|
|
@@ -42947,7 +43105,7 @@ class Device extends events.exports {
|
|
|
42947
43105
|
}
|
|
42948
43106
|
toMessageObject() {
|
|
42949
43107
|
var _a;
|
|
42950
|
-
if (this.isUnacquired())
|
|
43108
|
+
if (this.isUnacquired() || !this.features)
|
|
42951
43109
|
return null;
|
|
42952
43110
|
const env = DataManager.getSettings('env');
|
|
42953
43111
|
const deviceType = this.getCurrentDeviceType();
|
|
@@ -42960,6 +43118,7 @@ class Device extends events.exports {
|
|
|
42960
43118
|
const state = this.state ? createPublicDeviceState(this.state) : undefined;
|
|
42961
43119
|
return {
|
|
42962
43120
|
connectId: DataManager.isBleConnect(env) ? this.mainId || null : connectId,
|
|
43121
|
+
connectProtocol: this.originalDescriptor.protocolType,
|
|
42963
43122
|
serialNo,
|
|
42964
43123
|
uuid: serialNo,
|
|
42965
43124
|
commType: this.originalDescriptor.commType,
|
|
@@ -43015,21 +43174,21 @@ class Device extends events.exports {
|
|
|
43015
43174
|
resolve(false);
|
|
43016
43175
|
}));
|
|
43017
43176
|
}
|
|
43018
|
-
acquire(
|
|
43177
|
+
acquire(expectedProtocol, options) {
|
|
43019
43178
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
43020
43179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43021
43180
|
const env = DataManager.getSettings('env');
|
|
43022
43181
|
const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
|
|
43023
|
-
const
|
|
43182
|
+
const protocolHint = expectedProtocol ? undefined : this.originalDescriptor.protocolType;
|
|
43024
43183
|
try {
|
|
43025
43184
|
let acquireResult;
|
|
43026
43185
|
if (DataManager.isBleConnect(env)) {
|
|
43027
|
-
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, expectedProtocol));
|
|
43186
|
+
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, expectedProtocol, protocolHint));
|
|
43028
43187
|
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
43029
43188
|
Log$e.debug('Expected uuid:', this.mainId);
|
|
43030
43189
|
}
|
|
43031
43190
|
else {
|
|
43032
|
-
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, expectedProtocol));
|
|
43191
|
+
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, expectedProtocol, protocolHint));
|
|
43033
43192
|
this.mainId = acquireResult;
|
|
43034
43193
|
Log$e.debug('Expected session id:', this.mainId);
|
|
43035
43194
|
}
|
|
@@ -43299,14 +43458,25 @@ class Device extends events.exports {
|
|
|
43299
43458
|
return undefined;
|
|
43300
43459
|
return deviceWalletSessionStore.get(deviceId, this.passphraseState);
|
|
43301
43460
|
}
|
|
43302
|
-
|
|
43461
|
+
getStandardInternalState(_deviceId) {
|
|
43462
|
+
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
43463
|
+
if (!deviceId)
|
|
43464
|
+
return undefined;
|
|
43465
|
+
return deviceWalletSessionStore.getStandard(deviceId);
|
|
43466
|
+
}
|
|
43467
|
+
updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null, walletType = 'hidden') {
|
|
43303
43468
|
Log$e.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `hasPassphraseState: ${Boolean(passphraseState)}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
|
|
43304
43469
|
const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
|
|
43305
43470
|
if (!cacheDeviceKey)
|
|
43306
43471
|
return;
|
|
43307
43472
|
if (enablePassphrase) {
|
|
43308
43473
|
const walletSessionId = sessionId || featuresSessionId || deviceWalletSessionStore.getPending(cacheDeviceKey);
|
|
43309
|
-
|
|
43474
|
+
if (walletType === 'standard') {
|
|
43475
|
+
deviceWalletSessionStore.setStandard(cacheDeviceKey, passphraseState, walletSessionId !== null && walletSessionId !== void 0 ? walletSessionId : undefined);
|
|
43476
|
+
}
|
|
43477
|
+
else {
|
|
43478
|
+
deviceWalletSessionStore.set(cacheDeviceKey, passphraseState, walletSessionId !== null && walletSessionId !== void 0 ? walletSessionId : undefined);
|
|
43479
|
+
}
|
|
43310
43480
|
}
|
|
43311
43481
|
deviceWalletSessionStore.deletePending(cacheDeviceKey);
|
|
43312
43482
|
}
|
|
@@ -43334,6 +43504,12 @@ class Device extends events.exports {
|
|
|
43334
43504
|
deviceWalletSessionStore.delete(deviceId, this.passphraseState);
|
|
43335
43505
|
}
|
|
43336
43506
|
}
|
|
43507
|
+
clearStandardInternalState(_deviceId) {
|
|
43508
|
+
const deviceId = this.getSessionCacheDeviceKey(_deviceId);
|
|
43509
|
+
if (!deviceId)
|
|
43510
|
+
return;
|
|
43511
|
+
deviceWalletSessionStore.deleteStandard(deviceId);
|
|
43512
|
+
}
|
|
43337
43513
|
initialize(options) {
|
|
43338
43514
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43339
43515
|
if (this.isProtocolV2()) {
|
|
@@ -43361,7 +43537,9 @@ class Device extends events.exports {
|
|
|
43361
43537
|
const expectedDeviceId = options === null || options === void 0 ? void 0 : options.deviceId;
|
|
43362
43538
|
if (expectedDeviceId) {
|
|
43363
43539
|
this.passphraseState = undefined;
|
|
43364
|
-
yield
|
|
43540
|
+
const { message } = yield this.commands.typedCall('GetFeatures', 'Features', {});
|
|
43541
|
+
this._updateFeatures(message);
|
|
43542
|
+
yield TransportManager.reconfigure(this.features);
|
|
43365
43543
|
if (!this.checkDeviceId(expectedDeviceId)) {
|
|
43366
43544
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
43367
43545
|
}
|
|
@@ -43381,14 +43559,7 @@ class Device extends events.exports {
|
|
|
43381
43559
|
if (options === null || options === void 0 ? void 0 : options.deriveCardano) {
|
|
43382
43560
|
payload.derive_cardano = true;
|
|
43383
43561
|
}
|
|
43384
|
-
|
|
43385
|
-
Boolean(internalState) ||
|
|
43386
|
-
Boolean(options === null || options === void 0 ? void 0 : options.passphraseState) ||
|
|
43387
|
-
(options === null || options === void 0 ? void 0 : options.deriveCardano) === true ||
|
|
43388
|
-
(options === null || options === void 0 ? void 0 : options.initSession) === true;
|
|
43389
|
-
if (requiresWalletInitialize) {
|
|
43390
|
-
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
43391
|
-
}
|
|
43562
|
+
yield callInitialize(payload, options === null || options === void 0 ? void 0 : options.initSession);
|
|
43392
43563
|
}
|
|
43393
43564
|
catch (error) {
|
|
43394
43565
|
Log$e.error('Initialization failed:', error);
|
|
@@ -43538,37 +43709,44 @@ class Device extends events.exports {
|
|
|
43538
43709
|
return this.features;
|
|
43539
43710
|
}
|
|
43540
43711
|
probeProtocolV2RuntimeState(deviceInfo, timeoutMs) {
|
|
43712
|
+
var _a;
|
|
43541
43713
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43542
|
-
|
|
43543
|
-
|
|
43544
|
-
|
|
43545
|
-
|
|
43546
|
-
|
|
43547
|
-
|
|
43714
|
+
const protocolInfo = yield requestProtocolV2ProtocolInfo({
|
|
43715
|
+
commands: this.commands,
|
|
43716
|
+
timeoutMs,
|
|
43717
|
+
});
|
|
43718
|
+
const runtimeMode = getProtocolV2RuntimeMode(protocolInfo);
|
|
43719
|
+
const protocolV2DeviceType = resolveProtocolV2DeviceIdentity((_a = deviceInfo.hw) === null || _a === void 0 ? void 0 : _a.Device_type).deviceType;
|
|
43720
|
+
if (runtimeMode === 'romloader' && protocolV2DeviceType !== hdShared.EDeviceType.Pro2) {
|
|
43721
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Protocol V2 romloader mode is only supported for Pro2.');
|
|
43548
43722
|
}
|
|
43549
|
-
|
|
43550
|
-
|
|
43551
|
-
|
|
43552
|
-
deviceStatusAvailable: false,
|
|
43553
|
-
});
|
|
43554
|
-
Log$e.debug('Protocol V2 DeviceStatusGet unavailable; use temporary loader fallback', {
|
|
43555
|
-
runtimeMode,
|
|
43556
|
-
error: error instanceof Error ? error.message : String(error),
|
|
43557
|
-
});
|
|
43558
|
-
return this.updateProtocolV2Features(deviceInfo, null, runtimeMode);
|
|
43723
|
+
const deviceStatusSupported = supportsProtocolV2Message(protocolInfo, PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE);
|
|
43724
|
+
if (runtimeMode === 'bootloader' || runtimeMode === 'romloader') {
|
|
43725
|
+
return this.updateProtocolV2Features(deviceInfo, null, runtimeMode, protocolInfo);
|
|
43559
43726
|
}
|
|
43560
|
-
|
|
43727
|
+
if (!deviceStatusSupported) {
|
|
43728
|
+
if (runtimeMode === 'normal') {
|
|
43729
|
+
return this.updateProtocolV2Features(deviceInfo, null, runtimeMode, protocolInfo);
|
|
43730
|
+
}
|
|
43731
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Unknown Protocol V2 build fingerprint without DeviceStatusGet capability: ${protocolInfo.build_fingerprint}`);
|
|
43732
|
+
}
|
|
43733
|
+
const deviceStatus = yield requestProtocolV2DeviceStatus({
|
|
43734
|
+
commands: this.commands,
|
|
43735
|
+
timeoutMs,
|
|
43736
|
+
});
|
|
43737
|
+
return this.updateProtocolV2Features(deviceInfo, deviceStatus, 'normal', protocolInfo);
|
|
43561
43738
|
});
|
|
43562
43739
|
}
|
|
43563
|
-
updateProtocolV2Features(deviceInfo, deviceStatus, runtimeMode) {
|
|
43740
|
+
updateProtocolV2Features(deviceInfo, deviceStatus, runtimeMode, protocolInfo) {
|
|
43564
43741
|
var _a;
|
|
43565
43742
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
43566
|
-
const resolvedMode = runtimeMode !== null && runtimeMode !== void 0 ? runtimeMode : (deviceStatus
|
|
43567
|
-
? getProtocolV2RuntimeMode({ deviceInfo, deviceStatusAvailable: true })
|
|
43568
|
-
: (_a = this.state) === null || _a === void 0 ? void 0 : _a.status.mode);
|
|
43743
|
+
const resolvedMode = runtimeMode !== null && runtimeMode !== void 0 ? runtimeMode : (deviceStatus ? 'normal' : (_a = this.state) === null || _a === void 0 ? void 0 : _a.status.mode);
|
|
43569
43744
|
if (deviceInfo) {
|
|
43570
43745
|
this.updateState(mapProtocolV2DeviceInfoToState(deviceInfo, resolvedMode), 'device-info');
|
|
43571
43746
|
}
|
|
43747
|
+
if (protocolInfo) {
|
|
43748
|
+
this.updateState({ raw: { protocolV2ProtocolInfo: protocolInfo } }, 'device-info');
|
|
43749
|
+
}
|
|
43572
43750
|
if (deviceStatus) {
|
|
43573
43751
|
this.updateState(mapProtocolV2DeviceStatusToState(deviceStatus), 'device-status');
|
|
43574
43752
|
}
|
|
@@ -43631,13 +43809,13 @@ class Device extends events.exports {
|
|
|
43631
43809
|
attachToPinEnabled: null,
|
|
43632
43810
|
unlockedAttachPin: null,
|
|
43633
43811
|
},
|
|
43634
|
-
raw: { protocolV2DeviceStatus: null },
|
|
43812
|
+
raw: { protocolV2ProtocolInfo: null, protocolV2DeviceStatus: null },
|
|
43635
43813
|
}, 'transport-reconnect');
|
|
43636
43814
|
return;
|
|
43637
43815
|
}
|
|
43638
43816
|
this.updateState({
|
|
43639
43817
|
status: { mode: 'normal', unlocked: null },
|
|
43640
|
-
raw: { protocolV2DeviceStatus: null },
|
|
43818
|
+
raw: { protocolV2ProtocolInfo: null, protocolV2DeviceStatus: null },
|
|
43641
43819
|
}, 'transport-reconnect');
|
|
43642
43820
|
}
|
|
43643
43821
|
updateDescriptor(descriptor, forceUpdate = false) {
|
|
@@ -43844,7 +44022,14 @@ class Device extends events.exports {
|
|
|
43844
44022
|
isBootloader() {
|
|
43845
44023
|
if (!this.state)
|
|
43846
44024
|
return undefined;
|
|
43847
|
-
return this.state.status.mode === 'bootloader'
|
|
44025
|
+
return this.state.status.mode === 'bootloader';
|
|
44026
|
+
}
|
|
44027
|
+
isRomloader() {
|
|
44028
|
+
if (!this.state)
|
|
44029
|
+
return undefined;
|
|
44030
|
+
return (this.isProtocolV2() &&
|
|
44031
|
+
this.getCurrentDeviceType() === hdShared.EDeviceType.Pro2 &&
|
|
44032
|
+
this.state.status.mode === 'romloader');
|
|
43848
44033
|
}
|
|
43849
44034
|
isInitialized() {
|
|
43850
44035
|
if (!this.state)
|
|
@@ -44649,14 +44834,22 @@ class GetPassphraseState extends BaseMethod {
|
|
|
44649
44834
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed);
|
|
44650
44835
|
}
|
|
44651
44836
|
const isProtocolV2 = this.device.isProtocolV2();
|
|
44837
|
+
if (isProtocolV2 && this.payload.useEmptyPassphrase !== true) {
|
|
44838
|
+
const features = yield refreshProtocolV2DeviceStatus(this.device);
|
|
44839
|
+
if (features.unlocked === false) {
|
|
44840
|
+
yield this.device.unlockDevice();
|
|
44841
|
+
}
|
|
44842
|
+
}
|
|
44652
44843
|
const { passphraseState } = yield getPassphraseStateWithRefreshDeviceInfo(this.device, isProtocolV2
|
|
44653
44844
|
? {
|
|
44654
44845
|
onlyMainPin: this.payload.useEmptyPassphrase === true,
|
|
44655
44846
|
initSession: this.payload.initSession === true,
|
|
44656
44847
|
}
|
|
44657
44848
|
: undefined);
|
|
44658
|
-
|
|
44659
|
-
|
|
44849
|
+
if (!isProtocolV2 && this.device.getCurrentPassphraseProtection() !== true) {
|
|
44850
|
+
return undefined;
|
|
44851
|
+
}
|
|
44852
|
+
return passphraseState;
|
|
44660
44853
|
});
|
|
44661
44854
|
}
|
|
44662
44855
|
}
|
|
@@ -44697,7 +44890,7 @@ const formatAnyHex = value => {
|
|
|
44697
44890
|
return value;
|
|
44698
44891
|
};
|
|
44699
44892
|
const hexes = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
44700
|
-
function bytesToHex$
|
|
44893
|
+
function bytesToHex$1(uint8a) {
|
|
44701
44894
|
if (!(uint8a instanceof Uint8Array))
|
|
44702
44895
|
throw new Error('Uint8Array expected');
|
|
44703
44896
|
let hex = '';
|
|
@@ -44902,7 +45095,6 @@ class OpenWalletSession extends BaseMethod {
|
|
|
44902
45095
|
this.payload.useEmptyPassphrase = this.params.mode === OpenWalletSessionMode.Standard;
|
|
44903
45096
|
}
|
|
44904
45097
|
run() {
|
|
44905
|
-
var _a;
|
|
44906
45098
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44907
45099
|
const isProtocolV2 = this.device.isProtocolV2();
|
|
44908
45100
|
const state = yield this.device.getDeviceState({ refreshSections: ['status'] });
|
|
@@ -44918,6 +45110,11 @@ class OpenWalletSession extends BaseMethod {
|
|
|
44918
45110
|
currentDeviceId = refreshedState.identity.deviceId;
|
|
44919
45111
|
return requireDeviceId();
|
|
44920
45112
|
});
|
|
45113
|
+
const unlockProtocolV2IfLocked = () => __awaiter(this, void 0, void 0, function* () {
|
|
45114
|
+
if (isProtocolV2 && state.status.unlocked === false) {
|
|
45115
|
+
yield this.device.unlockDevice();
|
|
45116
|
+
}
|
|
45117
|
+
});
|
|
44921
45118
|
const protocol = isProtocolV2 ? 'V2' : 'V1';
|
|
44922
45119
|
if (this.params.mode === OpenWalletSessionMode.Standard) {
|
|
44923
45120
|
this.device.passphraseState = undefined;
|
|
@@ -44932,7 +45129,7 @@ class OpenWalletSession extends BaseMethod {
|
|
|
44932
45129
|
try {
|
|
44933
45130
|
yield this.device.lockDevice();
|
|
44934
45131
|
}
|
|
44935
|
-
catch (
|
|
45132
|
+
catch (_a) {
|
|
44936
45133
|
}
|
|
44937
45134
|
this.device.clearInternalState();
|
|
44938
45135
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
@@ -44947,9 +45144,7 @@ class OpenWalletSession extends BaseMethod {
|
|
|
44947
45144
|
}
|
|
44948
45145
|
if (this.params.mode === OpenWalletSessionMode.ResumeHidden) {
|
|
44949
45146
|
if (isProtocolV2) {
|
|
44950
|
-
|
|
44951
|
-
yield this.device.unlockDevice();
|
|
44952
|
-
}
|
|
45147
|
+
yield unlockProtocolV2IfLocked();
|
|
44953
45148
|
const refreshedDeviceId = yield refreshProtocolV2DeviceId();
|
|
44954
45149
|
if (refreshedDeviceId !== this.params.deviceId) {
|
|
44955
45150
|
deviceWalletSessionStore.delete(this.params.deviceId, this.params.passphraseState);
|
|
@@ -44961,7 +45156,7 @@ class OpenWalletSession extends BaseMethod {
|
|
|
44961
45156
|
}
|
|
44962
45157
|
this.device.passphraseState = this.params.passphraseState;
|
|
44963
45158
|
const cachedSessionId = deviceWalletSessionStore.get(this.params.deviceId, this.params.passphraseState);
|
|
44964
|
-
if (!cachedSessionId) {
|
|
45159
|
+
if (!cachedSessionId && !isProtocolV2) {
|
|
44965
45160
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
44966
45161
|
}
|
|
44967
45162
|
if (!isProtocolV2) {
|
|
@@ -44978,23 +45173,28 @@ class OpenWalletSession extends BaseMethod {
|
|
|
44978
45173
|
expectPassphraseState: this.params.passphraseState,
|
|
44979
45174
|
});
|
|
44980
45175
|
const deviceId = requireDeviceId();
|
|
44981
|
-
if (
|
|
45176
|
+
if (session.passphraseState !== this.params.passphraseState) {
|
|
44982
45177
|
this.device.clearInternalState();
|
|
44983
45178
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
44984
45179
|
}
|
|
44985
|
-
return Object.assign(Object.assign({ protocol, walletType: 'hidden', deviceId }, requireHiddenWalletResponse(session)), { resumed: wasResumed(session) || session.newSession === cachedSessionId });
|
|
45180
|
+
return Object.assign(Object.assign({ protocol, walletType: 'hidden', deviceId }, requireHiddenWalletResponse(session)), { resumed: wasResumed(session) || (!isProtocolV2 && session.newSession === cachedSessionId) });
|
|
44986
45181
|
}
|
|
44987
45182
|
this.device.passphraseState = undefined;
|
|
45183
|
+
yield unlockProtocolV2IfLocked();
|
|
44988
45184
|
const session = isProtocolV2
|
|
44989
|
-
? yield getProtocolV2WalletSession(this.device, {
|
|
45185
|
+
? yield getProtocolV2WalletSession(this.device, { forceWalletSelection: true })
|
|
44990
45186
|
: yield getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
|
|
44991
45187
|
const deviceId = isProtocolV2 ? yield refreshProtocolV2DeviceId() : requireDeviceId();
|
|
45188
|
+
if (isProtocolV2 && this.device.getCurrentPassphraseProtection() !== true) {
|
|
45189
|
+
this.device.clearInternalState();
|
|
45190
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
45191
|
+
}
|
|
44992
45192
|
const responseBase = {
|
|
44993
45193
|
protocol,
|
|
44994
45194
|
deviceId,
|
|
44995
45195
|
resumed: wasResumed(session),
|
|
44996
45196
|
};
|
|
44997
|
-
return this.device.getCurrentPassphraseProtection() === false
|
|
45197
|
+
return !isProtocolV2 && this.device.getCurrentPassphraseProtection() === false
|
|
44998
45198
|
? Object.assign(Object.assign({}, responseBase), { walletType: 'standard', passphraseState: null }) : Object.assign(Object.assign(Object.assign({}, responseBase), { walletType: 'hidden' }), requireHiddenWalletResponse(session));
|
|
44999
45199
|
});
|
|
45000
45200
|
}
|
|
@@ -45256,41 +45456,10 @@ const CURRENT_HASH_BY_COMPONENT_TARGET = {
|
|
|
45256
45456
|
APPLICATION_P1: 'applicationP1Hash',
|
|
45257
45457
|
APPLICATION_P2: 'applicationP2Hash',
|
|
45258
45458
|
};
|
|
45259
|
-
const PROTOCOL_V2_PACKAGE_METADATA_END = 0x27f;
|
|
45260
|
-
const PROTOCOL_V2_PACKAGE_PAYLOAD_HASH_OFFSET = 0x200;
|
|
45261
|
-
const PROTOCOL_V2_PACKAGE_PAYLOAD_HASH_SIZE = 64;
|
|
45262
|
-
function bytesToHex$1(bytes) {
|
|
45263
|
-
return Array.from(bytes)
|
|
45264
|
-
.map(byte => byte.toString(16).padStart(2, '0'))
|
|
45265
|
-
.join('');
|
|
45266
|
-
}
|
|
45267
45459
|
function normalizeHex(value) {
|
|
45268
45460
|
const normalized = value === null || value === void 0 ? void 0 : value.replace(/^0x/i, '').toLowerCase();
|
|
45269
45461
|
return normalized && /^[0-9a-f]+$/.test(normalized) ? normalized : undefined;
|
|
45270
45462
|
}
|
|
45271
|
-
function getRemoteComponentPayloadHash(url) {
|
|
45272
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45273
|
-
try {
|
|
45274
|
-
const binary = yield httpRequest$1(url, 'binary', {
|
|
45275
|
-
headers: { Range: `bytes=0-${PROTOCOL_V2_PACKAGE_METADATA_END}` },
|
|
45276
|
-
connectTimeoutMs: 5000,
|
|
45277
|
-
readTimeoutMs: 5000,
|
|
45278
|
-
overallTimeoutMs: 10000,
|
|
45279
|
-
maxRetries: 1,
|
|
45280
|
-
retryDelayMs: 250,
|
|
45281
|
-
});
|
|
45282
|
-
const bytes = new Uint8Array(binary);
|
|
45283
|
-
if (bytes.byteLength <= PROTOCOL_V2_PACKAGE_METADATA_END ||
|
|
45284
|
-
String.fromCharCode(...bytes.slice(0, 4)) !== 'OKPP') {
|
|
45285
|
-
return null;
|
|
45286
|
-
}
|
|
45287
|
-
return bytesToHex$1(bytes.slice(PROTOCOL_V2_PACKAGE_PAYLOAD_HASH_OFFSET, PROTOCOL_V2_PACKAGE_PAYLOAD_HASH_OFFSET + PROTOCOL_V2_PACKAGE_PAYLOAD_HASH_SIZE));
|
|
45288
|
-
}
|
|
45289
|
-
catch (_a) {
|
|
45290
|
-
return null;
|
|
45291
|
-
}
|
|
45292
|
-
});
|
|
45293
|
-
}
|
|
45294
45463
|
function toVersionString(version) {
|
|
45295
45464
|
return (version === null || version === void 0 ? void 0 : version.length) ? version.join('.') : null;
|
|
45296
45465
|
}
|
|
@@ -45331,20 +45500,22 @@ function buildComponentRelease({ configKey, component, currentVersions, currentV
|
|
|
45331
45500
|
else if (semver__default["default"].gt(currentVersion, targetVersion)) {
|
|
45332
45501
|
status = 'valid';
|
|
45333
45502
|
}
|
|
45334
|
-
else
|
|
45503
|
+
else {
|
|
45335
45504
|
const currentHashKey = CURRENT_HASH_BY_COMPONENT_TARGET[componentTarget];
|
|
45336
|
-
|
|
45337
|
-
|
|
45338
|
-
if (currentHash && expectedHash) {
|
|
45339
|
-
status = expectedHash.startsWith(currentHash) ? 'valid' : 'outdated';
|
|
45505
|
+
if (!currentHashKey) {
|
|
45506
|
+
status = 'valid';
|
|
45340
45507
|
}
|
|
45341
45508
|
else {
|
|
45342
|
-
|
|
45509
|
+
const currentHash = normalizeHex(currentVerification[currentHashKey]);
|
|
45510
|
+
const expectedHash = normalizeHex(remotePayloadHash !== null && remotePayloadHash !== void 0 ? remotePayloadHash : undefined);
|
|
45511
|
+
if (currentHash && expectedHash) {
|
|
45512
|
+
status = expectedHash.startsWith(currentHash) ? 'valid' : 'outdated';
|
|
45513
|
+
}
|
|
45514
|
+
else {
|
|
45515
|
+
status = 'unknown';
|
|
45516
|
+
}
|
|
45343
45517
|
}
|
|
45344
45518
|
}
|
|
45345
|
-
else {
|
|
45346
|
-
status = 'valid';
|
|
45347
|
-
}
|
|
45348
45519
|
}
|
|
45349
45520
|
return {
|
|
45350
45521
|
configKey,
|
|
@@ -45377,7 +45548,7 @@ function buildProtocolV2FirmwareRelease({ currentVersions, currentVerification =
|
|
|
45377
45548
|
currentVerification,
|
|
45378
45549
|
remotePayloadHash: Object.prototype.hasOwnProperty.call(remotePayloadHashes, configKey)
|
|
45379
45550
|
? remotePayloadHashes[configKey]
|
|
45380
|
-
:
|
|
45551
|
+
: normalizeHex(component.payloadHash),
|
|
45381
45552
|
releaseRequired: release.required,
|
|
45382
45553
|
}));
|
|
45383
45554
|
if (!currentVersions.applicationP2) {
|
|
@@ -45492,37 +45663,9 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
45492
45663
|
const { firmwareType: firmwareTypeParam } = this.payload;
|
|
45493
45664
|
const firmwareType = (_a = firmwareTypeParam !== null && firmwareTypeParam !== void 0 ? firmwareTypeParam : state.identity.firmwareType) !== null && _a !== void 0 ? _a : hdShared.EFirmwareType.Universal;
|
|
45494
45665
|
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
45495
|
-
const remotePayloadHashes = {};
|
|
45496
|
-
if (release) {
|
|
45497
|
-
yield Promise.all(getOrderedComponentEntries(release).map(([configKey, component]) => __awaiter(this, void 0, void 0, function* () {
|
|
45498
|
-
var _b;
|
|
45499
|
-
const componentTarget = component.target.toUpperCase();
|
|
45500
|
-
if (!CURRENT_HASH_BY_COMPONENT_TARGET[componentTarget])
|
|
45501
|
-
return;
|
|
45502
|
-
const currentVersionKey = CURRENT_VERSION_BY_COMPONENT_TARGET[componentTarget];
|
|
45503
|
-
const currentVersion = currentVersionKey
|
|
45504
|
-
? (_b = state.versions[currentVersionKey]) !== null && _b !== void 0 ? _b : (componentTarget === 'APPLICATION_P1' ? state.versions.firmware : null)
|
|
45505
|
-
: null;
|
|
45506
|
-
const targetVersion = toVersionString(component.version);
|
|
45507
|
-
if (currentVersion &&
|
|
45508
|
-
targetVersion &&
|
|
45509
|
-
semver__default["default"].valid(currentVersion) &&
|
|
45510
|
-
semver__default["default"].valid(targetVersion) &&
|
|
45511
|
-
semver__default["default"].eq(currentVersion, targetVersion)) {
|
|
45512
|
-
const configuredPayloadHash = normalizeHex(component.payloadHash);
|
|
45513
|
-
if (configuredPayloadHash) {
|
|
45514
|
-
remotePayloadHashes[configKey] = configuredPayloadHash;
|
|
45515
|
-
}
|
|
45516
|
-
else if (component.fingerprint && component.url) {
|
|
45517
|
-
remotePayloadHashes[configKey] = yield getRemoteComponentPayloadHash(component.url);
|
|
45518
|
-
}
|
|
45519
|
-
}
|
|
45520
|
-
})));
|
|
45521
|
-
}
|
|
45522
45666
|
const plan = buildProtocolV2FirmwareRelease({
|
|
45523
45667
|
currentVersions: state.versions,
|
|
45524
45668
|
currentVerification: state.verification,
|
|
45525
|
-
remotePayloadHashes,
|
|
45526
45669
|
firmwareType,
|
|
45527
45670
|
release,
|
|
45528
45671
|
});
|
|
@@ -45853,12 +45996,16 @@ class DeviceReset extends BaseMethod {
|
|
|
45853
45996
|
}
|
|
45854
45997
|
}
|
|
45855
45998
|
|
|
45856
|
-
const
|
|
45999
|
+
const PROTOCOL_V2_LOCK_FREE_DEVICE_SETTINGS = [
|
|
45857
46000
|
'language',
|
|
45858
46001
|
'brightness',
|
|
46002
|
+
'animation_enable',
|
|
46003
|
+
'tap_to_wake',
|
|
45859
46004
|
'haptic_feedback',
|
|
45860
|
-
|
|
45861
|
-
|
|
46005
|
+
'device_name_display_enabled',
|
|
46006
|
+
];
|
|
46007
|
+
const lockFreeDeviceSettings = new Set(PROTOCOL_V2_LOCK_FREE_DEVICE_SETTINGS);
|
|
46008
|
+
const getProtocolV2SettingsUnlockPolicy = (settings) => Object.keys(settings).every(key => lockFreeDeviceSettings.has(key))
|
|
45862
46009
|
? 'none'
|
|
45863
46010
|
: 'unlock-before-run';
|
|
45864
46011
|
const getProtocolV2SettingsBehavior = (operation) => {
|
|
@@ -46012,7 +46159,11 @@ class DeviceSettings extends BaseMethod {
|
|
|
46012
46159
|
page: hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
46013
46160
|
});
|
|
46014
46161
|
const updated = yield this.device.getDeviceState({ refreshSections: ['status'] });
|
|
46015
|
-
|
|
46162
|
+
const lockedAfterDisabling = requestedPassphrase === false &&
|
|
46163
|
+
current.status.unlocked === true &&
|
|
46164
|
+
updated.status.unlocked === false;
|
|
46165
|
+
if (updated.status.passphraseProtection !== requestedPassphrase &&
|
|
46166
|
+
!lockedAfterDisabling) {
|
|
46016
46167
|
throw hdShared.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 passphrase setting did not reach the requested value.');
|
|
46017
46168
|
}
|
|
46018
46169
|
return res.message;
|
|
@@ -46465,7 +46616,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
|
|
|
46465
46616
|
const header = new Uint8Array(payload.slice(0, HEADER_SIZE));
|
|
46466
46617
|
try {
|
|
46467
46618
|
const headerRes = yield typedCall('UpgradeFileHeader', 'Success', {
|
|
46468
|
-
data: bytesToHex$
|
|
46619
|
+
data: bytesToHex$1(header),
|
|
46469
46620
|
});
|
|
46470
46621
|
const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
|
|
46471
46622
|
if (headerRes.type !== 'Success' && !isUnknownMessage) {
|
|
@@ -46714,8 +46865,8 @@ const processResourceRequest = (typedCall, res, data) => __awaiter(void 0, void
|
|
|
46714
46865
|
const payload = new Uint8Array(data.slice(offset, Math.min(offset + data_length, data.byteLength)));
|
|
46715
46866
|
const digest = blake2s.blake2s(payload);
|
|
46716
46867
|
const resourceAckParams = {
|
|
46717
|
-
data_chunk: bytesToHex$
|
|
46718
|
-
hash: bytesToHex$
|
|
46868
|
+
data_chunk: bytesToHex$1(payload),
|
|
46869
|
+
hash: bytesToHex$1(digest),
|
|
46719
46870
|
};
|
|
46720
46871
|
const response = yield typedCall('ResourceAck', ['ResourceRequest', 'Success'], Object.assign({}, resourceAckParams));
|
|
46721
46872
|
return processResourceRequest(typedCall, response, data);
|
|
@@ -46726,8 +46877,8 @@ const updateResource = (typedCall, fileName, data, onConfirmAfter) => __awaiter(
|
|
|
46726
46877
|
const res = yield typedCall('ResourceUpdate', ['ResourceRequest', 'Success'], {
|
|
46727
46878
|
file_name: fileName,
|
|
46728
46879
|
data_length: data.byteLength,
|
|
46729
|
-
initial_data_chunk: bytesToHex$
|
|
46730
|
-
hash: bytesToHex$
|
|
46880
|
+
initial_data_chunk: bytesToHex$1(chunk),
|
|
46881
|
+
hash: bytesToHex$1(digest),
|
|
46731
46882
|
});
|
|
46732
46883
|
onConfirmAfter === null || onConfirmAfter === void 0 ? void 0 : onConfirmAfter();
|
|
46733
46884
|
return processResourceRequest(typedCall, res, data);
|
|
@@ -48896,7 +49047,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
48896
49047
|
});
|
|
48897
49048
|
}
|
|
48898
49049
|
prepareRemoteProtocolV2Binaries(firmwareType, features) {
|
|
48899
|
-
var _a;
|
|
49050
|
+
var _a, _b;
|
|
48900
49051
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48901
49052
|
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
48902
49053
|
let bootloaderBinary = null;
|
|
@@ -48912,10 +49063,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
48912
49063
|
const entries = this.getRemoteComponentEntries(release);
|
|
48913
49064
|
const targetsToUpdate = new Set((_a = this.params.targetsToUpdate) !== null && _a !== void 0 ? _a : []);
|
|
48914
49065
|
for (const [key, component] of entries) {
|
|
48915
|
-
const
|
|
48916
|
-
const
|
|
48917
|
-
const
|
|
48918
|
-
|
|
49066
|
+
const targetName = (_b = component.target) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
49067
|
+
const target = PROTOCOL_V2_REMOTE_COMPONENT_TARGETS[targetName];
|
|
49068
|
+
const updateTarget = target
|
|
49069
|
+
? PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID.get(target.targetId)
|
|
49070
|
+
: undefined;
|
|
49071
|
+
if (updateTarget && targetsToUpdate.has(updateTarget)) {
|
|
48919
49072
|
const remoteBinary = yield this.downloadRemoteProtocolV2Component(key, component);
|
|
48920
49073
|
if (remoteBinary.kind === 'bootloader') {
|
|
48921
49074
|
bootloaderBinary = remoteBinary.binary;
|
|
@@ -49088,17 +49241,31 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49088
49241
|
});
|
|
49089
49242
|
}
|
|
49090
49243
|
isProtocolV2BootloaderMode() {
|
|
49091
|
-
var _a;
|
|
49244
|
+
var _a, _b, _c;
|
|
49092
49245
|
if (typeof this.device.isBootloader === 'function') {
|
|
49093
49246
|
return this.device.isBootloader();
|
|
49094
49247
|
}
|
|
49095
|
-
return
|
|
49248
|
+
return (((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.mode) === 'bootloader' ||
|
|
49249
|
+
(((_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)));
|
|
49096
49250
|
}
|
|
49097
|
-
|
|
49251
|
+
isProtocolV2RomloaderMode() {
|
|
49098
49252
|
var _a;
|
|
49253
|
+
if (!this.device.isProtocolV2() || this.device.getCurrentDeviceType() !== hdShared.EDeviceType.Pro2) {
|
|
49254
|
+
return false;
|
|
49255
|
+
}
|
|
49256
|
+
if (typeof this.device.isRomloader === 'function') {
|
|
49257
|
+
return this.device.isRomloader();
|
|
49258
|
+
}
|
|
49259
|
+
return ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.mode) === 'romloader';
|
|
49260
|
+
}
|
|
49261
|
+
enterProtocolV2BootloaderMode() {
|
|
49099
49262
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49100
|
-
if (this.
|
|
49101
|
-
Log$5.debug('Protocol V2 device is
|
|
49263
|
+
if (this.isProtocolV2RomloaderMode()) {
|
|
49264
|
+
Log$5.debug('Protocol V2 device is in romloader mode; start firmware update directly');
|
|
49265
|
+
return false;
|
|
49266
|
+
}
|
|
49267
|
+
if (this.isProtocolV2BootloaderMode()) {
|
|
49268
|
+
Log$5.debug('Protocol V2 device is already in bootloader mode, skip reboot');
|
|
49102
49269
|
return false;
|
|
49103
49270
|
}
|
|
49104
49271
|
try {
|
|
@@ -49130,8 +49297,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49130
49297
|
timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
49131
49298
|
});
|
|
49132
49299
|
this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
|
|
49133
|
-
const features = this.device.
|
|
49134
|
-
if (features === null || features === void 0 ? void 0 : features.
|
|
49300
|
+
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
|
|
49301
|
+
if ((features === null || features === void 0 ? void 0 : features.mode) === 'bootloader') {
|
|
49135
49302
|
return features;
|
|
49136
49303
|
}
|
|
49137
49304
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
@@ -49290,7 +49457,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49290
49457
|
while (Date.now() - startTime < PROTOCOL_V2_INSTALL_TIMEOUT) {
|
|
49291
49458
|
try {
|
|
49292
49459
|
yield this.reconnectProtocolV2Device();
|
|
49293
|
-
yield this.verifyProtocolV2ReconnectIdentity();
|
|
49460
|
+
const deviceInfo = yield this.verifyProtocolV2ReconnectIdentity();
|
|
49294
49461
|
try {
|
|
49295
49462
|
const statusResponse = yield this.device.getCommands().typedCall('DeviceFirmwareUpdateStatusGet', 'DeviceFirmwareUpdateStatus', {
|
|
49296
49463
|
fields: {
|
|
@@ -49310,11 +49477,16 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49310
49477
|
throw error;
|
|
49311
49478
|
}
|
|
49312
49479
|
if (isProtocolV2FirmwareStatusEndpointUnavailable(error)) {
|
|
49313
|
-
|
|
49314
|
-
|
|
49480
|
+
if (yield this.probeProtocolV2NormalMode(deviceInfo)) {
|
|
49481
|
+
Log$5.log('[FirmwareUpdateV4] firmware status endpoint unavailable after confirmed App reboot');
|
|
49482
|
+
return;
|
|
49483
|
+
}
|
|
49484
|
+
lastError = new Error('Protocol V2 firmware status endpoint is unavailable while the device remains in loader mode');
|
|
49485
|
+
}
|
|
49486
|
+
else {
|
|
49487
|
+
lastError = error;
|
|
49488
|
+
Log$5.log('[FirmwareUpdateV4] DeviceFirmwareUpdateStatusGet unavailable during install: ', error);
|
|
49315
49489
|
}
|
|
49316
|
-
lastError = error;
|
|
49317
|
-
Log$5.log('[FirmwareUpdateV4] DeviceFirmwareUpdateStatusGet unavailable during install: ', error);
|
|
49318
49490
|
}
|
|
49319
49491
|
}
|
|
49320
49492
|
catch (error) {
|
|
@@ -49339,6 +49511,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49339
49511
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
49340
49512
|
});
|
|
49341
49513
|
}
|
|
49514
|
+
probeProtocolV2NormalMode(deviceInfo) {
|
|
49515
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49516
|
+
const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
|
|
49517
|
+
return features.mode === 'normal' && !features.bootloaderMode;
|
|
49518
|
+
});
|
|
49519
|
+
}
|
|
49342
49520
|
waitForProtocolV2FinalFeatures() {
|
|
49343
49521
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49344
49522
|
const features = yield this.waitForProtocolV2ReconnectAndFeatures(PROTOCOL_V2_FINAL_RECONNECT_TIMEOUT);
|
|
@@ -49521,9 +49699,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49521
49699
|
const env = DataManager.getSettings('env');
|
|
49522
49700
|
if (DataManager.isBleConnect(env)) {
|
|
49523
49701
|
yield hdShared.wait(3000);
|
|
49524
|
-
yield this.acquireProtocolV2BleDevice();
|
|
49525
|
-
yield this.device.initialize();
|
|
49526
49702
|
}
|
|
49703
|
+
yield this.reconnectProtocolV2Device();
|
|
49704
|
+
yield this.verifyProtocolV2ReconnectIdentity();
|
|
49705
|
+
yield this.device.initialize();
|
|
49527
49706
|
yield hdShared.wait(2000);
|
|
49528
49707
|
});
|
|
49529
49708
|
}
|
|
@@ -49666,7 +49845,7 @@ class DeviceGetOnboardingStatus extends BaseMethod {
|
|
|
49666
49845
|
}
|
|
49667
49846
|
run() {
|
|
49668
49847
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49669
|
-
const { message } = yield this.device.commands.typedCall('
|
|
49848
|
+
const { message } = yield this.device.commands.typedCall('OnboardingStatusGet', 'OnboardingStatus', {});
|
|
49670
49849
|
return message;
|
|
49671
49850
|
});
|
|
49672
49851
|
}
|
|
@@ -49839,7 +50018,7 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
49839
50018
|
this.encoded = encodePro2Wallpaper({ width, height, rgba: rgbaBytes });
|
|
49840
50019
|
this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
|
|
49841
50020
|
this.params = { width, height, rgba: rgbaBytes, fileName, chunkSize };
|
|
49842
|
-
this.unlockPolicy = '
|
|
50021
|
+
this.unlockPolicy = 'none';
|
|
49843
50022
|
this.skipForceUpdateCheck = true;
|
|
49844
50023
|
this.useDevicePassphraseState = false;
|
|
49845
50024
|
}
|
|
@@ -52001,6 +52180,8 @@ function getAddress ({ typedCall, param, }) {
|
|
|
52001
52180
|
});
|
|
52002
52181
|
}
|
|
52003
52182
|
|
|
52183
|
+
const shouldUseLegacyV1EvmMessages = (device) => !device.isProtocolV2() && TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema';
|
|
52184
|
+
|
|
52004
52185
|
class EvmGetAddress extends BaseMethod {
|
|
52005
52186
|
constructor() {
|
|
52006
52187
|
super(...arguments);
|
|
@@ -52035,7 +52216,7 @@ class EvmGetAddress extends BaseMethod {
|
|
|
52035
52216
|
}
|
|
52036
52217
|
getEvmAddress(param) {
|
|
52037
52218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52038
|
-
if (
|
|
52219
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52039
52220
|
return getAddressLegacyV1({
|
|
52040
52221
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52041
52222
|
param,
|
|
@@ -52126,7 +52307,7 @@ class EVMGetPublicKey extends BaseMethod {
|
|
|
52126
52307
|
});
|
|
52127
52308
|
}
|
|
52128
52309
|
getEvmPublicKey(param) {
|
|
52129
|
-
if (
|
|
52310
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52130
52311
|
return getPublicKeyLegacyV1({
|
|
52131
52312
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52132
52313
|
param,
|
|
@@ -52215,7 +52396,7 @@ class EVMSignMessage$2 extends BaseMethod {
|
|
|
52215
52396
|
}
|
|
52216
52397
|
run() {
|
|
52217
52398
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52218
|
-
if (
|
|
52399
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52219
52400
|
return signMessageLegacyV1({
|
|
52220
52401
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52221
52402
|
params: this.params,
|
|
@@ -52535,7 +52716,7 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
52535
52716
|
const { addressN, isEIP1559, isEIP7702, formattedTx } = this;
|
|
52536
52717
|
if (formattedTx == null)
|
|
52537
52718
|
throw hdShared.ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
52538
|
-
if (
|
|
52719
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
52539
52720
|
return signTransaction({
|
|
52540
52721
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
52541
52722
|
addressN,
|
|
@@ -52896,28 +53077,24 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
52896
53077
|
const { addressN, data, metamaskV4Compat, chainId } = this.params;
|
|
52897
53078
|
let supportTrezor = false;
|
|
52898
53079
|
let response;
|
|
52899
|
-
|
|
52900
|
-
|
|
52901
|
-
|
|
52902
|
-
|
|
52903
|
-
|
|
52904
|
-
|
|
52905
|
-
|
|
52906
|
-
|
|
52907
|
-
|
|
52908
|
-
|
|
52909
|
-
|
|
52910
|
-
|
|
52911
|
-
|
|
52912
|
-
|
|
52913
|
-
|
|
52914
|
-
|
|
52915
|
-
|
|
52916
|
-
|
|
52917
|
-
metamaskV4Compat,
|
|
52918
|
-
chainId,
|
|
52919
|
-
});
|
|
52920
|
-
break;
|
|
53080
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
53081
|
+
supportTrezor = true;
|
|
53082
|
+
response = yield signTypedData$1({
|
|
53083
|
+
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
53084
|
+
addressN,
|
|
53085
|
+
data,
|
|
53086
|
+
metamaskV4Compat,
|
|
53087
|
+
chainId,
|
|
53088
|
+
});
|
|
53089
|
+
}
|
|
53090
|
+
else {
|
|
53091
|
+
response = yield signTypedData({
|
|
53092
|
+
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
53093
|
+
addressN,
|
|
53094
|
+
data,
|
|
53095
|
+
metamaskV4Compat,
|
|
53096
|
+
chainId,
|
|
53097
|
+
});
|
|
52921
53098
|
}
|
|
52922
53099
|
return this.handleSignTypedData({
|
|
52923
53100
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
@@ -52930,27 +53107,24 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
52930
53107
|
signTypedHash({ typedCall, addressN, chainId, domainHash, messageHash, }) {
|
|
52931
53108
|
if (!domainHash)
|
|
52932
53109
|
throw hdShared.ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
52933
|
-
|
|
52934
|
-
|
|
52935
|
-
|
|
52936
|
-
|
|
52937
|
-
|
|
52938
|
-
|
|
52939
|
-
|
|
52940
|
-
|
|
52941
|
-
|
|
52942
|
-
});
|
|
52943
|
-
case 'v1CurrentSchema':
|
|
52944
|
-
default:
|
|
52945
|
-
return signTypedHash({
|
|
52946
|
-
typedCall,
|
|
52947
|
-
addressN,
|
|
52948
|
-
domainHash,
|
|
52949
|
-
messageHash,
|
|
52950
|
-
chainId,
|
|
52951
|
-
device: this.device,
|
|
52952
|
-
});
|
|
53110
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
53111
|
+
return signTypedHash$1({
|
|
53112
|
+
typedCall,
|
|
53113
|
+
addressN,
|
|
53114
|
+
domainHash,
|
|
53115
|
+
messageHash,
|
|
53116
|
+
chainId,
|
|
53117
|
+
device: this.device,
|
|
53118
|
+
});
|
|
52953
53119
|
}
|
|
53120
|
+
return signTypedHash({
|
|
53121
|
+
typedCall,
|
|
53122
|
+
addressN,
|
|
53123
|
+
domainHash,
|
|
53124
|
+
messageHash,
|
|
53125
|
+
chainId,
|
|
53126
|
+
device: this.device,
|
|
53127
|
+
});
|
|
52954
53128
|
}
|
|
52955
53129
|
getVersionRange() {
|
|
52956
53130
|
return {
|
|
@@ -53207,7 +53381,7 @@ class EVMSignMessage$1 extends BaseMethod {
|
|
|
53207
53381
|
}
|
|
53208
53382
|
run() {
|
|
53209
53383
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53210
|
-
if (
|
|
53384
|
+
if (shouldUseLegacyV1EvmMessages(this.device)) {
|
|
53211
53385
|
return verifyMessageLegacyV1({
|
|
53212
53386
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
53213
53387
|
params: this.params,
|
|
@@ -57431,7 +57605,11 @@ class KaspaSignTransaction extends BaseMethod {
|
|
|
57431
57605
|
});
|
|
57432
57606
|
const outputs = payload.outputs.map(output => {
|
|
57433
57607
|
var _a;
|
|
57608
|
+
const address = getOutputAddress(output);
|
|
57434
57609
|
const addressN = getOutputAddressN(output);
|
|
57610
|
+
if (address !== undefined && addressN !== undefined) {
|
|
57611
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'KaspaSignTransaction: outputs must not contain both address and addressN');
|
|
57612
|
+
}
|
|
57435
57613
|
validateParams(output, [
|
|
57436
57614
|
{ name: 'satoshis', required: true },
|
|
57437
57615
|
{ name: 'address', type: 'string' },
|
|
@@ -57944,7 +58122,7 @@ class NostrSignEvent extends BaseMethod {
|
|
|
57944
58122
|
const addressN = validatePath(payload.path, 5);
|
|
57945
58123
|
this.params = {
|
|
57946
58124
|
address_n: addressN,
|
|
57947
|
-
event: bytesToHex$
|
|
58125
|
+
event: bytesToHex$1(Buffer.from(JSON.stringify(payload.event, null, 0), 'utf-8')),
|
|
57948
58126
|
};
|
|
57949
58127
|
}
|
|
57950
58128
|
getVersionRange() {
|
|
@@ -58135,8 +58313,8 @@ class LnurlAuth1 extends BaseMethod {
|
|
|
58135
58313
|
{ name: 'k1', type: 'string', required: true },
|
|
58136
58314
|
]);
|
|
58137
58315
|
this.params = {
|
|
58138
|
-
domain: bytesToHex$
|
|
58139
|
-
data: bytesToHex$
|
|
58316
|
+
domain: bytesToHex$1(Buffer.from(payload.domain, 'utf-8')),
|
|
58317
|
+
data: bytesToHex$1(Buffer.from(payload.k1, 'hex')),
|
|
58140
58318
|
};
|
|
58141
58319
|
}
|
|
58142
58320
|
getVersionRange() {
|
|
@@ -59732,9 +59910,9 @@ class DeviceConnector {
|
|
|
59732
59910
|
stop() {
|
|
59733
59911
|
this.listening = false;
|
|
59734
59912
|
}
|
|
59735
|
-
acquire(path, session, forceCleanRunPromise,
|
|
59913
|
+
acquire(path, session, forceCleanRunPromise, expectedProtocol, protocolHint) {
|
|
59736
59914
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59737
|
-
Log$3.debug('acquire', path, session,
|
|
59915
|
+
Log$3.debug('acquire', path, session, expectedProtocol, protocolHint);
|
|
59738
59916
|
const env = DataManager.getSettings('env');
|
|
59739
59917
|
try {
|
|
59740
59918
|
let res;
|
|
@@ -59742,20 +59920,22 @@ class DeviceConnector {
|
|
|
59742
59920
|
res = yield this.transport.acquire({
|
|
59743
59921
|
uuid: path,
|
|
59744
59922
|
forceCleanRunPromise,
|
|
59745
|
-
expectedProtocol
|
|
59923
|
+
expectedProtocol,
|
|
59924
|
+
protocolHint,
|
|
59746
59925
|
});
|
|
59747
59926
|
}
|
|
59748
59927
|
else {
|
|
59749
59928
|
res = yield this.transport.acquire({
|
|
59750
59929
|
path,
|
|
59751
59930
|
previous: session !== null && session !== void 0 ? session : null,
|
|
59752
|
-
expectedProtocol
|
|
59931
|
+
expectedProtocol,
|
|
59932
|
+
protocolHint,
|
|
59753
59933
|
});
|
|
59754
59934
|
}
|
|
59755
|
-
if (
|
|
59935
|
+
if (expectedProtocol) {
|
|
59756
59936
|
const detectedProtocol = this.transport.getProtocolType(path);
|
|
59757
|
-
if (detectedProtocol !==
|
|
59758
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${
|
|
59937
|
+
if (detectedProtocol !== expectedProtocol) {
|
|
59938
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expectedProtocol}, detected ${detectedProtocol}`);
|
|
59759
59939
|
}
|
|
59760
59940
|
}
|
|
59761
59941
|
return res;
|
|
@@ -59939,6 +60119,13 @@ const getSynchronize = (mutex) => {
|
|
|
59939
60119
|
return (action, lockId) => lock(lockId).then(unlock => Promise.resolve().then(action).finally(unlock));
|
|
59940
60120
|
};
|
|
59941
60121
|
|
|
60122
|
+
function isDeviceLockedError(error) {
|
|
60123
|
+
return (typeof error === 'object' &&
|
|
60124
|
+
error !== null &&
|
|
60125
|
+
'errorCode' in error &&
|
|
60126
|
+
error.errorCode === hdShared.HardwareErrorCode.DeviceLocked);
|
|
60127
|
+
}
|
|
60128
|
+
|
|
59942
60129
|
const isProtocolV2UiEnabled = (method) => method.protocolV2UiMode !== 'none';
|
|
59943
60130
|
const getDisplayState = (value) => {
|
|
59944
60131
|
const visited = new Set();
|
|
@@ -60073,10 +60260,22 @@ const restoreExpectedWalletSessionAfterUnlock = (method, device) => __awaiter(vo
|
|
|
60073
60260
|
Log$1.debug('Protocol V2 wallet session restored after unlock', { method: method.name });
|
|
60074
60261
|
});
|
|
60075
60262
|
function runMethodWithUnlockRetry(method, device, uiCoordinator) {
|
|
60076
|
-
var _a;
|
|
60263
|
+
var _a, _b, _c, _d, _e;
|
|
60077
60264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60078
60265
|
const shouldEmitUi = isProtocolV2UiEnabled(method);
|
|
60079
|
-
const
|
|
60266
|
+
const isProtocolV2 = device.isProtocolV2();
|
|
60267
|
+
const requiresFreshStatus = isProtocolV2 &&
|
|
60268
|
+
method.unlockPolicy === 'unlock-before-run' &&
|
|
60269
|
+
!((_a = device.isBootloader) === null || _a === void 0 ? void 0 : _a.call(device)) &&
|
|
60270
|
+
!((_b = device.isRomloader) === null || _b === void 0 ? void 0 : _b.call(device));
|
|
60271
|
+
if (requiresFreshStatus) {
|
|
60272
|
+
yield refreshProtocolV2DeviceStatus(device);
|
|
60273
|
+
}
|
|
60274
|
+
const shouldUnlockBeforeRun = isProtocolV2 &&
|
|
60275
|
+
method.unlockPolicy !== 'none' &&
|
|
60276
|
+
!((_c = device.isBootloader) === null || _c === void 0 ? void 0 : _c.call(device)) &&
|
|
60277
|
+
!((_d = device.isRomloader) === null || _d === void 0 ? void 0 : _d.call(device)) &&
|
|
60278
|
+
((_e = device.features) === null || _e === void 0 ? void 0 : _e.unlocked) === false;
|
|
60080
60279
|
if (shouldUnlockBeforeRun) {
|
|
60081
60280
|
if (shouldEmitUi) {
|
|
60082
60281
|
uiCoordinator === null || uiCoordinator === void 0 ? void 0 : uiCoordinator.enterUnlockInteraction(method.name);
|
|
@@ -60096,9 +60295,7 @@ function runMethodWithUnlockRetry(method, device, uiCoordinator) {
|
|
|
60096
60295
|
return yield method.run();
|
|
60097
60296
|
}
|
|
60098
60297
|
catch (error) {
|
|
60099
|
-
if (!
|
|
60100
|
-
method.unlockPolicy !== 'retry-on-locked' ||
|
|
60101
|
-
!isDeviceLockedError(error)) {
|
|
60298
|
+
if (!isProtocolV2 || method.unlockPolicy !== 'retry-on-locked' || !isDeviceLockedError(error)) {
|
|
60102
60299
|
throw error;
|
|
60103
60300
|
}
|
|
60104
60301
|
Log$1.debug('Protocol V2 unlock retry triggered', { method: method.name });
|
|
@@ -61100,10 +61297,10 @@ class Core extends events.exports {
|
|
|
61100
61297
|
}
|
|
61101
61298
|
case IFRAME.CALL: {
|
|
61102
61299
|
const logBlockLabel = getLogBlockLabel(message);
|
|
61103
|
-
Log.log(`[${Date.now()}][CALL_API]`, logBlockLabel
|
|
61300
|
+
Log.log(formatLogMethodLabel(`[${Date.now()}][CALL_API]`, logBlockLabel), getSafeLogPayload(message, logBlockLabel));
|
|
61104
61301
|
const response = yield callAPI(this.getCoreContext(), message);
|
|
61105
61302
|
const { success, payload } = response;
|
|
61106
|
-
Log.log(`[${Date.now()}][CALL_API_RESPONSE]`, logBlockLabel
|
|
61303
|
+
Log.log(formatLogMethodLabel(`[${Date.now()}][CALL_API_RESPONSE]`, logBlockLabel), getSafeLogPayload(response, logBlockLabel));
|
|
61107
61304
|
if (success) {
|
|
61108
61305
|
return response;
|
|
61109
61306
|
}
|
|
@@ -61149,7 +61346,7 @@ class Core extends events.exports {
|
|
|
61149
61346
|
}
|
|
61150
61347
|
_deviceList = undefined;
|
|
61151
61348
|
_connector = undefined;
|
|
61152
|
-
DevicePool.
|
|
61349
|
+
DevicePool.dispose();
|
|
61153
61350
|
deviceCacheMap.clear();
|
|
61154
61351
|
preWarmInflight.clear();
|
|
61155
61352
|
preWarmDoneAt.clear();
|
|
@@ -61297,6 +61494,7 @@ exports["default"] = HardwareSdk;
|
|
|
61297
61494
|
exports.enableLog = enableLog;
|
|
61298
61495
|
exports.encodePro2Wallpaper = encodePro2Wallpaper;
|
|
61299
61496
|
exports.executeCallback = executeCallback;
|
|
61497
|
+
exports.formatLogMethodLabel = formatLogMethodLabel;
|
|
61300
61498
|
exports.formatRequestContext = formatRequestContext;
|
|
61301
61499
|
exports.generateInstanceId = generateInstanceId;
|
|
61302
61500
|
exports.generateSdkInstanceId = generateSdkInstanceId;
|
|
@@ -61329,6 +61527,7 @@ exports.getLogger = getLogger;
|
|
|
61329
61527
|
exports.getMethodVersionRange = getMethodVersionRange;
|
|
61330
61528
|
exports.getOutputScriptType = getOutputScriptType;
|
|
61331
61529
|
exports.getSDKVersion = getSDKVersion;
|
|
61530
|
+
exports.getSafeLogPayload = getSafeLogPayload;
|
|
61332
61531
|
exports.getScriptType = getScriptType;
|
|
61333
61532
|
exports.getTimeStamp = getTimeStamp;
|
|
61334
61533
|
exports.httpRequest = httpRequest;
|