No CAPTCHA required

Security-hardened
UI components.
One tag. No config.

Drop-in secure UI components with CSRF protection, XSS prevention, and behavioral bot detection built in by default. No vendor lock-in, no CAPTCHA required. Works with any framework or server-rendered HTML.

MIT Licence · Free forever

npm i secure-ui-components
Zero dependencies
MIT License
11 secure UI components
Any framework

Try it now

Touch the components.
See security in action.

These are live secure-input and secure-form components. CSRF token injection, XSS sanitization, and audit logging are active. Inspect the DOM — the Shadow DOM keeps the internal structure isolated.

See all 11 components
secure-form + secure-input Live
Live signals
email vel— dwell— paste—
password vel— dwell— paste—

Submitted securely

Built-in Behavioral Intelligence

Bot Detection Without
the Vendor Tax

secure-telemetry-provider collects HMAC-signed behavioral signals on every form submission. Score submissions silently — serve CAPTCHA only to high-risk requests, or skip it entirely for low-risk traffic. No third-party SDKs. No per-transaction fees. Your data, your rules.

  • Stops bots that pass visual CAPTCHAs
  • Detects webdrivers, headless browsers, and DevTools automation
  • Flags DOM tampering and injected scripts in real time
  • HMAC-SHA-256 signed — forged telemetry is detectable server-side
  • Your infrastructure, your rules — no data leaves your servers
See how it works

Security model

Tamper-evidence, not cryptographic proof The HMAC key lives in client-side JS memory. Any same-page XSS or privileged script can read it from the heap and forge envelopes. Treat the signature as a deterrent against scripted attacks — rotate the key per-session from a server nonce endpoint for stronger guarantees.

All signals are heuristic A determined attacker can spoof behavioral signals. The value is raising the cost of commodity automated attacks — not eliminating them. Always combine with server-side rate limiting and validation.

Prefer setSigningKey() over the HTML attribute Supplying the key via setSigningKey() means it never appears in the DOM. The signing-key HTML attribute is supported for compatibility but is automatically removed from the DOM on mount. The derived CryptoKey is cached and cleared on disconnect.

Non-secure contexts SubtleCrypto is unavailable on http:// origins — the signature will be an empty string. Treat unsigned envelopes as lowest-trust submissions and enforce HTTPS in production.

What sets it apart

Not just a UI library

Shadow DOM isolation, behavioral telemetry, and audit logging — capabilities MUI, ShadCN, and Radix cannot add without a full architectural rewrite. In Secure-UI they ship by default.

Closed Shadow DOM

Field values live inside a closed shadow root. Scripts, extensions, and devtools cannot read or tamper with the internal DOM. Validation state stays private until submission.

  • Script injection attacks blocked
  • Extension data harvesting prevented
  • Validation state private until submit

Behavioral Telemetry

Passive behavioral signals catch commodity bots silently. Score every submission — only trigger a CAPTCHA challenge for the small percentage that looks suspicious. Real users never see a puzzle.

  • Webdriver and headless detection
  • Typing velocity and dwell analysis
  • HMAC-signed risk envelope per submit

Audit Trail by Default

Every injection attempt, validation failure, and selection change dispatches a secure-audit CustomEvent. Blocked inputs record the exact value attempted. Compliance logging ships out of the box.

  • Injection attempts logged with exact value
  • Timestamped interaction history per field
  • No extra instrumentation required

Automatic CSRF Protection

All forms automatically include CSRF tokens. No manual token management required.

  • Per-request token generation
  • Automatic token injection and validation
  • Single-use, server-side expiry

Input Sanitization

XSS prevention built into every component. Automatic encoding, script stripping, handler removal.

  • HTML entity encoding
  • Script tag stripping
  • Event handler removal

Zero Dependencies

The entire library is self-contained TypeScript. No transitive packages, no supply chain risk, no CVEs inherited from third-party code. A single script tag is all you add to your project.

  • No npm install required at runtime
  • No transitive vulnerability surface
  • Works from CDN or self-hosted

