From c41daf5d9e455561eca8eae80b351825ee26b332 Mon Sep 17 00:00:00 2001 From: Todd Showalter Date: Mon, 5 Aug 2024 14:07:34 -0400 Subject: [PATCH 1/2] Comment format updates. Use DocC format. --- Sources/MobileSdk/StorageManager.swift | 98 +++++++++++--------------- 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/Sources/MobileSdk/StorageManager.swift b/Sources/MobileSdk/StorageManager.swift index 47c10f5..73ca759 100644 --- a/Sources/MobileSdk/StorageManager.swift +++ b/Sources/MobileSdk/StorageManager.swift @@ -1,31 +1,20 @@ -// 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 -// -// Code -// - -// Class: StorageManager -// Store and retrieve sensitive data. - +/// Store and retrieve sensitive data. class StorageManager: NSObject { - // 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 { @@ -44,15 +33,13 @@ class StorageManager: NSObject { } } - // 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: String, value: Data) -> Bool { guard let file = path(file: key) else { return false } @@ -67,14 +54,12 @@ class StorageManager: NSObject { return true } - // 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: String) -> Data? { guard let file = path(file: key) else { return nil } @@ -89,12 +74,12 @@ class StorageManager: NSObject { return nil } - // 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() -> [String] { guard let asdir = path(file: "")?.path else { return [String]() } @@ -106,14 +91,14 @@ class StorageManager: NSObject { } } - // 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: String) -> Bool { guard let file = path(file: key) else { return true } @@ -127,8 +112,7 @@ class StorageManager: NSObject { return true } - // Method: sys_test() - // Check to see if everything works. + /// Check to see if everything works. func sys_test() { let key = "test_key" From 54c1d21cf7c460cd673586c3077058eedf840dfd Mon Sep 17 00:00:00 2001 From: Todd Showalter Date: Mon, 5 Aug 2024 14:12:48 -0400 Subject: [PATCH 2/2] Formatting fixes & merge. Resolving a conflict. --- Sources/MobileSdk/StorageManager.swift | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Sources/MobileSdk/StorageManager.swift b/Sources/MobileSdk/StorageManager.swift index 5457ee1..a80caf9 100644 --- a/Sources/MobileSdk/StorageManager.swift +++ b/Sources/MobileSdk/StorageManager.swift @@ -6,21 +6,6 @@ import Foundation 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. - -/* - public typealias Key = String - public typealias Value = Data - - public protocol StorageManagerInterface : AnyObject { - func add(key: Key, value: Value) throws - func get(key: Key) throws -> Value - func list() -> [Key] - func remove(key: Key) throws - } - */ - /// Store and retrieve sensitive data. class StorageManager: NSObject, StorageManagerInterface {