Skip to content

[WAL-1158] fix(openid4vci): align wallet nonce handling with 1.0#1937

Open
szijpeter wants to merge 3 commits into
mainfrom
fix/wal-1158-openid4vci-nonce-endpoint
Open

[WAL-1158] fix(openid4vci): align wallet nonce handling with 1.0#1937
szijpeter wants to merge 3 commits into
mainfrom
fix/wal-1158-openid4vci-nonce-endpoint

Conversation

@szijpeter

@szijpeter szijpeter commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements WAL-1158 as the wallet-side OpenID4VCI 1.0 correction for proof nonce handling and invalid_nonce recovery.

When an issuer advertises nonce_endpoint, the wallet obtains a fresh c_nonce for each proof-bound credential request. When it does not, the wallet still creates the required proof without a nonce claim; token-response c_nonce values and access tokens are never used as proof nonces.

The matching enterprise consumer is walt-id/waltid-identity-enterprise#547.

What Changed

  • adds a reusable typed KMP NonceRequestBuilder for nonce-endpoint responses with sanitized failures
  • makes proof nonce input nullable and omits the JWT nonce claim when no nonce was obtained
  • obtains a fresh metadata-advertised nonce for each proof-bound credential request
  • removes token-response c_nonce and access-token fallback from proof construction and isolated token results
  • retries a full credential request exactly once after an issuer returns the standard invalid_nonce error, using a newly fetched nonce and freshly signed proof
  • keeps isolated fetch-credential calls single-shot and propagates the typed credential error so API clients explicitly control any retry
  • maps the exact invalid_nonce credential error to the Wallet2 HTTP API response
  • updates focused wallet, route, and nonce-client coverage plus protocol documentation

Architecture Notes

NonceRequestBuilder is deliberately a small protocol client: it requests and parses the nonce response, preserves cancellation, and redacts malformed response material. The higher-level issuance flow owns the bounded retry because it alone can fetch a nonce and regenerate a proof safely.

The wallet intentionally applies no HTTPS-enforcement or redirect-rejection policy to nonce_endpoint; transport reachability remains the HTTP client's concern. This is the agreed non-standard-compliance trade-off for these PRs.

This PR is the prerequisite for walt-id/waltid-identity#1935, which is restacked to consume the shared implementation instead of carrying WAL-1158 inside the broader WAL-995 change.

Caveats and Follow-Ups

  • Automatic recovery is limited to one retry and only to the standard invalid_nonce error. Other credential errors propagate unchanged.
  • Isolated API consumers receive the typed error rather than an implicit replay, because they own the surrounding issuance state.

Breaking Changes

  • TokenRequestBuilder.TokenResponse.c_nonce and c_nonce_expires_in are removed.
  • RequestTokenResult.cNonce is removed.
  • RequestNonceResult.nonce and proof-builder nonce inputs are nullable so issuers can require proofs without advertising a Nonce Endpoint.

@linear-code

linear-code Bot commented Jul 20, 2026

Copy link
Copy Markdown

WAL-1158

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7cb81cb2-d0b9-48ea-b610-2b675fef9107

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@szijpeter szijpeter changed the title fix(openid4vci): align wallet nonce handling with 1.0 (WAL-1158) [WAL-1158] fix(openid4vci): align wallet nonce handling with 1.0 Jul 20, 2026
@szijpeter szijpeter self-assigned this Jul 20, 2026
@szijpeter
szijpeter force-pushed the fix/wal-1158-openid4vci-nonce-endpoint branch 8 times, most recently from fe7126e to 1ad6dad Compare July 21, 2026 01:31
@szijpeter
szijpeter marked this pull request as ready for review July 21, 2026 06:34
@szijpeter
szijpeter marked this pull request as draft July 21, 2026 07:07
@szijpeter szijpeter added the ci:mobile Run mobile related CI workflows for this PR label Jul 21, 2026
@szijpeter szijpeter mentioned this pull request Jul 21, 2026
@szijpeter
szijpeter force-pushed the fix/wal-1158-openid4vci-nonce-endpoint branch from c2772ec to 0345cb7 Compare July 21, 2026 10:13
@szijpeter
szijpeter changed the base branch from main to chore/credentials-reproducible-install July 21, 2026 10:34
Base automatically changed from chore/credentials-reproducible-install to main July 21, 2026 13:01
@szijpeter
szijpeter marked this pull request as ready for review July 21, 2026 13:32
@szijpeter
szijpeter force-pushed the fix/wal-1158-openid4vci-nonce-endpoint branch from 0345cb7 to 1b0a1d3 Compare July 21, 2026 15:38
@szijpeter
szijpeter enabled auto-merge July 21, 2026 15:42
@szijpeter
szijpeter disabled auto-merge July 21, 2026 15:42

@chsavvaidis chsavvaidis left a comment

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.

see comment

@szijpeter
szijpeter force-pushed the fix/wal-1158-openid4vci-nonce-endpoint branch 3 times, most recently from 2e5f1be to ea627ee Compare July 22, 2026 12:57
@szijpeter
szijpeter force-pushed the fix/wal-1158-openid4vci-nonce-endpoint branch from bff82e2 to 693fe56 Compare July 22, 2026 15:39
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

ci:mobile Run mobile related CI workflows for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants