pyeudiw.status_list package

Submodules

pyeudiw.status_list.exceptions module

exception pyeudiw.status_list.exceptions.InvalidTokenFormatError[source]

Bases: Exception

Exception raised when the token type is invalid.

exception pyeudiw.status_list.exceptions.MissingStatusListUriError[source]

Bases: Exception

Exception raised when the status list URI is missing.

exception pyeudiw.status_list.exceptions.PositionOutOfRangeError[source]

Bases: Exception

Exception raised when the position is out of range.

exception pyeudiw.status_list.exceptions.StatusListRetrievalError[source]

Bases: Exception

Exception raised when there is an error retrieving the status list.

pyeudiw.status_list.helper module

class pyeudiw.status_list.helper.StatusListTokenHelper(header: dict, payload: dict, bits: int, status_list: bytes, aggregation_uri: str | None = None)[source]

Bases: object

static from_status(status: dict, httpc_params: dict | None = None) StatusListTokenHelper[source]

Create a StatusListTokenHelper instance from a status dictionary. :param status: The status dictionary. :type status: dict

Raises:
Returns:

A StatusListTokenHelper instance.

Return type:

StatusListTokenHelper

static from_token(token: str | bytes) StatusListTokenHelper[source]

Create a StatusListTokenHelper instance from a status list token. :param token: The status list token. :type token: str | bytes

Raises:

InvalidTokenFormatError – If the token is not a valid JWT or CWT.

Returns:

A StatusListTokenHelper instance.

Return type:

StatusListTokenHelper

get_aggregation_uri() str | None[source]

Returns the aggregation URI.

Returns:

The aggregation URI.

Return type:

Optional[str]

get_status(position: int) int[source]

Returns the status at the given position.

Parameters:

position (int) – The position of the status in the list.

Raises:

IndexError – If the position is out of range.

Returns:

The status at the given position.

Return type:

int

property iat: int | None

Returns the issued at time of the token.

Returns:

The issued at time of the token.

Return type:

Optional[int]

is_expired() bool[source]

Returns True if the token is expired, False otherwise.

Returns:

True if the token is expired, False otherwise.

Return type:

bool

property iss: str | None

Returns the issuer of the token.

Returns:

The issuer of the token.

Return type:

Optional[str]

property sub: str | None

Returns the subject of the token.

Returns:

The subject of the token.

Return type:

Optional[str]

property ttl: int | None

Returns the time to live (TTL) of the token in seconds.

Returns:

The TTL of the token in seconds.

Return type:

Optional[int]

Module contents

pyeudiw.status_list.array_to_bitstring(status_array: list[dict], bit_size: int = 1) bytes[source]

Convert an array of status objects to a bitstring.

Parameters:
  • status_array (list[dict]) – The array of status objects.

  • bit_size (int) – The size of each bit in the bitstring.

Returns:

The resulting bitstring.

Return type:

bytes

pyeudiw.status_list.decode_cwt_status_list_token(token: bytes) tuple[bool, dict, dict, int, bytes][source]

Decode a CWT status list token.

Parameters:

token (bytes) – The CWT status list token.

Returns:

A tuple containing the parsing status, the header, payload, bits, and status list.

Return type:

tuple[dict, dict, int, bytes]

pyeudiw.status_list.decode_jwt_status_list_token(token: str) tuple[bool, dict, dict, int, bytes][source]

Decode a JWT status list token.

Parameters:

token (str) – The JWT status list token.

Returns:

A tuple containing the parsing status, the header, payload, bits, and status list.

Return type:

tuple[dict, dict, int, bytes]

pyeudiw.status_list.encode_cwt_status_list_token(payload_parts: Tuple[dict, dict, dict], bits: int, status_list: bytes, payload_map: dict | None = None, private_key: dict | None = None) bytes[source]

Encode a CWT representing a status list and optionally sign it.

Compresses the status list and inserts it under claim 65533 in the payload; if a private_key is provided the token will be signed.

Parameters:
  • payload_parts (Tuple[dict, dict, dict]) – A tuple containing the protected header, unprotected header, and payload.

  • bits (int) – The number of bits in the status list.

  • status_list (bytes) – The status list as a byte string.

  • payload_map (dict | None) – An optional mapping to replace keys in the payload.

  • private_key (dict | None) – An optional private key for signing the token.

Returns:

The encoded CWT as a byte string.

Return type:

bytes

pyeudiw.status_list.generate_status_list(bitstring: bytes, bits: int = 1, aggregation_uri: str | None = None, format: Literal['jwt', 'cwt'] = 'jwt') dict | bytes[source]

Generate a status list.

Parameters:
  • bitstring (bytes) – The bitstring to generate the status list from.

  • bits (int) – The number of bits in the status list.

  • aggregation_uri (Optional[str]) – The aggregation URI.

  • format (StatusListFormat) – The format of the status list, either “jwt” or “cwt”.

Returns:

A dictionary containing the status list or a CWT token.

Return type:

Union[dict, bytes]