-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Digital Credentials: implement CANONICAL_REQUEST_OBJECTS with actual mDoc data #56352
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements canonical request objects with real mDoc data for the Digital Credentials API and refactors the internal architecture to support flexible protocol and data configuration.
Key changes:
- Adds
CANONICAL_REQUEST_OBJECTSwith actual ISO mDocdeviceRequestandencryptionInfodata (base64-encoded) - Refactors helper functions to use configuration object pattern with
makeGetOptions(config)andmakeCreateOptions(config)signatures - Makes
mediationandsignaloptional in type definitions while maintaining sensible defaults in implementations - Introduces new internal helpers
buildRequests()andmakeOptionsInternal()for cleaner architecture
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| digital-credentials/dc-types.ts | Adds type definitions for OpenID protocols, mDocRequest interface, configuration interfaces (MakeGetOptionsConfig, MakeCreateOptionsConfig), and makes mediation/signal optional in option types |
| digital-credentials/support/helper.js | Major refactor: adds CANONICAL_REQUEST_OBJECTS with mDoc data, implements new buildRequests/makeOptionsInternal helpers, updates factory functions to use config object pattern, adds protocol detection logic |
| digital-credentials/user-activation.https.html | Updates test calls from legacy API makeGetOptions("protocol") to new config pattern makeGetOptions({protocol}) |
| digital-credentials/get.tentative.https.html | Updates test calls to use new config object pattern with {protocol: [], signal} syntax |
| digital-credentials/create.tentative.https.html | Updates test calls to use new config object pattern with {protocol: [], signal} syntax |
| digital-credentials/create.disabled-by-permissions-policy.https.sub.html | Updates test call to use new config pattern {protocol: []} |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@marcoscaceres I've opened a new pull request, #56353, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
c160952 to
4841b68
Compare
532af27 to
95ffbec
Compare
|
@mohamedamir, ok, I introduced a The makeGetRequest({protocol: "openid4vp-whatever", requests: [orangeRequest, bananaRequest] });And they get nicely merged together. this is nice too: makeGetRequest({requests: [orangeRequest, bananaRequest] });And, so is: makeGetRequest({protocol: ["x", "y"], requests: [orangeRequest, bananaRequest] }); |
|
In the future, we could combine them: makeGetRequest({requests: [orangeRequest, "openid4vp-v1-unsigned", bananaRequest, "org-iso-mdoc"] });That can be a nice followup. |
| * @template Req | ||
| * @param {Protocol[]} protocols | ||
| * @param {Record<Protocol, (data?: MobileDocumentRequest | object) => Req>} mapping | ||
| * @param {MobileDocumentRequest | object} [explicitData] - Explicit data for create operations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create operation has a different meaning in this context. I got confused some time why this is specific for create and not for get.
I believe this refers to building the request.
So may be use build instead of create in multiple comments introduce in this PR?
…mDoc data - Add CANONICAL_REQUEST_OBJECTS with real mDoc deviceRequest and encryptionInfo data - Update factory functions to use canonical objects as defaults with data spread - Refactor internal architecture with new buildRequests and makeOptionsInternal helpers - Make mediation optional in type definitions (no longer defaults to 'required') - Add comprehensive data parameter support to config interfaces - Complete property bag + signal + protocol selection + canonical objects integration
…quests parameter - Add requests parameter to MakeGetOptionsConfig and MakeCreateOptionsConfig interfaces - Replace complex makeOptionsUnified/makeOptionsInternal system with simpler makeCredentialOptionsFromConfig - Convert buildRequestsFromProtocols to functional programming approach using .map() - Remove factory functions (makeOID4VPDict, makeMDocRequest) in favor of inline functions in allMappings - Make mediation optional in CredentialRequestOptions and CredentialCreationOptions - Enhance TypeScript annotations with generics for better type safety - Support empty protocol arrays (protocol: []) for testing scenarios - Clean up unused imports and improve documentation alignment
95ffbec to
de0d785
Compare
| throw new Error(`Internal error: Invalid options type specified: ${type}`); | ||
| } | ||
| function makeCredentialOptionsFromConfig(config, mapping) { | ||
| const { protocol, requests = [], data, mediation = "required", signal } = config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, we should also remove populating the default mediation to make sure browsers don't reply on it being set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely. That's in the next PR.... just making sure this all continues to work as it was.
| /** | ||
| * Optional data to override canonical data for protocol-based requests. | ||
| */ | ||
| data?: MobileDocumentRequest | object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall that some tests are testing passing here invalid data, which aren't necessarily objects.
Maybe we should make this to capture that?
| data?: MobileDocumentRequest | object; | |
| data?: MobileDocumentRequest | any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true. However, we don't actually validate these inputs in the tests themselves (maybe we should.... will check if we can do that).
mohamedamir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks solid now!
Thanks a lot Marcos for the revisions!
Some minor comments are left!
But otherwise, LGTM
… data override pattern
- Add data parameter to MakeGetOptionsConfig and MakeCreateOptionsConfig for overriding canonical data
- Wire explicitData parameter through buildRequestsFromProtocols call chain properly
- Update tests to use clean makeGetOptions({data}) pattern instead of manual object construction
- Replace post-construction data manipulation with clean data override during construction
- Maintain separation of concerns: protocol selection automatic, data override optional
de0d785 to
e8894c4
Compare
Part 4: