feat: copper accent theme, always-expanded group filter, app icon; rename MyPass to KeeVault
- Custom copper AccentColor and warm VaultBackground color assets (light/dark), applied to both the main app and the AutoFill extension (which needed its own copy of the asset catalog plus ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME and an explicit .tint() modifier, since extensions don't pick up the app-wide accent color the same way a full SwiftUI App/Scene does). - GroupFilterView no longer uses DisclosureGroup for subgroups -- the whole tree renders always-expanded (indented per depth) so active filters are visible at a glance instead of requiring tap-to-expand. - Added a placeholder app icon (padlock glyph, light/dark/tinted variants plus macOS sizes) -- previously the icon slot existed but had no actual images, which blocks App Store/TestFlight archive validation. - Added ITSAppUsesNonExemptEncryption = NO (standard encryption only, via KeePassKit) to skip the export-compliance prompt on each upload. - Renamed the app from MyPass to KeeVault throughout: Xcode project/targets/ schemes, the MyPassCore package (now KeeVaultCore) and every import site, folder and file names, bundle identifiers (org.antiloop222.keevault) and their App Group/Keychain-group entitlements, and remaining UI/string references -- MyPass was already taken as an App Store app name.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// FileBookmarkService.swift
|
||||
// KeeVault
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Persists a security-scoped bookmark for the user's KDBX file in the shared App Group.
|
||||
public final class FileBookmarkService {
|
||||
private static let key = "kdbxBookmark"
|
||||
private let defaults: UserDefaults
|
||||
|
||||
public init(appGroup: String = "group.org.antiloop222.keevault") {
|
||||
defaults = UserDefaults(suiteName: appGroup) ?? .standard
|
||||
}
|
||||
|
||||
// `.withSecurityScope` is a macOS-only bookmark-creation option; iOS grants scoped
|
||||
// access automatically once the user picks a file, without that flag.
|
||||
private static var creationOptions: URL.BookmarkCreationOptions {
|
||||
#if os(macOS)
|
||||
return .withSecurityScope
|
||||
#else
|
||||
return []
|
||||
#endif
|
||||
}
|
||||
|
||||
private static var resolutionOptions: URL.BookmarkResolutionOptions {
|
||||
#if os(macOS)
|
||||
return .withSecurityScope
|
||||
#else
|
||||
return []
|
||||
#endif
|
||||
}
|
||||
|
||||
public func save(url: URL) throws {
|
||||
// For File Provider-backed URLs (e.g. iCloud Drive), creating a bookmark without
|
||||
// an active security scope produces one that resolves later with
|
||||
// NSCocoaErrorDomain Code=4 ("The file doesn't exist"), even immediately after picking.
|
||||
let accessing = url.startAccessingSecurityScopedResource()
|
||||
defer { if accessing { url.stopAccessingSecurityScopedResource() } }
|
||||
let data = try url.bookmarkData(
|
||||
options: Self.creationOptions,
|
||||
includingResourceValuesForKeys: nil,
|
||||
relativeTo: nil
|
||||
)
|
||||
defaults.set(data, forKey: Self.key)
|
||||
}
|
||||
|
||||
/// Returns the resolved URL, starting security access. Caller must call `stopAccess(url:)` when done.
|
||||
public func resolveURL() throws -> URL {
|
||||
guard let data = defaults.data(forKey: Self.key) else { throw BookmarkError.notFound }
|
||||
var isStale = false
|
||||
let url = try URL(
|
||||
resolvingBookmarkData: data,
|
||||
options: Self.resolutionOptions,
|
||||
relativeTo: nil,
|
||||
bookmarkDataIsStale: &isStale
|
||||
)
|
||||
if isStale {
|
||||
let fresh = try url.bookmarkData(options: Self.creationOptions, includingResourceValuesForKeys: nil, relativeTo: nil)
|
||||
defaults.set(fresh, forKey: Self.key)
|
||||
}
|
||||
guard url.startAccessingSecurityScopedResource() else { throw BookmarkError.accessDenied }
|
||||
return url
|
||||
}
|
||||
|
||||
public func stopAccess(url: URL) {
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
}
|
||||
|
||||
public func clear() {
|
||||
defaults.removeObject(forKey: Self.key)
|
||||
}
|
||||
|
||||
public var hasBookmark: Bool {
|
||||
defaults.data(forKey: Self.key) != nil
|
||||
}
|
||||
}
|
||||
|
||||
public enum BookmarkError: Error {
|
||||
case notFound
|
||||
case accessDenied
|
||||
}
|
||||
Reference in New Issue
Block a user