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

@revealui/security

v0.4.0

Published

Security primitives — CSP/CORS/HSTS headers, RBAC + ABAC policy engine, encryption helpers, audit logging, GDPR compliance. Ships with RevealUI.

Readme

@revealui/security

Security infrastructure for RevealUI. Provides HTTP security headers, CORS management, RBAC/ABAC authorization, field-level encryption, audit logging, and GDPR compliance tooling.

When to Use This

  • You need security headers (CSP, HSTS, CORS) on HTTP responses
  • You're implementing role-based or attribute-based access control
  • You need audit logging for compliance (SOC2, HIPAA)
  • You need GDPR tooling: consent management, data export, breach reporting, anonymization
  • You need field-level encryption or key rotation
  • You need to sanitize untrusted input before rendering (terminal streams, shell args, SQL identifiers)

If you only need session auth (login/logout/password reset), use @revealui/auth instead.

Installation

pnpm add @revealui/security

Dependencies: @revealui/contracts, @revealui/utils

API Reference

Security Headers & CORS

| Export | Type | Purpose | |--------|------|---------| | SecurityHeaders | Class | Generate CSP, HSTS, Permissions-Policy, X-Frame-Options headers | | SecurityPresets | Object | Pre-built header configs (strict, moderate, development) | | CORSManager | Class | CORS origin/method/header management | | CORSPresets | Object | Pre-built CORS configs (restrictive, public API, development) | | createSecurityMiddleware | Function | Hono middleware applying all security headers | | setRateLimitHeaders | Function | Add X-RateLimit-* headers to responses |

Authorization (RBAC + ABAC)

| Export | Type | Purpose | |--------|------|---------| | AuthorizationSystem | Class | Combined RBAC + ABAC policy engine | | CommonRoles | Object | Pre-defined roles (admin, editor, viewer, superAdmin) | | PolicyBuilder | Class | Fluent API for building ABAC policies | | PermissionBuilder | Class | Fluent API for building RBAC permissions | | PermissionCache | Class | LRU cache for permission lookups | | canAccessResource | Function | Check if user can perform action on resource | | checkAttributeAccess | Function | Evaluate ABAC policy conditions | | createAuthorizationMiddleware | Function | Hono middleware for route-level authorization | | RequirePermission | Decorator | Enforce permission on class methods | | RequireRole | Decorator | Enforce role on class methods |

Encryption

| Export | Type | Purpose | |--------|------|---------| | EncryptionSystem | Class | AES-256 encryption with key management | | EnvelopeEncryption | Class | Envelope encryption (data key + master key) | | FieldEncryption | Class | Encrypt/decrypt individual database fields | | KeyRotationManager | Class | Scheduled key rotation with re-encryption | | DataMasking | Class | Mask sensitive data for display (email, phone, SSN) | | TokenGenerator | Class | Secure random token generation |

Audit Logging

| Export | Type | Purpose | |--------|------|---------| | AuditSystem | Class | Structured audit event recording | | AuditTrail | Class | Query and filter audit history | | AuditReportGenerator | Class | Generate compliance reports from audit data | | createAuditMiddleware | Function | Hono middleware for automatic request auditing | | InMemoryAuditStorage | Class | In-memory storage for testing |

GDPR Compliance

| Export | Type | Purpose | |--------|------|---------| | ConsentManager | Class | Record and query user consent | | CookieConsentManager | Class | Browser cookie consent banner state | | DataDeletionSystem | Class | Right-to-erasure request processing | | DataExportSystem | Class | Right-to-portability data export | | DataAnonymization | Class | Anonymize user data while preserving analytics | | DataBreachManager | Class | Breach detection, notification, and reporting | | PrivacyPolicyManager | Class | Version and publish privacy policies | | InMemoryGDPRStorage | Class | In-memory GDPR storage for testing | | InMemoryBreachStorage | Class | In-memory breach storage for testing |

Input Sanitization

| Export | Type | Purpose | |--------|------|---------| | sanitizeTerminalLine | Function | Strip ANSI escape sequences from untrusted terminal output; preserves SGR color codes, removes CSI/OSC/DCS sequences and C0/C1 control chars |

Used by RevDev Studio's terminal view to neutralize malicious output (e.g. cursor hijacking, title injection) before rendering. Consumers must treat all subprocess stdout/stderr as untrusted.

Design Principles

  • Hermetic: Security boundaries are sealed - auth checks happen at middleware, never inside business logic
  • Sovereign: All security infrastructure runs in your deployment, no external auth service required
  • Justifiable: Every security header and policy has a documented reason (CSP prevents XSS, HSTS forces HTTPS, etc.)

Related Packages

  • @revealui/auth - Session-based authentication (login, password reset, OAuth)
  • @revealui/core - Applies security middleware to CMS routes
  • @revealui/contracts - Shared types for roles, permissions, consent records