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

Conversation

timcappalli
Copy link
Member

@timcappalli timcappalli commented Oct 8, 2024

Closes #125

The following tasks have been completed:

  • Modified Web platform tests (link)

Implementation commitment:

  • WebKit (link to issue)
  • Chromium (link to issue)
  • Gecko (link to issue)

Documentation and checks

  • Affects privacy
  • Affects security
  • Pinged MDN
  • Updated Explainer

Preview | Diff

index.html Outdated Show resolved Hide resolved
index.html Outdated
Comment on lines 314 to 316
<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?

Copy link
Collaborator

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

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

Couple of small things...

@marcoscaceres marcoscaceres changed the title Require JSON Types Require JSON serialization checks "in and out" Oct 21, 2024
index.html Outdated Show resolved Hide resolved
@marcoscaceres
Copy link
Collaborator

@timcappalli, see also #179 (comment)

Co-authored-by: Marcos Cáceres <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[spec] DigitalCredentialRequestOptions and DigitalCredential objects must be JSON serializable
3 participants