secretive/SecretKit/SmartCard/SmartCardStore.swift

37 lines
1.1 KiB
Swift
Raw Normal View History

2020-03-04 07:14:38 +00:00
import Foundation
import Security
import CryptoTokenKit
2020-03-06 06:47:13 +00:00
// TODO: Might need to split this up into "sub-stores?"
// ie, each token has its own Store.
2020-03-04 07:14:38 +00:00
extension SmartCard {
public class Store: SecretStore {
// TODO: Read actual smart card name, eg "YubiKey 5c"
public let name = NSLocalizedString("Smart Card", comment: "Smart Card")
@Published public fileprivate(set) var secrets: [Secret] = []
fileprivate let watcher = TKTokenWatcher()
public init() {
watcher.setInsertionHandler { (string) in
2020-03-06 06:47:13 +00:00
guard !string.contains("setoken") else { return }
let driver = TKSmartCardTokenDriver()
let token = TKToken(tokenDriver: driver, instanceID: string)
2020-03-06 07:57:31 +00:00
let session = TKSmartCardTokenSession(token: token)
2020-03-06 06:47:13 +00:00
print(session)
2020-03-04 07:14:38 +00:00
}
print(watcher.tokenIDs)
}
public func sign(data: Data, with secret: SmartCard.Secret) throws -> Data {
fatalError()
}
public func delete(secret: SmartCard.Secret) throws {
}
}
}