dominusnode-dify 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-dify might be problematic. Click here for more details.
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/PKG-INFO +1 -1
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify/tools.py +51 -2
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify.egg-info/PKG-INFO +1 -1
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/pyproject.toml +1 -1
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/LICENSE +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/README.md +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify/__init__.py +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify.egg-info/SOURCES.txt +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify.egg-info/dependency_links.txt +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify.egg-info/requires.txt +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify.egg-info/top_level.txt +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/setup.cfg +0 -0
- {dominusnode_dify-1.2.0 → dominusnode_dify-1.2.1}/tests/test_tools.py +0 -0
|
@@ -12,6 +12,7 @@ protections.
|
|
|
12
12
|
|
|
13
13
|
from __future__ import annotations
|
|
14
14
|
|
|
15
|
+
import hashlib
|
|
15
16
|
import ipaddress
|
|
16
17
|
import json
|
|
17
18
|
import math
|
|
@@ -351,6 +352,46 @@ def _sanitize_error(message: str) -> str:
|
|
|
351
352
|
return _CREDENTIAL_RE.sub("***", message)
|
|
352
353
|
|
|
353
354
|
|
|
355
|
+
def _count_leading_zero_bits(data: bytes) -> int:
|
|
356
|
+
"""Count leading zero bits in a byte array."""
|
|
357
|
+
count = 0
|
|
358
|
+
for byte in data:
|
|
359
|
+
if byte == 0:
|
|
360
|
+
count += 8
|
|
361
|
+
else:
|
|
362
|
+
mask = 0x80
|
|
363
|
+
while mask and not (byte & mask):
|
|
364
|
+
count += 1
|
|
365
|
+
mask >>= 1
|
|
366
|
+
break
|
|
367
|
+
return count
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def _solve_pow(base_url: str) -> Optional[dict]:
|
|
371
|
+
"""Solve a Proof-of-Work challenge for CAPTCHA-free registration."""
|
|
372
|
+
try:
|
|
373
|
+
pow_url = f"{base_url.rstrip('/')}/api/auth/pow/challenge"
|
|
374
|
+
with httpx.Client(timeout=30.0, follow_redirects=False) as client:
|
|
375
|
+
resp = client.post(pow_url, headers={"Content-Type": "application/json"})
|
|
376
|
+
if resp.status_code >= 400:
|
|
377
|
+
return None
|
|
378
|
+
challenge = resp.json()
|
|
379
|
+
prefix = challenge.get("prefix", "")
|
|
380
|
+
difficulty = challenge.get("difficulty", 20)
|
|
381
|
+
challenge_id = challenge.get("challengeId", "")
|
|
382
|
+
if not prefix or not challenge_id:
|
|
383
|
+
return None
|
|
384
|
+
nonce = 0
|
|
385
|
+
while nonce < 100_000_000:
|
|
386
|
+
h = hashlib.sha256((prefix + str(nonce)).encode()).digest()
|
|
387
|
+
if _count_leading_zero_bits(h) >= difficulty:
|
|
388
|
+
return {"challengeId": challenge_id, "nonce": str(nonce)}
|
|
389
|
+
nonce += 1
|
|
390
|
+
return None
|
|
391
|
+
except Exception:
|
|
392
|
+
return None
|
|
393
|
+
|
|
394
|
+
|
|
354
395
|
# ---------------------------------------------------------------------------
|
|
355
396
|
# Prototype pollution prevention
|
|
356
397
|
# ---------------------------------------------------------------------------
|
|
@@ -1837,12 +1878,20 @@ class DominusNodeProvider:
|
|
|
1837
1878
|
return {"error": "password must be 128 characters or fewer"}
|
|
1838
1879
|
|
|
1839
1880
|
try:
|
|
1881
|
+
body: dict = {"email": email, "password": password}
|
|
1882
|
+
pow_result = _solve_pow(self.base_url)
|
|
1883
|
+
if pow_result:
|
|
1884
|
+
body["pow"] = pow_result
|
|
1840
1885
|
result = self._unauthenticated_request(
|
|
1841
1886
|
"POST",
|
|
1842
1887
|
"/api/auth/register",
|
|
1843
|
-
|
|
1888
|
+
body,
|
|
1844
1889
|
)
|
|
1845
|
-
|
|
1890
|
+
if not isinstance(result, dict):
|
|
1891
|
+
result = {"data": result}
|
|
1892
|
+
if pow_result:
|
|
1893
|
+
result["_pow_verified"] = True
|
|
1894
|
+
return result
|
|
1846
1895
|
except Exception as e:
|
|
1847
1896
|
return {"error": _sanitize_error(str(e))}
|
|
1848
1897
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dominusnode-dify"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.1"
|
|
8
8
|
description = "Dominus Node tool provider for Dify -- 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_dify-1.2.0 → dominusnode_dify-1.2.1}/dominusnode_dify.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|