From 55384343dd4890c7d6b82dd5915e8d201c92a7a3 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Thu, 1 Jan 2026 17:53:34 +0400 Subject: [PATCH] [Authlib] Annotate more --- stubs/Authlib/@tests/stubtest_allowlist.txt | 17 +++++ stubs/Authlib/authlib/common/urls.pyi | 2 +- .../requests_client/oauth2_session.pyi | 2 +- .../authlib/jose/drafts/_jwe_algorithms.pyi | 10 +-- .../jose/drafts/_jwe_enc_cryptodome.pyi | 4 +- stubs/Authlib/authlib/jose/rfc7515/jws.pyi | 18 +++-- stubs/Authlib/authlib/jose/rfc7515/models.pyi | 6 +- stubs/Authlib/authlib/jose/rfc7516/jwe.pyi | 32 +++++---- stubs/Authlib/authlib/jose/rfc7516/models.pyi | 16 ++--- .../authlib/jose/rfc7517/asymmetric_key.pyi | 24 +++++-- .../Authlib/authlib/jose/rfc7517/base_key.pyi | 2 +- stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi | 5 +- .../Authlib/authlib/jose/rfc7518/jwe_algs.pyi | 21 +++--- .../Authlib/authlib/jose/rfc7518/jwe_encs.pyi | 22 +++---- .../Authlib/authlib/jose/rfc7518/jws_algs.pyi | 66 ++++++++++--------- .../Authlib/authlib/jose/rfc7518/oct_key.pyi | 2 +- .../Authlib/authlib/jose/rfc7518/rsa_key.pyi | 3 +- .../Authlib/authlib/jose/rfc8037/okp_key.pyi | 2 +- stubs/Authlib/authlib/oauth1/client.pyi | 14 ++-- .../oauth1/rfc5849/authorization_server.pyi | 4 +- .../authlib/oauth1/rfc5849/base_server.pyi | 10 +-- .../authlib/oauth1/rfc5849/client_auth.pyi | 12 ++-- .../Authlib/authlib/oauth1/rfc5849/models.pyi | 2 +- .../authlib/oauth1/rfc5849/wrapper.pyi | 12 ++-- stubs/Authlib/authlib/oauth2/auth.pyi | 18 ++--- stubs/Authlib/authlib/oauth2/base.pyi | 7 +- stubs/Authlib/authlib/oauth2/client.pyi | 19 ++++-- .../authlib/oauth2/rfc6750/parameters.pyi | 6 +- .../authlib/oauth2/rfc9101/discovery.pyi | 4 +- 29 files changed, 213 insertions(+), 149 deletions(-) diff --git a/stubs/Authlib/@tests/stubtest_allowlist.txt b/stubs/Authlib/@tests/stubtest_allowlist.txt index f6fa5a1738fa..a3df5800da40 100644 --- a/stubs/Authlib/@tests/stubtest_allowlist.txt +++ b/stubs/Authlib/@tests/stubtest_allowlist.txt @@ -10,6 +10,9 @@ authlib.jose.rfc7518.AESAlgorithm.description authlib.jose.rfc7518.AESAlgorithm.name authlib.jose.rfc7518.ECDHESAlgorithm.description authlib.jose.rfc7518.ECDHESAlgorithm.name +authlib.jose.rfc7518.CBCHS2EncAlgorithm.CEK_SIZE +authlib.jose.rfc7518.CBCHS2EncAlgorithm.description +authlib.jose.rfc7518.CBCHS2EncAlgorithm.name authlib.jose.rfc7518.jwe_algs.AESAlgorithm.description authlib.jose.rfc7518.jwe_algs.AESAlgorithm.name authlib.jose.rfc7518.jwe_algs.AESGCMAlgorithm.description @@ -18,6 +21,20 @@ authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.description authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.name authlib.jose.rfc7518.jwe_algs.RSAAlgorithm.description authlib.jose.rfc7518.jwe_algs.RSAAlgorithm.name +authlib.jose.rfc7518.jwe_encs.CBCHS2EncAlgorithm.CEK_SIZE +authlib.jose.rfc7518.jwe_encs.CBCHS2EncAlgorithm.description +authlib.jose.rfc7518.jwe_encs.CBCHS2EncAlgorithm.name +authlib.jose.rfc7518.jwe_encs.GCMEncAlgorithm.CEK_SIZE +authlib.jose.rfc7518.jwe_encs.GCMEncAlgorithm.description +authlib.jose.rfc7518.jwe_encs.GCMEncAlgorithm.name +authlib.jose.rfc7518.jws_algs.ECAlgorithm.description +authlib.jose.rfc7518.jws_algs.ECAlgorithm.name +authlib.jose.rfc7518.jws_algs.HMACAlgorithm.description +authlib.jose.rfc7518.jws_algs.HMACAlgorithm.name +authlib.jose.rfc7518.jws_algs.RSAAlgorithm.description +authlib.jose.rfc7518.jws_algs.RSAAlgorithm.name +authlib.jose.rfc7518.jws_algs.RSAPSSAlgorithm.description +authlib.jose.rfc7518.jws_algs.RSAPSSAlgorithm.name # Methods whose *args and **kwargs arguments are added dynamically due to the @hooked decorator: authlib.oauth2.rfc6749.AuthorizationCodeGrant.create_token_response diff --git a/stubs/Authlib/authlib/common/urls.pyi b/stubs/Authlib/authlib/common/urls.pyi index e4180eeb8647..a07c2112c9be 100644 --- a/stubs/Authlib/authlib/common/urls.pyi +++ b/stubs/Authlib/authlib/common/urls.pyi @@ -11,7 +11,7 @@ _ExplodedQueryString: TypeAlias = list[tuple[str, str]] def url_encode(params: _ExplodedQueryString) -> str: ... def url_decode(query: str) -> _ExplodedQueryString: ... def add_params_to_qs(query: str, params: _ExplodedQueryString) -> str: ... -def add_params_to_uri(uri: str, params: _ExplodedQueryString, fragment: bool = False): ... +def add_params_to_uri(uri: str, params: _ExplodedQueryString, fragment: bool = False) -> str: ... def quote(s: str, safe: bytes = b"/") -> str: ... def unquote(s: str | bytes) -> str: ... def quote_url(s: str) -> str: ... diff --git a/stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi b/stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi index 63cae01d2b0a..f358acc47ca5 100644 --- a/stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi +++ b/stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi @@ -21,7 +21,7 @@ class OAuth2Session(OAuth2Client): client_auth_class = OAuth2ClientAuth token_auth_class = OAuth2Auth oauth_error_class = OAuthError # type: ignore[assignment] - SESSION_REQUEST_PARAMS: tuple[str, ...] + SESSION_REQUEST_PARAMS: tuple[str, ...] # type: ignore[assignment] default_timeout: Incomplete def __init__( self, diff --git a/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi b/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi index 92784727b9aa..8e6b423d1bcb 100644 --- a/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi +++ b/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi @@ -3,16 +3,18 @@ from collections.abc import Iterable from typing import ClassVar, Final from authlib.jose.rfc7516 import JWEAlgorithmWithTagAwareKeyAgreement +from authlib.jose.rfc7518 import AESAlgorithm, ECKey +from authlib.jose.rfc8037 import OKPKey class ECDH1PUAlgorithm(JWEAlgorithmWithTagAwareKeyAgreement): EXTRA_HEADERS: ClassVar[Iterable[str]] - ALLOWED_KEY_CLS: Incomplete + ALLOWED_KEY_CLS: tuple[type, ...] name: str description: str key_size: Incomplete - aeskw: Incomplete + aeskw: AESAlgorithm def __init__(self, key_size=None) -> None: ... - def prepare_key(self, raw_data): ... + def prepare_key(self, raw_data) -> ECKey | OKPKey: ... def generate_preset(self, enc_alg, key) -> dict[str, Incomplete]: ... def compute_shared_key(self, shared_key_e, shared_key_s): ... def compute_fixed_info(self, headers, bit_size, tag) -> bytes: ... @@ -22,7 +24,7 @@ class ECDH1PUAlgorithm(JWEAlgorithmWithTagAwareKeyAgreement): self, recipient_key, sender_static_pubkey, sender_ephemeral_pubkey, headers, bit_size, tag ) -> bytes: ... def generate_keys_and_prepare_headers(self, enc_alg, key, sender_key, preset=None) -> dict[str, Incomplete]: ... - def agree_upon_key_and_wrap_cek(self, enc_alg, headers, key, sender_key, epk, cek, tag): ... + def agree_upon_key_and_wrap_cek(self, enc_alg, headers, key, sender_key, epk, cek, tag) -> dict[str, Incomplete]: ... def wrap(self, enc_alg, headers, key, sender_key, preset=None) -> dict[str, Incomplete]: ... def unwrap(self, enc_alg, ek, headers, key, sender_key, tag=None) -> bytes: ... diff --git a/stubs/Authlib/authlib/jose/drafts/_jwe_enc_cryptodome.pyi b/stubs/Authlib/authlib/jose/drafts/_jwe_enc_cryptodome.pyi index 69fea45b85c7..594739d28a22 100644 --- a/stubs/Authlib/authlib/jose/drafts/_jwe_enc_cryptodome.pyi +++ b/stubs/Authlib/authlib/jose/drafts/_jwe_enc_cryptodome.pyi @@ -9,5 +9,5 @@ class XC20PEncAlgorithm(JWEEncAlgorithm): key_size: Incomplete CEK_SIZE: Incomplete def __init__(self, key_size) -> None: ... - def encrypt(self, msg, aad, iv, key): ... - def decrypt(self, ciphertext, aad, iv, tag, key): ... + def encrypt(self, msg, aad, iv, key) -> tuple[bytes, bytes]: ... + def decrypt(self, ciphertext, aad, iv, tag, key) -> bytes: ... diff --git a/stubs/Authlib/authlib/jose/rfc7515/jws.pyi b/stubs/Authlib/authlib/jose/rfc7515/jws.pyi index 7868d7fceb7a..0de9cb372359 100644 --- a/stubs/Authlib/authlib/jose/rfc7515/jws.pyi +++ b/stubs/Authlib/authlib/jose/rfc7515/jws.pyi @@ -1,17 +1,21 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, ReadableBuffer +from collections.abc import Iterable +from typing import SupportsBytes, SupportsIndex -from .models import JWSObject +from .models import JWSAlgorithm, JWSObject class JsonWebSignature: REGISTERED_HEADER_PARAMETER_NAMES: frozenset[str] MAX_CONTENT_LENGTH: int - ALGORITHMS_REGISTRY: dict[str, Incomplete] + ALGORITHMS_REGISTRY: dict[str, JWSAlgorithm] def __init__(self, algorithms=None, private_headers=None) -> None: ... @classmethod - def register_algorithm(cls, algorithm) -> None: ... + def register_algorithm(cls, algorithm: JWSAlgorithm) -> None: ... def serialize_compact(self, protected, payload, key) -> bytes: ... - def deserialize_compact(self, s, key, decode=None) -> JWSObject: ... - def serialize_json(self, header_obj, payload, key): ... + def deserialize_compact( + self, s: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer, key, decode=None + ) -> JWSObject: ... + def serialize_json(self, header_obj, payload, key) -> dict[str, Incomplete]: ... def deserialize_json(self, obj, key, decode=None) -> JWSObject: ... - def serialize(self, header, payload, key): ... + def serialize(self, header, payload, key) -> dict[str, Incomplete] | bytes: ... def deserialize(self, s, key, decode=None) -> JWSObject: ... diff --git a/stubs/Authlib/authlib/jose/rfc7515/models.pyi b/stubs/Authlib/authlib/jose/rfc7515/models.pyi index f1a68a55d49b..e01bdf0e2c94 100644 --- a/stubs/Authlib/authlib/jose/rfc7515/models.pyi +++ b/stubs/Authlib/authlib/jose/rfc7515/models.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from typing_extensions import Self class JWSAlgorithm: - name: Incomplete - description: Incomplete + name: str | None + description: str | None algorithm_type: str algorithm_location: str def prepare_key(self, raw_data): ... @@ -20,7 +20,7 @@ class JWSHeader(dict[str, object]): class JWSObject(dict[str, object]): header: Incomplete payload: Incomplete - type: Incomplete + type: str def __init__(self, header, payload, type: str = "compact") -> None: ... @property def headers(self): ... diff --git a/stubs/Authlib/authlib/jose/rfc7516/jwe.pyi b/stubs/Authlib/authlib/jose/rfc7516/jwe.pyi index e7b3d9a068d9..c0783698a279 100644 --- a/stubs/Authlib/authlib/jose/rfc7516/jwe.pyi +++ b/stubs/Authlib/authlib/jose/rfc7516/jwe.pyi @@ -1,24 +1,34 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, ReadableBuffer from collections import OrderedDict +from collections.abc import Iterable +from typing import SupportsBytes, SupportsIndex + +from .models import JWEAlgorithmBase, JWEEncAlgorithm, JWEZipAlgorithm class JsonWebEncryption: REGISTERED_HEADER_PARAMETER_NAMES: frozenset[str] - ALG_REGISTRY: dict[Incomplete, Incomplete] - ENC_REGISTRY: dict[Incomplete, Incomplete] - ZIP_REGISTRY: dict[Incomplete, Incomplete] + ALG_REGISTRY: dict[str, JWEAlgorithmBase] + ENC_REGISTRY: dict[str, JWEEncAlgorithm] + ZIP_REGISTRY: dict[str, JWEZipAlgorithm] def __init__(self, algorithms=None, private_headers=None) -> None: ... @classmethod - def register_algorithm(cls, algorithm) -> None: ... + def register_algorithm(cls, algorithm: JWEAlgorithmBase | JWEEncAlgorithm | JWEZipAlgorithm) -> None: ... def serialize_compact(self, protected, payload, key, sender_key=None) -> bytes: ... def serialize_json(self, header_obj, payload, keys, sender_key=None) -> OrderedDict[Incomplete, Incomplete]: ... - def serialize(self, header, payload, key, sender_key=None): ... - def deserialize_compact(self, s, key, decode=None, sender_key=None): ... + def serialize(self, header, payload, key, sender_key=None) -> OrderedDict[Incomplete, Incomplete] | bytes: ... + def deserialize_compact( + self, + s: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer, + key, + decode=None, + sender_key=None, + ) -> dict[str, Incomplete]: ... def deserialize_json(self, obj, key, decode=None, sender_key=None) -> dict[str, Incomplete]: ... - def deserialize(self, obj, key, decode=None, sender_key=None): ... + def deserialize(self, obj, key, decode=None, sender_key=None) -> dict[str, Incomplete]: ... @staticmethod def parse_json(obj) -> dict[Incomplete, Incomplete]: ... - def get_header_alg(self, header): ... - def get_header_enc(self, header): ... - def get_header_zip(self, header): ... + def get_header_alg(self, header) -> JWEAlgorithmBase: ... + def get_header_enc(self, header) -> JWEEncAlgorithm: ... + def get_header_zip(self, header) -> JWEZipAlgorithm: ... def prepare_key(alg, header, key): ... diff --git a/stubs/Authlib/authlib/jose/rfc7516/models.pyi b/stubs/Authlib/authlib/jose/rfc7516/models.pyi index b93d5b6c22bd..90727d972fe2 100644 --- a/stubs/Authlib/authlib/jose/rfc7516/models.pyi +++ b/stubs/Authlib/authlib/jose/rfc7516/models.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from abc import ABCMeta -from collections.abc import Iterable +from collections.abc import Iterable, Sized from typing import ClassVar from typing_extensions import Self @@ -28,13 +28,13 @@ class JWEEncAlgorithm: description: str | None algorithm_type: str algorithm_location: str - IV_SIZE: Incomplete - CEK_SIZE: Incomplete - def generate_cek(self): ... - def generate_iv(self): ... - def check_iv(self, iv) -> None: ... - def encrypt(self, msg, aad, iv, key): ... - def decrypt(self, ciphertext, aad, iv, tag, key): ... + IV_SIZE: int | None + CEK_SIZE: int | None + def generate_cek(self) -> bytes: ... + def generate_iv(self) -> bytes: ... + def check_iv(self, iv: Sized) -> None: ... + def encrypt(self, msg, aad, iv, key) -> tuple[bytes, bytes]: ... + def decrypt(self, ciphertext, aad, iv, tag, key) -> bytes: ... class JWEZipAlgorithm: name: Incomplete diff --git a/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi b/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi index 32b792bf6ef6..1361ba23ac48 100644 --- a/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi +++ b/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi @@ -1,5 +1,6 @@ -from _typeshed import Incomplete -from typing import ClassVar +from _typeshed import Incomplete, ReadableBuffer +from collections.abc import Iterable +from typing import ClassVar, Literal, SupportsBytes, SupportsIndex from typing_extensions import Self from authlib.jose.rfc7517 import Key @@ -26,9 +27,22 @@ class AsymmetricKey(Key): def load_public_key(self): ... def as_dict(self, is_private: bool = False, **params) -> dict[Incomplete, Incomplete]: ... def as_key(self, is_private: bool = False): ... - def as_bytes(self, encoding=None, is_private: bool = False, password=None): ... - def as_pem(self, is_private: bool = False, password=None): ... - def as_der(self, is_private: bool = False, password=None): ... + def as_bytes( + self, + encoding: Literal["PEM", "DER"] | None = None, + is_private: bool = False, + password: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer | None = None, + ): ... + def as_pem( + self, + is_private: bool = False, + password: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer | None = None, + ): ... + def as_der( + self, + is_private: bool = False, + password: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer | None = None, + ): ... @classmethod def import_dict_key(cls, raw, options=None) -> Self: ... @classmethod diff --git a/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi b/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi index 414254efe023..0614eacf2a48 100644 --- a/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi +++ b/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi @@ -7,7 +7,7 @@ class Key: PRIVATE_KEY_OPS: ClassVar[list[str]] PUBLIC_KEY_OPS: ClassVar[list[str]] REQUIRED_JSON_FIELDS: ClassVar[list[str]] - options: Incomplete + options: dict[Incomplete, Incomplete] def __init__(self, options=None) -> None: ... @property def tokens(self) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi b/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi index 8a449b235e53..fcfe58ec2c44 100644 --- a/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi +++ b/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from typing import ClassVar from authlib.jose.rfc7517 import AsymmetricKey @@ -6,8 +5,8 @@ from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey class ECKey(AsymmetricKey): kty: str - DSS_CURVES: Incomplete - CURVES_DSS: Incomplete + DSS_CURVES: dict[str, type] + CURVES_DSS: dict[property, str] REQUIRED_JSON_FIELDS: ClassVar[list[str]] PUBLIC_KEY_FIELDS = REQUIRED_JSON_FIELDS PRIVATE_KEY_FIELDS: ClassVar[list[str]] diff --git a/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi b/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi index ea1c2d897d46..d1f2e06c419a 100644 --- a/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi +++ b/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi @@ -4,6 +4,7 @@ from typing import ClassVar, Final, SupportsBytes, SupportsIndex from authlib.jose.rfc7516 import JWEAlgorithm +from .ec_key import ECKey from .oct_key import OctKey from .rsa_key import RSAKey @@ -20,7 +21,7 @@ class RSAAlgorithm(JWEAlgorithm): name: str description: str padding: Incomplete - def __init__(self, name, description, pad_fn) -> None: ... + def __init__(self, name: str, description: str, pad_fn) -> None: ... def prepare_key(self, raw_data) -> RSAKey: ... def generate_preset(self, enc_alg, key) -> dict[str, Incomplete]: ... def wrap(self, enc_alg, headers, key, preset=None) -> dict[str, Incomplete]: ... @@ -29,8 +30,8 @@ class RSAAlgorithm(JWEAlgorithm): class AESAlgorithm(JWEAlgorithm): name: str description: str - key_size: Incomplete - def __init__(self, key_size) -> None: ... + key_size: int + def __init__(self, key_size: int) -> None: ... def prepare_key(self, raw_data) -> OctKey: ... def generate_preset(self, enc_alg, key) -> dict[str, Incomplete]: ... def wrap_cek(self, cek, key) -> dict[str, Incomplete]: ... @@ -41,8 +42,8 @@ class AESGCMAlgorithm(JWEAlgorithm): EXTRA_HEADERS: ClassVar[Iterable[str]] name: str description: str - key_size: Incomplete - def __init__(self, key_size) -> None: ... + key_size: int + def __init__(self, key_size: int) -> None: ... def prepare_key(self, raw_data) -> OctKey: ... def generate_preset(self, enc_alg, key) -> dict[str, Incomplete]: ... def wrap(self, enc_alg, headers, key, preset=None) -> dict[str, Incomplete]: ... @@ -53,12 +54,12 @@ class ECDHESAlgorithm(JWEAlgorithm): ALLOWED_KEY_CLS = Incomplete name: str description: str - key_size: Incomplete - aeskw: Incomplete - def __init__(self, key_size=None) -> None: ... - def prepare_key(self, raw_data): ... + key_size: int | None + aeskw: AESAlgorithm + def __init__(self, key_size: int | None = None) -> None: ... + def prepare_key(self, raw_data) -> ECKey: ... def generate_preset(self, enc_alg, key) -> dict[str, Incomplete]: ... - def compute_fixed_info(self, headers, bit_size): ... + def compute_fixed_info(self, headers, bit_size) -> bytes: ... def compute_derived_key(self, shared_key, fixed_info, bit_size) -> bytes: ... def deliver(self, key, pubkey, headers, bit_size) -> bytes: ... def wrap(self, enc_alg, headers, key, preset=None) -> dict[str, Incomplete]: ... diff --git a/stubs/Authlib/authlib/jose/rfc7518/jwe_encs.pyi b/stubs/Authlib/authlib/jose/rfc7518/jwe_encs.pyi index 1f71240e48ae..4fd43557af0f 100644 --- a/stubs/Authlib/authlib/jose/rfc7518/jwe_encs.pyi +++ b/stubs/Authlib/authlib/jose/rfc7518/jwe_encs.pyi @@ -5,23 +5,23 @@ from authlib.jose.rfc7516 import JWEEncAlgorithm class CBCHS2EncAlgorithm(JWEEncAlgorithm): IV_SIZE: int - name: Incomplete - description: Incomplete - key_size: Incomplete - key_len: Incomplete - CEK_SIZE: Incomplete + name: str + description: str + key_size: int + key_len: int + CEK_SIZE: int hash_alg: Incomplete - def __init__(self, key_size, hash_type) -> None: ... + def __init__(self, key_size: int, hash_type: int | str) -> None: ... def encrypt(self, msg, aad, iv, key) -> tuple[bytes, bytes]: ... def decrypt(self, ciphertext, aad, iv, tag, key) -> bytes: ... class GCMEncAlgorithm(JWEEncAlgorithm): IV_SIZE: int - name: Incomplete - description: Incomplete - key_size: Incomplete - CEK_SIZE: Incomplete - def __init__(self, key_size) -> None: ... + name: str + description: str + key_size: int + CEK_SIZE: int + def __init__(self, key_size: int) -> None: ... def encrypt(self, msg, aad, iv, key) -> tuple[bytes, bytes]: ... def decrypt(self, ciphertext, aad, iv, tag, key) -> bytes: ... diff --git a/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi b/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi index 6f0246acead7..72ea74f05396 100644 --- a/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi +++ b/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi @@ -2,61 +2,67 @@ import hashlib from _typeshed import Incomplete from authlib.jose.rfc7515 import JWSAlgorithm +from cryptography.hazmat.primitives import hashes +from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 + +from .ec_key import ECKey +from .oct_key import OctKey +from .rsa_key import RSAKey class NoneAlgorithm(JWSAlgorithm): name: str description: str - def prepare_key(self, raw_data): ... - def sign(self, msg, key): ... + def prepare_key(self, raw_data) -> None: ... + def sign(self, msg, key) -> bytes: ... def verify(self, msg, sig, key) -> bool: ... class HMACAlgorithm(JWSAlgorithm): SHA256 = hashlib.sha256 SHA384 = hashlib.sha384 SHA512 = hashlib.sha512 - name: Incomplete - description: Incomplete + name: str + description: str hash_alg: Incomplete - def __init__(self, sha_type) -> None: ... - def prepare_key(self, raw_data): ... - def sign(self, msg, key): ... + def __init__(self, sha_type: int | str) -> None: ... + def prepare_key(self, raw_data) -> OctKey: ... + def sign(self, msg, key) -> bytes: ... def verify(self, msg, sig, key) -> bool: ... class RSAAlgorithm(JWSAlgorithm): - SHA256: Incomplete - SHA384: Incomplete - SHA512: Incomplete - name: Incomplete - description: Incomplete + SHA256 = hashes.SHA256 + SHA384 = hashes.SHA384 + SHA512 = hashes.SHA512 + name: str + description: str hash_alg: Incomplete - padding: Incomplete - def __init__(self, sha_type) -> None: ... - def prepare_key(self, raw_data): ... + padding: PKCS1v15 + def __init__(self, sha_type: int | str) -> None: ... + def prepare_key(self, raw_data) -> RSAKey: ... def sign(self, msg, key): ... def verify(self, msg, sig, key) -> bool: ... class ECAlgorithm(JWSAlgorithm): - SHA256: Incomplete - SHA384: Incomplete - SHA512: Incomplete - name: Incomplete + SHA256 = hashes.SHA256 + SHA384 = hashes.SHA384 + SHA512 = hashes.SHA512 + name: str curve: Incomplete - description: Incomplete + description: str hash_alg: Incomplete - def __init__(self, name, curve, sha_type) -> None: ... - def prepare_key(self, raw_data): ... - def sign(self, msg, key): ... + def __init__(self, name: str, curve, sha_type: int | str) -> None: ... + def prepare_key(self, raw_data) -> ECKey: ... + def sign(self, msg, key) -> bytes: ... def verify(self, msg, sig, key) -> bool: ... class RSAPSSAlgorithm(JWSAlgorithm): - SHA256: Incomplete - SHA384: Incomplete - SHA512: Incomplete - name: Incomplete - description: Incomplete + SHA256 = hashes.SHA256 + SHA384 = hashes.SHA384 + SHA512 = hashes.SHA512 + name: str + description: str hash_alg: Incomplete - def __init__(self, sha_type) -> None: ... - def prepare_key(self, raw_data): ... + def __init__(self, sha_type: int | str) -> None: ... + def prepare_key(self, raw_data) -> RSAKey: ... def sign(self, msg, key): ... def verify(self, msg, sig, key) -> bool: ... diff --git a/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi b/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi index af1d546b7b69..d4fad5a6571c 100644 --- a/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi +++ b/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi @@ -12,7 +12,7 @@ class OctKey(Key): raw_key: Incomplete def __init__(self, raw_key=None, options=None) -> None: ... @property - def public_only(self): ... + def public_only(self) -> bool: ... def get_op_key(self, operation): ... def load_raw_key(self) -> None: ... def load_dict_key(self) -> None: ... diff --git a/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi b/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi index 18e332c2f8e5..0a15f339f6f7 100644 --- a/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi +++ b/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi @@ -1,3 +1,4 @@ +from collections.abc import Iterable from typing import ClassVar from typing_extensions import Self @@ -21,4 +22,4 @@ class RSAKey(AsymmetricKey): @classmethod def import_dict_key(cls, raw, options=None) -> Self: ... -def has_all_prime_factors(obj) -> bool: ... +def has_all_prime_factors(obj: Iterable[str]) -> bool: ... diff --git a/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi b/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi index 47186b8fdb92..d85297a1bf2a 100644 --- a/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi +++ b/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi @@ -17,7 +17,7 @@ class OKPKey(AsymmetricKey): PUBLIC_KEY_CLS: ClassVar[tuple[type, ...]] PRIVATE_KEY_CLS: ClassVar[tuple[type, ...]] SSH_PUBLIC_PREFIX: ClassVar[bytes] - def exchange_shared_key(self, pubkey) -> bytes: ... + def exchange_shared_key(self, pubkey: X25519PrivateKey | X448PublicKey) -> bytes: ... @staticmethod def get_key_curve(key) -> str | None: ... def load_private_key(self) -> Ed25519PrivateKey | Ed448PrivateKey | X25519PrivateKey | X448PrivateKey: ... diff --git a/stubs/Authlib/authlib/oauth1/client.pyi b/stubs/Authlib/authlib/oauth1/client.pyi index 460ad8ae3e1b..26a40823343c 100644 --- a/stubs/Authlib/authlib/oauth1/client.pyi +++ b/stubs/Authlib/authlib/oauth1/client.pyi @@ -4,9 +4,9 @@ from typing import Any, NoReturn from authlib.oauth1 import ClientAuth class OAuth1Client: - auth_class: type[ClientAuth] = ... + auth_class: type[ClientAuth] session: Incomplete - auth: Incomplete + auth: ClientAuth def __init__( self, session, @@ -28,14 +28,14 @@ class OAuth1Client: @redirect_uri.setter def redirect_uri(self, uri) -> None: ... @property - def token(self): ... + def token(self) -> dict[Incomplete, Incomplete]: ... @token.setter def token(self, token) -> None: ... - def create_authorization_url(self, url, request_token=None, **kwargs): ... + def create_authorization_url(self, url, request_token=None, **kwargs) -> str: ... def fetch_request_token(self, url: str, **kwargs) -> dict[str, Any]: ... def fetch_access_token(self, url, verifier=None, **kwargs): ... - def parse_authorization_response(self, url): ... - def parse_response_token(self, status_code, text): ... + def parse_authorization_response(self, url: str) -> dict[str, str]: ... + def parse_response_token(self, status_code: int, text: str): ... @staticmethod - def handle_error(error_type, error_description) -> NoReturn: ... + def handle_error(error_type: str, error_description: str) -> NoReturn: ... def __del__(self) -> None: ... diff --git a/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi b/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi index 5b124285c50b..e77bd50c9227 100644 --- a/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi +++ b/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi @@ -1,9 +1,7 @@ -from _typeshed import Incomplete - from authlib.oauth1.rfc5849.base_server import BaseServer class AuthorizationServer(BaseServer): - TOKEN_RESPONSE_HEADER: Incomplete + TOKEN_RESPONSE_HEADER: list[tuple[str, str]] TEMPORARY_CREDENTIALS_METHOD: str def create_oauth1_request(self, request): ... def handle_response(self, status_code, payload, headers): ... diff --git a/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi b/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi index 2508c953034e..ac2c014e5144 100644 --- a/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi +++ b/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi @@ -1,12 +1,12 @@ -from _typeshed import Incomplete +from collections.abc import Callable class BaseServer: - SIGNATURE_METHODS: Incomplete - SUPPORTED_SIGNATURE_METHODS: Incomplete + SIGNATURE_METHODS: dict[str, Callable[..., bool]] + SUPPORTED_SIGNATURE_METHODS: list[str] EXPIRY_TIME: int @classmethod - def register_signature_method(cls, name, verify) -> None: ... + def register_signature_method(cls, name: str, verify: Callable[..., bool]) -> None: ... def validate_timestamp_and_nonce(self, request) -> None: ... def validate_oauth_signature(self, request) -> None: ... def get_client_by_id(self, client_id): ... - def exists_nonce(self, nonce, request): ... + def exists_nonce(self, nonce, request) -> bool: ... diff --git a/stubs/Authlib/authlib/oauth1/rfc5849/client_auth.pyi b/stubs/Authlib/authlib/oauth1/rfc5849/client_auth.pyi index e0214cc5bb3e..4fc70d6c19dc 100644 --- a/stubs/Authlib/authlib/oauth1/rfc5849/client_auth.pyi +++ b/stubs/Authlib/authlib/oauth1/rfc5849/client_auth.pyi @@ -1,12 +1,14 @@ from _typeshed import Incomplete +from collections.abc import Callable +from typing import Final -CONTENT_TYPE_FORM_URLENCODED: str -CONTENT_TYPE_MULTI_PART: str +CONTENT_TYPE_FORM_URLENCODED: Final = "application/x-www-form-urlencoded" +CONTENT_TYPE_MULTI_PART: Final = "multipart/form-data" class ClientAuth: - SIGNATURE_METHODS: Incomplete + SIGNATURE_METHODS: dict[str, Callable[..., str]] @classmethod - def register_signature_method(cls, name, sign) -> None: ... + def register_signature_method(cls, name: str, sign: Callable[..., str]) -> None: ... client_id: Incomplete client_secret: Incomplete token: Incomplete @@ -33,7 +35,7 @@ class ClientAuth: force_include_body: bool = False, ) -> None: ... def get_oauth_signature(self, method, uri, headers, body) -> str: ... - def get_oauth_params(self, nonce, timestamp) -> list[Incomplete]: ... + def get_oauth_params(self, nonce, timestamp) -> list[tuple[str, Incomplete]]: ... def sign(self, method, uri, headers, body) -> tuple[Incomplete, Incomplete, Incomplete]: ... def prepare(self, method, uri, headers, body) -> tuple[Incomplete, ...]: ... diff --git a/stubs/Authlib/authlib/oauth1/rfc5849/models.pyi b/stubs/Authlib/authlib/oauth1/rfc5849/models.pyi index dfeba9680bf3..98e0cfd55d7c 100644 --- a/stubs/Authlib/authlib/oauth1/rfc5849/models.pyi +++ b/stubs/Authlib/authlib/oauth1/rfc5849/models.pyi @@ -16,6 +16,6 @@ class TemporaryCredential(dict[str, object], TemporaryCredentialMixin): def get_client_id(self): ... def get_user_id(self): ... def get_redirect_uri(self): ... - def check_verifier(self, verifier): ... + def check_verifier(self, verifier) -> bool: ... def get_oauth_token(self): ... def get_oauth_token_secret(self): ... diff --git a/stubs/Authlib/authlib/oauth1/rfc5849/wrapper.pyi b/stubs/Authlib/authlib/oauth1/rfc5849/wrapper.pyi index ed0c1c936359..973e82fc0bf9 100644 --- a/stubs/Authlib/authlib/oauth1/rfc5849/wrapper.pyi +++ b/stubs/Authlib/authlib/oauth1/rfc5849/wrapper.pyi @@ -5,13 +5,17 @@ class OAuth1Request: uri: Incomplete body: Incomplete headers: Incomplete - client: Incomplete - credential: Incomplete - user: Incomplete + client: Incomplete | None + credential: Incomplete | None + user: Incomplete | None query: Incomplete query_params: Incomplete body_params: Incomplete - params: Incomplete + auth_params: Incomplete + realm: Incomplete + signature_type: str | None + oauth_params: Incomplete + params: list[Incomplete] def __init__(self, method, uri, body=None, headers=None) -> None: ... @property def client_id(self): ... diff --git a/stubs/Authlib/authlib/oauth2/auth.pyi b/stubs/Authlib/authlib/oauth2/auth.pyi index b4b818d942ec..5be0ac7fc0f6 100644 --- a/stubs/Authlib/authlib/oauth2/auth.pyi +++ b/stubs/Authlib/authlib/oauth2/auth.pyi @@ -1,11 +1,11 @@ from _typeshed import Incomplete -def encode_client_secret_basic(client, method, uri, headers, body): ... -def encode_client_secret_post(client, method, uri, headers, body): ... -def encode_none(client, method, uri, headers, body): ... +def encode_client_secret_basic(client, method, uri, headers, body) -> tuple[Incomplete, Incomplete, Incomplete]: ... +def encode_client_secret_post(client, method, uri, headers, body) -> tuple[Incomplete, Incomplete, str]: ... +def encode_none(client, method, uri, headers, body) -> tuple[Incomplete, Incomplete, Incomplete]: ... class ClientAuth: - DEFAULT_AUTH_METHODS: Incomplete + DEFAULT_AUTH_METHODS: dict[str, Incomplete] client_id: Incomplete client_secret: Incomplete auth_method: Incomplete @@ -14,12 +14,12 @@ class ClientAuth: class TokenAuth: DEFAULT_TOKEN_TYPE: str - SIGN_METHODS: Incomplete + SIGN_METHODS: dict[str, Incomplete] token: Incomplete - token_placement: Incomplete - client: Incomplete - hooks: Incomplete + token_placement: str + client: Incomplete | None + hooks: set[Incomplete] def __init__(self, token, token_placement: str = "header", client=None) -> None: ... def set_token(self, token) -> None: ... - def prepare(self, uri, headers, body): ... + def prepare(self, uri, headers, body) -> tuple[Incomplete, Incomplete, Incomplete]: ... def __del__(self) -> None: ... diff --git a/stubs/Authlib/authlib/oauth2/base.pyi b/stubs/Authlib/authlib/oauth2/base.pyi index 218040b4fc9b..91181720ef60 100644 --- a/stubs/Authlib/authlib/oauth2/base.pyi +++ b/stubs/Authlib/authlib/oauth2/base.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from typing import Literal from authlib.common.errors import AuthlibHTTPError @@ -10,7 +11,7 @@ class OAuth2Error(AuthlibHTTPError): redirect_fragment: Incomplete def __init__( self, - description=None, + description: str | None = None, uri=None, status_code=None, state=None, @@ -18,5 +19,5 @@ class OAuth2Error(AuthlibHTTPError): redirect_fragment: bool = False, error=None, ) -> None: ... - def get_body(self) -> list[Incomplete]: ... - def __call__(self, uri=None): ... + def get_body(self) -> list[tuple[Literal["error", "error_description", "error_uri"], str | None]]: ... + def __call__(self, uri: str | None = None): ... diff --git a/stubs/Authlib/authlib/oauth2/client.pyi b/stubs/Authlib/authlib/oauth2/client.pyi index 56914286ef21..4fcba50b6955 100644 --- a/stubs/Authlib/authlib/oauth2/client.pyi +++ b/stubs/Authlib/authlib/oauth2/client.pyi @@ -8,8 +8,8 @@ class OAuth2Client: client_auth_class = ClientAuth token_auth_class = TokenAuth oauth_error_class = OAuth2Error - EXTRA_AUTHORIZE_PARAMS: Incomplete - SESSION_REQUEST_PARAMS: Incomplete + EXTRA_AUTHORIZE_PARAMS: tuple[str, ...] + SESSION_REQUEST_PARAMS: list[str] session: Incomplete client_id: Incomplete client_secret: Incomplete @@ -21,9 +21,9 @@ class OAuth2Client: code_challenge_method: Incomplete token_auth: Incomplete update_token: Incomplete - metadata: Incomplete - compliance_hook: Incomplete - leeway: Incomplete + metadata: dict[str, Incomplete] + compliance_hook: dict[str, set[Incomplete]] + leeway: int def __init__( self, session, @@ -39,6 +39,11 @@ class OAuth2Client: token_placement: str = "header", update_token=None, leeway: int = 60, + *, + token_updater=None, + response_type=None, + grant_type: str | None = None, + token_endpoint=None, **metadata, ) -> None: ... def register_client_auth_method(self, auth) -> None: ... @@ -47,11 +52,11 @@ class OAuth2Client: def token(self): ... @token.setter def token(self, token) -> None: ... - def create_authorization_url(self, url, state=None, code_verifier=None, **kwargs): ... + def create_authorization_url(self, url, state=None, code_verifier=None, **kwargs) -> tuple[str, Incomplete]: ... def fetch_token( self, url=None, body: str = "", method: str = "POST", headers=None, auth=None, grant_type=None, state=None, **kwargs ): ... - def token_from_fragment(self, authorization_response, state=None): ... + def token_from_fragment(self, authorization_response, state=None) -> dict[Incomplete, Incomplete]: ... def refresh_token(self, url=None, refresh_token=None, body: str = "", auth=None, headers=None, **kwargs): ... def ensure_active_token(self, token=None): ... def revoke_token(self, url, token=None, token_type_hint=None, body=None, auth=None, headers=None, **kwargs): ... diff --git a/stubs/Authlib/authlib/oauth2/rfc6750/parameters.pyi b/stubs/Authlib/authlib/oauth2/rfc6750/parameters.pyi index 2548a286248b..00d3365808ff 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6750/parameters.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6750/parameters.pyi @@ -1,4 +1,6 @@ -def add_to_uri(token, uri): ... +from _typeshed import Incomplete + +def add_to_uri(token, uri) -> str: ... def add_to_headers(token, headers=None): ... def add_to_body(token, body=None) -> str: ... -def add_bearer_token(token, uri, headers, body, placement: str = "header"): ... +def add_bearer_token(token, uri, headers, body, placement: str = "header") -> tuple[Incomplete, Incomplete, Incomplete]: ... diff --git a/stubs/Authlib/authlib/oauth2/rfc9101/discovery.pyi b/stubs/Authlib/authlib/oauth2/rfc9101/discovery.pyi index 82d106bbae5b..92b57602e5ef 100644 --- a/stubs/Authlib/authlib/oauth2/rfc9101/discovery.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc9101/discovery.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - class AuthorizationServerMetadata(dict[str, object]): - REGISTRY_KEYS: Incomplete + REGISTRY_KEYS: list[str] def validate_require_signed_request_object(self) -> None: ...