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.2.0.tar.gz (50.4 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.2.0-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for webex_kms_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ce07fc70ab8bab997e8e91e0bb1936665d1094f78ee16d7de28fa0c619d641cd
MD5 894e9529ba67688e037520fc35badfca
BLAKE2b-256 9d9dc2eb4ddc95d8541eaeae7281c5493c5378d73305ba9f845bf48b03c75f08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for webex_kms_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afce1a9e8fd3cfe3af4e6cea309071a7425be0772e22921f5a599ec1572a099f
MD5 9d775d7f09e442bf63e0a871b98c3be0
BLAKE2b-256 bfd3a4b1255213ec762b5fe1bf0674af13f7676b663e585e416b5d215ae16619

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