Repository navigation
Typed elements: bstr, full-date and tdate from the claims schema (value_type) - #41
scott410md wants to merge 2 commits into
Conversation
…ue_type) A claims descriptor in a credential configuration can name the ISO 18013-5 data type of an element with value_type: bstr, full-date or tdate. The issuer checks the input and passes it to isomdl-uniffi as a typed element envelope, which writes a byte string, tag 1004 or tag 0. Elements without a value_type are unchanged. Unknown types are refused at registration; bad inputs at exchange creation and at issuance, naming the element only. Needs isomdl-uniffi with typed-element support. With an older library the issue fails (the envelope would otherwise be written as a CBOR map). Signed-off-by: Scott Harris <82886769+scott410md@users.noreply.github.com>
Claim descriptors already use value_type as claim metadata with other values, for example "boolean" or "string". Only bstr, full-date and tdate now select a typed element; any other value is ignored and the element is converted as before, so those configurations register and issue as they did. A malformed input for one of the three types is still refused, naming the element only. Signed-off-by: Scott Harris <82886769+scott410md@users.noreply.github.com>
e1d83ec to
36e3d6c
Compare
Indicio Team Review: PR #41 — Typed elements (bstr, full-date, tdate) for mso_mdocReviewed by a virtual team assembled from Indicio's engineering playbooks: Backend Engineer, Architect, Security Engineer, Tech Lead, and QA Test Engineer, each reviewing the full diff independently. SummaryThis PR fixes a real ISO 18013-5 spec-compliance gap: generic mso_mdoc doctypes currently write every element as CBOR text, even elements the spec defines as byte strings or tagged dates (e.g., portrait images, issue dates). The fix lets a credential configuration tag an element with All five reviewers converged on the same verdict: good design, not yet mergeable as-is. Two independent reviewers (Security Engineer and QA) found the same functional bug by actually running the code, and Backend Engineer found a separate, more serious crash risk in the one code path the test suite doesn't really exercise yet (because the companion library isn't merged). None of this requires rethinking the design — it's tightening before ship. Findings by roleBackend EngineerBlocking: Also flagged: no version pin on the unmerged companion dependency; silent no-op on near-miss ArchitectConfirmed via Security EngineerTraced the full call graph and confirmed defense-in-depth actually holds: Tech LeadVerified (by grepping every QA Test EngineerRan the code directly rather than just reading it, and confirmed a functional bug independently of Security Engineer: Consensus
Action items
🤖 Generated with Claude Code |
What it does
For generic (non-mDL) mso_mdoc doctypes, every element value travels to isomdl-uniffi as JSON. As a result, an element that ISO 18013-5 defines as a byte string or a tagged date was written as CBOR text.
With this change, a credential configuration can name the ISO 18013-5 data type of an element in its claims descriptor:
The OID4VCI 1.0 list form,
[{"path": ["<namespace>", "<element>"], "value_type": "..."}], is also read.At issuance the issuer checks the input and passes the element to isomdl-uniffi as a typed element envelope. isomdl-uniffi then writes the CBOR type. The envelope is:
{"$isomdl": "<type>", "value": "<text>"}Elements without a
value_typeare unchanged, and so are mDL (org.iso.18013.5.1.mDL) credentials, whose element types come from the namespace definition.Only
bstr,full-dateandtdateselect a typed element. Any othervalue_type(configurations already use it as claim metadata, for examplebooleanorstring) is left alone, and the element is converted as before.value_type values
bstrfull-dateYYYY-MM-DD, a calendar-valid datetdateYYYY-MM-DDTHH:MM:SSZ, UTC, no fractional secondsErrors
Each check happens as early as it can:
Errors are raised as
CredProcessorErrorand name the element and the type, never the value, for example:claim '<element>': tdate value is not a valid YYYY-MM-DDTHH:MM:SSZ date-time.value_typeis stored with the configuration but is not added to the issuer metadata served to wallets.Dependency on the library change
Mdoc.create_and_signas before.$isomdl, the issue fails withinstalled isomdl-uniffi does not support typed elements (element '<element>' was written as a map), so no mdoc with a wrong element type is issued.value_typedo not depend on the library change.Files
oid4vc/mso_mdoc/mdoc/typed_values.py(new): readsvalue_typefrom the claims, checks inputs and builds the envelope.oid4vc/mso_mdoc/mdoc/issuer.py: wraps typed elements for generic doctypes and adds the guard above.oid4vc/mso_mdoc/cred_processor.py: the checks at exchange creation and issuance.oid4vc/mso_mdoc/tests/test_typed_values.py(new): 44 tests.Tests
The new tests cover:
value_typefrom both claims forms;value_typevalues (for exampleboolean,string) left alone at registration, exchange creation and issuance, including an mDL configuration withvalue_type: boolean;value_typekept out of issuer metadata;Results on this branch, with isomdl-uniffi built from the library change:
pytest mso_mdoc -qgives 149 passed (44 of them intest_typed_values.py), 0 failed.Depends on: Indicio-tech/isomdl-uniffi#37