Skip to content

Commit 36424a7

Browse files
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.
1 parent 3d9cf73 commit 36424a7

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

Xcodes/Backend/AppState.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ class AppState: ObservableObject {
355355
.store(in: &cancellables)
356356
}
357357

358-
var fido2: FIDO2?
359-
358+
private lazy var fido2 = FIDO2()
359+
360360
func createAndSubmitSecurityKeyAssertationWithPinCode(_ pinCode: String?, sessionData: AppleSessionData, authOptions: AuthOptionsResponse) {
361361
self.presentedSheet = .securityKeyTouchToConfirm
362362

@@ -379,8 +379,6 @@ class AppState: ObservableObject {
379379

380380
Task {
381381
do {
382-
let fido2 = FIDO2()
383-
self.fido2 = fido2
384382
let response = try fido2.respondToChallenge(args: ChallengeArgs(rpId: rpId, validCredentials: validCreds, devPin: pinCode, challenge: challenge, origin: origin))
385383

386384
Task { @MainActor in
@@ -413,7 +411,7 @@ class AppState: ObservableObject {
413411
}
414412

415413
func cancelSecurityKeyAssertationRequest() {
416-
self.fido2?.cancel()
414+
self.fido2.cancel()
417415
}
418416

419417
private func handleAuthenticationFlowCompletion(_ completion: Subscribers.Completion<Error>) {

0 commit comments

Comments
 (0)