From 08b5e5c144a642bf015bbfa3060bb79edf8afea7 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 1 Jun 2022 11:50:39 +0200 Subject: [PATCH] Add PasswordStorage --- Sources/ElixxirDAppsSDK/Errors.swift | 4 +++ Sources/ElixxirDAppsSDK/PasswordStorage.swift | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Sources/ElixxirDAppsSDK/PasswordStorage.swift diff --git a/Sources/ElixxirDAppsSDK/Errors.swift b/Sources/ElixxirDAppsSDK/Errors.swift index ae4ae8ae..0f113897 100644 --- a/Sources/ElixxirDAppsSDK/Errors.swift +++ b/Sources/ElixxirDAppsSDK/Errors.swift @@ -5,3 +5,7 @@ public struct BindingsDownloadAndVerifySignedNdfWithUrlUnknownError: Error, Equa public struct BindingsGenerateSecretUnknownError: Error, Equatable { public init() {} } + +public struct PasswordStorageMissingPasswordError: Error, Equatable { + public init() {} +} diff --git a/Sources/ElixxirDAppsSDK/PasswordStorage.swift b/Sources/ElixxirDAppsSDK/PasswordStorage.swift new file mode 100644 index 00000000..82ae04dc --- /dev/null +++ b/Sources/ElixxirDAppsSDK/PasswordStorage.swift @@ -0,0 +1,29 @@ +import Foundation + +public struct PasswordStorage { + public init( + save: @escaping (Data) throws -> Void, + load: @escaping () throws -> Data + ) { + self.save = save + self.load = load + } + + public var save: (Data) throws -> Void + public var load: () throws -> Data +} + +#if DEBUG +extension PasswordStorage { + public static let failing = PasswordStorage( + save: { _ in + struct NotImplemented: Error {} + throw NotImplemented() + }, + load: { + struct NotImplemented: Error {} + throw NotImplemented() + } + ) +} +#endif -- GitLab