aidbox-python-sdk 0.2.3__py3-none-any.whl → 0.3.0__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.
@@ -1,5 +1,5 @@
1
1
  __title__ = "aidbox-python-sdk"
2
- __version__ = "0.2.3"
2
+ __version__ = "0.3.0"
3
3
  __author__ = "beda.software"
4
4
  __license__ = "None"
5
5
  __copyright__ = "Copyright 2026 beda.software"
@@ -1,5 +1,7 @@
1
1
  import asyncio
2
+ import base64
2
3
  import logging
4
+ import secrets
3
5
  from typing import Any
4
6
 
5
7
  from aiohttp import web
@@ -11,6 +13,13 @@ logger = logging.getLogger("aidbox_sdk")
11
13
  routes = web.RouteTableDef()
12
14
 
13
15
 
16
+ def is_from_aidbox(request: web.Request) -> bool:
17
+ """Aidbox calls an http-rpc endpoint with the secret the app registered it under."""
18
+ settings = request.app[ak.settings]
19
+ expected = b"Basic " + base64.b64encode(f"{settings.APP_ID}:{settings.APP_SECRET}".encode())
20
+ return secrets.compare_digest(request.headers.get("Authorization", "").encode(), expected)
21
+
22
+
14
23
  async def subscription(request: web.Request, data: dict):
15
24
  logger.debug("Subscription handler: %s", data["handler"])
16
25
  if "handler" not in data or "event" not in data:
