mirror of
https://github.com/bitwarden/browser
synced 2024-12-27 10:23:48 +01:00
Change biometric prompt to use the same logic as electron (#1805)
* Change biometric prompt to use the same logic as electron
This commit is contained in:
parent
cbe4be59d4
commit
5bf10376a8
@ -85,7 +85,9 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
|
||||
var error: NSError?
|
||||
let laContext = LAContext()
|
||||
|
||||
guard laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
|
||||
laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
|
||||
|
||||
if let e = error, e.code != kLAErrorBiometryLockout {
|
||||
response.userInfo = [
|
||||
SFExtensionMessageKey: [
|
||||
"message": [
|
||||
@ -95,10 +97,22 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
|
||||
],
|
||||
],
|
||||
]
|
||||
break;
|
||||
break
|
||||
}
|
||||
|
||||
laContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Bitwarden Safari Extension") { (success, error) in
|
||||
guard let accessControl = SecAccessControlCreateWithFlags(nil, kSecAttrAccessibleWhenUnlockedThisDeviceOnly, [.privateKeyUsage, .userPresence], nil) else {
|
||||
response.userInfo = [
|
||||
SFExtensionMessageKey: [
|
||||
"message": [
|
||||
"command": "biometricUnlock",
|
||||
"response": "not supported",
|
||||
"timestamp": Int64(NSDate().timeIntervalSince1970 * 1000),
|
||||
],
|
||||
],
|
||||
]
|
||||
break
|
||||
}
|
||||
laContext.evaluateAccessControl(accessControl, operation: .useKeySign, localizedReason: "Bitwarden Safari Extension") { (success, error) in
|
||||
if success {
|
||||
let passwordName = "key"
|
||||
var passwordLength: UInt32 = 0
|
||||
@ -134,7 +148,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
|
||||
context.completeRequest(returningItems: [response], completionHandler: nil)
|
||||
}
|
||||
|
||||
return;
|
||||
return
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user