mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added iCloud sync for keys??
reindented all apple sample code
This commit is contained in:
@@ -19,8 +19,6 @@ class KeyManager: ObservableObject {
|
||||
var keyIDs: [UUID] {
|
||||
keypairs.map { $0.id }
|
||||
}
|
||||
// @Published var keyTypes: [UUID: KeyType] = [:]
|
||||
// @Published var keyNames: [UUID: String] = [:]
|
||||
private let baseTag = "com.neon443.ShhShell.keys".data(using: .utf8)!
|
||||
|
||||
init() {
|
||||
@@ -59,9 +57,8 @@ class KeyManager: ObservableObject {
|
||||
}
|
||||
|
||||
func deleteKey(_ keypair: Keypair) {
|
||||
withAnimation { keypairs.removeAll(where: { $0.id == keypair.id }) }
|
||||
removeFromKeycahin(keypair: keypair)
|
||||
let keyID = keypair.id
|
||||
withAnimation { keypairs.removeAll(where: { $0.id == keyID }) }
|
||||
saveKeypairs()
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ struct GenericPasswordStore {
|
||||
kSecAttrAccount: account,
|
||||
kSecAttrAccessible: kSecAttrAccessibleWhenUnlocked,
|
||||
kSecUseDataProtectionKeychain: true,
|
||||
kSecAttrSynchronizable: true,
|
||||
kSecValueData: cfd] as [String: Any]
|
||||
|
||||
// Add the key data.
|
||||
@@ -39,7 +40,8 @@ struct GenericPasswordStore {
|
||||
let query = [kSecClass: kSecClassGenericPassword,
|
||||
kSecAttrAccount: account,
|
||||
kSecUseDataProtectionKeychain: true,
|
||||
kSecReturnData: true] as [String: Any]
|
||||
kSecReturnData: true,
|
||||
kSecAttrSynchronizable: true] as [String: Any]
|
||||
|
||||
// Find and cast the result as data.
|
||||
var item: CFTypeRef?
|
||||
@@ -73,6 +75,7 @@ struct GenericPasswordStore {
|
||||
func deleteKey(account: String) throws {
|
||||
let query = [kSecClass: kSecClassGenericPassword,
|
||||
kSecUseDataProtectionKeychain: true,
|
||||
kSecAttrSynchronizable: kSecAttrSynchronizableAny,
|
||||
kSecAttrAccount: account] as [String: Any]
|
||||
switch SecItemDelete(query as CFDictionary) {
|
||||
case errSecItemNotFound, errSecSuccess: break // Okay to ignore
|
||||
|
||||
Reference in New Issue
Block a user