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

inputshield

v0.1.0

Published

Lightweight, TypeScript-first input validation and security hardening library for Node.js applications.

Readme

inputshield

Lightweight, TypeScript-first input validation and security hardening library for Node.js applications.

inputshield provides strongly typed, composable validation schemas for user inputs with built-in prototype pollution defenses and fail-closed security guarantees.

Installation

npm install inputshield

Usage & Examples

1. Schema Factory Import

import { s, InputShieldError } from 'inputshield';

2. Primitive Validators

String Validation

const EmailSchema = s.string().trim().toLowerCase().email();
const UsernameSchema = s.string().min(3).max(20).regex(/^[a-z0-9_]+$/);

const res1 = EmailSchema.safeParse('  [email protected]  ');
// res1.success === true -> res1.data === '[email protected]'

const UrlSchema = s.string().url();
const res2 = UrlSchema.safeParse('https://example.com');
// res2.success === true

Number Validation

const AgeSchema = s.number().int().min(18).max(120);

const res = AgeSchema.safeParse(25);
// res.success === true -> res.data === 25

Date Validation

const EventDateSchema = s.date().coerce().min(new Date('2026-01-01'));

const res = EventDateSchema.safeParse('2026-08-14T00:00:00.000Z');
// res.success === true -> res.data is a Date instance

3. Object & Array Schemas

Object Validation (With Built-In Prototype Pollution Defense)

ObjectSchema validates key-value schemas while automatically rejecting dangerous object keys (__proto__, constructor, prototype) to prevent prototype contamination.

const UserProfileSchema = s.object({
  username: s.string().min(3),
  age: s.number().int().min(18),
  email: s.string().email().optional(),
});

// Safe parse
const result = UserProfileSchema.safeParse({
  username: 'alice',
  age: 25,
  email: '[email protected]',
});

if (result.success) {
  console.log('Validated User:', result.data.username);
} else {
  console.error('Validation Issues:', result.error.issues);
}

Array Validation

const TagsSchema = s.array(s.string().min(1)).min(1).max(5);

const res = TagsSchema.safeParse(['typescript', 'security']);
// res.success === true

4. Result Parsing Modes

Non-Throwing (safeParse)

Returns a discriminated union { success: true, data } | { success: false, error }.

const result = s.string().min(5).safeParse('hi');

if (!result.success) {
  console.log(result.error.issues); 
  // [{ code: 'TOO_SHORT', message: 'String must be at least 5 characters long', received: 'hi' }]
}

Exception-Based (parse)

Returns the validated data directly or throws an InputShieldError.

try {
  const data = s.string().min(5).parse('hi');
} catch (err) {
  if (err instanceof InputShieldError) {
    console.error(err.message);
    console.error(err.issues);
  }
}

License

MIT