@onekeyfe/hwk-trezor-adapter 1.2.8-alpha.50 → 1.2.8-alpha.52

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.js CHANGED
@@ -1427,6 +1427,10 @@ var _TrezorAdapter = class _TrezorAdapter {
1427
1427
  }
1428
1428
  async _releaseOperationConnection(operation) {
1429
1429
  const { connectId } = operation;
1430
+ const activeKey = _optionalChain([this, 'access', _49 => _49._jobQueue, 'access', _50 => _50.getActiveJob, 'call', _51 => _51(), 'optionalAccess', _52 => _52.deviceId]);
1431
+ if (activeKey !== void 0 && !_hwkadaptercore.isHardwareOperationId.call(void 0, activeKey) && (activeKey === connectId || activeKey === "" || activeKey === operation.device.deviceId)) {
1432
+ return;
1433
+ }
1430
1434
  const connecting = this._connectingPromises.has(connectId);
1431
1435
  this._connectingPromises.delete(connectId);
1432
1436
  const sessionId = this._sessions.get(connectId);
@@ -1464,7 +1468,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1464
1468
  const bundleContext = {};
1465
1469
  const topLevelFailureIndexes = /* @__PURE__ */ new Set();
1466
1470
  const isSingleNetworkBundle = params.bundle.every(
1467
- (item) => item.network === _optionalChain([params, 'access', _49 => _49.bundle, 'access', _50 => _50[0], 'optionalAccess', _51 => _51.network])
1471
+ (item) => item.network === _optionalChain([params, 'access', _53 => _53.bundle, 'access', _54 => _54[0], 'optionalAccess', _55 => _55.network])
1468
1472
  );
1469
1473
  const getLiveDeviceId = async (expectedDeviceId) => {
1470
1474
  if (liveDeviceId) return _hwkadaptercore.success.call(void 0, liveDeviceId);
@@ -1477,7 +1481,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1477
1481
  if (deviceIdResponse.success) {
1478
1482
  liveDeviceId = deviceIdResponse.payload;
1479
1483
  if (!target.payload.operationId) {
1480
- effectiveTargetId = _nullishCoalesce(_optionalChain([bundleContext, 'access', _52 => _52.connection, 'optionalAccess', _53 => _53.connectId]), () => ( effectiveTargetId));
1484
+ effectiveTargetId = _nullishCoalesce(_optionalChain([bundleContext, 'access', _56 => _56.connection, 'optionalAccess', _57 => _57.connectId]), () => ( effectiveTargetId));
1481
1485
  }
1482
1486
  }
1483
1487
  return deviceIdResponse;
@@ -1542,14 +1546,14 @@ var _TrezorAdapter = class _TrezorAdapter {
1542
1546
  // One named boolean per abort reason.
1543
1547
  shouldAbortBundle: (response, { index }) => {
1544
1548
  const isSessionLevelFailure = topLevelFailureIndexes.has(index);
1545
- const isWholeChainForbidden = isSingleNetworkBundle && _optionalChain([response, 'access', _54 => _54.payload, 'optionalAccess', _55 => _55.code]) === _hwkadaptercore.HardwareErrorCode.DevicePathForbidden;
1549
+ const isWholeChainForbidden = isSingleNetworkBundle && _optionalChain([response, 'access', _58 => _58.payload, 'optionalAccess', _59 => _59.code]) === _hwkadaptercore.HardwareErrorCode.DevicePathForbidden;
1546
1550
  const { code } = _nullishCoalesce(response.payload, () => ( {}));
1547
1551
  return isSessionLevelFailure || isWholeChainForbidden || _hwkadaptercore.isWalletSafetyFailure.call(void 0, code) || _hwkadaptercore.isUserRefusal.call(void 0, code) || _hwkadaptercore.isConnectionLost.call(void 0, code);
1548
1552
  }
1549
1553
  });
1550
1554
  } finally {
1551
1555
  cancelScope.release();
1552
- _optionalChain([releaseOperationRetention, 'optionalCall', _56 => _56()]);
1556
+ _optionalChain([releaseOperationRetention, 'optionalCall', _60 => _60()]);
1553
1557
  }
