clipcloudlib 0.4.13__tar.gz → 0.4.16__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.
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/PKG-INFO +6 -1
- clipcloudlib-0.4.16/clipcloudlib/auth.py +82 -0
- clipcloudlib-0.4.16/clipcloudlib/config.py +14 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/enums.py +10 -1
- clipcloudlib-0.4.16/clipcloudlib/repositories/redis/room_member.py +67 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/schemas/__init__.py +2 -1
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/schemas/events.py +69 -27
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/schemas/message.py +1 -1
- clipcloudlib-0.4.16/clipcloudlib/schemas/presence.py +10 -0
- clipcloudlib-0.4.16/clipcloudlib/schemas/promo.py +11 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/schemas/room.py +7 -1
- clipcloudlib-0.4.16/clipcloudlib/session.py +48 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib.egg-info/PKG-INFO +6 -1
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib.egg-info/SOURCES.txt +6 -0
- clipcloudlib-0.4.16/clipcloudlib.egg-info/requires.txt +6 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/pyproject.toml +6 -1
- clipcloudlib-0.4.13/clipcloudlib.egg-info/requires.txt +0 -1
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/README.md +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/__init__.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/exceptions.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/mappers/__init__.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/mappers/base.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/mappers/room.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/mappers/session.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/models/redis/__init__.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/models/redis/base.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/models/redis/room.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/models/redis/session.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/required.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/schemas/file.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib/schemas/session.py +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib.egg-info/dependency_links.txt +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/clipcloudlib.egg-info/top_level.txt +0 -0
- {clipcloudlib-0.4.13 → clipcloudlib-0.4.16}/setup.cfg +0 -0
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clipcloudlib
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.16
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Project-URL: Repository, https://github.com/rorka491/clipcloud-lib.git
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: pydantic>=2.13.4
|
|
9
|
+
Requires-Dist: fastapi>=0.135.1
|
|
10
|
+
Requires-Dist: httpx>=0.28.1
|
|
11
|
+
Requires-Dist: pyjwt[crypto]>=2.13.0
|
|
12
|
+
Requires-Dist: pydantic-settings>=2.16.2
|
|
13
|
+
Requires-Dist: redis>=8.1.0
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
from typing import Optional, Callable
|
|
2
|
+
import asyncio
|
|
3
|
+
import httpx
|
|
4
|
+
import jwt
|
|
5
|
+
from jwt.exceptions import PyJWTError
|
|
6
|
+
from fastapi import HTTPException
|
|
7
|
+
from clipcloudlib.exceptions import InvalidTokenException
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TokenService:
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
public_key: bytes,
|
|
14
|
+
alghoritms: list,
|
|
15
|
+
):
|
|
16
|
+
self.alghoritms = alghoritms
|
|
17
|
+
self._public_key = public_key
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def public_key(self):
|
|
22
|
+
return self._public_key
|
|
23
|
+
|
|
24
|
+
def _verify_token(self, token: str) -> dict:
|
|
25
|
+
try:
|
|
26
|
+
payload = jwt.decode(
|
|
27
|
+
token, self.public_key, algorithms=self.alghoritms # pyright: ignore[reportArgumentType]
|
|
28
|
+
)
|
|
29
|
+
except PyJWTError as e:
|
|
30
|
+
raise HTTPException(
|
|
31
|
+
detail=str(e),
|
|
32
|
+
status_code=401
|
|
33
|
+
)
|
|
34
|
+
# if payload.get("is_active") is False:
|
|
35
|
+
# raise UserIsNotActive
|
|
36
|
+
return payload
|
|
37
|
+
|
|
38
|
+
def verify_access_token(self, token: str) -> dict:
|
|
39
|
+
payload = self._verify_token(token)
|
|
40
|
+
if payload.get("type") != "access":
|
|
41
|
+
raise InvalidTokenException
|
|
42
|
+
return payload
|
|
43
|
+
|
|
44
|
+
def verify_refresh_token(self, token: str) -> dict:
|
|
45
|
+
payload = self._verify_token(token)
|
|
46
|
+
if payload.get("type") != "refresh":
|
|
47
|
+
raise InvalidTokenException
|
|
48
|
+
return payload
|
|
49
|
+
|
|
50
|
+
class PublicKeyProvider:
|
|
51
|
+
|
|
52
|
+
def __init__(self, base_url: str) -> None:
|
|
53
|
+
self.base_url = base_url
|
|
54
|
+
self._key: bytes | None = None
|
|
55
|
+
self._lock = asyncio.Lock()
|
|
56
|
+
self._client = httpx.AsyncClient()
|
|
57
|
+
|
|
58
|
+
async def close(self) -> None:
|
|
59
|
+
await self._client.aclose()
|
|
60
|
+
|
|
61
|
+
async def get(self) -> bytes:
|
|
62
|
+
if self._key is None:
|
|
63
|
+
async with self._lock:
|
|
64
|
+
if self._key is None:
|
|
65
|
+
self._key = await self._fetch()
|
|
66
|
+
return self._key
|
|
67
|
+
|
|
68
|
+
async def _fetch(self) -> bytes:
|
|
69
|
+
response = await self._client.get(
|
|
70
|
+
f"{self.base_url}/api/v1/public-key"
|
|
71
|
+
)
|
|
72
|
+
response.raise_for_status()
|
|
73
|
+
return response.content
|
|
74
|
+
|
|
75
|
+
async def __aenter__(self):
|
|
76
|
+
return self
|
|
77
|
+
|
|
78
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
79
|
+
await self.close()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pydantic import PrivateAttr
|
|
2
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class RedisSettings(BaseSettings):
|
|
6
|
+
model_config = SettingsConfigDict(env_file=".env", extra="ignore",)
|
|
7
|
+
|
|
8
|
+
REDIS_HOST: str = "localhost"
|
|
9
|
+
REDIS_PORT: int = 6379
|
|
10
|
+
REDIS_DB: int = 0
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def REDIS_URL(self) -> str:
|
|
14
|
+
return f"redis://{self.REDIS_HOST}:{self.REDIS_PORT}/{self.REDIS_DB}"
|
|
@@ -21,4 +21,13 @@ class EventTargetEnum(StrEnum):
|
|
|
21
21
|
ROOM = "room"
|
|
22
22
|
ROOM_EXCEPT = "room_except"
|
|
23
23
|
USER = "user"
|
|
24
|
-
ALL = "all"
|
|
24
|
+
ALL = "all"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Channel(StrEnum):
|
|
28
|
+
EVENT = "event"
|
|
29
|
+
SESSION_LAST_SEEN = "session.last_seen"
|
|
30
|
+
PRESENCE_CHANGED = "presence.changed"
|
|
31
|
+
MESSAGE_INDEX_ADD = "message.index.add"
|
|
32
|
+
MESSAGE_INDEX_UPDATE = "message.index.update"
|
|
33
|
+
MESSAGE_INDEX_REMOVE = "message.index.remove"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from uuid import UUID
|
|
2
|
+
from redis.asyncio import Redis
|
|
3
|
+
from clipcloudlib.schemas.room import RoomMemberRedis
|
|
4
|
+
|
|
5
|
+
class RoomMemberRepository:
|
|
6
|
+
def __init__(self, redis: Redis) -> None:
|
|
7
|
+
self._redis = redis
|
|
8
|
+
|
|
9
|
+
def _key(self, room_id: UUID) -> str:
|
|
10
|
+
return f"room:{room_id}:members"
|
|
11
|
+
|
|
12
|
+
async def add(
|
|
13
|
+
self,
|
|
14
|
+
room_id: UUID,
|
|
15
|
+
member: RoomMemberRedis,
|
|
16
|
+
ttl: int | None = None,
|
|
17
|
+
) -> None:
|
|
18
|
+
key = self._key(room_id)
|
|
19
|
+
pipe = self._redis.pipeline()
|
|
20
|
+
pipe.hset(
|
|
21
|
+
key,
|
|
22
|
+
str(member.session_id),
|
|
23
|
+
member.model_dump_json(),
|
|
24
|
+
)
|
|
25
|
+
if ttl:
|
|
26
|
+
pipe.expire(key, ttl)
|
|
27
|
+
await pipe.execute()
|
|
28
|
+
|
|
29
|
+
async def rename(self, room_id: UUID, session_id: UUID, username: str) -> None:
|
|
30
|
+
await self._redis.hset(self._key(room_id), str(session_id), username) # type: ignore
|
|
31
|
+
|
|
32
|
+
async def remove(self, room_id: UUID, session_id: UUID) -> None:
|
|
33
|
+
await self._redis.hdel(self._key(room_id), str(session_id)) # type: ignore
|
|
34
|
+
|
|
35
|
+
async def members(self, room_id: UUID) -> list[RoomMemberRedis]:
|
|
36
|
+
data = await self._redis.hgetall(self._key(room_id)) # type: ignore
|
|
37
|
+
return [
|
|
38
|
+
RoomMemberRedis.model_validate_json(value)
|
|
39
|
+
for value in data.values()
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
async def exists(self, room_id: UUID) -> bool:
|
|
43
|
+
return bool(await self._redis.exists(self._key(room_id)))
|
|
44
|
+
|
|
45
|
+
async def set_all(
|
|
46
|
+
self,
|
|
47
|
+
room_id: UUID,
|
|
48
|
+
members: list[RoomMemberRedis],
|
|
49
|
+
ttl: int | None = None,
|
|
50
|
+
) -> None:
|
|
51
|
+
key = self._key(room_id)
|
|
52
|
+
pipe = self._redis.pipeline()
|
|
53
|
+
pipe.delete(key)
|
|
54
|
+
if members:
|
|
55
|
+
pipe.hset(
|
|
56
|
+
key,
|
|
57
|
+
mapping={
|
|
58
|
+
str(member.session_id): member.model_dump_json()
|
|
59
|
+
for member in members
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
if ttl:
|
|
63
|
+
pipe.expire(key, ttl)
|
|
64
|
+
await pipe.execute()
|
|
65
|
+
|
|
66
|
+
async def delete(self, room_id: UUID) -> None:
|
|
67
|
+
await self._redis.delete(self._key(room_id))
|
|
@@ -2,5 +2,6 @@ from clipcloudlib.schemas.session import SessionSchema, SessionSchemaAccessToken
|
|
|
2
2
|
from clipcloudlib.schemas.room import RoomSchema
|
|
3
3
|
from clipcloudlib.schemas.message import MessageCreateSchema, MessageSchema, MessageUpdateSchema
|
|
4
4
|
from clipcloudlib.schemas.file import FileSchema
|
|
5
|
+
from clipcloudlib.schemas.promo import PromoSchema
|
|
5
6
|
|
|
6
|
-
__all__ = ["SessionSchema", "RoomSchema", "SessionSchemaAccessToken", "MessageCreateSchema", "MessageSchema", "MessageUpdateSchema"]
|
|
7
|
+
__all__ = ["SessionSchema", "RoomSchema", "SessionSchemaAccessToken", "MessageCreateSchema", "MessageSchema", "MessageUpdateSchema", "PromoSchema"]
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
from typing import Annotated, ClassVar, Self, Union, Literal
|
|
1
|
+
from typing import Annotated, ClassVar, Self, TypeAlias, Union, Literal
|
|
2
2
|
from uuid import UUID
|
|
3
3
|
from pydantic import Field, RootModel, BaseModel, model_validator
|
|
4
|
+
# from src.schemas.promo import PromoSchema
|
|
4
5
|
from clipcloudlib.enums import EventTypeEnum, EventTargetEnum
|
|
6
|
+
# from src.schemas.message import MessageSchema
|
|
7
|
+
from clipcloudlib.schemas import MessageSchema, PromoSchema
|
|
8
|
+
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
class EventRoute(BaseModel):
|
|
@@ -27,8 +31,6 @@ class EventRoute(BaseModel):
|
|
|
27
31
|
raise ValueError("room_id is none")
|
|
28
32
|
return self.room_id
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
34
|
@model_validator(mode="after")
|
|
33
35
|
def validate_fields(self,) -> Self:
|
|
34
36
|
required_fields = self.__target_required.get(self.target, ())
|
|
@@ -40,74 +42,88 @@ class EventRoute(BaseModel):
|
|
|
40
42
|
|
|
41
43
|
class ToggleRoomAccessStatusEvent(BaseModel):
|
|
42
44
|
type: Literal[EventTypeEnum.TOGGLE_ROOM_ACCESS] = EventTypeEnum.TOGGLE_ROOM_ACCESS
|
|
43
|
-
payload: dict
|
|
45
|
+
# payload: dict
|
|
46
|
+
is_private: bool
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
class DeleteMessageEvent(BaseModel):
|
|
47
50
|
type: Literal[EventTypeEnum.DELETE_MESSAGE] = EventTypeEnum.DELETE_MESSAGE
|
|
48
|
-
payload: dict
|
|
51
|
+
# payload: dict
|
|
52
|
+
message_id: UUID
|
|
49
53
|
|
|
50
54
|
|
|
51
55
|
class ChangeMessageEvent(BaseModel):
|
|
52
56
|
type: Literal[EventTypeEnum.CHANGE_MESSAGE] = EventTypeEnum.CHANGE_MESSAGE
|
|
53
|
-
payload: dict
|
|
57
|
+
# payload: dict
|
|
58
|
+
message_id: UUID
|
|
59
|
+
text: str
|
|
54
60
|
|
|
55
61
|
|
|
56
62
|
class SetUsernameEvent(BaseModel):
|
|
57
63
|
type: Literal[EventTypeEnum.SET_USERNAME] = EventTypeEnum.SET_USERNAME
|
|
58
|
-
payload: dict
|
|
64
|
+
# payload: dict
|
|
65
|
+
username: str
|
|
66
|
+
session_id: UUID
|
|
59
67
|
|
|
60
68
|
|
|
61
69
|
class PromoEvent(BaseModel):
|
|
62
|
-
type
|
|
63
|
-
|
|
70
|
+
type = EventTypeEnum.PROMO
|
|
71
|
+
promo: PromoSchema
|
|
64
72
|
|
|
65
73
|
|
|
66
74
|
class QuitRoomEvent(BaseModel):
|
|
67
|
-
type
|
|
68
|
-
payload: dict
|
|
75
|
+
type = EventTypeEnum.QUIT_ROOM
|
|
76
|
+
# payload: dict
|
|
77
|
+
username: str,
|
|
78
|
+
session_id: UUID,
|
|
79
|
+
room_id: UUID
|
|
69
80
|
|
|
70
81
|
|
|
71
82
|
class JoinRoomEvent(BaseModel):
|
|
72
|
-
type
|
|
73
|
-
payload: dict
|
|
83
|
+
type = EventTypeEnum.USER_JOIN_THE_ROOM
|
|
84
|
+
# payload: dict
|
|
85
|
+
username: str
|
|
86
|
+
room_id: UUID
|
|
74
87
|
|
|
75
88
|
|
|
76
89
|
class PairingEvent(BaseModel):
|
|
77
|
-
type
|
|
78
|
-
payload: dict
|
|
90
|
+
type = EventTypeEnum.PAIRING
|
|
91
|
+
# payload: dict
|
|
92
|
+
room_code: str
|
|
79
93
|
|
|
80
94
|
|
|
81
95
|
class MessageEvent(BaseModel):
|
|
82
96
|
type: Literal[EventTypeEnum.MESSAGE] = EventTypeEnum.MESSAGE
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
data: MessageSchema
|
|
85
98
|
|
|
86
99
|
class ChangeRoomCodeEvent(BaseModel):
|
|
87
100
|
type: Literal[EventTypeEnum.CHANGE_ROOM_CODE] = EventTypeEnum.CHANGE_ROOM_CODE
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
room_code: str
|
|
102
|
+
# payload: dict
|
|
103
|
+
|
|
90
104
|
|
|
91
105
|
class UserTypingEvent(BaseModel):
|
|
92
|
-
type
|
|
93
|
-
|
|
106
|
+
type = EventTypeEnum.USER_TYPING
|
|
107
|
+
username: str
|
|
94
108
|
|
|
95
109
|
|
|
96
110
|
class UserOnlineEvent(BaseModel):
|
|
97
111
|
type: Literal[EventTypeEnum.USER_ONLINE] = EventTypeEnum.USER_ONLINE
|
|
98
|
-
payload: dict
|
|
112
|
+
# payload: dict
|
|
113
|
+
session_id: UUID
|
|
99
114
|
|
|
100
115
|
|
|
101
116
|
class UserOfflineEvent(BaseModel):
|
|
102
117
|
type: Literal[EventTypeEnum.USER_OFFLINE] = EventTypeEnum.USER_OFFLINE
|
|
103
|
-
|
|
118
|
+
session_id: UUID
|
|
119
|
+
|
|
104
120
|
|
|
105
121
|
class RoomDelete(BaseModel):
|
|
106
|
-
type
|
|
107
|
-
|
|
122
|
+
type = EventTypeEnum.ROOM_DELETE
|
|
123
|
+
room_id: UUID
|
|
108
124
|
|
|
109
125
|
|
|
110
|
-
|
|
126
|
+
EventSchema: TypeAlias = Annotated[
|
|
111
127
|
Union[
|
|
112
128
|
ToggleRoomAccessStatusEvent,
|
|
113
129
|
DeleteMessageEvent,
|
|
@@ -128,4 +144,30 @@ EventUnion = Annotated[
|
|
|
128
144
|
]
|
|
129
145
|
|
|
130
146
|
|
|
131
|
-
|
|
147
|
+
|
|
148
|
+
class BrokerEvent(BaseModel):
|
|
149
|
+
target_room_id: UUID | None = None
|
|
150
|
+
target_session_id: UUID | None = None
|
|
151
|
+
target: EventTargetEnum
|
|
152
|
+
event: EventSchema
|
|
153
|
+
# event_route: EventRoute | None = None # TODO Это временное решение чтобы не переписывать много кода
|
|
154
|
+
# session_ids: list[UUID] | None = None
|
|
155
|
+
|
|
156
|
+
# @property
|
|
157
|
+
# def required_session_ids(self) -> list[UUID]:
|
|
158
|
+
# if self.session_ids is None:
|
|
159
|
+
# raise ValueError("session_ids is none")
|
|
160
|
+
# return self.session_ids
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@property
|
|
164
|
+
def required_target_session_id(self) -> UUID:
|
|
165
|
+
if self.target_session_id is None:
|
|
166
|
+
raise ValueError("target_session_id is none")
|
|
167
|
+
return self.target_session_id
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def required_target_room_id(self) -> UUID:
|
|
171
|
+
if self.target_room_id is None:
|
|
172
|
+
raise ValueError("target_room_id is none")
|
|
173
|
+
return self.target_room_id
|
|
@@ -16,4 +16,10 @@ class RoomMember(BaseModel):
|
|
|
16
16
|
username: str
|
|
17
17
|
is_owner: bool = False
|
|
18
18
|
is_online: bool = False
|
|
19
|
-
last_seen_at: datetime | None = None
|
|
19
|
+
last_seen_at: datetime | None = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class RoomMemberRedis(BaseModel):
|
|
23
|
+
session_id: UUID
|
|
24
|
+
username: str
|
|
25
|
+
is_owner: bool = False
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from uuid import UUID
|
|
2
|
+
from fastapi import HTTPException, Request, WebSocket
|
|
3
|
+
from clipcloudlib.auth import TokenService
|
|
4
|
+
from clipcloudlib.exceptions import InvalidTokenException
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_session_id(
|
|
8
|
+
connection: Request | WebSocket,
|
|
9
|
+
token_service: TokenService
|
|
10
|
+
) -> UUID:
|
|
11
|
+
token = connection.cookies.get("access_token")
|
|
12
|
+
telegram_service_token = connection.query_params.get("telegram_service_token")
|
|
13
|
+
if telegram_service_token:
|
|
14
|
+
session_id = connection.query_params.get("telegram_user_session_id")
|
|
15
|
+
if not session_id:
|
|
16
|
+
raise HTTPException(
|
|
17
|
+
status_code=400,
|
|
18
|
+
detail="Missing telegram_user_session_id",
|
|
19
|
+
)
|
|
20
|
+
try:
|
|
21
|
+
session_id = UUID(session_id)
|
|
22
|
+
except ValueError:
|
|
23
|
+
raise HTTPException(
|
|
24
|
+
status_code=400,
|
|
25
|
+
detail="Invalid telegram_user_session_id",
|
|
26
|
+
)
|
|
27
|
+
else:
|
|
28
|
+
if not token:
|
|
29
|
+
raise HTTPException(
|
|
30
|
+
status_code=401,
|
|
31
|
+
detail="Missing Authorization header"
|
|
32
|
+
)
|
|
33
|
+
try:
|
|
34
|
+
payload = token_service.verify_access_token(token)
|
|
35
|
+
except InvalidTokenException:
|
|
36
|
+
raise HTTPException(
|
|
37
|
+
status_code=401,
|
|
38
|
+
detail="Invalid token"
|
|
39
|
+
)
|
|
40
|
+
try:
|
|
41
|
+
session_id = UUID(payload["session_id"])
|
|
42
|
+
except (KeyError, ValueError):
|
|
43
|
+
raise HTTPException(
|
|
44
|
+
status_code=403,
|
|
45
|
+
detail="Invalid session id in token"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
return session_id
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clipcloudlib
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.16
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Project-URL: Repository, https://github.com/rorka491/clipcloud-lib.git
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: pydantic>=2.13.4
|
|
9
|
+
Requires-Dist: fastapi>=0.135.1
|
|
10
|
+
Requires-Dist: httpx>=0.28.1
|
|
11
|
+
Requires-Dist: pyjwt[crypto]>=2.13.0
|
|
12
|
+
Requires-Dist: pydantic-settings>=2.16.2
|
|
13
|
+
Requires-Dist: redis>=8.1.0
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
README.md
|
|
2
2
|
pyproject.toml
|
|
3
3
|
clipcloudlib/__init__.py
|
|
4
|
+
clipcloudlib/auth.py
|
|
5
|
+
clipcloudlib/config.py
|
|
4
6
|
clipcloudlib/enums.py
|
|
5
7
|
clipcloudlib/exceptions.py
|
|
6
8
|
clipcloudlib/required.py
|
|
9
|
+
clipcloudlib/session.py
|
|
7
10
|
clipcloudlib.egg-info/PKG-INFO
|
|
8
11
|
clipcloudlib.egg-info/SOURCES.txt
|
|
9
12
|
clipcloudlib.egg-info/dependency_links.txt
|
|
@@ -17,9 +20,12 @@ clipcloudlib/models/redis/__init__.py
|
|
|
17
20
|
clipcloudlib/models/redis/base.py
|
|
18
21
|
clipcloudlib/models/redis/room.py
|
|
19
22
|
clipcloudlib/models/redis/session.py
|
|
23
|
+
clipcloudlib/repositories/redis/room_member.py
|
|
20
24
|
clipcloudlib/schemas/__init__.py
|
|
21
25
|
clipcloudlib/schemas/events.py
|
|
22
26
|
clipcloudlib/schemas/file.py
|
|
23
27
|
clipcloudlib/schemas/message.py
|
|
28
|
+
clipcloudlib/schemas/presence.py
|
|
29
|
+
clipcloudlib/schemas/promo.py
|
|
24
30
|
clipcloudlib/schemas/room.py
|
|
25
31
|
clipcloudlib/schemas/session.py
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "clipcloudlib"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.16"
|
|
4
4
|
description = "Add your description here"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"pydantic>=2.13.4",
|
|
9
|
+
"fastapi>=0.135.1",
|
|
10
|
+
"httpx>=0.28.1",
|
|
11
|
+
"pyjwt[crypto]>=2.13.0",
|
|
12
|
+
"pydantic-settings>=2.16.2",
|
|
13
|
+
"redis>=8.1.0",
|
|
9
14
|
]
|
|
10
15
|
[dependency-groups]
|
|
11
16
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pydantic>=2.13.4
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|