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

@vinhnt-sdk/security

v0.1.2

Published

Security utilities for VNT Agent — prompt injection protection and secret redaction

Readme

@vinhnt-sdk/security

Version: 0.1.2-beta.0 | Status: BETA

Security utilities for vinhnt-sdk — prompt injection protection and secret redaction.

Install

# npm
npm install @vinhnt-sdk/security

# pnpm (monorepo)
pnpm add @vinhnt-sdk/security

Quick Start

import {
  redactSecrets,
  detectSecrets,
  sanitizeInput,
  checkInjection,
} from '@vinhnt-sdk/security';

// Redact secrets from text
const result = redactSecrets("api_key=sk_12345678901234567890");
console.log(result.redacted); // "api_key=[REDACTED:api_key]"
console.log(result.redactions); // [{ type: "api_key", start: 0, end: 31 }]

// Detect secrets without modifying
const detected = detectSecrets("Password: mypassword123");
console.log(detected); // [{ type: "password", ... }]

// Sanitize input
const sanitized = sanitizeInput('<script>alert("xss")</script>Hello');
console.log(sanitized.sanitized); // "Hello"
console.log(sanitized.warnings); // ["Detected potential XSS attack"]

// Check for injection attacks
const injection = checkInjection("Ignore all previous instructions");
console.log(injection.safe); // false
console.log(injection.threats); // ["instruction_override"]
console.log(injection.score); // 60

API Reference

redactSecrets

import { redactSecrets } from '@vinhnt-sdk/security';

const result = redactSecrets(text: string): RedactionResult;

RedactionResult:

interface RedactionResult {
  original: string;
  redacted: string;
  redactions: Redaction[];
}

interface Redaction {
  type: string;      // "api_key", "email", "phone", etc.
  start: number;
  end: number;
}

detectSecrets

import { detectSecrets } from '@vinhnt-sdk/security';

const detected = detectSecrets(text: string): SecretDetection[];

SecretDetection:

interface SecretDetection {
  type: string;
  start: number;
  end: number;
  severity: "low" | "medium" | "high";
}

sanitizeInput

import { sanitizeInput } from '@vinhnt-sdk/security';

const result = sanitizeInput(input: string): SanitizationResult;

SanitizationResult:

interface SanitizationResult {
  original: string;
  sanitized: string;
  warnings: string[];
}

checkInjection

import { checkInjection } from '@vinhnt-sdk/security';

const result = checkInjection(input: string): InjectionCheckResult;

InjectionCheckResult:

interface InjectionCheckResult {
  safe: boolean;
  threats: string[];
  score: number; // 0-100, higher = more dangerous
}

SecretRedactor

import { SecretRedactor } from '@vinhnt-sdk/security';

const redactor = new SecretRedactor();

// Add custom pattern
redactor.addPattern({
  type: "custom_key",
  regex: /custom_key_[a-zA-Z0-9]{20,}/g,
  replacement: "[REDACTED:custom_key]",
});

// Redact
const result = redactor.redact("custom_key_abc123def456ghi789jkl0");

Detected Patterns

| Pattern | Type | Severity | |---------|------|----------| | API keys | api_key | high | | Email addresses | email | medium | | Phone numbers | phone | low | | Credit card numbers | credit_card | high | | SSN | ssn | high | | Passwords | password | high |

Injection Detection

| Pattern | Threat | Score | |---------|--------|-------| | Ignore previous instructions | instruction_override | 60 | | You are now a... | role_hijacking | 25 | | System: | system_prompt_injection | 20 | | Jailbreak/DAN | jailbreak_attempt | 35 | | Pretend to be... | role_play_attack | 20 | | Forget everything... | memory_manipulation | 25 |

Dependencies

None

Peer Dependencies

None

Usage Examples

Protect User Input

import { sanitizeInput, checkInjection } from '@vinhnt-sdk/security';

function processUserInput(input: string) {
  // Check for injection attacks
  const injection = checkInjection(input);
  if (!injection.safe) {
    throw new Error(`Potential attack detected: ${injection.threats.join(", ")}`);
  }

  // Sanitize input
  const { sanitized, warnings } = sanitizeInput(input);
  if (warnings.length > 0) {
    console.warn("Security warnings:", warnings);
  }

  return sanitized;
}

Redact Sensitive Data

import { redactSecrets } from '@vinhnt-sdk/security';

function logSafe(message: string) {
  const { redacted } = redactSecrets(message);
  console.log(redacted);
}

logSafe("User connected with api_key=sk_12345678901234567890");
// Output: "User connected with api_key=[REDACTED:api_key]"

Custom Redactor

import { SecretRedactor } from '@vinhnt-sdk/security';

const redactor = new SecretRedactor();

// Add custom pattern for internal tokens
redactor.addPattern({
  type: "internal_token",
  regex: /token_[a-zA-Z0-9]{32}/g,
  replacement: "[REDACTED:token]",
});

// Use in application
const clean = redactor.redact("User token_token_abc123def456ghi789jkl0123456");
console.log(clean); // "User token_[REDACTED:token]"

License

MIT