@onekeyfe/hd-core 1.1.27-alpha.31 → 1.1.27-alpha.33
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 +319 -9
- 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.map +1 -1
- package/dist/api/PathInfo.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/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- 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 +2 -2
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +185 -83
- package/dist/protocols/protocol-v2/features.d.ts +1 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +4 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -0
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/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/GetPassphraseState.ts +5 -1
- package/src/api/PathInfo.ts +2 -1
- 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 +4 -4
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/helpers/filesystemValidation.ts +51 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +2 -1
- package/src/api/protocol-v2/helpers.ts +34 -11
- package/src/core/index.ts +12 -4
- package/src/data-manager/DataManager.ts +7 -7
- package/src/data-manager/MessagesConfig.ts +6 -6
- package/src/data-manager/TransportManager.ts +4 -4
- package/src/device/Device.ts +2 -2
- package/src/protocols/protocol-v2/features.ts +37 -40
- package/src/protocols/protocol-v2/firmware.ts +1 -1
- package/src/types/api/getPassphraseState.ts +5 -1
- package/src/types/api/index.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +26 -10
- /package/src/data/messages/{messages-pro2.json → messages-protocol-v2.json} +0 -0
package/dist/index.js
CHANGED
|
@@ -38515,7 +38515,7 @@ var nested = {
|
|
|
38515
38515
|
}
|
|
38516
38516
|
}
|
|
38517
38517
|
};
|
|
38518
|
-
var
|
|
38518
|
+
var MessagesProtocolV2JSON = {
|
|
38519
38519
|
nested: nested
|
|
38520
38520
|
};
|
|
38521
38521
|
|
|
@@ -38670,7 +38670,7 @@ class DataManager {
|
|
|
38670
38670
|
}
|
|
38671
38671
|
});
|
|
38672
38672
|
}
|
|
38673
|
-
static getProtobufMessages(schema = '
|
|
38673
|
+
static getProtobufMessages(schema = 'v1CurrentSchema') {
|
|
38674
38674
|
return this.messages[schema];
|
|
38675
38675
|
}
|
|
38676
38676
|
static getSettings(key) {
|
|
@@ -38711,9 +38711,9 @@ DataManager.deviceMap = {
|
|
|
38711
38711
|
};
|
|
38712
38712
|
DataManager.assets = null;
|
|
38713
38713
|
DataManager.messages = {
|
|
38714
|
-
|
|
38715
|
-
|
|
38716
|
-
|
|
38714
|
+
v1CurrentSchema: MessagesJSON,
|
|
38715
|
+
v1LegacySchema: MessagesLegacyV1JSON,
|
|
38716
|
+
v2Schema: MessagesProtocolV2JSON,
|
|
38717
38717
|
};
|
|
38718
38718
|
DataManager.lastCheckTimestamp = 0;
|
|
38719
38719
|
DataManager.getFirmwareStatus = (features, firmwareType) => {
|
|
@@ -38912,14 +38912,14 @@ DataManager.isBrowserWebUsb = (env) => env === 'webusb';
|
|
|
38912
38912
|
|
|
38913
38913
|
const PROTOBUF_MESSAGE_CONFIG = {
|
|
38914
38914
|
model_mini: [
|
|
38915
|
-
{ minVersion: '3.3.0', protocolV1MessageSchema: '
|
|
38916
|
-
{ minVersion: '0.0.1', protocolV1MessageSchema: '
|
|
38917
|
-
{ minVersion: '0.0.0', protocolV1MessageSchema: '
|
|
38915
|
+
{ minVersion: '3.3.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38916
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
|
|
38917
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38918
38918
|
],
|
|
38919
38919
|
model_touch: [
|
|
38920
|
-
{ minVersion: '4.5.0', protocolV1MessageSchema: '
|
|
38921
|
-
{ minVersion: '0.0.1', protocolV1MessageSchema: '
|
|
38922
|
-
{ minVersion: '0.0.0', protocolV1MessageSchema: '
|
|
38920
|
+
{ minVersion: '4.5.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38921
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
|
|
38922
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
38923
38923
|
],
|
|
38924
38924
|
};
|
|
38925
38925
|
|
|
@@ -38927,8 +38927,8 @@ const getSupportProtocolV1MessageSchema = (features) => {
|
|
|
38927
38927
|
var _a;
|
|
38928
38928
|
if (!features)
|
|
38929
38929
|
return {
|
|
38930
|
-
messages: DataManager.messages.
|
|
38931
|
-
protocolV1MessageSchema: '
|
|
38930
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
38931
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
38932
38932
|
};
|
|
38933
38933
|
const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
|
|
38934
38934
|
const deviceType = getDeviceType(features);
|
|
@@ -38947,8 +38947,8 @@ const getSupportProtocolV1MessageSchema = (features) => {
|
|
|
38947
38947
|
}
|
|
38948
38948
|
}
|
|
38949
38949
|
return {
|
|
38950
|
-
messages: DataManager.messages.
|
|
38951
|
-
protocolV1MessageSchema: '
|
|
38950
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
38951
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
38952
38952
|
};
|
|
38953
38953
|
};
|
|
38954
38954
|
const supportInputPinOnSoftware = (features) => {
|
|
@@ -38986,8 +38986,10 @@ const getPassphraseStateWithRefreshDeviceInfo = (device, options) => __awaiter(v
|
|
|
38986
38986
|
if (needRefreshWithLocked || needRefreshWithPassphrase) {
|
|
38987
38987
|
yield device.getFeatures();
|
|
38988
38988
|
}
|
|
38989
|
-
if (isPro2 && device.features
|
|
38990
|
-
|
|
38989
|
+
if (isPro2 && device.features) {
|
|
38990
|
+
if (passphraseState) {
|
|
38991
|
+
device.features.passphrase_protection = true;
|
|
38992
|
+
}
|
|
38991
38993
|
if (newSession) {
|
|
38992
38994
|
device.features.session_id = newSession;
|
|
38993
38995
|
}
|
|
@@ -39007,9 +39009,13 @@ const getPassphraseState = (features, commands, options) => __awaiter(void 0, vo
|
|
|
39007
39009
|
deviceType === hdShared.EDeviceType.Pro2 ||
|
|
39008
39010
|
(deviceType === hdShared.EDeviceType.Pro && semver__default["default"].gte(firmwareVersion.join('.'), '4.15.0'));
|
|
39009
39011
|
if (supportGetPassphraseState) {
|
|
39010
|
-
const
|
|
39011
|
-
|
|
39012
|
-
|
|
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);
|
|
39013
39019
|
if (type === 'CallMethodError') {
|
|
39014
39020
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
39015
39021
|
}
|
|
@@ -40150,7 +40156,7 @@ class TransportManager {
|
|
|
40150
40156
|
Log$d.debug('transport manager load');
|
|
40151
40157
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
40152
40158
|
this.currentMessages = this.defaultMessages;
|
|
40153
|
-
this.protocolV1MessageSchema = '
|
|
40159
|
+
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
40154
40160
|
}
|
|
40155
40161
|
static configure() {
|
|
40156
40162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40187,7 +40193,7 @@ class TransportManager {
|
|
|
40187
40193
|
Log$d.debug('Configuring transports');
|
|
40188
40194
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
40189
40195
|
this.currentMessages = this.defaultMessages;
|
|
40190
|
-
this.protocolV1MessageSchema = '
|
|
40196
|
+
this.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
40191
40197
|
yield this.configureProtocolV2Messages();
|
|
40192
40198
|
Log$d.debug('Configuring transports done');
|
|
40193
40199
|
}
|
|
@@ -40240,7 +40246,7 @@ class TransportManager {
|
|
|
40240
40246
|
}
|
|
40241
40247
|
static configureProtocolV2Messages() {
|
|
40242
40248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40243
|
-
const protocolV2Messages = DataManager.getProtobufMessages('
|
|
40249
|
+
const protocolV2Messages = DataManager.getProtobufMessages('v2Schema');
|
|
40244
40250
|
const { configureProtocolV2 } = this.transport;
|
|
40245
40251
|
if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
|
|
40246
40252
|
yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
|
|
@@ -40259,7 +40265,7 @@ class TransportManager {
|
|
|
40259
40265
|
}
|
|
40260
40266
|
}
|
|
40261
40267
|
TransportManager.reactNativeInit = false;
|
|
40262
|
-
TransportManager.protocolV1MessageSchema = '
|
|
40268
|
+
TransportManager.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
40263
40269
|
TransportManager.plugin = null;
|
|
40264
40270
|
|
|
40265
40271
|
const MAX_DEBUG_ARRAY_ITEMS = 20;
|
|
@@ -40817,6 +40823,24 @@ class DeviceCommands {
|
|
|
40817
40823
|
}
|
|
40818
40824
|
}
|
|
40819
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
|
+
};
|
|
40820
40844
|
function parseVersion(version) {
|
|
40821
40845
|
if (!version)
|
|
40822
40846
|
return [0, 0, 0];
|
|
@@ -40917,7 +40941,7 @@ function normalizeProtocolV2Features(descriptor, deviceInfo) {
|
|
|
40917
40941
|
const [fwMajor, fwMinor, fwPatch] = parseVersion(firmwareVersion);
|
|
40918
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) });
|
|
40919
40943
|
}
|
|
40920
|
-
function getProtocolV2Features({ commands, descriptor, timeoutMs, }) {
|
|
40944
|
+
function getProtocolV2Features({ commands, descriptor, onDeviceInfoError, timeoutMs, }) {
|
|
40921
40945
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40922
40946
|
const callOptions = timeoutMs ? { timeoutMs } : undefined;
|
|
40923
40947
|
if (callOptions) {
|
|
@@ -40926,7 +40950,16 @@ function getProtocolV2Features({ commands, descriptor, timeoutMs, }) {
|
|
|
40926
40950
|
else {
|
|
40927
40951
|
yield commands.typedCall('Ping', 'Success', { message: 'init' });
|
|
40928
40952
|
}
|
|
40929
|
-
|
|
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
|
+
}
|
|
40930
40963
|
});
|
|
40931
40964
|
}
|
|
40932
40965
|
|
|
@@ -41957,7 +41990,11 @@ class GetPassphraseState extends BaseMethod {
|
|
|
41957
41990
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41958
41991
|
if (!this.device.features)
|
|
41959
41992
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed));
|
|
41960
|
-
const { passphraseState, newSession, unlockedAttachPin } = 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
|
+
});
|
|
41961
41998
|
const { features } = this.device;
|
|
41962
41999
|
const isPro2 = getDeviceType(features) === hdShared.EDeviceType.Pro2;
|
|
41963
42000
|
if (isPro2) {
|
|
@@ -42348,37 +42385,37 @@ function parseChainId(chainId) {
|
|
|
42348
42385
|
throw new Error(`Invalid chainId ${chainId}`);
|
|
42349
42386
|
}
|
|
42350
42387
|
|
|
42351
|
-
const invalidParameter = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
42388
|
+
const invalidParameter$1 = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
42352
42389
|
const invalidResponse = (message) => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodError, message);
|
|
42353
42390
|
const validateParams = (values, fields) => {
|
|
42354
42391
|
fields.forEach(field => {
|
|
42355
42392
|
const existsProp = Object.prototype.hasOwnProperty.call(values, field.name);
|
|
42356
42393
|
if (!existsProp && field.required) {
|
|
42357
|
-
throw invalidParameter(`Missing required parameter: ${field.name}`);
|
|
42394
|
+
throw invalidParameter$1(`Missing required parameter: ${field.name}`);
|
|
42358
42395
|
}
|
|
42359
42396
|
const value = values[field.name];
|
|
42360
42397
|
if (value && field.type) {
|
|
42361
42398
|
switch (field.type) {
|
|
42362
42399
|
case 'array':
|
|
42363
42400
|
if (!Array.isArray(value)) {
|
|
42364
|
-
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}].`);
|
|
42365
42402
|
}
|
|
42366
42403
|
else if (!field.allowEmpty && value.length < 1) {
|
|
42367
|
-
throw invalidParameter(`Parameter "${field.name}" is empty.`);
|
|
42404
|
+
throw invalidParameter$1(`Parameter "${field.name}" is empty.`);
|
|
42368
42405
|
}
|
|
42369
42406
|
break;
|
|
42370
42407
|
case 'uint':
|
|
42371
42408
|
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
42372
|
-
throw invalidParameter(`Parameter [${field.name}] has invalid type. "string|number" expected.`);
|
|
42409
|
+
throw invalidParameter$1(`Parameter [${field.name}] has invalid type. "string|number" expected.`);
|
|
42373
42410
|
}
|
|
42374
42411
|
if ((typeof value === 'number' && !Number.isSafeInteger(value)) ||
|
|
42375
42412
|
!/^(?:[1-9]\d*|\d)$/.test(value.toString().replace(/^-/, field.allowNegative ? '' : '-'))) {
|
|
42376
|
-
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.`);
|
|
42377
42414
|
}
|
|
42378
42415
|
break;
|
|
42379
42416
|
case 'bigNumber':
|
|
42380
42417
|
if (typeof value !== 'string') {
|
|
42381
|
-
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].`);
|
|
42382
42419
|
}
|
|
42383
42420
|
try {
|
|
42384
42421
|
const bn = new BigNumber__default["default"](value);
|
|
@@ -42387,12 +42424,12 @@ const validateParams = (values, fields) => {
|
|
|
42387
42424
|
}
|
|
42388
42425
|
}
|
|
42389
42426
|
catch (error) {
|
|
42390
|
-
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}].`);
|
|
42391
42428
|
}
|
|
42392
42429
|
break;
|
|
42393
42430
|
case 'buffer': {
|
|
42394
42431
|
if (typeof value === 'undefined' || value === null) {
|
|
42395
|
-
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].`);
|
|
42396
42433
|
}
|
|
42397
42434
|
const isNodeBuffer = typeof Buffer !== 'undefined' &&
|
|
42398
42435
|
typeof Buffer.isBuffer === 'function' &&
|
|
@@ -42405,18 +42442,18 @@ const validateParams = (values, fields) => {
|
|
|
42405
42442
|
typeof ArrayBuffer.isView === 'function' &&
|
|
42406
42443
|
ArrayBuffer.isView(value);
|
|
42407
42444
|
if (!isNodeBuffer && !isCustomBuffer && !isArrayBuffer && !isArrayBufferView) {
|
|
42408
|
-
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].`);
|
|
42409
42446
|
}
|
|
42410
42447
|
break;
|
|
42411
42448
|
}
|
|
42412
42449
|
case 'hexString':
|
|
42413
42450
|
if (typeof value !== 'string' || !isHexString(addHexPrefix(value))) {
|
|
42414
|
-
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}].`);
|
|
42415
42452
|
}
|
|
42416
42453
|
break;
|
|
42417
42454
|
default:
|
|
42418
42455
|
if (typeof value !== field.type) {
|
|
42419
|
-
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}].`);
|
|
42420
42457
|
}
|
|
42421
42458
|
break;
|
|
42422
42459
|
}
|
|
@@ -44730,6 +44767,45 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
44730
44767
|
}
|
|
44731
44768
|
}
|
|
44732
44769
|
|
|
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
|
+
|
|
44733
44809
|
const DEVICE_REBOOT_TYPES = {
|
|
44734
44810
|
Normal: hdTransport.DeviceRebootType.Normal,
|
|
44735
44811
|
normal: hdTransport.DeviceRebootType.Normal,
|
|
@@ -44754,13 +44830,19 @@ function normalizeRebootType(value) {
|
|
|
44754
44830
|
}
|
|
44755
44831
|
return hdTransport.DeviceRebootType.Normal;
|
|
44756
44832
|
}
|
|
44757
|
-
function normalizeTargetId(value) {
|
|
44758
|
-
if (
|
|
44759
|
-
|
|
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
|
+
}
|
|
44760
44842
|
const numeric = Number(value);
|
|
44761
|
-
if (Number.
|
|
44843
|
+
if (Number.isSafeInteger(numeric) && numeric > 0)
|
|
44762
44844
|
return numeric;
|
|
44763
|
-
|
|
44845
|
+
throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
|
|
44764
44846
|
}
|
|
44765
44847
|
function normalizeFirmwareTargets(params) {
|
|
44766
44848
|
var _a, _b, _c;
|
|
@@ -44772,10 +44854,20 @@ function normalizeFirmwareTargets(params) {
|
|
|
44772
44854
|
},
|
|
44773
44855
|
]
|
|
44774
44856
|
: []);
|
|
44775
|
-
|
|
44776
|
-
|
|
44777
|
-
|
|
44778
|
-
|
|
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
|
+
});
|
|
44779
44871
|
}
|
|
44780
44872
|
function buildTargets(params) {
|
|
44781
44873
|
if (params.targets)
|
|
@@ -45600,8 +45692,9 @@ class DeviceFirmwareUpdate extends BaseMethod {
|
|
|
45600
45692
|
}
|
|
45601
45693
|
run() {
|
|
45602
45694
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45695
|
+
const targets = normalizeFirmwareTargets(this.params);
|
|
45603
45696
|
const res = yield this.device.commands.typedCall('DeviceFirmwareUpdate', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
|
|
45604
|
-
targets
|
|
45697
|
+
targets,
|
|
45605
45698
|
}, PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS);
|
|
45606
45699
|
return Promise.resolve(res.message);
|
|
45607
45700
|
});
|
|
@@ -45740,15 +45833,15 @@ function toUint8Array(value) {
|
|
|
45740
45833
|
}
|
|
45741
45834
|
class FileRead extends BaseMethod {
|
|
45742
45835
|
init() {
|
|
45743
|
-
var _a, _b;
|
|
45744
45836
|
this.skipForceUpdateCheck = true;
|
|
45745
45837
|
this.useDevicePassphraseState = false;
|
|
45838
|
+
const path = validateNonEmptyString(this.payload.path, 'path');
|
|
45746
45839
|
this.params = {
|
|
45747
|
-
path
|
|
45748
|
-
offset: (
|
|
45749
|
-
totalSize: (
|
|
45750
|
-
chunkLen: this.payload.chunkLen,
|
|
45751
|
-
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'),
|
|
45752
45845
|
};
|
|
45753
45846
|
}
|
|
45754
45847
|
run() {
|
|
@@ -45828,7 +45921,7 @@ function dataToUint8Array(data) {
|
|
|
45828
45921
|
if (typeof Blob !== 'undefined' && data instanceof Blob) {
|
|
45829
45922
|
return new Uint8Array(yield data.arrayBuffer());
|
|
45830
45923
|
}
|
|
45831
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
45924
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Unsupported FilesystemFileWrite data');
|
|
45832
45925
|
});
|
|
45833
45926
|
}
|
|
45834
45927
|
function normalizeChunkSize(value, maxChunkSize) {
|
|
@@ -45852,20 +45945,22 @@ function getConfirmedProgress(processedByte, totalSize, written, dataLength) {
|
|
|
45852
45945
|
}
|
|
45853
45946
|
class FileWrite extends BaseMethod {
|
|
45854
45947
|
init() {
|
|
45855
|
-
var _a, _b
|
|
45948
|
+
var _a, _b;
|
|
45856
45949
|
this.skipForceUpdateCheck = true;
|
|
45857
45950
|
this.useDevicePassphraseState = false;
|
|
45858
|
-
|
|
45951
|
+
validateRequiredData(this.payload.data, 'data');
|
|
45952
|
+
const path = validateNonEmptyString(this.payload.path, 'path');
|
|
45953
|
+
const offset = validateNonNegativeInteger(this.payload.offset, 'offset', 0);
|
|
45859
45954
|
this.params = {
|
|
45860
|
-
path
|
|
45955
|
+
path,
|
|
45861
45956
|
offset,
|
|
45862
|
-
totalSize: (
|
|
45957
|
+
totalSize: validateNonNegativeInteger(this.payload.totalSize, 'totalSize', 0),
|
|
45863
45958
|
data: this.payload.data,
|
|
45864
|
-
chunkSize: this.payload.chunkSize,
|
|
45865
|
-
chunkLen: this.payload.chunkLen,
|
|
45866
|
-
overwrite: (
|
|
45867
|
-
append: (
|
|
45868
|
-
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'),
|
|
45869
45964
|
};
|
|
45870
45965
|
}
|
|
45871
45966
|
run() {
|
|
@@ -45942,7 +46037,7 @@ class FileDelete extends BaseMethod {
|
|
|
45942
46037
|
init() {
|
|
45943
46038
|
this.skipForceUpdateCheck = true;
|
|
45944
46039
|
this.useDevicePassphraseState = false;
|
|
45945
|
-
this.params = { path: this.payload.path };
|
|
46040
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
45946
46041
|
}
|
|
45947
46042
|
run() {
|
|
45948
46043
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45959,8 +46054,8 @@ class DirList extends BaseMethod {
|
|
|
45959
46054
|
this.skipForceUpdateCheck = true;
|
|
45960
46055
|
this.useDevicePassphraseState = false;
|
|
45961
46056
|
this.params = {
|
|
45962
|
-
path: this.payload.path,
|
|
45963
|
-
depth: this.payload.depth,
|
|
46057
|
+
path: validateNonEmptyString(this.payload.path, 'path'),
|
|
46058
|
+
depth: validateOptionalNonNegativeInteger(this.payload.depth, 'depth'),
|
|
45964
46059
|
};
|
|
45965
46060
|
}
|
|
45966
46061
|
run() {
|
|
@@ -45978,7 +46073,7 @@ class DirMake extends BaseMethod {
|
|
|
45978
46073
|
init() {
|
|
45979
46074
|
this.skipForceUpdateCheck = true;
|
|
45980
46075
|
this.useDevicePassphraseState = false;
|
|
45981
|
-
this.params = { path: this.payload.path };
|
|
46076
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
45982
46077
|
}
|
|
45983
46078
|
run() {
|
|
45984
46079
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45994,7 +46089,7 @@ class DirRemove extends BaseMethod {
|
|
|
45994
46089
|
init() {
|
|
45995
46090
|
this.skipForceUpdateCheck = true;
|
|
45996
46091
|
this.useDevicePassphraseState = false;
|
|
45997
|
-
this.params = { path: this.payload.path };
|
|
46092
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
45998
46093
|
}
|
|
45999
46094
|
run() {
|
|
46000
46095
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -46010,7 +46105,7 @@ class PathInfo extends BaseMethod {
|
|
|
46010
46105
|
init() {
|
|
46011
46106
|
this.skipForceUpdateCheck = true;
|
|
46012
46107
|
this.useDevicePassphraseState = false;
|
|
46013
|
-
this.params = { path: this.payload.path };
|
|
46108
|
+
this.params = { path: validateNonEmptyString(this.payload.path, 'path') };
|
|
46014
46109
|
}
|
|
46015
46110
|
run() {
|
|
46016
46111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -47989,7 +48084,7 @@ class EvmGetAddress extends BaseMethod {
|
|
|
47989
48084
|
}
|
|
47990
48085
|
getEvmAddress(param) {
|
|
47991
48086
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47992
|
-
if (TransportManager.getProtocolV1MessageSchema() === '
|
|
48087
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
47993
48088
|
return getAddressLegacyV1({
|
|
47994
48089
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
47995
48090
|
param,
|
|
@@ -48076,7 +48171,7 @@ class EVMGetPublicKey extends BaseMethod {
|
|
|
48076
48171
|
});
|
|
48077
48172
|
}
|
|
48078
48173
|
getEvmPublicKey(param) {
|
|
48079
|
-
if (TransportManager.getProtocolV1MessageSchema() === '
|
|
48174
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
48080
48175
|
return getPublicKeyLegacyV1({
|
|
48081
48176
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
48082
48177
|
param,
|
|
@@ -48160,7 +48255,7 @@ class EVMSignMessage$2 extends BaseMethod {
|
|
|
48160
48255
|
}
|
|
48161
48256
|
run() {
|
|
48162
48257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48163
|
-
if (TransportManager.getProtocolV1MessageSchema() === '
|
|
48258
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
48164
48259
|
return signMessageLegacyV1({
|
|
48165
48260
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
48166
48261
|
params: this.params,
|
|
@@ -48473,7 +48568,7 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
48473
48568
|
const { addressN, isEIP1559, isEIP7702, formattedTx } = this;
|
|
48474
48569
|
if (formattedTx == null)
|
|
48475
48570
|
throw hdShared.ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
48476
|
-
if (TransportManager.getProtocolV1MessageSchema() === '
|
|
48571
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
48477
48572
|
return signTransaction({
|
|
48478
48573
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
48479
48574
|
addressN,
|
|
@@ -48820,7 +48915,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48820
48915
|
let supportTrezor = false;
|
|
48821
48916
|
let response;
|
|
48822
48917
|
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
48823
|
-
case '
|
|
48918
|
+
case 'v1LegacySchema':
|
|
48824
48919
|
supportTrezor = true;
|
|
48825
48920
|
response = yield signTypedData$1({
|
|
48826
48921
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
@@ -48830,7 +48925,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48830
48925
|
chainId,
|
|
48831
48926
|
});
|
|
48832
48927
|
break;
|
|
48833
|
-
case '
|
|
48928
|
+
case 'v1CurrentSchema':
|
|
48834
48929
|
default:
|
|
48835
48930
|
supportTrezor = false;
|
|
48836
48931
|
response = yield signTypedData({
|
|
@@ -48854,7 +48949,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48854
48949
|
if (!domainHash)
|
|
48855
48950
|
throw hdShared.ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
48856
48951
|
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
48857
|
-
case '
|
|
48952
|
+
case 'v1LegacySchema':
|
|
48858
48953
|
return signTypedHash$1({
|
|
48859
48954
|
typedCall,
|
|
48860
48955
|
addressN,
|
|
@@ -48863,7 +48958,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
48863
48958
|
chainId,
|
|
48864
48959
|
device: this.device,
|
|
48865
48960
|
});
|
|
48866
|
-
case '
|
|
48961
|
+
case 'v1CurrentSchema':
|
|
48867
48962
|
default:
|
|
48868
48963
|
return signTypedHash({
|
|
48869
48964
|
typedCall,
|
|
@@ -49124,7 +49219,7 @@ class EVMSignMessage$1 extends BaseMethod {
|
|
|
49124
49219
|
}
|
|
49125
49220
|
run() {
|
|
49126
49221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49127
|
-
if (TransportManager.getProtocolV1MessageSchema() === '
|
|
49222
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
49128
49223
|
return verifyMessageLegacyV1({
|
|
49129
49224
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
49130
49225
|
params: this.params,
|
|
@@ -55641,7 +55736,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
55641
55736
|
yield TransportManager.reconfigure(device.features);
|
|
55642
55737
|
}
|
|
55643
55738
|
checkPassphraseEnableState(method, device.features);
|
|
55644
|
-
if (
|
|
55739
|
+
if (shouldCheckPassphraseState(method, device)) {
|
|
55645
55740
|
const support = supportNewPassphrase(device.features);
|
|
55646
55741
|
if (!support.support) {
|
|
55647
55742
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase, `Device not support passphrase, please update to ${support.require}`, {
|
|
@@ -56028,7 +56123,6 @@ const cancel = (context, connectId) => {
|
|
|
56028
56123
|
const checkPassphraseEnableState = (method, features) => {
|
|
56029
56124
|
if (!method.useDevicePassphraseState)
|
|
56030
56125
|
return;
|
|
56031
|
-
const isPro2 = getDeviceType(features) === hdShared.EDeviceType.Pro2;
|
|
56032
56126
|
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true) {
|
|
56033
56127
|
const hasNoPassphraseState = method.payload.passphraseState == null || method.payload.passphraseState === '';
|
|
56034
56128
|
const shouldRequirePassphrase = !method.payload.useEmptyPassphrase && !method.payload.skipPassphraseCheck;
|
|
@@ -56037,11 +56131,19 @@ const checkPassphraseEnableState = (method, features) => {
|
|
|
56037
56131
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceOpenedPassphrase);
|
|
56038
56132
|
}
|
|
56039
56133
|
}
|
|
56040
|
-
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === false && method.payload.passphraseState
|
|
56134
|
+
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === false && method.payload.passphraseState) {
|
|
56041
56135
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
56042
56136
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
56043
56137
|
}
|
|
56044
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
|
+
};
|
|
56045
56147
|
const cleanup = () => {
|
|
56046
56148
|
_uiPromises = [];
|
|
56047
56149
|
Log.debug('Cleanup...');
|
|
@@ -47,7 +47,7 @@ type ProtocolV2DeviceInfo = {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
export declare function normalizeProtocolV2Features(descriptor: DeviceDescriptor, deviceInfo?: ProtocolV2DeviceInfo): Features;
|
|
50
|
-
export declare function getProtocolV2Features({ commands, descriptor, timeoutMs, }: {
|
|
50
|
+
export declare function getProtocolV2Features({ commands, descriptor, onDeviceInfoError, timeoutMs, }: {
|
|
51
51
|
commands: DeviceCommands;
|
|
52
52
|
descriptor: DeviceDescriptor;
|
|
53
53
|
onDeviceInfoError?: (error: unknown) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol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,iBAAiB,EACjB,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,sDA0BA"}
|
|
@@ -5,5 +5,8 @@ export type GetPassphraseStatePayload = string | {
|
|
|
5
5
|
unlocked_attach_pin?: boolean;
|
|
6
6
|
passphrase_protection?: boolean | null;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type GetPassphraseStateParams = CommonParams & {
|
|
9
|
+
allowCreateAttachPin?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function getPassphraseState(connectId?: string, params?: GetPassphraseStateParams): Response<GetPassphraseStatePayload>;
|
|
9
12
|
//# sourceMappingURL=getPassphraseState.d.ts.map
|