Skip to content

fix(wallet): select first supported OID4VCI credential format to avoid unsupported issuance requests - #22

Merged
AlexanderShenshin merged 3 commits into
hiero-ledger:mainfrom
darshit2308:fix/oid4vc-credential-format-filtering
Apr 6, 2026
Merged

fix(wallet): select first supported OID4VCI credential format to avoid unsupported issuance requests#22
AlexanderShenshin merged 3 commits into
hiero-ledger:mainfrom
darshit2308:fix/oid4vc-credential-format-filtering

Conversation

@darshit2308

Copy link
Copy Markdown
Contributor

Description:
The wallet was not filtering offered credentials by supported format before requesting issuance.
If an issuer offered an unsupported format (e.g., AnonCreds or jwt_vc) first in the credential
offer list, the wallet would blindly attempt to request it and crash at runtime with an unhelpful
error, violating the OID4VCI specification's expectation that holders negotiate supported formats.

  • Add WALLET_SUPPORTED_CREDENTIAL_FORMATS constant listing the four wallet-supported formats (vc+sd-jwt, jwt_vc_json, jwt_vc_json-ld, mso_mdoc)
  • Add walletSupportsCredentialFormat helper that safely handles undefined format values
  • Replace naive offeredCredentials[0] selection with .find() that filters by supported format
  • Add early validation guard when a specific credentialConfigurationIdToRequest is passed but resolves to an unsupported format
  • Add descriptive error messages showing both supported and offered formats to aid debugging

Related issue(s):
No prior issue, this is a self-contained bug fix identified during code review of the OID4VCI
credential handling flow in useOpenIdHandlers.ts.

Notes for reviewer:
The core change is in receiveCredentialFromOpenId4VciOffer inside useOpenIdHandlers.ts.
Previously, offeredCredentials[0] was used without any format check. Now:

  • When no specific credential config ID is requested, the wallet picks the first credential whose format it supports
  • When a specific config ID is requested, the wallet also validates the resolved credential's format is supported before proceeding
  • Both failure paths produce actionable error messages listing supported vs offered formats
  • No behavior change occurs when the issuer only offers supported formats (the common case)

Checklist

  • Documented (Code comments added explaining the format filtering logic)
  • Tested (Three new tests added to useOpenIdHandlers.spec.ts covering: format-aware selection from mixed offers, explicit unsupported format rejection, and all-unsupported-formats rejection)

Copilot AI review requested due to automatic review settings April 3, 2026 10:24
Signed-off-by: darshit2308 <darshit2308@gmail.com>
@darshit2308
darshit2308 force-pushed the fix/oid4vc-credential-format-filtering branch from 909db54 to 95c106a Compare April 3, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the OID4VCI issuance flow in the wallet by ensuring the requested credential configuration is selected based on a format the wallet supports, preventing runtime crashes when issuers list unsupported formats first.

Changes:

  • Introduces a wallet-scoped allowlist of supported credential formats plus a helper to validate formats (including undefined).
  • Updates credential selection to choose the first supported offered credential when no specific configuration ID is provided, and validates explicitly requested IDs for supported format.
  • Adds tests covering mixed-format offers, explicit unsupported-format rejection, and all-unsupported rejection.

Reviewed changes

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

File Description
heka-wallet/app/src/credentials/useOpenIdHandlers.ts Adds supported-format filtering/validation and improves failure behavior with more descriptive errors.
heka-wallet/app/__tests__/credentials/useOpenIdHandlers.spec.ts Adds regression tests ensuring selection/validation behaves correctly with unsupported formats.

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

Comment thread heka-wallet/app/src/credentials/useOpenIdHandlers.ts Outdated
Comment thread heka-wallet/app/src/credentials/useOpenIdHandlers.ts Outdated
Signed-off-by: darshit2308 <darshit2308@gmail.com>
@darshit2308
darshit2308 force-pushed the fix/oid4vc-credential-format-filtering branch from db2984c to 8c33943 Compare April 3, 2026 11:48
@AlexanderShenshin AlexanderShenshin self-assigned this Apr 6, 2026
@AlexanderShenshin
AlexanderShenshin self-requested a review April 6, 2026 09:02

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

Thanks for a contribution!
Looks great, I have couple of minor suggestions here.

Comment thread heka-wallet/app/src/credentials/useOpenIdHandlers.ts Outdated
Comment thread heka-wallet/app/src/credentials/useOpenIdHandlers.ts Outdated
Signed-off-by: darshit2308 <darshit2308@gmail.com>
@darshit2308
darshit2308 force-pushed the fix/oid4vc-credential-format-filtering branch from e6ea28b to 1c5b5e1 Compare April 6, 2026 16:00
@darshit2308

Copy link
Copy Markdown
Contributor Author

@AlexanderShenshin Sure, I have made the required changes .

@AlexanderShenshin
AlexanderShenshin merged commit 257ffb1 into hiero-ledger:main Apr 6, 2026
6 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.

3 participants