@onekeyfe/hd-transport-web-device 1.2.0-alpha.20 → 1.2.0-alpha.21
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/__tests__/webusb-protocol-v2-timeout.test.ts +0 -25
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -6
- package/dist/webusb.d.ts +0 -1
- package/dist/webusb.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/webusb.ts +1 -10
|
@@ -60,29 +60,4 @@ describe('WebUsbTransport Protocol V2 timeout recovery', () => {
|
|
|
60
60
|
expect(webusb.resetConnectionAfterProbe).toHaveBeenCalledWith(path);
|
|
61
61
|
expect(webusb.protocolV2Sessions.has(path)).toBe(false);
|
|
62
62
|
});
|
|
63
|
-
|
|
64
|
-
test('resets a stalled write while retaining the device sequence cursor', async () => {
|
|
65
|
-
const webusb = new WebUsbTransport() as any;
|
|
66
|
-
const path = 'pro2-webusb';
|
|
67
|
-
webusb.messages = transport.parseConfigure(schema);
|
|
68
|
-
webusb.messagesV2 = transport.parseConfigure(schema);
|
|
69
|
-
webusb.protocolV2WriteTimeoutMs = 10;
|
|
70
|
-
webusb.protocolV2Assemblers.set(path, new ProtocolV2FrameAssembler());
|
|
71
|
-
webusb.transferOutOnce = jest.fn(() => new Promise(() => {}));
|
|
72
|
-
webusb.receiveProtocolV2Frame = jest.fn();
|
|
73
|
-
webusb.resetConnectionAfterProbe = jest.fn().mockImplementation(() => {
|
|
74
|
-
webusb.protocolV2Sessions.delete(path);
|
|
75
|
-
webusb.protocolV2ReadTimeouts.delete(path);
|
|
76
|
-
webusb.protocolV2Assemblers.get(path)?.reset();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
await expect(
|
|
80
|
-
webusb.callProtocolV2(path, 'Ping', { message: 'timeout' }, { timeoutMs: 10 })
|
|
81
|
-
).rejects.toThrow('Protocol V2 write timeout after 10ms for Ping');
|
|
82
|
-
|
|
83
|
-
expect(webusb.resetConnectionAfterProbe).toHaveBeenCalledWith(path);
|
|
84
|
-
expect(webusb.protocolV2Sequences.has(path)).toBe(true);
|
|
85
|
-
expect(webusb.protocolV2Sessions.has(path)).toBe(false);
|
|
86
|
-
expect(webusb.receiveProtocolV2Frame).not.toHaveBeenCalled();
|
|
87
|
-
});
|
|
88
63
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ declare class WebUsbTransport {
|
|
|
27
27
|
private protocolV2Sequences;
|
|
28
28
|
/** Read timeout for the current Protocol V2 call, consumed by cached readFrame. */
|
|
29
29
|
private protocolV2ReadTimeouts;
|
|
30
|
-
private protocolV2WriteTimeoutMs;
|
|
31
30
|
/** Per-path USB endpoint / interface numbers (discovered from USB descriptors) */
|
|
32
31
|
private deviceEndpoints;
|
|
33
32
|
/**
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,6 @@ class WebUsbTransport {
|
|
|
71
71
|
this.protocolV2Sessions = new Map();
|
|
72
72
|
this.protocolV2Sequences = new Map();
|
|
73
73
|
this.protocolV2ReadTimeouts = new Map();
|
|
74
|
-
this.protocolV2WriteTimeoutMs = transport.PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS;
|
|
75
74
|
this.deviceEndpoints = new Map();
|
|
76
75
|
this.mockSerialPaths = new WeakMap();
|
|
77
76
|
this.mockSerialCounter = 0;
|
|
@@ -641,7 +640,6 @@ class WebUsbTransport {
|
|
|
641
640
|
},
|
|
642
641
|
router: transport.PROTOCOL_V2_CHANNEL_USB,
|
|
643
642
|
sequenceCursor,
|
|
644
|
-
writeTimeoutMs: this.protocolV2WriteTimeoutMs,
|
|
645
643
|
writeFrame: (frame) => this.transferOutOnce(path, frame),
|
|
646
644
|
readFrame: () => this.receiveProtocolV2Frame(path, this.protocolV2ReadTimeouts.get(path)),
|
|
647
645
|
logger: this.Log,
|
|
@@ -657,10 +655,7 @@ class WebUsbTransport {
|
|
|
657
655
|
}
|
|
658
656
|
catch (error) {
|
|
659
657
|
const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
|
|
660
|
-
if (message.includes('protocol v2 read timeout') ||
|
|
661
|
-
message.includes('protocol v2 write timeout') ||
|
|
662
|
-
message.includes('protocol v2 delivery timeout') ||
|
|
663
|
-
message.includes('response timeout')) {
|
|
658
|
+
if (message.includes('protocol v2 read timeout') || message.includes('response timeout')) {
|
|
664
659
|
try {
|
|
665
660
|
yield this.resetConnectionAfterProbe(path);
|
|
666
661
|
}
|
package/dist/webusb.d.ts
CHANGED
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,
|
|
1
|
+
{"version":3,"file":"webusb.d.ts","sourceRoot":"","sources":["../src/webusb.ts"],"names":[],"mappings":";AACA,OAAO,SAWN,MAAM,wBAAwB,CAAC;AAYhC,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAqBhC,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,SAAS,CAAC;IAGpE,OAAO,CAAC,cAAc,CAAwC;IAE9D,OAAO,CAAC,mBAAmB,CAAwC;IAGnE,OAAO,CAAC,oBAAoB,CAAoD;IAGhF,OAAO,CAAC,kBAAkB,CAA6C;IAGvE,OAAO,CAAC,mBAAmB,CAAoD;IAG/E,OAAO,CAAC,sBAAsB,CAA8C;IAG5E,OAAO,CAAC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AM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YA8BlB,cAAc;YAkCd,cAAc;YA6Dd,sBAAsB;IA4C9B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAgD5C,OAAO,CAAC,IAAI,EAAE,MAAM;IAmB1B,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.21",
|
|
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.2.0-alpha.
|
|
24
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
23
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.21",
|
|
24
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.21"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.
|
|
27
|
+
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.21",
|
|
28
28
|
"@types/w3c-web-usb": "^1.0.6",
|
|
29
29
|
"@types/web-bluetooth": "^0.0.17"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "efe594367fb3b196a5126baee7e2aba3e94986cd"
|
|
32
32
|
}
|
package/src/webusb.ts
CHANGED
|
@@ -6,7 +6,6 @@ import transport, {
|
|
|
6
6
|
PROTOCOL_V1_USB_PACKET_SIZE,
|
|
7
7
|
PROTOCOL_V2_CHANNEL_USB,
|
|
8
8
|
PROTOCOL_V2_FRAME_MAX_BYTES,
|
|
9
|
-
PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS,
|
|
10
9
|
ProtocolV2FrameAssembler,
|
|
11
10
|
ProtocolV2SequenceCursor,
|
|
12
11
|
ProtocolV2Session,
|
|
@@ -89,8 +88,6 @@ export default class WebUsbTransport {
|
|
|
89
88
|
/** Read timeout for the current Protocol V2 call, consumed by cached readFrame. */
|
|
90
89
|
private protocolV2ReadTimeouts: Map<string, number | undefined> = new Map();
|
|
91
90
|
|
|
92
|
-
private protocolV2WriteTimeoutMs = PROTOCOL_V2_WRITE_WATCHDOG_TIMEOUT_MS;
|
|
93
|
-
|
|
94
91
|
/** Per-path USB endpoint / interface numbers (discovered from USB descriptors) */
|
|
95
92
|
private deviceEndpoints: Map<string, DeviceEndpoints> = new Map();
|
|
96
93
|
|
|
@@ -823,7 +820,6 @@ export default class WebUsbTransport {
|
|
|
823
820
|
},
|
|
824
821
|
router: PROTOCOL_V2_CHANNEL_USB,
|
|
825
822
|
sequenceCursor,
|
|
826
|
-
writeTimeoutMs: this.protocolV2WriteTimeoutMs,
|
|
827
823
|
writeFrame: (frame: Uint8Array) => this.transferOutOnce(path, frame),
|
|
828
824
|
readFrame: () => this.receiveProtocolV2Frame(path, this.protocolV2ReadTimeouts.get(path)),
|
|
829
825
|
logger: this.Log,
|
|
@@ -841,12 +837,7 @@ export default class WebUsbTransport {
|
|
|
841
837
|
} catch (error) {
|
|
842
838
|
const message =
|
|
843
839
|
error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
|
|
844
|
-
if (
|
|
845
|
-
message.includes('protocol v2 read timeout') ||
|
|
846
|
-
message.includes('protocol v2 write timeout') ||
|
|
847
|
-
message.includes('protocol v2 delivery timeout') ||
|
|
848
|
-
message.includes('response timeout')
|
|
849
|
-
) {
|
|
840
|
+
if (message.includes('protocol v2 read timeout') || message.includes('response timeout')) {
|
|
850
841
|
try {
|
|
851
842
|
await this.resetConnectionAfterProbe(path);
|
|
852
843
|
} catch (resetError) {
|