@onekeyfe/hwk-trezor-adapter 1.2.5-alpha.1 → 1.2.5-alpha.2

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