From 341b6d9405d745a9c9b59f64df701e2a57e4107d Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sat, 26 Jun 2021 15:03:52 -0700 Subject: [PATCH] Add driver name when on macOS 12.0 --- SecretKit/SmartCard/SmartCardStore.swift | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/SecretKit/SmartCard/SmartCardStore.swift b/SecretKit/SmartCard/SmartCardStore.swift index 236ec0c..dfff4d4 100644 --- a/SecretKit/SmartCard/SmartCardStore.swift +++ b/SecretKit/SmartCard/SmartCardStore.swift @@ -103,12 +103,22 @@ extension SmartCard.Store { private func loadSecrets() { guard let tokenID = tokenID else { return } - // Hack to read name if there's only one smart card - let slotNames = TKSmartCardSlotManager().slotNames - if watcher.nonSecureEnclaveTokens.count == 1 && slotNames.count == 1 { - name = slotNames.first! + + let fallbackName = NSLocalizedString("Smart Card", comment: "Smart Card") + if #available(macOS 12.0, *) { + if let driverName = watcher.tokenInfo(forTokenID: tokenID)?.driverName { + name = driverName + } else { + name = fallbackName + } } else { - name = NSLocalizedString("Smart Card", comment: "Smart Card") + // Hack to read name if there's only one smart card + let slotNames = TKSmartCardSlotManager().slotNames + if watcher.nonSecureEnclaveTokens.count == 1 && slotNames.count == 1 { + name = slotNames.first! + } else { + name = fallbackName + } } let attributes = [