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

@cv-challenge/server

v1.4.0

Published

Server-side engine and Express adapter for the CV Challenge interactive verification flow.

Readme

@cv-challenge/server

Server-side renderer, token manager, and Express adapter for CV Challenge.

Install

pnpm add @cv-challenge/server

Requirements

  • ffmpeg available in PATH
  • OpenCV for opencv4nodejs

Engine usage

import Motion3DChallenge from '@cv-challenge/server';

const engine = new Motion3DChallenge(180, 60, 3, 20);
const { videoBuffer, hitbox, debug } = await engine.generate({ failureCount: 3 });
const ok = engine.validate({ x: 42, y: 12 }, hitbox);

Constructor defaults:

  • width: 180
  • height: 60
  • durationSec: 3
  • objectCount: 20

generate optionally accepts { failureCount } to shrink cube scale and increase cube count as failures rise.

Express adapter

import express from 'express';
import Motion3DChallenge, {
  createChallengeExpressRouter,
  createChallengeTokenManager
} from '@cv-challenge/server';

const app = express();
app.use(express.json({ limit: '1mb' }));

const engine = new Motion3DChallenge();
const tokenManager = createChallengeTokenManager<{ sessionId: string }>({
  secret: process.env.CHALLENGE_JWT_SECRET ?? 'dev-only-change-me',
  tokenTtlSec: 20,
  successTokenTtlSec: 60
});

const router = createChallengeExpressRouter<{ sessionId: string }>({
  challenge: engine,
  tokenManager,
  onChallenge: ({ req }) => String(req.headers['x-session-id'] ?? req.ip ?? ''),
  onVerified: async ({ req }) => {
    const sessionId = String(req.headers['x-session-id'] ?? '');
    if (!sessionId) return null;
    return { expiresInSec: 60, payload: { sessionId } };
  },
  validateSuccessToken: (payload, { req }) => {
    const sessionId = String(req.headers['x-session-id'] ?? '');
    return payload.payload?.sessionId === sessionId;
  },
  debug: 'info'
});

app.use(router);

Routes

GET /challenge

  • Response: video/webm
  • Headers:
    • X-Challenge-Token
    • X-Challenge-Expires-At
    • X-Challenge-Expires-In
  • Optional request header:
    • X-Challenge-Success-Token
  • 429 response when onChallenge identifies an active challenge:
    • Body: { error: "challenge-already-issued", challengeExpiresAt, challengeExpiresIn }
    • Header: Retry-After
  • 429 response when backoff is active for the requester:
    • Body: { error: "challenge-backoff", backoffExpiresAt, backoffExpiresIn }
    • Header: Retry-After

POST /challenge/verify

  • Body: { token: string, x: number, y: number }
  • Response: { success, reload, successToken, successTokenExpiresAt, successTokenExpiresIn }

Token behavior

  • Challenge tokens are encrypted with the provided secret.
  • Success tokens are encoded only (alg "none"), intended as a short-lived hint to skip cold start.
  • Use validateSuccessToken to bind success tokens to your own session or user data.
  • Success tokens are invalidated after 3 consecutive failed verifications tied to them.
  • Failed verification blacklists the challenge token JTI until expiry.

API options

createChallengeTokenManager(options)

  • secret (required): encryption key for challenge tokens.
  • tokenTtlSec (default 20): challenge token lifetime.
  • successTokenTtlSec (default 60): success token lifetime.
  • Pass a generic type parameter to type the success token payload.

createChallengeExpressRouter(options)

  • challenge (required): the engine instance.
  • tokenManager (required): token manager from createChallengeTokenManager.
  • onChallenge: optional callback that returns a unique key for the requester (session id, IP, etc). When provided, only one active challenge per key is allowed; additional GET /challenge requests return 429 until the prior challenge is verified or expires.
  • backoff: optional per-key verification backoff (requires onChallenge). Defaults to a 10-minute window, reset on success, and a schedule of [0, 0, 2000, 5000, 10000, 20000, 35000, 55000, 75000] ms (cap 75s). Expired challenges that are never verified count as a failure within the window. Set enabled: false to disable when onChallenge is present.
  • onVerified: optional callback; return undefined for default success token, object to override TTL/payload, or null to skip.
  • validateSuccessToken: optional validator for decoded success token payloads.
  • debug: "none" | "error" | "info" (default "none").
  • Pass a matching generic type parameter to type SuccessTokenPayload.