@onekeyfe/hwk-trezor-adapter 1.2.5-alpha.2 → 1.2.5-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.
package/dist/index.js CHANGED
@@ -1310,7 +1310,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1310
1310
  }));
1311
1311
  }
1312
1312
  async bindBleDevice(params) {
1313
- if (params.identity.vendor !== "trezor" || !params.identity.value) {
1313
+ if (_optionalChain([params, 'access', _38 => _38.identity, 'optionalAccess', _39 => _39.vendor]) !== "trezor" || !params.identity.value) {
1314
1314
  return _hwkadaptercore.failure.call(void 0, _hwkadaptercore.HardwareErrorCode.InvalidParams, "Trezor device identity is required");
1315
1315
  }
1316
1316
  const { value: deviceId } = params.identity;
@@ -1364,7 +1364,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1364
1364
  this._ensureDevicePermission(
1365
1365
  searchTargetId,
1366
1366
  void 0,
1367
- _optionalChain([this, 'access', _38 => _38._devices, 'access', _39 => _39.get, 'call', _40 => _40(searchTargetId), 'optionalAccess', _41 => _41.connectionType])
1367
+ _optionalChain([this, 'access', _40 => _40._devices, 'access', _41 => _41.get, 'call', _42 => _42(searchTargetId), 'optionalAccess', _43 => _43.connectionType])
1368
1368
  )
1369
1369
  );
1370
1370
  await this._ensureSession(searchTargetId, scope.signal);
@@ -1441,7 +1441,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1441
1441
  const bundleContext = {};
1442
1442
  const topLevelFailureIndexes = /* @__PURE__ */ new Set();
1443
1443
  const isSingleNetworkBundle = params.bundle.every(
1444
- (item) => item.network === _optionalChain([params, 'access', _42 => _42.bundle, 'access', _43 => _43[0], 'optionalAccess', _44 => _44.network])
1444
+ (item) => item.network === _optionalChain([params, 'access', _44 => _44.bundle, 'access', _45 => _45[0], 'optionalAccess', _46 => _46.network])
1445
1445
  );
1446
1446
  const getLiveDeviceId = async (expectedDeviceId) => {
1447
1447
  if (liveDeviceId) return _hwkadaptercore.success.call(void 0, liveDeviceId);
@@ -1454,7 +1454,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1454
1454
  if (deviceIdResponse.success) {
1455
1455
  liveDeviceId = deviceIdResponse.payload;
1456
1456
  if (!target.payload.operationId) {
1457
- effectiveTargetId = _nullishCoalesce(_optionalChain([bundleContext, 'access', _45 => _45.connection, 'optionalAccess', _46 => _46.connectId]), () => ( effectiveTargetId));
1457
+ effectiveTargetId = _nullishCoalesce(_optionalChain([bundleContext, 'access', _47 => _47.connection, 'optionalAccess', _48 => _48.connectId]), () => ( effectiveTargetId));
1458
1458
  }
1459
1459
  }
1460
1460
  return deviceIdResponse;
@@ -1519,15 +1519,15 @@ var _TrezorAdapter = class _TrezorAdapter {
1519
1519
  // One named boolean per abort reason.
1520
1520
  shouldAbortBundle: (response, { index }) => {
1521
1521
  const isSessionLevelFailure = topLevelFailureIndexes.has(index);
1522
- const isWholeChainForbidden = isSingleNetworkBundle && _optionalChain([response, 'access', _47 => _47.payload, 'optionalAccess', _48 => _48.code]) === _hwkadaptercore.HardwareErrorCode.DevicePathForbidden;
1523
- const isPassphrasePolicyFailure = _optionalChain([response, 'access', _49 => _49.payload, 'optionalAccess', _50 => _50.code]) === _hwkadaptercore.HardwareErrorCode.PassphraseAlwaysOnDevice;
1522
+ const isWholeChainForbidden = isSingleNetworkBundle && _optionalChain([response, 'access', _49 => _49.payload, 'optionalAccess', _50 => _50.code]) === _hwkadaptercore.HardwareErrorCode.DevicePathForbidden;
1523
+ const isPassphrasePolicyFailure = _optionalChain([response, 'access', _51 => _51.payload, 'optionalAccess', _52 => _52.code]) === _hwkadaptercore.HardwareErrorCode.PassphraseAlwaysOnDevice;
1524
1524
  const { code } = _nullishCoalesce(response.payload, () => ( {}));
1525
1525
  return isSessionLevelFailure || isWholeChainForbidden || isPassphrasePolicyFailure || _hwkadaptercore.isUserRefusal.call(void 0, code) || _hwkadaptercore.isConnectionLost.call(void 0, code);
1526
1526
  }
1527
1527
  });
1528
1528
  } finally {
1529
1529
  cancelScope.release();
1530
- _optionalChain([releaseOperationRetention, 'optionalCall', _51 => _51()]);
1530
+ _optionalChain([releaseOperationRetention, 'optionalCall', _53 => _53()]);
1531
1531
  }
