Skip to content

Features

Everything you need to issue a DTE in production.

dte-sdk is a focused toolkit for Chilean electronic tax documents — typed end to end, careful with your keys, and portable to every runtime.

Functions

9

Tests

412

Dependencies

0

Bundle size

~8.4 KB

Why dte-sdk in production

Complete

The whole lifecycle, from line items to acceptance.

  • Eight document types: 33, 34, 39, 41, 46, 52, 56, 61
  • Build, total, stamp, sign, send, and track
  • References for credit and debit notes
  • Full TypeScript types across the API surface

Correct

Numbers and XML the SII accepts.

  • Per-line half-up rounding in whole pesos
  • Exempt lines and IVA-inclusive receipts
  • Folio range and CAF expiry checks
  • XSD-conformant output, ISO-8859-1 by default

Secure

Built for the path where your keys live.

  • Passwords and CAF keys never logged or serialized
  • Generic, typed errors — no PII in messages
  • Web Crypto signing, no native binaries

Multi-runtime

Runs everywhere your JS/TS runs.

  • Zero dependencies, ~8.4 KB gzipped
  • Node (>= 20), Deno, Bun, Edge
  • Tree-shakeable ESM + CommonJS

Reliable by proof

Every function is exercised against valid, invalid, and adversarial documents — happy paths, SII edge cases, and failure modes included.

Test cases

412

Test suites

14

Pass rate

100%

Per suite

  • createDte()78
  • calculateTotals()64
  • stampDte()52
  • signDte()41
  • sendToSii()38
  • toXml()36
  • getStatus()24
  • parseCaf()22
  • loadCertificate()15
  • Property-based totals14
  • DteError12
  • XSD schema conformance10
  • Built-bundle smoke5
  • Compile-time types1

What's covered

Document building

  • All eight document types
  • Required fields per type
  • Up to 60 line items
  • References on notes (56, 61)

Totals & IVA

  • Per-line half-up rounding
  • Exempt and mixed documents
  • IVA-inclusive receipts
  • Discounts per line
  • Property-based invariants

CAF & TED

  • Folio inside and outside the range
  • Type and issuer mismatches
  • Expired CAF
  • PDF417 payload shape

Signing

  • Valid and corrupted certificates
  • Wrong password, no leak
  • Canonicalization round-trips

SII transport

  • Token caching and expiry
  • Upload retries and timeouts
  • All acceptance states

Output

  • XSD schema conformance
  • ISO-8859-1 and UTF-8 encoding
  • Escaping of names and addresses
  • Built-bundle smoke tests
dte-sdk

MIT License © 2026 Arrow Software