Threat coverage

OWASP Top 10:2021 Alignment

Client-side defences that complement your server-side security, mapped against the OWASP Top 10:2021.

RiskTitleCoverageHow Secure-UI helps
A01Broken Access ControlAddressedAutomatic CSRF token injection via <secure-form>. Immutable security tiers prevent runtime downgrade.
A02Cryptographic FailuresComplementaryDisables autocomplete and browser caching on sensitive and critical tiers via <secure-input>. Cryptographic controls require server-side implementation.
A03InjectionAddressedAll input sanitized via HTML entity encoding, script tag stripping, and event handler removal. Closed Shadow DOM isolates component internals. See secure-input and secure-textarea.
A04Insecure DesignAddressedSecurity-by-default architecture. Fail-secure defaults, four-tier security model, and progressive enhancement ensure security without developer effort. See all components.
A05Security MisconfigurationAddressedDefaults to CRITICAL tier. Provides CSP directives and security header recommendations out of the box. See secure-form.
A06Vulnerable and Outdated ComponentsAddressedZero runtime dependencies. No transitive supply chain risk. The entire library is self-contained TypeScript. See secure-file-upload; upload integrity hooks included.
A07Authentication FailuresComplementaryBehavioral telemetry via secure-telemetry-provider detects automated clients before submission. Client-side rate limiting on sensitive and critical tiers adds a secondary layer. Authentication logic requires server-side implementation.
A08Software and Data Integrity FailuresAddressedCSRF protection via secure-form. File upload scan hooks via secure-file-upload. Closed Shadow DOM prevents DOM tampering.
A09Security Logging FailuresAddressedEvery component records client-side security events via getAuditLog() and secure-audit events. See secure-telemetry-provider.
A10Server-Side Request ForgeryComplementaryCSP form-action 'self' restricts form submissions to the same origin via secure-form. Components make no outbound requests.

Secure-UI provides client-side defences as part of a defence-in-depth strategy. Server-side validation, authentication, and encryption remain essential.

Integration

Security Without Complexity

One tag. No configuration. Secure by default. Native HTML elements — every framework, or no framework at all.

One script tag

Import once. Every component self-registers. No build step, no bundler config, no peer dependencies to reconcile.

Framework agnostic

Built on the W3C Custom Elements standard. React, Vue, Angular, Svelte, and server-rendered HTML all treat them identically.

Secure by default

CSRF injection, XSS sanitization, input validation, and audit logging are active from the first render. No flags to set.

Progressive enhancement

Server renders native HTML fallbacks. The component upgrades on connect — forms submit correctly with or without JavaScript.

Component markup Any framework
<!-- Works identically in React, Vue,
     Angular, Svelte, or Go templates -->

<secure-form action="/register" method="POST">

  <secure-input
    name="email"
    type="email"
    label="Email address"
    security-tier="sensitive"
    required>
  </secure-input>

  <secure-input
    name="password"
    type="password"
    label="Password"
    security-tier="critical"
    required>
  </secure-input>

  <secure-submit-button>
    Create account
  </secure-submit-button>

</secure-form>

<!-- CSRF token injected automatically.
     XSS prevention active on every field.
     Audit log available via getAuditLog(). -->
Server handler Go example
// CSRF already validated by middleware.
// No manual token handling required.
func (h *Handlers) Register(
    w http.ResponseWriter,
    r *http.Request,
) {
    email := validation.Sanitize(
        r.FormValue("email"),
    )
    password := r.FormValue("password")

    v := validation.New()
    v.Required("email", email, "Email").
        Email("email", email, "Email").
        Required("password", password, "Password").
        MinLength("password", password, 8, "Password")

    if !v.Result().IsValid() {
        // Re-render form with errors.
        // Component preserves field values.
        renderWithErrors(w, r, v.Result())
        return
    }

    // Components sanitized client-side too,
    // but server-side is the security boundary.
    h.auth.Register(r.Context(), email, password)
}

