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

@veridot/kafka

v3.0.0

Published

Kafka-backed metadata broker for Veridot — distributes signing keys across replicas with LMDB local cache.

Readme

@veridot/kafka

Kafka-backed metadata broker for Veridot.

npm License: MIT Node.js

KafkaMetadataBroker distributes Veridot's public-key metadata across all your services through a Kafka topic, with a local LMDB cache for sub-millisecond reads. It's the recommended broker for high-throughput, multi-region deployments.

Installation

pnpm add @veridot/core @veridot/kafka

Quick start (with the Veridot facade)

import { Veridot } from '@veridot/core';
import { KafkaMetadataBroker } from '@veridot/kafka';

const broker = await KafkaMetadataBroker.of({
  clientId: 'billing-api',
  brokers: process.env.KAFKA_BROKERS!.split(','),  // ['kafka1:9092', 'kafka2:9092']
  topic: 'veridot_keys',                            // optional, defaults to 'veridot_keys'
  dbPath: './data/veridot-keys',                    // optional, LMDB cache path
});

const veridot = await Veridot.create({
  metadataBroker: broker,
  salt: process.env.VDOT_SALT!,
  hashPepper: process.env.VDOT_PEPPER!,
  expectedIssuer: 'https://auth.example.com',
  expectedAudience: 'billing-api',
});

const { accessToken, refreshToken } = await veridot.signWithRefreshToken(
  { sub: 'user-123', role: 'admin' },
  { subject: 'user-123' }
);

Options

| Option | Type | Default | Description | | ---------- | -------------------------- | --------------------- | ------------------------------------------------------------------------- | | clientId | string | — | Kafka client ID — should be unique per service instance. | | brokers | string \| string[] | — | Bootstrap brokers ('kafka:9092' or ['kafka1:9092', 'kafka2:9092']). | | topic | string | 'veridot_keys' | Kafka topic carrying the public-key metadata. | | dbPath | string | './veridot-keys' | LMDB cache directory (one per service instance, must be writable). | | logger | Logger (@veridot/core) | ConsoleLogger | Pluggable structured logger (pino / winston / NestJS / …). |

Architecture

┌──────────────┐  publish   ┌──────────────┐  consume  ┌──────────────┐
│   Issuer     │──────────▶│              │──────────▶│   Verifier   │
│   service    │            │   Kafka      │            │   service    │
│   (RSA priv) │            │   topic      │            │              │
└──────┬───────┘            └──────────────┘            └──────┬───────┘
       │                                                        │
       │  cache  ┌──────────────┐                cache  ┌──────▼───────┐
       └────────▶│   LMDB       │◀───────────────────────│   LMDB       │
                 │   (local)    │                         │   (local)    │
                 └──────────────┘                         └──────────────┘
  • Producers publish key metadata to a Kafka topic.
  • Every consumer keeps a local LMDB mirror so verify() is a sub-millisecond, zero-network operation in the steady state.
  • LMDB survives restarts; on cold start, the broker replays from the topic.

Production tips

Kafka topic configuration

Create the topic with a long retention (or compaction) — clients that lag need to be able to fetch keys signed days ago:

kafka-topics.sh --create --topic veridot_keys \
  --partitions 3 \
  --replication-factor 3 \
  --config cleanup.policy=compact \
  --config min.compaction.lag.ms=86400000

cleanup.policy=compact keeps the last value for each key (= each keyId) forever, perfect for long-lived public keys.

Logger injection

import pino from 'pino';
const log = pino();

const broker = await KafkaMetadataBroker.of({
  clientId: 'billing-api',
  brokers: ['kafka:9092'],
  logger: {
    debug: (m, ctx) => log.debug(ctx, m),
    info:  (m, ctx) => log.info(ctx, m),
    warn:  (m, ctx) => log.warn(ctx, m),
    error: (m, ctx) => log.error(ctx, m),
  },
});

Graceful shutdown

process.on('SIGTERM', async () => {
  await veridot.shutdown();   // disconnects the broker as well
  process.exit(0);
});

Observability hooks

The broker also publishes keys:rotated events on the Veridot event bus:

veridot.events().on('keys:rotated', (e) => {
  metrics.gauge('veridot.active_key', 1, { kid: e.nextKeyId });
});

Environment variables (legacy fallbacks)

If you don't pass options, Config reads from the environment:

| Variable | Maps to | Default | | --------------------------------- | -------------------- | -------------------- | | VDOT_KAFKA_BOOTSTRAP_SERVERS | brokers | localhost:9092 | | VDOT_TOKEN_VERIFIER_TOPIC | topic | veridot_keys | | VDOT_EMBEDDED_DATABASE_PATH | dbPath | ./veridot-keys |

Explicit options always take precedence.

Lower-level usage (no facade)

If you need to drive the broker yourself:

import { GenericSignerVerifier, BasicConfigurer, TokenMode } from '@veridot/core';
import { KafkaMetadataBroker } from '@veridot/kafka';

const broker = await KafkaMetadataBroker.of({ clientId: 'svc', brokers: ['kafka:9092'] });
const signer = new GenericSignerVerifier(broker, process.env.VDOT_SALT!, {
  allowedAlgorithms: ['RS256'],
});

const config = new BasicConfigurer().mode(TokenMode.JWT).validity(15, 'minutes');
const token  = await signer.sign({ userId: 1 }, config);
const data   = await signer.verify(token, JSON.parse);

await signer.shutdown();
await broker.disconnect();

Related packages

License

MIT — see LICENSE.