Update Models, Services and docs

Summary:
- Sources: update Models, Services
- Docs: update docs for README

Stats:
- 4 files changed, 38 insertions(+), 4 deletions(-)
This commit is contained in:
Matt Bruce 2026-01-14 13:39:50 -06:00
parent 024af6865d
commit 4a17e7bea7
4 changed files with 38 additions and 4 deletions

View File

@ -47,6 +47,7 @@ These helpers are internal implementation details used by `StorageRouter`. They
- **StorageError** - Comprehensive error types
- **StorageKeyDescriptor** - Audit snapshot of a keys storage metadata
- **EncryptionConfiguration** - Global encryption settings (Keychain identifiers, key length)
- **SyncConfiguration** - Global sync settings (Max automatic sync size)
- **AnyStorageKey** - Type-erased storage key for catalogs
- **AnyCodable** - Type-erased Codable for mixed-type payloads
@ -152,6 +153,15 @@ await StorageRouter.shared.updateEncryptionConfiguration(config)
> [!WARNING]
> Changing the `masterKeyService` or `masterKeyAccount` in an existing app will cause the app to look for the master key in a new location. Previously encrypted data will be lost.
#### Global Sync Configuration
You can customize the maximum size for automatic synchronization:
```swift
let syncConfig = SyncConfiguration(maxAutoSyncSize: 50_000) // 50KB limit
await StorageRouter.shared.updateSyncConfiguration(syncConfig)
```
```swift
struct RemoteKeyProvider: KeyMaterialProviding {
func keyMaterial(for keyName: String) async throws -> Data {

View File

@ -0,0 +1,13 @@
import Foundation
/// Configuration for WatchConnectivity sync operations.
public struct SyncConfiguration: Sendable {
/// Maximum data size for automatic sync in bytes.
public let maxAutoSyncSize: Int
public init(maxAutoSyncSize: Int = 100_000) {
self.maxAutoSyncSize = maxAutoSyncSize
}
public static let `default` = SyncConfiguration()
}

View File

@ -23,6 +23,11 @@ public actor StorageRouter: StorageProviding {
await EncryptionHelper.shared.updateConfiguration(configuration)
}
/// Updates the sync configuration.
public func updateSyncConfiguration(_ configuration: SyncConfiguration) async {
await SyncHelper.shared.updateConfiguration(configuration)
}
// MARK: - Key Material Providers
/// Registers a key material provider for external encryption policies.

View File

@ -9,10 +9,16 @@ actor SyncHelper {
public static let shared = SyncHelper()
/// Maximum data size for automatic sync (100KB).
public static let maxAutoSyncSize = 100_000
private var configuration: SyncConfiguration
private init() {}
private init(configuration: SyncConfiguration = .default) {
self.configuration = configuration
}
/// Updates the sync configuration.
public func updateConfiguration(_ configuration: SyncConfiguration) {
self.configuration = configuration
}
// MARK: - Public Interface
@ -40,7 +46,7 @@ actor SyncHelper {
return
case .automaticSmall:
guard data.count <= Self.maxAutoSyncSize else {
guard data.count <= configuration.maxAutoSyncSize else {
throw StorageError.dataTooLargeForSync
}
try performSync(data: data, keyName: keyName)