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 🙏

© 2025 – Pkg Stats / Ryan Hefner

pow-auth

v1.1.0

Published

Hashcash-based authentication module using Web Crypto API

Readme

Pow Auth

A proof-of-work based authentication module using Web Crypto API.

Features

  • Hashcash-style proof of work authentication
  • Configurable difficulty level
  • Replay attack protection using LRU cache
  • Time-based validation with configurable windows
  • Built on Web Crypto API for secure cryptographic operations

Installation

npm install pow-auth

Usage

import { PowAuth } from 'pow-auth';

// Create a new instance with difficulty level 2 (requiring 2 leading zeros)
const auth = new PowAuth({ 
  difficulty: 2,
  timeWindow: 300000,    // 5 minutes
  timeTolerance: 60000,  // 1 minute
  maxCacheSize: 10000    // Maximum number of proofs to cache
});

// Generate a key from username and password
const key = await auth.generateKey('username', 'password');

// Generate a proof of work
const proof = await auth.generateProof('username', 'password');

// Verify the proof
const result = await auth.verifyProof(proof, key);
if (result.valid) {
  console.log('Authentication successful');
} else {
  console.log(`Authentication failed: ${result.reason}`);
}

API

new PowAuth(config)

Creates a new PowAuth instance.

Config Options

  • difficulty: Number of leading zeros required for proof of work
  • timeWindow: Time window in milliseconds (default: 300000, 5 minutes)
  • timeTolerance: Time tolerance in milliseconds (default: 60000, 1 minute)
  • maxCacheSize: Maximum number of used proofs to store (default: 10000)

generateKey(name: string, password: string): Promise<string>

Generates a SHA-256 hash key from name and password.

generateProof(name: string, password: string): Promise<Proof>

Generates a proof of work based on the hashcash principle.

Returns a proof object containing:

  • name: Username
  • ts: Timestamp
  • nonce: Nonce value
  • hash: Generated hash

verifyProof(proof: Proof, key: string): Promise<VerifyResult>

Verifies a proof against a key.

Returns a result object containing:

  • valid: Boolean indicating if proof is valid
  • code: Status code ('OK' or error code)
  • reason: Description of the result

Error Codes

  • EXPIRED: Proof has expired
  • FUTURE_TIMESTAMP: Proof timestamp is too far in the future
  • REPLAY: Proof has already been used
  • INSUFFICIENT_DIFFICULTY: Hash does not meet difficulty requirement
  • INVALID_HASH: Hash verification failed

Security Considerations

  1. The difficulty level should be set based on your security requirements
  2. Time windows should be adjusted based on your network latency expectations
  3. Cache size should be set based on your expected traffic volume

License

MIT