diff --git a/Sources/MobileSdk/StorageManager.swift b/Sources/MobileSdk/StorageManager.swift index 07c83f4..b1fcdc3 100644 --- a/Sources/MobileSdk/StorageManager.swift +++ b/Sources/MobileSdk/StorageManager.swift @@ -1,15 +1,11 @@ -// File: Storage Manager -// -// Store and retrieve sensitive data. Data is stored in the Application Support directory of the app, encrypted in place -// via the .completeFileProtection option, and marked as excluded from backups so it will not be included in iCloud backps. - -// -// Imports -// +/// Storage Manager +/// +/// Store and retrieve sensitive data. Data is stored in the Application Support directory of the app, encrypted in place +/// via the .completeFileProtection option, and marked as excluded from backups so it will not be included in iCloud backps. import Foundation -// import SpruceIDMobileSdkRs +import SpruceIDMobileSdkRs // The following is a stripped-down version of the protocol definition from mobile-sdk-rs against which the storage // manager is intended to link. @@ -34,23 +30,16 @@ public protocol StorageManagerInterface: AnyObject { } */ -// -// Code -// - -// Class: StorageManager -// Store and retrieve sensitive data. - +/// Store and retrieve sensitive data. class StorageManager: NSObject, StorageManagerInterface { - // Local-Method: path() - // Get the path to the application support dir, appending the given file name to it. We use the application support - // directory because its contents are not shared. - // - // Arguments: - // file - the name of the file - // - // Returns: - // An URL for the named file in the app's Application Support directory. + /// Get the path to the application support dir, appending the given file name to it. + /// + /// We use the application support directory because its contents are not shared. + /// + /// - Parameters: + /// - file: the name of the file + /// + /// - Returns: An URL for the named file in the app's Application Support directory. private func path(file: String) -> URL? { do { @@ -87,15 +76,13 @@ class StorageManager: NSObject, StorageManagerInterface { } } - // Method: add() - // Store a value for a specified key, encrypted in place. - // - // Arguments: - // key - the name of the file - // value - the data to store - // - // Returns: - // A boolean indicating success. + /// Store a value for a specified key, encrypted in place. + /// + /// - Parameters: + /// - key: the name of the file + /// - value: the data to store + /// + /// - Returns: a boolean indicating success func add(key: Key, value: Value) throws { guard let file = path(file: key) else { return } @@ -107,14 +94,12 @@ class StorageManager: NSObject, StorageManagerInterface { } } - // Method: get() - // Get a value for the specified key. - // - // Arguments: - // key - the name associated with the data - // - // Returns: - // Optional data potentially containing the value associated with the key; may be `nil`. + /// Get a value for the specified key. + /// + /// - Parameters: + /// - key: the name associated with the data + /// + /// - Returns: optional data potentially containing the value associated with the key; may be `nil` func get(key: Key) throws -> Value { guard let file = path(file: key) else { return Data() } @@ -127,12 +112,12 @@ class StorageManager: NSObject, StorageManagerInterface { } } - // Method: list() - // List the the items in storage. Note that this will list all items in the `application support` directory, - // potentially including any files created by other systems. - // - // Returns: - // A list of items in storage. + /// List the the items in storage. + /// + /// Note that this will list all items in the `application support` directory, potentially including any files created + /// by other systems. + /// + /// - Returns: a list of items in storage func list() -> [Key] { guard let asdir = path(file: "")?.path else { return [String]() } @@ -144,14 +129,14 @@ class StorageManager: NSObject, StorageManagerInterface { } } - // Method: remove() - // Remove a key/value pair. Removing a nonexistent key/value pair is not an error. - // - // Arguments: - // key - the name of the file - // - // Returns: - // A boolean indicating success; at present, there is no failure path, but this may change in the future. + /// Remove a key/value pair. + /// + /// Removing a nonexistent key/value pair is not an error. + /// + /// - Parameters: + /// - key: the name of the file + /// + /// - Returns: a boolean indicating success; at present, there is no failure path, but this may change in the future func remove(key: Key) throws { guard let file = path(file: key) else { return }