npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

didit-node-client

v1.0.4

Published

A Nodejs client library for integrating with the DiDiT verification API. This client handles authentication, session management, PDF report generation, and webhook processing.

Readme

DiDiT Node.js Client

A Node.js client library for integrating with the DiDiT verification API. This client handles authentication, session management, PDF report generation, and webhook processing.

Installation

npm install didit-node-client

Configuration

import { DiDiTClient } from "didit-node-client";

const client = new DiDiTClient({
  clientId: "your_client_id",
  clientSecret: "your_client_secret",
  webhookSecret: "your_webhook_secret", // Required for webhook verification
  baseUrl: "https://verification.didit.me", // Optional
  authUrl: "https://apx.didit.me", // Optional
  tokenExpiryBuffer: 300, // Optional: Buffer time in seconds before token expiry
  timeout: 10000, // Optional: Request timeout in milliseconds
  debug: false, // Optional: Enable debug logging
});

Environment variables:

  • DIDIT_CLIENT_ID
  • DIDIT_CLIENT_SECRET
  • DIDIT_WEBHOOK_SECRET
  • DIDIT_BASE_URL
  • DIDIT_AUTH_URL

Features

Session Management

// Create a new verification session
const session = await client.createSession(
  "https://your-callback-url.com",
  "123", // optional Unique identifier or data for the vendor, typically the identifier of the user trying to verify.
  {
    features: "OCR + NFC + FACE", // Optional features configuration
  }
);

// Get session details and verification decision
const sessionDecision = await client.getSession("session_id");

// Update session status (Approve/Decline)
const updatedSession = await client.updateSessionStatus(
  "session_id",
  "Approved",
  "Verification completed successfully" // Optional comment
);

// Generate PDF report
const pdfBuffer = await client.generateSessionPDF("session_id");

Webhook Processing

import express from "express";
import { createRawBodyMiddleware, DiDiTClient } from "didit-node-client";

const app = express();
const client = new DiDiTClient({
  webhookSecret: "your_webhook_secret",
});

// Add raw body middleware for webhook signature verification
app.use("/webhook", createRawBodyMiddleware());

app.post("/webhook", (req, res) => {
  try {
    const payload = client.processWebhook(req);
    console.log("Webhook received:", payload);

    // Handle different webhook events
    switch (payload.event_type) {
      case "session.completed":
        // Handle completed session
        break;
      case "session.declined":
        // Handle declined session
        break;
      // ... handle other events
    }

    res.json({ success: true });
  } catch (error) {
    console.error("Webhook error:", error);
    res.status(400).json({ error: error.message });
  }
});

Error Handling

The client includes comprehensive error handling with context:

try {
  const session = await client.createSession("https://callback-url.com");
} catch (error) {
  console.error("Error:", error.message);
  console.error("Context:", error.context);
  console.error("Original Error:", error.originalError);
  console.error("API Response:", error.response?.data);
}

Authentication

The client automatically handles:

  • Token acquisition and caching
  • Token refresh before expiry
  • Token rotation
  • Request authentication

TypeScript Support

Import types for better type safety:

import {
  DiDiTClient,
  SessionOptions,
  WebhookEvent,
  SessionDecision,
} from "didit-node-client";

Security Best Practices

  1. Store credentials securely:

    • Use environment variables
    • Never commit secrets to source control
    • Use secure secret management in production
  2. Webhook security:

    • Always verify webhook signatures
    • Validate webhook timestamp freshness
    • Use HTTPS endpoints
  3. General security:

    • Use HTTPS for callback URLs
    • Keep dependencies updated
    • Implement proper error handling

Documentation

For detailed API documentation, visit:

License

MIT

Support

For issues and feature requests, please visit our GitHub repository.