light-mode-image
Learn

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

Initialize the SDK
    try mobileCredentialHolder.initialize()
Initialize the SDK
mobileCredentialHolder.initialize(context)
Initialize the SDK
const initialiseResult = await mobileCredentialHolder.initialise()
if (initialiseResult.isErr()) {
    const { error } = initialiseResult
    // handle error scenarios
    return
}

Create a proximity presentation session

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.

Create a proximity presentation session
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.

Create a proximity presentation session
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

Present matching credentials to the 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 the createProximityPresentationSession method on a onRequestReceived 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.

Present matching credentials to the holder
    val credential = mobileCredentialHolder.getCredential(credentialId)
  • credentialId : Pass the identifier of the credential you want to present, as a string. This information is returned by the createProximityPresentationSession method on a onRequestReceived 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.

Present matching credentials to the holder
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 the createProximityPresentationSession method on a onRequestReceived 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

Send response to the verifier
    try await proximityPresentationSession.sendResponse(credentialIds: [id])
  • id : Pass the identifier of the credential you want to send, as a string.
Send response to the verifier
    proximityPresentationSession?.sendResponse(credentialIds = listOf(credentialId))
  • credentialId : Pass the identifier of the credential you want to send, as a string.
Send response to the verifier
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?