Open Ben-Lichtman opened 2 months ago
Hi @Ben-Lichtman, the issue here is the use of ArrayBuffer
by the webauthn types which is readonly memory. When trying to serialize to JSON
it will automatically "drop" the value and replace it with an empty object. To get around this you need to either re-map the array buffer to an array or a base64url string. OR remap it directly from the web_sys
/js_sys
types. Perhaps wasm_bindgen_serde
could help with this but I haven't tested it.
I would like to one day build wasm dedicated library for the passkey
crates, but thats a fairly heavy lift that I currently don't really have time for. We alway welcome contributions.
@Progdrasil I'm a little confused - isn't the deserialization though JsValueSerdeExt (via gloo) designed to do exactly that (remap from the web_sys type into your PublicKeyCredential type)?
It would make sense to me that the answer would be to change the Deserialize implementation on Bytes to handle visit_map?
Please let me know if I'm misunderstanding.
JsValueSerdeExt
does not. It uses the JSON.stringify
method internally which transforms it to an empty map. See this JSFiddle as an example. Implementing visit_map
will not help since the value will be lost by stringifying the array buffer and that map will be empty.
Trying to implement webauthn on the browser, which includes deserializing the browser's response to the message into a
passkey_types::webauthn::CreatedPublicKeyCredential
/passkey_types::webauthn::PublicKeyCredential
, however it seems that theraw_id
field ofPublicKeyCredential
is allowed to be{}
when returned from the browser, which causes the deserialization to return an error.