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

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.
@@ -1,10 +1,5 @@
1
1
  import transport, { PROTOCOL_V2_CHANNEL_BLE_UART, bytesToHex } from '@onekeyfe/hd-transport';
2
- import {
3
- EBleDisconnectReason,
4
- ERRORS,
5
- HardwareErrorCode,
6
- createDeferred,
7
- } from '@onekeyfe/hd-shared';
2
+ import { EBleDisconnectReason, HardwareErrorCode, createDeferred } from '@onekeyfe/hd-shared';
8
3
  import EventEmitter from 'events';
9
4
 
10
5
  import ElectronBleTransport from '../src/electron-ble-transport';
@@ -348,6 +343,49 @@ describe('ElectronBleTransport protocol detection', () => {
348
343
  }
349
344
  );
350
345
 
346
+ test.each(['Pro 2', 'Neo'])(
347
+ 'retains %s V2 subscription while forwarding keepSession=false for idle disconnect',
348
+ async name => {
349
+ const device = { id: 'retained-idle-v2-id', name };
350
+ const release = jest.fn().mockResolvedValue(undefined);
351
+ const nobleBle = { ...createNobleBle(device), release };
352
+ echoProtocolV2(nobleBle, device.id);
353
+ const bleTransport = configureTransport(nobleBle);
354
+ await bleTransport.acquire({ uuid: device.id, expectedProtocol: 'V2' });
355
+ await bleTransport.call(device.id, 'Ping', { message: 'before-release' });
356
+ const notifyCleanup = nobleBle.onNotification.mock.results[0].value;
357
+
358
+ try {
359
+ await bleTransport.release(device.id, false, false, { retainLink: true });
360
+ expect(release).toHaveBeenCalledWith(device.id, false);
361
+ expect(bleTransport.getProtocolType(device.id)).toBe('V2');
362
+ expect(notifyCleanup).not.toHaveBeenCalled();
363
+
364
+ await expect(
365
+ bleTransport.acquire({ uuid: device.id, expectedProtocol: 'V2' })
366
+ ).resolves.toMatchObject({ uuid: device.id, protocolType: 'V2' });
367
+ await expect(
368
+ bleTransport.call(device.id, 'Ping', { message: 'within-idle-window' })
369
+ ).resolves.toMatchObject({ type: 'Success' });
370
+
371
+ expect(nobleBle.connect).toHaveBeenCalledTimes(1);
372
+ expect(nobleBle.subscribe).toHaveBeenCalledTimes(1);
373
+ expect(
374
+ nobleBle.write.mock.calls.map(([, hex]) => Number.parseInt(hex.slice(12, 14), 16))
375
+ ).toEqual([1, 2, 3]);
376
+
377
+ // Once the main-process 20s idle timer drops the link, retained state is cleared.
378
+ await bleTransport.release(device.id, false, false, { retainLink: true });
379
+ const disconnectHandler = nobleBle.onDeviceDisconnected.mock.calls[0][0];
380
+ disconnectHandler({ ...device, reason: EBleDisconnectReason.IdleKeepAlive });
381
+ expect(notifyCleanup).toHaveBeenCalledTimes(1);
382
+ expect(bleTransport.getProtocolType(device.id)).toBeUndefined();
383
+ } finally {
384
+ await bleTransport.disconnect(device.id);
385
+ }
386
+ }
387
+ );
388
+
351
389
  test.each(['ordinary release', 'onclose', 'forced probe'])(
352
390
  'does not retain renderer state for %s',
353
391
  async mode => {
@@ -1454,356 +1492,4 @@ describe('ElectronBleTransport protocol detection', () => {
1454
1492
  expect(nobleBle.connect).not.toHaveBeenCalled();
1455
1493
  expect(nobleBle.disconnect).not.toHaveBeenCalled();
1456
1494
  });
1457
-
1458
- test('wakes a sleeping legacy V1 Classic with Initialize after silent GetFeatures without probing V2', async () => {
1459
- const device = { id: 'sleeping-classic-id', name: 'K8141' };
1460
- const nobleBle = createNobleBle(device);
1461
- const bleTransport = configureTransport(nobleBle);
1462
- const probes = bleTransport as any;
1463
- const probeProtocolV1 = jest.spyOn(probes, 'probeProtocolV1').mockResolvedValue(false);
1464
- const probeProtocolV2 = jest.spyOn(probes, 'probeProtocolV2').mockResolvedValue(false);
1465
- const callProtocolV1 = jest.spyOn(probes, 'callProtocolV1').mockResolvedValue({
1466
- type: 'Features',
1467
- message: {},
1468
- });
1469
-
1470
- await expect(bleTransport.acquire({ uuid: device.id })).resolves.toMatchObject({
1471
- uuid: device.id,
1472
- protocolType: 'V1',
1473
- });
1474
-
1475
- expect(probeProtocolV1).toHaveBeenCalledTimes(1);
1476
- expect(callProtocolV1).toHaveBeenCalledTimes(1);
1477
- expect(callProtocolV1.mock.calls[0]?.[1]).toBe('Initialize');
1478
- expect(probeProtocolV2).not.toHaveBeenCalled();
1479
- });
1480
-
1481
- test('skips Initialize wake on Electron BLE when onlyConnectBleDevice is true', async () => {
1482
- const device = { id: 'only-connect-classic-id', name: 'K1361' };
1483
- const nobleBle = createNobleBle(device);
1484
- const bleTransport = configureTransport(nobleBle);
1485
- const probes = bleTransport as any;
1486
- jest.spyOn(probes, 'probeProtocolV1').mockResolvedValue(false);
1487
- jest.spyOn(probes, 'probeProtocolV2').mockResolvedValue(false);
1488
- const callProtocolV1 = jest.spyOn(probes, 'callProtocolV1').mockResolvedValue({
1489
- type: 'Features',
1490
- message: {},
1491
- });
1492
-
1493
- await expect(
1494
- bleTransport.acquire({ uuid: device.id, onlyConnectBleDevice: true })
1495
- ).rejects.toBeDefined();
1496
- expect(callProtocolV1).not.toHaveBeenCalled();
1497
- });
1498
-
1499
- test('propagates Windows pairing rejection from GetFeatures without consuming the wake for later reconnects', async () => {
1500
- const device = { id: 'win-pairing-classic-id', name: 'K8141' };
1501
- const nobleBle = createNobleBle(device);
1502
- const bleTransport = configureTransport(nobleBle);
1503
- const probes = bleTransport as any;
1504
- const probeProtocolV2 = jest.spyOn(probes, 'probeProtocolV2').mockResolvedValue(false);
1505
-
1506
- // Attempt 1: host aborts GetFeatures write after Windows pairing rejection.
1507
- nobleBle.write.mockRejectedValueOnce(
1508
- ERRORS.TypedError(
1509
- HardwareErrorCode.BleConnectedError,
1510
- 'Write failed with abortable error for device win-pairing-classic-id: status: 3'
1511
- )
1512
- );
1513
- await expect(bleTransport.acquire({ uuid: device.id })).rejects.toMatchObject({
1514
- errorCode: HardwareErrorCode.BleConnectedError,
1515
- });
1516
- expect(nobleBle.write).toHaveBeenCalledTimes(1);
1517
- expect(probeProtocolV2).not.toHaveBeenCalled();
1518
-
1519
- // Attempt 2: paired successfully, GetFeatures still silent (device asleep), so the
1520
- // preserved wake sends a one-shot Initialize and confirms V1.
1521
- nobleBle.write.mockClear();
1522
- jest.spyOn(probes, 'probeProtocolV1').mockResolvedValueOnce(false);
1523
- const callProtocolV1 = jest.spyOn(probes, 'callProtocolV1').mockResolvedValueOnce({
1524
- type: 'Features',
1525
- message: {},
1526
- });
1527
-
1528
- await expect(bleTransport.acquire({ uuid: device.id })).resolves.toMatchObject({
1529
- uuid: device.id,
1530
- protocolType: 'V1',
1531
- });
1532
- expect(callProtocolV1).toHaveBeenCalledWith(
1533
- device.id,
1534
- 'Initialize',
1535
- {},
1536
- { timeoutMs: 3000 },
1537
- { oneShot: true },
1538
- true
1539
- );
1540
- });
1541
-
1542
- test('sends Initialize wake as a single one-shot native write and preserves wake when host proves write never started', async () => {
1543
- const device = { id: 'oneshot-classic-id', name: 'K1361' };
1544
- const nobleBle = createNobleBle(device);
1545
- const bleTransport = configureTransport(nobleBle);
1546
- const probes = bleTransport as any;
1547
- jest.spyOn(probes, 'probeProtocolV1').mockResolvedValue(false);
1548
- jest.spyOn(probes, 'probeProtocolV2').mockResolvedValue(false);
1549
-
1550
- // Attempt 1: host rejects Initialize before submitting a GATT write.
1551
- nobleBle.write.mockRejectedValueOnce(
1552
- ERRORS.TypedError(
1553
- HardwareErrorCode.BleCharacteristicNotFound,
1554
- 'Device oneshot-classic-id not connected or characteristics not available'
1555
- )
1556
- );
1557
- await expect(bleTransport.acquire({ uuid: device.id })).rejects.toMatchObject({
1558
- errorCode: HardwareErrorCode.BleCharacteristicNotFound,
1559
- });
1560
- expect(nobleBle.write).toHaveBeenCalledTimes(1);
1561
- expect(nobleBle.write.mock.calls[0]?.[2]).toEqual({ oneShot: true });
1562
-
1563
- // Attempt 2: wake is still armed and executes one native write with { oneShot: true }.
1564
- nobleBle.write.mockClear();
1565
- let notifyHandler: ((id: string, hex: string) => void) | undefined;
1566
- nobleBle.onNotification.mockImplementation(handler => {
1567
- notifyHandler = handler;
1568
- return jest.fn();
1569
- });
1570
- nobleBle.write.mockImplementationOnce((id: string) => {
1571
- const reply = ProtocolV1.encodeTransportPackets(schemas.protocolV1, 'Success', {
1572
- message: 'ok',
1573
- });
1574
- const packetHex = reply[0].toString('hex');
1575
- const payloadLen = parseInt(packetHex.slice(10, 18), 16);
1576
- notifyHandler?.(id, packetHex.slice(0, (9 + payloadLen) * 2));
1577
- return Promise.resolve();
1578
- });
1579
-
1580
- await expect(bleTransport.acquire({ uuid: device.id })).resolves.toMatchObject({
1581
- uuid: device.id,
1582
- protocolType: 'V1',
1583
- });
1584
- expect(nobleBle.write).toHaveBeenCalledTimes(1);
1585
- expect(nobleBle.write.mock.calls[0]?.[2]).toEqual({ oneShot: true });
1586
- });
1587
-
1588
- test('sends initial V1 GetFeatures probe with oneShot and rethrows TransportCallInProgress without waking', async () => {
1589
- const device = { id: 'oneshot-getfeatures-id', name: 'K8141' };
1590
- const nobleBle = createNobleBle(device);
1591
- let notifyHandler: ((id: string, hex: string) => void) | undefined;
1592
- nobleBle.onNotification.mockImplementation(handler => {
1593
- notifyHandler = handler;
1594
- return jest.fn();
1595
- });
1596
- nobleBle.write.mockImplementationOnce((id: string) => {
1597
- const reply = ProtocolV1.encodeTransportPackets(schemas.protocolV1, 'Success', {
1598
- message: 'ok',
1599
- });
1600
- const packetHex = reply[0].toString('hex');
1601
- const payloadLen = parseInt(packetHex.slice(10, 18), 16);
1602
- notifyHandler?.(id, packetHex.slice(0, (9 + payloadLen) * 2));
1603
- return Promise.resolve();
1604
- });
1605
- const bleTransport = configureTransport(nobleBle);
1606
-
1607
- await expect(bleTransport.acquire({ uuid: device.id })).resolves.toMatchObject({
1608
- uuid: device.id,
1609
- protocolType: 'V1',
1610
- });
1611
- expect(nobleBle.write).toHaveBeenCalledTimes(1);
1612
- expect(nobleBle.write.mock.calls[0]?.[2]).toEqual({ oneShot: true });
1613
-
1614
- await bleTransport.release(device.id);
1615
-
1616
- const probes = bleTransport as any;
1617
- const inProgressErr = ERRORS.TypedError(HardwareErrorCode.TransportCallInProgress);
1618
- const callSpy = jest.spyOn(probes, 'callProtocolV1').mockRejectedValueOnce(inProgressErr);
1619
- const wakeSpy = jest.spyOn(probes, 'wakeSilentProtocolV1Device');
1620
-
1621
- await expect(bleTransport.acquire({ uuid: device.id })).rejects.toMatchObject({
1622
- errorCode: HardwareErrorCode.TransportCallInProgress,
1623
- });
1624
- expect(callSpy).toHaveBeenCalledTimes(1);
1625
- expect(wakeSpy).not.toHaveBeenCalled();
1626
- });
1627
-
1628
- test('skips Electron Initialize wake if abortSignal aborts during probe state reset', async () => {
1629
- const device = { id: 'abort-reset-classic-id', name: 'K8141' };
1630
- const nobleBle = createNobleBle(device);
1631
- const bleTransport = configureTransport(nobleBle);
1632
- const probes = bleTransport as any;
1633
- const abortController = new AbortController();
1634
- jest.spyOn(probes, 'probeProtocolV1').mockResolvedValue(false);
1635
- jest.spyOn(probes, 'resetProbeStateAfterProtocolProbe').mockImplementation(() => {
1636
- abortController.abort();
1637
- return Promise.resolve();
1638
- });
1639
- const callProtocolV1 = jest.spyOn(probes, 'callProtocolV1');
1640
-
1641
- await expect(
1642
- bleTransport.acquire({ uuid: device.id, abortSignal: abortController.signal })
1643
- ).rejects.toMatchObject({
1644
- errorCode: HardwareErrorCode.DeviceInterruptedFromUser,
1645
- });
1646
- expect(callProtocolV1).not.toHaveBeenCalled();
1647
- });
1648
-
1649
- test('does not send Initialize wake when GetFeatures fails from an ordinary GATT write error', async () => {
1650
- const device = { id: 'gatt-write-err-classic-id', name: 'K8141' };
1651
- const nobleBle = createNobleBle(device);
1652
- const bleTransport = configureTransport(nobleBle);
1653
- const probes = bleTransport as any;
1654
- const wakeSpy = jest.spyOn(probes, 'wakeSilentProtocolV1Device');
1655
- jest.spyOn(probes, 'probeProtocolV2').mockResolvedValue(false);
1656
- nobleBle.write.mockRejectedValueOnce(new Error('GATT write error'));
1657
-
1658
- await expect(bleTransport.acquire({ uuid: device.id })).rejects.toMatchObject({
1659
- errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
1660
- });
1661
- expect(wakeSpy).not.toHaveBeenCalled();
1662
- });
1663
-
1664
- test('prevents a canceled acquire whose getDevice settles late from disconnecting a replacement acquire', async () => {
1665
- const device = { id: 'superseded-acquire-id', name: 'K8141' };
1666
- const nobleBle = createNobleBle(device);
1667
- let resolveFirstGetDevice: ((d: typeof device) => void) | undefined;
1668
- nobleBle.getDevice
1669
- .mockImplementationOnce(
1670
- () =>
1671
- new Promise(resolve => {
1672
- resolveFirstGetDevice = resolve;
1673
- })
1674
- )
1675
- .mockResolvedValue(device);
1676
- const bleTransport = configureTransport(nobleBle);
1677
- const abortA = new AbortController();
1678
-
1679
- const acquireA = bleTransport.acquire({
1680
- uuid: device.id,
1681
- expectedProtocol: 'V1',
1682
- abortSignal: abortA.signal,
1683
- });
1684
- abortA.abort();
1685
-
1686
- // Acquire B succeeds while acquire A is still waiting on getDevice.
1687
- await expect(
1688
- bleTransport.acquire({ uuid: device.id, expectedProtocol: 'V1' })
1689
- ).resolves.toMatchObject({ uuid: device.id, protocolType: 'V1' });
1690
- nobleBle.disconnect.mockClear();
1691
- nobleBle.unsubscribe.mockClear();
1692
-
1693
- // Acquire A resumes when its delayed lookup settles; it must not tear down B's link.
1694
- resolveFirstGetDevice?.(device);
1695
- await expect(acquireA).rejects.toMatchObject({
1696
- errorCode: HardwareErrorCode.DeviceInterruptedFromUser,
1697
- });
1698
- expect(nobleBle.unsubscribe).not.toHaveBeenCalled();
1699
- expect(nobleBle.disconnect).not.toHaveBeenCalled();
1700
- expect(bleTransport.getProtocolType(device.id)).toBe('V1');
1701
- });
1702
-
1703
- test('restores wake eligibility when Windows rejects the Initialize wake write with writeRejected', async () => {
1704
- const device = { id: 'win-wake-reject-id', name: 'K8141' };
1705
- const nobleBle = createNobleBle(device);
1706
- const bleTransport = configureTransport(nobleBle);
1707
- const probes = bleTransport as any;
1708
- jest.spyOn(probes, 'probeProtocolV1').mockResolvedValue(false);
1709
- jest.spyOn(probes, 'probeProtocolV2').mockResolvedValue(false);
1710
-
1711
- nobleBle.write.mockRejectedValueOnce(
1712
- ERRORS.TypedError(
1713
- HardwareErrorCode.BleConnectedError,
1714
- 'Write failed with abortable error for device win-wake-reject-id: status: 3',
1715
- { writeRejected: true }
1716
- )
1717
- );
1718
- await expect(bleTransport.acquire({ uuid: device.id })).rejects.toMatchObject({
1719
- errorCode: HardwareErrorCode.BleConnectedError,
1720
- });
1721
-
1722
- // After pairing succeeds on the next acquire, Initialize wake must still run.
1723
- const callProtocolV1 = jest.spyOn(probes, 'callProtocolV1').mockResolvedValueOnce({
1724
- type: 'Features',
1725
- message: {},
1726
- });
1727
- await expect(bleTransport.acquire({ uuid: device.id })).resolves.toMatchObject({
1728
- uuid: device.id,
1729
- protocolType: 'V1',
1730
- });
1731
- expect(callProtocolV1).toHaveBeenCalledTimes(1);
1732
- expect(callProtocolV1.mock.calls[0]?.[1]).toBe('Initialize');
1733
- });
1734
-
1735
- test('disconnects an ordinary 3000ms Initialize call on timeout instead of treating it as a probe', async () => {
1736
- const device = { id: 'ordinary-init-3s-id', name: 'OneKey Classic' };
1737
- const nobleBle = createNobleBle(device);
1738
- nobleBle.onNotification.mockImplementation(() => jest.fn());
1739
- nobleBle.write.mockImplementation(() => Promise.resolve());
1740
- const bleTransport = configureTransport(nobleBle);
1741
-
1742
- await bleTransport.acquire({ uuid: device.id, expectedProtocol: 'V1' });
1743
- jest.useFakeTimers({ doNotFake: ['performance'] });
1744
- try {
1745
- const pending = bleTransport.call(device.id, 'Initialize', {}, { timeoutMs: 3000 });
1746
- const expectation = expect(pending).rejects.toMatchObject({
1747
- errorCode: HardwareErrorCode.BleTimeoutError,
1748
- });
1749
- await Promise.resolve();
1750
- await Promise.resolve();
1751
- jest.advanceTimersByTime(3000);
1752
- await expectation;
1753
- } finally {
1754
- jest.useRealTimers();
1755
- }
1756
-
1757
- expect(nobleBle.disconnect).toHaveBeenCalledWith(device.id);
1758
- expect(bleTransport.getProtocolType(device.id)).toBeUndefined();
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
- });
1809
1495
  });
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { Deferred } from '@onekeyfe/hd-shared';
3
3
  import type { DesktopAPI } from '@onekeyfe/hd-transport-electron';
