Skip to content

@dlbr/eid-sdk quickstarts

The SDK is for trusted server-side runtimes. Keep sk_test_ and sk_live_ API keys in environment variables or platform secrets; never ship them to browser code.

Set DLBR_ID_BASE_URL and DLBR_ID_API_KEY for the selected environment. Sandbox uses mode: "test"; production uses mode: "live".

Node.js

sh
npm install @dlbr/eid-sdk
js
import { DlbrId } from "@dlbr/eid-sdk";

const id = new DlbrId({
  baseUrl: process.env.DLBR_ID_BASE_URL,
  apiKey: process.env.DLBR_ID_API_KEY,
  mode: "test",
});

const session = await id.sessions.create({
  credentials: [{
    format: "mso_mdoc",
    issuer_id: "https://issuer.example",
    namespace: "org.iso.18013.5.1",
    claims: ["given_name", "family_name"],
  }],
});

console.log(session.session_id, session.qr_code_url);

Runnable source: node.mjs.

Bun

sh
bun add @dlbr/eid-sdk
ts
import { DlbrId } from "@dlbr/eid-sdk";

const id = new DlbrId({
  baseUrl: Bun.env.DLBR_ID_BASE_URL,
  apiKey: Bun.env.DLBR_ID_API_KEY ?? "",
  mode: "test",
});

const session = await id.sessions.create({
  credentials: [{ format: "mso_mdoc", issuer_id: "https://issuer.example", namespace: "org.iso.18013.5.1", claims: ["given_name"] }],
});
console.log(session.qr_code_url);

Runnable source: bun.ts.

Deno

ts
import { DlbrId } from "npm:@dlbr/eid-sdk";

const id = new DlbrId({
  baseUrl: Deno.env.get("DLBR_ID_BASE_URL") ?? "",
  apiKey: Deno.env.get("DLBR_ID_API_KEY") ?? "",
  mode: "test",
});

const session = await id.sessions.create({
  credentials: [{ format: "mso_mdoc", issuer_id: "https://issuer.example", namespace: "org.iso.18013.5.1", claims: ["given_name"] }],
});
console.log(session.session_id, session.qr_code_url);

Run with deno run --allow-env --allow-net packages/sdk/examples/deno.ts.

Runnable source: deno.ts.

Cloudflare Workers

Store the key as a Worker secret:

sh
wrangler secret put DLBR_ID_API_KEY --env staging
ts
import { DlbrId } from "@dlbr/eid-sdk";

interface Env {
  DLBR_ID_API_KEY: string;
  DLBR_ID_BASE_URL: string;
}

export default {
  async fetch(_request: Request, env: Env): Promise<Response> {
    const id = new DlbrId({ baseUrl: env.DLBR_ID_BASE_URL, apiKey: env.DLBR_ID_API_KEY, mode: "test" });
    const session = await id.sessions.create({
      credentials: [{ format: "mso_mdoc", issuer_id: "https://issuer.example", namespace: "org.iso.18013.5.1", claims: ["given_name"] }],
    });
    return Response.json({ session_id: session.session_id, qr_code_url: session.qr_code_url });
  },
};

Runnable source: cloudflare-worker.ts.

To receive a signed webhook, pass the unparsed request body and Worker Headers to the SDK verifier before doing any JSON parsing:

ts
import { verifyWebhook } from "@dlbr/eid-sdk";

interface Env {
  DLBR_WEBHOOK_SECRET: string;
}

async function handleWebhook(request: Request, env: Env): Promise<Response> {
  try {
    const event = await verifyWebhook(
      await request.text(),
      request.headers,
      env.DLBR_WEBHOOK_SECRET,
    );
    return Response.json({ received: event.sessionId });
  } catch {
    return Response.json({ error: "ERR_INVALID_WEBHOOK_SIGNATURE" }, { status: 400 });
  }
}

Store DLBR_WEBHOOK_SECRET as a Worker secret. For production replay protection, provide verifyWebhook an atomic WebhookReplayStore backed by a Durable Object or another store with an atomic claim operation.

Environment switching

EnvironmentKey prefixSDK mode
Sandbox/stagingsk_test_test
Live/productionsk_live_live

The SDK rejects an explicit mode/key mismatch and requires HTTPS for live mode.

Built for developers integrating privacy-preserving identity verification.