diff --git a/helper/helper/base.py b/helper/helper/base.py index a8bfaaf4..c894b10f 100644 --- a/helper/helper/base.py +++ b/helper/helper/base.py @@ -148,6 +148,7 @@ class RpcNode: raise InvalidParametersException(e) def close(self): + logger.debug(f"Closing node {self}") self._closed = True if self._child: self._close_child() diff --git a/helper/helper/device.py b/helper/helper/device.py index c8510103..e059c03d 100644 --- a/helper/helper/device.py +++ b/helper/helper/device.py @@ -168,7 +168,7 @@ class ReadersNode(RpcNode): return self._readers def create_child(self, name): - return ReaderDeviceNode(self._reader_mapping[name], None) + return ReaderDeviceNode(self._reader_mapping[name]) class _ScanDevices: @@ -238,7 +238,7 @@ class DevicesNode(RpcNode): dev_id = str(info.serial) else: dev_id = _id_from_fingerprint(dev.fingerprint) - self._device_mapping[dev_id] = (dev, info) + self._device_mapping[dev_id] = dev name = get_name(info, dev.pid.yubikey_type if dev.pid else None) self._devices[dev_id] = dict(pid=dev.pid, name=name, serial=info.serial) @@ -255,16 +255,16 @@ class DevicesNode(RpcNode): if name not in self._device_mapping and self._list_state == 0: self.list_children() try: - return UsbDeviceNode(*self._device_mapping[name]) + return UsbDeviceNode(self._device_mapping[name]) except KeyError: raise NoSuchNodeException(name) class AbstractDeviceNode(RpcNode): - def __init__(self, device, info): + def __init__(self, device): super().__init__() self._device = device - self._info = info + self._info = None self._data = None def __call__(self, *args, **kwargs): @@ -383,8 +383,8 @@ RESTRICTED_NDEF = bytes.fromhex("001fd1011b5504") + b"yubico.com/getting-started class ReaderDeviceNode(AbstractDeviceNode): - def __init__(self, device, info): - super().__init__(device, info) + def __init__(self, device): + super().__init__(device) self._observer = _ReaderObserver(device) self._monitor = CardMonitor() self._monitor.addObserver(self._observer) diff --git a/lib/desktop/oath/state.dart b/lib/desktop/oath/state.dart index c0434613..f15dedf5 100755 --- a/lib/desktop/oath/state.dart +++ b/lib/desktop/oath/state.dart @@ -28,6 +28,7 @@ import '../../app/logging.dart'; import '../../app/models.dart'; import '../../app/state.dart'; import '../../app/views/user_interaction.dart'; +import '../../management/models.dart'; import '../../oath/models.dart'; import '../../oath/state.dart'; import '../rpc.dart'; @@ -37,8 +38,16 @@ final _log = Logger('desktop.oath.state'); final _sessionProvider = Provider.autoDispose.family( - (ref, devicePath) => RpcNodeSession( - ref.watch(rpcProvider).requireValue, devicePath, ['ccid', 'oath']), + (ref, devicePath) { + // Reset state if the OATH capability is toggled. + ref.watch(currentDeviceDataProvider.select((value) => + (value.valueOrNull?.info.config + .enabledCapabilities[value.valueOrNull?.node.transport] ?? + 0) & + Capability.oath.value)); + return RpcNodeSession( + ref.watch(rpcProvider).requireValue, devicePath, ['ccid', 'oath']); + }, ); // This remembers the key for all devices for the duration of the process.