fix: prevented from exporting telemetry_id, access and refresh token

This commit is contained in:
Serhiy Mytrovtsiy
2025-05-23 23:13:55 +02:00
parent 78710c1ecd
commit 48836fcd34

View File

@@ -73,13 +73,26 @@ public class Store {
public func export(to url: URL) {
guard let id = Bundle.main.bundleIdentifier,
let dicitionary = self.defaults.persistentDomain(forName: id) else { return }
NSDictionary(dictionary: dicitionary).write(to: url, atomically: true)
var dictionary = self.defaults.persistentDomain(forName: id) else { return }
dictionary.removeValue(forKey: "telemetry_id")
dictionary.removeValue(forKey: "access_token")
dictionary.removeValue(forKey: "refresh_token")
NSDictionary(dictionary: dictionary).write(to: url, atomically: true)
}
public func `import`(from url: URL) {
guard let id = Bundle.main.bundleIdentifier, let dict = NSDictionary(contentsOf: url) as? [String: Any] else { return }
self.defaults.setPersistentDomain(dict, forName: id)
var importedDict = dict
let keysToPreserve = ["telemetry_id", "access_token", "refresh_token"]
for key in keysToPreserve {
if let existingValue = self.defaults.string(forKey: key) {
importedDict[key] = existingValue
}
}
self.defaults.setPersistentDomain(importedDict, forName: id)
restartApp(self)
}
}