Tap2iD SDK for Windows - API Reference
API reference for the Tap2iD Windows SDK. Covers SDK initialization and mDL verification over BLE and NFC.
Overview
The Tap2iD Windows SDK verifies ISO 18013-5 mobile driver's licenses (mDLs) over BLE and NFC. Use Tap2iDSdk: initialize it once with your license key, then call VerifyMdoc for each session.
- Language: C# / .NET 8.0
- Platform: Windows 10 / 11 (x64)
- Transport: BLE, NFC.
- Standard: ISO/IEC 18013-5:2021
Installation
Add the Credence ID Nexus repository to your NuGet sources in Visual Studio, then install Tap2iDSdk. Requires .NET 8.0 and Windows 11+.
NuGet Source URL
https://nexus.credenceid.com/repository/tap2id-sdk-nuget/
Auto-installed dependencies
Initialize SDK
Call InitSdk once at startup, before any mDL verification. Pass your license key in CoreSdkConfig, and attach result callbacks through InitSdkResultListener.
/// Initializes the SDK with the provided configuration.
public void InitSdk(
CoreSdkConfig coreSdkConfig,
InitSdkResultListener sdkInitlistener
);
CoreSdkConfig
| Property | Type | Default | Description |
|---|---|---|---|
| ApiKey | string | "" | Your Verify with Credence license key. required |
| PackageName | string | "" | Application package identifier. optional |
InitSdkResultListener delegates
Example
var config = new CoreSdkConfig { ApiKey = "YOUR_API_KEY_HERE" };
var listener = new InitSdkResultListener
{
OnInitializationSuccess = result => Console.WriteLine("SDK ready"),
OnInitializationFailure = (e, msg) => Console.WriteLine($"Failed: {e}: {msg}")
};
sdk.InitSdk(config, listener);
Verify mDL
Call VerifyMdocAsync with the engagement string from a QR scan, NFC tap, or BLE discovery. Subscribe to DelegateVerifyState for progress updates.
public Task<Tap2iDResult> VerifyMdocAsync(
MdocConfig mdocConfig,
DelegateVerifyState State,
CancellationToken cancellationToken = default
);
MdocConfig Properties
| Property | Type | Default | Description |
|---|---|---|---|
| DeviceEngagementString | string | "" | Encoded engagement payload. Required for QR code engagement |
| EngagementMode | DeviceEngagementMode | QrCode | Physical capture method (QrCode or Nfc). |
| BleWriteOption | BleWriteOption | Write | BLE write mode: Write or WriteWithoutResponse. |
| IsReaderAuthentication | bool | false | Present verifier certificate to holder device. |
| NfcReaderNameFilter | string? | null | Substring to select a specific NFC reader. optional |
| NfcDeviceEngagementTimeout | int | 30s | NFC engagement wait time. Range: 5–300. |
| BleConnectionTimeout | int | 10s | BLE scan + connect phase. Range: 5–300. |
| BleConsentAndDataTransferTimeout | int | 30s | Consent + data transfer after connection. Range: 5–300. |
VerifyState Lifecycle
Example
var config = new MdocConfig
{
DeviceEngagementString = qrCodeData,
EngagementMode = DeviceEngagementMode.QrCode,
BleConnectionTimeout = 15,
BleConsentAndDataTransferTimeout = 45
};
Tap2iDResult result = await sdk.VerifyMdocAsync(config, new DelegateVerifyState
{
OnVerifyState = state => Console.WriteLine($"→ {state}")
});
VerifiedDocument
| Property | Type | Description |
|---|---|---|
| DocType | string | ISO document type, e.g. org.iso.18013.5.1.mDL |
| Authentication | AuthenticationResult | Cryptographic and trust verification for this document. |
| Namespaces | List<NamespaceData> | Attributes organized by namespace → key → value. |
ResultError before accessing Documents: a non-OK result may return an empty or partial list.
Retrieve Data
Iterate through Namespaces and their Items to access attribute values. Binary fields like portrait and signature_usual_mark are returned as byte[].
foreach (var doc in result.Documents)
foreach (var ns in doc.Namespaces)
foreach (var item in ns.Items)
{
if (item.Key == "portrait" && item.Value is byte[] img)
{ /* render as ImageSource */ continue; }
Console.WriteLine($"{item.Key}: {item.Value}");
}
org.iso.18013.5.1. Common fields: family_name, given_name, birth_date, document_number, portrait, driving_privileges.
Security Status
Each VerifiedDocument has an AuthenticationResult with five checks. Review them before trusting the data.
var auth = doc.Authentication;
bool isTrusted = auth.TrustAttributes.IsIssuerTrusted;
bool deviceSigned = auth.SecurityChecks.IsDeviceSignedValid;
bool issuerSigned = auth.SecurityChecks.IsIssuerSignedValid;
bool digestsValid = auth.SecurityChecks.AreDigestsValid;
var msoStatus = auth.MsoValidity.Status; // Valid | NotYetValid | Expired
foreach (var err in auth.ValidationErrors)
Console.WriteLine($"Error: {err.Message}");
| Property | Type | Description |
|---|---|---|
| TrustAttributes.IsIssuerTrusted | bool | Issuing CA found in the SDK trust store. |
| SecurityChecks.IsDeviceSignedValid | bool | ECDSA/MAC device signature passes verification. |
| SecurityChecks.IsIssuerSignedValid | bool | Mobile Security Object signature is valid. |
| SecurityChecks.AreDigestsValid | bool | Data item hashes match MSO digests. |
| MsoValidity.Status | MsoStatus | Valid, NotYetValid, or Expired. |
| ValidationErrors | List<ValidationError> | Detailed issues. Empty when all checks pass. |
Class Reference
NfcCommunicationException
Thrown when an error occurs during NFC data exchange.
| Constructor | Description |
|---|---|
NfcCommunicationException(string message) | Creates exception with descriptive message. |
NfcCommunicationException(string message, Exception inner) | Wraps the underlying NFC failure. |
CommunicationBleCentralClientMode
Manages the BLE Central role for reading from a holder device acting as a peripheral.
| Member | Type | Description |
|---|---|---|
| SetTimeout(int) | void | Overrides BLE operation timeout in seconds. |
| BleWriteOption | BleWriteOption | Acknowledged write or fire-and-forget mode. |
| ConsentStarted | EventHandler? | Fires when holder device begins consent flow. |
| ConsentEnded | EventHandler? | Fires when consent flow completes. |
| MessageReceived | MessageReceivedHandler? | Raw BLE message as byte[]. |
Error Codes
Returned via Tap2iDResult.ResultError and the OnInitializationFailure callback.
SDK / License
| Enum name | Value | Description |
|---|---|---|
| OK | 0 | No error. |
| LicenceError | 1 | License is invalid. |
| NoNFCTagDetected | 2 | No NFC tag was presented. |
| LicenceExpiredLicenceError | 10 | License expired. |
| ApiExceptionLicenseError | 11 | Failed to verify license. |
Transaction / Connection
| Enum name | Value | Description |
|---|---|---|
| ERROR_INVALID_BARCODE / ERROR_INVALID_QR_CODE | 111 | Invalid QR code. |
| ERROR_NFC_STATIC_HANDOVER | 112 | NFC connection failed. |
| ERROR_NFC_NEGOTIATED_HANDOVER | 113 | NFC connection failed. |
| ERROR_NFC_NOT_ENABLED | 114 | NFC not enabled. |
| ERROR_DE_CONNECTION_TIMEOUT | 115 | Bluetooth connection timed out. |
| ERROR_NFC_TAG | 116 | NFC connection failed, not an ID. |
| ERROR_GENERAL | 117 | Unknown error. |
| OperationCancelled | 130 | Operation cancelled by caller. |
| ERROR_GENERAL_NFC_DEVICE_ENGAGEMENT | 132 | Unknown NFC error during device engagement. |
| ERROR_TAG_LOST | 133 | NFC tag lost. |
| ERROR_BLE_CONNECTION | 212 | Bluetooth connection failed. |
| ERROR_BLE_L2CAP | 213 | Bluetooth L2CAP connection failed. |
| ERROR_DR_CONNECTION_TIMEOUT | 214 | Data retrieval timed out. |
| ERROR_CONSENT_DENIED_FOR_ALL | 216 | Holder denied sharing all data. |
| ERROR_CONSENT_DENIED_FOR_FEW | 217 | Holder denied sharing some data. |
| ERROR_DR_UNKNOWN_ERROR | 218 | Data retrieval failed, unknown error. |
| ERROR_CONSENT_DENIED_FOR_ALL_ATTRIBUTE | 219 | Consent denied, no attribute returned. |
Supported Hardware
BLE Dongles
The BLE transport uses the Bumble library and requires a compatible USB Bluetooth adapter.
| VID/PID | Device |
|---|---|
| 0BDA / A728 | Realtek BLE Adapter |
| 0BDA / 8771 | Startech Adapter / USBA-BLUETOOTH-V5-C2 |
NFC Readers
Any PC/SC-compatible USB NFC reader. Most readers work with the standard Windows drivers.
QR / Barcode
Any built-in or USB webcam, or USB barcode scanner operating as a standard HID / keyboard wedge device.