algovoi-passport-sdk
A small SDK for building passport-aware agents on the AlgoVoi payment rails. It turns the two agent patterns into a few lines each: an agent that presents its Agent Passport on outbound calls, and a relying-party agent that guards its endpoints by verifying presented passports offline and enforcing a policy.
Built on algovoi-passport-client.
Part of the AlgoVoi Payment Rails.
pip install algovoi-passport-sdk
Present your passport (agent side)
from algovoi_passport_sdk import PassportHolder
me = PassportHolder.from_env() # $ALGOVOI_AGENT_PASSPORT, or from_file(path)
# attach it to an outbound call
headers = me.apply({"Accept": "application/json"}) # adds X-Agent-Passport
metadata = me.a2a_metadata() # A2A message metadata
Guard your agent (relying-party side)
from algovoi_passport_sdk import PassportGuard, PassportPolicy
guard = PassportGuard(
issuer_url="https://pay.issuer.com", # resolves + caches key & CRL
policy=PassportPolicy(required_scopes=("pay:invoice",), min_spend_microusd=1_000_000),
)
decision = guard.check(incoming_headers, required_scope="pay:invoice")
if decision: # truthy only when admitted
verdict = decision.verdict # agent_did, scopes, spend, ...
... # grant the spend
else:
reject(decision.reason) # e.g. "revoked: REVOKED"
guard.check(...) accepts a raw credential, an x402 headers mapping, an A2A metadata
mapping, or a full A2A message; it pulls the passport out, verifies it offline
(fail-closed), and applies the policy. Issuer key and revocation list are cached with a TTL
(default 300s). For a strictly offline trust base, pin them instead of fetching:
guard = PassportGuard(issuer_keys={kid: pk_bytes}, crl={"revoked": [...]})
Policy
PassportPolicy fields, all optional:
required_scopes: every scope must be present on the passport.min_spend_microusd: a floor; the passport's own limit must cover it (a passport with no stated limit is treated as unbounded).allowed_agents: an allowlist ofagent_dids.require_revocation_check: default True; if the CRL cannot be confirmed the passport is denied asunverifiable, never admitted.
Per-call required_scope and min_spend on check(...) add to the policy.
FastAPI
from fastapi import FastAPI, Depends
from algovoi_passport_sdk import PassportGuard
from algovoi_passport_sdk.integrations import fastapi_passport_dependency
guard = PassportGuard(issuer_url="https://pay.issuer.com")
require_pay = fastapi_passport_dependency(guard, scope="pay:invoice")
app = FastAPI()
@app.post("/charge")
def charge(verdict = Depends(require_pay)): # 403 unless a valid, in-scope passport is presented
return {"agent": verdict.agent_did}
Install the extra with pip install 'algovoi-passport-sdk[fastapi]'.
License
Apache-2.0. (c) AlgoVoi. Keep the NOTICE attribution when you redistribute.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 algovoi_passport_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: algovoi_passport_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
669720c09672b19c599d13eb14cf1a0c3ffcaec571359cedb57af516fb90dc57
|
|
| MD5 |
01aa127949c251c6ddad726d4f9acf82
|
|
| BLAKE2b-256 |
2e74c568b5a5838cfd1e37e212229c77b9ff6fe7779c6c85b1d2d648d2c77392
|