Proximity Presentation mDocs Holder SDK Cheatsheet
This guide provides a quick overview of how to use the MATTR mDocs Holder SDKs to present a claimed mDoc for verification in-person via a proximity presentation workflow as per ISO/IEC 18013-5:2021.
Use these guides as a quick reference to get started. For detailed information, explore the linked tutorials and reference documentation tailored for each platform.
Core usage
Initialize the SDK
try mobileCredentialHolder.initialize()
mobileCredentialHolder.initialize(context)
const initialiseResult = await mobileCredentialHolder.initialise()
if (initialiseResult.isErr()) {
const { error } = initialiseResult
// handle error scenarios
return
}
Create a proximity presentation session
let proximityPresentationSession = try await mobileCredentialHolder.createProximityPresentationSession(
onRequestReceived: onRequestReceived(_:error:)
// 1. Callback triggered when the verifier requests a credential for verification. Use this callback to display the request on the UI and get the user's consent to share any matched credentials.
)
The
createProximityPresentationSession
method returns an instance of
ProximityPresentationSession
which contains a deviceEngagement
property that must be shared with the verifier embedded in a QR
code to establish a secure connection.
val proximityPresentationSession = mobileCredentialHolder.createProximityPresentationSession(
onRequestReceived = { session, matchedCredentials, error ->
if (error != null) {
// Handle error
} else {
// 1. Show request on UI
// 2. Show matched credentials on UI and get user's consent to share them
// 3:
session.sendResponse(
val credentialIds = matchedCredentials!!.flatMap {
it.matchedCredentials.map { credential -> credential.id }
} ,
activity = activity
)
}
}
)
The
createProximityPresentationSession
method returns an instance of
ProximityPresentationSession
which contains a deviceEngagement
property that must be shared with the verifier embedded in a QR
code to establish a secure connection.
const createSessionResult = await mobileCredentialHolder.createProximityPresentationSession({
onRequestReceived: (data) => {
if ('error' in data) {
// handle error scenarios
return
}
// 1. Show UI prompt and gather user consent
// 2. Retrieve matching credential from request object
}
})
if (createSessionResult.isErr()) {
const { error } = createSessionResult
// handle error scenarios
return
}
const proximityPresentationSession = createSessionResult.value
The createProximityPresentationSession
method returns an instance of
ProximityPresentationSession
which contains a deviceEngagement
property that must be shared with
the verifier embedded in a QR code to
establish a secure connection.
Present matching credentials to holder
let credential = try await mobileCredentialHolder.getCredential(credentialId: id)
id
: Pass the identifier of the credential you want to present, as a string. This information is returned by thecreateProximityPresentationSession
method on aonRequestReceived
event, triggered when the verifier requests a credential for verification.
Your application must then gather the user's consent to share the matching credential with the verifier.
val credential = mobileCredentialHolder.getCredential(credentialId)
credentialId
: Pass the identifier of the credential you want to present, as a string. This information is returned by thecreateProximityPresentationSession
method on aonRequestReceived
event, triggered when the verifier requests a credential for verification.
Your application must then gather the user's consent to share the matching credential with the verifier.
const credentialResult = await mobileCredentialHolder.getCredential(credentialId)
if (credentialResult.isErr()) {
const { error } = credentialResult
// handle error scenarios
return
}
const credential = credentialResult.value
//
// Send a response to the verifier
//
const sendResponseResult = await mobileCredentialHolder.sendProximityPresentationResponse({
credentialIds: [credentialId],
terminateSession: false
})
if (sendResponseResult.isErr()) {
const { error } = sendResponseResult
// handle error scenarios
return
}
credentialId
: Pass the identifier of the credential you want to present, as a string. This information is returned by thecreateProximityPresentationSession
method on aonRequestReceived
event, triggered when the verifier requests a credential for verification.
Your application must then gather the user's consent to share the matching credential with the verifier.
Send a response to the verifier
try await proximityPresentationSession.sendResponse(credentialIds: [id])
id
: Pass the identifier of the credential you want to send, as a string.
proximityPresentationSession?.sendResponse(credentialIds = listOf(credentialId))
credentialId
: Pass the identifier of the credential you want to send, as a string.
const sendResponseResult = await mobileCredentialHolder.sendProximityPresentationResponse({
credentialIds: [credentialId]
})
if (sendResponseResult.isErr()) {
const { error } = sendResponseResult
// handle error scenarios
return
}
credentialId
: Pass the identifier of the credential you want to send, as a string.
How would you rate this page?