dominusnode-moltbook 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.

Potentially problematic release.


This version of dominusnode-moltbook might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dominusnode-moltbook
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: Dominus Node integration for Moltbook -- interact with the AI agent social network through rotating proxies
5
5
  License: MIT
6
6
  Requires-Python: >=3.10
@@ -373,6 +373,46 @@ def _sanitize_error(message: str) -> str:
373
373
  return result
374
374
 
375
375
 
376
+ def _count_leading_zero_bits(data: bytes) -> int:
377
+ """Count leading zero bits in a byte array."""
378
+ count = 0
379
+ for byte in data:
380
+ if byte == 0:
381
+ count += 8
382
+ else:
383
+ mask = 0x80
384
+ while mask and not (byte & mask):
385
+ count += 1
386
+ mask >>= 1
387
+ break
388
+ return count
389
+
390
+
391
+ def _solve_pow(base_url: str) -> Optional[dict]:
392
+ """Solve a Proof-of-Work challenge for CAPTCHA-free registration."""
393
+ try:
394
+ pow_url = f"{base_url.rstrip('/')}/api/auth/pow/challenge"
395
+ with httpx.Client(timeout=30.0, follow_redirects=False) as client:
396
+ resp = client.post(pow_url, headers={"Content-Type": "application/json"})
397
+ if resp.status_code >= 400:
398
+ return None
399
+ challenge = resp.json()
400
+ prefix = challenge.get("prefix", "")
401
+ difficulty = challenge.get("difficulty", 20)
402
+ challenge_id = challenge.get("challengeId", "")
403
+ if not prefix or not challenge_id:
404
+ return None
405
+ nonce = 0
406
+ while nonce < 100_000_000:
407
+ h = hashlib.sha256((prefix + str(nonce)).encode()).digest()
408
+ if _count_leading_zero_bits(h) >= difficulty:
409
+ return {"challengeId": challenge_id, "nonce": str(nonce)}
410
+ nonce += 1
411
+ return None
412
+ except Exception:
413
+ return None
414
+
415
+
376
416
  # ---------------------------------------------------------------------------
377
417
  # Prototype pollution prevention
378
418
  # ---------------------------------------------------------------------------
@@ -2170,6 +2210,10 @@ class MoltbookClient:
2170
2210
  return json.dumps({"error": "password must be 128 characters or fewer"})
2171
2211
 
2172
2212
  try:
2213
+ body: dict = {"email": email, "password": password}
2214
+ pow_result = _solve_pow(self.dominusnode_base_url)
2215
+ if pow_result:
2216
+ body["pow"] = pow_result
2173
2217
  headers: Dict[str, str] = {
2174
2218
  "User-Agent": "dominusnode-moltbook/1.0.0",
2175
2219
  "Content-Type": "application/json",
@@ -2183,7 +2227,7 @@ class MoltbookClient:
2183
2227
  ) as client:
2184
2228
  resp = client.post(
2185
2229
  f"{self.dominusnode_base_url}/api/auth/register",
2186
- json={"email": email, "password": password},
2230
+ json=body,
2187
2231
  headers=headers,
2188
2232
  )
2189
2233
  if len(resp.content) > MAX_RESPONSE_BYTES:
@@ -2198,8 +2242,10 @@ class MoltbookClient:
2198
2242
  if resp.text:
2199
2243
  data = resp.json()
2200
2244
  _strip_dangerous_keys(data)
2245
+ if pow_result:
2246
+ data["_pow_verified"] = True
2201
2247
  return json.dumps(data)
2202
- return json.dumps({})
2248
+ return json.dumps({"_pow_verified": True} if pow_result else {})
2203
2249
  except Exception as e:
2204
2250
  return json.dumps({"error": _sanitize_error(str(e))})
2205
2251
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dominusnode-moltbook
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: Dominus Node integration for Moltbook -- interact with the AI agent social network through rotating proxies
5
5
  License: MIT
6
6
  Requires-Python: >=3.10
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dominusnode-moltbook"
7
- version = "1.2.2"
7
+ version = "1.2.3"
8
8
  description = "Dominus Node integration for Moltbook -- interact with the AI agent social network through rotating proxies"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}