File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
import json
3
3
from json import JSONEncoder , JSONDecoder
4
+ from typing import Type
4
5
from .rfc7519 .claims import convert_claims
5
6
from .rfc7519 .claims import Claims as Claims
6
7
from .rfc7519 .claims import check_sensitive_data as check_sensitive_data
@@ -51,7 +52,7 @@ def encode(
51
52
key : KeyFlexible ,
52
53
algorithms : list [str ] | None = None ,
53
54
registry : JWSRegistry | JWERegistry | None = None ,
54
- encoder_cls : JSONEncoder | None = None ) -> str :
55
+ encoder_cls : Type [ JSONEncoder ] | None = None ) -> str :
55
56
"""Encode a JSON Web Token with the given header, and claims.
56
57
57
58
:param header: A dict of the JWT header
@@ -75,7 +76,7 @@ def decode(
75
76
key : KeyFlexible ,
76
77
algorithms : list [str ] | None = None ,
77
78
registry : JWSRegistry | JWERegistry | None = None ,
78
- decoder_cls : JSONDecoder | None = None ) -> Token :
79
+ decoder_cls : Type [ JSONDecoder ] | None = None ) -> Token :
79
80
"""Decode the JSON Web Token string with the given key, and validate
80
81
it with the claims requests.
81
82
Original file line number Diff line number Diff line change 5
5
import datetime
6
6
import calendar
7
7
from json import JSONEncoder
8
- from typing import Dict , Any
8
+ from typing import Dict , Any , Type
9
9
from ..util import to_bytes
10
10
from ..errors import InsecureClaimError
11
11
26
26
Claims = Dict [str , Any ]
27
27
28
28
29
- def convert_claims (claims : Claims , encoder_cls : JSONEncoder | None = None ) -> bytes :
29
+ def convert_claims (claims : Claims , encoder_cls : Type [ JSONEncoder ] | None = None ) -> bytes :
30
30
"""Turn claims into bytes payload."""
31
31
for k in ["exp" , "iat" , "nbf" ]:
32
32
claim = claims .get (k )
You can’t perform that action at this time.
0 commit comments