Skip to content

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.

  • Online presentation requestsOnlinePresentationRequest with builder pattern for requesting specific namespaces and data elements
  • Pre-built request templateswith_identity_elements(), with_age_verification(), and with_driving_privileges() for common use cases
  • Presentation responsesOnlinePresentationResponse wraps CBOR-encoded device responses with document type metadata
  • Privacy-preserving age checks — request only age_over_18 / age_over_21 without revealing full identity
  • Bilingual errorsMdlOnlineError variants with English and French messages
use baseid_mdl_online::request::OnlinePresentationRequest;
use baseid_mdl_online::response::OnlinePresentationResponse;
// Build a request for identity elements
let 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 privileges
let driving_request = OnlinePresentationRequest::mdl()
.with_driving_privileges();
// Requests: driving_privileges, issue_date, expiry_date
// Custom element requests
let custom = OnlinePresentationRequest::mdl()
.with_elements("org.iso.18013.5.1", vec![
"family_name".into(),
"document_number".into(),
]);
// Create a response with device data
let response = OnlinePresentationResponse::new(
"org.iso.18013.5.1.mDL",
device_response_cbor,
);
assert!(response.is_mdl());
MethodRequested 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
TypeDescription
OnlinePresentationRequestRequest specifying doc_type and requested elements per namespace
OnlinePresentationResponseResponse wrapping doc_type and CBOR-encoded device response bytes
MdlOnlineErrorError variants: InvalidRequest, PresentationFailed, VerificationFailed
  • 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_mdoc format