Iso18013ReaderQrPresentment

suspend fun Iso18013ReaderQrPresentment(uri: String, source: PresentmentSource, transportFactory: MdocTransportFactory = MdocTransportFactory.Default, options: MdocTransportOptions = MdocTransportOptions(), preferredConnectionMethodOrder: List<String> = emptyList(), bleDirectL2capEnabled: Boolean = true, supportedCurves: List<EcCurve> = Crypto.supportedCurves.filter { it.supportsKeyAgreement }, capabilities: Map<Capability, DataItem> = mapOf( Capability.READER_AUTH_ALL_SUPPORT to true.toDataItem(), Capability.EXTENDED_REQUEST_SUPPORT to true.toDataItem(), ), preselectedDocuments: List<Document> = emptyList(), connectionTimeout: Duration? = 15.seconds, timeout: Duration? = 15.seconds, timeoutSubsequentRequests: Duration? = 30.seconds, onConnecting: () -> Unit = {}, onWaitingForRequest: () -> Unit = {}, onWaitingForUserInput: () -> Unit = {}, onDocumentsInFocus: (documents: List<Document>) -> Unit = {}, onSendingResponse: () -> Unit = {}, onDeviceRequest: (deviceRequest: DeviceRequest) -> Unit = {}, onTelemetry: (telemetry: PresentmentTelemetry) -> Unit = {})

Performs holder-side proximity presentment using ISO/IEC 18013-5 Second Edition Reader QR engagement (clauses 9.7 and 12.2.4).

This parses the scanned mdoc:<base64url(ReaderEngagement)> uri, validates that the reader's ephemeral key curve is in supportedCurves, selects a BLE connection method according to preferredConnectionMethodOrder and bleDirectL2capEnabled, opens the BLE transport, transmits the initial unencrypted {"deviceEngagementBytes": #6.24(bstr .cbor DeviceEngagement)} message, and completes the encrypted presentment session.

Parameters

uri

the scanned Reader QR URI ("mdoc:" followed by base64url-without-padding ReaderEngagement CBOR).

source

the source of truth for documents to present.

transportFactory

factory used to construct the selected BLE MdocTransport.

options

options passed to transportFactory.

preferredConnectionMethodOrder

optional list of connection method string prefixes (for example, "ble:direct_l2cap_central:", "ble:gatt_central:", "ble:gatt_peripheral:") specifying preference order when the reader advertises multiple BLE modes. When empty or unmatched, defaults to the first eligible method decoded from ReaderEngagement (DirectL2capCentral, GattCentral, GattPeripheral).

bleDirectL2capEnabled

whether DirectL2capCentral methods offered by the reader may be selected.

supportedCurves

ECDH curves supported for session encryption (EDeviceKey is generated on the same curve as EReaderKey).

capabilities

mdoc capabilities included in DeviceEngagement.

preselectedDocuments

documents preselected by the user, if any.

connectionTimeout

timeout for establishing the BLE connection to the reader, or null for no timeout.

timeout

timeout for receiving the initial encrypted DeviceRequest message after connecting.

timeoutSubsequentRequests

timeout for receiving subsequent messages in multi-request sessions.

onConnecting

callback invoked right before opening the BLE transport connection.

onWaitingForRequest

callback invoked when waiting for a request message from the reader.

onWaitingForUserInput

callback invoked when waiting for user consent, authentication, or face matching.

onDocumentsInFocus

callback invoked with the documents currently in focus for consent.

onSendingResponse

callback invoked right before sending the encrypted DeviceResponse.

onDeviceRequest

callback invoked when a verified DeviceRequest is received.

onTelemetry

callback invoked with the final PresentmentTelemetry before returning or throwing.

Throws

if uri or ReaderEngagement is malformed or uses an unsupported curve.

if establishing the BLE connection exceeds connectionTimeout.

if user authentication failed or was canceled.

if face matching failed or was canceled.

if the user canceled in a consent prompt.

if it's not possible to satisfy the request.