GitHub

ksef2.raw

Raw endpoint interface for advanced KSeF integrations.

Na tej stronie

Raw endpoint interface for advanced KSeF integrations.

Klasy

AsyncRawAuthenticatedClient

Import: from ksef2.raw import AsyncRawAuthenticatedClient

class AsyncRawAuthenticatedClient
python
AsyncRawAuthenticatedClient(
    *,
    transport: AsyncMiddleware,
    authed_transport: AsyncMiddleware,
    environment: Environment,
)
python

Raw authenticated endpoint facade for advanced async integrations.

Metody

AsyncRawAuthenticatedClient.auth (właściwość)

auth: AsyncAuthEndpoints
python

Return raw authenticated authentication-session endpoints.

Zwraca

  • AsyncAuthEndpoints — Raw authenticated authentication-session endpoints.

AsyncRawAuthenticatedClient.certificates (właściwość)

certificates: AsyncCertificatesEndpoints
python

Return raw certificate lifecycle endpoints.

Zwraca

  • AsyncCertificatesEndpoints — Raw certificate lifecycle endpoints.

AsyncRawAuthenticatedClient.encryption (właściwość)

encryption: AsyncEncryptionEndpoints
python

Return raw public encryption-certificate endpoints.

Zwraca

  • AsyncEncryptionEndpoints — Raw public encryption-certificate endpoints.

AsyncRawAuthenticatedClient.invoices (właściwość)

invoices: AsyncInvoicesEndpoints
python

Return raw invoice and invoice-session endpoints.

Zwraca

  • AsyncInvoicesEndpoints — Raw invoice and invoice-session endpoints.

AsyncRawAuthenticatedClient.limits (właściwość)

limits: AsyncLimitEndpoints
python

Return raw limit endpoints.

Zwraca

  • AsyncLimitEndpoints — Raw limit endpoints.

AsyncRawAuthenticatedClient.collective_identifiers (właściwość)

collective_identifiers: AsyncCollectiveIdentifiersEndpoints
python

Return raw collective invoice identifier endpoints.

Zwraca

  • AsyncCollectiveIdentifiersEndpoints — Raw collective invoice identifier endpoints.

AsyncRawAuthenticatedClient.peppol (właściwość)

peppol: AsyncPeppolEndpoints
python

Return raw Peppol provider endpoints.

Zwraca

  • AsyncPeppolEndpoints — Raw Peppol provider endpoints.

AsyncRawAuthenticatedClient.permissions (właściwość)

permissions: AsyncRawPermissionsEndpoints
python

Return raw permission endpoint groups.

Zwraca

  • AsyncRawPermissionsEndpoints — Raw permission endpoint groups.

AsyncRawAuthenticatedClient.session (właściwość)

session: AsyncSessionEndpoints
python

Return raw online and batch session endpoints.

Zwraca

  • AsyncSessionEndpoints — Raw online and batch session endpoints.

AsyncRawAuthenticatedClient.testdata (właściwość)

testdata: AsyncTestDataEndpoints
python

Return raw TEST-only data seeding endpoints.

Zwraca

  • AsyncTestDataEndpoints — Raw TEST-only data seeding endpoints.

AsyncRawAuthenticatedClient.tokens (właściwość)

tokens: AsyncTokenEndpoints
python

Return raw token lifecycle endpoints.

Zwraca

  • AsyncTokenEndpoints — Raw token lifecycle endpoints.

AsyncRawClient

Import: from ksef2.raw import AsyncRawClient

class AsyncRawClient
python
AsyncRawClient(transport: AsyncMiddleware, environment: Environment)
python

Raw unauthenticated endpoint facade for advanced async integrations.

Metody

AsyncRawClient.auth (właściwość)

auth: AsyncAuthEndpoints
python

Return raw authentication endpoints.

Zwraca

  • AsyncAuthEndpoints — Raw authentication endpoints.

