Skip to content

Define "prepare credential requests" algorithm#420

Open
marcoscaceres wants to merge 3 commits intomainfrom
prepare
Open

Define "prepare credential requests" algorithm#420
marcoscaceres wants to merge 3 commits intomainfrom
prepare

Conversation

@marcoscaceres
Copy link
Collaborator

@marcoscaceres marcoscaceres commented Dec 16, 2025

Added the "prepare credential requests" algorithm, detailing validation of each request, handling of unsupported protocols, error propagation, and abort signal integration.

Closes #432
Closes #249
Closes #220
Closes #207
Closes #159

The following tasks have been completed:

  • Modified Web platform tests

Implementation commitment:

Documentation and checks

  • Affects privacy
  • Affects security
  • Pinged MDN
  • Updated Explainer
  • Updated digitalcredentials.dev

Preview | Diff

@marcoscaceres
Copy link
Collaborator Author

Blocked on tests.

webkit-commit-queue pushed a commit to marcoscaceres/WebKit that referenced this pull request Jan 20, 2026
…if AbortSignal races with picker result

rdar://163295172
https://bugs.webkit.org/show_bug.cgi?id=305363

Reviewed by Pascoe.

Fix race and crash in CredentialRequestCoordinator by settling promises only after picker teardown and safely handling abort reasons.
Ensure credential requests always settle after the picker UI has fully torn down.

This change:

- Defers promise settlement until the picker dismiss callback fires
- Better handles aborts during presentation and teardown
- Avoids capturing unprotected JSValues across async boundaries
- Keeps coordinator state transitions more consistent (with better checks)

It also more closely follows the spec:
w3c-fedid/digital-credentials#420
w3c-fedid/digital-credentials#419

* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/get.tentative.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/non-fully-active.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/non-fully-active.https.html:
* Source/WebCore/Modules/identity/CredentialRequestCoordinator.cpp:
(WebCore::CredentialRequestCoordinator::PickerStateGuard::PickerStateGuard):
(WebCore::CredentialRequestCoordinator::PickerStateGuard::~PickerStateGuard):
(WebCore::CredentialRequestCoordinator::setState):
(WebCore::CredentialRequestCoordinator::prepareCredentialRequest):
(WebCore::CredentialRequestCoordinator::handleDigitalCredentialsPickerResult):
(WebCore:: const):
(WebCore::CredentialRequestCoordinator::dismissPickerAndSettle):
(WebCore::CredentialRequestCoordinator::abortPicker):
(WebCore::CredentialRequestCoordinator::contextDestroyed):
(WebCore::CredentialRequestCoordinator::~CredentialRequestCoordinator):
(): Deleted.
(WebCore::CredentialRequestCoordinator::presentPicker): Deleted.
(WebCore::CredentialRequestCoordinator::finalizeDigitalCredential): Deleted.
* Source/WebCore/Modules/identity/CredentialRequestCoordinator.h:
* Source/WebCore/Modules/identity/DigitalCredential.cpp:
(WebCore::DigitalCredential::discoverFromExternalSource):
* Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations:

Canonical link: https://commits.webkit.org/305868@main
@hlflanagan
Copy link

Discussed in 21 January 2026 Series B call

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Defines the “prepare credential requests” algorithm for the credential request coordinator and wires it into the DigitalCredential get/create integration flow.

Changes:

  • Adds a detailed “Prepare credential requests” algorithm, including request filtering, protocol checks, validation, error propagation, and abort integration.
  • Updates [[DiscoverFromExternalSource]] and [[Create]] to create/return a promise and delegate to the new preparation algorithm.
  • Updates WebIDL around DigitalCredential.protocol by introducing a DigitalCredentialProtocol typedef and changing the attribute type accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Feb 3, 2026

@marcoscaceres I've opened a new pull request, #459, to work on those changes. Once the pull request is ready, I'll request review from you.

@marcoscaceres marcoscaceres added the agenda+ Add to the weekly agenda label Feb 23, 2026
<li>If the [=user agent=] does not allow |protocol|,
[=iteration/continue=].
</li>
<li>Let |validatedRequest| be the result of validating |request|'s
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
<li>Let |validatedRequest| be the result of validating |request|'s
<li>Let |validatedRequestOrException| be the result of validating |request|'s

</p>
</aside>
</li>
<li>If |validatedRequest| is an [=exception=]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
<li>If |validatedRequest| is an [=exception=]:
<li>If |validatedRequestOrException| is an [=exception=]:

<li>If |validatedRequest| is an [=exception=]:
<ol>
<li>[=credential request coordinator/Complete credential request
with=] |promise| and |validatedRequest|.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
with=] |promise| and |validatedRequest|.
with error=] passing |promise| and |validatedRequestOrException|.

</li>
</ol>
</li>
<li>[=list/Append=] |validatedRequest| to |validatedRequests|.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
<li>[=list/Append=] |validatedRequest| to |validatedRequests|.
<li>[=list/Append=] |validatedRequestOrException| to |validatedRequests|.

Comment on lines 919 to 922
To <dfn data-dfn-for="credential request coordinator" data-local-lt=
"complete credential request with">complete credential request with
error</dfn> given a {{Promise}} |promise:Promise| and (a JavaScript
Value) |error|:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
To <dfn data-dfn-for="credential request coordinator">reject request with</dfn> a (JavaScript Value) |error| and a {{Promise}} |promise:Promise|:

</li>
</ol>
<h3>
Complete credential request with error
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
Complete credential request with error
Reject request with error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agenda+ Add to the weekly agenda

Projects

None yet

6 participants