@onekeyfe/hd-core 1.2.0-alpha.157 → 1.2.0-alpha.159

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/dist/index.js CHANGED
@@ -468,7 +468,7 @@ const getDeviceTypeByBleName = (name) => {
468
468
  if (/^Touch/i.test(name))
469
469
  return hdShared.EDeviceType.Touch;
470
470
  const compactName = name.replace(/[\s-]/g, '');
471
- if (/\bPro\s*2\b/i.test(name) || /^Pro2/i.test(name) || /^(?:OneKey)?Pro2/i.test(compactName)) {
471
+ if (/\bPro\s*2\b/i.test(name) || /^(?:OneKey)?Pro2[a-f0-9]{4}$/i.test(compactName)) {
472
472
  return hdShared.EDeviceType.Pro2;
473
473
  }
474
474
  if (/\bNeo\b/i.test(name) || /^Neo/i.test(name) || /^(?:OneKey)?Neo/i.test(compactName)) {
@@ -930,22 +930,6 @@ const finalizeFirmwareUpdatePlan = ({ features, firmwareType, platform, artifact
930
930
  };
931
931
  return assertFirmwareUpdatePlan(Object.assign(Object.assign({}, planWithoutDigest), { planDigest: digestFirmwareUpdatePlan(planWithoutDigest) }));
932
932
  };
933
- const buildProtocolV2LocalFirmwareUpdatePlan = ({ features, firmwareType, platform, artifacts, }) => {
934
- if (artifacts.length === 0) {
935
- return planError('Protocol V2 local firmware plan has no artifacts');
936
- }
937
- const plan = finalizeFirmwareUpdatePlan({
938
- features,
939
- firmwareType,
940
- platform,
941
- artifacts: artifacts.map(artifact => (Object.assign(Object.assign({}, artifact), { role: artifact.target === 'resource' ? 'resourceBundle' : 'component', url: `https://local-firmware.invalid/${encodeURIComponent(artifact.artifactId)}` }))),
942
- targetsToUpdate: artifacts.map(artifact => artifact.target),
943
- });
944
- if (plan.executor !== 'v4') {
945
- return planError('Protocol V2 local firmware plan requires executor v4');
946
- }
947
- return plan;
948
- };
949
933
  const buildProtocolV2FirmwareUpdatePlan = ({ features, firmwareType, platform, release, targetsToUpdate, forceUpdateTargets, resourceArchive, }) => {
950
934
  const validatedForceTargets = validateFirmwareUpdatePlanForceTargets(forceUpdateTargets);
951
935
  if (validatedForceTargets.some(target => target === 'ble' || target === 'bootloader')) {
@@ -43430,7 +43414,7 @@ class TransportManager {
43430
43414
  yield this.transport.init(WebBleLogger, DevicePool.emitter);
43431
43415
  }
43432
43416
  else if (env === 'webusb' || env === 'desktop-webusb') {
43433
- yield this.transport.init(WebUsbLogger);
43417
+ yield this.transport.init(WebUsbLogger, DevicePool.emitter);
43434
43418
  }
43435
43419
  else {
43436
43420
  yield this.transport.init(HttpLogger);
@@ -51719,86 +51703,6 @@ const INSTALLABLE_FIRMWARE_TARGET_IDS = new Set([
51719
51703
  ]);
51720
51704
  new Map(Object.entries(ProtocolV2FirmwareTargetType).flatMap(([key, value]) => INSTALLABLE_FIRMWARE_TARGET_IDS.has(value) ? [[key, value]] : []));
51721
51705
 
51722
- let memoryHostSequence = 0;
51723
- const createReference = (binary, prefix) => {
51724
- const digest = utils.bytesToHex(sha256.sha256(new Uint8Array(binary)));
51725
- return {
51726
- artifactRef: `fwmem:${prefix}:${digest.slice(0, 32)}`,
51727
- size: binary.byteLength,
51728
- sha256: digest,
51729
- };
51730
- };
51731
- function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }) {
51732
- if (plan.executor !== 'v4') {
51733
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Firmware memory host only supports V4 plans');
51734
- }
51735
- memoryHostSequence += 1;
51736
- const hostId = `${Date.now()}:${memoryHostSequence}`;
51737
- const binaries = new Map();
51738
- const inputs = artifacts.map((input, artifactIndex) => {
51739
- var _a;
51740
- const artifactBinary = new Uint8Array(input.binary).slice();
51741
- const artifact = createReference(artifactBinary.buffer, `${hostId}:artifact:${artifactIndex}`);
51742
- binaries.set(artifact.artifactRef, artifactBinary);
51743
- const materializedEntries = (_a = input.materializedEntries) === null || _a === void 0 ? void 0 : _a.map((entry, entryIndex) => {
51744
- const entryArtifact = createReference(entry.binary, `${hostId}:entry:${artifactIndex}:${entryIndex}`);
51745
- return {
51746
- entryName: entry.entryName,
51747
- artifact: entryArtifact,
51748
- };
51749
- });
51750
- return Object.assign({ artifactId: input.artifactId, artifact }, ((materializedEntries === null || materializedEntries === void 0 ? void 0 : materializedEntries.length) ? { materializedEntries } : {}));
51751
- });
51752
- const preparedPlan = sdk.prepareFirmwareUpdatePlan({
51753
- plan,
51754
- leaseRef: `fwmemlease:${hostId}`,
51755
- artifacts: inputs,
51756
- });
51757
- const readers = new Map();
51758
- let readerSequence = 0;
51759
- const artifactReader = {
51760
- open({ artifactRef }) {
51761
- const binary = binaries.get(artifactRef);
51762
- if (!binary) {
51763
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Firmware memory artifact is unavailable');
51764
- }
51765
- readerSequence += 1;
51766
- const readerId = `fwmemreader:${hostId}:${readerSequence}`;
51767
- readers.set(readerId, binary);
51768
- return Promise.resolve({ readerId, size: binary.byteLength });
51769
- },
51770
- read({ readerId, offset, length }) {
51771
- const binary = readers.get(readerId);
51772
- if (!binary || offset < 0 || length <= 0 || offset + length > binary.byteLength) {
51773
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Firmware memory artifact read is invalid');
51774
- }
51775
- const data = binary.slice(offset, offset + length).buffer;
51776
- return Promise.resolve({
51777
- data,
51778
- bytesRead: data.byteLength,
51779
- eof: offset + length === binary.byteLength,
51780
- });
51781
- },
51782
- close({ readerId }) {
51783
- readers.delete(readerId);
51784
- return Promise.resolve();
51785
- },
51786
- };
51787
- const hostBindingGeneration = sdk.registerFirmwareUpdateHostBinding({
51788
- artifactReader,
51789
- preparedPlanDigest: preparedPlan.preparedPlanDigest,
51790
- });
51791
- return {
51792
- preparedPlan,
51793
- hostBindingGeneration,
51794
- release: () => {
51795
- sdk.unregisterFirmwareUpdateHostBinding(hostBindingGeneration);
51796
- readers.clear();
51797
- binaries.clear();
51798
- },
51799
- };
51800
- }
51801
-
51802
51706
  const Log$7 = getLogger(exports.LoggerNames.Method);
51803
51707
  const SESSION_ERROR$1 = 'session not found';
51804
51708
  const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 90 * 1000;
@@ -51918,12 +51822,8 @@ const PROTOCOL_V2_REMOTE_COMPONENT_TARGETS = {
51918
51822
  },
51919
51823
  };
51920
51824
  const PROTOCOL_V2_FIRMWARE_STAGING_PATHS = new Set(Object.values(PROTOCOL_V2_REMOTE_COMPONENT_TARGETS).map(target => `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}${target.fileName}`));
51921
- const isProtocolV2BootResourcePackagePath = (devicePath) => {
51922
- if (typeof devicePath !== 'string')
51923
- return false;
51924
- const normalized = devicePath.toLowerCase();
51925
- return (normalized.startsWith('vol0:/loaders/bootloader/') && normalized.endsWith('.okpkg.staging'));
51926
- };
51825
+ const isProtocolV2BootResourcePackagePath = (devicePath) => typeof devicePath === 'string' &&
51826
+ devicePath.toLowerCase() === PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH;
51927
51827
  const PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID = new Map([
51928
51828
  [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER, 'boot'],
51929
51829
  [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1, 'app_v1'],
@@ -52271,16 +52171,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52271
52171
  if (!this.params.preparedPlan &&
52272
52172
  this.params.resourceArchiveBinary &&
52273
52173
  ((_c = this.params.targetsToUpdate) === null || _c === void 0 ? void 0 : _c.includes('resource'))) {
52274
- const localMemoryHost = yield this.prepareProtocolV2LocalMemoryHost({
52275
- features: deviceFeatures,
52276
- firmwareType,
52277
- });
52278
- try {
52279
- return yield this.runProtocolV2PreparedArtifacts(deviceFeatures, firmwareType);
52280
- }
52281
- finally {
52282
- localMemoryHost.release();
52283
- }
52174
+ return this.runProtocolV2DirectArtifacts({});
52284
52175
  }
52285
52176
  const hasPreparedComponentArtifacts = Object.values((_d = this.params.componentArtifacts) !== null && _d !== void 0 ? _d : {}).some(Boolean);
52286
52177
  if (this.params.preparedPlan || hasPreparedComponentArtifacts) {
@@ -52289,12 +52180,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52289
52180
  let fwBinaryMap = [];
52290
52181
  let bootloaderBinary = null;
52291
52182
  let installItems;
52292
- let resourceMemoryHost;
52183
+ let explicitInstallItems;
52293
52184
  try {
52294
52185
  this.postTipMessage(exports.FirmwareUpdateTipMessage.StartDownloadFirmware);
52295
52186
  fwBinaryMap = this.collectExplicitTargetBinaries();
52296
52187
  bootloaderBinary = this.prepareBootloaderBinary();
52297
- const explicitInstallItems = this.buildProtocolV2InstallItems({
52188
+ explicitInstallItems = this.buildProtocolV2InstallItems({
52298
52189
  bootloaderBinary,
52299
52190
  fwBinaryMap,
52300
52191
  });
@@ -52336,16 +52227,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52336
52227
  }
52337
52228
  if (wantsResources) {
52338
52229
  this.params.resourceArchiveBinary = yield this.downloadRemoteProtocolV2ResourceArchive(deviceFeatures, firmwareType);
52339
- resourceMemoryHost = yield this.prepareProtocolV2LocalMemoryHost({
52340
- features: deviceFeatures,
52341
- firmwareType,
52342
- availableInstallItems: installItems !== null && installItems !== void 0 ? installItems : explicitInstallItems,
52343
- });
52344
52230
  }
52345
52231
  this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
52346
52232
  }
52347
52233
  catch (err) {
52348
- resourceMemoryHost === null || resourceMemoryHost === void 0 ? void 0 : resourceMemoryHost.release();
52349
52234
  if (typeof err === 'object' &&
52350
52235
  err !== null &&
52351
52236
  'params' in err &&
@@ -52357,13 +52242,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52357
52242
  }
52358
52243
  throw normalizeFirmwarePreparationError(err);
52359
52244
  }
52360
- if (resourceMemoryHost) {
52361
- try {
52362
- return yield this.runProtocolV2PreparedArtifacts(deviceFeatures, firmwareType, false);
52363
- }
52364
- finally {
52365
- resourceMemoryHost.release();
52366
- }
52245
+ if (wantsResources && this.params.resourceArchiveBinary) {
52246
+ return this.runProtocolV2DirectArtifacts({
52247
+ availableInstallItems: installItems !== null && installItems !== void 0 ? installItems : explicitInstallItems,
52248
+ announceDownload: false,
52249
+ });
52367
52250
  }
52368
52251
  if (!bootloaderBinary && fwBinaryMap.length === 0 && !(installItems === null || installItems === void 0 ? void 0 : installItems.length)) {
52369
52252
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, 'No firmware to update');
@@ -52464,95 +52347,59 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52464
52347
  return installSources;
52465
52348
  });
52466
52349
  }
52467
- prepareProtocolV2LocalMemoryHost({ features, firmwareType, availableInstallItems = this.buildProtocolV2InstallItems({
52468
- bootloaderBinary: this.prepareBootloaderBinary(),
52469
- fwBinaryMap: this.collectExplicitTargetBinaries(),
52470
- }), }) {
52471
- var _a, _b;
52350
+ runProtocolV2DirectArtifacts({ availableInstallItems, announceDownload = true, }) {
52472
52351
  return __awaiter(this, void 0, void 0, function* () {
52473
- const requestedComponentTargets = new Set(((_a = this.params.targetsToUpdate) !== null && _a !== void 0 ? _a : []).filter((target) => target !== 'resource' && target !== 'boot_resources'));
52474
- const localComponentTargets = new Set(availableInstallItems.flatMap(item => {
52475
- const target = PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID.get(item.targetId);
52476
- return target ? [target] : [];
52477
- }));
52478
- const missingTarget = Array.from(requestedComponentTargets).find(target => !localComponentTargets.has(target));
52479
- if (missingTarget) {
52480
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Protocol V2 local update has no binary for requested target ${missingTarget}`, {
52481
- firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
52482
- artifactName: missingTarget,
52352
+ try {
52353
+ if (announceDownload) {
52354
+ this.postTipMessage(exports.FirmwareUpdateTipMessage.StartDownloadFirmware);
52355
+ }
52356
+ const installItems = this.filterProtocolV2LocalInstallItems(availableInstallItems !== null && availableInstallItems !== void 0 ? availableInstallItems : this.buildProtocolV2InstallItems({
52357
+ bootloaderBinary: this.prepareBootloaderBinary(),
52358
+ fwBinaryMap: this.collectExplicitTargetBinaries(),
52359
+ }));
52360
+ const installSources = yield Promise.all(installItems.map((item) => __awaiter(this, void 0, void 0, function* () {
52361
+ return ({
52362
+ fileName: item.fileName,
52363
+ source: yield this.openProtocolV2MemorySource(item.binary),
52364
+ targetId: item.targetId,
52365
+ kind: item.kind,
52366
+ });
52367
+ })));
52368
+ const resourceSources = this.params.resourceArchiveBinary
52369
+ ? yield this.createProtocolV2ResourceSourcesFromArchive(this.params.resourceArchiveBinary)
52370
+ : [];
52371
+ if (installSources.length === 0 && resourceSources.length === 0) {
52372
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, 'No firmware to update');
52373
+ }
52374
+ if (announceDownload) {
52375
+ this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
52376
+ }
52377
+ return yield this.executeProtocolV2SourceUpdate({
52378
+ installSources,
52379
+ resourceSources,
52483
52380
  });
52484
52381
  }
52485
- const installItems = this.filterProtocolV2LocalInstallItems(availableInstallItems);
52486
- const planArtifacts = [];
52487
- const memoryArtifacts = [];
52488
- for (const item of installItems) {
52489
- const target = PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID.get(item.targetId);
52490
- if (!target || item.binary.byteLength <= 0) {
52491
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Protocol V2 local firmware artifact is invalid: ${item.fileName}`, { firmwareUpdateCode: 'FirmwareArtifactsNotPrepared' });
52492
- }
52493
- const artifactId = `component:${target}`;
52494
- planArtifacts.push(Object.assign({ artifactId,
52495
- target, container: 'raw', logicalName: item.fileName, expectedSize: item.binary.byteLength, expectedSha256: bytesToHex(sha256.sha256(new Uint8Array(item.binary))) }, (((_b = this.params.expectedTargetVersions) === null || _b === void 0 ? void 0 : _b[target])
52496
- ? { targetVersion: this.params.expectedTargetVersions[target] }
52497
- : {})));
52498
- memoryArtifacts.push({ artifactId, binary: item.binary });
52382
+ finally {
52383
+ yield this.closeProtocolV2PreparedSources();
52499
52384
  }
52500
- const resourceArchive = yield this.prepareProtocolV2LocalResourceArchive(this.params.resourceArchiveBinary);
52501
- const resourceArtifactId = 'resource:archive';
52502
- planArtifacts.push({
52503
- artifactId: resourceArtifactId,
52504
- target: 'resource',
52505
- container: 'zip',
52506
- logicalName: 'protocol-v2-local-resource-archive',
52507
- expectedSize: resourceArchive.binary.byteLength,
52508
- expectedSha256: bytesToHex(sha256.sha256(new Uint8Array(resourceArchive.binary))),
52509
- });
52510
- memoryArtifacts.push({
52511
- artifactId: resourceArtifactId,
52512
- binary: resourceArchive.binary,
52513
- materializedEntries: resourceArchive.materializedEntries,
52514
- });
52515
- const plan = buildProtocolV2LocalFirmwareUpdatePlan({
52516
- features,
52517
- firmwareType,
52518
- platform: this.params.platform,
52519
- artifacts: planArtifacts,
52520
- });
52521
- let memoryHost;
52522
- try {
52523
- memoryHost = prepareFirmwareUpdateV4MemoryHost({
52524
- sdk: {
52525
- prepareFirmwareUpdatePlan,
52526
- registerFirmwareUpdateHostBinding,
52527
- unregisterFirmwareUpdateHostBinding,
52528
- },
52529
- plan,
52530
- artifacts: memoryArtifacts,
52531
- });
52532
- const preparedPlan = validateFirmwareUpdatePreparedPlan(memoryHost.preparedPlan);
52533
- assertFirmwareUpdatePreparedPlanBinding({
52534
- preparedPlan,
52535
- executor: 'v4',
52536
- platform: this.params.platform,
52537
- scopeTargets: [],
52538
- bindings: [],
52539
- });
52540
- assertFirmwareUpdatePreparedPlanDeviceIdentity({
52541
- preparedPlan,
52542
- deviceIdentity: this.protocolV2ExpectedSerialNumber,
52543
- deviceModel: this.getProtocolV2PreparedPlanDeviceModel(features),
52385
+ });
52386
+ }
52387
+ createProtocolV2ResourceSourcesFromArchive(binary) {
52388
+ var _a;
52389
+ return __awaiter(this, void 0, void 0, function* () {
52390
+ const archive = yield this.prepareProtocolV2LocalResourceArchive(binary);
52391
+ const sources = [];
52392
+ for (const resource of archive.resources) {
52393
+ sources.push({
52394
+ name: (_a = resource.entryName.split('/').pop()) !== null && _a !== void 0 ? _a : resource.entryName,
52395
+ source: yield this.openProtocolV2MemorySource(resource.binary),
52396
+ devicePath: resource.header.devicePath,
52397
+ version: resource.header.version,
52398
+ payloadHash: resource.header.payloadHash,
52399
+ headerHash: resource.header.headerHash,
52544
52400
  });
52545
- const hostBinding = resolveFirmwareUpdateHostBinding(memoryHost.hostBindingGeneration, preparedPlan.preparedPlanDigest);
52546
- this.params.preparedPlan = preparedPlan;
52547
- this.params.targetsToUpdate = [...preparedPlan.targetsToUpdate];
52548
- this.params.artifactReader = hostBinding.artifactReader;
52549
- this.params.componentArtifacts = undefined;
52550
- return memoryHost;
52551
- }
52552
- catch (error) {
52553
- memoryHost === null || memoryHost === void 0 ? void 0 : memoryHost.release();
52554
- throw error;
52555
52401
  }
52402
+ return sources;
52556
52403
  });
52557
52404
  }
52558
52405
  prepareProtocolV2LocalResourceArchive(binary) {
@@ -52574,7 +52421,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52574
52421
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 resource ZIP has no valid resource package set', { firmwareUpdateCode: 'FirmwareArtifactsNotPrepared' });
52575
52422
  }
52576
52423
  let totalSize = 0;
52577
- const materializedEntries = [];
52578
52424
  const resources = [];
52579
52425
  const devicePaths = new Set();
52580
52426
  for (const entry of resourceEntries) {
@@ -52601,10 +52447,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52601
52447
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Protocol V2 resource ZIP contains duplicate device path: ${header.devicePath}`, { firmwareUpdateCode: 'FirmwareArtifactsNotPrepared' });
52602
52448
  }
52603
52449
  devicePaths.add(canonicalDevicePath);
52604
- materializedEntries.push({ entryName: entry.name, binary: fileBinary });
52605
52450
  resources.push({ entryName: entry.name, binary: fileBinary, header });
52606
52451
  }
52607
- return { binary, materializedEntries, resources };
52452
+ return { binary, resources };
52608
52453
  });
52609
52454
  }
52610
52455
  prepareProtocolV2ResourceSources() {
@@ -52622,7 +52467,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52622
52467
  });
52623
52468
  }
52624
52469
  prepareProtocolV2ResourceArchiveSources() {
52625
- var _a, _b, _c;
52470
+ var _a, _b;
52626
52471
  return __awaiter(this, void 0, void 0, function* () {
52627
52472
  const archiveArtifacts = (_b = (_a = this.params.preparedPlan) === null || _a === void 0 ? void 0 : _a.artifacts.filter(artifact => artifact.role === 'resourceBundle' &&
52628
52473
  artifact.target === 'resource' &&
@@ -52649,20 +52494,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
52649
52494
  if (archiveDigest !== archiveArtifact.artifact.sha256.toLowerCase()) {
52650
52495
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 prepared resource archive does not match its approved receipt', { firmwareUpdateCode: 'FirmwareArtifactReceiptMismatch' });
52651
52496
  }
52652
- const verifiedArchive = yield this.prepareProtocolV2LocalResourceArchive(archiveBinary);
52653
- const sources = [];
52654
- for (const resource of verifiedArchive.resources) {
52655
- const source = yield this.openProtocolV2MemorySource(resource.binary);
52656
- sources.push({
52657
- name: (_c = resource.entryName.split('/').pop()) !== null && _c !== void 0 ? _c : resource.entryName,
52658
- source,
52659
- devicePath: resource.header.devicePath,
52660
- version: resource.header.version,
52661
- payloadHash: resource.header.payloadHash,
52662
- headerHash: resource.header.headerHash,
52663
- });
52664
- }
52665
- return sources;
52497
+ return this.createProtocolV2ResourceSourcesFromArchive(archiveBinary);
52666
52498
  });
52667
52499
  }
52668
52500
  runProtocolV2PreparedArtifacts(features, firmwareType, announceDownload = true) {
@@ -53030,6 +52862,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53030
52862
  return `vol0:${path}`;
53031
52863
  return `vol0:/${path}`;
53032
52864
  }
52865
+ getProtocolV2ResourceComparePath(devicePath) {
52866
+ return isProtocolV2BootResourcePackagePath(devicePath)
52867
+ ? PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_PATH
52868
+ : devicePath;
52869
+ }
53033
52870
  readProtocolV2DeviceFileHeader(path, expectedSize) {
53034
52871
  var _a, _b, _c, _d;
53035
52872
  return __awaiter(this, void 0, void 0, function* () {
@@ -53088,7 +52925,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53088
52925
  if (!bundle.payloadHash || !bundle.headerHash)
53089
52926
  return false;
53090
52927
  try {
53091
- const header = yield this.readProtocolV2DeviceFileHeader(bundle.devicePath, bundle.source.size);
52928
+ const header = yield this.readProtocolV2DeviceFileHeader(this.getProtocolV2ResourceComparePath(bundle.devicePath), bundle.source.size);
53092
52929
  if (!header)
53093
52930
  return false;
53094
52931
  if (bundle.version) {
@@ -53289,8 +53126,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53289
53126
  let totalSize = installSources.reduce((total, item) => total + item.source.size, 0);
53290
53127
  const resourcesToSync = [];
53291
53128
  for (const resource of resourceSources) {
53292
- const requiresFreshStaging = isProtocolV2BootResourcePackagePath(resource.devicePath);
53293
- if (!requiresFreshStaging && (yield this.isProtocolV2ResourceBundleUpToDate(resource))) {
53129
+ if (yield this.isProtocolV2ResourceBundleUpToDate(resource)) {
53294
53130
  Log$7.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
53295
53131
  }
53296
53132
  else {
@@ -66356,7 +66192,6 @@ exports.parseConnectSettings = parseConnectSettings;
66356
66192
  exports.parseMessage = parseMessage;
66357
66193
  exports.patchFeatures = patchFeatures;
66358
66194
  exports.preloadSessionCache = preloadSessionCache;
66359
- exports.prepareFirmwareUpdateV4MemoryHost = prepareFirmwareUpdateV4MemoryHost;
66360
66195
  exports.projectDeviceStateFeatures = projectFeatures;
66361
66196
  exports.registerFirmwareUpdateHostBinding = registerFirmwareUpdateHostBinding;
66362
66197
  exports.safeThrowError = safeThrowError;
@@ -1 +1 @@
1
- {"version":3,"file":"deviceInfoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceInfoUtils.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAKlE,eAAO,MAAM,aAAa,cAAe,mBAAmB,KAAG,WAClC,CAAC;AAM9B,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,WAmBtD,CAAC;AAMF,eAAO,MAAM,gBAAgB,cAAe,mBAAmB,KAAG,MAAM,GAAG,IAC3C,CAAC;AAKjC,eAAO,MAAM,iBAAiB,cAAe,mBAAmB,KAAG,MAClC,CAAC;AAKlC,eAAO,MAAM,aAAa,cANmB,mBAAmB,KAAG,MAMrB,CAAC;AAK/C,eAAO,MAAM,cAAc,cAAe,mBAAmB,kBAkB5D,CAAC;AAMF,eAAO,MAAM,qBAAqB,aACtB,mBAAmB,GAAG,SAAS,iCACV,WAAW,GAAG,YAAY,KAAK,aAAa,GAAG,SAAS,KACtF,aAAa,GAAG,SAyBlB,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,mBAAmB,gDACzB,CAAC"}
1
+ {"version":3,"file":"deviceInfoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceInfoUtils.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAKlE,eAAO,MAAM,aAAa,cAAe,mBAAmB,KAAG,WAClC,CAAC;AAM9B,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,WAqBtD,CAAC;AAMF,eAAO,MAAM,gBAAgB,cAAe,mBAAmB,KAAG,MAAM,GAAG,IAC3C,CAAC;AAKjC,eAAO,MAAM,iBAAiB,cAAe,mBAAmB,KAAG,MAClC,CAAC;AAKlC,eAAO,MAAM,aAAa,cANmB,mBAAmB,KAAG,MAMrB,CAAC;AAK/C,eAAO,MAAM,cAAc,cAAe,mBAAmB,kBAkB5D,CAAC;AAMF,eAAO,MAAM,qBAAqB,aACtB,mBAAmB,GAAG,SAAS,iCACV,WAAW,GAAG,YAAY,KAAK,aAAa,GAAG,SAAS,KACtF,aAAa,GAAG,SAyBlB,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,mBAAmB,gDACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.0-alpha.157",
3
+ "version": "1.2.0-alpha.159",
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.157",
29
- "@onekeyfe/hd-transport": "1.2.0-alpha.157",
28
+ "@onekeyfe/hd-shared": "1.2.0-alpha.159",
29
+ "@onekeyfe/hd-transport": "1.2.0-alpha.159",
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": "1e9aaf5fbf64562504ebc22dc34fb22220ba0b0b"
49
+ "gitHead": "302f9ff916b3769cdb0cf79d58d09a87eeac68c2"
50
50
  }