mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-10 17:47:19 +00:00
Remove pending.
This commit is contained in:
parent
80a2bd42a3
commit
971f831a2f
@ -17,7 +17,6 @@ extension SecureEnclave {
|
|||||||
public let name = NSLocalizedString("Secure Enclave", comment: "Secure Enclave")
|
public let name = NSLocalizedString("Secure Enclave", comment: "Secure Enclave")
|
||||||
@Published public private(set) var secrets: [Secret] = []
|
@Published public private(set) var secrets: [Secret] = []
|
||||||
|
|
||||||
private var pendingAuthenticationContext: PersistentAuthenticationContext? = nil
|
|
||||||
private var persistedAuthenticationContexts: [Secret: PersistentAuthenticationContext] = [:]
|
private var persistedAuthenticationContexts: [Secret: PersistentAuthenticationContext] = [:]
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
@ -103,7 +102,6 @@ extension SecureEnclave {
|
|||||||
} else {
|
} else {
|
||||||
let newContext = LAContext()
|
let newContext = LAContext()
|
||||||
newContext.localizedCancelTitle = "Deny"
|
newContext.localizedCancelTitle = "Deny"
|
||||||
pendingAuthenticationContext = PersistentAuthenticationContext(secret: secret, context: newContext, expiration: Date(timeIntervalSinceNow: Constants.authenticationPersistenceOptInWindow))
|
|
||||||
context = newContext
|
context = newContext
|
||||||
}
|
}
|
||||||
context.localizedReason = "sign a request from \"\(provenance.origin.displayName)\" using secret \"\(secret.name)\""
|
context.localizedReason = "sign a request from \"\(provenance.origin.displayName)\" using secret \"\(secret.name)\""
|
||||||
@ -144,17 +142,11 @@ extension SecureEnclave {
|
|||||||
let newContext = LAContext()
|
let newContext = LAContext()
|
||||||
newContext.localizedCancelTitle = "Deny"
|
newContext.localizedCancelTitle = "Deny"
|
||||||
newContext.localizedReason = "sign requests without reprompting"
|
newContext.localizedReason = "sign requests without reprompting"
|
||||||
newContext.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometricsOrWatch, localizedReason: newContext.localizedReason) { x, y in
|
newContext.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometricsOrWatch, localizedReason: newContext.localizedReason) { [weak self] success, _ in
|
||||||
print(x, y)
|
let context = PersistentAuthenticationContext(secret: secret, context: newContext, expiration: Date(timeIntervalSinceNow: duration))
|
||||||
|
self?.persistedAuthenticationContexts[secret] = context
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let pending = pendingAuthenticationContext,
|
|
||||||
secret == pending.secret,
|
|
||||||
pending.valid
|
|
||||||
else { throw AuthenticationPersistenceExpiredError() }
|
|
||||||
let rewrapped = PersistentAuthenticationContext(secret: secret, context: newContext, expiration: Date(timeIntervalSinceNow: duration))
|
|
||||||
persistedAuthenticationContexts[secret] = rewrapped
|
|
||||||
pendingAuthenticationContext = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -224,8 +216,6 @@ extension SecureEnclave {
|
|||||||
public let error: SecurityError?
|
public let error: SecurityError?
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct AuthenticationPersistenceExpiredError: Error {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SecureEnclave {
|
extension SecureEnclave {
|
||||||
|
Loading…
Reference in New Issue
Block a user