kraph 5.0.0__tar.gz → 5.1.0__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.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: kraph
3
- Version: 5.0.0
3
+ Version: 5.1.0
4
4
  Summary: the arkitekt knowledge graph
5
5
  Author-email: jhnnsrs <jhnnsrs@gmail.com>
6
6
  License-Expression: GPL-3.0-or-later
7
7
  Requires-Python: <4.0,>=3.11
8
- Requires-Dist: arkitekt-spec>=3.4
8
+ Requires-Dist: arkitekt-spec>=3.19.1
9
9
  Requires-Dist: dokker>=2.8
10
- Requires-Dist: fakts>=5.4
10
+ Requires-Dist: fakts>=6.1
11
11
  Requires-Dist: rath>=4.1.1
12
12
  Requires-Dist: websockets>=15.0.1
13
13
  Description-Content-Type: text/markdown
@@ -111,8 +111,8 @@ def kraph(
111
111
  FaktsAuthLink(token_loader=tokens),
112
112
  UploadLink(datalayer=store),
113
113
  SplitLink(
114
- left=AIOHttpLink(endpoint_url=kraph.to_http_path("graphql"), proxy=kraph.proxy),
115
- right=GraphQLWSLink(ws_endpoint_url=kraph.to_ws_path("graphql"), proxy=kraph.proxy),
114
+ left=AIOHttpLink(endpoint_url=kraph.to_http_path("graphql"), proxy=kraph.proxy, ssl_context=kraph.ssl_context()),
115
+ right=GraphQLWSLink(ws_endpoint_url=kraph.to_ws_path("graphql"), proxy=kraph.proxy, ssl_context=kraph.ssl_context()),
116
116
  split=lambda o: o.node.operation != OperationType.SUBSCRIPTION,
117
117
  ),
118
118
  )
@@ -31,6 +31,7 @@ Example:
31
31
 
32
32
  """
33
33
 
34
+ import ssl
34
35
  from types import TracebackType
35
36
  from fakts import Alias
36
37
  from koil.composition import KoiledModel
@@ -56,6 +57,18 @@ class DataLayer(KoiledModel):
56
57
  """The HTTP forward proxy (``http://host:port``) the store is only reachable
57
58
  through, when it sits on a private mesh. ``None`` connects directly."""
58
59
 
60
+ certificates: list[str] = []
61
+ """The certificate(s) the store's hub registered, when its alias is pinned:
62
+ TLS to it is verified by those alone (``arkitekt_spec.declare.tls``). Empty
63
+ for any other store."""
64
+
65
+ def ssl_context(self) -> ssl.SSLContext:
66
+ """The context to reach the store with: its hub's certificate alone when
67
+ pinned, the public roots otherwise."""
68
+ from arkitekt_spec.declare import tls
69
+
70
+ return tls.pinned_context(self.certificates) if self.certificates else tls.default_context()
71
+
59
72
 
60
73
  @classmethod
61
74
  def from_alias(cls, alias: "Alias") -> "DataLayer":
@@ -67,7 +80,11 @@ class DataLayer(KoiledModel):
67
80
  Returns:
68
81
  The datalayer, ready to use.
69
82
  """
70
- return cls(endpoint_url=alias.to_http_path(), proxy=alias.proxy)
83
+ return cls(
84
+ endpoint_url=alias.to_http_path(),
85
+ proxy=alias.proxy,
86
+ certificates=list(alias.certificates) if alias.is_pinned() else [],
87
+ )
71
88
 
72
89
  async def get_endpoint_url(self):
73
90
  return self.endpoint_url
@@ -14,7 +14,10 @@ async def adownload_file(datalayer: "DataLayer", presigned_url: str, file_name:
14
14
  async with aiohttp.ClientSession() as session:
15
15
  # ``proxy=None`` is aiohttp's own default, so an unproxied datalayer is unchanged.
16
16
  async with session.get(
17
- endpoint_url + presigned_url, proxy=datalayer.proxy
17
+ endpoint_url + presigned_url,
18
+ proxy=datalayer.proxy,
19
+ # A pinned store by its hub's certificate alone; any other as before.
20
+ ssl=datalayer.ssl_context() if datalayer.certificates else True,
18
21
  ) as response:
19
22
  with open(file_name, "wb") as file:
20
23
  while True:
@@ -13,9 +13,9 @@ dependencies = [
13
13
  "rath>=4.1.1",
14
14
  "websockets>=15.0.1",
15
15
  # The service and structures are declared with arkitekt-spec.
16
- "arkitekt-spec>=3.4",
16
+ "arkitekt-spec>=3.19.1",
17
17
  # The service wiring (Alias, Require, FaktsAuthLink); it came through rekuest before.
18
- "fakts>=5.4",
18
+ "fakts>=6.1",
19
19
  ]
20
20
 
21
21
  [project.optional-dependencies]
@@ -32,6 +32,7 @@ dev-dependencies = [
32
32
  "black>=23.1.0,<24",
33
33
  "pytest-aiohttp>=1.0.4,<2",
34
34
  "ruff>=0.0.254",
35
+ "turms>=2.3.0",
35
36
  "dokker>=2.8",
36
37
  "basedpyright>=1.21",
37
38
  ]
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
File without changes