|
@@ -25,6 +25,9 @@
|
|
|
|
|
|
import Foundation
|
|
import Foundation
|
|
import Security
|
|
import Security
|
|
|
|
+#if os(iOS) || os(OSX)
|
|
|
|
+import LocalAuthentication
|
|
|
|
+#endif
|
|
|
|
|
|
public let KeychainAccessErrorDomain = "com.kishikawakatsumi.KeychainAccess.error"
|
|
public let KeychainAccessErrorDomain = "com.kishikawakatsumi.KeychainAccess.error"
|
|
|
|
|
|
@@ -389,11 +392,12 @@ public final class Keychain {
|
|
return options.authenticationPrompt
|
|
return options.authenticationPrompt
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #if os(iOS) || os(OSX)
|
|
@available(iOS 9.0, OSX 10.11, *)
|
|
@available(iOS 9.0, OSX 10.11, *)
|
|
- @available(watchOS, unavailable)
|
|
|
|
- public var authenticationContext: Any? {
|
|
|
|
- return options.authenticationContext
|
|
|
|
|
|
+ public var authenticationContext: LAContext? {
|
|
|
|
+ return options.authenticationContext as? LAContext
|
|
}
|
|
}
|
|
|
|
+ #endif
|
|
|
|
|
|
fileprivate let options: Options
|
|
fileprivate let options: Options
|
|
|
|
|
|
@@ -495,13 +499,14 @@ public final class Keychain {
|
|
return Keychain(options)
|
|
return Keychain(options)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #if os(iOS) || os(OSX)
|
|
@available(iOS 9.0, OSX 10.11, *)
|
|
@available(iOS 9.0, OSX 10.11, *)
|
|
- @available(watchOS, unavailable)
|
|
|
|
- public func authenticationContext(_ authenticationContext: Any) -> Keychain {
|
|
|
|
|
|
+ public func authenticationContext(_ authenticationContext: LAContext) -> Keychain {
|
|
var options = self.options
|
|
var options = self.options
|
|
options.authenticationContext = authenticationContext
|
|
options.authenticationContext = authenticationContext
|
|
return Keychain(options)
|
|
return Keychain(options)
|
|
}
|
|
}
|
|
|
|
+ #endif
|
|
|
|
|
|
// MARK:
|
|
// MARK:
|
|
|
|
|
|
@@ -1064,7 +1069,7 @@ struct Options {
|
|
var comment: String?
|
|
var comment: String?
|
|
|
|
|
|
var authenticationPrompt: String?
|
|
var authenticationPrompt: String?
|
|
- var authenticationContext: Any?
|
|
|
|
|
|
+ var authenticationContext: AnyObject?
|
|
|
|
|
|
var attributes = [String: Any]()
|
|
var attributes = [String: Any]()
|
|
}
|
|
}
|
|
@@ -1201,7 +1206,7 @@ extension Options {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- #if os(iOS) || os(macOS)
|
|
|
|
|
|
+ #if !os(watchOS)
|
|
if #available(iOS 9.0, OSX 10.11, *) {
|
|
if #available(iOS 9.0, OSX 10.11, *) {
|
|
if authenticationContext != nil {
|
|
if authenticationContext != nil {
|
|
query[UseAuthenticationContext] = authenticationContext
|
|
query[UseAuthenticationContext] = authenticationContext
|