Skip to content

Commit 4ea569a

Browse files
authored
[jwcrypto] Update to 1.5.7 (#15633)
* Replace some ABCs with concrete types or protocols. * Use `LiteralString` in some instances.
1 parent 7483613 commit 4ea569a

File tree

7 files changed

+37
-25
lines changed

7 files changed

+37
-25
lines changed

stubs/jwcrypto/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version = "1.5.*"
1+
version = "1.5.7"
22
upstream-repository = "https://github.com/latchset/jwcrypto"
33
dependencies = ["cryptography"]

stubs/jwcrypto/jwcrypto/jwa.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from collections.abc import Mapping
33
from typing import ClassVar
44

55
default_max_pbkdf2_iterations: int
6+
default_enforce_hmac_key_length: bool
67

78
class JWAAlgorithm(metaclass=ABCMeta):
89
@property

stubs/jwcrypto/jwcrypto/jwe.pyi

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
from _typeshed import Incomplete
2-
from collections.abc import Mapping, Sequence
1+
from _typeshed import Incomplete, SupportsKeysAndGetItem
2+
from collections.abc import Iterable
33
from typing import Any
4-
from typing_extensions import Self
4+
from typing_extensions import LiteralString, Self
55

66
from jwcrypto import common
77
from jwcrypto.common import JWException, JWSEHeaderParameter, JWSEHeaderRegistry
88
from jwcrypto.jwk import JWK, JWKSet
99

1010
default_max_compressed_size: int
11-
JWEHeaderRegistry: Mapping[str, JWSEHeaderParameter]
12-
default_allowed_algs: Sequence[str]
11+
default_max_plaintext_size: int
12+
13+
JWEHeaderRegistry: dict[LiteralString, JWSEHeaderParameter]
14+
15+
default_allowed_algs: list[LiteralString]
1316

1417
class InvalidJWEData(JWException):
1518
def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ...
@@ -23,6 +26,7 @@ class JWE:
2326
objects: dict[str, Any]
2427
plaintext: bytes | None
2528
header_registry: JWSEHeaderRegistry
29+
flattened: bool
2630
cek: Incomplete
2731
decryptlog: list[str] | None
2832
def __init__(
@@ -31,18 +35,23 @@ class JWE:
3135
protected: str | None = None,
3236
unprotected: str | None = None,
3337
aad: bytes | None = None,
34-
algs: list[str] | None = None,
38+
algs: list[LiteralString] | None = None,
3539
recipient: str | None = None,
3640
header: str | None = None,
37-
header_registry: Mapping[str, JWSEHeaderParameter] | None = None,
41+
header_registry: (
42+
SupportsKeysAndGetItem[LiteralString, JWSEHeaderParameter]
43+
| Iterable[tuple[LiteralString, JWSEHeaderParameter]]
44+
| None
45+
) = None,
46+
flattened: bool = True,
3847
) -> None: ...
3948
@property
40-
def allowed_algs(self) -> list[str]: ...
49+
def allowed_algs(self) -> list[LiteralString]: ...
4150
@allowed_algs.setter
42-
def allowed_algs(self, algs: list[str]) -> None: ...
51+
def allowed_algs(self, algs: list[LiteralString]) -> None: ...
4352
def add_recipient(self, key: JWK, header: dict[str, Any] | str | None = None) -> None: ...
4453
def serialize(self, compact: bool = False) -> str: ...
45-
def decrypt(self, key: JWK | JWKSet) -> None: ...
54+
def decrypt(self, key: JWK | JWKSet, max_plaintext: int = 0) -> None: ...
4655
def deserialize(self, raw_jwe: str | bytes, key: JWK | JWKSet | None = None) -> None: ...
4756
@property
4857
def payload(self) -> bytes: ...

stubs/jwcrypto/jwcrypto/jwk.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from _typeshed import Unused
22
from collections.abc import Callable, Sequence
33
from enum import Enum
44
from typing import Any, Literal, NamedTuple, TypeVar, overload
5-
from typing_extensions import Self, TypeAlias, deprecated
5+
from typing_extensions import LiteralString, Self, TypeAlias, deprecated
66

77
from cryptography.hazmat.primitives import hashes
88
from cryptography.hazmat.primitives.asymmetric import ec, rsa
@@ -62,18 +62,18 @@ class JWKParameter(NamedTuple):
6262
required: bool | None
6363
type: ParmType | None
6464

65-
JWKValuesRegistry: dict[str, dict[str, JWKParameter]]
66-
JWKParamsRegistry: dict[str, JWKParameter]
67-
JWKEllipticCurveRegistry: dict[str, str]
65+
JWKValuesRegistry: dict[LiteralString, dict[LiteralString, JWKParameter]]
66+
JWKParamsRegistry: dict[LiteralString, JWKParameter]
67+
JWKEllipticCurveRegistry: dict[LiteralString, str]
6868
_JWKUseSupported: TypeAlias = Literal["sig", "enc"]
6969
JWKUseRegistry: dict[_JWKUseSupported, str]
7070
_JWKOperationSupported: TypeAlias = Literal[
7171
"sign", "verify", "encrypt", "decrypt", "wrapKey", "unwrapKey", "deriveKey", "deriveBits"
7272
]
7373
JWKOperationsRegistry: dict[_JWKOperationSupported, str]
74-
JWKpycaCurveMap: dict[str, str]
74+
JWKpycaCurveMap: dict[LiteralString, LiteralString]
7575
IANANamedInformationHashAlgorithmRegistry: dict[
76-
str,
76+
LiteralString,
7777
hashes.SHA256
7878
| hashes.SHA384
7979
| hashes.SHA512
@@ -103,6 +103,7 @@ class InvalidJWKOperation(JWException):
103103
class InvalidJWKValue(JWException): ...
104104

105105
class JWK(dict[str, Any]):
106+
unsafe_skip_rsa_key_validation: bool
106107
def __init__(self, **kwargs) -> None: ...
107108
# `kty` and the other keyword arguments are passed as `params` to the called generator
108109
# function. The possible arguments depend on the value of `kty`.

stubs/jwcrypto/jwcrypto/jws.pyi

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from _typeshed import Incomplete
2-
from collections.abc import Mapping
32
from typing import Any, Literal
4-
from typing_extensions import Self
3+
from typing_extensions import LiteralString, Self
54

65
from jwcrypto.common import JWException, JWSEHeaderParameter
76
from jwcrypto.jwa import JWAAlgorithm
87
from jwcrypto.jwk import JWK, JWKSet
98

10-
JWSHeaderRegistry: Mapping[str, JWSEHeaderParameter]
11-
default_allowed_algs: list[str]
9+
JWSHeaderRegistry: dict[LiteralString, JWSEHeaderParameter]
10+
default_allowed_algs: list[LiteralString]
1211

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

4039
class JWS:
41-
objects: Incomplete
40+
objects: dict[str, Incomplete]
4241
verifylog: list[str] | None
4342
header_registry: Incomplete
4443
def __init__(self, payload=None, header_registry=None) -> None: ...

stubs/jwcrypto/jwcrypto/jwt.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from collections.abc import Mapping
21
from typing import Any, SupportsInt
3-
from typing_extensions import deprecated
2+
from typing_extensions import LiteralString, deprecated
43

54
from jwcrypto.common import JWException, JWKeyNotFound
65
from jwcrypto.jwk import JWK, JWKSet
76

8-
JWTClaimsRegistry: Mapping[str, str]
7+
JWTClaimsRegistry: dict[LiteralString, str]
98
JWT_expect_type: bool
109

1110
class JWTExpired(JWException):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Final
2+
3+
__version__: Final[str]

0 commit comments

Comments
 (0)