Skip to content

Commit 47386c4

Browse files
committed
fix(examples): correct from_jwk call signature + warn on missing WEBHOOK_BEARER_TOKEN
Pre-PR review blockers: - from_jwk takes a JWK dict; kid/alg/adcp_use live inside the dict, not as separate kwargs. Fix the doc table and hello_seller.py comment accordingly. - hello_seller_with_webhooks.py now warns (instead of silently continuing) when WEBHOOK_BEARER_TOKEN is unset, so developers discover the dev-fixture default rather than running a production server with it. https://claude.ai/code/session_01Ay2SJvRpBg8EP9nG9DgQMy
1 parent e73529a commit 47386c4

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

docs/handler-authoring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ Pick one per `WebhookSender` instance. All three share the same
10531053

10541054
| Constructor | Auth mode | When to use |
10551055
|---|---|---|
1056-
| `WebhookSender.from_jwk(jwk, key_id, alg)` | RFC 9421 HTTP-signature | AdCP-conformant buyers; spec baseline |
1056+
| `WebhookSender.from_jwk(jwk)` | RFC 9421 HTTP-signature | AdCP-conformant buyers; spec baseline (`kid`/`alg`/`adcp_use` live in the JWK dict) |
10571057
| `WebhookSender.from_bearer_token(token)` | `Authorization: Bearer` | Simplest; no key management; requires TLS |
10581058
| `WebhookSender.from_standard_webhooks_secret(secret)` | Standard Webhooks v1 | Svix / Resend / standardwebhooks.com receivers |
10591059

examples/hello_seller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,9 @@ def _get_packages(req: Any) -> list[dict[str, Any]]:
344344
# from adcp.webhook_sender import WebhookSender
345345
# from adcp.webhook_supervisor import InMemoryWebhookDeliverySupervisor
346346
#
347-
# # RFC 9421 JWK signing — AdCP spec baseline (recommended):
348-
# sender = WebhookSender.from_jwk(signing_jwk, key_id="kid_1", alg="ES256")
347+
# # RFC 9421 JWK signing — AdCP spec baseline (recommended).
348+
# # signing_jwk must be a dict with kid, alg, and adcp_use="webhook-signing":
349+
# sender = WebhookSender.from_jwk(signing_jwk)
349350
#
350351
# # Shared bearer token — no key management, requires TLS:
351352
# sender = WebhookSender.from_bearer_token(os.environ["WEBHOOK_BEARER_TOKEN"])

examples/hello_seller_with_webhooks.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@
3535
from adcp.webhook_supervisor import InMemoryWebhookDeliverySupervisor
3636

3737
if __name__ == "__main__":
38-
token = os.environ.get("WEBHOOK_BEARER_TOKEN", "dev-fixture-token")
38+
token = os.environ.get("WEBHOOK_BEARER_TOKEN", "")
39+
if not token:
40+
import warnings
41+
42+
warnings.warn(
43+
"WEBHOOK_BEARER_TOKEN is not set; using 'dev-fixture-token'. "
44+
"Set WEBHOOK_BEARER_TOKEN=<real-token> before connecting real buyers.",
45+
stacklevel=1,
46+
)
47+
token = "dev-fixture-token"
3948
sender = WebhookSender.from_bearer_token(token)
4049
# InMemoryWebhookDeliverySupervisor wraps the sender with retry
4150
# (exponential backoff, 3 attempts) and per-endpoint circuit breakers.

0 commit comments

Comments
 (0)