ADORSYS-GIS / ADORSYS-GIS/cloud-identity-wallet

fix: resolve CredentialFormat and credential_types from issuer metadata instead of hardcoding SdJwtVc

Aperta
#233 9 commenti 0 reazioni 1 assegnatario Rivendicata da @martcpp Vedi su GitHub
bug
Lingua principale
Rust
Stelle
4
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Problem

In `src/domain/models/issuance/mod.rs`, the `store_credential` helper hardcodes two values regardless of the actual credential format being stored:

**Bug 1 : Wrong format tag:**
```rust
format: CredentialFormat::SdJwtVc, // TODO: Determine the format from the credential
```
Every credential — including `mso_mdoc` — gets stored with `CredentialFormat::SdJwtVc`. This means any downstream logic that branches on `format` (display, validation, presentation routing) will misidentify mdoc credentials as SD-JWT VCs.

**Bug 2 : Wrong credential type identifier:**
```rust
credential_types: vec![credential_config_id.to_owned()],
```
For `mso_mdoc`, the spec (OID4VCI Appendix A.2) defines the credential type as the `doctype` string (e.g. `"org.iso.18013.5.1.mDL"`), not the credential configuration ID. Storing `config_id` here makes the field meaningless for mdoc and breaks any filtering or display that relies on it.

## Acceptance Criteria
- [ ] A credential received with `format: "mso_mdoc"` in the issuer metadata is stored with `CredentialFormat::MsoMdoc` in the database.
- [ ] A credential received with `format: "mso_mdoc"` stores `doctype` (e.g. `"org.iso.18013.5.1.mDL"`) in `credential_types`, not the configuration ID.
- [ ] A credential received with `format: "vc+sd-jwt"` is unaffected — format and `credential_types` behaviour is identical to before.
- [ ] If `credential_config_id` is not found in the issuer metadata, the function falls back gracefully without panicking.
- [ ] No new dependencies added.
- [ ] Existing tests pass. New unit test added covering the mdoc branch.

Estimated time: 3 hours

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.