1532
1532
  }
1533
1533
  getFeatures(connectId, operationContext) {
@@ -1571,7 +1571,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1571
1571
  if (!internalModel) {
1572
1572
  return _hwkadaptercore.failure.call(void 0, _hwkadaptercore.HardwareErrorCode.UnknownError, "Device internal_model unavailable");
1573
1573
  }
1574
- const challengeHex = _nullishCoalesce(_optionalChain([params, 'access', _52 => _52.challenge, 'optionalAccess', _53 => _53.toLowerCase, 'call', _54 => _54()]), () => ( Buffer.from(_utils.randomBytes.call(void 0, 32)).toString("hex")));
1574
+ const challengeHex = _nullishCoalesce(_optionalChain([params, 'access', _54 => _54.challenge, 'optionalAccess', _55 => _55.toLowerCase, 'call', _56 => _56()]), () => ( Buffer.from(_utils.randomBytes.call(void 0, 32)).toString("hex")));
1575
1575
  const challenge = Buffer.from(challengeHex, "hex");
1576
1576
  const proofRes = await this._callDeviceManagerMethod(
1577
1577
  "authenticateDevice",
@@ -1629,7 +1629,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1629
1629
  );
1630
1630
  }
1631
1631
  async _getTrezorDeviceId(connectId, expectedDeviceId, commonParams, bundleContext) {
1632
- const hasConnectionContext = _optionalChain([commonParams, 'optionalAccess', _55 => _55.knownConnections]) !== void 0 || _optionalChain([commonParams, 'optionalAccess', _56 => _56.extra]) !== void 0;
1632
+ const hasConnectionContext = _optionalChain([commonParams, 'optionalAccess', _57 => _57.knownConnections]) !== void 0 || _optionalChain([commonParams, 'optionalAccess', _58 => _58.extra]) !== void 0;
1633
1633
  const features = bundleContext || hasConnectionContext ? await this._callMethod(
1634
1634
  "getFeatures",
1635
1635
  connectId,
@@ -1673,7 +1673,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1673
1673
  const userAbortReason = Object.assign(new Error("User aborted operation"), {
1674
1674
  code: _hwkadaptercore.HardwareErrorCode.UserAborted
1675
1675
  });
1676
- const activeJobId = _optionalChain([this, 'access', _57 => _57._jobQueue, 'access', _58 => _58.getActiveJob, 'call', _59 => _59(), 'optionalAccess', _60 => _60.deviceId]);
1676
+ const activeJobId = _optionalChain([this, 'access', _59 => _59._jobQueue, 'access', _60 => _60.getActiveJob, 'call', _61 => _61(), 'optionalAccess', _62 => _62.deviceId]);
1677
1677
  const targetId = _nullishCoalesce(connectId, () => ( activeJobId));
1678
1678
  if (targetId) {
1679
1679
  let resolvedConnectId = targetId;
@@ -1687,7 +1687,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1687
1687
  }
1688
1688
  }
1689
1689
  const interactionForPhysicalId = !operationId && connectId ? this._operations.findActiveByConnectionKey(connectId) : void 0;
1690
- const pendingOperationId = _nullishCoalesce(operationId, () => ( _optionalChain([interactionForPhysicalId, 'optionalAccess', _61 => _61.operationId])));
1690
+ const pendingOperationId = _nullishCoalesce(operationId, () => ( _optionalChain([interactionForPhysicalId, 'optionalAccess', _63 => _63.operationId])));
1691
1691
  if (!connectId) {
1692
1692
  this._uiRegistry.cancel();
1693
1693
  } else if (pendingOperationId) {
@@ -1719,10 +1719,10 @@ var _TrezorAdapter = class _TrezorAdapter {
1719
1719
  * operation of its connectId, so a mid-call UI request can name it.
1720
1720
  */
1721
1721
  _activeOperationId() {
1722
- const activeJobId = _optionalChain([this, 'access', _62 => _62._jobQueue, 'access', _63 => _63.getActiveJob, 'call', _64 => _64(), 'optionalAccess', _65 => _65.deviceId]);
1722
+ const activeJobId = _optionalChain([this, 'access', _64 => _64._jobQueue, 'access', _65 => _65.getActiveJob, 'call', _66 => _66(), 'optionalAccess', _67 => _67.deviceId]);
1723
1723
  if (!activeJobId) return void 0;
1724
1724
  if (_hwkadaptercore.isHardwareOperationId.call(void 0, activeJobId)) return activeJobId;
1725
- return _optionalChain([this, 'access', _66 => _66._operations, 'access', _67 => _67.findActiveByConnectionKey, 'call', _68 => _68(activeJobId), 'optionalAccess', _69 => _69.operationId]);
1725
+ return _optionalChain([this, 'access', _68 => _68._operations, 'access', _69 => _69.findActiveByConnectionKey, 'call', _70 => _70(activeJobId), 'optionalAccess', _71 => _71.operationId]);
1726
1726
  }
1727
1727
  /**
1728
1728
  * Routes to BOTH the adapter's local UI registry (preemption decisions,
@@ -1756,7 +1756,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1756
1756
  * the THP session selection).
1757
1757
  */
1758
1758
  getPassphraseState(connectId, passphraseState, operationContext) {
1759
- const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _70 => _70.expectedDeviceIdentity]);
1759
+ const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _72 => _72.expectedDeviceIdentity]);
1760
1760
  if (expectedIdentity && (expectedIdentity.vendor !== "trezor" || expectedIdentity.type !== "deviceId")) {
1761
1761
  return Promise.resolve(
1762
1762
  _hwkadaptercore.failure.call(void 0, _hwkadaptercore.HardwareErrorCode.InvalidParams, "Trezor device identity is required")
@@ -1764,7 +1764,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1764
1764
  }
1765
1765
  const target = _hwkadaptercore.resolveHardwareOperationTarget.call(void 0,
1766
1766
  connectId,
1767
- _optionalChain([operationContext, 'optionalAccess', _71 => _71.operationId]),
1767
+ _optionalChain([operationContext, 'optionalAccess', _73 => _73.operationId]),
1768
1768
  "trezor"
1769
1769
  );
1770
1770
  if (!target.success) return Promise.resolve(target);
@@ -1785,7 +1785,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1785
1785
  let selectionRequestId;
1786
1786
  let verified = false;
1787
1787
  try {
1788
- if (!operationId && _optionalChain([expectedIdentity, 'optionalAccess', _72 => _72.value]) && (!connectId || _optionalChain([operationContext, 'optionalAccess', _73 => _73.knownConnections]) !== void 0)) {
1788
+ if (!operationId && _optionalChain([expectedIdentity, 'optionalAccess', _74 => _74.value]) && (!connectId || _optionalChain([operationContext, 'optionalAccess', _75 => _75.knownConnections]) !== void 0)) {
1789
1789
  const resolved = await this._resolveExpectedDeviceConnectId(
1790
1790
  expectedIdentity.value,
1791
1791
  signal,
@@ -1794,9 +1794,9 @@ var _TrezorAdapter = class _TrezorAdapter {
1794
1794
  resolvedConnectId = resolved.connectId;
1795
1795
  selectionRequestId = resolved.selectionRequestId;
1796
1796
  }
1797
- if (_optionalChain([expectedIdentity, 'optionalAccess', _74 => _74.value])) {
1797
+ if (_optionalChain([expectedIdentity, 'optionalAccess', _76 => _76.value])) {
1798
1798
  if (!operationId) await this._ensureSession(resolvedConnectId, signal);
1799
- if (_optionalChain([this, 'access', _75 => _75._devices, 'access', _76 => _76.get, 'call', _77 => _77(resolvedConnectId), 'optionalAccess', _78 => _78.deviceId]) !== expectedIdentity.value) {
1799
+ if (_optionalChain([this, 'access', _77 => _77._devices, 'access', _78 => _78.get, 'call', _79 => _79(resolvedConnectId), 'optionalAccess', _80 => _80.deviceId]) !== expectedIdentity.value) {
1800
1800
  return _hwkadaptercore.failure.call(void 0,
1801
1801
  _hwkadaptercore.HardwareErrorCode.DeviceMismatch,
1802
1802
  "Trezor device identity does not match"
@@ -1816,7 +1816,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1816
1816
  signal,
1817
1817
  operationId
1818
1818
  );
1819
- if (result.success && _optionalChain([expectedIdentity, 'optionalAccess', _79 => _79.value])) {
1819
+ if (result.success && _optionalChain([expectedIdentity, 'optionalAccess', _81 => _81.value])) {
1820
1820
  await this._emitVerifiedBinding(
1821
1821
  expectedIdentity.value,
1822
1822
  resolvedConnectId,
@@ -1843,7 +1843,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1843
1843
  rejectIfBusy: true,
1844
1844
  busyError: _TrezorAdapter._createDeviceBusyError("getPassphraseState")
1845
1845
  }
1846
- ).catch((error) => this._errorToFailure(error)).finally(() => _optionalChain([releaseOperationRetention, 'optionalCall', _80 => _80()]));
1846
+ ).catch((error) => this._errorToFailure(error)).finally(() => _optionalChain([releaseOperationRetention, 'optionalCall', _82 => _82()]));
1847
1847
  }
1848
1848
  evmGetAddress(connectId, deviceId, params) {
1849
1849
  return this._callWalletMethod("evmGetAddress", connectId, deviceId, params);
@@ -1907,7 +1907,7 @@ var _TrezorAdapter = class _TrezorAdapter {
1907
1907
  return result;
1908
1908
  }
1909
1909
  async _callConnector(sessionId, method, params, signal) {
1910
- if (_optionalChain([signal, 'optionalAccess', _81 => _81.aborted])) {
1910
+ if (_optionalChain([signal, 'optionalAccess', _83 => _83.aborted])) {
1911
1911
  throw _nullishCoalesce(signal.reason, () => ( new Error("Aborted")));
1912
1912
  }
1913
1913
  this._assertConnectorIdle(method);
@@ -2015,8 +2015,8 @@ var _TrezorAdapter = class _TrezorAdapter {
2015
2015
  /** UserAborted is a top-level abort code, so this ends the bundle. */
2016
2016
  static _buildCancelledFailure(signal) {
2017
2017
  const reason = signal.reason;
2018
- const code = typeof _optionalChain([reason, 'optionalAccess', _82 => _82.code]) === "number" ? reason.code : _hwkadaptercore.HardwareErrorCode.UserAborted;
2019
- const message = typeof _optionalChain([reason, 'optionalAccess', _83 => _83.message]) === "string" ? reason.message : "";
2018
+ const code = typeof _optionalChain([reason, 'optionalAccess', _84 => _84.code]) === "number" ? reason.code : _hwkadaptercore.HardwareErrorCode.UserAborted;
2019
+ const message = typeof _optionalChain([reason, 'optionalAccess', _85 => _85.message]) === "string" ? reason.message : "";
2020
2020
  return _hwkadaptercore.failure.call(void 0, code, message || "All-network get-address cancelled");
2021
2021
  }
2022
2022
  _callAllNetworkMethod(connectId, method, item, bundleContext) {
@@ -2046,7 +2046,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2046
2046
  return this._callMethod(methodName, connectId, deviceId, params, true);
2047
2047
  }
2048
2048
  _callDeviceManagerMethod(methodName, connectId, params, operationContext) {
2049
- const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _84 => _84.expectedDeviceIdentity]);
2049
+ const expectedIdentity = _optionalChain([operationContext, 'optionalAccess', _86 => _86.expectedDeviceIdentity]);
2050
2050
  if (expectedIdentity && (expectedIdentity.vendor !== "trezor" || expectedIdentity.type !== "deviceId")) {
2051
2051
  return Promise.resolve(
2052
2052
  _hwkadaptercore.failure.call(void 0,
@@ -2058,14 +2058,14 @@ var _TrezorAdapter = class _TrezorAdapter {
2058
2058
  return this._callMethod(
2059
2059
  methodName,
2060
2060
  connectId,
2061
- _optionalChain([expectedIdentity, 'optionalAccess', _85 => _85.value]),
2061
+ _optionalChain([expectedIdentity, 'optionalAccess', _87 => _87.value]),
2062
2062
  {
2063
2063
  ...params && typeof params === "object" ? params : {},
2064
- knownConnections: _optionalChain([operationContext, 'optionalAccess', _86 => _86.knownConnections]),
2065
- extra: _optionalChain([operationContext, 'optionalAccess', _87 => _87.extra]),
2066
- allowDeviceSelection: _optionalChain([operationContext, 'optionalAccess', _88 => _88.allowDeviceSelection]),
2067
- supportedTransports: _optionalChain([operationContext, 'optionalAccess', _89 => _89.supportedTransports]),
2068
- ..._optionalChain([operationContext, 'optionalAccess', _90 => _90.operationId]) ? { operationId: operationContext.operationId } : {}
2064
+ knownConnections: _optionalChain([operationContext, 'optionalAccess', _88 => _88.knownConnections]),
2065
+ extra: _optionalChain([operationContext, 'optionalAccess', _89 => _89.extra]),
2066
+ allowDeviceSelection: _optionalChain([operationContext, 'optionalAccess', _90 => _90.allowDeviceSelection]),
2067
+ supportedTransports: _optionalChain([operationContext, 'optionalAccess', _91 => _91.supportedTransports]),
2068
+ ..._optionalChain([operationContext, 'optionalAccess', _92 => _92.operationId]) ? { operationId: operationContext.operationId } : {}
2069
2069
  },
2070
2070
  false
2071
2071
  );
@@ -2103,7 +2103,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2103
2103
  let effectiveConnectId = call.connectId;
2104
2104
  let selectionRequestId;
2105
2105
  try {
2106
- if (!_optionalChain([bundleContext, 'optionalAccess', _91 => _91.connection]) && !operationId && deviceId && (!connectId || _optionalChain([commonParams, 'access', _92 => _92.connectionContext, 'optionalAccess', _93 => _93.knownConnections]) !== void 0)) {
2106
+ if (!_optionalChain([bundleContext, 'optionalAccess', _93 => _93.connection]) && !operationId && deviceId && (!connectId || _optionalChain([commonParams, 'access', _94 => _94.connectionContext, 'optionalAccess', _95 => _95.knownConnections]) !== void 0)) {
2107
2107
  const resolved = await this._resolveExpectedDeviceConnectId(
2108
2108
  deviceId,
2109
2109
  signal,
@@ -2116,7 +2116,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2116
2116
  return this._errorToFailure(error);
2117
2117
  }
2118
2118
  const response2 = await this._callWithRetry(
2119
- _nullishCoalesce(_optionalChain([bundleContext, 'optionalAccess', _94 => _94.connection, 'optionalAccess', _95 => _95.connectId]), () => ( effectiveConnectId)),
2119
+ _nullishCoalesce(_optionalChain([bundleContext, 'optionalAccess', _96 => _96.connection, 'optionalAccess', _97 => _97.connectId]), () => ( effectiveConnectId)),
2120
2120
  methodName,
2121
2121
  call.params,
2122
2122
  deviceId || "",
@@ -2153,7 +2153,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2153
2153
  });
2154
2154
  return response;
2155
2155
  } finally {
2156
- _optionalChain([releaseOperationRetention, 'optionalCall', _96 => _96()]);
2156
+ _optionalChain([releaseOperationRetention, 'optionalCall', _98 => _98()]);
2157
2157
  }
2158
2158
  }
2159
2159
  async _callWithRetry(connectId, methodName, params, expectedDeviceId, requiresWalletIntent, allowRetry, signal, operationId, selectionRequestId, bundleContext) {
@@ -2165,7 +2165,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2165
2165
  useEmptyPassphrase
2166
2166
  });
2167
2167
  try {
2168
- if (_optionalChain([bundleContext, 'optionalAccess', _97 => _97.connection])) {
2168
+ if (_optionalChain([bundleContext, 'optionalAccess', _99 => _99.connection])) {
2169
2169
  const pinned = bundleContext.connection;
2170
2170
  if (this._sessions.get(pinned.connectId) !== pinned.sessionId) {
2171
2171
  return _hwkadaptercore.failure.call(void 0,
@@ -2190,7 +2190,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2190
2190
  bundleContext.connection = { connectId, sessionId };
2191
2191
  }
2192
2192
  if (expectedDeviceId) {
2193
- const actualDeviceId = _optionalChain([this, 'access', _98 => _98._devices, 'access', _99 => _99.get, 'call', _100 => _100(connectId), 'optionalAccess', _101 => _101.deviceId]);
2193
+ const actualDeviceId = _optionalChain([this, 'access', _100 => _100._devices, 'access', _101 => _101.get, 'call', _102 => _102(connectId), 'optionalAccess', _103 => _103.deviceId]);
2194
2194
  if (!actualDeviceId || actualDeviceId !== expectedDeviceId) {
2195
2195
  return _hwkadaptercore.failure.call(void 0,
2196
2196
  _hwkadaptercore.HardwareErrorCode.DeviceMismatch,
@@ -2315,7 +2315,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2315
2315
  if (pending) return pending;
2316
2316
  const stateGeneration = this._stateGeneration;
2317
2317
  const promise = (async () => {
2318
- if (_optionalChain([signal, 'optionalAccess', _102 => _102.aborted])) {
2318
+ if (_optionalChain([signal, 'optionalAccess', _104 => _104.aborted])) {
2319
2319
  throw Object.assign(new Error("Trezor connection aborted"), {
2320
2320
  code: _hwkadaptercore.HardwareErrorCode.UserAborted
2321
2321
  });
@@ -2358,13 +2358,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2358
2358
  );
2359
2359
  const mismatchedDeviceIds = [];
2360
2360
  const knownConnection = this._knownDeviceConnections.get(expectedDeviceId);
2361
- const knownUsbIds = _optionalChain([context, 'optionalAccess', _103 => _103.knownConnections]) !== void 0 ? context.knownConnections.flatMap(
2361
+ const knownUsbIds = _optionalChain([context, 'optionalAccess', _105 => _105.knownConnections]) !== void 0 ? context.knownConnections.flatMap(
2362
2362
  (connection) => connection.transport === "usb" ? [connection.connectId] : []
2363
- ) : [_optionalChain([knownConnection, 'optionalAccess', _104 => _104.usbConnectId])].filter((id) => Boolean(id));
2364
- const suppliedBleIds = _optionalChain([context, 'optionalAccess', _105 => _105.knownConnections, 'optionalAccess', _106 => _106.flatMap, 'call', _107 => _107(
2363
+ ) : [_optionalChain([knownConnection, 'optionalAccess', _106 => _106.usbConnectId])].filter((id) => Boolean(id));
2364
+ const suppliedBleIds = _optionalChain([context, 'optionalAccess', _107 => _107.knownConnections, 'optionalAccess', _108 => _108.flatMap, 'call', _109 => _109(
2365
2365
  (connection) => connection.transport === "ble" ? [connection.connectId] : []
2366
2366
  )]);
2367
- const knownBleIds = _optionalChain([suppliedBleIds, 'optionalAccess', _108 => _108.length]) ? suppliedBleIds : [_optionalChain([knownConnection, 'optionalAccess', _109 => _109.bleConnectId])].filter((id) => Boolean(id));
2367
+ const knownBleIds = _optionalChain([suppliedBleIds, 'optionalAccess', _110 => _110.length]) ? suppliedBleIds : [_optionalChain([knownConnection, 'optionalAccess', _111 => _111.bleConnectId])].filter((id) => Boolean(id));
2368
2368
  const usbCandidates = candidates.filter(
2369
2369
  (device) => device.connectionType === "usb" && (!knownUsbIds.length || knownUsbIds.includes(device.connectId))
2370
2370
  );
@@ -2372,7 +2372,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2372
2372
  let sessionId;
2373
2373
  try {
2374
2374
  sessionId = await this._ensureSession(candidate.connectId, signal, "usb");
2375
- const actualDeviceId = _nullishCoalesce(_optionalChain([this, 'access', _110 => _110._devices, 'access', _111 => _111.get, 'call', _112 => _112(candidate.connectId), 'optionalAccess', _113 => _113.deviceId]), () => ( ""));
2375
+ const actualDeviceId = _nullishCoalesce(_optionalChain([this, 'access', _112 => _112._devices, 'access', _113 => _113.get, 'call', _114 => _114(candidate.connectId), 'optionalAccess', _115 => _115.deviceId]), () => ( ""));
2376
2376
  if (actualDeviceId === expectedDeviceId) return { connectId: candidate.connectId };
2377
2377
  mismatchedDeviceIds.push(actualDeviceId || "unknown");
2378
2378
  } catch (error) {
@@ -2403,7 +2403,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2403
2403
  this._ensureDevicePermission(knownBleConnectId, expectedDeviceId, "ble")
2404
2404
  );
2405
2405
  await this._ensureSession(knownBleConnectId, signal, "ble");
2406
- const actualDeviceId = _optionalChain([this, 'access', _114 => _114._devices, 'access', _115 => _115.get, 'call', _116 => _116(knownBleConnectId), 'optionalAccess', _117 => _117.deviceId]);
2406
+ const actualDeviceId = _optionalChain([this, 'access', _116 => _116._devices, 'access', _117 => _117.get, 'call', _118 => _118(knownBleConnectId), 'optionalAccess', _119 => _119.deviceId]);
2407
2407
  if (actualDeviceId === expectedDeviceId) return { connectId: knownBleConnectId };
2408
2408
  await this._disconnectSession(knownBleConnectId);
2409
2409
  throw _hwkadaptercore.createHwkError.call(void 0, {
@@ -2411,13 +2411,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2411
2411
  message: "The bound Trezor Bluetooth device has a different identity"
2412
2412
  });
2413
2413
  }
2414
- if (_optionalChain([context, 'optionalAccess', _118 => _118.supportedTransports]) && !context.supportedTransports.includes("ble")) {
2414
+ if (_optionalChain([context, 'optionalAccess', _120 => _120.supportedTransports]) && !context.supportedTransports.includes("ble")) {
2415
2415
  throw _hwkadaptercore.createHwkError.call(void 0, {
2416
2416
  code: _hwkadaptercore.HardwareErrorCode.DeviceNotFound,
2417
2417
  message: "This Trezor model has no Bluetooth transport; connect it over USB"
2418
2418
  });
2419
2419
  }
2420
- if (_optionalChain([context, 'optionalAccess', _119 => _119.allowDeviceSelection]) === false) {
2420
+ if (_optionalChain([context, 'optionalAccess', _121 => _121.allowDeviceSelection]) === false) {
2421
2421
  throw _hwkadaptercore.createHwkError.call(void 0, {
2422
2422
  code: _hwkadaptercore.HardwareErrorCode.DeviceNotFound,
2423
2423
  message: "No known Trezor connection is available"
@@ -2428,9 +2428,9 @@ var _TrezorAdapter = class _TrezorAdapter {
2428
2428
  async _selectBleDeviceForBinding(expectedDeviceId, signal, context, reason) {
2429
2429
  const availableTransports = this._availableTransports();
2430
2430
  const allowUsbFallback = reason !== "manual-rebind" && availableTransports.includes("usb");
2431
- const knownUsbIds = _optionalChain([context, 'optionalAccess', _120 => _120.knownConnections]) ? context.knownConnections.flatMap(
2431
+ const knownUsbIds = _optionalChain([context, 'optionalAccess', _122 => _122.knownConnections]) ? context.knownConnections.flatMap(
2432
2432
  (connection) => connection.transport === "usb" ? [connection.connectId] : []
2433
- ) : [_optionalChain([this, 'access', _121 => _121._knownDeviceConnections, 'access', _122 => _122.get, 'call', _123 => _123(expectedDeviceId), 'optionalAccess', _124 => _124.usbConnectId])];
2433
+ ) : [_optionalChain([this, 'access', _123 => _123._knownDeviceConnections, 'access', _124 => _124.get, 'call', _125 => _125(expectedDeviceId), 'optionalAccess', _126 => _126.usbConnectId])];
2434
2434
  if (availableTransports.includes("ble")) {
2435
2435
  await _TrezorAdapter._abortable(
2436
2436
  signal,
@@ -2472,7 +2472,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2472
2472
  transport: "ble",
2473
2473
  reason
2474
2474
  },
2475
- extra: _optionalChain([context, 'optionalAccess', _125 => _125.extra]),
2475
+ extra: _optionalChain([context, 'optionalAccess', _127 => _127.extra]),
2476
2476
  operationId: this._activeOperationId()
2477
2477
  }
2478
2478
  });
@@ -2486,7 +2486,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2486
2486
  this._emitBindingStatus(requestId, signal.aborted ? "cancelled" : "failed");
2487
2487
  throw error;
2488
2488
  }
2489
- if (_optionalChain([this, 'access', _126 => _126._devices, 'access', _127 => _127.get, 'call', _128 => _128(selected.connectId), 'optionalAccess', _129 => _129.deviceId]) !== expectedDeviceId) {
2489
+ if (_optionalChain([this, 'access', _128 => _128._devices, 'access', _129 => _129.get, 'call', _130 => _130(selected.connectId), 'optionalAccess', _131 => _131.deviceId]) !== expectedDeviceId) {
2490
2490
  await this._disconnectSession(selected.connectId);
2491
2491
  rejectedConnectId = selected.connectId;
2492
2492
  rejectedConnectIds.add(selected.connectId);
@@ -2515,7 +2515,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2515
2515
  const known = _nullishCoalesce(this._knownDeviceConnections.get(deviceId), () => ( { deviceId }));
2516
2516
  if (device.connectionType === "ble") {
2517
2517
  known.bleConnectId = connectId;
2518
- } else if (device.connectionType === "usb" && _optionalChain([device, 'access', _130 => _130.capabilities, 'optionalAccess', _131 => _131.persistentDeviceIdentity])) {
2518
+ } else if (device.connectionType === "usb" && _optionalChain([device, 'access', _132 => _132.capabilities, 'optionalAccess', _133 => _133.persistentDeviceIdentity])) {
2519
2519
  known.usbConnectId = connectId;
2520
2520
  }
2521
2521
  this._knownDeviceConnections.set(deviceId, known);
@@ -2534,7 +2534,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2534
2534
  selectionRequestId,
2535
2535
  connection: { transport: "ble", connectId },
2536
2536
  identity: { vendor: "trezor", type: "deviceId", value: deviceId },
2537
- extra: _optionalChain([context, 'optionalAccess', _132 => _132.extra]),
2537
+ extra: _optionalChain([context, 'optionalAccess', _134 => _134.extra]),
2538
2538
  operationId: this._activeOperationId()
2539
2539
  },
2540
2540
  signal
@@ -2570,7 +2570,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2570
2570
  signal
2571
2571
  )
2572
2572
  );
2573
- if (_optionalChain([created, 'optionalAccess', _133 => _133.protocol]) === "thp" && !created.thpSessionId || _optionalChain([created, 'optionalAccess', _134 => _134.protocol]) !== "thp" && _optionalChain([created, 'optionalAccess', _135 => _135.protocol]) !== "v1") {
2573
+ if (_optionalChain([created, 'optionalAccess', _135 => _135.protocol]) === "thp" && !created.thpSessionId || _optionalChain([created, 'optionalAccess', _136 => _136.protocol]) !== "thp" && _optionalChain([created, 'optionalAccess', _137 => _137.protocol]) !== "v1") {
2574
2574
  throw _hwkadaptercore.createHwkError.call(void 0, {
2575
2575
  code: _hwkadaptercore.HardwareErrorCode.TransportError,
2576
2576
  message: "Cannot verify the requested Trezor wallet session"
@@ -2589,13 +2589,13 @@ var _TrezorAdapter = class _TrezorAdapter {
2589
2589
  }
2590
2590
  _rememberVerifiedPassphraseSession(connectId, passphraseState, sessionId, created) {
2591
2591
  let session;
2592
- if (_optionalChain([created, 'optionalAccess', _136 => _136.protocol]) === "thp" && typeof created.thpSessionId === "string") {
2592
+ if (_optionalChain([created, 'optionalAccess', _138 => _138.protocol]) === "thp" && typeof created.thpSessionId === "string") {
2593
2593
  session = {
2594
2594
  sessionId,
2595
2595
  protocol: "thp",
2596
2596
  thpSessionId: created.thpSessionId
2597
2597
  };
2598
- } else if (_optionalChain([created, 'optionalAccess', _137 => _137.protocol]) === "v1") {
2598
+ } else if (_optionalChain([created, 'optionalAccess', _139 => _139.protocol]) === "v1") {
2599
2599
  session = {
2600
2600
  sessionId,
2601
2601
  protocol: "v1"
@@ -2615,7 +2615,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2615
2615
  }
2616
2616
  }
2617
2617
  async _reuseVerifiedPassphraseSession(connectId, sessionId, passphraseState, signal) {
2618
- const cached = _optionalChain([this, 'access', _138 => _138._verifiedPassphraseSessionsByConnectId, 'access', _139 => _139.get, 'call', _140 => _140(connectId), 'optionalAccess', _141 => _141.get, 'call', _142 => _142(passphraseState)]);
2618
+ const cached = _optionalChain([this, 'access', _140 => _140._verifiedPassphraseSessionsByConnectId, 'access', _141 => _141.get, 'call', _142 => _142(connectId), 'optionalAccess', _143 => _143.get, 'call', _144 => _144(passphraseState)]);
2619
2619
  if (!cached || cached.sessionId !== sessionId) {
2620
2620
  this._forgetVerifiedPassphraseSession(connectId, passphraseState);
2621
2621
  return false;
@@ -2682,7 +2682,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2682
2682
  signal
2683
2683
  )
2684
2684
  );
2685
- const state = _optionalChain([derived, 'optionalAccess', _143 => _143.publicKey]);
2685
+ const state = _optionalChain([derived, 'optionalAccess', _145 => _145.publicKey]);
2686
2686
  if (!state) {
2687
2687
  throw Object.assign(new Error("Failed to derive passphrase state (wallet public key)"), {
2688
2688
  code: _hwkadaptercore.HardwareErrorCode.UnknownError
@@ -2719,7 +2719,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2719
2719
  signal,
2720
2720
  this._callConnector(sessionId, "getFeatures", { refresh: true }, signal)
2721
2721
  );
2722
- if (_optionalChain([features, 'optionalAccess', _144 => _144.passphrase_protection]) !== true) {
2722
+ if (_optionalChain([features, 'optionalAccess', _146 => _146.passphrase_protection]) !== true) {
2723
2723
  return _hwkadaptercore.success.call(void 0, null);
2724
2724
  }
2725
2725
  this._rememberVerifiedPassphraseSession(connectId, state, sessionId, created);
@@ -2767,7 +2767,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2767
2767
  }
2768
2768
  const trustedNumericCode = typeof typed.code === "number" && KNOWN_HARDWARE_ERROR_CODES.has(typed.code) ? typed.code : void 0;
2769
2769
  const code = _nullishCoalesce(_nullishCoalesce(trustedNumericCode, () => ( _TrezorAdapter._mapTrezorFailureCode(error))), () => ( _hwkadaptercore.HardwareErrorCode.UnknownError));
2770
- const stampedOrigin = _optionalChain([error, 'optionalAccess', _145 => _145.origin]);
2770
+ const stampedOrigin = _optionalChain([error, 'optionalAccess', _147 => _147.origin]);
2771
2771
  const origin = stampedOrigin === "device" || stampedOrigin === "transport" || stampedOrigin === "host" ? stampedOrigin : _hwkadaptercore.defaultOriginForCode.call(void 0, code);
2772
2772
  const params = typed.params && typeof typed.params === "object" ? typed.params : void 0;
2773
2773
  return _hwkadaptercore.failure.call(void 0,