Skip to main content

A2SPA Python Payload Helpers

Helper-only Python package for building, hashing, and signing A2SPA runtime authorization payloads.

The verifier remains server-side. This package does not authorize actions by itself.

Install

pip install a2spa

For ML-DSA signing support where the optional wheel is available:

pip install "a2spa[pq]"

Basic Usage

from pathlib import Path

from a2spa import build_payload_fields, build_signed_request, policy_input

private_key_text = Path("sender.priv.pem").read_text(encoding="utf-8")

payload = build_payload_fields(
    agent_id="user-123_sender",
    target_agent_id="user-123_receiver",
    input_data=policy_input(action="deliver", workflow_scope="messages:deliver"),
)

request_body = build_signed_request(private_key_text, payload)

Send request_body to POST /api/verify_payload with your account API key in the x-api-key header.

Helper Functions

  • build_payload_fields(...)
  • policy_input(...)
  • policy_template(...)
  • state_continuity_claim(...)
  • canonicalize_payload(...)
  • compute_payload_hash(...)
  • finalize_payload(...)
  • sign_payload(...)
  • build_signed_request(...)
  • is_authorized_result(...)
  • require_authorized_result(...)
  • build_debug_snapshot(...)

Signed Bytes

Current A2SPA 2.0 helper compatibility signs the UTF-8 bytes of json.dumps(signable_payload, sort_keys=True) using the normalized signable fields. Do not reimplement canonicalization unless your bytes match canonicalize_payload(...) exactly.

Security Boundary

Private keys must stay in a secret manager, server environment, or deployment secret. Do not paste private keys into chats, logs, client-side code, or source control.

Metadata

Release files for a2spa 0.1.3

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

Source distribution (sdist)

Source distribution for a2spa 0.1.3
File Size Uploaded Provenance
a2spa-0.1.3.tar.gz 7.8 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 14.4 kB

Release files / a2spa-0.1.3.tar.gz

Download URL a2spa-0.1.3.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
823601bad2b387f81e4600449028275e15aafd0808c851cdb13259ed23f89292
BLAKE2b-256 checksum
How to use checksums
4a9e457082d6835d7fd05df35dda7710112520f747a8e7a0bee6206b3ffecc34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / a2spa-0.1.3-py3-none-any.whl

Download URL a2spa-0.1.3-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e091c1b7401c8165c9fdb10112c24c144ff09ea9e84e129a6a953138b662a1f6
BLAKE2b-256 checksum
How to use checksums
fd691988cf77e4d9c19f3fcabf264ab3f599c6e5155bff263bfbf92596dfd44c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for a2spa 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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