dominusnode-superagi 1.2.2__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/PKG-INFO +1 -1
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi/tools.py +48 -1
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi.egg-info/PKG-INFO +1 -1
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/pyproject.toml +1 -1
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/LICENSE +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/README.md +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi/__init__.py +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi/toolkit.py +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi.egg-info/SOURCES.txt +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi.egg-info/dependency_links.txt +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi.egg-info/requires.txt +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi.egg-info/top_level.txt +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/setup.cfg +0 -0
- {dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/tests/test_tools.py +0 -0
|
@@ -34,6 +34,7 @@ Requires: httpx (``pip install httpx``)
|
|
|
34
34
|
|
|
35
35
|
from __future__ import annotations
|
|
36
36
|
|
|
37
|
+
import hashlib
|
|
37
38
|
import ipaddress
|
|
38
39
|
import json
|
|
39
40
|
import math
|
|
@@ -387,6 +388,46 @@ def _sanitize_error(message: str) -> str:
|
|
|
387
388
|
return _CREDENTIAL_RE.sub("***", message)
|
|
388
389
|
|
|
389
390
|
|
|
391
|
+
def _count_leading_zero_bits(data: bytes) -> int:
|
|
392
|
+
"""Count leading zero bits in a byte array."""
|
|
393
|
+
count = 0
|
|
394
|
+
for byte in data:
|
|
395
|
+
if byte == 0:
|
|
396
|
+
count += 8
|
|
397
|
+
else:
|
|
398
|
+
mask = 0x80
|
|
399
|
+
while mask and not (byte & mask):
|
|
400
|
+
count += 1
|
|
401
|
+
mask >>= 1
|
|
402
|
+
break
|
|
403
|
+
return count
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
def _solve_pow(base_url: str) -> Optional[dict]:
|
|
407
|
+
"""Solve a Proof-of-Work challenge for CAPTCHA-free registration."""
|
|
408
|
+
try:
|
|
409
|
+
pow_url = f"{base_url.rstrip('/')}/api/auth/pow/challenge"
|
|
410
|
+
with httpx.Client(timeout=30.0, follow_redirects=False) as client:
|
|
411
|
+
resp = client.post(pow_url, headers={"Content-Type": "application/json"})
|
|
412
|
+
if resp.status_code >= 400:
|
|
413
|
+
return None
|
|
414
|
+
challenge = resp.json()
|
|
415
|
+
prefix = challenge.get("prefix", "")
|
|
416
|
+
difficulty = challenge.get("difficulty", 20)
|
|
417
|
+
challenge_id = challenge.get("challengeId", "")
|
|
418
|
+
if not prefix or not challenge_id:
|
|
419
|
+
return None
|
|
420
|
+
nonce = 0
|
|
421
|
+
while nonce < 100_000_000:
|
|
422
|
+
h = hashlib.sha256((prefix + str(nonce)).encode()).digest()
|
|
423
|
+
if _count_leading_zero_bits(h) >= difficulty:
|
|
424
|
+
return {"challengeId": challenge_id, "nonce": str(nonce)}
|
|
425
|
+
nonce += 1
|
|
426
|
+
return None
|
|
427
|
+
except Exception:
|
|
428
|
+
return None
|
|
429
|
+
|
|
430
|
+
|
|
390
431
|
# ---------------------------------------------------------------------------
|
|
391
432
|
# Prototype pollution prevention
|
|
392
433
|
# ---------------------------------------------------------------------------
|
|
@@ -1798,11 +1839,17 @@ class _DominusNodeClient:
|
|
|
1798
1839
|
return json.dumps({"error": err})
|
|
1799
1840
|
|
|
1800
1841
|
try:
|
|
1842
|
+
body: dict = {"email": email.strip(), "password": password}
|
|
1843
|
+
pow_result = _solve_pow(self.base_url)
|
|
1844
|
+
if pow_result:
|
|
1845
|
+
body["pow"] = pow_result
|
|
1801
1846
|
result = self._unauthenticated_request(
|
|
1802
1847
|
"POST",
|
|
1803
1848
|
"/api/auth/register",
|
|
1804
|
-
|
|
1849
|
+
body,
|
|
1805
1850
|
)
|
|
1851
|
+
if pow_result and isinstance(result, dict):
|
|
1852
|
+
result["_pow_verified"] = True
|
|
1806
1853
|
return json.dumps(result)
|
|
1807
1854
|
except Exception as e:
|
|
1808
1855
|
return json.dumps({"error": _sanitize_error(str(e))})
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dominusnode-superagi"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.3"
|
|
8
8
|
description = "Dominus Node toolkit for SuperAGI -- 22 proxy, wallet, and team management tools"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dominusnode_superagi-1.2.2 → dominusnode_superagi-1.2.3}/dominusnode_superagi.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|