<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kai Wang</title>
    <description>The latest articles on DEV Community by Kai Wang (@eueinvoice).</description>
    <link>https://dev.to/eueinvoice</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4284789%2F31d5dee0-b716-4eb2-9967-329a355bd5bb.png</url>
      <title>DEV Community: Kai Wang</title>
      <link>https://dev.to/eueinvoice</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eueinvoice"/>
    <language>en</language>
    <item>
      <title>Building a Zero-Upload EU E-Invoice Validator (XRechnung, ZUGFeRD, Factur-X) Enforced by CSP connect-src 'self'</title>
      <dc:creator>Kai Wang</dc:creator>
      <pubDate>Sat, 05 Dec 2026 13:15:51 +0000</pubDate>
      <link>https://dev.to/eueinvoice/building-a-zero-upload-eu-e-invoice-validator-xrechnung-zugferd-factur-x-enforced-by-csp-500p</link>
      <guid>https://dev.to/eueinvoice/building-a-zero-upload-eu-e-invoice-validator-xrechnung-zugferd-factur-x-enforced-by-csp-500p</guid>
      <description>&lt;p&gt;With Germany's B2B e-invoicing mandate already underway (XRechnung / ZUGFeRD) and France's mandatory receiving rollout arriving in September 2026 (Factur-X), freelancers and small businesses across Europe are suddenly receiving raw UBL 2.1 / UN/CEFACT CII XML files and hybrid PDF/A-3 documents in their inbox.&lt;/p&gt;

&lt;p&gt;When you try to inspect one of these files without installing heavy desktop software, most free web "viewers" expect you to upload real B2B invoices—complete with IBANs, VAT IDs, customer line items, and hourly rates—to an unknown backend server. Even worse, a wave of LLM wrapper tools has popped up that parse financial documents probabilistically and quietly hallucinate rounding or tax math.&lt;/p&gt;

&lt;p&gt;To solve this cleanly, I built &lt;a href="https://eueinvoice.com/en/" rel="noopener noreferrer"&gt;EU eInvoice&lt;/a&gt; (also available in &lt;a href="https://eueinvoice.com/de/" rel="noopener noreferrer"&gt;German&lt;/a&gt; and &lt;a href="https://eueinvoice.com/fr/" rel="noopener noreferrer"&gt;French&lt;/a&gt;) around one hard architectural rule: &lt;strong&gt;invoice bytes must never leave the user's browser&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proving "Zero Uploads" with HTTP Headers Instead of Privacy Copy
&lt;/h2&gt;

&lt;p&gt;Anyone can write &lt;em&gt;"we respect your privacy"&lt;/em&gt; in a footer. A much stronger guarantee is letting the browser enforce it at the network layer.&lt;/p&gt;

&lt;p&gt;In our static Cloudflare Pages deployment (&lt;code&gt;public/_headers&lt;/code&gt;), every page ships with a strict Content-Security-Policy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Security&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Policy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="s1"&gt;'self'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;script&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="s1"&gt;'self'&lt;/span&gt; &lt;span class="s1"&gt;'unsafe-inline'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="s1"&gt;'self'&lt;/span&gt; &lt;span class="s1"&gt;'unsafe-inline'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="s1"&gt;'self'&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="s1"&gt;'self'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;connect&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="s1"&gt;'self'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;object&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="s1"&gt;'none'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="s1"&gt;'self'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ancestors&lt;/span&gt; &lt;span class="s1"&gt;'none'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because &lt;code&gt;connect-src 'self'&lt;/code&gt; blocks arbitrary third-party XHR/fetch destinations, even an accidental future dependency cannot quietly exfiltrate parsed invoice data to external analytics or AI APIs. You can open DevTools (&lt;code&gt;F12 -&amp;gt; Network&lt;/code&gt;), drop an invoice, or even disconnect Wi-Fi after page load, and verify that 0 bytes are transmitted during viewing, validation, XML extraction, or generation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Full transparency: there is an optional local Pro tier for accountants who need month-end batch workflows, and activating a license key calls a single same-origin &lt;code&gt;/api/verify-license&lt;/code&gt; edge route with only the license key—never any invoice data.)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Four Interesting Engineering Details Under the Hood
&lt;/h2&gt;

