mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-19 12:56:06 +00:00
34 lines
854 B
Swift
34 lines
854 B
Swift
//
|
|
// TrustStore.swift
|
|
// QuickDrop
|
|
//
|
|
// Created by Leon Böttger on 22.08.25.
|
|
//
|
|
|
|
|
|
import Foundation
|
|
|
|
class TrustStore {
|
|
|
|
static let shared = TrustStore()
|
|
private let trustedKeysKey = "com.leonboettger.quickdrop.identity.trustedKeys"
|
|
|
|
|
|
private func getTrustedKeys() -> [String: Data] {
|
|
return AppGroup.appGroupUD.dictionary(forKey: trustedKeysKey) as? [String: Data] ?? [:]
|
|
}
|
|
|
|
|
|
func findTrustedKey(for secretIdHash: Data) -> Data? {
|
|
return getTrustedKeys()[secretIdHash.hex]
|
|
}
|
|
|
|
|
|
func addTrusted(certificate: Sharing_Nearby_PublicCertificate) {
|
|
guard let publicKeyData = try? certificate.serializedData() else { return }
|
|
var keys = getTrustedKeys()
|
|
keys[certificate.secretID.hex] = publicKeyData
|
|
AppGroup.appGroupUD.set(keys, forKey: trustedKeysKey)
|
|
}
|
|
}
|