dominusnode-crewai 1.2.0__tar.gz → 1.2.1__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.
Potentially problematic release.
This version of dominusnode-crewai might be problematic. Click here for more details.
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/PKG-INFO +1 -1
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/dominusnode_crewai/tools.py +48 -2
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/pyproject.toml +1 -1
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/.gitignore +0 -0
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/CHANGELOG.md +0 -0
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/LICENSE +0 -0
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/README.md +0 -0
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/conftest.py +0 -0
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/dominusnode_crewai/__init__.py +0 -0
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/tests/__init__.py +0 -0
- {dominusnode_crewai-1.2.0 → dominusnode_crewai-1.2.1}/tests/test_tools.py +0 -0
|
@@ -12,6 +12,7 @@ Security:
|
|
|
12
12
|
|
|
13
13
|
from __future__ import annotations
|
|
14
14
|
|
|
15
|
+
import hashlib
|
|
15
16
|
import ipaddress
|
|
16
17
|
import math
|
|
17
18
|
import os
|
|
@@ -50,6 +51,46 @@ def _sanitize_error(message: str) -> str:
|
|
|
50
51
|
return _CREDENTIAL_RE.sub("***", message)
|
|
51
52
|
|
|
52
53
|
|
|
54
|
+
def _count_leading_zero_bits(data: bytes) -> int:
|
|
55
|
+
"""Count leading zero bits in a byte array."""
|
|
56
|
+
count = 0
|
|
57
|
+
for byte in data:
|
|
58
|
+
if byte == 0:
|
|
59
|
+
count += 8
|
|
60
|
+
else:
|
|
61
|
+
mask = 0x80
|
|
62
|
+
while mask and not (byte & mask):
|
|
63
|
+
count += 1
|
|
64
|
+
mask >>= 1
|
|
65
|
+
break
|
|
66
|
+
return count
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _solve_pow(base_url: str) -> Optional[dict]:
|
|
70
|
+
"""Solve a Proof-of-Work challenge for CAPTCHA-free registration."""
|
|
71
|
+
try:
|
|
72
|
+
pow_url = f"{base_url}/api/auth/pow/challenge"
|
|
73
|
+
with httpx.Client(timeout=30.0, follow_redirects=False) as client:
|
|
74
|
+
resp = client.post(pow_url, headers={"Content-Type": "application/json"})
|
|
75
|
+
if resp.status_code >= 400:
|
|
76
|
+
return None
|
|
77
|
+
challenge = resp.json()
|
|
78
|
+
prefix = challenge.get("prefix", "")
|
|
79
|
+
difficulty = challenge.get("difficulty", 20)
|
|
80
|
+
challenge_id = challenge.get("challengeId", "")
|
|
81
|
+
if not prefix or not challenge_id:
|
|
82
|
+
return None
|
|
83
|
+
nonce = 0
|
|
84
|
+
while nonce < 100_000_000:
|
|
85
|
+
h = hashlib.sha256((prefix + str(nonce)).encode()).digest()
|
|
86
|
+
if _count_leading_zero_bits(h) >= difficulty:
|
|
87
|
+
return {"challengeId": challenge_id, "nonce": str(nonce)}
|
|
88
|
+
nonce += 1
|
|
89
|
+
return None
|
|
90
|
+
except Exception:
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
|
|
53
94
|
# ---------------------------------------------------------------------------
|
|
54
95
|
# Prototype pollution prevention
|
|
55
96
|
# ---------------------------------------------------------------------------
|
|
@@ -2123,13 +2164,18 @@ class DominusNodeRegisterTool(BaseTool):
|
|
|
2123
2164
|
url = self.base_url or os.environ.get("DOMINUSNODE_BASE_URL", "https://api.dominusnode.com")
|
|
2124
2165
|
|
|
2125
2166
|
try:
|
|
2126
|
-
|
|
2167
|
+
body: dict = {"email": email, "password": password}
|
|
2168
|
+
pow_result = _solve_pow(url)
|
|
2169
|
+
if pow_result:
|
|
2170
|
+
body["pow"] = pow_result
|
|
2171
|
+
result = _api_request_unauth(url, "POST", "/api/auth/register", body)
|
|
2172
|
+
pow_msg = "Email auto-verified via Proof-of-Work." if pow_result else "Check your email for a verification link."
|
|
2127
2173
|
return (
|
|
2128
2174
|
f"Registration Successful\n"
|
|
2129
2175
|
f" User ID: {result.get('id', 'unknown')}\n"
|
|
2130
2176
|
f" Email: {result.get('email', email)}\n"
|
|
2131
2177
|
f" Status: {result.get('status', 'pending verification')}\n\n"
|
|
2132
|
-
f"
|
|
2178
|
+
f"{pow_msg}"
|
|
2133
2179
|
)
|
|
2134
2180
|
except httpx.HTTPStatusError as exc:
|
|
2135
2181
|
return f"Error: API returned {exc.response.status_code} -- {_sanitize_error(exc.response.text[:200])}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|