Skip to content

Installation

dte-sdk is a single package with zero runtime dependencies. It ships ESM and CommonJS builds with bundled types, and it's fully tree-shakeable (sideEffects: false), so you only pay for the functions you import. The full bundle is about 8.4 KB min+gzip.

Installing today gives you 0.0.2, a placeholder release that only exports hello(). The functions on these pages are the planned 1.0 API and may change before release.

Requirements#

  • Node.js 20 or later (engines: node >=20), Deno, Bun, or any modern browser
  • A package manager: npm, pnpm, bun or yarn
  • TypeScript is optional: types are bundled (there's no @types package to install), and the library works in plain JavaScript too

Add the package#

Shell
npm install dte-sdk

Verify the installation#

1

Import a function

Imports are named and tree-shakeable. calculateTotals() is a pure function (no CAF, certificate or network involved), which makes it a good smoke test.

TypeScript
import { calculateTotals } from 'dte-sdk'
2

Run it

One line at 120.000 CLP net, with 19% IVA on top.

TypeScript
const totals = calculateTotals([
  { name: 'Licencia anual', quantity: 1, unitPrice: 120000 },
])
 
console.log(totals.vat)   // 22800
console.log(totals.total) // 142800
3

You're set

If both lines log as above, the package is wired correctly. Continue with the Quick Start.

Module formats#

dte-sdk works with both module systems without configuration:

TypeScript
// ESM / TypeScript
import { createDte, signDte } from 'dte-sdk'
JavaScript
// CommonJS
const { createDte, signDte } = require('dte-sdk')

Runtime support#

The same code runs on Node, Deno, Bun and the browser. Signing uses the Web Crypto API (crypto.subtle), which every supported runtime provides: no native modules, no crypto bindings, no polyfills.

EnvironmentSupportedNotes
Node.js (>=20)✅ESM and CommonJS
Bun✅Native ESM
Deno✅Import with the npm:dte-sdk specifier
Browsers✅Bundle with any tool; tree-shakeable

Running in the browser is supported, but signing there means the certificate's private key is in the browser too. For most apps, build and preview documents on the client and stamp, sign and send on the server. See Security.

What you'll need besides the package#

dte-sdk handles the document format, the cryptography and the conversation with the SII. To issue documents the SII accepts, you also need three things the package can't give you:

You needWhat it isWhere it comes from
A CAF per document typeAn XML file that authorizes a range of folios, with the private key used to stamp themRequested from the SII, one per document type
A digital certificateA .pfx or .p12 file and its password, issued to a person authorized to sign for the companyAn accredited certification provider
An SII resolutionThe number and date of the resolution that authorizes the company as an electronic issuerGranted by the SII after certification (use number 0 in the certification environment)

You don't need any of them to try createDte(), calculateTotals() or toXml(): they're pure functions. Core Concepts explains how the pieces fit together.

Next steps#