SDK
Verification SDK
Create verification requests and retrieve results using the JavaScript SDK
The VerifierClient handles creating OID4VP authorization requests, polling for results, and generating QR codes.
Setup
import { createVerifierClient } from '@verifiables/eudi-sdk'
const client = createVerifierClient({
apiUrl: 'https://api.verifiables.com',
headers: { Authorization: 'Bearer oat_your_publishable_key' },
})Create a verification request
Using namespace shorthand
const { url, id, version } = await client.createAuthorizationRequest({
namespace: 'eu.europa.ec.eudi.pid.1',
attributes: ['given_name', 'family_name', 'birth_date'],
})Using a DCQL query
const { url, id } = await client.createAuthorizationRequest({
version: 'v1',
dcql_query: {
credentials: [{
id: 'pid',
format: 'mso_mdoc',
meta: { doctype_value: 'eu.europa.ec.eudi.pid.1' },
claims: [
{ path: ['eu.europa.ec.eudi.pid.1', 'given_name'] },
{ path: ['eu.europa.ec.eudi.pid.1', 'family_name'] },
],
}],
},
})Scheme selection
Override the URL scheme for specific wallet compatibility:
const { url, id } = await client.createAuthorizationRequest({
namespace: 'eu.europa.ec.eudi.pid.1',
attributes: ['age_over_18'],
scheme: 'openid4vp', // or 'mdoc-openid4vp', 'haip-vp', 'eu-eaap', 'av'
})The url is what you display to the user: typically as a QR code or a deep link button. The id is used to check for results.
Poll for results
const result = await client.getAuthorizationStatus(id)
if (result.status === 'valid') {
console.log(result.presentation)
console.log(result.verification) // per-credential checks
}With automatic polling
const result = await client.pollAuthorizationStatus(id, {
interval: 2000, // Poll every 2 seconds
timeout: 120000, // Give up after 2 minutes
})With an AbortController
const controller = new AbortController()
// Cancel after 30 seconds
setTimeout(() => controller.abort(), 30000)
const result = await client.pollAuthorizationStatus(id, {
signal: controller.signal,
})Status values
| Status | Meaning |
|---|---|
created | Request created, waiting for wallet scan |
claimed | Wallet scanned, processing |
pending | Processing the response |
valid | Verification succeeded |
failed | Verification failed |
QR code generation
Generate styled QR codes from the authorization URL:
import { generateQRCode, createQRConfig } from '@verifiables/eudi-sdk'
const canvas = document.getElementById('qr') as HTMLCanvasElement
const config = createQRConfig(url)
await generateQRCode(canvas, config)Web component
A drop-in <verifier-element> for quick integration:
import { registerVerifierElement } from '@verifiables/eudi-sdk'
registerVerifierElement()<verifier-element
api-url="https://api.verifiables.com"
api-key="oat_your_publishable_key"
namespace="eu.europa.ec.eudi.pid.1"
attributes="given_name,family_name"
></verifier-element>Draft 18 compatibility
For wallets that only support OID4VP Draft 18 (PEX):
const { url, id } = await client.createAuthorizationRequest({
version: 'draft18',
namespace: 'eu.europa.ec.eudi.pid.1',
attributes: ['given_name', 'family_name'],
})