&lt;p&gt;The entire workbench runs client-side on &lt;strong&gt;Astro 5 + React 18 + TypeScript&lt;/strong&gt;, using a minimal set of browser-compatible libraries:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Extracting Embedded XML from Hybrid PDF/A-3 Files (&lt;code&gt;pdf-lib&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;ZUGFeRD and Factur-X invoices look like ordinary PDFs, but they carry a structured XML file (&lt;code&gt;factur-x.xml&lt;/code&gt;, &lt;code&gt;zugferd-invoice.xml&lt;/code&gt;, or &lt;code&gt;xrechnung.xml&lt;/code&gt;) inside the PDF catalog's &lt;code&gt;/Names -&amp;gt; /EmbeddedFiles&lt;/code&gt; name tree. Using &lt;code&gt;pdf-lib&lt;/code&gt;, we traverse the PDF catalog directly in memory, inflate the embedded &lt;code&gt;FlateDecode&lt;/code&gt; stream, and hand the UTF-8 XML straight to the parser—no server-side Poppler or Ghostscript needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Parsing Both OASIS UBL 2.1 and UN/CEFACT CII (&lt;code&gt;fast-xml-parser&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;European EN 16931 invoices arrive in two completely different XML syntaxes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UBL 2.1&lt;/strong&gt; (&lt;code&gt;Invoice&lt;/code&gt; / &lt;code&gt;CreditNote&lt;/code&gt;, common in Peppol BIS 3.0 and German XRechnung)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UN/CEFACT Cross-Industry Invoice (CII)&lt;/strong&gt; (used by ZUGFeRD and Factur-X)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Normalizing both into a single typed internal model lets the renderer, validator, CSV exporter, and payment QR generator stay syntax-agnostic while still letting users inspect the raw XML tree side-by-side.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Deterministic EN 16931 &amp;amp; ISO 13616 Validation
&lt;/h3&gt;

&lt;p&gt;Financial validation must be deterministic, not probabilistic. The browser validator checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mandatory EN 16931 fields and line/tax/total rounding rules (such as &lt;code&gt;BR-CO-10&lt;/code&gt; and &lt;code&gt;BR-CO-13&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Country-specific business rules like German &lt;code&gt;BR-DE-15&lt;/code&gt; (Buyer Reference / Leitweg-ID) and French SIREN/SIRET identifiers&lt;/li&gt;
&lt;li&gt;Full &lt;strong&gt;ISO 13616 IBAN MOD-97&lt;/strong&gt; checksum verification&lt;/li&gt;
&lt;li&gt;One-click generation of a polite supplier rejection email draft when an incoming invoice fails compliance, plus a local XML anonymizer for stripping PII before sharing test files with IT or tax advisors&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Local SEPA GiroCode QR, DATEV EXTF v700 &amp;amp; ISO 20022 &lt;code&gt;pain.001&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;For EUR invoices containing an IBAN, the viewer automatically renders a local &lt;strong&gt;EPC069-12 SEPA GiroCode QR SVG&lt;/strong&gt; (via &lt;code&gt;qrcode-generator&lt;/code&gt;) so freelancers can scan and pay immediately from their European banking app without retyping a 22-character IBAN.&lt;/p&gt;

&lt;p&gt;For month-end bookkeeping batches, I also built pure-TypeScript exporters for German &lt;strong&gt;DATEV EXTF v700&lt;/strong&gt; (&lt;code&gt;Buchungsstapel&lt;/code&gt; CSV with SKR03/SKR04 and &lt;code&gt;BU-Schlüssel&lt;/code&gt; mapping), &lt;strong&gt;ISO 20022 SEPA &lt;code&gt;pain.001.001.09&lt;/code&gt; / &lt;code&gt;.03&lt;/code&gt;&lt;/strong&gt; batch credit transfer XMLs, and bundled A4 PDF + vector QR ZIP archives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It &amp;amp; Share Edge Cases
&lt;/h2&gt;

&lt;p&gt;The core viewer, EN 16931 validator, SEPA GiroCode QR generator, XML anonymizer, invoice generator, and Germany/France mandate deadline calculator are completely free with no account required:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;English: &lt;a href="https://eueinvoice.com/en/" rel="noopener noreferrer"&gt;eueinvoice.com/en/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Deutsch: &lt;a href="https://eueinvoice.com/de/" rel="noopener noreferrer"&gt;eueinvoice.com/de/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Français: &lt;a href="https://eueinvoice.com/fr/" rel="noopener noreferrer"&gt;eueinvoice.com/fr/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you work with European accounting workflows and run into exotic XRechnung, ZUGFeRD, or Factur-X XML edge cases—or quirks with specific German/French banks importing &lt;code&gt;pain.001&lt;/code&gt; files—I would love to hear about them in the comments!&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>privacy</category>
    </item>
  </channel>
</rss>
