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

omniguard

v0.2.0

Published

Zero-dependency validation, HTML text escaping, hashing, and focused HS256 JWT helpers for TypeScript.

Readme

OmniGuard

Zero-runtime-dependency validation, contextual HTML text escaping, hashing, and focused HS256 JWT helpers for TypeScript.

Live website · GitHub repository

OmniGuard is intentionally small. It is useful when an application needs fluent runtime validation and a few Web Crypto-based primitives without adopting a full schema or identity platform.

OmniGuard has not received an independent security audit. Read the security guarantees and non-goals before using it at a trust boundary.

Install

npm install omniguard

OmniGuard supports Node.js 18 or newer and modern runtimes that provide Web Crypto, TextEncoder, TextDecoder, atob, and btoa.

Validation

import { v } from 'omniguard';

const userSchema = v.object({
  age: v.number().int().nonnegative(),
  email: v.string().trim().email(),
  homepage: v.string().url(),
  roles: v.array(v.string().regex(/^[a-z-]+$/)),
});

const result = userSchema.safeParse(input);
if (!result.success) {
  console.error(result.error.issues);
}

Validators are available for strings, finite numbers, arrays, and objects. A schema can throw through parse or return a discriminated result through safeParse.

Output encoding and plain-text extraction

import { escapeHtmlText, stripHtmlTags, v } from 'omniguard';

escapeHtmlText('<strong>A&B</strong>');
// &lt;strong&gt;A&amp;B&lt;/strong&gt;

stripHtmlTags('<strong>Hello</strong>');
// Hello

const displayName = v.string().trim().escape().parse(untrustedName);

escapeHtmlText performs contextual encoding for HTML text. It is not safe for JavaScript, CSS, or URL contexts. stripHtmlTags only extracts approximate plain text and must not be used as an XSS sanitizer. Use a maintained allow-list sanitizer when you need to preserve untrusted HTML.

Hashing

import { hash } from 'omniguard';

const digest = await hash('message', 'SHA-256');

The hash helper produces a digest, not a password hash. Use a purpose-built password hashing implementation such as Argon2id or scrypt for credentials.

HS256 JWTs

import { signJWT, verifyJWT } from 'omniguard';

const secret = process.env.JWT_SECRET!; // at least 32 UTF-8 bytes, generated randomly

const token = await signJWT(
  { role: 'editor' },
  secret,
  {
    audience: 'dashboard',
    expiresInSeconds: 15 * 60,
    issuer: 'my-api',
    subject: 'user-42',
  },
);

const claims = await verifyJWT(token, secret, {
  algorithms: ['HS256'],
  audience: 'dashboard',
  issuer: 'my-api',
  maxTokenAgeSeconds: 15 * 60,
  requireExpiration: true,
});

Verification authenticates the signature and validates temporal and identity claims according to the options supplied by the caller. It returns null for an invalid token. Configuration errors, such as a secret shorter than 32 bytes, throw.

API surface

  • v.string(): min, max, email, url, regex, trim, escape, stripHtmlTags
  • v.number(): min, max, int, positive, nonnegative
  • v.array(schema) and v.object(shape)
  • hash(value, algorithm)
  • signJWT(payload, secret, options) and verifyJWT(token, secret, options)
  • escapeHtmlText(value) and stripHtmlTags(value)

The old escapeHtml, stripHtml, and validator .stripHtml() names remain as deprecated compatibility aliases in 0.2.x.

Development

npm ci
npm test
npm run build
npm pack --dry-run

See CONTRIBUTING.md, SECURITY.md, and CHANGELOG.md.

License

MIT © Onur Acar