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

Require JSON serialization checks "in and out" #179

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ <h3>
the [=digital credential/request data=] to be handled by the holder's
software, such as a digital wallet.
</p>
<p>
The object MUST only contain [=JSON type=] values.
</p>
timcappalli marked this conversation as resolved.
Show resolved Hide resolved
<h2>
The `DigitalCredential` interface
</h2>
Expand All @@ -252,6 +255,7 @@ <h2>
<pre class="idl">
[Exposed=Window, SecureContext]
interface DigitalCredential : Credential {
[Default] object toJSON();
readonly attribute DOMString protocol;
readonly attribute object data;
};
Expand Down Expand Up @@ -307,6 +311,9 @@ <h3>
</li>
<li>If |requests| is empty, [=exception/throw=] a {{TypeError}}.
</li>
<li>If |requests| does not contain [=JSON type=] values,
[=exception/throw=] a {{TypeError}}.
</li>
Copy link
Collaborator

@marcoscaceres marcoscaceres Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not right here... you need to:

  1. [=List/for each=] |request| of |requests|:
    1.1. [=serialize a JavaScript value to a JSON string|Serialize=] |request| a to a JSON string. Rethrow any exceptions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timcappalli, we also would need this on the way out, when readonly attribute object data; is set... though there might not be enough spec text in the current spec to add this right now. However, it would be good to add something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readonly attribute object data

The benefit of also doing this on the way back is that we could make this integrate well with fetch() ... arguably, we could also this in a separate PR ...

This is not right here... you need to:

Yeah, we'd still want to do this, I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also would need this on the way out, when readonly attribute object data; is set... though there might not be enough spec text in the current spec to add this right now. However, it would be good to add something.

@marcoscaceres @samuelgoto isn't this already covered by using the default toJSON() method?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is because if the wallet returns some bogus value that is not a JSON object (e.g., a string, or a number, will TypeError at this point), then that can't map to .data (because it's required to be an object). Thus you need to JSON parse the response before it is stored in .data... then the developer calling .toJSON() walks both the DigitalCredential instance and the . data. structure.

Make sense?

<li>
<aside class="issue">
Details of how to actually get the [=digital credential=] are
Expand Down