@@ -59,6 +68,10 @@ TYPES = {
59
68
  @routes.post("/aidbox")
60
69
  async def dispatch(request):
61
70
  logger.debug("Dispatch new request %s %s", request.method, request.url)
71
+ if not is_from_aidbox(request):
72
+ logger.error("Dispatch request without the app's credentials")
73
+ raise web.HTTPUnauthorized()
74
+
62
75
  data = await request.json()
63
76
  if "type" in data and data["type"] in TYPES:
64
77
  logger.debug("Dispatch to `%s` handler", data["type"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aidbox-python-sdk
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Aidbox SDK for python
5
5
  Author-email: "beda.software" <aidbox-python-sdk@beda.software>
6
6
  License: MIT License
@@ -35,13 +35,13 @@ Classifier: Intended Audience :: Developers
35
35
  Classifier: Operating System :: OS Independent
36
36
  Classifier: Programming Language :: Python
37
37
  Classifier: Programming Language :: Python :: 3
38
- Classifier: Programming Language :: Python :: 3.9
39
- Classifier: Programming Language :: Python :: 3.10
40
38
  Classifier: Programming Language :: Python :: 3.11
41
39
  Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Programming Language :: Python :: 3.13
41
+ Classifier: Programming Language :: Python :: 3.14
42
42
  Classifier: Topic :: Internet :: WWW/HTTP
43
43
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
44
- Requires-Python: >=3.9
44
+ Requires-Python: >=3.11
45
45
  Description-Content-Type: text/markdown
46
46
  License-File: LICENSE.md
47
47
  Requires-Dist: aiohttp>=3.11.0
@@ -62,11 +62,11 @@ Dynamic: license-file
62
62
 
63
63
  [![build status](https://github.com/Aidbox/aidbox-python-sdk/actions/workflows/build.yaml/badge.svg)](https://github.com/Aidbox/aidbox-python-sdk/actions/workflows/build.yaml)
64
64
  [![pypi](https://img.shields.io/pypi/v/aidbox-python-sdk.svg)](https://pypi.org/project/aidbox-python-sdk/)
65
- [![Supported Python version](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/release/python-390/)
65
+ [![Supported Python version](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/release/python-3110/)
66
66
 
67
67
  # aidbox-python-sdk
68
68
 
69
- 1. Create a python 3.9+ environment `pyenv `
69
+ 1. Create a python 3.11+ environment `pyenv `
70
70
  2. Set env variables and activate virtual environment `source activate_settings.sh`
71
71
  2. Install the required packages with `pipenv install --dev`
72
72
  3. Make sure the app's settings are configured correctly (see `activate_settings.sh` and `aidbox_python_sdk/settings.py`). You can also
@@ -1,18 +1,18 @@
1
- aidbox_python_sdk/__init__.py,sha256=U0Ed_h7iQ9XWaRJHsZj4z2dcW3GQeZr4la7tq7mRRIg,192
1
+ aidbox_python_sdk/__init__.py,sha256=SHb4ulvXRA4YCGOkMp_wqhSzprLIHt2tOdap815_6TQ,192
2
2
  aidbox_python_sdk/aidboxpy.py,sha256=7ewo0TO1FeGU8IVPqwm6PqR7-o8zSt3EvqPi2UfEWoE,4182
3
3
  aidbox_python_sdk/app_keys.py,sha256=5ZkoJcJaUhMB-veQXVDzN_yQsOD2OOkGIIunNHujRyM,454
4
4
  aidbox_python_sdk/db.py,sha256=AQlju5V6F2l3HIxkaTbspx2gm4mBntO-gsIzhQgZW_M,8351
5
5
  aidbox_python_sdk/db_migrations.py,sha256=xzTQKPyEsWQePyvaYFuHz7auCChMdTcUW8vEeY3QtkM,1459
6
6
  aidbox_python_sdk/exceptions.py,sha256=hOn2rhEYNmuWuSiImObdd3R4xApsskmVdbVnb2PrIoA,116
7
- aidbox_python_sdk/handlers.py,sha256=YEEhAkJBTjrtArwxLs8QWK1FEKvYLW6LSVZF17NpRjk,2832
7
+ aidbox_python_sdk/handlers.py,sha256=zptJpAykS-W3ke1jc_ksax7ARkZ98NhagsFVpXvdMrE,3379
8
8
  aidbox_python_sdk/main.py,sha256=Gk-5QHo2MDQcNv7FMqmRD1JcKIJJiLdk6K4ce3Mb_pw,2464
9
9
  aidbox_python_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  aidbox_python_sdk/pytest_plugin.py,sha256=wK5NqEwd9g2eDpRNv4MyFK9_ebmo56JfL4G4nUuMtXA,4845
11
11
  aidbox_python_sdk/sdk.py,sha256=USzJryMYKGBt7SuCSt6YFjLsFqnMaTW-itxMJDl2dBo,9163
12
12
  aidbox_python_sdk/settings.py,sha256=l-zdzH3UT4Pq_OjNgFe2ELmWKSjEnBgOAcChf-FQais,3231
13
13
  aidbox_python_sdk/types.py,sha256=Oqcq4QZgOR71MwfoxW38-y9fWWUr49U5IoRS5LNbRq4,478
14
- aidbox_python_sdk-0.2.3.dist-info/licenses/LICENSE.md,sha256=Opl86pEF7tgGGO2Wkdgfavnpi-MSgNY7RVJKxtZIGlE,1066
15
- aidbox_python_sdk-0.2.3.dist-info/METADATA,sha256=c4J5riTGayBW3WXkV3rFzJi6gmCD1ICABApXtVS9JKI,11470
16
- aidbox_python_sdk-0.2.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
17
- aidbox_python_sdk-0.2.3.dist-info/top_level.txt,sha256=FJCCumQP-K5JkLtm0wispLy8Hy7ftneBaMMW-g5dvpQ,18
18
- aidbox_python_sdk-0.2.3.dist-info/RECORD,,
14
+ aidbox_python_sdk-0.3.0.dist-info/licenses/LICENSE.md,sha256=Opl86pEF7tgGGO2Wkdgfavnpi-MSgNY7RVJKxtZIGlE,1066
15
+ aidbox_python_sdk-0.3.0.dist-info/METADATA,sha256=lOxyqIlT6Omau_qqQxT7-yTO-y5m3rNqsGRb-2UIsFw,11475
16
+ aidbox_python_sdk-0.3.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
17
+ aidbox_python_sdk-0.3.0.dist-info/top_level.txt,sha256=FJCCumQP-K5JkLtm0wispLy8Hy7ftneBaMMW-g5dvpQ,18
18
+ aidbox_python_sdk-0.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
2
+ Generator: setuptools (84.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5