@graph8/sdk 0.5.3 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,9 +96,17 @@ const analysis = await g8.voice.analysis(call.id);
96
96
  const page = await g8.pages.clone('https://competitor.com/pricing');
97
97
  const { url } = await g8.pages.publish(page.id);
98
98
 
99
- // Webhook events
100
- g8.webhooks.on('reply_received', (event) => {
101
- slack.send(`${event.contact} replied!`);
99
+ // Webhook events (push model — verify each delivery server-side)
100
+ app.post('/webhooks/graph8', (req, res) => {
101
+ const event = g8.webhooks.constructEvent(
102
+ req.rawBody, // raw body string (verify before JSON.parse)
103
+ req.header('X-Studio-Signature'),
104
+ req.header('X-Studio-Timestamp'),
105
+ process.env.G8_WEBHOOK_SECRET,
106
+ { toleranceSeconds: 300 },
107
+ );
108
+ if (event.event === 'engagement.email_replied') slack.send(`${event.data.contact} replied!`);
109
+ res.sendStatus(200);
102
110
  });
103
111
  ```
104
112
 
@@ -263,8 +271,8 @@ const { track, identify, visitors, copilot, calendar } = useG8();
263
271
 
264
272
  | Method | Description |
265
273
  |--------|-------------|
266
- | `g8.webhooks.on(event, cb)` | Listen for events |
267
- | `g8.webhooks.stop()` | Stop all listeners |
274
+ | `g8.webhooks.constructEvent(body, sig, ts, secret, opts?)` | Verify a delivery's HMAC signature and return the parsed event (throws `WebhookSignatureError`) |
275
+ | `g8.webhooks.knownEvents` | The known event-type catalog |
268
276
 
269
277
  ## Auth Modes
270
278