npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tribu

v0.1.0-experimental.1

Published

SUNAT electronic invoicing for TypeScript: issue invoices, receipts and notes to Peru's tax authority.

Readme

Tribu

Issue Peruvian electronic payment documents (comprobantes de pago electrónicos) to SUNAT from TypeScript.

const { record } = await sunat.invoice({
  customer: { ruc: '20123456786', name: 'CLIENTE SAC' },
  items: [{ description: 'Teclado', quantity: 2, price: 118 }],
});

Tribu calculates the amounts, validates the Document against SUNAT's rules before sending it, builds the UBL 2.1 XML, signs it, sends it, and hands back one plain JSON Record for you to save. You never write XML, never compute IGV, and never type a SUNAT code by hand.

Leer en español

[!WARNING] Experimental. Tribu is published only as an experimental version. SUNAT's beta environment accepts every document type it issues (Milestone 0 results), but it has not been verified in production. Try it in beta first. If you use it in production, read Trying it in production and please tell us how it went.

[!IMPORTANT] Detracciones work only on Invoices in soles, for the goods and services with one confirmed rate (Detracciones). Perceptions, retentions, advance payments, exports, free operations, ISC and ICBPER are out of scope (see What v0.1 covers).

Why Tribu

Without Tribu you compute the IGV, write the UBL XML, sign it, zip it, send it over SOAP, and decode SUNAT's answer yourself. With Tribu that is one call, SUNAT's rules are checked before sending, and every error tells you how to fix it. See the comparison, step by step.

Requirements

  • Node.js 22.12 or later. Tribu runs on the server only: it holds your Certificate and SOL password, so tribu.create refuses to run in a browser.
  • ESM only.

Installation

npm install tribu@experimental
# or
pnpm add tribu@experimental

The experimental versions (0.1.0-experimental.N) are tested against SUNAT beta only. A stable version will follow once Tribu is verified in production.

Quick start

import { readFileSync } from 'node:fs';
import tribu, { Status } from 'tribu';

const sunat = tribu.create({
  env: 'beta',
  issuer: { ruc: '20000000001', name: 'EMPRESA DE PRUEBA SAC', ubigeo: '150101' },
  sol: { user: 'MODDATOS', password: 'MODDATOS' }, // SUNAT's public beta credentials
  certificate: { pfx: readFileSync('certificate.pfx'), passphrase },
  nextNumber: (series) => db.nextNumber(series), // your database reserves the Number
});

const { record } = await sunat.invoice({
  customer: { ruc: '20123456786', name: 'CLIENTE SAC' },
  items: [{ description: 'Teclado', quantity: 2, price: 118 }],
});

await db.save(record); // save the Record before doing anything else

record.id;          // 'F001-1'
record.status.code; // 'accepted'
record.qr;          // the QR text for the Printed Representation

In production, sol and env usually come from the environment: SUNAT_ENV, SUNAT_SOL_USER and SUNAT_SOL_PASSWORD. Pass the SOL user without the RUC; Tribu adds it.

tribu.create opens the Certificate at once, so a wrong passphrase or an expired Certificate fails at startup, not on your first sale. A Certificate that expires within 30 days shows up in sunat.warnings.

[!CAUTION] Production is the default. Without env: 'beta' (or SUNAT_ENV=beta), Tribu talks to SUNAT's production service, and every Document is legally binding. See Configuration.

Documentation

| | | |---|---| | Examples | Recipes for everything Tribu does | | Documents | Amounts and IGV, Invoices, Receipts, notes, voiding | | Records and errors | What to save, statuses, errors, network failures | | Testing your code | fakeSunat() | | Configuration | Environments, options, entry points | | SUNAT deadlines | The deadlines Tribu checks | | Trying it in production | What you need and what is not verified yet |

The whole guide: docs/guide. The vocabulary: GLOSSARY.md.

What v0.1 covers

| Area | Included | |---|---| | Documents | Invoices, Receipts (individually or in a Daily Summary), Credit and Debit Notes | | Reporting | Daily Summary, Voided Documents, waitFor, retry | | Lines | Taxed, exempt or unaffected; units NIU and ZZ | | IGV | General and the reduced rate for restaurants and hotels | | Currency | PEN by default, USD | | Payment Terms | Cash, or credit with Installments | | Detracciones | On Invoices in soles; the amount and the net amount pending are calculated |

Not yet: detracciones on Receipts or in USD, perceptions, retentions, advance payments, exports and Invoices without RUC, free operations, ISC, ICBPER, the dispatch guide, PDF and QR images, and official support for OSEs (a custom transport works, but OSEs are not tested).

Contributing

Bug reports, production reports and improvements are welcome. Read CONTRIBUTING.md first: it explains how to report a problem without exposing your credentials, and how to propose a change.

License

MIT