AsyncRawClient.encryption (właściwość)

encryption: AsyncEncryptionEndpoints
python

Return raw public encryption-certificate endpoints.

Zwraca

  • AsyncEncryptionEndpoints — Raw public encryption-certificate endpoints.

AsyncRawClient.peppol (właściwość)

peppol: AsyncPeppolEndpoints
python

Return raw Peppol provider endpoints.

Zwraca

  • AsyncPeppolEndpoints — Raw Peppol provider endpoints.

AsyncRawClient.testdata (właściwość)

testdata: AsyncTestDataEndpoints
python

Return raw TEST-only data seeding endpoints.

Zwraca

  • AsyncTestDataEndpoints — Raw TEST-only data seeding endpoints.

AsyncRawPermissionsEndpoints

Import: from ksef2.raw import AsyncRawPermissionsEndpoints

class AsyncRawPermissionsEndpoints
python
AsyncRawPermissionsEndpoints(transport: AsyncMiddleware)
python

Raw permission endpoint groups bound to one async transport.

Metody

AsyncRawPermissionsEndpoints.grant (właściwość)

grant: AsyncPermissionsGrantEndpoints
python

Return permission grant endpoints.

Zwraca

  • AsyncPermissionsGrantEndpoints — Permission grant endpoints.

AsyncRawPermissionsEndpoints.revoke (właściwość)

revoke: AsyncRevokePermissionsEndpoints
python

Return permission revocation endpoints.

Zwraca

  • AsyncRevokePermissionsEndpoints — Permission revocation endpoints.

AsyncRawPermissionsEndpoints.query (właściwość)

query: AsyncQueryPermissionsEndpoints
python

Return permission query endpoints.

Zwraca

  • AsyncQueryPermissionsEndpoints — Permission query endpoints.

AsyncRawPermissionsEndpoints.status (właściwość)

status: AsyncGetPermissionsEndpoints
python

Return permission operation status and role endpoints.

Zwraca

  • AsyncGetPermissionsEndpoints — Permission operation status and role endpoints.

RawAuthenticatedClient

Import: from ksef2.raw import RawAuthenticatedClient

class RawAuthenticatedClient
python
RawAuthenticatedClient(
    *,
    transport: Middleware,
    authed_transport: Middleware,
    environment: Environment,
)
python

Raw authenticated endpoint facade for advanced integrations.

Metody

RawAuthenticatedClient.auth (właściwość)

auth: AuthEndpoints
python

Return raw authenticated authentication-session endpoints.

Zwraca

  • AuthEndpoints — Raw authenticated authentication-session endpoints.

RawAuthenticatedClient.certificates (właściwość)

certificates: CertificatesEndpoints
python

Return raw certificate lifecycle endpoints.

Zwraca

  • CertificatesEndpoints — Raw certificate lifecycle endpoints.

RawAuthenticatedClient.encryption (właściwość)

encryption: EncryptionEndpoints
python

Return raw public encryption-certificate endpoints.

Zwraca

  • EncryptionEndpoints — Raw public encryption-certificate endpoints.

RawAuthenticatedClient.invoices (właściwość)

invoices: InvoicesEndpoints
python

Return raw invoice and invoice-session endpoints.

Zwraca

  • InvoicesEndpoints — Raw invoice and invoice-session endpoints.

RawAuthenticatedClient.limits (właściwość)

limits: LimitEndpoints
python

Return raw limit endpoints.

Zwraca

  • LimitEndpoints — Raw limit endpoints.

RawAuthenticatedClient.collective_identifiers (właściwość)

collective_identifiers: CollectiveIdentifiersEndpoints
python

Return raw collective invoice identifier endpoints.

Zwraca

  • CollectiveIdentifiersEndpoints — Raw collective invoice identifier endpoints.

RawAuthenticatedClient.peppol (właściwość)

peppol: PeppolEndpoints
python

Return raw Peppol provider endpoints.

