mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-05 09:24:49 +01:00
Move types to common (#81)
This commit is contained in:
21
SecretKit/Common/Types/Secret.swift
Normal file
21
SecretKit/Common/Types/Secret.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
public protocol Secret: Identifiable, Hashable {
|
||||
|
||||
var name: String { get }
|
||||
var algorithm: Algorithm { get }
|
||||
var keySize: Int { get }
|
||||
var publicKey: Data { get }
|
||||
|
||||
}
|
||||
|
||||
public enum Algorithm: Hashable {
|
||||
case ellipticCurve
|
||||
public init(secAttr: NSNumber) {
|
||||
let secAttrString = secAttr.stringValue as CFString
|
||||
switch secAttrString {
|
||||
case kSecAttrKeyTypeEC:
|
||||
self = .ellipticCurve
|
||||
default:
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
}
|
||||
27
SecretKit/Common/Types/SecretStore.swift
Normal file
27
SecretKit/Common/Types/SecretStore.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
import Combine
|
||||
|
||||
public protocol SecretStore: ObservableObject, Identifiable {
|
||||
|
||||
associatedtype SecretType: Secret
|
||||
|
||||
var isAvailable: Bool { get }
|
||||
var id: UUID { get }
|
||||
var name: String { get }
|
||||
var secrets: [SecretType] { get }
|
||||
|
||||
func sign(data: Data, with secret: SecretType) throws -> Data
|
||||
|
||||
}
|
||||
|
||||
public protocol SecretStoreModifiable: SecretStore {
|
||||
|
||||
func create(name: String, requiresAuthentication: Bool) throws
|
||||
func delete(secret: SecretType) throws
|
||||
|
||||
}
|
||||
|
||||
extension NSNotification.Name {
|
||||
|
||||
static let secretStoreUpdated = NSNotification.Name("com.maxgoedjen.Secretive.secretStore.updated")
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user