sharkeyes-lib 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,4 @@
1
+ from .sharkeyes import configure, verify
2
+
3
+ # Явно указываем, что доступно для импорта извне
4
+ __all__ = ['configure', 'verify']
@@ -0,0 +1,69 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger(__name__)
4
+
5
+ _API_KEY: str = ""
6
+ _URL: str = "https://api.sharkeyes.dev/api/v2/server-verify"
7
+ _TIMEOUT: float = 5.0
8
+
9
+
10
+ def configure(api_key: str, url: str = None, timeout: float = None):
11
+ global _API_KEY, _URL, _TIMEOUT
12
+ _API_KEY = api_key
13
+ if url:
14
+ _URL = url
15
+ if timeout:
16
+ _TIMEOUT = timeout
17
+
18
+
19
+
20
+ def _extract_ip(request):
21
+ if hasattr(request, 'META'):
22
+ x_ff = request.META.get('HTTP_X_FORWARDED_FOR')
23
+ if x_ff:
24
+ return x_ff.split(',')[0].strip()
25
+ return request.META.get('REMOTE_ADDR')
26
+ if hasattr(request, 'headers'):
27
+ x_ff = request.headers.get('x-forwarded-for')
28
+ if x_ff:
29
+ return x_ff.split(',')[0].strip()
30
+ if hasattr(request, 'client') and request.client:
31
+ return request.client.host
32
+ return "127.0.0.1"
33
+
34
+
35
+ def verify(token: str, request_obj) -> tuple:
36
+
37
+ if not _API_KEY:
38
+ raise RuntimeError("First, call sharkeyes.configure(api_key='...')")
39
+ user_ip = _extract_ip(request_obj)
40
+ if not token or not token.strip():
41
+ return False, "Enable JavaScript."
42
+
43
+ try:
44
+ import httpx
45
+
46
+ resp = httpx.post(
47
+ _URL,
48
+ json={
49
+ "verification_token": token.strip(),
50
+ "user_ip": user_ip
51
+ },
52
+ headers={"X-Api-Key": _API_KEY},
53
+ timeout=_TIMEOUT,
54
+ )
55
+
56
+ if resp.status_code != 200:
57
+ return False, f"Verification error (Status: {resp.status_code})"
58
+
59
+ data = resp.json()
60
+
61
+ if data.get("is_bot") is False:
62
+ return True, None
63
+
64
+ return False, data.get("reason", "Verification failed.")
65
+
66
+
67
+ except Exception as e:
68
+ logger.error("[SharkEyes] %s", e)
69
+ return False, "Technical error during verification."
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: sharkeyes-lib
3
+ Version: 1.0.0
4
+ Summary: Python client for SharkEyes bot-detection API
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/SharkEyes-Dev/SharkEyes-Lib
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: httpx>=0.23.0
11
+ Dynamic: license-file
@@ -0,0 +1,7 @@
1
+ sharkeyes_lib/__init__.py,sha256=xl4J526vFgMHBxyglscES1qAcu80dPOYnlhWdK5OhAE,164
2
+ sharkeyes_lib/sharkeyes.py,sha256=AGzi0ymnHXbH2Emp83s2okeDKiJa4AxufRJrT2TVyF4,1852
3
+ sharkeyes_lib-1.0.0.dist-info/licenses/LICENSE,sha256=96xsptTwowYiQvLJ8osq7ImNe5jE8qgTDH3BFiSX9y0,1070
4
+ sharkeyes_lib-1.0.0.dist-info/METADATA,sha256=eY2Z4Og_QtbVaoGQKsh3m3A2BGm5gNWGX9vWmWOIGNo,331
5
+ sharkeyes_lib-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ sharkeyes_lib-1.0.0.dist-info/top_level.txt,sha256=nomE9QpKNSrECjnqKPq6Bx04UB2KjJKHDIXVDgtnS-M,14
7
+ sharkeyes_lib-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SharkEyes-Dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ sharkeyes_lib