1554
1558
  }
1555
1559
  getFeatures(connectId, operationContext) {
@@ -1593,7 +1597,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1593
1597
  if (!internalModel) {
1594
1598
  return _hwkadaptercore.failure.call(void 0, _hwkadaptercore.HardwareErrorCode.UnknownError, "Device internal_model unavailable");
1595
1599
  }
1596
- 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")));
1600
+ 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")));
1597
1601
  const challenge = Buffer.from(challengeHex, "hex");
1598
1602
  const proofRes = await this._callDeviceManagerMethod(
1599
1603
  "authenticateDevice",
@@ -1651,20 +1655,24 @@ var _TrezorAdapter = class _TrezorAdapter {
1651
1655
  );
1652
1656
  }
1653
1657
  async _getTrezorDeviceId(connectId, expectedDeviceId, commonParams, bundleContext) {
1654
- const hasConnectionContext = _optionalChain([commonParams, 'optionalAccess', _60 => _60.knownConnections]) !== void 0 || _optionalChain([commonParams, 'optionalAccess', _61 => _61.extra]) !== void 0;
1658
+ const hasConnectionContext = _optionalChain([commonParams, 'optionalAccess', _64 => _64.knownConnections]) !== void 0 || _optionalChain([commonParams, 'optionalAccess', _65 => _65.extra]) !== void 0;
1655
1659
  const features = bundleContext || hasConnectionContext ? await this._callMethod(
1656
1660
  "getFeatures",
1657
1661
  connectId,
1658
1662
  hasConnectionContext || !connectId ? expectedDeviceId : void 0,
1659
- hasConnectionContext ? {
1660
- operationId: commonParams.operationId,
1661
- knownConnections: commonParams.knownConnections,
1662
- extra: commonParams.extra,
1663
- allowDeviceSelection: commonParams.allowDeviceSelection,
1664
- supportedTransports: commonParams.supportedTransports,
1665
- passphraseState: commonParams.passphraseState,
1666
- useEmptyPassphrase: commonParams.useEmptyPassphrase
1667
- } : {},
1663
+ {
1664
+ // Routing limits always apply: the connection found here is reused by the whole
1665
+ // bundle, so dropping them would let a bundle open a transport the host excluded.
1666
+ operationId: _optionalChain([commonParams, 'optionalAccess', _66 => _66.operationId]),
1667
+ knownConnections: _optionalChain([commonParams, 'optionalAccess', _67 => _67.knownConnections]),
1668
+ extra: _optionalChain([commonParams, 'optionalAccess', _68 => _68.extra]),
1669
+ allowDeviceSelection: _optionalChain([commonParams, 'optionalAccess', _69 => _69.allowDeviceSelection]),
1670
+ supportedTransports: _optionalChain([commonParams, 'optionalAccess', _70 => _70.supportedTransports]),
1671
+ ...hasConnectionContext ? {
1672
+ passphraseState: commonParams.passphraseState,
1673
+ useEmptyPassphrase: commonParams.useEmptyPassphrase
1674
+ } : {}
1675
+ },
1668
1676
  false,
1669
1677
  bundleContext
1670
1678
  ) : await this.getFeatures(
@@ -1695,7 +1703,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1695
1703
  const userAbortReason = Object.assign(new Error("User aborted operation"), {
1696
1704
  code: _hwkadaptercore.HardwareErrorCode.UserAborted
1697
1705
  });
1698
- const activeJobId = _optionalChain([this, 'access', _62 => _62._jobQueue, 'access', _63 => _63.getActiveJob, 'call', _64 => _64(), 'optionalAccess', _65 => _65.deviceId]);
1706
+ const activeJobId = _optionalChain([this, 'access', _71 => _71._jobQueue, 'access', _72 => _72.getActiveJob, 'call', _73 => _73(), 'optionalAccess', _74 => _74.deviceId]);
1699
1707
  const targetId = _nullishCoalesce(connectId, () => ( activeJobId));
1700
1708
  if (targetId) {
1701
1709
  let resolvedConnectId = targetId;
@@ -1709,7 +1717,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1709
1717
  }
1710
1718
  }
1711
1719
  const interactionForPhysicalId = !operationId && connectId ? this._operations.findActiveByConnectionKey(connectId) : void 0;
1712
- const pendingOperationId = _nullishCoalesce(operationId, () => ( _optionalChain([interactionForPhysicalId, 'optionalAccess', _66 => _66.operationId])));
1720
+ const pendingOperationId = _nullishCoalesce(operationId, () => ( _optionalChain([interactionForPhysicalId, 'optionalAccess', _75 => _75.operationId])));
1713
1721
  if (!connectId) {
1714
1722
  this._uiRegistry.cancel();
1715
1723
  } else if (pendingOperationId) {
@@ -1741,7 +1749,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1741
1749
  * operation of its connectId, so a mid-call UI request can name it.
1742
1750
  */
1743
1751
  _activeOperationId() {
1744
- 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]));
1745
1753
  }
