@ledgerhq/react-native-hw-transport-ble 6.28.3 → 6.28.4-nightly.0

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,4 +1,4 @@
1
1
 
2
- > @ledgerhq/react-native-hw-transport-ble@6.28.2 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/react-native-hw-transport-ble
2
+ > @ledgerhq/react-native-hw-transport-ble@6.28.3 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/react-native-hw-transport-ble
3
3
  > tsc && tsc -m ES6 --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ledgerhq/react-native-hw-transport-ble
2
2
 
3
+ ## 6.28.4-nightly.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`1d0b2d19eb`](https://github.com/LedgerHQ/ledger-live/commit/1d0b2d19ebc5acd058930b842c6d37f8daf2a5a3)]:
8
+ - @ledgerhq/errors@6.12.4-nightly.0
9
+ - @ledgerhq/devices@8.0.1-nightly.0
10
+ - @ledgerhq/hw-transport@6.28.2-nightly.0
11
+
3
12
  ## 6.28.3
4
13
 
5
14
  ### Patch Changes
@@ -8,6 +17,14 @@
8
17
  - @ledgerhq/devices@8.0.0
9
18
  - @ledgerhq/hw-transport@6.28.1
10
19
 
20
+ ## 6.28.3-next.0
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [[`62af25493e`](https://github.com/LedgerHQ/ledger-live/commit/62af25493e2becf897d517af42542db208b971c7)]:
25
+ - @ledgerhq/devices@8.0.0-next.0
26
+ - @ledgerhq/hw-transport@6.28.1-next.0
27
+
11
28
  ## 6.28.2
12
29
 
13
30
  ### Patch Changes
@@ -1,21 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import Transport from "@ledgerhq/hw-transport";
3
- import type { Subscription as TransportSubscription, Observer as TransportObserver, DescriptorEvent } from "@ledgerhq/hw-transport";
3
+ import type { Subscription as TransportSubscription, Observer as TransportObserver } from "@ledgerhq/hw-transport";
4
+ import { DeviceId, Device, Characteristic } from "react-native-ble-plx";
4
5
  import type { DeviceModel } from "@ledgerhq/devices";
5
- import { Observable } from "rxjs";
6
+ import { Observable, Observer } from "rxjs";
6
7
  import { HwTransportError } from "@ledgerhq/errors";
7
- import type { Device, Characteristic } from "./types";
8
- declare type ReconnectionConfig = {
9
- pairingThreshold: number;
10
- delayAfterFirstPairing: number;
11
- };
12
- export declare function setReconnectionConfig(config: ReconnectionConfig | null | undefined): void;
13
- /**
14
- * react-native bluetooth BLE implementation
15
- * @example
16
- * import BluetoothTransport from "@ledgerhq/react-native-hw-transport-ble";
17
- */
18
- export default class BluetoothTransport extends Transport {
8
+ import { ReconnectionConfig } from "./types";
9
+ export declare const setReconnectionConfig: (config: ReconnectionConfig | null | undefined) => void;
10
+ export default class BleTransport extends Transport {
11
+ static disconnectTimeoutMs: number;
19
12
  /**
20
13
  *
21
14
  */
@@ -23,47 +16,84 @@ export default class BluetoothTransport extends Transport {
23
16
  /**
24
17
  *
25
18
  */
26
- static setLogLevel: (level: any) => void;
19
+ static list: () => Promise<void[]>;
27
20
  /**
28
- * TODO could add this concept in all transports
29
- * observe event with { available: bool, string } // available is generic, type is specific
30
- * an event is emit once and then listened
21
+ * Exposed method from the ble-plx library
22
+ * Sets new log level for native module's logging mechanism.
23
+ * @param string logLevel New log level to be set.
31
24
  */
32
- static observeState(observer: any): {
33
- unsubscribe: () => void;
34
- };
35
- static list: () => any;
25
+ static setLogLevel: (logLevel: string) => void;
26
+ /**
27
+ * Listen to state changes on the bleManagerInstance and notify the
28
+ * specified observer.
29
+ * @param observer
30
+ * @returns TransportSubscription
31
+ */
32
+ static observeState(observer: Observer<{
33
+ type: string;
34
+ available: boolean;
35
+ }>): TransportSubscription;
36
36
  /**
37
37
  * Scan for bluetooth Ledger devices
38
+ * @param observer Device is partial in order to avoid the live-common/this dep
39
+ * @returns TransportSubscription
38
40
  */
39
- static listen(observer: TransportObserver<DescriptorEvent<Device>, HwTransportError>): TransportSubscription;
41
+ static listen(observer: TransportObserver<any, HwTransportError>): TransportSubscription;
40
42
  /**
41
43
  * Open a BLE transport
42
- * @param {*} deviceOrId
44
+ * @param {Device | string} deviceOrId
43
45
  */
44
- static open(deviceOrId: Device | string): Promise<any>;
46
+ static open(deviceOrId: Device | string): Promise<BleTransport>;
45
47
  /**
46
- * Globally disconnect a BLE device by its ID
48
+ * Exposed method from the ble-plx library
49
+ * Disconnects from {@link Device} if it's connected or cancels pending connection.
47
50
  */
48
- static disconnect: (id: any) => Promise<void>;
49
- id: string;
51
+ static disconnect: (id: DeviceId) => Promise<void>;
50
52
  device: Device;
53
+ deviceModel: DeviceModel;
54
+ disconnectTimeout: null | ReturnType<typeof setTimeout>;
55
+ id: string;
56
+ isConnected: boolean;
51
57
  mtuSize: number;
52
- writeCharacteristic: Characteristic;
53
- writeCmdCharacteristic: Characteristic;
54
58
  notifyObservable: Observable<any>;
55
- deviceModel: DeviceModel;
56
59
  notYetDisconnected: boolean;
57
- constructor(device: Device, writeCharacteristic: Characteristic, writeCmdCharacteristic: Characteristic, notifyObservable: Observable<any>, deviceModel: DeviceModel);
60
+ writeCharacteristic: Characteristic;
61
+ writeCmdCharacteristic: Characteristic | undefined;
62
+ constructor(device: Device, writeCharacteristic: Characteristic, writeCmdCharacteristic: Characteristic | undefined, notifyObservable: Observable<any>, deviceModel: DeviceModel);
58
63
  /**
59
- * communicate with a BLE transport
64
+ * Send data to the device using a low level API.
65
+ * It's recommended to use the "send" method for a higher level API.
66
+ * @param {Buffer} apdu - The data to send.
67
+ * @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
60
68
  */
61
69
  exchange: (apdu: Buffer) => Promise<any>;
70
+ /**
71
+ * Negotiate with the device the maximum transfer unit for the ble frames
72
+ * @returns Promise<number>
73
+ */
62
74
  inferMTU(): Promise<number>;
63
- requestConnectionPriority(connectionPriority: "Balanced" | "High" | "LowPower"): Promise<void>;
64
- setScrambleKey(): void;
65
- write: (buffer: Buffer, txid?: string | null | undefined) => Promise<void>;
75
+ /**
76
+ * Exposed method from the ble-plx library
77
+ * Request the connection priority for the given device.
78
+ * @param {"Balanced" | "High" | "LowPower"} connectionPriority: Connection priority.
79
+ * @returns {Promise<Device>} Connected device.
80
+ */
81
+ requestConnectionPriority(connectionPriority: "Balanced" | "High" | "LowPower"): Promise<Device>;
82
+ /**
83
+ * Do not call this directly unless you know what you're doing. Communication
84
+ * with a Ledger device should be through the {@link exchange} method.
85
+ * @param buffer
86
+ * @param txid
87
+ */
88
+ write: (buffer: Buffer, txid?: string | undefined) => Promise<void>;
89
+ /**
90
+ * We intentionally do not immediately close a transport connection.
91
+ * Instead, we queue the disconnect and wait for a future connection to dismiss the event.
92
+ * This approach prevents unnecessary disconnects and reconnects. We use the isConnected
93
+ * flag to ensure that we do not trigger a disconnect if the current cached transport has
94
+ * already been disconnected.
95
+ * @returns {Promise<void>}
96
+ */
66
97
  close(): Promise<void>;
67
98
  }
68
- export {};
69
99
  //# sourceMappingURL=BleTransport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BleTransport.d.ts","sourceRoot":"","sources":["../src/BleTransport.ts"],"names":[],"mappings":";AACA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,EACV,YAAY,IAAI,qBAAqB,EACrC,QAAQ,IAAI,iBAAiB,EAC7B,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAWhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYrD,OAAO,EAAE,UAAU,EAAsC,MAAM,MAAM,CAAC;AAStE,OAAO,EAKL,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAmCtD,aAAK,kBAAkB,GAAG;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CA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