@ledgerhq/hw-transport-web-ble 6.29.4 → 6.29.5-next.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 +9 -0
- package/lib/TransportWebBLE.d.ts +1 -0
- package/lib/TransportWebBLE.d.ts.map +1 -1
- package/lib/TransportWebBLE.js +137 -153
- package/lib/TransportWebBLE.js.map +1 -1
- package/lib/monitorCharacteristic.d.ts +1 -0
- package/lib/monitorCharacteristic.d.ts.map +1 -1
- package/lib-es/TransportWebBLE.d.ts +1 -0
- package/lib-es/TransportWebBLE.d.ts.map +1 -1
- package/lib-es/TransportWebBLE.js +138 -155
- package/lib-es/TransportWebBLE.js.map +1 -1
- package/lib-es/monitorCharacteristic.d.ts +1 -0
- package/lib-es/monitorCharacteristic.d.ts.map +1 -1
- package/package.json +7 -6
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ledgerhq/hw-transport-web-ble
|
|
2
2
|
|
|
3
|
+
## 6.29.5-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`107f35a`](https://github.com/LedgerHQ/ledger-live/commit/107f35a0650412716b088a3503b86435e6d9cf47), [`9081c26`](https://github.com/LedgerHQ/ledger-live/commit/9081c2648490f977469a33762a3c67bb2c2a0be5)]:
|
|
8
|
+
- @ledgerhq/errors@6.21.0-next.0
|
|
9
|
+
- @ledgerhq/devices@8.4.5-next.0
|
|
10
|
+
- @ledgerhq/hw-transport@6.31.5-next.0
|
|
11
|
+
|
|
3
12
|
## 6.29.4
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/lib/TransportWebBLE.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportWebBLE.d.ts","sourceRoot":"","sources":["../src/TransportWebBLE.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G3B;IAEI,KAAK;CAKZ"}
|
package/lib/TransportWebBLE.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
|
-
var _a;
|
|
15
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
6
|
/* eslint-disable prefer-template */
|
|
17
7
|
const hw_transport_1 = __importDefault(require("@ledgerhq/hw-transport"));
|
|
@@ -54,85 +44,83 @@ const requestDeviceParam = () => ({
|
|
|
54
44
|
services: [uuid],
|
|
55
45
|
})),
|
|
56
46
|
});
|
|
57
|
-
const retrieveService = (device) =>
|
|
47
|
+
const retrieveService = async (device) => {
|
|
58
48
|
if (!device.gatt)
|
|
59
49
|
throw new Error("bluetooth gatt not found");
|
|
60
|
-
const [service] =
|
|
50
|
+
const [service] = await device.gatt.getPrimaryServices();
|
|
61
51
|
if (!service)
|
|
62
52
|
throw new Error("bluetooth service not found");
|
|
63
53
|
const infos = (0, devices_1.getInfosForServiceUuid)(service.uuid);
|
|
64
54
|
if (!infos)
|
|
65
55
|
throw new Error("bluetooth service infos not found");
|
|
66
56
|
return [service, infos];
|
|
67
|
-
}
|
|
68
|
-
function open(deviceOrId, needsReconnect) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return transportsCache[deviceOrId];
|
|
75
|
-
}
|
|
76
|
-
const bluetooth = requiresBluetooth();
|
|
77
|
-
// TODO instead we should "query" the device by its ID
|
|
78
|
-
device = yield bluetooth.requestDevice(requestDeviceParam());
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
device = deviceOrId;
|
|
82
|
-
}
|
|
83
|
-
if (!device.gatt.connected) {
|
|
84
|
-
(0, logs_1.log)("ble-verbose", "not connected. connecting...");
|
|
85
|
-
yield device.gatt.connect();
|
|
86
|
-
}
|
|
87
|
-
const [service, infos] = yield retrieveService(device);
|
|
88
|
-
const { deviceModel, writeUuid, notifyUuid } = infos;
|
|
89
|
-
const [writeC, notifyC] = yield Promise.all([
|
|
90
|
-
service.getCharacteristic(writeUuid),
|
|
91
|
-
service.getCharacteristic(notifyUuid),
|
|
92
|
-
]);
|
|
93
|
-
const notifyObservable = (0, monitorCharacteristic_1.monitorCharacteristic)(notifyC).pipe((0, operators_1.tap)(value => {
|
|
94
|
-
(0, logs_1.log)("ble-frame", "<= " + value.toString("hex"));
|
|
95
|
-
}), (0, operators_1.share)());
|
|
96
|
-
const notif = notifyObservable.subscribe();
|
|
97
|
-
const transport = new BluetoothTransport(device, writeC, notifyObservable, deviceModel);
|
|
98
|
-
if (!device.gatt.connected) {
|
|
99
|
-
throw new errors_1.DisconnectedDevice();
|
|
100
|
-
}
|
|
101
|
-
// eslint-disable-next-line require-atomic-updates
|
|
102
|
-
transportsCache[transport.id] = transport;
|
|
103
|
-
const onDisconnect = e => {
|
|
104
|
-
console.log("onDisconnect!", e);
|
|
105
|
-
delete transportsCache[transport.id];
|
|
106
|
-
transport.notYetDisconnected = false;
|
|
107
|
-
notif.unsubscribe();
|
|
108
|
-
device.removeEventListener("gattserverdisconnected", onDisconnect);
|
|
109
|
-
(0, logs_1.log)("ble-verbose", `BleTransport(${transport.id}) disconnected`);
|
|
110
|
-
transport.emit("disconnect", e);
|
|
111
|
-
};
|
|
112
|
-
device.addEventListener("gattserverdisconnected", onDisconnect);
|
|
113
|
-
const beforeMTUTime = Date.now();
|
|
114
|
-
try {
|
|
115
|
-
yield transport.inferMTU();
|
|
57
|
+
};
|
|
58
|
+
async function open(deviceOrId, needsReconnect) {
|
|
59
|
+
let device;
|
|
60
|
+
if (typeof deviceOrId === "string") {
|
|
61
|
+
if (transportsCache[deviceOrId]) {
|
|
62
|
+
(0, logs_1.log)("ble-verbose", "Transport in cache, using that.");
|
|
63
|
+
return transportsCache[deviceOrId];
|
|
116
64
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
65
|
+
const bluetooth = requiresBluetooth();
|
|
66
|
+
// TODO instead we should "query" the device by its ID
|
|
67
|
+
device = await bluetooth.requestDevice(requestDeviceParam());
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
device = deviceOrId;
|
|
71
|
+
}
|
|
72
|
+
if (!device.gatt.connected) {
|
|
73
|
+
(0, logs_1.log)("ble-verbose", "not connected. connecting...");
|
|
74
|
+
await device.gatt.connect();
|
|
75
|
+
}
|
|
76
|
+
const [service, infos] = await retrieveService(device);
|
|
77
|
+
const { deviceModel, writeUuid, notifyUuid } = infos;
|
|
78
|
+
const [writeC, notifyC] = await Promise.all([
|
|
79
|
+
service.getCharacteristic(writeUuid),
|
|
80
|
+
service.getCharacteristic(notifyUuid),
|
|
81
|
+
]);
|
|
82
|
+
const notifyObservable = (0, monitorCharacteristic_1.monitorCharacteristic)(notifyC).pipe((0, operators_1.tap)(value => {
|
|
83
|
+
(0, logs_1.log)("ble-frame", "<= " + value.toString("hex"));
|
|
84
|
+
}), (0, operators_1.share)());
|
|
85
|
+
const notif = notifyObservable.subscribe();
|
|
86
|
+
const transport = new BluetoothTransport(device, writeC, notifyObservable, deviceModel);
|
|
87
|
+
if (!device.gatt.connected) {
|
|
88
|
+
throw new errors_1.DisconnectedDevice();
|
|
89
|
+
}
|
|
90
|
+
// eslint-disable-next-line require-atomic-updates
|
|
91
|
+
transportsCache[transport.id] = transport;
|
|
92
|
+
const onDisconnect = e => {
|
|
93
|
+
console.log("onDisconnect!", e);
|
|
94
|
+
delete transportsCache[transport.id];
|
|
95
|
+
transport.notYetDisconnected = false;
|
|
96
|
+
notif.unsubscribe();
|
|
97
|
+
device.removeEventListener("gattserverdisconnected", onDisconnect);
|
|
98
|
+
(0, logs_1.log)("ble-verbose", `BleTransport(${transport.id}) disconnected`);
|
|
99
|
+
transport.emit("disconnect", e);
|
|
100
|
+
};
|
|
101
|
+
device.addEventListener("gattserverdisconnected", onDisconnect);
|
|
102
|
+
const beforeMTUTime = Date.now();
|
|
103
|
+
try {
|
|
104
|
+
await transport.inferMTU();
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
const afterMTUTime = Date.now();
|
|
108
|
+
// workaround for #279: we need to open() again if we come the first time here,
|
|
109
|
+
// to make sure we do a disconnect() after the first pairing time
|
|
110
|
+
// because of a firmware bug
|
|
111
|
+
if (afterMTUTime - beforeMTUTime < 1000) {
|
|
112
|
+
needsReconnect = false; // (optim) there is likely no new pairing done because mtu answer was fast.
|
|
130
113
|
}
|
|
131
114
|
if (needsReconnect) {
|
|
132
|
-
|
|
115
|
+
await device.gatt.disconnect();
|
|
116
|
+
// necessary time for the bonding workaround
|
|
117
|
+
await new Promise(s => setTimeout(s, 4000));
|
|
133
118
|
}
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
}
|
|
120
|
+
if (needsReconnect) {
|
|
121
|
+
return open(device, false);
|
|
122
|
+
}
|
|
123
|
+
return transport;
|
|
136
124
|
}
|
|
137
125
|
/**
|
|
138
126
|
* react-native bluetooth BLE implementation
|
|
@@ -140,6 +128,16 @@ function open(deviceOrId, needsReconnect) {
|
|
|
140
128
|
* import BluetoothTransport from "@ledgerhq/hw-transport-web-ble";
|
|
141
129
|
*/
|
|
142
130
|
class BluetoothTransport extends hw_transport_1.default {
|
|
131
|
+
static isSupported = () => Promise.resolve()
|
|
132
|
+
.then(requiresBluetooth)
|
|
133
|
+
.then(() => true, () => false);
|
|
134
|
+
/**
|
|
135
|
+
* observe event with { available: bool, type: string }
|
|
136
|
+
* (available is generic, type is specific)
|
|
137
|
+
* an event is emit once and then each time it changes
|
|
138
|
+
*/
|
|
139
|
+
static observeAvailability = (observer) => availability().subscribe(observer);
|
|
140
|
+
static list = () => Promise.resolve([]);
|
|
143
141
|
/**
|
|
144
142
|
* Scan for Ledger Bluetooth devices.
|
|
145
143
|
* On this web implementation, it only emits ONE device, the one that was selected in the UI (if any).
|
|
@@ -169,19 +167,28 @@ class BluetoothTransport extends hw_transport_1.default {
|
|
|
169
167
|
/**
|
|
170
168
|
* open a bluetooth device.
|
|
171
169
|
*/
|
|
172
|
-
static open(deviceOrId) {
|
|
173
|
-
return
|
|
174
|
-
return open(deviceOrId, true);
|
|
175
|
-
});
|
|
170
|
+
static async open(deviceOrId) {
|
|
171
|
+
return open(deviceOrId, true);
|
|
176
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* globally disconnect a bluetooth device by its id.
|
|
175
|
+
*/
|
|
176
|
+
static disconnect = async (id) => {
|
|
177
|
+
(0, logs_1.log)("ble-verbose", `user disconnect(${id})`);
|
|
178
|
+
const transport = transportsCache[id];
|
|
179
|
+
if (transport) {
|
|
180
|
+
transport.device.gatt.disconnect();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
id;
|
|
184
|
+
device;
|
|
185
|
+
mtuSize = 20;
|
|
186
|
+
writeCharacteristic;
|
|
187
|
+
notifyObservable;
|
|
188
|
+
notYetDisconnected = true;
|
|
189
|
+
deviceModel;
|
|
177
190
|
constructor(device, writeCharacteristic, notifyObservable, deviceModel) {
|
|
178
191
|
super();
|
|
179
|
-
this.mtuSize = 20;
|
|
180
|
-
this.notYetDisconnected = true;
|
|
181
|
-
this.write = (buffer) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
(0, logs_1.log)("ble-frame", "=> " + buffer.toString("hex"));
|
|
183
|
-
yield this.writeCharacteristic.writeValue(buffer);
|
|
184
|
-
});
|
|
185
192
|
this.id = device.id;
|
|
186
193
|
this.device = device;
|
|
187
194
|
this.writeCharacteristic = writeCharacteristic;
|
|
@@ -189,85 +196,62 @@ class BluetoothTransport extends hw_transport_1.default {
|
|
|
189
196
|
this.deviceModel = deviceModel;
|
|
190
197
|
(0, logs_1.log)("ble-verbose", `BleTransport(${String(this.id)}) new instance`);
|
|
191
198
|
}
|
|
192
|
-
inferMTU() {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
throw e;
|
|
204
|
-
}
|
|
205
|
-
}));
|
|
206
|
-
if (mtu > 23) {
|
|
207
|
-
const mtuSize = mtu - 3;
|
|
208
|
-
(0, logs_1.log)("ble-verbose", `BleTransport(${String(this.id)}) mtu set to ${String(mtuSize)}`);
|
|
209
|
-
this.mtuSize = mtuSize;
|
|
199
|
+
async inferMTU() {
|
|
200
|
+
let mtu = 23;
|
|
201
|
+
await this.exchangeAtomicImpl(async () => {
|
|
202
|
+
try {
|
|
203
|
+
mtu =
|
|
204
|
+
(await (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)(this.notifyObservable.pipe((0, operators_1.first)(buffer => buffer.readUInt8(0) === 0x08), (0, operators_1.map)(buffer => buffer.readUInt8(5))), (0, rxjs_1.defer)(() => (0, rxjs_1.from)(this.write(Buffer.from([0x08, 0, 0, 0, 0])))).pipe((0, operators_1.ignoreElements)())))) + 3;
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
(0, logs_1.log)("ble-error", "inferMTU got " + String(e));
|
|
208
|
+
this.device.gatt.disconnect();
|
|
209
|
+
throw e;
|
|
210
210
|
}
|
|
211
|
-
return this.mtuSize;
|
|
212
211
|
});
|
|
212
|
+
if (mtu > 23) {
|
|
213
|
+
const mtuSize = mtu - 3;
|
|
214
|
+
(0, logs_1.log)("ble-verbose", `BleTransport(${String(this.id)}) mtu set to ${String(mtuSize)}`);
|
|
215
|
+
this.mtuSize = mtuSize;
|
|
216
|
+
}
|
|
217
|
+
return this.mtuSize;
|
|
213
218
|
}
|
|
214
219
|
/**
|
|
215
220
|
* Exchange with the device using APDU protocol.
|
|
216
221
|
* @param apdu
|
|
217
222
|
* @returns a promise of apdu response
|
|
218
223
|
*/
|
|
219
|
-
exchange(apdu) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.device.gatt.disconnect();
|
|
235
|
-
}
|
|
236
|
-
throw e;
|
|
224
|
+
async exchange(apdu) {
|
|
225
|
+
const b = await this.exchangeAtomicImpl(async () => {
|
|
226
|
+
try {
|
|
227
|
+
const msgIn = apdu.toString("hex");
|
|
228
|
+
(0, logs_1.log)("apdu", `=> ${msgIn}`);
|
|
229
|
+
const data = await (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)(this.notifyObservable.pipe(receiveAPDU_1.receiveAPDU), (0, sendAPDU_1.sendAPDU)(this.write, apdu, this.mtuSize)));
|
|
230
|
+
const msgOut = data.toString("hex");
|
|
231
|
+
(0, logs_1.log)("apdu", `<= ${msgOut}`);
|
|
232
|
+
return data;
|
|
233
|
+
}
|
|
234
|
+
catch (e) {
|
|
235
|
+
(0, logs_1.log)("ble-error", "exchange got " + String(e));
|
|
236
|
+
if (this.notYetDisconnected) {
|
|
237
|
+
// in such case we will always disconnect because something is bad.
|
|
238
|
+
this.device.gatt.disconnect();
|
|
237
239
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
throw e;
|
|
241
|
+
}
|
|
240
242
|
});
|
|
243
|
+
return b;
|
|
241
244
|
}
|
|
242
245
|
setScrambleKey() { }
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
write = async (buffer) => {
|
|
247
|
+
(0, logs_1.log)("ble-frame", "=> " + buffer.toString("hex"));
|
|
248
|
+
await this.writeCharacteristic.writeValue(buffer);
|
|
249
|
+
};
|
|
250
|
+
async close() {
|
|
251
|
+
if (this.exchangeBusyPromise) {
|
|
252
|
+
await this.exchangeBusyPromise;
|
|
253
|
+
}
|
|
249
254
|
}
|
|
250
255
|
}
|
|
251
|
-
_a = BluetoothTransport;
|
|
252
|
-
BluetoothTransport.isSupported = () => Promise.resolve()
|
|
253
|
-
.then(requiresBluetooth)
|
|
254
|
-
.then(() => true, () => false);
|
|
255
|
-
/**
|
|
256
|
-
* observe event with { available: bool, type: string }
|
|
257
|
-
* (available is generic, type is specific)
|
|
258
|
-
* an event is emit once and then each time it changes
|
|
259
|
-
*/
|
|
260
|
-
BluetoothTransport.observeAvailability = (observer) => availability().subscribe(observer);
|
|
261
|
-
BluetoothTransport.list = () => Promise.resolve([]);
|
|
262
|
-
/**
|
|
263
|
-
* globally disconnect a bluetooth device by its id.
|
|
264
|
-
*/
|
|
265
|
-
BluetoothTransport.disconnect = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
266
|
-
(0, logs_1.log)("ble-verbose", `user disconnect(${id})`);
|
|
267
|
-
const transport = transportsCache[id];
|
|
268
|
-
if (transport) {
|
|
269
|
-
transport.device.gatt.disconnect();
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
256
|
exports.default = BluetoothTransport;
|
|
273
257
|
//# sourceMappingURL=TransportWebBLE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportWebBLE.js","sourceRoot":"","sources":["../src/TransportWebBLE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransportWebBLE.js","sourceRoot":"","sources":["../src/TransportWebBLE.ts"],"names":[],"mappings":";;;;;AAAA,oCAAoC;AACpC,0EAA+C;AAC/C,6CAAkF;AAClF,+CAAqF;AAErF,6DAA0D;AAC1D,mEAAgE;AAChE,yCAAqC;AACrC,+BAAoF;AACpF,8CAAwE;AAExE,mEAAgE;AAEhE,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,aAAa;IACb,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IAEhC,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,GAAwB,EAAE,CAC7C,iBAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;IAC3B,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAC;IAEtC,MAAM,qBAAqB,GAAG,CAAC,CAAC,EAAE;QAChC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,SAAS,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;IACzE,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,SAAS,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC3C,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACV,YAAY,GAAG,IAAI,CAAC;QACpB,SAAS,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;IAC9E,CA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/monitorCharacteristic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monitorCharacteristic.d.ts","sourceRoot":"","sources":["../src/monitorCharacteristic.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,eAAO,MAAM,qBAAqB,mBAAoB,cAAc,KAAG,WAAW,MAAM,CAmBpF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportWebBLE.d.ts","sourceRoot":"","sources":["../src/TransportWebBLE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransportWebBLE.d.ts","sourceRoot":"","sources":["../src/TransportWebBLE.ts"],"names":[],"mappings":";;AACA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAsC,MAAM,MAAM,CAAC;AAEpF,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAqItD;;;;GAIG;AAEH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,SAAS;IACvD,MAAM,CAAC,WAAW,QAAO,QAAQ,OAAO,CAAC,CAMnC;IAEN;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,aAAc,GAAG,KAAG,YAAY,CAAuC;IACjG,MAAM,CAAC,IAAI,QAAO,GAAG,CAAwB;IAE7C;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG;;;IA4B3B;;OAEG;WACU,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAI7C;;OAEG;IACH,MAAM,CAAC,UAAU,OAAc,GAAG,mBAOhC;IACF,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,SAAM;IACb,mBAAmB,EAAE,cAAc,CAAC;IACpC,gBAAgB,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,kBAAkB,UAAQ;IAC1B,WAAW,EAAE,WAAW,CAAC;gBAGvB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,cAAc,EACnC,gBAAgB,EAAE,UAAU,CAAC,GAAG,CAAC,EACjC,WAAW,EAAE,WAAW;IAWpB,QAAQ;IA8Bd;;;;OAIG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0B7C,cAAc;IAEd,KAAK,WAAkB,MAAM,mBAG3B;IAEI,KAAK;CAKZ"}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var _a;
|
|
11
1
|
/* eslint-disable prefer-template */
|
|
12
2
|
import Transport from "@ledgerhq/hw-transport";
|
|
13
3
|
import { DisconnectedDevice, TransportOpenUserCancelled } from "@ledgerhq/errors";
|
|
@@ -49,92 +39,100 @@ const requestDeviceParam = () => ({
|
|
|
49
39
|
services: [uuid],
|
|
50
40
|
})),
|
|
51
41
|
});
|
|
52
|
-
const retrieveService = (device) =>
|
|
42
|
+
const retrieveService = async (device) => {
|
|
53
43
|
if (!device.gatt)
|
|
54
44
|
throw new Error("bluetooth gatt not found");
|
|
55
|
-
const [service] =
|
|
45
|
+
const [service] = await device.gatt.getPrimaryServices();
|
|
56
46
|
if (!service)
|
|
57
47
|
throw new Error("bluetooth service not found");
|
|
58
48
|
const infos = getInfosForServiceUuid(service.uuid);
|
|
59
49
|
if (!infos)
|
|
60
50
|
throw new Error("bluetooth service infos not found");
|
|
61
51
|
return [service, infos];
|
|
62
|
-
}
|
|
63
|
-
function open(deviceOrId, needsReconnect) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return transportsCache[deviceOrId];
|
|
70
|
-
}
|
|
71
|
-
const bluetooth = requiresBluetooth();
|
|
72
|
-
// TODO instead we should "query" the device by its ID
|
|
73
|
-
device = yield bluetooth.requestDevice(requestDeviceParam());
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
device = deviceOrId;
|
|
77
|
-
}
|
|
78
|
-
if (!device.gatt.connected) {
|
|
79
|
-
log("ble-verbose", "not connected. connecting...");
|
|
80
|
-
yield device.gatt.connect();
|
|
81
|
-
}
|
|
82
|
-
const [service, infos] = yield retrieveService(device);
|
|
83
|
-
const { deviceModel, writeUuid, notifyUuid } = infos;
|
|
84
|
-
const [writeC, notifyC] = yield Promise.all([
|
|
85
|
-
service.getCharacteristic(writeUuid),
|
|
86
|
-
service.getCharacteristic(notifyUuid),
|
|
87
|
-
]);
|
|
88
|
-
const notifyObservable = monitorCharacteristic(notifyC).pipe(tap(value => {
|
|
89
|
-
log("ble-frame", "<= " + value.toString("hex"));
|
|
90
|
-
}), share());
|
|
91
|
-
const notif = notifyObservable.subscribe();
|
|
92
|
-
const transport = new BluetoothTransport(device, writeC, notifyObservable, deviceModel);
|
|
93
|
-
if (!device.gatt.connected) {
|
|
94
|
-
throw new DisconnectedDevice();
|
|
95
|
-
}
|
|
96
|
-
// eslint-disable-next-line require-atomic-updates
|
|
97
|
-
transportsCache[transport.id] = transport;
|
|
98
|
-
const onDisconnect = e => {
|
|
99
|
-
console.log("onDisconnect!", e);
|
|
100
|
-
delete transportsCache[transport.id];
|
|
101
|
-
transport.notYetDisconnected = false;
|
|
102
|
-
notif.unsubscribe();
|
|
103
|
-
device.removeEventListener("gattserverdisconnected", onDisconnect);
|
|
104
|
-
log("ble-verbose", `BleTransport(${transport.id}) disconnected`);
|
|
105
|
-
transport.emit("disconnect", e);
|
|
106
|
-
};
|
|
107
|
-
device.addEventListener("gattserverdisconnected", onDisconnect);
|
|
108
|
-
const beforeMTUTime = Date.now();
|
|
109
|
-
try {
|
|
110
|
-
yield transport.inferMTU();
|
|
52
|
+
};
|
|
53
|
+
async function open(deviceOrId, needsReconnect) {
|
|
54
|
+
let device;
|
|
55
|
+
if (typeof deviceOrId === "string") {
|
|
56
|
+
if (transportsCache[deviceOrId]) {
|
|
57
|
+
log("ble-verbose", "Transport in cache, using that.");
|
|
58
|
+
return transportsCache[deviceOrId];
|
|
111
59
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
60
|
+
const bluetooth = requiresBluetooth();
|
|
61
|
+
// TODO instead we should "query" the device by its ID
|
|
62
|
+
device = await bluetooth.requestDevice(requestDeviceParam());
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
device = deviceOrId;
|
|
66
|
+
}
|
|
67
|
+
if (!device.gatt.connected) {
|
|
68
|
+
log("ble-verbose", "not connected. connecting...");
|
|
69
|
+
await device.gatt.connect();
|
|
70
|
+
}
|
|
71
|
+
const [service, infos] = await retrieveService(device);
|
|
72
|
+
const { deviceModel, writeUuid, notifyUuid } = infos;
|
|
73
|
+
const [writeC, notifyC] = await Promise.all([
|
|
74
|
+
service.getCharacteristic(writeUuid),
|
|
75
|
+
service.getCharacteristic(notifyUuid),
|
|
76
|
+
]);
|
|
77
|
+
const notifyObservable = monitorCharacteristic(notifyC).pipe(tap(value => {
|
|
78
|
+
log("ble-frame", "<= " + value.toString("hex"));
|
|
79
|
+
}), share());
|
|
80
|
+
const notif = notifyObservable.subscribe();
|
|
81
|
+
const transport = new BluetoothTransport(device, writeC, notifyObservable, deviceModel);
|
|
82
|
+
if (!device.gatt.connected) {
|
|
83
|
+
throw new DisconnectedDevice();
|
|
84
|
+
}
|
|
85
|
+
// eslint-disable-next-line require-atomic-updates
|
|
86
|
+
transportsCache[transport.id] = transport;
|
|
87
|
+
const onDisconnect = e => {
|
|
88
|
+
console.log("onDisconnect!", e);
|
|
89
|
+
delete transportsCache[transport.id];
|
|
90
|
+
transport.notYetDisconnected = false;
|
|
91
|
+
notif.unsubscribe();
|
|
92
|
+
device.removeEventListener("gattserverdisconnected", onDisconnect);
|
|
93
|
+
log("ble-verbose", `BleTransport(${transport.id}) disconnected`);
|
|
94
|
+
transport.emit("disconnect", e);
|
|
95
|
+
};
|
|
96
|
+
device.addEventListener("gattserverdisconnected", onDisconnect);
|
|
97
|
+
const beforeMTUTime = Date.now();
|
|
98
|
+
try {
|
|
99
|
+
await transport.inferMTU();
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
const afterMTUTime = Date.now();
|
|
103
|
+
// workaround for #279: we need to open() again if we come the first time here,
|
|
104
|
+
// to make sure we do a disconnect() after the first pairing time
|
|
105
|
+
// because of a firmware bug
|
|
106
|
+
if (afterMTUTime - beforeMTUTime < 1000) {
|
|
107
|
+
needsReconnect = false; // (optim) there is likely no new pairing done because mtu answer was fast.
|
|
125
108
|
}
|
|
126
109
|
if (needsReconnect) {
|
|
127
|
-
|
|
110
|
+
await device.gatt.disconnect();
|
|
111
|
+
// necessary time for the bonding workaround
|
|
112
|
+
await new Promise(s => setTimeout(s, 4000));
|
|
128
113
|
}
|
|
129
|
-
|
|
130
|
-
|
|
114
|
+
}
|
|
115
|
+
if (needsReconnect) {
|
|
116
|
+
return open(device, false);
|
|
117
|
+
}
|
|
118
|
+
return transport;
|
|
131
119
|
}
|
|
132
120
|
/**
|
|
133
121
|
* react-native bluetooth BLE implementation
|
|
134
122
|
* @example
|
|
135
123
|
* import BluetoothTransport from "@ledgerhq/hw-transport-web-ble";
|
|
136
124
|
*/
|
|
137
|
-
class BluetoothTransport extends Transport {
|
|
125
|
+
export default class BluetoothTransport extends Transport {
|
|
126
|
+
static isSupported = () => Promise.resolve()
|
|
127
|
+
.then(requiresBluetooth)
|
|
128
|
+
.then(() => true, () => false);
|
|
129
|
+
/**
|
|
130
|
+
* observe event with { available: bool, type: string }
|
|
131
|
+
* (available is generic, type is specific)
|
|
132
|
+
* an event is emit once and then each time it changes
|
|
133
|
+
*/
|
|
134
|
+
static observeAvailability = (observer) => availability().subscribe(observer);
|
|
135
|
+
static list = () => Promise.resolve([]);
|
|
138
136
|
/**
|
|
139
137
|
* Scan for Ledger Bluetooth devices.
|
|
140
138
|
* On this web implementation, it only emits ONE device, the one that was selected in the UI (if any).
|
|
@@ -164,19 +162,28 @@ class BluetoothTransport extends Transport {
|
|
|
164
162
|
/**
|
|
165
163
|
* open a bluetooth device.
|
|
166
164
|
*/
|
|
167
|
-
static open(deviceOrId) {
|
|
168
|
-
return
|
|
169
|
-
return open(deviceOrId, true);
|
|
170
|
-
});
|
|
165
|
+
static async open(deviceOrId) {
|
|
166
|
+
return open(deviceOrId, true);
|
|
171
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* globally disconnect a bluetooth device by its id.
|
|
170
|
+
*/
|
|
171
|
+
static disconnect = async (id) => {
|
|
172
|
+
log("ble-verbose", `user disconnect(${id})`);
|
|
173
|
+
const transport = transportsCache[id];
|
|
174
|
+
if (transport) {
|
|
175
|
+
transport.device.gatt.disconnect();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
id;
|
|
179
|
+
device;
|
|
180
|
+
mtuSize = 20;
|
|
181
|
+
writeCharacteristic;
|
|
182
|
+
notifyObservable;
|
|
183
|
+
notYetDisconnected = true;
|
|
184
|
+
deviceModel;
|
|
172
185
|
constructor(device, writeCharacteristic, notifyObservable, deviceModel) {
|
|
173
186
|
super();
|
|
174
|
-
this.mtuSize = 20;
|
|
175
|
-
this.notYetDisconnected = true;
|
|
176
|
-
this.write = (buffer) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
log("ble-frame", "=> " + buffer.toString("hex"));
|
|
178
|
-
yield this.writeCharacteristic.writeValue(buffer);
|
|
179
|
-
});
|
|
180
187
|
this.id = device.id;
|
|
181
188
|
this.device = device;
|
|
182
189
|
this.writeCharacteristic = writeCharacteristic;
|
|
@@ -184,85 +191,61 @@ class BluetoothTransport extends Transport {
|
|
|
184
191
|
this.deviceModel = deviceModel;
|
|
185
192
|
log("ble-verbose", `BleTransport(${String(this.id)}) new instance`);
|
|
186
193
|
}
|
|
187
|
-
inferMTU() {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
throw e;
|
|
199
|
-
}
|
|
200
|
-
}));
|
|
201
|
-
if (mtu > 23) {
|
|
202
|
-
const mtuSize = mtu - 3;
|
|
203
|
-
log("ble-verbose", `BleTransport(${String(this.id)}) mtu set to ${String(mtuSize)}`);
|
|
204
|
-
this.mtuSize = mtuSize;
|
|
194
|
+
async inferMTU() {
|
|
195
|
+
let mtu = 23;
|
|
196
|
+
await this.exchangeAtomicImpl(async () => {
|
|
197
|
+
try {
|
|
198
|
+
mtu =
|
|
199
|
+
(await firstValueFrom(merge(this.notifyObservable.pipe(first(buffer => buffer.readUInt8(0) === 0x08), map(buffer => buffer.readUInt8(5))), defer(() => from(this.write(Buffer.from([0x08, 0, 0, 0, 0])))).pipe(ignoreElements())))) + 3;
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
log("ble-error", "inferMTU got " + String(e));
|
|
203
|
+
this.device.gatt.disconnect();
|
|
204
|
+
throw e;
|
|
205
205
|
}
|
|
206
|
-
return this.mtuSize;
|
|
207
206
|
});
|
|
207
|
+
if (mtu > 23) {
|
|
208
|
+
const mtuSize = mtu - 3;
|
|
209
|
+
log("ble-verbose", `BleTransport(${String(this.id)}) mtu set to ${String(mtuSize)}`);
|
|
210
|
+
this.mtuSize = mtuSize;
|
|
211
|
+
}
|
|
212
|
+
return this.mtuSize;
|
|
208
213
|
}
|
|
209
214
|
/**
|
|
210
215
|
* Exchange with the device using APDU protocol.
|
|
211
216
|
* @param apdu
|
|
212
217
|
* @returns a promise of apdu response
|
|
213
218
|
*/
|
|
214
|
-
exchange(apdu) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.device.gatt.disconnect();
|
|
230
|
-
}
|
|
231
|
-
throw e;
|
|
219
|
+
async exchange(apdu) {
|
|
220
|
+
const b = await this.exchangeAtomicImpl(async () => {
|
|
221
|
+
try {
|
|
222
|
+
const msgIn = apdu.toString("hex");
|
|
223
|
+
log("apdu", `=> ${msgIn}`);
|
|
224
|
+
const data = await firstValueFrom(merge(this.notifyObservable.pipe(receiveAPDU), sendAPDU(this.write, apdu, this.mtuSize)));
|
|
225
|
+
const msgOut = data.toString("hex");
|
|
226
|
+
log("apdu", `<= ${msgOut}`);
|
|
227
|
+
return data;
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
log("ble-error", "exchange got " + String(e));
|
|
231
|
+
if (this.notYetDisconnected) {
|
|
232
|
+
// in such case we will always disconnect because something is bad.
|
|
233
|
+
this.device.gatt.disconnect();
|
|
232
234
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
+
throw e;
|
|
236
|
+
}
|
|
235
237
|
});
|
|
238
|
+
return b;
|
|
236
239
|
}
|
|
237
240
|
setScrambleKey() { }
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
write = async (buffer) => {
|
|
242
|
+
log("ble-frame", "=> " + buffer.toString("hex"));
|
|
243
|
+
await this.writeCharacteristic.writeValue(buffer);
|
|
244
|
+
};
|
|
245
|
+
async close() {
|
|
246
|
+
if (this.exchangeBusyPromise) {
|
|
247
|
+
await this.exchangeBusyPromise;
|
|
248
|
+
}
|
|
244
249
|
}
|
|
245
250
|
}
|
|
246
|
-
_a = BluetoothTransport;
|
|
247
|
-
BluetoothTransport.isSupported = () => Promise.resolve()
|
|
248
|
-
.then(requiresBluetooth)
|
|
249
|
-
.then(() => true, () => false);
|
|
250
|
-
/**
|
|
251
|
-
* observe event with { available: bool, type: string }
|
|
252
|
-
* (available is generic, type is specific)
|
|
253
|
-
* an event is emit once and then each time it changes
|
|
254
|
-
*/
|
|
255
|
-
BluetoothTransport.observeAvailability = (observer) => availability().subscribe(observer);
|
|
256
|
-
BluetoothTransport.list = () => Promise.resolve([]);
|
|
257
|
-
/**
|
|
258
|
-
* globally disconnect a bluetooth device by its id.
|
|
259
|
-
*/
|
|
260
|
-
BluetoothTransport.disconnect = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
|
-
log("ble-verbose", `user disconnect(${id})`);
|
|
262
|
-
const transport = transportsCache[id];
|
|
263
|
-
if (transport) {
|
|
264
|
-
transport.device.gatt.disconnect();
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
export default BluetoothTransport;
|
|
268
251
|
//# sourceMappingURL=TransportWebBLE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransportWebBLE.js","sourceRoot":"","sources":["../src/TransportWebBLE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransportWebBLE.js","sourceRoot":"","sources":["../src/TransportWebBLE.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AA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
|
1
|
-
{"version":3,"file":"monitorCharacteristic.d.ts","sourceRoot":"","sources":["../src/monitorCharacteristic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monitorCharacteristic.d.ts","sourceRoot":"","sources":["../src/monitorCharacteristic.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,eAAO,MAAM,qBAAqB,mBAAoB,cAAc,KAAG,WAAW,MAAM,CAmBpF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-transport-web-ble",
|
|
3
|
-
"version": "6.29.
|
|
3
|
+
"version": "6.29.5-next.0",
|
|
4
4
|
"description": "Ledger Hardware Wallet Web Bluetooth implementation of the communication layer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"rxjs": "^7.8.1",
|
|
31
|
-
"@ledgerhq/devices": "
|
|
32
|
-
"@ledgerhq/errors": "^6.
|
|
33
|
-
"@ledgerhq/hw-transport": "^6.31.
|
|
31
|
+
"@ledgerhq/devices": "8.4.5-next.0",
|
|
32
|
+
"@ledgerhq/errors": "^6.21.0-next.0",
|
|
33
|
+
"@ledgerhq/hw-transport": "^6.31.5-next.0",
|
|
34
34
|
"@ledgerhq/logs": "^6.12.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jest": "^29.5.10",
|
|
38
|
-
"@types/node": "^
|
|
38
|
+
"@types/node": "^22.10.10",
|
|
39
39
|
"@types/web-bluetooth": "^0.0.20",
|
|
40
40
|
"documentation": "14.0.2",
|
|
41
41
|
"jest": "^29.7.0",
|
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
"gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec",
|
|
48
48
|
"scripts": {
|
|
49
49
|
"clean": "rimraf lib lib-es",
|
|
50
|
-
"build": "tsc && tsc -m
|
|
50
|
+
"build": "tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es",
|
|
51
51
|
"prewatch": "pnpm build",
|
|
52
52
|
"watch": "tsc --watch",
|
|
53
|
+
"watch:es": "tsc --watch -m esnext --moduleResolution bundler --outDir lib-es",
|
|
53
54
|
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
|
|
54
55
|
"lint:fix": "pnpm lint --fix",
|
|
55
56
|
"test": "jest",
|