Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
f4a4f1a527
commit
a8f49c1cf1
@ -1,28 +0,0 @@
|
||||
import Foundation
|
||||
import LocalData
|
||||
|
||||
/// File system key that demonstrates custom serializer usage.
|
||||
extension StorageKey where Value == String {
|
||||
/// Example using custom serializer for specialized encoding.
|
||||
nonisolated static let customEncoded = StorageKey(
|
||||
name: "custom_encoded",
|
||||
domain: .fileSystem(directory: .documents),
|
||||
security: .none,
|
||||
serializer: .custom(
|
||||
encode: { value in
|
||||
Data(value.utf8).base64EncodedData()
|
||||
},
|
||||
decode: { data in
|
||||
guard let decoded = Data(base64Encoded: data),
|
||||
let string = String(data: decoded, encoding: .utf8) else {
|
||||
throw StorageError.deserializationFailed
|
||||
}
|
||||
return string
|
||||
}
|
||||
),
|
||||
owner: "SampleApp",
|
||||
description: "Stores custom-encoded string data (Base64 example).",
|
||||
availability: .all,
|
||||
syncPolicy: .never
|
||||
)
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import LocalData
|
||||
import SharedKit
|
||||
|
||||
/// Keys that demonstrate conditional migrations based on app version.
|
||||
extension StorageKey where Value == String {
|
||||
@ -16,7 +17,7 @@ extension StorageKey where Value == String {
|
||||
|
||||
nonisolated static let modernAppMode = StorageKey(
|
||||
name: "modern_app_mode",
|
||||
domain: .keychain(service: "com.mbrucedogs.securestorage"),
|
||||
domain: .keychain(service: StorageServiceIdentifiers.keychainLocation),
|
||||
security: .keychain(
|
||||
accessibility: .afterFirstUnlock,
|
||||
accessControl: .userPresence
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import LocalData
|
||||
import SharedKit
|
||||
|
||||
/// Keys that demonstrate a simple legacy-to-modern migration path.
|
||||
extension StorageKey where Value == String {
|
||||
@ -18,7 +19,7 @@ extension StorageKey where Value == String {
|
||||
/// The modern key where data should end up (in Keychain).
|
||||
nonisolated static let modernMigrationDestination = StorageKey(
|
||||
name: "secure_user_id",
|
||||
domain: .keychain(service: "com.mbrucedogs.securestorage"),
|
||||
domain: .keychain(service: StorageServiceIdentifiers.keychainLocation),
|
||||
security: .keychain(
|
||||
accessibility: .afterFirstUnlock,
|
||||
accessControl: .userPresence
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import LocalData
|
||||
import SharedKit
|
||||
|
||||
/// Legacy string payload that will be transformed into a structured model.
|
||||
extension StorageKey where Value == String {
|
||||
@ -19,7 +20,7 @@ extension StorageKey where Value == String {
|
||||
extension StorageKey where Value == ProfileName {
|
||||
nonisolated static let modernProfileName = StorageKey(
|
||||
name: "modern_profile_name",
|
||||
domain: .keychain(service: "com.mbrucedogs.securestorage"),
|
||||
domain: .keychain(service: StorageServiceIdentifiers.keychainLocation),
|
||||
security: .keychain(
|
||||
accessibility: .afterFirstUnlock,
|
||||
accessControl: .userPresence
|
||||
|
||||
Loading…
Reference in New Issue
Block a user