1746
1754
  /**
1747
1755
  * Routes to BOTH the adapter's local UI registry (preemption decisions,
@@ -1775,7 +1783,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1775
1783
  * the THP session selection).
1776
1784
  */
1777
1785
  getPassphraseState(connectId, passphraseState, operationContext) {
1778
- const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _71 => _71.expectedDeviceIdentity]);
1786
+ const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _80 => _80.expectedDeviceIdentity]);
1779
1787
  if (expectedIdentity && (expectedIdentity.vendor !== "trezor" || expectedIdentity.type !== "deviceId")) {
1780
1788
  return Promise.resolve(
1781
1789
  _hwkadaptercore.failure.call(void 0, _hwkadaptercore.HardwareErrorCode.InvalidParams, "Trezor device identity is required")
@@ -1783,7 +1791,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1783
1791
  }
1784
1792
  const target = _hwkadaptercore.resolveHardwareOperationTarget.call(void 0,
1785
1793
  connectId,
1786
- _optionalChain([operationContext, 'optionalAccess', _72 => _72.operationId]),
1794
+ _optionalChain([operationContext, 'optionalAccess', _81 => _81.operationId]),
1787
1795
  "trezor"
1788
1796
  );
1789
1797
  if (!target.success) return Promise.resolve(target);
@@ -1804,7 +1812,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1804
1812
  let selectionRequestId;
1805
1813
  let verified = false;
1806
1814
  try {
1807
- 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)) {
1808
1816
  const resolved = await this._resolveExpectedDeviceConnectId(
1809
1817
  expectedIdentity.value,
1810
1818
  signal,
@@ -1813,9 +1821,9 @@ var _TrezorAdapter = class _TrezorAdapter {
1813
1821
  resolvedConnectId = resolved.connectId;
1814
1822
  selectionRequestId = resolved.selectionRequestId;
1815
1823
  }
1816
- if (_optionalChain([expectedIdentity, 'optionalAccess', _75 => _75.value])) {
1824
+ if (_optionalChain([expectedIdentity, 'optionalAccess', _84 => _84.value])) {
1817
1825
  if (!operationId) await this._ensureSession(resolvedConnectId, signal);
1818
- 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) {
1819
1827
  return _hwkadaptercore.failure.call(void 0,
1820
1828
  _hwkadaptercore.HardwareErrorCode.DeviceMismatch,
1821
1829
  "Trezor device identity does not match"
@@ -1835,7 +1843,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1835
1843
  signal,
1836
1844
  operationId
1837
1845
  );
1838
- if (result.success && _optionalChain([expectedIdentity, 'optionalAccess', _80 => _80.value])) {
1846
+ if (result.success && _optionalChain([expectedIdentity, 'optionalAccess', _89 => _89.value])) {
1839
1847
  await this._emitVerifiedBinding(
1840
1848
  expectedIdentity.value,
1841
1849
  resolvedConnectId,
@@ -1862,7 +1870,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1862
1870
  rejectIfBusy: true,
1863
1871
  busyError: _TrezorAdapter._createDeviceBusyError("getPassphraseState")
1864
1872
  }
1865
- ).catch((error) => this._errorToFailure(error)).finally(() => _optionalChain([releaseOperationRetention, 'optionalCall', _81 => _81()]));
1873
+ ).catch((error) => this._errorToFailure(error)).finally(() => _optionalChain([releaseOperationRetention, 'optionalCall', _90 => _90()]));
1866
1874
  }
1867
1875
  evmGetAddress(connectId, deviceId, params) {
1868
1876
  return this._callWalletMethod("evmGetAddress", connectId, deviceId, params);
@@ -1926,7 +1934,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1926
1934
  return result;
1927
1935
  }
1928
1936
  async _callConnector(sessionId, method, params, signal) {
1929
- if (_optionalChain([signal, 'optionalAccess', _82 => _82.aborted])) {
1937
+ if (_optionalChain([signal, 'optionalAccess', _91 => _91.aborted])) {
1930
1938
  throw _nullishCoalesce(signal.reason, () => ( new Error("Aborted")));
1931
1939
  }
1932
1940
  this._assertConnectorIdle(method);
@@ -1976,7 +1984,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1976
1984
  }
1977
1985
  /** Transports the connector offers and the host's model table allows; discovery opens no other. */
1978
1986
  _allowedTransports(context) {
1979
- const supported = _optionalChain([context, 'optionalAccess', _83 => _83.supportedTransports]);
1987
+ const supported = _optionalChain([context, 'optionalAccess', _92 => _92.supportedTransports]);
1980
1988
  const available = this._availableTransports();
1981
1989
  return supported ? available.filter((transport) => supported.includes(transport)) : available;
1982
1990
  }
@@ -2064,7 +2072,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2064
2072
  return this._callMethod(methodName, connectId, deviceId, params, true);
2065
2073
  }
2066
2074
  _callDeviceManagerMethod(methodName, connectId, params, operationContext) {
2067
- const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _84 => _84.expectedDeviceIdentity]);
2075
+ const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _93 => _93.expectedDeviceIdentity]);
2068
2076
  if (expectedIdentity && (expectedIdentity.vendor !== "trezor" || expectedIdentity.type !== "deviceId")) {
2069
2077
  return Promise.resolve(
2070
2078
  _hwkadaptercore.failure.call(void 0,
@@ -2076,14 +2084,14 @@ var _TrezorAdapter = class _TrezorAdapter {
2076
2084
  return this._callMethod(
2077
2085
  methodName,
2078
2086
  connectId,
2079
- _optionalChain([expectedIdentity, 'optionalAccess', _85 => _85.value]),
2087
+ _optionalChain([expectedIdentity, 'optionalAccess', _94 => _94.value]),
2080
2088
  {
2081
2089
  ...params && typeof params === "object" ? params : {},
2082
- knownConnections: _optionalChain([operationContext, 'optionalAccess', _86 => _86.knownConnections]),
2083
- extra: _optionalChain([operationContext, 'optionalAccess', _87 => _87.extra]),
2084
- allowDeviceSelection: _optionalChain([operationContext, 'optionalAccess', _88 => _88.allowDeviceSelection]),
2085
- supportedTransports: _optionalChain([operationContext, 'optionalAccess', _89 => _89.supportedTransports]),
2086
- ..._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 } : {}
2087
2095
  },
2088
2096
  false
2089
2097
  );
@@ -2121,7 +2129,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2121
2129
  let effectiveConnectId = call.connectId;
2122
2130
  let selectionRequestId;
2123
2131
  try {
2124
- 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)) {
2125
2133
  const resolved = await this._resolveExpectedDeviceConnectId(
2126
2134
  deviceId,
2127
2135
  signal,
@@ -2134,7 +2142,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2134
2142
  return this._errorToFailure(error);
2135
2143
  }
2136
2144
  const response2 = await this._callWithRetry(
2137
- _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)),
2138
2146
  methodName,
2139
2147
  call.params,
2140
2148
  deviceId || "",
@@ -2171,7 +2179,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2171
2179
  });
