Update components/middleware.py
Browse files- components/middleware.py +13 -5
components/middleware.py
CHANGED
|
@@ -20,7 +20,7 @@ from jwt.exceptions import (
|
|
| 20 |
|
| 21 |
import datetime
|
| 22 |
import time
|
| 23 |
-
|
| 24 |
#from geopy.geocoders import Nominatim
|
| 25 |
#from geopy.exc import GeocoderServiceError
|
| 26 |
#geolocator = Nominatim(user_agent="velocity")
|
|
@@ -35,17 +35,24 @@ import time
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
-
def SignatureVerification(X_401_Addr,X_401_Nonce,X_401_Sign,challange):
|
| 39 |
|
| 40 |
|
| 41 |
if X_401_Addr and X_401_Nonce and X_401_Sign:
|
| 42 |
|
| 43 |
try:
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
verify_key = VerifyKey(base58.b58decode(X_401_Addr))
|
| 47 |
payload_bytes = challange.encode("utf-8")
|
| 48 |
-
|
| 49 |
verify_key.verify(payload_bytes, signature_bytes)
|
| 50 |
return True
|
| 51 |
|
|
@@ -265,6 +272,7 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 265 |
mint_amount=float(request.headers.get("mint_amount"))
|
| 266 |
print(mint_amount)
|
| 267 |
helius_api_key = request.headers.get("helius_api_key")
|
|
|
|
| 268 |
|
| 269 |
|
| 270 |
|
|
@@ -272,7 +280,7 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 272 |
|
| 273 |
challange=f"CHALLENGE::{X_401_Nonce}::{request.url.path}::VELOCITY401"
|
| 274 |
|
| 275 |
-
signverify=SignatureVerification(X_401_Addr,X_401_Nonce,X_401_Sign,challange)
|
| 276 |
tokenverify=None
|
| 277 |
if required_mint=="no":
|
| 278 |
tokenverify=True
|
|
|
|
| 20 |
|
| 21 |
import datetime
|
| 22 |
import time
|
| 23 |
+
import base64
|
| 24 |
#from geopy.geocoders import Nominatim
|
| 25 |
#from geopy.exc import GeocoderServiceError
|
| 26 |
#geolocator = Nominatim(user_agent="velocity")
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
+
def SignatureVerification(mpc,X_401_Addr,X_401_Nonce,X_401_Sign,challange):
|
| 39 |
|
| 40 |
|
| 41 |
if X_401_Addr and X_401_Nonce and X_401_Sign:
|
| 42 |
|
| 43 |
try:
|
| 44 |
|
| 45 |
+
|
| 46 |
+
signature_bytes=None
|
| 47 |
+
|
| 48 |
+
if mpc==true:
|
| 49 |
+
signature_bytes = base64.b64decode(X_401_Sign)
|
| 50 |
+
else:
|
| 51 |
+
signature_bytes=base58.b58decode(X_401_Sign)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
verify_key = VerifyKey(base58.b58decode(X_401_Addr))
|
| 55 |
payload_bytes = challange.encode("utf-8")
|
|
|
|
| 56 |
verify_key.verify(payload_bytes, signature_bytes)
|
| 57 |
return True
|
| 58 |
|
|
|
|
| 272 |
mint_amount=float(request.headers.get("mint_amount"))
|
| 273 |
print(mint_amount)
|
| 274 |
helius_api_key = request.headers.get("helius_api_key")
|
| 275 |
+
mpc=request.headers.get("mpc")
|
| 276 |
|
| 277 |
|
| 278 |
|
|
|
|
| 280 |
|
| 281 |
challange=f"CHALLENGE::{X_401_Nonce}::{request.url.path}::VELOCITY401"
|
| 282 |
|
| 283 |
+
signverify=SignatureVerification(mpc,X_401_Addr,X_401_Nonce,X_401_Sign,challange)
|
| 284 |
tokenverify=None
|
| 285 |
if required_mint=="no":
|
| 286 |
tokenverify=True
|