Zwraca

  • PeppolEndpoints — Raw Peppol provider endpoints.

RawAuthenticatedClient.permissions (właściwość)

permissions: RawPermissionsEndpoints
python

Return raw permission endpoint groups.

Zwraca

  • RawPermissionsEndpoints — Raw permission endpoint groups.

RawAuthenticatedClient.session (właściwość)

session: SessionEndpoints
python

Return raw online and batch session endpoints.

Zwraca

  • SessionEndpoints — Raw online and batch session endpoints.

RawAuthenticatedClient.testdata (właściwość)

testdata: TestDataEndpoints
python

Return raw TEST-only data seeding endpoints.

Zwraca

  • TestDataEndpoints — Raw TEST-only data seeding endpoints.

RawAuthenticatedClient.tokens (właściwość)

tokens: TokenEndpoints
python

Return raw token lifecycle endpoints.

Zwraca

  • TokenEndpoints — Raw token lifecycle endpoints.

RawClient

Import: from ksef2.raw import RawClient

class RawClient
python
RawClient(transport: Middleware, environment: Environment)
python

Raw unauthenticated endpoint facade for advanced integrations.

Metody

RawClient.auth (właściwość)

auth: AuthEndpoints
python

Return raw authentication endpoints.

Zwraca

  • AuthEndpoints — Raw authentication endpoints.

RawClient.encryption (właściwość)

encryption: EncryptionEndpoints
python

Return raw public encryption-certificate endpoints.

Zwraca

  • EncryptionEndpoints — Raw public encryption-certificate endpoints.

RawClient.peppol (właściwość)

peppol: PeppolEndpoints
python

Return raw Peppol provider endpoints.

Zwraca

  • PeppolEndpoints — Raw Peppol provider endpoints.

RawClient.testdata (właściwość)

testdata: TestDataEndpoints
python

Return raw TEST-only data seeding endpoints.

Zwraca

  • TestDataEndpoints — Raw TEST-only data seeding endpoints.

RawPermissionsEndpoints

Import: from ksef2.raw import RawPermissionsEndpoints

class RawPermissionsEndpoints
python
RawPermissionsEndpoints(transport: Middleware)
python

Raw permission endpoint groups bound to one transport.

Metody

RawPermissionsEndpoints.grant (właściwość)

grant: PermissionsGrantEndpoints
python

Return permission grant endpoints.

Zwraca

  • PermissionsGrantEndpoints — Permission grant endpoints.

RawPermissionsEndpoints.revoke (właściwość)

revoke: RevokePermissionsEndpoints
python

Return permission revocation endpoints.

Zwraca

  • RevokePermissionsEndpoints — Permission revocation endpoints.

RawPermissionsEndpoints.query (właściwość)

query: QueryPermissionsEndpoints
python

Return permission query endpoints.

Zwraca

  • QueryPermissionsEndpoints — Permission query endpoints.

RawPermissionsEndpoints.status (właściwość)

status: GetPermissionsEndpoints
python

Return permission operation status and role endpoints.

Zwraca

  • GetPermissionsEndpoints — Permission operation status and role endpoints.

Funkcje

encrypt_invoice

Import: from ksef2.raw import encrypt_invoice

def encrypt_invoice(xml_bytes: bytes, key: bytes, iv: bytes) -> bytes
python

AES-256-CBC encrypt xml_bytes with PKCS#7 padding.

Parametry

  • xml_bytes (bytes) — Plain invoice XML bytes.
  • key (bytes) — 32-byte AES-256 key.
  • iv (bytes) — 16-byte initialization vector.

Zwraca

  • bytes — The raw ciphertext bytes. The caller is responsible for Base64 encoding.

Zgłasza

  • KSeFEncryptionError — If encryption fails, for example because of an invalid key length.

encrypt_symmetric_key

Import: from ksef2.raw import encrypt_symmetric_key

