@ledgerhq/hw-transport 6.27.10 → 6.28.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 +12 -0
- package/README.md +67 -48
- package/lib/Transport.d.ts +50 -37
- package/lib/Transport.d.ts.map +1 -1
- package/lib/Transport.js +101 -38
- package/lib/Transport.js.map +1 -1
- package/lib-es/Transport.d.ts +50 -37
- package/lib-es/Transport.d.ts.map +1 -1
- package/lib-es/Transport.js +101 -38
- package/lib-es/Transport.js.map +1 -1
- package/package.json +1 -1
- package/src/Transport.ts +77 -38
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/hw-transport@6.
|
|
2
|
+
> @ledgerhq/hw-transport@6.28.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-transport
|
|
3
3
|
> tsc && tsc -m ES6 --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ledgerhq/hw-transport
|
|
2
2
|
|
|
3
|
+
## 6.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2342](https://github.com/LedgerHQ/ledger-live/pull/2342) [`c2779b1cab`](https://github.com/LedgerHQ/ledger-live/commit/c2779b1cab18a1d5747ca955f5ceee86db920f57) Thanks [@gre](https://github.com/gre)! - Add Transport#exchangeBulk method to have a native batched mecanism to send a lot of APDU at once & in order to do it performantly.
|
|
8
|
+
|
|
9
|
+
## 6.28.0-next.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#2342](https://github.com/LedgerHQ/ledger-live/pull/2342) [`c2779b1cab`](https://github.com/LedgerHQ/ledger-live/commit/c2779b1cab18a1d5747ca955f5ceee86db920f57) Thanks [@gre](https://github.com/gre)! - Add Transport#exchangeBulk method to have a native batched mecanism to send a lot of APDU at once & in order to do it performantly.
|
|
14
|
+
|
|
3
15
|
## 6.27.10
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -22,31 +22,33 @@
|
|
|
22
22
|
* [Transport](#transport)
|
|
23
23
|
* [exchange](#exchange)
|
|
24
24
|
* [Parameters](#parameters)
|
|
25
|
-
* [
|
|
25
|
+
* [exchangeBulk](#exchangebulk)
|
|
26
26
|
* [Parameters](#parameters-1)
|
|
27
|
+
* [setScrambleKey](#setscramblekey)
|
|
28
|
+
* [Parameters](#parameters-2)
|
|
27
29
|
* [close](#close)
|
|
28
30
|
* [on](#on)
|
|
29
|
-
* [Parameters](#parameters-2)
|
|
30
|
-
* [off](#off)
|
|
31
31
|
* [Parameters](#parameters-3)
|
|
32
|
+
* [off](#off)
|
|
33
|
+
* [Parameters](#parameters-4)
|
|
32
34
|
* [setDebugMode](#setdebugmode)
|
|
33
35
|
* [setExchangeTimeout](#setexchangetimeout)
|
|
34
|
-
* [Parameters](#parameters-4)
|
|
35
|
-
* [setExchangeUnresponsiveTimeout](#setexchangeunresponsivetimeout)
|
|
36
36
|
* [Parameters](#parameters-5)
|
|
37
|
-
* [
|
|
37
|
+
* [setExchangeUnresponsiveTimeout](#setexchangeunresponsivetimeout)
|
|
38
38
|
* [Parameters](#parameters-6)
|
|
39
|
+
* [send](#send)
|
|
40
|
+
* [Parameters](#parameters-7)
|
|
39
41
|
* [isSupported](#issupported)
|
|
40
42
|
* [list](#list)
|
|
41
43
|
* [Examples](#examples)
|
|
42
44
|
* [listen](#listen)
|
|
43
|
-
* [Parameters](#parameters-
|
|
45
|
+
* [Parameters](#parameters-8)
|
|
44
46
|
* [Examples](#examples-1)
|
|
45
47
|
* [open](#open)
|
|
46
|
-
* [Parameters](#parameters-
|
|
48
|
+
* [Parameters](#parameters-9)
|
|
47
49
|
* [Examples](#examples-2)
|
|
48
50
|
* [create](#create)
|
|
49
|
-
* [Parameters](#parameters-
|
|
51
|
+
* [Parameters](#parameters-10)
|
|
50
52
|
* [Examples](#examples-3)
|
|
51
53
|
|
|
52
54
|
### Subscription
|
|
@@ -63,6 +65,7 @@ Type: any
|
|
|
63
65
|
|
|
64
66
|
### DescriptorEvent
|
|
65
67
|
|
|
68
|
+
A "descriptor" is a parameter that is specific to the implementation, and can be an ID, file path, or URL.
|
|
66
69
|
type: add or remove event
|
|
67
70
|
descriptor: a parameter that can be passed to open(descriptor)
|
|
68
71
|
deviceModel: device info on the model (is it a nano s, nano x, ...)
|
|
@@ -76,49 +79,63 @@ Type: Readonly<{next: function (event: EventType): any, error: function (e: Even
|
|
|
76
79
|
|
|
77
80
|
### Transport
|
|
78
81
|
|
|
79
|
-
Transport defines
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
The Transport class defines a generic interface for communicating with a Ledger hardware wallet.
|
|
83
|
+
There are different kind of transports based on the technology (channels like U2F, HID, Bluetooth, Webusb) and environment (Node, Web,...).
|
|
84
|
+
It is an abstract class that needs to be implemented.
|
|
82
85
|
|
|
83
86
|
#### exchange
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Instead, the recommanded way is to use send() method
|
|
88
|
+
Send data to the device using a low level API.
|
|
89
|
+
It's recommended to use the "send" method for a higher level API.
|
|
88
90
|
|
|
89
91
|
##### Parameters
|
|
90
92
|
|
|
91
93
|
* `_apdu` **[Buffer](https://nodejs.org/api/buffer.html)**
|
|
92
|
-
* `apdu`
|
|
94
|
+
* `apdu` **[Buffer](https://nodejs.org/api/buffer.html)** The data to send.
|
|
95
|
+
|
|
96
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Buffer](https://nodejs.org/api/buffer.html)>** A promise that resolves with the response data from the device.
|
|
97
|
+
|
|
98
|
+
#### exchangeBulk
|
|
99
|
+
|
|
100
|
+
Send apdus in batch to the device using a low level API.
|
|
101
|
+
The default implementation is to call exchange for each apdu.
|
|
102
|
+
|
|
103
|
+
##### Parameters
|
|
104
|
+
|
|
105
|
+
* `apdus` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Buffer](https://nodejs.org/api/buffer.html)>** array of apdus to send.
|
|
106
|
+
* `observer` **[Observer](#observer)<[Buffer](https://nodejs.org/api/buffer.html)>** an observer that will receive the response of each apdu.
|
|
93
107
|
|
|
94
|
-
Returns **[
|
|
108
|
+
Returns **[Subscription](#subscription)** A Subscription object on which you can call ".unsubscribe()" to stop sending apdus.
|
|
95
109
|
|
|
96
110
|
#### setScrambleKey
|
|
97
111
|
|
|
98
|
-
|
|
99
|
-
Each
|
|
112
|
+
Set the "scramble key" for the next data exchanges with the device.
|
|
113
|
+
Each app can have a different scramble key and it is set internally during instantiation.
|
|
100
114
|
|
|
101
115
|
##### Parameters
|
|
102
116
|
|
|
103
117
|
* `_key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
104
|
-
* `key`
|
|
118
|
+
* `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The scramble key to set.
|
|
119
|
+
|
|
120
|
+
**Meta**
|
|
121
|
+
|
|
122
|
+
* **deprecated**: This method is no longer needed for modern transports and should be migrated away from.
|
|
105
123
|
|
|
106
124
|
#### close
|
|
107
125
|
|
|
108
|
-
|
|
126
|
+
Close the connection with the device.
|
|
109
127
|
|
|
110
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<void>**
|
|
128
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<void>** A promise that resolves when the transport is closed.
|
|
111
129
|
|
|
112
130
|
#### on
|
|
113
131
|
|
|
114
|
-
Listen
|
|
115
|
-
Transport
|
|
116
|
-
|
|
117
|
-
* `"disconnect"` : triggered if Transport is disconnected
|
|
132
|
+
Listen for an event on the transport instance.
|
|
133
|
+
Transport implementations may have specific events. Common events include:
|
|
134
|
+
"disconnect" : triggered when the transport is disconnected.
|
|
118
135
|
|
|
119
136
|
##### Parameters
|
|
120
137
|
|
|
121
|
-
* `eventName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
138
|
+
* `eventName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the event to listen for.
|
|
122
139
|
* `cb` **function (...args: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>): any**
|
|
123
140
|
|
|
124
141
|
Returns **void**
|
|
@@ -160,28 +177,31 @@ Returns **void**
|
|
|
160
177
|
|
|
161
178
|
#### send
|
|
162
179
|
|
|
163
|
-
|
|
180
|
+
Send data to the device using the higher level API.
|
|
164
181
|
|
|
165
182
|
##### Parameters
|
|
166
183
|
|
|
167
|
-
* `cla` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
168
|
-
* `ins` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
169
|
-
* `p1` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
170
|
-
* `p2` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
171
|
-
* `data` **[Buffer](https://nodejs.org/api/buffer.html)**
|
|
172
|
-
* `statusList` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>**
|
|
184
|
+
* `cla` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The instruction class for the command.
|
|
185
|
+
* `ins` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The instruction code for the command.
|
|
186
|
+
* `p1` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The first parameter for the instruction.
|
|
187
|
+
* `p2` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The second parameter for the instruction.
|
|
188
|
+
* `data` **[Buffer](https://nodejs.org/api/buffer.html)** The data to be sent. Defaults to an empty buffer. (optional, default `Buffer.alloc(0)`)
|
|
189
|
+
* `statusList` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** A list of acceptable status codes for the response. Defaults to \[StatusCodes.OK]. (optional, default `[StatusCodes.OK]`)
|
|
173
190
|
|
|
174
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Buffer](https://nodejs.org/api/buffer.html)>**
|
|
191
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Buffer](https://nodejs.org/api/buffer.html)>** A promise that resolves with the response data from the device.
|
|
175
192
|
|
|
176
193
|
#### isSupported
|
|
177
194
|
|
|
178
|
-
|
|
195
|
+
Check if the transport is supported on the current platform/browser.
|
|
179
196
|
|
|
180
197
|
Type: function (): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>
|
|
181
198
|
|
|
199
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>** A promise that resolves with a boolean indicating support.
|
|
200
|
+
|
|
182
201
|
#### list
|
|
183
202
|
|
|
184
|
-
List
|
|
203
|
+
List all available descriptors for the transport.
|
|
204
|
+
For a better granularity, checkout `listen()`.
|
|
185
205
|
|
|
186
206
|
Type: function (): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>>
|
|
187
207
|
|
|
@@ -191,20 +211,19 @@ Type: function (): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/R
|
|
|
191
211
|
TransportFoo.list().then(descriptors => ...)
|
|
192
212
|
```
|
|
193
213
|
|
|
194
|
-
Returns **any
|
|
214
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>>** A promise that resolves with an array of descriptors.
|
|
195
215
|
|
|
196
216
|
#### listen
|
|
197
217
|
|
|
198
|
-
Listen
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
for instance if you plug a USB device after listen() or a bluetooth device become discoverable.
|
|
218
|
+
Listen for device events for the transport. The method takes an observer of DescriptorEvent and returns a Subscription.
|
|
219
|
+
A DescriptorEvent is an object containing a "descriptor" and a "type" field. The "type" field can be "add" or "remove", and the "descriptor" field can be passed to the "open" method.
|
|
220
|
+
The "listen" method will first emit all currently connected devices and then will emit events as they occur, such as when a USB device is plugged in or a Bluetooth device becomes discoverable.
|
|
202
221
|
|
|
203
222
|
Type: function (observer: [Observer](#observer)<[DescriptorEvent](#descriptorevent)\<any>>): [Subscription](#subscription)
|
|
204
223
|
|
|
205
224
|
##### Parameters
|
|
206
225
|
|
|
207
|
-
* `observer`
|
|
226
|
+
* `observer` **[Observer](#observer)<[DescriptorEvent](#descriptorevent)\<any>>** An object with "next", "error", and "complete" functions, following the observer pattern.
|
|
208
227
|
|
|
209
228
|
##### Examples
|
|
210
229
|
|
|
@@ -222,18 +241,18 @@ complete: () => {}
|
|
|
222
241
|
})
|
|
223
242
|
```
|
|
224
243
|
|
|
225
|
-
Returns **
|
|
244
|
+
Returns **[Subscription](#subscription)** A Subscription object on which you can call ".unsubscribe()" to stop listening to descriptors.
|
|
226
245
|
|
|
227
246
|
#### open
|
|
228
247
|
|
|
229
|
-
|
|
248
|
+
Attempt to create a Transport instance with a specific descriptor.
|
|
230
249
|
|
|
231
250
|
Type: function (descriptor: any, timeout: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Transport](#transport)>
|
|
232
251
|
|
|
233
252
|
##### Parameters
|
|
234
253
|
|
|
235
|
-
* `descriptor`
|
|
236
|
-
* `timeout`
|
|
254
|
+
* `descriptor` **any** The descriptor to open the transport with.
|
|
255
|
+
* `timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** An optional timeout for the transport connection.
|
|
237
256
|
|
|
238
257
|
##### Examples
|
|
239
258
|
|
|
@@ -241,7 +260,7 @@ Type: function (descriptor: any, timeout: [number](https://developer.mozilla.org
|
|
|
241
260
|
TransportFoo.open(descriptor).then(transport => ...)
|
|
242
261
|
```
|
|
243
262
|
|
|
244
|
-
Returns **
|
|
263
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Transport](#transport)>** A promise that resolves with a Transport instance.
|
|
245
264
|
|
|
246
265
|
#### create
|
|
247
266
|
|
package/lib/Transport.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare type Subscription = {
|
|
|
13
13
|
export declare type Device = any;
|
|
14
14
|
export declare type DescriptorEventType = "add" | "remove";
|
|
15
15
|
/**
|
|
16
|
+
* A "descriptor" is a parameter that is specific to the implementation, and can be an ID, file path, or URL.
|
|
16
17
|
* type: add or remove event
|
|
17
18
|
* descriptor: a parameter that can be passed to open(descriptor)
|
|
18
19
|
* deviceModel: device info on the model (is it a nano s, nano x, ...)
|
|
@@ -33,32 +34,34 @@ export declare type Observer<EventType, EventError = unknown> = Readonly<{
|
|
|
33
34
|
complete: () => unknown;
|
|
34
35
|
}>;
|
|
35
36
|
/**
|
|
36
|
-
* Transport defines
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* The Transport class defines a generic interface for communicating with a Ledger hardware wallet.
|
|
38
|
+
* There are different kind of transports based on the technology (channels like U2F, HID, Bluetooth, Webusb) and environment (Node, Web,...).
|
|
39
|
+
* It is an abstract class that needs to be implemented.
|
|
39
40
|
*/
|
|
40
41
|
export default class Transport {
|
|
41
42
|
exchangeTimeout: number;
|
|
42
43
|
unresponsiveTimeout: number;
|
|
43
44
|
deviceModel: DeviceModel | null | undefined;
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
+
* Check if the transport is supported on the current platform/browser.
|
|
47
|
+
* @returns {Promise<boolean>} A promise that resolves with a boolean indicating support.
|
|
46
48
|
*/
|
|
47
49
|
static readonly isSupported: () => Promise<boolean>;
|
|
48
50
|
/**
|
|
49
|
-
* List
|
|
50
|
-
*
|
|
51
|
+
* List all available descriptors for the transport.
|
|
52
|
+
* For a better granularity, checkout `listen()`.
|
|
53
|
+
*
|
|
54
|
+
* @returns {Promise<Array<any>>} A promise that resolves with an array of descriptors.
|
|
51
55
|
* @example
|
|
52
56
|
* TransportFoo.list().then(descriptors => ...)
|
|
53
57
|
*/
|
|
54
58
|
static readonly list: () => Promise<Array<any>>;
|
|
55
59
|
/**
|
|
56
|
-
* Listen
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @return a Subscription object on which you can `.unsubscribe()` to stop listening descriptors.
|
|
60
|
+
* Listen for device events for the transport. The method takes an observer of DescriptorEvent and returns a Subscription.
|
|
61
|
+
* A DescriptorEvent is an object containing a "descriptor" and a "type" field. The "type" field can be "add" or "remove", and the "descriptor" field can be passed to the "open" method.
|
|
62
|
+
* The "listen" method will first emit all currently connected devices and then will emit events as they occur, such as when a USB device is plugged in or a Bluetooth device becomes discoverable.
|
|
63
|
+
* @param {Observer<DescriptorEvent<any>>} observer - An object with "next", "error", and "complete" functions, following the observer pattern.
|
|
64
|
+
* @returns {Subscription} A Subscription object on which you can call ".unsubscribe()" to stop listening to descriptors.
|
|
62
65
|
* @example
|
|
63
66
|
const sub = TransportFoo.listen({
|
|
64
67
|
next: e => {
|
|
@@ -74,38 +77,48 @@ export default class Transport {
|
|
|
74
77
|
*/
|
|
75
78
|
static readonly listen: (observer: Observer<DescriptorEvent<any>>) => Subscription;
|
|
76
79
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @param descriptor
|
|
79
|
-
* @param timeout
|
|
80
|
-
* @
|
|
80
|
+
* Attempt to create a Transport instance with a specific descriptor.
|
|
81
|
+
* @param {any} descriptor - The descriptor to open the transport with.
|
|
82
|
+
* @param {number} timeout - An optional timeout for the transport connection.
|
|
83
|
+
* @returns {Promise<Transport>} A promise that resolves with a Transport instance.
|
|
81
84
|
* @example
|
|
82
85
|
TransportFoo.open(descriptor).then(transport => ...)
|
|
83
86
|
*/
|
|
84
87
|
static readonly open: (descriptor?: any, timeout?: number) => Promise<Transport>;
|
|
85
88
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
90
|
-
* @return a Promise of response data
|
|
89
|
+
* Send data to the device using a low level API.
|
|
90
|
+
* It's recommended to use the "send" method for a higher level API.
|
|
91
|
+
* @param {Buffer} apdu - The data to send.
|
|
92
|
+
* @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
|
|
91
93
|
*/
|
|
92
94
|
exchange(_apdu: Buffer): Promise<Buffer>;
|
|
93
95
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @param
|
|
96
|
+
* Send apdus in batch to the device using a low level API.
|
|
97
|
+
* The default implementation is to call exchange for each apdu.
|
|
98
|
+
* @param {Array<Buffer>} apdus - array of apdus to send.
|
|
99
|
+
* @param {Observer<Buffer>} observer - an observer that will receive the response of each apdu.
|
|
100
|
+
* @returns {Subscription} A Subscription object on which you can call ".unsubscribe()" to stop sending apdus.
|
|
101
|
+
*/
|
|
102
|
+
exchangeBulk(apdus: Buffer[], observer: Observer<Buffer>): Subscription;
|
|
103
|
+
/**
|
|
104
|
+
* Set the "scramble key" for the next data exchanges with the device.
|
|
105
|
+
* Each app can have a different scramble key and it is set internally during instantiation.
|
|
106
|
+
* @param {string} key - The scramble key to set.
|
|
107
|
+
* @deprecated This method is no longer needed for modern transports and should be migrated away from.
|
|
97
108
|
*/
|
|
98
109
|
setScrambleKey(_key: string): void;
|
|
99
110
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @
|
|
111
|
+
* Close the connection with the device.
|
|
112
|
+
* @returns {Promise<void>} A promise that resolves when the transport is closed.
|
|
102
113
|
*/
|
|
103
114
|
close(): Promise<void>;
|
|
104
115
|
_events: EventEmitter;
|
|
105
116
|
/**
|
|
106
|
-
* Listen
|
|
107
|
-
* Transport
|
|
108
|
-
*
|
|
117
|
+
* Listen for an event on the transport instance.
|
|
118
|
+
* Transport implementations may have specific events. Common events include:
|
|
119
|
+
* "disconnect" : triggered when the transport is disconnected.
|
|
120
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
121
|
+
* @param {(...args: Array<any>) => any} cb - The callback function to be invoked when the event occurs.
|
|
109
122
|
*/
|
|
110
123
|
on(eventName: string, cb: (...args: Array<any>) => any): void;
|
|
111
124
|
/**
|
|
@@ -126,14 +139,14 @@ export default class Transport {
|
|
|
126
139
|
*/
|
|
127
140
|
setExchangeUnresponsiveTimeout(unresponsiveTimeout: number): void;
|
|
128
141
|
/**
|
|
129
|
-
*
|
|
130
|
-
* @param cla
|
|
131
|
-
* @param ins
|
|
132
|
-
* @param p1
|
|
133
|
-
* @param p2
|
|
134
|
-
* @param data
|
|
135
|
-
* @param statusList
|
|
136
|
-
* @
|
|
142
|
+
* Send data to the device using the higher level API.
|
|
143
|
+
* @param {number} cla - The instruction class for the command.
|
|
144
|
+
* @param {number} ins - The instruction code for the command.
|
|
145
|
+
* @param {number} p1 - The first parameter for the instruction.
|
|
146
|
+
* @param {number} p2 - The second parameter for the instruction.
|
|
147
|
+
* @param {Buffer} data - The data to be sent. Defaults to an empty buffer.
|
|
148
|
+
* @param {Array<number>} statusList - A list of acceptable status codes for the response. Defaults to [StatusCodes.OK].
|
|
149
|
+
* @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
|
|
137
150
|
*/
|
|
138
151
|
send: (cla: number, ins: number, p1: number, p2: number, data?: Buffer, statusList?: Array<number>) => Promise<Buffer>;
|
|
139
152
|
/**
|
package/lib/Transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAEL,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,mBAAmB,GACpB,CAAC;AAEF;GACG;AACH,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF;GACG;AACH,oBAAY,MAAM,GAAG,GAAG,CAAC;AAEzB,oBAAY,mBAAmB,GAAG,KAAK,GAAG,QAAQ,CAAC;AACnD
|
|
1
|
+
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAEL,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,mBAAmB,GACpB,CAAC;AAEF;GACG;AACH,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF;GACG;AACH,oBAAY,MAAM,GAAG,GAAG,CA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