Async Python SDK slice for Webex Mercury communication and KMS-backed decryption
Project description
Webex KMS SDK
Async Python SDK slice for Webex Mercury communication and KMS-backed message decryption, with an optional thread-backed synchronous facade for scripts.
Based on https://github.com/WebexCommunity/webex-go-sdk, this package provides a focused implementation of the Webex Mercury protocol and KMS interactions needed for E2EE message decryption and conversation activity handling. It is designed to be used in conjunction with other Webex SDK components or as a standalone library for applications that need to interact with Webex conversations and messages.
This package intentionally covers a narrow part of the Webex Go SDK behavior:
- WDM device registration needed for Mercury
- Mercury WebSocket connection and event dispatch
- KMS ECDH setup, key retrieval, async Mercury response correlation, and key caching
- JWE text decryption and lightweight conversation activity helpers
- Thread-backed synchronous key retrieval for non-async scripts
It does not implement the full Webex REST API, WebRTC calling, outbound E2EE message encryption, or KMS administration.
Architecture
WebexClient is the async owner for the SDK sub-clients. ThreadedWebexClient is an optional
synchronous facade that runs the async client on a private background event loop and delegates KMS
operations to the same EncryptionClient implementation.
The message flow diagram shows the REST calls and websocket messages used for WDM registration, Mercury authorization and keepalive, KMS ECDH setup, and KMS key retrieval.
Install
pip install webex-kms-sdk
For local development:
uv sync --group dev
Async Quick Example
import asyncio
import os
from webex_kms_sdk import WebexClient
async def main() -> None:
client = WebexClient(os.environ["WEBEX_ACCESS_TOKEN"])
conversation = client.conversation
async def on_post(activity):
content = await conversation.get_message_content(activity)
print(content)
conversation.on("post", on_post)
await conversation.connect()
try:
await asyncio.Event().wait()
finally:
await conversation.disconnect()
await client.aclose()
asyncio.run(main())
Threaded Synchronous Example
Use ThreadedWebexClient when caller code is synchronous but KMS responses may still arrive
asynchronously over Mercury. The client starts an event loop and Mercury connection in a background
thread, then blocking methods such as get_key() wait for completion.
import os
from webex_kms_sdk import ThreadedWebexClient
with ThreadedWebexClient(os.environ["WEBEX_ACCESS_TOKEN"]) as client:
key = client.get_key(os.environ["KMS_KEY_URI"])
print(f"Retrieved key {key.uri}")
For a runnable script, see examples/threaded_get_key.py.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file webex_kms_sdk-0.4.0.tar.gz.
File metadata
- Download URL: webex_kms_sdk-0.4.0.tar.gz
- Upload date:
- Size: 50.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3a18f51412a3792843396ede6599e0c05a7995609f38a7620e047d051595c9c
|
|
| MD5 |
890af80d40f2d9e7a527e0b046d75e2e
|
|
| BLAKE2b-256 |
babaef7d2d289bf20b24c3091bd0726a8c5aad91b564509e39faf2042c160fee
|
File details
Details for the file webex_kms_sdk-0.4.0-py3-none-any.whl.
File metadata
- Download URL: webex_kms_sdk-0.4.0-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14fb22d2ced4fc5c99eea02f64064d20de17ee30f93b6aacc8782abe51624774
|
|
| MD5 |
964b6ca473902d5686c0bd1fbae0bd90
|
|
| BLAKE2b-256 |
173ca10cfa71a5434cde39a7f451f9ceca85a6437086a50191d36ce4681c10c3
|