Closed tiro-reflact closed 5 months ago
We figured out what was wrong:
We are storing the device in a MongoDB and authenticator.credentialPublicKey needs to be converted to Binary before storing. Afterwards you need to convert it back to a Uint8Array and then it works. Otherwise the data is corrupted.
//before storing
credentialPublicKey: new Binary(credentialPublicKey)
//after query
credentialPublicKey = new Uint8Array(credentialPublicKey.buffer)
To try and connect some dots here, this seems related to the following discussion where this same issue is solved in a similar manner:
MongoDB Authenticator types: Discussion https://github.com/MasterKale/SimpleWebAuthn/discussions/375
Note to self if this comes up again: I wonder if there's something I can do here to help out MongoDB users...
It happened again: someone else suffered something that looks suspiciously like this issue. While I await their confirmation that @tiro-reflact's post above is the solution for them too, I went ahead and codified the solution here into the docs:
https://simplewebauthn.dev/docs/packages/server#error-no-data
Hi @MasterKale , what should be the type of the credentialPublicKey . I did not use mongoDB..but still getting the same "Error: No data". I debugged the verifyAuthenticationResponse call..and the code reaches till the last method..which is verifySignature().And we use signature, data: signatureBase, credentialPublicKey: authenticator.credentialPublicKey . That's why I suspect there might be an type mismatch here from my side.
@jai-charan credentialPublicKey
should be of type Uint8Array
; in a Node project Buffer
should be okay too since last I checked it's a subclass of Uint8Array
.
If i have it as Uint8Array....then the value pf public key become undefined inside verifyAuthenticatorResponse.Only of type base64url.. I'm able to log the values in the verifyAuthenticatorResponse()
Hmm, at this point I'm going to need to see some code and inputs to help further. Include what you're getting out of the DB too please (there's no PII in credential ID or public key if that helps alleviate concerns about sharing those.)
Describe the issue
Hello! We are trying to implement Passkey's using this library. We followed the implementation described here: https://simplewebauthn.dev/docs/packages/server#2-verify-authentication-response When executing the function verifyAuthenticationResponse we get the following error:
This is what's inside the body of your request from the client: https://debugger.simplewebauthn.dev -> With Body
This is how we execute the function: "body" contains the Object from the debugger link above (We already checked, that every other param is set the correct way)
Dependencies
SimpleWebAuthn Libraries