crypticorn 2.1.2__py3-none-any.whl → 2.1.4__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 +0 -28
- crypticorn/common/auth_client.py +14 -18
- crypticorn/common/errors.py +216 -253
- crypticorn/common/sorter.py +36 -0
- crypticorn/pay/client/__init__.py +1 -0
- crypticorn/pay/client/api/now_payments_api.py +3 -16
- crypticorn/pay/client/api/payments_api.py +0 -42
- crypticorn/pay/client/api/products_api.py +18 -57
- crypticorn/pay/client/configuration.py +2 -1
- crypticorn/pay/client/models/__init__.py +1 -0
- crypticorn/pay/client/models/body_create_now_invoice.py +98 -0
- crypticorn/pay/client/models/body_create_product.py +98 -0
- crypticorn/pay/client/models/body_get_products.py +87 -0
- crypticorn/pay/client/models/body_handle_now_webhook.py +98 -0
- crypticorn/pay/client/models/body_update_product.py +98 -0
- crypticorn/pay/client/models/now_webhook_payload.py +1 -1
- crypticorn/pay/client/models/product_model.py +9 -0
- crypticorn/pay/client/models/scope.py +56 -0
- crypticorn/trade/client/api/api_keys_api.py +5 -70
- crypticorn/trade/client/api/bots_api.py +4 -56
- crypticorn/trade/client/api/exchanges_api.py +2 -19
- crypticorn/trade/client/api/futures_trading_panel_api.py +6 -74
- crypticorn/trade/client/api/notifications_api.py +6 -87
- crypticorn/trade/client/api/orders_api.py +2 -15
- crypticorn/trade/client/api/strategies_api.py +4 -56
- crypticorn/trade/client/api/trading_actions_api.py +1 -14
- crypticorn/trade/client/configuration.py +2 -1
- crypticorn/trade/client/models/api_error_identifier.py +4 -0
- {crypticorn-2.1.2.dist-info → crypticorn-2.1.4.dist-info}/METADATA +1 -1
- {crypticorn-2.1.2.dist-info → crypticorn-2.1.4.dist-info}/RECORD +32 -25
- {crypticorn-2.1.2.dist-info → crypticorn-2.1.4.dist-info}/WHEEL +0 -0
- {crypticorn-2.1.2.dist-info → crypticorn-2.1.4.dist-info}/top_level.txt +0 -0
crypticorn/common/auth.py
CHANGED
@@ -1,12 +1,5 @@
|
|
1
|
-
from typing import Optional, Callable, Any, Annotated
|
2
|
-
from typing_extensions import Doc
|
3
|
-
from enum import Enum
|
4
|
-
|
5
|
-
from fastapi import params
|
6
1
|
from fastapi.security import APIKeyHeader, HTTPBearer
|
7
2
|
|
8
|
-
from crypticorn.common import Scope
|
9
|
-
|
10
3
|
|
11
4
|
http_bearer = HTTPBearer(
|
12
5
|
bearerFormat="JWT",
|
@@ -19,24 +12,3 @@ apikey_header = APIKeyHeader(
|
|
19
12
|
auto_error=False,
|
20
13
|
description="The API key to use for authentication.",
|
21
14
|
)
|
22
|
-
|
23
|
-
|
24
|
-
def Security( # noqa: N802
|
25
|
-
dependency: Annotated[
|
26
|
-
Callable[..., Any], Doc("A dependable callable (like a function).")
|
27
|
-
],
|
28
|
-
scopes: Annotated[
|
29
|
-
list[Scope],
|
30
|
-
Doc("API scopes required for the *path operation*."),
|
31
|
-
] = [],
|
32
|
-
use_cache: Annotated[
|
33
|
-
bool, Doc("Whether to cache the dependency during a single request.")
|
34
|
-
] = True,
|
35
|
-
) -> Any:
|
36
|
-
"""Security Dependency. Extends the fastapi.Security class to support enum scopes instead of strings."""
|
37
|
-
|
38
|
-
scopes_str = [s.value if isinstance(s, Enum) else s for s in scopes] if scopes else None
|
39
|
-
|
40
|
-
return params.Security(
|
41
|
-
dependency=dependency, scopes=scopes_str, use_cache=use_cache
|
42
|
-
)
|
crypticorn/common/auth_client.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
from fastapi import Depends, HTTPException, Query, status
|
2
|
-
from fastapi.security import HTTPAuthorizationCredentials
|
2
|
+
from fastapi.security import HTTPAuthorizationCredentials, SecurityScopes
|
3
3
|
from typing_extensions import Annotated, Doc
|
4
4
|
import json
|
5
5
|
|
@@ -109,13 +109,13 @@ class AuthHandler:
|
|
109
109
|
async def api_key_auth(
|
110
110
|
self,
|
111
111
|
api_key: Annotated[str | None, Depends(apikey_header)] = None,
|
112
|
-
|
112
|
+
sec: SecurityScopes = SecurityScopes(),
|
113
113
|
) -> Verify200Response:
|
114
114
|
"""
|
115
115
|
Verifies the API key and checks if the user scopes are a subset of the API scopes.
|
116
116
|
Use this function if you only want to allow access via the API key.
|
117
117
|
"""
|
118
|
-
return await self.combined_auth(bearer=None, api_key=api_key,
|
118
|
+
return await self.combined_auth(bearer=None, api_key=api_key, sec=sec)
|
119
119
|
|
120
120
|
async def bearer_auth(
|
121
121
|
self,
|
@@ -123,13 +123,13 @@ class AuthHandler:
|
|
123
123
|
HTTPAuthorizationCredentials | None,
|
124
124
|
Depends(http_bearer),
|
125
125
|
] = None,
|
126
|
-
|
126
|
+
sec: SecurityScopes = SecurityScopes(),
|
127
127
|
) -> Verify200Response:
|
128
128
|
"""
|
129
129
|
Verifies the bearer token and checks if the user scopes are a subset of the API scopes.
|
130
130
|
Use this function if you only want to allow access via the bearer token.
|
131
131
|
"""
|
132
|
-
return await self.combined_auth(bearer=bearer, api_key=None,
|
132
|
+
return await self.combined_auth(bearer=bearer, api_key=None, sec=sec)
|
133
133
|
|
134
134
|
async def combined_auth(
|
135
135
|
self,
|
@@ -137,7 +137,7 @@ class AuthHandler:
|
|
137
137
|
HTTPAuthorizationCredentials | None, Depends(http_bearer)
|
138
138
|
] = None,
|
139
139
|
api_key: Annotated[str | None, Depends(apikey_header)] = None,
|
140
|
-
|
140
|
+
sec: SecurityScopes = SecurityScopes(),
|
141
141
|
) -> Verify200Response:
|
142
142
|
"""
|
143
143
|
Verifies the bearer token and/or API key and checks if the user scopes are a subset of the API scopes.
|
@@ -158,10 +158,8 @@ class AuthHandler:
|
|
158
158
|
res = await self._verify_bearer(token)
|
159
159
|
if res is None:
|
160
160
|
continue
|
161
|
-
if
|
162
|
-
await self._validate_scopes(
|
163
|
-
scopes, [Scope.from_str(scope) for scope in res.scopes]
|
164
|
-
)
|
161
|
+
if sec:
|
162
|
+
await self._validate_scopes(sec.scopes, res.scopes)
|
165
163
|
return res
|
166
164
|
|
167
165
|
except Exception as e:
|
@@ -173,18 +171,18 @@ class AuthHandler:
|
|
173
171
|
async def ws_api_key_auth(
|
174
172
|
self,
|
175
173
|
api_key: Annotated[str | None, Query()] = None,
|
176
|
-
|
174
|
+
sec: SecurityScopes = SecurityScopes(),
|
177
175
|
) -> Verify200Response:
|
178
176
|
"""
|
179
177
|
Verifies the API key and checks if the user scopes are a subset of the API scopes.
|
180
178
|
Use this function if you only want to allow access via the API key.
|
181
179
|
"""
|
182
|
-
return await self.api_key_auth(api_key=api_key,
|
180
|
+
return await self.api_key_auth(api_key=api_key, sec=sec)
|
183
181
|
|
184
182
|
async def ws_bearer_auth(
|
185
183
|
self,
|
186
184
|
bearer: Annotated[str | None, Query()] = None,
|
187
|
-
|
185
|
+
sec: SecurityScopes = SecurityScopes(),
|
188
186
|
) -> Verify200Response:
|
189
187
|
"""
|
190
188
|
Verifies the bearer token and checks if the user scopes are a subset of the API scopes.
|
@@ -195,13 +193,13 @@ class AuthHandler:
|
|
195
193
|
if bearer
|
196
194
|
else None
|
197
195
|
)
|
198
|
-
return await self.bearer_auth(bearer=credentials,
|
196
|
+
return await self.bearer_auth(bearer=credentials, sec=sec)
|
199
197
|
|
200
198
|
async def ws_combined_auth(
|
201
199
|
self,
|
202
200
|
bearer: Annotated[str | None, Query()] = None,
|
203
201
|
api_key: Annotated[str | None, Query()] = None,
|
204
|
-
|
202
|
+
sec: SecurityScopes = SecurityScopes(),
|
205
203
|
) -> Verify200Response:
|
206
204
|
"""
|
207
205
|
Verifies the bearer token and/or API key and checks if the user scopes are a subset of the API scopes.
|
@@ -212,6 +210,4 @@ class AuthHandler:
|
|
212
210
|
if bearer
|
213
211
|
else None
|
214
212
|
)
|
215
|
-
return await self.combined_auth(
|
216
|
-
bearer=credentials, api_key=api_key, scopes=scopes
|
217
|
-
)
|
213
|
+
return await self.combined_auth(bearer=credentials, api_key=api_key, sec=sec)
|