Add support for referencing DIDs from the wallet's DID store - #2163
Add support for referencing DIDs from the wallet's DID store#2163SuperBatata wants to merge 6 commits into
Conversation
Introduced a new `didReference` field to handle DIDs stored in the wallet's DID store. This ensures greater flexibility in DID selection by allowing use of a reference when an inline DID is not provided. Updates were made across relevant services and handlers to accommodate this feature.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request extends the OpenID4VC wallet issuance APIs to support selecting the holder/subject DID via a didReference that is resolved from the wallet’s DID store, in addition to existing inline did usage. The intent is to make DID selection more flexible across issuance session creation and issuance/proof flows while preserving precedence rules (inline did wins).
Changes:
- Added
didReferencefields to issuance/session request models and threaded that parameter through relevant handler/service flows. - Updated DID resolution logic to use
didfirst, then resolvedidReferencefromwallet.didStore, then fall back towallet.defaultDid(). - Minor formatting/serialization-friendly changes (e.g., trailing commas) and small readability adjustments.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| waltid-libraries/protocols/waltid-openid4vc-wallet/src/commonMain/kotlin/id/walt/wallet2/handlers/WalletIssuanceSessionService.kt | Adds didReference to session start requests and resolves the effective DID for new sessions. |
| waltid-libraries/protocols/waltid-openid4vc-wallet/src/commonMain/kotlin/id/walt/wallet2/handlers/WalletIssuanceHandler.kt | Adds didReference to multiple request DTOs and updates issuance/auth-code/proof-signing flows to resolve DID via DID store when provided. |
Suppressed comments (4)
waltid-libraries/protocols/waltid-openid4vc-wallet/src/commonMain/kotlin/id/walt/wallet2/handlers/WalletIssuanceHandler.kt:2100
- In the auth-code flow, an unresolved
didReferencecurrently falls back towallet.defaultDid(). That can cause the continuation to use a different DID than the caller intended. Prefer throwing whendidReferenceis non-null but not resolvable (or whendidStoreis not configured).
val holderDid = did
?: didReference?.let { wallet.didStore?.getDid(it)?.did }
?: wallet.defaultDid()
waltid-libraries/protocols/waltid-openid4vc-wallet/src/commonMain/kotlin/id/walt/wallet2/handlers/WalletIssuanceHandler.kt:371
SignProofRequestnow supportsdidReference, but (unlike the issuance requests)signProofdoes not default to the wallet's default DID when neitherdidnordidReferenceis provided. If that difference is intentional (e.g., to allow pure JWK binding), it should be documented on the request properties to avoid surprising API consumers.
val keyId: String? = null,
val did: String? = null,
/** Reference to a DID in the wallet's DID store. Ignored when [did] is provided. */
val didReference: String? = null,
waltid-libraries/protocols/waltid-openid4vc-wallet/src/commonMain/kotlin/id/walt/wallet2/handlers/WalletIssuanceSessionService.kt:332
- New
didReferenceresolution paths (session start, issuance, auth-code flow, proof signing) are not covered by tests. There are already handler/session tests in this module; adding cases for (1)didprecedence overdidReference, (2) usingdidReferencewhendidis null, and (3) behavior when the reference cannot be resolved would help prevent regressions.
did = request.did
?: request.didReference?.let { wallet.didStore?.getDid(it)?.did }
?: wallet.defaultDid(),
waltid-libraries/protocols/waltid-openid4vc-wallet/src/commonMain/kotlin/id/walt/wallet2/handlers/WalletIssuanceHandler.kt:1172
- In
signProof, an unresolveddidReferenceis silently ignored, which can unexpectedly switch the proof binding from DID-based (kid) to JWK-based (jwk). If a caller suppliesdidReference, it would be safer to fail fast when it cannot be resolved from the wallet DID store.
val resolvedDid = request.did
?: request.didReference?.let { wallet.didStore?.getDid(it)?.did }
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…d WalletIssuanceSessionService - Introduced unit tests for `did`, `didReference`, and fallback mechanisms in `WalletIssuanceHandler` and `WalletIssuanceSessionService`. - Verified inline `did` precedence, `didReference` resolution from wallet's DID store, and fallback to JWK binding when no valid DID is found. - Ensured adherence to the three-tier DID resolution strategy across both components.
|



This pull request adds support for referencing DIDs (Decentralized Identifiers) stored in the wallet's DID store, in addition to supporting inline DIDs. This enhancement is applied across multiple request and handler classes related to credential issuance, proof signing, and session management. The changes ensure that when both an inline DID and a DID reference are provided, the inline DID takes precedence; otherwise, the referenced DID is used, defaulting to the wallet's default DID if neither is specified.
Support for DID References in Credential Issuance and Proof Handling:
Added a
didReferenceproperty to various request data classes (ReceiveCredentialRequest,ReceiveCredentialFromPreviewRequest,SignProofRequest,ReceiveAuthorizedCredentialRequest,WalletIssuanceSessionRequest) to allow referencing a DID from the wallet's DID store. The logic ensuresdidtakes precedence overdidReference, and both default to the wallet's default DID if not provided. [1] [2] [3] [4] [5]Updated handler logic in
WalletIssuanceHandlerandWalletIssuanceSessionServiceto resolve the effective DID using the newdidReferenceproperty. This affects credential issuance, proof signing, and session creation flows. [1] [2] [3] [4]API and Internal Consistency Improvements:
didReferenceproperty throughout the credential issuance flow and related operations. [1] [2] [3]Code Cleanliness and Formatting:
These changes collectively enhance the flexibility of DID selection in credential issuance and proof processes, making the wallet more adaptable to different use cases and user preferences.