@onekeyfe/hd-core 1.2.8-alpha.1 → 1.2.8-alpha.100
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/README.md +27 -0
- package/__tests__/DeviceCommands.test.ts +66 -13
- package/__tests__/btc-derive-context-hash.test.ts +200 -0
- package/__tests__/core-error-output.test.ts +34 -3
- package/__tests__/device-lifecycle-events.test.ts +73 -24
- package/__tests__/device-pool-state.test.ts +50 -0
- package/__tests__/logBlockEvent.test.ts +43 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +43 -2
- package/__tests__/protocol-v2.test.ts +0 -47
- package/__tests__/refresh-device-state.test.ts +19 -17
- package/__tests__/sol-sign-offchain-message.test.ts +0 -8
- package/__tests__/zcash-sign-pczt.test.ts +212 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/btc/BTCDeriveContextHash.d.ts +16 -0
- package/dist/api/btc/BTCDeriveContextHash.d.ts.map +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/zcash/ZcashGetAddress.d.ts +12 -0
- package/dist/api/zcash/ZcashGetAddress.d.ts.map +1 -0
- package/dist/api/zcash/ZcashSignPczt.d.ts +17 -0
- package/dist/api/zcash/ZcashSignPczt.d.ts.map +1 -0
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +2 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +51 -5
- package/dist/index.js +488 -30
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/btcDeriveContextHash.d.ts +10 -0
- package/dist/types/api/btcDeriveContextHash.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +3 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +6 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/zcashGetAddress.d.ts +22 -0
- package/dist/types/api/zcashGetAddress.d.ts.map +1 -0
- package/dist/types/api/zcashSignPczt.d.ts +9 -0
- package/dist/types/api/zcashSignPczt.d.ts.map +1 -0
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.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/FirmwareUpdateV4.ts +8 -25
- package/src/api/GetDeviceState.ts +2 -5
- package/src/api/btc/BTCDeriveContextHash.ts +90 -0
- package/src/api/index.ts +3 -0
- package/src/api/protocol-v2/DeviceReboot.ts +2 -0
- package/src/api/zcash/ZcashGetAddress.ts +121 -0
- package/src/api/zcash/ZcashSignPczt.ts +153 -0
- package/src/core/index.ts +3 -7
- package/src/data/messages/messages-protocol-v2.json +138 -1
- package/src/data/messages/messages.json +51 -0
- package/src/device/Device.ts +11 -1
- package/src/device/DeviceCommands.ts +15 -1
- package/src/device/DevicePool.ts +12 -2
- package/src/events/core.ts +2 -2
- package/src/events/logBlockEvent.ts +6 -2
- package/src/inject.ts +6 -0
- package/src/types/api/btcDeriveContextHash.ts +15 -0
- package/src/types/api/export.ts +3 -0
- package/src/types/api/index.ts +10 -0
- package/src/types/api/zcashGetAddress.ts +36 -0
- package/src/types/api/zcashSignPczt.ts +18 -0
- package/src/types/params.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1635,6 +1635,7 @@ const createCoreApi = (call) => ({
|
|
|
1635
1635
|
evmVerifyMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'evmVerifyMessage' })),
|
|
1636
1636
|
btcGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'btcGetAddress' })),
|
|
1637
1637
|
btcGetPublicKey: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'btcGetPublicKey' })),
|
|
1638
|
+
btcDeriveContextHash: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'btcDeriveContextHash' })),
|
|
1638
1639
|
btcSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'btcSignMessage' })),
|
|
1639
1640
|
btcSignPsbt: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'btcSignPsbt' })),
|
|
1640
1641
|
btcSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'btcSignTransaction' })),
|
|
@@ -1720,6 +1721,8 @@ const createCoreApi = (call) => ({
|
|
|
1720
1721
|
benfenSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'benfenSignMessage' })),
|
|
1721
1722
|
neoGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'neoGetAddress' })),
|
|
1722
1723
|
neoSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'neoSignTransaction' })),
|
|
1724
|
+
zcashGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'zcashGetAddress' })),
|
|
1725
|
+
zcashSignPczt: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'zcashSignPczt' })),
|
|
1723
1726
|
});
|
|
1724
1727
|
|
|
1725
1728
|
const lowLevelInject = ({ call, cancel, dispose, eventEmitter, init, uiResponse, updateSettings, switchTransport, addHardwareGlobalEventListener, }) => {
|
|
@@ -15448,6 +15451,8 @@ var nested$2 = {
|
|
|
15448
15451
|
"(has_bitcoin_only_values)": true
|
|
15449
15452
|
},
|
|
15450
15453
|
values: {
|
|
15454
|
+
MessageType_BabylonDeriveContextHash: 10054,
|
|
15455
|
+
MessageType_BabylonDerivedContextHash: 10055,
|
|
15451
15456
|
MessageType_Initialize: 0,
|
|
15452
15457
|
MessageType_Ping: 1,
|
|
15453
15458
|
MessageType_Success: 2,
|
|
@@ -15912,6 +15917,55 @@ var nested$2 = {
|
|
|
15912
15917
|
MessageType_UpgradeFileHeader: 10050
|
|
15913
15918
|
}
|
|
15914
15919
|
},
|
|
15920
|
+
CanonicalBitcoinNetwork: {
|
|
15921
|
+
values: {
|
|
15922
|
+
BITCOIN_MAINNET: 0,
|
|
15923
|
+
BITCOIN_TESTNET: 1,
|
|
15924
|
+
BITCOIN_SIGNET: 2,
|
|
15925
|
+
BITCOIN_REGTEST: 3
|
|
15926
|
+
}
|
|
15927
|
+
},
|
|
15928
|
+
BabylonDeriveContextHash: {
|
|
15929
|
+
fields: {
|
|
15930
|
+
address_n: {
|
|
15931
|
+
rule: "repeated",
|
|
15932
|
+
type: "uint32",
|
|
15933
|
+
id: 1,
|
|
15934
|
+
options: {
|
|
15935
|
+
packed: false
|
|
15936
|
+
}
|
|
15937
|
+
},
|
|
15938
|
+
script_type: {
|
|
15939
|
+
rule: "required",
|
|
15940
|
+
type: "InputScriptType",
|
|
15941
|
+
id: 2
|
|
15942
|
+
},
|
|
15943
|
+
app_name: {
|
|
15944
|
+
rule: "required",
|
|
15945
|
+
type: "bytes",
|
|
15946
|
+
id: 3
|
|
15947
|
+
},
|
|
15948
|
+
context: {
|
|
15949
|
+
rule: "required",
|
|
15950
|
+
type: "bytes",
|
|
15951
|
+
id: 4
|
|
15952
|
+
},
|
|
15953
|
+
network: {
|
|
15954
|
+
rule: "required",
|
|
15955
|
+
type: "CanonicalBitcoinNetwork",
|
|
15956
|
+
id: 5
|
|
15957
|
+
}
|
|
15958
|
+
}
|
|
15959
|
+
},
|
|
15960
|
+
BabylonDerivedContextHash: {
|
|
15961
|
+
fields: {
|
|
15962
|
+
secret: {
|
|
15963
|
+
rule: "required",
|
|
15964
|
+
type: "bytes",
|
|
15965
|
+
id: 1
|
|
15966
|
+
}
|
|
15967
|
+
}
|
|
15968
|
+
},
|
|
15915
15969
|
google: {
|
|
15916
15970
|
nested: {
|
|
15917
15971
|
protobuf: {
|
|
@@ -38114,6 +38168,61 @@ var nested = {
|
|
|
38114
38168
|
}
|
|
38115
38169
|
}
|
|
38116
38170
|
},
|
|
38171
|
+
ZcashSignPczt: {
|
|
38172
|
+
fields: {
|
|
38173
|
+
pczt_length: {
|
|
38174
|
+
rule: "required",
|
|
38175
|
+
type: "uint32",
|
|
38176
|
+
id: 1
|
|
38177
|
+
},
|
|
38178
|
+
pczt_initial_chunk: {
|
|
38179
|
+
rule: "required",
|
|
38180
|
+
type: "bytes",
|
|
38181
|
+
id: 2
|
|
38182
|
+
}
|
|
38183
|
+
}
|
|
38184
|
+
},
|
|
38185
|
+
ZcashPcztChunkRequest: {
|
|
38186
|
+
fields: {
|
|
38187
|
+
chunk_length: {
|
|
38188
|
+
rule: "required",
|
|
38189
|
+
type: "uint32",
|
|
38190
|
+
id: 1
|
|
38191
|
+
}
|
|
38192
|
+
}
|
|
38193
|
+
},
|
|
38194
|
+
ZcashPcztChunkAck: {
|
|
38195
|
+
fields: {
|
|
38196
|
+
data_chunk: {
|
|
38197
|
+
rule: "required",
|
|
38198
|
+
type: "bytes",
|
|
38199
|
+
id: 1
|
|
38200
|
+
}
|
|
38201
|
+
}
|
|
38202
|
+
},
|
|
38203
|
+
ZcashSignedPczt: {
|
|
38204
|
+
fields: {
|
|
38205
|
+
pczt_length: {
|
|
38206
|
+
rule: "required",
|
|
38207
|
+
type: "uint32",
|
|
38208
|
+
id: 1
|
|
38209
|
+
},
|
|
38210
|
+
pczt_initial_chunk: {
|
|
38211
|
+
rule: "required",
|
|
38212
|
+
type: "bytes",
|
|
38213
|
+
id: 2
|
|
38214
|
+
}
|
|
38215
|
+
}
|
|
38216
|
+
},
|
|
38217
|
+
ZcashSignedPcztChunkRequest: {
|
|
38218
|
+
fields: {
|
|
38219
|
+
chunk_length: {
|
|
38220
|
+
rule: "required",
|
|
38221
|
+
type: "uint32",
|
|
38222
|
+
id: 1
|
|
38223
|
+
}
|
|
38224
|
+
}
|
|
38225
|
+
},
|
|
38117
38226
|
wire_in: {
|
|
38118
38227
|
type: "bool",
|
|
38119
38228
|
id: 50002,
|
|
@@ -38539,6 +38648,11 @@ var nested = {
|
|
|
38539
38648
|
MessageType_NeoAddress: 12302,
|
|
38540
38649
|
MessageType_NeoSignTx: 12303,
|
|
38541
38650
|
MessageType_NeoSignedTx: 12304,
|
|
38651
|
+
MessageType_ZcashSignPczt: 12402,
|
|
38652
|
+
MessageType_ZcashSignedPczt: 12403,
|
|
38653
|
+
MessageType_ZcashPcztChunkRequest: 12404,
|
|
38654
|
+
MessageType_ZcashPcztChunkAck: 12405,
|
|
38655
|
+
MessageType_ZcashSignedPcztChunkRequest: 12406,
|
|
38542
38656
|
MessageType_DeviceFactoryInfoSet: 60000,
|
|
38543
38657
|
MessageType_DeviceFactoryInfoGet: 60001,
|
|
38544
38658
|
MessageType_DeviceFactoryInfo: 60002,
|
|
@@ -38591,7 +38705,9 @@ var nested = {
|
|
|
38591
38705
|
MessageType_PortfolioUpdate: 61400,
|
|
38592
38706
|
MessageType_NftUpdate: 61500,
|
|
38593
38707
|
MessageType_OnboardingStatusGet: 61600,
|
|
38594
|
-
MessageType_OnboardingStatus: 61601
|
|
38708
|
+
MessageType_OnboardingStatus: 61601,
|
|
38709
|
+
MessageType_ZcashGetAddress: 12400,
|
|
38710
|
+
MessageType_ZcashAddress: 12401
|
|
38595
38711
|
},
|
|
38596
38712
|
reserved: [
|
|
38597
38713
|
[
|
|
@@ -40896,6 +41012,81 @@ var nested = {
|
|
|
40896
41012
|
}
|
|
40897
41013
|
}
|
|
40898
41014
|
}
|
|
41015
|
+
},
|
|
41016
|
+
ZcashAddressType: {
|
|
41017
|
+
values: {
|
|
41018
|
+
UNIFIED_ORCHARD_P2PKH: 0,
|
|
41019
|
+
TRANSPARENT_P2PKH: 1,
|
|
41020
|
+
UNIFIED_ORCHARD: 2
|
|
41021
|
+
}
|
|
41022
|
+
},
|
|
41023
|
+
ZcashAddressScope: {
|
|
41024
|
+
values: {
|
|
41025
|
+
EXTERNAL: 0,
|
|
41026
|
+
INTERNAL: 1
|
|
41027
|
+
}
|
|
41028
|
+
},
|
|
41029
|
+
ZcashGetAddress: {
|
|
41030
|
+
fields: {
|
|
41031
|
+
address_n: {
|
|
41032
|
+
rule: "repeated",
|
|
41033
|
+
type: "uint32",
|
|
41034
|
+
id: 1,
|
|
41035
|
+
options: {
|
|
41036
|
+
packed: false
|
|
41037
|
+
}
|
|
41038
|
+
},
|
|
41039
|
+
show_display: {
|
|
41040
|
+
type: "bool",
|
|
41041
|
+
id: 2
|
|
41042
|
+
},
|
|
41043
|
+
include_seed_fingerprint: {
|
|
41044
|
+
type: "bool",
|
|
41045
|
+
id: 3
|
|
41046
|
+
},
|
|
41047
|
+
include_ufvk: {
|
|
41048
|
+
type: "bool",
|
|
41049
|
+
id: 4
|
|
41050
|
+
},
|
|
41051
|
+
diversifier_index: {
|
|
41052
|
+
type: "uint32",
|
|
41053
|
+
id: 5,
|
|
41054
|
+
options: {
|
|
41055
|
+
"default": 0
|
|
41056
|
+
}
|
|
41057
|
+
},
|
|
41058
|
+
address_type: {
|
|
41059
|
+
type: "ZcashAddressType",
|
|
41060
|
+
id: 6,
|
|
41061
|
+
options: {
|
|
41062
|
+
"default": "UNIFIED_ORCHARD_P2PKH"
|
|
41063
|
+
}
|
|
41064
|
+
},
|
|
41065
|
+
scope: {
|
|
41066
|
+
type: "ZcashAddressScope",
|
|
41067
|
+
id: 7,
|
|
41068
|
+
options: {
|
|
41069
|
+
"default": "EXTERNAL"
|
|
41070
|
+
}
|
|
41071
|
+
}
|
|
41072
|
+
}
|
|
41073
|
+
},
|
|
41074
|
+
ZcashAddress: {
|
|
41075
|
+
fields: {
|
|
41076
|
+
address: {
|
|
41077
|
+
rule: "required",
|
|
41078
|
+
type: "string",
|
|
41079
|
+
id: 1
|
|
41080
|
+
},
|
|
41081
|
+
ufvk: {
|
|
41082
|
+
type: "string",
|
|
41083
|
+
id: 2
|
|
41084
|
+
},
|
|
41085
|
+
seed_fingerprint: {
|
|
41086
|
+
type: "bytes",
|
|
41087
|
+
id: 3
|
|
41088
|
+
}
|
|
41089
|
+
}
|
|
40899
41090
|
}
|
|
40900
41091
|
};
|
|
40901
41092
|
var MessagesProtocolV2JSON = {
|
|
@@ -41534,7 +41725,7 @@ const parseMessage = (messageData) => {
|
|
|
41534
41725
|
const createErrorMessage = (error) => {
|
|
41535
41726
|
let payload = { error: error.message, code: error.code };
|
|
41536
41727
|
if (error instanceof hdShared.HardwareError) {
|
|
41537
|
-
payload = { error: error.message, code: error.errorCode };
|
|
41728
|
+
payload = { error: error.message, code: error.errorCode, params: error.params };
|
|
41538
41729
|
}
|
|
41539
41730
|
return {
|
|
41540
41731
|
success: false,
|
|
@@ -41696,11 +41887,15 @@ const LogBlockEvent = new Set([
|
|
|
41696
41887
|
UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
41697
41888
|
]);
|
|
41698
41889
|
const LogPayloadBlockMethod = new Set([
|
|
41890
|
+
'btcDeriveContextHash',
|
|
41699
41891
|
'deviceUploadNft',
|
|
41700
41892
|
'deviceUploadWallpaper',
|
|
41701
41893
|
'uploadPortfolio',
|
|
41702
41894
|
'fileWrite',
|
|
41703
41895
|
'fileRead',
|
|
41896
|
+
'zcashGetAddress',
|
|
41897
|
+
'zcashGetUnifiedAddress',
|
|
41898
|
+
'zcashSignPczt',
|
|
41704
41899
|
]);
|
|
41705
41900
|
function getLogBlockLabel(message) {
|
|
41706
41901
|
if (!message || typeof message !== 'object')
|
|
@@ -43466,7 +43661,9 @@ class DevicePool extends events.exports {
|
|
|
43466
43661
|
const exist = canPathIdentifyDevice(cachedPath)
|
|
43467
43662
|
? descriptorList.find(d => d.path === cachedPath)
|
|
43468
43663
|
: undefined;
|
|
43469
|
-
if (exist &&
|
|
43664
|
+
if (exist &&
|
|
43665
|
+
!(initOptions === null || initOptions === void 0 ? void 0 : initOptions.forceProtocolDetection) &&
|
|
43666
|
+
!(device.needReloadDevice && device.isUnacquired())) {
|
|
43470
43667
|
device.updateDescriptor(exist, true);
|
|
43471
43668
|
yield this._refreshRuntimeState(device, initOptions);
|
|
43472
43669
|
devices[connectId] = device;
|
|
@@ -43522,7 +43719,11 @@ class DevicePool extends events.exports {
|
|
|
43522
43719
|
const forceProtocolDetection = (initOptions === null || initOptions === void 0 ? void 0 : initOptions.forceProtocolDetection) === true;
|
|
43523
43720
|
const isNewDevice = !cachedDevice;
|
|
43524
43721
|
const device = cachedDevice !== null && cachedDevice !== void 0 ? cachedDevice : Device.fromDescriptor(descriptor);
|
|
43525
|
-
if (isNewDevice ||
|
|
43722
|
+
if (isNewDevice ||
|
|
43723
|
+
forceProtocolDetection ||
|
|
43724
|
+
(device.needReloadDevice && device.isUnacquired())) {
|
|
43725
|
+
if (cachedDevice)
|
|
43726
|
+
device.updateDescriptor(descriptor, true);
|
|
43526
43727
|
device.deviceConnector = this.connector;
|
|
43527
43728
|
(_a = device.beginConnectionAttempt) === null || _a === void 0 ? void 0 : _a.call(device);
|
|
43528
43729
|
if (forceProtocolDetection && !isNewDevice) {
|
|
@@ -44209,6 +44410,12 @@ class DeviceCommands {
|
|
|
44209
44410
|
const isProtocolV2DeviceBusyFailure = this.device.isProtocolV2() &&
|
|
44210
44411
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
44211
44412
|
subcode === hdTransport.DeviceErrorCode.DeviceError_Busy;
|
|
44413
|
+
const isProtocolV2PinCancelledBusyFailure = this.device.isProtocolV2() &&
|
|
44414
|
+
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
44415
|
+
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
44416
|
+
/^pin cancelled$/i.test(normalizedMessage);
|
|
44417
|
+
const isProtocolV2FirmwareUpdateBusyFailure = this.device.isProtocolV2() &&
|
|
44418
|
+
/^requested command not allowed while a firmware update is in progress$/i.test(normalizedMessage);
|
|
44212
44419
|
const isLegacyProtocolV2LockedFailure = this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
44213
44420
|
if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
44214
44421
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_InvalidSession) {
|
|
@@ -44259,7 +44466,9 @@ class DeviceCommands {
|
|
|
44259
44466
|
firmwareMessage: message,
|
|
44260
44467
|
});
|
|
44261
44468
|
}
|
|
44262
|
-
else if (isProtocolV2DeviceBusyFailure
|
|
44469
|
+
else if (isProtocolV2DeviceBusyFailure ||
|
|
44470
|
+
isProtocolV2PinCancelledBusyFailure ||
|
|
44471
|
+
isProtocolV2FirmwareUpdateBusyFailure) {
|
|
44263
44472
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceBusy, message, {
|
|
44264
44473
|
failureCode: code,
|
|
44265
44474
|
subcode,
|
|
@@ -45486,6 +45695,7 @@ class Device extends events.exports {
|
|
|
45486
45695
|
this.connectionAttempt = 0;
|
|
45487
45696
|
this.interruptedAttempt = null;
|
|
45488
45697
|
this.stateStore = new DeviceStateStore();
|
|
45698
|
+
this.deviceBeforeWipe = null;
|
|
45489
45699
|
this.protocolV2StateNeedsReload = false;
|
|
45490
45700
|
this.protocolV2UiInteractionCounter = 0;
|
|
45491
45701
|
this.externalState = [];
|
|
@@ -45509,6 +45719,7 @@ class Device extends events.exports {
|
|
|
45509
45719
|
var _a;
|
|
45510
45720
|
if (this.isUnacquired() || !this.features)
|
|
45511
45721
|
return null;
|
|
45722
|
+
this.deviceBeforeWipe = null;
|
|
45512
45723
|
const env = DataManager.getSettings('env');
|
|
45513
45724
|
const deviceType = this.getCurrentDeviceType();
|
|
45514
45725
|
const bleName = this.getCurrentBleName();
|
|
@@ -45542,6 +45753,10 @@ class Device extends events.exports {
|
|
|
45542
45753
|
unavailableCapabilities: this.unavailableCapabilities,
|
|
45543
45754
|
};
|
|
45544
45755
|
}
|
|
45756
|
+
toDisconnectMessageObject() {
|
|
45757
|
+
var _a;
|
|
45758
|
+
return (_a = this.toMessageObject()) !== null && _a !== void 0 ? _a : this.deviceBeforeWipe;
|
|
45759
|
+
}
|
|
45545
45760
|
connect(connectProtocol, options) {
|
|
45546
45761
|
const env = DataManager.getSettings('env');
|
|
45547
45762
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -46293,6 +46508,8 @@ class Device extends events.exports {
|
|
|
46293
46508
|
this.invalidateProtocolV2RuntimeState();
|
|
46294
46509
|
}
|
|
46295
46510
|
invalidateAfterWipe() {
|
|
46511
|
+
var _a;
|
|
46512
|
+
this.deviceBeforeWipe = (_a = this.toMessageObject()) !== null && _a !== void 0 ? _a : this.deviceBeforeWipe;
|
|
46296
46513
|
const deviceId = this.getCurrentDeviceId();
|
|
46297
46514
|
if (deviceId) {
|
|
46298
46515
|
deviceWalletSessionStore.deleteDevice(deviceId);
|
|
@@ -46661,7 +46878,7 @@ class Device extends events.exports {
|
|
|
46661
46878
|
}
|
|
46662
46879
|
hasUnexpectedMode(allow, require) {
|
|
46663
46880
|
if (!this.isUnacquired()) {
|
|
46664
|
-
if (this.isBootloader()
|
|
46881
|
+
if ((this.isBootloader() || this.isRomloader()) && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
46665
46882
|
return UI_REQUEST.BOOTLOADER;
|
|
46666
46883
|
}
|
|
46667
46884
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -47472,7 +47689,7 @@ class GetDeviceState extends BaseMethod {
|
|
|
47472
47689
|
if (this.params.scope === 'settings' &&
|
|
47473
47690
|
this.device.isProtocolV2() &&
|
|
47474
47691
|
isLoaderMode(state.status.mode)) {
|
|
47475
|
-
throw hdShared.
|
|
47692
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NotAllowInBootloaderMode);
|
|
47476
47693
|
}
|
|
47477
47694
|
return state;
|
|
47478
47695
|
});
|
|
@@ -52591,12 +52808,11 @@ const getProtocolV2ErrorCode = (error) => {
|
|
|
52591
52808
|
};
|
|
52592
52809
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
52593
52810
|
var _a;
|
|
52594
|
-
return hdShared.
|
|
52595
|
-
(error
|
|
52596
|
-
|
|
52597
|
-
|
|
52598
|
-
|
|
52599
|
-
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE));
|
|
52811
|
+
return error instanceof hdShared.HardwareError &&
|
|
52812
|
+
(error.errorCode === hdShared.HardwareErrorCode.ActionCancelled ||
|
|
52813
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareError ||
|
|
52814
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareVerificationFailed ||
|
|
52815
|
+
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE);
|
|
52600
52816
|
};
|
|
52601
52817
|
const isProtocolV2TargetStatusFinished = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
|
|
52602
52818
|
const isProtocolV2TargetStatusInProgress = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_PENDING ||
|
|
@@ -53690,9 +53906,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53690
53906
|
return true;
|
|
53691
53907
|
}
|
|
53692
53908
|
catch (error) {
|
|
53693
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
53694
|
-
throw error;
|
|
53695
|
-
}
|
|
53696
53909
|
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53697
53910
|
return false;
|
|
53698
53911
|
}
|
|
@@ -53777,7 +53990,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53777
53990
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
53778
53991
|
}
|
|
53779
53992
|
catch (error) {
|
|
53780
|
-
if (
|
|
53993
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
53781
53994
|
throw error;
|
|
53782
53995
|
}
|
|
53783
53996
|
shouldReconnect = true;
|
|
@@ -53994,9 +54207,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53994
54207
|
}
|
|
53995
54208
|
catch (error) {
|
|
53996
54209
|
this.throwIfAborted();
|
|
53997
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
53998
|
-
throw error;
|
|
53999
|
-
}
|
|
54000
54210
|
lastError = error;
|
|
54001
54211
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
54002
54212
|
yield this.recoverProtocolV2FileTransfer();
|
|
@@ -54485,9 +54695,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54485
54695
|
}
|
|
54486
54696
|
}
|
|
54487
54697
|
catch (error) {
|
|
54488
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
54489
|
-
throw error;
|
|
54490
|
-
}
|
|
54491
54698
|
Log$6.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
54492
54699
|
}
|
|
54493
54700
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
@@ -54562,7 +54769,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54562
54769
|
lastError = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
|
|
54563
54770
|
}
|
|
54564
54771
|
catch (error) {
|
|
54565
|
-
if (
|
|
54772
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
54566
54773
|
throw error;
|
|
54567
54774
|
}
|
|
54568
54775
|
shouldReconnect = true;
|
|
@@ -54840,6 +55047,7 @@ class DeviceReboot extends BaseMethod {
|
|
|
54840
55047
|
return ['V2'];
|
|
54841
55048
|
}
|
|
54842
55049
|
init() {
|
|
55050
|
+
this.allowDeviceMode.push(UI_REQUEST.BOOTLOADER);
|
|
54843
55051
|
this.skipForceUpdateCheck = true;
|
|
54844
55052
|
this.useDevicePassphraseState = false;
|
|
54845
55053
|
this.unlockPolicy = 'unlock-before-run';
|
|
@@ -57136,6 +57344,72 @@ class BTCGetPublicKey extends BaseMethod {
|
|
|
57136
57344
|
}
|
|
57137
57345
|
}
|
|
57138
57346
|
|
|
57347
|
+
const NETWORKS = {
|
|
57348
|
+
'bitcoin-mainnet': 'BITCOIN_MAINNET',
|
|
57349
|
+
'bitcoin-testnet': 'BITCOIN_TESTNET',
|
|
57350
|
+
'bitcoin-signet': 'BITCOIN_SIGNET',
|
|
57351
|
+
'bitcoin-regtest': 'BITCOIN_REGTEST',
|
|
57352
|
+
};
|
|
57353
|
+
class BTCDeriveContextHash extends BaseMethod {
|
|
57354
|
+
constructor() {
|
|
57355
|
+
super(...arguments);
|
|
57356
|
+
this.strictCheckDeviceSupport = true;
|
|
57357
|
+
}
|
|
57358
|
+
init() {
|
|
57359
|
+
this.checkDeviceId = true;
|
|
57360
|
+
this.allowUsePreInitialize = true;
|
|
57361
|
+
validateParams(this.payload, [
|
|
57362
|
+
{ name: 'path', required: true },
|
|
57363
|
+
{ name: 'appName', type: 'string', required: true },
|
|
57364
|
+
{ name: 'context', type: 'string', required: true },
|
|
57365
|
+
{ name: 'network', type: 'string', required: true },
|
|
57366
|
+
]);
|
|
57367
|
+
const { path, appName, context, network } = this.payload;
|
|
57368
|
+
if (typeof appName !== 'string' || !/^[a-z0-9-]{1,64}$/.test(appName)) {
|
|
57369
|
+
throw invalidParameter('appName must contain 1..64 ASCII lowercase letters, digits or hyphens');
|
|
57370
|
+
}
|
|
57371
|
+
if (typeof context !== 'string' || !/^(?:[0-9a-f]{2}){1,1024}$/.test(context)) {
|
|
57372
|
+
throw invalidParameter('context must be 1..1024 bytes of lowercase hex without a prefix');
|
|
57373
|
+
}
|
|
57374
|
+
if (typeof network !== 'string' || !Object.prototype.hasOwnProperty.call(NETWORKS, network)) {
|
|
57375
|
+
throw invalidParameter('Unsupported Bitcoin network');
|
|
57376
|
+
}
|
|
57377
|
+
if ((typeof path === 'string' &&
|
|
57378
|
+
(!/^m(?:\/\d+'?)+$/i.test(path) ||
|
|
57379
|
+
path
|
|
57380
|
+
.split('/')
|
|
57381
|
+
.slice(1)
|
|
57382
|
+
.some(index => Number(index.replace(/'/g, '')) >= 0x80000000))) ||
|
|
57383
|
+
(Array.isArray(path) &&
|
|
57384
|
+
path.findIndex(index => !Number.isInteger(index) || index < 0 || index > 0xffffffff) !== -1)) {
|
|
57385
|
+
throw invalidParameter('Not a valid BIP-32 path');
|
|
57386
|
+
}
|
|
57387
|
+
const addressN = validatePath(path, 3);
|
|
57388
|
+
this.params = {
|
|
57389
|
+
address_n: addressN,
|
|
57390
|
+
script_type: getScriptType(addressN),
|
|
57391
|
+
app_name: buffer.Buffer.from(appName, 'ascii').toString('hex'),
|
|
57392
|
+
context,
|
|
57393
|
+
network: NETWORKS[network],
|
|
57394
|
+
};
|
|
57395
|
+
}
|
|
57396
|
+
getVersionRange() {
|
|
57397
|
+
return {
|
|
57398
|
+
classic1s: { min: '3.21.0' },
|
|
57399
|
+
classicpure: { min: '3.21.0' },
|
|
57400
|
+
};
|
|
57401
|
+
}
|
|
57402
|
+
run() {
|
|
57403
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57404
|
+
const { message } = yield this.device.commands.typedCall('BabylonDeriveContextHash', 'BabylonDerivedContextHash', this.params);
|
|
57405
|
+
if (typeof message.secret !== 'string' || !/^[0-9a-f]{64}$/.test(message.secret)) {
|
|
57406
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodError, 'Invalid Babylon context hash response');
|
|
57407
|
+
}
|
|
57408
|
+
return message;
|
|
57409
|
+
});
|
|
57410
|
+
}
|
|
57411
|
+
}
|
|
57412
|
+
|
|
57139
57413
|
class BTCSignMessage extends BaseMethod {
|
|
57140
57414
|
getSupportedProtocols() {
|
|
57141
57415
|
var _a;
|
|
@@ -65434,6 +65708,189 @@ class NeoSignTransaction extends BaseMethod {
|
|
|
65434
65708
|
}
|
|
65435
65709
|
}
|
|
65436
65710
|
|
|
65711
|
+
class ZcashGetAddress extends BaseMethod {
|
|
65712
|
+
constructor() {
|
|
65713
|
+
super(...arguments);
|
|
65714
|
+
this.hasBundle = false;
|
|
65715
|
+
}
|
|
65716
|
+
getSupportedProtocols() {
|
|
65717
|
+
return ['V2'];
|
|
65718
|
+
}
|
|
65719
|
+
init() {
|
|
65720
|
+
var _a;
|
|
65721
|
+
this.checkDeviceId = true;
|
|
65722
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
65723
|
+
this.strictCheckDeviceSupport = true;
|
|
65724
|
+
this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
|
|
65725
|
+
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
65726
|
+
validateParams(payload, [{ name: 'bundle', type: 'array' }]);
|
|
65727
|
+
this.params = [];
|
|
65728
|
+
payload.bundle.forEach((batch) => {
|
|
65729
|
+
var _a, _b, _c, _d, _e, _f;
|
|
65730
|
+
const addressN = validatePath(batch.path, 3);
|
|
65731
|
+
if (addressN.length !== 3 ||
|
|
65732
|
+
addressN[0] !== toHardened(32) ||
|
|
65733
|
+
addressN[1] !== toHardened(133) ||
|
|
65734
|
+
addressN[2] < toHardened(0) ||
|
|
65735
|
+
addressN[2] > 0xffffffff) {
|
|
65736
|
+
throw invalidParameter("Zcash requires a ZIP-32 account path m/32'/133'/account'");
|
|
65737
|
+
}
|
|
65738
|
+
const addressType = (_a = batch.addressType) !== null && _a !== void 0 ? _a : hdTransport.ZcashAddressType.UNIFIED_ORCHARD_P2PKH;
|
|
65739
|
+
const scope = (_b = batch.scope) !== null && _b !== void 0 ? _b : hdTransport.ZcashAddressScope.EXTERNAL;
|
|
65740
|
+
const diversifierIndex = (_c = batch.diversifierIndex) !== null && _c !== void 0 ? _c : 0;
|
|
65741
|
+
if (![
|
|
65742
|
+
hdTransport.ZcashAddressType.UNIFIED_ORCHARD_P2PKH,
|
|
65743
|
+
hdTransport.ZcashAddressType.TRANSPARENT_P2PKH,
|
|
65744
|
+
hdTransport.ZcashAddressType.UNIFIED_ORCHARD,
|
|
65745
|
+
].includes(addressType) ||
|
|
65746
|
+
![hdTransport.ZcashAddressScope.EXTERNAL, hdTransport.ZcashAddressScope.INTERNAL].includes(scope)) {
|
|
65747
|
+
throw invalidParameter('Invalid Zcash address type or scope');
|
|
65748
|
+
}
|
|
65749
|
+
const maxIndex = addressType === hdTransport.ZcashAddressType.UNIFIED_ORCHARD ? 0xffffffff : 0x7fffffff;
|
|
65750
|
+
if (!Number.isSafeInteger(diversifierIndex) ||
|
|
65751
|
+
diversifierIndex < 0 ||
|
|
65752
|
+
diversifierIndex > maxIndex) {
|
|
65753
|
+
throw invalidParameter('Invalid Zcash diversifier index');
|
|
65754
|
+
}
|
|
65755
|
+
validateParams(batch, [
|
|
65756
|
+
{ name: 'path', required: true },
|
|
65757
|
+
{ name: 'showOnOneKey', type: 'boolean' },
|
|
65758
|
+
{ name: 'includeUfvk', type: 'boolean' },
|
|
65759
|
+
{ name: 'includeSeedFingerprint', type: 'boolean' },
|
|
65760
|
+
]);
|
|
65761
|
+
this.params.push({
|
|
65762
|
+
address_n: addressN,
|
|
65763
|
+
address_type: addressType,
|
|
65764
|
+
scope,
|
|
65765
|
+
diversifier_index: diversifierIndex,
|
|
65766
|
+
show_display: (_d = batch.showOnOneKey) !== null && _d !== void 0 ? _d : true,
|
|
65767
|
+
include_ufvk: (_e = batch.includeUfvk) !== null && _e !== void 0 ? _e : false,
|
|
65768
|
+
include_seed_fingerprint: (_f = batch.includeSeedFingerprint) !== null && _f !== void 0 ? _f : false,
|
|
65769
|
+
});
|
|
65770
|
+
});
|
|
65771
|
+
}
|
|
65772
|
+
getVersionRange() {
|
|
65773
|
+
return {
|
|
65774
|
+
model_pro2: {
|
|
65775
|
+
min: '0.0.0',
|
|
65776
|
+
},
|
|
65777
|
+
};
|
|
65778
|
+
}
|
|
65779
|
+
run() {
|
|
65780
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65781
|
+
const responses = [];
|
|
65782
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
65783
|
+
const param = this.params[i];
|
|
65784
|
+
const res = yield this.device.commands.typedCall('ZcashGetAddress', 'ZcashAddress', Object.assign({}, param));
|
|
65785
|
+
const path = serializedPath(param.address_n);
|
|
65786
|
+
responses.push({
|
|
65787
|
+
path,
|
|
65788
|
+
address: res.message.address,
|
|
65789
|
+
ufvk: res.message.ufvk,
|
|
65790
|
+
seedFingerprint: res.message.seed_fingerprint,
|
|
65791
|
+
});
|
|
65792
|
+
this.postPreviousAddressMessage({
|
|
65793
|
+
address: res.message.address,
|
|
65794
|
+
path,
|
|
65795
|
+
});
|
|
65796
|
+
}
|
|
65797
|
+
validateResult(responses, ['address'], {
|
|
65798
|
+
expectedLength: this.params.length,
|
|
65799
|
+
});
|
|
65800
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
65801
|
+
});
|
|
65802
|
+
}
|
|
65803
|
+
}
|
|
65804
|
+
|
|
65805
|
+
const ZCASH_PCZT_MAX_BYTES = 24 * 1024;
|
|
65806
|
+
const CHUNK_BYTE_SIZE = 1024;
|
|
65807
|
+
class ZcashSignPczt extends BaseMethod {
|
|
65808
|
+
constructor() {
|
|
65809
|
+
super(...arguments);
|
|
65810
|
+
this.pczt = Buffer.alloc(0);
|
|
65811
|
+
this.uploadPczt = (typedCall, res, offset) => __awaiter(this, void 0, void 0, function* () {
|
|
65812
|
+
if (res.type === 'ZcashSignedPczt') {
|
|
65813
|
+
if (offset !== this.pczt.length) {
|
|
65814
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ResponseUnexpectTypeError, 'device completed signing before receiving the whole pczt');
|
|
65815
|
+
}
|
|
65816
|
+
return res;
|
|
65817
|
+
}
|
|
65818
|
+
const { chunk_length: chunkLength } = res.message;
|
|
65819
|
+
if (!Number.isSafeInteger(chunkLength) ||
|
|
65820
|
+
chunkLength <= 0 ||
|
|
65821
|
+
offset + chunkLength > this.pczt.length) {
|
|
65822
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ResponseUnexpectTypeError, `device requested ${chunkLength} bytes at offset ${offset} of ${this.pczt.length}`);
|
|
65823
|
+
}
|
|
65824
|
+
const chunk = this.pczt.subarray(offset, offset + chunkLength);
|
|
65825
|
+
const next = yield typedCall('ZcashPcztChunkAck', ['ZcashSignedPczt', 'ZcashPcztChunkRequest'], {
|
|
65826
|
+
data_chunk: utils.bytesToHex(chunk),
|
|
65827
|
+
});
|
|
65828
|
+
return this.uploadPczt(typedCall, next, offset + chunkLength);
|
|
65829
|
+
});
|
|
65830
|
+
this.downloadSignedPczt = (typedCall, res) => __awaiter(this, void 0, void 0, function* () {
|
|
65831
|
+
var _a;
|
|
65832
|
+
const { pczt_length: total, pczt_initial_chunk: initial } = res.message;
|
|
65833
|
+
if (!Number.isSafeInteger(total) || total <= 0 || total > ZCASH_PCZT_MAX_BYTES) {
|
|
65834
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ResponseUnexpectTypeError, `device announced invalid signed pczt length ${total}`);
|
|
65835
|
+
}
|
|
65836
|
+
const parts = [Buffer.from(initial !== null && initial !== void 0 ? initial : '', 'hex')];
|
|
65837
|
+
let received = parts[0].length;
|
|
65838
|
+
if (received > total) {
|
|
65839
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ResponseUnexpectTypeError, 'device returned more initial pczt bytes than announced');
|
|
65840
|
+
}
|
|
65841
|
+
while (received < total) {
|
|
65842
|
+
const chunkLength = Math.min(CHUNK_BYTE_SIZE, total - received);
|
|
65843
|
+
const ack = yield typedCall('ZcashSignedPcztChunkRequest', 'ZcashPcztChunkAck', {
|
|
65844
|
+
chunk_length: chunkLength,
|
|
65845
|
+
});
|
|
65846
|
+
const chunk = Buffer.from((_a = ack.message.data_chunk) !== null && _a !== void 0 ? _a : '', 'hex');
|
|
65847
|
+
if (chunk.length === 0 || received + chunk.length > total) {
|
|
65848
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ResponseUnexpectTypeError, `device returned ${chunk.length} bytes at offset ${received} of ${total}`);
|
|
65849
|
+
}
|
|
65850
|
+
parts.push(chunk);
|
|
65851
|
+
received += chunk.length;
|
|
65852
|
+
}
|
|
65853
|
+
return Buffer.concat(parts);
|
|
65854
|
+
});
|
|
65855
|
+
}
|
|
65856
|
+
getSupportedProtocols() {
|
|
65857
|
+
return ['V2'];
|
|
65858
|
+
}
|
|
65859
|
+
init() {
|
|
65860
|
+
this.checkDeviceId = true;
|
|
65861
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
65862
|
+
this.strictCheckDeviceSupport = true;
|
|
65863
|
+
validateParams(this.payload, [{ name: 'pczt', type: 'hexString', required: true }]);
|
|
65864
|
+
this.pczt = Buffer.from(formatAnyHex(this.payload.pczt), 'hex');
|
|
65865
|
+
if (this.pczt.length === 0) {
|
|
65866
|
+
throw invalidParameter('pczt is empty');
|
|
65867
|
+
}
|
|
65868
|
+
if (this.pczt.length > ZCASH_PCZT_MAX_BYTES) {
|
|
65869
|
+
throw invalidParameter(`pczt exceeds ${ZCASH_PCZT_MAX_BYTES} bytes (${this.pczt.length})`);
|
|
65870
|
+
}
|
|
65871
|
+
this.params = {
|
|
65872
|
+
pczt_length: this.pczt.length,
|
|
65873
|
+
pczt_initial_chunk: utils.bytesToHex(this.pczt.subarray(0, CHUNK_BYTE_SIZE)),
|
|
65874
|
+
};
|
|
65875
|
+
}
|
|
65876
|
+
getVersionRange() {
|
|
65877
|
+
return {
|
|
65878
|
+
model_pro2: {
|
|
65879
|
+
min: '0.0.0',
|
|
65880
|
+
},
|
|
65881
|
+
};
|
|
65882
|
+
}
|
|
65883
|
+
run() {
|
|
65884
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65885
|
+
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
65886
|
+
const first = yield typedCall('ZcashSignPczt', ['ZcashSignedPczt', 'ZcashPcztChunkRequest'], Object.assign({}, this.params));
|
|
65887
|
+
const signed = yield this.uploadPczt(typedCall, first, Math.min(CHUNK_BYTE_SIZE, this.pczt.length));
|
|
65888
|
+
const pczt = yield this.downloadSignedPczt(typedCall, signed);
|
|
65889
|
+
return { pczt: utils.bytesToHex(pczt) };
|
|
65890
|
+
});
|
|
65891
|
+
}
|
|
65892
|
+
}
|
|
65893
|
+
|
|
65437
65894
|
var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
65438
65895
|
__proto__: null,
|
|
65439
65896
|
testInitializeDeviceDuration: TestInitializeDeviceDuration,
|
|
@@ -65490,6 +65947,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
65490
65947
|
allNetworkGetAddressByLoop: AllNetworkGetAddressByLoop,
|
|
65491
65948
|
btcGetAddress: BTCGetAddress,
|
|
65492
65949
|
btcGetPublicKey: BTCGetPublicKey,
|
|
65950
|
+
btcDeriveContextHash: BTCDeriveContextHash,
|
|
65493
65951
|
btcSignMessage: BTCSignMessage,
|
|
65494
65952
|
btcSignPsbt: BTCSignPsbt,
|
|
65495
65953
|
btcSignTransaction: BTCSignTransaction,
|
|
@@ -65576,7 +66034,9 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
65576
66034
|
benfenSignMessage: BenfenSignMessage,
|
|
65577
66035
|
benfenSignTransaction: BenfenSignTransaction,
|
|
65578
66036
|
neoGetAddress: NeoGetAddress,
|
|
65579
|
-
neoSignTransaction: NeoSignTransaction
|
|
66037
|
+
neoSignTransaction: NeoSignTransaction,
|
|
66038
|
+
zcashGetAddress: ZcashGetAddress,
|
|
66039
|
+
zcashSignPczt: ZcashSignPczt
|
|
65580
66040
|
});
|
|
65581
66041
|
|
|
65582
66042
|
const publicMethodRegistry = ApiMethods;
|
|
@@ -66683,9 +67143,6 @@ function isMissingDetectedProtocolV2Error(method, error) {
|
|
|
66683
67143
|
typeof typedError.message === 'string' &&
|
|
66684
67144
|
typedError.message.includes('Device protocol has not been detected'));
|
|
66685
67145
|
}
|
|
66686
|
-
function isTerminalBleStaleBondError(error) {
|
|
66687
|
-
return hdShared.isBleStaleBondHardwareError(error);
|
|
66688
|
-
}
|
|
66689
67146
|
function isDeviceIdentityMismatchError(error) {
|
|
66690
67147
|
return ((error === null || error === void 0 ? void 0 : error.errorCode) === hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
66691
67148
|
}
|
|
@@ -66850,6 +67307,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66850
67307
|
hdShared.HardwareErrorCode.BridgeNotInstalled,
|
|
66851
67308
|
hdShared.HardwareErrorCode.BridgeTimeoutError,
|
|
66852
67309
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
67310
|
+
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
66853
67311
|
].includes(error.errorCode)) {
|
|
66854
67312
|
_deviceList = undefined;
|
|
66855
67313
|
reject(error);
|
|
@@ -66924,12 +67382,12 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66924
67382
|
hdShared.HardwareErrorCode.DeviceDetectInBootloaderMode,
|
|
66925
67383
|
hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
|
|
66926
67384
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
67385
|
+
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
66927
67386
|
hdShared.HardwareErrorCode.DeviceInterruptedFromUser,
|
|
66928
67387
|
hdShared.HardwareErrorCode.CallQueueActionCancelled,
|
|
66929
67388
|
].includes(error.errorCode) ||
|
|
66930
67389
|
(env === 'react-native' &&
|
|
66931
67390
|
[hdShared.HardwareErrorCode.BleDeviceDisconnected, hdShared.HardwareErrorCode.PollingTimeout].includes(error.errorCode)) ||
|
|
66932
|
-
isTerminalBleStaleBondError(error) ||
|
|
66933
67391
|
isDeviceIdentityMismatchError(error)) {
|
|
66934
67392
|
reject(error);
|
|
66935
67393
|
return;
|
|
@@ -67089,7 +67547,7 @@ const onDeviceConnectHandler = (device) => {
|
|
|
67089
67547
|
};
|
|
67090
67548
|
const onDeviceDisconnectHandler = (device) => {
|
|
67091
67549
|
device.clearPreInitialized();
|
|
67092
|
-
const deviceObject = device.
|
|
67550
|
+
const deviceObject = device.toDisconnectMessageObject();
|
|
67093
67551
|
if (!deviceObject)
|
|
67094
67552
|
return;
|
|
67095
67553
|
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|