From 04653c906f873ca69a14408c4c1d4f0520a261bc Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 13 Jul 2021 12:36:59 +0200 Subject: [PATCH] Remove PyJWT Closes: #4856 --- stubs/PyJWT/@tests/stubtest_allowlist.txt | 11 --- stubs/PyJWT/METADATA.toml | 3 - stubs/PyJWT/jwt/__init__.pyi | 49 ---------- stubs/PyJWT/jwt/algorithms.pyi | 93 ------------------- stubs/PyJWT/jwt/contrib/__init__.pyi | 0 .../PyJWT/jwt/contrib/algorithms/__init__.pyi | 0 .../PyJWT/jwt/contrib/algorithms/py_ecdsa.pyi | 10 -- .../PyJWT/jwt/contrib/algorithms/pycrypto.pyi | 10 -- 8 files changed, 176 deletions(-) delete mode 100644 stubs/PyJWT/@tests/stubtest_allowlist.txt delete mode 100644 stubs/PyJWT/METADATA.toml delete mode 100644 stubs/PyJWT/jwt/__init__.pyi delete mode 100644 stubs/PyJWT/jwt/algorithms.pyi delete mode 100644 stubs/PyJWT/jwt/contrib/__init__.pyi delete mode 100644 stubs/PyJWT/jwt/contrib/algorithms/__init__.pyi delete mode 100644 stubs/PyJWT/jwt/contrib/algorithms/py_ecdsa.pyi delete mode 100644 stubs/PyJWT/jwt/contrib/algorithms/pycrypto.pyi diff --git a/stubs/PyJWT/@tests/stubtest_allowlist.txt b/stubs/PyJWT/@tests/stubtest_allowlist.txt deleted file mode 100644 index a7f07d20dd6e..000000000000 --- a/stubs/PyJWT/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,11 +0,0 @@ -jwt.InvalidKeyError -jwt.MissingRequiredClaimError.__init__ -jwt.algorithms.ECAlgorithm -jwt.algorithms.Ed25519Algorithm -jwt.algorithms.HMACAlgorithm.SHA256 -jwt.algorithms.HMACAlgorithm.SHA384 -jwt.algorithms.HMACAlgorithm.SHA512 -jwt.algorithms.RSAAlgorithm -jwt.algorithms.RSAPSSAlgorithm -jwt.contrib.algorithms.py_ecdsa -jwt.contrib.algorithms.pycrypto diff --git a/stubs/PyJWT/METADATA.toml b/stubs/PyJWT/METADATA.toml deleted file mode 100644 index e5bcb1a2129c..000000000000 --- a/stubs/PyJWT/METADATA.toml +++ /dev/null @@ -1,3 +0,0 @@ -version = "1.7" -requires = ["types-cryptography"] -obsolete_since = "2.0.0" diff --git a/stubs/PyJWT/jwt/__init__.pyi b/stubs/PyJWT/jwt/__init__.pyi deleted file mode 100644 index d2b45a2de6ce..000000000000 --- a/stubs/PyJWT/jwt/__init__.pyi +++ /dev/null @@ -1,49 +0,0 @@ -from typing import Any, Dict, Mapping, Optional, Union - -from cryptography.hazmat.primitives.asymmetric import rsa - -from . import algorithms - -def decode( - jwt: Union[str, bytes], - key: Union[str, bytes, rsa.RSAPublicKey, rsa.RSAPrivateKey] = ..., - verify: bool = ..., - algorithms: Optional[Any] = ..., - options: Optional[Mapping[Any, Any]] = ..., - **kwargs: Any, -) -> Dict[str, Any]: ... -def encode( - payload: Mapping[str, Any], - key: Union[str, bytes, rsa.RSAPublicKey, rsa.RSAPrivateKey], - algorithm: str = ..., - headers: Optional[Mapping[str, Any]] = ..., - json_encoder: Optional[Any] = ..., -) -> bytes: ... -def register_algorithm(alg_id: str, alg_obj: algorithms.Algorithm[Any]) -> None: ... -def unregister_algorithm(alg_id: str) -> None: ... - -class PyJWTError(Exception): ... -class InvalidTokenError(PyJWTError): ... -class DecodeError(InvalidTokenError): ... -class ExpiredSignatureError(InvalidTokenError): ... -class InvalidAudienceError(InvalidTokenError): ... -class InvalidIssuerError(InvalidTokenError): ... -class InvalidIssuedAtError(InvalidTokenError): ... -class ImmatureSignatureError(InvalidTokenError): ... -class InvalidKeyError(PyJWTError): ... -class InvalidAlgorithmError(InvalidTokenError): ... -class MissingRequiredClaimError(InvalidTokenError): ... -class InvalidSignatureError(DecodeError): ... - -# Compatibility aliases (deprecated) -ExpiredSignature = ExpiredSignatureError -InvalidAudience = InvalidAudienceError -InvalidIssuer = InvalidIssuerError - -# These aren't actually documented, but the package -# exports them in __init__.py, so we should at least -# make sure that mypy doesn't raise spurious errors -# if they're used. -get_unverified_header: Any -PyJWT: Any -PyJWS: Any diff --git a/stubs/PyJWT/jwt/algorithms.pyi b/stubs/PyJWT/jwt/algorithms.pyi deleted file mode 100644 index cb875074e2fe..000000000000 --- a/stubs/PyJWT/jwt/algorithms.pyi +++ /dev/null @@ -1,93 +0,0 @@ -from hashlib import _Hash -from typing import Any, ClassVar, Dict, Generic, Optional, Set, TypeVar, Union - -from cryptography.hazmat.primitives import hashes -from cryptography.hazmat.primitives.asymmetric.ec import ( - EllipticCurvePrivateKey, - EllipticCurvePrivateKeyWithSerialization, - EllipticCurvePublicKey, - EllipticCurvePublicKeyWithSerialization, -) -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey -from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey -from cryptography.hazmat.primitives.asymmetric.utils import Prehashed -from cryptography.hazmat.primitives.hashes import HashAlgorithm - -requires_cryptography = Set[str] - -def get_default_algorithms() -> Dict[str, Algorithm[Any]]: ... - -_K = TypeVar("_K") - -class Algorithm(Generic[_K]): - def prepare_key(self, key: _K) -> _K: ... - def sign(self, msg: bytes, key: _K) -> bytes: ... - def verify(self, msg: bytes, key: _K, sig: bytes) -> bool: ... - @staticmethod - def to_jwk(key_obj: _K) -> str: ... - @staticmethod - def from_jwk(jwk: str) -> _K: ... - -class NoneAlgorithm(Algorithm[None]): - def prepare_key(self, key: Optional[str]) -> None: ... - -class _HashAlg: - def __call__(self, arg: Union[bytes, bytearray, memoryview] = ...) -> _Hash: ... - -class HMACAlgorithm(Algorithm[bytes]): - SHA256: ClassVar[_HashAlg] - SHA384: ClassVar[_HashAlg] - SHA512: ClassVar[_HashAlg] - hash_alg: _HashAlg - def __init__(self, hash_alg: _HashAlg) -> None: ... - def prepare_key(self, key: Union[str, bytes]) -> bytes: ... - @staticmethod - def to_jwk(key_obj: Union[str, bytes]) -> str: ... - @staticmethod - def from_jwk(jwk: Union[str, bytes]) -> bytes: ... - -# Only defined if cryptography is installed. -class RSAAlgorithm(Algorithm[Any]): - SHA256: ClassVar[hashes.SHA256] - SHA384: ClassVar[hashes.SHA384] - SHA512: ClassVar[hashes.SHA512] - hash_alg: Union[HashAlgorithm, Prehashed] - def __init__(self, hash_alg: Union[HashAlgorithm, Prehashed]) -> None: ... - def prepare_key(self, key: Union[bytes, str, RSAPrivateKey, RSAPublicKey]) -> Union[RSAPrivateKey, RSAPublicKey]: ... - @staticmethod - def to_jwk(key_obj: Any) -> str: ... - @staticmethod - def from_jwk(jwk: Union[str, bytes, Dict[str, Any]]) -> Union[RSAPrivateKey, RSAPublicKey]: ... - def sign(self, msg: bytes, key: RSAPrivateKey) -> bytes: ... - def verify(self, msg: bytes, key: RSAPublicKey, sig: bytes) -> bool: ... - -# Only defined if cryptography is installed. -class ECAlgorithm(Algorithm[Any]): - SHA256: ClassVar[hashes.SHA256] - SHA384: ClassVar[hashes.SHA384] - SHA512: ClassVar[hashes.SHA512] - hash_alg: Union[HashAlgorithm, Prehashed] - def __init__(self, hash_alg: Union[HashAlgorithm, Prehashed]) -> None: ... - def prepare_key( - self, key: Union[bytes, str, EllipticCurvePrivateKey, EllipticCurvePublicKey] - ) -> Union[EllipticCurvePrivateKey, EllipticCurvePublicKey]: ... - @staticmethod - def to_jwk(key_obj: Union[EllipticCurvePrivateKeyWithSerialization, EllipticCurvePublicKeyWithSerialization]) -> str: ... - @staticmethod - def from_jwk(jwk: Union[str, bytes]) -> Union[EllipticCurvePrivateKey, EllipticCurvePublicKey]: ... - def sign(self, msg: bytes, key: EllipticCurvePrivateKey) -> bytes: ... - def verify(self, msg: bytes, key: EllipticCurvePublicKey, sig: bytes) -> bool: ... - -# Only defined if cryptography is installed. Types should be tightened when -# cryptography gets type hints. -# See https://github.com/python/typeshed/issues/2542 -class RSAPSSAlgorithm(RSAAlgorithm): - def sign(self, msg: bytes, key: Any) -> bytes: ... - def verify(self, msg: bytes, key: Any, sig: bytes) -> bool: ... - -# Only defined if cryptography is installed. -class Ed25519Algorithm(Algorithm[Any]): - def __init__(self, **kwargs: Any) -> None: ... - def prepare_key(self, key: Union[str, bytes, Ed25519PrivateKey, Ed25519PublicKey]) -> Any: ... - def sign(self, msg: Union[str, bytes], key: Ed25519PrivateKey) -> bytes: ... - def verify(self, msg: Union[str, bytes], key: Ed25519PublicKey, sig: Union[str, bytes]) -> bool: ... diff --git a/stubs/PyJWT/jwt/contrib/__init__.pyi b/stubs/PyJWT/jwt/contrib/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/stubs/PyJWT/jwt/contrib/algorithms/__init__.pyi b/stubs/PyJWT/jwt/contrib/algorithms/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/stubs/PyJWT/jwt/contrib/algorithms/py_ecdsa.pyi b/stubs/PyJWT/jwt/contrib/algorithms/py_ecdsa.pyi deleted file mode 100644 index 0f63de0a6cd0..000000000000 --- a/stubs/PyJWT/jwt/contrib/algorithms/py_ecdsa.pyi +++ /dev/null @@ -1,10 +0,0 @@ -import hashlib -from typing import Any - -from jwt.algorithms import Algorithm - -class ECAlgorithm(Algorithm[Any]): - SHA256: hashlib._Hash - SHA384: hashlib._Hash - SHA512: hashlib._Hash - def __init__(self, hash_alg: hashlib._Hash) -> None: ... diff --git a/stubs/PyJWT/jwt/contrib/algorithms/pycrypto.pyi b/stubs/PyJWT/jwt/contrib/algorithms/pycrypto.pyi deleted file mode 100644 index 077684c67734..000000000000 --- a/stubs/PyJWT/jwt/contrib/algorithms/pycrypto.pyi +++ /dev/null @@ -1,10 +0,0 @@ -import hashlib -from typing import Any - -from jwt.algorithms import Algorithm - -class RSAAlgorithm(Algorithm[Any]): - SHA256: hashlib._Hash - SHA384: hashlib._Hash - SHA512: hashlib._Hash - def __init__(self, hash_alg: hashlib._Hash) -> None: ...