apexdevkit 1.30.2__tar.gz → 1.30.4__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.
Files changed (61) hide show
  1. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/PKG-INFO +1 -1
  2. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/http/__init__.py +2 -1
  3. apexdevkit-1.30.4/apexdevkit/http/httpx/__init__.py +10 -0
  4. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/http/httpx/hooks.py +13 -0
  5. apexdevkit-1.30.4/apexdevkit/security/__init__.py +8 -0
  6. apexdevkit-1.30.4/apexdevkit/security/core.py +18 -0
  7. apexdevkit-1.30.4/apexdevkit/security/hashing.py +21 -0
  8. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/pyproject.toml +7 -1
  9. apexdevkit-1.30.2/apexdevkit/http/httpx/__init__.py +0 -6
  10. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/LICENSE +0 -0
  11. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/README.md +0 -0
  12. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/__init__.py +0 -0
  13. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/annotation/__init__.py +0 -0
  14. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/annotation/deprecate.py +0 -0
  15. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/date.py +0 -0
  16. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/environment.py +0 -0
  17. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/error.py +0 -0
  18. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/__init__.py +0 -0
  19. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/builder.py +0 -0
  20. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/dependable.py +0 -0
  21. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/docs.py +0 -0
  22. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/name.py +0 -0
  23. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/resource.py +0 -0
  24. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/response.py +0 -0
  25. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/router.py +0 -0
  26. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/schema.py +0 -0
  27. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fastapi/service.py +0 -0
  28. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/fluent.py +0 -0
  29. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/formatter.py +0 -0
  30. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/http/fake.py +0 -0
  31. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/http/fluent.py +0 -0
  32. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/http/httpx/client.py +0 -0
  33. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/http/json.py +0 -0
  34. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/http/url.py +0 -0
  35. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/key_fn.py +0 -0
  36. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/py.typed +0 -0
  37. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/query/__init__.py +0 -0
  38. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/query/generator.py +0 -0
  39. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/query/query.py +0 -0
  40. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/__init__.py +0 -0
  41. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/core/__init__.py +0 -0
  42. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/core/database.py +0 -0
  43. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/core/decorator.py +0 -0
  44. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/core/interface.py +0 -0
  45. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/core/mixin.py +0 -0
  46. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/core/multi.py +0 -0
  47. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/in_memory/__init__.py +0 -0
  48. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/in_memory/mixin.py +0 -0
  49. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/in_memory/repository.py +0 -0
  50. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/in_memory/store.py +0 -0
  51. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/sql/__init__.py +0 -0
  52. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/sql/connector.py +0 -0
  53. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/sql/field.py +0 -0
  54. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/sql/mssql.py +0 -0
  55. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/repository/sql/sqlite.py +0 -0
  56. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/server.py +0 -0
  57. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/testing/__init__.py +0 -0
  58. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/testing/database.py +0 -0
  59. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/testing/fake.py +0 -0
  60. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/testing/rest.py +0 -0
  61. {apexdevkit-1.30.2 → apexdevkit-1.30.4}/apexdevkit/value.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apexdevkit
3
- Version: 1.30.2
3
+ Version: 1.30.4
4
4
  Summary: Apex Development Tools for python.
5
5
  License-File: LICENSE
6
6
  Author: Apex Dev
@@ -1,6 +1,6 @@
1
1
  from .fake import FakeHttp
2
2
  from .fluent import FluentHttp, FluentHttpRequest, FluentHttpResponse, Http, HttpMethod
3
- from .httpx import Httpx, HttpxConfig
3
+ from .httpx import Httpx, HttpxConfig, SignPayloadWith
4
4
  from .json import JsonDict
5
5
  from .url import HttpUrl
6
6
 
@@ -13,6 +13,7 @@ __all__ = [
13
13
  "HttpMethod",
14
14
  "Httpx",
15
15
  "HttpxConfig",
16
+ "SignPayloadWith",
16
17
  "JsonDict",
17
18
  "HttpUrl",
18
19
  ]
@@ -0,0 +1,10 @@
1
+ from .client import Httpx, HttpxConfig
2
+ from .hooks import DefaultHandler, HttpxHandler, SignPayloadWith
3
+
4
+ __all__ = [
5
+ "Httpx",
6
+ "HttpxConfig",
7
+ "SignPayloadWith",
8
+ "DefaultHandler",
9
+ "HttpxHandler",
10
+ ]
@@ -4,6 +4,9 @@ from dataclasses import dataclass
4
4
  from typing import Generic, Protocol, TypeVar
5
5
 
6
6
  import httpx
7
+ from httpx import Request, SyncByteStream
8
+
9
+ from apexdevkit.security import Authority
7
10
 
8
11
  ContextT = TypeVar("ContextT", contravariant=True)
9
12
 
@@ -70,3 +73,13 @@ class AfterResponseHook:
70
73
  self.handler.on_delete(response)
71
74
  case _:
72
75
  pass
76
+
77
+
78
+ @dataclass(frozen=True)
79
+ class SignPayloadWith(DefaultHandler[Request]):
80
+ authority: Authority
81
+
82
+ def on_post(self, context: Request) -> None:
83
+ assert isinstance(context.stream, SyncByteStream)
84
+ signature = self.authority.sign(next(iter(context.stream)).decode())
85
+ context.headers[signature.name] = signature.value
@@ -0,0 +1,8 @@
1
+ from .core import Authority, Signature
2
+ from .hashing import Hmac
3
+
4
+ __all__ = [
5
+ "Authority",
6
+ "Signature",
7
+ "Hmac",
8
+ ]
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Protocol
5
+
6
+
7
+ class Authority(Protocol):
8
+ def sign(self, message: str) -> Signature:
9
+ pass
10
+
11
+ def verify(self, message: str, signature: Signature) -> bool:
12
+ pass
13
+
14
+
15
+ @dataclass(frozen=True, kw_only=True)
16
+ class Signature:
17
+ name: str
18
+ value: str
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ import hmac
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class Hmac:
9
+ secret: str
10
+
11
+ algorithm: str = "sha256"
12
+
13
+ def __call__(self, value: str) -> bytes:
14
+ return self.hash(value)
15
+
16
+ def hash(self, value: str) -> bytes:
17
+ return hmac.new(
18
+ key=self.secret.encode("utf-8"),
19
+ msg=value.encode("utf-8"),
20
+ digestmod=self.algorithm,
21
+ ).digest()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "apexdevkit"
3
- version = "1.30.2"
3
+ version = "1.30.4"
4
4
  description = "Apex Development Tools for python."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -24,6 +24,7 @@ approvaltests = "*"
24
24
  pytest = "*"
25
25
  pytest-approvaltests = "*"
26
26
  pytest-cov = "*"
27
+ pytest-env = "^1.6.0"
27
28
  pytest-recording = "*"
28
29
  coverage = "*"
29
30
  faker = "*"
@@ -80,3 +81,8 @@ source = [
80
81
  skip_empty = true
81
82
  skip_covered = true
82
83
  show_missing = true
84
+
85
+ [tool.pytest]
86
+ env = [
87
+ "ECHO_SERVER=http://httpbin.org"
88
+ ]
@@ -1,6 +0,0 @@
1
- from .client import Httpx, HttpxConfig
2
-
3
- __all__ = [
4
- "Httpx",
5
- "HttpxConfig",
6
- ]
File without changes
File without changes