Remove changes

This commit is contained in:
Max Goedjen 2020-03-07 15:20:59 -08:00
parent 8863a42308
commit 734df29065
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
5 changed files with 29 additions and 27 deletions

View File

@ -4,19 +4,11 @@ import Combine
extension SecureEnclave {
public struct Secret: SecretKit.Secret {
public init(id: Data, name: String, publicKey: Data) {
self.id = id
self.name = name
self.publicKey = publicKey
}
public let id: Data
public let name: String
public let publicKey: Data
}
}

View File

@ -4,17 +4,9 @@ import Combine
extension SmartCard {
public struct Secret: SecretKit.Secret {
public init(id: Data, name: String, publicKey: Data) {
self.id = id
// self.name = name
self.publicKey = publicKey
}
public let id: Data
public var name: String {
UUID().uuidString
}
public var name: String
public let publicKey: Data
}

View File

@ -20,8 +20,11 @@ extension SmartCard {
guard self.id == nil else { return }
guard !string.contains("setoken") else { return }
self.id = string
self.secrets.removeAll()
self.loadSecrets()
self.reloadSecrets()
self.watcher.addRemovalHandler(self.reloadSecrets, forTokenID: string)
}
if let id = id {
self.watcher.addRemovalHandler(self.reloadSecrets, forTokenID: id)
}
loadSecrets()
}
@ -67,6 +70,13 @@ extension SmartCard {
extension SmartCard.Store {
fileprivate func reloadSecrets(for tokenID: String? = nil) {
DispatchQueue.main.async {
self.secrets.removeAll()
self.loadSecrets()
}
}
fileprivate func loadSecrets() {
guard let id = id else { return }
let attributes = [

View File

@ -15,7 +15,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
let contentView = ContentView(store: secureEnclave)
let contentView = ContentView(secureEnclave: secureEnclave, smartCard: smartCard)
// Create the window and set the content view.
window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),

View File

@ -3,8 +3,9 @@ import SecretKit
struct ContentView: View {
@ObservedObject var store: SecureEnclave.Store
@State var active: SecureEnclave.Secret.ID?
@ObservedObject var secureEnclave: SecureEnclave.Store
@ObservedObject var smartCard: SmartCard.Store
@State var active: Data?
@State var showingDeletion = false
@State var deletingSecret: SecureEnclave.Secret?
@ -12,8 +13,8 @@ struct ContentView: View {
var body: some View {
NavigationView {
List(selection: $active) {
Section(header: Text(store.name)) {
ForEach(store.secrets) { secret in
Section(header: Text(secureEnclave.name)) {
ForEach(secureEnclave.secrets) { secret in
NavigationLink(destination: SecretDetailView(secret: secret), tag: secret.id, selection: self.$active) {
Text(secret.name)
}.contextMenu {
@ -23,15 +24,22 @@ struct ContentView: View {
}
}
}
Section(header: Text(smartCard.name)) {
ForEach(smartCard.secrets) { secret in
NavigationLink(destination: SecretDetailView(secret: secret), tag: secret.id, selection: self.$active) {
Text(secret.name)
}
}
}
}.onAppear {
self.active = self.store.secrets.first?.id
self.active = self.secureEnclave.secrets.first?.id ?? self.smartCard.secrets.first?.id
}
.listStyle(SidebarListStyle())
.frame(minWidth: 100, idealWidth: 240)
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
.sheet(isPresented: $showingDeletion) {
DeleteSecretView(secret: self.deletingSecret!, store: self.store) {
DeleteSecretView(secret: self.deletingSecret!, store: self.secureEnclave) {
self.showingDeletion = false
}
}