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

@surfinguard/sdk

v1.0.0

Published

Surfinguard AI Security SDK for JavaScript/TypeScript — dual-mode Guard class with local and API modes

Downloads

28

Readme

@surfinguard/sdk

The trust layer for AI agents. Protect your AI agents from executing dangerous actions — phishing URLs, destructive commands, prompt injection, and sensitive file access.

Installation

npm install @surfinguard/sdk

Quick Start

Local Mode (Zero-Latency)

Runs the heuristic engine directly in your process — no network calls, no API key needed:

import { Guard } from '@surfinguard/sdk';

const guard = new Guard({ mode: 'local' });

// Check a URL
const result = guard.checkUrl('https://paypa1.com/login');
console.log(result.level);   // 'DANGER'
console.log(result.score);   // 9
console.log(result.reasons); // ['Brand impersonation: paypal']

// Check a command
const cmd = guard.checkCommand('rm -rf /');
console.log(cmd.level); // 'DANGER'

// Check text for prompt injection
const text = guard.checkText('Ignore all previous instructions');
console.log(text.level); // 'DANGER'

// Check file operations
const file = guard.checkFileRead('~/.ssh/id_rsa');
console.log(file.primitive); // 'EXFILTRATION'

API Mode (LLM-Enhanced)

Uses the Surfinguard API for cloud-based analysis with optional LLM enhancement:

import { Guard } from '@surfinguard/sdk';

const guard = new Guard({
  mode: 'api',
  apiKey: 'sg_live_...',
});

// All methods return Promises in API mode
const result = await guard.checkUrl('https://suspicious-site.xyz/login');
console.log(result.level);

Policy Enforcement

The SDK can automatically block dangerous actions:

import { Guard, NotAllowedError } from '@surfinguard/sdk';

// MODERATE (default): blocks DANGER, allows SAFE and CAUTION
const guard = new Guard({ mode: 'local', policy: 'moderate' });

// STRICT: blocks CAUTION and DANGER, only allows SAFE
const strict = new Guard({ mode: 'local', policy: 'strict' });

// PERMISSIVE: never blocks, returns results only
const permissive = new Guard({ mode: 'local', policy: 'permissive' });

try {
  guard.checkCommand('rm -rf /');
} catch (e) {
  if (e instanceof NotAllowedError) {
    console.log(`Blocked: ${e.result.level} (score=${e.result.score})`);
  }
}

All Check Methods

| Method | Action Type | Input | |--------|------------|-------| | checkUrl(url) | URL | URL string | | checkCommand(command) | Command | Shell command | | checkText(text) | Text | Free text / prompt | | checkFileRead(path) | File Read | File path | | checkFileWrite(path, content?) | File Write | Path + optional content | | check(type, value, metadata?) | Any | Universal check |

CheckResult

Every check returns a CheckResult:

interface CheckResult {
  allow: boolean;                // Should the action be allowed?
  score: number;                 // 0-10 risk score
  level: RiskLevel;              // 'SAFE', 'CAUTION', or 'DANGER'
  primitive: RiskPrimitive;      // Dominant risk primitive
  primitive_scores: PrimitiveScore[];  // Per-primitive breakdown
  reasons: string[];             // Human-readable explanations
  alternatives: string[];        // Safer alternatives (if any)
  latency_ms: number;            // Analysis time
}

Express Integration

import express from 'express';
import { Guard } from '@surfinguard/sdk';
import { surfinguardMiddleware } from '@surfinguard/sdk/express';

const app = express();
const guard = new Guard({ mode: 'local', policy: 'moderate' });

// Auto-infers action type from request body
app.post('/execute', surfinguardMiddleware({ guard }), (req, res) => {
  // req.surfinguard contains the CheckResult
  res.json({ allowed: true, risk: req.surfinguard });
});

// Custom value extraction
app.post('/run', surfinguardMiddleware({
  guard,
  actionType: 'command',
  extractValue: (req) => req.body.cmd,
}), handler);

Next.js Integration

import { Guard } from '@surfinguard/sdk';
import { withSurfinguard } from '@surfinguard/sdk/nextjs';

const guard = new Guard({ mode: 'local', policy: 'moderate' });

// Wrap your API route
export default withSurfinguard(guard, async (req, res) => {
  // req.surfinguard contains the CheckResult
  res.json({ result: req.surfinguard });
});

Error Handling

import {
  SurfinguardError,     // Base error class
  AuthenticationError,  // Invalid API key (401)
  RateLimitError,       // Rate limit exceeded (429)
  APIError,             // Server error (4xx/5xx)
  NotAllowedError,      // Policy blocked action — has .result
} from '@surfinguard/sdk';

Risk Levels

| Level | Score | Meaning | |-------|-------|---------| | SAFE | 0-2 | No risk detected | | CAUTION | 3-6 | Potential risk, review recommended | | DANGER | 7-10 | High risk, action should be blocked |

Risk Primitives

| Primitive | Description | |-----------|-------------| | DESTRUCTION | Data loss, system damage | | EXFILTRATION | Data theft, credential access | | ESCALATION | Privilege escalation | | PERSISTENCE | Backdoor installation, startup modification | | MANIPULATION | Phishing, prompt injection, deception |

License

MIT