Skip to content

Commit

Permalink
Merge pull request #29 from GoodRequest/feature/privacy-manifest
Browse files Browse the repository at this point in the history
feat: GoodPersistance update & added PrivacyInfo.xcprivacy
  • Loading branch information
Xaferis authored Mar 19, 2024
2 parents 6adb13a + 61cdac2 commit 52d7562
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,26 @@
"repositoryURL": "https://github.com/GoodRequest/GoodNetworking.git",
"state": {
"branch": null,
"revision": "cc11824e56c4da0fd7b4002be2c7a75459a9d051",
"version": "2.4.0"
"revision": "47b616af6b839166cdac357d02cbce6b65c959c0",
"version": "2.5.0"
}
},
{
"package": "GoodPersistence",
"repositoryURL": "https://github.com/GoodRequest/GoodPersistence.git",
"state": {
"branch": null,
"revision": "bf82128545d0a78603c764c6c164303e3f61f7fc",
"version": "1.1.0"
"revision": "841f777b44a6061e3a6f4e01ffb1e36af2dfe13f",
"version": "2.1.0"
}
},
{
"package": "KeychainAccess",
"repositoryURL": "https://github.com/kishikawakatsumi/KeychainAccess.git",
"state": {
"branch": null,
"revision": "84e546727d66f1adc5439debad16270d0fdd04e7",
"version": "4.2.2"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class CacheManager: CacheManagerType {
@UserDefaultValue("fullName", defaultValue: nil)
var fullName: String?

@UserDefaultValue("gender", defaultValue: 0)
@KeychainValue("gender", defaultValue: 0)
var gender: Int

@UserDefaultValue("favoriteColor", defaultValue: "Red")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ final class RequestManager: RequestManagerType {
init(baseServer: ApiServer) {
LoggingEventMonitor.maxVerboseLogSizeBytes = 1000000
let monitor = LoggingEventMonitor(logger: nil)
#if DEBUG
StandardOutputService.shared.connectCustomLogStreamPublisher(monitor.subscribeToMessages())
#endif
session = NetworkSession(baseUrl: baseServer.rawValue, configuration: .init(urlSessionConfiguration: .default, interceptor: nil, serverTrustManager: nil, eventMonitors: [monitor]))
}

Expand Down
22 changes: 20 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/GoodRequest/GoodPersistence.git",
"state" : {
"revision" : "780e03a1e21948b114d7af3bc0cfe0d8aecae4c0",
"version" : "1.0.2"
"revision" : "841f777b44a6061e3a6f4e01ffb1e36af2dfe13f",
"version" : "2.1.0"
}
},
{
"identity" : "keychainaccess",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kishikawakatsumi/KeychainAccess.git",
"state" : {
"revision" : "84e546727d66f1adc5439debad16270d0fdd04e7",
"version" : "4.2.2"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/swiftui-introspect",
"state" : {
"revision" : "0cd2a5a5895306bc21d54a2254302d24a9a571e4",
"version" : "1.1.3"
}
}
],
Expand Down
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
targets: ["AppDebugMode"]),
],
dependencies: [
.package(url: "https://github.com/GoodRequest/GoodPersistence.git", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/GoodRequest/GoodPersistence.git", .upToNextMajor(from: "2.1.0")),
.package(url: "https://github.com/siteline/swiftui-introspect", from: "1.0.0"),
],
targets: [
Expand All @@ -25,7 +25,8 @@ let package = Package(
.product(name: "GoodPersistence", package: "GoodPersistence"),
.product(name: "SwiftUIIntrospect", package: "swiftui-introspect"),
],
path: "Sources/AppDebugMode"
path: "Sources",
resources: [.copy("PrivacyInfo.xcprivacy")]
),
.testTarget(
name: "AppDebugModeTests",
Expand Down
15 changes: 4 additions & 11 deletions Sources/AppDebugMode/Providers/CacheProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import GoodPersistence
import KeychainAccess

final class CacheProvider {

Expand Down Expand Up @@ -128,30 +129,22 @@ private extension CacheProvider {
keychainValues[key] = receiveKeychainValueFromPropertyList(
key: key,
valueType: decodable.self,
defaultValue: defaultValueChild.value,
accessibility: childMirror.children.first(where: { $0.label == "accessibility" })?.value as? KeychainItemAccessibility
defaultValue: defaultValueChild.value
)
}
}

func receiveKeychainValueFromPropertyList<T: Codable>(
key: String,
valueType: T.Type,
defaultValue: Any,
accessibility: KeychainItemAccessibility?
defaultValue: Any
) -> String {
guard let data = KeychainWrapper.standard.data(
forKey: key,
withAccessibility: accessibility
) else {
guard let value = try? Keychain.default.get(key) else {
let defaultValueCodable = defaultValue as! Codable
// Return default value if data cannot be retrieved from Keychain
return formatValue(value: defaultValueCodable)
}

// Decode the data and get the value, or return default value if decoding fails
let value = (try? PropertyListDecoder().decode(Wrapper<T>.self, from: data))?.value

return formatValue(value: value)
}

Expand Down
31 changes: 31 additions & 0 deletions Sources/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
</dict>
</plist>

0 comments on commit 52d7562

Please sign in to comment.