Skip to content

Require JSON serialization checks coming in#179

Merged
marcoscaceres merged 12 commits into
mainfrom
tc-125-json
Jul 2, 2025
Merged

Require JSON serialization checks coming in#179
marcoscaceres merged 12 commits into
mainfrom
tc-125-json

Conversation

@timcappalli

@timcappalli timcappalli commented Oct 8, 2024

Copy link
Copy Markdown
Collaborator

Closes #125

The following tasks have been completed:

Implementation commitment:

Documentation and checks

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

Preview | Diff

Comment thread index.html
Comment thread index.html Outdated
Comment on lines +314 to +316
<li>If |requests| does not contain [=JSON type=] values,
[=exception/throw=] a {{TypeError}}.
</li>

@marcoscaceres marcoscaceres Oct 11, 2024

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Collaborator 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
Copy Markdown
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?

@marcoscaceres marcoscaceres left a comment

Copy link
Copy Markdown
Collaborator

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
timcappalli and others added 2 commits October 29, 2024 06:13
Co-authored-by: Marcos Cáceres <marcosc@apple.com>
Comment thread index.html Outdated
@marcoscaceres

Copy link
Copy Markdown
Collaborator

@timcappalli, see also #179 (comment)

Co-authored-by: Marcos Cáceres <marcosc@apple.com>
@marcoscaceres marcoscaceres changed the title Require JSON serialization checks "in and out" Require JSON serialization checks coming in Jan 15, 2025
@marcoscaceres

Copy link
Copy Markdown
Collaborator

Blocked on tests and browser bugs.

@marcoscaceres

Copy link
Copy Markdown
Collaborator

Blocked on tests.

@marcoscaceres marcoscaceres requested a review from a team as a code owner June 16, 2025 01:39
Comment thread index.html Outdated

@mohamedamir mohamedamir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks nice!
Thank you!

@marcoscaceres

Copy link
Copy Markdown
Collaborator

Still blocked on a test.

@marcoscaceres

Copy link
Copy Markdown
Collaborator

Implemented in WebKit and sent over a test.

@marcoscaceres marcoscaceres merged commit 10245d9 into main Jul 2, 2025
@marcoscaceres marcoscaceres deleted the tc-125-json branch July 2, 2025 03:19
webkit-commit-queue pushed a commit to marcoscaceres/WebKit that referenced this pull request Jul 3, 2025
…terface

https://bugs.webkit.org/show_bug.cgi?id=295018
rdar://problem/154733737

Reviewed by Abrar Rahman Protyasha.

Spec change:
w3c-fedid/digital-credentials#179

* Adds a default `toJSON()` method to the `DigitalCredential` interface.
* Adds JSON strinfication check for incoming request, as required by the spec.

Canonical link: https://commits.webkit.org/296963@main
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

4 participants