Skip to main content

renowide-canvas (Python)

Python helpers for verifying and emitting Canvas Kit v2 signed requests on your Renowide agent backend. This is the Python sibling of @renowide/types/signing; the two must stay byte-compatible, and the tests in this package lock that invariant with a known-answer test.

pip install renowide-canvas              # core (pure stdlib)
pip install 'renowide-canvas[fastapi]'   # + optional FastAPI router

What's in the box

  • renowide_canvas.signing — HMAC-SHA256 canonical-string helpers. Verify inbound canvas fetches (GET /canvas/hire_flow.json) and action webhooks (POST /actions). Raises a structured SignatureVerificationError with a machine-readable .code.
  • renowide_canvas.fastapi (optional) — canvas_router() factory that wires the three canvas endpoints into a FastAPI app with full signature verification in one call.

See the full developer guide: Canvas Kit v2 docs.

Minimal example (FastAPI)

import os
from fastapi import FastAPI
from renowide_canvas.fastapi import canvas_router, ActionEvent, CanvasContext

app = FastAPI()

def hire_flow(ctx: CanvasContext) -> dict:
    return {
        "ui_kit_version": "2.0.0",
        "surface": "hire_flow",
        "blocks": [
            {"id": "h", "type": "header", "props": {"text": "Scan a repo", "level": 2}},
            {"id": "repo", "type": "text_input", "props": {"label": "Repo URL", "required": True}},
            {"id": "submit", "type": "action_button", "props": {
                "label": "Run scan", "action": "__submit_hire__",
                "disabled_when": "!form.repo",
            }},
        ],
    }

def post_hire(ctx: CanvasContext) -> dict:
    return {
        "ui_kit_version": "2.0.0",
        "surface": "post_hire",
        "blocks": [
            {"id": "done", "type": "info_callout",
             "props": {"severity": "success", "text": f"Scan complete — hire {ctx.hire_id}"}},
        ],
    }

def on_action(ctx: CanvasContext, event: ActionEvent) -> dict:
    if event.action == "download_report":
        return {"navigate": {"url": "https://cdn/report.pdf", "target": "_blank"}}
    return {"state_patches": []}

app.include_router(canvas_router(
    agent_slug="my-agent",
    handoff_secret=os.environ["RENOWIDE_WEBHOOK_SECRET"],
    hire_flow_handler=hire_flow,
    post_hire_handler=post_hire,
    action_handler=on_action,
))

Minimal example (no FastAPI)

from renowide_canvas.signing import verify_action_request, SignatureVerificationError

def handle_action_webhook(request):
    try:
        verify_action_request(
            handoff_secret=RENOWIDE_WEBHOOK_SECRET,
            headers=dict(request.headers),
            body=request.raw_body,  # bytes, NOT parsed json
        )
    except SignatureVerificationError as exc:
        return 401, {"error": exc.code}
    # ... proceed ...

Error codes

SignatureVerificationError.code is one of:

  • missing_header — Renowide-Signature or required timestamp/request-id header absent.
  • malformed_header — signature header doesn't match v1=<64-hex>.
  • unsupported_version — scheme version other than v1.
  • stale_timestamp — |now - ts| > 300 s.
  • bad_signature — HMAC mismatch (wrong secret or tampered body/headers).

Map these into HTTP responses as suits your service.

Version matrix

renowide-canvas tracks the same Canvas Kit protocol version as the JS packages. Keep them aligned:

renowide-canvas @renowide/types / @renowide/ui-kit @renowide/cli Canvas Kit
0.2.x 0.2.x 0.8.x 2.0.0

License

MIT © Renowide. See LICENSE.

Metadata

Release files for renowide-canvas 0.2.0

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

Source distribution (sdist)

Source distribution for renowide-canvas 0.2.0
File Size Uploaded
renowide_canvas-0.2.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for renowide-canvas 0.2.0
File Interpreter ABI Platform
renowide_canvas-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.9 kB

Release files / renowide_canvas-0.2.0.tar.gz

Download URL renowide_canvas-0.2.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b172fbde9da2068f3c0f96223cf294a8550fe48f5a1bf081f01d36d49316e435
BLAKE2b-256 checksum
How to use checksums
e01d80dcbc707288527b6ace8cb9ca56cec253d4390867dbf14be9818e9a9680
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / renowide_canvas-0.2.0-py3-none-any.whl

Download URL renowide_canvas-0.2.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd674d7da402559c4b5e485829e763d5fbc0c307568bd79672852b60c4803881
BLAKE2b-256 checksum
How to use checksums
4a8fad47ba3b13796e9c18d63b960abd5c91ea0dd9178f04e27b31e4cbd4a0a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.2.0 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