nexawaresauth 1.0.0__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.
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: nexawaresauth
3
+ Version: 1.0.0
4
+ Summary: NEXA Wares Authentication Library
5
+ Author: Mehrab
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: requests
8
+ Dynamic: author
9
+ Dynamic: requires-dist
10
+ Dynamic: requires-python
11
+ Dynamic: summary
@@ -0,0 +1 @@
1
+ from .nexawaresauth import api
@@ -0,0 +1,114 @@
1
+ # nexawaresauth.py
2
+
3
+ import requests
4
+ import hashlib
5
+ import platform
6
+ import uuid
7
+
8
+ class api:
9
+ def __init__(
10
+ self,
11
+ name: str,
12
+ secret: str,
13
+ version: str = "1.0",
14
+ host: str = "https://iran.nexawares.ir"
15
+ ):
16
+ self.name = name
17
+ self.secret = secret
18
+ self.version = version
19
+ self.host = host.rstrip("/")
20
+ self.sessionid = None
21
+ self.user_data = None
22
+
23
+ def _post(self, payload):
24
+ r = requests.post(
25
+ f"{self.host}/api/1.0",
26
+ data=payload,
27
+ timeout=15
28
+ )
29
+
30
+ r.raise_for_status()
31
+ return r.json()
32
+
33
+ def get_hwid(self):
34
+ raw = (
35
+ platform.node() +
36
+ platform.machine() +
37
+ str(uuid.getnode())
38
+ )
39
+
40
+ return hashlib.sha256(raw.encode()).hexdigest()
41
+
42
+ def init(self):
43
+ data = self._post({
44
+ "type": "init",
45
+ "name": self.name,
46
+ "secret": self.secret
47
+ })
48
+
49
+ if not data.get("success"):
50
+ raise Exception(data.get("message", "Initialization failed"))
51
+
52
+ self.sessionid = data.get("sessionid")
53
+ return data
54
+
55
+ def license(self, key: str):
56
+ if not self.sessionid:
57
+ self.init()
58
+
59
+ data = self._post({
60
+ "type": "login",
61
+ "sessionid": self.sessionid,
62
+ "name": self.name,
63
+ "secret": self.secret,
64
+ "license": key,
65
+ "hwid": self.get_hwid()
66
+ })
67
+
68
+ self.user_data = data
69
+ return data
70
+
71
+ def login(self, username: str, password: str):
72
+ if not self.sessionid:
73
+ self.init()
74
+
75
+ data = self._post({
76
+ "type": "login_user",
77
+ "sessionid": self.sessionid,
78
+ "name": self.name,
79
+ "secret": self.secret,
80
+ "username": username,
81
+ "password": password,
82
+ "hwid": self.get_hwid()
83
+ })
84
+
85
+ self.user_data = data
86
+ return data
87
+
88
+ def redeem(self, username, password, license_key):
89
+ return self._post({
90
+ "type": "redeem",
91
+ "sessionid": self.sessionid,
92
+ "name": self.name,
93
+ "secret": self.secret,
94
+ "username": username,
95
+ "password": password,
96
+ "license": license_key,
97
+ "hwid": self.get_hwid()
98
+ })
99
+
100
+ def license_info(self, license_key):
101
+ return self._post({
102
+ "type": "license_info",
103
+ "sessionid": self.sessionid,
104
+ "name": self.name,
105
+ "secret": self.secret,
106
+ "license": license_key
107
+ })
108
+
109
+ @property
110
+ def success(self):
111
+ if not self.user_data:
112
+ return False
113
+
114
+ return bool(self.user_data.get("success"))
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: nexawaresauth
3
+ Version: 1.0.0
4
+ Summary: NEXA Wares Authentication Library
5
+ Author: Mehrab
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: requests
8
+ Dynamic: author
9
+ Dynamic: requires-dist
10
+ Dynamic: requires-python
11
+ Dynamic: summary
@@ -0,0 +1,9 @@
1
+ pyproject.toml
2
+ setup.py
3
+ nexawaresauth/__init__.py
4
+ nexawaresauth/nexawaresauth.py
5
+ nexawaresauth.egg-info/PKG-INFO
6
+ nexawaresauth.egg-info/SOURCES.txt
7
+ nexawaresauth.egg-info/dependency_links.txt
8
+ nexawaresauth.egg-info/requires.txt
9
+ nexawaresauth.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests
@@ -0,0 +1 @@
1
+ nexawaresauth
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="nexawaresauth",
5
+ version="1.0.0",
6
+ author="Mehrab",
7
+ description="NEXA Wares Authentication Library",
8
+ packages=find_packages(),
9
+ install_requires=["requests"],
10
+ python_requires=">=3.8",
11
+ )