baseid-mdl-online
The mdl-online crate implements ISO/IEC 18013-7, enabling online presentation of mobile driving licences via OID4VP. This complements the BLE/NFC-based in-person exchange in baseid-mdl.
Key Features
Section titled “Key Features”- Online presentation requests —
OnlinePresentationRequestwith builder pattern for requesting specific namespaces and data elements - Pre-built request templates —
with_identity_elements(),with_age_verification(), andwith_driving_privileges()for common use cases - Presentation responses —
OnlinePresentationResponsewraps CBOR-encoded device responses with document type metadata - Privacy-preserving age checks — request only
age_over_18/age_over_21without revealing full identity - Bilingual errors —
MdlOnlineErrorvariants with English and French messages
Quick Start
Section titled “Quick Start”use baseid_mdl_online::request::OnlinePresentationRequest;use baseid_mdl_online::response::OnlinePresentationResponse;
// Build a request for identity elementslet request = OnlinePresentationRequest::mdl() .with_identity_elements();// Requests: family_name, given_name, birth_date, portrait
// Or request only age verification (privacy-preserving)let age_request = OnlinePresentationRequest::mdl() .with_age_verification();// Requests: age_over_18, age_over_21
// Or request driving privilegeslet driving_request = OnlinePresentationRequest::mdl() .with_driving_privileges();// Requests: driving_privileges, issue_date, expiry_date
// Custom element requestslet custom = OnlinePresentationRequest::mdl() .with_elements("org.iso.18013.5.1", vec![ "family_name".into(), "document_number".into(), ]);
// Create a response with device datalet response = OnlinePresentationResponse::new( "org.iso.18013.5.1.mDL", device_response_cbor,);assert!(response.is_mdl());Request Templates
Section titled “Request Templates”| Method | Requested Elements |
|---|---|
with_identity_elements() | family_name, given_name, birth_date, portrait |
with_age_verification() | age_over_18, age_over_21 |
with_driving_privileges() | driving_privileges, issue_date, expiry_date |
with_elements(ns, elements) | Custom namespace and element list |
Key Types
Section titled “Key Types”| Type | Description |
|---|---|
OnlinePresentationRequest | Request specifying doc_type and requested elements per namespace |
OnlinePresentationResponse | Response wrapping doc_type and CBOR-encoded device response bytes |
MdlOnlineError | Error variants: InvalidRequest, PresentationFailed, VerificationFailed |
Related Crates
Section titled “Related Crates”- baseid-mdl — core mDL types (MobileDocument, MSO, COSE) used for the underlying credential format
- baseid-oid4vp — OID4VP protocol layer for online presentation transport
- baseid-haip — HAIP profile constraining mDL online presentation to
mso_mdocformat