Re: [webauthn] Define `TypeError` behavior during `.get()` (#2094)

I reckon this is inherited from the JavaScript-to-WebIDL language bindings? See for example the conversion routine for dictionary types (which include [`PublicKeyCredentialCreationOptions`](https://w3c.github.io/webauthn/#dictionary-makecredentialoptions) and [`PublicKeyCredentialRequestOptions`](https://w3c.github.io/webauthn/#dictionary-assertion-options)):

>**3.2.17. Dictionary types**
>[...]
>A JavaScript value _jsDict_ is [converted](https://webidl.spec.whatwg.org/#dfn-convert-ecmascript-to-idl-value) to an IDL [dictionary type](https://webidl.spec.whatwg.org/#idl-dictionary) value by running the following algorithm (where _D_ is the [dictionary type](https://webidl.spec.whatwg.org/#idl-dictionary)):
>
>1. If [Type](https://tc39.es/ecma262/#sec-ecmascript-data-types-and-values)(_jsDict_) is not Undefined, Null or Object, then [throw](https://webidl.spec.whatwg.org/#javascript-throw) a [`TypeError`](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-native-error-types-used-in-this-standard-typeerror).
>[...]
>4.1.3.1. Let _idlMemberValue_ be the result of [converting](https://webidl.spec.whatwg.org/#dfn-convert-ecmascript-to-idl-value) _jsMemberValue_ to an IDL value whose type is the type _member_ is declared to be of.
> [...]
>4.1.5. Otherwise, if _jsMemberValue_ is **undefined** and _member_ is [required](https://webidl.spec.whatwg.org/#required-dictionary-member), then throw a [`TypeError`](https://webidl.spec.whatwg.org/#exceptiondef-typeerror).

We don't explicitly state in the WebAuthn spec that this conversion must occur, but it clearly must since the API is defined in WebIDL and the actual implementation is exposed in JavaScript. See also:

>[§3.2. JavaScript type mapping](https://webidl.spec.whatwg.org/#js-type-mapping)
>[...]
>[...] For each IDL type, it is described how JavaScript values are converted to an IDL value when passed to a [platform object](https://webidl.spec.whatwg.org/#dfn-platform-object) expecting that type, [...]

>[§2.12. Objects implementing interfaces](https://webidl.spec.whatwg.org/#idl-objects)
>[...]
>**Platform objects** are objects that implement an [interface](https://webidl.spec.whatwg.org/#dfn-interface).

...which would for example include the [`PublicKeyCredential`](https://w3c.github.io/webauthn/#iface-pkcredential) interface.

I'm in favour of #2047 mentioning that `TypeError` is one of the errors RPs may expect, but I don't think WebAuthn needs to explicitly define how these particular `TypeError`s should be thrown - I figure that should be handled by WebIDL already.

-- 
GitHub Notification of comment by emlun
Please view or discuss this issue at https://github.com/w3c/webauthn/issues/2094#issuecomment-2218924582 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 9 July 2024 23:13:23 UTC