2172
2180
  return response;
2173
2181
  } finally {
2174
- _optionalChain([releaseOperationRetention, 'optionalCall', _96 => _96()]);
2182
+ _optionalChain([releaseOperationRetention, 'optionalCall', _105 => _105()]);
2175
2183
  }
2176
2184
  }
2177
2185
  async _callWithRetry(connectId, methodName, params, expectedDeviceId, requiresWalletIntent, allowRetry, signal, operationId, selectionRequestId, bundleContext) {
@@ -2183,7 +2191,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2183
2191
  useEmptyPassphrase
2184
2192
  });
2185
2193
  try {
2186
- if (_optionalChain([bundleContext, 'optionalAccess', _97 => _97.connection])) {
2194
+ if (_optionalChain([bundleContext, 'optionalAccess', _106 => _106.connection])) {
2187
2195
  const pinned = bundleContext.connection;
2188
2196
  if (this._sessions.get(pinned.connectId) !== pinned.sessionId) {
2189
2197
  return _hwkadaptercore.failure.call(void 0,
@@ -2208,7 +2216,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2208
2216
  bundleContext.connection = { connectId, sessionId };
2209
2217
  }
2210
2218
  if (expectedDeviceId) {
2211
- 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]);
2212
2220
  if (!actualDeviceId || actualDeviceId !== expectedDeviceId) {
2213
2221
  return _hwkadaptercore.failure.call(void 0,
2214
2222
  _hwkadaptercore.HardwareErrorCode.DeviceMismatch,
@@ -2333,7 +2341,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2333
2341
  if (pending) return pending;
2334
2342
  const stateGeneration = this._stateGeneration;
2335
2343
  const promise = (async () => {
2336
- if (_optionalChain([signal, 'optionalAccess', _102 => _102.aborted])) {
2344
+ if (_optionalChain([signal, 'optionalAccess', _111 => _111.aborted])) {
2337
2345
  throw Object.assign(new Error("Trezor connection aborted"), {
2338
2346
  code: _hwkadaptercore.HardwareErrorCode.UserAborted
2339
2347
  });
@@ -2380,13 +2388,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2380
2388
  ) : [];
2381
2389
  const mismatchedDeviceIds = [];
2382
2390
  const knownConnection = this._knownDeviceConnections.get(expectedDeviceId);
2383
- 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(
2384
2392
  (connection) => connection.transport === "usb" ? [connection.connectId] : []
2385
- ) : [_optionalChain([knownConnection, 'optionalAccess', _104 => _104.usbConnectId])].filter((id) => Boolean(id));
2386
- 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(
2387
2395
  (connection) => connection.transport === "ble" ? [connection.connectId] : []
2388
2396
  )]);
2389
- 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));
2390
2398
  const usbCandidates = candidates.filter(
2391
2399
  (device) => device.connectionType === "usb" && (!knownUsbIds.length || knownUsbIds.includes(device.connectId))
2392
2400
  );
@@ -2395,7 +2403,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2395
2403
  const probeOpensSession = !this._hasSessionOrConnect(candidate.connectId);
2396
2404
  try {
2397
2405
  sessionId = await this._ensureSession(candidate.connectId, signal, "usb");
2398
- 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]), () => ( ""));
2399
2407
  if (actualDeviceId === expectedDeviceId) return { connectId: candidate.connectId };
2400
2408
  mismatchedDeviceIds.push(actualDeviceId || "unknown");
2401
2409
  } catch (error) {
@@ -2427,7 +2435,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2427
2435
  );
2428
2436
  const probeOpensSession = !this._hasSessionOrConnect(knownBleConnectId);
2429
2437
  await this._ensureSession(knownBleConnectId, signal, "ble");
2430
- 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]);
2431
2439
  if (actualDeviceId === expectedDeviceId) return { connectId: knownBleConnectId };
