Skip to main content

Async Python SDK slice for Webex Mercury communication and KMS-backed decryption

Reason this release was yanked:

wrong homepage

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for webex_kms_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cce6bb1b17a71af011bafef1b1142161179d47bca87d59a362375a9461b9793c
MD5 1fe4971b41ab2652f2ccf007baadd98e
BLAKE2b-256 8682fdf807281f988b2b830e3a56121f0fd8cc4b05e0e2059cbdc781b6326eea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for webex_kms_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88c5855c53c549fc5e72dd206e76ec665d26165d9023357c1d705c596ca59142
MD5 ef083271775e06bcb3f684ff182826d4
BLAKE2b-256 e94dc95d89f316dedaaf0cfafe06caf2588538571d930e5ff73cd9d8a56d1c8c

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