File: signing.pyi

package info (click to toggle)
python-django-stubs 5.2.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,832 kB
  • sloc: python: 5,185; makefile: 15; sh: 8
file content (74 lines) | stat: -rw-r--r-- 2,293 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from datetime import timedelta
from typing import Any, Protocol, type_check_only

BASE62_ALPHABET: str

class BadSignature(Exception): ...
class SignatureExpired(BadSignature): ...

def b62_encode(s: int) -> str: ...
def b62_decode(s: str) -> int: ...
def b64_encode(s: bytes) -> bytes: ...
def b64_decode(s: bytes) -> bytes: ...
def base64_hmac(salt: bytes | str, value: bytes | str, key: bytes | str, algorithm: str = "sha1") -> str: ...
def get_cookie_signer(salt: str = "django.core.signing.get_cookie_signer") -> TimestampSigner: ...
@type_check_only
class Serializer(Protocol):
    def dumps(self, obj: Any) -> bytes: ...
    def loads(self, data: bytes) -> Any: ...

class JSONSerializer:
    def dumps(self, obj: Any) -> bytes: ...
    def loads(self, data: bytes) -> Any: ...

def dumps(
    obj: Any,
    key: bytes | str | None = None,
    salt: bytes | str = "django.core.signing",
    serializer: type[Serializer] = ...,
    compress: bool = False,
) -> str: ...
def loads(
    s: str,
    key: bytes | str | None = None,
    salt: bytes | str = "django.core.signing",
    serializer: type[Serializer] = ...,
    max_age: int | timedelta | None = None,
    fallback_keys: list[str | bytes] | None = None,
) -> Any: ...

class Signer:
    key: bytes | str
    fallback_keys: list[bytes | str]
    sep: str
    salt: bytes | str
    algorithm: str
    def __init__(
        self,
        *,
        key: bytes | str | None = None,
        sep: str = ":",
        salt: bytes | str | None = None,
        algorithm: str | None = None,
        fallback_keys: list[bytes | str] | None = None,
    ) -> None: ...
    def signature(self, value: bytes | str, key: bytes | str | None = None) -> str: ...
    def sign(self, value: str) -> str: ...
    def unsign(self, signed_value: str) -> str: ...
    def sign_object(
        self,
        obj: Any,
        serializer: type[Serializer] = ...,
        compress: bool = False,
    ) -> str: ...
    def unsign_object(
        self,
        signed_obj: str,
        serializer: type[Serializer] = ...,
        **kwargs: Any,
    ) -> Any: ...

class TimestampSigner(Signer):
    def timestamp(self) -> str: ...
    def sign(self, value: str) -> str: ...
    def unsign(self, value: str, max_age: int | timedelta | None = None) -> str: ...