Abstracted bundle prefix

This commit is contained in:
Maxwell Swadling
2023-03-12 15:01:45 +10:00
parent 12a8f1698b
commit 1bd724c8bf
15 changed files with 100 additions and 33 deletions

View File

@@ -11,6 +11,8 @@ public class Updater: ObservableObject, UpdaterProtocol {
private let osVersion: SemVer
/// The current version of the app that is running.
private let currentVersion: SemVer
/// The current bundle prefix.
private let bundlePreifx: String
/// Initializes an Updater.
/// - Parameters:
@@ -18,9 +20,10 @@ public class Updater: ObservableObject, UpdaterProtocol {
/// - checkFrequency: The interval at which the Updater should check for updates. Subject to a tolerance of 1 hour.
/// - osVersion: The current OS version.
/// - currentVersion: The current version of the app that is running.
public init(checkOnLaunch: Bool, checkFrequency: TimeInterval = Measurement(value: 24, unit: UnitDuration.hours).converted(to: .seconds).value, osVersion: SemVer = SemVer(ProcessInfo.processInfo.operatingSystemVersion), currentVersion: SemVer = SemVer(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.0")) {
public init(checkOnLaunch: Bool, bundlePrefix: String, checkFrequency: TimeInterval = Measurement(value: 24, unit: UnitDuration.hours).converted(to: .seconds).value, osVersion: SemVer = SemVer(ProcessInfo.processInfo.operatingSystemVersion), currentVersion: SemVer = SemVer(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.0")) {
self.osVersion = osVersion
self.currentVersion = currentVersion
self.bundlePreifx = bundlePrefix
testBuild = currentVersion == SemVer("0.0.0")
if checkOnLaunch {
// Don't do a launch check if the user hasn't seen the setup prompt explaining updater yet.
@@ -83,7 +86,7 @@ extension Updater {
/// The user defaults used to store user ignore state.
var defaults: UserDefaults {
UserDefaults(suiteName: "com.maxgoedjen.Secretive.updater.ignorelist")!
UserDefaults(suiteName: "\(bundlePreifx).updater.ignorelist")!
}
}

View File

@@ -12,13 +12,14 @@ public class Agent {
private let writer = OpenSSHKeyWriter()
private let requestTracer = SigningRequestTracer()
private let certificateHandler = OpenSSHCertificateHandler()
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent.agent", category: "")
private let logger: Logger
/// Initializes an agent with a store list and a witness.
/// - Parameters:
/// - storeList: The `SecretStoreList` to make available.
/// - witness: A witness to notify of requests.
public init(storeList: SecretStoreList, witness: SigningWitness? = nil) {
public init(storeList: SecretStoreList, bundlePrefix: String, witness: SigningWitness? = nil) {
logger = Logger(subsystem: "\(bundlePrefix).secretagent.agent", category: "")
logger.debug("Agent is running")
self.storeList = storeList
self.witness = witness

View File

@@ -196,6 +196,9 @@ extension SmartCard.Store {
let publicKeyAttributes = SecKeyCopyAttributes(publicKeySecRef) as! [CFString: Any]
let publicKey = publicKeyAttributes[kSecValueData] as! Data
return SmartCard.Secret(id: tokenID, name: name, algorithm: algorithm, keySize: keySize, publicKey: publicKey)
}.filter { key in
// We should exclude keys you can't use for signing to not confuse users.
return includeEncryptionKeys || key.name.hasPrefix("Key For Digital Signature")
}
secrets.append(contentsOf: wrapped)
}