Changelog
All notable changes to this project will be documented in this file.
[0.5.1] - 2026-03-30
Added
- Interactive setup wizard —
ksef setupguides users through NIP configuration, authentication, and optional API token generation in a single interactive session. Supports self-signed certificate quick auth on the test environment and external signature flow for demo/production. - Credentials store — persistent storage for long-lived API tokens in
~/.ksef/credentials.json, separate from session and config files. Tokens saved during setup or manually are automatically used byksef auth loginas a fallback when--tokenis not provided. - Cross-platform folder opener —
ksef setupopens the~/.ksef/folder in the system file manager during external signing to streamline the workflow. - Automatic session recovery — all CLI commands automatically restore expired sessions by refreshing the token or re-authenticating with stored credentials. No more manual
ksef auth loginafter session expiry. - Future invoice date validation — invoice validator now rejects P_1 (invoice issue date) set in the future, which KSeF silently rejects with a 445 error.
Fixed
- Encryption key mismatch on invoice send —
ksef session openandksef invoice sendeach generated independent AES-256 keys, causing KSeF to reject every invoice with status 445. Encryption keys are now persisted in the session store and reused across commands.
[0.5.0] - 2026-03-29
Added
- Invoice XML validation — client-side validation of invoice XML against official KSeF XSD schemas before submission. Three levels: XML well-formedness, Zod schema validation (generated from XSD at build time), and business rules (NIP/PESEL checksums). Auto-detects schema type from XML namespace. Supports all 6 invoice types (FA2, FA3, PEF3, PEF_KOR3, RR v1-0E, RR v1-1E). Available via
ksef invoice validateCLI command, programmaticvalidate()API, and opt-in--validateflag onksef invoice send. - Official XSD invoice schemas — all KSeF invoice XSD schemas (FA, PEF, RR) bundled in
docs/schemas/withyarn sync-schemasto update from the official Ministry of Finance repository. - Encrypted PEM key support —
--key-passwordoption forksef auth loginto use encrypted PEM private keys without manual decryption. whoamiidentity context —ksef auth whoaminow displays NIP, auth method, permissions, and token type parsed from the JWT access token. Full context available in--jsonmode.- Advanced E2E scenarios — RR invoicing (FA-RR agricultural invoice lifecycle), self-invoicing (buyer-seller cross-entity flow with seller verification), enforcement operations, technical corrections, incremental export with HWM, and duplicate invoice detection.
Changed
- Default form code switched to FA(3) — CLI commands, workflows, and E2E tests now default to FA(3), the invoice schema required by KSeF on DEMO and PROD since February 2026. FA(2) remains available via
--form-code FA2for backward compatibility. - CLI defaults to PROD environment —
ksefcommands now target the production KSeF API when--envis not specified. Use--env testorksef config set --env testfor development. The library (KSeFClient) still defaults to TEST as a safety measure.
Fixed
- CLI date format —
--fromand--todate arguments ininvoice query,invoice export, andinvoice export-incrementalare now normalized to full ISO-8601 datetime, fixing HTTP 400 errors when using shortYYYY-MM-DDformat.
[0.4.0] - 2026-03-28
Added
- External signing support —
buildUnsignedAuthTokenRequestXml()generates unsigned KSeF auth XML for external signing (HSM, EPUAP, smart cards). Supports all 4 context identifier types. IncludesauthenticateWithExternalSignature()callback-based workflow and CLIksef auth login-externalwith two-phase--generate/--submitflow. - Multiple document structures —
SystemCodeenum (FA v2/v3, PEF, PEF_KOR, FA_RR), typedFORM_CODESconstants (7 variants), session-type constrained unions, helper functions (getFormCode,parseFormCode,validateFormCodeForSession), InvoiceType mapping per document type. CLI--form-codeoption onksef session openandksef invoice sendwith PEF batch rejection. - Stream-based batch upload —
uploadBatchStream()workflow with constant memory usage via Web Streams API. Stream-based AES-256-CBC encryption, SHA-256 hashing, and ZIP splitting with two-pass stream factory pattern. Sequential part upload for O(max_part_size) memory. CLI--streamflag onksef invoice sendfor .zip files. - Incremental export (HWM) — iterative export of invoices with automatic high-water-mark tracking. Resumes from the last processed date across runs, handles truncated results with multiple iterations, and saves state to a JSON file for reliable long-running syncs. Includes CLI command and pluggable storage for custom integrations.
- UPO XML parsing — parse official KSeF receipt confirmations (UPO) into structured typed objects. Supports all authentication context variants and multi-document session receipts. Integrated into online and batch session workflows, with
--parsedCLI option for JSON output. - ZIP bomb protection — safe
unzip()/createZip()with configurable limits (file count, total/per-file size, compression ratio). Export workflow supports opt-in extraction viaextractoption. - Documentation — 6 new VitePress pages: Workflows, Batch Processing, HTTP Resilience, Cryptography, QR Codes, Validation & Data Integrity.
- E2E test expansion — 6 new E2E tests across 4 files
Changed
- TBD
Fixed
- Incremental export decryption —
incrementalExportAndDownloadused its own AES key instead of the one fromdoExport, causingbad decrypton downloaded parts. - DEFAULT_FORM_CODE —
systemCode/schemaVersion/valuefields were swapped in both workflow files; corrected to match OpenAPI spec (FA (2)/1-0E/FA). - CLI version —
ksef --versionwas hardcoded to0.1.0; now reads frompackage.jsonat runtime.
[0.3.0] - 2026-03-25
Added
- Test data environment guard —
TestDataServicenow throwsKSeFErrorwhen called on DEMO or PROD environments. - Batch auto-split —
BatchFileBuilderautomatically splits large ZIP files into parts (100 MB default), encrypts each part with AES-256-CBC, and computes SHA-256 hashes. - E2E test coverage expansion — 5 new E2E test suites: test-data limits & attachments, workflow auth, online session workflow, invoice export workflow, error handling. Existing suites extended with additional assertions.
Changed
uploadBatch()API — now accepts rawUint8ArrayZIP data instead of separate encryption parameters. Encryption, splitting, and hash computation are handled internally byBatchFileBuilder.
Fixed
- Export workflow —
exportAndDownload()now correctly initializes crypto before decrypting parts. - Session polling —
waitForUpo()now checks for terminal status codes (200 or >=400) instead of just "not 100".
[0.2.0] - 2026-03-22
Added
- Workflows — high-level orchestration functions for multi-step KSeF operations:
openOnlineSession()/openSendAndClose()— online session: open, send invoices, close, poll UPO.uploadBatch()— batch session: open, upload parts, close, poll UPO.exportInvoices()/exportAndDownload()— invoice export: initiate, poll status, download and decrypt parts.authenticateWithToken()/authenticateWithCertificate()/authenticateWithPkcs12()— full auth flow orchestration.- Shared
pollUntil()utility extracted from E2E helpers.
- UPO versioning — type-safe
UpoVersionconstants (V4_2,V4_3) andKSEF_FEATURE_HEADERforX-KSeF-Featureheader support on session open requests. - XAdES compliance header —
enforceXadesComplianceparameter onAuthService.submitXadesAuthRequest()withENFORCE_XADES_COMPLIANCEconstant. - KSeF number CRC-8 validation —
isValidKsefNumber()now verifies CRC-8 checksum (polynomial 0x07) per official KSeF spec. NewisValidKsefNumberV35()andisValidKsefNumberV36()validators for version-specific formats.
Fixed
- Added missing
context-type-not-allowedliteral toForbiddenReasonCodetype union (aligns with OpenAPI spec).
[0.1.1] - 2026-03-22
Added
- PKCS#12 authentication support (
src/crypto/pkcs12-loader.ts) for certificate-based login. - Full E2E test suite — 13 base suites + 5 permission suites (18 files total), zero secrets in code.
- E2E test helpers: auth, env, identifiers, invoices, polling; FA2/FA3 invoice fixtures.
scripts/check-openapi-coverage.mjsto validate OpenAPI spec coverage.scripts/whoami.tsdiagnostic script.- GitHub Actions:
release.yml(automated releases fromv*tags),e2e.yml(E2E tests). - E2E test documentation (
docs/e2e-tests.md). - Installation instructions in README.
Changed
- Updated OpenAPI source to KSeF API version
2.3.0. - Renamed
PRDenvironment toPRODacross the codebase. - Aligned
TestDataservice with OpenAPI spec — methods returnvoidinstead ofOperationStatusInfo. - Refactored status handling and type definitions across services.
- Updated invoice types: replaced deprecated
RRusage withFA_RR. - Improved NIP/PESEL validation patterns.
- Updated bearer auth scheme casing in the OpenAPI definition.
[0.1.0] - 2026-03-22
Added
- Initial public release of
ksef-client-tson npm. - OpenAPI source to KSeF API version
2.2.1 - TypeScript client for KSeF API v2 with typed models and service-based API.
- Dual ESM/CJS build output with generated type declarations.
- Built-in CLI (
ksef) with command groups for common KSeF operations. - Documentation site powered by VitePress.
Info
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning. Format:
## [{VERSION}] - {DATE}
### Added
- TBD
### Changed
- TBD
### Fixed
- TBD