@onekeyfe/hwk-adapter-core 1.2.10 → 1.2.11-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.
package/dist/index.mjs CHANGED
@@ -10,16 +10,17 @@ import {
10
10
  UI_REQUEST_TIMEOUT_TAG,
11
11
  UI_RESPONSE,
12
12
  UiRequestRegistry
13
- } from "./chunk-Z574MVAT.mjs";
13
+ } from "./chunk-5AIX6YY5.mjs";
14
14
  import {
15
15
  HardwareErrorCode,
16
16
  ORPHAN_ELIGIBLE_ERROR_CODES,
17
17
  createHwkError,
18
18
  defaultOriginForCode,
19
19
  defaultRecoveryForCode,
20
+ isHardwareErrorCode,
20
21
  isHwkRecoveryHint,
21
22
  operationMayHaveCompletedParams
22
- } from "./chunk-V2OHL2JS.mjs";
23
+ } from "./chunk-VKP46GTC.mjs";
23
24
 
24
25
  // src/types/response.ts
25
26
  function success(payload) {
@@ -846,6 +847,28 @@ var TypedEventEmitter = class {
846
847
  }
847
848
  };
848
849
 
850
+ // src/types/electronBle.ts
851
+ var isSerializedError = (value) => typeof value === "object" && value !== null && !(value instanceof Error) && typeof value.message === "string";
852
+ var restoreHostError = ({ message, code, params }) => isHardwareErrorCode(code) ? createHwkError({ code, message, ...params ? { params } : {} }) : new Error(message);
853
+ function rehydrateElectronBleErrors(bridge) {
854
+ const wrapped = Object.create(bridge);
855
+ for (const key of Object.keys(bridge)) {
856
+ if (typeof bridge[key] === "function") {
857
+ Object.defineProperty(wrapped, key, {
858
+ value: (...args) => {
859
+ const method = bridge[key];
860
+ const result = method.apply(bridge, args);
861
+ if (typeof result?.then !== "function") return result;
862
+ return Promise.resolve(result).catch((error) => {
863
+ throw isSerializedError(error) ? restoreHostError(error) : error;
864
+ });
865
+ }
866
+ });
867
+ }
868
+ }
869
+ return wrapped;
870
+ }
871
+
849
872
  // src/utils/requestSaveDeviceBinding.ts
850
873
  function emitDeviceBindingStatus(emitter, selectionRequestId, status) {
851
874
  emitter.emit(UI_REQUEST.DEVICE_BINDING_STATUS, {
@@ -1759,6 +1782,7 @@ export {
1759
1782
  hexToBytes,
1760
1783
  isAllNetworkMethodName,
1761
1784
  isConnectionLost,
1785
+ isHardwareErrorCode,
1762
1786
  isHardwareOperationId,
1763
1787
  isHwkRecoveryHint,
1764
1788
  isKnownNonTargetHardwareVendor,
@@ -1772,6 +1796,7 @@ export {
1772
1796
  pickConnectionContext,
1773
1797
  prepareSolanaOffchainMessageV1,
1774
1798
  rehydrateConnectorError,
1799
+ rehydrateElectronBleErrors,
1775
1800
  requestBleDeviceSelection,
1776
1801
  requestSaveDeviceBinding,
1777
1802
  resolveHardwareOperationTarget,