Trustplane SDK (Python) for generating request proof headers
Project description
Trustplane Python SDK (v0.3.1)
Minimal SDK to generate Trustplane proof headers.
Install
pip install trustplane-sdk
Usage
from trustplane_sdk import sign
out = sign(
tenant_id="mergematter.io",
api_id="api_demo",
client_id="client_demo",
key_id="key_demo",
private_key_b64url="<private_key_b64url>",
method="GET",
path="/orders",
body=""
)
print(out["headers"])
Verify headers (auth plane)
Call the Auth Plane header-native verifier directly (no JSON body):
from trustplane_sdk import verify_headers
res = verify_headers(
auth_base_url="https://auth.trustplane.mergematter.io",
tenant_id="mergematter.io",
api_id="api_demo",
client_id="client_demo",
key_id="key_demo",
private_key_b64url="<private_key_b64url>",
method="GET",
path="/orders",
body="",
)
print(res["status"], (res.get("data") or {}).get("decision"))
Config file
from trustplane_sdk import from_file
client = from_file("./trustplane.json")
out = client.sign(method="GET", path="/orders", body="", private_key_b64url="<private_key_b64url>")
Auto-enroll (CSR + OIDC / AWS IID)
Auto-enroll with a workload identity token. The SDK will fetch a GCP metadata
token if TP_OIDC_TOKEN is not set, or use AWS IID when proof_kind="aws_iid".
from trustplane_sdk import onboard
res = onboard(
base_url="https://control.trustplane.mergematter.io",
auth_base_url="https://auth.trustplane.mergematter.io",
tenant_id="new_tenant",
client_id="new_tenant_client",
api_id="api_demo_2",
scopes=["read:demo"],
proof_kind="oidc",
proof_auto=True,
proof_aud="trustplane-enroll",
auto_approve=True,
verify=True,
)
print(res["public_key_b64url"], res["private_key_b64url"])
To use a token explicitly:
from trustplane_sdk import enroll_request
res = enroll_request(
base_url="https://control.trustplane.mergematter.io",
tenant_id="new_tenant",
client_id="new_tenant_client",
public_key_b64url="<public_key_b64url>",
scopes=["read:demo"],
proof_kind="oidc",
proof_payload="<oidc_jwt>",
auto_approve=True,
)
# AWS IID (EC2/ECS on EC2)
res = enroll_request(
base_url="https://control.trustplane.mergematter.io",
tenant_id="new_tenant",
client_id="new_tenant_client",
public_key_b64url="<public_key_b64url>",
scopes=["read:demo"],
proof_kind="aws_iid",
proof_auto=True,
auto_approve=True,
)
Auto-approve retry: if the response includes `auto_approve_reason` with a token
error, the SDK fetches a fresh proof once and retries automatically.
Blindfold verify (one call)
from trustplane_sdk import blindfold_verify
res = blindfold_verify(
auth_base_url="https://auth.trustplane.mergematter.io",
tenant_id="new_tenant",
api_id="api_demo_2",
client_id="client_demo",
private_key_b64url="<private_key_b64url>",
method="GET",
path="/orders",
body="",
)
print(res["status"], res["data"])
Blindfold uses a blind OPRF exchange and only sends a blinded input to the Auth Plane.
Example scripts
TP_PRIVATE_KEY=<private_key_b64url> \
python3 sdk/python/examples/demo_core.py
TP_PRIVATE_KEY=<private_key_b64url> \
python3 sdk/python/examples/demo_blindfold.py
Both scripts read trustplane.json for gateway_url and request_path.
Tests
python3 -m unittest sdk/python/tests/test_vector.py
Integration test (against auth plane)
TP_AUTH_BASE_URL=https://auth.trustplane.mergematter.io \
TP_TENANT_ID=<tenant_id> \
TP_API_ID=<api_id> \
TP_CLIENT_ID=<client_id> \
TP_PRIVATE_KEY=<private_key_b64url> \
TP_VERIFY_HEADERS=true \
TP_MODE=core \
python3 sdk/python/tests/integration_test.py
For blindfold APIs, use TP_MODE=blindfold.
Project details
Release history Release notifications | RSS feed
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 trustplane_sdk-0.4.1.tar.gz.
File metadata
- Download URL: trustplane_sdk-0.4.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0cca7ef15e7b0481bef2db68ed04bc4d08fdca056b05fa0c6032e22502d5c43
|
|
| MD5 |
049cda16f832d53c2e5e93e210cc0429
|
|
| BLAKE2b-256 |
29c1bf1b665aeea366f1f0005baa78737035bbf002e45c10e142c93d817b582d
|
File details
Details for the file trustplane_sdk-0.4.1-py3-none-any.whl.
File metadata
- Download URL: trustplane_sdk-0.4.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9c04d1c33762bd8ce60d63ea94b1cb88ccca9cf4b1918de0d33e9eaf0a55139
|
|
| MD5 |
0bf13fcf42b9aa5524d55184568751b6
|
|
| BLAKE2b-256 |
c398d11162521e2fce6a6f7b75a7b55fdc25fbabf951a7946cc1eb9b97ff51d4
|