Eerste commit voor rename-mvp
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import base64
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
def decode_jwt_payload(token: str) -> dict:
|
||||
parts = token.split(".")
|
||||
if len(parts) != 3:
|
||||
raise ValueError("Invalid JWT format")
|
||||
|
||||
payload_b64 = parts[1]
|
||||
padding = "=" * (-len(payload_b64) % 4)
|
||||
raw = base64.urlsafe_b64decode(payload_b64 + padding)
|
||||
return json.loads(raw.decode("utf-8"))
|
||||
|
||||
|
||||
def unix_to_iso_utc(value: int | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
return datetime.fromtimestamp(value, tz=timezone.utc).isoformat()
|
||||
|
||||
|
||||
def now_utc_ts() -> int:
|
||||
return int(datetime.now(tz=timezone.utc).timestamp())
|
||||
Reference in New Issue
Block a user