@onekeyfe/hd-transport-web-device 1.2.0-alpha.145 → 1.2.0-alpha.146
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.
|
@@ -456,7 +456,7 @@ describe('ElectronBleTransport protocol detection', () => {
|
|
|
456
456
|
expect(transport.getProtocolType(device.id)).toBeUndefined();
|
|
457
457
|
});
|
|
458
458
|
|
|
459
|
-
test('
|
|
459
|
+
test('keeps a second expected Protocol V2 probe miss retryable', async () => {
|
|
460
460
|
const device = { id: 'retry-pro2-id', name: 'OneKey Pro 2' };
|
|
461
461
|
const nobleBle = createNobleBle(device);
|
|
462
462
|
const transport = configureTransport(nobleBle);
|
|
@@ -470,7 +470,7 @@ describe('ElectronBleTransport protocol detection', () => {
|
|
|
470
470
|
await expect(
|
|
471
471
|
transport.acquire({ uuid: device.id, expectedProtocol: 'V2' })
|
|
472
472
|
).rejects.toMatchObject({
|
|
473
|
-
errorCode: HardwareErrorCode.
|
|
473
|
+
errorCode: HardwareErrorCode.RuntimeError,
|
|
474
474
|
});
|
|
475
475
|
|
|
476
476
|
expect(transport.getProtocolType(device.id)).toBeUndefined();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";AAsBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,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,CA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AE,eAAe;;;;;;;;;;;IAqG9B,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO;IAY7D,UAAU,CAAC,EAAE,EAAE,MAAM;YAKb,aAAa;YAiBb,cAAc;IAwB5B,OAAO,CAAC,2BAA2B;IAUnC,OAAO,CAAC,4BAA4B;IAOpC,OAAO,CAAC,kBAAkB;YAMZ,cAAc;IAoD5B,OAAO,CAAC,8BAA8B;YAgBxB,iCAAiC;YAwBjC,eAAe;YAkBf,eAAe;YAuBf,SAAS;YAST,wBAAwB;IAKtC,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,oBAAoB;IAqB5B,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,4BAA4B;IAkBpC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;IAiBjC,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
|
@@ -212,8 +212,6 @@ declare class ElectronBleTransport {
|
|
|
212
212
|
private deviceProtocolHints;
|
|
213
213
|
/** Endpoints that answered a V2 probe in this transport lifetime. Survives disconnect. */
|
|
214
214
|
private confirmedProtocolV2;
|
|
215
|
-
/** First expected-V2 miss for an unconfirmed endpoint; the next miss is a stale bond. */
|
|
216
|
-
private retryableV2Mismatch;
|
|
217
215
|
private deviceMtus;
|
|
218
216
|
private devicePacketCapacities;
|
|
219
217
|
private v1Buffers;
|
package/dist/index.js
CHANGED
|
@@ -809,7 +809,6 @@ class ElectronBleTransport {
|
|
|
809
809
|
this.deviceProtocol = new Map();
|
|
810
810
|
this.deviceProtocolHints = new Map();
|
|
811
811
|
this.confirmedProtocolV2 = new Set();
|
|
812
|
-
this.retryableV2Mismatch = new Set();
|
|
813
812
|
this.deviceMtus = new Map();
|
|
814
813
|
this.devicePacketCapacities = new Map();
|
|
815
814
|
this.v1Buffers = new Map();
|
|
@@ -1106,14 +1105,7 @@ class ElectronBleTransport {
|
|
|
1106
1105
|
});
|
|
1107
1106
|
}
|
|
1108
1107
|
createProtocolMismatchError(expected, uuid) {
|
|
1109
|
-
const isStaleV2Bond = expected === 'V2' &&
|
|
1110
|
-
(this.confirmedProtocolV2.has(uuid) || this.retryableV2Mismatch.has(uuid));
|
|
1111
|
-
if (expected === 'V2' && !isStaleV2Bond) {
|
|
1112
|
-
this.retryableV2Mismatch.add(uuid);
|
|
1113
|
-
}
|
|
1114
|
-
else if (isStaleV2Bond) {
|
|
1115
|
-
this.retryableV2Mismatch.delete(uuid);
|
|
1116
|
-
}
|
|
1108
|
+
const isStaleV2Bond = expected === 'V2' && this.confirmedProtocolV2.has(uuid);
|
|
1117
1109
|
return hdShared.ERRORS.TypedError(isStaleV2Bond ? hdShared.HardwareErrorCode.BleDeviceBondError : hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
|
|
1118
1110
|
}
|
|
1119
1111
|
createProtocolDetectionError() {
|
|
@@ -1139,7 +1131,6 @@ class ElectronBleTransport {
|
|
|
1139
1131
|
if (yield this.probeProtocolV2(uuid)) {
|
|
1140
1132
|
this.deviceProtocol.set(uuid, 'V2');
|
|
1141
1133
|
this.confirmedProtocolV2.add(uuid);
|
|
1142
|
-
this.retryableV2Mismatch.delete(uuid);
|
|
1143
1134
|
(_b = this.Log) === null || _b === void 0 ? void 0 : _b.debug(`[Electron BLE] detectProtocol: uuid=${uuid} -> V2 (expected)`);
|
|
1144
1135
|
return 'V2';
|
|
1145
1136
|
}
|
|
@@ -1156,7 +1147,6 @@ class ElectronBleTransport {
|
|
|
1156
1147
|
this.deviceProtocol.set(uuid, protocol);
|
|
1157
1148
|
if (protocol === 'V2') {
|
|
1158
1149
|
this.confirmedProtocolV2.add(uuid);
|
|
1159
|
-
this.retryableV2Mismatch.delete(uuid);
|
|
1160
1150
|
}
|
|
1161
1151
|
(_c = this.Log) === null || _c === void 0 ? void 0 : _c.debug(`[Electron BLE] detectProtocol: uuid=${uuid} -> ${protocol}`);
|
|
1162
1152
|
return protocol;
|
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.146",
|
|
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.146",
|
|
25
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.146"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.146",
|
|
29
29
|
"@types/w3c-web-usb": "^1.0.6",
|
|
30
30
|
"@types/web-bluetooth": "^0.0.17"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "447f0806b061695326a6dcba63d8c228b871d01a"
|
|
33
33
|
}
|
|
@@ -104,9 +104,6 @@ export default class ElectronBleTransport {
|
|
|
104
104
|
/** Endpoints that answered a V2 probe in this transport lifetime. Survives disconnect. */
|
|
105
105
|
private confirmedProtocolV2 = new Set<string>();
|
|
106
106
|
|
|
107
|
-
/** First expected-V2 miss for an unconfirmed endpoint; the next miss is a stale bond. */
|
|
108
|
-
private retryableV2Mismatch = new Set<string>();
|
|
109
|
-
|
|
110
107
|
private deviceMtus: Map<string, number> = new Map();
|
|
111
108
|
|
|
112
109
|
private devicePacketCapacities: Map<string, number> = new Map();
|
|
@@ -439,17 +436,9 @@ export default class ElectronBleTransport {
|
|
|
439
436
|
}
|
|
440
437
|
|
|
441
438
|
private createProtocolMismatchError(expected: ProtocolType, uuid: string) {
|
|
442
|
-
//
|
|
443
|
-
//
|
|
444
|
-
|
|
445
|
-
const isStaleV2Bond =
|
|
446
|
-
expected === 'V2' &&
|
|
447
|
-
(this.confirmedProtocolV2.has(uuid) || this.retryableV2Mismatch.has(uuid));
|
|
448
|
-
if (expected === 'V2' && !isStaleV2Bond) {
|
|
449
|
-
this.retryableV2Mismatch.add(uuid);
|
|
450
|
-
} else if (isStaleV2Bond) {
|
|
451
|
-
this.retryableV2Mismatch.delete(uuid);
|
|
452
|
-
}
|
|
439
|
+
// A generic Ping miss is not a bond failure. Only a later miss after this
|
|
440
|
+
// endpoint already answered V2, or a native encryption/pairing error, is.
|
|
441
|
+
const isStaleV2Bond = expected === 'V2' && this.confirmedProtocolV2.has(uuid);
|
|
453
442
|
return ERRORS.TypedError(
|
|
454
443
|
isStaleV2Bond ? HardwareErrorCode.BleDeviceBondError : HardwareErrorCode.RuntimeError,
|
|
455
444
|
`Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`
|
|
@@ -487,7 +476,6 @@ export default class ElectronBleTransport {
|
|
|
487
476
|
if (await this.probeProtocolV2(uuid)) {
|
|
488
477
|
this.deviceProtocol.set(uuid, 'V2');
|
|
489
478
|
this.confirmedProtocolV2.add(uuid);
|
|
490
|
-
this.retryableV2Mismatch.delete(uuid);
|
|
491
479
|
this.Log?.debug(`[Electron BLE] detectProtocol: uuid=${uuid} -> V2 (expected)`);
|
|
492
480
|
return 'V2';
|
|
493
481
|
}
|
|
@@ -512,7 +500,6 @@ export default class ElectronBleTransport {
|
|
|
512
500
|
this.deviceProtocol.set(uuid, protocol);
|
|
513
501
|
if (protocol === 'V2') {
|
|
514
502
|
this.confirmedProtocolV2.add(uuid);
|
|
515
|
-
this.retryableV2Mismatch.delete(uuid);
|
|
516
503
|
}
|
|
517
504
|
this.Log?.debug(`[Electron BLE] detectProtocol: uuid=${uuid} -> ${protocol}`);
|
|
518
505
|
return protocol;
|