JavaScript / TypeScript SDK
Use the official @dlbr/eid-sdk package to create verification sessions, wait for results, verify webhooks, and handle API errors from your Node.js backend.
Install
Requires Node.js 20 or newer. The SDK is an ES module and includes TypeScript types.
pnpm add @dlbr/eid-sdkConfigure your backend
Get a Test API key from Console and inject it as DLBR_API_KEY through your server's secret manager. The public API origin is https://api.dlbr.app; the key selects Test or Live mode. Setting mode: 'test' makes the SDK reject a mismatched key locally.
import { EidClient } from '@dlbr/eid-sdk';
const apiKey = process.env.DLBR_API_KEY;
if (!apiKey) throw new Error('DLBR_API_KEY is required');
const eid = new EidClient({
apiKey,
mode: 'test',
timeoutMs: 10_000,
maxNetworkRetries: 2,
});Keep this client in your backend. Never embed the API key in a browser bundle. Console login and the Docs Try it session are separate from SDK API authentication.
Create, wait, and delete
Unlike the raw HTTP Quickstart, which illustrates SD-JWT with is_over_18, this helper uses mDOC with age_over_18. These are different approved credential profiles; do not interchange their claim names or issuer settings. Both examples use the same server-side DLBR_API_KEY environment variable.
The Age 18+ helper requests the dedicated Proof of Age mDOC and only its boolean threshold. Use an issuer and intended-use identifier registered for your relying party. If several relying-party instances are active, also pass relying_party_instance_id to the helper.
import { createAge18Request } from '@dlbr/eid-sdk';
const issuerId = process.env.DLBR_AGE_ISSUER;
const intendedUseId = process.env.DLBR_AGE_INTENDED_USE;
if (!issuerId || !intendedUseId) {
throw new Error('Configure the registered issuer and intended use');
}
const session = await eid.sessions.create(createAge18Request({
issuer_id: issuerId,
intended_use_id: intendedUseId,
}));
// Send session.qr_code_url to your UI so the user can open their wallet.
try {
const result = await eid.sessions.waitForCompletion(session.session_id, {
timeoutMs: 120_000,
pollIntervalMs: 1_000,
});
const age = result.claims?.age18 as { age_over_18?: boolean } | undefined;
const eligible = result.status === 'VERIFIED' && age?.age_over_18 === true;
// Apply your business decision using eligible; do not log raw claims.
} finally {
await eid.sessions.cancel(session.session_id);
}waitForCompletion returns on VERIFIED, FAILED, or EXPIRED; a completed wait does not by itself mean successful verification. Read the result promptly: claims are available for the short result-retention window, up to 30 seconds, or until earlier deletion. sessions.cancel deletes the session, including a completed result.
Handle API errors
import { DlbrIdApiError } from '@dlbr/eid-sdk';
try {
await eid.auth.whoami();
} catch (error) {
if (error instanceof DlbrIdApiError) {
console.error({
status: error.status,
code: error.code,
requestId: error.requestId,
});
}
throw error;
}Use error codes and request IDs for support. Keep API keys, raw response bodies, and disclosed claims out of logs.
More SDK resources
The SDK also provides PID onboarding and mDL request helpers, session event streams, webhook signature verification, and pagination helpers. See the complete SDK API reference and SDK examples.
For raw HTTP examples, see Quickstart. For local webhook development, see CLI.