4
- import type { OneKeyDeviceInfo, ProtocolType, TransportCallOptions } from '@onekeyfe/hd-transport';
4
+ import type { OneKeyDeviceInfo, ProtocolType, TransportCallOptions, TransportReleaseOptions } from '@onekeyfe/hd-transport';
5
5
  import type EventEmitter from 'events';
6
6
  declare global {
7
7
  interface Window {
@@ -13,8 +13,6 @@ export type BleAcquireInput = {
13
13
  forceCleanRunPromise?: boolean;
14
14
  expectedProtocol?: ProtocolType;
15
15
  protocolHint?: ProtocolType;
16
- onlyConnectBleDevice?: boolean;
17
- abortSignal?: AbortSignal;
18
16
  };
19
17
  export default class ElectronBleTransport {
20
18
  private _messages;
@@ -34,11 +32,6 @@ export default class ElectronBleTransport {
34
32
  private stopPromise?;
35
33
  private deviceProtocol;
36
34
  private deviceProtocolHints;
37
- private silentDetections;
38
- private probeResponseTimeoutErrors;
39
- private lastV1ProbeFailedWithoutTimeout;
40
- private acquireGenerations;
41
- private nextAcquireGeneration;
42
35
  private deviceMtus;
43
36
  private devicePacketCapacities;
44
37
  private v1Buffers;
@@ -76,7 +69,7 @@ export default class ElectronBleTransport {
76
69
  bleColorCode?: string | undefined;
77
70
  protocolType?: ProtocolType | undefined;
78
71
  }>;
79
- release(id: string, onclose?: boolean, keepSession?: boolean): Promise<void>;
72
+ release(id: string, onclose?: boolean, keepSession?: boolean, options?: TransportReleaseOptions): Promise<void>;
80
73
  disconnect(id: string): Promise<void>;
81
74
  private releaseNative;
82
75
  private releaseLogical;
@@ -84,7 +77,6 @@ export default class ElectronBleTransport {
84
77
  private createProtocolDetectionError;
85
78
  private clearProbeProtocol;
86
79
  private detectProtocol;
87
- private wakeSilentProtocolV1Device;
88
80
  private createNotificationSubscription;
89
81
  private resetProbeStateAfterProtocolProbe;
90
82
  private probeProtocolV1;
@@ -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;IAEtF,OAAO,CAAC,6BAA6B,CAAqB;IAE1D,IAAI,SAA0B;IAE9B,UAAU,UAAS;IAEnB,UAAU,EAAE,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,IAAI,CAAQ;IAExD,OAAO,CAAC,kBAAkB,CAAuB;IAEjD,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,OAAO,CAAC,EAAE,YAAY,CAAC;IAEvB,OAAO,CAAC,gBAAgB,CAA0B;IAElD,OAAO,CAAC,eAAe,CAA0B;IAEjD,OAAO,CAAC,oBAAoB,CAAkC;IAS9D,OAAO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AAC,qBAAqB;IAU7B,OAAO,CAAC,oBAAoB;IAqB5B,OAAO,CAAC,kBAAkB;IA+B1B,OAAO,CAAC,iCAAiC;IAazC,OAAO,CAAC,4BAA4B;IAkBpC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;IAiBjC,OAAO,CAAC,4BAA4B;IAqB9B,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;IAuB1B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;YAatD,cAAc;YAqFd,cAAc;IA+B5B,OAAO,CAAC,uBAAuB;IAyC/B,OAAO,CAAC,6BAA6B;IA4CrC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _onekeyfe_hd_transport from '@onekeyfe/hd-transport';
2
- import _onekeyfe_hd_transport__default, { ProtocolV2UsbTransportBase, AcquireInput, TransportCallOptions, ProtocolV2Schemas, ProtocolV2CallContext, ProtocolType, OneKeyDeviceInfoBase, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
2
+ import _onekeyfe_hd_transport__default, { ProtocolV2UsbTransportBase, AcquireInput, TransportCallOptions, ProtocolV2Schemas, ProtocolV2CallContext, ProtocolType, OneKeyDeviceInfoBase, OneKeyDeviceInfo, TransportReleaseOptions } from '@onekeyfe/hd-transport';
3
3
  import EventEmitter from 'events';
4
4
  import { Deferred } from '@onekeyfe/hd-shared';
5
5
  import { DesktopAPI } from '@onekeyfe/hd-transport-electron';
@@ -237,8 +237,6 @@ type BleAcquireInput = {
237
237
  forceCleanRunPromise?: boolean;
238
238
  expectedProtocol?: ProtocolType;
239
239
  protocolHint?: ProtocolType;
240
- onlyConnectBleDevice?: boolean;
241
- abortSignal?: AbortSignal;
242
240
  };
243
241
  /**
244
242
  * Desktop Electron BLE transport with automatic Protocol V1/V2 detection.
@@ -271,11 +269,6 @@ declare class ElectronBleTransport {
271
269
  private stopPromise?;
272
270
  private deviceProtocol;
273
271
  private deviceProtocolHints;
274
- private silentDetections;
275
- private probeResponseTimeoutErrors;
276
- private lastV1ProbeFailedWithoutTimeout;
277
- private acquireGenerations;
278
- private nextAcquireGeneration;
279
272
  private deviceMtus;
280
273
  private devicePacketCapacities;
281
274
  private v1Buffers;
@@ -327,7 +320,7 @@ declare class ElectronBleTransport {
327
320
  bleColorCode?: string | undefined;
328
321
  protocolType?: ProtocolType | undefined;
329
322
  }>;
330
- release(id: string, onclose?: boolean, keepSession?: boolean): Promise<void>;
323
+ release(id: string, onclose?: boolean, keepSession?: boolean, options?: TransportReleaseOptions): Promise<void>;
331
324
  disconnect(id: string): Promise<void>;
332
325
  private releaseNative;
333
326
  private releaseLogical;
@@ -335,7 +328,6 @@ declare class ElectronBleTransport {
335
328
  private createProtocolDetectionError;
336
329
  private clearProbeProtocol;
337
330
  private detectProtocol;
338
- private wakeSilentProtocolV1Device;
339
331
  private createNotificationSubscription;
340
332
  private resetProbeStateAfterProtocolProbe;
341
333
  private probeProtocolV1;