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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pkarr

v1.4.1

Published

client, server and CLI for public-key addressable resource records

Downloads

162

Readme

Pkarr

JavaScript implementation of Pkarr.

Usage

CLI

Publish resource records by passing a passphrase.

$ pkarr publish
◌  Enter a passphrase (learn more at https://www.useapassphrase.com/)
   Passphrase: ***********
   ❯ pk:54ftp7om3nkc619oaxwbz4mg4btzesnnu1k63pukonzt36xq144y
◌  Enter records to publish:
   ❯ foo bar
   ❯ answer 42
   ❯ Add record or press enter to submit
 ✔ Published Resource Records (8.29 seconds)

Resolve resource records of a public key

$ pkarr resolve pk:54ftp7om3nkc619oaxwbz4mg4btzesnnu1k63pukonzt36xq144y
 ✔ Resolved (1.51 seconds)
  ❯ foo    bar
  ❯ answer 42

  › updated_at: 4/9/2023, 8:48:21 AM
  › size      : 39/1000 bytes
  › from      : 129.159.143.235:8999

Keep your or your friend's records alive

$ pkarr keepalive add [url1] [url2] ...
 ✔  Successfully updated list of keys!

$ pkarr keepalive remove [url1] [url2] ...
 ✔  Successfully updated list of keys!

$ pkarr keepalive list
  ❯  yqrx81zchh6aotjj85s96gdqbmsoprxr3ks6ks6y8eccpj8b7oiy

$ pkarr keepalive
Starting republisher...

Relay

Run an HTTP relay to use Pkarr in UDP-less environments. Read more

pkarr relay

Consider adding your relay to the list of free and public relays

Client

In browsers and devices behind NAT, you can make HTTP requests to a any pkarr server.

import { Pkarr, SignedPacket, generateKeyPair } from '../index.js'

const keypair = generateKeyPair()

{
  // Create a DNS packet
  const packet = {
    id: 0,
    type: 'response',
    flags: 0,
    answers: [
      { name: '_matrix', type: 'TXT', class: 'IN', data: '@foobar:example.com' }
    ]
  }

  // Create a Sgined Packet
  const signedPacket = SignedPacket.fromPacket(keyPair, packet)

  // Send it to a relay
  const response = await Pkarr.relayPut(serverA.address, signedPacket)
}

{
  // === Resolve a packet ===
  const signedPacket = await Pkarr.relayGet(serverB.address, keyPair.publicKey)

  // Get a dns packet corrisponding to a public key from another server
  const {seq, packet} = Pkarr.resolve(key, ["relay.pkarr.org"])
}

API

Pkarr.relayPut(relayAddress, signedPacket)

Send a SignedPacket to a the DHT through an HTTP relay.

const signedPacket = Pkarr.relayGet(relayAddress, publicKey)

Get a SignedPacket from the DHT through an HTTP relay.

If returned, SignedPacket is valid and verified.

const signedPacket = SignedPacket.fromPacket(keyPair, dnsPacket)

Create a SignedPacket from a dns packet and a KeyPair

Notice that internally it will add the zbase32 encoded publicKey as the TLD of every answer in the packet, for example record {name: 'foo', data: 'bar'} will become {name: 'foo.8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo', data: 'bar'}.

const signedPacket = SignedPacket.fromBytes(publicKey, bytes)

Create a SignedPacket from bytes received from the HTTP relay, after verifying the signature.

const publicKey = signedPacket.publicKey()

Returns the publicKey

const bytes = signedPacket.bytes()

Returns the bytes of the signature, encoded timestamp and encoded packet as defined in the relay spec.

const signature = signedPacket.signature()

Returns the Signature of the signed packet

const packet = signedPacket.packet()

Returns the DNS packet

const records = signedPacket.resourceRecord(name)

Returns the resource records from the internal dns packet, that matches name, which can be relative to the TLD so you don't have to pass the full name, so foo instead of foo.8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo