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

@openprinter/protocol

v0.3.0

Published

Canonical OpenPrinter wire protocol schemas, types, validation, and codecs

Downloads

453

Readme

@openprinter/protocol

Canonical TypeBox schemas, inferred TypeScript types, and cross-runtime JSON codecs for the OpenPrinter wire protocol.

Responsibilities

  • define the versioned discovery, pairing, authentication, and agent/server wire contracts
  • validate every inbound and outbound message at runtime
  • model structured print documents and concrete printer descriptors
  • enforce bounded messages, documents, metadata, and image data
  • generate the committed language-neutral JSON Schema

The package defines authentication data and validates public keys and frames; private-key storage, signature execution, durable credentials, rendering, queues, discovery of local printers, and physical submission belong to other packages and crates.

Install

pnpm add @openprinter/protocol

Usage

import {
  PROTOCOL_VERSION,
  decodeAgentMessage,
  encodeServerMessage,
  type ServerMessage,
} from "@openprinter/protocol";

const inbound = decodeAgentMessage(webSocketPayload);

const heartbeat: ServerMessage = {
  protocolVersion: PROTOCOL_VERSION,
  messageId: "msg_heartbeat_42",
  sentAt: "2026-07-28T10:00:00Z",
  type: "server.heartbeat",
  payload: { timeoutMs: 15_000 },
};

socket.send(encodeServerMessage(heartbeat));

PROTOCOL_VERSION is the string "1". Discovery is validated with parseDiscoveryDocument, pairing requests with parsePairingRequest, and gateway authentication frames with the corresponding decodeGatewayAuthentication* codecs. Ed25519 keys use public OKP JWKs and canonical unpadded base64url values.

agent.job_received means the job is durably stored. agent.job_submitted means a backend accepted it. Neither state universally proves that paper was physically printed.

server.hello includes required OpenPrinterBrandMetadata with a bounded human-readable service name. It intentionally supports no icon or external resource URL.

Printer descriptors omit capabilities when discovery cannot determine them. An absent capability block means unknown; senders must not invent a media width or feature flags merely to populate the field.

Source of truth

The TypeBox schemas under src/schemas are canonical. The deterministic generator emits ../../protocol/schema/openprinter.schema.json; Rust mirrors the schema and validates the same fixtures under ../../protocol/fixtures. TypeBox evaluates string minLength and maxLength against JavaScript string length, so supplementary Unicode characters count as two UTF-16 code units; mirrors must preserve that boundary behavior.

pnpm build
pnpm test
pnpm schema:generate
pnpm schema:check
pnpm check

The public runtime API uses only standard TextEncoder, TextDecoder, and JSON APIs, so it is usable in modern Node.js, Bun, Deno, and browsers. The schema generator and test harness are development-only Node.js tools.

Current status

Protocol version 1 includes server discovery, pairing, challenge authentication, every initial agent/server message, structured document primitives, printer descriptors, print jobs, runtime codecs, and cross-language fixtures. Other versions are rejected explicitly.