@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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +17 -0
- package/lib/BleTransport.d.ts +67 -37
- package/lib/BleTransport.d.ts.map +1 -1
- package/lib/BleTransport.js +257 -198
- package/lib/BleTransport.js.map +1 -1
- package/lib/BleTransport.test.d.ts +2 -0
- package/lib/BleTransport.test.d.ts.map +1 -0
- package/lib/BleTransport.test.js +370 -0
- package/lib/BleTransport.test.js.map +1 -0
- package/lib/remapErrors.d.ts +4 -0
- package/lib/remapErrors.d.ts.map +1 -1
- package/lib/remapErrors.js +20 -1
- package/lib/remapErrors.js.map +1 -1
- package/lib/types.d.ts +4 -0
- package/lib/types.d.ts.map +1 -1
- package/lib-es/BleTransport.d.ts +67 -37
- package/lib-es/BleTransport.d.ts.map +1 -1
- package/lib-es/BleTransport.js +257 -198
- package/lib-es/BleTransport.js.map +1 -1
- package/lib-es/BleTransport.test.d.ts +2 -0
- package/lib-es/BleTransport.test.d.ts.map +1 -0
- package/lib-es/BleTransport.test.js +365 -0
- package/lib-es/BleTransport.test.js.map +1 -0
- package/lib-es/remapErrors.d.ts +4 -0
- package/lib-es/remapErrors.d.ts.map +1 -1
- package/lib-es/remapErrors.js +19 -1
- package/lib-es/remapErrors.js.map +1 -1
- package/lib-es/types.d.ts +4 -0
- package/lib-es/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/BleTransport.test.ts +275 -0
- package/src/BleTransport.ts +250 -172
- package/src/remapErrors.ts +33 -2
- package/src/types.ts +5 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/react-native-hw-transport-ble@6.28.
|
|
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
|
package/lib/BleTransport.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
8
|
-
declare
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
19
|
+
static list: () => Promise<void[]>;
|
|
27
20
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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<
|
|
41
|
+
static listen(observer: TransportObserver<any, HwTransportError>): TransportSubscription;
|
|
40
42
|
/**
|
|
41
43
|
* Open a BLE transport
|
|
42
|
-
* @param {
|
|
44
|
+
* @param {Device | string} deviceOrId
|
|
43
45
|
*/
|
|
44
|
-
static open(deviceOrId: Device | string): Promise<
|
|
46
|
+
static open(deviceOrId: Device | string): Promise<BleTransport>;
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
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:
|
|
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
|
-
|
|
60
|
+
writeCharacteristic: Characteristic;
|
|
61
|
+
writeCmdCharacteristic: Characteristic | undefined;
|
|
62
|
+
constructor(device: Device, writeCharacteristic: Characteristic, writeCmdCharacteristic: Characteristic | undefined, notifyObservable: Observable<any>, deviceModel: DeviceModel);
|
|
58
63
|
/**
|
|
59
|
-
*
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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":";
|
|
1
|
+
{"version":3,"file":"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