Skip to content
Merged
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
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.*"
version = "1.5.7"
upstream-repository = "https://github.com/latchset/jwcrypto"
dependencies = ["cryptography"]
1 change: 1 addition & 0 deletions stubs/jwcrypto/jwcrypto/jwa.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from collections.abc import Mapping
from typing import ClassVar

default_max_pbkdf2_iterations: int
default_enforce_hmac_key_length: bool

class JWAAlgorithm(metaclass=ABCMeta):
@property
Expand Down
29 changes: 19 additions & 10 deletions stubs/jwcrypto/jwcrypto/jwe.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from _typeshed import Incomplete
from collections.abc import Mapping, Sequence
from _typeshed import Incomplete, SupportsKeysAndGetItem
from collections.abc import Iterable
from typing import Any
from typing_extensions import Self
from typing_extensions import LiteralString, Self

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

default_max_compressed_size: int
JWEHeaderRegistry: Mapping[str, JWSEHeaderParameter]
default_allowed_algs: Sequence[str]
default_max_plaintext_size: int

JWEHeaderRegistry: dict[LiteralString, JWSEHeaderParameter]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was deliberately typed as Mapping rather than dict before to reflect the fact that you're probably not really meant to mutate it? I don't feel strongly, though

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but that would need at least a comment. And I'm not sure why you would need to prevent that. On the other hand, these are not marked as Final, so "readonly", but not Final seems incomplete in any case.


default_allowed_algs: list[LiteralString]

class InvalidJWEData(JWException):
def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ...
Expand All @@ -23,6 +26,7 @@ class JWE:
objects: dict[str, Any]
plaintext: bytes | None
header_registry: JWSEHeaderRegistry
flattened: bool
cek: Incomplete
decryptlog: list[str] | None
def __init__(
Expand All @@ -31,18 +35,23 @@ class JWE:
protected: str | None = None,
unprotected: str | None = None,
aad: bytes | None = None,
algs: list[str] | None = None,
algs: list[LiteralString] | None = None,
recipient: str | None = None,
header: str | None = None,
header_registry: Mapping[str, JWSEHeaderParameter] | None = None,
header_registry: (
SupportsKeysAndGetItem[LiteralString, JWSEHeaderParameter]
| Iterable[tuple[LiteralString, JWSEHeaderParameter]]
| None
) = None,
flattened: bool = True,
) -> None: ...
@property
def allowed_algs(self) -> list[str]: ...
def allowed_algs(self) -> list[LiteralString]: ...
@allowed_algs.setter
def allowed_algs(self, algs: list[str]) -> None: ...
def allowed_algs(self, algs: list[LiteralString]) -> None: ...
def add_recipient(self, key: JWK, header: dict[str, Any] | str | None = None) -> None: ...
def serialize(self, compact: bool = False) -> str: ...
def decrypt(self, key: JWK | JWKSet) -> None: ...
def decrypt(self, key: JWK | JWKSet, max_plaintext: int = 0) -> None: ...
def deserialize(self, raw_jwe: str | bytes, key: JWK | JWKSet | None = None) -> None: ...
@property
def payload(self) -> bytes: ...
Expand Down
13 changes: 7 additions & 6 deletions stubs/jwcrypto/jwcrypto/jwk.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import Unused
from collections.abc import Callable, Sequence
from enum import Enum
from typing import Any, Literal, NamedTuple, TypeVar, overload
from typing_extensions import Self, TypeAlias, deprecated
from typing_extensions import LiteralString, Self, TypeAlias, deprecated

from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec, rsa
Expand Down Expand Up @@ -62,18 +62,18 @@ class JWKParameter(NamedTuple):
required: bool | None
type: ParmType | None

JWKValuesRegistry: dict[str, dict[str, JWKParameter]]
JWKParamsRegistry: dict[str, JWKParameter]
JWKEllipticCurveRegistry: dict[str, str]
JWKValuesRegistry: dict[LiteralString, dict[LiteralString, JWKParameter]]
JWKParamsRegistry: dict[LiteralString, JWKParameter]
JWKEllipticCurveRegistry: dict[LiteralString, str]
_JWKUseSupported: TypeAlias = Literal["sig", "enc"]
JWKUseRegistry: dict[_JWKUseSupported, str]
_JWKOperationSupported: TypeAlias = Literal[
"sign", "verify", "encrypt", "decrypt", "wrapKey", "unwrapKey", "deriveKey", "deriveBits"
]
JWKOperationsRegistry: dict[_JWKOperationSupported, str]
JWKpycaCurveMap: dict[str, str]
JWKpycaCurveMap: dict[LiteralString, LiteralString]
IANANamedInformationHashAlgorithmRegistry: dict[
str,
LiteralString,
hashes.SHA256
| hashes.SHA384
| hashes.SHA512
Expand Down Expand Up @@ -103,6 +103,7 @@ class InvalidJWKOperation(JWException):
class InvalidJWKValue(JWException): ...

class JWK(dict[str, Any]):
unsafe_skip_rsa_key_validation: bool
def __init__(self, **kwargs) -> None: ...
# `kty` and the other keyword arguments are passed as `params` to the called generator
# function. The possible arguments depend on the value of `kty`.
Expand Down
9 changes: 4 additions & 5 deletions stubs/jwcrypto/jwcrypto/jws.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from _typeshed import Incomplete
from collections.abc import Mapping
from typing import Any, Literal
from typing_extensions import Self
from typing_extensions import LiteralString, Self

from jwcrypto.common import JWException, JWSEHeaderParameter
from jwcrypto.jwa import JWAAlgorithm
from jwcrypto.jwk import JWK, JWKSet

JWSHeaderRegistry: Mapping[str, JWSEHeaderParameter]
default_allowed_algs: list[str]
JWSHeaderRegistry: dict[LiteralString, JWSEHeaderParameter]
default_allowed_algs: list[LiteralString]

class InvalidJWSSignature(JWException):
def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ...
Expand Down Expand Up @@ -38,7 +37,7 @@ class JWSCore:
def verify(self, signature: bytes) -> Literal[True]: ...

class JWS:
objects: Incomplete
objects: dict[str, Incomplete]
verifylog: list[str] | None
header_registry: Incomplete
def __init__(self, payload=None, header_registry=None) -> None: ...
Expand Down
5 changes: 2 additions & 3 deletions stubs/jwcrypto/jwcrypto/jwt.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from collections.abc import Mapping
from typing import Any, SupportsInt
from typing_extensions import deprecated
from typing_extensions import LiteralString, deprecated

from jwcrypto.common import JWException, JWKeyNotFound
from jwcrypto.jwk import JWK, JWKSet

JWTClaimsRegistry: Mapping[str, str]
JWTClaimsRegistry: dict[LiteralString, str]
JWT_expect_type: bool

class JWTExpired(JWException):
Expand Down
3 changes: 3 additions & 0 deletions stubs/jwcrypto/jwcrypto/version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Final

__version__: Final[str]