From 6d1ceb23852000ea7595f98e33cec3dbd5005420 Mon Sep 17 00:00:00 2001 From: Filippos Sakellaropoulos Date: Mon, 2 Sep 2024 14:14:46 +0300 Subject: [PATCH 1/2] add DocumentStatus pending --- Sources/WalletStorage/Enumerations.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/WalletStorage/Enumerations.swift b/Sources/WalletStorage/Enumerations.swift index 362a5cf..5ff8639 100644 --- a/Sources/WalletStorage/Enumerations.swift +++ b/Sources/WalletStorage/Enumerations.swift @@ -52,4 +52,5 @@ public enum PrivateKeyType: String { public enum DocumentStatus: String { case issued case deferred + case pending } From 3e3900f32b591ba0e1577fc8131f8345d08dcf26 Mon Sep 17 00:00:00 2001 From: Filippos Sakellaropoulos Date: Mon, 2 Sep 2024 16:26:22 +0300 Subject: [PATCH 2/2] do not throw error in deletedocuments if id == nil, case-iterable status --- Sources/WalletStorage/Enumerations.swift | 2 +- Sources/WalletStorage/KeyChainStorageService.swift | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/WalletStorage/Enumerations.swift b/Sources/WalletStorage/Enumerations.swift index 5ff8639..413f5e4 100644 --- a/Sources/WalletStorage/Enumerations.swift +++ b/Sources/WalletStorage/Enumerations.swift @@ -49,7 +49,7 @@ public enum PrivateKeyType: String { /// document status -public enum DocumentStatus: String { +public enum DocumentStatus: String, CaseIterable { case issued case deferred case pending diff --git a/Sources/WalletStorage/KeyChainStorageService.swift b/Sources/WalletStorage/KeyChainStorageService.swift index 50b4389..30685f9 100644 --- a/Sources/WalletStorage/KeyChainStorageService.swift +++ b/Sources/WalletStorage/KeyChainStorageService.swift @@ -146,7 +146,10 @@ public class KeyChainStorageService: DataStorageService { let query: [String: Any] = makeQuery(id: id, bForSave: true, status: docStatus, dataType: dataType) let status = SecItemDelete(query as CFDictionary) let statusMessage = SecCopyErrorMessageString(status, nil) as? String - guard status == errSecSuccess else { + if status == errSecItemNotFound, id == nil { + let msg = statusMessage ?? "No items found" + logger.warning("\(msg)") + } else if status != errSecSuccess { logger.error("Error code: \(Int(status)), description: \(statusMessage ?? "")") throw StorageError(description: statusMessage ?? "", code: Int(status)) }