@onekeyfe/hd-transport-lowlevel 1.2.8-alpha.52 → 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.
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const { HardwareErrorCode } = require('@onekeyfe/hd-shared');
3
+
2
4
  const LowlevelTransport = require('../src').default;
3
5
  const { parseConfigure } = require('../../hd-transport/src/serialization/protobuf/messages');
4
6
  const { ProtocolV1, ProtocolV2 } = require('../../hd-transport/src/protocols');
@@ -538,8 +540,11 @@ describe('LowlevelTransport protocol framing', () => {
538
540
  });
539
541
  const lowlevel = configureTransport(plugin);
540
542
 
541
- await expect(lowlevel.acquire({ uuid: 'v2-id', expectedProtocol: 'V1' })).rejects.toThrow(
542
- 'Device protocol mismatch: expected V1'
543
+ await expect(lowlevel.acquire({ uuid: 'v2-id', expectedProtocol: 'V1' })).rejects.toMatchObject(
544
+ {
545
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
546
+ params: { expectedProtocol: 'V1' },
547
+ }
543
548
  );
544
549
  });
545
550
 
@@ -553,9 +558,9 @@ describe('LowlevelTransport protocol framing', () => {
553
558
  });
554
559
  const lowlevel = configureTransport(plugin);
555
560
 
556
- await expect(lowlevel.acquire({ uuid: 'flaky-pro2-id' })).rejects.toThrow(
557
- 'Unable to detect BLE protocol'
558
- );
561
+ await expect(lowlevel.acquire({ uuid: 'flaky-pro2-id' })).rejects.toMatchObject({
562
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
563
+ });
559
564
  expect(lowlevel.getProtocolType('flaky-pro2-id')).toBeUndefined();
560
565
  });
561
566
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,SAYN,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OA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,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;IAoB1B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;YAatD,cAAc;IA6E5B,OAAO,CAAC,0BAA0B;IAOlC,OAAO,CAAC,2BAA2B;IAMnC,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,kBAAkB;YAMZ,cAAc;YA2Cd,yBAAyB;YAkCzB,eAAe;YAgBf,eAAe;YA6Bf,UAAU;YAUV,qBAAqB;YAmBrB,mBAAmB;YAqBnB,oBAAoB;YAkBpB,+BAA+B;YAgB/B,cAAc;IAwB5B,OAAO,CAAC,uBAAuB;IAgC/B,OAAO,CAAC,2BAA2B;IAMnC,MAAM;CAGP"}
package/dist/index.js CHANGED
@@ -306,10 +306,12 @@ class LowlevelTransport {
306
306
  return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, `Lowlevel response timeout after ${timeout}ms for ${name}`);
307
307
  }
308
308
  createProtocolMismatchError(expected) {
309
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
309
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportProtocolProbeFailed, undefined, {
310
+ expectedProtocol: expected,
311
+ });
310
312
  }
311
313
  createProtocolDetectionError() {
312
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, 'Unable to detect BLE protocol: device did not respond to Protocol V1 Initialize or Protocol V2 Ping');
314
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportProtocolProbeFailed);
313
315
  }
314
316
  clearProbeProtocol(uuid, protocol) {
315
317
  if (this.deviceProtocol.get(uuid) === protocol) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-lowlevel",
3
- "version": "1.2.8-alpha.52",
3
+ "version": "1.2.8-alpha.53",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,8 +20,8 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-shared": "1.2.8-alpha.52",
24
- "@onekeyfe/hd-transport": "1.2.8-alpha.52"
23
+ "@onekeyfe/hd-shared": "1.2.8-alpha.53",
24
+ "@onekeyfe/hd-transport": "1.2.8-alpha.53"
25
25
  },
26
- "gitHead": "389c588beb19de26451c729bb09bc8e7ce6b0717"
26
+ "gitHead": "8b628967c6057e743ffe0d5fa8a8d2120e64c5e3"
27
27
  }
package/src/index.ts CHANGED
@@ -361,17 +361,13 @@ export default class LowlevelTransport {
361
361
  }
362
362
 
363
363
  private createProtocolMismatchError(expected: ProtocolType) {
364
- return ERRORS.TypedError(
365
- HardwareErrorCode.RuntimeError,
366
- `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`
367
- );
364
+ return ERRORS.TypedError(HardwareErrorCode.TransportProtocolProbeFailed, undefined, {
365
+ expectedProtocol: expected,
366
+ });
368
367
  }
369
368
 
370
369
  private createProtocolDetectionError() {
371
- return ERRORS.TypedError(
372
- HardwareErrorCode.BleTimeoutError,
373
- 'Unable to detect BLE protocol: device did not respond to Protocol V1 Initialize or Protocol V2 Ping'
374
- );
370
+ return ERRORS.TypedError(HardwareErrorCode.TransportProtocolProbeFailed);
375
371
  }
376
372
 
377
373
  private clearProbeProtocol(uuid: string, protocol: ProtocolType) {