mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-05 17:27:24 +01:00
Split out libraries into SPM packages (#298)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
class PreviewAgentStatusChecker: AgentStatusCheckerProtocol {
|
||||
|
||||
let running: Bool
|
||||
let developmentBuild = false
|
||||
|
||||
init(running: Bool = true) {
|
||||
self.running = running
|
||||
}
|
||||
|
||||
}
|
||||
74
Sources/Secretive/Preview Content/PreviewStore.swift
Normal file
74
Sources/Secretive/Preview Content/PreviewStore.swift
Normal file
@@ -0,0 +1,74 @@
|
||||
import Foundation
|
||||
import SecretKit
|
||||
|
||||
enum Preview {}
|
||||
|
||||
extension Preview {
|
||||
|
||||
struct Secret: SecretKit.Secret {
|
||||
|
||||
let id = UUID().uuidString
|
||||
let name: String
|
||||
let algorithm = Algorithm.ellipticCurve
|
||||
let keySize = 256
|
||||
let publicKey = UUID().uuidString.data(using: .utf8)!
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Preview {
|
||||
|
||||
class Store: SecretStore, ObservableObject {
|
||||
|
||||
let isAvailable = true
|
||||
let id = UUID()
|
||||
var name: String { "Preview Store" }
|
||||
@Published var secrets: [Secret] = []
|
||||
|
||||
init(secrets: [Secret]) {
|
||||
self.secrets.append(contentsOf: secrets)
|
||||
}
|
||||
|
||||
init(numberOfRandomSecrets: Int = 5) {
|
||||
let new = (0..<numberOfRandomSecrets).map { Secret(name: String(describing: $0)) }
|
||||
self.secrets.append(contentsOf: new)
|
||||
}
|
||||
|
||||
func sign(data: Data, with secret: Preview.Secret, for provenance: SigningRequestProvenance) throws -> SignedData {
|
||||
return SignedData(data: data, requiredAuthentication: false)
|
||||
}
|
||||
|
||||
func persistAuthentication(secret: Preview.Secret, forDuration duration: TimeInterval) throws {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class StoreModifiable: Store, SecretStoreModifiable {
|
||||
override var name: String { "Modifiable Preview Store" }
|
||||
|
||||
func create(name: String, requiresAuthentication: Bool) throws {
|
||||
}
|
||||
|
||||
func delete(secret: Preview.Secret) throws {
|
||||
}
|
||||
|
||||
func update(secret: Preview.Secret, name: String) throws {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Preview {
|
||||
|
||||
static func storeList(stores: [Store] = [], modifiableStores: [StoreModifiable] = []) -> SecretStoreList {
|
||||
let list = SecretStoreList()
|
||||
for store in stores {
|
||||
list.add(store: store)
|
||||
}
|
||||
for storeModifiable in modifiableStores {
|
||||
list.add(store: storeModifiable)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
}
|
||||
29
Sources/Secretive/Preview Content/PreviewUpdater.swift
Normal file
29
Sources/Secretive/Preview Content/PreviewUpdater.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import Brief
|
||||
|
||||
class PreviewUpdater: UpdaterProtocol {
|
||||
|
||||
let update: Release?
|
||||
let testBuild = false
|
||||
|
||||
init(update: Update = .none) {
|
||||
switch update {
|
||||
case .none:
|
||||
self.update = nil
|
||||
case .advisory:
|
||||
self.update = Release(name: "10.10.10", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Some regular update")
|
||||
case .critical:
|
||||
self.update = Release(name: "10.10.10", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension PreviewUpdater {
|
||||
|
||||
enum Update {
|
||||
case none, advisory, critical
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user