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

v0.1.4-rc.2

Published

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

Downloads

19

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 pkarr

🚀 Quick Start

const { Client, Keypair, SignedPacket } = require('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);
await client.publish(packet);

// Resolve later
const resolved = await client.resolve(keypair.public_key_string());
console.log('Records:', resolved.records);

🏗️ API Overview

Core Classes

  • Client - Publish and resolve packets via Pubky relays
  • Keypair - Generate and manage Ed25519 keypairs
  • SignedPacket - Build and sign DNS packets
  • Utils - Utility functions for validation

Client Methods

const { Client } = require('pkarr');

const client = new Client();                    // Default relays
const client = new Client(relays, timeout);     // Custom configuration

await client.publish(packet);                   // Publish a signed packet
await client.publish(packet, casTimestamp);     // Compare-and-swap publish
const packet = await client.resolve(publicKey); // Resolve most recent packet
const packet = await client.resolveMostRecent(publicKey); // Alternative resolve method

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

Keypair Operations

const { Keypair } = require('pkarr');

const keypair = new Keypair();                    // Generate new keypair
const keypair = Keypair.from_secret_key(bytes);   // From existing secret

const publicKey = keypair.public_key_string();    // Base32 public key
const publicBytes = keypair.public_key_bytes();   // Raw public key bytes
const secretBytes = keypair.secret_key_bytes();   // Raw secret key bytes

Packet Building

const { SignedPacket } = require('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.publicKeyString);
console.log(packet.timestampMs);
console.log(packet.records);

CAS ensures your update only succeeds if the server state hasn't changed since you last read it.

🧪 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('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.