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

@noosphere/payload

v0.2.0-alpha.2

Published

Noosphere PayloadData utilities for URI-based payload handling (browser & Node.js compatible)

Readme

@noosphere/payload

PayloadData utilities for URI-based payload handling in Noosphere. Works in both browser and Node.js environments.

Installation

npm install @noosphere/payload

Features

  • URI-based payload resolution - Support for data:, ipfs://, https:// schemes
  • Content integrity verification - Automatic keccak256 hash verification
  • Multiple storage backends - IPFS (Pinata), S3/R2, Data URI
  • Browser & Node.js compatible - Works in both environments
  • Automatic storage selection - Uploads large payloads to external storage

Quick Start

Creating PayloadData

import { createDataUriPayload, createIpfsPayload } from '@noosphere/payload';

// Small data - inline as data: URI
const smallPayload = createDataUriPayload('{"action": "ping"}');
// { contentHash: '0x...', uri: 'data:application/json;base64,...' }

// Large data - reference IPFS CID
const largePayload = createIpfsPayload(largeContent, 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG');
// { contentHash: '0x...', uri: 'ipfs://QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG' }

Resolving PayloadData

import { PayloadResolver } from '@noosphere/payload';

const resolver = new PayloadResolver({
  ipfs: {
    gateway: 'https://ipfs.io/ipfs/',
  },
});

// Resolve any PayloadData to actual content
const { content, verified, type } = await resolver.resolve(payload);
console.log(content);   // The actual content
console.log(verified);  // true if hash matches
console.log(type);      // 'data_uri' | 'ipfs' | 'https' | ...

Auto-encoding with Upload

import { PayloadResolver } from '@noosphere/payload';

const resolver = new PayloadResolver({
  uploadThreshold: 1024, // 1KB
  defaultStorage: 'ipfs',
  ipfs: {
    pinataApiKey: 'your-api-key',
    pinataApiSecret: 'your-api-secret',
  },
});

// Small content -> data: URI
const small = await resolver.encode('small content');
// { contentHash: '0x...', uri: 'data:...' }

// Large content -> automatically uploaded to IPFS
const large = await resolver.encode(largeContent);
// { contentHash: '0x...', uri: 'ipfs://Qm...' }

Supported URI Schemes

| Scheme | Description | Use Case | |--------|-------------|----------| | Scheme | Description | Use Case | |--------|-------------|----------| | data: | Inline base64-encoded | Small payloads (< threshold) | | ipfs:// | IPFS content addressing | Decentralized storage | | https:// | HTTP(S) URLs | S3, R2, any HTTP storage |

Storage Backends

Data URI (Inline)

import { DataUriStorage } from '@noosphere/payload';

const storage = new DataUriStorage();
const { uri } = await storage.upload('content');
// uri = 'data:application/json;base64,...'

IPFS (Pinata)

import { IpfsStorage } from '@noosphere/payload';

const storage = new IpfsStorage({
  gateway: 'https://ipfs.io/ipfs/',
  pinataApiKey: 'your-api-key',
  pinataApiSecret: 'your-api-secret',
});

const { uri, contentId } = await storage.upload('content');
// uri = 'ipfs://Qm...'
// contentId = 'Qm...'

S3/R2

import { S3Storage } from '@noosphere/payload';

const storage = new S3Storage({
  endpoint: 'https://account.r2.cloudflarestorage.com',
  bucket: 'my-bucket',
  accessKeyId: 'access-key',
  secretAccessKey: 'secret-key',
  publicUrlBase: 'https://pub-xxx.r2.dev',
});

const { uri } = await storage.upload('content');
// uri = 'https://pub-xxx.r2.dev/hash.json'

API Reference

PayloadUtils

// Create PayloadData
createDataUriPayload(content: string, mimeType?: string): PayloadData
createIpfsPayload(content: string, cid: string): PayloadData
createHttpsPayload(content: string, url: string): PayloadData
createInlinePayload(content: string): PayloadData

// Utilities
computeContentHash(content: string): `0x${string}`
verifyContentHash(content: string, expectedHash: `0x${string}`): boolean
detectPayloadType(payload: PayloadData): PayloadType
parseDataUri(uri: string): { mimeType, encoding, content }
extractIpfsCid(uri: string): string

PayloadResolver

class PayloadResolver {
  constructor(config?: PayloadResolverConfig)

  // Resolve PayloadData to content
  resolve(payload: PayloadData, inlineData?: string): Promise<ResolvedPayload>

  // Encode content as PayloadData (with auto-upload)
  encode(content: string, options?: { forceUpload?: boolean, storage?: 'ipfs' | 's3' | 'data' }): Promise<PayloadData>

  // Check if content should be uploaded
  shouldUpload(content: string): boolean
}

Types

interface PayloadData {
  contentHash: `0x${string}`;  // keccak256(content)
  uri: string;                  // Full URI
}

type PayloadType = 'inline' | 'data_uri' | 'ipfs' | 'https' | 'http' | 'unknown';

interface ResolvedPayload {
  content: string;
  verified: boolean;
  type: PayloadType;
}

License

MIT