2020-03-04 07:14:38 +00:00
|
|
|
import Cocoa
|
|
|
|
import SecretKit
|
2020-03-17 06:39:34 +00:00
|
|
|
import SecretAgentKit
|
2020-03-04 07:14:38 +00:00
|
|
|
import OSLog
|
|
|
|
|
|
|
|
@NSApplicationMain
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
|
2020-03-09 04:11:59 +00:00
|
|
|
let storeList: SecretStoreList = {
|
|
|
|
let list = SecretStoreList()
|
|
|
|
list.add(store: SecureEnclave.Store())
|
|
|
|
list.add(store: SmartCard.Store())
|
|
|
|
return list
|
|
|
|
}()
|
2020-03-04 07:14:38 +00:00
|
|
|
let notifier = Notifier()
|
|
|
|
lazy var agent: Agent = {
|
2020-03-17 07:56:55 +00:00
|
|
|
Agent(storeList: storeList, witness: notifier)
|
2020-03-04 07:14:38 +00:00
|
|
|
}()
|
|
|
|
lazy var socketController: SocketController = {
|
|
|
|
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String
|
|
|
|
return SocketController(path: path)
|
|
|
|
}()
|
|
|
|
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
|
|
os_log(.debug, "SecretAgent finished launching")
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
self.socketController.handler = self.agent.handle(fileHandle:)
|
|
|
|
}
|
|
|
|
notifier.prompt()
|
|
|
|
}
|
|
|
|
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
|
|
// Insert code here to tear down your application
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|