Skip to content

Commit d14566f

Browse files
author
Carlos Cabanero
committed
WebAuthn with extra logging for the flow
1 parent fb6a4bb commit d14566f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

BlinkConfig/WebAuthnKey.swift

+12-2
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,22 @@ extension WebAuthnKey: Signer {
114114
self.log?.message("WebAuthn Controller called to perform request.", .debug)
115115
return self.signaturePub!
116116
}
117+
.handleEvents(receiveCancel: {
118+
self.log?.message("WebAuthn signature publisher cancelled", .debug)
119+
})
117120
.sink(receiveCompletion: { completion in
121+
self.log?.message("WebAuthn received signature publisher completed with \(completion)", .debug)
118122
switch completion {
119123
case .failure(let err):
120124
error = err
121125
case .finished:
122126
break
123127
}
124128
semaphore.signal()
125-
}, receiveValue: { signature = $0 })
129+
}, receiveValue: { sig in
130+
self.log?.message("WebAuthn signature received.", .debug)
131+
signature = sig
132+
})
126133

127134
self.log?.message("WebAuthn Controller awaiting response.", .debug)
128135
semaphore.wait()
@@ -151,7 +158,9 @@ extension WebAuthnKey: ASAuthorizationControllerDelegate, ASAuthorizationControl
151158
let credentialAssertion = authorization.credential as? ASAuthorizationPublicKeyCredentialAssertion,
152159
let rawSignature = credentialAssertion.signature
153160
else {
154-
return signaturePub.send(completion: .failure(WebAuthnError.signatureError("Unexpected operation")))
161+
self.log?.message("WebAuthn Controller unexpected operation received.", .warn)
162+
signaturePub.send(completion: .failure(WebAuthnError.signatureError("Unexpected operation")))
163+
return
155164
}
156165

157166
let rawClientData = credentialAssertion.rawClientDataJSON
@@ -164,6 +173,7 @@ extension WebAuthnKey: ASAuthorizationControllerDelegate, ASAuthorizationControl
164173

165174
// TODO We should validate the CredentialID, to be sure we signed with the proper key,
166175
// before we fail or ask the user to retry.
176+
self.log?.message("WebAuthn Controller sending signature", .debug)
167177
signaturePub.send(webAuthnSig)
168178
signaturePub.send(completion: .finished)
169179
}

0 commit comments

Comments
 (0)