diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100755 index 0000000..6f13646 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Change Log + +## [1.0](https://github.com/idevelopers-in/FKSecureStore/releases/tag/1.0) +Released on ??, ?? ??, 2022. + +#### Added +* Initial release. diff --git a/FKSecureStore.podspec b/FKSecureStore.podspec new file mode 100755 index 0000000..4ea5cd1 --- /dev/null +++ b/FKSecureStore.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = 'FKSecureStore' + s.version = '1.0' + s.platform = :ios, '9.0' + s.license = { :type => 'MIT' } + s.homepage = 'https://github.com/idevelopers-in/FKSecureStore' + s.authors = { 'Firoz Khan' => 'f90khan@gmail.com' } + s.summary = 'A helper for keeping data secured in the keychain' + s.source = { :git => 'https://github.com/idevelopers-in/FKSecureStore.git', :tag => s.version } + s.source_files = 'FKSecureStore/*.{swift}' + s.frameworks = 'Security' + s.requires_arc = true +end diff --git a/FKSecureStore/FKSecureStore.swift b/FKSecureStore/FKSecureStore.swift index c7d1016..a142604 100644 --- a/FKSecureStore/FKSecureStore.swift +++ b/FKSecureStore/FKSecureStore.swift @@ -26,9 +26,9 @@ import Security private let kSecureKeyPrefix = Bundle.main.bundleIdentifier! + ".FKSecureStore." -@objc class FKSecureStore: NSObject +@objc public class FKSecureStore: NSObject { - @objc enum Status: Int + @objc public enum Status: Int { case success case noData @@ -59,13 +59,13 @@ private let kSecureKeyPrefix = Bundle.main.bundleIdentifier! + ".FKSecureStore." Save any `String` for a particular key inside the keychain. - Parameters: - - string: The string to be saved. - - key: The key for which the string should be saved. + - string: The string to be saved. + - key: The key for which the string should be saved. - Returns: An enum containing the status of the operation. */ @discardableResult - @objc class func save(string: String, key: String) -> Status { + @objc public class func save(string: String, key: String) -> Status { if let stringData = string.data(using: .utf8, allowLossyConversion: false) { return save(data: stringData, key: key) @@ -77,13 +77,13 @@ private let kSecureKeyPrefix = Bundle.main.bundleIdentifier! + ".FKSecureStore." Save any `Data` for a particular key inside the keychain. - Parameters: - - data: The data to be saved. - - key: The key for which the data should be saved. + - data: The data to be saved. + - key: The key for which the data should be saved. - Returns: An enum containing the status of the operation. */ @discardableResult - @objc class func save(data: Data, key: String) -> Status { + @objc public class func save(data: Data, key: String) -> Status { let query: [String: Any] = [ String(kSecClass): kSecClassKey, @@ -102,11 +102,13 @@ private let kSecureKeyPrefix = Bundle.main.bundleIdentifier! + ".FKSecureStore." /** Retrieve any saved `String` for a particular key inside the keychain. - - Parameter key: The key for which the `String` should be retrieved. + - Parameters: + - key: The key for which the `String` should be retrieved. - Returns: An optional `String` object. */ - @objc class func load(key: String) -> String? { + @discardableResult + @objc public class func load(key: String) -> String? { if let data = load(dataForKey: key){ return String(data: data, encoding: .utf8) @@ -117,11 +119,13 @@ private let kSecureKeyPrefix = Bundle.main.bundleIdentifier! + ".FKSecureStore." /** Retrieve any saved `Data` for a particular key inside the keychain. - - Parameter key: The key for which the `Data` should be retrieved. + - Parameters: + - key: The key for which the `Data` should be retrieved. - Returns: An optional `Data` object. */ - @objc class func load(dataForKey key: String) -> Data? { + @discardableResult + @objc public class func load(dataForKey key: String) -> Data? { let query = [ String(kSecClass): kSecClassKey, @@ -141,12 +145,13 @@ private let kSecureKeyPrefix = Bundle.main.bundleIdentifier! + ".FKSecureStore." /** Delete stored data for a particular key inside the keychain. - - Parameter key: The key for which the data should be deleted. + - Parameters: + - key: The key for which the data should be deleted. - Returns: An enum containing the status of the operation. */ @discardableResult - @objc class func delete(key: String) -> Status { + @objc public class func delete(key: String) -> Status { let query = [ String(kSecClass): kSecClassKey, @@ -163,7 +168,7 @@ private let kSecureKeyPrefix = Bundle.main.bundleIdentifier! + ".FKSecureStore." - Returns: An enum containing the status of the operation. */ @discardableResult - @objc class func clear() -> Status { + @objc public class func clear() -> Status { let query = [ String(kSecClass): kSecClassKey, diff --git a/README.md b/README.md index cde1b1a..dd420e9 100755 --- a/README.md +++ b/README.md @@ -38,12 +38,13 @@ Delete any saved data for a particular key in the keychain. ``` Delete all saved data for the app in the keychain. All data for any key you might have saved will be deleted. -#### Note -Saved data will persist in keychain even after application is deleted or device is restarted. +**Note:** Saved data will persist in keychain even after application is deleted or device is restarted. # To-do * Option to clear keychain data if app is uninstalled. [Might help?](https://developer.apple.com/forums/thread/36442) +* ~~Check if podspec requires linking to `Security` framework~~ +* ~~Add description of library to repo page and podspec~~ # License