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

hi-hello-auth

v1.0.2

Published

Zero-dependency plain JS HMAC-SHA256 handshake token generator & verifier with clock drift tolerance.

Readme

hi-hello-auth

Zero-dependency, synchronous, cross-platform HMAC-SHA256 handshake token generator and validator with clock drift tolerance. Works in Node.js and all modern/legacy browsers.

Features

  • Zero dependencies: Pure ES5 vanilla JavaScript implementation.
  • Synchronous & Portable: Runs anywhere without crypto.subtle async headaches or Node-only crypto modules. Works over unsecure http:// in local development too.
  • Configurable Time Windows: Default 5-minute time window (300s) or custom duration.
  • Clock Drift Buffer: Built-in 30-second buffer to handle boundary clock sync differences between client and server.
  • Timing Attack Safe: Validates tokens with constant-time XOR comparison.
  • Dual Support: CommonJS (require), ES Modules (import), and direct browser script tags. TypeScript definitions included.

Installation

npm install hi-hello-auth

Usage

1. Generating a Token (Client / Sender)

Pass null or undefined as the 2nd parameter when generating:

// CommonJS
const handshakeToken = require("hi-hello-auth");

// or ES Modules
import handshakeToken from "hi-hello-auth";

const SHARED_SECRET = "your-shared-secret-key";
const WINDOW_SECONDS = 300; // 5-minute window
const BUFFER_SECONDS = 30;  // 30-second buffer

// Generate token
const token = handshakeToken(SHARED_SECRET, null, WINDOW_SECONDS, BUFFER_SECONDS);
console.log(token);
// Output: 64-character hex string

2. Verifying a Token (Server / Receiver)

const handshakeToken = require("hi-hello-auth");

const SHARED_SECRET = "your-shared-secret-key";
const WINDOW_SECONDS = 300;
const BUFFER_SECONDS = 30;

const clientToken = req.headers["x-handshake-token"];

const isValid = handshakeToken(SHARED_SECRET, clientToken, WINDOW_SECONDS, BUFFER_SECONDS);

if (!isValid) {
  return res.status(401).json({ error: "Invalid or expired handshake token" });
}

// Proceed with request...

API

handshakeToken(secret, tokenToVerify, windowSeconds, bufferSeconds)

| Parameter | Type | Required | Description | | :--- | :--- | :--- | :--- | | secret | string | Yes | Shared secret key between client and server (non-empty string). | | tokenToVerify | string \| null \| undefined | Yes | The token string to validate, or null/undefined to generate a new token. | | windowSeconds | number | Yes | Validity window duration in seconds (must be a positive number). | | bufferSeconds | number | Yes | Boundary buffer in seconds to tolerate clock skew (must be >= 0). |

Returns:

  • string: 64-character hex token when generating.
  • boolean: true if valid, false otherwise when verifying.

Throws:

  • TypeError: If any mandatory parameter is missing or invalid.