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

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

Abierto
#233 9 comentarios 0 reacciones 1 asignado Reclamado por @martcpp Ver en GitHub
bug
Lenguaje dominante
Rust
Estrellas
4
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

## 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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.