Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What should be the data type for the response? #119

Closed
samuelgoto opened this issue Jun 5, 2024 · 3 comments · Fixed by #141
Closed

What should be the data type for the response? #119

samuelgoto opened this issue Jun 5, 2024 · 3 comments · Fixed by #141
Labels

Comments

@samuelgoto
Copy link
Collaborator

samuelgoto commented Jun 5, 2024

What should be the WebIDL data type for the DigitalCredential.data response?

This is currently returning any (to keep Safari and Chrome's implementation interoperable), but we should probably be more specific than that.

A few options that occurred to us:

  • An Uint8Array
  • A DOMString (what WebOTP uses)
  • An USVString (what FedCM uses -- as opposed to a DOMString it can take UTF-8, e.g. application/json, guidance from TAG here and here),
  • An ArrayBuffer (what WebAuthn is using, but also apparently discouraged)
  • A Blob, which has a text() and bytes() methods (thanks to Joshua Bell for bringing up this suggestion!).
  • object if everything can be JSON.parse()-able

It is not clear to me what are the trade-offs between these options (mostly ergonomics? or are there security trade-offs here?) nor what the requirements are (e.g. do we need to support passing back binary or non-JSON response's data?), so this issue here is intended to try to collect requirements and help us figure out what's best to use.

@marcoscaceres FYI

@marcoscaceres
Copy link
Collaborator

marcoscaceres commented Jun 6, 2024

Use of ArrayBuffer is discouraged (unless there's a good reason), so probably a Uint8Array.

See also: #93 and w3ctag/design-principles#463

However, before we settle on something, we need to make sure we fully understand what wallets are going to be returning.

There's also some overlap with #95 cc @timcappalli

@samuelgoto
Copy link
Collaborator Author

samuelgoto commented Jun 21, 2024

However, before we settle on something, we need to make sure we fully understand what wallets are going to be returning.

Yeah, agreed that this is the key question. The main question I have on my mind is whether wallets are going to be returning bytes or strings (e.g. text/json). I'm assuming wallets are going to be returning small payloads, so we don't need streams.

So, to narrow down the options here, I think we have to decide between a USVString (assumes text) and an Uint8Array (assumes bytes), which I think comes down to a trade-off between ergonomics (strings are easier to use) and expressivity (bytes can represent binary sequences).

We should also probably find a way to avoid cornering ourselves doing something that is forwards compatible if we wanted to change the type later.

@samuelgoto
Copy link
Collaborator Author

In the CG call today we converged as a group that object is the preferred direction, since:

  • we heard from @Sakurann that everything coming back from OpenID4VP would be JSON-serializable, so doesn't have to be Uint8Array,
  • If text can be assumed, object is more specific than DOMString and USVString, as JSON-parseable text

We heard from Lee that the cross-device hybrid/ctap structure also assume that the response can be JSON-parseable/stringifiable, so this aligns well.

@marcoscaceres and I will work towards patching the spec to specify that the response data is of type object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants