ksef-client-ts 0.6.2 → 0.7.1

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.
Files changed (37) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +2630 -634
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.cjs +1689 -138
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +361 -17
  7. package/dist/index.d.ts +361 -17
  8. package/dist/index.js +1657 -138
  9. package/dist/index.js.map +1 -1
  10. package/docs/schemas/FA/bazowe/ElementarneTypyDanych_v10-0E.xsd +1 -0
  11. package/docs/schemas/FA/bazowe/KodyKrajow_v10-0E.xsd +1283 -0
  12. package/docs/schemas/FA/bazowe/StrukturyDanych_v10-0E.xsd +1 -0
  13. package/docs/schemas/FA/schemat_FA(2)_v1-0E.xsd +3661 -0
  14. package/docs/schemas/FA/schemat_FA(3)_v1-0E.xsd +3950 -0
  15. package/docs/schemas/PEF/Schemat_PEF(3)_v2-1.xsd +977 -0
  16. package/docs/schemas/PEF/Schemat_PEF_KOR(3)_v2-1.xsd +926 -0
  17. package/docs/schemas/PEF/bazowe/20241206_PEFPL-CommonAggregateComponents-2.1-v1.4.34.xsd +428 -0
  18. package/docs/schemas/PEF/bazowe/20241206_PEFPL-CommonBasicComponents-2.1-v1.4.34.xsd +65 -0
  19. package/docs/schemas/PEF/bazowe/CCTS_CCT_SchemaModule-2.1.xsd +731 -0
  20. package/docs/schemas/PEF/bazowe/UBL-CommonAggregateComponents-2.1.xsd +39799 -0
  21. package/docs/schemas/PEF/bazowe/UBL-CommonBasicComponents-2.1.xsd +5389 -0
  22. package/docs/schemas/PEF/bazowe/UBL-CommonExtensionComponents-2.1.xsd +223 -0
  23. package/docs/schemas/PEF/bazowe/UBL-CommonSignatureComponents-2.1.xsd +101 -0
  24. package/docs/schemas/PEF/bazowe/UBL-ExtensionContentDataType-2.1.xsd +89 -0
  25. package/docs/schemas/PEF/bazowe/UBL-QualifiedDataTypes-2.1.xsd +69 -0
  26. package/docs/schemas/PEF/bazowe/UBL-SignatureAggregateComponents-2.1.xsd +138 -0
  27. package/docs/schemas/PEF/bazowe/UBL-SignatureBasicComponents-2.1.xsd +78 -0
  28. package/docs/schemas/PEF/bazowe/UBL-UnqualifiedDataTypes-2.1.xsd +553 -0
  29. package/docs/schemas/PEF/bazowe/UBL-XAdESv132-2.1.xsd +476 -0
  30. package/docs/schemas/PEF/bazowe/UBL-XAdESv141-2.1.xsd +25 -0
  31. package/docs/schemas/PEF/bazowe/UBL-xmldsig-core-schema-2.1.xsd +323 -0
  32. package/docs/schemas/PEF/bazowe/commontypes.xsd +735 -0
  33. package/docs/schemas/PEF/bazowe/isotypes.xsd +3158 -0
  34. package/docs/schemas/RR/schemat_FA_RR(1)_v1-1E.xsd +2188 -0
  35. package/docs/schemas/RR/schemat_RR(1)_v1-0E.xsd +2188 -0
  36. package/docs/schemas/RR/schemat_RR(1)_v1-1E.xsd +2188 -0
  37. package/package.json +14 -2
package/dist/index.d.cts CHANGED
@@ -57,6 +57,27 @@ declare class RateLimitPolicy {
57
57
  }
58
58
  declare function defaultRateLimitPolicy(): RateLimitPolicy;
59
59
 
