@onekeyfe/hd-transport-web-device 1.2.0-alpha.106 → 1.2.0-alpha.107
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.
|
@@ -148,7 +148,7 @@ describe('WebUsbTransport Protocol V2 timeout recovery', () => {
|
|
|
148
148
|
expect(webusb.deviceProtocol.get(path)).toBe('V2');
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
test('reports a
|
|
151
|
+
test('reports a Protocol V2 probe timeout only after the bounded retry is exhausted', async () => {
|
|
152
152
|
const webusb = new WebUsbTransport() as any;
|
|
153
153
|
const path = 'pro2-webusb';
|
|
154
154
|
webusb.probeProtocolV1 = jest.fn();
|
|
@@ -156,10 +156,9 @@ describe('WebUsbTransport Protocol V2 timeout recovery', () => {
|
|
|
156
156
|
webusb.resetConnectionAfterProbe = jest.fn().mockResolvedValue(undefined);
|
|
157
157
|
webusb.closeConnectionAfterProbe = jest.fn().mockResolvedValue(undefined);
|
|
158
158
|
|
|
159
|
-
await expect(webusb.detectProtocol(path, 'V2')).rejects.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
159
|
+
await expect(webusb.detectProtocol(path, 'V2')).rejects.toThrow(
|
|
160
|
+
'Protocol V2 probe timeout after 2 attempts'
|
|
161
|
+
);
|
|
163
162
|
|
|
164
163
|
expect(webusb.probeProtocolV2).toHaveBeenCalledTimes(2);
|
|
165
164
|
expect(webusb.probeProtocolV1).not.toHaveBeenCalled();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";AAuBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,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;IA0B5B,OAAO,CAAC,uBAAuB;IAyC/B,OAAO,CAAC,6BAA6B;IA4CrC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
|
package/dist/index.js
CHANGED
|
@@ -177,7 +177,7 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
177
177
|
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
|
|
178
178
|
}
|
|
179
179
|
createProtocolProbeTimeoutError(expected, attempts) {
|
|
180
|
-
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
180
|
+
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Protocol ${expected} probe timeout after ${attempts} attempts`);
|
|
181
181
|
}
|
|
182
182
|
createProtocolDetectionError() {
|
|
183
183
|
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
|
|
@@ -603,6 +603,9 @@ class WebUsbTransport extends transport.ProtocolV2UsbTransportBase {
|
|
|
603
603
|
if (!protocol) {
|
|
604
604
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol has not been detected for ${path}`);
|
|
605
605
|
}
|
|
606
|
+
if (!transport.shouldSuppressHighVolumeCallLog(name)) {
|
|
607
|
+
this.Log.debug('transport call', transport.createTransportCallLog(name, protocol, data));
|
|
608
|
+
}
|
|
606
609
|
if (protocol === 'V2') {
|
|
607
610
|
return this.callProtocolV2(path, name, data, options);
|
|
608
611
|
}
|
|
@@ -1359,6 +1362,7 @@ class ElectronBleTransport {
|
|
|
1359
1362
|
}
|
|
1360
1363
|
}
|
|
1361
1364
|
call(uuid, name, data, options) {
|
|
1365
|
+
var _a;
|
|
1362
1366
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1363
1367
|
if (!this._messages) {
|
|
1364
1368
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
|
|
@@ -1370,6 +1374,9 @@ class ElectronBleTransport {
|
|
|
1370
1374
|
if (!protocol) {
|
|
1371
1375
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol has not been detected for ${uuid}`);
|
|
1372
1376
|
}
|
|
1377
|
+
if (!transport.shouldSuppressHighVolumeCallLog(name)) {
|
|
1378
|
+
(_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('transport call', transport.createTransportCallLog(name, protocol, data));
|
|
1379
|
+
}
|
|
1373
1380
|
if (protocol === 'V2') {
|
|
1374
1381
|
return this.callProtocolV2(uuid, name, data, options);
|
|
1375
1382
|
}
|
package/dist/webusb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webusb.d.ts","sourceRoot":"","sources":["../src/webusb.ts"],"names":[],"mappings":";AACA,OAAO,SAAS,EAAE,EAQhB,0BAA0B,EAE3B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"webusb.d.ts","sourceRoot":"","sources":["../src/webusb.ts"],"names":[],"mappings":";AACA,OAAO,SAAS,EAAE,EAQhB,0BAA0B,EAE3B,MAAM,wBAAwB,CAAC;AAYhC,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AA0BhC,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,eAAgB,SAAQ,0BAA0B,CAAC,MAAM,CAAC;IAC7E,QAAQ,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAGlE,UAAU,EAAE,UAAU,CAAC,OAAO,SAAS,C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B;YAKzB,yBAAyB;YAMzB,uBAAuB;YA0CvB,eAAe;YAoBf,eAAe;IAgBvB,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YA8BlB,cAAc;YAkCd,cAAc;IAYtB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAgD5C,OAAO,CAAC,IAAI,EAAE,MAAM;IAQ1B,SAAS,CAAC,uBAAuB,IAAI,iBAAiB;IAUtD,SAAS,CAAC,sBAAsB;cAIhB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;cAIA,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,UAAU,CAAC;cASN,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1F,SAAS,CAAC,8BAA8B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKrE,SAAS,CAAC,+BAA+B,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK;IAWjF,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-web-device",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.107",
|
|
4
4
|
"author": "OneKey",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"lint:fix": "eslint . --fix"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
25
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
24
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.107",
|
|
25
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.107"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.107",
|
|
29
29
|
"@types/w3c-web-usb": "^1.0.6",
|
|
30
30
|
"@types/web-bluetooth": "^0.0.17"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "23fe3be6f7b41066a704b4149b49bbc64d883c55"
|
|
33
33
|
}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
isHeaderChunk,
|
|
19
19
|
} from '@onekeyfe/hd-shared';
|
|
20
20
|
|
|
21
|
+
import { createTransportCallLog, shouldSuppressHighVolumeCallLog } from './transportLog';
|
|
21
22
|
import { resolveBlePacketCapacity } from './ble-packet-capacity';
|
|
22
23
|
|
|
23
24
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
@@ -805,6 +806,10 @@ export default class ElectronBleTransport {
|
|
|
805
806
|
`Device protocol has not been detected for ${uuid}`
|
|
806
807
|
);
|
|
807
808
|
}
|
|
809
|
+
if (!shouldSuppressHighVolumeCallLog(name)) {
|
|
810
|
+
this.Log?.debug('transport call', createTransportCallLog(name, protocol, data));
|
|
811
|
+
}
|
|
812
|
+
|
|
808
813
|
if (protocol === 'V2') {
|
|
809
814
|
return this.callProtocolV2(uuid, name, data, options);
|
|
810
815
|
}
|
package/src/webusb.ts
CHANGED
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
} from '@onekeyfe/hd-shared';
|
|
20
20
|
import ByteBuffer from 'bytebuffer';
|
|
21
21
|
|
|
22
|
+
import { createTransportCallLog, shouldSuppressHighVolumeCallLog } from './transportLog';
|
|
23
|
+
|
|
22
24
|
import type {
|
|
23
25
|
AcquireInput,
|
|
24
26
|
OneKeyDeviceInfoBase,
|
|
@@ -264,7 +266,7 @@ export default class WebUsbTransport extends ProtocolV2UsbTransportBase<string>
|
|
|
264
266
|
|
|
265
267
|
private createProtocolProbeTimeoutError(expected: ProtocolType, attempts: number) {
|
|
266
268
|
return ERRORS.TypedError(
|
|
267
|
-
HardwareErrorCode.
|
|
269
|
+
HardwareErrorCode.RuntimeError,
|
|
268
270
|
`Protocol ${expected} probe timeout after ${attempts} attempts`
|
|
269
271
|
);
|
|
270
272
|
}
|
|
@@ -765,6 +767,10 @@ export default class WebUsbTransport extends ProtocolV2UsbTransportBase<string>
|
|
|
765
767
|
);
|
|
766
768
|
}
|
|
767
769
|
|
|
770
|
+
if (!shouldSuppressHighVolumeCallLog(name)) {
|
|
771
|
+
this.Log.debug('transport call', createTransportCallLog(name, protocol, data));
|
|
772
|
+
}
|
|
773
|
+
|
|
768
774
|
if (protocol === 'V2') {
|
|
769
775
|
return this.callProtocolV2(path, name, data, options);
|
|
770
776
|
}
|