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

@fourotwo/types

v1.0.0

Published

Shared types + DID derivation for fourotwo (facilitator, SDK, registry, dashboard)

Readme

@fourotwo/types

  /$$$$$$                               /$$$$$$    /$$                            
 /$$__  $$                             /$$__  $$  | $$                            
| $$  \__//$$$$$$  /$$   /$$  /$$$$$$ | $$  \ $$ /$$$$$$   /$$  /$$  /$$  /$$$$$$ 
| $$$$   /$$__  $$| $$  | $$ /$$__  $$| $$  | $$|_  $$_/  | $$ | $$ | $$ /$$__  $$
| $$_/  | $$  \ $$| $$  | $$| $$  \__/| $$  | $$  | $$    | $$ | $$ | $$| $$  \ $$
| $$    | $$  | $$| $$  | $$| $$      | $$  | $$  | $$ /$$| $$ | $$ | $$| $$  | $$
| $$    |  $$$$$$/|  $$$$$$/| $$      |  $$$$$$/  |  $$$$/|  $$$$$/$$$$/|  $$$$$$/
|__/     \______/  \______/ |__/       \______/    \___/   \_____/\___/  \______/ 
                                                                                      

Shared types, DID derivation, and the x402 payment-envelope codec for fourotwo.

The single source of truth for the shapes and byte formats used across the fourotwo facilitator, registry, SDK, and dashboard. Because every component imports the same package, DIDs and signed payloads are byte-identical everywhere ensuring no drift between signer and verifier.

Most agent developers use @fourotwo/agent-sdk and never import this directly. Reach for it when you build a server that accepts payments, or need DID/envelope primitives on their own.

Install

npm install @fourotwo/types

DID derivation

A fourotwo agent DID is did:fourotwo:{network}:{address}, derived deterministically from a public key (Casper → blake2b account hash, Base → EVM address).

import { deriveDid, deriveAddress, parseDid } from '@fourotwo/types';

const did = deriveDid('casper', publicKeyHex);
// did:fourotwo:casper:3d5de8c609159a0954e773dd686fb7724428316cb30e00bdc...

const { network, address } = parseDid(did);

Payment envelope codec

The PAYMENT-REQUIRED envelope a server sends on a 402, and the canonical bytes that get signed. Use encodeEnvelope when issuing a 402; the signer and verifier both sign canonicalPaymentBytes so signatures always line up.

import { encodeEnvelope, decodeEnvelope, canonicalPaymentBytes } from '@fourotwo/types';

const header = encodeEnvelope({
  amount: '5000',                 // smallest unit (motes / wei)
  recipient: 'account-hash-...',
  network: 'casper',
  token: 'CSPR',
  expiry: Math.floor(Date.now() / 1000) + 600,
  nonce: 'unique-per-request',    // replay protection
  facilitator: 'https://fourotwo-facilitator.onrender.com',
  minTrustScore: 40,              // optional gating
});

res.writeHead(402, { 'PAYMENT-REQUIRED': header });

What's exported

  • DID / addressesderiveDid, deriveAddress, formatDid, parseDid, isValidDid, casperAccountHash, baseAddress, DID_METHOD
  • Envelope codecencodeEnvelope, decodeEnvelope, canonicalPaymentBytes, canonicalPaymentMessage
  • Trust helperstierForScore, TIER_COLOR
  • TypesPaymentRequired, PaymentPayload, VerifyRequest, VerifyResponse, SettleRequest, SettleResponse, SettlementReceipt, SupportedResponse, TrustScore, TrustTier, TrustDimensions, ChainNetwork, SettlementMode, and more.

License & Terms of Service

Copyright (c) 2026. All rights reserved.

This repository is publicly visible for educational and review purposes only. By viewing this repository, you agree to the following terms:

  • No Duplication: You may not copy, duplicate, reproduce, or clone this source code, in whole or in part, outside of the GitHub platform.
  • No Modification or Distribution: You may not modify, distribute, publish, sub-license, or sell this code under any circumstances.
  • GitHub Platform Exception: In accordance with the GitHub Terms of Service, you are permitted to view and fork this repository strictly within GitHub for your own personal use.

Any unauthorized copying or use of this software constitutes copyright infringement.