def encrypt_symmetric_key(key: bytes, cert_b64: str) -> bytes
python

RSA-OAEP encrypt an AES key with a KSeF public-key certificate.

Parametry

  • key (bytes) — AES key to encrypt.
  • cert_b64 (str) — Base64-encoded DER certificate containing the RSA public key.

Zwraca

  • bytes — The raw ciphertext bytes. The caller is responsible for Base64 encoding.

Zgłasza

  • KSeFEncryptionError — If the certificate cannot be loaded or encryption fails.

encrypt_token

Import: from ksef2.raw import encrypt_token

def encrypt_token(token: str, timestamp: str, cert_b64: str) -> str
python

RSA-OAEP encrypt token|timestamp and return Base64.

Parametry

  • token (str) — KSeF token.
  • timestamp (str) — Challenge timestamp in Unix milliseconds, as a string.
  • cert_b64 (str) — Base64-encoded DER certificate containing the RSA public key.

Zwraca

  • str — The Base64-encoded ciphertext.

Zgłasza

  • KSeFEncryptionError — If the certificate cannot be loaded or encryption fails.

generate_session_key

Import: from ksef2.raw import generate_session_key

def generate_session_key() -> tuple[bytes, bytes]
python

Generate a random AES-256 key (32 bytes) and IV (16 bytes).

Zwraca

  • tuple[bytes, bytes] — A tuple of the AES key and the initialization vector.

prepare_batch_package

Import: from ksef2.raw import prepare_batch_package

def prepare_batch_package(
    *,
    invoices: Iterable[BatchInvoice],
    aes_key: bytes,
    iv: bytes,
    encrypted_key: bytes,
    public_key_id: str | None = None,
    form_code: FormSchema = FormSchema.FA3,
    offline_mode: bool = False,
    max_part_size: int = MAX_BATCH_PART_SIZE,
) -> PreparedBatch
python

Build, split, and encrypt a batch package from invoice payloads.

Parametry

  • invoices (Iterable[BatchInvoice]) — Invoices to include; each becomes one ZIP entry.
  • aes_key (bytes) — AES-256 key used to encrypt the parts.
  • iv (bytes) — AES initialization vector.
  • encrypted_key (bytes) — aes_key encrypted with the KSeF public key.
  • public_key_id (str | None) — Identifier of the KSeF public key used for encrypted_key; None for the default.
  • form_code (FormSchema) — Invoice schema of the batch.
  • offline_mode (bool) — Whether the invoices were issued in offline mode.
  • max_part_size (int) — Maximum size in bytes of one encrypted part.

Zwraca

  • PreparedBatch — The prepared batch: package metadata, encrypted parts and encryption material.

Zgłasza

  • KSeFEncryptionError — If part encryption fails.
  • KSeFValidationError — If the invoice list or part size is invalid.

sha256_b64

Import: from ksef2.raw import sha256_b64

def sha256_b64(data: bytes) -> str
python

Return the SHA-256 digest of data as a Base64-encoded string.

Parametry

  • data (bytes) — Bytes to hash.

Zwraca

  • str — The Base64-encoded digest.

Podmoduły

auth

Import: import ksef2.raw.auth

batch

Import: import ksef2.raw.batch

Supplementary models for batch session operations.

These models shadow the spec models with str instead of Base64Str fields to allow easier construction in mappers.

certificates

Import: import ksef2.raw.certificates

Supplementary models for certificate operations.

These models shadow generated schema models that use Base64Str fields so the SDK can pass already-base64-encoded request data without double decoding.

encryption

Import: import ksef2.raw.encryption

invoices

Import: import ksef2.raw.invoices

peppol

Import: import ksef2.raw.peppol

permissions

Import: import ksef2.raw.permissions

session

Import: import ksef2.raw.session

spec

Import: import ksef2.raw.spec

supp

Import: import ksef2.raw.supp

testdata

Import: import ksef2.raw.testdata