Python SDK for Alteriom Webhook Connector — HMAC verification, event parsing, FastAPI integration
Project description
alteriom-webhook-client
Python SDK for the Alteriom Webhook Connector. Provides HMAC-SHA256 signature verification, Pydantic models for delivery payloads, and a FastAPI integration helper.
Installation
pip install alteriom-webhook-client
# With FastAPI integration
pip install alteriom-webhook-client[fastapi]
Quick Start (FastAPI)
import os
from fastapi import Depends, FastAPI
from alteriom_webhook_client.fastapi import webhook_receiver
from alteriom_webhook_client.models import SubscriptionDelivery
app = FastAPI()
verify = webhook_receiver(secret=os.getenv("WEBHOOK_SECRET"))
@app.post("/webhook")
async def handle_webhook(delivery: SubscriptionDelivery = Depends(verify)):
if delivery.aggregate:
print(f"Got {delivery.aggregate.entity_type} for {delivery.aggregate.repository}")
return {"status": "accepted"}
Manual Usage
from alteriom_webhook_client import WebhookReceiver, WebhookVerificationError
receiver = WebhookReceiver(secret="your-secret")
# In any framework:
try:
delivery = receiver.receive(body=request_body_bytes, headers=request_headers_dict)
print(delivery.subscription_id)
print(delivery.aggregate.summary)
except WebhookVerificationError as e:
print(f"Verification failed: {e.message} (HTTP {e.status_code})")
Low-Level Signature Functions
from alteriom_webhook_client import verify_signature, sign_payload
# Verify a signature
is_valid = verify_signature(
body=raw_bytes,
signature=headers["x-connector-signature-256"],
timestamp=headers["x-connector-timestamp"],
secret="your-secret",
)
# Generate a signature (for testing)
sig = sign_payload(body=raw_bytes, timestamp="1711700000000", secret="your-secret")
Configuration
receiver = WebhookReceiver(
secret="your-secret",
max_age_ms=300_000, # Reject timestamps older than 5 minutes (default)
max_payload_bytes=10_485_760, # Reject payloads larger than 10 MB (default)
)
Models
SubscriptionDelivery— top-level delivery payloadAggregate— event aggregate (PR lifecycle, issue, workflow, etc.)Enrichment— AI enrichment dataWebhookEvent— individual webhook event
License
MIT
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 alteriom_webhook_client-0.1.0.tar.gz.
File metadata
- Download URL: alteriom_webhook_client-0.1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07a88adae6695bf28cd3c25a7d7a5cd15cfa2a2e508066de06bbe4ba04453dce
|
|
| MD5 |
7d521cc09b2b4422d17002f2e7201786
|
|
| BLAKE2b-256 |
f987300f5b419b29a2de7c696b99bb60b269972e94910f33b297196d3a6be93f
|
Provenance
The following attestation bundles were made for alteriom_webhook_client-0.1.0.tar.gz:
Publisher:
publish.yml on Alteriom/alteriom-webhook-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alteriom_webhook_client-0.1.0.tar.gz -
Subject digest:
07a88adae6695bf28cd3c25a7d7a5cd15cfa2a2e508066de06bbe4ba04453dce - Sigstore transparency entry: 1194280466
- Sigstore integration time:
-
Permalink:
Alteriom/alteriom-webhook-client-python@ce540f70627f3827b25ef02d3714c6858beb3cfd -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Alteriom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ce540f70627f3827b25ef02d3714c6858beb3cfd -
Trigger Event:
release
-
Statement type:
File details
Details for the file alteriom_webhook_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alteriom_webhook_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98ecd14fc022fc4ac35fb71f3c772fb4c858eabe9a52330ba767f1ddb70ca0fd
|
|
| MD5 |
f0b13de8e8b90bf4467fe8f96d1fc09f
|
|
| BLAKE2b-256 |
4ad74a5e9d8edc475ba49e45bb63a5bf608c0e9fb93760a9096804704f79e983
|
Provenance
The following attestation bundles were made for alteriom_webhook_client-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Alteriom/alteriom-webhook-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alteriom_webhook_client-0.1.0-py3-none-any.whl -
Subject digest:
98ecd14fc022fc4ac35fb71f3c772fb4c858eabe9a52330ba767f1ddb70ca0fd - Sigstore transparency entry: 1194280474
- Sigstore integration time:
-
Permalink:
Alteriom/alteriom-webhook-client-python@ce540f70627f3827b25ef02d3714c6858beb3cfd -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Alteriom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ce540f70627f3827b25ef02d3714c6858beb3cfd -
Trigger Event:
release
-
Statement type: