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

@barric/core

v0.1.2

Published

AI prompt firewall — secure any LLM call with input/output scanning

Readme

@barric/core

AI prompt firewall engine for LLM applications. Scans inputs and outputs for prompt injection, PII leaks, encoding attacks, and more.

Install

npm install @barric/core

Quick Start

import { createFirewall } from '@barric/core'

const firewall = createFirewall({
  rules: ['prompt-injection', 'pii-redaction', 'input-limit'],
  injection: { threshold: 0.7, action: 'block' },
  pii: { mode: 'redact', types: ['email', 'phone', 'ssn'] },
})

const result = await firewall.guard(
  userInput,
  async (sanitized) => llm.complete(sanitized),
  { context: { userId: 'user-123', ip: req.ip } }
)

if (result.blocked) {
  console.log('Blocked:', result.events[0].scanners)
} else {
  console.log('Response:', result.filteredOutput)
}

Scanners

| Scanner | Direction | What it does | |---------|-----------|-------------| | prompt-injection | Inbound | 200+ signature patterns detecting instruction override, persona hijacking, system prompt extraction | | pii-redaction | Both | Detects and redacts emails, phones, credit cards, SSNs, IP addresses. Supports redact/mask/block modes | | rate-limit | Inbound | Sliding window rate limiter with per-user keying | | input-limit | Inbound | Character and token length enforcement | | output-limit | Outbound | Character length enforcement on LLM responses | | system-prompt-leak | Outbound | Detects if the LLM leaks your system prompt via pattern matching and n-gram similarity | | encoding-detection | Inbound | Detects zero-width characters, base64 payloads, unicode escapes, homoglyph mixing |

Configuration

createFirewall({
  rules: ['prompt-injection', 'pii-redaction', 'rate-limit', 'input-limit',
          'output-limit', 'system-prompt-leak', 'encoding-detection'],

  injection: {
    threshold: 0.7,        // Detection sensitivity (0-1)
    action: 'block',       // 'pass' | 'log' | 'warn' | 'block'
    allowlist: [],         // Phrases to never flag
  },

  pii: {
    mode: 'redact',        // 'redact' | 'mask' | 'block'
    types: ['email', 'phone', 'credit-card', 'ssn', 'ip-address'],
    reversible: true,      // Re-inject PII into LLM output
    custom: [{ name: 'employee-id', pattern: /EMP-\d{6}/ }],
  },

  rateLimit: {
    maxRequests: 20,
    windowMs: 60_000,
    keyFn: (ctx) => ctx.userId ?? ctx.ip ?? 'anonymous',
  },

  input: { maxLength: 10_000, maxTokens: 4_000 },
  output: { maxLength: 20_000, systemPromptLeakThreshold: 0.6 },

  onViolation: (event) => console.warn('Violation:', event),
  onScan: (event) => analytics.track(event),
})

PII Redaction Flow

PII redaction is reversible by default — personal data is stripped before reaching the LLM, then re-injected into the output:

User input -> [email redacted] -> LLM processes sanitized text -> PII re-injected -> Response

SDK Wrappers

Use @barric/core directly, or with a provider wrapper:

License

MIT