github / webauthn-json

🔏 A small WebAuthn API wrapper that translates to/from pure JSON using base64url.
https://github.github.com/webauthn-json/demo/
MIT License
757 stars 60 forks source link

Officially expose `getClientExtensionResults()` #5

Closed lgarron closed 4 years ago

lgarron commented 5 years ago

Right now, we happen to copy the full extensions field:

https://github.com/github/webauthn-json/blob/master/src/webauthn-schema.ts#L30 https://github.com/github/webauthn-json/blob/master/src/webauthn-schema.ts#L58

This allows getClientExtensionResults() to work. If we ever deconstruct extensions in order to convert a binary field, we need to give an alternative way to expose this.

lgarron commented 5 years ago

Oh, seems I actually misunderstood this. getClientExtensionResults() is defined directly on PublicKeyCredential.

https://www.w3.org/TR/webauthn/#iface-pkcredential

We can't call the PublicKeyCredential constructor directly, so one option would be to proxy getClientExtensionResults in the prototype of the returned object.

Another alternative would be to expose the function through another channel, e.g. a callback, or an argument passed by reference. It would be nice to avoid changing the API shape any more than necessary, though.

lgarron commented 5 years ago

Based on talking to Googlers, I learned that this is a function (instead of being a field on the returned PublicKeyCredential) purely because of WebIDL quirks. In fact, it was originally defined as a clientExtensionResults field.

https://github.com/w3c/webauthn/pull/633/files

Based on talking to them, there is no reason to expect functionality or performance issues with calling getClientExtensionResults() every time, so I'm going to modify webauthn-json to do this.

lgarron commented 5 years ago

I'd like to avoid doing this in the default build, since it makes the library larger for everyone who doesn't need it. It should be possible to make an additional build for this.

lgarron commented 4 years ago

I'd like to avoid doing this in the default build, since it makes the library larger for everyone who doesn't need it. It should be possible to make an additional build for this.

Shipped in v0.4.1 under @github/webauthn-json/extended (implemented in de9d7a3d008ea081565e907928422bc69ba46c69).