зеркало из https://github.com/github/SoftU2F.git
upgrade to swift 4
This commit is contained in:
Родитель
8fb9b41980
Коммит
9ae2d4b5da
|
@ -88,25 +88,21 @@ public class DataReader {
|
|||
}
|
||||
|
||||
// Read n bytes from the data, advancing our offset into the data.
|
||||
func readData<I:Integer>(_ n: I) throws -> Data {
|
||||
let intN = Int(n.toIntMax())
|
||||
|
||||
guard let d = peekData(intN) else {
|
||||
func readData<I:BinaryInteger>(_ n: I) throws -> Data {
|
||||
guard let d = peekData(n) else {
|
||||
throw DataReaderError.End
|
||||
}
|
||||
|
||||
offset += intN
|
||||
offset += Int(n)
|
||||
return d
|
||||
}
|
||||
|
||||
// Read n bytes from the data, without advancing our offset into the data.
|
||||
func peekData<I:Integer>(_ n: I) -> Data? {
|
||||
let intN = Int(n.toIntMax())
|
||||
|
||||
if remaining < intN {
|
||||
func peekData<I:BinaryInteger>(_ n: I) -> Data? {
|
||||
if remaining < n {
|
||||
return nil
|
||||
}
|
||||
|
||||
return rest.subdata(in: 0..<intN)
|
||||
return rest.subdata(in: 0..<Int(n))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -723,7 +723,7 @@
|
|||
51F0900B1E37E8C600F03AD3 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = VEKTX9H2N7;
|
||||
LastSwiftMigration = 0820;
|
||||
LastSwiftMigration = 1000;
|
||||
ProvisioningStyle = Manual;
|
||||
SystemCapabilities = {
|
||||
com.apple.Keychain = {
|
||||
|
@ -734,7 +734,7 @@
|
|||
51F0901C1E37E8C600F03AD3 = {
|
||||
CreatedOnToolsVersion = 8.2.1;
|
||||
DevelopmentTeam = VEKTX9H2N7;
|
||||
LastSwiftMigration = 0820;
|
||||
LastSwiftMigration = 1000;
|
||||
ProvisioningStyle = Manual;
|
||||
TestTargetID = 51F0900B1E37E8C600F03AD3;
|
||||
};
|
||||
|
@ -751,12 +751,13 @@
|
|||
F738F4F01E4A2CCB005680A2 = {
|
||||
CreatedOnToolsVersion = 8.0;
|
||||
DevelopmentTeam = VEKTX9H2N7;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 1000;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
F738F52E1E4A2E8A005680A2 = {
|
||||
CreatedOnToolsVersion = 8.0;
|
||||
DevelopmentTeam = VEKTX9H2N7;
|
||||
LastSwiftMigration = 1000;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
F738F5591E4A31DE005680A2 = {
|
||||
|
@ -767,6 +768,7 @@
|
|||
F738F5701E4A3328005680A2 = {
|
||||
CreatedOnToolsVersion = 8.0;
|
||||
DevelopmentTeam = VEKTX9H2N7;
|
||||
LastSwiftMigration = 1000;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
|
@ -1132,7 +1134,8 @@
|
|||
PROVISIONING_PROFILE_SPECIFIER = SoftU2FTool;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SoftU2FTool/SoftU2F-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1155,7 +1158,8 @@
|
|||
PROVISIONING_PROFILE = "0d639ce7-4261-41e5-8e5d-8a39cdfc8c41";
|
||||
PROVISIONING_PROFILE_SPECIFIER = SoftU2FTool;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SoftU2FTool/SoftU2F-Bridging-Header.h";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -1177,7 +1181,8 @@
|
|||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SoftU2FToolTests/SoftU2FTests-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SoftU2F.app/Contents/MacOS/SoftU2F";
|
||||
};
|
||||
name = Debug;
|
||||
|
@ -1199,7 +1204,8 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SoftU2FToolTests/SoftU2FTests-Bridging-Header.h";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SoftU2F.app/Contents/MacOS/SoftU2F";
|
||||
};
|
||||
name = Release;
|
||||
|
@ -1286,7 +1292,8 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1313,7 +1320,8 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.github.APDU;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1330,7 +1338,8 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.APDUTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1345,7 +1354,8 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.APDUTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -1424,7 +1434,8 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.SelfSignedCertificateTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1439,7 +1450,8 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.SelfSignedCertificateTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
@ -31,10 +31,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
// Chrome ignores our U2F responses if it isn't active when we send them.
|
||||
// This hack should give focus back to Chrome immediately after the user interacts
|
||||
// with our notification.
|
||||
NSApplication.shared().hide(nil)
|
||||
NSApplication.shared.hide(nil)
|
||||
}
|
||||
|
||||
private func quit() {
|
||||
NSApplication.shared().terminate(self)
|
||||
NSApplication.shared.terminate(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,8 @@ class U2FAuthenticator {
|
|||
}
|
||||
|
||||
private var laptopIsOpen: Bool {
|
||||
guard let screens = NSScreen.screens() else { return true }
|
||||
|
||||
return screens.contains { screen in
|
||||
guard let screenID = screen.deviceDescription["NSScreenNumber"] as? uint32 else { return true }
|
||||
return NSScreen.screens.contains { screen in
|
||||
guard let screenID = convertFromNSDeviceDescriptionKeyDictionary(screen.deviceDescription)["NSScreenNumber"] as? uint32 else { return true }
|
||||
return CGDisplayIsBuiltin(screenID) == 1
|
||||
}
|
||||
}
|
||||
|
@ -214,3 +212,8 @@ class U2FAuthenticator {
|
|||
let _ = u2fhid.sendMsg(cid: cid, data: msg.raw)
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function inserted by Swift 4.2 migrator.
|
||||
fileprivate func convertFromNSDeviceDescriptionKeyDictionary(_ input: [NSDeviceDescriptionKey: Any]) -> [String: Any] {
|
||||
return Dictionary(uniqueKeysWithValues: input.map {key, value in (key.rawValue, value)})
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче