This release is a pre-release and may not be stable for production use.
Swarmauri PoP CWT
swarmauri_pop_cwt delivers COSE Sign1 proof-of-possession helpers that align with
RFC 8392 and RFC 9449. The signer and verifier share the same Swarmauri PoP
contract so services can mix CWT- and JWT-backed access tokens without changing
validation logic.
Features
- Provides
CwtPoPSignerandCwtPoPVerifierimplementations that honour the shared Swarmauri PoP contract - Accepts asynchronous key resolution hooks for COSE thumbprint matching and supports nonce/replay protections consistent with the DPoP workflow
- Generates
cnfbindings that can be embedded into OAuth access tokens or session metadata to enable downstream verification - Normalises HTTP request parts before signing or verifying to ensure interoperable coverage across services and languages
Installation
Install the package with your preferred tooling:
pip install swarmauri_pop_cwt
uv add swarmauri_pop_cwt
Usage
Signing an outgoing HTTP request
import base64
from cose.algorithms import SignatureAlg
from cose.keys import CoseKey
from swarmauri_pop_cwt import CwtPoPSigner
private_key = CoseKey.from_dict({
1: 1, # OKP
-1: 6, # Ed25519
-2: base64.urlsafe_b64decode("11qYAYafhZMrrZ8Zgo5u1g=="),
})
public_key = CoseKey.from_dict({
1: 1,
-1: 6,
-2: base64.urlsafe_b64decode("11qYAYafhZMrrZ8Zgo5u1g=="),
})
signer = CwtPoPSigner(
private_key=private_key,
public_key=public_key,
algorithm=SignatureAlg.EdDSA,
)
cwp_header = signer.sign_request("GET", "https://api.example.com/resource")
print("CWP header:", cwp_header)
print("cnf:", signer.cnf_binding())
Verifying an incoming HTTP request
import asyncio
from cose.keys import CoseKey
from swarmauri_core.pop import CnfBinding, HttpParts, VerifyPolicy
from swarmauri_pop_cwt import CwtPoPVerifier
def memory_key_resolver(thumb: CnfBinding) -> CoseKey:
return public_key
class ThumbResolver:
def by_kid(self, kid: bytes):
return None
def by_thumb(self, bind: CnfBinding):
return memory_key_resolver(bind)
async def verify_request(header: str, cnf: CnfBinding, access_token: str) -> None:
verifier = CwtPoPVerifier()
req = HttpParts(method="GET", url="https://api.example.com/resource", headers={"CWP": header})
await verifier.verify_http(
req,
cnf,
policy=VerifyPolicy(require_ath=True),
keys=ThumbResolver(),
extras={"access_token": access_token},
)
asyncio.run(verify_request(cwp_header, signer.cnf_binding(), "opaque-access-token"))
The verifier enforces COSE key thumbprints against the cnf binding and applies
the same replay and nonce strategies shared across Swarmauri PoP strategies.
Compatibility
- Python 3.10, 3.11, and 3.12
- Works alongside the shared
swarmauri_core.popabstractions and any asynchronous framework that can supply anHttpPartspayload - Designed to operate with HTTP gateways that forward method, URL, and header information for downstream validation
Related Packages
swarmauri_pop_dpopfor JWT-based Demonstration of Proof-of-Possession headersswarmauri_pop_x509when mutual TLS confirmation is requiredswarmauri_corefor the shared PoP contract, HTTP primitives, and error hierarchy leveraged by all PoP implementations
Contributing
Contributions are welcome through the
Swarmauri SDK repository. Follow
the project style guide, run the formatting and linting commands noted in the
root AGENTS.md, and open pull requests with focused commits that describe the
improvement.
Support
If you encounter issues integrating Swarmauri PoP CWT flows, please open a GitHub issue with details about your environment and the expected versus observed behaviour. Security concerns should be responsibly disclosed via the contact details in the repository security policy.
License
Apache License 2.0. See the LICENSE file for details.
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 swarmauri_pop_cwt-0.11.0.dev5.tar.gz.
File metadata
- Download URL: swarmauri_pop_cwt-0.11.0.dev5.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f446193dc052820bcbb3eb43728ee9ffae0d3323db10723eaa2388382ad2acb3
|
|
| MD5 |
64813d8769cce6cb14bd66674035569e
|
|
| BLAKE2b-256 |
bd240dfc1ce1b2c4103c199b54216fea924ce00b7f5e79d1e4c1890d759b75b6
|
File details
Details for the file swarmauri_pop_cwt-0.11.0.dev5-py3-none-any.whl.
File metadata
- Download URL: swarmauri_pop_cwt-0.11.0.dev5-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b04a2f547d4853183615415f05fac82e2d1fae9136a18e7044af904a96d1f993
|
|
| MD5 |
29f993f02e348ce6963b74ae7abec041
|
|
| BLAKE2b-256 |
7c9af457e91467e43e743468f7f11c10b406852ddb4e84e3775d597a36dcddd9
|