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

@synonymdev/pkarr

v1.0.0

Published

Public-Key Addressable Resource Records (Pkarr); publish and resolve DNS records over Mainline DHT

Readme

Pkarr

Public-Key Addressable Resource Records for publishing and resolving DNS packets over Mainline DHT

📦 Installation

This package is generated via wasm-pack and includes TypeScript definitions.

npm install @synonymdev/pkarr

🚀 Quick Start

const { Client, Keypair, ResolvePolicy, SignedPacket } = require('@synonymdev/pkarr');

// Create a new keypair and client
const keypair = new Keypair();
const client = new Client();

// Build a DNS packet
const builder = SignedPacket.builder();
builder.addTxtRecord("_service", "pkarr=v1.0", 3600);
builder.addARecord("www", "192.168.1.1", 3600);

// Sign and publish
const packet = builder.buildAndSign(keypair);
const storedNodeCount = await client.publish(packet);
console.log(`Stored on at least ${storedNodeCount} DHT nodes`);

// Resolve later
const resolved = await client.resolve(
    keypair.publicKey(),
    ResolvePolicy.CacheFirst,
);
console.log('Records:', resolved?.records ?? 'No packet found');

🏗️ API Overview

Core Classes

  • Client - Publish and resolve packets via Pubky relays
  • ResolvePolicy - Select cache-only, cache-first, or network-only resolution
  • Keypair - Generate and manage Ed25519 keypairs
  • SignedPacket - Build and sign DNS packets
  • Utils - Utility functions for validation

Client Methods

const { Client, ResolvePolicy } = require('@synonymdev/pkarr');

const client = new Client();                          // Default relays and 30s timeout
const customClient = new Client(relays, timeout);     // Custom configuration

const storedNodeCount = await client.publish(packet); // Minimum known DHT node count
const cached = await client.resolve(publicKey, ResolvePolicy.CacheOnly);
const fresh = await client.resolve(publicKey, ResolvePolicy.CacheFirst);
const latest = await client.resolve(publicKey, ResolvePolicy.NetworkOnly);

const relays = Client.defaultRelays();          // Get default relay list

Keypair Operations

const { Keypair } = require('@synonymdev/pkarr');

const keypair = new Keypair();                    // Generate new keypair
const restored = Keypair.fromSecretKey(bytes);    // Restore from an existing secret

const publicKey = keypair.publicKey();            // z-base-32 public key
const publicBytes = keypair.publicKeyBytes();     // Raw public key bytes
const secretBytes = keypair.secretKeyBytes();     // Raw secret key bytes

Packet Building

const { SignedPacket } = require('@synonymdev/pkarr');

const builder = SignedPacket.builder();

// Add DNS records (all 7 supported types)
builder.addTxtRecord(name, value, ttl);         // TXT records
builder.addARecord(name, ipv4, ttl);            // IPv4 addresses
builder.addAAAARecord(name, ipv6, ttl);         // IPv6 addresses
builder.addCnameRecord(name, target, ttl);      // Canonical names
builder.addNsRecord(name, nameserver, ttl);     // Name server records

// SVCB/HTTPS Parameters
const params = {
    port: 443,                           // Port number
    ipv4hint: "192.0.2.1",              // IPv4 hints (string or array)
    ipv6hint: ["2001:db8::1"],          // IPv6 hints (string or array)
    alpn: ["h2", "http/1.1"],           // ALPN protocol IDs
};

builder.addHttpsRecord(name, priority, target, ttl, params);  // HTTPS service records
builder.addSvcbRecord(name, priority, target, ttl, params);   // Service binding records

// Optional: Set custom timestamp
builder.setTimestamp(Date.now());

// Build and sign
const packet = builder.buildAndSign(keypair);

// Access packet data
console.log(packet.publicKey);
console.log(packet.timestampMs);
console.log(packet.records);

resolve returns null when no packet is found. Other resolution failures reject with JavaScript Error objects carrying a stable code, such as NoResponses, NoUsableResponses, or InvalidSignedPacket.

🧪 Examples

Run the example to see Pkarr in action:

npm run example          # Basic publish/resolve workflow

🌐 Network Operations

The client by default uses the following relays:

  • https://pkarr.pubky.app
  • https://pkarr.pubky.org

Custom Configuration

To publish the records to a custom relay, compile the pkarr-relay binary from source. Navigate to the pkarr repository and:

cargo build
./target/debug/pkarr-relay --testnet

After configuring your custom relay, you can initialize a client with custom relay URLs:

const { Client } = require('@synonymdev/pkarr');

const customRelays = ['http://localhost:15411'];
const client = new Client(customRelays, 10000); // 10s timeout

🧪 Testing and Examples

To run tests and examples:

# Run tests. NOTE: Integration tests require a local pkarr-relay server (see Custom Configuration above)
cd pkg
npm run test

# Run examples
npm run example

📄 License

MIT License - see LICENSE file for details.