HTML Security & Session Watchdog

Kreft protects both client and server against Cross-Site Scripting (XSS) and unattended sessions out of the box—with zero external dependencies.

1. Live XSS Sanitizer Playground

Type or paste untrusted HTML below. Dangerous tags (<script>, <svg>, <iframe>), inline event handlers (onerror, onclick), and entity-obfuscated javascript: / data: URLs are neutralized automatically.

k-html Live Render (Safe DOM)

Welcome to Kreft v2.4!

Safe links work: Docs.

stealCookies() Malicious Link

Kreftjs.cleanHtml(input) Output

<h3>Welcome to <b>Kreft v2.4</b>!</h3>
<p>Safe links work: <a href="https://example.com">Docs</a>.</p>
<img src="x">
        stealCookies()         

<a href="#">Malicious Link</a>

Kreftjs.stripTags(input) (Plain Text)

Welcome to Kreft v2.4 ! Safe links work: Docs . stealCookies() Malicious Link

Kreftjs.escapeHtml(input) (Entities)

&lt;h3&gt;Welcome to &lt;b&gt;Kreft v2.4&lt;/b&gt;!&lt;/h3&gt;
&lt;p&gt;Safe links work: &lt;a href=&quot;https://example.com&quot;&gt;Docs&lt;/a&gt;.&lt;/p&gt;
&lt;img src=&quot;x&quot; onerror=&quot;alert(&#39;XSS&#39;)&quot;&gt;
        stealCookies()         
&lt;svg onload=&quot;alert(1)&quot;&gt;&lt;/svg&gt;
&lt;a href=&quot;javascript:alert(1)&quot;&gt;Malicious Link&lt;/a&gt;

2. Session Inactivity Watchdog (Kreftjs.useInactivityTimer)

Protects authenticated dashboards when a user leaves their screen unattended. Try the 10-second interactive simulation below (warning triggers at 5 seconds left):

3. Server-Side Request & Model Sanitization

// 1) Request sanitization in Controllers
const safeBody  = req.clean('content')      // strips scripts & unsafe attributes
const plainText = req.strip('title')        // strips all HTML tags
const safeObj   = req.html('bio')           // wraps in SafeHtml instance

// 2) Automatic Model Casts (backend/app/Models/Article.js)
class Article extends Model {
  static casts = {
    title:   'strip_tags',   // automatically strips tags before INSERT / UPDATE
    content: 'safe_html',    // sanitizes on write & hydrates as SafeHtml
    snippet: 'escape_html',  // escapes &, <, >, ", '
  }
}