Make fido2 property a lazy var

- This object was being kept around after being created and as we need it in some other functions it made sense to make it lazy and keep it around that way.
- Arguably the FIDO2 instance could be removed after each time it’s been used, but as the FIDO2 class doesn’t have any state stored in it, it seems benign keeping it about for now.
This commit is contained in:
Edgar Story 2024-11-12 09:08:26 +00:00
parent 3d9cf73fc1
commit 36424a78e0
No known key found for this signature in database
GPG key ID: E808B9DE966FFDDA

View file

@ -355,8 +355,8 @@ class AppState: ObservableObject {
.store(in: &cancellables)
}
var fido2: FIDO2?
private lazy var fido2 = FIDO2()
func createAndSubmitSecurityKeyAssertationWithPinCode(_ pinCode: String?, sessionData: AppleSessionData, authOptions: AuthOptionsResponse) {
self.presentedSheet = .securityKeyTouchToConfirm
@ -379,8 +379,6 @@ class AppState: ObservableObject {
Task {
do {
let fido2 = FIDO2()
self.fido2 = fido2
let response = try fido2.respondToChallenge(args: ChallengeArgs(rpId: rpId, validCredentials: validCreds, devPin: pinCode, challenge: challenge, origin: origin))
Task { @MainActor in
@ -413,7 +411,7 @@ class AppState: ObservableObject {
}
func cancelSecurityKeyAssertationRequest() {
self.fido2?.cancel()
self.fido2.cancel()
}
private func handleAuthenticationFlowCompletion(_ completion: Subscribers.Completion<Error>) {