@onekeyfe/hwk-trezor-adapter 1.2.8-alpha.13 → 1.2.8-alpha.130

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.d.mts CHANGED
@@ -50,6 +50,7 @@ declare class TrezorAdapter implements IHardwareWallet {
50
50
  private static readonly _sensitiveLogKeys;
51
51
  private static _normalizeLogKey;
52
52
  private static _sanitizeForLog;
53
+ private static _responseForLog;
53
54
  private static _redactForLog;
54
55
  private static _errorForLog;
55
56
  private _setPassphraseRequestContext;
@@ -123,8 +124,7 @@ declare class TrezorAdapter implements IHardwareWallet {
123
124
  private _getTrezorDeviceId;
124
125
  cancel(connectId?: string): void;
125
126
  /**
126
- * Operation owning the running job: its queue key when pinned, else the live
127
- * operation of its connectId, so a mid-call UI request can name it.
127
+ * Only the operation explicitly supplied to the running job owns its UI requests.
128
128
  */
129
129
  private _activeOperationId;
130
130
  /**
package/dist/index.d.ts CHANGED
@@ -50,6 +50,7 @@ declare class TrezorAdapter implements IHardwareWallet {
50
50
  private static readonly _sensitiveLogKeys;
51
51
  private static _normalizeLogKey;
52
52
  private static _sanitizeForLog;
53
+ private static _responseForLog;
53
54
  private static _redactForLog;
54
55
  private static _errorForLog;
55
56
  private _setPassphraseRequestContext;
@@ -123,8 +124,7 @@ declare class TrezorAdapter implements IHardwareWallet {
123
124
  private _getTrezorDeviceId;
124
125
  cancel(connectId?: string): void;
125
126
  /**
126
- * Operation owning the running job: its queue key when pinned, else the live
127
- * operation of its connectId, so a mid-call UI request can name it.
127
+ * Only the operation explicitly supplied to the running job owns its UI requests.
128
128
  */
129
129
  private _activeOperationId;
130
130
  /**
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@
27
27
 
28
28
 
29
29
 
30
+
30
31
 
31
32
 
32
33
  var _hwkadaptercore = require('@onekeyfe/hwk-adapter-core');
@@ -912,7 +913,8 @@ var _TrezorAdapter = class _TrezorAdapter {
912
913
  this._emitter.emit(data.type, { ...data, payload });
913
914
  };
914
915
  this._onUiEvent = (data) => {
915
- this._emitter.emit("ui-event", data);
916
+ const operationId = this._activeOperationId();
917
+ this._emitter.emit("ui-event", operationId ? { ...data, operationId } : data);
916
918
  };
917
919
  this._onThpCredentialsChanged = (data) => {
918
920
  this._emitter.emit(_hwkadaptercore.DEVICE.TREZOR_THP_CREDENTIALS_CHANGED, {
@@ -984,11 +986,21 @@ var _TrezorAdapter = class _TrezorAdapter {
984
986
  static _normalizeLogKey(key) {
985
987
  return key.replace(/[_-]/g, "").toLowerCase();
986
988
  }
987
- // Mirrors hd-core's logBlockEvent: a signing method's body is the user's
988
- // transaction, so it is dropped wholesale; other methods redact by key.
989
- static _sanitizeForLog(value, methodName) {
990
- if (methodName && /sign/i.test(methodName)) return "[redacted]";
991
- return _TrezorAdapter._redactForLog(value, /* @__PURE__ */ new WeakSet());
989
+ // [REQ]/[RES] bodies: paths, chain ids and flags stay readable; transaction
990
+ // contents, keys and addresses become length + short hash; secrets are redacted.
991
+ static _sanitizeForLog(value, methodName, role = "params") {
992
+ return _hwkadaptercore.summarizeForLog.call(void 0, value, { method: methodName, role });
993
+ }
994
+ // A failure payload is an error record, so its message/error text stays readable.
995
+ static _responseForLog(response, methodName) {
996
+ if (response.success) {
997
+ return _TrezorAdapter._sanitizeForLog(response.payload, methodName, "result");
998
+ }
999
+ const out = _hwkadaptercore.summarizeForLog.call(void 0,
1000
+ { error: response.payload },
1001
+ { method: methodName, role: "result" }
1002
+ );
1003
+ return out && typeof out === "object" ? out.error : out;
992
1004
  }
993
1005
  static _redactForLog(value, seen) {
994
1006
  if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
@@ -1009,14 +1021,17 @@ var _TrezorAdapter = class _TrezorAdapter {
1009
1021
  static _errorForLog(error) {
1010
1022
  if (!error || typeof error !== "object") return error;
1011
1023
  const typed = error;
1012
- return _TrezorAdapter._sanitizeForLog({
1013
- name: typed.name,
1014
- message: typed.message,
1015
- code: typed.code,
1016
- errorCode: typed.errorCode,
1017
- statusCode: typed.statusCode,
1018
- response: typed.response
1019
- });
1024
+ return _TrezorAdapter._redactForLog(
1025
+ {
1026
+ name: typed.name,
1027
+ message: typed.message,
1028
+ code: typed.code,
1029
+ errorCode: typed.errorCode,
1030
+ statusCode: typed.statusCode,
1031
+ response: typed.response
1032
+ },
1033
+ /* @__PURE__ */ new WeakSet()
1034
+ );
1020
1035
  }
1021
1036
  _setPassphraseRequestContext(connectId, context) {
1022
1037
  const previous = this._passphraseRequestContextByConnectId.get(connectId);
@@ -1413,6 +1428,10 @@ var _TrezorAdapter = class _TrezorAdapter {
1413
1428
  }
1414
1429
  async _releaseOperationConnection(operation) {
1415
1430
  const { connectId } = operation;
1431
+ const activeKey = _optionalChain([this, 'access', _49 => _49._jobQueue, 'access', _50 => _50.getActiveJob, 'call', _51 => _51(), 'optionalAccess', _52 => _52.deviceId]);
1432
+ if (activeKey !== void 0 && !_hwkadaptercore.isHardwareOperationId.call(void 0, activeKey) && (activeKey === connectId || activeKey === "" || activeKey === operation.device.deviceId)) {
1433
+ return;
1434
+ }
1416
1435
  const connecting = this._connectingPromises.has(connectId);
1417
1436
  this._connectingPromises.delete(connectId);
1418
1437
  const sessionId = this._sessions.get(connectId);
@@ -1450,7 +1469,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1450
1469
  const bundleContext = {};
1451
1470
  const topLevelFailureIndexes = /* @__PURE__ */ new Set();
1452
1471
  const isSingleNetworkBundle = params.bundle.every(
1453
- (item) => item.network === _optionalChain([params, 'access', _49 => _49.bundle, 'access', _50 => _50[0], 'optionalAccess', _51 => _51.network])
1472
+ (item) => item.network === _optionalChain([params, 'access', _53 => _53.bundle, 'access', _54 => _54[0], 'optionalAccess', _55 => _55.network])
1454
1473
  );
1455
1474
  const getLiveDeviceId = async (expectedDeviceId) => {
1456
1475
  if (liveDeviceId) return _hwkadaptercore.success.call(void 0, liveDeviceId);
@@ -1463,7 +1482,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1463
1482
  if (deviceIdResponse.success) {
1464
1483
  liveDeviceId = deviceIdResponse.payload;
1465
1484
  if (!target.payload.operationId) {
1466
- effectiveTargetId = _nullishCoalesce(_optionalChain([bundleContext, 'access', _52 => _52.connection, 'optionalAccess', _53 => _53.connectId]), () => ( effectiveTargetId));
1485
+ effectiveTargetId = _nullishCoalesce(_optionalChain([bundleContext, 'access', _56 => _56.connection, 'optionalAccess', _57 => _57.connectId]), () => ( effectiveTargetId));
1467
1486
  }
1468
1487
  }
1469
1488
  return deviceIdResponse;
@@ -1528,14 +1547,14 @@ var _TrezorAdapter = class _TrezorAdapter {
1528
1547
  // One named boolean per abort reason.
1529
1548
  shouldAbortBundle: (response, { index }) => {
1530
1549
  const isSessionLevelFailure = topLevelFailureIndexes.has(index);
1531
- const isWholeChainForbidden = isSingleNetworkBundle && _optionalChain([response, 'access', _54 => _54.payload, 'optionalAccess', _55 => _55.code]) === _hwkadaptercore.HardwareErrorCode.DevicePathForbidden;
1550
+ const isWholeChainForbidden = isSingleNetworkBundle && _optionalChain([response, 'access', _58 => _58.payload, 'optionalAccess', _59 => _59.code]) === _hwkadaptercore.HardwareErrorCode.DevicePathForbidden;
1532
1551
  const { code } = _nullishCoalesce(response.payload, () => ( {}));
1533
1552
  return isSessionLevelFailure || isWholeChainForbidden || _hwkadaptercore.isWalletSafetyFailure.call(void 0, code) || _hwkadaptercore.isUserRefusal.call(void 0, code) || _hwkadaptercore.isConnectionLost.call(void 0, code);
1534
1553
  }
1535
1554
  });
1536
1555
  } finally {
1537
1556
  cancelScope.release();
1538
- _optionalChain([releaseOperationRetention, 'optionalCall', _56 => _56()]);
1557
+ _optionalChain([releaseOperationRetention, 'optionalCall', _60 => _60()]);
1539
1558
  }
1540
1559
  }
1541
1560
  getFeatures(connectId, operationContext) {
@@ -1579,7 +1598,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1579
1598
  if (!internalModel) {
1580
1599
  return _hwkadaptercore.failure.call(void 0, _hwkadaptercore.HardwareErrorCode.UnknownError, "Device internal_model unavailable");
1581
1600
  }
1582
- const challengeHex = _nullishCoalesce(_optionalChain([params, 'access', _57 => _57.challenge, 'optionalAccess', _58 => _58.toLowerCase, 'call', _59 => _59()]), () => ( Buffer.from(_utils.randomBytes.call(void 0, 32)).toString("hex")));
1601
+ const challengeHex = _nullishCoalesce(_optionalChain([params, 'access', _61 => _61.challenge, 'optionalAccess', _62 => _62.toLowerCase, 'call', _63 => _63()]), () => ( Buffer.from(_utils.randomBytes.call(void 0, 32)).toString("hex")));
1583
1602
  const challenge = Buffer.from(challengeHex, "hex");
1584
1603
  const proofRes = await this._callDeviceManagerMethod(
1585
1604
  "authenticateDevice",
@@ -1637,20 +1656,24 @@ var _TrezorAdapter = class _TrezorAdapter {
1637
1656
  );
1638
1657
  }
1639
1658
  async _getTrezorDeviceId(connectId, expectedDeviceId, commonParams, bundleContext) {
1640
- const hasConnectionContext = _optionalChain([commonParams, 'optionalAccess', _60 => _60.knownConnections]) !== void 0 || _optionalChain([commonParams, 'optionalAccess', _61 => _61.extra]) !== void 0;
1659
+ const hasConnectionContext = _optionalChain([commonParams, 'optionalAccess', _64 => _64.knownConnections]) !== void 0 || _optionalChain([commonParams, 'optionalAccess', _65 => _65.extra]) !== void 0;
1641
1660
  const features = bundleContext || hasConnectionContext ? await this._callMethod(
1642
1661
  "getFeatures",
1643
1662
  connectId,
1644
1663
  hasConnectionContext || !connectId ? expectedDeviceId : void 0,
1645
- hasConnectionContext ? {
1646
- operationId: commonParams.operationId,
1647
- knownConnections: commonParams.knownConnections,
1648
- extra: commonParams.extra,
1649
- allowDeviceSelection: commonParams.allowDeviceSelection,
1650
- supportedTransports: commonParams.supportedTransports,
1651
- passphraseState: commonParams.passphraseState,
1652
- useEmptyPassphrase: commonParams.useEmptyPassphrase
1653
- } : {},
1664
+ {
1665
+ // Routing limits always apply: the connection found here is reused by the whole
1666
+ // bundle, so dropping them would let a bundle open a transport the host excluded.
1667
+ operationId: _optionalChain([commonParams, 'optionalAccess', _66 => _66.operationId]),
1668
+ knownConnections: _optionalChain([commonParams, 'optionalAccess', _67 => _67.knownConnections]),
1669
+ extra: _optionalChain([commonParams, 'optionalAccess', _68 => _68.extra]),
1670
+ allowDeviceSelection: _optionalChain([commonParams, 'optionalAccess', _69 => _69.allowDeviceSelection]),
1671
+ supportedTransports: _optionalChain([commonParams, 'optionalAccess', _70 => _70.supportedTransports]),
1672
+ ...hasConnectionContext ? {
1673
+ passphraseState: commonParams.passphraseState,
1674
+ useEmptyPassphrase: commonParams.useEmptyPassphrase
1675
+ } : {}
1676
+ },
1654
1677
  false,
1655
1678
  bundleContext
1656
1679
  ) : await this.getFeatures(
@@ -1681,7 +1704,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1681
1704
  const userAbortReason = Object.assign(new Error("User aborted operation"), {
1682
1705
  code: _hwkadaptercore.HardwareErrorCode.UserAborted
1683
1706
  });
1684
- const activeJobId = _optionalChain([this, 'access', _62 => _62._jobQueue, 'access', _63 => _63.getActiveJob, 'call', _64 => _64(), 'optionalAccess', _65 => _65.deviceId]);
1707
+ const activeJobId = _optionalChain([this, 'access', _71 => _71._jobQueue, 'access', _72 => _72.getActiveJob, 'call', _73 => _73(), 'optionalAccess', _74 => _74.deviceId]);
1685
1708
  const targetId = _nullishCoalesce(connectId, () => ( activeJobId));
1686
1709
  if (targetId) {
1687
1710
  let resolvedConnectId = targetId;
@@ -1695,7 +1718,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1695
1718
  }
1696
1719
  }
1697
1720
  const interactionForPhysicalId = !operationId && connectId ? this._operations.findActiveByConnectionKey(connectId) : void 0;
1698
- const pendingOperationId = _nullishCoalesce(operationId, () => ( _optionalChain([interactionForPhysicalId, 'optionalAccess', _66 => _66.operationId])));
1721
+ const pendingOperationId = _nullishCoalesce(operationId, () => ( _optionalChain([interactionForPhysicalId, 'optionalAccess', _75 => _75.operationId])));
1699
1722
  if (!connectId) {
1700
1723
  this._uiRegistry.cancel();
1701
1724
  } else if (pendingOperationId) {
@@ -1710,7 +1733,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1710
1733
  for (const key of queueKeys) {
1711
1734
  this._jobQueue.cancelActiveAndPending(key, userAbortReason);
1712
1735
  }
1713
- if (resolvedConnectId) {
1736
+ if (resolvedConnectId && (activeJobId === void 0 || ownsConnectorInteraction)) {
1714
1737
  void this._connector.cancel(_nullishCoalesce(this._sessions.get(resolvedConnectId), () => ( resolvedConnectId)));
1715
1738
  }
1716
1739
  return;
@@ -1723,11 +1746,10 @@ var _TrezorAdapter = class _TrezorAdapter {
1723
1746
  }
1724
1747
  }
1725
1748
  /**
1726
- * Operation owning the running job: its queue key when pinned, else the live
1727
- * operation of its connectId, so a mid-call UI request can name it.
1749
+ * Only the operation explicitly supplied to the running job owns its UI requests.
1728
1750
  */
1729
1751
  _activeOperationId() {
1730
- return this._operations.findOperationIdByJobKey(_optionalChain([this, 'access', _67 => _67._jobQueue, 'access', _68 => _68.getActiveJob, 'call', _69 => _69(), 'optionalAccess', _70 => _70.deviceId]));
1752
+ return this._operations.findOperationIdByJobKey(_optionalChain([this, 'access', _76 => _76._jobQueue, 'access', _77 => _77.getActiveJob, 'call', _78 => _78(), 'optionalAccess', _79 => _79.deviceId]));
1731
1753
  }
1732
1754
  /**
1733
1755
  * Routes to BOTH the adapter's local UI registry (preemption decisions,
@@ -1761,7 +1783,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1761
1783
  * the THP session selection).
1762
1784
  */
1763
1785
  getPassphraseState(connectId, passphraseState, operationContext) {
1764
- const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _71 => _71.expectedDeviceIdentity]);
1786
+ const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _80 => _80.expectedDeviceIdentity]);
1765
1787
  if (expectedIdentity && (expectedIdentity.vendor !== "trezor" || expectedIdentity.type !== "deviceId")) {
1766
1788
  return Promise.resolve(
1767
1789
  _hwkadaptercore.failure.call(void 0, _hwkadaptercore.HardwareErrorCode.InvalidParams, "Trezor device identity is required")
@@ -1769,7 +1791,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1769
1791
  }
1770
1792
  const target = _hwkadaptercore.resolveHardwareOperationTarget.call(void 0,
1771
1793
  connectId,
1772
- _optionalChain([operationContext, 'optionalAccess', _72 => _72.operationId]),
1794
+ _optionalChain([operationContext, 'optionalAccess', _81 => _81.operationId]),
1773
1795
  "trezor"
1774
1796
  );
1775
1797
  if (!target.success) return Promise.resolve(target);
@@ -1790,7 +1812,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1790
1812
  let selectionRequestId;
1791
1813
  let verified = false;
1792
1814
  try {
1793
- if (!operationId && _optionalChain([expectedIdentity, 'optionalAccess', _73 => _73.value]) && (!connectId || _optionalChain([operationContext, 'optionalAccess', _74 => _74.knownConnections]) !== void 0)) {
1815
+ if (!operationId && _optionalChain([expectedIdentity, 'optionalAccess', _82 => _82.value]) && (!connectId || _optionalChain([operationContext, 'optionalAccess', _83 => _83.knownConnections]) !== void 0)) {
1794
1816
  const resolved = await this._resolveExpectedDeviceConnectId(
1795
1817
  expectedIdentity.value,
1796
1818
  signal,
@@ -1799,9 +1821,9 @@ var _TrezorAdapter = class _TrezorAdapter {
1799
1821
  resolvedConnectId = resolved.connectId;
1800
1822
  selectionRequestId = resolved.selectionRequestId;
1801
1823
  }
1802
- if (_optionalChain([expectedIdentity, 'optionalAccess', _75 => _75.value])) {
1824
+ if (_optionalChain([expectedIdentity, 'optionalAccess', _84 => _84.value])) {
1803
1825
  if (!operationId) await this._ensureSession(resolvedConnectId, signal);
1804
- if (_optionalChain([this, 'access', _76 => _76._devices, 'access', _77 => _77.get, 'call', _78 => _78(resolvedConnectId), 'optionalAccess', _79 => _79.deviceId]) !== expectedIdentity.value) {
1826
+ if (_optionalChain([this, 'access', _85 => _85._devices, 'access', _86 => _86.get, 'call', _87 => _87(resolvedConnectId), 'optionalAccess', _88 => _88.deviceId]) !== expectedIdentity.value) {
1805
1827
  return _hwkadaptercore.failure.call(void 0,
1806
1828
  _hwkadaptercore.HardwareErrorCode.DeviceMismatch,
1807
1829
  "Trezor device identity does not match"
@@ -1821,7 +1843,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1821
1843
  signal,
1822
1844
  operationId
1823
1845
  );
1824
- if (result.success && _optionalChain([expectedIdentity, 'optionalAccess', _80 => _80.value])) {
1846
+ if (result.success && _optionalChain([expectedIdentity, 'optionalAccess', _89 => _89.value])) {
1825
1847
  await this._emitVerifiedBinding(
1826
1848
  expectedIdentity.value,
1827
1849
  resolvedConnectId,
@@ -1848,7 +1870,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1848
1870
  rejectIfBusy: true,
1849
1871
  busyError: _TrezorAdapter._createDeviceBusyError("getPassphraseState")
1850
1872
  }
1851
- ).catch((error) => this._errorToFailure(error)).finally(() => _optionalChain([releaseOperationRetention, 'optionalCall', _81 => _81()]));
1873
+ ).catch((error) => this._errorToFailure(error)).finally(() => _optionalChain([releaseOperationRetention, 'optionalCall', _90 => _90()]));
1852
1874
  }
1853
1875
  evmGetAddress(connectId, deviceId, params) {
1854
1876
  return this._callWalletMethod("evmGetAddress", connectId, deviceId, params);
@@ -1912,7 +1934,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1912
1934
  return result;
1913
1935
  }
1914
1936
  async _callConnector(sessionId, method, params, signal) {
1915
- if (_optionalChain([signal, 'optionalAccess', _82 => _82.aborted])) {
1937
+ if (_optionalChain([signal, 'optionalAccess', _91 => _91.aborted])) {
1916
1938
  throw _nullishCoalesce(signal.reason, () => ( new Error("Aborted")));
1917
1939
  }
1918
1940
  this._assertConnectorIdle(method);
@@ -1962,7 +1984,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1962
1984
  }
1963
1985
  /** Transports the connector offers and the host's model table allows; discovery opens no other. */
1964
1986
  _allowedTransports(context) {
1965
- const supported = _optionalChain([context, 'optionalAccess', _83 => _83.supportedTransports]);
1987
+ const supported = _optionalChain([context, 'optionalAccess', _92 => _92.supportedTransports]);
1966
1988
  const available = this._availableTransports();
1967
1989
  return supported ? available.filter((transport) => supported.includes(transport)) : available;
1968
1990
  }
@@ -2050,7 +2072,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2050
2072
  return this._callMethod(methodName, connectId, deviceId, params, true);
2051
2073
  }
2052
2074
  _callDeviceManagerMethod(methodName, connectId, params, operationContext) {
2053
- const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _84 => _84.expectedDeviceIdentity]);
2075
+ const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _93 => _93.expectedDeviceIdentity]);
2054
2076
  if (expectedIdentity && (expectedIdentity.vendor !== "trezor" || expectedIdentity.type !== "deviceId")) {
2055
2077
  return Promise.resolve(
2056
2078
  _hwkadaptercore.failure.call(void 0,
@@ -2062,14 +2084,14 @@ var _TrezorAdapter = class _TrezorAdapter {
2062
2084
  return this._callMethod(
2063
2085
  methodName,
2064
2086
  connectId,
2065
- _optionalChain([expectedIdentity, 'optionalAccess', _85 => _85.value]),
2087
+ _optionalChain([expectedIdentity, 'optionalAccess', _94 => _94.value]),
2066
2088
  {
2067
2089
  ...params && typeof params === "object" ? params : {},
2068
- knownConnections: _optionalChain([operationContext, 'optionalAccess', _86 => _86.knownConnections]),
2069
- extra: _optionalChain([operationContext, 'optionalAccess', _87 => _87.extra]),
2070
- allowDeviceSelection: _optionalChain([operationContext, 'optionalAccess', _88 => _88.allowDeviceSelection]),
2071
- supportedTransports: _optionalChain([operationContext, 'optionalAccess', _89 => _89.supportedTransports]),
2072
- ..._optionalChain([operationContext, 'optionalAccess', _90 => _90.operationId]) ? { operationId: operationContext.operationId } : {}
2090
+ knownConnections: _optionalChain([operationContext, 'optionalAccess', _95 => _95.knownConnections]),
2091
+ extra: _optionalChain([operationContext, 'optionalAccess', _96 => _96.extra]),
2092
+ allowDeviceSelection: _optionalChain([operationContext, 'optionalAccess', _97 => _97.allowDeviceSelection]),
2093
+ supportedTransports: _optionalChain([operationContext, 'optionalAccess', _98 => _98.supportedTransports]),
2094
+ ..._optionalChain([operationContext, 'optionalAccess', _99 => _99.operationId]) ? { operationId: operationContext.operationId } : {}
2073
2095
  },
2074
2096
  false
2075
2097
  );
@@ -2107,7 +2129,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2107
2129
  let effectiveConnectId = call.connectId;
2108
2130
  let selectionRequestId;
2109
2131
  try {
2110
- if (!_optionalChain([bundleContext, 'optionalAccess', _91 => _91.connection]) && !operationId && deviceId && (!connectId || _optionalChain([commonParams, 'access', _92 => _92.connectionContext, 'optionalAccess', _93 => _93.knownConnections]) !== void 0)) {
2132
+ if (!_optionalChain([bundleContext, 'optionalAccess', _100 => _100.connection]) && !operationId && deviceId && (!connectId || _optionalChain([commonParams, 'access', _101 => _101.connectionContext, 'optionalAccess', _102 => _102.knownConnections]) !== void 0)) {
2111
2133
  const resolved = await this._resolveExpectedDeviceConnectId(
2112
2134
  deviceId,
2113
2135
  signal,
@@ -2120,7 +2142,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2120
2142
  return this._errorToFailure(error);
2121
2143
  }
2122
2144
  const response2 = await this._callWithRetry(
2123
- _nullishCoalesce(_optionalChain([bundleContext, 'optionalAccess', _94 => _94.connection, 'optionalAccess', _95 => _95.connectId]), () => ( effectiveConnectId)),
2145
+ _nullishCoalesce(_optionalChain([bundleContext, 'optionalAccess', _103 => _103.connection, 'optionalAccess', _104 => _104.connectId]), () => ( effectiveConnectId)),
2124
2146
  methodName,
2125
2147
  call.params,
2126
2148
  deviceId || "",
@@ -2145,7 +2167,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2145
2167
  debugLog("[TrezorAdapter][RES]", {
2146
2168
  method: methodName,
2147
2169
  success: response.success,
2148
- payload: _TrezorAdapter._sanitizeForLog(response.payload, methodName)
2170
+ payload: _TrezorAdapter._responseForLog(response, methodName)
2149
2171
  });
2150
2172
  return response;
2151
2173
  } catch (error) {
@@ -2153,11 +2175,11 @@ var _TrezorAdapter = class _TrezorAdapter {
2153
2175
  debugLog("[TrezorAdapter][RES]", {
2154
2176
  method: methodName,
2155
2177
  success: false,
2156
- payload: _TrezorAdapter._sanitizeForLog(response.payload, methodName)
2178
+ payload: _TrezorAdapter._responseForLog(response, methodName)
2157
2179
  });
2158
2180
  return response;
2159
2181
  } finally {
2160
- _optionalChain([releaseOperationRetention, 'optionalCall', _96 => _96()]);
2182
+ _optionalChain([releaseOperationRetention, 'optionalCall', _105 => _105()]);
2161
2183
  }
2162
2184
  }
2163
2185
  async _callWithRetry(connectId, methodName, params, expectedDeviceId, requiresWalletIntent, allowRetry, signal, operationId, selectionRequestId, bundleContext) {
@@ -2169,7 +2191,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2169
2191
  useEmptyPassphrase
2170
2192
  });
2171
2193
  try {
2172
- if (_optionalChain([bundleContext, 'optionalAccess', _97 => _97.connection])) {
2194
+ if (_optionalChain([bundleContext, 'optionalAccess', _106 => _106.connection])) {
2173
2195
  const pinned = bundleContext.connection;
2174
2196
  if (this._sessions.get(pinned.connectId) !== pinned.sessionId) {
2175
2197
  return _hwkadaptercore.failure.call(void 0,
@@ -2194,7 +2216,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2194
2216
  bundleContext.connection = { connectId, sessionId };
2195
2217
  }
2196
2218
  if (expectedDeviceId) {
2197
- const actualDeviceId = _optionalChain([this, 'access', _98 => _98._devices, 'access', _99 => _99.get, 'call', _100 => _100(connectId), 'optionalAccess', _101 => _101.deviceId]);
2219
+ const actualDeviceId = _optionalChain([this, 'access', _107 => _107._devices, 'access', _108 => _108.get, 'call', _109 => _109(connectId), 'optionalAccess', _110 => _110.deviceId]);
2198
2220
  if (!actualDeviceId || actualDeviceId !== expectedDeviceId) {
2199
2221
  return _hwkadaptercore.failure.call(void 0,
2200
2222
  _hwkadaptercore.HardwareErrorCode.DeviceMismatch,
@@ -2319,7 +2341,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2319
2341
  if (pending) return pending;
2320
2342
  const stateGeneration = this._stateGeneration;
2321
2343
  const promise = (async () => {
2322
- if (_optionalChain([signal, 'optionalAccess', _102 => _102.aborted])) {
2344
+ if (_optionalChain([signal, 'optionalAccess', _111 => _111.aborted])) {
2323
2345
  throw Object.assign(new Error("Trezor connection aborted"), {
2324
2346
  code: _hwkadaptercore.HardwareErrorCode.UserAborted
2325
2347
  });
@@ -2366,13 +2388,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2366
2388
  ) : [];
2367
2389
  const mismatchedDeviceIds = [];
2368
2390
  const knownConnection = this._knownDeviceConnections.get(expectedDeviceId);
2369
- const knownUsbIds = _optionalChain([context, 'optionalAccess', _103 => _103.knownConnections]) !== void 0 ? context.knownConnections.flatMap(
2391
+ const knownUsbIds = _optionalChain([context, 'optionalAccess', _112 => _112.knownConnections]) !== void 0 ? context.knownConnections.flatMap(
2370
2392
  (connection) => connection.transport === "usb" ? [connection.connectId] : []
2371
- ) : [_optionalChain([knownConnection, 'optionalAccess', _104 => _104.usbConnectId])].filter((id) => Boolean(id));
2372
- const suppliedBleIds = _optionalChain([context, 'optionalAccess', _105 => _105.knownConnections, 'optionalAccess', _106 => _106.flatMap, 'call', _107 => _107(
2393
+ ) : [_optionalChain([knownConnection, 'optionalAccess', _113 => _113.usbConnectId])].filter((id) => Boolean(id));
2394
+ const suppliedBleIds = _optionalChain([context, 'optionalAccess', _114 => _114.knownConnections, 'optionalAccess', _115 => _115.flatMap, 'call', _116 => _116(
2373
2395
  (connection) => connection.transport === "ble" ? [connection.connectId] : []
2374
2396
  )]);
2375
- const knownBleIds = _optionalChain([suppliedBleIds, 'optionalAccess', _108 => _108.length]) ? suppliedBleIds : [_optionalChain([knownConnection, 'optionalAccess', _109 => _109.bleConnectId])].filter((id) => Boolean(id));
2397
+ const knownBleIds = _optionalChain([suppliedBleIds, 'optionalAccess', _117 => _117.length]) ? suppliedBleIds : [_optionalChain([knownConnection, 'optionalAccess', _118 => _118.bleConnectId])].filter((id) => Boolean(id));
2376
2398
  const usbCandidates = candidates.filter(
2377
2399
  (device) => device.connectionType === "usb" && (!knownUsbIds.length || knownUsbIds.includes(device.connectId))
2378
2400
  );
@@ -2381,7 +2403,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2381
2403
  const probeOpensSession = !this._hasSessionOrConnect(candidate.connectId);
2382
2404
  try {
2383
2405
  sessionId = await this._ensureSession(candidate.connectId, signal, "usb");
2384
- const actualDeviceId = _nullishCoalesce(_optionalChain([this, 'access', _110 => _110._devices, 'access', _111 => _111.get, 'call', _112 => _112(candidate.connectId), 'optionalAccess', _113 => _113.deviceId]), () => ( ""));
2406
+ const actualDeviceId = _nullishCoalesce(_optionalChain([this, 'access', _119 => _119._devices, 'access', _120 => _120.get, 'call', _121 => _121(candidate.connectId), 'optionalAccess', _122 => _122.deviceId]), () => ( ""));
2385
2407
  if (actualDeviceId === expectedDeviceId) return { connectId: candidate.connectId };
2386
2408
  mismatchedDeviceIds.push(actualDeviceId || "unknown");
2387
2409
  } catch (error) {
@@ -2413,7 +2435,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2413
2435
  );
2414
2436
  const probeOpensSession = !this._hasSessionOrConnect(knownBleConnectId);
2415
2437
  await this._ensureSession(knownBleConnectId, signal, "ble");
2416
- const actualDeviceId = _optionalChain([this, 'access', _114 => _114._devices, 'access', _115 => _115.get, 'call', _116 => _116(knownBleConnectId), 'optionalAccess', _117 => _117.deviceId]);
2438
+ const actualDeviceId = _optionalChain([this, 'access', _123 => _123._devices, 'access', _124 => _124.get, 'call', _125 => _125(knownBleConnectId), 'optionalAccess', _126 => _126.deviceId]);
2417
2439
  if (actualDeviceId === expectedDeviceId) return { connectId: knownBleConnectId };
2418
2440
  if (probeOpensSession) await this._disconnectSession(knownBleConnectId);
2419
2441
  throw _hwkadaptercore.createHwkError.call(void 0, {
@@ -2421,13 +2443,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2421
2443
  message: "The bound Trezor Bluetooth device has a different identity"
2422
2444
  });
2423
2445
  }
2424
- if (_optionalChain([context, 'optionalAccess', _118 => _118.supportedTransports]) && !context.supportedTransports.includes("ble")) {
2446
+ if (_optionalChain([context, 'optionalAccess', _127 => _127.supportedTransports]) && !context.supportedTransports.includes("ble")) {
2425
2447
  throw _hwkadaptercore.createHwkError.call(void 0, {
2426
2448
  code: _hwkadaptercore.HardwareErrorCode.DeviceNotFound,
2427
2449
  message: "This Trezor model has no Bluetooth transport; connect it over USB"
2428
2450
  });
2429
2451
  }
2430
- if (_optionalChain([context, 'optionalAccess', _119 => _119.allowDeviceSelection]) === false) {
2452
+ if (_optionalChain([context, 'optionalAccess', _128 => _128.allowDeviceSelection]) === false) {
2431
2453
  throw _hwkadaptercore.createHwkError.call(void 0, {
2432
2454
  code: _hwkadaptercore.HardwareErrorCode.DeviceNotFound,
2433
2455
  message: "No known Trezor connection is available"
@@ -2438,9 +2460,9 @@ var _TrezorAdapter = class _TrezorAdapter {
2438
2460
  async _selectBleDeviceForBinding(expectedDeviceId, signal, context, reason) {
2439
2461
  const availableTransports = this._allowedTransports(context);
2440
2462
  const allowUsbFallback = reason !== "manual-rebind" && availableTransports.includes("usb");
2441
- const knownUsbIds = _optionalChain([context, 'optionalAccess', _120 => _120.knownConnections]) ? context.knownConnections.flatMap(
2463
+ const knownUsbIds = _optionalChain([context, 'optionalAccess', _129 => _129.knownConnections]) ? context.knownConnections.flatMap(
2442
2464
  (connection) => connection.transport === "usb" ? [connection.connectId] : []
2443
- ) : [_optionalChain([this, 'access', _121 => _121._knownDeviceConnections, 'access', _122 => _122.get, 'call', _123 => _123(expectedDeviceId), 'optionalAccess', _124 => _124.usbConnectId])];
2465
+ ) : [_optionalChain([this, 'access', _130 => _130._knownDeviceConnections, 'access', _131 => _131.get, 'call', _132 => _132(expectedDeviceId), 'optionalAccess', _133 => _133.usbConnectId])];
2444
2466
  if (availableTransports.includes("ble")) {
2445
2467
  await _TrezorAdapter._abortable(
2446
2468
  signal,
@@ -2482,7 +2504,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2482
2504
  transport: "ble",
2483
2505
  reason
2484
2506
  },
2485
- extra: _optionalChain([context, 'optionalAccess', _125 => _125.extra]),
2507
+ extra: _optionalChain([context, 'optionalAccess', _134 => _134.extra]),
2486
2508
  operationId: this._activeOperationId()
2487
2509
  }
2488
2510
  });
@@ -2498,7 +2520,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2498
2520
  this._emitBindingStatus(requestId, signal.aborted ? "cancelled" : "failed");
2499
2521
  throw error;
2500
2522
  }
2501
- if (_optionalChain([this, 'access', _126 => _126._devices, 'access', _127 => _127.get, 'call', _128 => _128(selected.connectId), 'optionalAccess', _129 => _129.deviceId]) !== expectedDeviceId) {
2523
+ if (_optionalChain([this, 'access', _135 => _135._devices, 'access', _136 => _136.get, 'call', _137 => _137(selected.connectId), 'optionalAccess', _138 => _138.deviceId]) !== expectedDeviceId) {
2502
2524
  if (probeOpensSession) await this._disconnectSession(selected.connectId);
2503
2525
  rejectedConnectId = selected.connectId;
2504
2526
  rejectedConnectIds.add(selected.connectId);
@@ -2524,7 +2546,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2524
2546
  const known = _nullishCoalesce(this._knownDeviceConnections.get(deviceId), () => ( { deviceId }));
2525
2547
  if (device.connectionType === "ble") {
2526
2548
  known.bleConnectId = connectId;
2527
- } else if (device.connectionType === "usb" && _optionalChain([device, 'access', _130 => _130.capabilities, 'optionalAccess', _131 => _131.persistentDeviceIdentity])) {
2549
+ } else if (device.connectionType === "usb" && _optionalChain([device, 'access', _139 => _139.capabilities, 'optionalAccess', _140 => _140.persistentDeviceIdentity])) {
2528
2550
  known.usbConnectId = connectId;
2529
2551
  }
2530
2552
  this._knownDeviceConnections.set(deviceId, known);
@@ -2543,7 +2565,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2543
2565
  selectionRequestId,
2544
2566
  connection: { transport: "ble", connectId },
2545
2567
  identity: { vendor: "trezor", type: "deviceId", value: deviceId },
2546
- extra: _optionalChain([context, 'optionalAccess', _132 => _132.extra]),
2568
+ extra: _optionalChain([context, 'optionalAccess', _141 => _141.extra]),
2547
2569
  operationId: this._activeOperationId()
2548
2570
  },
2549
2571
  signal
@@ -2579,7 +2601,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2579
2601
  signal
2580
2602
  )
2581
2603
  );
2582
- if (_optionalChain([created, 'optionalAccess', _133 => _133.protocol]) === "thp" && !created.thpSessionId || _optionalChain([created, 'optionalAccess', _134 => _134.protocol]) !== "thp" && _optionalChain([created, 'optionalAccess', _135 => _135.protocol]) !== "v1") {
2604
+ if (_optionalChain([created, 'optionalAccess', _142 => _142.protocol]) === "thp" && !created.thpSessionId || _optionalChain([created, 'optionalAccess', _143 => _143.protocol]) !== "thp" && _optionalChain([created, 'optionalAccess', _144 => _144.protocol]) !== "v1") {
2583
2605
  throw _hwkadaptercore.createHwkError.call(void 0, {
2584
2606
  code: _hwkadaptercore.HardwareErrorCode.TransportError,
2585
2607
  message: "Cannot verify the requested Trezor wallet session"
@@ -2598,13 +2620,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2598
2620
  }
2599
2621
  _rememberVerifiedPassphraseSession(connectId, passphraseState, sessionId, created) {
2600
2622
  let session;
2601
- if (_optionalChain([created, 'optionalAccess', _136 => _136.protocol]) === "thp" && typeof created.thpSessionId === "string") {
2623
+ if (_optionalChain([created, 'optionalAccess', _145 => _145.protocol]) === "thp" && typeof created.thpSessionId === "string") {
2602
2624
  session = {
2603
2625
  sessionId,
2604
2626
  protocol: "thp",
2605
2627
  thpSessionId: created.thpSessionId
2606
2628
  };
2607
- } else if (_optionalChain([created, 'optionalAccess', _137 => _137.protocol]) === "v1") {
2629
+ } else if (_optionalChain([created, 'optionalAccess', _146 => _146.protocol]) === "v1") {
2608
2630
  session = {
2609
2631
  sessionId,
2610
2632
  protocol: "v1"
@@ -2624,7 +2646,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2624
2646
  }
2625
2647
  }
2626
2648
  async _reuseVerifiedPassphraseSession(connectId, sessionId, passphraseState, signal) {
2627
- const cached = _optionalChain([this, 'access', _138 => _138._verifiedPassphraseSessionsByConnectId, 'access', _139 => _139.get, 'call', _140 => _140(connectId), 'optionalAccess', _141 => _141.get, 'call', _142 => _142(passphraseState)]);
2649
+ const cached = _optionalChain([this, 'access', _147 => _147._verifiedPassphraseSessionsByConnectId, 'access', _148 => _148.get, 'call', _149 => _149(connectId), 'optionalAccess', _150 => _150.get, 'call', _151 => _151(passphraseState)]);
2628
2650
  if (!cached || cached.sessionId !== sessionId) {
2629
2651
  this._forgetVerifiedPassphraseSession(connectId, passphraseState);
2630
2652
  return false;
@@ -2691,7 +2713,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2691
2713
  signal
2692
2714
  )
2693
2715
  );
2694
- const state = _optionalChain([derived, 'optionalAccess', _143 => _143.publicKey]);
2716
+ const state = _optionalChain([derived, 'optionalAccess', _152 => _152.publicKey]);
2695
2717
  if (!state) {
2696
2718
  throw Object.assign(new Error("Failed to derive passphrase state (wallet public key)"), {
2697
2719
  code: _hwkadaptercore.HardwareErrorCode.UnknownError
@@ -2728,7 +2750,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2728
2750
  signal,
2729
2751
  this._callConnector(sessionId, "getFeatures", { refresh: true }, signal)
2730
2752
  );
2731
- if (_optionalChain([features, 'optionalAccess', _144 => _144.passphrase_protection]) !== true) {
2753
+ if (_optionalChain([features, 'optionalAccess', _153 => _153.passphrase_protection]) !== true) {
2732
2754
  return _hwkadaptercore.success.call(void 0, null);
2733
2755
  }
2734
2756
  this._rememberVerifiedPassphraseSession(connectId, state, sessionId, created);
@@ -2776,7 +2798,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2776
2798
  }
2777
2799
  const trustedNumericCode = typeof typed.code === "number" && KNOWN_HARDWARE_ERROR_CODES.has(typed.code) ? typed.code : void 0;
2778
2800
  const code = _nullishCoalesce(_nullishCoalesce(trustedNumericCode, () => ( _TrezorAdapter._mapTrezorFailureCode(error))), () => ( _hwkadaptercore.HardwareErrorCode.UnknownError));
2779
- const stampedOrigin = _optionalChain([error, 'optionalAccess', _145 => _145.origin]);
2801
+ const stampedOrigin = _optionalChain([error, 'optionalAccess', _154 => _154.origin]);
2780
2802
  const origin = stampedOrigin === "device" || stampedOrigin === "transport" || stampedOrigin === "host" ? stampedOrigin : _hwkadaptercore.defaultOriginForCode.call(void 0, code);
2781
2803
  const params = typed.params && typeof typed.params === "object" ? typed.params : void 0;
2782
2804
  return _hwkadaptercore.failure.call(void 0,