Webhook signature verification
You're implementing the receiving end of Stripe-style webhooks in Node/TypeScript: verify the `Stripe-Signature` HMAC, reject forgeries and replays, and hand off valid events. You'll have an AI agent write the verifier. Write the prompt/spec — constraints, edge cases, acceptance criteria — so it's correct first try, given this guards money-moving events. What does a loose prompt ("verify the webhook signature") get dangerously wrong?
verify_webhook_events(secret: str, event_lines: list[str], now_seconds: int, tolerance_seconds: int) → list[str]["whsec_kernel",["evt_1|t=1749999990,v1=87a7370c|{\"id\":\"evt_1\",\"type\":\"charge.succeeded\",\"amount\":2000}","evt_1|t=1749999990,v1=87a7370c|{ \"id\": \"evt_1\", \"type\": \"charge.succeeded\", \"amount\": 2000 }"],1750000000,300]out["accepted","bad_signature"]["whsec_kernel",["evt_7|t=1749999999,v1=166bfbe4|{\"id\":\"evt_9\",\"type\":\"invoice.paid\",\"amount\":500}","evt_7|t=1749999999,v1=166bfbe4|{\"id\":\"evt_9\",\"type\":\"invoice.paid\",\"amount\":500}"],1750000000,300]out["accepted","duplicate"]["whsec_kernel",["evt_old|t=1749990000,v1=99b04ef0|{\"id\":\"evt_9\",\"type\":\"invoice.paid\",\"amount\":500}","evt_broken"],1750000000,300]out["stale","malformed"]Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.