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

@trueraft/sdk

v0.2.3

Published

Typed TypeScript SDK for the Trueraft document verification API.

Readme

@trueraft/sdk

Typed TypeScript client for the Trueraft verification + reverse-KYC API. Covers the verify engine (8 doc types), trust scoring, badge lookup, fraud feed, MSME / RERA / litigation / pay-verify, and includes a webhook signature verifier.

Install

npm install @trueraft/sdk

Requires Node ≥ 18 (uses native fetch and AbortSignal.timeout).

Quickstart

import { Trueraft } from "@trueraft/sdk";

const tr = new Trueraft({ apiKey: process.env.TRUERAFT_API_KEY! });

// Verify a single document — RC, DL, PAN, GSTIN, AADHAAR, BANK, FASTAG, CHASSIS
const rc = await tr.verify({ doc_type: "RC", doc_number: "MH12AB1234" });
console.log(rc.data?.owner_name);

What's in here

| Method | Endpoint | Purpose | |---|---|---| | verify() | POST /functions/v1/verify | Single-document verification | | verifyMany() | (parallel verify) | Concurrent batch with rate-limit-safe cap | | driverScore() | POST /functions/v1/driver-score | RC + DL → 0–100 score | | vehicleScore() | POST /functions/v1/trust-score | RC → 0–100 score | | badge() | GET /api/v1/badge | Trueraft Verified badge lookup | | fraudFeed() | GET /api/v1/fraud-feed | Paginated fraud-signal stream (enterprise) | | payVerify() | POST /api/v1/pay-verify | UPI / phone / PAN trust score | | msmeScore() | POST /api/v1/msme-score | MSME vendor-fitness score | | reraCheck() | POST /api/v1/rera-check | RERA registration lookup | | litigationCheck() | POST /api/v1/litigation-check | Court records by name + PAN | | health() | GET /functions/v1/health-check | Live provider status | | verifyWebhookSignature() | (helper) | HMAC-SHA256 webhook verification |

Idempotency

Pass idempotency_key to make a verification replay-safe. The same key returns the cached result for 24 hours instead of re-charging credits:

await tr.verify({
  doc_type:        "RC",
  doc_number:      "MH12AB1234",
  idempotency_key: "order-1284",
});

Errors + retries

All API failures throw a TrueraftError:

import { TrueraftError } from "@trueraft/sdk";

try {
  await tr.verify({ doc_type: "RC", doc_number: "INVALID" });
} catch (err) {
  if (err instanceof TrueraftError) {
    console.error(err.status, err.message, err.requestId, err.retryAfter);
  }
}

The SDK automatically retries on 5xx, 429, and network errors — by default 3 attempts with exponential backoff (200 ms → 400 ms → 800 ms). A server-supplied Retry-After header wins over the default schedule. Override:

new Trueraft({ apiKey: "...", retries: 5, retryBackoffMs: 500 });

4xx errors (other than 429) are not retried — those are caller bugs and should fail fast.

Fraud feed (incremental polling)

let cursor = ""; // store between runs

while (true) {
  const page = await tr.fraudFeed({ since: cursor, limit: 1000 });
  for (const row of page.results) {
    // row.entity_hash is HMAC-SHA256 of the entity — compare against your hashed inputs
  }
  if (page.results.length === 0) break;
  cursor = page.next_since;
}

For high-volume consumers, pass format: "ndjson" and stream the body.

Webhook signature verification

Trueraft signs every outbound webhook delivery with HMAC-SHA256 of the raw body. Verify before trusting:

import express from "express";
import { verifyWebhookSignature } from "@trueraft/sdk";

const app = express();
app.post("/webhooks/trueraft", express.raw({ type: "application/json" }), (req, res) => {
  const sig = req.header("X-Trueraft-Signature") ?? "";
  if (!verifyWebhookSignature(req.body, sig, process.env.TRUERAFT_WEBHOOK_SECRET!)) {
    return res.status(401).end();
  }
  const event = JSON.parse(req.body.toString());
  // ... handle event
  res.status(204).end();
});

The compare is constant-time — safe against signature-leak timing oracles.

Rate-limit awareness

Pass an onResponse hook to inspect rate-limit headers on every call:

new Trueraft({
  apiKey: "...",
  onResponse: ({ url, status, rateLimit }) => {
    if (rateLimit.remaining !== null && rateLimit.remaining < 10) {
      logger.warn(`Trueraft rate-limit low: ${rateLimit.remaining}/${rateLimit.limit}`);
    }
  },
});

Configuration

new Trueraft({
  apiKey:          "trk_live_…",
  baseUrl:         "https://api.trueraft.com",  // engine endpoints (verify, trust-score)
  webBaseUrl:      "https://trueraft.com",      // web endpoints (badge, fraud-feed, etc.)
  timeoutMs:       30_000,
  fetch:           customFetch,                 // override (e.g., undici, node-fetch polyfill)
  retries:         3,
  retryBackoffMs:  200,
  onResponse:      handler,
});

Versioning

This SDK follows the API versioning policy at https://trueraft.com/docs/versioning. Major SDK version bumps track API major bumps (1:1). Minor bumps may add new methods but never remove them. The current API version is v1.

Support

License

MIT