mirror of
				https://github.com/maxgoedjen/secretive.git
				synced 2025-10-29 06:20:56 +00:00 
			
		
		
		
	Merge branch 'master' of github.com:maxgoedjen/secretive
This commit is contained in:
		
						commit
						f7f182ec77
					
				| @ -2,6 +2,7 @@ import Foundation | ||||
| import SecretKit | ||||
| import SecretAgentKit | ||||
| import UserNotifications | ||||
| import AppKit | ||||
| 
 | ||||
| class Notifier { | ||||
| 
 | ||||
| @ -14,14 +15,34 @@ class Notifier { | ||||
|     func notify(accessTo secret: AnySecret, by provenance: SigningRequestProvenance) { | ||||
|         let notificationCenter = UNUserNotificationCenter.current() | ||||
|         let notificationContent = UNMutableNotificationContent() | ||||
|         notificationContent.title = "Signed Request" | ||||
|         notificationContent.body = "\(secret.name) was used to sign a request from \(provenance.origin.name)." | ||||
|         notificationContent.title = "Signed Request from \(provenance.origin.name)" | ||||
|         notificationContent.subtitle = secret.name | ||||
|         if let iconURL = iconURL(for: provenance), let attachment = try? UNNotificationAttachment(identifier: "icon", url: iconURL, options: nil) { | ||||
|             notificationContent.attachments = [attachment] | ||||
|         } | ||||
|         let request = UNNotificationRequest(identifier: UUID().uuidString, content: notificationContent, trigger: nil) | ||||
|         notificationCenter.add(request, withCompletionHandler: nil) | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| extension Notifier { | ||||
| 
 | ||||
|     func iconURL(for provenance: SigningRequestProvenance) -> URL? { | ||||
|         do { | ||||
|             if let app = NSRunningApplication(processIdentifier: provenance.origin.pid), let icon = app.icon?.tiffRepresentation { | ||||
|                 let temporaryURL = URL(fileURLWithPath: (NSTemporaryDirectory() as NSString).appendingPathComponent("\(UUID().uuidString).png")) | ||||
|                 let bitmap = NSBitmapImageRep(data: icon) | ||||
|                 try bitmap?.representation(using: .png, properties: [:])?.write(to: temporaryURL) | ||||
|                 return temporaryURL | ||||
|             } | ||||
|         } catch { | ||||
|         } | ||||
|         return nil | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| extension Notifier: SigningWitness { | ||||
| 
 | ||||
|     func speakNowOrForeverHoldYourPeace(forAccessTo secret: AnySecret, by provenance: SigningRequestProvenance) throws { | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								SecretAgent/Untitled.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SecretAgent/Untitled.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.6 KiB | 
| @ -28,6 +28,7 @@ | ||||
| 		50617DD223FCEFA90099B055 /* PreviewStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50617DD123FCEFA90099B055 /* PreviewStore.swift */; }; | ||||
| 		506772C72424784600034DED /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 506772C62424784600034DED /* Credits.rtf */; }; | ||||
| 		506772C92425BB8500034DED /* NoStoresView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506772C82425BB8500034DED /* NoStoresView.swift */; }; | ||||
| 		506772CB2426CCC200034DED /* Untitled.png in Resources */ = {isa = PBXBuildFile; fileRef = 506772CA2426CCC200034DED /* Untitled.png */; }; | ||||
| 		5068389E241471CD00F55094 /* SecretStoreList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5068389D241471CD00F55094 /* SecretStoreList.swift */; }; | ||||
| 		506838A12415EA5600F55094 /* AnySecret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506838A02415EA5600F55094 /* AnySecret.swift */; }; | ||||
| 		506838A32415EA5D00F55094 /* AnySecretStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506838A22415EA5D00F55094 /* AnySecretStore.swift */; }; | ||||
| @ -203,6 +204,7 @@ | ||||
| 		50617DD123FCEFA90099B055 /* PreviewStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewStore.swift; sourceTree = "<group>"; }; | ||||
| 		506772C62424784600034DED /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; }; | ||||
| 		506772C82425BB8500034DED /* NoStoresView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoStoresView.swift; sourceTree = "<group>"; }; | ||||
| 		506772CA2426CCC200034DED /* Untitled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Untitled.png; sourceTree = "<group>"; }; | ||||
| 		5068389D241471CD00F55094 /* SecretStoreList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretStoreList.swift; sourceTree = "<group>"; }; | ||||
| 		506838A02415EA5600F55094 /* AnySecret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnySecret.swift; sourceTree = "<group>"; }; | ||||
| 		506838A22415EA5D00F55094 /* AnySecretStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnySecretStore.swift; sourceTree = "<group>"; }; | ||||
| @ -507,6 +509,7 @@ | ||||
| 			children = ( | ||||
| 				50020BAF24064869003D4025 /* AppDelegate.swift */, | ||||
| 				5018F54E24064786002EB505 /* Notifier.swift */, | ||||
| 				506772CA2426CCC200034DED /* Untitled.png */, | ||||
| 				50A3B79024026B7600D209EA /* Assets.xcassets */, | ||||
| 				50A3B79524026B7600D209EA /* Main.storyboard */, | ||||
| 				50A3B79824026B7600D209EA /* Info.plist */, | ||||
| @ -790,6 +793,7 @@ | ||||
| 			isa = PBXResourcesBuildPhase; | ||||
| 			buildActionMask = 2147483647; | ||||
| 			files = ( | ||||
| 				506772CB2426CCC200034DED /* Untitled.png in Resources */, | ||||
| 				50A3B79724026B7600D209EA /* Main.storyboard in Resources */, | ||||
| 				50A3B79424026B7600D209EA /* Preview Assets.xcassets in Resources */, | ||||
| 				50A3B79124026B7600D209EA /* Assets.xcassets in Resources */, | ||||
|  | ||||
| @ -66,7 +66,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { | ||||
| 
 | ||||
|     @IBAction func runSetup(sender: AnyObject?) { | ||||
|         let setupWindow = NSWindow( | ||||
|             contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), | ||||
|             contentRect: NSRect(x: 0, y: 0, width: 00, height: 00), | ||||
|             styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], | ||||
|             backing: .buffered, defer: false) | ||||
|         let setupView = SetupView() { success in | ||||
| @ -74,6 +74,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { | ||||
|             self.agentStatusChecker.check() | ||||
|         } | ||||
|         setupWindow.contentView = NSHostingView(rootView: setupView) | ||||
|         setupWindow.setContentSize(setupWindow.contentView!.fittingSize) | ||||
|         window.beginSheet(setupWindow, completionHandler: nil) | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user