Fix PyNaCl exception name
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m4s
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m4s
Use BadSignatureError instead of BadSignature Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import sys
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from fastapi import FastAPI, HTTPException, Request, Response
|
from fastapi import FastAPI, HTTPException, Request, Response
|
||||||
from nacl.exceptions import BadSignature
|
from nacl.exceptions import BadSignatureError
|
||||||
from nacl.signing import VerifyKey
|
from nacl.signing import VerifyKey
|
||||||
|
|
||||||
DISCORD_PUBLIC_KEY = os.environ.get("DISCORD_PUBLIC_KEY", "")
|
DISCORD_PUBLIC_KEY = os.environ.get("DISCORD_PUBLIC_KEY", "")
|
||||||
@@ -25,7 +25,7 @@ def verify_signature(
|
|||||||
verify_key = VerifyKey(bytes.fromhex(public_key))
|
verify_key = VerifyKey(bytes.fromhex(public_key))
|
||||||
verify_key.verify(timestamp.encode() + body, bytes.fromhex(signature))
|
verify_key.verify(timestamp.encode() + body, bytes.fromhex(signature))
|
||||||
return True
|
return True
|
||||||
except (BadSignature, ValueError) as e:
|
except (BadSignatureError, ValueError) as e:
|
||||||
print(f"Signature verification failed: {e}", file=sys.stderr)
|
print(f"Signature verification failed: {e}", file=sys.stderr)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user