mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-09-20 03:10:57 +00:00
Persist auth async
This commit is contained in:
parent
720ae72beb
commit
7ae52ef482
@ -182,7 +182,7 @@ extension SecureEnclave {
|
|||||||
return persisted
|
return persisted
|
||||||
}
|
}
|
||||||
|
|
||||||
public func persistAuthentication(secret: Secret, forDuration duration: TimeInterval) throws {
|
public func persistAuthentication(secret: Secret, forDuration duration: TimeInterval) async throws {
|
||||||
let newContext = LAContext()
|
let newContext = LAContext()
|
||||||
newContext.touchIDAuthenticationAllowableReuseDuration = duration
|
newContext.touchIDAuthenticationAllowableReuseDuration = duration
|
||||||
newContext.localizedCancelTitle = String(localized: "auth_context_request_deny_button")
|
newContext.localizedCancelTitle = String(localized: "auth_context_request_deny_button")
|
||||||
@ -196,14 +196,12 @@ extension SecureEnclave {
|
|||||||
} else {
|
} else {
|
||||||
newContext.localizedReason = String(localized: "auth_context_persist_for_duration_unknown_\(secret.name)")
|
newContext.localizedReason = String(localized: "auth_context_persist_for_duration_unknown_\(secret.name)")
|
||||||
}
|
}
|
||||||
newContext.evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: newContext.localizedReason) { [weak self] success, _ in
|
guard try await newContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: newContext.localizedReason) else { return }
|
||||||
guard success, let self else { return }
|
|
||||||
let context = PersistentAuthenticationContext(secret: secret, context: newContext, duration: duration)
|
let context = PersistentAuthenticationContext(secret: secret, context: newContext, duration: duration)
|
||||||
self.persistedAuthenticationContexts.withLock {
|
self.persistedAuthenticationContexts.withLock {
|
||||||
$0[secret] = context
|
$0[secret] = context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public func reloadSecrets() async {
|
public func reloadSecrets() async {
|
||||||
await reloadSecretsInternal(notifyAgent: false)
|
await reloadSecretsInternal(notifyAgent: false)
|
||||||
|
Loading…
Reference in New Issue
Block a user