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

browsermesh-primitives

v0.1.1

Published

Shared primitives for browser mesh networking — wire format, identity (Ed25519), CRDTs, capabilities, trust model, and ACL engine

Readme

browsermesh-primitives

Shared primitives for browser mesh networking -- wire format, identity (Ed25519), CRDTs, capabilities, trust model, and ACL engine. Zero dependencies, pure ES modules, runs in browsers and Node.js.

Install

npm install browsermesh-primitives

Or via CDN:

<script type="module">
  import { PodIdentity, VectorClock, ACLEngine } from 'https://esm.sh/browsermesh-primitives'
</script>

Quick Start

import {
  PodIdentity,
  VectorClock,
  ORSet,
  CapabilityToken,
  ACLEngine,
  encodeMeshMessage,
  decodeMeshMessage,
} from 'browsermesh-primitives'

// Generate an Ed25519 identity
const identity = await PodIdentity.generate()
console.log(identity.podId) // base64url-encoded SHA-256 of public key

// Sign and verify data
const data = new TextEncoder().encode('hello mesh')
const sig = await identity.sign(data)
const ok = await PodIdentity.verify(identity.keyPair.publicKey, data, sig)

// CRDTs -- merge state across peers
const clockA = new VectorClock()
clockA.increment('node-a')
const clockB = new VectorClock()
clockB.increment('node-b')
const merged = clockA.merge(clockB)

// Observed-Remove Set
const set = new ORSet()
set.add('item', identity.podId)
console.log(set.has('item')) // true

API Overview

Constants & Errors

  • MESH_TYPE -- message type constants
  • MESH_ERROR -- error code constants
  • MeshError, MeshProtocolError, MeshCapabilityError -- error classes

Identity

  • PodIdentity -- Ed25519 key pair with sign/verify
  • derivePodId(publicKey) -- SHA-256 hash to base64url pod ID
  • encodeBase64url(bytes) / decodeBase64url(str) -- URL-safe base64

Wire Format

  • messageTypeRegistry -- extensible registry of message types
  • encodeMeshMessage(msg) / decodeMeshMessage(bytes) -- binary serialization

Capabilities

  • CapabilityToken -- scoped capability with expiry
  • parseScope(str) / matchScope(pattern, target) -- scope parsing and matching

Trust

  • TRUST_CATEGORIES -- predefined trust category constants
  • createTrustEdge(from, to, category, score) -- weighted trust edge
  • computeTransitiveTrust(edges, source, target) -- transitive trust score

ACL

  • ACLEngine -- evaluate access grants against resource patterns
  • Permission -- permission level enum
  • AccessGrant -- grant struct with resource pattern, permission, and principal
  • matchResourcePattern(pattern, resource) -- glob-style resource matching
  • generateGrantId() -- unique grant ID generator

CRDTs

  • VectorClock -- partial-order logical clock with merge
  • LWWRegister -- last-writer-wins register with nodeId tiebreak
  • GCounter -- grow-only counter
  • PNCounter -- positive-negative counter
  • ORSet -- observed-remove set (add-wins semantics)
  • RGA -- replicated growable array (ordered list)
  • LWWMap -- last-writer-wins map with tombstones

All CRDTs support merge(), toJSON(), and fromJSON() for serialization.

Test Utilities

  • DeterministicRNG -- seeded RNG for reproducible tests
  • LocalChannel / createLocalChannelPair() -- in-memory transport
  • TestMesh -- lightweight mesh harness
  • TESTMESH_LIMITS -- default resource limits for test meshes

License

MIT