-
-
Notifications
You must be signed in to change notification settings - Fork 0
Ux UI #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Ux UI #2
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "configurations" : [ | ||
| { | ||
| "id" : "86DBA0CF-7C5C-4C77-B1DA-42F46A4BD664", | ||
| "name" : "Test Scheme Action", | ||
| "options" : { | ||
|
|
||
| } | ||
| } | ||
| ], | ||
| "defaultOptions" : { | ||
| "performanceAntipatternCheckerEnabled" : true, | ||
| "targetForVariableExpansion" : { | ||
| "containerPath" : "container:", | ||
| "identifier" : "SilentKey", | ||
| "name" : "SilentKey" | ||
| } | ||
| }, | ||
| "testTargets" : [ | ||
| { | ||
| "parallelizable" : true, | ||
| "selectedTags" : { | ||
| "includeXCTests" : true | ||
| }, | ||
| "target" : { | ||
| "containerPath" : "container:", | ||
| "identifier" : "SilentKeyTests", | ||
| "name" : "SilentKeyTests" | ||
| } | ||
| } | ||
| ], | ||
| "version" : 1 | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // | ||
| // CertificateModels.swift | ||
| // SilentKey | ||
| // | ||
| // Models for SSL/TLS certificates and other digital certs | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| public struct CertificateSecret: SecretItemProtocol, EncryptableSecret, ExportableSecret { | ||
| public let id: UUID | ||
| public var title: String | ||
| public var notes: String? | ||
| public var tags: Set<String> | ||
| public let createdAt: Date | ||
| public var modifiedAt: Date | ||
| public var isFavorite: Bool | ||
|
|
||
| public var certificateName: String | ||
| public var issuer: String | ||
| public var expirationDate: Date? | ||
| public var encryptedFields: [String: Data] | ||
|
|
||
| public var category: SecretCategory { | ||
| .certificate | ||
| } | ||
|
|
||
| public var iconName: String { | ||
| category.icon | ||
| } | ||
|
|
||
| public init( | ||
| id: UUID = UUID(), | ||
| title: String, | ||
| certificateName: String, | ||
| issuer: String, | ||
| expirationDate: Date? = nil, | ||
| notes: String? = nil, | ||
| tags: Set<String> = [], | ||
| isFavorite: Bool = false | ||
| ) { | ||
| self.id = id | ||
| self.title = title | ||
| self.certificateName = certificateName | ||
| self.issuer = issuer | ||
| self.expirationDate = expirationDate | ||
| self.notes = notes | ||
| self.tags = tags | ||
| self.createdAt = Date() | ||
| self.modifiedAt = Date() | ||
| self.isFavorite = isFavorite | ||
| self.encryptedFields = [:] | ||
| } | ||
|
|
||
| public func encryptedData() throws -> Data { | ||
| try JSONEncoder().encode(self) | ||
| } | ||
|
|
||
| public func validate() throws { | ||
| guard !title.isEmpty else { throw ValidationError.emptyTitle } | ||
| guard !certificateName.isEmpty else { throw ValidationError.emptyCertName } | ||
| } | ||
|
|
||
| public func searchableText() -> String { | ||
| [title, certificateName, issuer, notes ?? ""].joined(separator: " ") | ||
| } | ||
|
|
||
| public mutating func encrypt(field: String, value: String, using key: Data) throws { | ||
| guard let data = value.data(using: .utf8) else { throw CertificateError.encryptionFailed } | ||
| encryptedFields[field] = data | ||
| modifiedAt = Date() | ||
| } | ||
|
|
||
| public func decrypt(field: String, using key: Data) throws -> String { | ||
| guard let data = encryptedFields[field] else { throw CertificateError.fieldNotFound } | ||
| guard let value = String(data: data, encoding: .utf8) else { throw CertificateError.decryptionFailed } | ||
| return value | ||
| } | ||
|
|
||
| public var supportedExportFormats: [ExportFormat] { | ||
| [.json, .encrypted] | ||
| } | ||
|
|
||
| public func export(format: ExportFormat) throws -> Data { | ||
| switch format { | ||
| case .json: return try JSONEncoder().encode(self) | ||
| case .encrypted: return try encryptedData() | ||
| default: throw CertificateError.unsupportedFormat | ||
| } | ||
| } | ||
|
|
||
| public enum ValidationError: Error { | ||
| case emptyTitle | ||
| case emptyCertName | ||
| } | ||
| } | ||
|
|
||
| public enum CertificateError: Error { | ||
| case encryptionFailed | ||
| case decryptionFailed | ||
| case fieldNotFound | ||
| case unsupportedFormat | ||
| } | ||
|
|
||
| extension CertificateSecret: SecretTemplate { | ||
| public static var templateName: String { "Certificate" } | ||
| public static var templateDescription: String { "SSL/TLS and other digital certificates" } | ||
| public static var requiredFields: [FieldDefinition] { | ||
| [ | ||
| FieldDefinition(name: "title", displayName: "Name", type: .text, isSecure: false, placeholder: "Server Cert", validationPattern: nil), | ||
| FieldDefinition(name: "certificateName", displayName: "Certificate Common Name", type: .text, isSecure: false, placeholder: "example.com", validationPattern: nil) | ||
| ] | ||
| } | ||
| public static var optionalFields: [FieldDefinition] { | ||
| [ | ||
| FieldDefinition(name: "issuer", displayName: "Issuer", type: .text, isSecure: false, placeholder: "Let's Encrypt", validationPattern: nil) | ||
| ] | ||
| } | ||
| public static func create(from fields: [String: Any]) throws -> CertificateSecret { | ||
| guard let title = fields["title"] as? String, | ||
| let certName = fields["certificateName"] as? String else { | ||
| throw CertificateError.encryptionFailed | ||
| } | ||
| return CertificateSecret(title: title, certificateName: certName, issuer: (fields["issuer"] as? String) ?? "Unknown") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| // | ||
| // PasswordModels.swift | ||
| // SilentKey | ||
| // | ||
| // Models for passwords and login credentials | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| public struct PasswordSecret: SecretItemProtocol, EncryptableSecret, ExportableSecret { | ||
| public let id: UUID | ||
| public var title: String | ||
| public var notes: String? | ||
| public var tags: Set<String> | ||
| public let createdAt: Date | ||
| public var modifiedAt: Date | ||
| public var isFavorite: Bool | ||
|
|
||
| public var username: String | ||
| public var url: String? | ||
| public var encryptedFields: [String: Data] | ||
|
|
||
| public var category: SecretCategory { | ||
| .password | ||
| } | ||
|
|
||
| public var iconName: String { | ||
| category.icon | ||
| } | ||
|
|
||
| public init( | ||
| id: UUID = UUID(), | ||
| title: String, | ||
| username: String, | ||
| url: String? = nil, | ||
| notes: String? = nil, | ||
| tags: Set<String> = [], | ||
| isFavorite: Bool = false | ||
| ) { | ||
| self.id = id | ||
| self.title = title | ||
| self.username = username | ||
| self.url = url | ||
| self.notes = notes | ||
| self.tags = tags | ||
| self.createdAt = Date() | ||
| self.modifiedAt = Date() | ||
| self.isFavorite = isFavorite | ||
| self.encryptedFields = [:] | ||
| } | ||
|
|
||
| public func encryptedData() throws -> Data { | ||
| try JSONEncoder().encode(self) | ||
| } | ||
|
|
||
| public func validate() throws { | ||
| guard !title.isEmpty else { throw ValidationError.emptyTitle } | ||
| guard !username.isEmpty else { throw ValidationError.emptyUsername } | ||
| } | ||
|
|
||
| public func searchableText() -> String { | ||
| [title, username, url ?? "", notes ?? ""].joined(separator: " ") | ||
| } | ||
|
|
||
| public mutating func encrypt(field: String, value: String, using key: Data) throws { | ||
| guard let data = value.data(using: .utf8) else { throw PasswordError.encryptionFailed } | ||
| encryptedFields[field] = data | ||
| modifiedAt = Date() | ||
| } | ||
|
|
||
| public func decrypt(field: String, using key: Data) throws -> String { | ||
| guard let data = encryptedFields[field] else { throw PasswordError.fieldNotFound } | ||
| guard let value = String(data: data, encoding: .utf8) else { throw PasswordError.decryptionFailed } | ||
| return value | ||
| } | ||
|
|
||
| public var supportedExportFormats: [ExportFormat] { | ||
| [.json, .encrypted, .csv] | ||
| } | ||
|
|
||
| public func export(format: ExportFormat) throws -> Data { | ||
| switch format { | ||
| case .json: return try JSONEncoder().encode(self) | ||
| case .encrypted: return try encryptedData() | ||
| default: throw PasswordError.unsupportedFormat | ||
| } | ||
| } | ||
|
|
||
| public enum ValidationError: Error { | ||
| case emptyTitle | ||
| case emptyUsername | ||
| } | ||
| } | ||
|
|
||
| public enum PasswordError: Error { | ||
| case encryptionFailed | ||
| case decryptionFailed | ||
| case fieldNotFound | ||
| case unsupportedFormat | ||
| } | ||
|
|
||
| extension PasswordSecret: SecretTemplate { | ||
| public static var templateName: String { "Password" } | ||
| public static var templateDescription: String { "Standard login credentials" } | ||
| public static var requiredFields: [FieldDefinition] { | ||
| [ | ||
| FieldDefinition(name: "title", displayName: "Name", type: .text, isSecure: false, placeholder: "My Account", validationPattern: nil), | ||
| FieldDefinition(name: "username", displayName: "Username/Email", type: .text, isSecure: false, placeholder: "user@example.com", validationPattern: nil), | ||
| FieldDefinition(name: "password", displayName: "Password", type: .password, isSecure: true, placeholder: "Password", validationPattern: nil) | ||
| ] | ||
| } | ||
| public static var optionalFields: [FieldDefinition] { | ||
| [ | ||
| FieldDefinition(name: "url", displayName: "Website URL", type: .url, isSecure: false, placeholder: "https://example.com", validationPattern: nil) | ||
| ] | ||
| } | ||
| public static func create(from fields: [String: Any]) throws -> PasswordSecret { | ||
| guard let title = fields["title"] as? String, | ||
| let username = fields["username"] as? String else { | ||
| throw PasswordError.encryptionFailed | ||
| } | ||
| return PasswordSecret(title: title, username: username, url: fields["url"] as? String) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deriveKey method signature changed from returning an optional SymmetricKey? to throwing and returning non-optional SymmetricKey. This is a breaking API change that will cause compilation errors in any code calling this method. All call sites need to be updated to handle the throwing behavior.