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

@nostr-dev-kit/ndk-wot

v0.2.7

Published

Web of Trust utilities for NDK

Readme

@nostr-dev-kit/ndk-wot

Web of Trust utilities for NDK.

Installation

npm install @nostr-dev-kit/ndk-wot

Usage

Build WOT Graph

import NDK from "@nostr-dev-kit/ndk";
import { NDKWoT } from "@nostr-dev-kit/ndk-wot";

const ndk = new NDK();
await ndk.connect();

// Build WOT graph from a user's perspective
const wot = new NDKWoT(ndk, myPubkey);
await wot.load({
    depth: 2,           // 2 hops out
    maxFollows: 1000,   // limit follows per user
    timeout: 30000      // 30s timeout
});

console.log(`WOT has ${wot.size} users`);

Filter Events

import { filterByWoT } from "@nostr-dev-kit/ndk-wot";

// Fetch events broadly
const events = await ndk.fetchEvents({ kinds: [1], limit: 500 });

// Filter by WOT
const filtered = filterByWoT(wot, events, {
    maxDepth: 2,           // only users within 2 hops
    minScore: 0.5,         // minimum WOT score
    includeUnknown: false  // exclude users outside WOT
});

// Adjust filter without re-fetching
const broader = filterByWoT(wot, events, { maxDepth: 3 });
const strictest = filterByWoT(wot, events, { maxDepth: 1 });

Rank Events

import { rankByWoT } from "@nostr-dev-kit/ndk-wot";

// Rank events by WOT
const ranked = rankByWoT(wot, events, {
    algorithm: "distance",  // "distance", "score", or "followers"
    unknownsLast: true      // put unknown users at the end
});

// Or use a custom comparator
const custom = rankByWoT(wot, events, {
    comparator: (a, b) => {
        // Custom ranking logic
        return wot.getScore(b.pubkey) - wot.getScore(a.pubkey);
    }
});

// Or create a comparator for manual sorting
import { createWoTComparator } from "@nostr-dev-kit/ndk-wot";

const comparator = createWoTComparator(wot, { algorithm: "distance" });
events.sort(comparator);

WOT Queries

// Check if user is in WOT
if (wot.includes(pubkey, { maxDepth: 2 })) {
    console.log("User is in WOT");
}

// Get WOT score (0-1, higher = closer)
const score = wot.getScore(pubkey);

// Get distance (hops from root)
const distance = wot.getDistance(pubkey); // returns number or null

// Get scores for multiple users
const scores = wot.getScores([pubkey1, pubkey2, pubkey3]);

// Get all pubkeys in WOT
const allUsers = wot.getAllPubkeys({ maxDepth: 2 });

Ranking Algorithms

  • distance: Ranks by graph distance (closer = higher)
  • score: Ranks by WOT score (inverse of depth)
  • followers: Ranks by number of WOT users following them

API

NDKWoT

  • constructor(ndk: NDK, rootPubkey: string) - Create WOT instance
  • load(options: WoTBuildOptions): Promise<void> - Build the graph
  • getScore(pubkey: string): number - Get WOT score (0-1)
  • getDistance(pubkey: string): number | null - Get hops from root
  • includes(pubkey: string, options?): boolean - Check if in WOT
  • getAllPubkeys(options?): string[] - Get all pubkeys in WOT
  • getScores(pubkeys: string[]): Map<string, number> - Batch scores
  • getNode(pubkey: string): WoTNode | null - Get WOT node details
  • size: number - Total nodes in graph

Filter Functions

  • filterByWoT(wot, events, options) - Filter events by WOT
  • rankByWoT(wot, events, options) - Rank events by WOT
  • createWoTComparator(wot, options) - Create comparator function

License

MIT