Presentation of Attestations

A relying party can request a user’s credentials. This process is called Presentation. The purpose for the user is to verify against a relying party e.g. one’s degree from a university, or one’s age. A relying party requests a certain Attestation and all, or a subset, of its containing Claims aka its data fields, e.g. first-name, last-name, birthdate,…

General Usage

To start a presentation to a relying party, the requesting side issues a requestUrl, presented as a QR-Code on a website or a deeplink on a website leading into a wallet app (see Installation to make sure the app is set up properly). The requestUrl String is passed to the SDK to start a presentation process and returns different events to lead the app through it. The InfoEvent and AttestationSelectionEvent both contain a result of type CompletableDeferred to continue the flow.

After the InfoEvent’s result is completed, the SDK provides an AuthenticationSelectionEvent providing a list of Attestations matching the request of the relying party. Complete the AttestationSelectionEvent’s result by passing the selected attestation’s attestationId to continue the flow.

[!NOTE] It’s currently not possible to present more than one credential at a time. This is object of a future version.

var infoResult: CompletableDeferred<Unit>? = null
var attestationSelectionResult: CompletableDeferred<String>? = null

suspend fun startPresentationWith(requestUrl: String) {
    walletSdk.presentations.presentWith(requestUrl).collect { event ->
        when (event) {
            is PresentationEvent.InfoEvent -> {
                val presentationRequest = event.presentationRequest /
                // show in app what's requested
                infoResult = event.result
            }
            is PresentationEvent.AttestationSelectionEvent -> {
                val attestations = event.attestations
                // show in app list of attestations matching the request
                attestationSelectionResult = event.result
            }
            PresentationEvent.InvalidRequestEvent,
            is PresentationEvent.NotImplementedEvent,
            PresentationEvent.ParsingErrorEvent
            is PresentationEvent.ErrorEvent,
            is PresentationEvent.PresentationFailedEvent,
            -> {
                // handle error in app
            }
            is PresentationEvent.PresentationSuccessEvent -> {
                // show success
            }
        }
    }
}
// if current flow item is InfoEvent, go on with completing the InfoResult. This will trigger the SDK to
// return a PrestationEvent.AttestationSelectionEvent with a list of attestations matching the request
fun showMatchingCredentials() {
    infoResult?.complete(Unit)
    infoResult = null
}
// if current flow item is AttestationSelectionEvent, go on with completeting the AttestationSelectionResult
// and pass the attestationId of the selected Attestation. This will trigger the SDK to present the
// selected attestation with all its claims to the verifying party.
fun presentSelectedAttestation(attestationId: String) {
    attestationSelectionResult?.complete(attestationId)
    attestationSelectionResult = null
}