generateDcRequestMdoc

suspend fun generateDcRequestMdoc(exchangeProtocols: List<String>, docType: String, claims: List<MdocRequestedClaim>, nonce: ByteString, origin: String, clientId: String?, responseEncryptionKey: EcPublicKey?, readerAuthenticationKey: AsymmetricKey.X509Compatible?, zkSystemSpecs: List<ZkSystemSpec>): JsonObject

Utility function to generate a W3C Digital Credentials API request for requesting a single ISO mdoc credential.

The request can expressed for multiple exchange protocols simultaneously, for example OpenID4VP 1.0 and ISO/IEC 18013:2025 Annex C.

The following exchange protocols are supported by this function

  • org-iso-mdoc

  • openid4vp

  • openid4vp-v1-signed

  • openid4v4-v1-unsigned

This can be used on the server-side to generate the request. The resulting JsonObject can be serialized to a string using Json.encodeToString and sent to the browser or requesting app which can pass it to navigator.credentials.get() or its native Credential Manager implementation.

Return

a JsonObject with the request.

Parameters

exchangeProtocols

a list of W3C Exchange Protocol strings to generate requests for. The order of requests in the resulting JSON will match the order in this list.

docType

the ISO mdoc document type, e.g. "org.iso.18013.5.1.mDL".

claims

the namespaces and data elements to request.

nonce

the nonce to use. For OpenID4VP, this will be base64url-encoded without padding. For mdoc-api this will be used as is.

origin

the origin to use.

clientId

the client id to use, must be non-null for signed requests.

responseEncryptionKey

the key to encrypt the response against or null to not encrypt the response. Note that in some protocols encryption of the response is mandatory and this will throw IllegalArgumentException if this is null for such protocols

readerAuthenticationKey

an optional key to use for reader authentication and its certificate chain.

zkSystemSpecs

if non-empty, request a ZK proof using these systems.