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

@streetjs/xss

v1.0.0

Published

StreetJS XSS foundation: dependency-free input sanitization — a fixed-point string sanitizer (strips tags, script/data/vbscript protocols, event handlers, null bytes), bounded recursive deep sanitization, and HTML entity escaping. Zero runtime dependencie

Readme

@streetjs/xss

The input-sanitization foundation for StreetJS: dependency-free XSS defenses — a fixed-point string sanitizer, bounded recursive deep sanitization, and HTML entity escaping.

Zero runtime dependencies. Pure functions, framework-agnostic and browser-safe, matching the StreetJS minimal, carefully curated dependency footprint.

npm install @streetjs/xss

This is the standalone home of the sanitizers that also back the streetjs/xss subpath; the streetjs framework re-exports them (and adds a request middleware around sanitizeDeep), so there is a single implementation.

API

import { sanitizeString, sanitizeDeep, escapeHtml } from '@streetjs/xss';

sanitizeString('<script>alert(1)</script>');   // "scriptalert(1)/script"
sanitizeString('javascript:evil()');            // "evil()"
sanitizeString('onclick=steal()');              // "steal()"

sanitizeDeep({ name: '<b>x</b>', tags: ['<i>a'] }); // recursively cleaned

escapeHtml('<a href="/x">');   // "&lt;a href=&quot;&#x2F;x&quot;&gt;"

Behavior & guarantees

  • sanitizeString removes angle brackets, javascript:/data:/vbscript: protocols, on*= event-handler attributes, and null bytes. It loops to a true fixed point — every pass only deletes characters, so it always terminates and cannot be defeated by "reconstitution" payloads like <scr<script>ipt>. Input longer than 1 MB is truncated first.
  • sanitizeDeep applies sanitizeString to every string value and key in a structure, passing numbers/booleans/null/undefined through and returning null for unsupported types. It is bounded against hostile input: depth ≤ 32, ≤ 500 keys per object, ≤ 10 000 array items.
  • escapeHtml escapes & < > " ' / for safe interpolation into HTML.

sanitizeString/sanitizeDeep remove dangerous constructs (for storing/processing untrusted input); escapeHtml encodes for display. Use escapeHtml (or a proper templating auto-escape) when rendering into HTML, and prefer context-aware output encoding for untrusted data in attributes, URLs, or scripts.

Public API

sanitizeString · sanitizeDeep · escapeHtml.

See ARCHITECTURE.md for design notes, and src/examples/integration.ts for a runnable example.

License

MIT © street contributors