Skip to content

Commit 999eeab

Browse files
authored
Merge pull request #15 from tekktrik/main
Update documentation and formatting
2 parents 17acf34 + 9a3676c commit 999eeab

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

adafruit_jwt.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"""
66
`adafruit_jwt`
7-
================================================================================
7+
==============
88
99
JSON Web Token Authentication
1010
@@ -27,6 +27,7 @@
2727
https://github.com/adafruit/Adafruit_CircuitPython_RSA
2828
2929
"""
30+
3031
try:
3132
from typing import Tuple, Union, Optional
3233
from circuitpython_typing import ReadableBuffer
@@ -36,7 +37,6 @@
3637
import io
3738
import json
3839
from adafruit_rsa import PrivateKey, sign
39-
4040
from adafruit_binascii import b2a_base64, a2b_base64
4141

4242

@@ -48,14 +48,15 @@ class JWT:
4848
"""JSON Web Token helper for CircuitPython. Warning: JWTs are
4949
credentials, which can grant access to resources. Be careful
5050
where you paste them!
51-
:param str algo: Encryption algorithm used for claims. Can be None.
5251
52+
:param str algo: Encryption algorithm used for claims. Can be None.
5353
"""
5454

5555
@staticmethod
5656
def validate(jwt: str) -> Tuple[str, dict]:
5757
"""Validates a provided JWT. Does not support validating
5858
nested signing. Returns JOSE Header and claim set.
59+
5960
:param str jwt: JSON Web Token.
6061
:returns: The message's decoded JOSE header and claims.
6162
:rtype: tuple
@@ -90,6 +91,7 @@ def generate(
9091
headers: Optional[dict] = None,
9192
) -> str:
9293
"""Generates and returns a new JSON Web Token.
94+
9395
:param dict claims: JWT claims set
9496
:param str private_key_data: Decoded RSA private key data.
9597
:param str algo: algorithm to be used. One of None, RS256, RS384 or RS512.
@@ -155,6 +157,7 @@ def urlsafe_b64encode(payload: ReadableBuffer) -> str:
155157
"""Encode bytes-like object using the URL- and filesystem-safe alphabet,
156158
which substitutes - instead of + and _ instead of / in
157159
the standard Base64 alphabet, and return the encoded bytes.
160+
158161
:param bytes payload: bytes-like object.
159162
"""
160163
return STRING_TOOLS.translate(
@@ -165,6 +168,7 @@ def urlsafe_b64encode(payload: ReadableBuffer) -> str:
165168
def urlsafe_b64decode(payload: Union[ReadableBuffer, str]) -> str:
166169
"""Decode bytes-like object or ASCII string using the URL
167170
and filesystem-safe alphabet
171+
168172
:param bytes payload: bytes-like object or ASCII string
169173
"""
170174
return a2b_base64(STRING_TOOLS._bytes_from_decode_data(payload)).decode("utf-8")
@@ -194,6 +198,7 @@ def _bytes_from_decode_data(str_data: Union[ReadableBuffer, str]) -> bytes:
194198
def translate(s: str, table: dict) -> str:
195199
"""Return a copy of the string in which each character
196200
has been mapped through the given translation table.
201+
197202
:param string s: String to-be-character-table.
198203
:param dict table: Translation table.
199204
"""

0 commit comments

Comments
 (0)