Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stubs/jwcrypto/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# test code does not need type hints
jwcrypto.tests
jwcrypto.tests-cookbook
jwcrypto.tests_mldsa

# even if the deprecated decorator is applied, the attribute is not present
jwcrypto.jwt.JWTMissingKeyID.__deprecated__
Expand Down
2 changes: 1 addition & 1 deletion stubs/jwcrypto/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version = "1.5.8"
version = "1.5.9"
upstream-repository = "https://github.com/latchset/jwcrypto"
dependencies = ["cryptography"]
3 changes: 3 additions & 0 deletions stubs/jwcrypto/jwcrypto/common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class InvalidJWAAlgorithm(JWException):
class InvalidCEKeyLength(JWException):
def __init__(self, expected: int, obtained: int) -> None: ...

class InvalidJWEData(JWException):
def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ...

class InvalidJWEOperation(JWException):
def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ...

Expand Down
5 changes: 4 additions & 1 deletion stubs/jwcrypto/jwcrypto/jwa.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
from typing import ClassVar
from typing import ClassVar, Literal

default_max_pbkdf2_iterations: int
default_warn_deprecated_algorithms: bool
default_enforce_hmac_key_length: bool

class JWAAlgorithm(metaclass=ABCMeta):
Expand All @@ -21,6 +22,8 @@ class JWAAlgorithm(metaclass=ABCMeta):
@property
@abstractmethod
def algorithm_use(self) -> str: ...
status: Literal["active", "deprecated", "prohibited"]
deprecated_by: str | None
@property
def input_keysize(self) -> int: ...

Expand Down
6 changes: 2 additions & 4 deletions stubs/jwcrypto/jwcrypto/jwe.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from typing import Any
from typing_extensions import LiteralString, Self

from jwcrypto import common
from jwcrypto.common import JWException, JWSEHeaderParameter, JWSEHeaderRegistry
from jwcrypto.common import JWSEHeaderParameter, JWSEHeaderRegistry
from jwcrypto.jwk import JWK, JWKSet

default_max_compressed_size: int
Expand All @@ -14,10 +14,8 @@ JWEHeaderRegistry: dict[LiteralString, JWSEHeaderParameter]

default_allowed_algs: list[LiteralString]

class InvalidJWEData(JWException):
def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ...

InvalidCEKeyLength = common.InvalidCEKeyLength
InvalidJWEData = common.InvalidJWEData
InvalidJWEKeyLength = common.InvalidJWEKeyLength
InvalidJWEKeyType = common.InvalidJWEKeyType
InvalidJWEOperation = common.InvalidJWEOperation
Expand Down
28 changes: 25 additions & 3 deletions stubs/jwcrypto/jwcrypto/jwk.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ from cryptography.hazmat.primitives.asymmetric.ed25519 import (
Ed25519PrivateKey as Ed25519PrivateKey,
Ed25519PublicKey as Ed25519PublicKey,
)
from cryptography.hazmat.primitives.asymmetric.mldsa import (
MLDSA44PrivateKey as MLDSA44PrivateKey,
MLDSA44PublicKey as MLDSA44PublicKey,
MLDSA65PrivateKey as MLDSA65PrivateKey,
MLDSA65PublicKey as MLDSA65PublicKey,
MLDSA87PrivateKey as MLDSA87PrivateKey,
MLDSA87PublicKey as MLDSA87PublicKey,
)
from cryptography.hazmat.primitives.asymmetric.x448 import X448PrivateKey as X448PrivateKey, X448PublicKey as X448PublicKey
from cryptography.hazmat.primitives.asymmetric.x25519 import (
X25519PrivateKey as X25519PrivateKey,
Expand All @@ -22,11 +30,11 @@ _T = TypeVar("_T")

class UnimplementedOKPCurveKey:
@classmethod
def generate(cls) -> None: ...
def generate(cls): ...
@classmethod
def from_public_bytes(cls, *args) -> None: ...
def from_public_bytes(cls, *args): ...
@classmethod
def from_private_bytes(cls, *args) -> None: ...
def from_private_bytes(cls, *args): ...

ImplementedOkpCurves: Sequence[str]
priv_bytes: Callable[[bytes], X25519PrivateKey] | None
Expand All @@ -47,6 +55,20 @@ class _X448_CURVE(NamedTuple):
pubkey: UnimplementedOKPCurveKey
privkey: UnimplementedOKPCurveKey

class UnimplementedAKPAlgorithm:
@classmethod
def generate(cls): ...
@classmethod
def from_public_bytes(cls, *args): ...
@classmethod
def from_seed_bytes(cls, *args): ...

ImplementedAKPAlgorithms: Sequence[str]

class _AKPAlg(NamedTuple):
pubkey: UnimplementedAKPAlgorithm
privkey: UnimplementedAKPAlgorithm

_JWKKeyTypeSupported: TypeAlias = Literal["oct", "RSA", "EC", "OKP"]
JWKTypesRegistry: dict[_JWKKeyTypeSupported, str]

Expand Down