2432
2440
  if (probeOpensSession) await this._disconnectSession(knownBleConnectId);
2433
2441
  throw _hwkadaptercore.createHwkError.call(void 0, {
@@ -2435,13 +2443,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2435
2443
  message: "The bound Trezor Bluetooth device has a different identity"
2436
2444
  });
2437
2445
  }
2438
- if (_optionalChain([context, 'optionalAccess', _118 => _118.supportedTransports]) && !context.supportedTransports.includes("ble")) {
2446
+ if (_optionalChain([context, 'optionalAccess', _127 => _127.supportedTransports]) && !context.supportedTransports.includes("ble")) {
2439
2447
  throw _hwkadaptercore.createHwkError.call(void 0, {
2440
2448
  code: _hwkadaptercore.HardwareErrorCode.DeviceNotFound,
2441
2449
  message: "This Trezor model has no Bluetooth transport; connect it over USB"
2442
2450
  });
2443
2451
  }
2444
- if (_optionalChain([context, 'optionalAccess', _119 => _119.allowDeviceSelection]) === false) {
2452
+ if (_optionalChain([context, 'optionalAccess', _128 => _128.allowDeviceSelection]) === false) {
2445
2453
  throw _hwkadaptercore.createHwkError.call(void 0, {
2446
2454
  code: _hwkadaptercore.HardwareErrorCode.DeviceNotFound,
2447
2455
  message: "No known Trezor connection is available"
@@ -2452,9 +2460,9 @@ var _TrezorAdapter = class _TrezorAdapter {
2452
2460
  async _selectBleDeviceForBinding(expectedDeviceId, signal, context, reason) {
2453
2461
  const availableTransports = this._allowedTransports(context);
2454
2462
  const allowUsbFallback = reason !== "manual-rebind" && availableTransports.includes("usb");
2455
- const knownUsbIds = _optionalChain([context, 'optionalAccess', _120 => _120.knownConnections]) ? context.knownConnections.flatMap(
2463
+ const knownUsbIds = _optionalChain([context, 'optionalAccess', _129 => _129.knownConnections]) ? context.knownConnections.flatMap(
2456
2464
  (connection) => connection.transport === "usb" ? [connection.connectId] : []
2457
- ) : [_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])];
2458
2466
  if (availableTransports.includes("ble")) {
2459
2467
  await _TrezorAdapter._abortable(
2460
2468
  signal,
@@ -2496,7 +2504,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2496
2504
  transport: "ble",
2497
2505
  reason
2498
2506
  },
2499
- extra: _optionalChain([context, 'optionalAccess', _125 => _125.extra]),
2507
+ extra: _optionalChain([context, 'optionalAccess', _134 => _134.extra]),
2500
2508
  operationId: this._activeOperationId()
2501
2509
  }
2502
2510
  });
@@ -2512,7 +2520,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2512
2520
  this._emitBindingStatus(requestId, signal.aborted ? "cancelled" : "failed");
2513
2521
  throw error;
2514
2522
  }
2515
- 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) {
2516
2524
  if (probeOpensSession) await this._disconnectSession(selected.connectId);
2517
2525
  rejectedConnectId = selected.connectId;
2518
2526
  rejectedConnectIds.add(selected.connectId);
@@ -2538,7 +2546,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2538
2546
  const known = _nullishCoalesce(this._knownDeviceConnections.get(deviceId), () => ( { deviceId }));
2539
2547
  if (device.connectionType === "ble") {
2540
2548
  known.bleConnectId = connectId;
2541
- } 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])) {
2542
2550
  known.usbConnectId = connectId;
2543
2551
  }
