ksef-client-ts 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.js +10 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +7134 -6461
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +130 -5
- package/dist/index.d.ts +130 -5
- package/dist/index.js +4125 -3464
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,14 +6,14 @@ TypeScript client for the Polish National e-Invoice System (KSeF) API v2.
|
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- **Complete API coverage** —
|
|
9
|
+
- **Complete API coverage** — KSeF API v2.3.0, types aligned with the official OpenAPI spec
|
|
10
10
|
- **Full-featured CLI** — `ksef` with many command groups and subcommands for day-to-day KSeF workflows
|
|
11
11
|
- **Full documentation** — VitePress site: Quick Start, API reference, OpenAPI spec
|
|
12
|
-
- **OpenAPI aligned** — types checked against the official KSeF spec; full spec and domain chunks in `docs/`
|
|
13
12
|
- **Comprehensive test coverage** — Vitest across HTTP, crypto, services, builders; CI on every change
|
|
14
13
|
- **Zero HTTP dependencies** — native `fetch` (Node 18+); dual ESM/CJS via tsup
|
|
15
14
|
- **Built-in cryptography** — AES-256-CBC, RSA-OAEP, ECDH, XAdES-B, self-signed certs (Node crypto)
|
|
16
15
|
- **Automatic token management** — AuthManager: token injection, 401 refresh with dedup, `loginWithToken` / `loginWithCertificate`
|
|
16
|
+
- **High-level workflows** — orchestration functions for auth, online/batch sessions, invoice export with polling and decryption
|
|
17
17
|
- **Typed errors & fluent builders** — `KSeFError` hierarchy (401, 403, 429, validation) and request builders
|
|
18
18
|
|
|
19
19
|
Requires **Node.js 18+**.
|
package/dist/cli.js
CHANGED
|
@@ -5590,6 +5590,10 @@ var DefaultAuthManager = class {
|
|
|
5590
5590
|
}
|
|
5591
5591
|
};
|
|
5592
5592
|
|
|
5593
|
+
// src/http/ksef-feature.ts
|
|
5594
|
+
var KSEF_FEATURE_HEADER = "X-KSeF-Feature";
|
|
5595
|
+
var ENFORCE_XADES_COMPLIANCE = "enforce-xades-compliance";
|
|
5596
|
+
|
|
5593
5597
|
// src/http/rest-request.ts
|
|
5594
5598
|
var RestRequest = class _RestRequest {
|
|
5595
5599
|
method;
|
|
@@ -5794,8 +5798,11 @@ var AuthService = class {
|
|
|
5794
5798
|
const response = await this.restClient.execute(request);
|
|
5795
5799
|
return response.body;
|
|
5796
5800
|
}
|
|
5797
|
-
async submitXadesAuthRequest(signedXml, verifyCertificateChain = false) {
|
|
5801
|
+
async submitXadesAuthRequest(signedXml, verifyCertificateChain = false, enforceXadesCompliance = false) {
|
|
5798
5802
|
const request = RestRequest.post(Routes.Authorization.xadesSignature).body(signedXml).header("Content-Type", "application/xml").query("verifyCertificateChain", String(verifyCertificateChain));
|
|
5803
|
+
if (enforceXadesCompliance) {
|
|
5804
|
+
request.header(KSEF_FEATURE_HEADER, ENFORCE_XADES_COMPLIANCE);
|
|
5805
|
+
}
|
|
5799
5806
|
const response = await this.restClient.execute(request);
|
|
5800
5807
|
return response.body;
|
|
5801
5808
|
}
|
|
@@ -5853,7 +5860,7 @@ var OnlineSessionService = class {
|
|
|
5853
5860
|
async openSession(request, upoVersion) {
|
|
5854
5861
|
const req = RestRequest.post(Routes.Sessions.Online.open).body(request);
|
|
5855
5862
|
if (upoVersion) {
|
|
5856
|
-
req.header(
|
|
5863
|
+
req.header(KSEF_FEATURE_HEADER, upoVersion);
|
|
5857
5864
|
}
|
|
5858
5865
|
const response = await this.restClient.execute(req);
|
|
5859
5866
|
return response.body;
|
|
@@ -5878,7 +5885,7 @@ var BatchSessionService = class {
|
|
|
5878
5885
|
async openSession(request, upoVersion) {
|
|
5879
5886
|
const req = RestRequest.post(Routes.Sessions.Batch.open).body(request);
|
|
5880
5887
|
if (upoVersion) {
|
|
5881
|
-
req.header(
|
|
5888
|
+
req.header(KSEF_FEATURE_HEADER, upoVersion);
|
|
5882
5889
|
}
|
|
5883
5890
|
const response = await this.restClient.execute(req);
|
|
5884
5891
|
return response.body;
|