Update SecureStorageSample
This commit is contained in:
parent
3317915dff
commit
f1f25c4b78
@ -90,9 +90,9 @@ The app demonstrates various storage configurations:
|
|||||||
- 6 access control options (biometry, passcode, etc.)
|
- 6 access control options (biometry, passcode, etc.)
|
||||||
|
|
||||||
### File System
|
### File System
|
||||||
- Documents directory (persisted, backed up)
|
- **Documents**: Permanent storage, backed up to iCloud. Use for critical user data.
|
||||||
- Caches directory (can be purged)
|
- **Caches**: Purgeable storage (iOS may delete when low on space), not backed up. Use for temporary data.
|
||||||
- JSON and PropertyList serializers
|
- JSON and PropertyList serializers supported.
|
||||||
|
|
||||||
### App Group Storage
|
### App Group Storage
|
||||||
- Shared UserDefaults via App Group identifier
|
- Shared UserDefaults via App Group identifier
|
||||||
@ -117,6 +117,8 @@ The app demonstrates how to configure the `LocalData` library globally during st
|
|||||||
|
|
||||||
- **Encryption**: Customized Keychain service (`SecureStorageSample`) and account (`AppMasterKey`) names to isolate the library's master encryption key from other apps.
|
- **Encryption**: Customized Keychain service (`SecureStorageSample`) and account (`AppMasterKey`) names to isolate the library's master encryption key from other apps.
|
||||||
- **Sync**: Set a custom `maxAutoSyncSize` of 50KB to control which data is automatically synchronized to the Apple Watch, overriding the library's 100KB default.
|
- **Sync**: Set a custom `maxAutoSyncSize` of 50KB to control which data is automatically synchronized to the Apple Watch, overriding the library's 100KB default.
|
||||||
|
- **File Storage**: Scoping all library files into a `SecureStorage` sub-directory. This ensures that the library's data (whether in the main sandbox or a shared App Group container) is kept neat and isolated within its own folder, rather than cluttering the root directories.
|
||||||
|
- **Storage Defaults**: Pre-configuring the default Keychain service and App Group identifier. This allows common keys in the app to omit these identifiers, reducing boilerplate and making the code more maintainable.
|
||||||
|
|
||||||
This approach centralizes infrastructure settings and avoids hardcoding environment-specific values within individual storage keys.
|
This approach centralizes infrastructure settings and avoids hardcoding environment-specific values within individual storage keys.
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,21 @@ struct SecureStorageSampleApp: App {
|
|||||||
let syncConfig = SyncConfiguration(maxAutoSyncSize: 50_000)
|
let syncConfig = SyncConfiguration(maxAutoSyncSize: 50_000)
|
||||||
await StorageRouter.shared.updateSyncConfiguration(syncConfig)
|
await StorageRouter.shared.updateSyncConfiguration(syncConfig)
|
||||||
|
|
||||||
|
// 3. Global File Storage Configuration
|
||||||
|
// We scope all our library files into a "SecureStorage" sub-directory
|
||||||
|
// underneath the standard Documents/Caches folders.
|
||||||
|
let fileConfig = FileStorageConfiguration(subDirectory: "SecureStorage")
|
||||||
|
await StorageRouter.shared.updateFileStorageConfiguration(fileConfig)
|
||||||
|
|
||||||
|
// 4. Global Storage Defaults
|
||||||
|
// Setting default identifiers for Keychain and App Groups.
|
||||||
|
// This allows keys to be defined more concisely without repeating these IDs.
|
||||||
|
let storageConfig = StorageConfiguration(
|
||||||
|
defaultKeychainService: StorageServiceIdentifiers.bundleIdentifier,
|
||||||
|
defaultAppGroupIdentifier: StorageServiceIdentifiers.appGroupIdentifier
|
||||||
|
)
|
||||||
|
await StorageRouter.shared.updateStorageConfiguration(storageConfig)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try await StorageRouter.shared.registerCatalog(AppStorageCatalog.self)
|
try await StorageRouter.shared.registerCatalog(AppStorageCatalog.self)
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user