From efeb7f09a3f8e44c19d733eb5c363067a764fbf0 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sat, 21 Mar 2020 23:33:51 -0700 Subject: [PATCH 1/5] Fix brief signing --- Secretive.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Secretive.xcodeproj/project.pbxproj b/Secretive.xcodeproj/project.pbxproj index 1c47f27..fe1eaea 100644 --- a/Secretive.xcodeproj/project.pbxproj +++ b/Secretive.xcodeproj/project.pbxproj @@ -1399,7 +1399,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "Developer ID Application"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; From 0d74f6f5610d31026cffa4d327100ed0a076d3a6 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sat, 21 Mar 2020 23:36:52 -0700 Subject: [PATCH 2/5] Really fix signing for brief --- Secretive.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Secretive.xcodeproj/project.pbxproj b/Secretive.xcodeproj/project.pbxproj index fe1eaea..bfb8b48 100644 --- a/Secretive.xcodeproj/project.pbxproj +++ b/Secretive.xcodeproj/project.pbxproj @@ -1369,7 +1369,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; @@ -1429,7 +1429,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "Developer ID Application"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; From 89f0798576d9c87b72222eda3b25a78dbfe4febf Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sat, 21 Mar 2020 23:40:10 -0700 Subject: [PATCH 3/5] Add status badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ced3101..e82fce5 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ Secretive is an app for storing and managing SSH keys in the Secure Enclave. It Screenshot of Secretive +![Test](https://github.com/maxgoedjen/secretive/workflows/Test/badge.svg) +![Release](https://github.com/maxgoedjen/secretive/workflows/Release/badge.svg) + ## Why? ### Safer Storage From 594d855f19cddc028d2e8d04df596554e3786355 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sat, 21 Mar 2020 23:40:43 -0700 Subject: [PATCH 4/5] Move status badges. --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e82fce5..9797135 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -# Secretive +# Secretive ![Test](https://github.com/maxgoedjen/secretive/workflows/Test/badge.svg) ![Release](https://github.com/maxgoedjen/secretive/workflows/Release/badge.svg) + Secretive is an app for storing and managing SSH keys in the Secure Enclave. It is inspired by the [sekey project](https://github.com/sekey/sekey), but rewritten in Swift with no external dependencies and with a handy native management app. Screenshot of Secretive -![Test](https://github.com/maxgoedjen/secretive/workflows/Test/badge.svg) -![Release](https://github.com/maxgoedjen/secretive/workflows/Release/badge.svg) ## Why? From b090a96975f95bcc324c86add81d64f9b5764bdb Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sun, 22 Mar 2020 15:26:29 -0700 Subject: [PATCH 5/5] Add option to ignore non-critical updates (#73) --- Brief/Updater.swift | 21 +++++++++++++++++++++ SecretAgent/AppDelegate.swift | 6 +++--- SecretAgent/Notifier.swift | 29 +++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/Brief/Updater.swift b/Brief/Updater.swift index f773cf7..f9f67c6 100644 --- a/Brief/Updater.swift +++ b/Brief/Updater.swift @@ -27,7 +27,20 @@ public class Updater: ObservableObject, UpdaterProtocol { }.resume() } + public func ignore(release: Release) { + guard !release.critical else { return } + defaults.set(true, forKey: release.name) + DispatchQueue.main.async { + self.update = nil + } + } + +} + +extension Updater { + func evaluate(release: Release) { + guard !userIgnored(release: release) else { return } let latestVersion = semVer(from: release.name) let currentVersion = semVer(from: Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String) for (latest, current) in zip(latestVersion, currentVersion) { @@ -48,6 +61,14 @@ public class Updater: ObservableObject, UpdaterProtocol { return split } + func userIgnored(release: Release) -> Bool { + guard !release.critical else { return false } + return defaults.bool(forKey: release.name) + } + + var defaults: UserDefaults { + UserDefaults(suiteName: "com.maxgoedjen.Secretive.updater.ignorelist")! + } } extension Updater { diff --git a/SecretAgent/AppDelegate.swift b/SecretAgent/AppDelegate.swift index 41ae78c..e1cfe7c 100644 --- a/SecretAgent/AppDelegate.swift +++ b/SecretAgent/AppDelegate.swift @@ -31,9 +31,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.socketController.handler = self.agent.handle(fileHandle:) } notifier.prompt() - updateSink = updater.$update.sink { release in - guard let release = release else { return } - self.notifier.notify(update: release) + updateSink = updater.$update.sink { update in + guard let update = update else { return } + self.notifier.notify(update: update, ignore: self.updater.ignore(release:)) } } diff --git a/SecretAgent/Notifier.swift b/SecretAgent/Notifier.swift index b55d9c8..cbfce20 100644 --- a/SecretAgent/Notifier.swift +++ b/SecretAgent/Notifier.swift @@ -10,9 +10,11 @@ class Notifier { fileprivate let notificationDelegate = NotificationDelegate() init() { - let action = UNNotificationAction(identifier: Constants.updateIdentitifier, title: "Update", options: []) - let categories = UNNotificationCategory(identifier: Constants.updateIdentitifier, actions: [action], intentIdentifiers: [], options: []) - UNUserNotificationCenter.current().setNotificationCategories([categories]) + let updateAction = UNNotificationAction(identifier: Constants.updateActionIdentitifier, title: "Update", options: []) + let ignoreAction = UNNotificationAction(identifier: Constants.ignoreActionIdentitifier, title: "Ignore", options: []) + let updateCategory = UNNotificationCategory(identifier: Constants.updateCategoryIdentitifier, actions: [updateAction, ignoreAction], intentIdentifiers: [], options: []) + let criticalUpdateCategory = UNNotificationCategory(identifier: Constants.updateCategoryIdentitifier, actions: [updateAction], intentIdentifiers: [], options: []) + UNUserNotificationCenter.current().setNotificationCategories([updateCategory, criticalUpdateCategory]) UNUserNotificationCenter.current().delegate = notificationDelegate } @@ -34,8 +36,9 @@ class Notifier { notificationCenter.add(request, withCompletionHandler: nil) } - func notify(update: Release) { + func notify(update: Release, ignore: ((Release) -> Void)?) { notificationDelegate.release = update + notificationDelegate.ignore = ignore let notificationCenter = UNUserNotificationCenter.current() let notificationContent = UNMutableNotificationContent() if update.critical { @@ -45,7 +48,7 @@ class Notifier { } notificationContent.subtitle = "Click to Update" notificationContent.body = update.body - notificationContent.categoryIdentifier = Constants.updateIdentitifier + notificationContent.categoryIdentifier = update.critical ? Constants.criticalUpdateCategoryIdentitifier : Constants.updateCategoryIdentitifier let request = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: nil) notificationCenter.add(request, withCompletionHandler: nil) } @@ -83,7 +86,10 @@ extension Notifier: SigningWitness { extension Notifier { enum Constants { - static let updateIdentitifier = "com.maxgoedjen.Secretive.SecretAgent.update" + static let updateCategoryIdentitifier = "com.maxgoedjen.Secretive.SecretAgent.update" + static let criticalUpdateCategoryIdentitifier = "com.maxgoedjen.Secretive.SecretAgent.update.critical" + static let updateActionIdentitifier = "com.maxgoedjen.Secretive.SecretAgent.update.updateaction" + static let ignoreActionIdentitifier = "com.maxgoedjen.Secretive.SecretAgent.update.ignoreaction" } } @@ -91,15 +97,22 @@ extension Notifier { class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate { fileprivate var release: Release? + fileprivate var ignore: ((Release) -> Void)? func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) { } func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { - guard response.notification.request.content.categoryIdentifier == Notifier.Constants.updateIdentitifier else { return } guard let update = release else { return } - NSWorkspace.shared.open(update.html_url) + switch response.actionIdentifier { + case Notifier.Constants.updateActionIdentitifier, UNNotificationDefaultActionIdentifier: + NSWorkspace.shared.open(update.html_url) + case Notifier.Constants.ignoreActionIdentitifier: + ignore?(update) + default: + fatalError() + } completionHandler() }