xn-auth 0.2.38__tar.gz → 0.2.39__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.
- {xn_auth-0.2.38 → xn_auth-0.2.39}/.pre-commit-config.yaml +1 -1
- {xn_auth-0.2.38/xn_auth.egg-info → xn_auth-0.2.39}/PKG-INFO +2 -1
- {xn_auth-0.2.38 → xn_auth-0.2.39}/pyproject.toml +1 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/x_auth/models.py +6 -14
- {xn_auth-0.2.38 → xn_auth-0.2.39/xn_auth.egg-info}/PKG-INFO +2 -1
- {xn_auth-0.2.38 → xn_auth-0.2.39}/xn_auth.egg-info/requires.txt +1 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/.env.dist +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/.gitignore +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/README.md +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/makefile +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/setup.cfg +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/x_auth/controller.py +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/x_auth/enums.py +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/x_auth/exceptions.py +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/x_auth/middleware.py +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/x_auth/types.py +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/xn_auth.egg-info/SOURCES.txt +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/xn_auth.egg-info/dependency_links.txt +0 -0
- {xn_auth-0.2.38 → xn_auth-0.2.39}/xn_auth.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xn-auth
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.39
|
|
4
4
|
Summary: Auth adapter for XN-Api framework
|
|
5
5
|
Author-email: Artemiev <mixartemev@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -10,6 +10,7 @@ Keywords: litestar,jwt,auth
|
|
|
10
10
|
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: aiogram
|
|
13
|
+
Requires-Dist: kurigram
|
|
13
14
|
Requires-Dist: msgspec
|
|
14
15
|
Requires-Dist: pyjwt
|
|
15
16
|
Requires-Dist: xn-model
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
|
|
3
|
+
from aiogram.utils.web_app import WebAppUser
|
|
3
4
|
from aiohttp import ClientSession
|
|
4
5
|
from msgspec import convert
|
|
5
6
|
from pyrogram.enums.client_platform import ClientPlatform
|
|
6
|
-
from pyrogram.types import User as
|
|
7
|
+
from pyrogram.types import User as PyroUser
|
|
8
|
+
from aiogram.types import User as AioUser
|
|
7
9
|
from tortoise.fields import (
|
|
8
10
|
BigIntField,
|
|
9
11
|
BooleanField,
|
|
@@ -31,7 +33,6 @@ from tortoise import Model as TortModel
|
|
|
31
33
|
from x_model.types import BaseUpd
|
|
32
34
|
|
|
33
35
|
from x_auth.enums import Lang, Role, PeerType
|
|
34
|
-
from x_auth.types import AuthUser
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
class Username(TortModel):
|
|
@@ -55,11 +56,8 @@ class User(Model):
|
|
|
55
56
|
|
|
56
57
|
app: BackwardOneToOneRelation["App"]
|
|
57
58
|
|
|
58
|
-
def get_auth(self) -> AuthUser:
|
|
59
|
-
return AuthUser.model_validate(self, from_attributes=True)
|
|
60
|
-
|
|
61
59
|
@classmethod
|
|
62
|
-
async def tg2in(cls, u:
|
|
60
|
+
async def tg2in(cls, u: PyroUser | AioUser | WebAppUser, blocked: bool = None) -> BaseUpd:
|
|
63
61
|
un, _ = await cls._meta.fields_map["username"].related_model.update_or_create({"username": u.username}, id=u.id)
|
|
64
62
|
user = cls.validate(
|
|
65
63
|
{
|
|
@@ -78,7 +76,7 @@ class User(Model):
|
|
|
78
76
|
return (await cls[int(sid)]).blocked
|
|
79
77
|
|
|
80
78
|
@classmethod
|
|
81
|
-
async def
|
|
79
|
+
async def tg_upsert(cls, u: PyroUser | AioUser, blocked: bool = None) -> tuple["User", bool]:
|
|
82
80
|
user_in: cls.in_type() = await cls.tg2in(u, blocked)
|
|
83
81
|
prms = user_in.df_unq()
|
|
84
82
|
return await cls.update_or_create(**prms)
|
|
@@ -87,13 +85,6 @@ class User(Model):
|
|
|
87
85
|
# abstract = True
|
|
88
86
|
|
|
89
87
|
|
|
90
|
-
# @pre_save(User)
|
|
91
|
-
# async def username(_meta, user: User, _db, _updated: dict) -> None:
|
|
92
|
-
# if user.username_id:
|
|
93
|
-
# return
|
|
94
|
-
# user.username = await Username.create(name=user.username)
|
|
95
|
-
|
|
96
|
-
|
|
97
88
|
class Country(Model):
|
|
98
89
|
id = SmallIntField(True)
|
|
99
90
|
code: int | None = IntField(null=True)
|
|
@@ -170,6 +161,7 @@ class Proxy(Model, TsTrait):
|
|
|
170
161
|
return dict(scheme="socks5", hostname=self.host, port=self.port, username=self.username, password=self.password)
|
|
171
162
|
|
|
172
163
|
def str(self):
|
|
164
|
+
# noinspection HttpUrlsUsage
|
|
173
165
|
return f"http://{self.username}:{self.password}@{self.host}:{self.port}"
|
|
174
166
|
|
|
175
167
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xn-auth
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.39
|
|
4
4
|
Summary: Auth adapter for XN-Api framework
|
|
5
5
|
Author-email: Artemiev <mixartemev@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -10,6 +10,7 @@ Keywords: litestar,jwt,auth
|
|
|
10
10
|
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: aiogram
|
|
13
|
+
Requires-Dist: kurigram
|
|
13
14
|
Requires-Dist: msgspec
|
|
14
15
|
Requires-Dist: pyjwt
|
|
15
16
|
Requires-Dist: xn-model
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|