generateDcRequestDcql

suspend fun generateDcRequestDcql(exchangeProtocols: List<String>, dcql: JsonObject, nonce: ByteString, origin: String, clientId: String?, responseEncryptionKey: EcPublicKey?, readerAuthenticationKey: AsymmetricKey.X509Compatible?, jsonTransactionData: List<String> = emptyList(), docRequestOtherInfo: Map<String, Map<String, DataItem>> = emptyMap()): JsonObject

Utility function to generate a W3C Digital Credentials API request for requesting credentials.

The request can expressed for multiple exchange protocols simultaneously, for example OpenID4VP 1.0 and ISO/IEC 18013:2025 Annex C. In the ISO 18013-5 case the DCQL is converted using the buildDeviceRequestFromDcql.

The following exchange protocols are supported by this function

  • org-iso-mdoc

  • openid4vp

  • openid4vp-v1-signed

  • openid4vp-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.

dcql

the DCQL to use.

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.

jsonTransactionData

JSON-formatted transaction data, before base64url encoding, see OpenID4VP 1.0 section 8.4.

docRequestOtherInfo

transaction data encoded for use in requestInfo` map in ISO 18013-7.

Throws

if dcql contains features not supported by DeviceRequest, for example a request for credentials that aren't ISO mdocs.