60
+ interface CircuitBreakerConfig {
61
+ failureThreshold: number;
62
+ openMs: number;
63
+ scope?: 'global' | 'endpoint';
64
+ }
65
+ declare class CircuitBreakerPolicy {
66
+ private readonly failureThreshold;
67
+ private readonly openMs;
68
+ private readonly scope;
69
+ private readonly states;
70
+ constructor(config?: Partial<CircuitBreakerConfig>);
71
+ ensureClosed(endpoint: string, alreadyOwnsProbe?: boolean): boolean;
72
+ recordSuccess(endpoint: string): void;
73
+ releaseProbe(endpoint: string): void;
74
+ recordFailure(endpoint: string): void;
75
+ private keyFor;
76
+ private maybeSweepStaleClosed;
77
+ private static readonly sweepThreshold;
78
+ }
79
+ declare function defaultCircuitBreakerPolicy(): CircuitBreakerPolicy;
80
+
60
81
  interface AuthManager {
61
82
  getAccessToken(): string | undefined;
62
83
  setAccessToken(token: string | undefined): void;
@@ -99,8 +120,22 @@ interface KSeFClientOptions {
99
120
  transport?: TransportFn;
100
121
  retry?: Partial<RetryPolicy>;
101
122
  rateLimit?: Partial<RateLimitConfig> | null;
123
+ /**
124
+ * HTTP circuit breaker. Opt-in: `undefined` or omitted keeps the feature off.
125
+ * Pass a partial config to enable with defaults merged in. Opens after
126
+ * consecutive network/5xx failures and fails fast during the cooldown window,
127
+ * then probes a single request to recover. 429/401 never trip the breaker.
128
+ */
129
+ circuitBreaker?: Partial<CircuitBreakerConfig> | null;
102
130
  presignedUrlHosts?: string[];
103
131
  authManager?: AuthManager;
132
+ /**
133
+ * Request format for server-returned error bodies. Defaults to
134
+ * `'problem-details'` (RFC 7807, KSeF API v2.4.0+). Set to `'legacy'`
135
+ * to suppress the `X-Error-Format` header and receive legacy error
136
+ * bodies from older servers or proxies.
137
+ */
138
+ errorFormat?: 'problem-details' | 'legacy';
104
139
  }
105
140
  interface ResolvedOptions {
106
141
  baseUrl: string;
@@ -110,6 +145,7 @@ interface ResolvedOptions {
110
145
  timeout: number;
111
146
  customHeaders: Record<string, string>;
112
147
  environmentName?: EnvironmentName;
148
+ errorFormat: 'problem-details' | 'legacy';
113
149
  }
114
150
  declare function resolveOptions(options?: KSeFClientOptions): ResolvedOptions;
115
151
 
@@ -137,13 +173,17 @@ interface UnauthorizedProblemDetails {
137
173
  timestamp?: string;
138
174
  }
139
175
  type ForbiddenReasonCode = 'missing-permissions' | 'ip-not-allowed' | 'insufficient-resource-access' | 'auth-method-not-allowed' | 'security-service-blocked' | 'context-type-not-allowed' | (string & {});
176
+ interface ForbiddenSecurityInfo {
177
+ requiredAnyOfPermissions?: string[];
178
+ presentPermissions?: string[];
179
+ }
140
180
  interface ForbiddenProblemDetails {
141
181
  title: string;
142
182
  status: number;
143
183
  detail: string;
144
184
  instance?: string;
145
185
  reasonCode: ForbiddenReasonCode;
146
- security?: Record<string, unknown>;
186
+ security?: ForbiddenSecurityInfo & Record<string, unknown>;
147
187
  traceId?: string;
148
188
  timestamp?: string;
149
189
  }
@@ -155,6 +195,37 @@ interface GoneProblemDetails {
155
195
  traceId?: string;
156
196
  timestamp?: string;
157
197
  }
198
+ interface BadRequestErrorDetail {
199
+ code: number;
200
+ description: string;
201
+ details: string[];
202
+ }
203
+ interface BadRequestProblemDetails {
204
+ title: string;
205
+ status: number;
206
+ detail?: string;
207
+ instance?: string;
208
+ errors: BadRequestErrorDetail[];
209
+ timestamp?: string;
210
+ traceId?: string;
211
+ }
212
+ interface TooManyRequestsProblemDetails {
213
+ title: string;
214
+ status: number;
215
+ detail?: string;
216
+ instance?: string;
217
+ timestamp?: string;
218
+ traceId?: string;
219
+ }
220
+ interface ProblemFields {
221
+ detail?: string;
222
+ reasonCode?: string;
223
+ errors?: BadRequestErrorDetail[];
224
+ security?: ForbiddenSecurityInfo & Record<string, unknown>;
225
+ traceId?: string;
226
+ instance?: string;
227
+ timestamp?: string;
228
+ }
158
229
 
159
230
  declare class KSeFError extends Error {
160
231
  constructor(message: string);
@@ -176,43 +247,61 @@ declare class KSeFApiError extends KSeFError {
176
247
  readonly errorResponse?: ApiErrorResponse;
177
248
  constructor(message: string, statusCode: number, errorResponse?: ApiErrorResponse);
178
249
  static fromResponse(statusCode: number, body?: ApiErrorResponse): KSeFApiError;
250
+ toProblemFields(): ProblemFields;
179
251
  }
180
252
 
181
253
  declare class KSeFRateLimitError extends KSeFApiError {
254
+ readonly statusCode: 429;
182
255
  readonly retryAfterSeconds?: number;
183
256
  readonly retryAfterDate?: Date;
184
257
  readonly recommendedDelay: number;
185
- constructor(message: string, statusCode: number, errorResponse?: ApiErrorResponse, retryAfterSeconds?: number, retryAfterDate?: Date);
186
- static fromRetryAfterHeader(statusCode: number, retryAfterHeader?: string | null, body?: ApiErrorResponse): KSeFRateLimitError;
258
+ readonly problem?: TooManyRequestsProblemDetails;
259
+ constructor(message: string, statusCode: number, errorResponse?: ApiErrorResponse, retryAfterSeconds?: number, retryAfterDate?: Date, problem?: TooManyRequestsProblemDetails);
260
+ static fromRetryAfterHeader(statusCode: number, retryAfterHeader?: string | null, body?: ApiErrorResponse, problem?: TooManyRequestsProblemDetails): KSeFRateLimitError;
261
+ toProblemFields(): ProblemFields;
187
262
  }
188
263
 
189
- declare class KSeFUnauthorizedError extends KSeFError {
190
- readonly statusCode = 401;
264
+ declare class KSeFUnauthorizedError extends KSeFApiError {
265
+ readonly statusCode: 401;
191
266
  readonly detail: string;
192
267
  readonly traceId?: string;
193
268
  readonly instance?: string;
194
269
  readonly timestamp?: string;
195
270
  constructor(problemDetails: UnauthorizedProblemDetails);
271
+ toProblemFields(): ProblemFields;
196
272
  }
197
273
 
198
- declare class KSeFForbiddenError extends KSeFError {
199
- readonly statusCode = 403;
274
+ declare class KSeFForbiddenError extends KSeFApiError {
275
+ readonly statusCode: 403;
200
276
  readonly detail: string;
201
277
  readonly reasonCode: ForbiddenReasonCode;
202
278
  readonly instance?: string;
203
- readonly security?: Record<string, unknown>;
279
+ readonly security?: ForbiddenSecurityInfo & Record<string, unknown>;
204
280
  readonly traceId?: string;
205
281
  readonly timestamp?: string;
206
282
  constructor(problemDetails: ForbiddenProblemDetails);
283
+ toProblemFields(): ProblemFields;
207
284
  }
208
285
 
209
- declare class KSeFGoneError extends KSeFError {
210
- readonly statusCode = 410;
286
+ declare class KSeFGoneError extends KSeFApiError {
287
+ readonly statusCode: 410;
211
288
  readonly detail: string;
212
289
  readonly instance?: string;
213
290
  readonly traceId?: string;
214
291
  readonly timestamp?: string;
215
292
  constructor(problemDetails: GoneProblemDetails);
293
+ toProblemFields(): ProblemFields;
294
+ }
295
+
296
+ declare class KSeFBadRequestError extends KSeFApiError {
297
+ readonly statusCode: 400;
298
+ readonly detail?: string;
299
+ readonly instance?: string;
300
+ readonly errors: BadRequestErrorDetail[];
301
+ readonly traceId?: string;
302
+ readonly timestamp?: string;
303
+ constructor(problemDetails: BadRequestProblemDetails);
304
+ toProblemFields(): ProblemFields;
216
305
  }
217
306
 
218
307
  declare class KSeFAuthStatusError extends KSeFError {
@@ -231,12 +320,29 @@ declare class KSeFBatchTimeoutError extends KSeFApiError {
231
320
  static fromResponse(statusCode: number, body?: ApiErrorResponse): KSeFBatchTimeoutError;
232
321
  }
233
322
 
323
+ declare class KSeFCircuitOpenError extends KSeFError {
324
+ readonly endpoint: string;
325
+ readonly openedAt: number;
326
+ readonly retryAfterMs: number;
327
+ constructor(endpoint: string, openedAt: number, retryAfterMs: number);
328
+ }
329
+
330
+ declare class KSeFXsdValidationError extends KSeFError {
331
+ readonly schemaFile: string;
332
+ readonly errors: string[];
333
+ constructor(schemaFile: string, errors: string[]);
334
+ }
335
+
234
336
  declare const KSeFErrorCode: {
235
337
  readonly BatchTimeout: 21208;
236
338
  readonly DuplicateInvoice: 440;
237
339
  };
238
340
  type KSeFErrorCode = (typeof KSeFErrorCode)[keyof typeof KSeFErrorCode];
239
341
 
342
+ declare function assertNever(value: never): never;
343
+
344
+ type KSeFApiProblem = KSeFBadRequestError | KSeFUnauthorizedError | KSeFForbiddenError | KSeFGoneError | KSeFRateLimitError;
345
+
240
346
  declare class RouteBuilder {
241
347
  private readonly apiVersion;
242
348
  constructor(apiVersion: string);
@@ -290,6 +396,7 @@ interface RestClientConfig {
290
396
  transport?: TransportFn;
291
397
  retryPolicy?: RetryPolicy;
292
398
  rateLimitPolicy?: RateLimitPolicy | null;
399
+ circuitBreakerPolicy?: CircuitBreakerPolicy | null;
293
400
  authManager?: AuthManager;
294
401
  presignedUrlPolicy?: PresignedUrlPolicy;
295
402
  }
@@ -299,6 +406,7 @@ declare class RestClient {
299
406
  private readonly transport;
300
407
  private readonly retryPolicy;
301
408
  private readonly rateLimitPolicy;
409
+ private readonly circuitBreakerPolicy;
302
410
  private readonly authManager?;
303
411
  private readonly presignedUrlPolicy?;
304
412
  constructor(options: ResolvedOptions, config?: RestClientConfig);
@@ -306,6 +414,7 @@ declare class RestClient {
306
414
  executeVoid(request: RestRequest): Promise<void>;
307
415
  executeRaw(request: RestRequest): Promise<RestResponse<ArrayBuffer>>;
308
416
  private sendRequest;
417
+ private recordCircuitOutcome;
309
418
  private doRequest;
310
419
  private buildUrl;
311
420
  private ensureSuccess;
@@ -553,13 +662,14 @@ declare const SchemaRegistry: {
553
662
  /**
554
663
  * Invoice XML validation service.
555
664
  *
556
- * Three independent validation levels:
557
- * - Level 1: XML well-formedness (xmldom parse)
558
- * - Level 2: Schema validation (xml→object→Zod safeParse)
559
- * - Level 3: Business rules (NIP/PESEL checksum verification)
665
+ * Four independent validation levels:
666
+ * - Level 1a: Char validity (processing instructions + discouraged Unicode)
667
+ * - Level 1: XML well-formedness (xmldom parse)
668
+ * - Level 2: Schema validation (xml→object→Zod safeParse)
669
+ * - Level 3: Business rules (NIP/PESEL checksum verification)
560
670
  */
561
671
 
562
- type InvoiceValidationErrorCode = 'MALFORMED_XML' | 'MISSING_REQUIRED_ELEMENT' | 'INVALID_VALUE' | 'INVALID_ENUM_VALUE' | 'PATTERN_MISMATCH' | 'MAX_OCCURS_EXCEEDED' | 'UNKNOWN_SCHEMA' | 'SCHEMA_VALIDATION_ERROR' | 'UNRECOGNIZED_KEY' | 'INVALID_NIP_CHECKSUM' | 'INVALID_PESEL_CHECKSUM' | 'FUTURE_INVOICE_DATE';
672
+ type InvoiceValidationErrorCode = 'XML_PROCESSING_INSTRUCTION' | 'XML_DISCOURAGED_UNICODE' | 'MALFORMED_XML' | 'MISSING_REQUIRED_ELEMENT' | 'INVALID_VALUE' | 'INVALID_ENUM_VALUE' | 'PATTERN_MISMATCH' | 'MAX_OCCURS_EXCEEDED' | 'UNKNOWN_SCHEMA' | 'SCHEMA_VALIDATION_ERROR' | 'UNRECOGNIZED_KEY' | 'INVALID_NIP_CHECKSUM' | 'INVALID_PESEL_CHECKSUM' | 'FUTURE_INVOICE_DATE';
563
673
  interface InvoiceValidationError {
564
674
  /** Error classification code. */
565
675
  code: InvoiceValidationErrorCode;
@@ -579,6 +689,12 @@ interface InvoiceValidationResult {
579
689
  interface ValidateOptions {
580
690
  /** Explicit schema type override (skip auto-detection). */
581
691
  schema?: SchemaType;
692
+ /**
693
+ * Skip Level 1a char-validity pre-parse check (processing instructions and
694
+ * discouraged Unicode code points). Defaults to `false` — the check runs and
695
+ * short-circuits the pipeline on failure.
696
+ */
697
+ skipCharValidity?: boolean;
582
698
  }
583
699
  /**
584
700
  * Check that the XML string is well-formed (parseable).
@@ -633,6 +749,47 @@ declare function batchValidationDetails(batch: BatchValidationResult): Array<{
633
749
  message: string;
634
750
  }>;
635
751
 
752
+ /**
753
+ * Level 1a — Character validity pre-parse check.
754
+ *
755
+ * KSeF API v2.4.0 rejects invoice XML that contains either:
756
+ * - XML processing instructions outside the `<?xml ... ?>` prolog, or
757
+ * - Unicode code points discouraged by W3C XML 1.0 §2.2.
758
+ *
759
+ * Strict server-side enforcement on KSeF production begins 2026-07-16.
760
+ * Running this check before `xmlToObject()` catches issues client-side
761
+ * with precise offsets instead of relying on a generic server rejection.
762
+ */
763
+
764
+ /**
765
+ * W3C XML 1.0 §2.2 discouraged Unicode code-point ranges (sorted, non-overlapping).
766
+ * Characters in any of these ranges are rejected by KSeF v2.4.0+.
767
+ */
768
+ declare const DISCOURAGED_UNICODE_RANGES: ReadonlyArray<readonly [number, number]>;
769
+ /**
770
+ * Scan raw XML string for disallowed processing instructions and discouraged
771
+ * Unicode code points. Returns accumulated errors; empty array means the
772
+ * document is acceptable at this level.
773
+ */
774
+ declare function validateCharValidity(xml: string): InvoiceValidationError[];
775
+
776
+ type InvoiceSchemaId = 'FA2' | 'FA3' | 'PEF' | 'PEF_KOR';
777
+ declare const FA_XSD_PATHS: {
778
+ readonly FA2: string;
779
+ readonly FA3: string;
780
+ };
781
+ declare const PEF_XSD_PATHS: {
782
+ readonly PEF: string;
783
+ readonly PEF_KOR: string;
784
+ };
785
+ declare function resolveXsdFor(schema: InvoiceSchemaId): string;
786
+ interface ValidateAgainstXsdResult {
787
+ valid: boolean;
788
+ errors: string[];
789
+ }
790
+ declare const libxmljsAvailable: boolean;
791
+ declare function validateAgainstXsd(xml: string, xsdPath: string): ValidateAgainstXsdResult;
792
+
636
793
  interface OperationResponse {
637
794
  referenceNumber: string;
638
795
  }
@@ -1841,6 +1998,13 @@ interface X500NameFields {
1841
1998
  countryCode?: string;
1842
1999
  }
1843
2000
  type CryptoEncryptionMethod = 'RSA' | 'ECDSA';
2001
+ /**
2002
+ * NIST elliptic curves for which KSeF XAdES signing is supported.
2003
+ *
2004
+ * The signing digest is paired with the curve per NIST SP 800-57:
2005
+ * P-256 → SHA-256, P-384 → SHA-384, P-521 → SHA-512.
2006
+ */
2007
+ type ECDigestCurve = 'P-256' | 'P-384' | 'P-521';
1844
2008
 
1845
2009
  type QRCodeContextIdentifierType = 'Nip' | 'InternalId' | 'NipVatUe' | 'PeppolId';
1846
2010
  interface QrCodeResult {
@@ -2012,8 +2176,19 @@ declare class PermissionsService {
2012
2176
  queryEuEntitiesGrants(options?: QueryEuEntitiesGrantsRequest, pageOffset?: number, pageSize?: number): Promise<PagedPermissionsResponse<EuEntityPermission>>;
2013
2177
  getOperationStatus(ref: string): Promise<PermissionsOperationStatusResponse>;
2014
2178
  getAttachmentStatus(): Promise<PermissionsAttachmentAllowedResponse>;
2179
+ private static validateContextIdentifier;
2015
2180
  }
2016
2181
 
2182
+ interface RevokeSelfOptions {
2183
+ /** Known reference number — skips discovery. */
2184
+ referenceNumber?: string;
2185
+ /** Access token used to infer the caller's context when discovery is needed. */
2186
+ accessToken?: string;
2187
+ }
2188
+ interface RevokeSelfResult {
2189
+ referenceNumber: string;
2190
+ alreadyRevoked: boolean;
2191
+ }
2017
2192
  declare class TokenService {
2018
2193
  private readonly restClient;
2019
2194
  constructor(restClient: RestClient);
@@ -2021,6 +2196,23 @@ declare class TokenService {
2021
2196
  queryTokens(options?: QueryKsefTokensOptions): Promise<QueryKsefTokensResponse>;
2022
2197
  getToken(ref: string): Promise<TokenStatusResponse>;
2023
2198
  revokeToken(ref: string): Promise<void>;
2199
+ /**
2200
+ * Resolves the reference number of the token currently in use for authentication.
2201
+ * The only JWT payload field treated as authoritative is the KSeF-specific `trn`
2202
+ * (token reference number). Standard RFC 7519 claims such as `jti` are NOT a safe
2203
+ * fallback — a `jti` that differs from the KSeF reference would cause a DELETE to
2204
+ * hit a non-existent path, which `revokeSelf` treats as already-revoked, falsely
2205
+ * reporting success while leaving the token active on the server. When `trn` is
2206
+ * absent, we fall back to `GET /tokens` filtered by author and context; requires
2207
+ * exactly one active match and returns undefined when ambiguous.
2208
+ */
2209
+ findSelfReferenceNumber(accessToken: string): Promise<string | undefined>;
2210
+ /**
2211
+ * Revokes the token currently used for authentication.
2212
+ * Treats 404/409/410 on DELETE as "already revoked" and returns successfully with
2213
+ * `alreadyRevoked: true` so callers can still clear local state.
2214
+ */
2215
+ revokeSelf(opts?: RevokeSelfOptions): Promise<RevokeSelfResult>;
2024
2216
  }
2025
2217
 
2026
2218
  declare class CertificateApiService {
@@ -2374,7 +2566,7 @@ declare class VerificationLinkService {
2374
2566
  * Build certificate verification URL (Code II).
2375
2567
  * Format: {baseQrUrl}/certificate/{contextType}/{contextId}/{sellerNip}/{certSerial}/{hash_base64url}/{signature_base64url}
2376
2568
  */
2377
- buildCertificateVerificationUrl(contextType: string, contextId: string, sellerNip: string, certSerial: string, invoiceHashBase64: string, privateKeyPem: string): string;
2569
+ buildCertificateVerificationUrl(contextType: string, contextId: string, sellerNip: string, certSerial: string, invoiceHashBase64: string, privateKeyPem: string, privateKeyPassword?: string): string;
2378
2570
  private base64ToBase64Url;
2379
2571
  }
2380
2572
 
@@ -2502,6 +2694,158 @@ interface InvoiceFields {
2502
2694
  */
2503
2695
  declare function extractInvoiceFields(xml: string): InvoiceFields;
2504
2696
 
2697
+ type XmlValue = string | number | boolean | null | XmlObject | XmlValue[];
2698
+ type XmlObject = {
2699
+ [key: string]: XmlValue;
2700
+ };
2701
+ type XmlDocument = Array<Record<string, unknown>>;
2702
+ type FakturaSchema = 'FA2' | 'FA3';
2703
+ type PefSchema = 'PEF' | 'PEF_KOR';
2704
+ type InvoiceSchema = FakturaSchema | PefSchema;
2705
+ interface FakturaInput {
2706
+ Naglowek: XmlObject;
2707
+ Podmiot1?: XmlObject;
2708
+ Podmiot2?: XmlObject;
2709
+ Podmiot3?: XmlObject;
2710
+ Fa: XmlObject;
2711
+ Stopka?: XmlObject;
2712
+ [key: string]: XmlValue | undefined;
2713
+ }
2714
+ interface PefUblInvoiceInput {
2715
+ schema?: 'PEF';
2716
+ Invoice: XmlObject;
2717
+ }
2718
+ interface PefUblCreditNoteInput {
2719
+ schema?: 'PEF_KOR';
2720
+ CreditNote: XmlObject;
2721
+ }
2722
+ type PefUblDocumentInput = PefUblInvoiceInput | PefUblCreditNoteInput;
2723
+ interface SerializeInvoiceOptions {
2724
+ schema?: InvoiceSchema;
2725
+ fakturaNamespace?: string;
2726
+ etdNamespace?: string;
2727
+ pretty?: boolean;
2728
+ }
2729
+ type InvoiceSerializerInput = string | Buffer | XmlDocument | FakturaInput | PefUblDocumentInput;
2730
+
2731
+ declare function parseXml(xml: string): XmlDocument;
2732
+ declare function buildXml(document: XmlDocument): string;
2733
+ declare function buildXmlFromObject(document: XmlObject, options?: {
2734
+ pretty?: boolean;
2735
+ }): string;
2736
+ declare function stripBom(input: string): string;
2737
+
2738
+ /**
2739
+ * ORDER_MAP declares element ordering for every known parent element in the
2740
+ * KSeF FA2/FA3 XSDs (docs/schemas/FA/schemat_FA(2|3)_v1-0E.xsd).
2741
+ *
2742
+ * Inside `Fa` the VAT amount fields P_13_N / P_14_N / P_14_NW must interleave
2743
+ * per tax group (P_13_1, P_14_1, P_14_1W, P_13_2, P_14_2, P_14_2W, ...) rather
2744
+ * than listing every P_13_* before every P_14_*. smekcio TS 0.5.0 (commit
2745
+ * d1ec8fe, 2026-04-14) corrected this bug; the dedicated regression test lives
2746
+ * in tests/unit/xml/faktura-builder.test.ts ("multi-rate interleave").
2747
+ *
2748
+ * `Fa` is intentionally a union of FA2 and FA3 child keys (e.g. P_14_NW and
2749
+ * P_13_6_N are FA3-only). Ordering is permissive by design: keys absent from
2750
+ * the input are silently skipped, and shape enforcement is the job of
2751
+ * `isFakturaInput` + XSD validation in the test harness, not this table.
2752
+ */
2753
+ declare const ORDER_MAP: Record<string, string[]>;
2754
+ /**
2755
+ * Natural-order sort for KSeF `P_*` keys.
2756
+ *
2757
+ * Splits on `_` after stripping the `P_` prefix, coerces numeric parts to
2758
+ * numbers, and compares numerically first, then lexicographically for any
2759
+ * trailing alphabetic parts (e.g. `P_20_A`, `P_20_B`).
2760
+ *
2761
+ * Examples:
2762
+ * P_13_1 < P_13_2 < P_13_10 < P_20_A < P_20_B
2763
+ */
2764
+ declare function comparePKey(a: string, b: string): number;
2765
+ /**
2766
+ * Recursively orders an XML-shaped object according to ORDER_MAP + P_* natural
2767
+ * sort + input-insertion for unknown keys.
2768
+ *
2769
+ * Algorithm:
2770
+ * 1. Apply ORDER_MAP[contextKey] keys in declared order.
2771
+ * 2. Append remaining P_* keys via comparePKey.
2772
+ * 3. Append all other unknown keys in input insertion order.
2773
+ * 4. `undefined` values are omitted.
2774
+ */
2775
+ declare function orderXmlObject(value: XmlObject, contextKey?: string): XmlObject;
2776
+
2777
+ declare const FAKTURA_NAMESPACE: Record<FakturaSchema, string>;
2778
+ declare const ETD_NAMESPACE: Record<FakturaSchema, string>;
2779
+ interface BuildFakturaOptions {
2780
+ schema?: FakturaSchema;
2781
+ fakturaNamespace?: string;
2782
+ etdNamespace?: string;
2783
+ pretty?: boolean;
2784
+ }
2785
+ declare function toKodFormularza(formCode: FormCode): XmlObject;
2786
+ declare function isFormCodeShape(value: unknown): value is FormCode;
2787
+ /**
2788
+ * Builds a Faktura XML string from a typed FakturaInput.
2789
+ *
2790
+ * Applies ORDER_MAP-driven element ordering (with multi-rate P_13/P_14
2791
+ * interleaving) and injects FA2/FA3 namespace attributes on the root
2792
+ * `<Faktura>` element.
2793
+ *
2794
+ * Default schema is FA3. The `fakturaNamespace` / `etdNamespace` options
2795
+ * override the per-schema defaults for advanced use cases.
2796
+ */
2797
+ declare function buildFakturaXml(faktura: FakturaInput, options?: BuildFakturaOptions): string;
2798
+ declare function isFakturaInput(input: unknown): input is FakturaInput;
2799
+
2800
+ declare const PEF_NAMESPACE: Record<PefSchema, string>;
2801
+ interface BuildPefOptions {
2802
+ schema?: PefSchema;
2803
+ pretty?: boolean;
2804
+ }
2805
+ declare function isPefUblDocumentInput(input: unknown): input is PefUblDocumentInput;
2806
+ /**
2807
+ * Builds a PEF (UBL) Invoice or CreditNote XML string.
2808
+ *
2809
+ * Detects the root by the presence of either `Invoice` or `CreditNote` and
2810
+ * injects the UBL namespace set on the root element. Throws
2811
+ * `KSeFValidationError` when the caller's `schema` option contradicts the
2812
+ * detected root, or when neither / both of the roots are provided.
2813
+ */
2814
+ declare function buildPefXml(input: PefUblDocumentInput, options?: BuildPefOptions): string;
2815
+
2816
+ /**
2817
+ * Serializes a KSeF invoice from any supported input shape into a UTF-8
2818
+ * encoded `Buffer`.
2819
+ *
2820
+ * Input dispatch:
2821
+ * - `Buffer` — returned byte-for-byte as the same reference;
2822
+ * callers must not mutate the buffer after the call
2823
+ * - `string` — UTF-8 BOM stripped, wrapped in a `Buffer`
2824
+ * - pre-parsed `XmlDocument` array — rebuilt via the engine
2825
+ * - `FakturaInput` — FA2/FA3 builder (default schema: FA3)
2826
+ * - `PefUblDocumentInput` — PEF / PEF_KOR builder
2827
+ *
2828
+ * Structured inputs that match none of the known shapes throw
2829
+ * `KSeFValidationError` naming the first missing top-level key. Callers
2830
+ * with an already-shaped `XmlObject` that deliberately sidesteps schema
2831
+ * dispatch can use `buildRawXmlString` directly.
2832
+ */
2833
+ declare function serializeInvoiceXml(input: InvoiceSerializerInput, options?: SerializeInvoiceOptions): Buffer;
2834
+ /**
2835
+ * Low-level escape hatch for callers that already have a plain XML-shaped
2836
+ * object (e.g. produced by `parseXml`) and want to build it back out without
2837
+ * running through the FakturaInput / PefUblDocumentInput dispatch.
2838
+ *
2839
+ * Returns a `string` (not a `Buffer`) — consumers that need bytes should
2840
+ * wrap the result with `Buffer.from(xml, 'utf8')` before handing it off to
2841
+ * `session.sendInvoice(...)`. The naming reflects the return type: the sibling
2842
+ * `serializeInvoiceXml` entry point stays the preferred API for byte-ready
2843
+ * output.
2844
+ */
2845
+ declare function buildRawXmlString(document: XmlObject, options?: {
2846
+ pretty?: boolean;
2847
+ }): string;
2848
+
2505
2849
  interface PollOptions {
2506
2850
  intervalMs?: number;
2507
2851
  maxAttempts?: number;
@@ -2952,4 +3296,4 @@ declare class FileOfflineInvoiceStorage implements OfflineInvoiceStorage {
2952
3296
  delete(id: string): Promise<void>;
2953
3297
  }
2954
3298
 
2955
- export { ActiveSessionsService, type AllowedIps, type AmountType, type ApiErrorResponse, type ApiRateLimitValuesOverride, type ApiRateLimitsOverride, type AttachmentPermissionGrantRequest, type AttachmentPermissionRevokeRequest, type AuthChallengeResponse, type AuthKsefTokenRequest, AuthKsefTokenRequestBuilder, type AuthManager, type AuthResult, AuthService, type AuthSessionInfo, type AuthTokenRequest, AuthTokenRequestBuilder, type AuthTokenRequestXmlOptions, type AuthenticationInitResponse, type AuthenticationKsefToken, type AuthenticationListResponse, type AuthenticationMethod, type AuthenticationMethodInfo, type AuthenticationMethodInfoCategory, type AuthenticationOperationStatusResponse, type AuthenticationTokenRefreshResponse, type AuthenticationTokensResponse, type AuthorizationGrant, AuthorizationPermissionGrantBuilder, type AuthorizationPolicy, BATCH_MAX_PARTS, BATCH_MAX_PART_SIZE, BATCH_MAX_TOTAL_SIZE, Base64String, type BatchFileBuildOptions, type BatchFileBuildResult, BatchFileBuilder, type BatchFileInfo, type BatchFilePartInfo, type BatchPartSendingInfo, type BatchPartStreamSendingInfo, type BatchSessionContextLimitsOverride, type BatchSessionEffectiveContextLimits, type BatchSessionFormCode, BatchSessionService, type BatchSessionState, type BatchStreamBuildResult, type BatchUploadOptions, type BatchUploadResult, type BatchValidationResult, type BlockContextAuthenticationRequest, type BuyerIdentifierType, CERTIFICATE_NAME_MAX_LENGTH, CERTIFICATE_NAME_MIN_LENGTH, CertificateApiService, type CertificateAuthOptions, type CertificateEffectiveSubjectLimits, type CertificateEnrollmentDataResponse, type CertificateEnrollmentStatusResponse, CertificateFetcher, CertificateFingerprint, type CertificateLimit, type CertificateLimitsResponse, type CertificateListItem, CertificateName, type CertificateRevocationReason, CertificateService, type CertificateStatus, type CertificateSubjectIdentifier, type CertificateSubjectIdentifierType, type CertificateSubjectLimitsOverride, type CertificateType, type ContextIdentifier, type ContextIdentifierType, type ContinuationPoints, type CryptoEncryptionMethod, CryptographyService, type CsrResult, DEFAULT_FORM_CODE, DefaultAuthManager, ENFORCE_XADES_COMPLIANCE, type EffectiveApiRateLimitValues, type EffectiveApiRateLimits, type EffectiveContextLimits, type EffectiveSubjectLimits, type EncryptionData, type EncryptionInfo, type EnrollCertificateRequest, type EnrollCertificateResponse, type EnrollmentEffectiveSubjectLimits, type EnrollmentSubjectLimitsOverride, type EntityAuthorizationGrant, type EntityAuthorizationPermissionType, type EntityAuthorizationPermissionsSubjectIdentifierType, type EntityAuthorizationSubjectIdentifier, type EntityAuthorizationsAuthorIdentifier, type EntityAuthorizationsAuthorIdentifierType, type EntityAuthorizationsAuthorizedEntityIdentifier, type EntityAuthorizationsAuthorizedEntityIdentifierType, type EntityAuthorizationsAuthorizingEntityIdentifier, type EntityAuthorizationsAuthorizingEntityIdentifierType, type EntityAuthorizationsQueryType, type EntityByFingerprintDetails, type EntityDetails, type EntityPermission, EntityPermissionGrantBuilder, type EntityPermissionItem, type EntityPermissionItemType, type EntityPermissionsContextIdentifier, type EntityPermissionsContextIdentifierType, type EntityRole, type EntityRoleType, type EntityRolesParentEntityIdentifier, type EntityRolesParentEntityIdentifierType, type EntitySubjectByFingerprintDetailsType, type EntitySubjectByIdentifierDetailsType, type EntitySubjectDetailsType, type EntitySubjectIdentifier, Environment, type EnvironmentConfig, type EnvironmentName, type EuEntityAdministrationContextIdentifier, type EuEntityAdministrationPermissionsContextIdentifierType, type EuEntityAdministrationPermissionsSubjectIdentifierType, type EuEntityAdministrationSubjectIdentifier, type EuEntityDetails, type EuEntityPermission, type EuEntityPermissionSubjectDetails, type EuEntityPermissionSubjectDetailsType, type EuEntityPermissionType, type EuEntityPermissionsAuthorIdentifier, type EuEntityPermissionsAuthorIdentifierType, type EuEntityPermissionsQueryPermissionType, type EuEntityPermissionsSubjectIdentifier, type EuEntityPermissionsSubjectIdentifierType, type ExceptionDetails, type ExportAndDownloadOptions, type ExportDownloadResult, type ExportExtractedResult, type ExportOptions, type ExportResult, type ExternalSignatureAuthOptions, FORM_CODES, FORM_CODE_KEYS, FileHwmStore, type FileMetadata, FileOfflineInvoiceStorage, type ForbiddenProblemDetails, type ForbiddenReasonCode, type FormCode, type FormType, type GoneProblemDetails, type GrantPermissionsAuthorizationRequest, type GrantPermissionsEntityRequest, type GrantPermissionsEuEntityAdminRequest, type GrantPermissionsEuEntityRepresentativeRequest, type GrantPermissionsEuEntityRequest, type GrantPermissionsIndirectRequest, type GrantPermissionsPersonRequest, type GrantPermissionsSubunitRequest, type HttpMethod, type HwmStore, INVOICE_TYPES_BY_SYSTEM_CODE, type IdDocument, InMemoryHwmStore, InMemoryOfflineInvoiceStorage, type IncrementalExportOptions, type IncrementalExportResult, type IndirectPermissionType, type IndirectPermissionsSubjectIdentifier, type IndirectPermissionsSubjectIdentifierType, type IndirectPermissionsTargetIdentifier, type IndirectPermissionsTargetIdentifierType, InternalId, InvoiceDownloadService, type InvoiceExportPackage, type InvoiceExportPackagePart, type InvoiceExportRequest, type InvoiceExportStatusResponse, type InvoiceFields, type InvoiceMetadata, type InvoiceMetadataAuthorizedSubject, type InvoiceMetadataBuyer, type InvoiceMetadataBuyerIdentifier, type InvoiceMetadataSeller, type InvoiceMetadataThirdSubject, type InvoiceMetadataThirdSubjectIdentifier, type InvoicePermissionType, type InvoiceQueryAmount, type InvoiceQueryBuyerIdentifier, type InvoiceQueryDateRange, type InvoiceQueryDateType, InvoiceQueryFilterBuilder, type InvoiceQueryFilters, type InvoiceResult, type InvoiceStatusInfo, type InvoiceSubjectType, type InvoiceType, type InvoiceValidationError, type InvoiceValidationErrorCode, type InvoiceValidationResult, type InvoicingMode, Ip4Address, Ip4Mask, Ip4Range, KSEF_FEATURE_HEADER, KSeFApiError, KSeFAuthStatusError, KSeFBatchTimeoutError, KSeFClient, type KSeFClientOptions, KSeFError, KSeFErrorCode, KSeFForbiddenError, KSeFGoneError, KSeFRateLimitError, KSeFSessionExpiredError, type KSeFTokenContext, KSeFUnauthorizedError, KSeFValidationError, type KsefMessagesResponse, KsefNumber, KsefNumberV35, KsefNumberV36, type KsefStatusResponse, type KsefSystemStatus, type KsefTokenPermissionType, type KsefTokenRequest, type KsefTokenResponse, type KsefTokenStatus, type LighthouseMessage, LighthouseService, LimitsService, type LoginResult, type MaintenanceWindow, Nip, NipVatUe, type OfflineBatchResult, type OfflineCertificate, type OfflineInvoiceFilter, type OfflineInvoiceInputData, type OfflineInvoiceMetadata, type OfflineInvoiceOptions, type OfflineInvoiceStatus, type OfflineInvoiceStorage, type OfflineInvoiceUpdates, OfflineInvoiceWorkflow, type OfflineMode, type OfflineReason, type OfflineSubmissionResult, type OnlineSessionContextLimitsOverride, type OnlineSessionEffectiveContextLimits, type OnlineSessionFormCode, type OnlineSessionHandle, OnlineSessionService, type OnlineSessionState, type OpenBatchSessionRequest, type OpenBatchSessionResponse, type OpenOnlineSessionOptions, type OpenOnlineSessionRequest, type OpenOnlineSessionResponse, type OperationResponse, type OperationStatusInfo, PERMISSION_DESCRIPTION_MAX_LENGTH, PERMISSION_DESCRIPTION_MIN_LENGTH, type PagedAuthorizationsResponse, type PagedPermissionsResponse, type PagedRolesResponse, type ParsedBatchUploadResult, type ParsedUpoInfo, type PartUploadRequest, PeppolId, type PeppolProvider, PeppolService, type PermissionState, type PermissionSubjectIdentifierType, type PermissionWithDelegate, type PermissionsAttachmentAllowedResponse, type PermissionsEuEntityDetails, type PermissionsOperationStatusResponse, PermissionsService, type PermissionsSubjectEntityByFingerprintDetails, type PermissionsSubjectEntityByIdentifierDetails, type PermissionsSubjectEntityDetails, type PermissionsSubjectPersonByFingerprintDetails, type PermissionsSubjectPersonDetails, type PersonByFingerprintWithIdentifierDetails, type PersonByFingerprintWithoutIdentifierDetails, type PersonByIdentifierDetails, type PersonCreateRequest, type PersonIdentifier, type PersonIdentifierType, type PersonPermission, PersonPermissionGrantBuilder, type PersonPermissionSubjectDetails, type PersonPermissionType, type PersonPermissionsAuthorIdentifier, type PersonPermissionsAuthorIdentifierType, type PersonPermissionsAuthorizedIdentifier, type PersonPermissionsAuthorizedIdentifierType, type PersonPermissionsContextIdentifier, type PersonPermissionsContextIdentifierType, type PersonPermissionsQueryType, type PersonPermissionsTargetIdentifier, type PersonPermissionsTargetIdentifierType, type PersonRemoveRequest, type PersonSubjectByFingerprintDetailsType, type PersonSubjectDetailsType, type PersonSubjectIdentifier, type PersonalPermission, type PersonalPermissionScopeType, type PersonalPermissionsAuthorizedIdentifier, type PersonalPermissionsAuthorizedIdentifierType, type PersonalPermissionsContextIdentifier, type PersonalPermissionsContextIdentifierType, type PersonalPermissionsTargetIdentifier, type PersonalPermissionsTargetIdentifierType, Pesel, type Pkcs12AuthOptions, Pkcs12Loader, type Pkcs12Result, type PollOptions, type PresignedUrlPolicy, type PublicKeyCertificate, type PublicKeyCertificateUsage, type QRCodeContextIdentifierType, type QrCodeOptions, type QrCodeResult, QrCodeService, type QueryAuthorizationsGrantsRequest, type QueryCertificatesRequest, type QueryCertificatesResponse, type QueryEntitiesGrantsRequest, type QueryEntitiesRolesRequest, type QueryEuEntitiesGrantsRequest, type QueryInvoicesMetadataResponse, type QueryKsefTokensOptions, type QueryKsefTokensResponse, type QueryPeppolProvidersResponse, type QueryPersonalGrantsRequest, type QueryPersonsGrantsRequest, type QuerySubordinateEntitiesRolesRequest, type QuerySubunitsGrantsRequest, type QueryTokensResponseItem, REQUIRED_CHALLENGE_LENGTH, type RateLimitConfig, RateLimitPolicy, ReferenceNumber, type ResolvedOptions, RestClient, RestRequest, type RestResponse, type RetrieveCertificatesListItem, type RetrieveCertificatesRequest, type RetrieveCertificatesResponse, type RetryPolicy, type RevokeCertificateRequest, RouteBuilder, Routes, SUBUNIT_NAME_MAX_LENGTH, SUBUNIT_NAME_MIN_LENGTH, SchemaRegistry, type SelfSignedCertificateResult, type SendAndCloseOptions, type SendInvoiceRequest, type SendInvoiceResponse, type SessionInvoiceStatusResponse, type SessionInvoicesResponse, type SessionStatus, type SessionStatusResponse, SessionStatusService, type SessionType, type SessionsFilter, type SessionsQueryResponse, type SessionsQueryResponseItem, type SetRateLimitsRequest, type SetSessionLimitsRequest, type SetSubjectLimitsRequest, Sha256Base64, SignatureService, type SortOrder, type StatusInfo, type SubjectCreateRequest, type SubjectRemoveRequest, type SubjectType, type SubmitOfflineInvoicesOptions, type SubordinateEntityRole, type SubordinateEntityRoleType, type SubordinateRoleSubordinateEntityIdentifier, type SubordinateRoleSubordinateEntityIdentifierType, type Subunit, type SubunitPermission, type SubunitPermissionScope, type SubunitPermissionsAuthorIdentifier, type SubunitPermissionsAuthorIdentifierType, type SubunitPermissionsAuthorizedIdentifier, type SubunitPermissionsContextIdentifier, type SubunitPermissionsContextIdentifierType, type SubunitPermissionsSubjectIdentifier, type SubunitPermissionsSubjectIdentifierType, type SubunitPermissionsSubunitIdentifier, type SubunitPermissionsSubunitIdentifierType, SystemCode, type TechnicalCorrectionOptions, type TestDataAuthenticationContextIdentifier, type TestDataAuthenticationContextIdentifierType, type TestDataAuthorizedIdentifier, type TestDataAuthorizedIdentifierType, type TestDataContextIdentifier, type TestDataContextIdentifierType, type TestDataPermission, type TestDataPermissionType, type TestDataPermissionsGrantRequest, type TestDataPermissionsRevokeRequest, TestDataService, type ThirdSubjectIdentifierType, type TokenAuthOptions, type TokenAuthorIdentifier, type TokenAuthorIdentifierType, type TokenContextIdentifier, type TokenContextIdentifierType, type TokenInfo, TokenService, type TokenStatusResponse, type TransportFn, type UnauthorizedProblemDetails, type UnblockContextAuthenticationRequest, type UnzipOptions, type UpoAuthProof, type UpoContextId, type UpoDokument, type UpoInfo, type UpoOpisPotwierdzenia, type UpoPage, type UpoPotwierdzenie, type UpoResponse, type UpoResult, type UpoUwierzytelnienie, UpoVersion, UpoVersion as UpoVersionType, type ValidateOptions, type ValidationDetail, VatUe, VerificationLinkService, type X500NameFields, type XadesSubjectIdentifierType, type XmlConversionResult, type ZipEntryInput, addBusinessDays, authenticateWithCertificate, authenticateWithExternalSignature, authenticateWithPkcs12, authenticateWithToken, batchValidationDetails, buildUnsignedAuthTokenRequestXml, calculateBackoff, calculateOfflineDeadline, createZip, decodeJwtPayload, deduplicateByKsefNumber, defaultPresignedUrlPolicy, defaultRateLimitPolicy, defaultRetryPolicy, defaultTransport, exportAndDownload, exportInvoices, extendDeadlineForMaintenance, extractInvoiceFields, getDefaultReason, getEffectiveStartDate, getFormCode, getPolishHolidays, getTimeUntilDeadline, incrementalExportAndDownload, isExpired, isPolishHoliday, isRetryableError, isRetryableStatus, isValidBase64, isValidCertificateFingerprint, isValidCertificateName, isValidInternalId, isValidIp4Address, isValidKsefNumber, isValidKsefNumberV35, isValidKsefNumberV36, isValidNip, isValidNipVatUe, isValidPeppolId, isValidPesel, isValidReferenceNumber, isValidSha256Base64, isValidVatUe, nextBusinessDay, openOnlineSession, openSendAndClose, parseFormCode, parseKSeFTokenContext, parseRetryAfter, parseUpoXml, pollUntil, resolveOptions, resumeOnlineSession, runWithConcurrency, sha256Base64, sleep, unzip, updateContinuationPoint, uploadBatch, uploadBatchParsed, uploadBatchStream, uploadBatchStreamParsed, validate, validateBatch, validateBusinessRules, validateFormCodeForSession, validatePresignedUrl, validateSchema, validateWellFormedness, verifyHash, xmlToObject };
3299
+ export { ActiveSessionsService, type AllowedIps, type AmountType, type ApiErrorResponse, type ApiRateLimitValuesOverride, type ApiRateLimitsOverride, type AttachmentPermissionGrantRequest, type AttachmentPermissionRevokeRequest, type AuthChallengeResponse, type AuthKsefTokenRequest, AuthKsefTokenRequestBuilder, type AuthManager, type AuthResult, AuthService, type AuthSessionInfo, type AuthTokenRequest, AuthTokenRequestBuilder, type AuthTokenRequestXmlOptions, type AuthenticationInitResponse, type AuthenticationKsefToken, type AuthenticationListResponse, type AuthenticationMethod, type AuthenticationMethodInfo, type AuthenticationMethodInfoCategory, type AuthenticationOperationStatusResponse, type AuthenticationTokenRefreshResponse, type AuthenticationTokensResponse, type AuthorizationGrant, AuthorizationPermissionGrantBuilder, type AuthorizationPolicy, BATCH_MAX_PARTS, BATCH_MAX_PART_SIZE, BATCH_MAX_TOTAL_SIZE, type BadRequestErrorDetail, type BadRequestProblemDetails, Base64String, type BatchFileBuildOptions, type BatchFileBuildResult, BatchFileBuilder, type BatchFileInfo, type BatchFilePartInfo, type BatchPartSendingInfo, type BatchPartStreamSendingInfo, type BatchSessionContextLimitsOverride, type BatchSessionEffectiveContextLimits, type BatchSessionFormCode, BatchSessionService, type BatchSessionState, type BatchStreamBuildResult, type BatchUploadOptions, type BatchUploadResult, type BatchValidationResult, type BlockContextAuthenticationRequest, type BuildFakturaOptions, type BuildPefOptions, type BuyerIdentifierType, CERTIFICATE_NAME_MAX_LENGTH, CERTIFICATE_NAME_MIN_LENGTH, CertificateApiService, type CertificateAuthOptions, type CertificateEffectiveSubjectLimits, type CertificateEnrollmentDataResponse, type CertificateEnrollmentStatusResponse, CertificateFetcher, CertificateFingerprint, type CertificateLimit, type CertificateLimitsResponse, type CertificateListItem, CertificateName, type CertificateRevocationReason, CertificateService, type CertificateStatus, type CertificateSubjectIdentifier, type CertificateSubjectIdentifierType, type CertificateSubjectLimitsOverride, type CertificateType, type CircuitBreakerConfig, CircuitBreakerPolicy, type ContextIdentifier, type ContextIdentifierType, type ContinuationPoints, type CryptoEncryptionMethod, CryptographyService, type CsrResult, DEFAULT_FORM_CODE, DISCOURAGED_UNICODE_RANGES, DefaultAuthManager, type ECDigestCurve, ENFORCE_XADES_COMPLIANCE, ETD_NAMESPACE, type EffectiveApiRateLimitValues, type EffectiveApiRateLimits, type EffectiveContextLimits, type EffectiveSubjectLimits, type EncryptionData, type EncryptionInfo, type EnrollCertificateRequest, type EnrollCertificateResponse, type EnrollmentEffectiveSubjectLimits, type EnrollmentSubjectLimitsOverride, type EntityAuthorizationGrant, type EntityAuthorizationPermissionType, type EntityAuthorizationPermissionsSubjectIdentifierType, type EntityAuthorizationSubjectIdentifier, type EntityAuthorizationsAuthorIdentifier, type EntityAuthorizationsAuthorIdentifierType, type EntityAuthorizationsAuthorizedEntityIdentifier, type EntityAuthorizationsAuthorizedEntityIdentifierType, type EntityAuthorizationsAuthorizingEntityIdentifier, type EntityAuthorizationsAuthorizingEntityIdentifierType, type EntityAuthorizationsQueryType, type EntityByFingerprintDetails, type EntityDetails, type EntityPermission, EntityPermissionGrantBuilder, type EntityPermissionItem, type EntityPermissionItemType, type EntityPermissionsContextIdentifier, type EntityPermissionsContextIdentifierType, type EntityRole, type EntityRoleType, type EntityRolesParentEntityIdentifier, type EntityRolesParentEntityIdentifierType, type EntitySubjectByFingerprintDetailsType, type EntitySubjectByIdentifierDetailsType, type EntitySubjectDetailsType, type EntitySubjectIdentifier, Environment, type EnvironmentConfig, type EnvironmentName, type EuEntityAdministrationContextIdentifier, type EuEntityAdministrationPermissionsContextIdentifierType, type EuEntityAdministrationPermissionsSubjectIdentifierType, type EuEntityAdministrationSubjectIdentifier, type EuEntityDetails, type EuEntityPermission, type EuEntityPermissionSubjectDetails, type EuEntityPermissionSubjectDetailsType, type EuEntityPermissionType, type EuEntityPermissionsAuthorIdentifier, type EuEntityPermissionsAuthorIdentifierType, type EuEntityPermissionsQueryPermissionType, type EuEntityPermissionsSubjectIdentifier, type EuEntityPermissionsSubjectIdentifierType, type ExceptionDetails, type ExportAndDownloadOptions, type ExportDownloadResult, type ExportExtractedResult, type ExportOptions, type ExportResult, type ExternalSignatureAuthOptions, FAKTURA_NAMESPACE, FA_XSD_PATHS, FORM_CODES, FORM_CODE_KEYS, type FakturaInput, type FakturaSchema, FileHwmStore, type FileMetadata, FileOfflineInvoiceStorage, type ForbiddenProblemDetails, type ForbiddenReasonCode, type ForbiddenSecurityInfo, type FormCode, type FormType, type GoneProblemDetails, type GrantPermissionsAuthorizationRequest, type GrantPermissionsEntityRequest, type GrantPermissionsEuEntityAdminRequest, type GrantPermissionsEuEntityRepresentativeRequest, type GrantPermissionsEuEntityRequest, type GrantPermissionsIndirectRequest, type GrantPermissionsPersonRequest, type GrantPermissionsSubunitRequest, type HttpMethod, type HwmStore, INVOICE_TYPES_BY_SYSTEM_CODE, type IdDocument, InMemoryHwmStore, InMemoryOfflineInvoiceStorage, type IncrementalExportOptions, type IncrementalExportResult, type IndirectPermissionType, type IndirectPermissionsSubjectIdentifier, type IndirectPermissionsSubjectIdentifierType, type IndirectPermissionsTargetIdentifier, type IndirectPermissionsTargetIdentifierType, InternalId, InvoiceDownloadService, type InvoiceExportPackage, type InvoiceExportPackagePart, type InvoiceExportRequest, type InvoiceExportStatusResponse, type InvoiceFields, type InvoiceMetadata, type InvoiceMetadataAuthorizedSubject, type InvoiceMetadataBuyer, type InvoiceMetadataBuyerIdentifier, type InvoiceMetadataSeller, type InvoiceMetadataThirdSubject, type InvoiceMetadataThirdSubjectIdentifier, type InvoicePermissionType, type InvoiceQueryAmount, type InvoiceQueryBuyerIdentifier, type InvoiceQueryDateRange, type InvoiceQueryDateType, InvoiceQueryFilterBuilder, type InvoiceQueryFilters, type InvoiceResult, type InvoiceSchema, type InvoiceSchemaId, type InvoiceSerializerInput, type InvoiceStatusInfo, type InvoiceSubjectType, type InvoiceType, type InvoiceValidationError, type InvoiceValidationErrorCode, type InvoiceValidationResult, type InvoicingMode, Ip4Address, Ip4Mask, Ip4Range, KSEF_FEATURE_HEADER, KSeFApiError, type KSeFApiProblem, KSeFAuthStatusError, KSeFBadRequestError, KSeFBatchTimeoutError, KSeFCircuitOpenError, KSeFClient, type KSeFClientOptions, KSeFError, KSeFErrorCode, KSeFForbiddenError, KSeFGoneError, KSeFRateLimitError, KSeFSessionExpiredError, type KSeFTokenContext, KSeFUnauthorizedError, KSeFValidationError, KSeFXsdValidationError, type KsefMessagesResponse, KsefNumber, KsefNumberV35, KsefNumberV36, type KsefStatusResponse, type KsefSystemStatus, type KsefTokenPermissionType, type KsefTokenRequest, type KsefTokenResponse, type KsefTokenStatus, type LighthouseMessage, LighthouseService, LimitsService, type LoginResult, type MaintenanceWindow, Nip, NipVatUe, ORDER_MAP, type OfflineBatchResult, type OfflineCertificate, type OfflineInvoiceFilter, type OfflineInvoiceInputData, type OfflineInvoiceMetadata, type OfflineInvoiceOptions, type OfflineInvoiceStatus, type OfflineInvoiceStorage, type OfflineInvoiceUpdates, OfflineInvoiceWorkflow, type OfflineMode, type OfflineReason, type OfflineSubmissionResult, type OnlineSessionContextLimitsOverride, type OnlineSessionEffectiveContextLimits, type OnlineSessionFormCode, type OnlineSessionHandle, OnlineSessionService, type OnlineSessionState, type OpenBatchSessionRequest, type OpenBatchSessionResponse, type OpenOnlineSessionOptions, type OpenOnlineSessionRequest, type OpenOnlineSessionResponse, type OperationResponse, type OperationStatusInfo, PEF_NAMESPACE, PEF_XSD_PATHS, PERMISSION_DESCRIPTION_MAX_LENGTH, PERMISSION_DESCRIPTION_MIN_LENGTH, type PagedAuthorizationsResponse, type PagedPermissionsResponse, type PagedRolesResponse, type ParsedBatchUploadResult, type ParsedUpoInfo, type PartUploadRequest, type PefSchema, type PefUblCreditNoteInput, type PefUblDocumentInput, type PefUblInvoiceInput, PeppolId, type PeppolProvider, PeppolService, type PermissionState, type PermissionSubjectIdentifierType, type PermissionWithDelegate, type PermissionsAttachmentAllowedResponse, type PermissionsEuEntityDetails, type PermissionsOperationStatusResponse, PermissionsService, type PermissionsSubjectEntityByFingerprintDetails, type PermissionsSubjectEntityByIdentifierDetails, type PermissionsSubjectEntityDetails, type PermissionsSubjectPersonByFingerprintDetails, type PermissionsSubjectPersonDetails, type PersonByFingerprintWithIdentifierDetails, type PersonByFingerprintWithoutIdentifierDetails, type PersonByIdentifierDetails, type PersonCreateRequest, type PersonIdentifier, type PersonIdentifierType, type PersonPermission, PersonPermissionGrantBuilder, type PersonPermissionSubjectDetails, type PersonPermissionType, type PersonPermissionsAuthorIdentifier, type PersonPermissionsAuthorIdentifierType, type PersonPermissionsAuthorizedIdentifier, type PersonPermissionsAuthorizedIdentifierType, type PersonPermissionsContextIdentifier, type PersonPermissionsContextIdentifierType, type PersonPermissionsQueryType, type PersonPermissionsTargetIdentifier, type PersonPermissionsTargetIdentifierType, type PersonRemoveRequest, type PersonSubjectByFingerprintDetailsType, type PersonSubjectDetailsType, type PersonSubjectIdentifier, type PersonalPermission, type PersonalPermissionScopeType, type PersonalPermissionsAuthorizedIdentifier, type PersonalPermissionsAuthorizedIdentifierType, type PersonalPermissionsContextIdentifier, type PersonalPermissionsContextIdentifierType, type PersonalPermissionsTargetIdentifier, type PersonalPermissionsTargetIdentifierType, Pesel, type Pkcs12AuthOptions, Pkcs12Loader, type Pkcs12Result, type PollOptions, type PresignedUrlPolicy, type ProblemFields, type PublicKeyCertificate, type PublicKeyCertificateUsage, type QRCodeContextIdentifierType, type QrCodeOptions, type QrCodeResult, QrCodeService, type QueryAuthorizationsGrantsRequest, type QueryCertificatesRequest, type QueryCertificatesResponse, type QueryEntitiesGrantsRequest, type QueryEntitiesRolesRequest, type QueryEuEntitiesGrantsRequest, type QueryInvoicesMetadataResponse, type QueryKsefTokensOptions, type QueryKsefTokensResponse, type QueryPeppolProvidersResponse, type QueryPersonalGrantsRequest, type QueryPersonsGrantsRequest, type QuerySubordinateEntitiesRolesRequest, type QuerySubunitsGrantsRequest, type QueryTokensResponseItem, REQUIRED_CHALLENGE_LENGTH, type RateLimitConfig, RateLimitPolicy, ReferenceNumber, type ResolvedOptions, RestClient, RestRequest, type RestResponse, type RetrieveCertificatesListItem, type RetrieveCertificatesRequest, type RetrieveCertificatesResponse, type RetryPolicy, type RevokeCertificateRequest, RouteBuilder, Routes, SUBUNIT_NAME_MAX_LENGTH, SUBUNIT_NAME_MIN_LENGTH, SchemaRegistry, type SelfSignedCertificateResult, type SendAndCloseOptions, type SendInvoiceRequest, type SendInvoiceResponse, type SerializeInvoiceOptions, type SessionInvoiceStatusResponse, type SessionInvoicesResponse, type SessionStatus, type SessionStatusResponse, SessionStatusService, type SessionType, type SessionsFilter, type SessionsQueryResponse, type SessionsQueryResponseItem, type SetRateLimitsRequest, type SetSessionLimitsRequest, type SetSubjectLimitsRequest, Sha256Base64, SignatureService, type SortOrder, type StatusInfo, type SubjectCreateRequest, type SubjectRemoveRequest, type SubjectType, type SubmitOfflineInvoicesOptions, type SubordinateEntityRole, type SubordinateEntityRoleType, type SubordinateRoleSubordinateEntityIdentifier, type SubordinateRoleSubordinateEntityIdentifierType, type Subunit, type SubunitPermission, type SubunitPermissionScope, type SubunitPermissionsAuthorIdentifier, type SubunitPermissionsAuthorIdentifierType, type SubunitPermissionsAuthorizedIdentifier, type SubunitPermissionsContextIdentifier, type SubunitPermissionsContextIdentifierType, type SubunitPermissionsSubjectIdentifier, type SubunitPermissionsSubjectIdentifierType, type SubunitPermissionsSubunitIdentifier, type SubunitPermissionsSubunitIdentifierType, SystemCode, type TechnicalCorrectionOptions, type TestDataAuthenticationContextIdentifier, type TestDataAuthenticationContextIdentifierType, type TestDataAuthorizedIdentifier, type TestDataAuthorizedIdentifierType, type TestDataContextIdentifier, type TestDataContextIdentifierType, type TestDataPermission, type TestDataPermissionType, type TestDataPermissionsGrantRequest, type TestDataPermissionsRevokeRequest, TestDataService, type ThirdSubjectIdentifierType, type TokenAuthOptions, type TokenAuthorIdentifier, type TokenAuthorIdentifierType, type TokenContextIdentifier, type TokenContextIdentifierType, type TokenInfo, TokenService, type TokenStatusResponse, type TooManyRequestsProblemDetails, type TransportFn, type UnauthorizedProblemDetails, type UnblockContextAuthenticationRequest, type UnzipOptions, type UpoAuthProof, type UpoContextId, type UpoDokument, type UpoInfo, type UpoOpisPotwierdzenia, type UpoPage, type UpoPotwierdzenie, type UpoResponse, type UpoResult, type UpoUwierzytelnienie, UpoVersion, UpoVersion as UpoVersionType, type ValidateAgainstXsdResult, type ValidateOptions, type ValidationDetail, VatUe, VerificationLinkService, type X500NameFields, type XadesSubjectIdentifierType, type XmlConversionResult, type XmlDocument, type XmlObject, type XmlValue, type ZipEntryInput, addBusinessDays, assertNever, authenticateWithCertificate, authenticateWithExternalSignature, authenticateWithPkcs12, authenticateWithToken, batchValidationDetails, buildFakturaXml, buildPefXml, buildRawXmlString, buildUnsignedAuthTokenRequestXml, buildXml, buildXmlFromObject, calculateBackoff, calculateOfflineDeadline, comparePKey, createZip, decodeJwtPayload, deduplicateByKsefNumber, defaultCircuitBreakerPolicy, defaultPresignedUrlPolicy, defaultRateLimitPolicy, defaultRetryPolicy, defaultTransport, exportAndDownload, exportInvoices, extendDeadlineForMaintenance, extractInvoiceFields, getDefaultReason, getEffectiveStartDate, getFormCode, getPolishHolidays, getTimeUntilDeadline, incrementalExportAndDownload, isExpired, isFakturaInput, isFormCodeShape, isPefUblDocumentInput, isPolishHoliday, isRetryableError, isRetryableStatus, isValidBase64, isValidCertificateFingerprint, isValidCertificateName, isValidInternalId, isValidIp4Address, isValidKsefNumber, isValidKsefNumberV35, isValidKsefNumberV36, isValidNip, isValidNipVatUe, isValidPeppolId, isValidPesel, isValidReferenceNumber, isValidSha256Base64, isValidVatUe, libxmljsAvailable, nextBusinessDay, openOnlineSession, openSendAndClose, orderXmlObject, parseFormCode, parseKSeFTokenContext, parseRetryAfter, parseUpoXml, parseXml, pollUntil, resolveOptions, resolveXsdFor, resumeOnlineSession, runWithConcurrency, serializeInvoiceXml, sha256Base64, sleep, stripBom, toKodFormularza, unzip, updateContinuationPoint, uploadBatch, uploadBatchParsed, uploadBatchStream, uploadBatchStreamParsed, validate, validateAgainstXsd, validateBatch, validateBusinessRules, validateCharValidity, validateFormCodeForSession, validatePresignedUrl, validateSchema, validateWellFormedness, verifyHash, xmlToObject };