diff --git a/README.md b/README.md index 7e46cfc1..1e766cc0 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ The identifier you choose for your Valet is used to create a sandbox for the dat #### Choosing a User-friendly Identifier on macOS ```swift -let mySecureEnclaveValet = Valet.valet(withExplicitlySet: Identifier(nonEmpty: "Druidia")!, accessibility: .whenUnlocked) +let myValet = Valet.valet(withExplicitlySet: Identifier(nonEmpty: "Druidia")!, accessibility: .whenUnlocked) ``` ```objc @@ -109,6 +109,22 @@ Mac apps signed with a developer ID may see their Valet’s identifier [shown to The Accessibility enum is used to determine when your secrets can be accessed. It’s a good idea to use the strictest accessibility possible that will allow your app to function. For example, if your app does not run in the background you will want to ensure the secrets can only be read when the phone is unlocked by using `.whenUnlocked` or `.whenUnlockedThisDeviceOnly`. +#### Changing an Accessibility Value After Persisting Data + +```swift +let myOldValet = Valet.valet(withExplicitlySet: Identifier(nonEmpty: "Druidia")!, accessibility: .whenUnlocked) +let myNewValet = Valet.valet(withExplicitlySet: Identifier(nonEmpty: "Druidia")!, accessibility: .afterFirstUnlock) +try? myNewValet.migrateObjects(from: myOldValet, removeOnCompletion: true) +``` + +```objc +VALValet *const myOldValet = [VALValet valetWithExplicitlySetIdentifier:@"Druidia" accessibility:VALAccessibilityWhenUnlocked]; +VALValet *const myNewValet = [VALValet valetWithExplicitlySetIdentifier:@"Druidia" accessibility:VALAccessibilityAfterFirstUnlock]; +[myNewValet migrateObjectsFrom:myOldValet removeOnCompletion:true error:nil]; +``` + +The Valet type, identifier, accessibility value, and initializer chosen to create a Valet are combined to create a sandbox within the keychain. This behavior ensures that different Valets can not read or write one another's key:value pairs. If you change a Valet's accessibility after persisting key:value pairs, you must migrate the key:value pairs from the Valet with the no-longer-desired accessibility to the Valet with the desired accessibility to avoid data loss. + ### Reading and Writing ```swift