mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-01 05:00:34 +00:00
RFC & SSH exchange for development
This commit is contained in:
parent
19f50d6d95
commit
46689d6477
22 changed files with 418 additions and 157 deletions
|
|
@ -3,8 +3,7 @@ import inspect
|
|||
import json
|
||||
from typing import Any, TypedDict
|
||||
import aiohttp
|
||||
import hmac
|
||||
import hashlib
|
||||
from python.helpers import crypto
|
||||
|
||||
from python.helpers import dotenv
|
||||
|
||||
|
|
@ -36,14 +35,14 @@ async def call_rfc(
|
|||
kwargs=kwargs,
|
||||
)
|
||||
call = RFCCall(
|
||||
rfc_input=json.dumps(input), hash=hash_data(json.dumps(input), password)
|
||||
rfc_input=json.dumps(input), hash=crypto.hash_data(json.dumps(input), password)
|
||||
)
|
||||
result = await _send_json_data(url, call)
|
||||
return result
|
||||
|
||||
|
||||
async def handle_rfc(rfc_call: RFCCall, password: str):
|
||||
if not verify_data(rfc_call["rfc_input"], rfc_call["hash"], password):
|
||||
if not crypto.verify_data(rfc_call["rfc_input"], rfc_call["hash"], password):
|
||||
raise Exception("Invalid RFC hash")
|
||||
|
||||
input: RFCInput = json.loads(rfc_call["rfc_input"])
|
||||
|
|
@ -80,11 +79,3 @@ async def _send_json_data(url: str, data):
|
|||
else:
|
||||
error = await response.text()
|
||||
raise Exception(error)
|
||||
|
||||
|
||||
def hash_data(data: str, password: str):
|
||||
return hmac.new(password.encode(), data.encode(), hashlib.sha256).hexdigest()
|
||||
|
||||
|
||||
def verify_data(data: str, hash: str, password: str):
|
||||
return hash_data(data, password) == hash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue