@onekeyfe/hd-transport-web-device 1.1.27-alpha.30 → 1.1.27-alpha.31

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/dist/index.js CHANGED
@@ -61,9 +61,6 @@ function shouldBlockWebUsbCallDataLog(name) {
61
61
  const normalized = name.replace(/[_\s-]/g, '');
62
62
  return transport.LogBlockCommand.has(name) || WEBUSB_FILE_WRITE_LOG_BLOCK_PATTERN.test(normalized);
63
63
  }
64
- function inferProtocolTypeFromDeviceName$1(name) {
65
- return /\bpro\s*2\b/i.test(name !== null && name !== void 0 ? name : '') ? 'V2' : undefined;
66
- }
67
64
  class WebUsbTransport {
68
65
  constructor() {
69
66
  this.deviceProtocol = new Map();
@@ -129,7 +126,6 @@ class WebUsbTransport {
129
126
  path: device.serialNumber,
130
127
  device,
131
128
  commType: 'webusb',
132
- protocolType: inferProtocolTypeFromDeviceName$1(device.productName),
133
129
  }));
134
130
  for (const dev of onekeyDevices) {
135
131
  this.Log.debug(`[WebUSB] Device: name="${dev.productName}" serial="${dev.serialNumber}" ` +
@@ -158,7 +154,6 @@ class WebUsbTransport {
158
154
  return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
159
155
  }
160
156
  detectProtocol(path, expectedProtocol) {
161
- var _a;
162
157
  return __awaiter(this, void 0, void 0, function* () {
163
158
  if (expectedProtocol === 'V1') {
164
159
  if (yield this.probeProtocolV1(path)) {
@@ -169,15 +164,6 @@ class WebUsbTransport {
169
164
  throw this.createProtocolMismatchError(expectedProtocol);
170
165
  }
171
166
  if (expectedProtocol === 'V2') {
172
- if (this.deviceProtocol.get(path) === 'V2') {
173
- this.Log.debug(`[WebUsbTransport] detectProtocol: path=${path} -> V2 (cached expected)`);
174
- return 'V2';
175
- }
176
- if (((_a = this.deviceList.find(device => device.path === path)) === null || _a === void 0 ? void 0 : _a.protocolType) === 'V2') {
177
- this.deviceProtocol.set(path, 'V2');
178
- this.Log.debug(`[WebUsbTransport] detectProtocol: path=${path} -> V2 (descriptor)`);
179
- return 'V2';
180
- }
181
167
  if (yield this.probeProtocolV2(path)) {
182
168
  this.deviceProtocol.set(path, 'V2');
183
169
  this.Log.debug(`[WebUsbTransport] detectProtocol: path=${path} -> V2 (expected)`);
@@ -647,13 +633,15 @@ class WebUsbTransport {
647
633
  });
648
634
  }
649
635
  release(path) {
650
- var _a;
636
+ var _a, _b;
651
637
  return __awaiter(this, void 0, void 0, function* () {
652
638
  const device = yield this.findDevice(path);
653
639
  const endpoints = this.deviceEndpoints.get(path);
654
640
  const ifaceNum = (_a = endpoints === null || endpoints === void 0 ? void 0 : endpoints.interfaceNumber) !== null && _a !== void 0 ? _a : this.interfaceId;
655
641
  yield device.releaseInterface(ifaceNum);
656
642
  yield device.close();
643
+ this.deviceProtocol.delete(path);
644
+ (_b = this.protocolV2Assemblers.get(path)) === null || _b === void 0 ? void 0 : _b.reset();
657
645
  this.protocolV2Assemblers.delete(path);
658
646
  this.deviceEndpoints.delete(path);
659
647
  });
@@ -1 +1 @@
1
- {"version":3,"file":"webusb.d.ts","sourceRoot":"","sources":["../src/webusb.ts"],"names":[],"mappings":";AACA,OAAO,SAWN,MAAM,wBAAwB,CAAC;AAIhC,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAiChC,MAAM,WAAW,UAAW,SAAQ,oBAAoB;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAaD,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,QAAQ,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAGlE,UAAU,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SA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;IAU7B,kBAAkB;IAmBlB,SAAS;IAQT,mBAAmB;IAgCnB,OAAO,CAAC,KAAK,EAAE,YAAY;IAiBjC,OAAO,CAAC,2BAA2B;YAOrB,cAAc;IAwCtB,UAAU,CAAC,IAAI,EAAE,MAAM;IAwBvB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAkB1C,OAAO,CAAC,iBAAiB;IAiCnB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAgC5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIvE,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,wBAAwB;YAalB,yBAAyB;IAiCvC,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,aAAa;YASP,oBAAoB;YAoCpB,mBAAmB;YA2CnB,yBAAyB;YAuBzB,uBAAuB;YA4CvB,eAAe;YAcf,eAAe;IAiBvB,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YA4BlB,cAAc;YAkCd,cAAc;YAmCd,sBAAsB;IA4C9B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAgD5C,OAAO,CAAC,IAAI,EAAE,MAAM;IAgB1B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;CAG5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-web-device",
3
- "version": "1.1.27-alpha.30",
3
+ "version": "1.1.27-alpha.31",
4
4
  "author": "OneKey",
5
5
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
6
6
  "license": "MIT",
@@ -20,13 +20,13 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-shared": "1.1.27-alpha.30",
24
- "@onekeyfe/hd-transport": "1.1.27-alpha.30"
23
+ "@onekeyfe/hd-shared": "1.1.27-alpha.31",
24
+ "@onekeyfe/hd-transport": "1.1.27-alpha.31"
25
25
  },
26
26
  "devDependencies": {
27
- "@onekeyfe/hd-transport-electron": "1.1.27-alpha.30",
27
+ "@onekeyfe/hd-transport-electron": "1.1.27-alpha.31",
28
28
  "@types/w3c-web-usb": "^1.0.6",
29
29
  "@types/web-bluetooth": "^0.0.17"
30
30
  },
31
- "gitHead": "f1e3a93e766463007436eaa9aff4a271ffd8830c"
31
+ "gitHead": "73a8ecbc0e5e47038966b2f9a5ab30dc2f947d8f"
32
32
  }
package/src/webusb.ts CHANGED
@@ -45,10 +45,6 @@ function shouldBlockWebUsbCallDataLog(name: string) {
45
45
  return LogBlockCommand.has(name) || WEBUSB_FILE_WRITE_LOG_BLOCK_PATTERN.test(normalized);
46
46
  }
47
47
 
48
- function inferProtocolTypeFromDeviceName(name?: string | null): ProtocolType | undefined {
49
- return /\bpro\s*2\b/i.test(name ?? '') ? 'V2' : undefined;
50
- }
51
-
52
48
  /**
53
49
  * Device information with path and WebUSB device instance
54
50
  */
@@ -187,7 +183,6 @@ export default class WebUsbTransport {
187
183
  path: device.serialNumber as string,
188
184
  device,
189
185
  commType: 'webusb',
190
- protocolType: inferProtocolTypeFromDeviceName(device.productName),
191
186
  }));
192
187
 
193
188
  // Debug: log all discovered devices. Protocol is detected after acquire via wire probe.
@@ -242,15 +237,6 @@ export default class WebUsbTransport {
242
237
  }
243
238
 
244
239
  if (expectedProtocol === 'V2') {
245
- if (this.deviceProtocol.get(path) === 'V2') {
246
- this.Log.debug(`[WebUsbTransport] detectProtocol: path=${path} -> V2 (cached expected)`);
247
- return 'V2';
248
- }
249
- if (this.deviceList.find(device => device.path === path)?.protocolType === 'V2') {
250
- this.deviceProtocol.set(path, 'V2');
251
- this.Log.debug(`[WebUsbTransport] detectProtocol: path=${path} -> V2 (descriptor)`);
252
- return 'V2';
253
- }
254
240
  if (await this.probeProtocolV2(path)) {
255
241
  this.deviceProtocol.set(path, 'V2');
256
242
  this.Log.debug(`[WebUsbTransport] detectProtocol: path=${path} -> V2 (expected)`);
@@ -839,6 +825,8 @@ export default class WebUsbTransport {
839
825
  const ifaceNum = endpoints?.interfaceNumber ?? this.interfaceId;
840
826
  await device.releaseInterface(ifaceNum);
841
827
  await device.close();
828
+ this.deviceProtocol.delete(path);
829
+ this.protocolV2Assemblers.get(path)?.reset();
842
830
  this.protocolV2Assemblers.delete(path);
843
831
  this.deviceEndpoints.delete(path);
844
832
  }