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

keypointjs

v1.2.2

Published

KeypointJS Identity-First API Framework with Mandatory Authentication

Readme

KeypointJS - Complete Documentation

KeypointJS Banner

A Modern, Extensible Authentication & Authorization Framework for Node.js

Quick StartDocumentationExamplesContributing Philosophy


Project Overview

KeypointJS is a layered authentication and authorization framework for Node.js, featuring:

  • Secure, production-ready authentication & authorization
  • Plugin architecture for extensibility
  • Real-time WebSocket support
  • Audit logging and monitoring
  • Built-in policy engine and scope management

Architecture

Layered Middleware System

┌─────────────────────────────────┐
│ Layer 0: Pre-processing Hooks   │
├─────────────────────────────────┤
│ Layer 1: Protocol Engine        │
├─────────────────────────────────┤
│ Layer 2: CORS Middleware        │
├─────────────────────────────────┤
│ Layer 3: Keypoint Validation    │
├─────────────────────────────────┤
│ Layer 4: Policy Check           │
├─────────────────────────────────┤
│ Layer 5: Plugin Processing      │
├─────────────────────────────────┤
│ Layer 6: Route Execution        │
├─────────────────────────────────┤
│ Layer 7: Response Processing    │
└─────────────────────────────────┘

File Structure & Responsibilities

Core Components (core/)

  • Context.js: Base request context
  • Request/Response wrapper
  • State management
  • Plugin data storage
  • JSON, text, HTML helpers
  • Header & query accessors

Protocol Engine (ProtocolEngine.js)

  • HTTP/HTTPS/WebSocket detection
  • Body parsing (JSON, form data)
  • IP extraction & validation
  • Request size limiting

Keypoint System (keypoint/)

  • Keypoint.js: Keypoint entity, scopes, protocols, expiration
  • KeypointContext.js: Context extension with scope checking, rate limiting, logging
  • KeypointStorage.js: In-memory & file-based storage with indexing
  • KeypointValidator.js: Extracts & validates keypoints
  • ScopeManager.js: Manages scopes, hierarchy, wildcard patterns

Policy Engine (policy/)

  • PolicyEngine.js: Rule-based access control
  • PolicyRule.js: Built-in & custom rules (method, origin, IP, rate, scope)
  • AccessDecision.js: Aggregates rule results

Plugin System (plugins/)

  • PluginManager.js: Plugin registration, lifecycle, hooks
  • AuditLogger.js: Request/response logging with rotation
  • RateLimiter.js: Keypoint-based rate limiting
  • WebSocketGuard.js: Secure WebSocket connections

Router (router/)

  • MinimalRouter.js: Simple HTTP router with method/path matching

Main Framework (keypointJS.js)

  • Orchestrates all components
  • Server creation & configuration
  • Statistics & health checks
  • Event emission & error handling

Quick Start

Installation

npm install keypointjs
# or
yarn add keypointjs
# or
pnpm add keypointjs

Initialization

import { KeypointJS } from './src/keypointJS.js';

const api = new KeypointJS({
  requireKeypoint: true,
  strictMode: false,
  enableCORS: true,
  maxRequestSize: '5mb'
});

Create Keypoint

const keypoint = await api.createKeypoint({
  keyId: 'test_key',
  secret: 'test_secret',
  scopes: ['api:public', 'users:read'],
  protocols: ['https', 'wss'],
  allowedOrigins: ['https://example.com'],
  rateLimit: { requests: 1000, window: 3600 }
});

Define Routes

api.get('/api/data', (ctx) => {
  return ctx.json({
    data: 'protected data',
    keypointId: ctx.getKeypointId(),
    scopes: ctx.keypoint?.scopes
  });
});

api.post('/api/webhook', (ctx) => {
  return ctx.json({ received: true });
});

Start Server

api.listen(3000, 'localhost', () => {
  console.log('Server running on port 3000');
});

Authentication Flow

  1. Request with Keypoint
GET /api/data HTTP/1.1
Host: localhost:3000
X-Keypoint-ID: test_key
X-Keypoint-Secret: test_secret
  1. Validation Process
Layer 1: ProtocolEngine (detect, parse)
Layer 2: KeypointValidator (validate keypoint)
Layer 3: PolicyEngine (evaluate rules)
Layer 4: Router (execute handler)
Layer 5: Response (format & return)
  1. Scope-Based Authorization
api.get('/api/users', (ctx) => {
  if (!ctx.hasScope('users:read')) {
    return ctx.status(403).json({ error: 'Insufficient scope' });
  }
  // Return user data
});

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Add tests for your changes
  4. Ensure all tests pass (npm test)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

Apache-2.0 license - see the LICENSE file for details.


Support

  • Documentation: Full API documentation in source code
  • Issues: Report bugs via GitHub issues
  • Contributions: PRs welcome
  • Questions: Open a discussion for usage questions

KeypointJS is Independent

KeypointJS does not depend on Express, Fastify, or any third-party HTTP framework. It ships with its own HTTP server, routing system, middleware pipeline, and security layer.

Created Base ♥️ KeypointJS

AnasBex - (づ ̄ ³ ̄)づ

KeypointJS provides a comprehensive, layered approach to API security with extensibility through plugins, real-time WebSocket capabilities, and detailed monitoring through audit logging. The framework is production-ready with built-in security features and can be extended to meet specific requirements.