@onekeyfe/hd-transport-web-device 1.2.11-alpha.17 → 1.2.11-alpha.19

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.
@@ -1757,4 +1757,53 @@ describe('ElectronBleTransport protocol detection', () => {
1757
1757
  expect(nobleBle.disconnect).toHaveBeenCalledWith(device.id);
1758
1758
  expect(bleTransport.getProtocolType(device.id)).toBeUndefined();
1759
1759
  });
1760
+
1761
+ test('uses the post-connect device name for Electron legacy V1 wake when initial lookup has a placeholder name', async () => {
1762
+ const placeholder = { id: 'cold-classic-id', name: 'OneKey Device' };
1763
+ const connected = { id: 'cold-classic-id', name: 'K8141', mtu: 247 };
1764
+ const nobleBle = createNobleBle(placeholder);
1765
+ nobleBle.getDevice.mockResolvedValueOnce(placeholder).mockResolvedValueOnce(connected);
1766
+ const bleTransport = configureTransport(nobleBle);
1767
+ const probes = bleTransport as any;
1768
+ jest.spyOn(probes, 'probeProtocolV1').mockResolvedValue(false);
1769
+ const probeProtocolV2 = jest.spyOn(probes, 'probeProtocolV2').mockResolvedValue(false);
1770
+ const callProtocolV1 = jest.spyOn(probes, 'callProtocolV1').mockResolvedValue({
1771
+ type: 'Features',
1772
+ message: {},
1773
+ });
1774
+
1775
+ await expect(bleTransport.acquire({ uuid: placeholder.id })).resolves.toMatchObject({
1776
+ uuid: placeholder.id,
1777
+ name: 'K8141',
1778
+ protocolType: 'V1',
1779
+ });
1780
+ expect(callProtocolV1).toHaveBeenCalledTimes(1);
1781
+ expect(callProtocolV1.mock.calls[0]?.[1]).toBe('Initialize');
1782
+ expect(probeProtocolV2).not.toHaveBeenCalled();
1783
+ });
1784
+
1785
+ test('rejects an already-aborted acquire without releasing an existing Electron BLE link', async () => {
1786
+ const device = { id: 'existing-link-id', name: 'OneKey Classic' };
1787
+ const nobleBle = createNobleBle(device);
1788
+ const bleTransport = configureTransport(nobleBle);
1789
+ await bleTransport.acquire({ uuid: device.id, expectedProtocol: 'V1' });
1790
+
1791
+ const aborted = new AbortController();
1792
+ aborted.abort();
1793
+ const releaseSpy = jest.spyOn(bleTransport, 'release');
1794
+ nobleBle.disconnect.mockClear();
1795
+
1796
+ await expect(
1797
+ bleTransport.acquire({
1798
+ uuid: device.id,
1799
+ expectedProtocol: 'V1',
1800
+ abortSignal: aborted.signal,
1801
+ })
1802
+ ).rejects.toMatchObject({
1803
+ errorCode: HardwareErrorCode.DeviceInterruptedFromUser,
1804
+ });
1805
+ expect(releaseSpy).not.toHaveBeenCalled();
1806
+ expect(nobleBle.disconnect).not.toHaveBeenCalled();
1807
+ expect(bleTransport.getProtocolType(device.id)).toBe('V1');
1808
+ });
1760
1809
  });
@@ -1 +1 @@
1
- {"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";AA0BA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAEV,gBAAgB,EAChB,YAAY,EAEZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAIvC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB;CACF;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAuFF,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,OAAO,CAAC,SAAS,CAAmE;IAEpF,OAAO,CAAC,WAAW,CAAmE;IAEt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AC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.js CHANGED
@@ -1782,12 +1782,15 @@ class ElectronBleTransport {
1782
1782
  });
1783
1783
  }
