@onekeyfe/hd-core 1.2.0-alpha.22 → 1.2.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/DeviceCommands.test.ts +8 -8
- package/__tests__/device-settings.test.ts +1 -1
- package/__tests__/device-wallet-session-store.test.ts +41 -0
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +86 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +13 -0
- package/__tests__/logBlockEvent.test.ts +17 -0
- package/__tests__/open-wallet-session.test.ts +90 -31
- package/__tests__/protocol-v2.test.ts +301 -63
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +0 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +0 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +6 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +3 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/device.d.ts +1 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +1 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.js +157 -268
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.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/CheckAllFirmwareRelease.ts +15 -8
- package/src/api/FirmwareUpdateV2.ts +8 -1
- package/src/api/FirmwareUpdateV3.ts +8 -0
- package/src/api/FirmwareUpdateV4.ts +21 -19
- package/src/api/GetPassphraseState.ts +11 -5
- package/src/api/device/DeviceUpdateBootloader.ts +9 -1
- package/src/api/device/DeviceWipe.ts +2 -0
- package/src/api/firmware/FirmwareArtifactSource.ts +1 -1
- package/src/api/firmware/FirmwareUpdatePlan.ts +1 -1
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +15 -1
- package/src/core/index.ts +1 -0
- package/src/data/messages/messages-protocol-v2.json +18 -57
- package/src/device/Device.ts +30 -7
- package/src/device/DeviceCommands.ts +24 -151
- package/src/events/device.ts +1 -0
- package/src/events/logBlockEvent.ts +1 -15
- package/src/events/ui-request.ts +1 -0
- package/src/protocols/protocol-v2/deviceSession.ts +1 -1
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +0 -1
- package/src/protocols/protocol-v2/walletSession.ts +41 -20
- package/src/types/api/getPassphraseState.ts +4 -3
- package/src/utils/deviceInfoUtils.ts +3 -16
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ var hdShared = require('@onekeyfe/hd-shared');
|
|
|
6
6
|
var utils = require('@noble/hashes/utils');
|
|
7
7
|
var sha256 = require('@noble/hashes/sha256');
|
|
8
8
|
var semver = require('semver');
|
|
9
|
-
var lodash = require('lodash');
|
|
10
9
|
var hdTransport = require('@onekeyfe/hd-transport');
|
|
11
10
|
var axios = require('axios');
|
|
11
|
+
var lodash = require('lodash');
|
|
12
12
|
var ByteBuffer = require('bytebuffer');
|
|
13
13
|
var BigNumber = require('bignumber.js');
|
|
14
14
|
var blake2s = require('@noble/hashes/blake2s');
|
|
@@ -437,19 +437,9 @@ const getDeviceUUID = getDeviceSerialNo;
|
|
|
437
437
|
const getDeviceLabel = (features) => {
|
|
438
438
|
if (!features)
|
|
439
439
|
return null;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if ('label' in features && typeof features.label === 'string' && !lodash.isEmpty(features.label)) {
|
|
444
|
-
return features.label;
|
|
445
|
-
}
|
|
446
|
-
const bleName = getDeviceBleName(features);
|
|
447
|
-
if (!lodash.isEmpty(bleName))
|
|
448
|
-
return bleName;
|
|
449
|
-
if (deviceType === hdShared.EDeviceType.ClassicPure) {
|
|
450
|
-
return 'OneKey Classic 1S';
|
|
451
|
-
}
|
|
452
|
-
return `OneKey ${deviceType.charAt(0).toUpperCase() + deviceType.slice(1)}`;
|
|
440
|
+
return 'label' in features && typeof features.label === 'string' && features.label.length > 0
|
|
441
|
+
? features.label
|
|
442
|
+
: null;
|
|
453
443
|
};
|
|
454
444
|
const getMethodVersionRange = (features, getVersionRange) => {
|
|
455
445
|
const deviceType = getDeviceType(features);
|
|
@@ -1079,6 +1069,13 @@ const validateFirmwareUpdatePreparedPlan = (value) => {
|
|
|
1079
1069
|
}
|
|
1080
1070
|
return preparedPlan;
|
|
1081
1071
|
};
|
|
1072
|
+
const assertFirmwareUpdatePreparedPlanDeviceIdentity = ({ preparedPlan: value, deviceIdentity, }) => {
|
|
1073
|
+
const preparedPlan = validateFirmwareUpdatePreparedPlan(value);
|
|
1074
|
+
if (!deviceIdentity || preparedPlan.deviceIdentity !== deviceIdentity) {
|
|
1075
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
1076
|
+
}
|
|
1077
|
+
return preparedPlan;
|
|
1078
|
+
};
|
|
1082
1079
|
const sameArtifactReference = (first, second) => first.artifactRef === second.artifactRef &&
|
|
1083
1080
|
first.size === second.size &&
|
|
1084
1081
|
first.sha256.toLowerCase() === second.sha256.toLowerCase();
|
|
@@ -27183,9 +27180,10 @@ var nested = {
|
|
|
27183
27180
|
MessageType_DeviceStatus: 60603,
|
|
27184
27181
|
MessageType_DevGetOnboardingStatus: 60604,
|
|
27185
27182
|
MessageType_DevOnboardingStatus: 60605,
|
|
27183
|
+
MessageType_DeviceSessionGet: 60606,
|
|
27186
27184
|
MessageType_DeviceSession: 60607,
|
|
27187
27185
|
MessageType_DeviceSessionAskPin: 60608,
|
|
27188
|
-
|
|
27186
|
+
MessageType_DeviceSessionAskPassphrase: 60609,
|
|
27189
27187
|
MessageType_FilesystemPermissionFix: 60800,
|
|
27190
27188
|
MessageType_FilesystemPathInfo: 60801,
|
|
27191
27189
|
MessageType_FilesystemPathInfoQuery: 60802,
|
|
@@ -27219,10 +27217,6 @@ var nested = {
|
|
|
27219
27217
|
[
|
|
27220
27218
|
309,
|
|
27221
27219
|
312
|
|
27222
|
-
],
|
|
27223
|
-
[
|
|
27224
|
-
60606,
|
|
27225
|
-
60606
|
|
27226
27220
|
]
|
|
27227
27221
|
]
|
|
27228
27222
|
},
|
|
@@ -39199,90 +39193,42 @@ var nested = {
|
|
|
39199
39193
|
DeviceSessionError_Busy: 5
|
|
39200
39194
|
}
|
|
39201
39195
|
},
|
|
39202
|
-
|
|
39196
|
+
DeviceSessionGet: {
|
|
39203
39197
|
fields: {
|
|
39204
39198
|
session_id: {
|
|
39205
|
-
rule: "required",
|
|
39206
39199
|
type: "bytes",
|
|
39207
39200
|
id: 1
|
|
39208
39201
|
}
|
|
39209
39202
|
}
|
|
39210
39203
|
},
|
|
39211
|
-
|
|
39212
|
-
fields: {
|
|
39213
|
-
passphrase: {
|
|
39214
|
-
rule: "required",
|
|
39215
|
-
type: "string",
|
|
39216
|
-
id: 1
|
|
39217
|
-
}
|
|
39218
|
-
}
|
|
39219
|
-
},
|
|
39220
|
-
DeviceSessionPassphraseOnDevice: {
|
|
39221
|
-
fields: {
|
|
39222
|
-
}
|
|
39223
|
-
},
|
|
39224
|
-
DeviceSessionAttachPinOnDevice: {
|
|
39225
|
-
fields: {
|
|
39226
|
-
}
|
|
39227
|
-
},
|
|
39228
|
-
DeviceSessionSelect: {
|
|
39229
|
-
oneofs: {
|
|
39230
|
-
access: {
|
|
39231
|
-
oneof: [
|
|
39232
|
-
"host_passphrase",
|
|
39233
|
-
"passphrase_on_device",
|
|
39234
|
-
"attach_pin_on_device"
|
|
39235
|
-
]
|
|
39236
|
-
}
|
|
39237
|
-
},
|
|
39204
|
+
DeviceSession: {
|
|
39238
39205
|
fields: {
|
|
39239
|
-
|
|
39240
|
-
type: "
|
|
39206
|
+
session_id: {
|
|
39207
|
+
type: "bytes",
|
|
39241
39208
|
id: 1
|
|
39242
39209
|
},
|
|
39243
|
-
|
|
39244
|
-
type: "
|
|
39210
|
+
btc_test_address: {
|
|
39211
|
+
type: "string",
|
|
39245
39212
|
id: 2
|
|
39246
|
-
},
|
|
39247
|
-
attach_pin_on_device: {
|
|
39248
|
-
type: "DeviceSessionAttachPinOnDevice",
|
|
39249
|
-
id: 3
|
|
39250
39213
|
}
|
|
39251
39214
|
}
|
|
39252
39215
|
},
|
|
39253
|
-
|
|
39254
|
-
|
|
39255
|
-
|
|
39256
|
-
|
|
39257
|
-
|
|
39258
|
-
"select"
|
|
39259
|
-
]
|
|
39260
|
-
}
|
|
39261
|
-
},
|
|
39262
|
-
fields: {
|
|
39263
|
-
resume: {
|
|
39264
|
-
type: "DeviceSessionResume",
|
|
39265
|
-
id: 1
|
|
39266
|
-
},
|
|
39267
|
-
select: {
|
|
39268
|
-
type: "DeviceSessionSelect",
|
|
39269
|
-
id: 2
|
|
39270
|
-
}
|
|
39216
|
+
DeviceSessionPinType: {
|
|
39217
|
+
values: {
|
|
39218
|
+
Any: 1,
|
|
39219
|
+
Main: 2,
|
|
39220
|
+
AttachToPin: 3
|
|
39271
39221
|
}
|
|
39272
39222
|
},
|
|
39273
|
-
|
|
39223
|
+
DeviceSessionAskPin: {
|
|
39274
39224
|
fields: {
|
|
39275
|
-
|
|
39276
|
-
type: "
|
|
39225
|
+
type: {
|
|
39226
|
+
type: "DeviceSessionPinType",
|
|
39277
39227
|
id: 1
|
|
39278
|
-
},
|
|
39279
|
-
btc_test_address: {
|
|
39280
|
-
type: "string",
|
|
39281
|
-
id: 2
|
|
39282
39228
|
}
|
|
39283
39229
|
}
|
|
39284
39230
|
},
|
|
39285
|
-
|
|
39231
|
+
DeviceSessionAskPassphrase: {
|
|
39286
39232
|
fields: {
|
|
39287
39233
|
}
|
|
39288
39234
|
},
|
|
@@ -40973,15 +40919,6 @@ const LogBlockEvent = new Set([
|
|
|
40973
40919
|
UI_RESPONSE.RECEIVE_PIN,
|
|
40974
40920
|
UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
40975
40921
|
]);
|
|
40976
|
-
const LogBlockMethod = new Set([
|
|
40977
|
-
'evmSignTypedData',
|
|
40978
|
-
'openWalletSession',
|
|
40979
|
-
'DeviceSessionOpen',
|
|
40980
|
-
'deviceUploadWallpaper',
|
|
40981
|
-
'uploadPortfolio',
|
|
40982
|
-
'fileWrite',
|
|
40983
|
-
'fileRead',
|
|
40984
|
-
]);
|
|
40985
40922
|
function getLogBlockLabel(message) {
|
|
40986
40923
|
if (!message || typeof message !== 'object')
|
|
40987
40924
|
return undefined;
|
|
@@ -40990,10 +40927,7 @@ function getLogBlockLabel(message) {
|
|
|
40990
40927
|
return type;
|
|
40991
40928
|
}
|
|
40992
40929
|
const methodName = method !== null && method !== void 0 ? method : payload === null || payload === void 0 ? void 0 : payload.method;
|
|
40993
|
-
|
|
40994
|
-
return methodName;
|
|
40995
|
-
}
|
|
40996
|
-
return undefined;
|
|
40930
|
+
return methodName;
|
|
40997
40931
|
}
|
|
40998
40932
|
|
|
40999
40933
|
function assertCompleteDeviceSession(message) {
|
|
@@ -41001,7 +40935,7 @@ function assertCompleteDeviceSession(message) {
|
|
|
41001
40935
|
!message.session_id ||
|
|
41002
40936
|
typeof message.btc_test_address !== 'string' ||
|
|
41003
40937
|
!message.btc_test_address) {
|
|
41004
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, '
|
|
40938
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'DeviceSessionGet returned an incomplete DeviceSession response.');
|
|
41005
40939
|
}
|
|
41006
40940
|
}
|
|
41007
40941
|
|
|
@@ -41017,16 +40951,31 @@ const negotiateEventlessWalletSession = (device) => __awaiter(void 0, void 0, vo
|
|
|
41017
40951
|
eventless_wallet_session: true,
|
|
41018
40952
|
});
|
|
41019
40953
|
});
|
|
41020
|
-
const
|
|
40954
|
+
const getDeviceSession = (device, request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41021
40955
|
try {
|
|
41022
|
-
return yield device.commands.typedCall('
|
|
40956
|
+
return yield device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
|
|
41023
40957
|
}
|
|
41024
40958
|
catch (error) {
|
|
41025
40959
|
if (!isDeviceLockedError(error)) {
|
|
41026
40960
|
throw error;
|
|
41027
40961
|
}
|
|
41028
|
-
yield device.unlockDevice();
|
|
41029
|
-
return device.commands.typedCall('
|
|
40962
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40963
|
+
return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
|
|
40964
|
+
}
|
|
40965
|
+
});
|
|
40966
|
+
const askDevicePassphrase = (device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40967
|
+
const request = () => device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', {}, {
|
|
40968
|
+
timeoutMs: 120000,
|
|
40969
|
+
});
|
|
40970
|
+
try {
|
|
40971
|
+
return yield request();
|
|
40972
|
+
}
|
|
40973
|
+
catch (error) {
|
|
40974
|
+
if (!isDeviceLockedError(error)) {
|
|
40975
|
+
throw error;
|
|
40976
|
+
}
|
|
40977
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
40978
|
+
return request();
|
|
41030
40979
|
}
|
|
41031
40980
|
});
|
|
41032
40981
|
const selectDeviceSession = (device) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -41036,10 +40985,10 @@ const selectDeviceSession = (device) => __awaiter(void 0, void 0, void 0, functi
|
|
|
41036
40985
|
source: 'wallet-session-coordinator',
|
|
41037
40986
|
reason: 'open-wallet',
|
|
41038
40987
|
};
|
|
41039
|
-
const response = yield device.commands.promptPassphrase(Object.assign({ existsAttachPinUser }, metadata), { cancelDeviceOnReject: false });
|
|
41040
|
-
const
|
|
40988
|
+
const response = yield device.commands.promptPassphrase(Object.assign({ existsAttachPinUser, deviceOnly: true }, metadata), { cancelDeviceOnReject: false });
|
|
40989
|
+
const hasHostPassphrase = typeof response.passphrase === 'string' && response.passphrase.length > 0;
|
|
41041
40990
|
const selections = [
|
|
41042
|
-
|
|
40991
|
+
hasHostPassphrase,
|
|
41043
40992
|
response.passphraseOnDevice === true,
|
|
41044
40993
|
response.attachPinOnDevice === true,
|
|
41045
40994
|
].filter(Boolean).length;
|
|
@@ -41051,21 +41000,19 @@ const selectDeviceSession = (device) => __awaiter(void 0, void 0, void 0, functi
|
|
|
41051
41000
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Attach PIN wallet selection is unavailable on this device.');
|
|
41052
41001
|
}
|
|
41053
41002
|
device.emit(DEVICE.ATTACH_PIN_ON_DEVICE, device, metadata);
|
|
41054
|
-
|
|
41055
|
-
|
|
41056
|
-
if (response.passphraseOnDevice) {
|
|
41057
|
-
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
41058
|
-
return openDeviceSession(device, { select: { passphrase_on_device: {} } });
|
|
41003
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.AttachToPin);
|
|
41004
|
+
return getDeviceSession(device, {});
|
|
41059
41005
|
}
|
|
41060
|
-
|
|
41061
|
-
|
|
41062
|
-
});
|
|
41006
|
+
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
41007
|
+
yield askDevicePassphrase(device);
|
|
41008
|
+
return getDeviceSession(device, {});
|
|
41063
41009
|
});
|
|
41064
41010
|
function getProtocolV2WalletSession(device, options) {
|
|
41065
41011
|
var _a, _b, _c, _d, _e, _f;
|
|
41066
41012
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41067
41013
|
if (options === null || options === void 0 ? void 0 : options.initSession) {
|
|
41068
41014
|
device.clearInternalState();
|
|
41015
|
+
device.passphraseState = undefined;
|
|
41069
41016
|
}
|
|
41070
41017
|
yield negotiateEventlessWalletSession(device);
|
|
41071
41018
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
@@ -41075,7 +41022,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41075
41022
|
? undefined
|
|
41076
41023
|
: (_a = options === null || options === void 0 ? void 0 : options.expectedPassphraseState) !== null && _a !== void 0 ? _a : device.passphraseState;
|
|
41077
41024
|
if (((_b = device.features) === null || _b === void 0 ? void 0 : _b.unlocked) === false) {
|
|
41078
|
-
yield device.unlockDevice();
|
|
41025
|
+
yield device.unlockDevice(hdTransport.DeviceSessionPinType.Main);
|
|
41079
41026
|
}
|
|
41080
41027
|
if ((options === null || options === void 0 ? void 0 : options.onlyMainPin) || device.getCurrentPassphraseProtection() === false) {
|
|
41081
41028
|
return {
|
|
@@ -41090,7 +41037,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41090
41037
|
let resumed = false;
|
|
41091
41038
|
if (cachedSessionId && expectedPassphraseState) {
|
|
41092
41039
|
try {
|
|
41093
|
-
response = yield
|
|
41040
|
+
response = yield getDeviceSession(device, { session_id: cachedSessionId });
|
|
41094
41041
|
resumed = true;
|
|
41095
41042
|
}
|
|
41096
41043
|
catch (error) {
|
|
@@ -42516,10 +42463,6 @@ TransportManager.reactNativeInit = false;
|
|
|
42516
42463
|
TransportManager.protocolV1MessageSchema = 'v1CurrentSchema';
|
|
42517
42464
|
TransportManager.plugin = null;
|
|
42518
42465
|
|
|
42519
|
-
const MAX_DEBUG_ARRAY_ITEMS = 20;
|
|
42520
|
-
const MAX_DEBUG_OBJECT_KEYS = 40;
|
|
42521
|
-
const MAX_DEBUG_STRING_LENGTH = 512;
|
|
42522
|
-
const MAX_DEBUG_DEPTH = 4;
|
|
42523
42466
|
const HIGH_VOLUME_DEBUG_CALLS = new Set([
|
|
42524
42467
|
'FilesystemFileRead',
|
|
42525
42468
|
'FilesystemFileWrite',
|
|
@@ -42530,84 +42473,14 @@ const HIGH_VOLUME_DEBUG_CALLS = new Set([
|
|
|
42530
42473
|
'FirmwareUpload',
|
|
42531
42474
|
'ResourceAck',
|
|
42532
42475
|
]);
|
|
42533
|
-
const
|
|
42476
|
+
const DEVICE_SESSION_CALLS = new Set([
|
|
42477
|
+
'DeviceSessionGet',
|
|
42478
|
+
'DeviceSessionAskPin',
|
|
42479
|
+
'DeviceSessionAskPassphrase',
|
|
42480
|
+
]);
|
|
42534
42481
|
function shouldReduceDebugForCall(type) {
|
|
42535
42482
|
return HIGH_VOLUME_DEBUG_CALLS.has(type);
|
|
42536
42483
|
}
|
|
42537
|
-
function shouldBlockDebugForCall(type) {
|
|
42538
|
-
return SENSITIVE_DEBUG_CALLS.has(type);
|
|
42539
|
-
}
|
|
42540
|
-
function getBinaryByteLength(value) {
|
|
42541
|
-
if (value instanceof ArrayBuffer) {
|
|
42542
|
-
return value.byteLength;
|
|
42543
|
-
}
|
|
42544
|
-
if (ArrayBuffer.isView(value)) {
|
|
42545
|
-
return value.byteLength;
|
|
42546
|
-
}
|
|
42547
|
-
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
42548
|
-
return value.size;
|
|
42549
|
-
}
|
|
42550
|
-
return undefined;
|
|
42551
|
-
}
|
|
42552
|
-
function summarizeRedactedData(value) {
|
|
42553
|
-
const byteLength = getBinaryByteLength(value);
|
|
42554
|
-
if (byteLength !== undefined) {
|
|
42555
|
-
return `[redacted data: ${byteLength} bytes]`;
|
|
42556
|
-
}
|
|
42557
|
-
if (typeof value === 'string') {
|
|
42558
|
-
return `[redacted data: string length=${value.length}]`;
|
|
42559
|
-
}
|
|
42560
|
-
if (Array.isArray(value)) {
|
|
42561
|
-
return `[redacted data: array length=${value.length}]`;
|
|
42562
|
-
}
|
|
42563
|
-
if (value && typeof value === 'object') {
|
|
42564
|
-
return `[redacted data: object keys=${Object.keys(value).length}]`;
|
|
42565
|
-
}
|
|
42566
|
-
return `[redacted data: ${typeof value}]`;
|
|
42567
|
-
}
|
|
42568
|
-
function sanitizeDebugPayload(value, key = '', depth = 0) {
|
|
42569
|
-
if (key === 'data' && value !== null && value !== undefined) {
|
|
42570
|
-
return summarizeRedactedData(value);
|
|
42571
|
-
}
|
|
42572
|
-
if (key && /passphrase/i.test(key)) {
|
|
42573
|
-
return '[redacted passphrase]';
|
|
42574
|
-
}
|
|
42575
|
-
const byteLength = getBinaryByteLength(value);
|
|
42576
|
-
if (byteLength !== undefined) {
|
|
42577
|
-
return `[binary: ${byteLength} bytes]`;
|
|
42578
|
-
}
|
|
42579
|
-
if (typeof value === 'string') {
|
|
42580
|
-
return value.length > MAX_DEBUG_STRING_LENGTH
|
|
42581
|
-
? `${value.slice(0, MAX_DEBUG_STRING_LENGTH)}... (len=${value.length})`
|
|
42582
|
-
: value;
|
|
42583
|
-
}
|
|
42584
|
-
if (!value || typeof value !== 'object') {
|
|
42585
|
-
return value;
|
|
42586
|
-
}
|
|
42587
|
-
if (depth >= MAX_DEBUG_DEPTH) {
|
|
42588
|
-
return Array.isArray(value)
|
|
42589
|
-
? `[array length=${value.length}]`
|
|
42590
|
-
: `[object keys=${Object.keys(value).length}]`;
|
|
42591
|
-
}
|
|
42592
|
-
if (Array.isArray(value)) {
|
|
42593
|
-
const items = value
|
|
42594
|
-
.slice(0, MAX_DEBUG_ARRAY_ITEMS)
|
|
42595
|
-
.map(item => sanitizeDebugPayload(item, key, depth + 1));
|
|
42596
|
-
if (value.length > MAX_DEBUG_ARRAY_ITEMS) {
|
|
42597
|
-
items.push(`... (${value.length - MAX_DEBUG_ARRAY_ITEMS} more)`);
|
|
42598
|
-
}
|
|
42599
|
-
return items;
|
|
42600
|
-
}
|
|
42601
|
-
const entries = Object.entries(value).slice(0, MAX_DEBUG_OBJECT_KEYS);
|
|
42602
|
-
const sanitized = {};
|
|
42603
|
-
entries.forEach(([entryKey, entryValue]) => {
|
|
42604
|
-
sanitized[entryKey] = sanitizeDebugPayload(entryValue, entryKey, depth + 1);
|
|
42605
|
-
});
|
|
42606
|
-
if (Object.keys(value).length > MAX_DEBUG_OBJECT_KEYS) {
|
|
42607
|
-
sanitized.__truncated__ = `${Object.keys(value).length - MAX_DEBUG_OBJECT_KEYS} more keys`;
|
|
42608
|
-
}
|
|
42609
|
-
return sanitized;
|
|
42610
|
-
}
|
|
42611
42484
|
const stripInteractiveAckTimeout = (options) => {
|
|
42612
42485
|
if (!options)
|
|
42613
42486
|
return options;
|
|
@@ -42778,16 +42651,16 @@ class DeviceCommands {
|
|
|
42778
42651
|
const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
|
|
42779
42652
|
this.callPromise = promise;
|
|
42780
42653
|
const res = yield promise;
|
|
42781
|
-
if (
|
|
42782
|
-
LogCore.debug('[DeviceCommands] [call] Received', res.type, res.message);
|
|
42783
|
-
}
|
|
42784
|
-
else if (!shouldReduceDebug) {
|
|
42654
|
+
if (!shouldReduceDebug) {
|
|
42785
42655
|
LogCore.debug('[DeviceCommands] [call] Received', res.type);
|
|
42786
42656
|
}
|
|
42787
42657
|
return res;
|
|
42788
42658
|
}
|
|
42789
42659
|
catch (error) {
|
|
42790
|
-
LogCore.debug('[DeviceCommands] [call] Received error',
|
|
42660
|
+
LogCore.debug('[DeviceCommands] [call] Received error', {
|
|
42661
|
+
request: type,
|
|
42662
|
+
errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
|
|
42663
|
+
});
|
|
42791
42664
|
if (error.errorCode === hdShared.HardwareErrorCode.BleDeviceBondError) {
|
|
42792
42665
|
return {
|
|
42793
42666
|
type: 'BleDeviceBondError',
|
|
@@ -42806,9 +42679,6 @@ class DeviceCommands {
|
|
|
42806
42679
|
catch (error) {
|
|
42807
42680
|
}
|
|
42808
42681
|
}
|
|
42809
|
-
if (responseData) {
|
|
42810
|
-
Log$f.debug('error response', responseData);
|
|
42811
|
-
}
|
|
42812
42682
|
if (responseError === 'device disconnected during action') {
|
|
42813
42683
|
return { type: 'BridgeDeviceDisconnected', message: { error: responseError } };
|
|
42814
42684
|
}
|
|
@@ -42830,29 +42700,6 @@ class DeviceCommands {
|
|
|
42830
42700
|
if (this.disposed) {
|
|
42831
42701
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'typedCall: DeviceCommands already disposed');
|
|
42832
42702
|
}
|
|
42833
|
-
try {
|
|
42834
|
-
const skipTypes = [
|
|
42835
|
-
'ButtonAck',
|
|
42836
|
-
'PinMatrixAck',
|
|
42837
|
-
'PassphraseAck',
|
|
42838
|
-
'Cancel',
|
|
42839
|
-
'DeviceSessionOpen',
|
|
42840
|
-
'BixinPinInputOnDevice',
|
|
42841
|
-
'FilesystemFileRead',
|
|
42842
|
-
'FilesystemFileWrite',
|
|
42843
|
-
'FileRead',
|
|
42844
|
-
'FileWrite',
|
|
42845
|
-
'EmmcFileRead',
|
|
42846
|
-
'EmmcFileWrite',
|
|
42847
|
-
'FirmwareUpload',
|
|
42848
|
-
'ResourceAck',
|
|
42849
|
-
];
|
|
42850
|
-
if (!skipTypes.includes(type) && !shouldBlockDebugForCall(type) && msg) {
|
|
42851
|
-
Log$f.debug('[DeviceCommands] [typedCall] Sending payload', type, sanitizeDebugPayload(msg));
|
|
42852
|
-
}
|
|
42853
|
-
}
|
|
42854
|
-
catch (e) {
|
|
42855
|
-
}
|
|
42856
42703
|
const expectedTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
42857
42704
|
const response = yield this._commonCall(type, msg, Object.assign(Object.assign({}, options), { expectedTypes: (_a = options === null || options === void 0 ? void 0 : options.expectedTypes) !== null && _a !== void 0 ? _a : expectedTypes }));
|
|
42858
42705
|
try {
|
|
@@ -42862,14 +42709,11 @@ class DeviceCommands {
|
|
|
42862
42709
|
Log$f.debug('DeviceCommands typedcall error: ', error);
|
|
42863
42710
|
if (error instanceof hdShared.HardwareError) {
|
|
42864
42711
|
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
42865
|
-
|
|
42866
|
-
|
|
42867
|
-
|
|
42868
|
-
|
|
42869
|
-
|
|
42870
|
-
response: sanitizeDebugPayload(response.message),
|
|
42871
|
-
});
|
|
42872
|
-
}
|
|
42712
|
+
Log$f.debug('[DeviceCommands] [typedCall] Unexpected response type', {
|
|
42713
|
+
request: type,
|
|
42714
|
+
expected: resType,
|
|
42715
|
+
received: response.type,
|
|
42716
|
+
});
|
|
42873
42717
|
if (error.message.indexOf('BridgeNetworkError') > -1) {
|
|
42874
42718
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeNetworkError);
|
|
42875
42719
|
}
|
|
@@ -42898,13 +42742,11 @@ class DeviceCommands {
|
|
|
42898
42742
|
_filterCommonTypes(res, callType, options) {
|
|
42899
42743
|
var _a;
|
|
42900
42744
|
try {
|
|
42901
|
-
if (shouldReduceDebugForCall(callType)
|
|
42902
|
-
|
|
42903
|
-
|
|
42904
|
-
|
|
42905
|
-
|
|
42906
|
-
else {
|
|
42907
|
-
Log$f.debug('_filterCommonTypes: ', sanitizeDebugPayload(res));
|
|
42745
|
+
if (!shouldReduceDebugForCall(callType)) {
|
|
42746
|
+
Log$f.debug('_filterCommonTypes: ', {
|
|
42747
|
+
request: callType,
|
|
42748
|
+
response: res.type,
|
|
42749
|
+
});
|
|
42908
42750
|
}
|
|
42909
42751
|
}
|
|
42910
42752
|
catch (error) {
|
|
@@ -42950,7 +42792,7 @@ class DeviceCommands {
|
|
|
42950
42792
|
const isLegacyProtocolV2ActionCancelledFailure = this.device.isProtocolV2() &&
|
|
42951
42793
|
/^(?:cancelled on device|confirm dismissed)$/i.test(normalizedMessage);
|
|
42952
42794
|
const isLegacyProtocolV2LockedFailure = this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
42953
|
-
if (callType
|
|
42795
|
+
if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
42954
42796
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_InvalidSession) {
|
|
42955
42797
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid, message, {
|
|
42956
42798
|
failureCode: code,
|
|
@@ -42958,7 +42800,7 @@ class DeviceCommands {
|
|
|
42958
42800
|
firmwareMessage: message,
|
|
42959
42801
|
});
|
|
42960
42802
|
}
|
|
42961
|
-
else if (callType
|
|
42803
|
+
else if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
42962
42804
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_UserCancelled) {
|
|
42963
42805
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ActionCancelled, message, {
|
|
42964
42806
|
failureCode: code,
|
|
@@ -42966,7 +42808,7 @@ class DeviceCommands {
|
|
|
42966
42808
|
firmwareMessage: message,
|
|
42967
42809
|
});
|
|
42968
42810
|
}
|
|
42969
|
-
else if (callType
|
|
42811
|
+
else if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
42970
42812
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_AttachPinUnavailable) {
|
|
42971
42813
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError, message, {
|
|
42972
42814
|
failureCode: code,
|
|
@@ -42974,7 +42816,7 @@ class DeviceCommands {
|
|
|
42974
42816
|
firmwareMessage: message,
|
|
42975
42817
|
});
|
|
42976
42818
|
}
|
|
42977
|
-
else if (callType
|
|
42819
|
+
else if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
42978
42820
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_PassphraseDisabled) {
|
|
42979
42821
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase, message, {
|
|
42980
42822
|
failureCode: code,
|
|
@@ -43979,8 +43821,8 @@ class Device extends events.exports {
|
|
|
43979
43821
|
deviceId,
|
|
43980
43822
|
path: (_a = this.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
|
|
43981
43823
|
bleName,
|
|
43982
|
-
name:
|
|
43983
|
-
label: label
|
|
43824
|
+
name: label || bleName || `OneKey ${deviceType === null || deviceType === void 0 ? void 0 : deviceType.toUpperCase()}`,
|
|
43825
|
+
label: label !== null && label !== void 0 ? label : '',
|
|
43984
43826
|
mode: this.getMode(),
|
|
43985
43827
|
features,
|
|
43986
43828
|
state,
|
|
@@ -44578,6 +44420,20 @@ class Device extends events.exports {
|
|
|
44578
44420
|
this.protocolV2StateNeedsReload = true;
|
|
44579
44421
|
this.clearPreInitialized();
|
|
44580
44422
|
}
|
|
44423
|
+
invalidateAfterWipe() {
|
|
44424
|
+
const deviceId = this.getCurrentDeviceId();
|
|
44425
|
+
if (deviceId) {
|
|
44426
|
+
deviceWalletSessionStore.deleteDevice(deviceId);
|
|
44427
|
+
}
|
|
44428
|
+
if (this.isProtocolV2() && this.originalDescriptor.path !== deviceId) {
|
|
44429
|
+
deviceWalletSessionStore.deleteDevice(this.originalDescriptor.path);
|
|
44430
|
+
this.protocolV2StateNeedsReload = true;
|
|
44431
|
+
}
|
|
44432
|
+
this.passphraseState = undefined;
|
|
44433
|
+
this.stateStore = new DeviceStateStore();
|
|
44434
|
+
this.clearPreInitialized();
|
|
44435
|
+
this.needReloadDevice = true;
|
|
44436
|
+
}
|
|
44581
44437
|
markProtocolV2Reboot(rebootType) {
|
|
44582
44438
|
if (!this.isProtocolV2())
|
|
44583
44439
|
return;
|
|
@@ -44873,12 +44729,12 @@ class Device extends events.exports {
|
|
|
44873
44729
|
},
|
|
44874
44730
|
};
|
|
44875
44731
|
}
|
|
44876
|
-
unlockDevice() {
|
|
44732
|
+
unlockDevice(pinType = hdTransport.DeviceSessionPinType.Main) {
|
|
44877
44733
|
var _a, _b, _c;
|
|
44878
44734
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44879
44735
|
if (this.isProtocolV2()) {
|
|
44880
44736
|
try {
|
|
44881
|
-
yield this.commands.typedCall('DeviceSessionAskPin', 'Success',
|
|
44737
|
+
yield this.commands.typedCall('DeviceSessionAskPin', 'Success', { type: pinType }, {
|
|
44882
44738
|
timeoutMs: 120000,
|
|
44883
44739
|
});
|
|
44884
44740
|
}
|
|
@@ -45564,13 +45420,16 @@ class GetPassphraseState extends BaseMethod {
|
|
|
45564
45420
|
}
|
|
45565
45421
|
run() {
|
|
45566
45422
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45567
|
-
if (this.device.isProtocolV2()) {
|
|
45568
|
-
throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
45569
|
-
}
|
|
45570
45423
|
if (!this.device.features) {
|
|
45571
45424
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed);
|
|
45572
45425
|
}
|
|
45573
|
-
const
|
|
45426
|
+
const isProtocolV2 = this.device.isProtocolV2();
|
|
45427
|
+
const { passphraseState } = yield getPassphraseStateWithRefreshDeviceInfo(this.device, isProtocolV2
|
|
45428
|
+
? {
|
|
45429
|
+
onlyMainPin: this.payload.useEmptyPassphrase === true,
|
|
45430
|
+
initSession: this.payload.initSession === true,
|
|
45431
|
+
}
|
|
45432
|
+
: undefined);
|
|
45574
45433
|
const passphraseProtection = this.device.getCurrentPassphraseProtection();
|
|
45575
45434
|
return Promise.resolve(passphraseProtection === true ? passphraseState : undefined);
|
|
45576
45435
|
});
|
|
@@ -46215,14 +46074,20 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
46215
46074
|
firmwareType,
|
|
46216
46075
|
});
|
|
46217
46076
|
const bleFirmwareReleaseInfo = getBleFirmwareReleaseInfo(features);
|
|
46218
|
-
|
|
46219
|
-
|
|
46220
|
-
|
|
46221
|
-
|
|
46222
|
-
|
|
46223
|
-
|
|
46224
|
-
|
|
46225
|
-
|
|
46077
|
+
let firmwareUpdatePlan;
|
|
46078
|
+
try {
|
|
46079
|
+
firmwareUpdatePlan = buildFirmwareUpdatePlan({
|
|
46080
|
+
features,
|
|
46081
|
+
firmwareType,
|
|
46082
|
+
platform: platform !== null && platform !== void 0 ? platform : 'web',
|
|
46083
|
+
firmware: firmwareRelease,
|
|
46084
|
+
ble: bleFirmwareReleaseInfo,
|
|
46085
|
+
bootloader: bootloaderRelease,
|
|
46086
|
+
});
|
|
46087
|
+
}
|
|
46088
|
+
catch (_c) {
|
|
46089
|
+
firmwareUpdatePlan = undefined;
|
|
46090
|
+
}
|
|
46226
46091
|
return {
|
|
46227
46092
|
firmware: firmwareRelease,
|
|
46228
46093
|
bootloader: bootloaderRelease,
|
|
@@ -46543,7 +46408,6 @@ class DeviceReset extends BaseMethod {
|
|
|
46543
46408
|
}
|
|
46544
46409
|
|
|
46545
46410
|
const LOCK_FREE_DEVICE_SETTINGS = new Set([
|
|
46546
|
-
'label',
|
|
46547
46411
|
'language',
|
|
46548
46412
|
'brightness',
|
|
46549
46413
|
'haptic_feedback',
|
|
@@ -47010,9 +46874,11 @@ class DeviceWipe extends BaseMethod {
|
|
|
47010
46874
|
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
47011
46875
|
page: hdTransport.DeviceSettingsPage.DeviceReset,
|
|
47012
46876
|
});
|
|
46877
|
+
this.device.invalidateAfterWipe();
|
|
47013
46878
|
return Promise.resolve(res.message);
|
|
47014
46879
|
}
|
|
47015
46880
|
const res = yield this.device.commands.typedCall('WipeDevice', 'Success');
|
|
46881
|
+
this.device.invalidateAfterWipe();
|
|
47016
46882
|
return Promise.resolve(res.message);
|
|
47017
46883
|
});
|
|
47018
46884
|
}
|
|
@@ -48074,6 +47940,10 @@ class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod {
|
|
|
48074
47940
|
: undefined;
|
|
48075
47941
|
const executionParams = Object.assign(Object.assign({}, payload), { artifactReader: (_a = hostBinding === null || hostBinding === void 0 ? void 0 : hostBinding.artifactReader) !== null && _a !== void 0 ? _a : payload.artifactReader });
|
|
48076
47942
|
if (payload.artifact) {
|
|
47943
|
+
assertFirmwareUpdatePreparedPlanDeviceIdentity({
|
|
47944
|
+
preparedPlan: payload.preparedPlan,
|
|
47945
|
+
deviceIdentity: getDeviceUUID(features) || undefined,
|
|
47946
|
+
});
|
|
48077
47947
|
assertFirmwareUpdatePreparedPlanBinding({
|
|
48078
47948
|
preparedPlan: payload.preparedPlan,
|
|
48079
47949
|
executor: 'v2',
|
|
@@ -48617,6 +48487,12 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
48617
48487
|
if (device.isProtocolV2()) {
|
|
48618
48488
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 firmware update must use firmwareUpdateV4');
|
|
48619
48489
|
}
|
|
48490
|
+
if (params.preparedPlan) {
|
|
48491
|
+
assertFirmwareUpdatePreparedPlanDeviceIdentity({
|
|
48492
|
+
preparedPlan: params.preparedPlan,
|
|
48493
|
+
deviceIdentity: getDeviceUUID(features) || undefined,
|
|
48494
|
+
});
|
|
48495
|
+
}
|
|
48620
48496
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
48621
48497
|
const firmwareType = (_a = params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
48622
48498
|
this.checkVersionForCopyTouchResource(features, firmwareType);
|
|
@@ -48901,6 +48777,12 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
48901
48777
|
if (!features) {
|
|
48902
48778
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device features not available');
|
|
48903
48779
|
}
|
|
48780
|
+
if (this.params.preparedPlan) {
|
|
48781
|
+
assertFirmwareUpdatePreparedPlanDeviceIdentity({
|
|
48782
|
+
preparedPlan: this.params.preparedPlan,
|
|
48783
|
+
deviceIdentity: getDeviceUUID(features) || undefined,
|
|
48784
|
+
});
|
|
48785
|
+
}
|
|
48904
48786
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
48905
48787
|
const firmwareType = (_b = this.params.firmwareType) !== null && _b !== void 0 ? _b : deviceFirmwareType;
|
|
48906
48788
|
this.isSwitchFirmware = firmwareType !== deviceFirmwareType;
|
|
@@ -49700,7 +49582,7 @@ const parseProtocolV2OkppHeader = (bytes) => {
|
|
|
49700
49582
|
};
|
|
49701
49583
|
const assertProtocolV2ReconnectIdentity = (expectedSerialNumber, actualSerialNumber) => {
|
|
49702
49584
|
if (!expectedSerialNumber || !actualSerialNumber) {
|
|
49703
|
-
|
|
49585
|
+
return;
|
|
49704
49586
|
}
|
|
49705
49587
|
if (actualSerialNumber !== expectedSerialNumber) {
|
|
49706
49588
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, `Protocol V2 reconnect physical identity mismatch: expected ${expectedSerialNumber}, received ${actualSerialNumber}`);
|
|
@@ -49759,14 +49641,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49759
49641
|
? resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration)
|
|
49760
49642
|
: undefined;
|
|
49761
49643
|
if (hostBinding) {
|
|
49762
|
-
if (!payload.expectedDeviceId) {
|
|
49763
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Protocol V2 prepared update requires the expected device identity');
|
|
49764
|
-
}
|
|
49765
49644
|
assertFirmwareUpdatePreparedPlanBinding({
|
|
49766
49645
|
preparedPlan: payload.preparedPlan,
|
|
49767
49646
|
executor: 'v4',
|
|
49768
49647
|
platform: payload.platform,
|
|
49769
|
-
deviceIdentity: payload.expectedDeviceId,
|
|
49770
49648
|
scopeTargets: [
|
|
49771
49649
|
'boot',
|
|
49772
49650
|
'app_v1',
|
|
@@ -49972,10 +49850,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49972
49850
|
artifactName: descriptor.name,
|
|
49973
49851
|
});
|
|
49974
49852
|
}
|
|
49853
|
+
const devicePath = validateProtocolV2FilesystemPath(descriptor.devicePath, 'resourceBundles[].devicePath');
|
|
49975
49854
|
sources.push({
|
|
49976
49855
|
name: descriptor.name,
|
|
49977
49856
|
source: yield this.openProtocolV2PreparedSource(artifact),
|
|
49978
|
-
devicePath
|
|
49857
|
+
devicePath,
|
|
49979
49858
|
version: descriptor.version,
|
|
49980
49859
|
payloadHash: descriptor.payloadHash,
|
|
49981
49860
|
headerHash: descriptor.headerHash,
|
|
@@ -50064,9 +49943,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
50064
49943
|
? visibleVersions[target]
|
|
50065
49944
|
: `${Math.floor(statusVersion / 0x10000) % 0x100}.${Math.floor(statusVersion / 0x100) % 0x100}.${statusVersion % 0x100}`;
|
|
50066
49945
|
if (!observedVersion) {
|
|
50067
|
-
|
|
49946
|
+
Log$5.warn(`Protocol V2 target ${target} has no observable final version; skipping version comparison`);
|
|
50068
49947
|
}
|
|
50069
|
-
if (observedVersion !== expectedVersion) {
|
|
49948
|
+
else if (observedVersion !== expectedVersion) {
|
|
50070
49949
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, `Protocol V2 target ${target} reached ${observedVersion}, expected ${expectedVersion}`);
|
|
50071
49950
|
}
|
|
50072
49951
|
}
|
|
@@ -50129,10 +50008,19 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
50129
50008
|
});
|
|
50130
50009
|
}
|
|
50131
50010
|
captureProtocolV2PhysicalIdentity() {
|
|
50011
|
+
var _a, _b;
|
|
50132
50012
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50133
50013
|
const deviceInfo = yield this.requestProtocolV2PhysicalIdentity();
|
|
50134
50014
|
const serialNumber = this.getProtocolV2SerialNumber(deviceInfo);
|
|
50135
|
-
|
|
50015
|
+
if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.preparedPlan) {
|
|
50016
|
+
assertFirmwareUpdatePreparedPlanDeviceIdentity({
|
|
50017
|
+
preparedPlan: this.params.preparedPlan,
|
|
50018
|
+
deviceIdentity: serialNumber,
|
|
50019
|
+
});
|
|
50020
|
+
}
|
|
50021
|
+
else {
|
|
50022
|
+
assertProtocolV2ReconnectIdentity((_b = this.params) === null || _b === void 0 ? void 0 : _b.expectedDeviceId, serialNumber);
|
|
50023
|
+
}
|
|
50136
50024
|
this.protocolV2ExpectedSerialNumber = serialNumber;
|
|
50137
50025
|
});
|
|
50138
50026
|
}
|
|
@@ -62236,6 +62124,7 @@ const onDevicePassphraseHandler = (...[device, requestPayload, callback]) => __a
|
|
|
62236
62124
|
device: device.toMessageObject(),
|
|
62237
62125
|
passphraseState: device.passphraseState,
|
|
62238
62126
|
existsAttachPinUser: requestPayload.existsAttachPinUser,
|
|
62127
|
+
deviceOnly: requestPayload.deviceOnly,
|
|
62239
62128
|
source: requestPayload.source,
|
|
62240
62129
|
reason: requestPayload.reason,
|
|
62241
62130
|
expectedPassphraseState: requestPayload.expectedPassphraseState,
|