reykit 1.2.2__py3-none-any.whl → 1.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
reykit/rdata.py
CHANGED
@@ -16,7 +16,7 @@ from itertools import chain as IChain
|
|
16
16
|
from decimal import Decimal
|
17
17
|
from json import dumps as json_dumps
|
18
18
|
from jwt import encode as jwt_encode, decode as jwt_decode
|
19
|
-
from jwt.exceptions import
|
19
|
+
from jwt.exceptions import InvalidTokenError
|
20
20
|
from bcrypt import gensalt as bcrypt_gensalt, hashpw as bcrypt_hashpw, checkpw as bcrypt_checkpw
|
21
21
|
|
22
22
|
from .rbase import T, KT, VT, Base, Null, check_least_one, check_most_one, is_iterable
|
@@ -554,18 +554,18 @@ class FunctionGenerator(Base):
|
|
554
554
|
return agenerator
|
555
555
|
|
556
556
|
|
557
|
-
def encode_jwt(
|
557
|
+
def encode_jwt(json: dict[str, Any], key: str | bytes) -> str:
|
558
558
|
"""
|
559
|
-
Encode data to JWT
|
559
|
+
Encode JSON data to JWT token, based on `HS256`.
|
560
560
|
|
561
561
|
Parameters
|
562
562
|
----------
|
563
|
-
|
563
|
+
json : JSON data.
|
564
564
|
key : Key.
|
565
565
|
|
566
566
|
Returns
|
567
567
|
-------
|
568
|
-
|
568
|
+
Token.
|
569
569
|
"""
|
570
570
|
|
571
571
|
# Parameter.
|
@@ -574,23 +574,23 @@ def encode_jwt(data: dict[str, Any], key: str | bytes) -> str:
|
|
574
574
|
algorithm = 'HS256'
|
575
575
|
|
576
576
|
# Encode.
|
577
|
-
|
577
|
+
token = jwt_encode(json, key, algorithm=algorithm)
|
578
578
|
|
579
|
-
return
|
579
|
+
return token
|
580
580
|
|
581
581
|
|
582
|
-
def decode_jwt(
|
582
|
+
def decode_jwt(token: str | bytes, key: str| bytes) -> dict[str, Any] | None:
|
583
583
|
"""
|
584
|
-
Decode JWT
|
584
|
+
Decode JWT token to JSON data, based on `HS256`. When decode error, then return `None`.
|
585
585
|
|
586
586
|
Parameters
|
587
587
|
----------
|
588
|
-
|
588
|
+
token : JWT token.
|
589
589
|
key : Key.
|
590
590
|
|
591
591
|
Returns
|
592
592
|
-------
|
593
|
-
|
593
|
+
JSON data or null.
|
594
594
|
"""
|
595
595
|
|
596
596
|
# Parameter.
|
@@ -598,11 +598,11 @@ def decode_jwt(jwt: str | bytes, key: str| bytes) -> dict[str, Any] | None:
|
|
598
598
|
|
599
599
|
# Decode.
|
600
600
|
try:
|
601
|
-
|
602
|
-
except
|
601
|
+
json = jwt_decode(token, key, algorithms=algorithm)
|
602
|
+
except InvalidTokenError:
|
603
603
|
return
|
604
604
|
|
605
|
-
return
|
605
|
+
return json
|
606
606
|
|
607
607
|
|
608
608
|
def hash_bcrypt(password: str | bytes) -> bytes:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
reykit/__init__.py,sha256=Garu_XWuCXSp2a8rXviXcndlDi03vtwx9IDgIYycTw0,748
|
2
2
|
reykit/rall.py,sha256=Oljb0rwJyCrC6LhGLxpPizdB6MhxoZ9DOOnWM1sQC4o,598
|
3
3
|
reykit/rbase.py,sha256=snRdHOMTdsaWFYDQ5sTIcdJRybNcMarlz59EErbrepA,20897
|
4
|
-
reykit/rdata.py,sha256=
|
4
|
+
reykit/rdata.py,sha256=Z3_ZwWcibaFes_IRoRt_Z9hUKiricm0-vtyKxhA4Itw,13579
|
5
5
|
reykit/remail.py,sha256=DE4sxfJEXNu6MiBJKUsWXqvBrIOJNmnm_1lnGL0tZec,6693
|
6
6
|
reykit/rimage.py,sha256=yzrvZdYm9A08DjXq9nBRFti6k48o1rVJHv5-V9cnb74,6049
|
7
7
|
reykit/rlog.py,sha256=yBArs48wl509v4q7e1vHbE3E_Bqi3VHEV-Iuw2Y58f8,25649
|
@@ -21,7 +21,7 @@ reykit/rtime.py,sha256=3UPpUK027TY1Wgf5bzwCQo1N4ZceZ2YtcZzM9I8Q9Qg,17766
|
|
21
21
|
reykit/rwrap.py,sha256=lOKBhSqx8V_PcsdipPP4SaiGXXcpfaEhO_qEGSySEkw,15065
|
22
22
|
reykit/rdll/__init__.py,sha256=mewj06HHIzzW6oreQAz-6in2zYwNJ4-d1eWWL7CPQgc,685
|
23
23
|
reykit/rdll/rdll_core.py,sha256=zBmOyxD6LkbNIadXmFHLJinj-6UFko8D6w5d7hYA7vU,5077
|
24
|
-
reykit-1.2.
|
25
|
-
reykit-1.2.
|
26
|
-
reykit-1.2.
|
27
|
-
reykit-1.2.
|
24
|
+
reykit-1.2.3.dist-info/METADATA,sha256=3Fa13n3d5_hWAhm3VfS5UlR8ili7qrEmG88L7betruI,1923
|
25
|
+
reykit-1.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
26
|
+
reykit-1.2.3.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
27
|
+
reykit-1.2.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|