@onekeyfe/hd-core 1.1.27-alpha.30 → 1.1.27-alpha.32
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__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/protocol-v2.test.ts +503 -37
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/DirMake.d.ts.map +1 -1
- package/dist/api/DirRemove.d.ts.map +1 -1
- package/dist/api/FileDelete.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +6 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +7 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +19 -19
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +4 -3
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +3 -3
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.d.ts +37 -27
- package/dist/index.js +385 -236
- package/dist/protocols/protocol-v2/features.d.ts +2 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +7 -7
- package/dist/types/api/getPassphraseState.d.ts +10 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +7 -6
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +16 -16
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +5 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/DirList.ts +6 -2
- package/src/api/DirMake.ts +2 -1
- package/src/api/DirRemove.ts +2 -1
- package/src/api/FileDelete.ts +2 -1
- package/src/api/FileRead.ts +12 -5
- package/src/api/FileWrite.ts +19 -7
- package/src/api/FirmwareUpdateV4.ts +13 -13
- package/src/api/GetPassphraseState.ts +18 -2
- package/src/api/PathInfo.ts +2 -1
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +15 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
- package/src/api/device/DeviceRebootToBootloader.ts +4 -4
- package/src/api/dynex/DnxGetAddress.ts +7 -0
- package/src/api/dynex/DnxSignTransaction.ts +7 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +6 -6
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/helpers/batchGetPublickeys.ts +4 -2
- package/src/api/helpers/filesystemValidation.ts +51 -0
- package/src/api/index.ts +5 -5
- package/src/api/protocol-v2/{DevFirmwareUpdate.ts → DeviceFirmwareUpdate.ts} +5 -4
- package/src/api/protocol-v2/{DevGetDeviceInfo.ts → DeviceGetDeviceInfo.ts} +3 -3
- package/src/api/protocol-v2/{DevGetFirmwareUpdateStatus.ts → DeviceGetFirmwareUpdateStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevGetOnboardingStatus.ts → DeviceGetOnboardingStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevReboot.ts → DeviceReboot.ts} +3 -3
- package/src/api/protocol-v2/helpers.ts +68 -45
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +13 -1
- package/src/data/messages/{messages-pro2.json → messages-protocol-v2.json} +67 -63
- package/src/data-manager/DataManager.ts +9 -8
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +13 -13
- package/src/device/Device.ts +7 -3
- package/src/inject.ts +9 -9
- package/src/protocols/protocol-v2/features.ts +39 -41
- package/src/protocols/protocol-v2/firmware.ts +16 -16
- package/src/types/api/getPassphraseState.ts +15 -2
- package/src/types/api/index.ts +11 -10
- package/src/types/api/protocolV2.ts +27 -27
- package/src/utils/deviceFeaturesUtils.ts +53 -19
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts +0 -7
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts +0 -7
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -138,11 +138,11 @@ const createCoreApi = (call) => ({
|
|
|
138
138
|
deviceRebootToBootloader: connectId => call({ connectId, method: 'deviceRebootToBootloader' }),
|
|
139
139
|
getProtoVersion: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'getProtoVersion' })),
|
|
140
140
|
ping: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'ping' })),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
deviceReboot: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceReboot' })),
|
|
142
|
+
deviceGetDeviceInfo: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetDeviceInfo' })),
|
|
143
|
+
deviceGetOnboardingStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetOnboardingStatus' })),
|
|
144
|
+
deviceFirmwareUpdate: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFirmwareUpdate' })),
|
|
145
|
+
deviceGetFirmwareUpdateStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetFirmwareUpdateStatus' })),
|
|
146
146
|
factoryDeviceInfoSettings: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'factoryDeviceInfoSettings' })),
|
|
147
147
|
factoryGetDeviceInfo: connectId => call({ connectId, method: 'factoryGetDeviceInfo' }),
|
|
148
148
|
filesystemFixPermission: connectId => call({ connectId, method: 'filesystemFixPermission' }),
|
|
@@ -25801,11 +25801,11 @@ var nested = {
|
|
|
25801
25801
|
MessageType_Ping: 60206,
|
|
25802
25802
|
MessageType_Success: 60207,
|
|
25803
25803
|
MessageType_Failure: 60208,
|
|
25804
|
-
|
|
25805
|
-
|
|
25804
|
+
MessageType_DeviceReboot: 60400,
|
|
25805
|
+
MessageType_DeviceGetDeviceInfo: 60600,
|
|
25806
25806
|
MessageType_DeviceInfo: 60601,
|
|
25807
|
-
|
|
25808
|
-
|
|
25807
|
+
MessageType_DeviceGetOnboardingStatus: 60602,
|
|
25808
|
+
MessageType_DeviceOnboardingStatus: 60603,
|
|
25809
25809
|
MessageType_FilesystemFixPermission: 60800,
|
|
25810
25810
|
MessageType_FilesystemPathInfo: 60801,
|
|
25811
25811
|
MessageType_FilesystemPathInfoQuery: 60802,
|
|
@@ -25818,10 +25818,10 @@ var nested = {
|
|
|
25818
25818
|
MessageType_FilesystemDirMake: 60809,
|
|
25819
25819
|
MessageType_FilesystemDirRemove: 60810,
|
|
25820
25820
|
MessageType_FilesystemFormat: 60811,
|
|
25821
|
-
|
|
25822
|
-
|
|
25823
|
-
|
|
25824
|
-
|
|
25821
|
+
MessageType_DeviceFirmwareUpdate: 61000,
|
|
25822
|
+
MessageType_DeviceFirmwareInstallProgress: 61001,
|
|
25823
|
+
MessageType_DeviceGetFirmwareUpdateStatus: 61002,
|
|
25824
|
+
MessageType_DeviceFirmwareUpdateStatus: 61003
|
|
25825
25825
|
}
|
|
25826
25826
|
},
|
|
25827
25827
|
AlephiumGetAddress: {
|
|
@@ -37142,18 +37142,18 @@ var nested = {
|
|
|
37142
37142
|
}
|
|
37143
37143
|
}
|
|
37144
37144
|
},
|
|
37145
|
-
|
|
37145
|
+
DeviceRebootType: {
|
|
37146
37146
|
values: {
|
|
37147
37147
|
Normal: 0,
|
|
37148
37148
|
Boardloader: 1,
|
|
37149
37149
|
Bootloader: 2
|
|
37150
37150
|
}
|
|
37151
37151
|
},
|
|
37152
|
-
|
|
37152
|
+
DeviceReboot: {
|
|
37153
37153
|
fields: {
|
|
37154
37154
|
reboot_type: {
|
|
37155
37155
|
rule: "required",
|
|
37156
|
-
type: "
|
|
37156
|
+
type: "DeviceRebootType",
|
|
37157
37157
|
id: 1
|
|
37158
37158
|
}
|
|
37159
37159
|
}
|
|
@@ -37168,20 +37168,20 @@ var nested = {
|
|
|
37168
37168
|
CLASSIC1S_PURE: 6
|
|
37169
37169
|
}
|
|
37170
37170
|
},
|
|
37171
|
-
|
|
37171
|
+
DeviceSeType: {
|
|
37172
37172
|
values: {
|
|
37173
37173
|
THD89: 0,
|
|
37174
37174
|
SE608A: 1
|
|
37175
37175
|
}
|
|
37176
37176
|
},
|
|
37177
|
-
|
|
37177
|
+
DeviceSEState: {
|
|
37178
37178
|
values: {
|
|
37179
37179
|
BOOT: 0,
|
|
37180
37180
|
APP_FACTORY: 51,
|
|
37181
37181
|
APP: 85
|
|
37182
37182
|
}
|
|
37183
37183
|
},
|
|
37184
|
-
|
|
37184
|
+
DeviceFirmwareImageInfo: {
|
|
37185
37185
|
fields: {
|
|
37186
37186
|
version: {
|
|
37187
37187
|
type: "string",
|
|
@@ -37197,9 +37197,9 @@ var nested = {
|
|
|
37197
37197
|
}
|
|
37198
37198
|
}
|
|
37199
37199
|
},
|
|
37200
|
-
|
|
37200
|
+
DeviceHardwareInfo: {
|
|
37201
37201
|
fields: {
|
|
37202
|
-
|
|
37202
|
+
Device_type: {
|
|
37203
37203
|
type: "DeviceType",
|
|
37204
37204
|
id: 10
|
|
37205
37205
|
},
|
|
@@ -37217,30 +37217,30 @@ var nested = {
|
|
|
37217
37217
|
}
|
|
37218
37218
|
}
|
|
37219
37219
|
},
|
|
37220
|
-
|
|
37220
|
+
DeviceMainMcuInfo: {
|
|
37221
37221
|
fields: {
|
|
37222
37222
|
board: {
|
|
37223
|
-
type: "
|
|
37223
|
+
type: "DeviceFirmwareImageInfo",
|
|
37224
37224
|
id: 10
|
|
37225
37225
|
},
|
|
37226
37226
|
boot: {
|
|
37227
|
-
type: "
|
|
37227
|
+
type: "DeviceFirmwareImageInfo",
|
|
37228
37228
|
id: 20
|
|
37229
37229
|
},
|
|
37230
37230
|
app: {
|
|
37231
|
-
type: "
|
|
37231
|
+
type: "DeviceFirmwareImageInfo",
|
|
37232
37232
|
id: 30
|
|
37233
37233
|
}
|
|
37234
37234
|
}
|
|
37235
37235
|
},
|
|
37236
|
-
|
|
37236
|
+
DeviceBluetoothInfo: {
|
|
37237
37237
|
fields: {
|
|
37238
37238
|
boot: {
|
|
37239
|
-
type: "
|
|
37239
|
+
type: "DeviceFirmwareImageInfo",
|
|
37240
37240
|
id: 20
|
|
37241
37241
|
},
|
|
37242
37242
|
app: {
|
|
37243
|
-
type: "
|
|
37243
|
+
type: "DeviceFirmwareImageInfo",
|
|
37244
37244
|
id: 30
|
|
37245
37245
|
},
|
|
37246
37246
|
adv_name: {
|
|
@@ -37253,27 +37253,27 @@ var nested = {
|
|
|
37253
37253
|
}
|
|
37254
37254
|
}
|
|
37255
37255
|
},
|
|
37256
|
-
|
|
37256
|
+
DeviceSEInfo: {
|
|
37257
37257
|
fields: {
|
|
37258
37258
|
boot: {
|
|
37259
|
-
type: "
|
|
37259
|
+
type: "DeviceFirmwareImageInfo",
|
|
37260
37260
|
id: 20
|
|
37261
37261
|
},
|
|
37262
37262
|
app: {
|
|
37263
|
-
type: "
|
|
37263
|
+
type: "DeviceFirmwareImageInfo",
|
|
37264
37264
|
id: 30
|
|
37265
37265
|
},
|
|
37266
37266
|
type: {
|
|
37267
|
-
type: "
|
|
37267
|
+
type: "DeviceSeType",
|
|
37268
37268
|
id: 100
|
|
37269
37269
|
},
|
|
37270
37270
|
state: {
|
|
37271
|
-
type: "
|
|
37271
|
+
type: "DeviceSEState",
|
|
37272
37272
|
id: 110
|
|
37273
37273
|
}
|
|
37274
37274
|
}
|
|
37275
37275
|
},
|
|
37276
|
-
|
|
37276
|
+
DeviceInfoTargets: {
|
|
37277
37277
|
fields: {
|
|
37278
37278
|
hw: {
|
|
37279
37279
|
type: "bool",
|
|
@@ -37309,7 +37309,7 @@ var nested = {
|
|
|
37309
37309
|
}
|
|
37310
37310
|
}
|
|
37311
37311
|
},
|
|
37312
|
-
|
|
37312
|
+
DeviceInfoTypes: {
|
|
37313
37313
|
fields: {
|
|
37314
37314
|
version: {
|
|
37315
37315
|
type: "bool",
|
|
@@ -37329,7 +37329,7 @@ var nested = {
|
|
|
37329
37329
|
}
|
|
37330
37330
|
}
|
|
37331
37331
|
},
|
|
37332
|
-
|
|
37332
|
+
DeviceStatus: {
|
|
37333
37333
|
fields: {
|
|
37334
37334
|
language: {
|
|
37335
37335
|
type: "string",
|
|
@@ -37357,14 +37357,14 @@ var nested = {
|
|
|
37357
37357
|
}
|
|
37358
37358
|
}
|
|
37359
37359
|
},
|
|
37360
|
-
|
|
37360
|
+
DeviceGetDeviceInfo: {
|
|
37361
37361
|
fields: {
|
|
37362
37362
|
targets: {
|
|
37363
|
-
type: "
|
|
37363
|
+
type: "DeviceInfoTargets",
|
|
37364
37364
|
id: 1
|
|
37365
37365
|
},
|
|
37366
37366
|
types: {
|
|
37367
|
-
type: "
|
|
37367
|
+
type: "DeviceInfoTypes",
|
|
37368
37368
|
id: 2
|
|
37369
37369
|
}
|
|
37370
37370
|
}
|
|
@@ -37377,56 +37377,56 @@ var nested = {
|
|
|
37377
37377
|
id: 1
|
|
37378
37378
|
},
|
|
37379
37379
|
hw: {
|
|
37380
|
-
type: "
|
|
37380
|
+
type: "DeviceHardwareInfo",
|
|
37381
37381
|
id: 100
|
|
37382
37382
|
},
|
|
37383
37383
|
fw: {
|
|
37384
|
-
type: "
|
|
37384
|
+
type: "DeviceMainMcuInfo",
|
|
37385
37385
|
id: 200
|
|
37386
37386
|
},
|
|
37387
37387
|
bt: {
|
|
37388
|
-
type: "
|
|
37388
|
+
type: "DeviceBluetoothInfo",
|
|
37389
37389
|
id: 300
|
|
37390
37390
|
},
|
|
37391
37391
|
se1: {
|
|
37392
|
-
type: "
|
|
37392
|
+
type: "DeviceSEInfo",
|
|
37393
37393
|
id: 400
|
|
37394
37394
|
},
|
|
37395
37395
|
se2: {
|
|
37396
|
-
type: "
|
|
37396
|
+
type: "DeviceSEInfo",
|
|
37397
37397
|
id: 410
|
|
37398
37398
|
},
|
|
37399
37399
|
se3: {
|
|
37400
|
-
type: "
|
|
37400
|
+
type: "DeviceSEInfo",
|
|
37401
37401
|
id: 420
|
|
37402
37402
|
},
|
|
37403
37403
|
se4: {
|
|
37404
|
-
type: "
|
|
37404
|
+
type: "DeviceSEInfo",
|
|
37405
37405
|
id: 430
|
|
37406
37406
|
},
|
|
37407
37407
|
status: {
|
|
37408
|
-
type: "
|
|
37408
|
+
type: "DeviceStatus",
|
|
37409
37409
|
id: 10000
|
|
37410
37410
|
}
|
|
37411
37411
|
}
|
|
37412
37412
|
},
|
|
37413
|
-
|
|
37413
|
+
DeviceFirmwareTargetType: {
|
|
37414
37414
|
values: {
|
|
37415
|
-
|
|
37416
|
-
|
|
37417
|
-
|
|
37418
|
-
|
|
37419
|
-
|
|
37420
|
-
|
|
37421
|
-
|
|
37415
|
+
TARGET_INVALID: 0,
|
|
37416
|
+
TARGET_ROMLOADER: 1,
|
|
37417
|
+
TARGET_BOOTLOADER: 2,
|
|
37418
|
+
TARGET_FIRMWARE_P1: 3,
|
|
37419
|
+
TARGET_FIRMWARE_P2: 4,
|
|
37420
|
+
TARGET_COPROCESSOR: 5,
|
|
37421
|
+
TARGET_SE: 6,
|
|
37422
37422
|
TARGET_RESOURCE: 10
|
|
37423
37423
|
}
|
|
37424
37424
|
},
|
|
37425
|
-
|
|
37425
|
+
DeviceFirmwareTarget: {
|
|
37426
37426
|
fields: {
|
|
37427
37427
|
target_id: {
|
|
37428
37428
|
rule: "required",
|
|
37429
|
-
type: "
|
|
37429
|
+
type: "DeviceFirmwareTargetType",
|
|
37430
37430
|
id: 1
|
|
37431
37431
|
},
|
|
37432
37432
|
path: {
|
|
@@ -37436,20 +37436,24 @@ var nested = {
|
|
|
37436
37436
|
}
|
|
37437
37437
|
}
|
|
37438
37438
|
},
|
|
37439
|
-
|
|
37439
|
+
DeviceFirmwareUpdate: {
|
|
37440
37440
|
fields: {
|
|
37441
37441
|
targets: {
|
|
37442
37442
|
rule: "repeated",
|
|
37443
|
-
type: "
|
|
37443
|
+
type: "DeviceFirmwareTarget",
|
|
37444
37444
|
id: 1
|
|
37445
|
+
},
|
|
37446
|
+
max_concurrent: {
|
|
37447
|
+
type: "uint32",
|
|
37448
|
+
id: 2
|
|
37445
37449
|
}
|
|
37446
37450
|
}
|
|
37447
37451
|
},
|
|
37448
|
-
|
|
37452
|
+
DeviceFirmwareInstallProgress: {
|
|
37449
37453
|
fields: {
|
|
37450
37454
|
target_id: {
|
|
37451
37455
|
rule: "required",
|
|
37452
|
-
type: "
|
|
37456
|
+
type: "DeviceFirmwareTargetType",
|
|
37453
37457
|
id: 1
|
|
37454
37458
|
},
|
|
37455
37459
|
progress: {
|
|
@@ -37463,11 +37467,11 @@ var nested = {
|
|
|
37463
37467
|
}
|
|
37464
37468
|
}
|
|
37465
37469
|
},
|
|
37466
|
-
|
|
37470
|
+
DeviceFirmwareUpdateStatusEntry: {
|
|
37467
37471
|
fields: {
|
|
37468
37472
|
target_id: {
|
|
37469
37473
|
rule: "required",
|
|
37470
|
-
type: "
|
|
37474
|
+
type: "DeviceFirmwareTargetType",
|
|
37471
37475
|
id: 1
|
|
37472
37476
|
},
|
|
37473
37477
|
status: {
|
|
@@ -37477,15 +37481,15 @@ var nested = {
|
|
|
37477
37481
|
}
|
|
37478
37482
|
}
|
|
37479
37483
|
},
|
|
37480
|
-
|
|
37484
|
+
DeviceGetFirmwareUpdateStatus: {
|
|
37481
37485
|
fields: {
|
|
37482
37486
|
}
|
|
37483
37487
|
},
|
|
37484
|
-
|
|
37488
|
+
DeviceFirmwareUpdateStatus: {
|
|
37485
37489
|
fields: {
|
|
37486
37490
|
targets: {
|
|
37487
37491
|
rule: "repeated",
|
|
37488
|
-
type: "
|
|
37492
|
+
type: "DeviceFirmwareUpdateStatusEntry",
|
|
37489
37493
|
id: 1
|
|
37490
37494
|
}
|
|
37491
37495
|
}
|
|
@@ -37755,11 +37759,11 @@ var nested = {
|
|
|
37755
37759
|
fields: {
|
|
37756
37760
|
}
|
|
37757
37761
|
},
|
|
37758
|
-
|
|
37762
|
+
DeviceGetOnboardingStatus: {
|
|
37759
37763
|
fields: {
|
|
37760
37764
|
}
|
|
37761
37765
|
},
|
|
37762
|
-
|
|
37766
|
+
DeviceOnboardingStatus: {
|
|
37763
37767
|
fields: {
|
|
37764
37768
|
page_index: {
|
|
37765
37769
|
type: "uint32",
|
|
@@ -38511,7 +38515,7 @@ var nested = {
|
|
|
38511
38515
|
}
|
|
38512
38516
|
}
|
|
38513
38517
|
};
|
|
38514
|
-
var
|
|
38518
|
+
var MessagesProtocolV2JSON = {
|
|
38515
38519
|
nested: nested
|
|
38516
38520
|
};
|
|
38517
38521
|
|
|
@@ -38666,8 +38670,8 @@ class DataManager {
|
|
|
38666
38670
|
}
|
|
38667
38671
|
});
|
|
38668
38672
|
}
|
|
38669
|
-
static getProtobufMessages(
|
|
38670
|
-
return this.messages[
|
|
38673
|
+
static getProtobufMessages(schema = 'v1CurrentSchema') {
|
|
38674
|
+
return this.messages[schema];
|
|
38671
38675
|
}
|
|
38672
38676
|
static getSettings(key) {
|
|
38673
38677
|
if (!this.settings)
|
|
@@ -38707,9 +38711,9 @@ DataManager.deviceMap = {
|
|
|
38707
38711
|
};
|
|
38708
38712
|
DataManager.assets = null;
|
|
38709
38713
|
DataManager.messages = {
|
|
38710
|
-
|
|
38711
|
-
|
|
38712
|
-
|
|
38714
|
+
v1CurrentSchema: MessagesJSON,
|
|
38715
|
+
v1LegacySchema: MessagesLegacyV1JSON,
|
|
38716
|
+
v2Schema: MessagesProtocolV2JSON,
|
|
38713
38717
|
};
|
|
38714
38718
|
DataManager.lastCheckTimestamp = 0;
|
|
38715
38719
|
DataManager.getFirmwareStatus = (features, firmwareType) => {
|
|
@@ -38908,23 +38912,23 @@ DataManager.isBrowserWebUsb = (env) => env === 'webusb';
|
|
|
38908
38912
|
|
|
38909
38913
|
const PROTOBUF_MESSAGE_CONFIG = {
|
|
38910
38914
|
model_mini: [
|
|
38911
|
-
{ minVersion: '3.3.0',
|
|
38912
|
-
{ minVersion: '0.0.1',
|
|
38913
|
-
{ minVersion: '0.0.0',
|
|
38915
|
+
{ minVersion: '3.3.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38916
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
|
|
38917
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38914
38918
|
],
|
|
38915
38919
|
model_touch: [
|
|
38916
|
-
{ minVersion: '4.5.0',
|
|
38917
|
-
{ minVersion: '0.0.1',
|
|
38918
|
-
{ minVersion: '0.0.0',
|
|
38920
|
+
{ minVersion: '4.5.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38921
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
|
|
38922
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38919
38923
|
],
|
|
38920
38924
|
};
|
|
38921
38925
|
|
|
38922
|
-
const
|
|
38926
|
+
const getSupportProtocolV1MessageSchema = (features) => {
|
|
38923
38927
|
var _a;
|
|
38924
38928
|
if (!features)
|
|
38925
38929
|
return {
|
|
38926
|
-
messages: DataManager.messages.
|
|
38927
|
-
|
|
38930
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
38931
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
38928
38932
|
};
|
|
38929
38933
|
const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
|
|
38930
38934
|
const deviceType = getDeviceType(features);
|
|
@@ -38934,17 +38938,17 @@ const getSupportMessageVersion = (features) => {
|
|
|
38934
38938
|
.map(model => PROTOBUF_MESSAGE_CONFIG[model])
|
|
38935
38939
|
.find(range => range !== undefined));
|
|
38936
38940
|
const sortedDeviceVersionConfigs = (_a = deviceVersionConfigs === null || deviceVersionConfigs === void 0 ? void 0 : deviceVersionConfigs.sort((a, b) => semver__default["default"].compare(b.minVersion, a.minVersion))) !== null && _a !== void 0 ? _a : [];
|
|
38937
|
-
for (const { minVersion,
|
|
38941
|
+
for (const { minVersion, protocolV1MessageSchema } of sortedDeviceVersionConfigs) {
|
|
38938
38942
|
if (semver__default["default"].gte(currentDeviceVersion, minVersion)) {
|
|
38939
38943
|
return {
|
|
38940
|
-
messages: DataManager.messages[
|
|
38941
|
-
|
|
38944
|
+
messages: DataManager.messages[protocolV1MessageSchema],
|
|
38945
|
+
protocolV1MessageSchema,
|
|
38942
38946
|
};
|
|
38943
38947
|
}
|
|
38944
38948
|
}
|
|
38945
38949
|
return {
|
|
38946
|
-
messages: DataManager.messages.
|
|
38947
|
-
|
|
38950
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
38951
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
38948
38952
|
};
|
|
38949
38953
|
};
|
|
38950
38954
|
const supportInputPinOnSoftware = (features) => {
|
|
@@ -38961,7 +38965,9 @@ const supportNewPassphrase = (features) => {
|
|
|
38961
38965
|
if (!features)
|
|
38962
38966
|
return { support: false };
|
|
38963
38967
|
const deviceType = getDeviceType(features);
|
|
38964
|
-
if (deviceType === hdShared.EDeviceType.Touch ||
|
|
38968
|
+
if (deviceType === hdShared.EDeviceType.Touch ||
|
|
38969
|
+
deviceType === hdShared.EDeviceType.Pro ||
|
|
38970
|
+
deviceType === hdShared.EDeviceType.Pro2) {
|
|
38965
38971
|
return { support: true };
|
|
38966
38972
|
}
|
|
38967
38973
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
@@ -38971,15 +38977,25 @@ const getPassphraseStateWithRefreshDeviceInfo = (device, options) => __awaiter(v
|
|
|
38971
38977
|
var _a, _b, _c, _d, _e;
|
|
38972
38978
|
const { features, commands } = device;
|
|
38973
38979
|
const locked = (features === null || features === void 0 ? void 0 : features.unlocked) === false;
|
|
38980
|
+
const deviceType = getDeviceType(features);
|
|
38981
|
+
const isPro2 = deviceType === hdShared.EDeviceType.Pro2;
|
|
38974
38982
|
const { passphraseState, newSession, unlockedAttachPin } = yield getPassphraseState(features, commands, Object.assign({}, options));
|
|
38975
|
-
const isModeT =
|
|
38976
|
-
const needRefreshWithPassphrase = passphraseState && (features === null || features === void 0 ? void 0 : features.passphrase_protection) !== true;
|
|
38983
|
+
const isModeT = deviceType === hdShared.EDeviceType.Touch || deviceType === hdShared.EDeviceType.Pro;
|
|
38984
|
+
const needRefreshWithPassphrase = !isPro2 && passphraseState && (features === null || features === void 0 ? void 0 : features.passphrase_protection) !== true;
|
|
38977
38985
|
const needRefreshWithLocked = isModeT && locked;
|
|
38978
38986
|
if (needRefreshWithLocked || needRefreshWithPassphrase) {
|
|
38979
38987
|
yield device.getFeatures();
|
|
38980
38988
|
}
|
|
38989
|
+
if (isPro2 && device.features) {
|
|
38990
|
+
if (passphraseState) {
|
|
38991
|
+
device.features.passphrase_protection = true;
|
|
38992
|
+
}
|
|
38993
|
+
if (newSession) {
|
|
38994
|
+
device.features.session_id = newSession;
|
|
38995
|
+
}
|
|
38996
|
+
}
|
|
38981
38997
|
if (features === null || features === void 0 ? void 0 : features.device_id) {
|
|
38982
|
-
device.updateInternalState((_b = (_a = device.features) === null || _a === void 0 ? void 0 : _a.passphrase_protection) !== null && _b !== void 0 ? _b : false, passphraseState, (_d = (_c = device.features) === null || _c === void 0 ? void 0 : _c.device_id) !== null && _d !== void 0 ? _d : '', newSession, (_e = device.features) === null || _e === void 0 ? void 0 : _e.session_id);
|
|
38998
|
+
device.updateInternalState(((_b = (_a = device.features) === null || _a === void 0 ? void 0 : _a.passphrase_protection) !== null && _b !== void 0 ? _b : false) || isPro2, passphraseState, (_d = (_c = device.features) === null || _c === void 0 ? void 0 : _c.device_id) !== null && _d !== void 0 ? _d : '', newSession, (_e = device.features) === null || _e === void 0 ? void 0 : _e.session_id);
|
|
38983
38999
|
}
|
|
38984
39000
|
return { passphraseState, newSession, unlockedAttachPin };
|
|
38985
39001
|
});
|
|
@@ -38990,11 +39006,16 @@ const getPassphraseState = (features, commands, options) => __awaiter(void 0, vo
|
|
|
38990
39006
|
const deviceType = getDeviceType(features);
|
|
38991
39007
|
const supportAttachPinCapability = existCapability(features, hdTransport.Enum_Capability.Capability_AttachToPin);
|
|
38992
39008
|
const supportGetPassphraseState = supportAttachPinCapability ||
|
|
39009
|
+
deviceType === hdShared.EDeviceType.Pro2 ||
|
|
38993
39010
|
(deviceType === hdShared.EDeviceType.Pro && semver__default["default"].gte(firmwareVersion.join('.'), '4.15.0'));
|
|
38994
39011
|
if (supportGetPassphraseState) {
|
|
38995
|
-
const
|
|
38996
|
-
|
|
38997
|
-
|
|
39012
|
+
const payload = (options === null || options === void 0 ? void 0 : options.onlyMainPin)
|
|
39013
|
+
? { _only_main_pin: true }
|
|
39014
|
+
: { passphrase_state: options === null || options === void 0 ? void 0 : options.expectPassphraseState };
|
|
39015
|
+
if (options === null || options === void 0 ? void 0 : options.allowCreateAttachPin) {
|
|
39016
|
+
payload.allow_create_attach_pin = true;
|
|
39017
|
+
}
|
|
39018
|
+
const { message, type } = yield commands.typedCall('GetPassphraseState', 'PassphraseState', payload);
|
|
38998
39019
|
if (type === 'CallMethodError') {
|
|
38999
39020
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
39000
39021
|
}
|
|
@@ -40135,7 +40156,7 @@ class TransportManager {
|
|
|
40135
40156
|
Log$d.debug('transport manager load');
|
|
40136
40157
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
40137
40158
|
this.currentMessages = this.defaultMessages;
|
|
40138
|
-
this.
|
|
40159
|
+
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
40139
40160
|
}
|
|
40140
40161
|
static configure() {
|
|
40141
40162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40172,7 +40193,7 @@ class TransportManager {
|
|
|
40172
40193
|
Log$d.debug('Configuring transports');
|
|
40173
40194
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
40174
40195
|
this.currentMessages = this.defaultMessages;
|
|
40175
|
-
this.
|
|
40196
|
+
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
40176
40197
|
yield this.configureProtocolV2Messages();
|
|
40177
40198
|
Log$d.debug('Configuring transports done');
|
|
40178
40199
|
}
|
|
@@ -40189,15 +40210,15 @@ class TransportManager {
|
|
|
40189
40210
|
if (!features) {
|
|
40190
40211
|
return;
|
|
40191
40212
|
}
|
|
40192
|
-
const {
|
|
40213
|
+
const { protocolV1MessageSchema, messages } = getSupportProtocolV1MessageSchema(features);
|
|
40193
40214
|
if (this.currentMessages === messages || !messages) {
|
|
40194
40215
|
return;
|
|
40195
40216
|
}
|
|
40196
|
-
Log$d.debug(`Reconfiguring transports
|
|
40217
|
+
Log$d.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
|
|
40197
40218
|
try {
|
|
40198
40219
|
yield this.transport.configure(JSON.stringify(messages));
|
|
40199
40220
|
this.currentMessages = messages;
|
|
40200
|
-
this.
|
|
40221
|
+
this.protocolV1MessageSchema = protocolV1MessageSchema;
|
|
40201
40222
|
}
|
|
40202
40223
|
catch (error) {
|
|
40203
40224
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportInvalidProtobuf, `Transport_InvalidProtobuf: ${error.message}`);
|
|
@@ -40225,7 +40246,7 @@ class TransportManager {
|
|
|
40225
40246
|
}
|
|
40226
40247
|
static configureProtocolV2Messages() {
|
|
40227
40248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40228
|
-
const protocolV2Messages = DataManager.getProtobufMessages('
|
|
40249
|
+
const protocolV2Messages = DataManager.getProtobufMessages('v2Schema');
|
|
40229
40250
|
const { configureProtocolV2 } = this.transport;
|
|
40230
40251
|
if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
|
|
40231
40252
|
yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
|
|
@@ -40239,12 +40260,12 @@ class TransportManager {
|
|
|
40239
40260
|
static getCurrentMessages() {
|
|
40240
40261
|
return this.currentMessages;
|
|
40241
40262
|
}
|
|
40242
|
-
static
|
|
40243
|
-
return this.
|
|
40263
|
+
static getProtocolV1MessageSchema() {
|
|
40264
|
+
return this.protocolV1MessageSchema;
|
|
40244
40265
|
}
|
|
40245
40266
|
}
|
|
40246
40267
|
TransportManager.reactNativeInit = false;
|
|
40247
|
-
TransportManager.
|
|
40268
|
+
TransportManager.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
40248
40269
|
TransportManager.plugin = null;
|
|
40249
40270
|
|
|
40250
40271
|
const MAX_DEBUG_ARRAY_ITEMS = 20;
|
|
@@ -40802,6 +40823,24 @@ class DeviceCommands {
|
|
|
40802
40823
|
}
|
|
40803
40824
|
}
|
|
40804
40825
|
|
|
40826
|
+
const PROTOCOL_V2_DEVICE_INFO_REQUEST = {
|
|
40827
|
+
targets: {
|
|
40828
|
+
hw: true,
|
|
40829
|
+
fw: true,
|
|
40830
|
+
bt: true,
|
|
40831
|
+
se1: true,
|
|
40832
|
+
se2: true,
|
|
40833
|
+
se3: true,
|
|
40834
|
+
se4: true,
|
|
40835
|
+
status: true,
|
|
40836
|
+
},
|
|
40837
|
+
types: {
|
|
40838
|
+
version: true,
|
|
40839
|
+
build_id: true,
|
|
40840
|
+
hash: true,
|
|
40841
|
+
specific: true,
|
|
40842
|
+
},
|
|
40843
|
+
};
|
|
40805
40844
|
function parseVersion(version) {
|
|
40806
40845
|
if (!version)
|
|
40807
40846
|
return [0, 0, 0];
|
|
@@ -40857,7 +40896,7 @@ function createBaseFeatures(descriptor) {
|
|
|
40857
40896
|
bootloader_mode: false,
|
|
40858
40897
|
device_id: descriptorId,
|
|
40859
40898
|
pin_protection: null,
|
|
40860
|
-
passphrase_protection:
|
|
40899
|
+
passphrase_protection: null,
|
|
40861
40900
|
language: null,
|
|
40862
40901
|
label: null,
|
|
40863
40902
|
initialized: false,
|
|
@@ -40902,7 +40941,7 @@ function normalizeProtocolV2Features(descriptor, deviceInfo) {
|
|
|
40902
40941
|
const [fwMajor, fwMinor, fwPatch] = parseVersion(firmwareVersion);
|
|
40903
40942
|
return Object.assign(Object.assign({}, features), { major_version: fwMajor, minor_version: fwMinor, patch_version: fwPatch, fw_major: fwMajor, fw_minor: fwMinor, fw_patch: fwPatch, device_id: serialNo, serial_no: serialNo, onekey_serial_no: serialNo, label: (_d = (_c = deviceInfo.status) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : features.label, language: (_f = (_e = deviceInfo.status) === null || _e === void 0 ? void 0 : _e.language) !== null && _f !== void 0 ? _f : features.language, initialized: (_h = (_g = deviceInfo.status) === null || _g === void 0 ? void 0 : _g.init_states) !== null && _h !== void 0 ? _h : features.initialized, passphrase_protection: (_k = (_j = deviceInfo.status) === null || _j === void 0 ? void 0 : _j.passphrase_protection) !== null && _k !== void 0 ? _k : features.passphrase_protection, needs_backup: (_m = (_l = deviceInfo.status) === null || _l === void 0 ? void 0 : _l.backup_required) !== null && _m !== void 0 ? _m : features.needs_backup, ble_enable: (_o = deviceInfo.status) === null || _o === void 0 ? void 0 : _o.bt_enable, onekey_ble_name: (_p = deviceInfo.bt) === null || _p === void 0 ? void 0 : _p.adv_name, ble_name: (_q = deviceInfo.bt) === null || _q === void 0 ? void 0 : _q.adv_name, onekey_firmware_version: firmwareVersion, onekey_firmware_build_id: getImageBuildId((_r = deviceInfo.fw) === null || _r === void 0 ? void 0 : _r.app), onekey_firmware_hash: getImageHash((_s = deviceInfo.fw) === null || _s === void 0 ? void 0 : _s.app), onekey_boot_version: getImageVersion((_t = deviceInfo.fw) === null || _t === void 0 ? void 0 : _t.boot), bootloader_version: getImageVersion((_u = deviceInfo.fw) === null || _u === void 0 ? void 0 : _u.boot), onekey_boot_build_id: getImageBuildId((_v = deviceInfo.fw) === null || _v === void 0 ? void 0 : _v.boot), onekey_boot_hash: getImageHash((_w = deviceInfo.fw) === null || _w === void 0 ? void 0 : _w.boot), onekey_board_version: getImageVersion((_x = deviceInfo.fw) === null || _x === void 0 ? void 0 : _x.board), onekey_board_hash: getImageHash((_y = deviceInfo.fw) === null || _y === void 0 ? void 0 : _y.board), onekey_ble_version: getImageVersion((_z = deviceInfo.bt) === null || _z === void 0 ? void 0 : _z.app), ble_ver: getImageVersion((_0 = deviceInfo.bt) === null || _0 === void 0 ? void 0 : _0.app), onekey_ble_build_id: getImageBuildId((_1 = deviceInfo.bt) === null || _1 === void 0 ? void 0 : _1.app), onekey_ble_hash: getImageHash((_2 = deviceInfo.bt) === null || _2 === void 0 ? void 0 : _2.app), onekey_se01_version: getImageVersion((_3 = deviceInfo.se1) === null || _3 === void 0 ? void 0 : _3.app), onekey_se01_hash: getImageHash((_4 = deviceInfo.se1) === null || _4 === void 0 ? void 0 : _4.app), onekey_se01_build_id: getImageBuildId((_5 = deviceInfo.se1) === null || _5 === void 0 ? void 0 : _5.app), onekey_se01_state: getSeState(deviceInfo.se1), onekey_se02_version: getImageVersion((_6 = deviceInfo.se2) === null || _6 === void 0 ? void 0 : _6.app), onekey_se02_state: getSeState(deviceInfo.se2), onekey_se03_version: getImageVersion((_7 = deviceInfo.se3) === null || _7 === void 0 ? void 0 : _7.app), onekey_se03_state: getSeState(deviceInfo.se3), onekey_se04_version: getImageVersion((_8 = deviceInfo.se4) === null || _8 === void 0 ? void 0 : _8.app), onekey_se04_state: getSeState(deviceInfo.se4) });
|
|
40904
40943
|
}
|
|
40905
|
-
function getProtocolV2Features({ commands, descriptor, timeoutMs, }) {
|
|
40944
|
+
function getProtocolV2Features({ commands, descriptor, onDeviceInfoError, timeoutMs, }) {
|
|
40906
40945
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40907
40946
|
const callOptions = timeoutMs ? { timeoutMs } : undefined;
|
|
40908
40947
|
if (callOptions) {
|
|
@@ -40911,34 +40950,42 @@ function getProtocolV2Features({ commands, descriptor, timeoutMs, }) {
|
|
|
40911
40950
|
else {
|
|
40912
40951
|
yield commands.typedCall('Ping', 'Success', { message: 'init' });
|
|
40913
40952
|
}
|
|
40914
|
-
|
|
40953
|
+
try {
|
|
40954
|
+
const { message } = callOptions
|
|
40955
|
+
? yield commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', PROTOCOL_V2_DEVICE_INFO_REQUEST, callOptions)
|
|
40956
|
+
: yield commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', PROTOCOL_V2_DEVICE_INFO_REQUEST);
|
|
40957
|
+
return normalizeProtocolV2Features(descriptor, message);
|
|
40958
|
+
}
|
|
40959
|
+
catch (error) {
|
|
40960
|
+
onDeviceInfoError === null || onDeviceInfoError === void 0 ? void 0 : onDeviceInfoError(error);
|
|
40961
|
+
return normalizeProtocolV2Features(descriptor);
|
|
40962
|
+
}
|
|
40915
40963
|
});
|
|
40916
40964
|
}
|
|
40917
40965
|
|
|
40918
40966
|
const ProtocolV2FirmwareTargetType = {
|
|
40919
|
-
|
|
40920
|
-
|
|
40921
|
-
|
|
40922
|
-
|
|
40923
|
-
|
|
40924
|
-
|
|
40925
|
-
|
|
40967
|
+
TARGET_INVALID: 0,
|
|
40968
|
+
TARGET_ROMLOADER: 1,
|
|
40969
|
+
TARGET_BOOTLOADER: 2,
|
|
40970
|
+
TARGET_FIRMWARE_P1: 3,
|
|
40971
|
+
TARGET_FIRMWARE_P2: 4,
|
|
40972
|
+
TARGET_COPROCESSOR: 5,
|
|
40973
|
+
TARGET_SE: 6,
|
|
40926
40974
|
TARGET_RESOURCE: 10,
|
|
40927
40975
|
};
|
|
40928
40976
|
function protocolV2FileNameToTargetId(fileName) {
|
|
40929
|
-
|
|
40930
|
-
|
|
40931
|
-
|
|
40932
|
-
|
|
40933
|
-
|
|
40934
|
-
|
|
40935
|
-
|
|
40936
|
-
|
|
40937
|
-
|
|
40938
|
-
|
|
40939
|
-
|
|
40940
|
-
|
|
40941
|
-
return ProtocolV2FirmwareTargetType.TARGET_MAIN_APP;
|
|
40977
|
+
const normalized = fileName.toLowerCase();
|
|
40978
|
+
if (normalized.includes('romloader'))
|
|
40979
|
+
return ProtocolV2FirmwareTargetType.TARGET_ROMLOADER;
|
|
40980
|
+
if (normalized.includes('bootloader'))
|
|
40981
|
+
return ProtocolV2FirmwareTargetType.TARGET_BOOTLOADER;
|
|
40982
|
+
if (normalized.includes('ble'))
|
|
40983
|
+
return ProtocolV2FirmwareTargetType.TARGET_COPROCESSOR;
|
|
40984
|
+
if (normalized.includes('se'))
|
|
40985
|
+
return ProtocolV2FirmwareTargetType.TARGET_SE;
|
|
40986
|
+
if (normalized.includes('p2'))
|
|
40987
|
+
return ProtocolV2FirmwareTargetType.TARGET_FIRMWARE_P2;
|
|
40988
|
+
return ProtocolV2FirmwareTargetType.TARGET_FIRMWARE_P1;
|
|
40942
40989
|
}
|
|
40943
40990
|
|
|
40944
40991
|
const parseRunOptions = (options) => {
|
|
@@ -41511,7 +41558,10 @@ class Device extends events.exports {
|
|
|
41511
41558
|
const firmwareVersion = (_a = getDeviceFirmwareVersion(this.features)) === null || _a === void 0 ? void 0 : _a.join('.');
|
|
41512
41559
|
const versionRange = getMethodVersionRange(this.features, type => this.supportUnlockVersionRange()[type]);
|
|
41513
41560
|
const supportAttachPinCapability = existCapability(this.features, hdTransport.Enum_Capability.Capability_AttachToPin);
|
|
41514
|
-
const
|
|
41561
|
+
const isPro2 = getDeviceType(this.features) === hdShared.EDeviceType.Pro2;
|
|
41562
|
+
const supportUnlock = supportAttachPinCapability ||
|
|
41563
|
+
isPro2 ||
|
|
41564
|
+
(versionRange && semver__default["default"].gte(firmwareVersion, versionRange.min));
|
|
41515
41565
|
if (supportUnlock) {
|
|
41516
41566
|
const res = yield this.commands.typedCall('UnLockDevice', 'UnLockDeviceResponse');
|
|
41517
41567
|
if (this.features) {
|
|
@@ -41936,11 +41986,25 @@ class GetPassphraseState extends BaseMethod {
|
|
|
41936
41986
|
this.useDevicePassphraseState = false;
|
|
41937
41987
|
}
|
|
41938
41988
|
run() {
|
|
41989
|
+
var _a, _b;
|
|
41939
41990
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41940
41991
|
if (!this.device.features)
|
|
41941
41992
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed));
|
|
41942
|
-
const { passphraseState } = yield getPassphraseStateWithRefreshDeviceInfo(this.device
|
|
41993
|
+
const { passphraseState, newSession, unlockedAttachPin } = yield getPassphraseStateWithRefreshDeviceInfo(this.device, {
|
|
41994
|
+
expectPassphraseState: this.payload.passphraseState,
|
|
41995
|
+
onlyMainPin: this.payload.useEmptyPassphrase,
|
|
41996
|
+
allowCreateAttachPin: this.payload.allowCreateAttachPin,
|
|
41997
|
+
});
|
|
41943
41998
|
const { features } = this.device;
|
|
41999
|
+
const isPro2 = getDeviceType(features) === hdShared.EDeviceType.Pro2;
|
|
42000
|
+
if (isPro2) {
|
|
42001
|
+
return Promise.resolve({
|
|
42002
|
+
passphrase_state: passphraseState,
|
|
42003
|
+
session_id: (_a = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.session_id) !== null && _a !== void 0 ? _a : undefined,
|
|
42004
|
+
unlocked_attach_pin: unlockedAttachPin,
|
|
42005
|
+
passphrase_protection: (_b = features === null || features === void 0 ? void 0 : features.passphrase_protection) !== null && _b !== void 0 ? _b : null,
|
|
42006
|
+
});
|
|
42007
|
+
}
|
|
41944
42008
|
if (features && features.passphrase_protection === true) {
|
|
41945
42009
|
return Promise.resolve(passphraseState);
|
|
41946
42010
|
}
|
|
@@ -42321,37 +42385,37 @@ function parseChainId(chainId) {
|
|
|
42321
42385
|
throw new Error(`Invalid chainId ${chainId}`);
|
|
42322
42386
|
}
|
|
42323
42387
|
|
|
42324
|
-
const invalidParameter = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
42388
|
+
const invalidParameter$1 = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
42325
42389
|
const invalidResponse = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodError, message);
|
|
42326
42390
|
const validateParams = (values, fields) => {
|
|
42327
42391
|
fields.forEach(field => {
|
|
42328
42392
|
const existsProp = Object.prototype.hasOwnProperty.call(values, field.name);
|
|
42329
42393
|
if (!existsProp && field.required) {
|
|
42330
|
-
throw invalidParameter(`Missing required parameter: ${field.name}`);
|
|
42394
|
+
throw invalidParameter$1(`Missing required parameter: ${field.name}`);
|
|
42331
42395
|
}
|
|
42332
42396
|
const value = values[field.name];
|
|
42333
42397
|
if (value && field.type) {
|
|
42334
42398
|
switch (field.type) {
|
|
42335
42399
|
case 'array':
|
|
42336
42400
|
if (!Array.isArray(value)) {
|
|
42337
|
-
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42401
|
+
throw invalidParameter$1(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42338
42402
|
}
|
|
42339
42403
|
else if (!field.allowEmpty && value.length < 1) {
|
|
42340
|
-
throw invalidParameter(`Parameter "${field.name}" is empty.`);
|
|
42404
|
+
throw invalidParameter$1(`Parameter "${field.name}" is empty.`);
|
|
42341
42405
|
}
|
|
42342
42406
|
break;
|
|
42343
42407
|
case 'uint':
|
|
42344
42408
|
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
42345
|
-
throw invalidParameter(`Parameter [${field.name}] has invalid type. "string|number" expected.`);
|
|
42409
|
+
throw invalidParameter$1(`Parameter [${field.name}] has invalid type. "string|number" expected.`);
|
|
42346
42410
|
}
|
|
42347
42411
|
if ((typeof value === 'number' && !Number.isSafeInteger(value)) ||
|
|
42348
42412
|
!/^(?:[1-9]\d*|\d)$/.test(value.toString().replace(/^-/, field.allowNegative ? '' : '-'))) {
|
|
42349
|
-
throw invalidParameter(`Parameter [${field.name}] has invalid value "${value}". Integer representation expected.`);
|
|
42413
|
+
throw invalidParameter$1(`Parameter [${field.name}] has invalid value "${value}". Integer representation expected.`);
|
|
42350
42414
|
}
|
|
42351
42415
|
break;
|
|
42352
42416
|
case 'bigNumber':
|
|
42353
42417
|
if (typeof value !== 'string') {
|
|
42354
|
-
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [string].`);
|
|
42418
|
+
throw invalidParameter$1(`Parameter [${field.name}] is of type invalid and should be [string].`);
|
|
42355
42419
|
}
|
|
42356
42420
|
try {
|
|
42357
42421
|
const bn = new BigNumber__default["default"](value);
|
|
@@ -42360,12 +42424,12 @@ const validateParams = (values, fields) => {
|
|
|
42360
42424
|
}
|
|
42361
42425
|
}
|
|
42362
42426
|
catch (error) {
|
|
42363
|
-
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42427
|
+
throw invalidParameter$1(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42364
42428
|
}
|
|
42365
42429
|
break;
|
|
42366
42430
|
case 'buffer': {
|
|
42367
42431
|
if (typeof value === 'undefined' || value === null) {
|
|
42368
|
-
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [buffer].`);
|
|
42432
|
+
throw invalidParameter$1(`Parameter [${field.name}] is of type invalid and should be [buffer].`);
|
|
42369
42433
|
}
|
|
42370
42434
|
const isNodeBuffer = typeof Buffer !== 'undefined' &&
|
|
42371
42435
|
typeof Buffer.isBuffer === 'function' &&
|
|
@@ -42378,18 +42442,18 @@ const validateParams = (values, fields) => {
|
|
|
42378
42442
|
typeof ArrayBuffer.isView === 'function' &&
|
|
42379
42443
|
ArrayBuffer.isView(value);
|
|
42380
42444
|
if (!isNodeBuffer && !isCustomBuffer && !isArrayBuffer && !isArrayBufferView) {
|
|
42381
|
-
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [buffer].`);
|
|
42445
|
+
throw invalidParameter$1(`Parameter [${field.name}] is of type invalid and should be [buffer].`);
|
|
42382
42446
|
}
|
|
42383
42447
|
break;
|
|
42384
42448
|
}
|
|
42385
42449
|
case 'hexString':
|
|
42386
42450
|
if (typeof value !== 'string' || !isHexString(addHexPrefix(value))) {
|
|
42387
|
-
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42451
|
+
throw invalidParameter$1(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42388
42452
|
}
|
|
42389
42453
|
break;
|
|
42390
42454
|
default:
|
|
42391
42455
|
if (typeof value !== field.type) {
|
|
42392
|
-
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42456
|
+
throw invalidParameter$1(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
|
|
42393
42457
|
}
|
|
42394
42458
|
break;
|
|
42395
42459
|
}
|
|
@@ -42472,8 +42536,8 @@ class DeviceRebootToBootloader extends BaseMethod {
|
|
|
42472
42536
|
var _a;
|
|
42473
42537
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42474
42538
|
if (((_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2') {
|
|
42475
|
-
const res = yield this.device.commands.typedCall('
|
|
42476
|
-
reboot_type: hdTransport.
|
|
42539
|
+
const res = yield this.device.commands.typedCall('DeviceReboot', 'Success', {
|
|
42540
|
+
reboot_type: hdTransport.DeviceRebootType.Bootloader,
|
|
42477
42541
|
});
|
|
42478
42542
|
return Promise.resolve(res.message);
|
|
42479
42543
|
}
|
|
@@ -42502,8 +42566,8 @@ class DeviceRebootToBoardloader extends BaseMethod {
|
|
|
42502
42566
|
var _a;
|
|
42503
42567
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42504
42568
|
if (((_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2') {
|
|
42505
|
-
const res = yield this.device.commands.typedCall('
|
|
42506
|
-
reboot_type: hdTransport.
|
|
42569
|
+
const res = yield this.device.commands.typedCall('DeviceReboot', 'Success', {
|
|
42570
|
+
reboot_type: hdTransport.DeviceRebootType.Boardloader,
|
|
42507
42571
|
});
|
|
42508
42572
|
return Promise.resolve(res.message);
|
|
42509
42573
|
}
|
|
@@ -44703,18 +44767,57 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
44703
44767
|
}
|
|
44704
44768
|
}
|
|
44705
44769
|
|
|
44706
|
-
const
|
|
44707
|
-
|
|
44708
|
-
|
|
44709
|
-
|
|
44710
|
-
|
|
44711
|
-
|
|
44712
|
-
|
|
44770
|
+
const invalidParameter = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
44771
|
+
function validateNonEmptyString(value, name) {
|
|
44772
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
44773
|
+
throw invalidParameter(`Parameter [${name}] is required and must be a non-empty string.`);
|
|
44774
|
+
}
|
|
44775
|
+
return value;
|
|
44776
|
+
}
|
|
44777
|
+
function validateNonNegativeInteger(value, name, defaultValue) {
|
|
44778
|
+
if (value === undefined || value === null) {
|
|
44779
|
+
if (defaultValue !== undefined)
|
|
44780
|
+
return defaultValue;
|
|
44781
|
+
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
44782
|
+
}
|
|
44783
|
+
const numeric = typeof value === 'string' && value.trim() !== '' ? Number(value) : value;
|
|
44784
|
+
if (typeof numeric !== 'number' || !Number.isSafeInteger(numeric) || numeric < 0) {
|
|
44785
|
+
throw invalidParameter(`Parameter [${name}] must be a non-negative integer.`);
|
|
44786
|
+
}
|
|
44787
|
+
return numeric;
|
|
44788
|
+
}
|
|
44789
|
+
function validateOptionalNonNegativeInteger(value, name) {
|
|
44790
|
+
if (value === undefined || value === null)
|
|
44791
|
+
return undefined;
|
|
44792
|
+
return validateNonNegativeInteger(value, name);
|
|
44793
|
+
}
|
|
44794
|
+
function validateOptionalPercentage(value, name) {
|
|
44795
|
+
const numeric = validateOptionalNonNegativeInteger(value, name);
|
|
44796
|
+
if (numeric === undefined)
|
|
44797
|
+
return undefined;
|
|
44798
|
+
if (numeric > 100) {
|
|
44799
|
+
throw invalidParameter(`Parameter [${name}] must be between 0 and 100.`);
|
|
44800
|
+
}
|
|
44801
|
+
return numeric;
|
|
44802
|
+
}
|
|
44803
|
+
function validateRequiredData(value, name) {
|
|
44804
|
+
if (value === undefined || value === null) {
|
|
44805
|
+
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
44806
|
+
}
|
|
44807
|
+
}
|
|
44808
|
+
|
|
44809
|
+
const DEVICE_REBOOT_TYPES = {
|
|
44810
|
+
Normal: hdTransport.DeviceRebootType.Normal,
|
|
44811
|
+
normal: hdTransport.DeviceRebootType.Normal,
|
|
44812
|
+
Boardloader: hdTransport.DeviceRebootType.Boardloader,
|
|
44813
|
+
boardloader: hdTransport.DeviceRebootType.Boardloader,
|
|
44814
|
+
Bootloader: hdTransport.DeviceRebootType.Bootloader,
|
|
44815
|
+
bootloader: hdTransport.DeviceRebootType.Bootloader,
|
|
44713
44816
|
};
|
|
44714
44817
|
const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS = {
|
|
44715
|
-
intermediateTypes: ['
|
|
44818
|
+
intermediateTypes: ['DeviceFirmwareInstallProgress'],
|
|
44716
44819
|
};
|
|
44717
|
-
const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES = ['Success', '
|
|
44820
|
+
const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES = ['Success', 'DeviceFirmwareUpdateStatus'];
|
|
44718
44821
|
function normalizeRebootType(value) {
|
|
44719
44822
|
if (typeof value === 'number')
|
|
44720
44823
|
return value;
|
|
@@ -44722,18 +44825,24 @@ function normalizeRebootType(value) {
|
|
|
44722
44825
|
const numeric = Number(value);
|
|
44723
44826
|
if (Number.isFinite(numeric))
|
|
44724
44827
|
return numeric;
|
|
44725
|
-
if (value in
|
|
44726
|
-
return
|
|
44828
|
+
if (value in DEVICE_REBOOT_TYPES)
|
|
44829
|
+
return DEVICE_REBOOT_TYPES[value];
|
|
44727
44830
|
}
|
|
44728
|
-
return hdTransport.
|
|
44831
|
+
return hdTransport.DeviceRebootType.Normal;
|
|
44729
44832
|
}
|
|
44730
|
-
function normalizeTargetId(value) {
|
|
44731
|
-
if (
|
|
44732
|
-
|
|
44833
|
+
function normalizeTargetId(value, name) {
|
|
44834
|
+
if (value === undefined || value === null) {
|
|
44835
|
+
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
44836
|
+
}
|
|
44837
|
+
if (typeof value === 'number') {
|
|
44838
|
+
if (Number.isSafeInteger(value) && value > 0)
|
|
44839
|
+
return value;
|
|
44840
|
+
throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
|
|
44841
|
+
}
|
|
44733
44842
|
const numeric = Number(value);
|
|
44734
|
-
if (Number.
|
|
44843
|
+
if (Number.isSafeInteger(numeric) && numeric > 0)
|
|
44735
44844
|
return numeric;
|
|
44736
|
-
|
|
44845
|
+
throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
|
|
44737
44846
|
}
|
|
44738
44847
|
function normalizeFirmwareTargets(params) {
|
|
44739
44848
|
var _a, _b, _c;
|
|
@@ -44745,10 +44854,20 @@ function normalizeFirmwareTargets(params) {
|
|
|
44745
44854
|
},
|
|
44746
44855
|
]
|
|
44747
44856
|
: []);
|
|
44748
|
-
|
|
44749
|
-
|
|
44750
|
-
|
|
44751
|
-
|
|
44857
|
+
if (!Array.isArray(targets) || targets.length === 0) {
|
|
44858
|
+
throw invalidParameter('Parameter [targets] must contain at least one firmware target.');
|
|
44859
|
+
}
|
|
44860
|
+
return targets.map((target, index) => {
|
|
44861
|
+
var _a;
|
|
44862
|
+
if (!target || typeof target !== 'object') {
|
|
44863
|
+
throw invalidParameter(`Parameter [targets.${index}] must be an object.`);
|
|
44864
|
+
}
|
|
44865
|
+
const targetId = (_a = target.target_id) !== null && _a !== void 0 ? _a : target.targetId;
|
|
44866
|
+
return {
|
|
44867
|
+
target_id: normalizeTargetId(targetId, `targets.${index}.target_id`),
|
|
44868
|
+
path: validateNonEmptyString(target.path, `targets.${index}.path`),
|
|
44869
|
+
};
|
|
44870
|
+
});
|
|
44752
44871
|
}
|
|
44753
44872
|
function buildTargets(params) {
|
|
44754
44873
|
if (params.targets)
|
|
@@ -44844,7 +44963,7 @@ const isProtocolV2PollingTransientError = (error) => {
|
|
|
44844
44963
|
const message = getUnknownErrorText(error).toLowerCase();
|
|
44845
44964
|
return (isDeviceDisconnectedError(error) ||
|
|
44846
44965
|
isProtocolV2ReconnectProbeError(error) ||
|
|
44847
|
-
(message.includes('response timeout') && message.includes('
|
|
44966
|
+
(message.includes('response timeout') && message.includes('devicegetfirmwareupdatestatus')) ||
|
|
44848
44967
|
message.includes('device not found') ||
|
|
44849
44968
|
message.includes('transportnotfound'));
|
|
44850
44969
|
};
|
|
@@ -45076,7 +45195,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
45076
45195
|
transferStartTime,
|
|
45077
45196
|
});
|
|
45078
45197
|
targets.push({
|
|
45079
|
-
target_id: ProtocolV2FirmwareTargetType.
|
|
45198
|
+
target_id: ProtocolV2FirmwareTargetType.TARGET_BOOTLOADER,
|
|
45080
45199
|
path: bootloaderPath,
|
|
45081
45200
|
});
|
|
45082
45201
|
}
|
|
@@ -45102,7 +45221,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
45102
45221
|
queryProtocolV2FirmwareUpdateStatus() {
|
|
45103
45222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45104
45223
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
45105
|
-
return typedCall('
|
|
45224
|
+
return typedCall('DeviceGetFirmwareUpdateStatus', 'DeviceFirmwareUpdateStatus', {}, {
|
|
45106
45225
|
timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
|
|
45107
45226
|
});
|
|
45108
45227
|
});
|
|
@@ -45140,7 +45259,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
45140
45259
|
if ((startResponse === null || startResponse === void 0 ? void 0 : startResponse.type) === 'Success') {
|
|
45141
45260
|
return;
|
|
45142
45261
|
}
|
|
45143
|
-
if ((startResponse === null || startResponse === void 0 ? void 0 : startResponse.type) === '
|
|
45262
|
+
if ((startResponse === null || startResponse === void 0 ? void 0 : startResponse.type) === 'DeviceFirmwareUpdateStatus') {
|
|
45144
45263
|
const statusTargets = ((_a = startResponse.message.targets) !== null && _a !== void 0 ? _a : []);
|
|
45145
45264
|
if (this.assertProtocolV2TargetStatus(statusTargets, expectedTargetIds)) {
|
|
45146
45265
|
return;
|
|
@@ -45189,7 +45308,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
45189
45308
|
exitProtocolV2BootloaderToNormal() {
|
|
45190
45309
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45191
45310
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.SwitchFirmwareReconnectDevice);
|
|
45192
|
-
yield this.protocolV2Reboot(hdTransport.
|
|
45311
|
+
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
45193
45312
|
});
|
|
45194
45313
|
}
|
|
45195
45314
|
waitForProtocolV2FinalFeatures() {
|
|
@@ -45356,10 +45475,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
45356
45475
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
45357
45476
|
let response;
|
|
45358
45477
|
try {
|
|
45359
|
-
response = yield typedCall('
|
|
45478
|
+
response = yield typedCall('DeviceFirmwareUpdate', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
|
|
45360
45479
|
targets,
|
|
45361
45480
|
}, {
|
|
45362
|
-
intermediateTypes: ['
|
|
45481
|
+
intermediateTypes: ['DeviceFirmwareInstallProgress'],
|
|
45363
45482
|
onIntermediateResponse: (response) => {
|
|
45364
45483
|
var _a;
|
|
45365
45484
|
const progress = Number((_a = response.message) === null || _a === void 0 ? void 0 : _a.progress);
|
|
@@ -45385,7 +45504,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
45385
45504
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45386
45505
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
45387
45506
|
try {
|
|
45388
|
-
const res = yield typedCall('
|
|
45507
|
+
const res = yield typedCall('DeviceReboot', 'Success', {
|
|
45389
45508
|
reboot_type: rebootType,
|
|
45390
45509
|
});
|
|
45391
45510
|
return res.message;
|
|
@@ -45494,7 +45613,7 @@ class Ping extends BaseMethod {
|
|
|
45494
45613
|
}
|
|
45495
45614
|
}
|
|
45496
45615
|
|
|
45497
|
-
class
|
|
45616
|
+
class DeviceReboot extends BaseMethod {
|
|
45498
45617
|
init() {
|
|
45499
45618
|
this.skipForceUpdateCheck = true;
|
|
45500
45619
|
this.useDevicePassphraseState = false;
|
|
@@ -45506,7 +45625,7 @@ class DevReboot extends BaseMethod {
|
|
|
45506
45625
|
run() {
|
|
45507
45626
|
var _a;
|
|
45508
45627
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45509
|
-
const res = yield this.device.commands.typedCall('
|
|
45628
|
+
const res = yield this.device.commands.typedCall('DeviceReboot', 'Success', {
|
|
45510
45629
|
reboot_type: normalizeRebootType((_a = this.params.reboot_type) !== null && _a !== void 0 ? _a : this.params.rebootType),
|
|
45511
45630
|
});
|
|
45512
45631
|
return Promise.resolve(res.message);
|
|
@@ -45514,7 +45633,7 @@ class DevReboot extends BaseMethod {
|
|
|
45514
45633
|
}
|
|
45515
45634
|
}
|
|
45516
45635
|
|
|
45517
|
-
class
|
|
45636
|
+
class DeviceGetDeviceInfo extends BaseMethod {
|
|
45518
45637
|
init() {
|
|
45519
45638
|
this.skipForceUpdateCheck = true;
|
|
45520
45639
|
this.useDevicePassphraseState = false;
|
|
@@ -45537,7 +45656,7 @@ class DevGetDeviceInfo extends BaseMethod {
|
|
|
45537
45656
|
}
|
|
45538
45657
|
run() {
|
|
45539
45658
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45540
|
-
const res = yield this.device.commands.typedCall('
|
|
45659
|
+
const res = yield this.device.commands.typedCall('DeviceGetDeviceInfo', 'DeviceInfo', {
|
|
45541
45660
|
targets: buildTargets(this.params),
|
|
45542
45661
|
types: buildTypes(this.params),
|
|
45543
45662
|
});
|
|
@@ -45546,7 +45665,7 @@ class DevGetDeviceInfo extends BaseMethod {
|
|
|
45546
45665
|
}
|
|
45547
45666
|
}
|
|
45548
45667
|
|
|
45549
|
-
class
|
|
45668
|
+
class DeviceGetOnboardingStatus extends BaseMethod {
|
|
45550
45669
|
init() {
|
|
45551
45670
|
this.skipForceUpdateCheck = true;
|
|
45552
45671
|
this.useDevicePassphraseState = false;
|
|
@@ -45554,13 +45673,13 @@ class DevGetOnboardingStatus extends BaseMethod {
|
|
|
45554
45673
|
}
|
|
45555
45674
|
run() {
|
|
45556
45675
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45557
|
-
const res = yield this.device.commands.typedCall('
|
|
45676
|
+
const res = yield this.device.commands.typedCall('DeviceGetOnboardingStatus', 'DeviceOnboardingStatus', {});
|
|
45558
45677
|
return Promise.resolve(res.message);
|
|
45559
45678
|
});
|
|
45560
45679
|
}
|
|
45561
45680
|
}
|
|
45562
45681
|
|
|
45563
|
-
class
|
|
45682
|
+
class DeviceFirmwareUpdate extends BaseMethod {
|
|
45564
45683
|
init() {
|
|
45565
45684
|
this.skipForceUpdateCheck = true;
|
|
45566
45685
|
this.useDevicePassphraseState = false;
|
|
@@ -45573,15 +45692,16 @@ class DevFirmwareUpdate extends BaseMethod {
|
|
|
45573
45692
|
}
|
|
45574
45693
|
run() {
|
|
45575
45694
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45576
|
-
const
|
|
45577
|
-
|
|
45695
|
+
const targets = normalizeFirmwareTargets(this.params);
|
|
45696
|
+
const res = yield this.device.commands.typedCall('DeviceFirmwareUpdate', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
|
|
45697
|
+
targets,
|
|
45578
45698
|
}, PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS);
|
|
45579
45699
|
return Promise.resolve(res.message);
|
|
45580
45700
|
});
|
|
45581
45701
|
}
|
|
45582
45702
|
}
|
|
45583
45703
|
|
|
45584
|
-
class
|
|
45704
|
+
class DeviceGetFirmwareUpdateStatus extends BaseMethod {
|
|
45585
45705
|
init() {
|
|
45586
45706
|
this.skipForceUpdateCheck = true;
|
|
45587
45707
|
this.useDevicePassphraseState = false;
|
|
@@ -45589,7 +45709,7 @@ class DevGetFirmwareUpdateStatus extends BaseMethod {
|
|
|
45589
45709
|
}
|
|
45590
45710
|
run() {
|
|
45591
45711
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45592
|
-
const res = yield this.device.commands.typedCall('
|
|
45712
|
+
const res = yield this.device.commands.typedCall('DeviceGetFirmwareUpdateStatus', 'DeviceFirmwareUpdateStatus', {});
|
|
45593
45713
|
return Promise.resolve(res.message);
|
|
45594
45714
|
});
|
|
45595
45715
|
}
|
|
@@ -45713,15 +45833,15 @@ function toUint8Array(value) {
|
|
|
45713
45833
|
}
|
|
45714
45834
|
class FileRead extends BaseMethod {
|
|
45715
45835
|
init() {
|
|
45716
|
-
var _a, _b;
|
|
45717
45836
|
this.skipForceUpdateCheck = true;
|
|
45718
45837
|
this.useDevicePassphraseState = false;
|
|
45838
|
+
const path = validateNonEmptyString(this.payload.path, 'path');
|
|
45719
45839
|
this.params = {
|
|
45720
|
-
path
|
|
45721
|
-
offset: (
|
|
45722
|
-
totalSize: (
|
|
45723
|
-
chunkLen: this.payload.chunkLen,
|
|
45724
|
-
uiPercentage: this.payload.uiPercentage,
|
|
45840
|
+
path,
|
|
45841
|
+
offset: validateNonNegativeInteger(this.payload.offset, 'offset', 0),
|
|
45842
|
+
totalSize: validateNonNegativeInteger(this.payload.totalSize, 'totalSize', 0),
|
|
45843
|
+
chunkLen: validateOptionalNonNegativeInteger(this.payload.chunkLen, 'chunkLen'),
|
|
45844
|
+
uiPercentage: validateOptionalPercentage(this.payload.uiPercentage, 'uiPercentage'),
|
|
45725
45845
|
};
|
|
45726
45846
|
}
|
|
45727
45847
|
run() {
|
|
@@ -45801,7 +45921,7 @@ function dataToUint8Array(data) {
|
|
|
45801
45921
|
if (typeof Blob !== 'undefined' && data instanceof Blob) {
|
|
45802
45922
|
return new Uint8Array(yield data.arrayBuffer());
|
|
45803
45923
|
}
|
|
45804
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
45924
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Unsupported FilesystemFileWrite data');
|
|
45805
45925
|
});
|
|
45806
45926
|
}
|
|
45807
45927
|
function normalizeChunkSize(value, maxChunkSize) {
|
|
@@ -45825,20 +45945,22 @@ function getConfirmedProgress(processedByte, totalSize, written, dataLength) {
|
|
|
45825
45945
|
}
|
|
45826
45946
|
class FileWrite extends BaseMethod {
|
|
45827
45947
|
init() {
|
|
45828
|
-
var _a, _b
|
|
45948
|
+
var _a, _b;
|
|
45829
45949
|
this.skipForceUpdateCheck = true;
|
|
45830
45950
|
this.useDevicePassphraseState = false;
|
|
45831
|
-
|
|
45951
|
+
validateRequiredData(this.payload.data, 'data');
|
|
45952
|
+
const path = validateNonEmptyString(this.payload.path, 'path');
|
|
45953
|
+
const offset = validateNonNegativeInteger(this.payload.offset, 'offset', 0);
|
|
45832
45954
|
this.params = {
|
|
45833
|
-
path
|
|
45955
|
+
path,
|
|
45834
45956
|
offset,
|
|
45835
|
-
totalSize: (
|
|
45957
|
+
totalSize: validateNonNegativeInteger(this.payload.totalSize, 'totalSize', 0),
|
|
45836
45958
|
data: this.payload.data,
|
|
45837
|
-
chunkSize: this.payload.chunkSize,
|
|
45838
|
-
chunkLen: this.payload.chunkLen,
|
|
45839
|
-
overwrite: (
|
|
45840
|
-
append: (
|
|
45841
|
-
uiPercentage: this.payload.uiPercentage,
|
|
45959
|
+
chunkSize: validateOptionalNonNegativeInteger(this.payload.chunkSize, 'chunkSize'),
|
|
45960
|
+
chunkLen: validateOptionalNonNegativeInteger(this.payload.chunkLen, 'chunkLen'),
|
|
45961
|
+
overwrite: (_a = this.payload.overwrite) !== null && _a !== void 0 ? _a : offset === 0,
|
|
45962
|
+
append: (_b = this.payload.append) !== null && _b !== void 0 ? _b : false,
|
|
45963
|
+
uiPercentage: validateOptionalPercentage(this.payload.uiPercentage, 'uiPercentage'),
|
|
45842
45964
|
};
|
|
45843
45965
|
}
|
|
45844
45966
|
run() {
|
|
@@ -45915,7 +46037,7 @@ class FileDelete extends BaseMethod {
|
|
|
45915
46037
|
init() {
|
|
45916
46038
|
this.skipForceUpdateCheck = true;
|
|
45917
46039
|
this.useDevicePassphraseState = false;
|
|
45918
|
-
this.params = { path: this.payload.path };
|
|
46040
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
45919
46041
|
}
|
|
45920
46042
|
run() {
|
|
45921
46043
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45932,8 +46054,8 @@ class DirList extends BaseMethod {
|
|
|
45932
46054
|
this.skipForceUpdateCheck = true;
|
|
45933
46055
|
this.useDevicePassphraseState = false;
|
|
45934
46056
|
this.params = {
|
|
45935
|
-
path: this.payload.path,
|
|
45936
|
-
depth: this.payload.depth,
|
|
46057
|
+
path: validateNonEmptyString(this.payload.path, 'path'),
|
|
46058
|
+
depth: validateOptionalNonNegativeInteger(this.payload.depth, 'depth'),
|
|
45937
46059
|
};
|
|
45938
46060
|
}
|
|
45939
46061
|
run() {
|
|
@@ -45951,7 +46073,7 @@ class DirMake extends BaseMethod {
|
|
|
45951
46073
|
init() {
|
|
45952
46074
|
this.skipForceUpdateCheck = true;
|
|
45953
46075
|
this.useDevicePassphraseState = false;
|
|
45954
|
-
this.params = { path: this.payload.path };
|
|
46076
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
45955
46077
|
}
|
|
45956
46078
|
run() {
|
|
45957
46079
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45967,7 +46089,7 @@ class DirRemove extends BaseMethod {
|
|
|
45967
46089
|
init() {
|
|
45968
46090
|
this.skipForceUpdateCheck = true;
|
|
45969
46091
|
this.useDevicePassphraseState = false;
|
|
45970
|
-
this.params = { path: this.payload.path };
|
|
46092
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
45971
46093
|
}
|
|
45972
46094
|
run() {
|
|
45973
46095
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45983,7 +46105,7 @@ class PathInfo extends BaseMethod {
|
|
|
45983
46105
|
init() {
|
|
45984
46106
|
this.skipForceUpdateCheck = true;
|
|
45985
46107
|
this.useDevicePassphraseState = false;
|
|
45986
|
-
this.params = { path: this.payload.path };
|
|
46108
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
45987
46109
|
}
|
|
45988
46110
|
run() {
|
|
45989
46111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -46393,10 +46515,16 @@ function preCheckDeviceSupport(device, method) {
|
|
|
46393
46515
|
}
|
|
46394
46516
|
}
|
|
46395
46517
|
function handleSkippableHardwareError(e, device, method) {
|
|
46396
|
-
var _a, _b, _c, _d, _e, _f;
|
|
46518
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
46397
46519
|
let error;
|
|
46520
|
+
const skipMethodSupportCheck = shouldSkipMethodSupportCheck(device.features, (_a = device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType);
|
|
46398
46521
|
if (e instanceof hdShared.HardwareError && e.errorCode !== hdShared.HardwareErrorCode.RuntimeError) {
|
|
46399
46522
|
const { errorCode } = e;
|
|
46523
|
+
if (skipMethodSupportCheck &&
|
|
46524
|
+
(errorCode === hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware ||
|
|
46525
|
+
errorCode === hdShared.HardwareErrorCode.DeviceNotSupportMethod)) {
|
|
46526
|
+
return undefined;
|
|
46527
|
+
}
|
|
46400
46528
|
if (errorCode === hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware) {
|
|
46401
46529
|
error = e;
|
|
46402
46530
|
}
|
|
@@ -46404,8 +46532,11 @@ function handleSkippableHardwareError(e, device, method) {
|
|
|
46404
46532
|
error = e;
|
|
46405
46533
|
}
|
|
46406
46534
|
}
|
|
46407
|
-
else if (((
|
|
46408
|
-
((
|
|
46535
|
+
else if (((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnexpectedMessage')) ||
|
|
46536
|
+
((_c = e.message) === null || _c === void 0 ? void 0 : _c.includes('Failure_UnknownMessage'))) {
|
|
46537
|
+
if (skipMethodSupportCheck) {
|
|
46538
|
+
return undefined;
|
|
46539
|
+
}
|
|
46409
46540
|
const versionRange = getMethodVersionRange(device.features, type => method.getVersionRange()[type]);
|
|
46410
46541
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
46411
46542
|
if (versionRange &&
|
|
@@ -46422,8 +46553,8 @@ function handleSkippableHardwareError(e, device, method) {
|
|
|
46422
46553
|
error = hdShared.ERRORS.createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
46423
46554
|
}
|
|
46424
46555
|
}
|
|
46425
|
-
else if (((
|
|
46426
|
-
((
|
|
46556
|
+
else if (((_e = (_d = e.message) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === null || _e === void 0 ? void 0 : _e.includes('forbidden key path')) ||
|
|
46557
|
+
((_g = (_f = e.message) === null || _f === void 0 ? void 0 : _f.toLowerCase()) === null || _g === void 0 ? void 0 : _g.includes('invalid path'))) {
|
|
46427
46558
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, e.message);
|
|
46428
46559
|
}
|
|
46429
46560
|
return error;
|
|
@@ -46936,13 +47067,14 @@ function splitArray(array, size) {
|
|
|
46936
47067
|
}
|
|
46937
47068
|
|
|
46938
47069
|
function batchGetPublickeys(device, paths, ecdsaCurveName, coinType, options) {
|
|
46939
|
-
var _a;
|
|
47070
|
+
var _a, _b;
|
|
46940
47071
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46941
47072
|
const existsPathNotValid = paths.find(p => p.address_n.length < 3);
|
|
46942
47073
|
if (existsPathNotValid) {
|
|
46943
47074
|
throw hdShared.TypedError(hdShared.HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
|
|
46944
47075
|
}
|
|
46945
|
-
const supportsBatchPublicKey =
|
|
47076
|
+
const supportsBatchPublicKey = shouldSkipMethodSupportCheck(device.features, (_a = device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) ||
|
|
47077
|
+
supportBatchPublicKey(device.features, options);
|
|
46946
47078
|
if (!supportsBatchPublicKey) {
|
|
46947
47079
|
throw hdShared.createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
|
|
46948
47080
|
}
|
|
@@ -46967,7 +47099,7 @@ function batchGetPublickeys(device, paths, ecdsaCurveName, coinType, options) {
|
|
|
46967
47099
|
const res = yield device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
46968
47100
|
paths,
|
|
46969
47101
|
ecdsa_curve_name: ecdsaCurveName,
|
|
46970
|
-
include_node: (
|
|
47102
|
+
include_node: (_b = options === null || options === void 0 ? void 0 : options.includeNode) !== null && _b !== void 0 ? _b : false,
|
|
46971
47103
|
});
|
|
46972
47104
|
if (res.type !== 'EcdsaPublicKeys') {
|
|
46973
47105
|
throw hdShared.createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
|
|
@@ -47873,7 +48005,7 @@ class ConfluxSignTransaction extends BaseMethod {
|
|
|
47873
48005
|
this.addressN = validatePath(path, 3);
|
|
47874
48006
|
const tx = transaction;
|
|
47875
48007
|
const schema = [
|
|
47876
|
-
{ name: 'to', type: '
|
|
48008
|
+
{ name: 'to', type: 'string', required: true },
|
|
47877
48009
|
{ name: 'value', type: 'hexString', required: true },
|
|
47878
48010
|
{ name: 'gasLimit', type: 'hexString', required: true },
|
|
47879
48011
|
{ name: 'gasPrice', type: 'hexString', required: true },
|
|
@@ -47884,7 +48016,7 @@ class ConfluxSignTransaction extends BaseMethod {
|
|
|
47884
48016
|
{ name: 'data', type: 'hexString' },
|
|
47885
48017
|
];
|
|
47886
48018
|
validateParams(tx, schema);
|
|
47887
|
-
this.formattedTx = formatAnyHex(tx);
|
|
48019
|
+
this.formattedTx = Object.assign(Object.assign({}, formatAnyHex(tx)), { to: tx.to });
|
|
47888
48020
|
}
|
|
47889
48021
|
getVersionRange() {
|
|
47890
48022
|
return {
|
|
@@ -47952,7 +48084,7 @@ class EvmGetAddress extends BaseMethod {
|
|
|
47952
48084
|
}
|
|
47953
48085
|
getEvmAddress(param) {
|
|
47954
48086
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47955
|
-
if (TransportManager.
|
|
48087
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
47956
48088
|
return getAddressLegacyV1({
|
|
47957
48089
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
47958
48090
|
param,
|
|
@@ -48039,7 +48171,7 @@ class EVMGetPublicKey extends BaseMethod {
|
|
|
48039
48171
|
});
|
|
48040
48172
|
}
|
|
48041
48173
|
getEvmPublicKey(param) {
|
|
48042
|
-
if (TransportManager.
|
|
48174
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
48043
48175
|
return getPublicKeyLegacyV1({
|
|
48044
48176
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
48045
48177
|
param,
|
|
@@ -48123,7 +48255,7 @@ class EVMSignMessage$2 extends BaseMethod {
|
|
|
48123
48255
|
}
|
|
48124
48256
|
run() {
|
|
48125
48257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48126
|
-
if (TransportManager.
|
|
48258
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
48127
48259
|
return signMessageLegacyV1({
|
|
48128
48260
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
48129
48261
|
params: this.params,
|
|
@@ -48436,7 +48568,7 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
48436
48568
|
const { addressN, isEIP1559, isEIP7702, formattedTx } = this;
|
|
48437
48569
|
if (formattedTx == null)
|
|
48438
48570
|
throw hdShared.ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
48439
|
-
if (TransportManager.
|
|
48571
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
48440
48572
|
return signTransaction({
|
|
48441
48573
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
48442
48574
|
addressN,
|
|
@@ -48782,8 +48914,8 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48782
48914
|
const { addressN, data, metamaskV4Compat, chainId } = this.params;
|
|
48783
48915
|
let supportTrezor = false;
|
|
48784
48916
|
let response;
|
|
48785
|
-
switch (TransportManager.
|
|
48786
|
-
case '
|
|
48917
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
48918
|
+
case 'v1LegacySchema':
|
|
48787
48919
|
supportTrezor = true;
|
|
48788
48920
|
response = yield signTypedData$1({
|
|
48789
48921
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
@@ -48793,7 +48925,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48793
48925
|
chainId,
|
|
48794
48926
|
});
|
|
48795
48927
|
break;
|
|
48796
|
-
case '
|
|
48928
|
+
case 'v1CurrentSchema':
|
|
48797
48929
|
default:
|
|
48798
48930
|
supportTrezor = false;
|
|
48799
48931
|
response = yield signTypedData({
|
|
@@ -48816,8 +48948,8 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48816
48948
|
signTypedHash({ typedCall, addressN, chainId, domainHash, messageHash, }) {
|
|
48817
48949
|
if (!domainHash)
|
|
48818
48950
|
throw hdShared.ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
48819
|
-
switch (TransportManager.
|
|
48820
|
-
case '
|
|
48951
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
48952
|
+
case 'v1LegacySchema':
|
|
48821
48953
|
return signTypedHash$1({
|
|
48822
48954
|
typedCall,
|
|
48823
48955
|
addressN,
|
|
@@ -48826,7 +48958,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48826
48958
|
chainId,
|
|
48827
48959
|
device: this.device,
|
|
48828
48960
|
});
|
|
48829
|
-
case '
|
|
48961
|
+
case 'v1CurrentSchema':
|
|
48830
48962
|
default:
|
|
48831
48963
|
return signTypedHash({
|
|
48832
48964
|
typedCall,
|
|
@@ -49087,7 +49219,7 @@ class EVMSignMessage$1 extends BaseMethod {
|
|
|
49087
49219
|
}
|
|
49088
49220
|
run() {
|
|
49089
49221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49090
|
-
if (TransportManager.
|
|
49222
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
49091
49223
|
return verifyMessageLegacyV1({
|
|
49092
49224
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
49093
49225
|
params: this.params,
|
|
@@ -50088,6 +50220,7 @@ class TronGetAddress extends BaseMethod {
|
|
|
50088
50220
|
|
|
50089
50221
|
class TronSignMessage extends BaseMethod {
|
|
50090
50222
|
init() {
|
|
50223
|
+
var _a;
|
|
50091
50224
|
this.checkDeviceId = true;
|
|
50092
50225
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
50093
50226
|
validateParams(this.payload, [
|
|
@@ -50098,7 +50231,7 @@ class TronSignMessage extends BaseMethod {
|
|
|
50098
50231
|
const { path, messageHex } = this.payload;
|
|
50099
50232
|
const addressN = validatePath(path, 3);
|
|
50100
50233
|
if (this.payload.messageType === 'V1' || this.payload.messageType == null) {
|
|
50101
|
-
throw hdShared.createDeviceNotSupportMethodError('TronSignMessage', getFirmwareType(this.device.features));
|
|
50234
|
+
throw hdShared.createDeviceNotSupportMethodError('TronSignMessage', getFirmwareType((_a = this.device) === null || _a === void 0 ? void 0 : _a.features));
|
|
50102
50235
|
}
|
|
50103
50236
|
const messageType = hdTransport.TronMessageType.V2;
|
|
50104
50237
|
this.params = {
|
|
@@ -51053,7 +51186,7 @@ class XrpGetAddress extends BaseMethod {
|
|
|
51053
51186
|
{ name: 'payment', type: 'object' },
|
|
51054
51187
|
]);
|
|
51055
51188
|
validateParams(transaction.payment, [
|
|
51056
|
-
{ name: 'amount', type: '
|
|
51189
|
+
{ name: 'amount', type: 'uint', required: true },
|
|
51057
51190
|
{ name: 'destination', type: 'string', required: true },
|
|
51058
51191
|
{ name: 'destinationTag', type: 'number' },
|
|
51059
51192
|
]);
|
|
@@ -53755,7 +53888,11 @@ class DnxGetAddress extends BaseMethod {
|
|
|
53755
53888
|
};
|
|
53756
53889
|
}
|
|
53757
53890
|
run() {
|
|
53891
|
+
var _a;
|
|
53758
53892
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53893
|
+
if (((_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2') {
|
|
53894
|
+
throw hdShared.createDeviceNotSupportMethodError(this.name, getFirmwareType(this.device.features));
|
|
53895
|
+
}
|
|
53759
53896
|
const responses = [];
|
|
53760
53897
|
for (let i = 0; i < this.params.length; i++) {
|
|
53761
53898
|
const param = this.params[i];
|
|
@@ -53859,7 +53996,11 @@ class DnxSignTransaction extends BaseMethod {
|
|
|
53859
53996
|
});
|
|
53860
53997
|
}
|
|
53861
53998
|
run() {
|
|
53999
|
+
var _a;
|
|
53862
54000
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54001
|
+
if (((_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2') {
|
|
54002
|
+
throw hdShared.createDeviceNotSupportMethodError(this.name, getFirmwareType(this.device.features));
|
|
54003
|
+
}
|
|
53863
54004
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
53864
54005
|
const res = yield this.device.commands.typedCall('DnxSignTx', 'DnxInputRequest', Object.assign({}, this.params));
|
|
53865
54006
|
return this.processTxRequest(typedCall, res, {});
|
|
@@ -54937,11 +55078,11 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
54937
55078
|
promptWebDeviceAccess: PromptWebDeviceAccess,
|
|
54938
55079
|
getProtoVersion: GetProtoVersion,
|
|
54939
55080
|
ping: Ping,
|
|
54940
|
-
|
|
54941
|
-
|
|
54942
|
-
|
|
54943
|
-
|
|
54944
|
-
|
|
55081
|
+
deviceReboot: DeviceReboot,
|
|
55082
|
+
deviceGetDeviceInfo: DeviceGetDeviceInfo,
|
|
55083
|
+
deviceGetOnboardingStatus: DeviceGetOnboardingStatus,
|
|
55084
|
+
deviceFirmwareUpdate: DeviceFirmwareUpdate,
|
|
55085
|
+
deviceGetFirmwareUpdateStatus: DeviceGetFirmwareUpdateStatus,
|
|
54945
55086
|
factoryDeviceInfoSettings: FactoryDeviceInfoSettings,
|
|
54946
55087
|
factoryGetDeviceInfo: FactoryGetDeviceInfo,
|
|
54947
55088
|
filesystemFixPermission: FilesystemFixPermission,
|
|
@@ -55595,7 +55736,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55595
55736
|
yield TransportManager.reconfigure(device.features);
|
|
55596
55737
|
}
|
|
55597
55738
|
checkPassphraseEnableState(method, device.features);
|
|
55598
|
-
if (
|
|
55739
|
+
if (shouldCheckPassphraseState(method, device)) {
|
|
55599
55740
|
const support = supportNewPassphrase(device.features);
|
|
55600
55741
|
if (!support.support) {
|
|
55601
55742
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase, `Device not support passphrase, please update to ${support.require}`, {
|
|
@@ -55995,6 +56136,14 @@ const checkPassphraseEnableState = (method, features) => {
|
|
|
55995
56136
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
55996
56137
|
}
|
|
55997
56138
|
};
|
|
56139
|
+
const shouldCheckPassphraseState = (method, device) => {
|
|
56140
|
+
var _a, _b;
|
|
56141
|
+
if (!method.useDevicePassphraseState)
|
|
56142
|
+
return false;
|
|
56143
|
+
const isPro2 = getDeviceType(device.features) === hdShared.EDeviceType.Pro2;
|
|
56144
|
+
const pro2ExplicitWalletSelection = isPro2 && (!!((_a = method.payload) === null || _a === void 0 ? void 0 : _a.passphraseState) || !!((_b = method.payload) === null || _b === void 0 ? void 0 : _b.useEmptyPassphrase));
|
|
56145
|
+
return device.hasUsePassphrase() || pro2ExplicitWalletSelection;
|
|
56146
|
+
};
|
|
55998
56147
|
const cleanup = () => {
|
|
55999
56148
|
_uiPromises = [];
|
|
56000
56149
|
Log.debug('Cleanup...');
|