<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PrivaUtils]]></title><description><![CDATA[Technical write-ups and benchmarks on building in-browser developer utilities with Web Workers, WebAssembly, and native WebCrypto.]]></description><link>https://privautils.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b0344ed7f0e6b970d64dfe9/d417a522-f846-4963-a397-9a63353772fb.png</url><title>PrivaUtils</title><link>https://privautils.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 24 Nov 2026 12:02:31 GMT</lastBuildDate><atom:link href="https://privautils.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Why We Moved Developer Utilities to Browser Memory (and Killed Server Uploads)]]></title><description><![CDATA[How we built a zero-server developer toolkit using Web Workers, WebCrypto, and in-memory streaming to eliminate data leaks]]></description><link>https://privautils.hashnode.dev/why-we-moved-developer-utilities-to-browser-memory-and-killed-server-uploads</link><guid isPermaLink="true">https://privautils.hashnode.dev/why-we-moved-developer-utilities-to-browser-memory-and-killed-server-uploads</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[React]]></category><category><![CDATA[Security]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[PrivaUtils]]></dc:creator><pubDate>Sun, 22 Nov 2026 20:13:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0344ed7f0e6b970d64dfe9/4c248beb-ca3e-43c2-b529-fe9ce83f36f4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every software engineer uses utility websites. We format API responses, decode JWT authentication headers, test regular expressions, and convert binary assets to Base64. </p>
<p>Open Chrome DevTools on most utility sites and check the Network tab. When you paste an authorization bearer token or upload a 10MB document, the page makes a <code>POST</code> request sending your data to an external server. That backend processes the string and returns the formatted response.</p>
<p>Even if the site owner has good intentions, server-side utility processing creates liabilities. Payloads get written to web server access logs, reverse proxy buffers, and temporary directories. If someone pastes customer records or private API tokens into a formatter, that data leaves their control.</p>
<p>We built <a href="https://privautils.com">PrivaUtils</a> to eliminate that risk entirely. It contains single-purpose utilities for coding, PDF processing, text manipulation, and cryptography. Every tool executes directly on the client machine using Web Workers, WebAssembly, and native WebCrypto.</p>
<p>Here is how we handled the three main technical problems of doing everything client-side.</p>
<h2>1. The 64-Bit Integer Problem in JSON</h2>
<p>A subtle issue with web JSON formatters is how JavaScript handles numbers. </p>
<p>Standard JavaScript numbers follow IEEE 754 double-precision floating-point format. The safe integer boundary is:</p>
<pre><code class="language-javascript">Number.MAX_SAFE_INTEGER; // 9,007,199,254,740,991 (2^53 - 1)
</code></pre>
<p>Modern backends frequently use 64-bit integers for database IDs, Discord Snowflake IDs, and Twitter message IDs. A typical 64-bit ID looks like this:</p>
<pre><code class="language-json">{
  "user_id": 9223372036854775807
}
</code></pre>
<p>If you run standard <code>JSON.parse()</code> on that payload in a browser or Node.js environment:</p>
<pre><code class="language-javascript">const data = JSON.parse('{"user_id": 9223372036854775807}');
console.log(data.user_id);
// Output: 9223372036854776000
</code></pre>
<p>The last three digits are rounded. If an engineer formats a payload, copies the result, and pastes it into Postman or a database query, the record lookups fail.</p>
<p>In our <a href="https://privautils.com/coding/json-formatter">JSON Formatter</a>, we bypass <code>JSON.parse</code> for number tokens. We tokenize raw numeric sequences with <code>json-bigint</code>, storing integers above <code>Number.MAX_SAFE_INTEGER</code> as native JavaScript <code>BigInt</code> objects. The tree view, search filters, and minifiers retain the exact string value of the number without float conversion.</p>
<h2>2. Preventing Browser Freezes from ReDoS</h2>
<p>Regular expression matching in client-side tools creates a Denial of Service risk. If a user pastes a nested quantifier like <code>(a+)+$</code> and tests it against <code>aaaaaaaaaaaaaaaaaaaaaaaaaaaaab</code>, the regex engine enters catastrophic backtracking.</p>
<p>Because computation runs in the user's browser, a runaway loop freezes the UI thread and crashes the tab.</p>
<p>To solve this in our <a href="https://privautils.com/coding/regex-tester">RegEx Tester</a>, evaluations never run on the main UI thread. They run inside an isolated Web Worker wrapped in an un-hijackable timer:</p>
<pre><code class="language-typescript">export function runRegexWithTimeout(
  pattern: string,
  flags: string,
  corpus: string,
  timeoutMs: number = 200
): Promise&lt;MatchResult[]&gt; {
  return new Promise((resolve, reject) =&gt; {
    const worker = new Worker(new URL('./regex.worker.ts', import.meta.url));

    const watchdog = setTimeout(() =&gt; {
      worker.terminate();
      reject(new Error('Evaluation cancelled: possible catastrophic backtracking (ReDoS).'));
    }, timeoutMs);

    worker.onmessage = (event) =&gt; {
      clearTimeout(watchdog);
      worker.terminate();
      resolve(event.data);
    };

    worker.onerror = (err) =&gt; {
      clearTimeout(watchdog);
      worker.terminate();
      reject(err);
    };

    worker.postMessage({ pattern, flags, corpus });
  });
}
</code></pre>
<p>If regex evaluation takes longer than 200 milliseconds, the main thread terminates the worker instance. The browser tab stays responsive at 60 FPS, and the user gets an explicit timeout diagnostic.</p>
<h2>3. Zero-Copy Binary Buffers for PDF Manipulation</h2>
<p>Document tools like PDF mergers and splitters typically require massive server memory. A multi-page PDF with embedded images can easily consume 40MB of RAM.</p>
<p>In our <a href="https://privautils.com/document/pdf-merger">PDF Merger</a> and <a href="https://privautils.com/document/pdf-splitter">PDF Splitter</a>, we use <code>pdf-lib</code> compiled to WebAssembly. The problem with running large file operations in Web Workers is buffer cloning.</p>
<p>If you pass a 40MB <code>ArrayBuffer</code> from the main thread to a worker via standard <code>postMessage</code>, JavaScript clones the entire memory block. Your browser memory consumption doubles instantly, which causes crashes on mobile browsers.</p>
<p>We solved this using Transferable Objects:</p>
<pre><code class="language-typescript">// The second argument transfers ownership instead of cloning
const buffer = await file.arrayBuffer();
worker.postMessage({ action: 'MERGE_PDFS', buffer }, [buffer]);
</code></pre>
<p>Once transferred, the memory buffer in the main thread becomes detached (zero bytes). The worker takes direct ownership of the allocated RAM. When the compiled PDF is ready, the worker transfers the output buffer back to the main thread and creates an ephemeral Blob URL (<code>blob:https://privautils.com/...</code>) for instant download.</p>
<p>No bytes ever leave the client machine.</p>
<h2>Architecture Summary</h2>
<p>Modern browsers have mature APIs:</p>
<ul>
<li><strong>WebCrypto SubtleCrypto</strong>: Hardware-isolated SHA-256, SHA-512, and HMAC signing without external JS cryptography libraries.</li>
<li><strong>Comlink &amp; Web Workers</strong>: Clean RPC interfaces that keep heavy operations off the DOM.</li>
<li><strong>OffscreenCanvas</strong>: Image resizing and format conversion on background threads.</li>
</ul>
<p>You can inspect all tools and test the implementation directly at <a href="https://privautils.com">privautils.com</a>.</p>
]]></content:encoded></item></channel></rss>