Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a9c1a6022b |
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Locksmith"
|
||||
s.version = "2.0.8"
|
||||
s.version = "2.0.5"
|
||||
s.summary = "Locksmith is a powerful, protocol-oriented library for working with the keychain in Swift."
|
||||
s.description = <<-DESC
|
||||
Locksmith is a powerful, protocol-oriented library for working with the iOS, Mac OS X, watchOS, and tvOS keychain in Swift. It provides extensive support for a lot of different keychain requests, and extensively uses Swift-native concepts.
|
||||
|
||||
@@ -346,32 +346,26 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0700;
|
||||
LastUpgradeCheck = 0800;
|
||||
LastUpgradeCheck = 0720;
|
||||
ORGANIZATIONNAME = "Mathew Palmer";
|
||||
TargetAttributes = {
|
||||
0EC25C581BA385AA004191AF = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
0EC25C611BA385AB004191AF = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
0EC25C741BA385F6004191AF = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
0EC25C7D1BA385F6004191AF = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
0EC25CA61BA39C9F004191AF = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
FBD0C9481C1866BE00291F2A = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -548,7 +542,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-iOS";
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -569,8 +562,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-iOS";
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -585,7 +576,6 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-iOSTests";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -600,8 +590,6 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-iOSTests";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -625,7 +613,6 @@
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -649,8 +636,6 @@
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -667,7 +652,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-OS-XTests";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -684,8 +668,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-OS-XTests";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -705,7 +687,6 @@
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 2.3;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
};
|
||||
@@ -728,8 +709,6 @@
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 2.3;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
};
|
||||
@@ -739,7 +718,6 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -760,7 +738,6 @@
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
@@ -790,7 +767,6 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -810,7 +786,6 @@
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
@@ -832,13 +807,11 @@
|
||||
FBD0C94E1C1866BE00291F2A /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BITCODE_GENERATION_MODE = bitcode;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_BITCODE = YES;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = Source/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
@@ -847,7 +820,6 @@
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 2.3;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
@@ -856,14 +828,12 @@
|
||||
FBD0C94F1C1866BE00291F2A /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BITCODE_GENERATION_MODE = bitcode;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_BITCODE = YES;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = Source/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
@@ -872,8 +842,6 @@
|
||||
PRODUCT_NAME = Locksmith;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 2.3;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -7,14 +7,6 @@ A powerful, protocol-oriented library for working with the keychain in Swift.
|
||||
- [x] ⌚️ watchOS 2
|
||||
- [x] 📺 tvOS
|
||||
|
||||
>
|
||||
>
|
||||
> 🚀 I make [Rocket](http://matthewpalmer.net/rocket?utm_source=locksmith&utm_medium=readme&utm_campaign=open_source), an app that gives you Slack-style emoji everywhere on your Mac.
|
||||
>
|
||||
>
|
||||
|
||||
## Details
|
||||
|
||||
How is Locksmith different to other keychain wrappers?
|
||||
|
||||
* Locksmith’s API is both super-simple and deeply powerful
|
||||
@@ -40,7 +32,7 @@ Locksmith is available through [CocoaPods](http://cocoapods.org).
|
||||
|
||||
Locksmith is available through [Carthage](https://github.com/Carthage/Carthage).
|
||||
|
||||
github "matthewpalmer/Locksmith"
|
||||
github 'matthewpalmer/Locksmith'
|
||||
|
||||
## Quick start
|
||||
|
||||
|
||||
+8
-35
@@ -39,14 +39,15 @@ public struct Locksmith {
|
||||
}
|
||||
|
||||
public static func updateData(data: [String: AnyObject], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService) throws {
|
||||
struct UpdateRequest: GenericPasswordSecureStorable, CreateableSecureStorable {
|
||||
let service: String
|
||||
let account: String
|
||||
let data: [String: AnyObject]
|
||||
// Delete and then re-save
|
||||
do {
|
||||
try Locksmith.deleteDataForUserAccount(userAccount, inService: service)
|
||||
} catch {
|
||||
// Deletion is likely to fail if the piece of data doesn't exist yet.
|
||||
// This doesn't matter--we only tell the user about errors on the save request.
|
||||
}
|
||||
|
||||
let request = UpdateRequest(service: service, account: userAccount, data: data)
|
||||
try request.updateInSecureStore()
|
||||
|
||||
return try Locksmith.saveData(data, forUserAccount: userAccount, inService: service)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +424,6 @@ public protocol CreateableSecureStorable: SecureStorable {
|
||||
var data: [String: AnyObject] { get }
|
||||
var performCreateRequestClosure: PerformRequestClosureType { get }
|
||||
func createInSecureStore() throws
|
||||
func updateInSecureStore() throws
|
||||
}
|
||||
|
||||
// MARK: - ReadableSecureStorable
|
||||
@@ -509,27 +509,6 @@ public protocol DeleteableSecureStorable: SecureStorable {
|
||||
|
||||
// MARK: - Default property dictionaries
|
||||
|
||||
extension CreateableSecureStorable {
|
||||
func updateInSecureStore(query: [String: AnyObject]) throws {
|
||||
var attributesToUpdate = query
|
||||
attributesToUpdate[String(kSecClass)] = nil
|
||||
|
||||
let status = SecItemUpdate(query, attributesToUpdate)
|
||||
|
||||
if let error = LocksmithError(fromStatusCode: Int(status)) {
|
||||
if error == .NotFound || error == .NotAvailable {
|
||||
try self.createInSecureStore()
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
} else {
|
||||
if status != errSecSuccess {
|
||||
throw LocksmithError.Undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension CreateableSecureStorable where Self : GenericPasswordSecureStorable {
|
||||
var asCreateableSecureStoragePropertyDictionary: [String: AnyObject] {
|
||||
var old = genericPasswordBaseStoragePropertyDictionary
|
||||
@@ -542,9 +521,6 @@ public extension CreateableSecureStorable where Self : GenericPasswordSecureStor
|
||||
func createInSecureStore() throws {
|
||||
try performSecureStorageAction(performCreateRequestClosure, secureStoragePropertyDictionary: asCreateableSecureStoragePropertyDictionary)
|
||||
}
|
||||
func updateInSecureStore() throws {
|
||||
try self.updateInSecureStore(self.asCreateableSecureStoragePropertyDictionary)
|
||||
}
|
||||
}
|
||||
|
||||
public extension CreateableSecureStorable where Self : InternetPasswordSecureStorable {
|
||||
@@ -567,9 +543,6 @@ public extension CreateableSecureStorable where Self : InternetPasswordSecureSto
|
||||
func createInSecureStore() throws {
|
||||
try performSecureStorageAction(performCreateRequestClosure, secureStoragePropertyDictionary: asCreateableSecureStoragePropertyDictionary)
|
||||
}
|
||||
func updateInSecureStore() throws {
|
||||
try self.updateInSecureStore(self.asCreateableSecureStoragePropertyDictionary)
|
||||
}
|
||||
}
|
||||
|
||||
public extension DeleteableSecureStorable {
|
||||
|
||||
+10
-61
@@ -53,12 +53,6 @@ class LocksmithTests: XCTestCase {
|
||||
let loaded3 = Locksmith.loadDataForUserAccount(userAccount, inService: service)! as! TestingDictionaryType
|
||||
|
||||
XCTAssertEqual(loaded3, updatedData)
|
||||
|
||||
try! Locksmith.deleteDataForUserAccount(userAccount, inService: service)
|
||||
|
||||
try! Locksmith.updateData(["some update": "data"], forUserAccount: userAccount, inService: service)
|
||||
let updateResult = Locksmith.loadDataForUserAccount(userAccount, inService: service)! as! [String: String]
|
||||
XCTAssertEqual(updateResult, ["some update": "data"])
|
||||
}
|
||||
|
||||
func testStaticMethodsForDefaultService() {
|
||||
@@ -100,40 +94,6 @@ class LocksmithTests: XCTestCase {
|
||||
createGenericPasswordWithData(data)
|
||||
}
|
||||
|
||||
func testUpdateCreatesIfNotExists() {
|
||||
let data = ["some": "data"]
|
||||
|
||||
struct CreateGenericPassword: CreateableSecureStorable, GenericPasswordSecureStorable, ReadableSecureStorable {
|
||||
var data: [String: AnyObject]
|
||||
let account: String
|
||||
let service: String
|
||||
}
|
||||
|
||||
let update = CreateGenericPassword(data: data, account: userAccount, service: service)
|
||||
try! update.updateInSecureStore()
|
||||
|
||||
let read = update.readFromSecureStore()!.data as! [String: String]
|
||||
XCTAssertEqual(read, ["some": "data"])
|
||||
}
|
||||
|
||||
func testUpdateForGenericPassword() {
|
||||
let data = ["some": "data"]
|
||||
|
||||
struct CreateGenericPassword: CreateableSecureStorable, GenericPasswordSecureStorable, ReadableSecureStorable {
|
||||
var data: [String: AnyObject]
|
||||
let account: String
|
||||
let service: String
|
||||
}
|
||||
|
||||
var create = CreateGenericPassword(data: data, account: userAccount, service: service)
|
||||
try! create.createInSecureStore() // make sure it doesn't throw
|
||||
create.data = ["other": "data"]
|
||||
try! create.updateInSecureStore()
|
||||
|
||||
let read = create.readFromSecureStore()!.data as! [String: String]
|
||||
XCTAssertEqual(read, ["other": "data"])
|
||||
}
|
||||
|
||||
func testLoadForGenericPassword() {
|
||||
let data = ["one": "two"]
|
||||
createGenericPasswordWithData(data)
|
||||
@@ -279,7 +239,7 @@ class LocksmithTests: XCTestCase {
|
||||
func testInternetPasswordMetaAttributesAreCreatedAndReturned() {
|
||||
struct CreateInternetPassword: CreateableSecureStorable, InternetPasswordSecureStorable {
|
||||
let account: String
|
||||
var data: [String: AnyObject]
|
||||
let data: [String: AnyObject]
|
||||
let server: String
|
||||
let port: Int
|
||||
let internetProtocol: LocksmithInternetProtocol
|
||||
@@ -305,31 +265,20 @@ class LocksmithTests: XCTestCase {
|
||||
let authenticationType: LocksmithInternetAuthenticationType
|
||||
}
|
||||
|
||||
var c = CreateInternetPassword(account: userAccount, data: initialData, server: server, port: port, internetProtocol: internetProtocol, authenticationType: authenticationType, path: path, securityDomain: securityDomain)
|
||||
let c = CreateInternetPassword(account: userAccount, data: initialData, server: server, port: port, internetProtocol: internetProtocol, authenticationType: authenticationType, path: path, securityDomain: securityDomain)
|
||||
try! c.createInSecureStore()
|
||||
|
||||
func assertResultMetadataIsOk(result: InternetPasswordSecureStorableResultType?) {
|
||||
XCTAssertEqual(result?.account, userAccount)
|
||||
XCTAssertEqual(result?.server, server)
|
||||
XCTAssertEqual(result?.port, port)
|
||||
XCTAssertEqual(result?.internetProtocol, internetProtocol)
|
||||
XCTAssertEqual(result?.authenticationType, authenticationType)
|
||||
XCTAssertEqual(result?.securityDomain, securityDomain)
|
||||
XCTAssertEqual(result?.path, path)
|
||||
}
|
||||
|
||||
let r = ReadInternetPassword(account: userAccount, server: server, port: port, internetProtocol: internetProtocol, authenticationType: authenticationType)
|
||||
let result = r.readFromSecureStore()
|
||||
|
||||
XCTAssertEqual(result?.account, userAccount)
|
||||
XCTAssertEqual(result!.data as! [String: String], initialData)
|
||||
assertResultMetadataIsOk(result)
|
||||
|
||||
// Assert that metadata is maintained after an update
|
||||
c.data = ["other internet": "junk"]
|
||||
try! c.updateInSecureStore()
|
||||
|
||||
let result2 = r.readFromSecureStore()
|
||||
XCTAssertEqual(result2!.data as! [String: String], ["other internet": "junk"])
|
||||
assertResultMetadataIsOk(result2)
|
||||
XCTAssertEqual(result?.server, server)
|
||||
XCTAssertEqual(result?.port, port)
|
||||
XCTAssertEqual(result?.internetProtocol, internetProtocol)
|
||||
XCTAssertEqual(result?.authenticationType, authenticationType)
|
||||
XCTAssertEqual(result?.securityDomain, securityDomain)
|
||||
XCTAssertEqual(result?.path, path)
|
||||
}
|
||||
|
||||
func assertStringPairsMatchInDictionary(dictionary: NSDictionary, pairs: [(key: CFString, expectedOutput: String)]) {
|
||||
|
||||
Reference in New Issue
Block a user