Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_pop_cwt Discord

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 CwtPoPSigner and CwtPoPVerifier implementations 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 cnf bindings 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.pop abstractions and any asynchronous framework that can supply an HttpParts payload
  • Designed to operate with HTTP gateways that forward method, URL, and header information for downstream validation

Related Packages

  • swarmauri_pop_dpop for JWT-based Demonstration of Proof-of-Possession headers
  • swarmauri_pop_x509 when mutual TLS confirmation is required
  • swarmauri_core for 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.

Metadata

Release files for swarmauri_pop_cwt 0.11.0.dev5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_pop_cwt 0.11.0.dev5
File Size Uploaded
swarmauri_pop_cwt-0.11.0.dev5.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_pop_cwt 0.11.0.dev5
File Interpreter ABI Platform
swarmauri_pop_cwt-0.11.0.dev5-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / swarmauri_pop_cwt-0.11.0.dev5.tar.gz

Download URL swarmauri_pop_cwt-0.11.0.dev5.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f446193dc052820bcbb3eb43728ee9ffae0d3323db10723eaa2388382ad2acb3
BLAKE2b-256 checksum
How to use checksums
bd240dfc1ce1b2c4103c199b54216fea924ce00b7f5e79d1e4c1890d759b75b6
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / swarmauri_pop_cwt-0.11.0.dev5-py3-none-any.whl

Download URL swarmauri_pop_cwt-0.11.0.dev5-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b04a2f547d4853183615415f05fac82e2d1fae9136a18e7044af904a96d1f993
BLAKE2b-256 checksum
How to use checksums
7c9af457e91467e43e743468f7f11c10b406852ddb4e84e3775d597a36dcddd9
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.11.0.dev5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page