2544
2552
  this._knownDeviceConnections.set(deviceId, known);
@@ -2557,7 +2565,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2557
2565
  selectionRequestId,
2558
2566
  connection: { transport: "ble", connectId },
2559
2567
  identity: { vendor: "trezor", type: "deviceId", value: deviceId },
2560
- extra: _optionalChain([context, 'optionalAccess', _132 => _132.extra]),
2568
+ extra: _optionalChain([context, 'optionalAccess', _141 => _141.extra]),
2561
2569
  operationId: this._activeOperationId()
2562
2570
  },
2563
2571
  signal
@@ -2593,7 +2601,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2593
2601
  signal
2594
2602
  )
2595
2603
  );
2596
- 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") {
2597
2605
  throw _hwkadaptercore.createHwkError.call(void 0, {
2598
2606
  code: _hwkadaptercore.HardwareErrorCode.TransportError,
2599
2607
  message: "Cannot verify the requested Trezor wallet session"
@@ -2612,13 +2620,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2612
2620
  }
2613
2621
  _rememberVerifiedPassphraseSession(connectId, passphraseState, sessionId, created) {
2614
2622
  let session;
2615
- 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") {
2616
2624
  session = {
2617
2625
  sessionId,
2618
2626
  protocol: "thp",
2619
2627
  thpSessionId: created.thpSessionId
2620
2628
  };
2621
- } else if (_optionalChain([created, 'optionalAccess', _137 => _137.protocol]) === "v1") {
2629
+ } else if (_optionalChain([created, 'optionalAccess', _146 => _146.protocol]) === "v1") {
2622
2630
  session = {
2623
2631
  sessionId,
2624
2632
  protocol: "v1"
@@ -2638,7 +2646,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2638
2646
  }
2639
2647
  }
2640
2648
  async _reuseVerifiedPassphraseSession(connectId, sessionId, passphraseState, signal) {
2641
- 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)]);
2642
2650
  if (!cached || cached.sessionId !== sessionId) {
2643
2651
  this._forgetVerifiedPassphraseSession(connectId, passphraseState);
2644
2652
  return false;
@@ -2705,7 +2713,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2705
2713
  signal
2706
2714
  )
