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

qiuth

v0.1.2

Published

Multi-factor authentication for API keys through IP allowlisting, TOTP-based MFA, and certificate-based authentication

Downloads

12

Readme

🔐 Qiuth

Multi-Factor Authentication for API Keys - Stop treating API keys like passwords.

npm version License: MIT TypeScript Tests Coverage

Qiuth transforms API keys from bearer tokens into proof-of-possession tokens, requiring multiple authentication factors to prevent unauthorized access—even if your API key is leaked.


🚨 The Problem

API keys are single points of failure. If your API key is leaked (committed to GitHub, intercepted in transit, stolen from logs), an attacker has unlimited access to your API.

# Your .env file accidentally committed to GitHub
API_KEY=sk_live_abc123def456

# Attacker finds it and has full access
curl -H "Authorization: Bearer sk_live_abc123def456" https://api.yourapp.com/data
# ✅ Success - Attacker downloads all your data

This happens more often than you think:

  • 🔴 Thousands of API keys leaked on GitHub every day
  • 🔴 .env files accidentally committed to public repos
  • 🔴 API keys logged in error messages or monitoring tools
  • 🔴 Keys intercepted in transit or stolen from compromised systems
  • 🔴 Even with key pairs, if the private key is leaked, it's game over

✨ The Solution

Qiuth adds multi-factor authentication to your API keys, transforming them from bearer tokens (anyone with the key can use it) into proof-of-possession tokens (you need the key PLUS additional factors).

Three Layers of Defense

  1. 🌐 IP Allowlisting - First line of defense

    • Verify requests come from authorized locations
    • Support for IPv4/IPv6 CIDR notation
    • Blocks unauthorized networks immediately
  2. 🔢 TOTP MFA - Time-based one-time passwords

    • Works for service accounts (programmatic)
    • Tokens change every 30 seconds
    • Even if API key is leaked, attacker needs TOTP secret
  3. 🔑 Certificate Authentication - Cryptographic proof

    • Requires private key to sign each request
    • Prevents replay attacks with timestamp validation
    • Even if API key + TOTP are leaked, attacker needs private key

Real-World Impact

After Qiuth:

# API key leaked in GitHub
API_KEY=sk_live_abc123def456

# Attacker tries to use it
curl -H "X-API-Key: sk_live_abc123def456" https://api.yourapp.com/data
# ❌ 401 Unauthorized - IP not in allowlist

# Attacker would need ALL THREE:
# 1. API key (leaked)
# 2. TOTP secret (stored separately)
# 3. Private key (never leaves secure environment)
# = Virtually impossible to compromise

🎯 Quick Start

Installation

npm install qiuth

Basic Usage

import { QiuthConfigBuilder, QiuthAuthenticator } from 'qiuth';

// Configure security layers
const config = new QiuthConfigBuilder()
  .withApiKey('your-api-key')
  .withIpAllowlist(['192.168.1.0/24'])
  .withTotp('your-totp-secret')
  .build();

// Authenticate requests
const authenticator = new QiuthAuthenticator();
const result = await authenticator.authenticate({
  apiKey: 'user-provided-key',
  clientIp: '192.168.1.100',
  totpToken: '123456',
  method: 'GET',
  url: 'https://api.example.com/resource',
}, config);

if (result.success) {
  console.log('✅ Authentication successful!');
} else {
  console.error('❌ Authentication failed:', result.errors);
}

Express Middleware

import express from 'express';
import { createQiuthMiddleware, QiuthConfigBuilder } from 'qiuth';

const app = express();

const qiuthAuth = createQiuthMiddleware({
  config: new QiuthConfigBuilder()
    .withApiKey('your-api-key')
    .withIpAllowlist(['0.0.0.0/0'])
    .withTotp('your-totp-secret')
    .build(),
});

app.get('/api/protected', qiuthAuth, (req, res) => {
  res.json({ message: 'Access granted!' });
});

🎬 Interactive Demo

See Qiuth in action in 5 minutes!

# Clone the repo
git clone https://github.com/clay-good/qiuth.git
cd qiuth

# Install dependencies
npm install

# Start the interactive demo
npm run demo

The demo server will start and display test credentials. Open a new terminal and try the test commands to see all three security layers in action!

What you'll experience:

  • ✅ Level 1: Basic API key authentication
  • ✅ Level 2: API key + IP allowlisting
  • ✅ Level 3: API key + IP + TOTP MFA
  • ✅ Level 4: Full security (all three layers)
  • ❌ Failure scenarios (wrong credentials, expired tokens, invalid signatures)

📖 Full Demo Guide →


🚀 Features

Security

  • Three-layer authentication - IP, TOTP, and certificate-based
  • Fail-fast validation - Stop at first failure for performance
  • Replay attack prevention - Timestamp validation
  • Secure credential generation - Cryptographically secure random generation
  • API key hashing - SHA-256 for secure storage

Developer Experience

  • TypeScript-first - Full type definitions included
  • Fluent API - Intuitive configuration builder
  • Express middleware - Drop-in authentication
  • HTTP client - Automatic request signing
  • CLI tool - Generate credentials easily

Production Ready

  • Zero-downtime credential rotation - Transition periods for updates
  • Structured logging - Comprehensive observability
  • Metrics collection - Track authentication performance
  • Environment configuration - Load from env vars
  • Comprehensive error handling - Detailed error messages

Build & Distribution

  • Dual module support - ESM and CommonJS
  • Tree-shakeable - Import only what you need
  • Zero dependencies - Only Node.js built-ins
  • Well-tested - 318 tests with 90%+ coverage

🎯 Use Cases

1. Service-to-Service Authentication

Secure microservices communication with MFA:

const config = new QiuthConfigBuilder()
  .withApiKey(process.env.API_KEY)
  .withIpAllowlist(['10.0.0.0/8']) // Internal network
  .withTotp(process.env.TOTP_SECRET)
  .build();

2. API Key Management

Add MFA to your existing API key system:

app.use('/api', createQiuthMiddleware({ config }));

3. Compliance Requirements

Meet PCI DSS, SOC 2, HIPAA security requirements:

const config = new QiuthConfigBuilder()
  .withApiKey(apiKey)
  .withIpAllowlist(allowedIps)
  .withTotp(totpSecret)
  .withCertificate(publicKey) // Maximum security
  .build();

4. CI/CD Pipeline Security

Secure automated deployments:

// GitHub Actions, Jenkins, etc.
const client = new QiuthClient({
  apiKey: process.env.API_KEY,
  totpSecret: process.env.TOTP_SECRET,
  privateKey: process.env.PRIVATE_KEY,
});

🔒 Security

Qiuth is designed with security as the top priority:

  • No sensitive data logging - API keys and secrets never logged
  • Cryptographically secure - Uses Node.js crypto module
  • RFC compliant - TOTP follows RFC 6238
  • Industry standards - RSA-SHA256 signatures
  • Regular audits - Automated security scanning

📊 Performance

Qiuth is designed for production use with minimal overhead:

  • IP Validation: < 1ms
  • TOTP Validation: < 5ms
  • Certificate Validation: < 10ms
  • Total: < 20ms for all three layers

Bundle Size:

  • ESM: ~60 KB
  • CommonJS: ~61 KB
  • TypeScript declarations: ~48 KB

Stop treating API keys like passwords. Add multi-factor authentication today. 🔐

Get StartedTry the DemoReadme