@onekeyfe/hd-core 1.2.0-alpha.169 → 1.2.0-alpha.170
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__/firmware-update/firmware-update-v4-install-poll.test.ts +58 -12
- package/__tests__/protocol-v2-resources.test.ts +7 -0
- package/__tests__/protocol-v2.test.ts +191 -106
- package/dist/api/FirmwareUpdateV4.d.ts +2 -1
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/index.js +88 -73
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +115 -86
- package/src/core/index.ts +5 -2
- package/src/device/DeviceConnector.ts +2 -3
- package/src/protocols/protocol-v2/resources.ts +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AA0BlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AA+B/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAoErC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,sBAAsB,EAC9B,0BAA0B,UAAQ,QAiCnC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AA0BlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AA+B/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAA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AAC,kCAAkC;YAQ5B,cAAc;YAuCd,6BAA6B;YAW7B,0BAA0B;YA2B1B,6BAA6B;YA0C7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAsB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAYxD,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EACV,6BAA6B,EAG9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAWpD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAmE7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAoFvE,CAAC;AAiqBF,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAWpF;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAW/E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAQlF;AA0PD,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAsB1C,OAAO,eAAe,M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,eAAe,aACd,GAAG,WACL,6BAA6B,8BAiBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":";;AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAI9F,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQlB,OAAO,CAAC,kBAAkB;IAYpB,SAAS;IAWT,MAAM;IAgCZ,IAAI;IAIE,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,oBAAoB,CAAC,EAAE,OAAO,EAC9B,gBAAgB,CAAC,EAAE,uBAAuB,EAC1C,YAAY,CAAC,EAAE,uBAAuB,EACtC,sBAAsB,CAAC,EAAE,OAAO,EAChC,iBAAiB,CAAC,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":";;AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAI9F,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQlB,OAAO,CAAC,kBAAkB;IAYpB,SAAS;IAWT,MAAM;IAgCZ,IAAI;IAIE,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,oBAAoB,CAAC,EAAE,OAAO,EAC9B,gBAAgB,CAAC,EAAE,uBAAuB,EAC1C,YAAY,CAAC,EAAE,uBAAuB,EACtC,sBAAsB,CAAC,EAAE,OAAO,EAChC,iBAAiB,CAAC,EAAE,OAAO;IAuDvB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO;IAShE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAWnD,kBAAkB,IAAI,OAAO,CAAC,SAAS,GAAG,eAAe,GAAG,IAAI,CAAC;IAQjE,oBAAoB;CAGrB"}
|
package/dist/index.js
CHANGED
|
@@ -40716,7 +40716,12 @@ function isProtocolV2ResourceArchiveEntryName(entryName) {
|
|
|
40716
40716
|
const fileName = (_a = parts[parts.length - 1]) !== null && _a !== void 0 ? _a : '';
|
|
40717
40717
|
return (fileName.length > 0 &&
|
|
40718
40718
|
!fileName.startsWith('.') &&
|
|
40719
|
-
!parts.some(part => part
|
|
40719
|
+
!parts.some(part => !part ||
|
|
40720
|
+
part === '.' ||
|
|
40721
|
+
part === '..' ||
|
|
40722
|
+
part === '.DS_Store' ||
|
|
40723
|
+
part.startsWith('._') ||
|
|
40724
|
+
part.toUpperCase() === '__MACOSX'));
|
|
40720
40725
|
}
|
|
40721
40726
|
function isSafeResourceDevicePath(path) {
|
|
40722
40727
|
return !(path.includes('\\') ||
|
|
@@ -52033,15 +52038,6 @@ const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
|
52033
52038
|
const isProtocolV2TargetStatusFinished = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
|
|
52034
52039
|
const isProtocolV2TargetStatusInProgress = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_PENDING ||
|
|
52035
52040
|
normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_IN_PROGRESS;
|
|
52036
|
-
const getProtocolV2FirmwareStatusFingerprint = (statusTargets) => JSON.stringify(statusTargets.map(target => {
|
|
52037
|
-
var _a, _b, _c, _d, _e;
|
|
52038
|
-
return ({
|
|
52039
|
-
targetId: (_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : target.target_id,
|
|
52040
|
-
status: (_c = (_b = normalizeProtocolV2TargetStatus(target.status)) !== null && _b !== void 0 ? _b : target.status) !== null && _c !== void 0 ? _c : null,
|
|
52041
|
-
payloadVersion: (_d = target.payload_version) !== null && _d !== void 0 ? _d : null,
|
|
52042
|
-
path: (_e = target.path) !== null && _e !== void 0 ? _e : null,
|
|
52043
|
-
});
|
|
52044
|
-
}));
|
|
52045
52041
|
const isProtocolV2TargetStatusFailed = (status) => {
|
|
52046
52042
|
const normalizedStatus = normalizeProtocolV2TargetStatus(status);
|
|
52047
52043
|
return (typeof normalizedStatus === 'number' && normalizedStatus >= PROTOCOL_V2_TARGET_STATUS_FAILED_MIN);
|
|
@@ -52145,6 +52141,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52145
52141
|
this.protocolV2CompletedTargetIds = new Set();
|
|
52146
52142
|
this.protocolV2InstallBaselineVersions = new Map();
|
|
52147
52143
|
this.protocolV2InstallNeedsBleReconnect = false;
|
|
52144
|
+
this.protocolV2InstallRequestConfirmed = false;
|
|
52148
52145
|
this.protocolV2LastTransferProgressAt = 0;
|
|
52149
52146
|
}
|
|
52150
52147
|
getSupportedProtocols() {
|
|
@@ -53420,12 +53417,25 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53420
53417
|
}
|
|
53421
53418
|
});
|
|
53422
53419
|
}
|
|
53423
|
-
|
|
53420
|
+
collectProtocolV2LiveTargetIds(statusTargets, expectedTargetIds, liveTargetIds) {
|
|
53421
|
+
statusTargets.forEach(target => {
|
|
53422
|
+
const targetId = normalizeProtocolV2TargetId(target.target_id);
|
|
53423
|
+
if (targetId !== undefined &&
|
|
53424
|
+
expectedTargetIds.has(targetId) &&
|
|
53425
|
+
isProtocolV2TargetStatusInProgress(target.status)) {
|
|
53426
|
+
liveTargetIds.add(targetId);
|
|
53427
|
+
}
|
|
53428
|
+
});
|
|
53429
|
+
}
|
|
53430
|
+
assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths, liveTargetIds) {
|
|
53431
|
+
const resolvedExpectedPaths = expectedPaths !== null && expectedPaths !== void 0 ? expectedPaths : new Map();
|
|
53424
53432
|
Log$7.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateStatus records=${JSON.stringify(statusTargets)}`);
|
|
53425
53433
|
const failedTarget = statusTargets.find(target => {
|
|
53426
53434
|
var _a;
|
|
53427
|
-
|
|
53428
|
-
|
|
53435
|
+
const targetId = (_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1;
|
|
53436
|
+
return (expectedTargetIds.has(targetId) &&
|
|
53437
|
+
isProtocolV2TargetStatusFailed(target.status) &&
|
|
53438
|
+
(!liveTargetIds || liveTargetIds.has(targetId)));
|
|
53429
53439
|
});
|
|
53430
53440
|
if (failedTarget) {
|
|
53431
53441
|
const failedTargetDetails = JSON.stringify({
|
|
@@ -53439,13 +53449,33 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53439
53449
|
firmwareUpdateCode: PROTOCOL_V2_INSTALL_FAILED_CODE,
|
|
53440
53450
|
});
|
|
53441
53451
|
}
|
|
53452
|
+
if (liveTargetIds) {
|
|
53453
|
+
const staleFailedTargets = statusTargets.filter(target => {
|
|
53454
|
+
var _a;
|
|
53455
|
+
const targetId = (_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1;
|
|
53456
|
+
return (expectedTargetIds.has(targetId) &&
|
|
53457
|
+
isProtocolV2TargetStatusFailed(target.status) &&
|
|
53458
|
+
!liveTargetIds.has(targetId));
|
|
53459
|
+
});
|
|
53460
|
+
if (staleFailedTargets.length > 0) {
|
|
53461
|
+
Log$7.log(`[FirmwareUpdateV4] ignoring stale failed firmware status until those targets start: ${JSON.stringify(staleFailedTargets.map(target => ({
|
|
53462
|
+
targetId: target.target_id,
|
|
53463
|
+
status: target.status,
|
|
53464
|
+
path: target.path,
|
|
53465
|
+
})))}`);
|
|
53466
|
+
}
|
|
53467
|
+
}
|
|
53442
53468
|
const matchingTargets = statusTargets.filter(target => { var _a; return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1); });
|
|
53443
53469
|
const seenTargetIds = new Set();
|
|
53444
53470
|
for (const target of matchingTargets) {
|
|
53445
53471
|
const targetId = normalizeProtocolV2TargetId(target.target_id);
|
|
53472
|
+
const pathConflictsWithCurrentInstall = Boolean(target.path) &&
|
|
53473
|
+
Boolean(resolvedExpectedPaths.get(targetId)) &&
|
|
53474
|
+
target.path !== resolvedExpectedPaths.get(targetId) &&
|
|
53475
|
+
(!liveTargetIds || liveTargetIds.has(targetId));
|
|
53446
53476
|
if (targetId === undefined ||
|
|
53447
53477
|
seenTargetIds.has(targetId) ||
|
|
53448
|
-
|
|
53478
|
+
pathConflictsWithCurrentInstall) {
|
|
53449
53479
|
Log$7.error(`[FirmwareUpdateV4] install status conflicts with target=${target.target_id}`);
|
|
53450
53480
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, 'Protocol V2 firmware install status conflict', {
|
|
53451
53481
|
firmwareUpdateCode: PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE,
|
|
@@ -53539,25 +53569,21 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53539
53569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53540
53570
|
const expectedTargetIds = new Set(targets.map(target => target.target_id));
|
|
53541
53571
|
const expectedPaths = new Map(targets.map(target => [target.target_id, target.path]));
|
|
53542
|
-
const
|
|
53543
|
-
let installStartedAt = requireCurrentInstallStatus ? undefined : confirmationStartedAt;
|
|
53544
|
-
const effectiveBaselineStatusTargets = this.protocolV2InstallStatusBaseline;
|
|
53545
|
-
const baselineStatusFingerprint = effectiveBaselineStatusTargets
|
|
53546
|
-
? getProtocolV2FirmwareStatusFingerprint(effectiveBaselineStatusTargets)
|
|
53547
|
-
: undefined;
|
|
53572
|
+
const startTime = Date.now();
|
|
53548
53573
|
let lastError;
|
|
53549
53574
|
let shouldReconnect = this.protocolV2InstallNeedsBleReconnect;
|
|
53550
53575
|
this.protocolV2InstallNeedsBleReconnect = false;
|
|
53551
53576
|
let deviceInfo;
|
|
53552
53577
|
let bleInstallLinkReady = false;
|
|
53553
|
-
let installEvidenceObserved =
|
|
53578
|
+
let installEvidenceObserved = this.protocolV2InstallRequestConfirmed;
|
|
53554
53579
|
let currentInstallStatusObserved = false;
|
|
53555
|
-
|
|
53580
|
+
const liveTargetIds = new Set();
|
|
53581
|
+
while (Date.now() - startTime < PROTOCOL_V2_INSTALL_TIMEOUT) {
|
|
53556
53582
|
this.throwIfAborted();
|
|
53557
53583
|
try {
|
|
53558
53584
|
if (shouldReconnect) {
|
|
53559
53585
|
const isBleInstallReconnect = this.isBleReconnect();
|
|
53560
|
-
yield this.reconnectProtocolV2Device({
|
|
53586
|
+
yield this.reconnectProtocolV2Device({ skipProtocolProbe: true });
|
|
53561
53587
|
bleInstallLinkReady = isBleInstallReconnect;
|
|
53562
53588
|
deviceInfo = isBleInstallReconnect
|
|
53563
53589
|
? undefined
|
|
@@ -53580,27 +53606,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53580
53606
|
const statusTargets = statusResponse.type === 'DeviceFirmwareUpdateStatus'
|
|
53581
53607
|
? ((_a = statusResponse.message.records) !== null && _a !== void 0 ? _a : [])
|
|
53582
53608
|
: [];
|
|
53583
|
-
|
|
53584
|
-
|
|
53585
|
-
return (targetId !== undefined &&
|
|
53586
|
-
expectedTargetIds.has(targetId) &&
|
|
53587
|
-
isProtocolV2TargetStatusInProgress(target.status));
|
|
53588
|
-
});
|
|
53589
|
-
const isExpectedStatusSnapshot = statusTargets.length === targets.length &&
|
|
53590
|
-
targets.every((expectedTarget, index) => {
|
|
53591
|
-
const statusTarget = statusTargets[index];
|
|
53592
|
-
return (statusTarget !== undefined &&
|
|
53593
|
-
normalizeProtocolV2TargetId(statusTarget.target_id) === expectedTarget.target_id &&
|
|
53594
|
-
statusTarget.path === expectedTarget.path);
|
|
53595
|
-
});
|
|
53596
|
-
const statusFingerprint = getProtocolV2FirmwareStatusFingerprint(statusTargets);
|
|
53597
|
-
const hasCurrentInstallTransition = baselineStatusFingerprint !== undefined
|
|
53598
|
-
? isExpectedStatusSnapshot && statusFingerprint !== baselineStatusFingerprint
|
|
53599
|
-
: hasPendingOrInProgressTarget;
|
|
53600
|
-
if (!currentInstallStatusObserved && hasCurrentInstallTransition) {
|
|
53609
|
+
this.collectProtocolV2LiveTargetIds(statusTargets, expectedTargetIds, liveTargetIds);
|
|
53610
|
+
if (liveTargetIds.size > 0) {
|
|
53601
53611
|
currentInstallStatusObserved = true;
|
|
53602
|
-
installStartedAt = Date.now();
|
|
53603
|
-
Log$7.log('[FirmwareUpdateV4] current firmware install records observed');
|
|
53604
53612
|
}
|
|
53605
53613
|
const hasMatchingTargetStatus = statusTargets.some(target => {
|
|
53606
53614
|
const targetId = normalizeProtocolV2TargetId(target.target_id);
|
|
@@ -53616,7 +53624,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53616
53624
|
});
|
|
53617
53625
|
const shouldVerifyTargetCompletion = !requireCurrentInstallStatus || currentInstallStatusObserved;
|
|
53618
53626
|
if (shouldVerifyTargetCompletion &&
|
|
53619
|
-
this.assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths)) {
|
|
53627
|
+
this.assertProtocolV2TargetStatus(statusTargets, expectedTargetIds, expectedPaths, requireCurrentInstallStatus ? liveTargetIds : undefined)) {
|
|
53620
53628
|
return;
|
|
53621
53629
|
}
|
|
53622
53630
|
if (requireCurrentInstallStatus &&
|
|
@@ -53814,16 +53822,36 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53814
53822
|
});
|
|
53815
53823
|
}
|
|
53816
53824
|
reconnectProtocolV2Device(options) {
|
|
53817
|
-
var _a, _b, _c, _d, _e, _f;
|
|
53825
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
53818
53826
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53819
53827
|
if (this.isBleReconnect()) {
|
|
53820
|
-
yield this.acquireProtocolV2BleDevice(options === null || options === void 0 ? void 0 : options.
|
|
53828
|
+
yield this.acquireProtocolV2BleDevice(options === null || options === void 0 ? void 0 : options.skipProtocolProbe);
|
|
53821
53829
|
return;
|
|
53822
53830
|
}
|
|
53823
53831
|
const deviceDiff = yield ((_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.enumerate());
|
|
53824
53832
|
const devicesDescriptor = (_b = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _b !== void 0 ? _b : [];
|
|
53825
|
-
|
|
53826
|
-
|
|
53833
|
+
const env = DataManager.getSettings('env');
|
|
53834
|
+
const isWebUsb = DataManager.isBrowserWebUsb(env) || DataManager.isDesktopWebUsb(env);
|
|
53835
|
+
if (isWebUsb && (options === null || options === void 0 ? void 0 : options.skipProtocolProbe)) {
|
|
53836
|
+
const expectedSerialNumber = (_c = this.protocolV2ExpectedSerialNumber) === null || _c === void 0 ? void 0 : _c.trim();
|
|
53837
|
+
const expectedPath = (_d = this.protocolV2ExpectedPath) === null || _d === void 0 ? void 0 : _d.trim();
|
|
53838
|
+
const reconnectDescriptor = devicesDescriptor.find(descriptor => {
|
|
53839
|
+
var _a;
|
|
53840
|
+
const descriptorPath = (_a = descriptor.path) === null || _a === void 0 ? void 0 : _a.trim();
|
|
53841
|
+
return ((!!expectedSerialNumber && descriptorPath === expectedSerialNumber) ||
|
|
53842
|
+
(!!expectedPath && descriptorPath === expectedPath));
|
|
53843
|
+
});
|
|
53844
|
+
if (!(reconnectDescriptor === null || reconnectDescriptor === void 0 ? void 0 : reconnectDescriptor.path)) {
|
|
53845
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
53846
|
+
}
|
|
53847
|
+
this.device.updateDescriptor(Object.assign(Object.assign({}, reconnectDescriptor), { protocolType: PROTOCOL_V2_CONNECT_PROTOCOL }), true);
|
|
53848
|
+
const mainId = yield ((_e = this.device.deviceConnector) === null || _e === void 0 ? void 0 : _e.acquire(reconnectDescriptor.path, null, undefined, PROTOCOL_V2_CONNECT_PROTOCOL, undefined, undefined, true));
|
|
53849
|
+
this.device.mainId = typeof mainId === 'string' ? mainId : reconnectDescriptor.path;
|
|
53850
|
+
this.device.commands.disposed = false;
|
|
53851
|
+
this.device.getCommands().mainId = this.device.mainId;
|
|
53852
|
+
return;
|
|
53853
|
+
}
|
|
53854
|
+
if (isWebUsb && devicesDescriptor.length === 1) {
|
|
53827
53855
|
const descriptor = devicesDescriptor[0];
|
|
53828
53856
|
if (!this.protocolV2ExpectedSerialNumber && descriptor.path !== this.protocolV2ExpectedPath) {
|
|
53829
53857
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
@@ -53831,14 +53859,14 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53831
53859
|
this.device.updateDescriptor(Object.assign(Object.assign({}, descriptor), { protocolType: PROTOCOL_V2_CONNECT_PROTOCOL }), true);
|
|
53832
53860
|
yield this.ensureProtocolV2DeviceAcquired();
|
|
53833
53861
|
this.device.commands.disposed = false;
|
|
53834
|
-
this.device.getCommands().mainId = (
|
|
53862
|
+
this.device.getCommands().mainId = (_f = this.device.mainId) !== null && _f !== void 0 ? _f : '';
|
|
53835
53863
|
return;
|
|
53836
53864
|
}
|
|
53837
53865
|
const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, undefined, {
|
|
53838
53866
|
connectProtocol: PROTOCOL_V2_CONNECT_PROTOCOL,
|
|
53839
53867
|
});
|
|
53840
|
-
const expectedSerialNumber = (
|
|
53841
|
-
const expectedPath = (
|
|
53868
|
+
const expectedSerialNumber = (_g = this.protocolV2ExpectedSerialNumber) === null || _g === void 0 ? void 0 : _g.trim();
|
|
53869
|
+
const expectedPath = (_h = this.protocolV2ExpectedPath) === null || _h === void 0 ? void 0 : _h.trim();
|
|
53842
53870
|
const reconnectDevice = deviceList.find(candidate => {
|
|
53843
53871
|
var _a;
|
|
53844
53872
|
const candidateSerialNumber = (_a = candidate.getCurrentSerialNo) === null || _a === void 0 ? void 0 : _a.call(candidate).trim();
|
|
@@ -53854,7 +53882,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53854
53882
|
this.device.updateFromCache(reconnectDevice);
|
|
53855
53883
|
yield this.ensureProtocolV2DeviceAcquired();
|
|
53856
53884
|
this.device.commands.disposed = false;
|
|
53857
|
-
this.device.getCommands().mainId = (
|
|
53885
|
+
this.device.getCommands().mainId = (_j = this.device.mainId) !== null && _j !== void 0 ? _j : '';
|
|
53858
53886
|
});
|
|
53859
53887
|
}
|
|
53860
53888
|
ensureProtocolV2DeviceAcquired() {
|
|
@@ -53932,34 +53960,20 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53932
53960
|
});
|
|
53933
53961
|
}
|
|
53934
53962
|
protocolV2StartFirmwareUpdate({ targets, }) {
|
|
53935
|
-
var _a;
|
|
53936
53963
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53937
53964
|
this.protocolV2LastRuntimeProbeFeatures = undefined;
|
|
53938
|
-
this.protocolV2InstallStatusBaseline = undefined;
|
|
53939
53965
|
this.protocolV2InstallNeedsBleReconnect = false;
|
|
53966
|
+
this.protocolV2InstallRequestConfirmed = false;
|
|
53940
53967
|
const commands = this.device.getCommands();
|
|
53941
53968
|
yield commands.typedCall('DeviceFirmwareUpdateStage', 'Success', { targets });
|
|
53942
|
-
try {
|
|
53943
|
-
const baselineStatusResponse = yield commands.typedCall('DeviceFirmwareUpdateStatusGet', ['DeviceFirmwareUpdateStatus', 'Success'], {
|
|
53944
|
-
fields: {
|
|
53945
|
-
status: true,
|
|
53946
|
-
payload_version: true,
|
|
53947
|
-
path: true,
|
|
53948
|
-
},
|
|
53949
|
-
}, { timeoutMs: PROTOCOL_V2_FIRMWARE_STATUS_RESPONSE_TIMEOUT });
|
|
53950
|
-
this.protocolV2InstallStatusBaseline =
|
|
53951
|
-
baselineStatusResponse.type === 'DeviceFirmwareUpdateStatus'
|
|
53952
|
-
? ((_a = baselineStatusResponse.message.records) !== null && _a !== void 0 ? _a : [])
|
|
53953
|
-
: [];
|
|
53954
|
-
}
|
|
53955
|
-
catch (error) {
|
|
53956
|
-
Log$7.log('[FirmwareUpdateV4] unable to capture pre-install firmware status: ', error);
|
|
53957
|
-
}
|
|
53958
53969
|
this.device.setCancelableAction(() => commands.cancelDevice());
|
|
53959
53970
|
const interaction = this.device.createProtocolV2UiPhaseMetadata('button', 'start');
|
|
53960
53971
|
this.postMessage(createUiMessage(UI_REQUEST.REQUEST_BUTTON, Object.assign({ device: this.device.toMessageObject(), source: 'method-lifecycle', reason: 'firmware-update', completion: 'operation-completed', deviceOnly: true, operation: this.name }, (interaction ? { interaction } : {}))));
|
|
53961
53972
|
try {
|
|
53962
|
-
yield commands.
|
|
53973
|
+
yield commands.typedCall('DeviceFirmwareUpdateRequest', 'Success', {});
|
|
53974
|
+
this.protocolV2InstallRequestConfirmed = true;
|
|
53975
|
+
this.postProgressMessage(1, 'installingFirmware');
|
|
53976
|
+
Log$7.log('[FirmwareUpdateV4] firmware install confirmed by device response');
|
|
53963
53977
|
}
|
|
53964
53978
|
catch (error) {
|
|
53965
53979
|
this.throwIfAborted();
|
|
@@ -64814,6 +64828,7 @@ class DeviceConnector {
|
|
|
64814
64828
|
expectedProtocol,
|
|
64815
64829
|
protocolHint,
|
|
64816
64830
|
forceProtocolDetection,
|
|
64831
|
+
skipProtocolProbe,
|
|
64817
64832
|
});
|
|
64818
64833
|
}
|
|
64819
64834
|
if (expectedProtocol) {
|
|
@@ -65906,6 +65921,7 @@ const cancel = (context, connectId) => {
|
|
|
65906
65921
|
requestQueue.cancelCallbackTasks(connectId);
|
|
65907
65922
|
const requestIds = requestQueue.getRequestTasksId();
|
|
65908
65923
|
Log.debug(`Cancel Api connect requestQueues: length:${requestIds.length} requestIds:${requestIds.join(',')}`);
|
|
65924
|
+
requestQueue.abortRequestsByConnectId(connectId);
|
|
65909
65925
|
const canceledDevices = [];
|
|
65910
65926
|
const interruptDevice = (device, deviceConnectId) => {
|
|
65911
65927
|
if (!device || canceledDevices.includes(device)) {
|
|
@@ -65924,7 +65940,6 @@ const cancel = (context, connectId) => {
|
|
|
65924
65940
|
}
|
|
65925
65941
|
}
|
|
65926
65942
|
interruptDevice(deviceCacheMap.get(connectId), connectId);
|
|
65927
|
-
requestQueue.abortRequestsByConnectId(connectId);
|
|
65928
65943
|
pollingManager.stop(connectId);
|
|
65929
65944
|
}
|
|
65930
65945
|
catch (e) {
|
|
@@ -65935,6 +65950,7 @@ const cancel = (context, connectId) => {
|
|
|
65935
65950
|
const env = DataManager.getSettings('env');
|
|
65936
65951
|
if (DataManager.isBleConnect(env)) {
|
|
65937
65952
|
Log.debug('Cancel Api all _deviceList: ');
|
|
65953
|
+
requestQueue.abortAllRequests();
|
|
65938
65954
|
const canceledDevices = [];
|
|
65939
65955
|
const interruptDevice = (device) => {
|
|
65940
65956
|
if (!device || canceledDevices.includes(device)) {
|
|
@@ -65956,7 +65972,6 @@ const cancel = (context, connectId) => {
|
|
|
65956
65972
|
}
|
|
65957
65973
|
}
|
|
65958
65974
|
deviceCacheMap.forEach(interruptDevice);
|
|
65959
|
-
requestQueue.abortAllRequests();
|
|
65960
65975
|
pollingManager.stopAll();
|
|
65961
65976
|
}
|
|
65962
65977
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,sCAAsC,iDACH,CAAC;AACjD,eAAO,MAAM,8CAA8C,QAAsD,CAAC;AAClH,eAAO,MAAM,mCAAmC,mCAAmC,CAAC;AACpF,eAAO,MAAM,wCAAwC,QAAS,CAAC;AAW/D,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CA8BzF;AAED,wBAAgB,oCAAoC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,sCAAsC,iDACH,CAAC;AACjD,eAAO,MAAM,8CAA8C,QAAsD,CAAC;AAClH,eAAO,MAAM,mCAAmC,mCAAmC,CAAC;AACpF,eAAO,MAAM,wCAAwC,QAAS,CAAC;AAW/D,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CA8BzF;AAED,wBAAgB,oCAAoC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAoB/E;AA0CD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,GAClB,+BAA+B,CAyCjC;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,WAAW,GAAG,UAAU,GAC/B,+BAA+B,CAGjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.170",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.170",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.170",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/w3c-web-usb": "^1.0.10",
|
|
47
47
|
"@types/web-bluetooth": "^0.0.21"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d702db069d6b19f74cd5f1cf42277a7152beb3a8"
|
|
50
50
|
}
|