2707
2715
  );
2708
- const state = _optionalChain([derived, 'optionalAccess', _143 => _143.publicKey]);
2716
+ const state = _optionalChain([derived, 'optionalAccess', _152 => _152.publicKey]);
2709
2717
  if (!state) {
2710
2718
  throw Object.assign(new Error("Failed to derive passphrase state (wallet public key)"), {
2711
2719
  code: _hwkadaptercore.HardwareErrorCode.UnknownError
@@ -2742,7 +2750,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2742
2750
  signal,
2743
2751
  this._callConnector(sessionId, "getFeatures", { refresh: true }, signal)
2744
2752
  );
2745
- if (_optionalChain([features, 'optionalAccess', _144 => _144.passphrase_protection]) !== true) {
2753
+ if (_optionalChain([features, 'optionalAccess', _153 => _153.passphrase_protection]) !== true) {
2746
2754
  return _hwkadaptercore.success.call(void 0, null);
2747
2755
  }
2748
2756
  this._rememberVerifiedPassphraseSession(connectId, state, sessionId, created);
@@ -2790,7 +2798,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2790
2798
  }
2791
2799
  const trustedNumericCode = typeof typed.code === "number" && KNOWN_HARDWARE_ERROR_CODES.has(typed.code) ? typed.code : void 0;
2792
2800
  const code = _nullishCoalesce(_nullishCoalesce(trustedNumericCode, () => ( _TrezorAdapter._mapTrezorFailureCode(error))), () => ( _hwkadaptercore.HardwareErrorCode.UnknownError));
2793
- const stampedOrigin = _optionalChain([error, 'optionalAccess', _145 => _145.origin]);
2801
+ const stampedOrigin = _optionalChain([error, 'optionalAccess', _154 => _154.origin]);
2794
2802
  const origin = stampedOrigin === "device" || stampedOrigin === "transport" || stampedOrigin === "host" ? stampedOrigin : _hwkadaptercore.defaultOriginForCode.call(void 0, code);
2795
2803
  const params = typed.params && typeof typed.params === "object" ? typed.params : void 0;
2796
2804
  return _hwkadaptercore.failure.call(void 0,