Skip to content

Define "present credential requests" algorithm.#419

Merged
marcoscaceres merged 18 commits into
mainfrom
present
Apr 30, 2026
Merged

Define "present credential requests" algorithm.#419
marcoscaceres merged 18 commits into
mainfrom
present

Conversation

@marcoscaceres

@marcoscaceres marcoscaceres commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator

Defines the "present the credential request" algorithm — the core user-facing part of the Digital Credentials flow that happens after validation passes.

What the algorithm does

Once the credential requests have been validated (by the "prepare" algorithm), this algorithm:

  1. Constructs a request context — bundles the validated requests with the top-level and document origins, so the platform/chooser knows who is asking and from where.
  2. Presents a digital credential chooser — a UA-provided UI that shows the user available credentials from registered holders. The user can select a credential, cancel, or the operation can be aborted via an AbortSignal.
  3. Handles abort — if the signal fires, the algorithm returns (the abort callback was already wired up by the "prepare" steps).
  4. Handles cancellation — rejects with AbortError.
  5. Maps platform errors — translates platform-specific failures to web-facing errors: NotAllowedError (permission denied), TypeError (malformed request data), InvalidStateError (concurrent request), or OperationError (catch-all).
  6. Processes the response — parses the holder's response as JSON, validates it's an object, constructs a DigitalCredential instance with data and protocol, resolves the promise, and cleans up coordinator state.

New terms introduced

  • Digital credential chooser — the UA-provided UI for credential selection
  • Request context — a struct carrying requests, top origin, and document origin into the chooser

Closes #419

The following tasks have been completed:

Implementation commitment:

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

Documentation and checks

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

Preview | Diff

@marcoscaceres marcoscaceres force-pushed the present branch 2 times, most recently from 26f5b15 to a98d215 Compare January 13, 2026 00:53
@marcoscaceres marcoscaceres marked this pull request as ready for review January 13, 2026 12:51
@marcoscaceres marcoscaceres requested a review from a team as a code owner January 13, 2026 12:51
@marcoscaceres marcoscaceres changed the title Define "Present credential requests" algorithm. Define "present credential requests" algorithm. Jan 13, 2026
@marcoscaceres marcoscaceres added the agenda+ Add to the weekly agenda label Jan 20, 2026
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
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
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.

I like the direction in general, I have added a couple of comments

Thank you, @marcoscaceres

Comment thread index.html Outdated
Comment thread index.html Outdated
@hlflanagan

Copy link
Copy Markdown

Discussed in 21 January 2026 Series B call

Comment thread index.html Outdated
@hlflanagan

Copy link
Copy Markdown

Discussed on 2026-02-09 call. Editors will bring this back to the group after more research for best practices and to suggest direction.

@mohamedamir mohamedamir removed the agenda+ Add to the weekly agenda label Feb 12, 2026
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html
Comment thread index.html Outdated
Comment thread index.html Outdated
@hlflanagan

Copy link
Copy Markdown

Discussed at the 20 April 2026 call. Note the idea to create a list of v2 (breaking changes) items for DC API, including calling origin and top level origin. Will bring back to next week's call.

@hlflanagan hlflanagan added the agenda+ Add to the weekly agenda label Apr 20, 2026
@marcoscaceres marcoscaceres removed the agenda+ Add to the weekly agenda label Apr 26, 2026
Co-authored-by: Mohamed Amir Yosef <mohamed.amir@gmail.com>
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
- Replace selectedRequest with platform-returned protocol identifier,
  since neither WebKit nor Chromium know which request was selected
- Rename parsedDataOrError to parsedResponseDataOrError for clarity
- Move JSON parsing, validation, and credential construction inside
  the queued global task so they execute in the correct realm
- Unify success/error ordering: cleanup abort, settle promise, null
  active promise, set idle (eliminates double-task-hop for errors)
- Remove document origin from request context (CTAP only supports
  one origin, Chromium does not send it); tracked in #504
- Derive top-level origin from environment settings object
- Rename "top origin" to "top-level origin" for clarity
- Wrap chooser and response handling in [=In parallel=]
- Fix "wait for the user to do" framing to "wait for outcomes"
- Fix grammar in abort note and protocol note
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@mohamedamir all suggestions applied.

@hlflanagan, @mohamedamir filed a bug about the iframe's origin #504 to fix in the future.

I think we are done 🥳

Confirmed that apart from a few error codes this matches 1:1 both WebKit and Chrome.

@timcappalli timcappalli 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.

LGTM with the name change (initiate)

…redential request"

Agent-Logs-Url: https://github.com/w3c-fedid/digital-credentials/sessions/727fd1f7-e1e3-48d7-a636-a4c14b7590a1

Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>

@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.

LGTM after replacing all mentions of "present" with "initiate"

Comment thread index.html Outdated
Co-authored-by: Mohamed Amir Yosef <mamir@chromium.org>
@wseltzer

Copy link
Copy Markdown
Contributor

29 April minutes

@marcoscaceres marcoscaceres merged commit 0bbd3e3 into main Apr 30, 2026
3 checks passed
@marcoscaceres marcoscaceres deleted the present branch April 30, 2026 00:21
github-actions Bot added a commit that referenced this pull request Apr 30, 2026
SHA: 0bbd3e3
Reason: push, by marcoscaceres

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

9 participants