Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: WEB4 Full Stack Engine — Solana ED25519 wallet auth + JWT sessions
- Flask API (port 5080): /challenge, /login, /session, /graph, /status
- Solana ED25519 imza dogrulama (nacl + base58)
- JWT session yonetimi
- Graph entegrasyonu (node/edge CRUD)
- JSON-based DB (users, sessions, graph)
- Test scripti ve start scriptleri (bash + PowerShell)
  • Loading branch information
devin-ai-integration[bot] committed Jun 22, 2026
commit c3dfdc8654821baf9455a7c35371ba34d5789f96
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Core engine (api.py — port 5002)
fastapi>=0.110.0
uvicorn>=0.29.0
python-dotenv>=1.0.0
pydantic>=2.6.0
requests>=2.31.0
httpx>=0.27.0

# Web4 full stack (web4_full/engine/app.py — port 5080)
flask>=3.0.0
pyjwt>=2.8.0
pynacl>=1.5.0
base58>=2.1.0
8 changes: 8 additions & 0 deletions web4_full/db/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"users": {},
"sessions": {},
"graph": {
"nodes": {},
"edges": []
}
}
160 changes: 160 additions & 0 deletions web4_full/engine/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
"""
MUCIZEWORK WEB4 FULL STACK ENGINE
Solana ED25519 wallet auth, JWT session, graph entegrasyonu.
Port: 5080
"""

from flask import Flask, request, jsonify
import json
import time
import os
import jwt
import secrets
import base58
from nacl.signing import VerifyKey
from nacl.exceptions import BadSignatureError

app = Flask(__name__)

DB_PATH = os.path.join(os.path.dirname(__file__), "..", "db", "db.json")
SECRET = "MUCIZEWORK_SECRET_KEY"


# =========================
# DB HELPERS
# =========================
def load_db():
if not os.path.exists(DB_PATH):
return {"users": {}, "sessions": {}, "graph": {"nodes": {}, "edges": []}}
with open(DB_PATH, "r", encoding="utf-8") as f:
return json.load(f)


def save_db(db):
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
with open(DB_PATH, "w", encoding="utf-8") as f:
json.dump(db, f, indent=2, ensure_ascii=False)


# =========================
# REAL SIGNATURE VERIFY (SOLANA ED25519)
# =========================
def verify_signature(pubkey, message, signature):
try:
vk = VerifyKey(base58.b58decode(pubkey))
vk.verify(message.encode("utf-8"), base58.b58decode(signature))
return True
except BadSignatureError:
return False
except Exception:
return False


# =========================
# CHALLENGE (NONCE)
# =========================
@app.route("/challenge/<wallet>")
def challenge(wallet):
nonce = secrets.token_hex(16)
message = f"MUCIZEWORK WEB4 LOGIN {wallet} {nonce}"

db = load_db()
db["users"][wallet] = {
"nonce": nonce,
"message": message,
}
save_db(db)

return jsonify({
"wallet": wallet,
"nonce": nonce,
"message": message,
})


# =========================
# LOGIN
# =========================
@app.route("/login", methods=["POST"])
def login():
data = request.json

wallet = data.get("wallet")
message = data.get("message")
signature = data.get("signature")

db = load_db()

if wallet not in db["users"]:
return jsonify({"status": "no_challenge"}), 400

ok = verify_signature(wallet, message, signature)

if not ok:
return jsonify({"status": "invalid_signature"}), 403

token = jwt.encode(
{
"wallet": wallet,
"time": time.time(),
},
SECRET,
algorithm="HS256",
)

db["sessions"][token] = {
"wallet": wallet,
"time": time.time(),
}
save_db(db)

return jsonify({
"status": "logged_in",
"token": token,
})


# =========================
# SESSION VERIFY
# =========================
@app.route("/session/<token>")
def session(token):
db = load_db()
return jsonify(db["sessions"].get(token, {"status": "invalid"}))


# =========================
# GRAPH INTEGRATION
# =========================
@app.route("/graph")
def graph():
db = load_db()
return jsonify(db["graph"])


@app.route("/graph/add", methods=["POST"])
def add_graph():
data = request.json
db = load_db()

db["graph"]["edges"].append(data)
save_db(db)

return jsonify({"status": "edge_added"})


# =========================
# STATUS
# =========================
@app.route("/status")
def status():
return jsonify({
"status": "online",
"engine": "MUCIZEWORK_WEB4_FULL_STACK",
})


if __name__ == "__main__":
print("WEB4 FULL STACK ACTIVE")
print("PORT: 5080")
app.run(port=5080, debug=False)
19 changes: 19 additions & 0 deletions web4_full/engine/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import requests

BASE = "http://127.0.0.1:5080"

c = requests.get(BASE + "/challenge/AJAN").json()
print("CHALLENGE:", c)

print("LOGIN ATTEMPT (needs real signature):")

r = requests.post(BASE + "/login", json={
"wallet": "AJAN",
"message": c["message"],
"signature": "DEMO",
})

print("LOGIN:", r.json())

print("GRAPH:", requests.get(BASE + "/graph").json())
print("STATUS:", requests.get(BASE + "/status").json())
5 changes: 5 additions & 0 deletions web4_full/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flask
pyjwt
pynacl
base58
requests
2 changes: 2 additions & 0 deletions web4_full/start.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd C:\Users\enver\mzc-engine-v3\web4_full\engine
python app.py
3 changes: 3 additions & 0 deletions web4_full/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
cd "$(dirname "$0")/engine"
python app.py