Skip to main content

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

Architecture diagram showing the Webex KMS SDK client hierarchy, threaded facade, and KMS response flow

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.

Message flow diagram showing WDM registration, Mercury websocket messages, KMS ECDH setup, ping/pong, and key retrieval

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webex_kms_sdk-0.1.0.tar.gz (50.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webex_kms_sdk-0.1.0-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file webex_kms_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: webex_kms_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 50.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.2

File hashes

Hashes for webex_kms_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e740c4f78a3bd8f6cb9ea2ff232b4073a43408cbf3b2baf69db52c104854939b
MD5 7a6576ebacab0ca4f4f18268f052f69c
BLAKE2b-256 a2fecb59e2a6db6cf229e66d2bfe43536d9891e20ca3c7f7c7526847192c8b6b

See more details on using hashes here.

File details

Details for the file webex_kms_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for webex_kms_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad47cac5ef8f121cf98b1940f064b06b55f447f9ace34d9cd3dba90aabeea0f3
MD5 7b61f56b7b5c59b786b9e4590419083c
BLAKE2b-256 b0feb5120779452a0ab5ea5d19fe82302d81f8321954c9beeb0163bf12674b11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page