Re: [webauthn] PRF inputs should be BufferSource instead of ArrayBuffer (#1851)

Hm, I see:

```webidl
typedef (ArrayBufferView or ArrayBuffer) BufferSource;
typedef (Int8Array or Int16Array or Int32Array or
         Uint8Array or Uint16Array or Uint32Array or Uint8ClampedArray or
         BigInt64Array or BigUint64Array or
         Float32Array or Float64Array or DataView) ArrayBufferView;
```

But...

> the underlying object will still be an `ArrayBuffer`. E.g.:
> 
> > > temp1.getClientExtensionResults().prf.results.first instanceof ArrayBuffer
> > > true

I don't get the same results in Chrome (110.0.5481.77) or Firefox (109.0.1):

```js
> new Uint8Array().buffer instanceof ArrayBuffer
true

> new Uint8Array() instanceof ArrayBuffer
false
```

and indeed, I can't find `ArrayBuffer` in the prototype hierarchy of `Uint8Array` either.

But on the other hand... in order to work with an `ArrayBuffer` (i.e., to base64-encode it) you'll most likely convert it to `Uint8Array` first, and the `Uint8Array` constructor accepts both `ArrayBuffer` as well as any `TypedArray`. You can just `new Uint8Array(prf.results.first)` and that will always work. So in that sense `BufferSource` is "Liskov substitution compatible" with `ArrayBuffer`, even though it's not formally a subtype.

So ok, yeah, I guess we could go either way. I do agree with not splitting the IDL just for this. It seems a bit inappropriate to use a union type for output, but I agree that `BufferSource` output seems less likely to trip people up than `ArrayBuffer` inputs.

So ok, this will be fixed by 5ebc25721158cc45a985e171121911da87d64994. Thanks!

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


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

Received on Wednesday, 15 February 2023 12:52:19 UTC