Fix Swift 6 actor-isolation warnings in model inits and services
- Message, Conversation, EmailLog: add nonisolated to inits — plain value types have no actor isolation, but the macOS 27 SDK was inferring it - EncryptionService: replace lazy var encryptionKey (which mutates self and gets inferred as @MainActor) with an eagerly-initialized let in init() - FileLogger: add nonisolated to shared, write, and minimumLevel so they are callable from nonisolated AppLogger methods without warnings - LogLevel.<: add nonisolated to the Comparable conformance method Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,12 +31,11 @@ import IOKit
|
||||
class EncryptionService {
|
||||
nonisolated static let shared = EncryptionService()
|
||||
|
||||
private let salt = "oAI-secure-storage-v1" // App-specific salt
|
||||
private lazy var encryptionKey: SymmetricKey = {
|
||||
deriveEncryptionKey()
|
||||
}()
|
||||
private let encryptionKey: SymmetricKey
|
||||
|
||||
private init() {}
|
||||
private init() {
|
||||
self.encryptionKey = Self.deriveEncryptionKey()
|
||||
}
|
||||
|
||||
// MARK: - Public Interface
|
||||
|
||||
@@ -73,19 +72,17 @@ class EncryptionService {
|
||||
// MARK: - Key Derivation
|
||||
|
||||
/// Derive encryption key from machine-specific data
|
||||
private func deriveEncryptionKey() -> SymmetricKey {
|
||||
// Combine machine UUID + bundle ID + salt for key material
|
||||
private static func deriveEncryptionKey() -> SymmetricKey {
|
||||
let machineUUID = getMachineUUID()
|
||||
let bundleID = Bundle.main.bundleIdentifier ?? "com.oai.oAI"
|
||||
let salt = "oAI-secure-storage-v1"
|
||||
let keyMaterial = "\(machineUUID)-\(bundleID)-\(salt)"
|
||||
|
||||
// Hash to create consistent 256-bit key
|
||||
let hash = SHA256.hash(data: Data(keyMaterial.utf8))
|
||||
return SymmetricKey(data: hash)
|
||||
}
|
||||
|
||||
/// Get machine-specific UUID (IOPlatformUUID)
|
||||
private func getMachineUUID() -> String {
|
||||
private static func getMachineUUID() -> String {
|
||||
// Get IOPlatformUUID from IOKit
|
||||
let platformExpert = IOServiceGetMatchingService(
|
||||
kIOMainPortDefault,
|
||||
|
||||
Reference in New Issue
Block a user