API Reference

Documentation

Complete reference for Secure-UI web components. Security-first form elements with built-in validation, XSS prevention, and audit logging.

9 Components
4 Security Tiers
0 Dependencies
10 OWASP Controls
npm install secure-ui-components

Quick Start

Add Secure-UI components to your project by importing the component library. Components self-register and are immediately available for use.

npm Shell
npm install secure-ui-components
ES Module (npm) JavaScript
// Import all components
import 'secure-ui-components';

// Or import individual components
import 'secure-ui-components/secure-input';
import 'secure-ui-components/secure-form';
CDN / Self-hosted HTML
<!-- All components — single bundle, no build step required -->
<script type="module" src="/components/secure-ui.bundle.js"></script>
Basic Usage HTML
<secure-input
  label="Email Address"
  name="email"
  type="email"
  security-tier="sensitive"
  required
></secure-input>

Security Tiers

Every component supports four security tiers that control validation strictness, visual indicators, and security features. Choose the appropriate tier based on the sensitivity of the data being collected.

Public
Standard security for non-sensitive data. Basic validation, autocomplete allowed.
Authenticated
For logged-in users. Enhanced validation, session-aware features.
Sensitive
PII and personal data. Masking, no autocomplete, rate limiting.
Critical
Passwords, financial data. Maximum security, full audit logging.
Security Tier Example HTML
<!-- Public tier - for general information -->
<secure-input security-tier="public" label="Name" name="name"></secure-input>

<!-- Sensitive tier - for PII like email, phone -->
<secure-input security-tier="sensitive" label="Email" name="email" type="email"></secure-input>

<!-- Critical tier - for passwords, financial data -->
<secure-input security-tier="critical" label="Password" name="password" type="password"></secure-input>

Components

Nine security-first web components. Each ships with XSS prevention, validation, and audit logging enabled by default — security is opt-out, not opt-in.

Form Inputs

Orchestration

Display

Guides

Common Attributes

All Secure-UI components share these common attributes inherited from the base component.

AttributeTypeDefaultDescription
security-tierstring"critical"Security level: "public", "authenticated", "sensitive", or "critical"
namestring-Form field name for submission
labelstring-Accessible label text displayed above the field
requiredbooleanfalseWhether the field is required
disabledbooleanfalseDisables the component

Built-in Security Features

Security by Default
Core security features like XSS prevention, input sanitization, and audit logging are enabled by default with sensible defaults for each security tier.

XSS Prevention

All user input is automatically sanitized before rendering. HTML entities are encoded, script tags are stripped, and event handlers are removed.

CSRF Protection

The <secure-form> component automatically includes and validates CSRF tokens. Tokens are generated server-side and validated on form submission.

Input Validation

Type-specific validation is applied based on input type and security tier. Email formats, URL patterns, and custom regex patterns are validated client-side with server-side validation as the authoritative source.

Audit Logging

All components maintain an audit log of security-relevant events. Access the log via the getAuditLog() method on any component instance.

Accessing Audit Logs JavaScript
const input = document.querySelector('secure-input');
const auditLog = input.getAuditLog();

// Log contains entries like:
// { action: 'input_focused', timestamp: '...', data: { name: 'email' } }
// { action: 'validation_failed', timestamp: '...', data: { reason: 'invalid email' } }
console.log(auditLog);

Progressive Enhancement

All components are built with progressive enhancement in mind. They work without JavaScript using native HTML form elements, and enhance with additional security features when JavaScript is available.

Graceful Degradation
When JavaScript is unavailable, components degrade to unstyled custom elements. Server-side validation should always be the authoritative security layer regardless.