You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-10Lines changed: 32 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,14 +92,14 @@ let password: String? = try keychain.retrieve(
92
92
For example, if you need to store distinct ports credentials for the same user working on the same server, you might further characterize the query by specifying protection space.
93
93
94
94
```swift
95
-
let space1 =WebProtectionSpace(host: "https://example.com", port: 443)
95
+
let space1 =WebProtectionSpace(host: "example.com", port: 443)
let privateKey: P256.KeyAgreement.PrivateKey?=try? Keychain.default.retrieve(.privateKey(tag: "Alice"))
168
+
let publicKey = privateKey.publicKey
169
+
```
170
+
171
+
#### Get Data & Persistent Reference
172
+
173
+
```swift
174
+
let value =try keychain.retrieve([.data, .persistentReference], query: .credential(for: "OpenAI"))
175
+
ifcaselet .dictionary(info) = value {
176
+
// Data
177
+
info.data
178
+
// Persistent Reference
179
+
info.persistentReference
180
+
}
181
+
```
182
+
159
183
#### Debug
160
184
161
185
```swift
@@ -256,10 +280,8 @@ if success {
256
280
> [SharedWebCredentials API](https://developer.apple.com/documentation/security/shared_web_credentials) makes it possible to share credentials with the website counterpart. For example, a user may log in to a website in Safari and save credentials to the iCloud Keychain. Later, the user may run an app from the same developer, and instead of asking the user to reenter a username and password, it could access the existing credentials. The user can create new accounts, update passwords, or delete account from within the app. These changes should be saved from the app to be used by Safari.
257
281
258
282
```swift
259
-
let credential =SharedWebCredential("https://example.com", account: "username")
260
-
261
-
// Store
262
-
credential.store(password) { result in
283
+
/ Store
284
+
SharedWebCredential.store("https://example.com", account: "username", password: "secret") { result in
263
285
switch result {
264
286
case .failure(let error):
265
287
// Handle error
@@ -269,14 +291,14 @@ credential.store(password) { result in
269
291
}
270
292
271
293
// Remove
272
-
credential.remove(completion: { result in
294
+
SharedWebCredential.remove("https://example.com", account: "username") { result in
273
295
switch result {
274
296
case .failure(let error):
275
297
// Handle error
276
298
case .success:
277
299
// Handle success
278
300
}
279
-
})
301
+
}
280
302
281
303
// Retrieve
282
304
// - Use `ASAuthorizationController` to make an `ASAuthorizationPasswordRequest`.
@@ -305,7 +327,7 @@ To add support for custom types, you can extend them by conforming to the follow
305
327
// Store as Data (GenericPassword, InternetPassword)
0 commit comments