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.
@@ -23,7 +23,7 @@ repos:
23
23
 
24
24
  - repo: https://github.com/astral-sh/ruff-pre-commit
25
25
  ### Ruff version.
26
- rev: v0.6.4
26
+ rev: v0.12.7
27
27
  hooks:
28
28
  ### Run the linter.
29
29
  - id: ruff
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xn-auth
3
- Version: 0.2.38
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
@@ -12,6 +12,7 @@ dynamic = ["version"]
12
12
 
13
13
  dependencies = [
14
14
  'aiogram',
15
+ 'kurigram',
15
16
  'msgspec',
16
17
  "pyjwt",
17
18
  "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 TgUser
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: TgUser, blocked: bool = None) -> BaseUpd:
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 pyro_upsert(cls, u: TgUser, blocked: bool = None) -> tuple["User", bool]:
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.38
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,4 +1,5 @@
1
1
  aiogram
2
+ kurigram
2
3
  msgspec
3
4
  pyjwt
4
5
  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