added iCloud sync for keys??

reindented all apple sample code
This commit is contained in:
neon443
2025-07-03 11:10:54 +01:00
parent 5ef1a51ba8
commit 200e1fd76c
6 changed files with 262 additions and 262 deletions

View File

@@ -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()
}

View File

@@ -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