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

ksef-client-ts

v0.5.1

Published

TypeScript client for the Polish National e-Invoice System (KSeF) API

Readme

ksef-client-ts

TypeScript client for the Polish National e-Invoice System (KSeF) API v2.

Documentation · NPM

Features

  • Complete API coverage — KSeF API v2.3.0, types aligned with the official OpenAPI spec
  • Full-featured CLIksef with 14 command groups for auth, sessions, invoices, batch upload, export, and more
  • High-level workflows — auth, online/batch sessions, invoice export — full lifecycle in a single call
  • Built-in cryptography — AES-256-CBC, RSA-OAEP, ECDH, XAdES-B signatures, self-signed certs (Node crypto)
  • External signing — HSM, EPUAP, and smart card authentication via callback-based signing
  • Automatic token management — AuthManager: token injection, 401 refresh with dedup
  • Streaming batch uploads — constant-memory batch upload via Web Streams API with ZIP bomb protection
  • Incremental export — HWM-based paginated export with file-based state persistence
  • Multiple document structures — FA, PEF, PEF_KOR, FA_RR with typed FormCode constants and UPO parsing
  • Invoice XML validation — three-level client-side validation (well-formedness, XSD schema via Zod, NIP/PESEL checksums, future date rejection) with auto-detection for all 6 invoice types
  • Typed errors & fluent buildersKSeFError hierarchy (401, 403, 429, validation) and request builders
  • Comprehensive test coverage — unit + E2E tests across HTTP, crypto, services, workflows; CI on every change
  • Interactive setup wizardksef setup guides through environment selection, authentication, and token generation in one flow
  • Zero HTTP dependencies — native fetch (Node 18+); dual ESM/CJS via tsup

Requires Node.js 18+.

Install

Install CLI globally:

npm i -g ksef-client-ts
ksef --help

Install in a project:

# Choose one package manager:
# npm
npm i ksef-client-ts
# Yarn
yarn add ksef-client-ts
# pnpm
pnpm add ksef-client-ts

For local development, clone and build:

git clone https://github.com/Flopsstuff/ksef-client-ts.git
cd ksef-client-ts
yarn install && yarn build
import { KSeFClient } from 'ksef-client-ts';

const client = new KSeFClient({ environment: 'TEST' });
await client.crypto.init();

const challenge = await client.auth.getChallenge();
// ... authenticate, open session, send invoices
ksef auth login --token "$KSEF_TOKEN" --nip "$KSEF_NIP"
ksef session open
ksef invoice send invoice.xml
ksef session close

See the documentation for full usage, API reference, and CLI reference.

Development

yarn install      # Install dependencies (yarn 4.x via Corepack)
yarn build        # Build ESM + CJS + DTS via tsup
yarn lint         # Type-check (tsc --noEmit)
yarn test         # Run all tests (vitest)

Related

License

MIT


Tests Coverage NPM Version NPM Downloads GitHub Stars GitHub Forks GitHub License