- 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.
50 lines
1.9 KiB
Swift
50 lines
1.9 KiB
Swift
import Foundation
|
|
|
|
public enum CredentialMatcher {
|
|
public static func matches(entry: Entry, serviceIdentifier: String) -> Bool {
|
|
guard !entry.url.isEmpty else { return false }
|
|
guard let entryHost = host(from: entry.url),
|
|
let serviceHost = host(from: serviceIdentifier)
|
|
else {
|
|
return entry.url.lowercased().contains(serviceIdentifier.lowercased())
|
|
}
|
|
return hostsMatch(entryHost, serviceHost)
|
|
}
|
|
|
|
public static func filter(
|
|
entries: [Entry],
|
|
for serviceIdentifiers: [String]
|
|
) -> (suggested: [Entry], all: [Entry]) {
|
|
guard !serviceIdentifiers.isEmpty else { return ([], entries) }
|
|
let suggested = entries.filter { entry in
|
|
serviceIdentifiers.contains { matches(entry: entry, serviceIdentifier: $0) }
|
|
}
|
|
let suggestedIDs = Set(suggested.map(\.id))
|
|
let rest = entries.filter { !suggestedIDs.contains($0.id) }
|
|
return (suggested: suggested, all: rest)
|
|
}
|
|
|
|
private static func host(from urlString: String) -> String? {
|
|
// KDBX entries and AutoFill service identifiers commonly omit the scheme
|
|
// (e.g. "allocine.fr"), but URL(string:) only populates `.host` when an
|
|
// authority component ("//") is present -- without it, the whole string
|
|
// is parsed as a relative path and `.host` is nil.
|
|
if let host = URL(string: urlString)?.host, !host.isEmpty {
|
|
return host
|
|
}
|
|
return URL(string: "https://" + urlString)?.host
|
|
}
|
|
|
|
private static func hostsMatch(_ a: String, _ b: String) -> Bool {
|
|
let na = stripped(a)
|
|
let nb = stripped(b)
|
|
return na == nb
|
|
|| na.hasSuffix("." + nb)
|
|
|| nb.hasSuffix("." + na)
|
|
}
|
|
|
|
private static func stripped(_ host: String) -> String {
|
|
host.hasPrefix("www.") ? String(host.dropFirst(4)).lowercased() : host.lowercased()
|
|
}
|
|
}
|