In-person verification Verifier Mobile SDKs cheatsheet
This guide provides a quick overview of how to use the MATTR Pi mDocs Verifier SDKs to verify an mDoc presented 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
mobileCredentialVerifier.initialize()
try await mobileCredentialVerifier.addTrustedIssuerCertificates(certificates: [certificate])
certificate
: Pass the IACA certificate of an issuer your want your application to trust.
MobileCredentialVerifier.initialize(activity)
MobileCredentialVerifier.addTrustedIssuerCertificates(certificates = listOf(certificate))
certificate
: Pass the IACA certificate of an issuer your want your application to trust.
await mobileCredentialVerifier.initialise()
await mobileCredentialVerifier.addTrustedIssuerCertificates([certificate])
Create a presentation request
let mobileCredentialRequest = MobileCredentialRequest(
docType: "<DocType>",
namespaces: [
"<Namespace>": [
"<AttributeName1>": false,
"<AttributeName2>": false,
"<AttributeName3>": false
]
]
)
docType
: The type of credential being requested (e.g., an mDL).namespaces
: A dictionary mapping each namespace to its requested attributes. Each attribute is a key with a Boolean indicating whether the verifier intends to retain this attribute (true
) or not (false
).
val mobileCredentialRequest = MobileCredentialRequest(
docType = "<DocType>",
namespaces = NameSpaces(
mapOf(
"<Namespace>" to DataElements(
mapOf(
"<AttributeName1>" to false,
"<AttributeName2>" to false,
"<AttributeName3>" to false
)
)
)
)
)
docType
: The type of credential being requested (e.g., an mDL).namespaces
: A map of requested attributes under each namespace, where false indicates the verifier does not intent to retain this attribute.
const mobileCredentialRequest = {
docType: '<DocType>',
namespaces: {
'<Namespace>': {
'<AttributeName1>': false,
'<AttributeName2>': false,
'<AttributeName3>': false
}
}
}
docType
: The type of credential being requested (e.g., an mDL).namespaces
: An object that defines the attributes being requested for each namespace. A value offalse
indicates the verifier does not intent to retain this attribute.
Create a proximity presentation session
- Extend a class with the
ProximityPresentationSessionListener
protocol:
extension VerifierViewModel: ProximityPresentationSessionListener {
public func onEstablished() {
// Handle session establishment: show presentation session details or send a request.
}
public func onTerminated(error: (any Error)?) {
/// Handle session termination
print("Session Terminated")
}
}
- Call the
createProximityPresentationSession
function with an instance of the extended class:
mobileCredentialVerifier.createProximityPresentationSession(encodedDeviceEngagementString: deviceEngagementString, listener: self)
encodedDeviceEngagementString
: Pass the device engagement string retrieved from a QR code presented by the holder.listener
: An object that conforms toProximityPresentationSessionListener
protocol and will handle the session events.
- Implement the
ProximityPresentationSessionListener
interface:
val sessionListener = object : ProximityPresentationSessionListener {
override fun onEstablished() {
// Handle session establishment: show presentation session details or send a request.
}
override fun onTerminated(error: Throwable?) {
Log.d("SessionListener", "Session Terminated")
}
}
- Call the
createProximityPresentationSession
function with an instance of the extended class:
MobileCredentialVerifier.createProximityPresentationSession(activity, deviceEngagementString, sessionListener)
deviceEngagementString
: Pass the device engagement string retrieved from a QR code presented by the holder.sessionListener
: An object that implementsProximityPresentationSessionListener
interface and will handle the session events.
const proximityPresentationSession =
await mobileCredentialVerifier.createProximityPresentationSession({
encodedDeviceEngagementString: encodedDeviceEngagementString,
onSessionTerminated: (error) => {
// Handle session termination or error
}
})
encodedDeviceEngagementString
: Pass the device engagement string retrieved from a QR code presented by the holder.onSessionTerminated
: A callback triggered when the session ends or fails.
The
createProximityPresentationSession
method returns an empty success response, indicating that the session has been created and the
verifier application can send a presentation request to the holder.
Listen to NFC session requests
This capability is currently only available in the Android SDK.
MobileCredentialVerifier.registerForNfcDeviceEngagement(activity, sessionListener)
sessionListener
: An object that implements theProximityPresentationSessionListener
interface and will handle the session events.
MobileCredentialVerifier.deregisterForNfcDeviceEngagement(activity)
This capability is currently only available in the Android SDK.
Send a presentation request
try await mobileCredentialVerifier.sendProximityPresentationRequest(request: [mobileCredentialRequest])
request
: Pass theMobileCredentialRequest
object created in the previous step.skipStatusCheck
: A Boolean indicating whether to skip the revocation status check. Set tofalse
to check credential revocation status as part of the verification.
MobileCredentialVerifier.sendProximityPresentationRequest(request = listOf(mobileCredentialRequest))
request
: Pass theMobileCredentialRequest
object created in the previous step.skipStatusCheck
: A Boolean indicating whether to skip the revocation status check. Set tofalse
to check credential revocation status as part of the verification.
const mobileCredentialResponse =
await proximityPresentationSession.sendProximityPresentationRequest({
request: mobileCredentialRequest,
skipStatusCheck: false
})
request
: Pass theMobileCredentialRequest
object created two steps up.skipStatusCheck
: A Boolean indicating whether to skip the status check. Set tofalse
to check credential revocation status as part of the verification.
Handle the presentation response
The
requestMobileCredentials
method returns a
MobileCredentialResponse
object. This response contains the presentation details provided by the holder, including any errors
encountered and the verification status of the credentials returned in the response:
let mobileCredentialResponse = MobileCredentialResponse(
credentialErrors: [/* CredentialError */],
credentials: [
MobileCredentialPresentation(
branding: /* Branding information for displaying the credential */,
claimErrors: [
/* Namespace */: [
/* ElementID */: /* MobileCredentialResponseErrorCode */
]
],
claims: [
/* Namespace */: [
/* ElementID */: /* MobileCredentialElementValue */
]
],
docType: /* DocType */,
issuerInfo: /* IssuerInfo */,
validityInfo: /* Validity */,
verificationResult: /* VerificationResult */
)
]
)
credentialErrors
: Any requested docTypes not returned by the holder.credentials
: A list of presented credentials with their data, status, and any attribute-specific errors.
The
sendProximityPresentationRequest
method returns a
MobileCredentialResponse
object. This response contains the presentation details provided by the holder, including any errors
encountered and the verification status of the credentials returned in the response:
data class MobileCredentialResponse(
val credentials: List<MobileCredentialPresentation>?,
val credentialErrors: List<CredentialError>?
)
data class MobileCredentialPresentation(
val docType: DocType,
val validityInfo: MobileCredentialValidity,
val claimErrors: Map<NameSpace, Map<DataElementIdentifier, ErrorCode>>?,
val claims: Map<NameSpace, Map<DataElementIdentifier, MobileCredentialElement>>?,
val branding: Branding?,
val issuerInfo: IssuerInfo?,
val verificationResult: MobileCredentialVerificationResult
)
data class CredentialError(
val docType: DocType,
val errorCode: ErrorCode
)
typealias DocType = String
typealias ErrorCode = Int
credentialErrors
: Any requested docTypes not returned by the holder.credentials
: A list of presented credentials with their data, status, and any attribute-specific errors.
The
sendProximityPresentationRequest
returns a
MobileCredentialResponse
object. This response contains the presentation details provided by the holder, including any errors
encountered and the verification status of the credentials returned in the response:
const mobileCredentialResponse = {
credentialErrors: [/* CredentialError */],
credentials: [
{
branding: /* Branding */,
claimErrors: {
/* Namespace */: {
/* ElementID */: /* MobileCredentialResponseErrorCode */
}
},
claims: {
/* Namespace */: {
/* ElementID */: /* MobileCredentialElementValue */
}
},
docType: /* DocType */,
issuerInfo: /* IssuerInfo */,
validityInfo: /* Validity */,
verificationResult: /* VerificationResult */
}
]
};
credentialErrors
: Any requested docTypes not returned by the holder.credentials
: A list of presented credentials with their data, status, and any attribute-specific errors.
How would you rate this page?