|
2 | 2 | import email.utils |
3 | 3 | import hashlib |
4 | 4 | import secrets |
5 | | -from typing import List, Union |
| 5 | +from typing import Union, Sequence, Type |
6 | 6 |
|
7 | 7 | import http_sfv |
8 | 8 | import requests |
9 | 9 |
|
10 | 10 | from requests.exceptions import RequestException |
11 | 11 | from http_message_signatures import (algorithms, HTTPSignatureComponentResolver, HTTPSignatureKeyResolver, # noqa: F401 |
12 | 12 | HTTPMessageSigner, HTTPMessageVerifier, HTTPSignatureAlgorithm, InvalidSignature) |
13 | | -from http_message_signatures.structures import CaseInsensitiveDict |
| 13 | +from http_message_signatures.structures import CaseInsensitiveDict, VerifyResult |
14 | 14 |
|
15 | 15 |
|
16 | 16 | class RequestsHttpSignatureException(RequestException): |
@@ -84,11 +84,11 @@ class HTTPSignatureAuth(requests.auth.AuthBase): |
84 | 84 | _auto_cover_header_fields = {"authorization", "content-digest", "date"} |
85 | 85 |
|
86 | 86 | def __init__(self, *, |
87 | | - signature_algorithm: HTTPSignatureAlgorithm, |
| 87 | + signature_algorithm: Type[HTTPSignatureAlgorithm], |
88 | 88 | key: bytes = None, |
89 | 89 | key_id: str, |
90 | 90 | key_resolver: HTTPSignatureKeyResolver = None, |
91 | | - covered_component_ids: List[str] = ("@method", "@authority", "@target-uri"), |
| 91 | + covered_component_ids: Sequence[str] = ("@method", "@authority", "@target-uri"), |
92 | 92 | label: str = None, |
93 | 93 | include_alg: bool = True, |
94 | 94 | use_nonce: bool = False, |
@@ -168,10 +168,10 @@ def get_body(cls, message): |
168 | 168 |
|
169 | 169 | @classmethod |
170 | 170 | def verify(cls, message: Union[requests.PreparedRequest, requests.Response], *, |
171 | | - require_components: List[str] = ("@method", "@authority", "@target-uri"), |
172 | | - signature_algorithm: HTTPSignatureAlgorithm, |
| 171 | + require_components: Sequence[str] = ("@method", "@authority", "@target-uri"), |
| 172 | + signature_algorithm: Type[HTTPSignatureAlgorithm], |
173 | 173 | key_resolver: HTTPSignatureKeyResolver, |
174 | | - max_age: datetime.timedelta = datetime.timedelta(days=1)): |
| 174 | + max_age: datetime.timedelta = datetime.timedelta(days=1)) -> VerifyResult: |
175 | 175 | """ |
176 | 176 | Verify an HTTP message signature. |
177 | 177 |
|
|
0 commit comments