ksef-client-ts 0.1.0 → 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/dist/index.d.cts CHANGED
@@ -16,7 +16,7 @@ declare const Environment: {
16
16
  readonly qrUrl: "https://qr-demo.ksef.mf.gov.pl";
17
17
  readonly lighthouseUrl: "";
18
18
  };
19
- readonly PRD: {
19
+ readonly PROD: {
20
20
  readonly apiUrl: "https://api.ksef.mf.gov.pl";
21
21
  readonly qrUrl: "https://qr.ksef.mf.gov.pl";
22
22
  readonly lighthouseUrl: "https://api-latarnia.ksef.mf.gov.pl";
@@ -122,7 +122,7 @@ interface UnauthorizedProblemDetails {
122
122
  instance?: string;
123
123
  traceId?: string;
124
124
  }
125
- type ForbiddenReasonCode = 'missing-permissions' | 'ip-not-allowed' | 'insufficient-resource-access' | 'auth-method-not-allowed' | 'security-service-blocked' | (string & {});
125
+ type ForbiddenReasonCode = 'missing-permissions' | 'ip-not-allowed' | 'insufficient-resource-access' | 'auth-method-not-allowed' | 'security-service-blocked' | 'context-type-not-allowed' | (string & {});
126
126
  interface ForbiddenProblemDetails {
127
127
  title: string;
128
128
  status: number;
@@ -257,6 +257,7 @@ declare class RestClient {
257
257
  private readonly presignedUrlPolicy?;
258
258
  constructor(options: ResolvedOptions, config?: RestClientConfig);
259
259
  execute<T>(request: RestRequest): Promise<RestResponse<T>>;
260
+ executeVoid(request: RestRequest): Promise<void>;
260
261
  executeRaw(request: RestRequest): Promise<RestResponse<ArrayBuffer>>;
261
262
  private sendRequest;
262
263
  private doRequest;
@@ -392,6 +393,19 @@ declare const Routes: {
392
393
  };
393
394
  };
394
395
 
396
+ /** Header name for KSeF feature negotiation. */
397
+ declare const KSEF_FEATURE_HEADER: "X-KSeF-Feature";
398
+ /** Known UPO format versions. */
399
+ declare const UpoVersion: {
400
+ /** UPO v4-2 format (default before 2026-01-05). */
401
+ readonly V4_2: "upo-v4-2";
402
+ /** UPO v4-3 format (default from 2026-01-05, adds InvoicingMode field). */
403
+ readonly V4_3: "upo-v4-3";
404
+ };
405
+ type UpoVersion = (typeof UpoVersion)[keyof typeof UpoVersion];
406
+ /** XAdES compliance enforcement value for X-KSeF-Feature header. */
407
+ declare const ENFORCE_XADES_COMPLIANCE: "enforce-xades-compliance";
408
+
395
409
  declare const Nip: RegExp;
396
410
  declare const VatUe: RegExp;
397
411
  declare const NipVatUe: RegExp;
@@ -416,6 +430,8 @@ declare function isValidInternalId(value: string): boolean;
416
430
  declare function isValidPeppolId(value: string): boolean;
417
431
  declare function isValidReferenceNumber(value: string): boolean;
418
432
  declare function isValidKsefNumber(value: string): boolean;
433
+ declare function isValidKsefNumberV35(value: string): boolean;
434
+ declare function isValidKsefNumberV36(value: string): boolean;
419
435
  declare function isValidPesel(value: string): boolean;
420
436
  declare function isValidCertificateName(value: string): boolean;
421
437
  declare function isValidCertificateFingerprint(value: string): boolean;
@@ -437,7 +453,7 @@ interface OperationResponse {
437
453
  interface OperationStatusInfo {
438
454
  code: number;
439
455
  description: string;
440
- details?: string[];
456
+ details?: string[] | null;
441
457
  }
442
458
  interface TokenInfo {
443
459
  token: string;
@@ -494,11 +510,11 @@ interface AuthenticationOperationStatusResponse {
494
510
  startDate: string;
495
511
  authenticationMethodInfo: AuthenticationMethodInfo;
496
512
  /** @deprecated Required by spec but deprecated. */
497
- authenticationMethod?: AuthenticationMethod;
513
+ authenticationMethod: AuthenticationMethod;
498
514
  status: OperationStatusInfo;
499
- isTokenRedeemed?: boolean;
500
- lastTokenRefreshDate?: string;
501
- refreshTokenValidUntil?: string;
515
+ isTokenRedeemed?: boolean | null;
516
+ lastTokenRefreshDate?: string | null;
517
+ refreshTokenValidUntil?: string | null;
502
518
  }
503
519
  /**
504
520
  * Subject identifier type for the XAdES auth XML request.
@@ -507,12 +523,12 @@ interface AuthenticationOperationStatusResponse {
507
523
  */
508
524
  type XadesSubjectIdentifierType = 'certificateSubject' | (string & {});
509
525
  interface AllowedIps {
510
- ip4Addresses?: string[];
511
- ip4Ranges?: string[];
512
- ip4Masks?: string[];
526
+ ip4Addresses?: string[] | null;
527
+ ip4Ranges?: string[] | null;
528
+ ip4Masks?: string[] | null;
513
529
  }
514
530
  interface AuthorizationPolicy {
515
- allowedIps?: AllowedIps;
531
+ allowedIps?: AllowedIps | null;
516
532
  }
517
533
  interface AuthTokenRequest {
518
534
  challenge: string;
@@ -532,16 +548,16 @@ interface AuthSessionInfo {
532
548
  startDate: string;
533
549
  authenticationMethodInfo: AuthenticationMethodInfo;
534
550
  /** @deprecated Required by spec but deprecated. */
535
- authenticationMethod?: AuthenticationMethod;
551
+ authenticationMethod: AuthenticationMethod;
536
552
  status: OperationStatusInfo;
537
- isTokenRedeemed?: boolean;
538
- lastTokenRefreshDate?: string;
539
- refreshTokenValidUntil?: string;
553
+ isTokenRedeemed?: boolean | null;
554
+ lastTokenRefreshDate?: string | null;
555
+ refreshTokenValidUntil?: string | null;
540
556
  referenceNumber: string;
541
557
  isCurrent: boolean;
542
558
  }
543
559
  interface AuthenticationListResponse {
544
- continuationToken?: string;
560
+ continuationToken?: string | null;
545
561
  items: AuthSessionInfo[];
546
562
  }
547
563
 
@@ -645,7 +661,7 @@ interface InvoiceStatusInfo {
645
661
  code: number;
646
662
  description: string;
647
663
  details?: string[];
648
- extensions?: Record<string, string>;
664
+ extensions?: Record<string, string | null> | null;
649
665
  }
650
666
  interface SessionInvoiceStatusResponse {
651
667
  ordinalNumber: number;
@@ -683,7 +699,7 @@ type InvoiceQueryDateType = 'Issue' | 'Invoicing' | 'PermanentStorage';
683
699
  type AmountType = 'Brutto' | 'Netto' | 'Vat';
684
700
  type BuyerIdentifierType = 'Nip' | 'VatUe' | 'Other' | 'None';
685
701
  type ThirdSubjectIdentifierType = 'Nip' | 'InternalId' | 'VatUe' | 'Other' | 'None';
686
- type FormType = 'FA' | 'PEF' | 'RR';
702
+ type FormType = 'FA' | 'PEF' | 'RR' | 'FA_RR';
687
703
  type InvoiceType = 'Vat' | 'Zal' | 'Kor' | 'Roz' | 'Upr' | 'KorZal' | 'KorRoz' | 'VatPef' | 'VatPefSp' | 'KorPef' | 'VatRr' | 'KorVatRr';
688
704
  interface InvoiceQueryDateRange {
689
705
  dateType: InvoiceQueryDateType;
@@ -773,6 +789,7 @@ interface QueryInvoicesMetadataResponse {
773
789
  interface InvoiceExportRequest {
774
790
  encryption: EncryptionInfo;
775
791
  filters: InvoiceQueryFilters;
792
+ onlyMetadata?: boolean;
776
793
  }
777
794
  interface InvoiceExportPackagePart {
778
795
  ordinalNumber: number;
@@ -1560,10 +1577,6 @@ interface BlockContextAuthenticationRequest {
1560
1577
  interface UnblockContextAuthenticationRequest {
1561
1578
  contextIdentifier?: TestDataAuthenticationContextIdentifier | null;
1562
1579
  }
1563
- interface TestDataStatusResponse {
1564
- code: number;
1565
- description: string;
1566
- }
1567
1580
 
1568
1581
  type PublicKeyCertificateUsage = 'KsefTokenEncryption' | 'SymmetricKeyEncryption';
1569
1582
  interface PublicKeyCertificate {
@@ -1613,7 +1626,7 @@ declare class AuthService {
1613
1626
  private readonly restClient;
1614
1627
  constructor(restClient: RestClient);
1615
1628
  getChallenge(): Promise<AuthChallengeResponse>;
1616
- submitXadesAuthRequest(signedXml: string, verifyCertificateChain?: boolean): Promise<AuthenticationInitResponse>;
1629
+ submitXadesAuthRequest(signedXml: string, verifyCertificateChain?: boolean, enforceXadesCompliance?: boolean): Promise<AuthenticationInitResponse>;
1617
1630
  submitKsefTokenAuthRequest(payload: AuthKsefTokenRequest): Promise<AuthenticationInitResponse>;
1618
1631
  getAuthStatus(referenceNumber: string, authToken: string): Promise<AuthenticationOperationStatusResponse>;
1619
1632
  getAccessToken(authToken: string): Promise<AuthenticationTokensResponse>;
@@ -1631,7 +1644,7 @@ declare class ActiveSessionsService {
1631
1644
  declare class OnlineSessionService {
1632
1645
  private readonly restClient;
1633
1646
  constructor(restClient: RestClient);
1634
- openSession(request: OpenOnlineSessionRequest, upoVersion?: string): Promise<OpenOnlineSessionResponse>;
1647
+ openSession(request: OpenOnlineSessionRequest, upoVersion?: UpoVersion | string): Promise<OpenOnlineSessionResponse>;
1635
1648
  sendInvoice(sessionRef: string, request: SendInvoiceRequest): Promise<SendInvoiceResponse>;
1636
1649
  closeSession(sessionRef: string): Promise<void>;
1637
1650
  }
@@ -1639,7 +1652,7 @@ declare class OnlineSessionService {
1639
1652
  declare class BatchSessionService {
1640
1653
  private readonly restClient;
1641
1654
  constructor(restClient: RestClient);
1642
- openSession(request: OpenBatchSessionRequest, upoVersion?: string): Promise<OpenBatchSessionResponse>;
1655
+ openSession(request: OpenBatchSessionRequest, upoVersion?: UpoVersion | string): Promise<OpenBatchSessionResponse>;
1643
1656
  sendParts(openResponse: OpenBatchSessionResponse, parts: BatchPartSendingInfo[]): Promise<void>;
1644
1657
  closeSession(batchRef: string): Promise<void>;
1645
1658
  }
@@ -1739,23 +1752,23 @@ declare class PeppolService {
1739
1752
  declare class TestDataService {
1740
1753
  private readonly restClient;
1741
1754
  constructor(restClient: RestClient);
1742
- createSubject(request: SubjectCreateRequest): Promise<TestDataStatusResponse>;
1743
- removeSubject(request: SubjectRemoveRequest): Promise<TestDataStatusResponse>;
1744
- createPerson(request: PersonCreateRequest): Promise<TestDataStatusResponse>;
1745
- removePerson(request: PersonRemoveRequest): Promise<TestDataStatusResponse>;
1746
- grantPermissions(request: TestDataPermissionsGrantRequest): Promise<TestDataStatusResponse>;
1747
- revokePermissions(request: TestDataPermissionsRevokeRequest): Promise<TestDataStatusResponse>;
1748
- enableAttachment(request: AttachmentPermissionGrantRequest): Promise<TestDataStatusResponse>;
1749
- disableAttachment(request: AttachmentPermissionRevokeRequest): Promise<TestDataStatusResponse>;
1750
- changeSessionLimits(request: SetSessionLimitsRequest): Promise<TestDataStatusResponse>;
1751
- restoreDefaultSessionLimits(): Promise<TestDataStatusResponse>;
1752
- changeCertificatesLimit(request: SetSubjectLimitsRequest): Promise<TestDataStatusResponse>;
1753
- restoreDefaultCertificatesLimit(): Promise<TestDataStatusResponse>;
1754
- setRateLimits(request: SetRateLimitsRequest): Promise<TestDataStatusResponse>;
1755
- restoreDefaultRateLimits(): Promise<TestDataStatusResponse>;
1756
- setProductionRateLimits(): Promise<TestDataStatusResponse>;
1757
- blockContext(request: BlockContextAuthenticationRequest): Promise<TestDataStatusResponse>;
1758
- unblockContext(request: UnblockContextAuthenticationRequest): Promise<TestDataStatusResponse>;
1755
+ createSubject(request: SubjectCreateRequest): Promise<void>;
1756
+ removeSubject(request: SubjectRemoveRequest): Promise<void>;
1757
+ createPerson(request: PersonCreateRequest): Promise<void>;
1758
+ removePerson(request: PersonRemoveRequest): Promise<void>;
1759
+ grantPermissions(request: TestDataPermissionsGrantRequest): Promise<void>;
1760
+ revokePermissions(request: TestDataPermissionsRevokeRequest): Promise<void>;
1761
+ enableAttachment(request: AttachmentPermissionGrantRequest): Promise<void>;
1762
+ disableAttachment(request: AttachmentPermissionRevokeRequest): Promise<void>;
1763
+ changeSessionLimits(request: SetSessionLimitsRequest): Promise<void>;
1764
+ restoreDefaultSessionLimits(): Promise<void>;
1765
+ changeCertificatesLimit(request: SetSubjectLimitsRequest): Promise<void>;
1766
+ restoreDefaultCertificatesLimit(): Promise<void>;
1767
+ setRateLimits(request: SetRateLimitsRequest): Promise<void>;
1768
+ restoreDefaultRateLimits(): Promise<void>;
1769
+ setProductionRateLimits(): Promise<void>;
1770
+ blockContext(request: BlockContextAuthenticationRequest): Promise<void>;
1771
+ unblockContext(request: UnblockContextAuthenticationRequest): Promise<void>;
1759
1772
  }
1760
1773
 
1761
1774
  declare class AuthTokenRequestBuilder {
@@ -1958,6 +1971,14 @@ declare class CertificateService {
1958
1971
  static generateCompanySeal(orgName: string, orgIdentifier: string, commonName: string, method?: CryptoEncryptionMethod): Promise<SelfSignedCertificateResult>;
1959
1972
  }
1960
1973
 
1974
+ interface Pkcs12Result {
1975
+ certificatePem: string;
1976
+ privateKeyPem: string;
1977
+ }
1978
+ declare class Pkcs12Loader {
1979
+ static load(p12: Buffer | Uint8Array, password: string): Pkcs12Result;
1980
+ }
1981
+
1961
1982
  declare class VerificationLinkService {
1962
1983
  private readonly baseQrUrl;
1963
1984
  constructor(baseQrUrl: string);
@@ -1982,6 +2003,53 @@ declare class QrCodeService {
1982
2003
  static generateResult(url: string, options?: QrCodeOptions): Promise<QrCodeResult>;
1983
2004
  }
1984
2005
 
2006
+ interface PollOptions {
2007
+ intervalMs?: number;
2008
+ maxAttempts?: number;
2009
+ onProgress?: (attempt: number, maxAttempts: number) => void;
2010
+ }
2011
+ interface OnlineSessionHandle {
2012
+ readonly sessionRef: string;
2013
+ readonly validUntil: string;
2014
+ sendInvoice(invoiceXml: string | Uint8Array): Promise<string>;
2015
+ close(): Promise<void>;
2016
+ waitForUpo(options?: PollOptions): Promise<UpoInfo>;
2017
+ }
2018
+ interface UpoInfo {
2019
+ pages: Array<{
2020
+ referenceNumber: string;
2021
+ downloadUrl: string;
2022
+ }>;
2023
+ invoiceCount?: number;
2024
+ successfulInvoiceCount?: number;
2025
+ failedInvoiceCount?: number;
2026
+ }
2027
+ interface BatchUploadResult {
2028
+ sessionRef: string;
2029
+ upo: UpoInfo;
2030
+ }
2031
+ interface ExportResult {
2032
+ parts: Array<{
2033
+ ordinalNumber: number;
2034
+ url: string;
2035
+ method: string;
2036
+ partSize: number;
2037
+ encryptedPartSize: number;
2038
+ encryptedPartHash: string;
2039
+ expirationDate: string;
2040
+ }>;
2041
+ invoiceCount: number;
2042
+ isTruncated: boolean;
2043
+ permanentStorageHwmDate?: string;
2044
+ }
2045
+ interface ExportDownloadResult extends ExportResult {
2046
+ decryptedParts: Uint8Array[];
2047
+ }
2048
+
2049
+ declare function pollUntil<T>(action: () => Promise<T>, condition: (result: T) => boolean, options?: PollOptions & {
2050
+ description?: string;
2051
+ }): Promise<T>;
2052
+
1985
2053
  declare class KSeFClient {
1986
2054
  readonly auth: AuthService;
1987
2055
  readonly activeSessions: ActiveSessionsService;
@@ -2003,7 +2071,72 @@ declare class KSeFClient {
2003
2071
  constructor(options?: KSeFClientOptions);
2004
2072
  loginWithToken(token: string, nip: string): Promise<void>;
2005
2073
  loginWithCertificate(certPem: string, keyPem: string, nip: string): Promise<void>;
2074
+ loginWithPkcs12(p12: Buffer | Uint8Array, password: string, nip: string): Promise<void>;
2075
+ private awaitAuthReady;
2006
2076
  logout(): Promise<void>;
2007
2077
  }
2008
2078
 
2009
- export { ActiveSessionsService, type AllowedIps, type AmountType, type ApiErrorResponse, type ApiRateLimitValuesOverride, type ApiRateLimitsOverride, type AttachmentPermissionGrantRequest, type AttachmentPermissionRevokeRequest, type AuthChallengeResponse, type AuthKsefTokenRequest, AuthKsefTokenRequestBuilder, type AuthManager, AuthService, type AuthSessionInfo, type AuthTokenRequest, AuthTokenRequestBuilder, type AuthenticationInitResponse, type AuthenticationKsefToken, type AuthenticationListResponse, type AuthenticationMethod, type AuthenticationMethodInfo, type AuthenticationMethodInfoCategory, type AuthenticationOperationStatusResponse, type AuthenticationTokenRefreshResponse, type AuthenticationTokensResponse, type AuthorizationGrant, AuthorizationPermissionGrantBuilder, type AuthorizationPolicy, Base64String, type BatchFileInfo, type BatchFilePartInfo, type BatchPartSendingInfo, type BatchSessionContextLimitsOverride, type BatchSessionEffectiveContextLimits, BatchSessionService, type BlockContextAuthenticationRequest, type BuyerIdentifierType, CERTIFICATE_NAME_MAX_LENGTH, CERTIFICATE_NAME_MIN_LENGTH, CertificateApiService, 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 CryptoEncryptionMethod, CryptographyService, type CsrResult, DefaultAuthManager, 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 FileMetadata, type ForbiddenProblemDetails, type ForbiddenReasonCode, type FormCode, type FormType, type GrantPermissionsAuthorizationRequest, type GrantPermissionsEntityRequest, type GrantPermissionsEuEntityAdminRequest, type GrantPermissionsEuEntityRepresentativeRequest, type GrantPermissionsEuEntityRequest, type GrantPermissionsIndirectRequest, type GrantPermissionsPersonRequest, type GrantPermissionsSubunitRequest, type HttpMethod, type IdDocument, type IndirectPermissionType, type IndirectPermissionsSubjectIdentifier, type IndirectPermissionsSubjectIdentifierType, type IndirectPermissionsTargetIdentifier, type IndirectPermissionsTargetIdentifierType, InternalId, InvoiceDownloadService, type InvoiceExportPackage, type InvoiceExportPackagePart, type InvoiceExportRequest, type InvoiceExportStatusResponse, 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 InvoiceStatusInfo, type InvoiceSubjectType, type InvoiceType, type InvoicingMode, Ip4Address, Ip4Mask, Ip4Range, KSeFApiError, KSeFAuthStatusError, KSeFClient, type KSeFClientOptions, KSeFError, KSeFForbiddenError, KSeFRateLimitError, KSeFSessionExpiredError, KSeFUnauthorizedError, KSeFValidationError, type KsefMessagesResponse, KsefNumber, KsefNumberV35, KsefNumberV36, type KsefStatusResponse, type KsefSystemStatus, type KsefTokenPermissionType, type KsefTokenRequest, type KsefTokenResponse, type KsefTokenStatus, type LighthouseMessage, LighthouseService, LimitsService, Nip, NipVatUe, type OnlineSessionContextLimitsOverride, type OnlineSessionEffectiveContextLimits, OnlineSessionService, type OpenBatchSessionRequest, type OpenBatchSessionResponse, type OpenOnlineSessionRequest, type OpenOnlineSessionResponse, type OperationResponse, type OperationStatusInfo, PERMISSION_DESCRIPTION_MAX_LENGTH, PERMISSION_DESCRIPTION_MIN_LENGTH, type PagedAuthorizationsResponse, type PagedPermissionsResponse, type PagedRolesResponse, 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 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, type SelfSignedCertificateResult, 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 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, type TestDataAuthenticationContextIdentifier, type TestDataAuthenticationContextIdentifierType, type TestDataAuthorizedIdentifier, type TestDataAuthorizedIdentifierType, type TestDataContextIdentifier, type TestDataContextIdentifierType, type TestDataPermission, type TestDataPermissionType, type TestDataPermissionsGrantRequest, type TestDataPermissionsRevokeRequest, TestDataService, type TestDataStatusResponse, type ThirdSubjectIdentifierType, type TokenAuthorIdentifier, type TokenAuthorIdentifierType, type TokenContextIdentifier, type TokenContextIdentifierType, type TokenInfo, TokenService, type TokenStatusResponse, type TransportFn, type UnauthorizedProblemDetails, type UnblockContextAuthenticationRequest, type UpoPage, type UpoResponse, type UpoResult, type ValidationDetail, VatUe, VerificationLinkService, type X500NameFields, type XadesSubjectIdentifierType, calculateBackoff, defaultPresignedUrlPolicy, defaultRateLimitPolicy, defaultRetryPolicy, defaultTransport, isRetryableError, isRetryableStatus, isValidBase64, isValidCertificateFingerprint, isValidCertificateName, isValidInternalId, isValidIp4Address, isValidKsefNumber, isValidNip, isValidNipVatUe, isValidPeppolId, isValidPesel, isValidReferenceNumber, isValidSha256Base64, isValidVatUe, parseRetryAfter, resolveOptions, sleep, validatePresignedUrl };
2079
+ interface OpenOnlineSessionOptions {
2080
+ formCode?: FormCode;
2081
+ upoVersion?: UpoVersion | string;
2082
+ }
2083
+ interface SendAndCloseOptions extends OpenOnlineSessionOptions {
2084
+ pollOptions?: PollOptions;
2085
+ }
2086
+ declare function openOnlineSession(client: KSeFClient, options?: OpenOnlineSessionOptions): Promise<OnlineSessionHandle>;
2087
+ declare function openSendAndClose(client: KSeFClient, invoices: Array<string | Uint8Array>, options?: SendAndCloseOptions): Promise<UpoInfo>;
2088
+
2089
+ interface BatchUploadOptions {
2090
+ formCode?: FormCode;
2091
+ upoVersion?: UpoVersion | string;
2092
+ pollOptions?: PollOptions;
2093
+ }
2094
+ interface BatchPart {
2095
+ data: ArrayBuffer;
2096
+ }
2097
+ declare function uploadBatch(client: KSeFClient, zipParts: BatchPart[], totalFileSize: number, totalFileHash: string, options?: BatchUploadOptions): Promise<BatchUploadResult>;
2098
+
2099
+ interface ExportOptions {
2100
+ onlyMetadata?: boolean;
2101
+ pollOptions?: PollOptions;
2102
+ }
2103
+ interface ExportAndDownloadOptions extends ExportOptions {
2104
+ /** Custom fetch function for downloading parts (defaults to global fetch). */
2105
+ transport?: typeof fetch;
2106
+ }
2107
+ declare function exportInvoices(client: KSeFClient, filters: InvoiceQueryFilters, options?: ExportOptions): Promise<ExportResult>;
2108
+ declare function exportAndDownload(client: KSeFClient, filters: InvoiceQueryFilters, options?: ExportAndDownloadOptions): Promise<ExportDownloadResult>;
2109
+
2110
+ interface AuthResult {
2111
+ accessToken: string;
2112
+ accessTokenValidUntil: string;
2113
+ refreshToken: string;
2114
+ refreshTokenValidUntil: string;
2115
+ }
2116
+ interface TokenAuthOptions {
2117
+ nip: string;
2118
+ token: string;
2119
+ authorizationPolicy?: AuthorizationPolicy;
2120
+ pollOptions?: PollOptions;
2121
+ }
2122
+ interface CertificateAuthOptions {
2123
+ nip: string;
2124
+ certPem: string;
2125
+ keyPem: string;
2126
+ verifyCertificateChain?: boolean;
2127
+ enforceXadesCompliance?: boolean;
2128
+ pollOptions?: PollOptions;
2129
+ }
2130
+ interface Pkcs12AuthOptions {
2131
+ nip: string;
2132
+ p12: Buffer | Uint8Array;
2133
+ password: string;
2134
+ verifyCertificateChain?: boolean;
2135
+ enforceXadesCompliance?: boolean;
2136
+ pollOptions?: PollOptions;
2137
+ }
2138
+ declare function authenticateWithToken(client: KSeFClient, options: TokenAuthOptions): Promise<AuthResult>;
2139
+ declare function authenticateWithCertificate(client: KSeFClient, options: CertificateAuthOptions): Promise<AuthResult>;
2140
+ declare function authenticateWithPkcs12(client: KSeFClient, options: Pkcs12AuthOptions): Promise<AuthResult>;
2141
+
2142
+ 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 AuthenticationInitResponse, type AuthenticationKsefToken, type AuthenticationListResponse, type AuthenticationMethod, type AuthenticationMethodInfo, type AuthenticationMethodInfoCategory, type AuthenticationOperationStatusResponse, type AuthenticationTokenRefreshResponse, type AuthenticationTokensResponse, type AuthorizationGrant, AuthorizationPermissionGrantBuilder, type AuthorizationPolicy, Base64String, type BatchFileInfo, type BatchFilePartInfo, type BatchPart, type BatchPartSendingInfo, type BatchSessionContextLimitsOverride, type BatchSessionEffectiveContextLimits, BatchSessionService, type BatchUploadOptions, type BatchUploadResult, 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 CryptoEncryptionMethod, CryptographyService, type CsrResult, 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 ExportOptions, type ExportResult, type FileMetadata, type ForbiddenProblemDetails, type ForbiddenReasonCode, type FormCode, type FormType, type GrantPermissionsAuthorizationRequest, type GrantPermissionsEntityRequest, type GrantPermissionsEuEntityAdminRequest, type GrantPermissionsEuEntityRepresentativeRequest, type GrantPermissionsEuEntityRequest, type GrantPermissionsIndirectRequest, type GrantPermissionsPersonRequest, type GrantPermissionsSubunitRequest, type HttpMethod, type IdDocument, type IndirectPermissionType, type IndirectPermissionsSubjectIdentifier, type IndirectPermissionsSubjectIdentifierType, type IndirectPermissionsTargetIdentifier, type IndirectPermissionsTargetIdentifierType, InternalId, InvoiceDownloadService, type InvoiceExportPackage, type InvoiceExportPackagePart, type InvoiceExportRequest, type InvoiceExportStatusResponse, 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 InvoiceStatusInfo, type InvoiceSubjectType, type InvoiceType, type InvoicingMode, Ip4Address, Ip4Mask, Ip4Range, KSEF_FEATURE_HEADER, KSeFApiError, KSeFAuthStatusError, KSeFClient, type KSeFClientOptions, KSeFError, KSeFForbiddenError, KSeFRateLimitError, KSeFSessionExpiredError, KSeFUnauthorizedError, KSeFValidationError, type KsefMessagesResponse, KsefNumber, KsefNumberV35, KsefNumberV36, type KsefStatusResponse, type KsefSystemStatus, type KsefTokenPermissionType, type KsefTokenRequest, type KsefTokenResponse, type KsefTokenStatus, type LighthouseMessage, LighthouseService, LimitsService, Nip, NipVatUe, type OnlineSessionContextLimitsOverride, type OnlineSessionEffectiveContextLimits, type OnlineSessionHandle, OnlineSessionService, 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 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, 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 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, 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 UpoInfo, type UpoPage, type UpoResponse, type UpoResult, UpoVersion, UpoVersion as UpoVersionType, type ValidationDetail, VatUe, VerificationLinkService, type X500NameFields, type XadesSubjectIdentifierType, authenticateWithCertificate, authenticateWithPkcs12, authenticateWithToken, calculateBackoff, defaultPresignedUrlPolicy, defaultRateLimitPolicy, defaultRetryPolicy, defaultTransport, exportAndDownload, exportInvoices, isRetryableError, isRetryableStatus, isValidBase64, isValidCertificateFingerprint, isValidCertificateName, isValidInternalId, isValidIp4Address, isValidKsefNumber, isValidKsefNumberV35, isValidKsefNumberV36, isValidNip, isValidNipVatUe, isValidPeppolId, isValidPesel, isValidReferenceNumber, isValidSha256Base64, isValidVatUe, openOnlineSession, openSendAndClose, parseRetryAfter, pollUntil, resolveOptions, sleep, uploadBatch, validatePresignedUrl };