Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
dd61bedf14
commit
8368900f49
28
README.md
28
README.md
@ -34,7 +34,14 @@ These helpers are internal implementation details used by `StorageRouter`. They
|
||||
- **UserDefaultsHelper** - Wraps UserDefaults and suites safely.
|
||||
- **SyncHelper** - Manages WatchConnectivity sync.
|
||||
|
||||
### Models
|
||||
### Global Configuration Models
|
||||
These are used at app lifecycle start to tune library engine behaviors:
|
||||
- **StorageConfiguration** - Default Keychain service and App Group IDs
|
||||
- **EncryptionConfiguration** - Global encryption settings (Keychain identifiers, key length)
|
||||
- **SyncConfiguration** - Global sync settings (Max automatic sync size)
|
||||
- **FileStorageConfiguration** - Global file settings (Sub-directory scoping)
|
||||
|
||||
### Other Models
|
||||
- **StorageDomain** - userDefaults, appGroupUserDefaults, keychain, fileSystem, encryptedFileSystem, appGroupFileSystem
|
||||
- **SecurityPolicy** - none, keychain, encrypted (AES-256 or ChaCha20-Poly1305)
|
||||
- **Serializer** - JSON, plist, Data, or custom
|
||||
@ -46,9 +53,6 @@ These helpers are internal implementation details used by `StorageRouter`. They
|
||||
- **FileDirectory** - documents, caches, custom URL
|
||||
- **StorageError** - Comprehensive error types
|
||||
- **StorageKeyDescriptor** - Audit snapshot of a key’s storage metadata
|
||||
- **EncryptionConfiguration** - Global encryption settings (Keychain identifiers, key length)
|
||||
- **SyncConfiguration** - Global sync settings (Max automatic sync size)
|
||||
- **FileStorageConfiguration** - Global file settings (Custom folder names)
|
||||
- **AnyStorageKey** - Type-erased storage key for catalogs
|
||||
- **AnyCodable** - Type-erased Codable for mixed-type payloads
|
||||
|
||||
@ -192,6 +196,22 @@ This will result in paths like:
|
||||
> [!WARNING]
|
||||
> Changing the `subDirectory` in an existing app will cause the library to look in the new location. Existing files in the old location will not be automatically moved.
|
||||
|
||||
#### Global Storage Defaults
|
||||
|
||||
To avoid repeating the same Keychain service or App Group identifier in every key, you can set library-wide defaults:
|
||||
|
||||
```swift
|
||||
let storageConfig = StorageConfiguration(
|
||||
defaultKeychainService: "com.myapp.keychain",
|
||||
defaultAppGroupIdentifier: "group.com.myapp"
|
||||
)
|
||||
await StorageRouter.shared.updateStorageConfiguration(storageConfig)
|
||||
```
|
||||
|
||||
When defaults are set, you can define keys using `nil` for these identifiers:
|
||||
- `.keychain(service: nil)` -> Uses "com.myapp.keychain"
|
||||
- `.appGroupUserDefaults(identifier: nil)` -> Uses "group.com.myapp"
|
||||
|
||||
```swift
|
||||
struct RemoteKeyProvider: KeyMaterialProviding {
|
||||
func keyMaterial(for keyName: String) async throws -> Data {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user