1784
1784
  acquire(input) {
1785
- var _a, _b, _c, _d, _e, _f, _g;
1785
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1786
1786
  return __awaiter(this, void 0, void 0, function* () {
1787
1787
  const { uuid, forceCleanRunPromise, expectedProtocol, forceProtocolDetection } = input;
1788
1788
  if (!uuid) {
1789
1789
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleRequiredUUID);
1790
1790
  }
1791
+ if ((_a = input.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
1792
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
1793
+ }
1791
1794
  const acquireGeneration = this.nextAcquireGeneration;
1792
1795
  this.nextAcquireGeneration += 1;
1793
1796
  this.acquireGenerations.set(uuid, acquireGeneration);
@@ -1819,7 +1822,7 @@ class ElectronBleTransport {
1819
1822
  this.acquiringDevices.add(uuid);
1820
1823
  let connectAttempted = false;
1821
1824
  try {
1822
- if (!((_a = window.desktopApi) === null || _a === void 0 ? void 0 : _a.nobleBle)) {
1825
+ if (!((_b = window.desktopApi) === null || _b === void 0 ? void 0 : _b.nobleBle)) {
1823
1826
  throw new Error('Noble BLE API not available');
1824
1827
  }
1825
1828
  const device = yield invokeNobleBle(window.desktopApi.nobleBle.getDevice(uuid));
@@ -1835,7 +1838,7 @@ class ElectronBleTransport {
1835
1838
  }
1836
1839
  const protocolHint = expectedProtocol
1837
1840
  ? undefined
1838
- : (_b = input.protocolHint) !== null && _b !== void 0 ? _b : this.deviceProtocolHints.get(uuid);
1841
+ : (_c = input.protocolHint) !== null && _c !== void 0 ? _c : this.deviceProtocolHints.get(uuid);
1839
1842
  if (protocolHint) {
1840
1843
  this.deviceProtocolHints.set(uuid, protocolHint);
1841
1844
  }
@@ -1862,30 +1865,31 @@ class ElectronBleTransport {
1862
1865
  this.handleBluetoothError(error);
1863
1866
  }
1864
1867
  assertAcquireActive();
1865
- yield this.refreshBlePacketCapacity(uuid);
1868
+ const connectedDevice = yield this.refreshBlePacketCapacity(uuid);
1866
1869
  assertAcquireActive();
1870
+ const resolvedDeviceName = (connectedDevice === null || connectedDevice === void 0 ? void 0 : connectedDevice.name) || device.name;
1867
1871
  const cleanup = this.createNotificationSubscription(uuid);
1868
1872
  this.notificationCleanups.set(uuid, cleanup);
1869
1873
  const protocolType = yield this.detectProtocol(uuid, expectedProtocol, protocolHint, {
1870
- isKnownLegacyV1Device: hdShared.isLegacyProtocolV1BleName(device.name),
1874
+ isKnownLegacyV1Device: hdShared.isLegacyProtocolV1BleName(resolvedDeviceName),
1871
1875
  onlyConnectBleDevice: input.onlyConnectBleDevice,
1872
1876
  abortSignal: input.abortSignal,
1873
1877
  });
1874
1878
  assertAcquireActive();
1875
1879
  if (protocolType === 'V2') {
1876
- (_c = this.Log) === null || _c === void 0 ? void 0 : _c.debug('[Electron BLE] Protocol V2 write configured', {
1880
+ (_d = this.Log) === null || _d === void 0 ? void 0 : _d.debug('[Electron BLE] Protocol V2 write configured', {
1877
1881
  writeMode: 'withoutResponse',
1878
1882
  negotiatedMtu: this.deviceMtus.get(uuid),
1879
- packetCapacity: (_d = this.devicePacketCapacities.get(uuid)) !== null && _d !== void 0 ? _d : BLE_PACKET_SIZE_FALLBACK,
1883
+ packetCapacity: (_e = this.devicePacketCapacities.get(uuid)) !== null && _e !== void 0 ? _e : BLE_PACKET_SIZE_FALLBACK,
1880
1884
  });
1881
1885
  }
1882
- return Object.assign(Object.assign({}, toBleDescriptor({ id: device.id, name: device.name }, protocolType)), { uuid });
1886
+ return Object.assign(Object.assign({}, toBleDescriptor({ id: device.id, name: resolvedDeviceName }, protocolType)), { uuid });
1883
1887
  }
1884
1888
  catch (error) {
1885
- (_e = this.Log) === null || _e === void 0 ? void 0 : _e.error('[Electron BLE] acquire failed:', error);
1889
+ (_f = this.Log) === null || _f === void 0 ? void 0 : _f.error('[Electron BLE] acquire failed:', error);
1886
1890
  if (isCurrentAcquire()) {
1887
1891
  try {
1888
- const nobleBle = (_f = window.desktopApi) === null || _f === void 0 ? void 0 : _f.nobleBle;
1892
+ const nobleBle = (_g = window.desktopApi) === null || _g === void 0 ? void 0 : _g.nobleBle;
1889
1893
  if (nobleBle && !this.stopped && (connectAttempted || this.connectedDevices.has(uuid))) {
1890
1894
  if (this.connectedDevices.has(uuid)) {
1891
1895
  yield invokeNobleBle(nobleBle.unsubscribe(uuid)).catch(cleanupError => {
@@ -1897,7 +1901,7 @@ class ElectronBleTransport {
1897
1901
  }
1898
1902
  }
1899
1903
  catch (cleanupError) {
1900
- (_g = this.Log) === null || _g === void 0 ? void 0 : _g.debug('[Electron BLE] acquire cleanup failed:', cleanupError);
1904
+ (_h = this.Log) === null || _h === void 0 ? void 0 : _h.debug('[Electron BLE] acquire cleanup failed:', cleanupError);
1901
1905
  }
1902
1906
  this.cleanupDeviceState(uuid);
1903
1907
  }
@@ -2212,6 +2216,7 @@ class ElectronBleTransport {
2212
2216
  const nobleBle = (_a = window.desktopApi) === null || _a === void 0 ? void 0 : _a.nobleBle;
2213
2217
  const device = nobleBle ? yield invokeNobleBle(nobleBle.getDevice(uuid)) : undefined;
2214
2218
  this.updateBlePacketCapacity(uuid, device === null || device === void 0 ? void 0 : device.mtu);
2219
+ return device;
2215
2220
  });
2216
2221
  }
2217
2222
  updateBlePacketCapacity(uuid, mtu) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-web-device",
3
- "version": "1.2.11-alpha.17",
3
+ "version": "1.2.11-alpha.19",
4
4
  "author": "OneKey",
5
5
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
6
6
  "license": "MIT",
@@ -21,14 +21,14 @@
21
21
  "lint:fix": "eslint . --fix"
22
22
  },
23
23
  "dependencies": {
24
- "@onekeyfe/hd-shared": "1.2.11-alpha.17",
25
- "@onekeyfe/hd-transport": "1.2.11-alpha.17",
24
+ "@onekeyfe/hd-shared": "1.2.11-alpha.19",
25
+ "@onekeyfe/hd-transport": "1.2.11-alpha.19",
26
26
  "bytebuffer": "^5.0.1"
27
27
  },
28
28
  "devDependencies": {
29
- "@onekeyfe/hd-transport-electron": "1.2.11-alpha.17",
29
+ "@onekeyfe/hd-transport-electron": "1.2.11-alpha.19",
30
30
  "@types/w3c-web-usb": "^1.0.6",
31
31
  "@types/web-bluetooth": "^0.0.17"
32
32
  },
33
- "gitHead": "0983ef025972bb84f363d23dc32d62eeae72a623"
33
+ "gitHead": "4e187534319627c54ad1822066369ede4ea57493"
34
34
  }
@@ -471,6 +471,9 @@ export default class ElectronBleTransport {
471
471
  if (!uuid) {
472
472
  throw ERRORS.TypedError(HardwareErrorCode.BleRequiredUUID);
473
473
  }
474
+ if (input.abortSignal?.aborted) {
475
+ throw ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
476
+ }
474
477
 
475
478
  const acquireGeneration = this.nextAcquireGeneration;
476
479
  this.nextAcquireGeneration += 1;
@@ -559,14 +562,15 @@ export default class ElectronBleTransport {
559
562
  this.handleBluetoothError(error);
560
563
  }
561
564
  assertAcquireActive();
562
- await this.refreshBlePacketCapacity(uuid);
565
+ const connectedDevice = await this.refreshBlePacketCapacity(uuid);
563
566
  assertAcquireActive();
567
+ const resolvedDeviceName = connectedDevice?.name || device.name;
564
568
 
565
569
  const cleanup = this.createNotificationSubscription(uuid);
566
570
  this.notificationCleanups.set(uuid, cleanup);
567
571
 
568
572
  const protocolType = await this.detectProtocol(uuid, expectedProtocol, protocolHint, {
569
- isKnownLegacyV1Device: isLegacyProtocolV1BleName(device.name),
573
+ isKnownLegacyV1Device: isLegacyProtocolV1BleName(resolvedDeviceName),
570
574
  onlyConnectBleDevice: input.onlyConnectBleDevice,
571
575
  abortSignal: input.abortSignal,
572
576
  });
@@ -580,7 +584,7 @@ export default class ElectronBleTransport {
580
584
  }
581
585
 
582
586
  return {
583
- ...toBleDescriptor({ id: device.id, name: device.name }, protocolType),
587
+ ...toBleDescriptor({ id: device.id, name: resolvedDeviceName }, protocolType),
584
588
  uuid,
585
589
  };
586
590
  } catch (error) {
@@ -975,10 +979,11 @@ export default class ElectronBleTransport {
975
979
  }
976
980
  }
977
981
 
978
- private async refreshBlePacketCapacity(uuid: string): Promise<void> {
982
+ private async refreshBlePacketCapacity(uuid: string) {
979
983
  const nobleBle = window.desktopApi?.nobleBle;
980
984
  const device = nobleBle ? await invokeNobleBle(nobleBle.getDevice(uuid)) : undefined;
981
985
  this.updateBlePacketCapacity(uuid, device?.mtu);
986
+ return device;
982
987
  }
983
988
 
984
989
  private updateBlePacketCapacity(uuid: string, mtu?: number): void {