crypticorn 2.17.0rc3__py3-none-any.whl → 2.17.0rc4__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.
- crypticorn/common/auth.py +7 -15
- crypticorn/common/pagination.py +21 -0
- {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc4.dist-info}/METADATA +1 -1
- {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc4.dist-info}/RECORD +8 -8
- {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc4.dist-info}/WHEEL +0 -0
- {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc4.dist-info}/entry_points.txt +0 -0
- {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc4.dist-info}/licenses/LICENSE +0 -0
- {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc4.dist-info}/top_level.txt +0 -0
crypticorn/common/auth.py
CHANGED
@@ -112,6 +112,7 @@ class AuthHandler:
|
|
112
112
|
elif message == "jwt expired":
|
113
113
|
error = ApiError.EXPIRED_BEARER
|
114
114
|
else:
|
115
|
+
message = "Invalid bearer token"
|
115
116
|
error = (
|
116
117
|
ApiError.INVALID_BEARER
|
117
118
|
) # jwt malformed, jwt not active (https://www.npmjs.com/package/jsonwebtoken#errors--codes)
|
@@ -234,10 +235,7 @@ class AuthHandler:
|
|
234
235
|
Use this function if you only want to allow access via the API key.
|
235
236
|
This function is used for WebSocket connections.
|
236
237
|
"""
|
237
|
-
|
238
|
-
return await self.api_key_auth(api_key=api_key, sec=sec)
|
239
|
-
except HTTPException as e:
|
240
|
-
raise WebSocketException.from_http_exception(e)
|
238
|
+
return await self.api_key_auth(api_key=api_key, sec=sec)
|
241
239
|
|
242
240
|
async def ws_bearer_auth(
|
243
241
|
self,
|
@@ -249,11 +247,8 @@ class AuthHandler:
|
|
249
247
|
Use this function if you only want to allow access via the bearer token.
|
250
248
|
This function is used for WebSocket connections.
|
251
249
|
"""
|
252
|
-
|
253
|
-
|
254
|
-
return await self.bearer_auth(bearer=credentials, sec=sec)
|
255
|
-
except HTTPException as e:
|
256
|
-
raise WebSocketException.from_http_exception(e)
|
250
|
+
credentials = HTTPAuthorizationCredentials(scheme="Bearer", credentials=bearer)
|
251
|
+
return await self.bearer_auth(bearer=credentials, sec=sec)
|
257
252
|
|
258
253
|
async def ws_combined_auth(
|
259
254
|
self,
|
@@ -271,9 +266,6 @@ class AuthHandler:
|
|
271
266
|
if bearer
|
272
267
|
else None
|
273
268
|
)
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
)
|
278
|
-
except HTTPException as e:
|
279
|
-
raise WebSocketException.from_http_exception(e)
|
269
|
+
return await self.combined_auth(
|
270
|
+
bearer=credentials, api_key=api_key, sec=sec
|
271
|
+
)
|
crypticorn/common/pagination.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
from typing import Annotated, Any, Generic, Type, TypeVar, Optional, Literal
|
4
4
|
from pydantic import BaseModel, Field, model_validator
|
5
|
+
import math
|
5
6
|
|
6
7
|
T = TypeVar("T")
|
7
8
|
|
@@ -17,6 +18,26 @@ class PaginatedResponse(BaseModel, Generic[T]):
|
|
17
18
|
page_size: int = Field(description="The number of items per page")
|
18
19
|
prev: Optional[int] = Field(None, description="The previous page number")
|
19
20
|
next: Optional[int] = Field(None, description="The next page number")
|
21
|
+
last: Optional[int] = Field(None, description="The last page number")
|
22
|
+
|
23
|
+
@staticmethod
|
24
|
+
def get_next_page(total: int, page_size: int, page: int) -> Optional[int]:
|
25
|
+
"""Get the next page number"""
|
26
|
+
if page < math.ceil(total / page_size):
|
27
|
+
return page + 1
|
28
|
+
return None
|
29
|
+
|
30
|
+
@staticmethod
|
31
|
+
def get_prev_page(page: int) -> Optional[int]:
|
32
|
+
"""Get the previous page number"""
|
33
|
+
if page > 1:
|
34
|
+
return page - 1
|
35
|
+
return None
|
36
|
+
|
37
|
+
@staticmethod
|
38
|
+
def get_last_page(total: int, page_size: int) -> int:
|
39
|
+
"""Get the last page number"""
|
40
|
+
return max(1, math.ceil(total / page_size))
|
20
41
|
|
21
42
|
|
22
43
|
class PaginationParams(BaseModel, Generic[T]):
|
@@ -67,7 +67,7 @@ crypticorn/cli/templates/merge-env.sh,sha256=BNPrDTihII0yG2gehBkWwWj0GqHmb6xwmrA
|
|
67
67
|
crypticorn/cli/templates/ruff.yml,sha256=gWicFFTzC4nToSmRkIIGipos8CZ447YG0kebBCJhtJE,319
|
68
68
|
crypticorn/common/__init__.py,sha256=3nv8Kfuqh15s9oTIqMQtDAqKGGNVC4BVHlHQFDmfg8I,792
|
69
69
|
crypticorn/common/ansi_colors.py,sha256=-tMlUTE8NI7TPv7uj0kGRe-SI2hGaUNPKBFI_dfiZy0,1392
|
70
|
-
crypticorn/common/auth.py,sha256=
|
70
|
+
crypticorn/common/auth.py,sha256=yYfCmSfiO5ataDCFqbbBbMGimxJBDTJdYL6c-pS1X5E,9723
|
71
71
|
crypticorn/common/decorators.py,sha256=t5Y3vSJ-gt0n2vOYYjYN0dtzNXvZxrJs2SEItpzG8oo,1127
|
72
72
|
crypticorn/common/enums.py,sha256=x-2xe0NUI8kB6DNg9GLjqAjYOsFAGwP-jdM1YgIt9AI,1381
|
73
73
|
crypticorn/common/errors.py,sha256=qPCYpmxw0uZNmQw9RYj9vUsg-_R5aRn7fYE8qxTAnyA,30129
|
@@ -77,7 +77,7 @@ crypticorn/common/metrics.py,sha256=Hhl05p7UzcHWdv2l8UUfPlbCtQG0CDJ1DGEoKOiko7I,
|
|
77
77
|
crypticorn/common/middleware.py,sha256=9J-Da1GNo14Xp7kPYkCPJFs9ozi4s1fHZ8ROuaQndHk,2599
|
78
78
|
crypticorn/common/mixins.py,sha256=l7XQrBISaee6fDZXy96k0HnQ18XYocjTUXlNpVxhaOY,2206
|
79
79
|
crypticorn/common/openapi.py,sha256=D8bCpCVVzYQptHrJ7SYOgCxI3R_d0cjW9KMOBq-x0xk,279
|
80
|
-
crypticorn/common/pagination.py,sha256=
|
80
|
+
crypticorn/common/pagination.py,sha256=Qzwq6Qc7N3cgr8GNhPcM85F0FE9e8wIG_VPEQbg2KEg,8539
|
81
81
|
crypticorn/common/scopes.py,sha256=ZreqkW_XshlyLJjciAfaIFmcy4HO6RnCsbbkjCw-fxc,2900
|
82
82
|
crypticorn/common/urls.py,sha256=v23H2gevTNZ6HMRXDPiuc8znBbNdNqj0JTAdm5Hhms8,1223
|
83
83
|
crypticorn/common/utils.py,sha256=5aWZmQEP6yKTeb7JbhfmXljUoNi2iR6F5GgG9aymTnM,3110
|
@@ -281,9 +281,9 @@ crypticorn/trade/client/models/strategy_update.py,sha256=g427iKdk-gIsQ_BfD3E0W8b
|
|
281
281
|
crypticorn/trade/client/models/tpsl.py,sha256=iuHwBxHaUdtJn7NhcTE6Skzv4nmoSF8jEnf7_bTglwk,3730
|
282
282
|
crypticorn/trade/client/models/tpsl_create.py,sha256=nX4i2BGWv5rmu3SLgRngfvEMFOWa3CIy0G3fyoxI-e4,3351
|
283
283
|
crypticorn/trade/client/models/trading_action_type.py,sha256=BysUEOl85zs79EA2zOcDN1EExcpQdABaJ4Jz08_z8VU,857
|
284
|
-
crypticorn-2.17.
|
285
|
-
crypticorn-2.17.
|
286
|
-
crypticorn-2.17.
|
287
|
-
crypticorn-2.17.
|
288
|
-
crypticorn-2.17.
|
289
|
-
crypticorn-2.17.
|
284
|
+
crypticorn-2.17.0rc4.dist-info/licenses/LICENSE,sha256=HonAVvzFXkP2C1d7D3ByIKPwjGH8NcHTAQvKH7uvOHQ,1856
|
285
|
+
crypticorn-2.17.0rc4.dist-info/METADATA,sha256=90j4teSD13rNbajS-sYCjviH9bKgJsr-YQM2EvCI9wA,11712
|
286
|
+
crypticorn-2.17.0rc4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
287
|
+
crypticorn-2.17.0rc4.dist-info/entry_points.txt,sha256=d_xHsGvUTebPveVUK0SrpDFQ5ZRSjlI7lNCc11sn2PM,59
|
288
|
+
crypticorn-2.17.0rc4.dist-info/top_level.txt,sha256=EP3NY216qIBYfmvGl0L2Zc9ItP0DjGSkiYqd9xJwGcM,11
|
289
|
+
crypticorn-2.17.0rc4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|