Works in every environment

Vanilla HTML React Vue Angular Svelte Next.js Nuxt Go / Templ Django Rails Laravel Any SSR

Building a production Angular application? Angular Security Development Guideline →

All components are fully themeable via CSS custom properties. Explore theming →

Common questions

Frequently Asked Questions

Can secure-telemetry-provider fully replace CAPTCHA?
For the majority of traffic, yes. Commodity bots — scrapers, credential stuffers, form spammers — are caught silently with no friction for real users. For sophisticated bots that mimic human behavior, use the risk score as a gate: serve CAPTCHA only when the score exceeds your threshold, typically 5–10% of requests. This eliminates the CAPTCHA burden for 90%+ of users while keeping a challenge in reserve for flagged sessions.
How should I supply the signing key?
Use setSigningKey() — the key is stored in a private JS field and never appears in the DOM, making it invisible to getAttribute(), devtools inspection, and XSS. The signing-key HTML attribute is supported for backward compatibility: if present, it is automatically migrated to the private field and removed from the DOM on mount. Even with the private field, the key lives in JS memory — a same-page XSS or compromised script can still read it from the heap. For stronger integrity, rotate the key per-session from a server nonce endpoint.
What risk score threshold should I use?
A common starting point: 0–30 allow, 31–60 log and optionally challenge, 61+ reject or require step-up authentication. Start permissive, log everything, then tighten based on real traffic patterns.
Does behavioral scoring work on mobile?
Yes. Touch devices never produce mouse events, so the scoring function skips the mouse-movement penalty when pointerType is touch or pen. Timing and webdriver signals apply equally across all device types.
Does Secure-UI work without JavaScript?
Yes. All components render as native HTML elements when JavaScript is unavailable. Client-side features — XSS sanitisation, rate limiting, audit logging — activate when JS is enabled. The page never breaks.
What is a security tier?
A per-field declaration of data sensitivity: public, authenticated, sensitive, or critical. Set it via security-tier="sensitive". The library automatically applies the corresponding protections — stricter rate limits, autocomplete suppression, enhanced audit logging.
How does Secure-UI prevent XSS?
Every input component scans the raw field value on every keystroke against 8 injection patterns — script tags, javascript: URIs, inline event handlers, injected HTML elements, CSS expressions, VBScript URIs, data:text/html payloads, and template injection probes. The first match fires a secure-threat-detected event (raw value intentionally absent). Values are also sanitised via HTML entity encoding before emitting. The closed Shadow DOM prevents host-page scripts from reaching component internals.
Is this a replacement for server-side validation?
No. Secure-UI is a client-side defence layer. Your server must still validate and sanitise all input — client-side controls can be bypassed. The components reduce boilerplate and enforce security by default, but server-side validation is always the security boundary.
Does it work with React, Vue, Angular, or Next.js?
Yes. Web Components are a browser standard supported by all major frameworks. Import the library once with a single script tag, then use the element tags anywhere in your templates — React, Vue, Angular, Svelte, Next.js, Nuxt, Go Templ, Django, Rails, or plain HTML. For Angular-specific security practices, see the Angular Security Development Guideline.
How are CSRF tokens handled?
<secure-form> automatically fetches a CSRF token and injects it before each submission as both a request header and a hidden field. No manual token management required. The token is single-use and expires server-side.
What makes this different from DOMPurify?
DOMPurify sanitises HTML strings as a post-processing step. Secure-UI is a complete form component library: CSRF defence, behavioral bot detection, audit logging, security tier enforcement, and input sanitisation are all part of the interaction model.
Is there a CDN option?
Yes. Load directly from unpkg without installing anything: <script type="module" src="https://unpkg.com/secure-ui-components/dist/secure-ui.bundle.js"></script>