Skip to content

Commit

Permalink
cleanup: docstrings to type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
thatmattlove committed Sep 28, 2020
1 parent be7a364 commit 512bf3e
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions hyperglass/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,8 @@
from hyperglass.exceptions import RestError


async def jwt_decode(payload, secret):
"""Decode & validate an encoded JSON Web Token (JWT).
Arguments:
payload {str} -- Raw JWT payload
secret {str} -- JWT secret
Raises:
RestError: Raised if decoded payload is improperly formatted
or if the JWT is not able to be decoded.
Returns:
{str} -- Decoded response payload
"""
async def jwt_decode(payload: str, secret: str) -> str:
"""Decode & validate an encoded JSON Web Token (JWT)."""
try:
decoded = jwt.decode(payload, secret, algorithm="HS256")
decoded = decoded["payload"]
Expand All @@ -32,17 +20,8 @@ async def jwt_decode(payload, secret):
raise RestError(str(exp)) from None


async def jwt_encode(payload, secret, duration):
"""Encode a query to a JSON Web Token (JWT).
Arguments:
payload {str} -- Stringified JSON request
secret {str} -- JWT secret
duration {int} -- Number of seconds claim is valid
Returns:
str -- Encoded request payload
"""
async def jwt_encode(payload: str, secret: str, duration: int) -> str:
"""Encode a query to a JSON Web Token (JWT)."""
token = {
"payload": payload,
"nbf": datetime.datetime.utcnow(),
Expand Down

0 comments on commit 512bf3e

Please sign in to comment.