Skip to content

Commit 86feba5

Browse files
committed
Add cancel button to example app
1 parent 0b257e9 commit 86feba5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

LibFido2TestApp/ContentView.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SwiftUI
99
import LibFido2Swift
1010

1111
struct ContentView: View {
12+
let fido2 = FIDO2()
1213
@AppStorage("challengeUrl") var challengeUrl = ""
1314
@AppStorage("rpId") var rpId = ""
1415
@AppStorage("validCreds") var validCreds = ""
@@ -23,13 +24,18 @@ struct ContentView: View {
2324
TextField("Valid Credentials (comma separated)", text: $validCreds)
2425
TextField("Origin", text: $origin)
2526
TextField("Device Pin", text: $devicePin)
26-
Button("FIDO") {
27-
do {
28-
try fido()
29-
} catch {
30-
print(error)
27+
Button("Get Assertion") {
28+
DispatchQueue.global().async {
29+
do {
30+
try fido()
31+
} catch {
32+
print(error)
33+
}
3134
}
3235
}
36+
Button("Cancel") {
37+
fido2.cancel()
38+
}
3339
}
3440
VStack {
3541
Text("Response:")
@@ -44,7 +50,6 @@ struct ContentView: View {
4450
}
4551

4652
func fido() throws {
47-
let fido2 = FIDO2()
4853
let validCredsArray = validCreds.split(separator: ",").map { String($0) }
4954
let response = try fido2.respondToChallenge(args: ChallengeArgs(rpId: rpId,
5055
validCredentials: validCredsArray,

0 commit comments

Comments
 (0)