File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22import json
33from json import JSONEncoder , JSONDecoder
4+ from typing import Type
45from .rfc7519 .claims import convert_claims
56from .rfc7519 .claims import Claims as Claims
67from .rfc7519 .claims import check_sensitive_data as check_sensitive_data
@@ -51,7 +52,7 @@ def encode(
5152 key : KeyFlexible ,
5253 algorithms : list [str ] | None = None ,
5354 registry : JWSRegistry | JWERegistry | None = None ,
54- encoder_cls : JSONEncoder | None = None ) -> str :
55+ encoder_cls : Type [ JSONEncoder ] | None = None ) -> str :
5556 """Encode a JSON Web Token with the given header, and claims.
5657
5758 :param header: A dict of the JWT header
@@ -75,7 +76,7 @@ def decode(
7576 key : KeyFlexible ,
7677 algorithms : list [str ] | None = None ,
7778 registry : JWSRegistry | JWERegistry | None = None ,
78- decoder_cls : JSONDecoder | None = None ) -> Token :
79+ decoder_cls : Type [ JSONDecoder ] | None = None ) -> Token :
7980 """Decode the JSON Web Token string with the given key, and validate
8081 it with the claims requests.
8182
Original file line number Diff line number Diff line change 55import datetime
66import calendar
77from json import JSONEncoder
8- from typing import Dict , Any
8+ from typing import Dict , Any , Type
99from ..util import to_bytes
1010from ..errors import InsecureClaimError
1111
2626Claims = Dict [str , Any ]
2727
2828
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 :
3030 """Turn claims into bytes payload."""
3131 for k in ["exp" , "iat" , "nbf" ]:
3232 claim = claims .get (k )
You can’t perform that action at this time.
0 commit comments