webex-message-handler 0.4.1__tar.gz → 0.4.3__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 (22) hide show
  1. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/PKG-INFO +1 -1
  2. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/pyproject.toml +1 -1
  3. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/handler.py +31 -17
  4. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/kms_client.py +0 -1
  5. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/.gitignore +0 -0
  6. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/API.md +0 -0
  7. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/LICENSE +0 -0
  8. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/README.md +0 -0
  9. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/examples/basic_bot.py +0 -0
  10. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/__init__.py +0 -0
  11. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/device_manager.py +0 -0
  12. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/errors.py +0 -0
  13. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/logger.py +0 -0
  14. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/mercury_socket.py +0 -0
  15. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/message_decryptor.py +0 -0
  16. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/src/webex_message_handler/types.py +0 -0
  17. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/tests/__init__.py +0 -0
  18. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/tests/conftest.py +0 -0
  19. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/tests/test_device_manager.py +0 -0
  20. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/tests/test_handler.py +0 -0
  21. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/tests/test_integration.py +0 -0
  22. {webex_message_handler-0.4.1 → webex_message_handler-0.4.3}/tests/test_message_decryptor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: webex-message-handler
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Lightweight Webex Mercury WebSocket + KMS decryption for receiving bot messages without the full Webex SDK
5
5
  Project-URL: Homepage, https://github.com/3rg0n/webex-message-handler
6
6
  Project-URL: Repository, https://github.com/3rg0n/webex-message-handler
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "webex-message-handler"
7
- version = "0.4.1"
7
+ version = "0.4.3"
8
8
  description = "Lightweight Webex Mercury WebSocket + KMS decryption for receiving bot messages without the full Webex SDK"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -32,6 +32,7 @@ if TYPE_CHECKING:
32
32
  pass
33
33
 
34
34
  import base64
35
+ import json as _json
35
36
 
36
37
  # Type alias for event callbacks
37
38
  EventCallback = Callable[..., Any]
@@ -143,27 +144,40 @@ class WebexMessageHandler:
143
144
  ) -> FetchFunction:
144
145
  """Create HTTP adapter using native aiohttp."""
145
146
  async def http_do(request: FetchRequest) -> FetchResponse:
146
- async with aiohttp.ClientSession(connector=connector) as session:
147
- async with session.request(
147
+ # When a shared connector is provided, don't let the session close it.
148
+ # When no connector is provided, let the session own (and close) the auto-created one.
149
+ session = aiohttp.ClientSession(
150
+ connector=connector,
151
+ connector_owner=connector is None,
152
+ )
153
+ try:
154
+ response = await session.request(
148
155
  request.method,
149
156
  request.url,
150
157
  headers=request.headers,
151
158
  data=request.body,
152
- ) as response:
153
- # Create a simple response wrapper
154
- class NativeFetchResponse:
155
- def __init__(self, resp: aiohttp.ClientResponse):
156
- self.status = resp.status
157
- self.ok = 200 <= resp.status < 300
158
- self._response = resp
159
-
160
- async def json(self) -> Any:
161
- return await self._response.json()
162
-
163
- async def text(self) -> str:
164
- return await self._response.text()
165
-
166
- return NativeFetchResponse(response) # type: ignore[return-value]
159
+ )
160
+ # Read the body eagerly so we can close the session
161
+ body_bytes = await response.read()
162
+ status = response.status
163
+ ok = 200 <= status < 300
164
+ await session.close()
165
+ except Exception:
166
+ await session.close()
167
+ raise
168
+
169
+ class EagerFetchResponse:
170
+ def __init__(self) -> None:
171
+ self.status = status
172
+ self.ok = ok
173
+
174
+ async def json(self) -> Any:
175
+ return _json.loads(body_bytes)
176
+
177
+ async def text(self) -> str:
178
+ return body_bytes.decode("utf-8")
179
+
180
+ return EagerFetchResponse() # type: ignore[return-value]
167
181
 
168
182
  return http_do
169
183
 
@@ -50,7 +50,6 @@ class KmsClient:
50
50
  self._encryption_service_url = encryption_service_url
51
51
  self._http_do = http_do
52
52
  self._logger: Logger = logger or noop_logger # type: ignore[assignment]
53
- self._connector = connector
54
53
 
55
54
  self._kms_cluster: str = ""
56
55
  self._ephemeral_key: jwk.JWK | None = None