@productcraft/social 1.1.2 → 1.2.0
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 +10 -0
- package/api.md +250 -246
- package/dist/index.cjs +257 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +270 -249
- package/dist/index.d.ts +270 -249
- package/dist/index.js +257 -247
- package/dist/index.js.map +1 -1
- package/manifest.json +198 -198
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -197,6 +197,16 @@ app.post("/webhooks", async (c) => {
|
|
|
197
197
|
});
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
+
Testing a handler: `webhooks.sign()` signs an event the way ProductCraft does, so a test needs no live delivery and no hand-rolled HMAC.
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
import { Social } from "@productcraft/social";
|
|
204
|
+
const social = new Social({ webhookSecret: "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw" });
|
|
205
|
+
const { payload, headers } = await social.webhooks.sign({ payload: { id: "evt_test_1", type: "actor.updated", created_at: new Date().toISOString(), data: {} } });
|
|
206
|
+
const event = await social.webhooks.unwrap({ payload, headers });
|
|
207
|
+
console.log(event.type);
|
|
208
|
+
```
|
|
209
|
+
|
|
200
210
|
## Raw responses
|
|
201
211
|
|
|
202
212
|
Every returned object has a non-enumerable `lastResponse` (`requestId`, `status`, `headers`). `.withResponse()` adds the `Response` and parsed rate-limit headers.
|