@onekeyfe/hd-transport-web-device 1.2.8-alpha.51 → 1.2.8-alpha.53

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.
@@ -102,7 +102,7 @@ describe('WebUsbTransport Protocol V2 timeout recovery', () => {
102
102
  expect(webusb.deviceProtocol.get(path)).toBe('V2');
103
103
  });
104
104
 
105
- test('reports DeviceNotFound when automatic protocol detection exhausts both probes', async () => {
105
+ test('reports a typed probe failure when automatic detection exhausts both protocols', async () => {
106
106
  const webusb = new WebUsbTransport() as any;
107
107
  const path = 'unresponsive-webusb';
108
108
  webusb.probeProtocolV1 = jest.fn().mockResolvedValue(false);
@@ -111,7 +111,7 @@ describe('WebUsbTransport Protocol V2 timeout recovery', () => {
111
111
  webusb.closeConnectionAfterProbe = jest.fn().mockResolvedValue(undefined);
112
112
 
113
113
  await expect(webusb.detectProtocol(path)).rejects.toMatchObject({
114
- errorCode: HardwareErrorCode.DeviceNotFound,
114
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
115
115
  });
116
116
 
117
117
  expect(webusb.probeProtocolV1).toHaveBeenCalledTimes(1);
@@ -154,7 +154,20 @@ describe('WebUsbTransport Protocol V2 timeout recovery', () => {
154
154
  expect(webusb.deviceProtocol.get(path)).toBe('V2');
155
155
  });
156
156
 
157
- test('reports a device initialization failure only after the bounded retry is exhausted', async () => {
157
+ test('reports a strict V1 probe miss without falling back to another protocol', async () => {
158
+ const webusb = new WebUsbTransport() as any;
159
+ webusb.probeProtocolV1 = jest.fn().mockResolvedValue(false);
160
+ webusb.probeProtocolV2 = jest.fn();
161
+ webusb.closeConnectionAfterProbe = jest.fn().mockResolvedValue(undefined);
162
+ await expect(webusb.detectProtocol('classic-webusb', 'V1')).rejects.toMatchObject({
163
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
164
+ params: { expectedProtocol: 'V1' },
165
+ });
166
+ expect(webusb.probeProtocolV2).not.toHaveBeenCalled();
167
+ expect(webusb.closeConnectionAfterProbe).toHaveBeenCalledTimes(1);
168
+ });
169
+
170
+ test('reports a typed protocol probe failure only after the bounded retry is exhausted', async () => {
158
171
  const webusb = new WebUsbTransport() as any;
159
172
  const path = 'pro2-webusb';
160
173
  webusb.probeProtocolV1 = jest.fn();
@@ -163,8 +176,8 @@ describe('WebUsbTransport Protocol V2 timeout recovery', () => {
163
176
  webusb.closeConnectionAfterProbe = jest.fn().mockResolvedValue(undefined);
164
177
 
165
178
  await expect(webusb.detectProtocol(path, 'V2')).rejects.toMatchObject({
166
- errorCode: HardwareErrorCode.DeviceInitializeFailed,
167
- message: 'Protocol V2 probe timeout after 2 attempts',
179
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
180
+ params: { expectedProtocol: 'V2', attempts: 2 },
168
181
  });
169
182
 
170
183
  expect(webusb.probeProtocolV2).toHaveBeenCalledTimes(2);
@@ -1 +1 @@
1
- {"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";AAyBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAA4B,MAAM,iCAAiC,CAAC;AAC5F,OAAO,KAAK,EACV,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;CAC7B,CAAC;AAiDF,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,OAAO,CAAC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C,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;IA0B5B,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
@@ -31,6 +31,9 @@ declare class WebUsbTransport extends ProtocolV2UsbTransportBase<string> {
31
31
  /** Paths currently acquired (between a successful acquire() and its release()). */
32
32
  private acquiredPaths;
33
33
  private identityProbeDevices;
34
+ private normalDevices;
35
+ private pendingHandleOperations;
36
+ private stopPromise?;
34
37
  private identityProbeCleanupPaths;
35
38
  /**
36
39
  * The exact USBDevice object each cached protocol was probed against. The
@@ -61,6 +64,10 @@ declare class WebUsbTransport extends ProtocolV2UsbTransportBase<string> {
61
64
  * Initialize WebUSB transport
62
65
  */
63
66
  init(logger: any, emitter?: EventEmitter): void;
67
+ stop(): Promise<void>;
68
+ private stopResources;
69
+ private assertRunning;
70
+ private runHandleOperation;
64
71
  /**
65
72
  * Announce that a USB device left. Called from the module-scoped disconnect
66
73
  * listener, which is why it is public rather than inlined.
@@ -133,6 +140,9 @@ declare class WebUsbTransport extends ProtocolV2UsbTransportBase<string> {
133
140
  */
134
141
  connectToDevice(path: string, first: boolean): Promise<undefined>;
135
142
  private assertHandleAvailable;
143
+ private claimNormalHandle;
144
+ private releaseNormalHandles;
145
+ private isHandleOwnershipError;
136
146
  private claimIdentityProbeHandle;
137
147
  private releaseIdentityProbeHandle;
138
148
  private closeOpenDevice;
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ const REPORT_ID = transport.PROTOCOL_V1_REPORT_ID;
51
51
  const HEADER_LENGTH = transport.PROTOCOL_V1_MESSAGE_HEADER_SIZE;
52
52
  const PACKET_IO_MAX_RETRIES = 3;
53
53
  const PACKET_IO_RETRY_DELAY = 300;
54
+ const USB_DEVICE_IN_USE = 'USB device is already in use';
54
55
  const PROTOCOL_V1_PROBE_TIMEOUT = 5000;
55
56
  const PROTOCOL_V2_PROBE_TIMEOUT = 1000;
56
57
  const EXPECTED_PROTOCOL_V2_PROBE_ATTEMPTS = 2;
@@ -58,6 +59,7 @@ let activeWebUsbTransport;
58
59
  let usbDisconnectListenerAttached = false;
59
60
  const identityProbeHandles = new WeakSet();
60
61
  const openingHandles = new WeakSet();
62
+ const normalHandleOwners = new WeakMap();
61
63
  function registerActiveWebUsbTransport(instance, usb) {
62
64
  activeWebUsbTransport = instance;
63
65
  if (usbDisconnectListenerAttached)
@@ -87,6 +89,8 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
87
89
  this.staleProtocolPaths = new Set();
88
90
  this.acquiredPaths = new Set();
89
91
  this.identityProbeDevices = new Map();
92
+ this.normalDevices = new Map();
93
+ this.pendingHandleOperations = new Set();
90
94
  this.identityProbeCleanupPaths = new Set();
91
95
  this.probedDeviceObjects = new Map();
92
96
  this.deviceEndpoints = new Map();
@@ -109,6 +113,102 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
109
113
  if (!this.identityProbe)
110
114
  registerActiveWebUsbTransport(this, usb);
111
115
  }
116
+ stop() {
117
+ this.stopped = true;
118
+ this.acquiredPaths.clear();
119
+ if (activeWebUsbTransport === this)
120
+ activeWebUsbTransport = undefined;
121
+ if (!this.stopPromise) {
122
+ this.stopPromise = this.stopResources().catch(error => {
123
+ this.stopPromise = undefined;
124
+ throw error;
125
+ });
126
+ }
127
+ return this.stopPromise;
128
+ }
129
+ stopResources() {
130
+ var _a, _b, _c;
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ let cleanupError;
133
+ try {
134
+ yield this.disposeProtocolV2UsbLinks('WebUSB transport stopped');
135
+ }
136
+ catch (error) {
137
+ cleanupError = error;
138
+ }
139
+ yield Promise.allSettled([...this.pendingHandleOperations]);
140
+ const handles = this.identityProbe
141
+ ? [...this.identityProbeDevices].map(([path, device]) => [device, path])
142
+ : [...this.normalDevices];
143
+ for (const [device, path] of handles) {
144
+ if (!this.identityProbe && normalHandleOwners.get(device) !== this) {
145
+ this.normalDevices.delete(device);
146
+ }
147
+ else {
148
+ try {
149
+ if (device.opened) {
150
+ const iface = (_b = (_a = this.deviceEndpoints.get(path)) === null || _a === void 0 ? void 0 : _a.interfaceNumber) !== null && _b !== void 0 ? _b : this.interfaceId;
151
+ try {
152
+ yield device.releaseInterface(iface);
153
+ }
154
+ catch (error) {
155
+ (_c = this.Log) === null || _c === void 0 ? void 0 : _c.debug('[WebUsbTransport] stop releaseInterface failed:', error);
156
+ }
157
+ yield device.close();
158
+ if (device.opened)
159
+ throw new Error('WebUSB handle remains open after stop');
160
+ }
161
+ if (this.identityProbe) {
162
+ identityProbeHandles.delete(device);
163
+ this.identityProbeDevices.delete(path);
164
+ this.identityProbeCleanupPaths.delete(path);
165
+ }
166
+ else {
167
+ normalHandleOwners.delete(device);
168
+ this.normalDevices.delete(device);
169
+ }
170
+ }
171
+ catch (error) {
172
+ cleanupError !== null && cleanupError !== void 0 ? cleanupError : (cleanupError = error);
173
+ }
174
+ }
175
+ }
176
+ this.deviceList = [];
177
+ this.deviceProtocol.clear();
178
+ this.confirmedDeviceProtocols.clear();
179
+ this.deviceProtocolHints.clear();
180
+ this.staleProtocolPaths.clear();
181
+ this.probedDeviceObjects.clear();
182
+ if (!this.normalDevices.size && !this.identityProbeDevices.size) {
183
+ this.deviceEndpoints.clear();
184
+ }
185
+ if (cleanupError) {
186
+ throw cleanupError instanceof Error
187
+ ? cleanupError
188
+ : new Error(this.getErrorMessage(cleanupError));
189
+ }
190
+ });
191
+ }
192
+ assertRunning() {
193
+ if (this.stopped) {
194
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'WebUSB transport is stopped');
195
+ }
196
+ }
197
+ runHandleOperation(operation) {
198
+ return __awaiter(this, void 0, void 0, function* () {
199
+ this.assertRunning();
200
+ const pending = Promise.resolve(operation());
201
+ this.pendingHandleOperations.add(pending);
202
+ try {
203
+ const result = yield pending;
204
+ this.assertRunning();
205
+ return result;
206
+ }
207
+ finally {
208
+ this.pendingHandleOperations.delete(pending);
209
+ }
210
+ });
211
+ }
112
212
  emitDeviceDisconnect(path, device) {
113
213
  var _a, _b;
114
214
  (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.emit(transport.TRANSPORT_EVENT.DEVICE_DISCONNECT, {
@@ -168,10 +268,24 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
168
268
  });
169
269
  }
170
270
  getConnectedDevices() {
271
+ var _a;
171
272
  return __awaiter(this, void 0, void 0, function* () {
273
+ this.assertRunning();
172
274
  if (!this.usb)
173
275
  return [];
174
276
  const devices = yield this.usb.getDevices();
277
+ this.assertRunning();
278
+ for (const owner of new Set(devices.map(device => normalHandleOwners.get(device)))) {
279
+ if (owner === null || owner === void 0 ? void 0 : owner.stopped) {
280
+ try {
281
+ yield owner.stop();
282
+ }
283
+ catch (error) {
284
+ (_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('[WebUsbTransport] stopped owner cleanup failed:', error);
285
+ }
286
+ }
287
+ }
288
+ this.assertRunning();
175
289
  const onekeyDevices = devices.filter(dev => {
176
290
  const isOneKey = hdShared.ONEKEY_WEBUSB_FILTER.some((desc) => dev.vendorId === desc.vendorId && dev.productId === desc.productId);
177
291
  return isOneKey && !hdShared.isKnownTrezorWebUsbDevice(dev);
@@ -198,12 +312,16 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
198
312
  acquire(input) {
199
313
  var _a, _b, _c, _d, _e, _f, _g;
200
314
  return __awaiter(this, void 0, void 0, function* () {
315
+ this.assertRunning();
201
316
  if (!input.path)
202
317
  return;
203
318
  if (this.identityProbe) {
204
319
  yield this.getConnectedDevices();
205
320
  this.claimIdentityProbeHandle(input.path, yield this.findDevice(input.path));
206
321
  }
322
+ else {
323
+ this.claimNormalHandle(input.path, yield this.findDevice(input.path));
324
+ }
207
325
  try {
208
326
  yield this.rotateProtocolV2UsbGeneration(input.path, 'WebUSB transport acquired');
209
327
  yield this.closeOpenDevice(input.path);
@@ -253,12 +371,14 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
253
371
  this.deviceProtocolHints.set(input.path, protocolHint);
254
372
  }
255
373
  const detectedProtocol = yield this.detectProtocol(input.path, input.expectedProtocol, protocolHint);
374
+ this.assertRunning();
256
375
  this.confirmedDeviceProtocols.set(input.path, detectedProtocol);
257
376
  const probedDevice = (_g = this.deviceList.find(d => d.path === input.path)) === null || _g === void 0 ? void 0 : _g.device;
258
377
  if (probedDevice) {
259
378
  this.probedDeviceObjects.set(input.path, probedDevice);
260
379
  }
261
380
  }
381
+ this.assertRunning();
262
382
  this.acquiredPaths.add(input.path);
263
383
  return yield Promise.resolve(input.path);
264
384
  }
@@ -270,19 +390,25 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
270
390
  }
271
391
  finally {
272
392
  this.releaseIdentityProbeHandle(input.path);
393
+ this.releaseNormalHandles(input.path);
273
394
  }
274
395
  throw e;
275
396
  }
276
397
  });
277
398
  }
278
399
  createProtocolMismatchError(expected) {
279
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
400
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportProtocolProbeFailed, undefined, {
401
+ expectedProtocol: expected,
402
+ });
280
403
  }
281
404
  createProtocolProbeTimeoutError(expected, attempts) {
282
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Protocol ${expected} probe timeout after ${attempts} attempts`);
405
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportProtocolProbeFailed, undefined, {
406
+ expectedProtocol: expected,
407
+ attempts,
408
+ });
283
409
  }
284
410
  createProtocolDetectionError() {
285
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
411
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportProtocolProbeFailed);
286
412
  }
287
413
  detectProtocol(path, expectedProtocol, protocolHint) {
288
414
  var _a;
@@ -350,10 +476,12 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
350
476
  return __awaiter(this, void 0, void 0, function* () {
351
477
  const maxRetries = 5;
352
478
  for (let i = 0; i < maxRetries; i++) {
479
+ this.assertRunning();
353
480
  try {
354
481
  return yield this.connectToDevice(path, first);
355
482
  }
356
483
  catch (e) {
484
+ this.assertRunning();
357
485
  if (e instanceof hdShared.HardwareError && e.errorCode === hdShared.HardwareErrorCode.BridgeNeedsPermission) {
358
486
  throw e;
359
487
  }
@@ -396,17 +524,20 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
396
524
  connectToDevice(path, first) {
397
525
  var _a;
398
526
  return __awaiter(this, void 0, void 0, function* () {
527
+ this.assertRunning();
399
528
  let device = yield this.findDevice(path);
400
529
  if (this.identityProbe && this.identityProbeDevices.get(path) !== device) {
401
530
  yield this.closeOpenDevice(path);
402
531
  this.releaseIdentityProbeHandle(path);
403
532
  this.claimIdentityProbeHandle(path, device);
404
533
  }
534
+ if (!this.identityProbe)
535
+ this.claimNormalHandle(path, device);
405
536
  this.assertHandleAvailable(device);
406
537
  if (!device.opened) {
407
538
  openingHandles.add(device);
408
539
  try {
409
- yield device.open();
540
+ yield this.runHandleOperation(() => device.open());
410
541
  }
411
542
  catch (error) {
412
543
  return yield this.throwWebUsbIoError(path, 'open', error);
@@ -417,9 +548,10 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
417
548
  }
418
549
  if (first || this.deviceProtocol.get(path) !== 'V1') {
419
550
  try {
420
- yield device.reset();
551
+ yield this.runHandleOperation(() => device.reset());
421
552
  }
422
553
  catch (error) {
554
+ this.assertRunning();
423
555
  (_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('[WebUsbTransport] reset before claim failed, continuing:', error);
424
556
  }
425
557
  }
@@ -430,11 +562,13 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
430
562
  this.releaseIdentityProbeHandle(path);
431
563
  this.claimIdentityProbeHandle(path, device);
432
564
  }
565
+ if (!this.identityProbe)
566
+ this.claimNormalHandle(path, device);
433
567
  this.assertHandleAvailable(device);
434
568
  if (!device.opened) {
435
569
  openingHandles.add(device);
436
570
  try {
437
- yield device.open();
571
+ yield this.runHandleOperation(() => device.open());
438
572
  }
439
573
  catch (error) {
440
574
  return yield this.throwWebUsbIoError(path, 'open', error);
@@ -446,12 +580,12 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
446
580
  if (first ||
447
581
  !device.configuration ||
448
582
  device.configuration.configurationValue !== this.configurationId) {
449
- yield device.selectConfiguration(this.configurationId);
583
+ yield this.runHandleOperation(() => device.selectConfiguration(this.configurationId));
450
584
  }
451
585
  const endpoints = this.discoverEndpoints(device);
452
586
  this.deviceEndpoints.set(path, endpoints);
453
587
  try {
454
- yield device.claimInterface(endpoints.interfaceNumber);
588
+ yield this.runHandleOperation(() => device.claimInterface(endpoints.interfaceNumber));
455
589
  }
456
590
  catch (error) {
457
591
  return this.throwWebUsbIoError(path, 'claimInterface', error);
@@ -461,19 +595,48 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
461
595
  });
462
596
  }
463
597
  assertHandleAvailable(device) {
464
- if (identityProbeHandles.has(device) &&
465
- ![...this.identityProbeDevices.values()].includes(device)) {
466
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'USB device is already in use');
598
+ this.assertRunning();
599
+ const normalOwner = normalHandleOwners.get(device);
600
+ if ((normalOwner && normalOwner !== this) ||
601
+ (identityProbeHandles.has(device) &&
602
+ ![...this.identityProbeDevices.values()].includes(device))) {
603
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, USB_DEVICE_IN_USE);
467
604
  }
468
605
  }
606
+ claimNormalHandle(path, device) {
607
+ this.assertHandleAvailable(device);
608
+ normalHandleOwners.set(device, this);
609
+ this.normalDevices.set(device, path);
610
+ }
611
+ releaseNormalHandles(path) {
612
+ if (this.stopped)
613
+ return;
614
+ for (const [device, ownedPath] of this.normalDevices) {
615
+ if (ownedPath === path) {
616
+ normalHandleOwners.delete(device);
617
+ this.normalDevices.delete(device);
618
+ }
619
+ }
620
+ }
621
+ isHandleOwnershipError(error) {
622
+ return (error instanceof hdShared.HardwareError &&
623
+ error.errorCode === hdShared.HardwareErrorCode.RuntimeError &&
624
+ this.getErrorMessage(error).includes(USB_DEVICE_IN_USE));
625
+ }
469
626
  claimIdentityProbeHandle(path, device) {
470
- if (device.opened || openingHandles.has(device) || identityProbeHandles.has(device)) {
471
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'USB device is already in use');
627
+ this.assertRunning();
628
+ if (device.opened ||
629
+ openingHandles.has(device) ||
630
+ identityProbeHandles.has(device) ||
631
+ normalHandleOwners.has(device)) {
632
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, USB_DEVICE_IN_USE);
472
633
  }
473
634
  identityProbeHandles.add(device);
474
635
  this.identityProbeDevices.set(path, device);
475
636
  }
476
637
  releaseIdentityProbeHandle(path) {
638
+ if (this.stopped)
639
+ return;
477
640
  const device = this.identityProbeDevices.get(path);
478
641
  if (device === null || device === void 0 ? void 0 : device.opened) {
479
642
  this.identityProbeCleanupPaths.add(path);
@@ -487,6 +650,8 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
487
650
  closeOpenDevice(path) {
488
651
  var _a, _b, _c, _d;
489
652
  return __awaiter(this, void 0, void 0, function* () {
653
+ if (this.stopped)
654
+ return;
490
655
  const current = this.identityProbe
491
656
  ? this.identityProbeDevices.get(path)
492
657
  : (_a = this.deviceList.find(device => device.path === path)) === null || _a === void 0 ? void 0 : _a.device;
@@ -496,13 +661,14 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
496
661
  const endpoints = this.deviceEndpoints.get(path);
497
662
  const ifaceNum = (_b = endpoints === null || endpoints === void 0 ? void 0 : endpoints.interfaceNumber) !== null && _b !== void 0 ? _b : this.interfaceId;
498
663
  try {
499
- yield current.releaseInterface(ifaceNum);
664
+ yield this.runHandleOperation(() => current.releaseInterface(ifaceNum));
500
665
  }
501
666
  catch (error) {
502
667
  (_c = this.Log) === null || _c === void 0 ? void 0 : _c.debug('[WebUsbTransport] releaseInterface before reconnect failed:', error);
503
668
  }
669
+ this.assertHandleAvailable(current);
504
670
  try {
505
- yield current.close();
671
+ yield this.runHandleOperation(() => current.close());
506
672
  }
507
673
  catch (error) {
508
674
  (_d = this.Log) === null || _d === void 0 ? void 0 : _d.debug('[WebUsbTransport] close before reconnect failed:', error);
@@ -514,15 +680,18 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
514
680
  clearEndpointHalt(device, direction, endpointNumber) {
515
681
  var _a;
516
682
  return __awaiter(this, void 0, void 0, function* () {
683
+ this.assertHandleAvailable(device);
517
684
  try {
518
- yield device.clearHalt(direction, endpointNumber);
685
+ yield this.runHandleOperation(() => device.clearHalt(direction, endpointNumber));
519
686
  }
520
687
  catch (error) {
688
+ this.assertRunning();
521
689
  (_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug(`[WebUsbTransport] clearHalt ${direction} endpoint ${endpointNumber} failed, continuing:`, error);
522
690
  }
523
691
  });
524
692
  }
525
693
  assertAcquired(path) {
694
+ this.assertRunning();
526
695
  if (!this.acquiredPaths.has(path)) {
527
696
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device is not acquired for ${path}`);
528
697
  }
@@ -579,7 +748,8 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
579
748
  throwWebUsbIoError(path, operation, error) {
580
749
  var _a;
581
750
  return __awaiter(this, void 0, void 0, function* () {
582
- if (this.isWebUsbIoHardwareError(error))
751
+ this.assertRunning();
752
+ if (this.isHandleOwnershipError(error) || this.isWebUsbIoHardwareError(error))
583
753
  throw error;
584
754
  if (error instanceof transport.ProtocolV2LinkError && error.code !== 'io')
585
755
  throw error;
@@ -613,7 +783,9 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
613
783
  return /LIBUSB_ERROR_ACCESS|\b(?:access|permission) denied\b/i.test(message);
614
784
  }
615
785
  isRetryablePacketIoError(error) {
616
- if (this.isWebUsbIoHardwareError(error))
786
+ if (this.stopped)
787
+ return false;
788
+ if (this.isHandleOwnershipError(error) || this.isWebUsbIoHardwareError(error))
617
789
  return false;
618
790
  const message = this.getErrorMessage(error).toLowerCase();
619
791
  if (this.isWebUsbPermissionDeniedMessage(message))
@@ -632,21 +804,27 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
632
804
  this.Log.debug(`[WebUsbTransport] transfer${direction} failed, retry ${attempt}/${PACKET_IO_MAX_RETRIES}: ${this.getErrorMessage(error)}`);
633
805
  this.staleProtocolPaths.add(path);
634
806
  yield hdShared.wait(attempt * PACKET_IO_RETRY_DELAY);
807
+ this.assertRunning();
635
808
  try {
636
809
  const currentDevice = yield this.findDevice(path);
810
+ this.assertHandleAvailable(currentDevice);
637
811
  if (currentDevice.opened) {
638
812
  const endpoints = this.deviceEndpoints.get(path);
639
813
  const ifaceNum = (_a = endpoints === null || endpoints === void 0 ? void 0 : endpoints.interfaceNumber) !== null && _a !== void 0 ? _a : this.interfaceId;
640
814
  try {
641
- yield currentDevice.releaseInterface(ifaceNum);
815
+ yield this.runHandleOperation(() => currentDevice.releaseInterface(ifaceNum));
642
816
  }
643
817
  catch (releaseError) {
644
818
  this.Log.debug('[WebUsbTransport] releaseInterface before retry error:', releaseError);
645
819
  }
646
- yield currentDevice.close();
820
+ this.assertHandleAvailable(currentDevice);
821
+ yield this.runHandleOperation(() => currentDevice.close());
647
822
  }
648
823
  }
649
824
  catch (closeError) {
825
+ this.assertRunning();
826
+ if (this.isHandleOwnershipError(closeError))
827
+ throw closeError;
650
828
  this.Log.debug('[WebUsbTransport] close device before retry error:', closeError);
651
829
  }
652
830
  yield this.getConnectedDevices();
@@ -688,6 +866,9 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
688
866
  yield this.reconnectForPacketIoRetry(path, 'out', attempt, error);
689
867
  }
690
868
  catch (reconnectError) {
869
+ this.assertRunning();
870
+ if (this.isHandleOwnershipError(reconnectError))
871
+ throw reconnectError;
691
872
  lastError = reconnectError;
692
873
  this.Log.debug(`[WebUsbTransport] transferout reconnect failed on retry ${attempt}/${PACKET_IO_MAX_RETRIES}: ${this.getErrorMessage(reconnectError)}`);
693
874
  }
@@ -706,7 +887,9 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
706
887
  const endpoints = this.deviceEndpoints.get(path);
707
888
  const endpointOut = (_a = endpoints === null || endpoints === void 0 ? void 0 : endpoints.endpointOut) !== null && _a !== void 0 ? _a : this.endpointId;
708
889
  const transferBuffer = this.toArrayBuffer(packet.buffer.slice(packet.byteOffset, packet.byteOffset + packet.byteLength));
890
+ this.assertHandleAvailable(device);
709
891
  const result = yield device.transferOut(endpointOut, transferBuffer);
892
+ this.assertHandleAvailable(device);
710
893
  if (result.status !== 'ok') {
711
894
  return this.throwWebUsbIoError(path, 'transferOut', new Error(`transferOut status: ${String(result.status)}`));
712
895
  }
@@ -727,7 +910,9 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
727
910
  }
728
911
  const endpoints = this.deviceEndpoints.get(path);
729
912
  const endpointIn = (_a = endpoints === null || endpoints === void 0 ? void 0 : endpoints.endpointIn) !== null && _a !== void 0 ? _a : this.endpointId;
913
+ this.assertHandleAvailable(device);
730
914
  const result = yield device.transferIn(endpointIn, length);
915
+ this.assertHandleAvailable(device);
731
916
  return this.getTransferInData(result);
732
917
  }
733
918
  catch (error) {
@@ -743,6 +928,9 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
743
928
  yield this.reconnectForPacketIoRetry(path, 'in', attempt, error);
744
929
  }
745
930
  catch (reconnectError) {
931
+ this.assertRunning();
932
+ if (this.isHandleOwnershipError(reconnectError))
933
+ throw reconnectError;
746
934
  lastError = reconnectError;
747
935
  this.Log.debug(`[WebUsbTransport] transferin reconnect failed on retry ${attempt}/${PACKET_IO_MAX_RETRIES}: ${this.getErrorMessage(reconnectError)}`);
748
936
  }
@@ -760,7 +948,9 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
760
948
  }
761
949
  const endpoints = this.deviceEndpoints.get(path);
762
950
  const endpointIn = (_a = endpoints === null || endpoints === void 0 ? void 0 : endpoints.endpointIn) !== null && _a !== void 0 ? _a : this.endpointId;
951
+ this.assertHandleAvailable(device);
763
952
  const result = yield device.transferIn(endpointIn, length);
953
+ this.assertHandleAvailable(device);
764
954
  return this.getTransferInData(result);
765
955
  });
766
956
  }
@@ -946,6 +1136,7 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
946
1136
  }
947
1137
  finally {
948
1138
  this.releaseIdentityProbeHandle(path);
1139
+ this.releaseNormalHandles(path);
949
1140
  }
950
1141
  this.deviceEndpoints.delete(path);
951
1142
  });
@@ -1353,10 +1544,12 @@ class ElectronBleTransport {
1353
1544
  });
1354
1545
  }
1355
1546
  createProtocolMismatchError(expected) {
1356
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
1547
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportProtocolProbeFailed, undefined, {
1548
+ expectedProtocol: expected,
1549
+ });
1357
1550
  }
1358
1551
  createProtocolDetectionError() {
1359
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, 'Unable to detect BLE protocol: device did not respond to Protocol V1 GetFeatures or Protocol V2 Ping');
1552
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportProtocolProbeFailed);
1360
1553
  }
