Modern Apps git

← xtool.git

KeyValueStorage tweaks

Commit
23e7b770802b6665107780c6fb2f103518552a02
Author
Kabir Oberai <[email protected]>
When
2024-12-30 19:21 UTC (1 year ago)
Parents
4e77c5b

Diff

Sources/Supersign/Utilities/KeyValueStorage.swift
diff --git a/Sources/Supersign/Utilities/KeyValueStorage.swift b/Sources/Supersign/Utilities/KeyValueStorage.swiftindex 6d20fa5..b268088 100644--- a/Sources/Supersign/Utilities/KeyValueStorage.swift+++ b/Sources/Supersign/Utilities/KeyValueStorage.swift@@ -22,8 +22,8 @@ public protocol KeyValueStorage: Sendable {     func setString(_ string: String?, forKey key: String) throws } -public enum KeyValueStorageDependencyKey: TestDependencyKey {-    public static let testValue: KeyValueStorage = UnimplementedKeyValueStorage()+public enum KeyValueStorageDependencyKey: DependencyKey {+    public static let liveValue: KeyValueStorage = DirectoryStorage() }  extension DependencyValues {@@ -56,16 +56,6 @@ extension KeyValueStorage {     } } -private struct UnimplementedKeyValueStorage: KeyValueStorage {-    func data(forKey key: String) throws -> Data? {-        unimplemented(placeholder: nil)-    }-    -    func setData(_ data: Data?, forKey key: String) throws {-        unimplemented()-    }-}- public final class MemoryKeyValueStorage: KeyValueStorage {      private let dict = LockIsolated<[String: Data]>([:])
Sources/SupersignCLI/SupersignCLI.swift
diff --git a/Sources/SupersignCLI/SupersignCLI.swift b/Sources/SupersignCLI/SupersignCLI.swiftindex 3475bf0..df3234f 100644--- a/Sources/SupersignCLI/SupersignCLI.swift+++ b/Sources/SupersignCLI/SupersignCLI.swift@@ -5,22 +5,16 @@ import Dependencies  @main enum SupersignCLIMain {     static func main() async throws {+        prepareDependencies { dependencies in+            #warning("Improve persistence mechanism")+            // for macOS, we can use KeychainStorage but we need to sign with entitlements.+            // for Windows, we could use dpapi.h or wincred.h.+            // for Linux, maybe use libsecret?+            // see https://github.com/atom/node-keytar+//            #if os(macOS)+//            dependencies.keyValueStorage = KeychainStorage(service: "com.kabiroberai.Supercharge-Keychain.credentials")+//            #endif+        }         try await SupersignCLI.run()     } }--#warning("Improve persistence mechanism")--// for macOS, we can use KeychainStorage but we need to sign with entitlements.-// for Windows, we could use dpapi.h or wincred.h.-// for Linux, maybe use libsecret?-// see https://github.com/atom/node-keytar-extension KeyValueStorageDependencyKey: DependencyKey {-    public static let liveValue: KeyValueStorage = {-//        #if os(macOS)-//        KeychainStorage(service: "com.kabiroberai.Supercharge-Keychain.credentials")-//        #else-        DirectoryStorage()-//        #endif-    }()-}