Skip to content

fix: VPResponse.VPToken as map[string][]string per OID4VP DCQL spec#386

Merged
masv3971 merged 2 commits into
SUNET:mainfrom
sirosfoundation:fix/vptoken-dcql-array
May 18, 2026
Merged

fix: VPResponse.VPToken as map[string][]string per OID4VP DCQL spec#386
masv3971 merged 2 commits into
SUNET:mainfrom
sirosfoundation:fix/vptoken-dcql-array

Conversation

@leifj
Copy link
Copy Markdown
Contributor

@leifj leifj commented May 8, 2026

Summary

Per OID4VP §6.3 with DCQL, vp_token values are arrays of Verifiable Presentations keyed by credential query ID. The previous map[string]string type caused json.Unmarshal to fail when a spec-compliant wallet sends array values, resulting in errors like failed to unmarshal decrypted JWE.

Changes

  • Change VPToken from map[string]string to map[string][]string in VPResponse
  • Unwrap first token from array in apigw DCQL credential query loop (handlers_verifier.go)
  • Unwrap first token from array in verifier scope-based lookup (handlers_verification.go)
  • Update tests to use new type

Notes

This is the forward-port of sirosfoundation/vc@5caa7704 (already deployed in release/sirosid/v0.5.0) to the main-branch DCQL handler structure, which uses a for _, cq := range authCtx.DCQLQuery.Credentials loop instead of a single key lookup.

Fixes #365

Per OID4VP §6.3 with DCQL, vp_token values are arrays of Verifiable
Presentations keyed by credential query ID. The previous map[string]string
type caused json.Unmarshal to fail with spec-compliant wallets that send
array values.

- Change VPToken from map[string]string to map[string][]string
- Unwrap first token from array in apigw DCQL credential query loop
- Unwrap first token from array in verifier scope-based lookup
- Update tests to use new type

Forward-port of 5caa770 to the main-branch DCQL handler structure.
Fixes SUNET#365
@leifj leifj marked this pull request as draft May 8, 2026 10:08
@masv3971 masv3971 requested a review from Copilot May 8, 2026 10:42
Copy link
Copy Markdown
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

Updates the OpenID4VP DCQL vp_token response handling to align with the spec requirement that each credential query ID maps to an array of Verifiable Presentations, preventing JSON unmarshal failures from spec-compliant wallets.

Changes:

  • Change VPResponse.VPToken from map[string]string to map[string][]string.
  • Update verifier and API gateway handlers to unwrap the first presentation from each vp_token array.
  • Update unit tests to reflect the new VPToken type.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/openid4vp/response_parameters.go Updates VPResponse.VPToken to map[string][]string per OID4VP DCQL expectations.
pkg/openid4vp/response_parameters_additional_test.go Adjusts VPResponse marshalling/unmarshalling test data to use array-valued map entries.
internal/verifier/apiv1/handlers_verification.go Unwraps first token from vp_token arrays when mapping VP tokens to requested scopes.
internal/apigw/apiv1/handlers_verifier.go Unwraps first token from vp_token arrays when selecting VP token for a DCQL credential query.

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

Comment thread internal/verifier/apiv1/handlers_verification.go
Comment thread internal/apigw/apiv1/handlers_verifier.go
Current verifier only processes the first VP token per credential query.
Add Info-level log when additional tokens are present to make the
limitation explicit rather than silently ignoring extras.
@sonarqubecloud
Copy link
Copy Markdown

@leifj leifj marked this pull request as ready for review May 18, 2026 19:43
@masv3971 masv3971 merged commit 0ffdae2 into SUNET:main May 18, 2026
5 checks passed
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.

Make VPResponse.VPToken spec compliant.

3 participants