Affinidi Iota Framework overview

Learn how the Affinidi Iota Framework simplifies secure data sharing with user consent to enhance user experience.

The Affinidi Iota Framework uses OpenID for Verifiable Presentation (OID4VP) - a standard built on OAuth 2.0 - to request and receive data from Affinidi Vault. OID4VP enables secure and simple credential presentation.

Through the OID4VP standard, the request includes a query based on the Presentation Exchange (PEX Query) protocol, which introduces the Presentation Definition parameter. This parameter provides a syntax for defining the required presentation of Verifiable Credentials (VCs) stored in the user’s Affinidi Vault.

Once the user consents to share their data, Affinidi Vault generates the Verifiable Presentation token (VP token) containing the requested VCs.

With the Affinidi Iota Framework:

  • Users share data they already hold in Affinidi Vault, so they fill in fewer forms.
  • Users review and consent to each request before any data is shared.
  • You can start a query from a template in Affinidi Portal and change it to request the data you need.

Data-sharing flow overview

Enabling your website to request user data begins with creating an Affinidi Iota Framework configuration. This setup defines the signing wallet, sets the request token expiration, and specifies the presentation definitions needed to query data from the user’s Affinidi Vault.

Once the configuration is in place, you can integrate the Affinidi Iota Framework into your website using the Affinidi TDK. This integration allows your site to request and receive user data with consent.

The diagrams below show a data-sharing request in WebSockets mode. First, your backend gets the browser the credentials it needs to connect to Affinidi Iota Framework:

After the user signs in and opens a page that needs data, the website backend signs a limited token with its private key and the user's DID, and exchanges it with Affinidi Iota Framework for Iota credentials. The page loads with those credentials, and the frontend uses them to open a live connection to Affinidi Iota Framework. After the user signs in and opens a page that needs data, the website backend signs a limited token with its private key and the user's DID, and exchanges it with Affinidi Iota Framework for Iota credentials. The page loads with those credentials, and the frontend uses them to open a live connection to Affinidi Iota Framework.

With the connection open, the user can share data whenever your page asks for it:

When the user clicks to share data, the frontend sends the request over its connection and receives the signed request token. It opens Affinidi Vault with the token. After the user consents, the Vault creates a Verifiable Presentation and sends it to Affinidi Iota Framework, which sends the VP token to the frontend over the connection. When the user clicks to share data, the frontend sends the request over its connection and receives the signed request token. It opens Affinidi Vault with the token. After the user consents, the Vault creates a Verifiable Presentation and sends it to Affinidi Iota Framework, which sends the VP token to the frontend over the connection.

You can provide different context-based data-sharing requests for your users at every touchpoint within your website, requesting different data sets while giving users value in return.

Affinidi Iota Framework configuration

In the Affinidi Iota Framework configuration, you define the wallet responsible for signing the request token, set the token’s expiration to enhance security, and specify the presentation definitions used to query data from the user’s Affinidi Vault.

You also need to select a data-sharing flow mode which determines how the request will be handled.

Optionally, you can enable verification of the credentials shared by the user. You can also store the user’s consent for future reference.

Affinidi Iota Framework Configuration

  Read more details about Affinidi Iota Framework configuration.

  Query user data using Presentation Definition (PEX Query).

  Test your configuration before starting the integration process with your website.

Data-sharing mode

To integrate with the Affinidi Iota Framework, your app must define how to handle the data-sharing request, including how the response is returned to your website.

The framework supports two modes: WebSockets and Redirect.

WebSockets

In this mode, the browser keeps a live connection to Affinidi Iota Framework. It sends the data-sharing request over the connection, receives the signed request token, and after the user responds, receives either a Verifiable Presentation token (VP token) or an error message.

WebSockets mode requires Affinidi Login, because your backend needs the user’s Decentralised Identifier (DID) to create the limited token it exchanges for the browser’s Iota credentials. It supports both Popup and New Tab options when opening Affinidi Vault - a secure store for user credentials.

Redirect

Redirect mode doesn’t require Affinidi Login. Your backend starts the request with a redirect URL, which must be one of the redirect URLs in your configuration. After the user responds to the Affinidi Vault consent screen, they are redirected to that URL with a response code. Your backend uses the code to fetch the response, which contains either the VP token or an error message. The code works only once and expires shortly after, so fetch the response as soon as the user returns.

The website backend starts a data-sharing request with Affinidi Iota Framework, which checks the redirect URI against the configuration and returns a signed request token. The frontend opens Affinidi Vault with the token. After the user consents, the Vault sends the Verifiable Presentation to Affinidi Iota Framework and receives a response code. The Vault redirects the user back to the website with the code, and the backend exchanges it once for the VP token. The website backend starts a data-sharing request with Affinidi Iota Framework, which checks the redirect URI against the configuration and returns a signed request token. The frontend opens Affinidi Vault with the token. After the user consents, the Vault sends the Verifiable Presentation to Affinidi Iota Framework and receives a response code. The Vault redirects the user back to the website with the code, and the backend exchanges it once for the VP token.

Credential verification

The Affinidi Iota Framework allows you to enable credential verification, sending a VP token shared by the user to the credential verification service. This service checks the digital signature to confirm the credential is authentic and tamper-evident.

  Learn more about the Credential Verification service.

You can enable Consent Logging to store the consent given by the user in Affinidi Vault when they agree to share their data. When enabled, it records the user’s Decentralised Identifier (DID), the type of Verifiable Credential shared, the date of consent, and the consent status.

This feature gives you proof that the user has agreed to share their data. It also provides an overview of how many consents have been given and which credentials were shared.

You can view Consent Logs on the Affinidi Iota Configuration page of Affinidi Portal . This page lets you download and filter logs by the user’s DID.

To access the logs, scroll to the bottom of the page and open the Consents panel.

Affinidi Iota Framework Consent Logs

  Get the consent logs stored on your project.

What’s next

  Implement consent-driven data-sharing flow on your website

  Issue Verifiable Credentials (VCs) to your users

Works with