From 37be7178866dc6deb087fc41e338d6c2bb646229 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Wed, 17 Jun 2020 16:11:42 +0200 Subject: [PATCH] Add stubs for cryptography's Fernet.[encrypt|decrypt]_at_time() (#4238) --- third_party/2and3/cryptography/fernet.pyi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/third_party/2and3/cryptography/fernet.pyi b/third_party/2and3/cryptography/fernet.pyi index 058cd15ce..6c4c06fa4 100644 --- a/third_party/2and3/cryptography/fernet.pyi +++ b/third_party/2and3/cryptography/fernet.pyi @@ -5,7 +5,12 @@ class InvalidToken(Exception): ... class Fernet(object): def __init__(self, key: Union[bytes, Text]) -> None: ... def decrypt(self, token: bytes, ttl: Optional[int] = ...) -> bytes: ... + # decrypt_at_time accepts None ttl at runtime but it's an implementtion detail and it doesn't really + # make sense for the client code to use it like that, so the parameter is typed as int as opposed to + # Optional[int]. + def decrypt_at_time(self, token: bytes, ttl: int, current_time: int) -> bytes: ... def encrypt(self, data: bytes) -> bytes: ... + def encrypt_at_time(self, data: bytes, current_time: int) -> bytes: ... def extract_timestamp(self, token: bytes) -> int: ... @classmethod def generate_key(cls) -> bytes: ... @@ -13,5 +18,8 @@ class Fernet(object): class MultiFernet(object): def __init__(self, fernets: List[Fernet]) -> None: ... def decrypt(self, token: bytes, ttl: Optional[int] = ...) -> bytes: ... + # See a note above on the typing of the ttl parameter. + def decrypt_at_time(self, token: bytes, ttl: int, current_time: int) -> bytes: ... def encrypt(self, data: bytes) -> bytes: ... + def encrypt_at_time(self, data: bytes, current_time: int) -> bytes: ... def rotate(self, msg: bytes) -> bytes: ...