|
| 1 | +# Stubs for itsdangerous (Python 3) |
| 2 | +# |
| 3 | +# NOTE: This dynamically typed stub was automatically generated by stubgen. |
| 4 | + |
| 5 | +from datetime import datetime |
| 6 | +from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, TypeVar, Union |
| 7 | + |
| 8 | +PY2 = ... # type: bool |
| 9 | +text_type = str |
| 10 | +int_to_byte = Callable[[int], bytes] |
| 11 | +number_types = (int, float) |
| 12 | +izip = zip |
| 13 | + |
| 14 | +bytes_like = Union[bytearray, bytes] |
| 15 | +str_like = Union[str, bytes] |
| 16 | +can_become_bytes = Union[str, bytes, bytearray] |
| 17 | +comparable_bytes = TypeVar('comparable_bytes', str, Union[bytes, bytearray]) |
| 18 | + |
| 19 | +class _CompactJSON: |
| 20 | + def loads(self, payload: Text) -> Any: ... |
| 21 | + def dumps(self, obj: Any) -> Text: ... |
| 22 | + |
| 23 | +compact_json = _CompactJSON |
| 24 | +EPOCH = ... # type: int |
| 25 | + |
| 26 | +def want_bytes(s: can_become_bytes, encoding='', errors='') -> bytes: ... |
| 27 | +def is_text_serializer(serializer: Any) -> bool: ... |
| 28 | +def constant_time_compare(val1: comparable_bytes, val2: comparable_bytes) -> bool: ... |
| 29 | + |
| 30 | +class BadData(Exception): |
| 31 | + message = ... # type: str |
| 32 | + def __init__(self, message: str) -> None: ... |
| 33 | + |
| 34 | +class BadPayload(BadData): |
| 35 | + original_error = ... # type: Optional[Exception] |
| 36 | + def __init__(self, message: str, original_error: Optional[Exception]=None) -> None: ... |
| 37 | + |
| 38 | +class BadSignature(BadData): |
| 39 | + payload = ... # type: Optional[Any] |
| 40 | + def __init__(self, message: str, payload: Optional[Any]=None) -> None: ... |
| 41 | + |
| 42 | +class BadTimeSignature(BadSignature): |
| 43 | + date_signed = ... # type: Optional[int] |
| 44 | + def __init__(self, message, payload: Optional[Any]=None, date_signed: Optional[int]=None) -> None: ... |
| 45 | + |
| 46 | +class BadHeader(BadSignature): |
| 47 | + header = ... # type: Any |
| 48 | + original_error = ... # type: Any |
| 49 | + def __init__(self, message, payload=None, header=None, original_error=None) -> None: ... |
| 50 | + |
| 51 | +class SignatureExpired(BadTimeSignature): ... |
| 52 | + |
| 53 | +def base64_encode(string: can_become_bytes) -> bytes: ... |
| 54 | +def base64_decode(string: can_become_bytes) -> bytes: ... |
| 55 | +def int_to_bytes(num: int) -> bytes: ... |
| 56 | +def bytes_to_int(bytestr: can_become_bytes) -> bytes: ... |
| 57 | + |
| 58 | +class SigningAlgorithm: |
| 59 | + def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ... |
| 60 | + def verify_signature(self, key: bytes_like, value: bytes_like, sig: can_become_bytes) -> bool: ... |
| 61 | + |
| 62 | +class NoneAlgorithm(SigningAlgorithm): |
| 63 | + def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ... |
| 64 | + |
| 65 | +class HMACAlgorithm(SigningAlgorithm): |
| 66 | + default_digest_method = ... # type: Callable |
| 67 | + digest_method = ... # type: Callable |
| 68 | + def __init__(self, digest_method: Optional[Callable]=None) -> None: ... |
| 69 | + def get_signature(self, key: bytes_like, value: bytes_like) -> bytes: ... |
| 70 | + |
| 71 | +class Signer: |
| 72 | + default_digest_method = ... # type: Callable |
| 73 | + default_key_derivation = ... # type: str |
| 74 | + secret_key = ... # type: can_become_bytes |
| 75 | + sep = ... # type: can_become_bytes |
| 76 | + salt = ... # type: can_become_bytes |
| 77 | + key_derivation = ... # type: str |
| 78 | + digest_method = ... # type: Callable |
| 79 | + algorithm = ... # type: SigningAlgorithm |
| 80 | + def __init__(self, secret_key: can_become_bytes, salt: Optional[can_become_bytes]=None, sep: Optional[can_become_bytes]='', |
| 81 | + key_derivation: Optional[str]=None, |
| 82 | + digest_method: Optional[Callable]=None, |
| 83 | + algorithm: Optional[SigningAlgorithm]=None) -> None: ... |
| 84 | + def derive_key(self) -> bytes: ... |
| 85 | + def get_signature(self, value: bytes_like) -> bytes: ... |
| 86 | + def sign(self, value: bytes_like) -> bytes: ... |
| 87 | + def verify_signature(self, value: bytes_like, sig: can_become_bytes) -> bool: ... |
| 88 | + def unsign(self, signed_value: can_become_bytes) -> str: ... |
| 89 | + def validate(self, signed_value: can_become_bytes) -> bool: ... |
| 90 | + |
| 91 | +class TimestampSigner(Signer): |
| 92 | + def get_timestamp(self) -> int: ... |
| 93 | + def timestamp_to_datetime(self, ts: int) -> datetime: ... |
| 94 | + def sign(self, value: bytes_like) -> bytes: ... |
| 95 | + def unsign(self, value: can_become_bytes, max_age: Optional[int]=None, return_timestamp=False) -> Any: ... |
| 96 | + def validate(self, signed_value: can_become_bytes, max_age: Optional[int]=None) -> bool: ... |
| 97 | + |
| 98 | +class Serializer: |
| 99 | + default_serializer = ... # type: Any |
| 100 | + default_signer = ... # type: Callable[..., Signer] |
| 101 | + secret_key = ... # type: Any |
| 102 | + salt = ... # type: can_become_bytes |
| 103 | + serializer = ... # type: Any |
| 104 | + is_text_serializer = ... # type: bool |
| 105 | + signer = ... # type: Signer |
| 106 | + signer_kwargs = ... # type: MutableMapping |
| 107 | + def __init__(self, secret_key: can_become_bytes, salt: Optional[can_become_bytes]=b'', serializer=None, signer: Optional[Callable[..., Signer]]=None, signer_kwargs: Optional[MutableMapping]=None) -> None: ... |
| 108 | + def load_payload(self, payload: Any, serializer=None) -> Any: ... |
| 109 | + def dump_payload(self, *args, **kwargs) -> bytes: ... |
| 110 | + def make_signer(self, salt: Optional[can_become_bytes]=None) -> Signer: ... |
| 111 | + def dumps(self, obj: Any, salt: Optional[can_become_bytes]=None) -> str_like: ... |
| 112 | + def dump(self, obj: Any, f: IO, salt: Optional[can_become_bytes]=None) -> None: ... |
| 113 | + def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None) -> Any: ... |
| 114 | + def load(self, f: IO, salt: Optional[can_become_bytes]=None): ... |
| 115 | + def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None) -> Tuple[bool, Any]: ... |
| 116 | + def load_unsafe(self, f: IO, *args, **kwargs) -> Tuple[bool, Any]: ... |
| 117 | + |
| 118 | +class TimedSerializer(Serializer): |
| 119 | + default_signer = ... # type: Callable[..., TimestampSigner] |
| 120 | + def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, max_age: Optional[int]=None, return_timestamp=False) -> Any: ... |
| 121 | + def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, max_age: Optional[int]=None) -> Tuple[bool, Any]: ... |
| 122 | + |
| 123 | +class JSONWebSignatureSerializer(Serializer): |
| 124 | + jws_algorithms = ... # type: MutableMapping[str, SigningAlgorithm] |
| 125 | + default_algorithm = ... # type: str |
| 126 | + default_serializer = ... # type: Any |
| 127 | + algorithm_name = ... # type: str |
| 128 | + algorithm = ... # type: Any |
| 129 | + def __init__(self, secret_key: can_become_bytes, salt: Optional[can_become_bytes]=None, serializer=None, signer: Optional[Callable[..., Signer]]=None, signer_kwargs: Optional[MutableMapping]=None, algorithm_name: Optional[str]=None) -> None: ... |
| 130 | + def load_payload(self, payload: Any, return_header=False) -> Any: ... |
| 131 | + def dump_payload(self, *args, **kwargs) -> bytes: ... |
| 132 | + def make_algorithm(self, algorithm_name: str) -> SigningAlgorithm: ... |
| 133 | + def make_signer(self, salt: Optional[can_become_bytes]=None, algorithm_name: Optional[str]=None) -> Signer: ... |
| 134 | + def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ... |
| 135 | + def dumps(self, obj: Any, salt: Optional[can_become_bytes]=None, header_fields=Optional[MutableMapping]) -> str: ... |
| 136 | + def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Any: ... |
| 137 | + def loads_unsafe(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Tuple[bool, Any]: ... |
| 138 | + |
| 139 | +class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer): |
| 140 | + DEFAULT_EXPIRES_IN = ... # type: int |
| 141 | + expires_in = ... # type: int |
| 142 | + def __init__(self, secret_key: can_become_bytes, expires_in: Optional[int]=None, **kwargs) -> None: ... |
| 143 | + def make_header(self, header_fields=Optional[MutableMapping]) -> MutableMapping: ... |
| 144 | + def loads(self, s: can_become_bytes, salt: Optional[can_become_bytes]=None, return_header=False) -> Any: ... |
| 145 | + def get_issue_date(self, header: MutableMapping) -> Optional[datetime]: ... |
| 146 | + def now(self) -> int: ... |
| 147 | + |
| 148 | +class URLSafeSerializerMixin: |
| 149 | + def load_payload(self, payload: Any, **kwargs) -> Any: ... |
| 150 | + def dump_payload(self, *args, **kwargs) -> bytes: ... |
| 151 | + |
| 152 | +class URLSafeSerializer(URLSafeSerializerMixin, Serializer): |
| 153 | + default_serializer = ... # type: Any |
| 154 | + |
| 155 | +class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer): |
| 156 | + default_serializer = ... # type: Any |
0 commit comments