1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-11 02:29:19 +00:00

feat: Add VS Code launch/task configurations and refactor app icon and resource management.

This commit is contained in:
Tw93
2025-12-15 14:00:27 +08:00
parent 46cebd7dbb
commit 4547f5819e
28 changed files with 111 additions and 35 deletions

37
app/KeychainHelper.swift Normal file
View File

@@ -0,0 +1,37 @@
import Foundation
// Note: Switched to File-based storage to avoid repetitive System Keychain prompts
// during development (Unsigned Binary). Files are set to 600 layout (User Only).
class KeychainHelper {
static let shared = KeychainHelper()
private var storeURL: URL {
let home = FileManager.default.homeDirectoryForCurrentUser
return home.appendingPathComponent(".mole").appendingPathComponent(".key")
}
func save(_ data: String) {
let url = storeURL
do {
try FileManager.default.createDirectory(
at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
try data.write(to: url, atomically: true, encoding: .utf8)
// Set permissions to User Read/Write Only (600) for security
try FileManager.default.setAttributes([.posixPermissions: 0o600], ofItemAtPath: url.path)
} catch {
print("Failed to save credentials: \(error)")
}
}
func load() -> String? {
do {
return try String(contentsOf: storeURL, encoding: .utf8)
} catch {
return nil
}
}
func delete() {
try? FileManager.default.removeItem(at: storeURL)
}
}