@onekeyfe/hd-transport-react-native 1.0.7 → 1.0.8-alpha.1

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,gCAAgC,CAAC;AAExC,OAAO,SAAkD,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAkB,QAAQ,EAA6B,MAAM,qBAAqB,CAAC;AAC1F,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAavC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAmBjE,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,WAAW,SAAQ;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAExC,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,OAAO,CAAC,EAAE,YAAY,CAAC;gBAEX,OAAO,EAAE,gBAAgB;IAIrC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY;IAKvC,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IA6FT,OAAO,CAAC,KAAK,EAAE,eAAe;;;IAwMpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IAkE/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAepB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM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AAC;IA+FpE,IAAI;IAIJ,MAAM;CAOP"}
package/dist/index.js CHANGED
@@ -174,6 +174,7 @@ const transportCache = {};
174
174
  let connectOptions = {
175
175
  requestMTU: 256,
176
176
  timeout: 3000,
177
+ refreshGatt: 'OnConnected',
177
178
  };
178
179
  const tryToGetConfiguration = (device) => {
179
180
  if (!device || !device.serviceUUIDs)
@@ -461,7 +462,7 @@ class ReactNativeBleTransport {
461
462
  let bufferLength = 0;
462
463
  let buffer$1 = [];
463
464
  const subscription = characteristic.monitor((error, c) => {
464
- var _a, _b, _c, _d, _e;
465
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
465
466
  if (error) {
466
467
  this.Log.debug(`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${error}`);
467
468
  if (this.runPromise) {
@@ -472,7 +473,14 @@ class ReactNativeBleTransport {
472
473
  if ((_b = error.reason) === null || _b === void 0 ? void 0 : _b.includes('Encryption is insufficient')) {
473
474
  ERROR = hdShared.HardwareErrorCode.BleDeviceBondError;
474
475
  }
475
- this.runPromise.reject(hdShared.ERRORS.TypedError(ERROR, (_c = error.reason) !== null && _c !== void 0 ? _c : error.message));
476
+ if (((_c = error.reason) === null || _c === void 0 ? void 0 : _c.includes('Cannot write client characteristic config descriptor')) ||
477
+ ((_d = error.reason) === null || _d === void 0 ? void 0 : _d.includes('Cannot find client characteristic config descriptor')) ||
478
+ ((_e = error.reason) === null || _e === void 0 ? void 0 : _e.includes('The handle is invalid'))) {
479
+ this.runPromise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure, (_f = error.message) !== null && _f !== void 0 ? _f : error.reason));
480
+ this.Log.debug(`${hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure} ${error.message} ${error.reason}`);
481
+ return;
482
+ }
483
+ this.runPromise.reject(hdShared.ERRORS.TypedError(ERROR, (_g = error.reason) !== null && _g !== void 0 ? _g : error.message));
476
484
  this.Log.debug(': monitor notify error, and has unreleased Promise');
477
485
  }
478
486
  return;
@@ -493,12 +501,12 @@ class ReactNativeBleTransport {
493
501
  const value = buffer.Buffer.from(buffer$1);
494
502
  bufferLength = 0;
495
503
  buffer$1 = [];
496
- (_d = this.runPromise) === null || _d === void 0 ? void 0 : _d.resolve(value.toString('hex'));
504
+ (_h = this.runPromise) === null || _h === void 0 ? void 0 : _h.resolve(value.toString('hex'));
497
505
  }
498
506
  }
499
507
  catch (error) {
500
508
  this.Log.debug('monitor data error: ', error);
501
- (_e = this.runPromise) === null || _e === void 0 ? void 0 : _e.reject(error);
509
+ (_j = this.runPromise) === null || _j === void 0 ? void 0 : _j.reject(error);
502
510
  }
503
511
  });
504
512
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.0.7",
3
+ "version": "1.0.8-alpha.1",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,10 +19,10 @@
19
19
  "lint:fix": "eslint . --fix"
20
20
  },
21
21
  "dependencies": {
22
- "@onekeyfe/hd-shared": "^1.0.7",
23
- "@onekeyfe/hd-transport": "^1.0.7",
24
- "@onekeyfe/react-native-ble-plx": "3.0.0",
22
+ "@onekeyfe/hd-shared": "^1.0.8-alpha.1",
23
+ "@onekeyfe/hd-transport": "^1.0.8-alpha.1",
24
+ "@onekeyfe/react-native-ble-plx": "3.0.1",
25
25
  "react-native-ble-manager": "^8.1.0"
26
26
  },
27
- "gitHead": "8b08f905e7426fac23b5cf9ec55eb336278f0e3b"
27
+ "gitHead": "064ad0959385083431440c60f4a936346c2b693a"
28
28
  }
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ const transportCache: Record<string, any> = {};
32
32
  let connectOptions: Record<string, unknown> = {
33
33
  requestMTU: 256,
34
34
  timeout: 3000,
35
+ refreshGatt: 'OnConnected',
35
36
  };
36
37
 
37
38
  const tryToGetConfiguration = (device: Device) => {
@@ -405,6 +406,22 @@ export default class ReactNativeBleTransport {
405
406
  if (error.reason?.includes('Encryption is insufficient')) {
406
407
  ERROR = HardwareErrorCode.BleDeviceBondError;
407
408
  }
409
+ if (
410
+ error.reason?.includes('Cannot write client characteristic config descriptor') ||
411
+ error.reason?.includes('Cannot find client characteristic config descriptor') ||
412
+ error.reason?.includes('The handle is invalid')
413
+ ) {
414
+ this.runPromise.reject(
415
+ ERRORS.TypedError(
416
+ HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
417
+ error.message ?? error.reason
418
+ )
419
+ );
420
+ this.Log.debug(
421
+ `${HardwareErrorCode.BleCharacteristicNotifyChangeFailure} ${error.message} ${error.reason}`
422
+ );
423
+ return;
424
+ }
408
425
  this.runPromise.reject(ERRORS.TypedError(ERROR, error.reason ?? error.message));
409
426
  this.Log.debug(': monitor notify error, and has unreleased Promise');
410
427
  }