Skip to content

Commit 39ebea5

Browse files
committed
revive fido2 list (Nitrokey#60)
1 parent 8b77234 commit 39ebea5

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

pynitrokey/cli/fido2.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,24 @@ def rng():
160160
@click.command()
161161
def list():
162162
"""List all 'Nitrokey FIDO2' devices"""
163-
solos = nkfido2.find_all()
163+
devs = nkfido2.find_all()
164164
local_print(":: 'Nitrokey FIDO2' keys")
165-
for c in solos:
166-
devdata = c.dev.descriptor
167-
if "serial_number" in devdata:
168-
local_print(f"{devdata['serial_number']}: {devdata['product_string']}")
165+
for c in devs:
166+
descr = c.dev.descriptor
167+
168+
if hasattr(descr, "product_name"):
169+
name = descr.product_name
170+
elif c.is_solo_bootloader():
171+
name = "FIDO2 Bootloader device"
169172
else:
170-
local_print(f"{devdata['path']}: {devdata['product_string']}")
173+
name = "FIDO2 device"
171174

175+
if hasattr(descr, "serial_number"):
176+
id_ = descr.serial_number
177+
else:
178+
id_ = descr.path
179+
180+
local_print(f"{id_}: {name}")
172181

173182
@click.command()
174183
@click.option("--count", default=8, help="How many bytes to generate (defaults to 8)")

pynitrokey/fido2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def find_all():
5454

5555
hid_devices = list(CtapHidDevice.list_devices())
5656
solo_devices = [d for d in hid_devices
57-
if (d.descriptor["vendor_id"], d.descriptor["product_id"]) in [
57+
if (d.descriptor.vid, d.descriptor.pid) in [
5858
## @FIXME: move magic numbers
5959
(1155, 41674),
6060
(0x20A0, 0x42B3),

0 commit comments

Comments
 (0)