1361
1554
  clearProbeProtocol(uuid, protocol) {
1362
1555
  if (this.deviceProtocol.get(uuid) === protocol) {
package/dist/webusb.d.ts CHANGED
@@ -19,6 +19,9 @@ export default class WebUsbTransport extends ProtocolV2UsbTransportBase<string>
19
19
  private staleProtocolPaths;
20
20
  private acquiredPaths;
21
21
  private identityProbeDevices;
22
+ private normalDevices;
23
+ private pendingHandleOperations;
24
+ private stopPromise?;
22
25
  private identityProbeCleanupPaths;
23
26
  private probedDeviceObjects;
24
27
  private deviceEndpoints;
@@ -34,6 +37,10 @@ export default class WebUsbTransport extends ProtocolV2UsbTransportBase<string>
34
37
  interfaceId: number;
35
38
  constructor(identityProbe?: boolean);
36
39
  init(logger: any, emitter?: EventEmitter): void;
40
+ stop(): Promise<void>;
41
+ private stopResources;
42
+ private assertRunning;
43
+ private runHandleOperation;
37
44
  emitDeviceDisconnect(path: string, device?: USBDevice): void;
38
45
  markProtocolStale(path: string): void;
39
46
  configure(signedData: any): void;
@@ -51,6 +58,9 @@ export default class WebUsbTransport extends ProtocolV2UsbTransportBase<string>
51
58
  private discoverEndpoints;
52
59
  connectToDevice(path: string, first: boolean): Promise<undefined>;
53
60
  private assertHandleAvailable;
61
+ private claimNormalHandle;
62
+ private releaseNormalHandles;
63
+ private isHandleOwnershipError;
54
64
  private claimIdentityProbeHandle;
55
65
  private releaseIdentityProbeHandle;
56
66
  private closeOpenDevice;
@@ -1 +1 @@
1
- {"version":3,"file":"webusb.d.ts","sourceRoot":"","sources":["../src/webusb.ts"],"names":[],"mappings":";;AACA,OAAO,SAAS,EAAE,EAQhB,0BAA0B,EAG3B,MAAM,wBAAwB,CAAC;AAahC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KA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