Skip to content

Tap2iD SDK API Documentation

mreynier-cid edited this page Apr 4, 2025 · 3 revisions

Introduction

The Tap2iD SDK is based on the ISO/IEC 18013-5:2021 standard which establishes an interoperable digital representation for mobile based credentials such as mobile drivers licenses (mDL)

Public APIs for SDK

Step 1: SDK Initialization

You need to initialize SDK before doing any mdoc verification.

/// <summary>
/// Initializes the SDK with the given configuration.
/// </summary>
/// <param name="coreSdkConfig">The configuration object containing api key and necessary parameters to initialize the SDK</param>
/// <param name="sdkInitlistener">This listener object to listen for the results of the Tap2iD SDK initialization process.</param>
public void InitSdk(CoreSdkConfig coreSdkConfig, InitSdkResultListener sdkInitlistener);
public class CoreSdkConfig
{
    // Api Key needed for authentication
    public string ApiKey { get; set; } = "";
}

/// <summary>
///  A delegate that is invoked when the SDK initialization is successful. 
///  The delegate receives an SdkInitializationResult object as a parameter, 
///  providing information about the initialization result.
/// </summary>
public delegate void OnInitializationSuccess(SdkInitializationResult result);

/// <summary>
///  A delegate that is invoked when the SDK initialization fails. 
///  The delegate receives a Tap2iDResultError object as the first parameter, 
///  representing the error that occurred, and a string as the second parameter, 
///  containing a more detailed error message.
/// </summary>
public delegate void OnInitializationFailure(Tap2iDResultError error, string ErrorMessage);

/// <summary>
///  This class is used to listen for the results of the Tap2iD SDK initialization process.
/// </summary>
public class InitSdkResultListener
{
    public OnInitializationSuccess? OnInitializationSuccess { get; set; }
    public OnInitializationFailure? OnInitializationFailure { get; set; }

}

Step 2: Verify MDoc

After initialisation, you can call the VerifyMDocAsync method

/// <summary>
/// Verifies the mDoc in a single-step process, handling engagement, connection, and data retrieval.
/// </summary>
/// <param name="mdocConfig">Configuration with engagement string and Engagement Mode</param>
/// <param name="State">State of the Mdoc verify process</param>
/// <returns> Tap2iDResult containing the error code and the Identity data.</returns>
public Task<Tap2iDResult> VerifyMdocAsync(MdocConfig mdocConfig, DelegateVerifyState State);

Here parameter description:

public class MdocConfig
{
    /// <summary>
    /// Gets or sets the device engagement string.
    /// This string is used for establishing a connection with the mDoc system.
    /// </summary>
    public string DeviceEngagementString { get; set; } = "";

    /// <summary>
    /// Gets or sets the device engagement mode.
    /// Specifies the mode of engagement, such as QR Code or NFC.
    /// </summary>
    public DeviceEngagementMode EngagementMode { get; set; } = DeviceEngagementMode.QrCode;

    /// <summary>
    /// Gets or sets the BLE (Bluetooth Low Energy) write option.Write or Write without response.
    /// </summary>
    public BleWriteOption BleWriteOption { get; set; } = BleWriteOption.Write;

    /// <summary>
    /// Gets or sets the NFC device engagement timeout in seconds.
    /// Specifies the maximum time to wait for NFC-based engagement before timing out.
    /// </summary
    public int NfcDeviceEngagementTimeout { get; set; } = 30;
}

public delegate void OnVerifyState(VerifyState verifyState);

public class DelegateVerifyState
{
    public OnVerifyState? OnVerifyState { get; set; }
}

public enum VerifyState
{
    Unknown,
    DeviceEngagementStarted,
    DeviceEngagementEnded,
    DeviceConnectionStarted,
    DeviceConnectionEnded,
    UserConsentStarted,
    UserConsentEnded,
    DataTransferStarted,
    DataTransferEnded,
    DataValidationStarted,
    DataValidationEnded,
}
Clone this wiki locally