Remove changes
This commit is contained in:
parent
8863a42308
commit
734df29065
|
@ -4,19 +4,11 @@ import Combine
|
||||||
extension SecureEnclave {
|
extension SecureEnclave {
|
||||||
|
|
||||||
public struct Secret: SecretKit.Secret {
|
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 id: Data
|
||||||
public let name: String
|
public let name: String
|
||||||
public let publicKey: Data
|
public let publicKey: Data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,9 @@ import Combine
|
||||||
extension SmartCard {
|
extension SmartCard {
|
||||||
|
|
||||||
public struct Secret: SecretKit.Secret {
|
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 id: Data
|
||||||
public var name: String {
|
public var name: String
|
||||||
UUID().uuidString
|
|
||||||
}
|
|
||||||
public let publicKey: Data
|
public let publicKey: Data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,11 @@ extension SmartCard {
|
||||||
guard self.id == nil else { return }
|
guard self.id == nil else { return }
|
||||||
guard !string.contains("setoken") else { return }
|
guard !string.contains("setoken") else { return }
|
||||||
self.id = string
|
self.id = string
|
||||||
self.secrets.removeAll()
|
self.reloadSecrets()
|
||||||
self.loadSecrets()
|
self.watcher.addRemovalHandler(self.reloadSecrets, forTokenID: string)
|
||||||
|
}
|
||||||
|
if let id = id {
|
||||||
|
self.watcher.addRemovalHandler(self.reloadSecrets, forTokenID: id)
|
||||||
}
|
}
|
||||||
loadSecrets()
|
loadSecrets()
|
||||||
}
|
}
|
||||||
|
@ -67,6 +70,13 @@ extension SmartCard {
|
||||||
|
|
||||||
extension SmartCard.Store {
|
extension SmartCard.Store {
|
||||||
|
|
||||||
|
fileprivate func reloadSecrets(for tokenID: String? = nil) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.secrets.removeAll()
|
||||||
|
self.loadSecrets()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fileprivate func loadSecrets() {
|
fileprivate func loadSecrets() {
|
||||||
guard let id = id else { return }
|
guard let id = id else { return }
|
||||||
let attributes = [
|
let attributes = [
|
||||||
|
|
|
@ -15,7 +15,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
|
|
||||||
let contentView = ContentView(store: secureEnclave)
|
let contentView = ContentView(secureEnclave: secureEnclave, smartCard: smartCard)
|
||||||
// Create the window and set the content view.
|
// Create the window and set the content view.
|
||||||
window = NSWindow(
|
window = NSWindow(
|
||||||
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
||||||
|
|
|
@ -3,8 +3,9 @@ import SecretKit
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
||||||
@ObservedObject var store: SecureEnclave.Store
|
@ObservedObject var secureEnclave: SecureEnclave.Store
|
||||||
@State var active: SecureEnclave.Secret.ID?
|
@ObservedObject var smartCard: SmartCard.Store
|
||||||
|
@State var active: Data?
|
||||||
|
|
||||||
@State var showingDeletion = false
|
@State var showingDeletion = false
|
||||||
@State var deletingSecret: SecureEnclave.Secret?
|
@State var deletingSecret: SecureEnclave.Secret?
|
||||||
|
@ -12,8 +13,8 @@ struct ContentView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
List(selection: $active) {
|
List(selection: $active) {
|
||||||
Section(header: Text(store.name)) {
|
Section(header: Text(secureEnclave.name)) {
|
||||||
ForEach(store.secrets) { secret in
|
ForEach(secureEnclave.secrets) { secret in
|
||||||
NavigationLink(destination: SecretDetailView(secret: secret), tag: secret.id, selection: self.$active) {
|
NavigationLink(destination: SecretDetailView(secret: secret), tag: secret.id, selection: self.$active) {
|
||||||
Text(secret.name)
|
Text(secret.name)
|
||||||
}.contextMenu {
|
}.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 {
|
}.onAppear {
|
||||||
self.active = self.store.secrets.first?.id
|
self.active = self.secureEnclave.secrets.first?.id ?? self.smartCard.secrets.first?.id
|
||||||
}
|
}
|
||||||
.listStyle(SidebarListStyle())
|
.listStyle(SidebarListStyle())
|
||||||
.frame(minWidth: 100, idealWidth: 240)
|
.frame(minWidth: 100, idealWidth: 240)
|
||||||
}
|
}
|
||||||
.navigationViewStyle(DoubleColumnNavigationViewStyle())
|
.navigationViewStyle(DoubleColumnNavigationViewStyle())
|
||||||
.sheet(isPresented: $showingDeletion) {
|
.sheet(isPresented: $showingDeletion) {
|
||||||
DeleteSecretView(secret: self.deletingSecret!, store: self.store) {
|
DeleteSecretView(secret: self.deletingSecret!, store: self.secureEnclave) {
|
||||||
self.showingDeletion = false
|
self.showingDeletion = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue