You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Added
createWebhookHandler: an event-driven webhook handler. handleVerification answers the handshake, handleDelivery(rawBody, signature) and handleRequest(request) verify X-Hub-Signature-256 over the raw bytes, parse the delivery and call handlers registered with on. Options: appSecrets (one secret or an array for rotation), verifyToken, resolveTenant, allowUnsigned, maxBodyBytes, maxEventAgeSeconds, dedupe, dedupeKey, ackMode, waitUntil, retryOnHandlerError, concurrency and onError.
Typed events and parseWebhookEvents: message, status, error, call, flow, template, account, group and unknown, each with a ctx (WABA ID, field, time, metadata, matching contact). Fields the SDK does not model arrive as unknown with the untouched value.
createMemoryDedupe and the WebhookDedupe interface, with default keys message:<id> and status:<id>:<status>.
@solvejet/whatsapp-cloud-api/web entry point with the handler, parsers, dedupe and verifySignatureAsync. It uses Web Crypto and imports nothing from node:*, so it runs on Cloudflare Workers, Deno, Bun and Node 20+ (all run in CI). Vercel Edge is documented but not run in CI.
@solvejet/whatsapp-cloud-api/testing entry point: signWebhookBody, buildWebhookPayload and createTestRequest for testing handlers in-process.
Incoming message types order, unsupported, edit and revoke, and interactive.type values product and call_permission_reply.
Helpers isKnownMessage, getUserKey and isStale.
verifySignature and WebhookHandler accept an array of app secrets, so an old and a new secret can both be valid during rotation.
allowUnsigned option for WebhookHandler and createWebhookHandler.
CI jobs that run the built web entry on Deno, Bun and Cloudflare workerd, and a Node 20 smoke test of every entry point as ESM and CJS.
Examples rewritten on createWebhookHandler, an edge-runtime example for Cloudflare Workers, a lower-level example, and documentation pages for the handler, edge runtimes and testing.
Changed
The IncomingMessage union has new members (order, unsupported, edit, revoke), and interactive.type is wider. Code that checks a switch on message.type for exhaustiveness with a never assignment no longer compiles until it handles the new cases or has a default branch.
Accepting a webhook body without an appSecret now emits a one-time process warning (WHATSAPP_WEBHOOK_UNSIGNED, or console.warn where process.emitWarning is missing). Behaviour is otherwise unchanged. Set allowUnsigned: true to silence it.
verifySignature and WebhookHandler now accept an array for the app secret (a widening). Version 1.3.x returned false or threw for an array. An empty array, an array with an empty string and an array with no matching secret still fail closed.
package.jsonexports uses separate types conditions for import and require for every entry point, and adds ./web and ./testing.
Deprecated
Accepting unsigned deliveries without allowUnsigned: true. Version 2.0 will require an explicit opt-out; set appSecret (or appSecrets) now.