@onekeyfe/hd-core 1.1.19-alpha.3 → 1.1.19-alpha.4

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/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAsClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAiB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAIxD,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EAEV,6BAA6B,EAE9B,MAAM,wBAAwB,CAAC;AAKhC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA8D7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAuEvE,CAAC;AA8oBF,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SAkF9D,CAAC;AAsEF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AAyFF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,cAAc,CAAoB;IAE1C,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,YAAY,CAAsB;IAG1C,OAAO,CAAC,qBAAqB,CAA4B;IAEzD,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IAoBhB,aAAa,CAAC,OAAO,EAAE,WAAW;IA0DxC,OAAO;CAMR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAoBvC,CAAC;AAE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ASf,CAAC"}
package/dist/index.js CHANGED
@@ -39962,9 +39962,6 @@ function initDevice(method) {
39962
39962
  if (!device) {
39963
39963
  const env = DataManager.getSettings('env');
39964
39964
  if (DataManager.isWebUsbConnect(env)) {
39965
- if (!method.payload.skipWebDevicePrompt) {
39966
- postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
39967
- }
39968
39965
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission);
39969
39966
  }
39970
39967
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
@@ -40019,6 +40016,7 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
40019
40016
  Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
40020
40017
  const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
40021
40018
  return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
40019
+ var _k;
40022
40020
  const abort = () => {
40023
40021
  if (abortSignal && abortSignal.aborted) {
40024
40022
  if (timer) {
@@ -40112,7 +40110,6 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
40112
40110
  hdShared.HardwareErrorCode.SelectDevice,
40113
40111
  hdShared.HardwareErrorCode.DeviceDetectInBootloaderMode,
40114
40112
  hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
40115
- hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission,
40116
40113
  hdShared.HardwareErrorCode.BridgeNeedsPermission,
40117
40114
  ].includes(error.errorCode)) {
40118
40115
  reject(error);
@@ -40124,7 +40121,15 @@ const ensureConnected = (_context, method, pollingId, abortSignal) => __awaiter(
40124
40121
  clearTimeout(timer);
40125
40122
  }
40126
40123
  Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
40127
- reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound));
40124
+ if (DataManager.isWebUsbConnect(env)) {
40125
+ if (!((_k = method.payload) === null || _k === void 0 ? void 0 : _k.skipWebDevicePrompt)) {
40126
+ postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
40127
+ }
40128
+ reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
40129
+ }
40130
+ else {
40131
+ reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound));
40132
+ }
40128
40133
  return;
40129
40134
  }
40130
40135
  if (abort()) {
@@ -40410,7 +40415,7 @@ const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0,
40410
40415
  yield DataManager.load(settings);
40411
40416
  initTransport(Transport, plugin);
40412
40417
  }
40413
- catch (_k) {
40418
+ catch (_l) {
40414
40419
  Log.error('DataManager.load error');
40415
40420
  }
40416
40421
  enableLog(DataManager.getSettings('debug'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.1.19-alpha.3",
3
+ "version": "1.1.19-alpha.4",
4
4
  "description": "Core processes and APIs for communicating with OneKey hardware devices.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "1.1.19-alpha.3",
29
- "@onekeyfe/hd-transport": "1.1.19-alpha.3",
28
+ "@onekeyfe/hd-shared": "1.1.19-alpha.4",
29
+ "@onekeyfe/hd-transport": "1.1.19-alpha.4",
30
30
  "axios": "1.12.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/w3c-web-usb": "^1.0.10",
45
45
  "@types/web-bluetooth": "^0.0.21"
46
46
  },
47
- "gitHead": "9039715c7d1ec7ebaf71ec8e22737f3f2b013ca5"
47
+ "gitHead": "69284804bddd892cb4a4231bb1ad41a039ac80cc"
48
48
  }
package/src/core/index.ts CHANGED
@@ -644,9 +644,6 @@ function initDevice(method: BaseMethod) {
644
644
  if (!device) {
645
645
  const env = DataManager.getSettings('env');
646
646
  if (DataManager.isWebUsbConnect(env)) {
647
- if (!method.payload.skipWebDevicePrompt) {
648
- postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
649
- }
650
647
  throw ERRORS.TypedError(HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission);
651
648
  }
652
649
  throw ERRORS.TypedError(HardwareErrorCode.DeviceNotFound);
@@ -716,7 +713,6 @@ const ensureConnected = async (
716
713
  const POLL_INTERVAL_TIME = (method.payload && method.payload.pollIntervalTime) || 1000;
717
714
  const TIME_OUT = (method.payload && method.payload.timeout) || 10000;
718
715
  let timer: ReturnType<typeof setTimeout> | null = null;
719
-
720
716
  Log.debug(
721
717
  `EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `
722
718
  );
@@ -830,7 +826,6 @@ const ensureConnected = async (
830
826
  HardwareErrorCode.SelectDevice,
831
827
  HardwareErrorCode.DeviceDetectInBootloaderMode,
832
828
  HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
833
- HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission,
834
829
  HardwareErrorCode.BridgeNeedsPermission,
835
830
  ].includes(error.errorCode)
836
831
  ) {
@@ -844,7 +839,15 @@ const ensureConnected = async (
844
839
  clearTimeout(timer);
845
840
  }
846
841
  Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
847
- reject(ERRORS.TypedError(HardwareErrorCode.DeviceNotFound));
842
+ // WebUSB scenario: after all retries failed, send permission prompt and return error
843
+ if (DataManager.isWebUsbConnect(env)) {
844
+ if (!method.payload?.skipWebDevicePrompt) {
845
+ postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
846
+ }
847
+ reject(ERRORS.TypedError(HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
848
+ } else {
849
+ reject(ERRORS.TypedError(HardwareErrorCode.DeviceNotFound));
850
+ }
848
851
  return;
849
852
  }
850
853